const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/jxl-Bf8efzFI.js","chunks/imagedata-nux9wJ4s.js","chunks/transcode-CQf3sO1K.js","chunks/avif-8uBl4tmX.js"])))=>i.map(i=>d[i]);
import{t as e}from"./preload-helper-CggyeTPP.js";import{n as t,t as n,u as r}from"./transcode-CQf3sO1K.js";import{n as i,t as a}from"./license-LxoBP-L0.js";import{n as o,r as s}from"./voucher-4ZssGMfe.js";async function c(e,t={}){try{if(e.license&&(t.licensePublicKey?await i(e.license,t.licensePublicKey):await a(e.license)).valid)return!0;if(e.voucher){let t=await o(e.voucher);if(t&&s(t))return!0}return!1}catch{return!1}}function l(e){let t=e instanceof File?e.name:``;return e.type===`image/jxl`||/\.jxl$/i.test(t)}async function u(n){if(!l(n))return n;let{decodeJxl:r}=await e(async()=>{let{decodeJxl:e}=await import(`./jxl-Bf8efzFI.js`);return{decodeJxl:e}},__vite__mapDeps([0,1,2])),i=await r(n),a=t(i.width,i.height),o=new OffscreenCanvas(a.width,a.height),s=o.getContext(`2d`);if(!s)throw Error(`no 2d context for jxl decode`);if(!a.scaled)s.putImageData(i,0,0);else{let e=await createImageBitmap(i);try{s.drawImage(e,0,0,a.width,a.height)}finally{e.close()}}return o.convertToBlob({type:`image/png`})}async function d(t,i,a){if((r(i.target)||l(t))&&!await c(a??{}))throw Error(`pro_required`);let o=await u(t);if(r(i.target)){if(i.target===`image/avif`){let{encodeAvif:t}=await e(async()=>{let{encodeAvif:e}=await import(`./avif-8uBl4tmX.js`);return{encodeAvif:e}},__vite__mapDeps([3,1,2]));return{blob:await t(o,{quality:Math.round(i.quality*100)}),mime:`image/avif`,width:0,height:0,scaled:!1}}if(i.target===`image/jxl`){let{encodeJxl:t}=await e(async()=>{let{encodeJxl:e}=await import(`./jxl-Bf8efzFI.js`);return{encodeJxl:e}},__vite__mapDeps([0,1,2]));return{blob:await t(o,{quality:Math.round(i.quality*100)}),mime:`image/jxl`,width:0,height:0,scaled:!1}}throw Error(`unsupported pro target: ${i.target}`)}return n(o,{target:i.target,quality:i.quality,matte:i.matte,keepExif:i.keepExif})}export{d as t};