/*! ImReso: Unlimited Target-Size Image Compressor — plugin code (c) ImageResizer.cc, GPLv2 or later. Bundled third-party code keeps its own licence: see licenses/ and readme.txt. */
import{b as u}from"./chunk-QZY7QCEA.js";import"./chunk-HWGPDIIB.js";var d={quality:50,qualityAlpha:-1,denoiseLevel:0,tileColsLog2:0,tileRowsLog2:0,speed:6,subsample:1,chromaDeltaQ:!1,sharpness:0,tune:0,enableSharpYUV:!1,bitDepth:8,lossless:!1};function r(t,s,e={}){let n;return s&&(n=(a,l)=>{let o=new WebAssembly.Instance(s,a);return l(o),o.exports}),t({noInitialRun:!0,instantiateWasm:n,...e})}var i,f=()=>typeof process<"u"&&process.release&&process.release.name==="node",p=()=>{var t;return((t=globalThis.caches)===null||t===void 0?void 0:t.default)!==void 0};async function c(t,s){let e=t,n=s;if(arguments.length===1&&!(t instanceof WebAssembly.Module)&&(e=void 0,n=t),!f()&&!p()&&await u()){let l=await import("./avif_enc_mt-C3UNE3D7.js");return i=r(l.default,e,n),i}let a=await import("./avif_enc-R66TJH7A.js");return i=r(a.default,e,n),i}async function h(t,s={}){i||(i=c());let e={...d,...s};if(e.bitDepth!==8&&e.bitDepth!==10&&e.bitDepth!==12)throw new Error("Invalid bit depth. Supported values are 8, 10, or 12.");if(!(t.data instanceof Uint16Array)&&e.bitDepth!==8)throw new Error("Invalid image data for bit depth. Must use Uint16Array for bit depths greater than 8.");e.lossless&&(s.quality!==void 0&&s.quality!==100&&console.warn("AVIF lossless: Quality setting is ignored when lossless is enabled (quality must be 100)."),s.qualityAlpha!==void 0&&s.qualityAlpha!==100&&s.qualityAlpha!==-1&&console.warn("AVIF lossless: QualityAlpha setting is ignored when lossless is enabled (qualityAlpha must be 100 or -1)."),s.subsample!==void 0&&s.subsample!==3&&console.warn("AVIF lossless: Subsample setting is ignored when lossless is enabled (subsample must be 3 for YUV444)."),e.quality=100,e.qualityAlpha=-1,e.subsample=3);let a=(await i).encode(new Uint8Array(t.data.buffer),t.width,t.height,e);if(!a)throw new Error("Encoding error.");return a.buffer}export{h as default,c as init};
