!function(t){var e={};function r(o){if(e[o])return e[o].exports;var a=e[o]={i:o,l:!1,exports:{}};return t[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(o,a,function(e){return t[e]}.bind(null,a));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){var o,a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,u={};((t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})})(u,{ValidationError:()=>p,decode:()=>w,encode:()=>x,isBlurhashValid:()=>b}),t.exports=(o=u,((t,e,r,o)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let u of l(e))!h.call(t,u)&&u!==r&&a(t,u,{get:()=>e[u],enumerable:!(o=n(e,u))||o.enumerable});return t})(a({},"__esModule",{value:!0}),o));var s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","#","$","%","*","+",",","-",".",":",";","=","?","@","[","]","^","_","{","|","}","~"],i=t=>{let e=0;for(let r=0;r<t.length;r++){let o=t[r];e=83*e+s.indexOf(o)}return e},f=(t,e)=>{var r="";for(let o=1;o<=e;o++){let a=Math.floor(t)/Math.pow(83,e-o)%83;r+=s[Math.floor(a)]}return r},c=t=>{let e=t/255;return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},M=t=>{let e=Math.max(0,Math.min(1,t));return e<=.0031308?Math.trunc(12.92*e*255+.5):Math.trunc(255*(1.055*Math.pow(e,.4166666666666667)-.055)+.5)},d=(t,e)=>(t=>t<0?-1:1)(t)*Math.pow(Math.abs(t),e),p=class extends Error{constructor(t){super(t),this.name="ValidationError",this.message=t}},m=t=>{if(!t||t.length<6)throw new p("The blurhash string must be at least 6 characters");let e=i(t[0]),r=Math.floor(e/9)+1,o=e%9+1;if(t.length!==4+2*o*r)throw new p(`blurhash length mismatch: length is ${t.length} but it should be ${4+2*o*r}`)},b=t=>{try{m(t)}catch(t){return{result:!1,errorReason:t.message}}return{result:!0}},g=t=>{let e=t>>8&255,r=255&t;return[c(t>>16),c(e),c(r)]},y=(t,e)=>{let r=Math.floor(t/361),o=Math.floor(t/19)%19,a=t%19;return[d((r-9)/9,2)*e,d((o-9)/9,2)*e,d((a-9)/9,2)*e]},w=(t,e,r,o)=>{m(t),o|=1;let a=i(t[0]),n=Math.floor(a/9)+1,l=a%9+1,h=(i(t[1])+1)/166,u=new Array(l*n);for(let e=0;e<u.length;e++)if(0===e){let r=i(t.substring(2,6));u[e]=g(r)}else{let r=i(t.substring(4+2*e,6+2*e));u[e]=y(r,h*o)}let s=4*e,f=new Uint8ClampedArray(s*r);for(let t=0;t<r;t++)for(let o=0;o<e;o++){let a=0,h=0,i=0;for(let s=0;s<n;s++)for(let n=0;n<l;n++){let f=Math.cos(Math.PI*o*n/e)*Math.cos(Math.PI*t*s/r),c=u[n+s*l];a+=c[0]*f,h+=c[1]*f,i+=c[2]*f}let c=M(a),d=M(h),p=M(i);f[4*o+0+t*s]=c,f[4*o+1+t*s]=d,f[4*o+2+t*s]=p,f[4*o+3+t*s]=255}return f},v=(t,e,r,o)=>{let a=0,n=0,l=0,h=4*e;for(let u=0;u<e;u++){let e=4*u;for(let s=0;s<r;s++){let r=e+s*h,i=o(u,s);a+=i*c(t[r]),n+=i*c(t[r+1]),l+=i*c(t[r+2])}}let u=1/(e*r);return[a*u,n*u,l*u]},x=(t,e,r,o,a)=>{if(o<1||o>9||a<1||a>9)throw new p("BlurHash must have between 1 and 9 components");if(e*r*4!==t.length)throw new p("Width and height must match the pixels array");let n=[];for(let l=0;l<a;l++)for(let a=0;a<o;a++){let o=0==a&&0==l?1:2,h=v(t,e,r,((t,n)=>o*Math.cos(Math.PI*a*t/e)*Math.cos(Math.PI*l*n/r)));n.push(h)}let l,h=n[0],u=n.slice(1),s="";if(s+=f(o-1+9*(a-1),1),u.length>0){let t=Math.max(...u.map((t=>Math.max(...t)))),e=Math.floor(Math.max(0,Math.min(82,Math.floor(166*t-.5))));l=(e+1)/166,s+=f(e,1)}else l=1,s+=f(0,1);return s+=f((t=>(M(t[0])<<16)+(M(t[1])<<8)+M(t[2]))(h),4),u.forEach((t=>{s+=f(((t,e)=>19*Math.floor(Math.max(0,Math.min(18,Math.floor(9*d(t[0]/e,.5)+9.5))))*19+19*Math.floor(Math.max(0,Math.min(18,Math.floor(9*d(t[1]/e,.5)+9.5))))+Math.floor(Math.max(0,Math.min(18,Math.floor(9*d(t[2]/e,.5)+9.5)))))(t,l),2)})),s}},function(t,e,r){"use strict";r.r(e);var o=r(0);const a=self;a.addEventListener("message",(t=>{const{seq:e,imageData:r}=t.data,n=Object(o.encode)(r.data,r.width,r.height,r.width>=r.height?4:3,r.height>=r.width?4:3);a.postMessage({seq:e,blurhash:n})}))}]);
//# sourceMappingURL=18a139a682b4f1258ea4.worker.js.map