"use strict";var xr=Object.create;var x=Object.defineProperty;var Tr=Object.getOwnPropertyDescriptor;var wr=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty;var Cr=(r,e)=>{for(var t in e)x(r,t,{get:e[t],enumerable:!0})},A=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wr(e))!Er.call(r,s)&&s!==t&&x(r,s,{get:()=>e[s],enumerable:!(a=Tr(e,s))||a.enumerable});return r};var P=(r,e,t)=>(t=r!=null?xr(Ir(r)):{},A(e||!r||!r.__esModule?x(t,"default",{value:r,enumerable:!0}):t,r)),Pr=r=>A(x({},"__esModule",{value:!0}),r);var Mr={};Cr(Mr,{default:()=>Sr,image:()=>dr});module.exports=Pr(Mr);var L=P(require("validate"),1),U={include:"**/*.{heic,heif,avif,jpeg,jpg,png,tiff,webp,gif}?*",exclude:"",deliminator:",",transformers:[],default_exports:["src","aspect","width","height","format"]},z=["avif","dz","fits","gif","heif","input","jpeg","jpg","magick","openslide","pdf","png","ppm","raw","svg","tif","tiff","v","webp"],j=["b-w","histogram","xyz","lab","cmyk","labq","rgb","cmc","lch","labs","srgb","yxy","fourier","rgb16","grey16","matrix","scrgb","hsv"],S="/@image/",G=new RegExp(`^${S}([a-z0-9]{40})$`),T="__VITE_IMAGE_ASSET__",M=new RegExp(`${T}([a-z0-9]{8})`,"g"),D=new L.default({include:{type:String},exclude:{type:String},deliminator:{type:String},transformers:[{name:{type:String,required:!0},matcher:{type:Function,required:!0},transform:{type:Function,required:!0}}],default_exports:[{type:String}]},{strict:!0});var q=require("crypto"),I=require("path");var u=(r,e,t)=>Math.max(Math.min(r,t),e),B=r=>(0,q.createHash)("sha1").update(r).digest("hex"),X=r=>(0,I.basename)(r,(0,I.extname)(r)),w=r=>[...new Set(r)];function $(r,e){let t={},a=e.filter(s=>s in r);for(let s of a)t[s]=r[s];return t}function H(r){let e=Object.assign({...U},r),t=D.validate(e);if(t.length!==0)throw new AggregateError(t);return e}function V(r){return r===""||r==="true"?!0:r==="false"?!1:Number.isNaN(+r)?r:+r}function W(r,e){let t={};for(let o of w(r.keys())){let n=o.startsWith("!"),i=r.getAll(o).flatMap(l=>l.split(e)).map(l=>n?!V(l):V(l)),f=n?o.slice(1):o;t[f]??=[],t[f]=w(t[f].concat(i))}let a=Object.keys(t),s=Object.values(t);if(a.length===1)return s[0].map(o=>({[a[0]]:o}));let h=s.reduce((o,n)=>o.flatMap(i=>n.map(f=>[i,f].flat()))),m=[];for(let o of h){let n={};for(let i=0;itypeof r=="boolean",c=r=>typeof r=="number",g=r=>r===!0||c(r),E=(r,e)=>r.includes(e);var K={name:"format",matcher:r=>E(z,r.format),transform:(r,e)=>r.toFormat(e.format)};var Q={name:"resize",matcher:r=>c(r.width??r.height)&&(typeof r.width=="number"||typeof r.width>"u")&&(typeof r.height=="number"||typeof r.height>"u"),transform:(r,e)=>{let t=typeof e.width=="number"?Math.round(Math.max(e.width,1)):void 0,a=typeof e.height=="number"?Math.round(Math.max(e.height,1)):void 0;return r.resize(t,a,t&&a?{fit:"fill"}:void 0)}};var Y={name:"rotate",matcher:r=>c(r.rotate),transform:(r,e)=>r.rotate(e.rotate)};var Z={name:"flip",matcher:r=>p(r.flip),transform:(r,e)=>r.flip(e.flip)};var rr={name:"flop",matcher:r=>p(r.flop),transform:(r,e)=>r.flop(e.flop)};var er={name:"sharpen",matcher:r=>g(r.sharpen),transform:(r,e)=>e.sharpen===!0?r.sharpen():r.sharpen({sigma:u(e.sharpen,.01,1e4)})};var tr={name:"median",matcher:r=>g(r.median),transform:(r,e)=>e.median===!0?r.median():r.median(u(e.median,1,1e3))};var or={name:"blur",matcher:r=>g(r.blur),transform:(r,e)=>e.blur===!0?r.blur():r.blur(u(e.blur,.3,1e3))};var ar={name:"gamma",matcher:r=>g(r.gamma),transform:(r,e)=>e.gamma===!0?r.gamma():r.gamma(u(e.gamma,1,3))};var nr={name:"negate",matcher:r=>p(r.negate),transform:(r,e)=>r.negate(e.negate)};var sr={name:"normalize",matcher:r=>p(r.normalize),transform:(r,e)=>r.normalize(e.normalize)};var mr={name:"threshold",matcher:r=>c(r.threshold),transform:(r,e)=>r.threshold(u(e.threshold,0,255))};var ir={name:"modulate",matcher:r=>c(r.brightness??r.saturation??r.hue??r.lightness)&&(typeof r.brightness=="number"||typeof r.brightness>"u")&&(typeof r.saturation=="number"||typeof r.saturation>"u")&&(typeof r.hue=="number"||typeof r.hue>"u")&&(typeof r.lightness=="number"||typeof r.lightness>"u"),transform:(r,e)=>r.modulate({brightness:e.brightness??1,saturation:e.saturation??1,hue:e.hue??0,lightness:e.lightness??0})};var fr={name:"tint",matcher:r=>typeof r.tint=="string"&&r.tint.startsWith("#"),transform:(r,e)=>r.tint(e.tint)};var pr={name:"grayscale",matcher:r=>p(r.grayscale),transform:(r,e)=>r.grayscale(e.grayscale)};var ur={name:"colorspace",matcher:r=>E(j,r.colorspace),transform:(r,e)=>r.toColorspace(e.colorspace)};var lr={name:"metadata",matcher:r=>p(r.metadata),transform:(r,e)=>e.metadata?r.withMetadata():r};var cr=[K,Q,Y,Z,rr,er,tr,or,ar,nr,sr,mr,ir,fr,pr,ur,lr];var gr=require("vite"),hr=P(require("magic-string"),1),k=P(require("sharp"),1);function dr(r={}){let e=H(r),t=new Map,a=new Map,s=(0,gr.createFilter)(e.include,e.exclude),h;return{name:"image",enforce:"pre",configResolved(m){h=m},async load(m){if(!s(m))return null;let{searchParams:o,pathname:n}=new URL(m,"file:"),i=o.get("export")?.split(e.deliminator),f=w(i??e.default_exports);if(o.delete("export"),!t.has(n)){let d=await(0,k.default)(n).rotate().withMetadata().toBuffer().catch(this.error);t.set(n,(0,k.default)(d))}let l=t.get(n),C=[...e.transformers,...cr],y=[];for(let d of W(o,e.deliminator)){let _=n+JSON.stringify(d);if(a.has(_)){y.push(a.get(_).data);continue}let{image:R,queued_transformers:F,errors:O}=await J(l.clone(),d,C);if(O.errors.length!==0&&this.warn(O),F.length===0)continue;let{info:b,data:yr}=await R.toBuffer({resolveWithObject:!0}).catch(this.error),N=S+B(_);if(!this.meta.watchMode){let _r=`${X(n)}.${b.format}`,br=this.emitFile({name:_r,source:yr,type:"asset"});N=T+br}let v=Object.assign(b,{aspect:b.width/b.height,src:N,transformers:F});a.set(_,{image:R,data:v}),y.push(v)}return y.length===0?null:`export default ${JSON.stringify(y.map(d=>$(d,f)))}`},configureServer(m){m.middlewares.use((o,n,i)=>{if(!o.url)return i();let f=G.exec(o.url);if(!f?.[1])return i();let l=f[1];if(!a.has(l))return i();let{image:C}=a.get(l);return C.clone().pipe(n)})},renderChunk(m){if(!m.includes(T))return null;let o=(i,f)=>h.base+this.getFileName(f);if(!h.build.sourcemap)return{code:m.replace(M,o)};let n=new hr.default(m).replace(M,o);return{code:n.toString(),map:n.generateMap({hires:!0})}}}}var Sr=dr;0&&(module.exports={image});