dara-components 1.21.24__py3-none-any.whl → 1.22.0__py3-none-any.whl

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,17 @@
1
+ /**
2
+ * Minified by jsDelivr using Terser v5.37.0.
3
+ * Original file: /npm/pixi-filters@6.0.4/dist/pixi-filters.js
4
+ *
5
+ * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6
+ */
7
+ /*!
8
+ * pixi-filters - v6.0.4
9
+ * Compiled Wed, 05 Jun 2024 13:46:03 UTC
10
+ *
11
+ * pixi-filters is licensed under the MIT License.
12
+ * http://www.opensource.org/licenses/mit-license
13
+ *
14
+ * Copyright 2024, undefined, All Rights Reserved
15
+ */
16
+ this.PIXI=this.PIXI||{},this.PIXI.filters=function(e,n){"use strict";var r="in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n",t="struct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n };\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); \n}\n\nfn getSize() -> vec2<f32>\n{\n return gfu.uGlobalFrame.zw;\n}\n \n@vertex\nfn mainVertex(\n @location(0) aPosition : vec2<f32>, \n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}",o=Object.defineProperty,i=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,a=(e,n,r)=>n in e?o(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,s=(e,n)=>{for(var r in n||(n={}))u.call(n,r)&&a(e,r,n[r]);if(i)for(var r of i(n))l.call(n,r)&&a(e,r,n[r]);return e},f=(e,n,r)=>(a(e,"symbol"!=typeof n?n+"":n,r),r);const c=class e extends n.Filter{constructor(o){o=s(s({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct AdjustmentUniforms {\n uGamma: f32,\n uContrast: f32,\n uSaturation: f32,\n uBrightness: f32,\n uColor: vec4<f32>,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> adjustmentUniforms : AdjustmentUniforms;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n var sample = textureSample(uTexture, uSampler, uv);\n let color = adjustmentUniforms.uColor;\n\n if (sample.a > 0.0) \n {\n sample = vec4<f32>(sample.rgb / sample.a, sample.a);\n var rgb: vec3<f32> = pow(sample.rgb, vec3<f32>(1. / adjustmentUniforms.uGamma));\n rgb = mix(vec3<f32>(.5), mix(vec3<f32>(dot(vec3<f32>(.2125, .7154, .0721), rgb)), rgb, adjustmentUniforms.uSaturation), adjustmentUniforms.uContrast);\n rgb.r *= color.r;\n rgb.g *= color.g;\n rgb.b *= color.b;\n sample = vec4<f32>(rgb.rgb * adjustmentUniforms.uBrightness, sample.a);\n sample = vec4<f32>(sample.rgb * sample.a, sample.a);\n }\n\n return sample * color.a;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uGamma;\nuniform float uContrast;\nuniform float uSaturation;\nuniform float uBrightness;\nuniform vec4 uColor;\n\nvoid main()\n{\n vec4 c = texture(uTexture, vTextureCoord);\n\n if (c.a > 0.0) {\n c.rgb /= c.a;\n\n vec3 rgb = pow(c.rgb, vec3(1. / uGamma));\n rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, uSaturation), uContrast);\n rgb.r *= uColor.r;\n rgb.g *= uColor.g;\n rgb.b *= uColor.b;\n c.rgb = rgb * uBrightness;\n\n c.rgb *= c.a;\n }\n\n finalColor = c * uColor.a;\n}\n",name:"adjustment-filter"}),resources:{adjustmentUniforms:{uGamma:{value:o.gamma,type:"f32"},uContrast:{value:o.contrast,type:"f32"},uSaturation:{value:o.saturation,type:"f32"},uBrightness:{value:o.brightness,type:"f32"},uColor:{value:[o.red,o.green,o.blue,o.alpha],type:"vec4<f32>"}}}}),f(this,"uniforms"),this.uniforms=this.resources.adjustmentUniforms.uniforms}get gamma(){return this.uniforms.uGamma}set gamma(e){this.uniforms.uGamma=e}get contrast(){return this.uniforms.uContrast}set contrast(e){this.uniforms.uContrast=e}get saturation(){return this.uniforms.uSaturation}set saturation(e){this.uniforms.uSaturation=e}get brightness(){return this.uniforms.uBrightness}set brightness(e){this.uniforms.uBrightness=e}get red(){return this.uniforms.uColor[0]}set red(e){this.uniforms.uColor[0]=e}get green(){return this.uniforms.uColor[1]}set green(e){this.uniforms.uColor[1]=e}get blue(){return this.uniforms.uColor[2]}set blue(e){this.uniforms.uColor[2]=e}get alpha(){return this.uniforms.uColor[3]}set alpha(e){this.uniforms.uColor[3]=e}};f(c,"DEFAULT_OPTIONS",{gamma:1,contrast:1,saturation:1,brightness:1,red:1,green:1,blue:1,alpha:1});let m=c;var p=Object.defineProperty,v=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,h=(e,n,r)=>n in e?p(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,x=(e,n)=>{for(var r in n||(n={}))g.call(n,r)&&h(e,r,n[r]);if(v)for(var r of v(n))d.call(n,r)&&h(e,r,n[r]);return e},y=(e,n,r)=>(h(e,"symbol"!=typeof n?n+"":n,r),r);const S=class e extends n.Filter{constructor(...o){var i,u,l;let a=null!=(i=o[0])?i:{};("number"==typeof a||Array.isArray(a))&&(n.deprecation("6.0.0","KawaseBlurFilter constructor params are now options object. See params: { strength, quality, clamp, pixelSize }"),a={strength:a},void 0!==o[1]&&(a.quality=o[1]),void 0!==o[2]&&(a.clamp=o[2])),a=x(x({},e.DEFAULT_OPTIONS),a);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:null!=a&&a.clamp?"struct KawaseBlurUniforms {\n uOffset:vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uOffset = kawaseBlurUniforms.uOffset;\n var color: vec4<f32> = vec4(0.0);\n\n // Sample top left pixel\n color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));\n // Sample top right pixel\n color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));\n // Sample bottom right pixel\n color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));\n // Sample bottom left pixel\n color += textureSample(uTexture, uSampler, clamp(vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y), gfu.uInputClamp.xy, gfu.uInputClamp.zw));\n // Average\n color *= 0.25;\n \n return color;\n}":"struct KawaseBlurUniforms {\n uOffset:vec2<f32>,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> kawaseBlurUniforms : KawaseBlurUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uOffset = kawaseBlurUniforms.uOffset;\n var color: vec4<f32> = vec4<f32>(0.0);\n\n // Sample top left pixel\n color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y + uOffset.y));\n // Sample top right pixel\n color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y + uOffset.y));\n // Sample bottom right pixel\n color += textureSample(uTexture, uSampler, vec2<f32>(uv.x + uOffset.x, uv.y - uOffset.y));\n // Sample bottom left pixel\n color += textureSample(uTexture, uSampler, vec2<f32>(uv.x - uOffset.x, uv.y - uOffset.y));\n // Average\n color *= 0.25;\n\n return color;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:null!=a&&a.clamp?"\nprecision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uOffset;\n\nuniform vec4 uInputClamp;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));\n\n // Sample top right pixel\n color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), uInputClamp.xy, uInputClamp.zw));\n\n // Sample bottom right pixel\n color += texture(uTexture, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));\n\n // Sample bottom left pixel\n color += texture(uTexture, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), uInputClamp.xy, uInputClamp.zw));\n\n // Average\n color *= 0.25;\n\n finalColor = color;\n}\n":"\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uOffset;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample top right pixel\n color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample bottom right pixel\n color += texture(uTexture, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Sample bottom left pixel\n color += texture(uTexture, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Average\n color *= 0.25;\n\n finalColor = color;\n}",name:"kawase-blur-filter"}),resources:{kawaseBlurUniforms:{uOffset:{value:new Float32Array(2),type:"vec2<f32>"}}}}),y(this,"uniforms"),y(this,"_pixelSize",{x:0,y:0}),y(this,"_clamp"),y(this,"_kernels",[]),y(this,"_blur"),y(this,"_quality"),this.uniforms=this.resources.kawaseBlurUniforms.uniforms,this.pixelSize=null!=(u=a.pixelSize)?u:{x:1,y:1},Array.isArray(a.strength)?this.kernels=a.strength:"number"==typeof a.strength&&(this._blur=a.strength,this.quality=null!=(l=a.quality)?l:3),this._clamp=!!a.clamp}apply(e,r,t,o){const i=this.pixelSizeX/r.source.width,u=this.pixelSizeY/r.source.height;let l;if(1===this._quality||0===this._blur)l=this._kernels[0]+.5,this.uniforms.uOffset[0]=l*i,this.uniforms.uOffset[1]=l*u,e.applyFilter(this,r,t,o);else{const a=n.TexturePool.getSameSizeTexture(r);let s,f=r,c=a;const m=this._quality-1;for(let n=0;n<m;n++)l=this._kernels[n]+.5,this.uniforms.uOffset[0]=l*i,this.uniforms.uOffset[1]=l*u,e.applyFilter(this,f,c,!0),s=f,f=c,c=s;l=this._kernels[m]+.5,this.uniforms.uOffset[0]=l*i,this.uniforms.uOffset[1]=l*u,e.applyFilter(this,f,t,o),n.TexturePool.returnTexture(a)}}get strength(){return this._blur}set strength(e){this._blur=e,this._generateKernels()}get quality(){return this._quality}set quality(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()}get kernels(){return this._kernels}set kernels(e){Array.isArray(e)&&e.length>0?(this._kernels=e,this._quality=e.length,this._blur=Math.max(...e)):(this._kernels=[0],this._quality=1)}get pixelSize(){return this._pixelSize}set pixelSize(e){if("number"!=typeof e)return Array.isArray(e)?(this.pixelSizeX=e[0],void(this.pixelSizeY=e[1])):void(this._pixelSize=e);this.pixelSizeX=this.pixelSizeY=e}get pixelSizeX(){return this.pixelSize.x}set pixelSizeX(e){this.pixelSize.x=e}get pixelSizeY(){return this.pixelSize.y}set pixelSizeY(e){this.pixelSize.y=e}get clamp(){return this._clamp}_updatePadding(){this.padding=Math.ceil(this._kernels.reduce(((e,n)=>e+n+.5),0))}_generateKernels(){const e=this._blur,n=this._quality,r=[e];if(e>0){let t=e;const o=e/n;for(let e=1;e<n;e++)t-=o,r.push(t)}this._kernels=r,this._updatePadding()}};y(S,"DEFAULT_OPTIONS",{strength:4,quality:3,clamp:!1,pixelSize:{x:1,y:1}});let b=S;var C=Object.defineProperty,T=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,O=(e,n,r)=>n in e?C(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,_=(e,n)=>{for(var r in n||(n={}))P.call(n,r)&&O(e,r,n[r]);if(T)for(var r of T(n))z.call(n,r)&&O(e,r,n[r]);return e},A=(e,n,r)=>(O(e,"symbol"!=typeof n?n+"":n,r),r);const F=class e extends n.Filter{constructor(o){o=_(_({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct ExtractBrightnessUniforms {\n uThreshold: f32,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> extractBrightnessUniforms : ExtractBrightnessUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n // A simple & fast algorithm for getting brightness.\n // It's inaccurate, but good enough for this feature.\n let max: f32 = max(max(color.r, color.g), color.b);\n let min: f32 = min(min(color.r, color.g), color.b);\n let brightness: f32 = (max + min) * 0.5;\n\n return select(vec4<f32>(0.), color, brightness > extractBrightnessUniforms.uThreshold);\n}\n",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uThreshold;\n\nvoid main() {\n vec4 color = texture(uTexture, vTextureCoord);\n\n // A simple & fast algorithm for getting brightness.\n // It's inaccuracy , but good enought for this feature.\n float _max = max(max(color.r, color.g), color.b);\n float _min = min(min(color.r, color.g), color.b);\n float brightness = (_max + _min) * 0.5;\n\n if(brightness > uThreshold) {\n finalColor = color;\n } else {\n finalColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}\n",name:"extract-brightness-filter"}),resources:{extractBrightnessUniforms:{uThreshold:{value:o.threshold,type:"f32"}}}}),A(this,"uniforms"),this.uniforms=this.resources.extractBrightnessUniforms.uniforms}get threshold(){return this.uniforms.uThreshold}set threshold(e){this.uniforms.uThreshold=e}};A(F,"DEFAULT_OPTIONS",{threshold:.5});let w=F;var I=Object.defineProperty,U=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,M=(e,n,r)=>n in e?I(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,G=(e,n)=>{for(var r in n||(n={}))R.call(n,r)&&M(e,r,n[r]);if(U)for(var r of U(n))D.call(n,r)&&M(e,r,n[r]);return e},E=(e,n,r)=>(M(e,"symbol"!=typeof n?n+"":n,r),r);const L=class e extends n.Filter{constructor(o){var i;o=G(G({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct AdvancedBloomUniforms {\n uBloomScale: f32,\n uBrightness: f32,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> advancedBloomUniforms : AdvancedBloomUniforms;\n@group(1) @binding(1) var uMapTexture: texture_2d<f32>;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n var color = textureSample(uTexture, uSampler, uv);\n color = vec4<f32>(color.rgb * advancedBloomUniforms.uBrightness, color.a);\n\n var bloomColor = vec4<f32>(textureSample(uMapTexture, uSampler, uv).rgb, 0.0);\n bloomColor = vec4<f32>(bloomColor.rgb * advancedBloomUniforms.uBloomScale, bloomColor.a);\n \n return color + bloomColor;\n}\n",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMapTexture;\nuniform float uBloomScale;\nuniform float uBrightness;\n\nvoid main() {\n vec4 color = texture(uTexture, vTextureCoord);\n color.rgb *= uBrightness;\n vec4 bloomColor = vec4(texture(uMapTexture, vTextureCoord).rgb, 0.0);\n bloomColor.rgb *= uBloomScale;\n finalColor = color + bloomColor;\n}\n",name:"advanced-bloom-filter"}),resources:{advancedBloomUniforms:{uBloomScale:{value:o.bloomScale,type:"f32"},uBrightness:{value:o.brightness,type:"f32"}},uMapTexture:n.Texture.WHITE}}),E(this,"uniforms"),E(this,"bloomScale",1),E(this,"brightness",1),E(this,"_extractFilter"),E(this,"_blurFilter"),this.uniforms=this.resources.advancedBloomUniforms.uniforms,this._extractFilter=new w({threshold:o.threshold}),this._blurFilter=new b({strength:null!=(i=o.kernels)?i:o.blur,quality:o.kernels?void 0:o.quality}),Object.assign(this,o)}apply(e,r,t,o){const i=n.TexturePool.getSameSizeTexture(r);this._extractFilter.apply(e,r,i,!0);const u=n.TexturePool.getSameSizeTexture(r);this._blurFilter.apply(e,i,u,!0),this.uniforms.uBloomScale=this.bloomScale,this.uniforms.uBrightness=this.brightness,this.resources.uMapTexture=u.source,e.applyFilter(this,r,t,o),n.TexturePool.returnTexture(u),n.TexturePool.returnTexture(i)}get threshold(){return this._extractFilter.threshold}set threshold(e){this._extractFilter.threshold=e}get kernels(){return this._blurFilter.kernels}set kernels(e){this._blurFilter.kernels=e}get blur(){return this._blurFilter.strength}set blur(e){this._blurFilter.strength=e}get quality(){return this._blurFilter.quality}set quality(e){this._blurFilter.quality=e}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(e){"number"==typeof e&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._blurFilter.pixelSize=e}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(e){this._blurFilter.pixelSizeX=e}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(e){this._blurFilter.pixelSizeY=e}};E(L,"DEFAULT_OPTIONS",{threshold:.5,bloomScale:1,brightness:1,blur:8,quality:4,pixelSize:{x:1,y:1}});let k=L;var j=Object.defineProperty,B=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,X=(e,n,r)=>n in e?j(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Y=(e,n)=>{for(var r in n||(n={}))N.call(n,r)&&X(e,r,n[r]);if(B)for(var r of B(n))V.call(n,r)&&X(e,r,n[r]);return e},K=(e,n,r)=>(X(e,"symbol"!=typeof n?n+"":n,r),r);const W=class e extends n.Filter{constructor(...o){var i,u;let l=null!=(i=o[0])?i:{};"number"==typeof l&&(n.deprecation("6.0.0","AsciiFilter constructor params are now options object. See params: { size, color, replaceColor }"),l={size:l});const a=(null==l?void 0:l.color)&&!1!==l.replaceColor;l=Y(Y({},e.DEFAULT_OPTIONS),l);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct AsciiUniforms {\n uSize: f32,\n uColor: vec3<f32>,\n uReplaceColor: f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> asciiUniforms : AsciiUniforms;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n let pixelSize: f32 = asciiUniforms.uSize;\n let coord: vec2<f32> = mapCoord(uv);\n\n // get the rounded color..\n var pixCoord: vec2<f32> = pixelate(coord, vec2<f32>(pixelSize));\n pixCoord = unmapCoord(pixCoord);\n\n var color = textureSample(uTexture, uSampler, pixCoord);\n\n // determine the character to use\n let gray: f32 = 0.3 * color.r + 0.59 * color.g + 0.11 * color.b;\n \n var n: f32 = 65536.0; // .\n if (gray > 0.2) {\n n = 65600.0; // :\n }\n if (gray > 0.3) {\n n = 332772.0; // *\n }\n if (gray > 0.4) {\n n = 15255086.0; // o\n }\n if (gray > 0.5) {\n n = 23385164.0; // &\n }\n if (gray > 0.6) {\n n = 15252014.0; // 8\n }\n if (gray > 0.7) {\n n = 13199452.0; // @\n }\n if (gray > 0.8) {\n n = 11512810.0; // #\n }\n\n // get the mod..\n let modd: vec2<f32> = getMod(coord, vec2<f32>(pixelSize));\n return select(color, vec4<f32>(asciiUniforms.uColor, 1.), asciiUniforms.uReplaceColor > 0.5) * character(n, vec2<f32>(-1.0) + modd * 2.0);\n}\n\nfn pixelate(coord: vec2<f32>, size: vec2<f32>) -> vec2<f32>\n{\n return floor( coord / size ) * size;\n}\n\nfn getMod(coord: vec2<f32>, size: vec2<f32>) -> vec2<f32>\n{\n return moduloVec2( coord , size) / size;\n}\n\nfn character(n: f32, p: vec2<f32>) -> f32\n{\n var q: vec2<f32> = floor(p*vec2<f32>(4.0, 4.0) + 2.5);\n\n if (clamp(q.x, 0.0, 4.0) == q.x)\n {\n if (clamp(q.y, 0.0, 4.0) == q.y)\n {\n if (i32(modulo(n/exp2(q.x + 5.0*q.y), 2.0)) == 1)\n {\n return 1.0;\n }\n }\n }\n\n return 0.0;\n}\n\nfn modulo(x: f32, y: f32) -> f32\n{\n return x - y * floor(x/y);\n}\n\nfn moduloVec2(x: vec2<f32>, y: vec2<f32>) -> vec2<f32>\n{\n return x - y * floor(x/y);\n}\n\nfn mapCoord(coord: vec2<f32> ) -> vec2<f32>\n{\n var mappedCoord: vec2<f32> = coord;\n mappedCoord *= gfu.uInputSize.xy;\n mappedCoord += gfu.uOutputFrame.xy;\n return mappedCoord;\n}\n\nfn unmapCoord(coord: vec2<f32> ) -> vec2<f32>\n{\n var mappedCoord: vec2<f32> = coord;\n mappedCoord -= gfu.uOutputFrame.xy;\n mappedCoord /= gfu.uInputSize.xy;\n return mappedCoord;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uSize;\nuniform vec3 uColor;\nuniform float uReplaceColor;\n\nuniform vec4 uInputSize;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= uInputSize.xy;\n coord += uInputSize.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= uInputSize.zw;\n coord /= uInputSize.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 size)\n{\n return floor(coord / size) * size;\n}\n\nvec2 getMod(vec2 coord, vec2 size)\n{\n return mod(coord, size) / size;\n}\n\nfloat character(float n, vec2 p)\n{\n p = floor(p*vec2(4.0, 4.0) + 2.5);\n\n if (clamp(p.x, 0.0, 4.0) == p.x)\n {\n if (clamp(p.y, 0.0, 4.0) == p.y)\n {\n if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0;\n }\n }\n return 0.0;\n}\n\nvoid main()\n{\n vec2 coord = mapCoord(vTextureCoord);\n\n // get the grid position\n vec2 pixCoord = pixelate(coord, vec2(uSize));\n pixCoord = unmapCoord(pixCoord);\n\n // sample the color at grid position\n vec4 color = texture(uTexture, pixCoord);\n\n // brightness of the color as it's perceived by the human eye\n float gray = 0.3 * color.r + 0.59 * color.g + 0.11 * color.b;\n\n // determine the character to use\n float n = 65536.0; // .\n if (gray > 0.2) n = 65600.0; // :\n if (gray > 0.3) n = 332772.0; // *\n if (gray > 0.4) n = 15255086.0; // o\n if (gray > 0.5) n = 23385164.0; // &\n if (gray > 0.6) n = 15252014.0; // 8\n if (gray > 0.7) n = 13199452.0; // @\n if (gray > 0.8) n = 11512810.0; // #\n\n // get the mod..\n vec2 modd = getMod(coord, vec2(uSize));\n\n finalColor = (uReplaceColor > 0.5 ? vec4(uColor, 1.) : color) * character( n, vec2(-1.0) + modd * 2.0);\n}\n",name:"ascii-filter"}),resources:{asciiUniforms:{uSize:{value:l.size,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uReplaceColor:{value:Number(a),type:"f32"}}}}),K(this,"uniforms"),K(this,"_color"),this.uniforms=this.resources.asciiUniforms.uniforms,this._color=new n.Color,this.color=null!=(u=l.color)?u:16777215}get size(){return this.uniforms.uSize}set size(e){this.uniforms.uSize=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[n,r,t]=this._color.toArray();this.uniforms.uColor[0]=n,this.uniforms.uColor[1]=r,this.uniforms.uColor[2]=t}get replaceColor(){return this.uniforms.uReplaceColor>.5}set replaceColor(e){this.uniforms.uReplaceColor=e?1:0}};K(W,"DEFAULT_OPTIONS",{size:8,color:16777215,replaceColor:!1});let q=W;var H=Object.defineProperty,Z=(e,n,r)=>(((e,n,r)=>{n in e?H(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r})(e,"symbol"!=typeof n?n+"":n,r),r);class Q extends n.BlurFilter{constructor(e){super(e),Z(this,"_blendPass"),this.blendRequired=!0,this.padding=0,this._blendPass=new n.Filter({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var uBackground: texture_2d<f32>; \n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n var front: vec4<f32> = textureSample(uTexture, uSampler, uv);\n var back: vec4<f32> = textureSample(uBackground, uSampler, uv);\n \n if (front.a == 0.0) {\n discard;\n }\n\n var color: vec3<f32> = mix(back.rgb, front.rgb / front.a, front.a);\n\n return vec4<f32>(color, 1.0);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform sampler2D uBackground;\n\nvoid main(void){\n vec4 front = texture(uTexture, vTextureCoord);\n vec4 back = texture(uBackground, vTextureCoord);\n\n if (front.a == 0.0) {\n discard;\n }\n \n vec3 color = mix(back.rgb, front.rgb / front.a, front.a);\n\n finalColor = vec4(color, 1.0);\n}",name:"drop-shadow-filter"}),resources:{uBackground:n.Texture.EMPTY}})}apply(e,r,t,o){const i=e._activeFilterData.backTexture,u=n.TexturePool.getSameSizeTexture(r);super.apply(e,i,u,!0),this._blendPass.resources.uBackground=u.source,this._blendPass.apply(e,r,t,o),n.TexturePool.returnTexture(u)}updatePadding(){this.padding=0}}var $=Object.defineProperty,J=Object.getOwnPropertySymbols,ee=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,re=(e,n,r)=>n in e?$(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,te=(e,n)=>{for(var r in n||(n={}))ee.call(n,r)&&re(e,r,n[r]);if(J)for(var r of J(n))ne.call(n,r)&&re(e,r,n[r]);return e},oe=(e,n,r)=>(re(e,"symbol"!=typeof n?n+"":n,r),r);const ie=class e extends n.Filter{constructor(o){var i,u;o=te(te({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct BevelUniforms {\n uLightColor: vec3<f32>,\n uLightAlpha: f32,\n uShadowColor: vec3<f32>,\n uShadowAlpha: f32,\n uTransform: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> bevelUniforms : BevelUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let transform = vec2<f32>(1.0 / gfu.uInputSize.xy) * vec2<f32>(bevelUniforms.uTransform.x, bevelUniforms.uTransform.y);\n var color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n let lightSample: f32 = textureSample(uTexture, uSampler, uv - transform).a;\n let shadowSample: f32 = textureSample(uTexture, uSampler, uv + transform).a;\n\n let light = vec4<f32>(bevelUniforms.uLightColor, bevelUniforms.uLightAlpha);\n let shadow = vec4<f32>(bevelUniforms.uShadowColor, bevelUniforms.uShadowAlpha);\n\n color = vec4<f32>(mix(color.rgb, light.rgb, clamp((color.a - lightSample) * light.a, 0.0, 1.0)), color.a);\n color = vec4<f32>(mix(color.rgb, shadow.rgb, clamp((color.a - shadowSample) * shadow.a, 0.0, 1.0)), color.a);\n \n return vec4<f32>(color.rgb * color.a, color.a);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uTransform;\nuniform vec3 uLightColor;\nuniform float uLightAlpha;\nuniform vec3 uShadowColor;\nuniform float uShadowAlpha;\n\nuniform vec4 uInputSize;\n\nvoid main(void) {\n vec2 transform = vec2(1.0 / uInputSize) * vec2(uTransform.x, uTransform.y);\n vec4 color = texture(uTexture, vTextureCoord);\n float light = texture(uTexture, vTextureCoord - transform).a;\n float shadow = texture(uTexture, vTextureCoord + transform).a;\n\n color.rgb = mix(color.rgb, uLightColor, clamp((color.a - light) * uLightAlpha, 0.0, 1.0));\n color.rgb = mix(color.rgb, uShadowColor, clamp((color.a - shadow) * uShadowAlpha, 0.0, 1.0));\n finalColor = vec4(color.rgb * color.a, color.a);\n}\n",name:"bevel-filter"}),resources:{bevelUniforms:{uLightColor:{value:new Float32Array(3),type:"vec3<f32>"},uLightAlpha:{value:o.lightAlpha,type:"f32"},uShadowColor:{value:new Float32Array(3),type:"vec3<f32>"},uShadowAlpha:{value:o.shadowAlpha,type:"f32"},uTransform:{value:new Float32Array(2),type:"vec2<f32>"}}},padding:1}),oe(this,"uniforms"),oe(this,"_thickness"),oe(this,"_rotation"),oe(this,"_lightColor"),oe(this,"_shadowColor"),this.uniforms=this.resources.bevelUniforms.uniforms,this._lightColor=new n.Color,this._shadowColor=new n.Color,this.lightColor=null!=(i=o.lightColor)?i:16777215,this.shadowColor=null!=(u=o.shadowColor)?u:0,Object.assign(this,o)}get rotation(){return this._rotation/n.DEG_TO_RAD}set rotation(e){this._rotation=e*n.DEG_TO_RAD,this._updateTransform()}get thickness(){return this._thickness}set thickness(e){this._thickness=e,this._updateTransform()}get lightColor(){return this._lightColor.value}set lightColor(e){this._lightColor.setValue(e);const[n,r,t]=this._lightColor.toArray();this.uniforms.uLightColor[0]=n,this.uniforms.uLightColor[1]=r,this.uniforms.uLightColor[2]=t}get lightAlpha(){return this.uniforms.uLightAlpha}set lightAlpha(e){this.uniforms.uLightAlpha=e}get shadowColor(){return this._shadowColor.value}set shadowColor(e){this._shadowColor.setValue(e);const[n,r,t]=this._shadowColor.toArray();this.uniforms.uShadowColor[0]=n,this.uniforms.uShadowColor[1]=r,this.uniforms.uShadowColor[2]=t}get shadowAlpha(){return this.uniforms.uShadowAlpha}set shadowAlpha(e){this.uniforms.uShadowAlpha=e}_updateTransform(){this.uniforms.uTransform[0]=this.thickness*Math.cos(this._rotation),this.uniforms.uTransform[1]=this.thickness*Math.sin(this._rotation)}};oe(ie,"DEFAULT_OPTIONS",{rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7});let ue=ie;var le=Object.defineProperty,ae=Object.defineProperties,se=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,pe=(e,n,r)=>n in e?le(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,ve=(e,n)=>{for(var r in n||(n={}))ce.call(n,r)&&pe(e,r,n[r]);if(fe)for(var r of fe(n))me.call(n,r)&&pe(e,r,n[r]);return e},ge=(e,n)=>ae(e,se(n)),de=(e,n,r)=>(pe(e,"symbol"!=typeof n?n+"":n,r),r);const he=class e extends n.AlphaFilter{constructor(...r){var t;let o=null!=(t=r[0])?t:{};if("number"==typeof o||Array.isArray(o)||"x"in o&&"y"in o){n.deprecation("6.0.0","BloomFilter constructor params are now options object. See params: { strength, quality, resolution, kernelSize }");let e=o;Array.isArray(e)&&(e={x:e[0],y:e[1]}),o={strength:e},void 0!==r[1]&&(o.quality=r[1]),void 0!==r[2]&&(o.resolution=r[2]),void 0!==r[3]&&(o.kernelSize=r[3])}o=ve(ve({},e.DEFAULT_OPTIONS),o),super(),de(this,"_blurXFilter"),de(this,"_blurYFilter"),de(this,"_strength"),this._strength={x:2,y:2},o.strength&&("number"==typeof o.strength?(this._strength.x=o.strength,this._strength.y=o.strength):(this._strength.x=o.strength.x,this._strength.y=o.strength.y)),this._blurXFilter=new n.BlurFilterPass(ge(ve({},o),{horizontal:!0,strength:this.strengthX})),this._blurYFilter=new n.BlurFilterPass(ge(ve({},o),{horizontal:!1,strength:this.strengthY})),this._blurYFilter.blendMode="screen",Object.assign(this,o)}apply(e,r,t,o){const i=n.TexturePool.getSameSizeTexture(r);e.applyFilter(this,r,t,o),this._blurXFilter.apply(e,r,i,!0),this._blurYFilter.apply(e,i,t,!1),n.TexturePool.returnTexture(i)}get strength(){return this._strength}set strength(e){this._strength="number"==typeof e?{x:e,y:e}:e,this._updateStrength()}get strengthX(){return this.strength.x}set strengthX(e){this.strength.x=e,this._updateStrength()}get strengthY(){return this.strength.y}set strengthY(e){this.strength.y=e,this._updateStrength()}_updateStrength(){this._blurXFilter.blur=this.strengthX,this._blurYFilter.blur=this.strengthY}get blur(){return n.deprecation("6.0.0","BloomFilter.blur is deprecated, please use BloomFilter.strength instead"),this.strengthX}set blur(e){n.deprecation("6.0.0","BloomFilter.blur is deprecated, please use BloomFilter.strength instead"),this.strength=e}get blurX(){return n.deprecation("6.0.0","BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead"),this.strengthX}set blurX(e){n.deprecation("6.0.0","BloomFilter.blurX is deprecated, please use BloomFilter.strengthX instead"),this.strengthX=e}get blurY(){return n.deprecation("6.0.0","BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead"),this.strengthY}set blurY(e){n.deprecation("6.0.0","BloomFilter.blurY is deprecated, please use BloomFilter.strengthY instead"),this.strengthY=e}};de(he,"DEFAULT_OPTIONS",{strength:{x:2,y:2},quality:4,resolution:1,kernelSize:5});let xe=he;var ye=Object.defineProperty,Se=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,Te=(e,n,r)=>n in e?ye(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Pe=(e,n)=>{for(var r in n||(n={}))be.call(n,r)&&Te(e,r,n[r]);if(Se)for(var r of Se(n))Ce.call(n,r)&&Te(e,r,n[r]);return e},ze=(e,n,r)=>(Te(e,"symbol"!=typeof n?n+"":n,r),r);const Oe=class e extends n.Filter{constructor(o){o=Pe(Pe({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct BulgePinchUniforms {\n uDimensions: vec2<f32>,\n uCenter: vec2<f32>,\n uRadius: f32,\n uStrength: f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> bulgePinchUniforms : BulgePinchUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let dimensions: vec2<f32> = bulgePinchUniforms.uDimensions;\n let center: vec2<f32> = bulgePinchUniforms.uCenter;\n let radius: f32 = bulgePinchUniforms.uRadius;\n let strength: f32 = bulgePinchUniforms.uStrength;\n var coord: vec2<f32> = (uv * gfu.uInputSize.xy) - center * dimensions.xy;\n\n let distance: f32 = length(coord);\n\n if (distance < radius) {\n let percent: f32 = distance / radius;\n if (strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);\n }\n }\n coord += (center * dimensions.xy);\n coord /= gfu.uInputSize.xy;\n\n let clampedCoord: vec2<f32> = clamp(coord, gfu.uInputClamp.xy, gfu.uInputClamp.zw);\n var color: vec4<f32> = textureSample(uTexture, uSampler, clampedCoord);\n if (coord.x != clampedCoord.x && coord.y != clampedCoord.y) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n return color;\n}\n\nfn compareVec2(x: vec2<f32>, y: vec2<f32>) -> bool\n{\n if (x.x == y.x && x.y == y.y)\n {\n return true;\n }\n\n return false;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uDimensions;\nuniform vec2 uCenter;\nuniform float uRadius;\nuniform float uStrength;\n\nuniform vec4 uInputSize;\nuniform vec4 uInputClamp;\n\nvoid main()\n{\n vec2 coord = vTextureCoord * uInputSize.xy;\n coord -= uCenter * uDimensions.xy;\n float distance = length(coord);\n\n if (distance < uRadius) {\n float percent = distance / uRadius;\n if (uStrength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, uRadius / distance, percent), uStrength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + uStrength * 0.75) * uRadius / distance, 1.0 - percent);\n }\n }\n\n coord += uCenter * uDimensions.xy;\n coord /= uInputSize.xy;\n vec2 clampedCoord = clamp(coord, uInputClamp.xy, uInputClamp.zw);\n vec4 color = texture(uTexture, clampedCoord);\n\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n finalColor = color;\n}\n",name:"bulge-pinch-filter"}),resources:{bulgePinchUniforms:{uDimensions:{value:[0,0],type:"vec2<f32>"},uCenter:{value:o.center,type:"vec2<f32>"},uRadius:{value:o.radius,type:"f32"},uStrength:{value:o.strength,type:"f32"}}}}),ze(this,"uniforms"),this.uniforms=this.resources.bulgePinchUniforms.uniforms,Object.assign(this,o)}apply(e,n,r,t){this.uniforms.uDimensions[0]=n.frame.width,this.uniforms.uDimensions[1]=n.frame.height,e.applyFilter(this,n,r,t)}get center(){return this.uniforms.uCenter}set center(e){"number"==typeof e&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.uniforms.uCenter.x}set centerX(e){this.uniforms.uCenter.x=e}get centerY(){return this.uniforms.uCenter.y}set centerY(e){this.uniforms.uCenter.y=e}get radius(){return this.uniforms.uRadius}set radius(e){this.uniforms.uRadius=e}get strength(){return this.uniforms.uStrength}set strength(e){this.uniforms.uStrength=e}};ze(Oe,"DEFAULT_OPTIONS",{center:{x:.5,y:.5},radius:100,strength:1});let _e=Oe;var Ae="struct BaseUniforms {\n uOptions: vec4<f32>,\n uCounts: vec2<f32>,\n};\n\nstruct StopsUniforms {\n uColors: array<vec3<f32>, MAX_STOPS>,\n uStops: array<vec4<f32>, MAX_STOPS>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> baseUniforms : BaseUniforms;\n@group(1) @binding(1) var<uniform> stopsUniforms : StopsUniforms;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) coord : vec2<f32>\n};\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn filterCoord( vTextureCoord:vec2<f32> ) -> vec2<f32>\n{\n return vTextureCoord * gfu.uInputSize.xy / gfu.uOutputFrame.zw;\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw); \n}\n\nfn getSize() -> vec2<f32>\n{\n return gfu.uGlobalFrame.zw;\n}\n \n@vertex\nfn mainVertex(\n @location(0) aPosition : vec2<f32>, \n) -> VSOutput {\n let vTextureCoord: vec2<f32> = filterTextureCoord(aPosition);\n return VSOutput(\n filterVertexPosition(aPosition),\n vTextureCoord,\n filterCoord(vTextureCoord),\n );\n}\n\nstruct ColorStop {\n offset: f32,\n color: vec3<f32>,\n alpha: f32,\n};\n\nfn rotate2d(angle: f32) -> mat2x2<f32>{\n return mat2x2(cos(angle), -sin(angle),\n sin(angle), cos(angle));\n}\n\nfn projectLinearPosition(pos: vec2<f32>, angle: f32) -> f32 {\n var center: vec2<f32> = vec2<f32>(0.5);\n var result: vec2<f32> = pos - center;\n result = rotate2d(angle) * result;\n result = result + center;\n return clamp(result.x, 0.0, 1.0);\n}\n\nfn projectRadialPosition(pos: vec2<f32>) -> f32 {\n var r: f32 = distance(pos, vec2<f32>(0.5));\n return clamp(2.0 * r, 0.0, 1.0);\n}\n\nfn projectAnglePosition(pos: vec2<f32>, angle: f32) -> f32 {\n var center: vec2<f32> = pos - vec2<f32>(0.5, 0.5);\n var polarAngle: f32 = atan2(-center.y, center.x);\n return ((polarAngle + angle) % PI_2) / PI_2;\n}\n\nfn projectPosition(pos: vec2<f32>, gradientType: i32, angle: f32) -> f32 {\n if (gradientType == TYPE_LINEAR) {\n return projectLinearPosition(pos, angle);\n } else if (gradientType == TYPE_RADIAL) {\n return projectRadialPosition(pos);\n } else if (gradientType == TYPE_CONIC) {\n return projectAnglePosition(pos, angle);\n }\n\n return pos.y;\n}\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) coord : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uType: i32 = i32(baseUniforms.uOptions[0]);\n let uAngle: f32 = baseUniforms.uOptions[1];\n let uAlpha: f32 = baseUniforms.uOptions[2];\n let uReplace: f32 = baseUniforms.uOptions[3];\n\n let uNumStops: i32 = i32(baseUniforms.uCounts[0]);\n let uMaxColors: f32 = baseUniforms.uCounts[1];\n\n // current/original color\n var currentColor: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n // skip calculations if gradient alpha is 0\n if (uAlpha == 0.0) { return currentColor; }\n\n // project position\n var y: f32 = projectPosition(coord, uType, radians(uAngle));\n\n // check gradient bounds\n var offsetMin: f32 = stopsUniforms.uStops[0][0];\n var offsetMax: f32 = 0.0;\n\n let numStops: i32 = uNumStops;\n\n for (var i: i32 = 0; i < MAX_STOPS; i = i + 1) {\n if (i == numStops - 1) { // last index\n offsetMax = stopsUniforms.uStops[i][0];\n }\n }\n\n if (y < offsetMin || y > offsetMax) { return currentColor; }\n\n // limit colors\n if (uMaxColors > 0.0) {\n var stepSize: f32 = 1.0 / uMaxColors;\n var stepNumber: f32 = floor(y / stepSize);\n y = stepSize * (stepNumber + 0.5); // offset by 0.5 to use color from middle of segment\n }\n\n // find color stops\n var stopFrom: ColorStop;\n var stopTo: ColorStop;\n\n for (var i: i32 = 0; i < MAX_STOPS; i = i + 1) {\n if (y >= stopsUniforms.uStops[i][0]) {\n stopFrom = ColorStop(stopsUniforms.uStops[i][0], stopsUniforms.uColors[i], stopsUniforms.uStops[i][1]);\n stopTo = ColorStop(stopsUniforms.uStops[i + 1][0], stopsUniforms.uColors[i + 1], stopsUniforms.uStops[i + 1][1]);\n }\n\n if (i == numStops - 1) { // last index\n break;\n }\n }\n\n // mix colors from stops\n var colorFrom: vec4<f32> = vec4<f32>(stopFrom.color * stopFrom.alpha, stopFrom.alpha);\n var colorTo: vec4<f32> = vec4<f32>(stopTo.color * stopTo.alpha, stopTo.alpha);\n\n var segmentHeight: f32 = stopTo.offset - stopFrom.offset;\n var relativePos: f32 = y - stopFrom.offset; // position from 0 to [segmentHeight]\n var relativePercent: f32 = relativePos / segmentHeight; // position in percent between [from.offset] and [to.offset].\n\n var gradientAlpha: f32 = uAlpha * currentColor.a;\n var gradientColor: vec4<f32> = mix(colorFrom, colorTo, relativePercent) * gradientAlpha;\n\n if (uReplace < 0.5) {\n // mix resulting color with current color\n return gradientColor + currentColor * (1.0 - gradientColor.a);\n } else {\n // replace with gradient color\n return gradientColor;\n }\n}\n\nconst PI: f32 = 3.14159265358979323846264;\nconst PI_2: f32 = PI * 2.0;\n\nconst TYPE_LINEAR: i32 = 0;\nconst TYPE_RADIAL: i32 = 1;\nconst TYPE_CONIC: i32 = 2;\nconst MAX_STOPS: i32 = 32;";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Fe,we,Ie={};(we=we||{}).stringify=(Fe={"visit_linear-gradient":function(e){return Fe.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return Fe.visit_gradient(e)},"visit_radial-gradient":function(e){return Fe.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return Fe.visit_gradient(e)},visit_gradient:function(e){var n=Fe.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+Fe.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=Fe.visit(e.at),t=Fe.visit(e.style);return t&&(n+=" "+t),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=Fe.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=Fe.visit(e.at);return r&&(n+=" at "+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return Fe.visit(e.value.x)+" "+Fe.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_literal:function(e){return Fe.visit_color(e.value,e)},visit_hex:function(e){return Fe.visit_color("#"+e.value,e)},visit_rgb:function(e){return Fe.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return Fe.visit_color("rgba("+e.value.join(", ")+")",e)},visit_color:function(e,n){var r=e,t=Fe.visit(n.length);return t&&(r+=" "+t),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach((function(e,t){n+=Fe.visit(e),t<r-1&&(n+=", ")})),n},visit:function(e){if(!e)return"";if(e instanceof Array)return Fe.visit_array(e,"");if(e.type){var n=Fe["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}throw Error("Invalid node.")}},function(e){return Fe.visit(e)}),(we=we||{}).parse=function(){var e=/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,n=/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,r=/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,t=/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,o=/^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i,i=/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,u=/^(left|center|right|top|bottom)/i,l=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,a=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,s=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,f=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,c=/^\(/,m=/^\)/,p=/^,/,v=/^\#([0-9a-fA-F]+)/,g=/^([a-zA-Z]+)/,d=/^rgb/i,h=/^rgba/i,x=/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/,y="";function S(e){var n=new Error(y+": "+e);throw n.source=y,n}function b(){var e=I(C);return y.length>0&&S("Invalid input not EOF"),e}function C(){return T("linear-gradient",e,z)||T("repeating-linear-gradient",n,z)||T("radial-gradient",r,O)||T("repeating-radial-gradient",t,O)}function T(e,n,r){return P(n,(function(n){var t=r();return t&&(E(p)||S("Missing comma before color stops")),{type:e,orientation:t,colorStops:I(U)}}))}function P(e,n){var r=E(e);if(r){E(c)||S("Missing (");var t=n(r);return E(m)||S("Missing )"),t}}function z(){return G("directional",o,1)||G("angular",f,1)}function O(){var e,n,r=_();return r&&((e=[]).push(r),n=y,E(p)&&((r=_())?e.push(r):y=n)),e}function _(){var e=function(){var e=G("shape",/^(circle)/i,0);return e&&(e.style=M()||A()),e}()||function(){var e=G("shape",/^(ellipse)/i,0);return e&&(e.style=D()||A()),e}();if(e)e.at=F();else{var n=A();if(n){e=n;var r=F();r&&(e.at=r)}else{var t=w();t&&(e={type:"default-radial",at:t})}}return e}function A(){return G("extent-keyword",i,1)}function F(){if(G("position",/^at/,0)){var e=w();return e||S("Missing positioning value"),e}}function w(){var e={x:D(),y:D()};if(e.x||e.y)return{type:"position",value:e}}function I(e){var n=e(),r=[];if(n)for(r.push(n);E(p);)(n=e())?r.push(n):S("One extra comma");return r}function U(){var e=G("hex",v,1)||P(h,(function(){return{type:"rgba",value:I(R)}}))||P(d,(function(){return{type:"rgb",value:I(R)}}))||G("literal",g,0);return e||S("Expected color definition"),e.length=D(),e}function R(){return E(x)[1]}function D(){return G("%",a,1)||G("position-keyword",u,1)||M()}function M(){return G("px",l,1)||G("em",s,1)}function G(e,n,r){var t=E(n);if(t)return{type:e,value:t[r]}}function E(e){var n,r;return(r=/^[\n\r\t\s]+/.exec(y))&&L(r[0].length),(n=e.exec(y))&&L(n[0].length),n}function L(e){y=y.substr(e)}return function(e){return y=e.toString(),b()}}();var Ue=Ie.parse=we.parse;Ie.stringify=we.stringify;function Re(e){const n=Ue(Be(e));if(0===n.length)throw new Error("Invalid CSS gradient.");if(1!==n.length)throw new Error("Unsupported CSS gradient (multiple gradients is not supported).");const r=n[0];return{type:De(r.type),stops:Me(r.colorStops),angle:ke(r.orientation)}}function De(e){const n={"linear-gradient":0,"radial-gradient":1};if(!(e in n))throw new Error(`Unsupported gradient type "${e}"`);return n[e]}function Me(e){const r=Ee(e),t=[],o=new n.Color;for(let n=0;n<e.length;n++){const i=Ge(e[n]),u=o.setValue(i).toArray();t.push({offset:r[n],color:u.slice(0,3),alpha:u[3]})}return t}function Ge(e){switch(e.type){case"hex":return`#${e.value}`;case"literal":return e.value;default:return`${e.type}(${e.value.join(",")})`}}function Ee(e){const n=[];for(let r=0;r<e.length;r++){const t=e[r];let o=-1;"literal"===t.type&&t.length&&"type"in t.length&&"%"===t.length.type&&"value"in t.length&&(o=parseFloat(t.length.value)/100),n.push(o)}const r=e=>{for(let r=e;r<n.length;r++)if(-1!==n[r])return{indexDelta:r-e,offset:n[r]};return{indexDelta:n.length-1-e,offset:1}};let t=0;for(let e=0;e<n.length;e++){const o=n[e];if(-1!==o)t=o;else if(0===e)n[e]=0;else if(e+1===n.length)n[e]=1;else{const o=r(e),i=(o.offset-t)/(1+o.indexDelta);for(let r=0;r<=o.indexDelta;r++)n[e+r]=t+(r+1)*i;e+=o.indexDelta,t=n[e]}}return n.map(Le)}function Le(e){return e.toString().length>6?parseFloat(e.toString().substring(0,6)):e}function ke(e){if(void 0===e)return 0;if("type"in e&&"value"in e)switch(e.type){case"angular":return parseFloat(e.value);case"directional":return je(e.value)}return 0}function je(e){const n={left:270,top:0,bottom:180,right:90,"left top":315,"top left":315,"left bottom":225,"bottom left":225,"right top":45,"top right":45,"right bottom":135,"bottom right":135};if(!(e in n))throw new Error(`Unsupported directional value "${e}"`);return n[e]}function Be(e){let n=e.replace(/\s{2,}/gu," ");return n=n.replace(/;/g,""),n=n.replace(/ ,/g,","),n=n.replace(/\( /g,"("),n=n.replace(/ \)/g,")"),n.trim()}var Ne=Object.defineProperty,Ve=Object.defineProperties,Xe=Object.getOwnPropertyDescriptors,Ye=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable,qe=(e,n,r)=>n in e?Ne(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,He=(e,n)=>{for(var r in n||(n={}))Ke.call(n,r)&&qe(e,r,n[r]);if(Ye)for(var r of Ye(n))We.call(n,r)&&qe(e,r,n[r]);return e},Ze=(e,n,r)=>(qe(e,"symbol"!=typeof n?n+"":n,r),r);const Qe=class e extends n.Filter{constructor(r){var t,o,i;if(r=r&&"css"in r?((e,n)=>Ve(e,Xe(n)))(He({},Re(r.css||"")),{alpha:null!=(t=r.alpha)?t:e.defaults.alpha,maxColors:null!=(o=r.maxColors)?o:e.defaults.maxColors}):He(He({},e.defaults),r),!r.stops||r.stops.length<2)throw new Error("ColorGradientFilter requires at least 2 color stops.");super({gpuProgram:n.GpuProgram.from({vertex:{source:Ae,entryPoint:"mainVertex"},fragment:{source:Ae,entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:"in vec2 aPosition;\nout vec2 vTextureCoord;\nout vec2 vFilterCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n vFilterCoord = vTextureCoord * uInputSize.xy / uOutputFrame.zw;\n}\n",fragment:"precision highp float;\nin vec2 vTextureCoord;\nin vec2 vFilterCoord;\nout vec4 finalColor;\n\nconst int TYPE_LINEAR = 0;\nconst int TYPE_RADIAL = 1;\nconst int TYPE_CONIC = 2;\nconst int MAX_STOPS = 32;\n\nuniform sampler2D uTexture;\nuniform vec4 uOptions;\nuniform vec2 uCounts;\nuniform vec3 uColors[MAX_STOPS];\nuniform vec4 uStops[MAX_STOPS];\n\nconst float PI = 3.1415926538;\nconst float PI_2 = PI*2.;\n\nstruct ColorStop {\n float offset;\n vec3 color;\n float alpha;\n};\n\nmat2 rotate2d(float angle){\n return mat2(cos(angle), -sin(angle),\n sin(angle), cos(angle));\n}\n\nfloat projectLinearPosition(vec2 pos, float angle){\n vec2 center = vec2(0.5);\n vec2 result = pos - center;\n result = rotate2d(angle) * result;\n result = result + center;\n return clamp(result.x, 0., 1.);\n}\n\nfloat projectRadialPosition(vec2 pos) {\n float r = distance(pos, vec2(0.5));\n return clamp(2.*r, 0., 1.);\n}\n\nfloat projectAnglePosition(vec2 pos, float angle) {\n vec2 center = pos - vec2(0.5);\n float polarAngle=atan(-center.y, center.x);\n return mod(polarAngle + angle, PI_2) / PI_2;\n}\n\nfloat projectPosition(vec2 pos, int type, float angle) {\n if (type == TYPE_LINEAR) {\n return projectLinearPosition(pos, angle);\n } else if (type == TYPE_RADIAL) {\n return projectRadialPosition(pos);\n } else if (type == TYPE_CONIC) {\n return projectAnglePosition(pos, angle);\n }\n\n return pos.y;\n}\n\nvoid main(void) {\n int uType = int(uOptions[0]);\n float uAngle = uOptions[1];\n float uAlpha = uOptions[2];\n float uReplace = uOptions[3];\n\n int uNumStops = int(uCounts[0]);\n float uMaxColors = uCounts[1];\n\n // current/original color\n vec4 currentColor = texture(uTexture, vTextureCoord);\n\n // skip calculations if gradient alpha is 0\n if (0.0 == uAlpha) {\n finalColor = currentColor;\n return;\n }\n\n // project position\n float y = projectPosition(vFilterCoord, int(uType), radians(uAngle));\n\n // check gradient bounds\n float offsetMin = uStops[0][0];\n float offsetMax = 0.0;\n\n int numStops = int(uNumStops);\n\n for (int i = 0; i < MAX_STOPS; i++) {\n if (i == numStops-1){ // last index\n offsetMax = uStops[i][0];\n }\n }\n\n if (y < offsetMin || y > offsetMax) {\n finalColor = currentColor;\n return;\n }\n\n // limit colors\n if (uMaxColors > 0.) {\n float stepSize = 1./uMaxColors;\n float stepNumber = float(floor(y/stepSize));\n y = stepSize * (stepNumber + 0.5);// offset by 0.5 to use color from middle of segment\n }\n\n // find color stops\n ColorStop from;\n ColorStop to;\n\n for (int i = 0; i < MAX_STOPS; i++) {\n if (y >= uStops[i][0]) {\n from = ColorStop(uStops[i][0], uColors[i], uStops[i][1]);\n to = ColorStop(uStops[i+1][0], uColors[i+1], uStops[i+1][1]);\n }\n\n if (i == numStops-1){ // last index\n break;\n }\n }\n\n // mix colors from stops\n vec4 colorFrom = vec4(from.color * from.alpha, from.alpha);\n vec4 colorTo = vec4(to.color * to.alpha, to.alpha);\n\n float segmentHeight = to.offset - from.offset;\n float relativePos = y - from.offset;// position from 0 to [segmentHeight]\n float relativePercent = relativePos / segmentHeight;// position in percent between [from.offset] and [to.offset].\n\n float gradientAlpha = uAlpha * currentColor.a;\n vec4 gradientColor = mix(colorFrom, colorTo, relativePercent) * gradientAlpha;\n\n if (uReplace < 0.5) {\n // mix resulting color with current color\n finalColor = gradientColor + currentColor*(1.-gradientColor.a);\n } else {\n // replace with gradient color\n finalColor = gradientColor;\n }\n}\n",name:"color-gradient-filter"}),resources:{baseUniforms:{uOptions:{value:[r.type,null!=(i=r.angle)?i:90,r.alpha,r.replace?1:0],type:"vec4<f32>"},uCounts:{value:[r.stops.length,r.maxColors],type:"vec2<f32>"}},stopsUniforms:{uColors:{value:new Float32Array(96),type:"vec3<f32>",size:32},uStops:{value:new Float32Array(128),type:"vec4<f32>",size:32}}}}),Ze(this,"baseUniforms"),Ze(this,"stopsUniforms"),Ze(this,"_stops",[]),this.baseUniforms=this.resources.baseUniforms.uniforms,this.stopsUniforms=this.resources.stopsUniforms.uniforms,Object.assign(this,r)}get stops(){return this._stops}set stops(e){const r=function(e){return[...e].sort(((e,n)=>e.offset-n.offset))}(e),t=new n.Color;let o,i,u;for(let e=0;e<r.length;e++){t.setValue(r[e].color);const n=3*e;[o,i,u]=t.toArray(),this.stopsUniforms.uColors[n]=o,this.stopsUniforms.uColors[n+1]=i,this.stopsUniforms.uColors[n+2]=u,this.stopsUniforms.uStops[4*e]=r[e].offset,this.stopsUniforms.uStops[4*e+1]=r[e].alpha}this.baseUniforms.uCounts[0]=r.length,this._stops=r}get type(){return this.baseUniforms.uOptions[0]}set type(e){this.baseUniforms.uOptions[0]=e}get angle(){return this.baseUniforms.uOptions[1]+90}set angle(e){this.baseUniforms.uOptions[1]=e-90}get alpha(){return this.baseUniforms.uOptions[2]}set alpha(e){this.baseUniforms.uOptions[2]=e}get maxColors(){return this.baseUniforms.uCounts[1]}set maxColors(e){this.baseUniforms.uCounts[1]=e}get replace(){return this.baseUniforms.uOptions[3]>.5}set replace(e){this.baseUniforms.uOptions[3]=e?1:0}};Ze(Qe,"LINEAR",0),Ze(Qe,"RADIAL",1),Ze(Qe,"CONIC",2),Ze(Qe,"defaults",{type:Qe.LINEAR,stops:[{offset:0,color:16711680,alpha:1},{offset:1,color:255,alpha:1}],alpha:1,angle:90,maxColors:0,replace:!1});let $e=Qe;var Je=Object.defineProperty,en=Object.getOwnPropertySymbols,nn=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable,tn=(e,n,r)=>n in e?Je(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,on=(e,n)=>{for(var r in n||(n={}))nn.call(n,r)&&tn(e,r,n[r]);if(en)for(var r of en(n))rn.call(n,r)&&tn(e,r,n[r]);return e},un=(e,n,r)=>(tn(e,"symbol"!=typeof n?n+"":n,r),r);const ln=class e extends n.Filter{constructor(...o){var i;let u=null!=(i=o[0])?i:{};if((u instanceof n.Texture||u instanceof n.TextureSource)&&(n.deprecation("6.0.0","ColorMapFilter constructor params are now options object. See params: { colorMap, nearest, mix }"),u={colorMap:u},void 0!==o[1]&&(u.nearest=o[1]),void 0!==o[2]&&(u.mix=o[2])),u=on(on({},e.DEFAULT_OPTIONS),u),!u.colorMap)throw Error("No color map texture source was provided to ColorMapFilter");super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct ColorMapUniforms {\n uMix: f32,\n uSize: f32,\n uSliceSize: f32,\n uSlicePixelSize: f32,\n uSliceInnerSize: f32,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> colorMapUniforms : ColorMapUniforms;\n@group(1) @binding(1) var uMapTexture: texture_2d<f32>;\n@group(1) @binding(2) var uMapSampler: sampler;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n var color:vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n var adjusted: vec4<f32>;\n\n var altColor: vec4<f32> = vec4<f32>(color.rgb / color.a, color.a);\n let innerWidth: f32 = colorMapUniforms.uSize - 1.0;\n let zSlice0: f32 = min(floor(color.b * innerWidth), innerWidth);\n let zSlice1: f32 = min(zSlice0 + 1.0, innerWidth);\n let xOffset: f32 = colorMapUniforms.uSlicePixelSize * 0.5 + color.r * colorMapUniforms.uSliceInnerSize;\n let s0: f32 = xOffset + (zSlice0 * colorMapUniforms.uSliceSize);\n let s1: f32 = xOffset + (zSlice1 * colorMapUniforms.uSliceSize);\n let yOffset: f32 = colorMapUniforms.uSliceSize * 0.5 + color.g * (1.0 - colorMapUniforms.uSliceSize);\n let slice0Color: vec4<f32> = textureSample(uMapTexture, uMapSampler, vec2(s0,yOffset));\n let slice1Color: vec4<f32> = textureSample(uMapTexture, uMapSampler, vec2(s1,yOffset));\n let zOffset: f32 = fract(color.b * innerWidth);\n adjusted = mix(slice0Color, slice1Color, zOffset);\n altColor = vec4<f32>(color.rgb * color.a, color.a);\n\n let realColor: vec4<f32> = select(color, altColor, color.a > 0.0);\n\n return vec4<f32>(mix(realColor, adjusted, colorMapUniforms.uMix).rgb, realColor.a);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMapTexture;\nuniform float uMix;\nuniform float uSize;\nuniform float uSliceSize;\nuniform float uSlicePixelSize;\nuniform float uSliceInnerSize;\n\nvoid main() {\n vec4 color = texture(uTexture, vTextureCoord.xy);\n vec4 adjusted;\n\n if (color.a > 0.0) {\n color.rgb /= color.a;\n float innerWidth = uSize - 1.0;\n float zSlice0 = min(floor(color.b * innerWidth), innerWidth);\n float zSlice1 = min(zSlice0 + 1.0, innerWidth);\n float xOffset = uSlicePixelSize * 0.5 + color.r * uSliceInnerSize;\n float s0 = xOffset + (zSlice0 * uSliceSize);\n float s1 = xOffset + (zSlice1 * uSliceSize);\n float yOffset = uSliceSize * 0.5 + color.g * (1.0 - uSliceSize);\n vec4 slice0Color = texture(uMapTexture, vec2(s0,yOffset));\n vec4 slice1Color = texture(uMapTexture, vec2(s1,yOffset));\n float zOffset = fract(color.b * innerWidth);\n adjusted = mix(slice0Color, slice1Color, zOffset);\n\n color.rgb *= color.a;\n }\n\n finalColor = vec4(mix(color, adjusted, uMix).rgb, color.a);\n\n}",name:"color-map-filter"}),resources:{colorMapUniforms:{uMix:{value:u.mix,type:"f32"},uSize:{value:0,type:"f32"},uSliceSize:{value:0,type:"f32"},uSlicePixelSize:{value:0,type:"f32"},uSliceInnerSize:{value:0,type:"f32"}},uMapTexture:u.colorMap.source,uMapSampler:u.colorMap.source.style}}),un(this,"uniforms"),un(this,"_size",0),un(this,"_sliceSize",0),un(this,"_slicePixelSize",0),un(this,"_sliceInnerSize",0),un(this,"_nearest",!1),un(this,"_scaleMode","linear"),un(this,"_colorMap"),this.uniforms=this.resources.colorMapUniforms.uniforms,Object.assign(this,u)}get mix(){return this.uniforms.uMix}set mix(e){this.uniforms.uMix=e}get colorSize(){return this._size}get colorMap(){return this._colorMap}set colorMap(e){if(!e||e===this.colorMap)return;const r=e instanceof n.Texture?e.source:e;r.style.scaleMode=this._scaleMode,r.autoGenerateMipmaps=!1,this._size=r.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms.uSize=this._size,this.uniforms.uSliceSize=this._sliceSize,this.uniforms.uSlicePixelSize=this._slicePixelSize,this.uniforms.uSliceInnerSize=this._sliceInnerSize,this.resources.uMapTexture=r,this._colorMap=e}get nearest(){return this._nearest}set nearest(e){this._nearest=e,this._scaleMode=e?"nearest":"linear";const n=this._colorMap;n&&n.source&&(n.source.scaleMode=this._scaleMode,n.source.autoGenerateMipmaps=!1,n.source.style.update(),n.source.update())}updateColorMap(){const e=this._colorMap;null!=e&&e.source&&(e.source.update(),this.colorMap=e)}destroy(){var e;null==(e=this._colorMap)||e.destroy(),super.destroy()}};un(ln,"DEFAULT_OPTIONS",{colorMap:n.Texture.WHITE,nearest:!1,mix:1});let an=ln;var sn=Object.defineProperty,fn=Object.getOwnPropertySymbols,cn=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable,pn=(e,n,r)=>n in e?sn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,vn=(e,n)=>{for(var r in n||(n={}))cn.call(n,r)&&pn(e,r,n[r]);if(fn)for(var r of fn(n))mn.call(n,r)&&pn(e,r,n[r]);return e},gn=(e,n,r)=>(pn(e,"symbol"!=typeof n?n+"":n,r),r);const dn=class e extends n.Filter{constructor(...o){var i,u;let l=null!=(i=o[0])?i:{};("number"==typeof l||Array.isArray(l)||l instanceof Float32Array)&&(n.deprecation("6.0.0","ColorOverlayFilter constructor params are now options object. See params: { color, alpha }"),l={color:l},void 0!==o[1]&&(l.alpha=o[1])),l=vn(vn({},e.DEFAULT_OPTIONS),l);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct ColorOverlayUniforms {\n uColor: vec3<f32>,\n uAlpha: f32,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> colorOverlayUniforms : ColorOverlayUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let c = textureSample(uTexture, uSampler, uv);\n return vec4<f32>(mix(c.rgb, colorOverlayUniforms.uColor.rgb, c.a * colorOverlayUniforms.uAlpha), c.a);\n}\n",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec3 uColor;\nuniform float uAlpha;\n\nvoid main(void) {\n vec4 c = texture(uTexture, vTextureCoord);\n finalColor = vec4(mix(c.rgb, uColor.rgb, c.a * uAlpha), c.a);\n}\n",name:"color-overlay-filter"}),resources:{colorOverlayUniforms:{uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:l.alpha,type:"f32"}}}}),gn(this,"uniforms"),gn(this,"_color"),this.uniforms=this.resources.colorOverlayUniforms.uniforms,this._color=new n.Color,this.color=null!=(u=l.color)?u:0}get color(){return this._color.value}set color(e){this._color.setValue(e);const[n,r,t]=this._color.toArray();this.uniforms.uColor[0]=n,this.uniforms.uColor[1]=r,this.uniforms.uColor[2]=t}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}};gn(dn,"DEFAULT_OPTIONS",{color:0,alpha:1});let hn=dn;var xn=Object.defineProperty,yn=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable,Cn=(e,n,r)=>n in e?xn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Tn=(e,n)=>{for(var r in n||(n={}))Sn.call(n,r)&&Cn(e,r,n[r]);if(yn)for(var r of yn(n))bn.call(n,r)&&Cn(e,r,n[r]);return e},Pn=(e,n,r)=>(Cn(e,"symbol"!=typeof n?n+"":n,r),r);const zn=class e extends n.Filter{constructor(...o){var i,u,l;let a=null!=(i=o[0])?i:{};("number"==typeof a||Array.isArray(a)||a instanceof Float32Array)&&(n.deprecation("6.0.0","ColorReplaceFilter constructor params are now options object. See params: { originalColor, targetColor, tolerance }"),a={originalColor:a},void 0!==o[1]&&(a.targetColor=o[1]),void 0!==o[2]&&(a.tolerance=o[2])),a=Tn(Tn({},e.DEFAULT_OPTIONS),a);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct ColorReplaceUniforms {\n uOriginalColor: vec3<f32>,\n uTargetColor: vec3<f32>,\n uTolerance: f32,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> colorReplaceUniforms : ColorReplaceUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let sample: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n let colorDiff: vec3<f32> = colorReplaceUniforms.uOriginalColor - (sample.rgb / max(sample.a, 0.0000000001));\n let colorDistance: f32 = length(colorDiff);\n let doReplace: f32 = step(colorDistance, colorReplaceUniforms.uTolerance);\n\n return vec4<f32>(mix(sample.rgb, (colorReplaceUniforms.uTargetColor + colorDiff) * sample.a, doReplace), sample.a);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec3 uOriginalColor;\nuniform vec3 uTargetColor;\nuniform float uTolerance;\n\nvoid main(void) {\n vec4 c = texture(uTexture, vTextureCoord);\n vec3 colorDiff = uOriginalColor - (c.rgb / max(c.a, 0.0000000001));\n float colorDistance = length(colorDiff);\n float doReplace = step(colorDistance, uTolerance);\n finalColor = vec4(mix(c.rgb, (uTargetColor + colorDiff) * c.a, doReplace), c.a);\n}\n",name:"color-replace-filter"}),resources:{colorReplaceUniforms:{uOriginalColor:{value:new Float32Array(3),type:"vec3<f32>"},uTargetColor:{value:new Float32Array(3),type:"vec3<f32>"},uTolerance:{value:a.tolerance,type:"f32"}}}}),Pn(this,"uniforms"),Pn(this,"_originalColor"),Pn(this,"_targetColor"),this.uniforms=this.resources.colorReplaceUniforms.uniforms,this._originalColor=new n.Color,this._targetColor=new n.Color,this.originalColor=null!=(u=a.originalColor)?u:16711680,this.targetColor=null!=(l=a.targetColor)?l:0,Object.assign(this,a)}get originalColor(){return this._originalColor.value}set originalColor(e){this._originalColor.setValue(e);const[n,r,t]=this._originalColor.toArray();this.uniforms.uOriginalColor[0]=n,this.uniforms.uOriginalColor[1]=r,this.uniforms.uOriginalColor[2]=t}get targetColor(){return this._targetColor.value}set targetColor(e){this._targetColor.setValue(e);const[n,r,t]=this._targetColor.toArray();this.uniforms.uTargetColor[0]=n,this.uniforms.uTargetColor[1]=r,this.uniforms.uTargetColor[2]=t}get tolerance(){return this.uniforms.uTolerance}set tolerance(e){this.uniforms.uTolerance=e}set newColor(e){n.deprecation("6.0.0","ColorReplaceFilter.newColor is deprecated, please use ColorReplaceFilter.targetColor instead"),this.targetColor=e}get newColor(){return n.deprecation("6.0.0","ColorReplaceFilter.newColor is deprecated, please use ColorReplaceFilter.targetColor instead"),this.targetColor}set epsilon(e){n.deprecation("6.0.0","ColorReplaceFilter.epsilon is deprecated, please use ColorReplaceFilter.tolerance instead"),this.tolerance=e}get epsilon(){return n.deprecation("6.0.0","ColorReplaceFilter.epsilon is deprecated, please use ColorReplaceFilter.tolerance instead"),this.tolerance}};Pn(zn,"DEFAULT_OPTIONS",{originalColor:16711680,targetColor:0,tolerance:.4});let On=zn;var _n=Object.defineProperty,An=Object.getOwnPropertySymbols,Fn=Object.prototype.hasOwnProperty,wn=Object.prototype.propertyIsEnumerable,In=(e,n,r)=>n in e?_n(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Un=(e,n)=>{for(var r in n||(n={}))Fn.call(n,r)&&In(e,r,n[r]);if(An)for(var r of An(n))wn.call(n,r)&&In(e,r,n[r]);return e},Rn=(e,n,r)=>(In(e,"symbol"!=typeof n?n+"":n,r),r);const Dn=class e extends n.Filter{constructor(...o){var i,u,l;let a=null!=(i=o[0])?i:{};Array.isArray(a)&&(n.deprecation("6.0.0","ConvolutionFilter constructor params are now options object. See params: { matrix, width, height }"),a={matrix:a},void 0!==o[1]&&(a.width=o[1]),void 0!==o[2]&&(a.height=o[2])),a=Un(Un({},e.DEFAULT_OPTIONS),a);const s=null!=(u=a.width)?u:200,f=null!=(l=a.height)?l:200;super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct ConvolutionUniforms {\n uMatrix: mat3x3<f32>,\n uTexelSize: vec2<f32>,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> convolutionUniforms : ConvolutionUniforms;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n let texelSize = convolutionUniforms.uTexelSize;\n let matrix = convolutionUniforms.uMatrix;\n\n let c11: vec4<f32> = textureSample(uTexture, uSampler, uv - texelSize); // top left\n let c12: vec4<f32> = textureSample(uTexture, uSampler, vec2<f32>(uv.x, uv.y - texelSize.y)); // top center\n let c13: vec4<f32> = textureSample(uTexture, uSampler, vec2<f32>(uv.x + texelSize.x, uv.y - texelSize.y)); // top right\n\n let c21: vec4<f32> = textureSample(uTexture, uSampler, vec2<f32>(uv.x - texelSize.x, uv.y)); // mid left\n let c22: vec4<f32> = textureSample(uTexture, uSampler, uv); // mid center\n let c23: vec4<f32> = textureSample(uTexture, uSampler, vec2<f32>(uv.x + texelSize.x, uv.y)); // mid right\n\n let c31: vec4<f32> = textureSample(uTexture, uSampler, vec2<f32>(uv.x - texelSize.x, uv.y + texelSize.y)); // bottom left\n let c32: vec4<f32> = textureSample(uTexture, uSampler, vec2<f32>(uv.x, uv.y + texelSize.y)); // bottom center\n let c33: vec4<f32> = textureSample(uTexture, uSampler, uv + texelSize); // bottom right\n\n var finalColor: vec4<f32> = vec4<f32>(\n c11 * matrix[0][0] + c12 * matrix[0][1] + c13 * matrix[0][2] +\n c21 * matrix[1][0] + c22 * matrix[1][1] + c23 * matrix[1][2] +\n c31 * matrix[2][0] + c32 * matrix[2][1] + c33 * matrix[2][2]\n );\n\n finalColor.a = c22.a;\n\n return finalColor;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uTexelSize;\nuniform mat3 uMatrix;\n\nvoid main(void)\n{\n vec4 c11 = texture(uTexture, vTextureCoord - uTexelSize); // top left\n vec4 c12 = texture(uTexture, vec2(vTextureCoord.x, vTextureCoord.y - uTexelSize.y)); // top center\n vec4 c13 = texture(uTexture, vec2(vTextureCoord.x + uTexelSize.x, vTextureCoord.y - uTexelSize.y)); // top right\n\n vec4 c21 = texture(uTexture, vec2(vTextureCoord.x - uTexelSize.x, vTextureCoord.y)); // mid left\n vec4 c22 = texture(uTexture, vTextureCoord); // mid center\n vec4 c23 = texture(uTexture, vec2(vTextureCoord.x + uTexelSize.x, vTextureCoord.y)); // mid right\n\n vec4 c31 = texture(uTexture, vec2(vTextureCoord.x - uTexelSize.x, vTextureCoord.y + uTexelSize.y)); // bottom left\n vec4 c32 = texture(uTexture, vec2(vTextureCoord.x, vTextureCoord.y + uTexelSize.y)); // bottom center\n vec4 c33 = texture(uTexture, vTextureCoord + uTexelSize); // bottom right\n\n finalColor =\n c11 * uMatrix[0][0] + c12 * uMatrix[0][1] + c13 * uMatrix[0][2] +\n c21 * uMatrix[1][0] + c22 * uMatrix[1][1] + c23 * uMatrix[1][2] +\n c31 * uMatrix[2][0] + c32 * uMatrix[2][1] + c33 * uMatrix[2][2];\n\n finalColor.a = c22.a;\n}",name:"convolution-filter"}),resources:{convolutionUniforms:{uMatrix:{value:a.matrix,type:"mat3x3<f32>"},uTexelSize:{value:{x:1/s,y:1/f},type:"vec2<f32>"}}}}),Rn(this,"uniforms"),this.uniforms=this.resources.convolutionUniforms.uniforms,this.width=s,this.height=f}get matrix(){return this.uniforms.uMatrix}set matrix(e){e.forEach(((e,n)=>{this.uniforms.uMatrix[n]=e}))}get width(){return 1/this.uniforms.uTexelSize.x}set width(e){this.uniforms.uTexelSize.x=1/e}get height(){return 1/this.uniforms.uTexelSize.y}set height(e){this.uniforms.uTexelSize.y=1/e}};Rn(Dn,"DEFAULT_OPTIONS",{matrix:new Float32Array(9),width:200,height:200});let Mn=Dn;class Gn extends n.Filter{constructor(){super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n let lum: f32 = length(textureSample(uTexture, uSampler, uv).rgb);\n\n if (lum < 1.00)\n {\n if (modulo(position.x + position.y, 10.0) == 0.0)\n {\n return vec4<f32>(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.75)\n {\n if (modulo(position.x - position.y, 10.0) == 0.0)\n {\n return vec4<f32>(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.50)\n {\n if (modulo(position.x + position.y - 5.0, 10.0) == 0.0)\n {\n return vec4<f32>(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.3)\n {\n if (modulo(position.x - position.y - 5.0, 10.0) == 0.0)\n {\n return vec4<f32>(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n return vec4<f32>(1.0);\n}\n\nfn modulo(x: f32, y: f32) -> f32\n{\n return x - y * floor(x/y);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\n\nvoid main(void)\n{\n float lum = length(texture(uTexture, vTextureCoord.xy).rgb);\n\n finalColor = vec4(1.0, 1.0, 1.0, 1.0);\n\n if (lum < 1.00)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0)\n {\n finalColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.75)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0)\n {\n finalColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.50)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n finalColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.3)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n finalColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n}\n",name:"cross-hatch-filter"}),resources:{}})}}var En=Object.defineProperty,Ln=Object.getOwnPropertySymbols,kn=Object.prototype.hasOwnProperty,jn=Object.prototype.propertyIsEnumerable,Bn=(e,n,r)=>n in e?En(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Nn=(e,n)=>{for(var r in n||(n={}))kn.call(n,r)&&Bn(e,r,n[r]);if(Ln)for(var r of Ln(n))jn.call(n,r)&&Bn(e,r,n[r]);return e},Vn=(e,n,r)=>(Bn(e,"symbol"!=typeof n?n+"":n,r),r);const Xn=class e extends n.Filter{constructor(o){o=Nn(Nn({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct CRTUniforms {\n uLine: vec4<f32>,\n uNoise: vec2<f32>,\n uVignette: vec3<f32>,\n uSeed: f32,\n uTime: f32,\n uDimensions: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> crtUniforms : CRTUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n \n var color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n let coord: vec2<f32> = uv * gfu.uInputSize.xy / crtUniforms.uDimensions;\n\n let uNoise = crtUniforms.uNoise;\n\n if (uNoise[0] > 0.0 && uNoise[1] > 0.0)\n {\n color += vec4<f32>(vec3<f32>(noise(uv)), color.a);\n }\n\n if (crtUniforms.uVignette[0] > 0.)\n {\n color *= vec4<f32>(vec3<f32>(vignette(color.rgb, coord)), color.a);\n }\n\n if (crtUniforms.uLine[1] > 0.0)\n {\n color = vec4<f32>(vec3<f32>(interlaceLines(color.rgb, uv)), color.a); \n }\n\n return color;\n}\n\nconst SQRT_2: f32 = 1.414213;\n\nfn modulo(x: f32, y: f32) -> f32\n{\n return x - y * floor(x/y);\n}\n\nfn rand(co: vec2<f32>) -> f32\n{\n return fract(sin(dot(co, vec2<f32>(12.9898, 78.233))) * 43758.5453);\n}\n\nfn vignette(co: vec3<f32>, coord: vec2<f32>) -> f32\n{\n let uVignette = crtUniforms.uVignette;\n let uDimensions = crtUniforms.uDimensions;\n \n let outter: f32 = SQRT_2 - uVignette[0] * SQRT_2;\n var dir: vec2<f32> = vec2<f32>(0.5) - coord;\n dir.y *= uDimensions.y / uDimensions.x;\n let darker: f32 = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + uVignette[2] * SQRT_2), 0.0, 1.0);\n return darker + (1.0 - darker) * (1.0 - uVignette[1]);\n}\n\nfn noise(coord: vec2<f32>) -> f32\n{\n let uNoise = crtUniforms.uNoise;\n let uSeed = crtUniforms.uSeed;\n\n var pixelCoord: vec2<f32> = coord * gfu.uInputSize.xy;\n pixelCoord.x = floor(pixelCoord.x / uNoise[1]);\n pixelCoord.y = floor(pixelCoord.y / uNoise[1]);\n return (rand(pixelCoord * uNoise[1] * uSeed) - 0.5) * uNoise[0];\n}\n\nfn interlaceLines(co: vec3<f32>, coord: vec2<f32>) -> vec3<f32>\n{\n var color = co;\n\n let uDimensions = crtUniforms.uDimensions;\n\n let curvature: f32 = crtUniforms.uLine[0];\n let lineWidth: f32 = crtUniforms.uLine[1];\n let lineContrast: f32 = crtUniforms.uLine[2];\n let verticalLine: f32 = crtUniforms.uLine[3];\n\n let dir: vec2<f32> = vec2<f32>(coord * gfu.uInputSize.xy / uDimensions - 0.5);\n\n let _c: f32 = select(1., curvature, curvature > 0.);\n let k: f32 = select(1., (length(dir * dir) * 0.25 * _c * _c + 0.935 * _c), curvature > 0.);\n let uv: vec2<f32> = dir * k;\n let v: f32 = select(uv.y * uDimensions.y, uv.x * uDimensions.x, verticalLine > 0.5) * min(1.0, 2.0 / lineWidth ) / _c;\n let j: f32 = 1. + cos(v * 1.2 - crtUniforms.uTime) * 0.5 * lineContrast;\n color *= j;\n\n let segment: f32 = select(modulo((dir.y + .5) * uDimensions.y, 4.), modulo((dir.x + .5) * uDimensions.x, 4.), verticalLine > 0.5);\n color *= 0.99 + ceil(segment) * 0.015;\n\n return color;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec4 uLine;\nuniform vec2 uNoise;\nuniform vec3 uVignette;\nuniform float uSeed;\nuniform float uTime;\nuniform vec2 uDimensions;\n\nuniform vec4 uInputSize;\n\nconst float SQRT_2 = 1.414213;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nfloat vignette(vec3 co, vec2 coord)\n{\n float outter = SQRT_2 - uVignette[0] * SQRT_2;\n vec2 dir = vec2(0.5) - coord;\n dir.y *= uDimensions.y / uDimensions.x;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + uVignette[2] * SQRT_2), 0.0, 1.0);\n return darker + (1.0 - darker) * (1.0 - uVignette[1]);\n}\n\nfloat noise(vec2 coord)\n{\n vec2 pixelCoord = coord * uInputSize.xy;\n pixelCoord.x = floor(pixelCoord.x / uNoise[1]);\n pixelCoord.y = floor(pixelCoord.y / uNoise[1]);\n return (rand(pixelCoord * uNoise[1] * uSeed) - 0.5) * uNoise[0];\n}\n\nvec3 interlaceLines(vec3 co, vec2 coord)\n{\n vec3 color = co;\n\n float curvature = uLine[0];\n float lineWidth = uLine[1];\n float lineContrast = uLine[2];\n float verticalLine = uLine[3];\n\n vec2 dir = vec2(coord * uInputSize.xy / uDimensions - 0.5);\n\n float _c = curvature > 0. ? curvature : 1.;\n float k = curvature > 0. ? (length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.;\n vec2 uv = dir * k;\n float v = verticalLine > 0.5 ? uv.x * uDimensions.x : uv.y * uDimensions.y;\n v *= min(1.0, 2.0 / lineWidth ) / _c;\n float j = 1. + cos(v * 1.2 - uTime) * 0.5 * lineContrast;\n color *= j;\n\n float segment = verticalLine > 0.5 ? mod((dir.x + .5) * uDimensions.x, 4.) : mod((dir.y + .5) * uDimensions.y, 4.);\n color *= 0.99 + ceil(segment) * 0.015;\n\n return color;\n}\n\nvoid main(void)\n{\n finalColor = texture(uTexture, vTextureCoord);\n vec2 coord = vTextureCoord * uInputSize.xy / uDimensions;\n\n if (uNoise[0] > 0.0 && uNoise[1] > 0.0)\n {\n float n = noise(vTextureCoord);\n finalColor += vec4(n, n, n, finalColor.a);\n }\n\n if (uVignette[0] > 0.)\n {\n float v = vignette(finalColor.rgb, coord);\n finalColor *= vec4(v, v, v, finalColor.a);\n }\n\n if (uLine[1] > 0.0)\n {\n finalColor = vec4(interlaceLines(finalColor.rgb, vTextureCoord), finalColor.a); \n }\n}\n",name:"crt-filter"}),resources:{crtUniforms:{uLine:{value:new Float32Array(4),type:"vec4<f32>"},uNoise:{value:new Float32Array(2),type:"vec2<f32>"},uVignette:{value:new Float32Array(3),type:"vec3<f32>"},uSeed:{value:o.seed,type:"f32"},uTime:{value:o.time,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),Vn(this,"uniforms"),Vn(this,"seed"),Vn(this,"time"),this.uniforms=this.resources.crtUniforms.uniforms,Object.assign(this,o)}apply(e,n,r,t){this.uniforms.uDimensions[0]=n.frame.width,this.uniforms.uDimensions[1]=n.frame.height,this.uniforms.uSeed=this.seed,this.uniforms.uTime=this.time,e.applyFilter(this,n,r,t)}get curvature(){return this.uniforms.uLine[0]}set curvature(e){this.uniforms.uLine[0]=e}get lineWidth(){return this.uniforms.uLine[1]}set lineWidth(e){this.uniforms.uLine[1]=e}get lineContrast(){return this.uniforms.uLine[2]}set lineContrast(e){this.uniforms.uLine[2]=e}get verticalLine(){return this.uniforms.uLine[3]>.5}set verticalLine(e){this.uniforms.uLine[3]=e?1:0}get noise(){return this.uniforms.uNoise[0]}set noise(e){this.uniforms.uNoise[0]=e}get noiseSize(){return this.uniforms.uNoise[1]}set noiseSize(e){this.uniforms.uNoise[1]=e}get vignetting(){return this.uniforms.uVignette[0]}set vignetting(e){this.uniforms.uVignette[0]=e}get vignettingAlpha(){return this.uniforms.uVignette[1]}set vignettingAlpha(e){this.uniforms.uVignette[1]=e}get vignettingBlur(){return this.uniforms.uVignette[2]}set vignettingBlur(e){this.uniforms.uVignette[2]=e}};Vn(Xn,"DEFAULT_OPTIONS",{curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0,seed:0});let Yn=Xn;var Kn=Object.defineProperty,Wn=Object.getOwnPropertySymbols,qn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,Zn=(e,n,r)=>n in e?Kn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Qn=(e,n)=>{for(var r in n||(n={}))qn.call(n,r)&&Zn(e,r,n[r]);if(Wn)for(var r of Wn(n))Hn.call(n,r)&&Zn(e,r,n[r]);return e};const $n=class e extends n.Filter{constructor(...o){var i;let u=null!=(i=o[0])?i:{};"number"==typeof u&&(n.deprecation("6.0.0","DotFilter constructor params are now options object. See params: { scale, angle, grayscale }"),u={scale:u},void 0!==o[1]&&(u.angle=o[1]),void 0!==o[2]&&(u.grayscale=o[2])),u=Qn(Qn({},e.DEFAULT_OPTIONS),u);const l={uScale:{value:u.scale,type:"f32"},uAngle:{value:u.angle,type:"f32"},uGrayScale:{value:u.grayscale?1:0,type:"f32"}};super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct DotUniforms {\n uScale:f32,\n uAngle:f32,\n uGrayScale:f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> dotUniforms : DotUniforms;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n let color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n let gray: vec3<f32> = vec3<f32>(dot(color.rgb, vec3<f32>(0.299, 0.587, 0.114)));\n // dotUniforms.uGrayScale == 1 doesn't ever pass so it is converted to a float and compared to 0.5 instead \n let finalColor: vec3<f32> = select(color.rgb, gray, f32(dotUniforms.uGrayScale) >= 0.5);\n\n return vec4<f32>(finalColor * 10.0 - 5.0 + pattern(uv), color.a);\n}\n\nfn pattern(uv: vec2<f32>) -> f32\n{\n let s: f32 = sin(dotUniforms.uAngle);\n let c: f32 = cos(dotUniforms.uAngle);\n \n let tex: vec2<f32> = uv * gfu.uInputSize.xy;\n \n let p: vec2<f32> = vec2<f32>(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * dotUniforms.uScale;\n\n return (sin(p.x) * sin(p.y)) * 4.0;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uAngle;\nuniform float uScale;\nuniform bool uGrayScale;\n\nuniform vec4 uInputSize;\n\nfloat pattern()\n{\n float s = sin(uAngle), c = cos(uAngle);\n vec2 tex = vTextureCoord * uInputSize.xy;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * uScale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n }\n\n void main()\n {\n vec4 color = texture(uTexture, vTextureCoord);\n vec3 colorRGB = vec3(color);\n\n if (uGrayScale)\n {\n colorRGB = vec3(color.r + color.g + color.b) / 3.0;\n }\n\n finalColor = vec4(colorRGB * 10.0 - 5.0 + pattern(), color.a);\n}\n",name:"dot-filter"}),resources:{dotUniforms:l}})}get scale(){return this.resources.dotUniforms.uniforms.uScale}set scale(e){this.resources.dotUniforms.uniforms.uScale=e}get angle(){return this.resources.dotUniforms.uniforms.uAngle}set angle(e){this.resources.dotUniforms.uniforms.uAngle=e}get grayscale(){return 1===this.resources.dotUniforms.uniforms.uGrayScale}set grayscale(e){this.resources.dotUniforms.uniforms.uGrayScale=e?1:0}};((e,n,r)=>{Zn(e,"symbol"!=typeof n?n+"":n,r)})($n,"DEFAULT_OPTIONS",{scale:1,angle:5,grayscale:!0});let Jn=$n;var er=Object.defineProperty,nr=Object.getOwnPropertySymbols,rr=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,or=(e,n,r)=>n in e?er(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,ir=(e,n)=>{for(var r in n||(n={}))rr.call(n,r)&&or(e,r,n[r]);if(nr)for(var r of nr(n))tr.call(n,r)&&or(e,r,n[r]);return e},ur=(e,n,r)=>(or(e,"symbol"!=typeof n?n+"":n,r),r);const lr=class e extends n.Filter{constructor(o){var i,u;o=ir(ir({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct DropShadowUniforms {\n uAlpha: f32,\n uColor: vec3<f32>,\n uOffset: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> dropShadowUniforms : DropShadowUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n var color: vec4<f32> = textureSample(uTexture, uSampler, uv - dropShadowUniforms.uOffset * gfu.uInputSize.zw);\n\n // Premultiply alpha\n color = vec4<f32>(vec3<f32>(dropShadowUniforms.uColor.rgb * color.a), color.a);\n // alpha user alpha\n color *= dropShadowUniforms.uAlpha;\n\n return color;\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uAlpha;\nuniform vec3 uColor;\nuniform vec2 uOffset;\n\nuniform vec4 uInputSize;\n\nvoid main(void){\n vec4 sample = texture(uTexture, vTextureCoord - uOffset * uInputSize.zw);\n\n // Premultiply alpha\n sample.rgb = uColor.rgb * sample.a;\n\n // alpha user alpha\n sample *= uAlpha;\n\n finalColor = sample;\n}",name:"drop-shadow-filter"}),resources:{dropShadowUniforms:{uAlpha:{value:o.alpha,type:"f32"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uOffset:{value:o.offset,type:"vec2<f32>"}}},resolution:o.resolution}),ur(this,"uniforms"),ur(this,"shadowOnly",!1),ur(this,"_color"),ur(this,"_blurFilter"),ur(this,"_basePass"),this.uniforms=this.resources.dropShadowUniforms.uniforms,this._color=new n.Color,this.color=null!=(i=o.color)?i:0,this._blurFilter=new b({strength:null!=(u=o.kernels)?u:o.blur,quality:o.kernels?void 0:o.quality}),this._basePass=new n.Filter({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"\n @group(0) @binding(1) var uTexture: texture_2d<f32>; \n @group(0) @binding(2) var uSampler: sampler;\n @fragment\n fn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n ) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n }\n ",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"\n in vec2 vTextureCoord;\n out vec4 finalColor;\n uniform sampler2D uTexture;\n\n void main(void){\n finalColor = texture(uTexture, vTextureCoord);\n }\n ",name:"drop-shadow-filter"}),resources:{}}),Object.assign(this,o)}apply(e,r,t,o){const i=n.TexturePool.getSameSizeTexture(r);e.applyFilter(this,r,i,!0),this._blurFilter.apply(e,i,t,o),this.shadowOnly||e.applyFilter(this._basePass,r,t,!1),n.TexturePool.returnTexture(i)}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e,this._updatePadding()}get offsetX(){return this.offset.x}set offsetX(e){this.offset.x=e,this._updatePadding()}get offsetY(){return this.offset.y}set offsetY(e){this.offset.y=e,this._updatePadding()}get color(){return this._color.value}set color(e){this._color.setValue(e);const[n,r,t]=this._color.toArray();this.uniforms.uColor[0]=n,this.uniforms.uColor[1]=r,this.uniforms.uColor[2]=t}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get blur(){return this._blurFilter.strength}set blur(e){this._blurFilter.strength=e,this._updatePadding()}get quality(){return this._blurFilter.quality}set quality(e){this._blurFilter.quality=e,this._updatePadding()}get kernels(){return this._blurFilter.kernels}set kernels(e){this._blurFilter.kernels=e}get pixelSize(){return this._blurFilter.pixelSize}set pixelSize(e){"number"==typeof e&&(e={x:e,y:e}),Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._blurFilter.pixelSize=e}get pixelSizeX(){return this._blurFilter.pixelSizeX}set pixelSizeX(e){this._blurFilter.pixelSizeX=e}get pixelSizeY(){return this._blurFilter.pixelSizeY}set pixelSizeY(e){this._blurFilter.pixelSizeY=e}_updatePadding(){const e=Math.max(Math.abs(this.offsetX),Math.abs(this.offsetY));this.padding=e+2*this.blur+4*this.quality}};ur(lr,"DEFAULT_OPTIONS",{offset:{x:4,y:4},color:0,alpha:.5,shadowOnly:!1,kernels:void 0,blur:2,quality:3,pixelSize:{x:1,y:1},resolution:1});let ar=lr;var sr=Object.defineProperty,fr=(e,n,r)=>(((e,n,r)=>{n in e?sr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r})(e,"symbol"!=typeof n?n+"":n,r),r);class cr extends n.Filter{constructor(e=5){super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct EmbossUniforms {\n uStrength:f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> embossUniforms : EmbossUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let onePixel: vec2<f32> = vec2<f32>(1.0 / gfu.uInputSize.xy);\n\tvar color: vec3<f32> = vec3<f32>(0.5);\n\n\tcolor -= (textureSample(uTexture, uSampler, uv - onePixel) * embossUniforms.uStrength).rgb;\n\tcolor += (textureSample(uTexture, uSampler, uv + onePixel) * embossUniforms.uStrength).rgb;\n\n\tcolor = vec3<f32>((color.r + color.g + color.b) / 3.0);\n\n\tlet blendColor: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n\treturn vec4<f32>(color.rgb * blendColor.a, blendColor.a);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uStrength;\n\nuniform vec4 uInputSize;\n\nvoid main(void)\n{\n\tvec2 onePixel = vec2(1.0 / uInputSize);\n\n\tvec4 color;\n\n\tcolor.rgb = vec3(0.5);\n\n\tcolor -= texture(uTexture, vTextureCoord - onePixel) * uStrength;\n\tcolor += texture(uTexture, vTextureCoord + onePixel) * uStrength;\n\n\tcolor.rgb = vec3((color.r + color.g + color.b) / 3.0);\n\n\tfloat alpha = texture(uTexture, vTextureCoord).a;\n\n\tfinalColor = vec4(color.rgb * alpha, alpha);\n}\n",name:"emboss-filter"}),resources:{embossUniforms:{uStrength:{value:e,type:"f32"}}}}),fr(this,"uniforms"),this.uniforms=this.resources.embossUniforms.uniforms}get strength(){return this.uniforms.uStrength}set strength(e){this.uniforms.uStrength=e}}var mr=Object.defineProperty,pr=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable,dr=(e,n,r)=>n in e?mr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,hr=(e,n)=>{for(var r in n||(n={}))vr.call(n,r)&&dr(e,r,n[r]);if(pr)for(var r of pr(n))gr.call(n,r)&&dr(e,r,n[r]);return e},xr=(e,n,r)=>(dr(e,"symbol"!=typeof n?n+"":n,r),r),yr=(e=>(e[e.TRANSPARENT=0]="TRANSPARENT",e[e.ORIGINAL=1]="ORIGINAL",e[e.LOOP=2]="LOOP",e[e.CLAMP=3]="CLAMP",e[e.MIRROR=4]="MIRROR",e))(yr||{});const Sr=class e extends n.Filter{constructor(o){var i,u,l,a,s;o=hr(hr({},e.defaults),o);const f=n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct GlitchUniforms {\n uSeed: f32,\n uDimensions: vec2<f32>,\n uAspect: f32,\n uFillMode: f32,\n uOffset: f32,\n uDirection: f32,\n uRed: vec2<f32>,\n uGreen: vec2<f32>,\n uBlue: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> glitchUniforms : GlitchUniforms;\n@group(1) @binding(1) var uDisplacementMap: texture_2d<f32>; \n@group(1) @binding(2) var uDisplacementSampler: sampler; \n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uSeed: f32 = glitchUniforms.uSeed;\n let uDimensions: vec2<f32> = glitchUniforms.uDimensions;\n let uAspect: f32 = glitchUniforms.uAspect;\n let uOffset: f32 = glitchUniforms.uOffset;\n let uDirection: f32 = glitchUniforms.uDirection;\n let uRed: vec2<f32> = glitchUniforms.uRed;\n let uGreen: vec2<f32> = glitchUniforms.uGreen;\n let uBlue: vec2<f32> = glitchUniforms.uBlue;\n\n let uInputSize: vec4<f32> = gfu.uInputSize;\n let uInputClamp: vec4<f32> = gfu.uInputClamp;\n\n var discarded: bool = false;\n var coord: vec2<f32> = (uv * uInputSize.xy) / uDimensions;\n\n if (coord.x > 1.0 || coord.y > 1.0) {\n discarded = true;\n }\n\n let sinDir: f32 = sin(uDirection);\n let cosDir: f32 = cos(uDirection);\n\n let cx: f32 = coord.x - 0.5;\n let cy: f32 = (coord.y - 0.5) * uAspect;\n var ny: f32 = (-sinDir * cx + cosDir * cy) / uAspect + 0.5;\n\n ny = select(select(ny, -ny, ny < 0.0), 2.0 - ny, ny > 1.0);\n\n let dc: vec4<f32> = textureSample(uDisplacementMap, uDisplacementSampler, vec2<f32>(0.5, ny));\n\n let displacement: f32 = (dc.r - dc.g) * (uOffset / uInputSize.x);\n\n coord = uv + vec2<f32>(cosDir * displacement, sinDir * displacement * uAspect);\n\n let fillMode: i32 = i32(glitchUniforms.uFillMode);\n\n if (fillMode == CLAMP) {\n coord = clamp(coord, uInputClamp.xy, uInputClamp.zw);\n } else {\n if (coord.x > uInputClamp.z) {\n if (fillMode == TRANSPARENT) {\n discarded = true;\n } else if (fillMode == LOOP) {\n coord.x = coord.x - uInputClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x = uInputClamp.z * 2.0 - coord.x;\n }\n } else if (coord.x < uInputClamp.x) {\n if (fillMode == TRANSPARENT) {\n discarded = true;\n } else if (fillMode == LOOP) {\n coord.x = coord.x + uInputClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x = coord.x * -uInputClamp.z;\n }\n }\n\n if (coord.y > uInputClamp.w) {\n if (fillMode == TRANSPARENT) {\n discarded = true;\n } else if (fillMode == LOOP) {\n coord.y = coord.y - uInputClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y = uInputClamp.w * 2.0 - coord.y;\n }\n } else if (coord.y < uInputClamp.y) {\n if (fillMode == TRANSPARENT) {\n discarded = true;\n } else if (fillMode == LOOP) {\n coord.y = coord.y + uInputClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y = coord.y * -uInputClamp.w;\n }\n }\n }\n\n let seedR: f32 = 1.0 - uSeed * 0.4;\n let seedG: f32 = 1.0 - uSeed * 0.3;\n let seedB: f32 = 1.0 - uSeed * 0.2;\n\n let offsetR: vec2<f32> = vec2(uRed.x * seedR / uInputSize.x, uRed.y * seedR / uInputSize.y);\n let offsetG: vec2<f32> = vec2(uGreen.x * seedG / uInputSize.x, uGreen.y * seedG / uInputSize.y);\n let offsetB: vec2<f32> = vec2(uBlue.x * seedB / uInputSize.x, uBlue.y * seedB / uInputSize.y);\n\n let r = textureSample(uTexture, uSampler, coord + offsetR).r;\n let g = textureSample(uTexture, uSampler, coord + offsetG).g;\n let b = textureSample(uTexture, uSampler, coord + offsetB).b;\n let a = textureSample(uTexture, uSampler, coord).a;\n\n return select(vec4<f32>(r, g, b, a), vec4<f32>(0.0,0.0,0.0,0.0), discarded);\n}\n\nconst TRANSPARENT: i32 = 0;\nconst ORIGINAL: i32 = 1;\nconst LOOP: i32 = 2;\nconst CLAMP: i32 = 3;\nconst MIRROR: i32 = 4;",entryPoint:"mainFragment"}}),c=n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform sampler2D uDisplacementMap;\nuniform float uSeed;\nuniform vec2 uDimensions;\nuniform float uAspect;\nuniform float uFillMode;\nuniform float uOffset;\nuniform float uDirection;\nuniform vec2 uRed;\nuniform vec2 uGreen;\nuniform vec2 uBlue;\n\nuniform vec4 uInputSize;\nuniform vec4 uInputClamp;\n\nconst int TRANSPARENT = 0;\nconst int ORIGINAL = 1;\nconst int LOOP = 2;\nconst int CLAMP = 3;\nconst int MIRROR = 4;\n\nvoid main(void)\n{\n vec2 coord = (vTextureCoord * uInputSize.xy) / uDimensions;\n\n if (coord.x > 1.0 || coord.y > 1.0) {\n return;\n }\n\n float sinDir = sin(uDirection);\n float cosDir = cos(uDirection);\n\n float cx = coord.x - 0.5;\n float cy = (coord.y - 0.5) * uAspect;\n float ny = (-sinDir * cx + cosDir * cy) / uAspect + 0.5;\n\n // displacementMap: repeat\n // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny);\n\n // displacementMap: mirror\n ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny);\n\n vec4 dc = texture(uDisplacementMap, vec2(0.5, ny));\n\n float displacement = (dc.r - dc.g) * (uOffset / uInputSize.x);\n\n coord = vTextureCoord + vec2(cosDir * displacement, sinDir * displacement * uAspect);\n\n int fillMode = int(uFillMode);\n\n if (fillMode == CLAMP) {\n coord = clamp(coord, uInputClamp.xy, uInputClamp.zw);\n } else {\n if( coord.x > uInputClamp.z ) {\n if (fillMode == TRANSPARENT) {\n discard;\n } else if (fillMode == LOOP) {\n coord.x -= uInputClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x = uInputClamp.z * 2.0 - coord.x;\n }\n } else if( coord.x < uInputClamp.x ) {\n if (fillMode == TRANSPARENT) {\n discard;\n } else if (fillMode == LOOP) {\n coord.x += uInputClamp.z;\n } else if (fillMode == MIRROR) {\n coord.x *= -uInputClamp.z;\n }\n }\n\n if( coord.y > uInputClamp.w ) {\n if (fillMode == TRANSPARENT) {\n discard;\n } else if (fillMode == LOOP) {\n coord.y -= uInputClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y = uInputClamp.w * 2.0 - coord.y;\n }\n } else if( coord.y < uInputClamp.y ) {\n if (fillMode == TRANSPARENT) {\n discard;\n } else if (fillMode == LOOP) {\n coord.y += uInputClamp.w;\n } else if (fillMode == MIRROR) {\n coord.y *= -uInputClamp.w;\n }\n }\n }\n\n finalColor.r = texture(uTexture, coord + uRed * (1.0 - uSeed * 0.4) / uInputSize.xy).r;\n finalColor.g = texture(uTexture, coord + uGreen * (1.0 - uSeed * 0.3) / uInputSize.xy).g;\n finalColor.b = texture(uTexture, coord + uBlue * (1.0 - uSeed * 0.2) / uInputSize.xy).b;\n finalColor.a = texture(uTexture, coord).a;\n}\n",name:"glitch-filter"}),m=document.createElement("canvas");m.width=4,m.height=null!=(i=o.sampleSize)?i:512;const p=new n.Texture({source:new n.ImageSource({resource:m})});super({gpuProgram:f,glProgram:c,resources:{glitchUniforms:{uSeed:{value:null!=(u=null==o?void 0:o.seed)?u:0,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"},uAspect:{value:1,type:"f32"},uFillMode:{value:null!=(l=null==o?void 0:o.fillMode)?l:0,type:"f32"},uOffset:{value:null!=(a=null==o?void 0:o.offset)?a:100,type:"f32"},uDirection:{value:null!=(s=null==o?void 0:o.direction)?s:0,type:"f32"},uRed:{value:o.red,type:"vec2<f32>"},uGreen:{value:o.green,type:"vec2<f32>"},uBlue:{value:o.blue,type:"vec2<f32>"}},uDisplacementMap:p.source,uDisplacementSampler:p.source.style}}),xr(this,"uniforms"),xr(this,"average",!1),xr(this,"minSize",8),xr(this,"sampleSize",512),xr(this,"_canvas"),xr(this,"texture"),xr(this,"_slices",0),xr(this,"_sizes",new Float32Array(1)),xr(this,"_offsets",new Float32Array(1)),this.uniforms=this.resources.glitchUniforms.uniforms,this._canvas=m,this.texture=p,Object.assign(this,o)}apply(e,n,r,t){const{width:o,height:i}=n.frame;this.uniforms.uDimensions[0]=o,this.uniforms.uDimensions[1]=i,this.uniforms.uAspect=i/o,e.applyFilter(this,n,r,t)}_randomizeSizes(){const e=this._sizes,n=this._slices-1,r=this.sampleSize,t=Math.min(this.minSize/r,.9/this._slices);if(this.average){const r=this._slices;let o=1;for(let i=0;i<n;i++){const n=o/(r-i),u=Math.max(n*(1-.6*Math.random()),t);e[i]=u,o-=u}e[n]=o}else{let r=1;const o=Math.sqrt(1/this._slices);for(let i=0;i<n;i++){const n=Math.max(o*r*Math.random(),t);e[i]=n,r-=n}e[n]=r}this.shuffle()}shuffle(){const e=this._sizes;for(let n=this._slices-1;n>0;n--){const r=Math.random()*n|0,t=e[n];e[n]=e[r],e[r]=t}}_randomizeOffsets(){for(let e=0;e<this._slices;e++)this._offsets[e]=Math.random()*(Math.random()<.5?-1:1)}refresh(){this._randomizeSizes(),this._randomizeOffsets(),this.redraw()}redraw(){const e=this.sampleSize,n=this.texture,r=this._canvas.getContext("2d");r.clearRect(0,0,8,e);let t,o=0;for(let n=0;n<this._slices;n++){t=Math.floor(256*this._offsets[n]);const i=this._sizes[n]*e,u=t>0?t:0,l=t<0?-t:0;r.fillStyle=`rgba(${u}, ${l}, 0, 1)`,r.fillRect(0,o|0,e,i+1|0),o+=i}n.source.update()}set sizes(e){const n=Math.min(this._slices,e.length);for(let r=0;r<n;r++)this._sizes[r]=e[r]}get sizes(){return this._sizes}set offsets(e){const n=Math.min(this._slices,e.length);for(let r=0;r<n;r++)this._offsets[r]=e[r]}get offsets(){return this._offsets}get slices(){return this._slices}set slices(e){this._slices!==e&&(this._slices=e,this._sizes=new Float32Array(e),this._offsets=new Float32Array(e),this.refresh())}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e}get seed(){return this.uniforms.uSeed}set seed(e){this.uniforms.uSeed=e}get fillMode(){return this.uniforms.uFillMode}set fillMode(e){this.uniforms.uFillMode=e}get direction(){return this.uniforms.uDirection/n.DEG_TO_RAD}set direction(e){this.uniforms.uDirection=e*n.DEG_TO_RAD}get red(){return this.uniforms.uRed}set red(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uRed=e}get green(){return this.uniforms.uGreen}set green(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uGreen=e}get blue(){return this.uniforms.uBlue}set blue(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uBlue=e}destroy(){var e;null==(e=this.texture)||e.destroy(!0),this.texture=this._canvas=this.red=this.green=this.blue=this._sizes=this._offsets=null}};xr(Sr,"defaults",{slices:5,offset:100,direction:0,fillMode:0,average:!1,seed:0,red:{x:0,y:0},green:{x:0,y:0},blue:{x:0,y:0},minSize:8,sampleSize:512});let br=Sr;var Cr="precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uStrength;\nuniform vec3 uColor;\nuniform float uKnockout;\nuniform float uAlpha;\n\nuniform vec4 uInputSize;\nuniform vec4 uInputClamp;\n\nconst float PI = 3.14159265358979323846264;\n\n// Hard-assignment of DIST and ANGLE_STEP_SIZE instead of using uDistance and uQuality to allow them to be use on GLSL loop conditions\nconst float DIST = __DIST__;\nconst float ANGLE_STEP_SIZE = min(__ANGLE_STEP_SIZE__, PI * 2.);\nconst float ANGLE_STEP_NUM = ceil(PI * 2. / ANGLE_STEP_SIZE);\nconst float MAX_TOTAL_ALPHA = ANGLE_STEP_NUM * DIST * (DIST + 1.) / 2.;\n\nvoid main(void) {\n vec2 px = vec2(1.) / uInputSize.xy;\n\n float totalAlpha = 0.;\n\n vec2 direction;\n vec2 displaced;\n vec4 curColor;\n\n for (float angle = 0.; angle < PI * 2.; angle += ANGLE_STEP_SIZE) {\n direction = vec2(cos(angle), sin(angle)) * px;\n\n for (float curDistance = 0.; curDistance < DIST; curDistance++) {\n displaced = clamp(vTextureCoord + direction * (curDistance + 1.), uInputClamp.xy, uInputClamp.zw);\n curColor = texture(uTexture, displaced);\n totalAlpha += (DIST - curDistance) * curColor.a;\n }\n }\n \n curColor = texture(uTexture, vTextureCoord);\n\n vec4 glowColor = vec4(uColor, uAlpha);\n bool knockout = uKnockout > .5;\n float innerStrength = uStrength[0];\n float outerStrength = uStrength[1];\n\n float alphaRatio = totalAlpha / MAX_TOTAL_ALPHA;\n float innerGlowAlpha = (1. - alphaRatio) * innerStrength * curColor.a * uAlpha;\n float innerGlowStrength = min(1., innerGlowAlpha);\n \n vec4 innerColor = mix(curColor, glowColor, innerGlowStrength);\n float outerGlowAlpha = alphaRatio * outerStrength * (1. - curColor.a) * uAlpha;\n float outerGlowStrength = min(1. - innerColor.a, outerGlowAlpha);\n vec4 outerGlowColor = outerGlowStrength * glowColor.rgba;\n\n if (knockout) {\n float resultAlpha = outerGlowAlpha + innerGlowAlpha;\n finalColor = vec4(glowColor.rgb * resultAlpha, resultAlpha);\n }\n else {\n finalColor = innerColor + outerGlowColor;\n }\n}\n",Tr=Object.defineProperty,Pr=Object.getOwnPropertySymbols,zr=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable,_r=(e,n,r)=>n in e?Tr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Ar=(e,n)=>{for(var r in n||(n={}))zr.call(n,r)&&_r(e,r,n[r]);if(Pr)for(var r of Pr(n))Or.call(n,r)&&_r(e,r,n[r]);return e},Fr=(e,n,r)=>(_r(e,"symbol"!=typeof n?n+"":n,r),r);const wr=class e extends n.Filter{constructor(o){var i,u,l,a;const s=null!=(i=(o=Ar(Ar({},e.DEFAULT_OPTIONS),o)).distance)?i:10,f=null!=(u=o.quality)?u:.1;super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct GlowUniforms {\n uDistance: f32,\n uStrength: vec2<f32>,\n uColor: vec3<f32>,\n uAlpha: f32,\n uQuality: f32,\n uKnockout: f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> glowUniforms : GlowUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let quality = glowUniforms.uQuality;\n let distance = glowUniforms.uDistance;\n\n let dist: f32 = glowUniforms.uDistance;\n let angleStepSize: f32 = min(1. / quality / distance, PI * 2.0);\n let angleStepNum: f32 = ceil(PI * 2.0 / angleStepSize);\n\n let px: vec2<f32> = vec2<f32>(1.0 / gfu.uInputSize.xy);\n\n var totalAlpha: f32 = 0.0;\n\n var direction: vec2<f32>;\n var displaced: vec2<f32>;\n var curColor: vec4<f32>;\n\n for (var angle = 0.0; angle < PI * 2.0; angle += angleStepSize) {\n direction = vec2<f32>(cos(angle), sin(angle)) * px;\n for (var curDistance = 0.0; curDistance < dist; curDistance+=1) {\n displaced = vec2<f32>(clamp(uv + direction * (curDistance + 1.0), gfu.uInputClamp.xy, gfu.uInputClamp.zw));\n curColor = textureSample(uTexture, uSampler, displaced);\n totalAlpha += (dist - curDistance) * curColor.a;\n }\n }\n \n curColor = textureSample(uTexture, uSampler, uv);\n\n let glowColorRGB = glowUniforms.uColor;\n let glowAlpha = glowUniforms.uAlpha;\n let glowColor = vec4<f32>(glowColorRGB, glowAlpha);\n let knockout: bool = glowUniforms.uKnockout > 0.5;\n let innerStrength = glowUniforms.uStrength[0];\n let outerStrength = glowUniforms.uStrength[1];\n\n let alphaRatio: f32 = (totalAlpha / (angleStepNum * dist * (dist + 1.0) / 2.0));\n let innerGlowAlpha: f32 = (1.0 - alphaRatio) * innerStrength * curColor.a * glowAlpha;\n let innerGlowStrength: f32 = min(1.0, innerGlowAlpha);\n \n let innerColor: vec4<f32> = mix(curColor, glowColor, innerGlowStrength);\n let outerGlowAlpha: f32 = alphaRatio * outerStrength * (1. - curColor.a) * glowAlpha;\n let outerGlowStrength: f32 = min(1.0 - innerColor.a, outerGlowAlpha);\n let outerGlowColor: vec4<f32> = outerGlowStrength * glowColor.rgba;\n \n if (knockout) {\n let resultAlpha: f32 = outerGlowAlpha + innerGlowAlpha;\n return vec4<f32>(glowColor.rgb * resultAlpha, resultAlpha);\n }\n else {\n return innerColor + outerGlowColor;\n }\n}\n\nconst PI: f32 = 3.14159265358979323846264;",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:Cr.replace(/__ANGLE_STEP_SIZE__/gi,`${(1/f/s).toFixed(7)}`).replace(/__DIST__/gi,`${s.toFixed(0)}.0`),name:"glow-filter"}),resources:{glowUniforms:{uDistance:{value:s,type:"f32"},uStrength:{value:[o.innerStrength,o.outerStrength],type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:o.alpha,type:"f32"},uQuality:{value:f,type:"f32"},uKnockout:{value:null!=(l=null==o?void 0:o.knockout)&&l?1:0,type:"f32"}}},padding:s}),Fr(this,"uniforms"),Fr(this,"_color"),this.uniforms=this.resources.glowUniforms.uniforms,this._color=new n.Color,this.color=null!=(a=o.color)?a:16777215}get distance(){return this.uniforms.uDistance}set distance(e){this.uniforms.uDistance=this.padding=e}get innerStrength(){return this.uniforms.uStrength[0]}set innerStrength(e){this.uniforms.uStrength[0]=e}get outerStrength(){return this.uniforms.uStrength[1]}set outerStrength(e){this.uniforms.uStrength[1]=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[n,r,t]=this._color.toArray();this.uniforms.uColor[0]=n,this.uniforms.uColor[1]=r,this.uniforms.uColor[2]=t}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this.uniforms.uQuality}set quality(e){this.uniforms.uQuality=e}get knockout(){return 1===this.uniforms.uKnockout}set knockout(e){this.uniforms.uKnockout=e?1:0}};Fr(wr,"DEFAULT_OPTIONS",{distance:10,outerStrength:4,innerStrength:0,color:16777215,alpha:1,quality:.1,knockout:!1});let Ir=wr;var Ur="precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uDimensions;\nuniform float uParallel;\nuniform vec2 uLight;\nuniform float uAspect;\nuniform float uTime;\nuniform vec3 uRay;\n\nuniform vec4 uInputSize;\n\n${PERLIN}\n\nvoid main(void) {\n vec2 uDimensions = uDimensions;\n bool uParallel = uParallel > 0.5;\n vec2 uLight = uLight;\n float uAspect = uAspect;\n\n vec2 coord = vTextureCoord * uInputSize.xy / uDimensions;\n\n float d;\n\n if (uParallel) {\n float _cos = uLight.x;\n float _sin = uLight.y;\n d = (_cos * coord.x) + (_sin * coord.y * uAspect);\n } else {\n float dx = coord.x - uLight.x / uDimensions.x;\n float dy = (coord.y - uLight.y / uDimensions.y) * uAspect;\n float dis = sqrt(dx * dx + dy * dy) + 0.00001;\n d = dy / dis;\n }\n\n float uTime = uTime;\n vec3 uRay = uRay;\n\n float gain = uRay[0];\n float lacunarity = uRay[1];\n float alpha = uRay[2];\n\n vec3 dir = vec3(d, d, 0.0);\n float noise = turb(dir + vec3(uTime, 0.0, 62.1 + uTime) * 0.05, vec3(480.0, 320.0, 480.0), lacunarity, gain);\n noise = mix(noise, 0.0, 0.3);\n //fade vertically.\n vec4 mist = vec4(vec3(noise), 1.0) * (1.0 - coord.y);\n mist.a = 1.0;\n // apply user alpha\n mist *= alpha;\n\n finalColor = texture(uTexture, vTextureCoord) + mist;\n}\n",Rr="struct GodrayUniforms {\n uLight: vec2<f32>,\n uParallel: f32,\n uAspect: f32,\n uTime: f32,\n uRay: vec3<f32>,\n uDimensions: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> godrayUniforms : GodrayUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uDimensions: vec2<f32> = godrayUniforms.uDimensions;\n let uParallel: bool = godrayUniforms.uParallel > 0.5;\n let uLight: vec2<f32> = godrayUniforms.uLight;\n let uAspect: f32 = godrayUniforms.uAspect;\n\n let coord: vec2<f32> = uv * gfu.uInputSize.xy / uDimensions;\n\n var d: f32;\n\n if (uParallel) {\n let _cos: f32 = uLight.x;\n let _sin: f32 = uLight.y;\n d = (_cos * coord.x) + (_sin * coord.y * uAspect);\n } else {\n let dx: f32 = coord.x - uLight.x / uDimensions.x;\n let dy: f32 = (coord.y - uLight.y / uDimensions.y) * uAspect;\n let dis: f32 = sqrt(dx * dx + dy * dy) + 0.00001;\n d = dy / dis;\n }\n\n let uTime: f32 = godrayUniforms.uTime;\n let uRay: vec3<f32> = godrayUniforms.uRay;\n \n let gain = uRay[0];\n let lacunarity = uRay[1];\n let alpha = uRay[2];\n\n let dir: vec3<f32> = vec3<f32>(d, d, 0.0);\n var noise: f32 = turb(dir + vec3<f32>(uTime, 0.0, 62.1 + uTime) * 0.05, vec3<f32>(480.0, 320.0, 480.0), lacunarity, gain);\n noise = mix(noise, 0.0, 0.3);\n //fade vertically.\n var mist: vec4<f32> = vec4<f32>(vec3<f32>(noise), 1.0) * (1.0 - coord.y);\n mist.a = 1.0;\n // apply user alpha\n mist *= alpha;\n return textureSample(uTexture, uSampler, uv) + mist;\n}\n\n${PERLIN}",Dr=Object.defineProperty,Mr=Object.getOwnPropertySymbols,Gr=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable,Lr=(e,n,r)=>n in e?Dr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,kr=(e,n)=>{for(var r in n||(n={}))Gr.call(n,r)&&Lr(e,r,n[r]);if(Mr)for(var r of Mr(n))Er.call(n,r)&&Lr(e,r,n[r]);return e},jr=(e,n,r)=>(Lr(e,"symbol"!=typeof n?n+"":n,r),r);const Br=class e extends n.Filter{constructor(o){o=kr(kr({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:Rr.replace("${PERLIN}","// Taken from https://gist.github.com/munrocket/236ed5ba7e409b8bdf1ff6eca5dcdc39\n\nfn moduloVec3(x: vec3<f32>, y: vec3<f32>) -> vec3<f32>\n{\n return x - y * floor(x/y);\n}\nfn mod289Vec3(x: vec3<f32>) -> vec3<f32>\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\nfn mod289Vec4(x: vec4<f32>) -> vec4<f32>\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\nfn permute4(x: vec4<f32>) -> vec4<f32>\n{\n return mod289Vec4(((x * 34.0) + 1.0) * x);\n}\nfn taylorInvSqrt(r: vec4<f32>) -> vec4<f32>\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\nfn fade3(t: vec3<f32>) -> vec3<f32>\n{\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\nfn fade2(t: vec2<f32>) -> vec2<f32> { return t * t * t * (t * (t * 6. - 15.) + 10.); }\n\nfn perlinNoise2(P: vec2<f32>) -> f32 {\n var Pi: vec4<f32> = floor(P.xyxy) + vec4<f32>(0., 0., 1., 1.);\n let Pf = fract(P.xyxy) - vec4<f32>(0., 0., 1., 1.);\n Pi = Pi % vec4<f32>(289.); // To avoid truncation effects in permutation\n let ix = Pi.xzxz;\n let iy = Pi.yyww;\n let fx = Pf.xzxz;\n let fy = Pf.yyww;\n let i = permute4(permute4(ix) + iy);\n var gx: vec4<f32> = 2. * fract(i * 0.0243902439) - 1.; // 1/41 = 0.024...\n let gy = abs(gx) - 0.5;\n let tx = floor(gx + 0.5);\n gx = gx - tx;\n var g00: vec2<f32> = vec2<f32>(gx.x, gy.x);\n var g10: vec2<f32> = vec2<f32>(gx.y, gy.y);\n var g01: vec2<f32> = vec2<f32>(gx.z, gy.z);\n var g11: vec2<f32> = vec2<f32>(gx.w, gy.w);\n let norm = 1.79284291400159 - 0.85373472095314 *\n vec4<f32>(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11));\n g00 = g00 * norm.x;\n g01 = g01 * norm.y;\n g10 = g10 * norm.z;\n g11 = g11 * norm.w;\n let n00 = dot(g00, vec2<f32>(fx.x, fy.x));\n let n10 = dot(g10, vec2<f32>(fx.y, fy.y));\n let n01 = dot(g01, vec2<f32>(fx.z, fy.z));\n let n11 = dot(g11, vec2<f32>(fx.w, fy.w));\n let fade_xy = fade2(Pf.xy);\n let n_x = mix(vec2<f32>(n00, n01), vec2<f32>(n10, n11), vec2<f32>(fade_xy.x));\n let n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return 2.3 * n_xy;\n}\n\n// Classic Perlin noise, periodic variant\nfn perlinNoise3(P: vec3<f32>, rep: vec3<f32>) -> f32\n{\n var Pi0: vec3<f32> = moduloVec3(floor(P), rep); // Integer part, modulo period\n var Pi1: vec3<f32> = moduloVec3(Pi0 + vec3<f32>(1.0), rep); // Integer part + 1, mod period\n Pi0 = mod289Vec3(Pi0);\n Pi1 = mod289Vec3(Pi1);\n let Pf0: vec3<f32> = fract(P); // Fractional part for interpolation\n let Pf1: vec3<f32> = Pf0 - vec3<f32>(1.0); // Fractional part - 1.0\n let ix: vec4<f32> = vec4<f32>(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n let iy: vec4<f32> = vec4<f32>(Pi0.yy, Pi1.yy);\n let iz0: vec4<f32> = Pi0.zzzz;\n let iz1: vec4<f32> = Pi1.zzzz;\n let ixy: vec4<f32> = permute4(permute4(ix) + iy);\n let ixy0: vec4<f32> = permute4(ixy + iz0);\n let ixy1: vec4<f32> = permute4(ixy + iz1);\n var gx0: vec4<f32> = ixy0 * (1.0 / 7.0);\n var gy0: vec4<f32> = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n let gz0: vec4<f32> = vec4<f32>(0.5) - abs(gx0) - abs(gy0);\n let sz0: vec4<f32> = step(gz0, vec4<f32>(0.0));\n gx0 -= sz0 * (step(vec4<f32>(0.0), gx0) - 0.5);\n gy0 -= sz0 * (step(vec4<f32>(0.0), gy0) - 0.5);\n var gx1: vec4<f32> = ixy1 * (1.0 / 7.0);\n var gy1: vec4<f32> = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n let gz1: vec4<f32> = vec4<f32>(0.5) - abs(gx1) - abs(gy1);\n let sz1: vec4<f32> = step(gz1, vec4<f32>(0.0));\n gx1 -= sz1 * (step(vec4<f32>(0.0), gx1) - 0.5);\n gy1 -= sz1 * (step(vec4<f32>(0.0), gy1) - 0.5);\n var g000: vec3<f32> = vec3<f32>(gx0.x, gy0.x, gz0.x);\n var g100: vec3<f32> = vec3<f32>(gx0.y, gy0.y, gz0.y);\n var g010: vec3<f32> = vec3<f32>(gx0.z, gy0.z, gz0.z);\n var g110: vec3<f32> = vec3<f32>(gx0.w, gy0.w, gz0.w);\n var g001: vec3<f32> = vec3<f32>(gx1.x, gy1.x, gz1.x);\n var g101: vec3<f32> = vec3<f32>(gx1.y, gy1.y, gz1.y);\n var g011: vec3<f32> = vec3<f32>(gx1.z, gy1.z, gz1.z);\n var g111: vec3<f32> = vec3<f32>(gx1.w, gy1.w, gz1.w);\n let norm0: vec4<f32> = taylorInvSqrt(vec4<f32>(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n let norm1: vec4<f32> = taylorInvSqrt(vec4<f32>(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n let n000: f32 = dot(g000, Pf0);\n let n100: f32 = dot(g100, vec3<f32>(Pf1.x, Pf0.yz));\n let n010: f32 = dot(g010, vec3<f32>(Pf0.x, Pf1.y, Pf0.z));\n let n110: f32 = dot(g110, vec3<f32>(Pf1.xy, Pf0.z));\n let n001: f32 = dot(g001, vec3<f32>(Pf0.xy, Pf1.z));\n let n101: f32 = dot(g101, vec3<f32>(Pf1.x, Pf0.y, Pf1.z));\n let n011: f32 = dot(g011, vec3<f32>(Pf0.x, Pf1.yz));\n let n111: f32 = dot(g111, Pf1);\n let fade_xyz: vec3<f32> = fade3(Pf0);\n let n_z: vec4<f32> = mix(vec4<f32>(n000, n100, n010, n110), vec4<f32>(n001, n101, n011, n111), fade_xyz.z);\n let n_yz: vec2<f32> = mix(n_z.xy, n_z.zw, fade_xyz.y);\n let n_xyz: f32 = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n}\nfn turb(P: vec3<f32>, rep: vec3<f32>, lacunarity: f32, gain: f32) -> f32\n{\n var sum: f32 = 0.0;\n var sc: f32 = 1.0;\n var totalgain: f32 = 1.0;\n for (var i = 0.0; i < 6.0; i += 1)\n {\n sum += totalgain * perlinNoise3(P * sc, rep);\n sc *= lacunarity;\n totalgain *= gain;\n }\n return abs(sum);\n}"),entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:Ur.replace("${PERLIN}","vec3 mod289(vec3 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\nvec4 mod289(vec4 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\nvec4 permute(vec4 x)\n{\n return mod289(((x * 34.0) + 1.0) * x);\n}\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\nvec3 fade(vec3 t)\n{\n return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n// Classic Perlin noise, periodic variant\nfloat pnoise(vec3 P, vec3 rep)\n{\n vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period\n vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n vec3 g000 = vec3(gx0.x, gy0.x, gz0.x);\n vec3 g100 = vec3(gx0.y, gy0.y, gz0.y);\n vec3 g010 = vec3(gx0.z, gy0.z, gz0.z);\n vec3 g110 = vec3(gx0.w, gy0.w, gz0.w);\n vec3 g001 = vec3(gx1.x, gy1.x, gz1.x);\n vec3 g101 = vec3(gx1.y, gy1.y, gz1.y);\n vec3 g011 = vec3(gx1.z, gy1.z, gz1.z);\n vec3 g111 = vec3(gx1.w, gy1.w, gz1.w);\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n}\nfloat turb(vec3 P, vec3 rep, float lacunarity, float gain)\n{\n float sum = 0.0;\n float sc = 1.0;\n float totalgain = 1.0;\n for (float i = 0.0; i < 6.0; i++)\n {\n sum += totalgain * pnoise(P * sc, rep);\n sc *= lacunarity;\n totalgain *= gain;\n }\n return abs(sum);\n}\n"),name:"god-ray-filter"}),resources:{godrayUniforms:{uLight:{value:new Float32Array(2),type:"vec2<f32>"},uParallel:{value:0,type:"f32"},uAspect:{value:0,type:"f32"},uTime:{value:o.time,type:"f32"},uRay:{value:new Float32Array(3),type:"vec3<f32>"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),jr(this,"uniforms"),jr(this,"time",0),jr(this,"_angleLight",[0,0]),jr(this,"_angle",0),jr(this,"_center"),this.uniforms=this.resources.godrayUniforms.uniforms,Object.assign(this,o)}apply(e,n,r,t){const o=n.frame.width,i=n.frame.height;this.uniforms.uLight[0]=this.parallel?this._angleLight[0]:this._center.x,this.uniforms.uLight[1]=this.parallel?this._angleLight[1]:this._center.y,this.uniforms.uDimensions[0]=o,this.uniforms.uDimensions[1]=i,this.uniforms.uAspect=i/o,this.uniforms.uTime=this.time,e.applyFilter(this,n,r,t)}get angle(){return this._angle}set angle(e){this._angle=e;const r=e*n.DEG_TO_RAD;this._angleLight[0]=Math.cos(r),this._angleLight[1]=Math.sin(r)}get parallel(){return this.uniforms.uParallel>.5}set parallel(e){this.uniforms.uParallel=e?1:0}get center(){return this._center}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this._center=e}get centerX(){return this.center.x}set centerX(e){this.center.x=e}get centerY(){return this.center.y}set centerY(e){this.center.y=e}get gain(){return this.uniforms.uRay[0]}set gain(e){this.uniforms.uRay[0]=e}get lacunarity(){return this.uniforms.uRay[1]}set lacunarity(e){this.uniforms.uRay[1]=e}get alpha(){return this.uniforms.uRay[2]}set alpha(e){this.uniforms.uRay[2]=e}};jr(Br,"DEFAULT_OPTIONS",{angle:30,gain:.5,lacunarity:2.5,parallel:!0,time:0,center:{x:0,y:0},alpha:1});let Nr=Br;class Vr extends n.Filter{constructor(){super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n let color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n let g: f32 = dot(color.rgb, vec3<f32>(0.299, 0.587, 0.114));\n return vec4<f32>(vec3<f32>(g), 1.);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\n\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\n\n// https://en.wikipedia.org/wiki/Luma_(video)\nconst vec3 weight = vec3(0.299, 0.587, 0.114);\n\nvoid main()\n{\n vec4 c = texture(uTexture, vTextureCoord);\n finalColor = vec4(\n vec3(c.r * weight.r + c.g * weight.g + c.b * weight.b),\n c.a\n );\n}\n",name:"grayscale-filter"}),resources:{}})}}var Xr=Object.defineProperty,Yr=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Wr=Object.prototype.propertyIsEnumerable,qr=(e,n,r)=>n in e?Xr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Hr=(e,n)=>{for(var r in n||(n={}))Kr.call(n,r)&&qr(e,r,n[r]);if(Yr)for(var r of Yr(n))Wr.call(n,r)&&qr(e,r,n[r]);return e},Zr=(e,n,r)=>(qr(e,"symbol"!=typeof n?n+"":n,r),r);const Qr=class e extends n.Filter{constructor(o){o=Hr(Hr({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct HslUniforms {\n uHsl:vec3<f32>,\n uColorize:f32,\n uAlpha:f32,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> hslUniforms : HslUniforms;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n let color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n var resultRGB: vec3<f32> = color.rgb;\n\n let hue: f32 = hslUniforms.uHsl[0];\n let saturation: f32 = hslUniforms.uHsl[1];\n let lightness: f32 = hslUniforms.uHsl[2];\n\n // colorize\n if (hslUniforms.uColorize > 0.5) {\n resultRGB = vec3<f32>(dot(color.rgb, vec3<f32>(0.299, 0.587, 0.114)), 0., 0.);\n }\n\n // hue\n resultRGB = hueShift(resultRGB, hue);\n\n // saturation\n // https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/huesaturation.js\n let average: f32 = (resultRGB.r + resultRGB.g + resultRGB.b) / 3.0;\n\n if (saturation > 0.) {\n resultRGB += (average - resultRGB) * (1. - 1. / (1.001 - saturation));\n } else {\n resultRGB -= (average - resultRGB) * saturation;\n }\n\n // lightness\n resultRGB = mix(resultRGB, vec3<f32>(ceil(lightness)) * color.a, abs(lightness));\n\n // alpha\n return mix(color, vec4<f32>(resultRGB, color.a), hslUniforms.uAlpha);\n}\n\n// https://gist.github.com/mairod/a75e7b44f68110e1576d77419d608786?permalink_comment_id=3195243#gistcomment-3195243\nconst k: vec3<f32> = vec3(0.57735, 0.57735, 0.57735);\n\nfn hueShift(color: vec3<f32>, angle: f32) -> vec3<f32> \n{\n let cosAngle: f32 = cos(angle);\n return vec3<f32>(\n color * cosAngle +\n cross(k, color) * sin(angle) +\n k * dot(k, color) * (1.0 - cosAngle)\n );\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec3 uHsl;\nuniform float uAlpha;\nuniform float uColorize;\n\n// https://en.wikipedia.org/wiki/Luma_(video)\nconst vec3 weight = vec3(0.299, 0.587, 0.114);\n\nfloat getWeightedAverage(vec3 rgb) {\n return rgb.r * weight.r + rgb.g * weight.g + rgb.b * weight.b;\n}\n\n// https://gist.github.com/mairod/a75e7b44f68110e1576d77419d608786?permalink_comment_id=3195243#gistcomment-3195243\nconst vec3 k = vec3(0.57735, 0.57735, 0.57735);\n\nvec3 hueShift(vec3 color, float angle) {\n float cosAngle = cos(angle);\n return vec3(\n color * cosAngle +\n cross(k, color) * sin(angle) +\n k * dot(k, color) * (1.0 - cosAngle)\n );\n}\n\nvoid main()\n{\n vec4 color = texture(uTexture, vTextureCoord);\n vec3 resultRGB = color.rgb;\n\n float hue = uHsl[0];\n float saturation = uHsl[1];\n float lightness = uHsl[2];\n\n // colorize\n if (uColorize > 0.5) {\n resultRGB = vec3(getWeightedAverage(resultRGB), 0., 0.);\n }\n\n // hue\n resultRGB = hueShift(resultRGB, hue);\n\n // saturation\n // https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/huesaturation.js\n float average = (resultRGB.r + resultRGB.g + resultRGB.b) / 3.0;\n\n if (saturation > 0.) {\n resultRGB += (average - resultRGB) * (1. - 1. / (1.001 - saturation));\n } else {\n resultRGB -= (average - resultRGB) * saturation;\n }\n\n // lightness\n resultRGB = mix(resultRGB, vec3(ceil(lightness)) * color.a, abs(lightness));\n\n // alpha\n finalColor = mix(color, vec4(resultRGB, color.a), uAlpha);\n}\n",name:"hsl-adjustment-filter"}),resources:{hslUniforms:{uHsl:{value:new Float32Array(3),type:"vec3<f32>"},uColorize:{value:o.colorize?1:0,type:"f32"},uAlpha:{value:o.alpha,type:"f32"}}}}),Zr(this,"uniforms"),Zr(this,"_hue"),this.uniforms=this.resources.hslUniforms.uniforms,this.hue=o.hue}get hue(){return this._hue}set hue(e){this._hue=e,this.resources.hslUniforms.uniforms.uHsl[0]=e*(Math.PI/180)}get saturation(){return this.resources.hslUniforms.uniforms.uHsl[1]}set saturation(e){this.resources.hslUniforms.uniforms.uHsl[1]=e}get lightness(){return this.resources.hslUniforms.uniforms.uHsl[2]}set lightness(e){this.resources.hslUniforms.uniforms.uHsl[2]=e}get colorize(){return 1===this.resources.hslUniforms.uniforms.uColorize}set colorize(e){this.resources.hslUniforms.uniforms.uColorize=e?1:0}get alpha(){return this.resources.hslUniforms.uniforms.uAlpha}set alpha(e){this.resources.hslUniforms.uniforms.uAlpha=e}};Zr(Qr,"DEFAULT_OPTIONS",{hue:0,saturation:0,lightness:0,colorize:!1,alpha:1});let $r=Qr;var Jr=Object.defineProperty,et=Object.getOwnPropertySymbols,nt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,tt=(e,n,r)=>n in e?Jr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,ot=(e,n)=>{for(var r in n||(n={}))nt.call(n,r)&&tt(e,r,n[r]);if(et)for(var r of et(n))rt.call(n,r)&&tt(e,r,n[r]);return e},it=(e,n,r)=>(tt(e,"symbol"!=typeof n?n+"":n,r),r);const ut=class e extends n.Filter{constructor(...o){var i,u;let l=null!=(i=o[0])?i:{};if(Array.isArray(l)||"x"in l&&"y"in l||l instanceof n.ObservablePoint){n.deprecation("6.0.0","MotionBlurFilter constructor params are now options object. See params: { velocity, kernelSize, offset }");l={velocity:{x:"x"in l?l.x:l[0],y:"y"in l?l.y:l[1]}},void 0!==o[1]&&(l.kernelSize=o[1]),void 0!==o[2]&&(l.offset=o[2])}l=ot(ot({},e.DEFAULT_OPTIONS),l);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct MotionBlurUniforms {\n uVelocity: vec2<f32>,\n uKernelSize: f32,\n uOffset: f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> motionBlurUniforms : MotionBlurUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uVelocity = motionBlurUniforms.uVelocity;\n let uKernelSize = motionBlurUniforms.uKernelSize;\n let uOffset = motionBlurUniforms.uOffset;\n\n let velocity: vec2<f32> = uVelocity / gfu.uInputSize.xy;\n let offset: f32 = -uOffset / length(uVelocity) - 0.5;\n let k: i32 = i32(min(uKernelSize - 1, MAX_KERNEL_SIZE - 1));\n\n var color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n for(var i: i32 = 0; i < k; i += 1) {\n let bias: vec2<f32> = velocity * (f32(i) / f32(k) + offset);\n color += textureSample(uTexture, uSampler, uv + bias);\n }\n \n return select(color / f32(uKernelSize), textureSample(uTexture, uSampler, uv), uKernelSize == 0);\n}\n\nconst MAX_KERNEL_SIZE: f32 = 2048;",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uVelocity;\nuniform int uKernelSize;\nuniform float uOffset;\n\nuniform vec4 uInputSize;\n\nconst int MAX_KERNEL_SIZE = 2048;\n\n// Notice:\n// the perfect way:\n// int kernelSize = min(uKernelSize, MAX_KERNELSIZE);\n// BUT in real use-case , uKernelSize < MAX_KERNELSIZE almost always.\n// So use uKernelSize directly.\n\nvoid main(void)\n{\n vec4 color = texture(uTexture, vTextureCoord);\n\n if (uKernelSize == 0)\n {\n finalColor = color;\n return;\n }\n\n vec2 velocity = uVelocity / uInputSize.xy;\n float offset = -uOffset / length(uVelocity) - 0.5;\n int k = uKernelSize - 1;\n\n for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) {\n if (i == k) {\n break;\n }\n vec2 bias = velocity * (float(i) / float(k) + offset);\n color += texture(uTexture, vTextureCoord + bias);\n }\n finalColor = color / float(uKernelSize);\n}\n",name:"motion-blur-filter"}),resources:{motionBlurUniforms:{uVelocity:{value:l.velocity,type:"vec2<f32>"},uKernelSize:{value:Math.trunc(null!=(u=l.kernelSize)?u:5),type:"i32"},uOffset:{value:l.offset,type:"f32"}}}}),it(this,"uniforms"),it(this,"_kernelSize"),this.uniforms=this.resources.motionBlurUniforms.uniforms,Object.assign(this,l)}get velocity(){return this.uniforms.uVelocity}set velocity(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uVelocity=e,this._updateDirty()}get velocityX(){return this.velocity.x}set velocityX(e){this.velocity.x=e,this._updateDirty()}get velocityY(){return this.velocity.y}set velocityY(e){this.velocity.y=e,this._updateDirty()}get kernelSize(){return this._kernelSize}set kernelSize(e){this._kernelSize=e,this._updateDirty()}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e}_updateDirty(){this.padding=1+(Math.max(Math.abs(this.velocityX),Math.abs(this.velocityY))|0),this.uniforms.uKernelSize=0!==this.velocityX||0!==this.velocityY?this._kernelSize:0}};it(ut,"DEFAULT_OPTIONS",{velocity:{x:0,y:0},kernelSize:5,offset:0});let lt=ut;var at="in vec2 vTextureCoord;\nout vec4 finalColor;\n\nconst int MAX_COLORS = ${MAX_COLORS};\n\nuniform sampler2D uTexture;\nuniform vec3 uOriginalColors[MAX_COLORS];\nuniform vec3 uTargetColors[MAX_COLORS];\nuniform float uTolerance;\n\nvoid main(void)\n{\n finalColor = texture(uTexture, vTextureCoord);\n\n float alpha = finalColor.a;\n if (alpha < 0.0001)\n {\n return;\n }\n\n vec3 color = finalColor.rgb / alpha;\n\n for(int i = 0; i < MAX_COLORS; i++)\n {\n vec3 origColor = uOriginalColors[i];\n if (origColor.r < 0.0)\n {\n break;\n }\n vec3 colorDiff = origColor - color;\n if (length(colorDiff) < uTolerance)\n {\n vec3 targetColor = uTargetColors[i];\n finalColor = vec4((targetColor + colorDiff) * alpha, alpha);\n return;\n }\n }\n}\n",st="struct MultiColorReplaceUniforms {\n uOriginalColors: array<vec3<f32>, MAX_COLORS>,\n uTargetColors: array<vec3<f32>, MAX_COLORS>,\n uTolerance:f32,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> multiColorReplaceUniforms : MultiColorReplaceUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uOriginalColors = multiColorReplaceUniforms.uOriginalColors;\n let uTargetColors = multiColorReplaceUniforms.uTargetColors;\n let uTolerance = multiColorReplaceUniforms.uTolerance;\n\n var color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n let alpha: f32 = color.a;\n\n if (alpha > 0.0001)\n {\n var modColor: vec3<f32> = vec3<f32>(color.rgb) / alpha;\n\n for(var i: i32 = 0; i < MAX_COLORS; i += 1)\n {\n let origColor: vec3<f32> = uOriginalColors[i];\n if (origColor.r < 0.0)\n {\n break;\n }\n let colorDiff: vec3<f32> = origColor - modColor;\n \n if (length(colorDiff) < uTolerance)\n {\n let targetColor: vec3<f32> = uTargetColors[i];\n color = vec4((targetColor + colorDiff) * alpha, alpha);\n return color;\n }\n }\n }\n\n return color;\n}\n\nconst MAX_COLORS: i32 = ${MAX_COLORS};",ft=Object.defineProperty,ct=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable,vt=(e,n,r)=>n in e?ft(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,gt=(e,n)=>{for(var r in n||(n={}))mt.call(n,r)&&vt(e,r,n[r]);if(ct)for(var r of ct(n))pt.call(n,r)&&vt(e,r,n[r]);return e},dt=(e,n,r)=>(vt(e,"symbol"!=typeof n?n+"":n,r),r);const ht=class e extends n.Filter{constructor(...o){var i,u;let l=null!=(i=o[0])?i:{};Array.isArray(l)&&(n.deprecation("6.0.0","MultiColorReplaceFilter constructor params are now options object. See params: { replacements, tolerance, maxColors }"),l={replacements:l},o[1]&&(l.tolerance=o[1]),o[2]&&(l.maxColors=o[2])),l=gt(gt({},e.DEFAULT_OPTIONS),l);const a=null!=(u=l.maxColors)?u:l.replacements.length;super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:st.replace(/\$\{MAX_COLORS\}/g,a.toFixed(0)),entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:at.replace(/\$\{MAX_COLORS\}/g,a.toFixed(0)),name:"multi-color-replace-filter"}),resources:{multiColorReplaceUniforms:{uOriginalColors:{value:new Float32Array(3*a),type:"vec3<f32>",size:a},uTargetColors:{value:new Float32Array(3*a),type:"vec3<f32>",size:a},uTolerance:{value:l.tolerance,type:"f32"}}}}),dt(this,"uniforms"),dt(this,"_replacements",[]),dt(this,"_maxColors"),this._maxColors=a,this.uniforms=this.resources.multiColorReplaceUniforms.uniforms,this.replacements=l.replacements}set replacements(e){const r=this.uniforms.uOriginalColors,t=this.uniforms.uTargetColors,o=e.length,i=new n.Color;if(o>this._maxColors)throw new Error(`Length of replacements (${o}) exceeds the maximum colors length (${this._maxColors})`);let u,l,a;r[3*o]=-1;for(let n=0;n<o;n++){const o=e[n];i.setValue(o[0]),[u,l,a]=i.toArray(),r[3*n]=u,r[3*n+1]=l,r[3*n+2]=a,i.setValue(o[1]),[u,l,a]=i.toArray(),t[3*n]=u,t[3*n+1]=l,t[3*n+2]=a}this._replacements=e}get replacements(){return this._replacements}refresh(){this.replacements=this._replacements}get maxColors(){return this._maxColors}get tolerance(){return this.uniforms.uTolerance}set tolerance(e){this.uniforms.uTolerance=e}set epsilon(e){n.deprecation("6.0.0","MultiColorReplaceFilter.epsilon is deprecated, please use MultiColorReplaceFilter.tolerance instead"),this.tolerance=e}get epsilon(){return n.deprecation("6.0.0","MultiColorReplaceFilter.epsilon is deprecated, please use MultiColorReplaceFilter.tolerance instead"),this.tolerance}};dt(ht,"DEFAULT_OPTIONS",{replacements:[[16711680,255]],tolerance:.05,maxColors:void 0});let xt=ht;var yt=Object.defineProperty,St=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,Tt=(e,n,r)=>n in e?yt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Pt=(e,n)=>{for(var r in n||(n={}))bt.call(n,r)&&Tt(e,r,n[r]);if(St)for(var r of St(n))Ct.call(n,r)&&Tt(e,r,n[r]);return e},zt=(e,n,r)=>(Tt(e,"symbol"!=typeof n?n+"":n,r),r);const Ot=class e extends n.Filter{constructor(o){o=Pt(Pt({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct OldFilmUniforms {\n uSepia: f32,\n uNoise: vec2<f32>,\n uScratch: vec3<f32>,\n uVignetting: vec3<f32>,\n uSeed: f32,\n uDimensions: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> oldFilmUniforms : OldFilmUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n var color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n\n if (oldFilmUniforms.uSepia > 0.)\n {\n color = vec4<f32>(sepia(color.rgb), color.a);\n }\n\n let coord: vec2<f32> = uv * gfu.uInputSize.xy / oldFilmUniforms.uDimensions;\n\n if (oldFilmUniforms.uVignetting[0] > 0.)\n {\n color *= vec4<f32>(vec3<f32>(vignette(color.rgb, coord)), color.a);\n }\n\n let uScratch = oldFilmUniforms.uScratch; \n\n if (uScratch[1] > oldFilmUniforms.uSeed && uScratch[0] != 0.)\n {\n color = vec4<f32>(scratch(color.rgb, coord), color.a);\n }\n\n let uNoise = oldFilmUniforms.uNoise;\n\n if (uNoise[0] > 0.0 && uNoise[1] > 0.0)\n {\n color += vec4<f32>(vec3<f32>(noise(uv)), color.a);\n }\n\n return color;\n}\n\nconst SQRT_2: f32 = 1.414213;\nconst SEPIA_RGB: vec3<f32> = vec3<f32>(112.0 / 255.0, 66.0 / 255.0, 20.0 / 255.0);\n\nfn modulo(x: f32, y: f32) -> f32\n{\n return x - y * floor(x/y);\n}\n\nfn rand(co: vec2<f32>) -> f32\n{\n return fract(sin(dot(co, vec2<f32>(12.9898, 78.233))) * 43758.5453);\n}\n\nfn overlay(src: vec3<f32>, dst: vec3<f32>) -> vec3<f32>\n{\n // if (dst <= 0.5) then: 2 * src * dst\n // if (dst > 0.5) then: 1 - 2 * (1 - dst) * (1 - src)\n\n return vec3<f32>(\n select((1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)), (2.0 * src.x * dst.x), (dst.x <= 0.5)), \n select((1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)), (2.0 * src.y * dst.y), (dst.y <= 0.5)),\n select((1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z)), (2.0 * src.z * dst.z), (dst.z <= 0.5))\n );\n}\n\nfn sepia(co: vec3<f32>) -> vec3<f32>\n{\n let gray: f32 = (co.x + co.y + co.z) / 3.0;\n let grayscale: vec3<f32> = vec3<f32>(gray);\n let color = overlay(SEPIA_RGB, grayscale);\n return grayscale + oldFilmUniforms.uSepia * (color - grayscale);\n}\n\nfn vignette(co: vec3<f32>, coord: vec2<f32>) -> f32\n{\n let uVignetting = oldFilmUniforms.uVignetting;\n let uDimensions = oldFilmUniforms.uDimensions;\n \n let outter: f32 = SQRT_2 - uVignetting[0] * SQRT_2;\n var dir: vec2<f32> = vec2<f32>(vec2<f32>(0.5) - coord);\n dir.y *= uDimensions.y / uDimensions.x;\n let darker: f32 = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + uVignetting[2] * SQRT_2), 0.0, 1.0);\n return darker + (1.0 - darker) * (1.0 - uVignetting[1]);\n}\n\nfn scratch(co: vec3<f32>, coord: vec2<f32>) -> vec3<f32>\n{\n var color = co;\n let uScratch = oldFilmUniforms.uScratch;\n let uSeed = oldFilmUniforms.uSeed;\n let uDimensions = oldFilmUniforms.uDimensions;\n\n let phase: f32 = uSeed * 256.0;\n let s: f32 = modulo(floor(phase), 2.0);\n let dist: f32 = 1.0 / uScratch[1];\n let d: f32 = distance(coord, vec2<f32>(uSeed * dist, abs(s - uSeed * dist)));\n\n if (d < uSeed * 0.6 + 0.4)\n {\n let period: f32 = uScratch[1] * 10.0;\n\n let xx: f32 = coord.x * period + phase;\n let aa: f32 = abs(modulo(xx, 0.5) * 4.0);\n let bb: f32 = modulo(floor(xx / 0.5), 2.0);\n let yy: f32 = (1.0 - bb) * aa + bb * (2.0 - aa);\n\n let kk: f32 = 2.0 * period;\n let dw: f32 = uScratch[2] / uDimensions.x * (0.75 + uSeed);\n let dh: f32 = dw * kk;\n\n var tine: f32 = (yy - (2.0 - dh));\n\n if (tine > 0.0) {\n let _sign: f32 = sign(uScratch[0]);\n\n tine = s * tine / period + uScratch[0] + 0.1;\n tine = clamp(tine + 1.0, 0.5 + _sign * 0.5, 1.5 + _sign * 0.5);\n\n color *= tine;\n }\n }\n\n return color;\n}\n\nfn noise(coord: vec2<f32>) -> f32\n{\n let uNoise = oldFilmUniforms.uNoise;\n let uSeed = oldFilmUniforms.uSeed;\n\n var pixelCoord: vec2<f32> = coord * gfu.uInputSize.xy;\n pixelCoord.x = floor(pixelCoord.x / uNoise[1]);\n pixelCoord.y = floor(pixelCoord.y / uNoise[1]);\n return (rand(pixelCoord * uNoise[1] * uSeed) - 0.5) * uNoise[0];\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uSepia;\nuniform vec2 uNoise;\nuniform vec3 uScratch;\nuniform vec3 uVignetting;\nuniform float uSeed;\nuniform vec2 uDimensions;\n\nuniform vec4 uInputSize;\n\nconst float SQRT_2 = 1.414213;\nconst vec3 SEPIA_RGB = vec3(112.0 / 255.0, 66.0 / 255.0, 20.0 / 255.0);\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvec3 Overlay(vec3 src, vec3 dst)\n{\n // if (dst <= 0.5) then: 2 * src * dst\n // if (dst > 0.5) then: 1 - 2 * (1 - dst) * (1 - src)\n return vec3((dst.x <= 0.5) ? (2.0 * src.x * dst.x) : (1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)),\n (dst.y <= 0.5) ? (2.0 * src.y * dst.y) : (1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)),\n (dst.z <= 0.5) ? (2.0 * src.z * dst.z) : (1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z)));\n}\n\n\nvoid main()\n{\n finalColor = texture(uTexture, vTextureCoord);\n vec3 color = finalColor.rgb;\n\n if (uSepia > 0.0)\n {\n float gray = (color.x + color.y + color.z) / 3.0;\n vec3 grayscale = vec3(gray);\n\n color = Overlay(SEPIA_RGB, grayscale);\n\n color = grayscale + uSepia * (color - grayscale);\n }\n\n vec2 coord = vTextureCoord * uInputSize.xy / uDimensions.xy;\n\n float vignette = uVignetting[0];\n float vignetteAlpha = uVignetting[1];\n float vignetteBlur = uVignetting[2];\n\n if (vignette > 0.0)\n {\n float outter = SQRT_2 - vignette * SQRT_2;\n vec2 dir = vec2(vec2(0.5, 0.5) - coord);\n dir.y *= uDimensions.y / uDimensions.x;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignetteBlur * SQRT_2), 0.0, 1.0);\n color.rgb *= darker + (1.0 - darker) * (1.0 - vignetteAlpha);\n }\n\n float scratch = uScratch[0];\n float scratchDensity = uScratch[1];\n float scratchWidth = uScratch[2];\n\n if (scratchDensity > uSeed && scratch != 0.0)\n {\n float phase = uSeed * 256.0;\n float s = mod(floor(phase), 2.0);\n float dist = 1.0 / scratchDensity;\n float d = distance(coord, vec2(uSeed * dist, abs(s - uSeed * dist)));\n if (d < uSeed * 0.6 + 0.4)\n {\n highp float period = scratchDensity * 10.0;\n\n float xx = coord.x * period + phase;\n float aa = abs(mod(xx, 0.5) * 4.0);\n float bb = mod(floor(xx / 0.5), 2.0);\n float yy = (1.0 - bb) * aa + bb * (2.0 - aa);\n\n float kk = 2.0 * period;\n float dw = scratchWidth / uDimensions.x * (0.75 + uSeed);\n float dh = dw * kk;\n\n float tine = (yy - (2.0 - dh));\n\n if (tine > 0.0) {\n float _sign = sign(scratch);\n\n tine = s * tine / period + scratch + 0.1;\n tine = clamp(tine + 1.0, 0.5 + _sign * 0.5, 1.5 + _sign * 0.5);\n\n color.rgb *= tine;\n }\n }\n }\n\n float noise = uNoise[0];\n float noiseSize = uNoise[1];\n\n if (noise > 0.0 && noiseSize > 0.0)\n {\n vec2 pixelCoord = vTextureCoord.xy * uInputSize.xy;\n pixelCoord.x = floor(pixelCoord.x / noiseSize);\n pixelCoord.y = floor(pixelCoord.y / noiseSize);\n // vec2 d = pixelCoord * noiseSize * vec2(1024.0 + uSeed * 512.0, 1024.0 - uSeed * 512.0);\n // float _noise = snoise(d) * 0.5;\n float _noise = rand(pixelCoord * noiseSize * uSeed) - 0.5;\n color += _noise * noise;\n }\n\n finalColor.rgb = color;\n}",name:"old-film-filter"}),resources:{oldFilmUniforms:{uSepia:{value:o.sepia,type:"f32"},uNoise:{value:new Float32Array(2),type:"vec2<f32>"},uScratch:{value:new Float32Array(3),type:"vec3<f32>"},uVignetting:{value:new Float32Array(3),type:"vec3<f32>"},uSeed:{value:o.seed,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),zt(this,"uniforms"),zt(this,"seed"),this.uniforms=this.resources.oldFilmUniforms.uniforms,Object.assign(this,o)}apply(e,n,r,t){this.uniforms.uDimensions[0]=n.frame.width,this.uniforms.uDimensions[1]=n.frame.height,this.uniforms.uSeed=this.seed,e.applyFilter(this,n,r,t)}get sepia(){return this.uniforms.uSepia}set sepia(e){this.uniforms.uSepia=e}get noise(){return this.uniforms.uNoise[0]}set noise(e){this.uniforms.uNoise[0]=e}get noiseSize(){return this.uniforms.uNoise[1]}set noiseSize(e){this.uniforms.uNoise[1]=e}get scratch(){return this.uniforms.uScratch[0]}set scratch(e){this.uniforms.uScratch[0]=e}get scratchDensity(){return this.uniforms.uScratch[1]}set scratchDensity(e){this.uniforms.uScratch[1]=e}get scratchWidth(){return this.uniforms.uScratch[2]}set scratchWidth(e){this.uniforms.uScratch[2]=e}get vignetting(){return this.uniforms.uVignetting[0]}set vignetting(e){this.uniforms.uVignetting[0]=e}get vignettingAlpha(){return this.uniforms.uVignetting[1]}set vignettingAlpha(e){this.uniforms.uVignetting[1]=e}get vignettingBlur(){return this.uniforms.uVignetting[2]}set vignettingBlur(e){this.uniforms.uVignetting[2]=e}};zt(Ot,"DEFAULT_OPTIONS",{sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,seed:0});let _t=Ot;var At="precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uThickness;\nuniform vec3 uColor;\nuniform float uAlpha;\nuniform float uKnockout;\n\nuniform vec4 uInputClamp;\n\nconst float DOUBLE_PI = 2. * 3.14159265358979323846264;\nconst float ANGLE_STEP = ${ANGLE_STEP};\n\nfloat outlineMaxAlphaAtPos(vec2 pos) {\n if (uThickness.x == 0. || uThickness.y == 0.) {\n return 0.;\n }\n\n vec4 displacedColor;\n vec2 displacedPos;\n float maxAlpha = 0.;\n\n for (float angle = 0.; angle <= DOUBLE_PI; angle += ANGLE_STEP) {\n displacedPos.x = vTextureCoord.x + uThickness.x * cos(angle);\n displacedPos.y = vTextureCoord.y + uThickness.y * sin(angle);\n displacedColor = texture(uTexture, clamp(displacedPos, uInputClamp.xy, uInputClamp.zw));\n maxAlpha = max(maxAlpha, displacedColor.a);\n }\n\n return maxAlpha;\n}\n\nvoid main(void) {\n vec4 sourceColor = texture(uTexture, vTextureCoord);\n vec4 contentColor = sourceColor * float(uKnockout < 0.5);\n float outlineAlpha = uAlpha * outlineMaxAlphaAtPos(vTextureCoord.xy) * (1.-sourceColor.a);\n vec4 outlineColor = vec4(vec3(uColor) * outlineAlpha, outlineAlpha);\n finalColor = contentColor + outlineColor;\n}\n",Ft=Object.defineProperty,wt=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable,Rt=(e,n,r)=>n in e?Ft(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Dt=(e,n)=>{for(var r in n||(n={}))It.call(n,r)&&Rt(e,r,n[r]);if(wt)for(var r of wt(n))Ut.call(n,r)&&Rt(e,r,n[r]);return e},Mt=(e,n,r)=>(Rt(e,"symbol"!=typeof n?n+"":n,r),r);const Gt=class e extends n.Filter{constructor(...o){var i,u,l;let a=null!=(i=o[0])?i:{};"number"==typeof a&&(n.deprecation("6.0.0","OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"),a={thickness:a},void 0!==o[1]&&(a.color=o[1]),void 0!==o[2]&&(a.quality=o[2]),void 0!==o[3]&&(a.alpha=o[3]),void 0!==o[4]&&(a.knockout=o[4])),a=Dt(Dt({},e.DEFAULT_OPTIONS),a);const s=null!=(u=a.quality)?u:.1;super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct OutlineUniforms {\n uThickness:vec2<f32>,\n uColor:vec3<f32>,\n uAlpha:f32,\n uAngleStep:f32,\n uKnockout:f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> outlineUniforms : OutlineUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let sourceColor: vec4<f32> = textureSample(uTexture, uSampler, uv);\n let contentColor: vec4<f32> = sourceColor * (1. - outlineUniforms.uKnockout);\n \n let outlineAlpha: f32 = outlineUniforms.uAlpha * outlineMaxAlphaAtPos(uv) * (1. - sourceColor.a);\n let outlineColor: vec4<f32> = vec4<f32>(vec3<f32>(outlineUniforms.uColor) * outlineAlpha, outlineAlpha);\n \n return contentColor + outlineColor;\n}\n\nfn outlineMaxAlphaAtPos(uv: vec2<f32>) -> f32 {\n let thickness = outlineUniforms.uThickness;\n\n if (thickness.x == 0. || thickness.y == 0.) {\n return 0.;\n }\n \n let angleStep = outlineUniforms.uAngleStep;\n\n var displacedColor: vec4<f32>;\n var displacedPos: vec2<f32>;\n\n var maxAlpha: f32 = 0.;\n var displaced: vec2<f32>;\n var curColor: vec4<f32>;\n\n for (var angle = 0.; angle <= DOUBLE_PI; angle += angleStep)\n {\n displaced.x = uv.x + thickness.x * cos(angle);\n displaced.y = uv.y + thickness.y * sin(angle);\n curColor = textureSample(uTexture, uSampler, clamp(displaced, gfu.uInputClamp.xy, gfu.uInputClamp.zw));\n maxAlpha = max(maxAlpha, curColor.a);\n }\n\n return maxAlpha;\n}\n\nconst DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:At.replace(/\$\{ANGLE_STEP\}/,e.getAngleStep(s).toFixed(7)),name:"outline-filter"}),resources:{outlineUniforms:{uThickness:{value:new Float32Array(2),type:"vec2<f32>"},uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:a.alpha,type:"f32"},uAngleStep:{value:0,type:"f32"},uKnockout:{value:a.knockout?1:0,type:"f32"}}}}),Mt(this,"uniforms"),Mt(this,"_thickness"),Mt(this,"_quality"),Mt(this,"_color"),this.uniforms=this.resources.outlineUniforms.uniforms,this.uniforms.uAngleStep=e.getAngleStep(s),this._color=new n.Color,this.color=null!=(l=a.color)?l:0,Object.assign(this,a)}apply(e,n,r,t){this.uniforms.uThickness[0]=this.thickness/n.source.width,this.uniforms.uThickness[1]=this.thickness/n.source.height,e.applyFilter(this,n,r,t)}static getAngleStep(n){return parseFloat((2*Math.PI/Math.max(n*e.MAX_SAMPLES,e.MIN_SAMPLES)).toFixed(7))}get thickness(){return this._thickness}set thickness(e){this._thickness=this.padding=e}get color(){return this._color.value}set color(e){this._color.setValue(e);const[n,r,t]=this._color.toArray();this.uniforms.uColor[0]=n,this.uniforms.uColor[1]=r,this.uniforms.uColor[2]=t}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}get quality(){return this._quality}set quality(n){this._quality=n,this.uniforms.uAngleStep=e.getAngleStep(n)}get knockout(){return 1===this.uniforms.uKnockout}set knockout(e){this.uniforms.uKnockout=e?1:0}};Mt(Gt,"DEFAULT_OPTIONS",{thickness:1,color:0,alpha:1,quality:.1,knockout:!1}),Mt(Gt,"MIN_SAMPLES",1),Mt(Gt,"MAX_SAMPLES",100);let Et=Gt;class Lt extends n.Filter{constructor(e=10){super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct PixelateUniforms {\n uSize:vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> pixelateUniforms : PixelateUniforms;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n let pixelSize: vec2<f32> = pixelateUniforms.uSize;\n let coord: vec2<f32> = mapCoord(uv);\n\n var pixCoord: vec2<f32> = pixelate(coord, pixelSize);\n pixCoord = unmapCoord(pixCoord);\n\n return textureSample(uTexture, uSampler, pixCoord);\n}\n\nfn mapCoord(coord: vec2<f32> ) -> vec2<f32>\n{\n var mappedCoord: vec2<f32> = coord;\n mappedCoord *= gfu.uInputSize.xy;\n mappedCoord += gfu.uOutputFrame.xy;\n return mappedCoord;\n}\n\nfn unmapCoord(coord: vec2<f32> ) -> vec2<f32>\n{\n var mappedCoord: vec2<f32> = coord;\n mappedCoord -= gfu.uOutputFrame.xy;\n mappedCoord /= gfu.uInputSize.xy;\n return mappedCoord;\n}\n\nfn pixelate(coord: vec2<f32>, size: vec2<f32>) -> vec2<f32>\n{\n return floor( coord / size ) * size;\n}\n\n",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform vec2 uSize;\nuniform sampler2D uTexture;\nuniform vec4 uInputSize;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= uInputSize.xy;\n coord += uInputSize.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= uInputSize.zw;\n coord /= uInputSize.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 uSize)\n{\n\treturn floor( coord / uSize ) * uSize;\n}\n\nvoid main(void)\n{\n vec2 coord = mapCoord(vTextureCoord);\n coord = pixelate(coord, uSize);\n coord = unmapCoord(coord);\n finalColor = texture(uTexture, coord);\n}\n",name:"pixelate-filter"}),resources:{pixelateUniforms:{uSize:{value:new Float32Array(2),type:"vec2<f32>"}}}}),this.size=e}get size(){return this.resources.pixelateUniforms.uniforms.uSize}set size(e){e instanceof n.Point?(this.sizeX=e.x,this.sizeY=e.y):Array.isArray(e)?this.resources.pixelateUniforms.uniforms.uSize=e:this.sizeX=this.sizeY=e}get sizeX(){return this.resources.pixelateUniforms.uniforms.uSize[0]}set sizeX(e){this.resources.pixelateUniforms.uniforms.uSize[0]=e}get sizeY(){return this.resources.pixelateUniforms.uniforms.uSize[1]}set sizeY(e){this.resources.pixelateUniforms.uniforms.uSize[1]=e}}var kt=Object.defineProperty,jt=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,Vt=(e,n,r)=>n in e?kt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Xt=(e,n)=>{for(var r in n||(n={}))Bt.call(n,r)&&Vt(e,r,n[r]);if(jt)for(var r of jt(n))Nt.call(n,r)&&Vt(e,r,n[r]);return e},Yt=(e,n,r)=>(Vt(e,"symbol"!=typeof n?n+"":n,r),r);const Kt=class e extends n.Filter{constructor(...o){var i;let u=null!=(i=o[0])?i:{};if("number"==typeof u){if(n.deprecation("6.0.0","RadialBlurFilter constructor params are now options object. See params: { angle, center, kernelSize, radius }"),u={angle:u},o[1]){const e="x"in o[1]?o[1].x:o[1][0],n="y"in o[1]?o[1].y:o[1][1];u.center={x:e,y:n}}o[2]&&(u.kernelSize=o[2]),o[3]&&(u.radius=o[3])}u=Xt(Xt({},e.DEFAULT_OPTIONS),u);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct RadialBlurUniforms {\n uRadian: f32,\n uCenter: vec2<f32>,\n uKernelSize: f32,\n uRadius: f32,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> radialBlurUniforms : RadialBlurUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uRadian = radialBlurUniforms.uRadian;\n let uCenter = radialBlurUniforms.uCenter;\n let uKernelSize = radialBlurUniforms.uKernelSize;\n let uRadius = radialBlurUniforms.uRadius;\n \n var returnColorOnly = false;\n\n if (uKernelSize == 0)\n {\n returnColorOnly = true;\n }\n\n let aspect: f32 = gfu.uInputSize.y / gfu.uInputSize.x;\n let center: vec2<f32> = uCenter.xy / gfu.uInputSize.xy;\n let gradient: f32 = uRadius / gfu.uInputSize.x * 0.3;\n let radius: f32 = uRadius / gfu.uInputSize.x - gradient * 0.5;\n let k: i32 = i32(uKernelSize - 1);\n\n var coord: vec2<f32> = uv;\n let dir: vec2<f32> = vec2<f32>(center - coord);\n let dist: f32 = length(vec2<f32>(dir.x, dir.y * aspect));\n\n var radianStep: f32 = uRadian;\n \n if (radius >= 0.0 && dist > radius)\n {\n let delta: f32 = dist - radius;\n let gap: f32 = gradient;\n let scale: f32 = 1.0 - abs(delta / gap);\n if (scale <= 0.0) {\n returnColorOnly = true;\n }\n radianStep *= scale;\n }\n\n radianStep /= f32(k);\n\n let s: f32 = sin(radianStep);\n let c: f32 = cos(radianStep);\n let rotationMatrix: mat2x2<f32> = mat2x2<f32>(vec2<f32>(c, -s), vec2<f32>(s, c));\n \n var color: vec4<f32> = textureSample(uTexture, uSampler, uv);\n let baseColor = vec4<f32>(color);\n\n let minK: i32 = min(i32(uKernelSize) - 1, MAX_KERNEL_SIZE - 1);\n\n for(var i: i32 = 0; i < minK; i += 1) \n {\n coord -= center;\n coord.y *= aspect;\n coord = rotationMatrix * coord;\n coord.y /= aspect;\n coord += center;\n let sample: vec4<f32> = textureSample(uTexture, uSampler, coord);\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n color += sample;\n }\n\n return select(color / f32(uKernelSize), baseColor, returnColorOnly);\n}\n\nconst MAX_KERNEL_SIZE: i32 = 2048;",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uRadian;\nuniform vec2 uCenter;\nuniform float uRadius;\nuniform int uKernelSize;\n\nuniform vec4 uInputSize;\n\nconst int MAX_KERNEL_SIZE = 2048;\n\nvoid main(void)\n{\n vec4 color = texture(uTexture, vTextureCoord);\n\n if (uKernelSize == 0)\n {\n finalColor = color;\n return;\n }\n\n float aspect = uInputSize.y / uInputSize.x;\n vec2 center = uCenter.xy / uInputSize.xy;\n float gradient = uRadius / uInputSize.x * 0.3;\n float radius = uRadius / uInputSize.x - gradient * 0.5;\n int k = uKernelSize - 1;\n\n vec2 coord = vTextureCoord;\n vec2 dir = vec2(center - coord);\n float dist = length(vec2(dir.x, dir.y * aspect));\n\n float radianStep = uRadian;\n if (radius >= 0.0 && dist > radius) {\n float delta = dist - radius;\n float gap = gradient;\n float scale = 1.0 - abs(delta / gap);\n if (scale <= 0.0) {\n finalColor = color;\n return;\n }\n radianStep *= scale;\n }\n radianStep /= float(k);\n\n float s = sin(radianStep);\n float c = cos(radianStep);\n mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c));\n\n for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) {\n if (i == k) {\n break;\n }\n\n coord -= center;\n coord.y *= aspect;\n coord = rotationMatrix * coord;\n coord.y /= aspect;\n coord += center;\n\n vec4 sample = texture(uTexture, coord);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample;\n }\n\n finalColor = color / float(uKernelSize);\n}\n",name:"radial-blur-filter"}),resources:{radialBlurUniforms:{uRadian:{value:0,type:"f32"},uCenter:{value:u.center,type:"vec2<f32>"},uKernelSize:{value:u.kernelSize,type:"i32"},uRadius:{value:u.radius,type:"f32"}}}}),Yt(this,"uniforms"),Yt(this,"_angle"),Yt(this,"_kernelSize"),this.uniforms=this.resources.radialBlurUniforms.uniforms,Object.assign(this,u)}_updateKernelSize(){this.uniforms.uKernelSize=0!==this._angle?this.kernelSize:0}get angle(){return this._angle}set angle(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180,this._updateKernelSize()}get center(){return this.uniforms.uCenter}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.center.x}set centerX(e){this.center.x=e}get centerY(){return this.center.y}set centerY(e){this.center.y=e}get kernelSize(){return this._kernelSize}set kernelSize(e){this._kernelSize=e,this._updateKernelSize()}get radius(){return this.uniforms.uRadius}set radius(e){this.uniforms.uRadius=e<0||e===1/0?-1:e}};Yt(Kt,"DEFAULT_OPTIONS",{angle:0,center:{x:0,y:0},kernelSize:5,radius:-1});let Wt=Kt;var qt=Object.defineProperty,Ht=Object.getOwnPropertySymbols,Zt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,$t=(e,n,r)=>n in e?qt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Jt=(e,n)=>{for(var r in n||(n={}))Zt.call(n,r)&&$t(e,r,n[r]);if(Ht)for(var r of Ht(n))Qt.call(n,r)&&$t(e,r,n[r]);return e},eo=(e,n,r)=>($t(e,"symbol"!=typeof n?n+"":n,r),r);const no=class e extends n.Filter{constructor(o){o=Jt(Jt({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct ReflectionUniforms {\n uMirror: f32,\n uBoundary: f32,\n uAmplitude: vec2<f32>,\n uWavelength: vec2<f32>,\n uAlpha: vec2<f32>,\n uTime: f32,\n uDimensions: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> reflectionUniforms : ReflectionUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uDimensions: vec2<f32> = reflectionUniforms.uDimensions;\n let uBoundary: f32 = reflectionUniforms.uBoundary;\n let uMirror: bool = reflectionUniforms.uMirror > 0.5;\n let uAmplitude: vec2<f32> = reflectionUniforms.uAmplitude;\n let uWavelength: vec2<f32> = reflectionUniforms.uWavelength;\n let uAlpha: vec2<f32> = reflectionUniforms.uAlpha;\n let uTime: f32 = reflectionUniforms.uTime;\n\n let pixelCoord: vec2<f32> = uv * gfu.uInputSize.xy;\n let coord: vec2<f32> = pixelCoord /uDimensions;\n var returnColorOnly: bool = false;\n\n if (coord.y < uBoundary) {\n returnColorOnly = true;\n }\n\n let k: f32 = (coord.y - uBoundary) / (1. - uBoundary + 0.0001);\n let areaY: f32 = uBoundary * uDimensions.y / gfu.uInputSize.y;\n let v: f32 = areaY + areaY - uv.y;\n let y: f32 = select(uv.y, v, uMirror);\n\n let amplitude: f32 = ((uAmplitude.y - uAmplitude.x) * k + uAmplitude.x ) / gfu.uInputSize.x;\n let waveLength: f32 = ((uWavelength.y - uWavelength.x) * k + uWavelength.x) / gfu.uInputSize.y;\n let alpha: f32 = select((uAlpha.y - uAlpha.x) * k + uAlpha.x, 1., returnColorOnly);\n\n var x: f32 = uv.x + cos(v * 6.28 / waveLength - uTime) * amplitude;\n x = clamp(x, gfu.uInputClamp.x, gfu.uInputClamp.z);\n \n return textureSample(uTexture, uSampler, select(vec2<f32>(x, y), uv, returnColorOnly)) * alpha;\n}\n\nfn rand(co: vec2<f32>) -> f32 \n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uMirror;\nuniform float uBoundary;\nuniform vec2 uAmplitude;\nuniform vec2 uWavelength;\nuniform vec2 uAlpha;\nuniform float uTime;\nuniform vec2 uDimensions;\n\nuniform vec4 uInputSize;\nuniform vec4 uInputClamp;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * uInputSize.xy;\n vec2 coord = pixelCoord / uDimensions;\n\n if (coord.y < uBoundary) {\n finalColor = texture(uTexture, vTextureCoord);\n return;\n }\n\n float k = (coord.y - uBoundary) / (1. - uBoundary + 0.0001);\n float areaY = uBoundary * uDimensions.y / uInputSize.y;\n float v = areaY + areaY - vTextureCoord.y;\n float y = uMirror > 0.5 ? v : vTextureCoord.y;\n\n float _amplitude = ((uAmplitude.y - uAmplitude.x) * k + uAmplitude.x ) / uInputSize.x;\n float _waveLength = ((uWavelength.y - uWavelength.x) * k + uWavelength.x) / uInputSize.y;\n float _alpha = (uAlpha.y - uAlpha.x) * k + uAlpha.x;\n\n float x = vTextureCoord.x + cos(v * 6.28 / _waveLength - uTime) * _amplitude;\n x = clamp(x, uInputClamp.x, uInputClamp.z);\n\n vec4 color = texture(uTexture, vec2(x, y));\n\n finalColor = color * _alpha;\n}\n",name:"reflection-filter"}),resources:{reflectionUniforms:{uMirror:{value:o.mirror?1:0,type:"f32"},uBoundary:{value:o.boundary,type:"f32"},uAmplitude:{value:o.amplitude,type:"vec2<f32>"},uWavelength:{value:o.waveLength,type:"vec2<f32>"},uAlpha:{value:o.alpha,type:"vec2<f32>"},uTime:{value:o.time,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}}}}),eo(this,"uniforms"),eo(this,"time",0),this.uniforms=this.resources.reflectionUniforms.uniforms,Object.assign(this,o)}apply(e,n,r,t){this.uniforms.uDimensions[0]=n.frame.width,this.uniforms.uDimensions[1]=n.frame.height,this.uniforms.uTime=this.time,e.applyFilter(this,n,r,t)}get mirror(){return this.uniforms.uMirror>.5}set mirror(e){this.uniforms.uMirror=e?1:0}get boundary(){return this.uniforms.uBoundary}set boundary(e){this.uniforms.uBoundary=e}get amplitude(){return Array.from(this.uniforms.uAmplitude)}set amplitude(e){this.uniforms.uAmplitude[0]=e[0],this.uniforms.uAmplitude[1]=e[1]}get amplitudeStart(){return this.uniforms.uAmplitude[0]}set amplitudeStart(e){this.uniforms.uAmplitude[0]=e}get amplitudeEnd(){return this.uniforms.uAmplitude[1]}set amplitudeEnd(e){this.uniforms.uAmplitude[1]=e}get waveLength(){return Array.from(this.uniforms.uWavelength)}set waveLength(e){this.uniforms.uWavelength[0]=e[0],this.uniforms.uWavelength[1]=e[1]}get wavelengthStart(){return this.uniforms.uWavelength[0]}set wavelengthStart(e){this.uniforms.uWavelength[0]=e}get wavelengthEnd(){return this.uniforms.uWavelength[1]}set wavelengthEnd(e){this.uniforms.uWavelength[1]=e}get alpha(){return Array.from(this.uniforms.uAlpha)}set alpha(e){this.uniforms.uAlpha[0]=e[0],this.uniforms.uAlpha[1]=e[1]}get alphaStart(){return this.uniforms.uAlpha[0]}set alphaStart(e){this.uniforms.uAlpha[0]=e}get alphaEnd(){return this.uniforms.uAlpha[1]}set alphaEnd(e){this.uniforms.uAlpha[1]=e}};eo(no,"DEFAULT_OPTIONS",{mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0});let ro=no;var to=Object.defineProperty,oo=Object.getOwnPropertySymbols,io=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,lo=(e,n,r)=>n in e?to(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,ao=(e,n)=>{for(var r in n||(n={}))io.call(n,r)&&lo(e,r,n[r]);if(oo)for(var r of oo(n))uo.call(n,r)&&lo(e,r,n[r]);return e},so=(e,n,r)=>(lo(e,"symbol"!=typeof n?n+"":n,r),r);const fo=class e extends n.Filter{constructor(...o){var i;let u=null!=(i=o[0])?i:{};(Array.isArray(u)||"x"in u&&"y"in u)&&(n.deprecation("6.0.0","RGBSplitFilter constructor params are now options object. See params: { red, green, blue }"),u={red:u},void 0!==o[1]&&(u.green=o[1]),void 0!==o[2]&&(u.blue=o[2])),u=ao(ao({},e.DEFAULT_OPTIONS),u);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct RgbSplitUniforms {\n uRed: vec2<f32>,\n uGreen: vec2<f32>,\n uBlue: vec3<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> rgbSplitUniforms : RgbSplitUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let r = textureSample(uTexture, uSampler, uv + vec2<f32>(rgbSplitUniforms.uRed.x / gfu.uInputSize.x, rgbSplitUniforms.uRed.y / gfu.uInputSize.y)).r;\n let g = textureSample(uTexture, uSampler, uv + vec2<f32>(rgbSplitUniforms.uGreen.x / gfu.uInputSize.x, rgbSplitUniforms.uGreen.y / gfu.uInputSize.y)).g;\n let b = textureSample(uTexture, uSampler, uv + vec2<f32>(rgbSplitUniforms.uBlue.x / gfu.uInputSize.x, rgbSplitUniforms.uBlue.y / gfu.uInputSize.y)).b;\n let a = textureSample(uTexture, uSampler, uv).a;\n return vec4<f32>(r, g, b, a);\n}\n",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec4 uInputSize;\nuniform vec2 uRed;\nuniform vec2 uGreen;\nuniform vec2 uBlue;\n\nvoid main(void)\n{\n float r = texture(uTexture, vTextureCoord + uRed/uInputSize.xy).r;\n float g = texture(uTexture, vTextureCoord + uGreen/uInputSize.xy).g;\n float b = texture(uTexture, vTextureCoord + uBlue/uInputSize.xy).b;\n float a = texture(uTexture, vTextureCoord).a;\n finalColor = vec4(r, g, b, a);\n}\n",name:"rgb-split-filter"}),resources:{rgbSplitUniforms:{uRed:{value:u.red,type:"vec2<f32>"},uGreen:{value:u.green,type:"vec2<f32>"},uBlue:{value:u.blue,type:"vec2<f32>"}}}}),so(this,"uniforms"),this.uniforms=this.resources.rgbSplitUniforms.uniforms,Object.assign(this,u)}get red(){return this.uniforms.uRed}set red(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uRed=e}get redX(){return this.red.x}set redX(e){this.red.x=e}get redY(){return this.red.y}set redY(e){this.red.y=e}get green(){return this.uniforms.uGreen}set green(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uGreen=e}get greenX(){return this.green.x}set greenX(e){this.green.x=e}get greenY(){return this.green.y}set greenY(e){this.green.y=e}get blue(){return this.uniforms.uBlue}set blue(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uBlue=e}get blueX(){return this.blue.x}set blueX(e){this.blue.x=e}get blueY(){return this.blue.y}set blueY(e){this.blue.y=e}};so(fo,"DEFAULT_OPTIONS",{red:{x:-10,y:0},green:{x:0,y:10},blue:{x:0,y:0}});let co=fo;var mo=Object.defineProperty,po=Object.getOwnPropertySymbols,vo=Object.prototype.hasOwnProperty,go=Object.prototype.propertyIsEnumerable,ho=(e,n,r)=>n in e?mo(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,xo=(e,n)=>{for(var r in n||(n={}))vo.call(n,r)&&ho(e,r,n[r]);if(po)for(var r of po(n))go.call(n,r)&&ho(e,r,n[r]);return e},yo=(e,n,r)=>(ho(e,"symbol"!=typeof n?n+"":n,r),r);const So=class e extends n.Filter{constructor(...o){var i;let u=null!=(i=o[0])?i:{};(Array.isArray(u)||"x"in u&&"y"in u)&&(n.deprecation("6.0.0","ShockwaveFilter constructor params are now options object. See params: { center, speed, amplitude, wavelength, brightness, radius, time }"),u=xo({center:u},o[1]),void 0!==o[2]&&(u.time=o[2])),u=xo(xo({},e.DEFAULT_OPTIONS),u);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"\nstruct ShockWaveUniforms {\n uTime: f32,\n uOffset: vec2<f32>,\n uSpeed: f32,\n uWave: vec4<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> shockwaveUniforms : ShockWaveUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n\n let uTime = shockwaveUniforms.uTime;\n let uOffset = shockwaveUniforms.uOffset;\n let uSpeed = shockwaveUniforms.uSpeed;\n let uAmplitude = shockwaveUniforms.uWave[0];\n let uWavelength = shockwaveUniforms.uWave[1];\n let uBrightness = shockwaveUniforms.uWave[2];\n let uRadius = shockwaveUniforms.uWave[3];\n let halfWavelength: f32 = uWavelength * 0.5 / gfu.uInputSize.x;\n let maxRadius: f32 = uRadius / gfu.uInputSize.x;\n let currentRadius: f32 = uTime * uSpeed / gfu.uInputSize.x;\n var fade: f32 = 1.0;\n var returnColorOnly: bool = false;\n \n if (maxRadius > 0.0) {\n if (currentRadius > maxRadius) {\n returnColorOnly = true;\n }\n fade = 1.0 - pow(currentRadius / maxRadius, 2.0);\n }\n var dir: vec2<f32> = vec2<f32>(uv - uOffset / gfu.uInputSize.xy);\n dir.y *= gfu.uInputSize.y / gfu.uInputSize.x;\n\n let dist:f32 = length(dir);\n\n if (dist <= 0.0 || dist < currentRadius - halfWavelength || dist > currentRadius + halfWavelength) {\n returnColorOnly = true;\n }\n\n let diffUV: vec2<f32> = normalize(dir);\n let diff: f32 = (dist - currentRadius) / halfWavelength;\n let p: f32 = 1.0 - pow(abs(diff), 2.0);\n let powDiff: f32 = 1.25 * sin(diff * PI) * p * ( uAmplitude * fade );\n let offset: vec2<f32> = diffUV * powDiff / gfu.uInputSize.xy;\n // Do clamp :\n let coord: vec2<f32> = uv + offset;\n let clampedCoord: vec2<f32> = clamp(coord, gfu.uInputClamp.xy, gfu.uInputClamp.zw);\n\n var clampedColor: vec4<f32> = textureSample(uTexture, uSampler, clampedCoord);\n \n if (boolVec2(coord, clampedCoord)) \n {\n clampedColor *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n // No clamp :\n var finalColor = clampedColor;\n\n return select(finalColor, textureSample(uTexture, uSampler, uv), returnColorOnly);\n}\n\nfn boolVec2(x: vec2<f32>, y: vec2<f32>) -> bool\n{\n if (x.x == y.x && x.y == y.y)\n {\n return true;\n }\n \n return false;\n}\n\nconst PI: f32 = 3.14159265358979323846264;\n",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"\nprecision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uCenter;\nuniform float uTime;\nuniform float uSpeed;\nuniform vec4 uWave;\n\nuniform vec4 uInputSize;\nuniform vec4 uInputClamp;\n\nconst float PI = 3.14159;\n\nvoid main()\n{\n float uAmplitude = uWave[0];\n float uWavelength = uWave[1];\n float uBrightness = uWave[2];\n float uRadius = uWave[3];\n\n float halfWavelength = uWavelength * 0.5 / uInputSize.x;\n float maxRadius = uRadius / uInputSize.x;\n float currentRadius = uTime * uSpeed / uInputSize.x;\n\n float fade = 1.0;\n\n if (maxRadius > 0.0) {\n if (currentRadius > maxRadius) {\n finalColor = texture(uTexture, vTextureCoord);\n return;\n }\n fade = 1.0 - pow(currentRadius / maxRadius, 2.0);\n }\n\n vec2 dir = vec2(vTextureCoord - uCenter / uInputSize.xy);\n dir.y *= uInputSize.y / uInputSize.x;\n float dist = length(dir);\n\n if (dist <= 0.0 || dist < currentRadius - halfWavelength || dist > currentRadius + halfWavelength) {\n finalColor = texture(uTexture, vTextureCoord);\n return;\n }\n\n vec2 diffUV = normalize(dir);\n\n float diff = (dist - currentRadius) / halfWavelength;\n\n float p = 1.0 - pow(abs(diff), 2.0);\n\n // float powDiff = diff * pow(p, 2.0) * ( amplitude * fade );\n float powDiff = 1.25 * sin(diff * PI) * p * ( uAmplitude * fade );\n\n vec2 offset = diffUV * powDiff / uInputSize.xy;\n\n // Do clamp :\n vec2 coord = vTextureCoord + offset;\n vec2 clampedCoord = clamp(coord, uInputClamp.xy, uInputClamp.zw);\n vec4 color = texture(uTexture, clampedCoord);\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n // No clamp :\n // finalColor = texture(uTexture, vTextureCoord + offset);\n\n color.rgb *= 1.0 + (uBrightness - 1.0) * p * fade;\n\n finalColor = color;\n}\n",name:"shockwave-filter"}),resources:{shockwaveUniforms:{uTime:{value:u.time,type:"f32"},uCenter:{value:u.center,type:"vec2<f32>"},uSpeed:{value:u.speed,type:"f32"},uWave:{value:new Float32Array(4),type:"vec4<f32>"}}}}),yo(this,"uniforms"),yo(this,"time"),this.time=0,this.uniforms=this.resources.shockwaveUniforms.uniforms,Object.assign(this,u)}apply(e,n,r,t){this.uniforms.uTime=this.time,e.applyFilter(this,n,r,t)}get center(){return this.uniforms.uCenter}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.uniforms.uCenter.x}set centerX(e){this.uniforms.uCenter.x=e}get centerY(){return this.uniforms.uCenter.y}set centerY(e){this.uniforms.uCenter.y=e}get speed(){return this.uniforms.uSpeed}set speed(e){this.uniforms.uSpeed=e}get amplitude(){return this.uniforms.uWave[0]}set amplitude(e){this.uniforms.uWave[0]=e}get wavelength(){return this.uniforms.uWave[1]}set wavelength(e){this.uniforms.uWave[1]=e}get brightness(){return this.uniforms.uWave[2]}set brightness(e){this.uniforms.uWave[2]=e}get radius(){return this.uniforms.uWave[3]}set radius(e){this.uniforms.uWave[3]=e}};yo(So,"DEFAULT_OPTIONS",{center:{x:0,y:0},speed:500,amplitude:30,wavelength:160,brightness:1,radius:-1});let bo=So;var Co=Object.defineProperty,To=Object.getOwnPropertySymbols,Po=Object.prototype.hasOwnProperty,zo=Object.prototype.propertyIsEnumerable,Oo=(e,n,r)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,_o=(e,n)=>{for(var r in n||(n={}))Po.call(n,r)&&Oo(e,r,n[r]);if(To)for(var r of To(n))zo.call(n,r)&&Oo(e,r,n[r]);return e},Ao=(e,n,r)=>(Oo(e,"symbol"!=typeof n?n+"":n,r),r);const Fo=class e extends n.Filter{constructor(...o){var i,u;let l=null!=(i=o[0])?i:{};if(l instanceof n.Texture&&(n.deprecation("6.0.0","SimpleLightmapFilter constructor params are now options object. See params: { lightMap, color, alpha }"),l={lightMap:l},void 0!==o[1]&&(l.color=o[1]),void 0!==o[2]&&(l.alpha=o[2])),l=_o(_o({},e.DEFAULT_OPTIONS),l),!l.lightMap)throw Error("No light map texture source was provided to SimpleLightmapFilter");super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct SimpleLightmapUniforms {\n uColor: vec3<f32>,\n uAlpha: f32,\n uDimensions: vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> simpleLightmapUniforms : SimpleLightmapUniforms;\n@group(1) @binding(1) var uMapTexture: texture_2d<f32>;\n@group(1) @binding(2) var uMapSampler: sampler;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n) -> @location(0) vec4<f32> {\n let uColor = simpleLightmapUniforms.uColor;\n let uAlpha = simpleLightmapUniforms.uAlpha;\n let uDimensions = simpleLightmapUniforms.uDimensions;\n\n let diffuseColor: vec4<f32> = textureSample(uTexture, uSampler, uv);\n let lightCoord: vec2<f32> = (uv * gfu.uInputSize.xy) / simpleLightmapUniforms.uDimensions;\n let light: vec4<f32> = textureSample(uMapTexture, uMapSampler, lightCoord);\n let ambient: vec3<f32> = uColor * uAlpha;\n let intensity: vec3<f32> = ambient + light.rgb;\n let finalColor: vec3<f32> = diffuseColor.rgb * intensity;\n return vec4<f32>(finalColor, diffuseColor.a);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMapTexture;\nuniform vec3 uColor;\nuniform float uAlpha;\nuniform vec2 uDimensions;\n\nuniform vec4 uInputSize;\n\nvoid main() {\n vec4 diffuseColor = texture(uTexture, vTextureCoord);\n vec2 lightCoord = (vTextureCoord * uInputSize.xy) / uDimensions;\n vec4 light = texture(uMapTexture, lightCoord);\n vec3 ambient = uColor.rgb * uAlpha;\n vec3 intensity = ambient + light.rgb;\n vec3 color = diffuseColor.rgb * intensity;\n finalColor = vec4(color, diffuseColor.a);\n}\n",name:"simple-lightmap-filter"}),resources:{simpleLightmapUniforms:{uColor:{value:new Float32Array(3),type:"vec3<f32>"},uAlpha:{value:l.alpha,type:"f32"},uDimensions:{value:new Float32Array(2),type:"vec2<f32>"}},uMapTexture:l.lightMap.source,uMapSampler:l.lightMap.source.style}}),Ao(this,"uniforms"),Ao(this,"_color"),Ao(this,"_lightMap"),this.uniforms=this.resources.simpleLightmapUniforms.uniforms,this._color=new n.Color,this.color=null!=(u=l.color)?u:0,Object.assign(this,l)}apply(e,n,r,t){this.uniforms.uDimensions[0]=n.frame.width,this.uniforms.uDimensions[1]=n.frame.height,e.applyFilter(this,n,r,t)}get lightMap(){return this._lightMap}set lightMap(e){this._lightMap=e,this.resources.uMapTexture=e.source,this.resources.uMapSampler=e.source.style}get color(){return this._color.value}set color(e){this._color.setValue(e);const[n,r,t]=this._color.toArray();this.uniforms.uColor[0]=n,this.uniforms.uColor[1]=r,this.uniforms.uColor[2]=t}get alpha(){return this.uniforms.uAlpha}set alpha(e){this.uniforms.uAlpha=e}};Ao(Fo,"DEFAULT_OPTIONS",{lightMap:n.Texture.WHITE,color:0,alpha:1});let wo=Fo;var Io=Object.defineProperty,Uo=Object.getOwnPropertySymbols,Ro=Object.prototype.hasOwnProperty,Do=Object.prototype.propertyIsEnumerable,Mo=(e,n,r)=>n in e?Io(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Go=(e,n)=>{for(var r in n||(n={}))Ro.call(n,r)&&Mo(e,r,n[r]);if(Uo)for(var r of Uo(n))Do.call(n,r)&&Mo(e,r,n[r]);return e},Eo=(e,n,r)=>(Mo(e,"symbol"!=typeof n?n+"":n,r),r);const Lo=class e extends n.Filter{constructor(o){var i,u;o=Go(Go({},e.DEFAULT_OPTIONS),o);super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct TiltShiftUniforms {\n uBlur: vec2<f32>,\n uStart: vec2<f32>,\n uEnd: vec2<f32>,\n uDelta: vec2<f32>,\n uTexSize: vec2<f32>,\n};\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> tiltShiftUniforms : TiltShiftUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uBlur = tiltShiftUniforms.uBlur[0];\n let uBlurGradient = tiltShiftUniforms.uBlur[1];\n let uStart = tiltShiftUniforms.uStart;\n let uEnd = tiltShiftUniforms.uEnd;\n let uDelta = tiltShiftUniforms.uDelta;\n let uTexSize = tiltShiftUniforms.uTexSize;\n\n var color: vec4<f32> = vec4<f32>(0.0);\n var total: f32 = 0.0;\n\n let offset: f32 = random(position, vec3<f32>(12.9898, 78.233, 151.7182), 0.0);\n let normal: vec2<f32> = normalize(vec2<f32>(uStart.y - uEnd.y, uEnd.x - uStart.x));\n let radius: f32 = smoothstep(0.0, 1.0, abs(dot(uv * uTexSize - uStart, normal)) / uBlurGradient) * uBlur;\n\n for (var t: f32 = -30.0; t <= 30.0; t += 1.0)\n {\n var percent: f32 = (t + offset - 0.5) / 30.0;\n var weight: f32 = 1.0 - abs(percent);\n var sample: vec4<f32> = textureSample(uTexture, uSampler, uv + uDelta / uTexSize * percent * radius);\n sample = vec4<f32>(sample.xyz * sample.a, sample.a); // multiply sample.rgb with sample.a\n color += sample * weight;\n total += weight;\n }\n\n color /= total;\n color = vec4<f32>(color.xyz / (color.a + 0.00001), color.a); // divide color.rgb by color.a + 0.00001\n\n return color;\n}\n\n\nfn random(position: vec4<f32>, scale: vec3<f32>, seed: f32) -> f32\n{\n return fract(sin(dot(position.xyz + seed, scale)) * 43758.5453 + seed);\n}",entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uBlur;\nuniform vec2 uStart;\nuniform vec2 uEnd;\nuniform vec2 uDelta;\nuniform vec2 uTexSize;\n\nfloat random(vec3 scale, float seed)\n{\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n float blur = uBlur[0];\n float gradientBlur = uBlur[1];\n\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(uStart.y - uEnd.y, uEnd.x - uStart.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * uTexSize - uStart, normal)) / gradientBlur) * blur;\n\n for (float t = -30.0; t <= 30.0; t++)\n {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 sample = texture(uTexture, vTextureCoord + uDelta / uTexSize * percent * radius);\n sample.rgb *= sample.a;\n color += sample * weight;\n total += weight;\n }\n\n color /= total;\n color.rgb /= color.a + 0.00001;\n\n finalColor = color;\n}\n",name:"tilt-shift-axis-filter"}),resources:{tiltShiftUniforms:{uBlur:{value:new Float32Array([null!=(i=o.blur)?i:100,null!=(u=o.gradientBlur)?u:600]),type:"vec2<f32>"},uStart:{value:o.start,type:"vec2<f32>"},uEnd:{value:o.end,type:"vec2<f32>"},uDelta:{value:new Float32Array([30,30]),type:"vec2<f32>"},uTexSize:{value:new Float32Array([window.innerWidth,window.innerHeight]),type:"vec2<f32>"}}}}),Eo(this,"uniforms"),Eo(this,"_tiltAxis"),this.uniforms=this.resources.tiltShiftUniforms.uniforms,this._tiltAxis=o.axis,this.updateDelta()}updateDelta(){if(this.uniforms.uDelta[0]=0,this.uniforms.uDelta[1]=0,void 0===this._tiltAxis)return;const e=this.uniforms.uEnd,n=this.uniforms.uStart,r=e.x-n.x,t=e.y-n.y,o=Math.sqrt(r*r+t*t),i="vertical"===this._tiltAxis;this.uniforms.uDelta[0]=i?-t/o:r/o,this.uniforms.uDelta[1]=i?r/o:t/o}};Eo(Lo,"DEFAULT_OPTIONS",{blur:100,gradientBlur:600,start:{x:0,y:window.innerHeight/2},end:{x:600,y:window.innerHeight/2}});let ko=Lo;var jo=Object.defineProperty,Bo=Object.defineProperties,No=Object.getOwnPropertyDescriptors,Vo=Object.getOwnPropertySymbols,Xo=Object.prototype.hasOwnProperty,Yo=Object.prototype.propertyIsEnumerable,Ko=(e,n,r)=>n in e?jo(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,Wo=(e,n)=>{for(var r in n||(n={}))Xo.call(n,r)&&Ko(e,r,n[r]);if(Vo)for(var r of Vo(n))Yo.call(n,r)&&Ko(e,r,n[r]);return e},qo=(e,n)=>Bo(e,No(n));var Ho=Object.defineProperty,Zo=Object.getOwnPropertySymbols,Qo=Object.prototype.hasOwnProperty,$o=Object.prototype.propertyIsEnumerable,Jo=(e,n,r)=>n in e?Ho(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,ei=(e,n)=>{for(var r in n||(n={}))Qo.call(n,r)&&Jo(e,r,n[r]);if(Zo)for(var r of Zo(n))$o.call(n,r)&&Jo(e,r,n[r]);return e},ni=(e,n,r)=>(Jo(e,"symbol"!=typeof n?n+"":n,r),r);const ri=class e extends n.Filter{constructor(o){var i,u;o=ei(ei({},e.DEFAULT_OPTIONS),o);const l=n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:"struct TwistUniforms {\n uTwist:vec2<f32>,\n uOffset:vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> twistUniforms : TwistUniforms;\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, unmapCoord(twist(mapCoord(uv))));\n}\n\nfn mapCoord(coord: vec2<f32> ) -> vec2<f32>\n{\n var mappedCoord: vec2<f32> = coord;\n mappedCoord *= gfu.uInputSize.xy;\n mappedCoord += gfu.uOutputFrame.xy;\n return mappedCoord;\n}\n\nfn unmapCoord(coord: vec2<f32> ) -> vec2<f32>\n{\n var mappedCoord: vec2<f32> = coord;\n mappedCoord -= gfu.uOutputFrame.xy;\n mappedCoord /= gfu.uInputSize.xy;\n return mappedCoord;\n}\n\nfn twist(coord: vec2<f32>) -> vec2<f32>\n{\n var twistedCoord: vec2<f32> = coord;\n let uRadius = twistUniforms.uTwist[0];\n let uAngle = twistUniforms.uTwist[1];\n let uOffset = twistUniforms.uOffset;\n\n twistedCoord -= uOffset;\n \n let dist = length(twistedCoord);\n\n if (dist < uRadius)\n {\n let ratioDist: f32 = (uRadius - dist) / uRadius;\n let angleMod: f32 = ratioDist * ratioDist * uAngle;\n let s: f32 = sin(angleMod);\n let c: f32 = cos(angleMod);\n twistedCoord = vec2<f32>(twistedCoord.x * c - twistedCoord.y * s, twistedCoord.x * s + twistedCoord.y * c);\n }\n\n twistedCoord += uOffset;\n return twistedCoord;\n}\n",entryPoint:"mainFragment"}}),a=n.GlProgram.from({vertex:r,fragment:"precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform vec2 uTwist;\nuniform vec2 uOffset;\nuniform vec4 uInputSize;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= uInputSize.xy;\n coord += uInputSize.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= uInputSize.zw;\n coord /= uInputSize.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= uOffset;\n\n float dist = length(coord);\n float uRadius = uTwist[0];\n float uAngle = uTwist[1];\n\n if (dist < uRadius)\n {\n float ratioDist = (uRadius - dist) / uRadius;\n float angleMod = ratioDist * ratioDist * uAngle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += uOffset;\n\n return coord;\n}\n\nvoid main(void)\n{\n vec2 coord = mapCoord(vTextureCoord);\n coord = twist(coord);\n coord = unmapCoord(coord);\n finalColor = texture(uTexture, coord);\n}\n",name:"twist-filter"});super(ei({gpuProgram:l,glProgram:a,resources:{twistUniforms:{uTwist:{value:[null!=(i=o.radius)?i:0,null!=(u=o.angle)?u:0],type:"vec2<f32>"},uOffset:{value:o.offset,type:"vec2<f32>"}}}},o)),ni(this,"uniforms"),this.uniforms=this.resources.twistUniforms.uniforms}get radius(){return this.uniforms.uTwist[0]}set radius(e){this.uniforms.uTwist[0]=e}get angle(){return this.uniforms.uTwist[1]}set angle(e){this.uniforms.uTwist[1]=e}get offset(){return this.uniforms.uOffset}set offset(e){this.uniforms.uOffset=e}get offsetX(){return this.offset.x}set offsetX(e){this.offset.x=e}get offsetY(){return this.offset.y}set offsetY(e){this.offset.y=e}};ni(ri,"DEFAULT_OPTIONS",{padding:20,radius:200,angle:4,offset:{x:0,y:0}});let ti=ri;var oi="precision highp float;\nin vec2 vTextureCoord;\nout vec4 finalColor;\n\nuniform sampler2D uTexture;\nuniform float uStrength;\nuniform vec2 uCenter;\nuniform vec2 uRadii;\n\nuniform vec4 uInputSize;\n\nconst float MAX_KERNEL_SIZE = ${MAX_KERNEL_SIZE};\n\n// author: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand(vec2 co, float seed) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);\n return fract(sin(sn) * c + seed);\n}\n\nvoid main() {\n float minGradient = uRadii[0] * 0.3;\n float innerRadius = (uRadii[0] + minGradient * 0.5) / uInputSize.x;\n\n float gradient = uRadii[1] * 0.3;\n float radius = (uRadii[1] - gradient * 0.5) / uInputSize.x;\n\n float countLimit = MAX_KERNEL_SIZE;\n\n vec2 dir = vec2(uCenter.xy / uInputSize.xy - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * uInputSize.y / uInputSize.x));\n\n float strength = uStrength;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (radius >= 0.0 && dist > radius) { // radius < 0 means it's infinity\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / uInputSize.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture(uTexture, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = rand(vTextureCoord, 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {\n float percent = (t + offset) / MAX_KERNEL_SIZE;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture(uTexture, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n color /= total;\n // switch back from pre-multiplied alpha\n // color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n",ii="struct ZoomBlurUniforms {\n uStrength:f32,\n uCenter:vec2<f32>,\n uRadii:vec2<f32>,\n};\n\nstruct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n\n@group(0) @binding(1) var uTexture: texture_2d<f32>; \n@group(0) @binding(2) var uSampler: sampler;\n@group(1) @binding(0) var<uniform> zoomBlurUniforms : ZoomBlurUniforms;\n\n@fragment\nfn mainFragment(\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>\n) -> @location(0) vec4<f32> {\n let uStrength = zoomBlurUniforms.uStrength;\n let uCenter = zoomBlurUniforms.uCenter;\n let uRadii = zoomBlurUniforms.uRadii;\n\n let minGradient: f32 = uRadii[0] * 0.3;\n let innerRadius: f32 = (uRadii[0] + minGradient * 0.5) / gfu.uInputSize.x;\n\n let gradient: f32 = uRadii[1] * 0.3;\n let radius: f32 = (uRadii[1] - gradient * 0.5) / gfu.uInputSize.x;\n\n let MAX_KERNEL_SIZE: f32 = ${MAX_KERNEL_SIZE};\n\n var countLimit: f32 = MAX_KERNEL_SIZE;\n\n var dir: vec2<f32> = vec2<f32>(uCenter / gfu.uInputSize.xy - uv);\n let dist: f32 = length(vec2<f32>(dir.x, dir.y * gfu.uInputSize.y / gfu.uInputSize.x));\n\n var strength: f32 = uStrength;\n\n var delta: f32 = 0.0;\n var gap: f32;\n\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (radius >= 0.0 && dist > radius) { // radius < 0 means it's infinity\n delta = dist - radius;\n gap = gradient;\n }\n\n var returnColorOnly: bool = false;\n\n if (delta > 0.0) {\n let normalCount: f32 = gap / gfu.uInputSize.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n \n if (countLimit < 1.0)\n {\n returnColorOnly = true;;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n let offset: f32 = rand(uv, 0.0);\n\n var total: f32 = 0.0;\n var color: vec4<f32> = vec4<f32>(0.);\n\n dir *= strength;\n\n for (var t = 0.0; t < MAX_KERNEL_SIZE; t += 1.0) {\n let percent: f32 = (t + offset) / MAX_KERNEL_SIZE;\n let weight: f32 = 4.0 * (percent - percent * percent);\n let p: vec2<f32> = uv + dir * percent;\n let sample: vec4<f32> = textureSample(uTexture, uSampler, p);\n \n if (t < countLimit)\n {\n color += sample * weight;\n total += weight;\n }\n }\n\n color /= total;\n\n return select(color, textureSample(uTexture, uSampler, uv), returnColorOnly);\n}\n\nfn modulo(x: f32, y: f32) -> f32\n{\n return x - y * floor(x/y);\n}\n\n// author: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nfn rand(co: vec2<f32>, seed: f32) -> f32\n{\n let a: f32 = 12.9898;\n let b: f32 = 78.233;\n let c: f32 = 43758.5453;\n let dt: f32 = dot(co + seed, vec2<f32>(a, b));\n let sn: f32 = modulo(dt, 3.14159);\n return fract(sin(sn) * c + seed);\n}",ui=Object.defineProperty,li=Object.getOwnPropertySymbols,ai=Object.prototype.hasOwnProperty,si=Object.prototype.propertyIsEnumerable,fi=(e,n,r)=>n in e?ui(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,ci=(e,n)=>{for(var r in n||(n={}))ai.call(n,r)&&fi(e,r,n[r]);if(li)for(var r of li(n))si.call(n,r)&&fi(e,r,n[r]);return e},mi=(e,n,r)=>(fi(e,"symbol"!=typeof n?n+"":n,r),r);const pi=class e extends n.Filter{constructor(o){var i;const u=null!=(i=(o=ci(ci({},e.DEFAULT_OPTIONS),o)).maxKernelSize)?i:32;super({gpuProgram:n.GpuProgram.from({vertex:{source:t,entryPoint:"mainVertex"},fragment:{source:ii.replace("${MAX_KERNEL_SIZE}",u.toFixed(1)),entryPoint:"mainFragment"}}),glProgram:n.GlProgram.from({vertex:r,fragment:oi.replace("${MAX_KERNEL_SIZE}",u.toFixed(1)),name:"zoom-blur-filter"}),resources:{zoomBlurUniforms:{uStrength:{value:o.strength,type:"f32"},uCenter:{value:o.center,type:"vec2<f32>"},uRadii:{value:new Float32Array(2),type:"vec2<f32>"}}}}),mi(this,"uniforms"),this.uniforms=this.resources.zoomBlurUniforms.uniforms,Object.assign(this,o)}get strength(){return this.uniforms.uStrength}set strength(e){this.uniforms.uStrength=e}get center(){return this.uniforms.uCenter}set center(e){Array.isArray(e)&&(e={x:e[0],y:e[1]}),this.uniforms.uCenter=e}get centerX(){return this.uniforms.uCenter.x}set centerX(e){this.uniforms.uCenter.x=e}get centerY(){return this.uniforms.uCenter.y}set centerY(e){this.uniforms.uCenter.y=e}get innerRadius(){return this.uniforms.uRadii[0]}set innerRadius(e){this.uniforms.uRadii[0]=e}get radius(){return this.uniforms.uRadii[1]}set radius(e){this.uniforms.uRadii[1]=e<0||e===1/0?-1:e}};mi(pi,"DEFAULT_OPTIONS",{strength:.1,center:{x:0,y:0},innerRadius:0,radius:-1,maxKernelSize:32});let vi=pi;return e.AdjustmentFilter=m,e.AdvancedBloomFilter=k,e.AsciiFilter=q,e.BackdropBlurFilter=Q,e.BevelFilter=ue,e.BloomFilter=xe,e.BulgePinchFilter=_e,e.CRTFilter=Yn,e.ColorGradientFilter=$e,e.ColorMapFilter=an,e.ColorOverlayFilter=hn,e.ColorReplaceFilter=On,e.ConvolutionFilter=Mn,e.CrossHatchFilter=Gn,e.DotFilter=Jn,e.DropShadowFilter=ar,e.EmbossFilter=cr,e.GlitchFilter=br,e.GlowFilter=Ir,e.GodrayFilter=Nr,e.GrayscaleFilter=Vr,e.HslAdjustmentFilter=$r,e.KawaseBlurFilter=b,e.MotionBlurFilter=lt,e.MultiColorReplaceFilter=xt,e.OldFilmFilter=_t,e.OutlineFilter=Et,e.PixelateFilter=Lt,e.RGBSplitFilter=co,e.RadialBlurFilter=Wt,e.ReflectionFilter=ro,e.ShockwaveFilter=bo,e.SimpleLightmapFilter=wo,e.TiltShiftAxisFilter=ko,e.TiltShiftFilter=class extends ko{constructor(e){e=Wo(Wo({},ko.DEFAULT_OPTIONS),e),super(qo(Wo({},e),{axis:"horizontal"})),((e,n,r)=>{Ko(e,"symbol"!=typeof n?n+"":n,r)})(this,"_tiltShiftYFilter"),this._tiltShiftYFilter=new ko(qo(Wo({},e),{axis:"vertical"})),Object.assign(this,e)}apply(e,r,t,o){const i=n.TexturePool.getSameSizeTexture(r);e.applyFilter(this,r,i,!0),e.applyFilter(this._tiltShiftYFilter,i,t,o),n.TexturePool.returnTexture(i)}get blur(){return this.uniforms.uBlur[0]}set blur(e){this.uniforms.uBlur[0]=this._tiltShiftYFilter.uniforms.uBlur[0]=e}get gradientBlur(){return this.uniforms.uBlur[1]}set gradientBlur(e){this.uniforms.uBlur[1]=this._tiltShiftYFilter.uniforms.uBlur[1]=e}get start(){return this.uniforms.uStart}set start(e){this.uniforms.uStart=this._tiltShiftYFilter.uniforms.uStart=e}get startX(){return this.start.x}set startX(e){this.start.x=e}get startY(){return this.start.y}set startY(e){this.start.y=e}get end(){return this.uniforms.uEnd}set end(e){this.uniforms.uEnd=this._tiltShiftYFilter.uniforms.uEnd=e}get endX(){return this.end.x}set endX(e){this.end.x=e}get endY(){return this.end.y}set endY(e){this.end.y=e}},e.TwistFilter=ti,e.ZoomBlurFilter=vi,e.angleFromCssOrientation=ke,e.angleFromDirectionalValue=je,e.colorAsStringFromCssStop=Ge,e.offsetsFromCssColorStops=Ee,e.parseCssGradient=Re,e.stopsFromCssStops=Me,e.trimCssGradient=Be,e.typeFromCssType=De,e.vertex=r,e.wgslVertex=t,Object.defineProperty(e,"__esModule",{value:!0}),e}({},PIXI);
17
+ //# sourceMappingURL=/sm/251ad77e8b83f6cb4e357d59d9d84ac02d15a76f7213923559df9e86f4fdd476.map