1410 lines
44 KiB
JavaScript
1410 lines
44 KiB
JavaScript
import { t as typeHandlers, a as types, A as AstroError, N as NoImageMetadata, F as FailedToFetchRemoteImageDimensions, i as isRemoteAllowed, R as RemoteImageNotAllowed, j as joinPaths, E as ExpectedImage, b as isRemotePath, L as LocalImageUsedWrongly, M as MissingImageDimension, U as UnsupportedImageFormat, I as IncompatibleDescriptorOptions, c as UnsupportedImageConversion, d as InvalidImageService, e as ExpectedImageOptions, f as ExpectedNotESMImage, g as ImageMissingAlt, m as maybeRenderHead, h as addAttribute, s as spreadAttributes, r as renderTemplate, k as FontFamilyNotFound, u as unescapeHTML } from './entrypoint_CZ7e8met.mjs';
|
|
import { c as createComponent } from './astro-component_Dg_tJ-jn.mjs';
|
|
|
|
function isESMImportedImage(src) {
|
|
return typeof src === "object" || typeof src === "function" && "src" in src;
|
|
}
|
|
function isRemoteImage(src) {
|
|
return typeof src === "string";
|
|
}
|
|
async function resolveSrc(src) {
|
|
if (typeof src === "object" && "then" in src) {
|
|
const resource = await src;
|
|
return resource.default ?? resource;
|
|
}
|
|
return src;
|
|
}
|
|
|
|
const firstBytes = /* @__PURE__ */ new Map([
|
|
[0, "heif"],
|
|
[56, "psd"],
|
|
[66, "bmp"],
|
|
[68, "dds"],
|
|
[71, "gif"],
|
|
[73, "tiff"],
|
|
[77, "tiff"],
|
|
[82, "webp"],
|
|
[105, "icns"],
|
|
[137, "png"],
|
|
[255, "jpg"]
|
|
]);
|
|
function detector(input) {
|
|
const byte = input[0];
|
|
const type = firstBytes.get(byte);
|
|
if (type && typeHandlers.get(type).validate(input)) {
|
|
return type;
|
|
}
|
|
return types.find((imageType) => typeHandlers.get(imageType).validate(input));
|
|
}
|
|
|
|
function lookup$1(input) {
|
|
const type = detector(input);
|
|
if (typeof type !== "undefined") {
|
|
const size = typeHandlers.get(type).calculate(input);
|
|
if (size !== void 0) {
|
|
size.type = size.type ?? type;
|
|
return size;
|
|
}
|
|
}
|
|
throw new TypeError("unsupported file type: " + type);
|
|
}
|
|
|
|
async function imageMetadata(data, src) {
|
|
let result;
|
|
try {
|
|
result = lookup$1(data);
|
|
} catch {
|
|
throw new AstroError({
|
|
...NoImageMetadata,
|
|
message: NoImageMetadata.message(src)
|
|
});
|
|
}
|
|
if (!result.height || !result.width || !result.type) {
|
|
throw new AstroError({
|
|
...NoImageMetadata,
|
|
message: NoImageMetadata.message(src)
|
|
});
|
|
}
|
|
const { width, height, type, orientation } = result;
|
|
const isPortrait = (orientation || 0) >= 5;
|
|
return {
|
|
width: isPortrait ? height : width,
|
|
height: isPortrait ? width : height,
|
|
format: type,
|
|
orientation
|
|
};
|
|
}
|
|
|
|
async function inferRemoteSize(url, imageConfig) {
|
|
if (!URL.canParse(url)) {
|
|
throw new AstroError({
|
|
...FailedToFetchRemoteImageDimensions,
|
|
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
});
|
|
}
|
|
const allowlistConfig = imageConfig ? {
|
|
domains: imageConfig.domains ?? [],
|
|
remotePatterns: imageConfig.remotePatterns ?? []
|
|
} : void 0;
|
|
if (!allowlistConfig) {
|
|
const parsedUrl = new URL(url);
|
|
if (!["http:", "https:"].includes(parsedUrl.protocol)) {
|
|
throw new AstroError({
|
|
...FailedToFetchRemoteImageDimensions,
|
|
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
});
|
|
}
|
|
}
|
|
if (allowlistConfig && !isRemoteAllowed(url, allowlistConfig)) {
|
|
throw new AstroError({
|
|
...RemoteImageNotAllowed,
|
|
message: RemoteImageNotAllowed.message(url)
|
|
});
|
|
}
|
|
const response = await fetch(url, { redirect: "manual" });
|
|
if (response.status >= 300 && response.status < 400) {
|
|
throw new AstroError({
|
|
...FailedToFetchRemoteImageDimensions,
|
|
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
});
|
|
}
|
|
if (!response.body || !response.ok) {
|
|
throw new AstroError({
|
|
...FailedToFetchRemoteImageDimensions,
|
|
message: FailedToFetchRemoteImageDimensions.message(url)
|
|
});
|
|
}
|
|
const reader = response.body.getReader();
|
|
let done, value;
|
|
let accumulatedChunks = new Uint8Array();
|
|
while (!done) {
|
|
const readResult = await reader.read();
|
|
done = readResult.done;
|
|
if (done) break;
|
|
if (readResult.value) {
|
|
value = readResult.value;
|
|
let tmp = new Uint8Array(accumulatedChunks.length + value.length);
|
|
tmp.set(accumulatedChunks, 0);
|
|
tmp.set(value, accumulatedChunks.length);
|
|
accumulatedChunks = tmp;
|
|
try {
|
|
const dimensions = await imageMetadata(accumulatedChunks, url);
|
|
if (dimensions) {
|
|
await reader.cancel();
|
|
return dimensions;
|
|
}
|
|
} catch {
|
|
}
|
|
}
|
|
}
|
|
throw new AstroError({
|
|
...NoImageMetadata,
|
|
message: NoImageMetadata.message(url)
|
|
});
|
|
}
|
|
|
|
const VALID_SUPPORTED_FORMATS = [
|
|
"jpeg",
|
|
"jpg",
|
|
"png",
|
|
"tiff",
|
|
"webp",
|
|
"gif",
|
|
"svg",
|
|
"avif"
|
|
];
|
|
const DEFAULT_OUTPUT_FORMAT = "webp";
|
|
const DEFAULT_HASH_PROPS = [
|
|
"src",
|
|
"width",
|
|
"height",
|
|
"format",
|
|
"quality",
|
|
"fit",
|
|
"position",
|
|
"background"
|
|
];
|
|
|
|
const DEFAULT_RESOLUTIONS = [
|
|
640,
|
|
// older and lower-end phones
|
|
750,
|
|
// iPhone 6-8
|
|
828,
|
|
// iPhone XR/11
|
|
960,
|
|
// older horizontal phones
|
|
1080,
|
|
// iPhone 6-8 Plus
|
|
1280,
|
|
// 720p
|
|
1668,
|
|
// Various iPads
|
|
1920,
|
|
// 1080p
|
|
2048,
|
|
// QXGA
|
|
2560,
|
|
// WQXGA
|
|
3200,
|
|
// QHD+
|
|
3840,
|
|
// 4K
|
|
4480,
|
|
// 4.5K
|
|
5120,
|
|
// 5K
|
|
6016
|
|
// 6K
|
|
];
|
|
const LIMITED_RESOLUTIONS = [
|
|
640,
|
|
// older and lower-end phones
|
|
750,
|
|
// iPhone 6-8
|
|
828,
|
|
// iPhone XR/11
|
|
1080,
|
|
// iPhone 6-8 Plus
|
|
1280,
|
|
// 720p
|
|
1668,
|
|
// Various iPads
|
|
2048,
|
|
// QXGA
|
|
2560
|
|
// WQXGA
|
|
];
|
|
const getWidths = ({
|
|
width,
|
|
layout,
|
|
breakpoints = DEFAULT_RESOLUTIONS,
|
|
originalWidth
|
|
}) => {
|
|
const smallerThanOriginal = (w) => !originalWidth || w <= originalWidth;
|
|
if (layout === "full-width") {
|
|
return breakpoints.filter(smallerThanOriginal);
|
|
}
|
|
if (!width) {
|
|
return [];
|
|
}
|
|
const doubleWidth = width * 2;
|
|
const maxSize = originalWidth ? Math.min(doubleWidth, originalWidth) : doubleWidth;
|
|
if (layout === "fixed") {
|
|
return originalWidth && width > originalWidth ? [originalWidth] : [width, maxSize];
|
|
}
|
|
if (layout === "constrained") {
|
|
return [
|
|
// Always include the image at 1x and 2x the specified width
|
|
width,
|
|
doubleWidth,
|
|
...breakpoints
|
|
].filter((w) => w <= maxSize).sort((a, b) => a - b);
|
|
}
|
|
return [];
|
|
};
|
|
const getSizesAttribute = ({
|
|
width,
|
|
layout
|
|
}) => {
|
|
if (!width || !layout) {
|
|
return void 0;
|
|
}
|
|
switch (layout) {
|
|
// If screen is wider than the max size then image width is the max size,
|
|
// otherwise it's the width of the screen
|
|
case "constrained":
|
|
return `(min-width: ${width}px) ${width}px, 100vw`;
|
|
// Image is always the same width, whatever the size of the screen
|
|
case "fixed":
|
|
return `${width}px`;
|
|
// Image is always the width of the screen
|
|
case "full-width":
|
|
return `100vw`;
|
|
case "none":
|
|
default:
|
|
return void 0;
|
|
}
|
|
};
|
|
|
|
function isLocalService(service) {
|
|
if (!service) {
|
|
return false;
|
|
}
|
|
return "transform" in service;
|
|
}
|
|
function parseQuality(quality) {
|
|
let result = Number.parseInt(quality);
|
|
if (Number.isNaN(result)) {
|
|
return quality;
|
|
}
|
|
return result;
|
|
}
|
|
const sortNumeric = (a, b) => a - b;
|
|
function verifyOptions(options) {
|
|
if (!options.src || !isRemoteImage(options.src) && !isESMImportedImage(options.src)) {
|
|
throw new AstroError({
|
|
...ExpectedImage,
|
|
message: ExpectedImage.message(
|
|
JSON.stringify(options.src),
|
|
typeof options.src,
|
|
JSON.stringify(options, (_, v) => v === void 0 ? null : v)
|
|
)
|
|
});
|
|
}
|
|
if (!isESMImportedImage(options.src)) {
|
|
if (options.src.startsWith("/@fs/") || !isRemotePath(options.src) && !options.src.startsWith("/")) {
|
|
throw new AstroError({
|
|
...LocalImageUsedWrongly,
|
|
message: LocalImageUsedWrongly.message(options.src)
|
|
});
|
|
}
|
|
let missingDimension;
|
|
if (!options.width && !options.height) {
|
|
missingDimension = "both";
|
|
} else if (!options.width && options.height) {
|
|
missingDimension = "width";
|
|
} else if (options.width && !options.height) {
|
|
missingDimension = "height";
|
|
}
|
|
if (missingDimension) {
|
|
throw new AstroError({
|
|
...MissingImageDimension,
|
|
message: MissingImageDimension.message(missingDimension, options.src)
|
|
});
|
|
}
|
|
} else {
|
|
if (!VALID_SUPPORTED_FORMATS.includes(options.src.format)) {
|
|
throw new AstroError({
|
|
...UnsupportedImageFormat,
|
|
message: UnsupportedImageFormat.message(
|
|
options.src.format,
|
|
options.src.src,
|
|
VALID_SUPPORTED_FORMATS
|
|
)
|
|
});
|
|
}
|
|
if (options.widths && options.densities) {
|
|
throw new AstroError(IncompatibleDescriptorOptions);
|
|
}
|
|
if (options.src.format !== "svg" && options.format === "svg") {
|
|
throw new AstroError(UnsupportedImageConversion);
|
|
}
|
|
}
|
|
}
|
|
const baseService = {
|
|
validateOptions(options) {
|
|
verifyOptions(options);
|
|
if (!options.format) {
|
|
if (isESMImportedImage(options.src) && options.src.format === "svg") {
|
|
options.format = "svg";
|
|
} else {
|
|
options.format = DEFAULT_OUTPUT_FORMAT;
|
|
}
|
|
}
|
|
if (options.width) options.width = Math.round(options.width);
|
|
if (options.height) options.height = Math.round(options.height);
|
|
if (options.layout) {
|
|
delete options.layout;
|
|
}
|
|
if (options.fit === "none") {
|
|
delete options.fit;
|
|
}
|
|
return options;
|
|
},
|
|
getHTMLAttributes(options) {
|
|
const { targetWidth, targetHeight } = getTargetDimensions(options);
|
|
const {
|
|
src,
|
|
width,
|
|
height,
|
|
format,
|
|
quality,
|
|
densities,
|
|
widths,
|
|
formats,
|
|
layout,
|
|
priority,
|
|
fit,
|
|
position,
|
|
background,
|
|
...attributes
|
|
} = options;
|
|
return {
|
|
...attributes,
|
|
width: targetWidth,
|
|
height: targetHeight,
|
|
loading: attributes.loading ?? "lazy",
|
|
decoding: attributes.decoding ?? "async"
|
|
};
|
|
},
|
|
getSrcSet(options) {
|
|
const { targetWidth, targetHeight } = getTargetDimensions(options);
|
|
const aspectRatio = targetWidth / targetHeight;
|
|
const { widths, densities } = options;
|
|
const targetFormat = options.format ?? DEFAULT_OUTPUT_FORMAT;
|
|
let transformedWidths = (widths ?? []).sort(sortNumeric);
|
|
let imageWidth = options.width;
|
|
let maxWidth = Number.POSITIVE_INFINITY;
|
|
if (isESMImportedImage(options.src)) {
|
|
imageWidth = options.src.width;
|
|
maxWidth = imageWidth;
|
|
if (transformedWidths.length > 0 && transformedWidths.at(-1) > maxWidth) {
|
|
transformedWidths = transformedWidths.filter((width) => width <= maxWidth);
|
|
transformedWidths.push(maxWidth);
|
|
}
|
|
}
|
|
transformedWidths = Array.from(new Set(transformedWidths));
|
|
const {
|
|
width: transformWidth,
|
|
height: transformHeight,
|
|
...transformWithoutDimensions
|
|
} = options;
|
|
let allWidths = [];
|
|
if (densities) {
|
|
const densityValues = densities.map((density) => {
|
|
if (typeof density === "number") {
|
|
return density;
|
|
} else {
|
|
return Number.parseFloat(density);
|
|
}
|
|
});
|
|
const densityWidths = densityValues.sort(sortNumeric).map((density) => Math.round(targetWidth * density));
|
|
allWidths = densityWidths.map((width, index) => ({
|
|
width,
|
|
descriptor: `${densityValues[index]}x`
|
|
}));
|
|
} else if (transformedWidths.length > 0) {
|
|
allWidths = transformedWidths.map((width) => ({
|
|
width,
|
|
descriptor: `${width}w`
|
|
}));
|
|
}
|
|
return allWidths.map(({ width, descriptor }) => {
|
|
const height = Math.round(width / aspectRatio);
|
|
const transform = { ...transformWithoutDimensions, width, height };
|
|
return {
|
|
transform,
|
|
descriptor,
|
|
attributes: {
|
|
type: `image/${targetFormat}`
|
|
}
|
|
};
|
|
});
|
|
},
|
|
getURL(options, imageConfig) {
|
|
const searchParams = new URLSearchParams();
|
|
if (isESMImportedImage(options.src)) {
|
|
searchParams.append("href", options.src.src);
|
|
} else if (isRemoteAllowed(options.src, imageConfig)) {
|
|
searchParams.append("href", options.src);
|
|
} else {
|
|
return options.src;
|
|
}
|
|
const params = {
|
|
w: "width",
|
|
h: "height",
|
|
q: "quality",
|
|
f: "format",
|
|
fit: "fit",
|
|
position: "position",
|
|
background: "background"
|
|
};
|
|
Object.entries(params).forEach(([param, key]) => {
|
|
options[key] && searchParams.append(param, options[key].toString());
|
|
});
|
|
const imageEndpoint = joinPaths("/", imageConfig.endpoint.route);
|
|
let url = `${imageEndpoint}?${searchParams}`;
|
|
if (imageConfig.assetQueryParams) {
|
|
const assetQueryString = imageConfig.assetQueryParams.toString();
|
|
if (assetQueryString) {
|
|
url += "&" + assetQueryString;
|
|
}
|
|
}
|
|
return url;
|
|
},
|
|
parseURL(url) {
|
|
const params = url.searchParams;
|
|
if (!params.has("href")) {
|
|
return void 0;
|
|
}
|
|
const transform = {
|
|
src: params.get("href"),
|
|
width: params.has("w") ? Number.parseInt(params.get("w")) : void 0,
|
|
height: params.has("h") ? Number.parseInt(params.get("h")) : void 0,
|
|
format: params.get("f"),
|
|
quality: params.get("q"),
|
|
fit: params.get("fit"),
|
|
position: params.get("position") ?? void 0,
|
|
background: params.get("background") ?? void 0
|
|
};
|
|
return transform;
|
|
},
|
|
getRemoteSize(url, imageConfig) {
|
|
return inferRemoteSize(url, imageConfig);
|
|
}
|
|
};
|
|
function getTargetDimensions(options) {
|
|
let targetWidth = options.width;
|
|
let targetHeight = options.height;
|
|
if (isESMImportedImage(options.src)) {
|
|
const aspectRatio = options.src.width / options.src.height;
|
|
if (targetHeight && !targetWidth) {
|
|
targetWidth = Math.round(targetHeight * aspectRatio);
|
|
} else if (targetWidth && !targetHeight) {
|
|
targetHeight = Math.round(targetWidth / aspectRatio);
|
|
} else if (!targetWidth && !targetHeight) {
|
|
targetWidth = options.src.width;
|
|
targetHeight = options.src.height;
|
|
}
|
|
}
|
|
return {
|
|
targetWidth,
|
|
targetHeight
|
|
};
|
|
}
|
|
|
|
function isImageMetadata(src) {
|
|
return src.fsPath && !("fsPath" in src);
|
|
}
|
|
|
|
const PLACEHOLDER_BASE = "astro://placeholder";
|
|
function createPlaceholderURL(pathOrUrl) {
|
|
return new URL(pathOrUrl, PLACEHOLDER_BASE);
|
|
}
|
|
function stringifyPlaceholderURL(url) {
|
|
return url.href.replace(PLACEHOLDER_BASE, "");
|
|
}
|
|
|
|
const cssFitValues = ["fill", "contain", "cover", "scale-down"];
|
|
async function getConfiguredImageService() {
|
|
if (!globalThis?.astroAsset?.imageService) {
|
|
const { default: service } = await import(
|
|
// @ts-expect-error
|
|
'./sharp_BETh8Fss.mjs'
|
|
).catch((e) => {
|
|
const error = new AstroError(InvalidImageService);
|
|
error.cause = e;
|
|
throw error;
|
|
});
|
|
if (!globalThis.astroAsset) globalThis.astroAsset = {};
|
|
globalThis.astroAsset.imageService = service;
|
|
return service;
|
|
}
|
|
return globalThis.astroAsset.imageService;
|
|
}
|
|
async function getImage$1(options, imageConfig) {
|
|
if (!options || typeof options !== "object") {
|
|
throw new AstroError({
|
|
...ExpectedImageOptions,
|
|
message: ExpectedImageOptions.message(JSON.stringify(options))
|
|
});
|
|
}
|
|
if (typeof options.src === "undefined") {
|
|
throw new AstroError({
|
|
...ExpectedImage,
|
|
message: ExpectedImage.message(
|
|
options.src,
|
|
"undefined",
|
|
JSON.stringify(options)
|
|
)
|
|
});
|
|
}
|
|
if (isImageMetadata(options)) {
|
|
throw new AstroError(ExpectedNotESMImage);
|
|
}
|
|
const service = await getConfiguredImageService();
|
|
const resolvedOptions = {
|
|
...options,
|
|
src: await resolveSrc(options.src)
|
|
};
|
|
let originalWidth;
|
|
let originalHeight;
|
|
if (resolvedOptions.inferSize) {
|
|
delete resolvedOptions.inferSize;
|
|
if (isRemoteImage(resolvedOptions.src) && isRemotePath(resolvedOptions.src)) {
|
|
if (!isRemoteAllowed(resolvedOptions.src, imageConfig)) {
|
|
throw new AstroError({
|
|
...RemoteImageNotAllowed,
|
|
message: RemoteImageNotAllowed.message(resolvedOptions.src)
|
|
});
|
|
}
|
|
const getRemoteSize = (url) => service.getRemoteSize?.(url, imageConfig) ?? inferRemoteSize(url, imageConfig);
|
|
const result = await getRemoteSize(resolvedOptions.src);
|
|
resolvedOptions.width ??= result.width;
|
|
resolvedOptions.height ??= result.height;
|
|
originalWidth = result.width;
|
|
originalHeight = result.height;
|
|
}
|
|
}
|
|
const originalFilePath = isESMImportedImage(resolvedOptions.src) ? resolvedOptions.src.fsPath : void 0;
|
|
const clonedSrc = isESMImportedImage(resolvedOptions.src) ? (
|
|
// @ts-expect-error - clone is a private, hidden prop
|
|
resolvedOptions.src.clone ?? resolvedOptions.src
|
|
) : resolvedOptions.src;
|
|
if (isESMImportedImage(clonedSrc)) {
|
|
originalWidth = clonedSrc.width;
|
|
originalHeight = clonedSrc.height;
|
|
}
|
|
if (originalWidth && originalHeight) {
|
|
const aspectRatio = originalWidth / originalHeight;
|
|
if (resolvedOptions.height && !resolvedOptions.width) {
|
|
resolvedOptions.width = Math.round(resolvedOptions.height * aspectRatio);
|
|
} else if (resolvedOptions.width && !resolvedOptions.height) {
|
|
resolvedOptions.height = Math.round(resolvedOptions.width / aspectRatio);
|
|
} else if (!resolvedOptions.width && !resolvedOptions.height) {
|
|
resolvedOptions.width = originalWidth;
|
|
resolvedOptions.height = originalHeight;
|
|
}
|
|
}
|
|
resolvedOptions.src = clonedSrc;
|
|
const layout = options.layout ?? imageConfig.layout ?? "none";
|
|
if (resolvedOptions.priority) {
|
|
resolvedOptions.loading ??= "eager";
|
|
resolvedOptions.decoding ??= "sync";
|
|
resolvedOptions.fetchpriority ??= "high";
|
|
delete resolvedOptions.priority;
|
|
} else {
|
|
resolvedOptions.loading ??= "lazy";
|
|
resolvedOptions.decoding ??= "async";
|
|
resolvedOptions.fetchpriority ??= void 0;
|
|
}
|
|
if (layout !== "none") {
|
|
resolvedOptions.widths ||= getWidths({
|
|
width: resolvedOptions.width,
|
|
layout,
|
|
originalWidth,
|
|
breakpoints: imageConfig.breakpoints?.length ? imageConfig.breakpoints : isLocalService(service) ? LIMITED_RESOLUTIONS : DEFAULT_RESOLUTIONS
|
|
});
|
|
resolvedOptions.sizes ||= getSizesAttribute({ width: resolvedOptions.width, layout });
|
|
delete resolvedOptions.densities;
|
|
resolvedOptions["data-astro-image"] = layout;
|
|
if (resolvedOptions.fit && cssFitValues.includes(resolvedOptions.fit)) {
|
|
resolvedOptions["data-astro-image-fit"] = resolvedOptions.fit;
|
|
}
|
|
if (resolvedOptions.position) {
|
|
resolvedOptions["data-astro-image-pos"] = resolvedOptions.position.replace(/\s+/g, "-");
|
|
}
|
|
}
|
|
const validatedOptions = service.validateOptions ? await service.validateOptions(resolvedOptions, imageConfig) : resolvedOptions;
|
|
const srcSetTransforms = service.getSrcSet ? await service.getSrcSet(validatedOptions, imageConfig) : [];
|
|
const lazyImageURLFactory = (getValue) => {
|
|
let cached = null;
|
|
return () => cached ??= getValue();
|
|
};
|
|
const initialImageURL = await service.getURL(validatedOptions, imageConfig);
|
|
let lazyImageURL = lazyImageURLFactory(() => initialImageURL);
|
|
const matchesValidatedTransform = (transform) => transform.width === validatedOptions.width && transform.height === validatedOptions.height && transform.format === validatedOptions.format;
|
|
let srcSets = await Promise.all(
|
|
srcSetTransforms.map(async (srcSet) => {
|
|
return {
|
|
transform: srcSet.transform,
|
|
url: matchesValidatedTransform(srcSet.transform) ? initialImageURL : await service.getURL(srcSet.transform, imageConfig),
|
|
descriptor: srcSet.descriptor,
|
|
attributes: srcSet.attributes
|
|
};
|
|
})
|
|
);
|
|
if (isLocalService(service) && globalThis.astroAsset.addStaticImage && !(isRemoteImage(validatedOptions.src) && initialImageURL === validatedOptions.src)) {
|
|
const propsToHash = service.propertiesToHash ?? DEFAULT_HASH_PROPS;
|
|
lazyImageURL = lazyImageURLFactory(
|
|
() => globalThis.astroAsset.addStaticImage(validatedOptions, propsToHash, originalFilePath)
|
|
);
|
|
srcSets = srcSetTransforms.map((srcSet) => {
|
|
return {
|
|
transform: srcSet.transform,
|
|
url: matchesValidatedTransform(srcSet.transform) ? lazyImageURL() : globalThis.astroAsset.addStaticImage(srcSet.transform, propsToHash, originalFilePath),
|
|
descriptor: srcSet.descriptor,
|
|
attributes: srcSet.attributes
|
|
};
|
|
});
|
|
} else if (imageConfig.assetQueryParams) {
|
|
const imageURLObj = createPlaceholderURL(initialImageURL);
|
|
imageConfig.assetQueryParams.forEach((value, key) => {
|
|
imageURLObj.searchParams.set(key, value);
|
|
});
|
|
lazyImageURL = lazyImageURLFactory(() => stringifyPlaceholderURL(imageURLObj));
|
|
srcSets = srcSets.map((srcSet) => {
|
|
const urlObj = createPlaceholderURL(srcSet.url);
|
|
imageConfig.assetQueryParams.forEach((value, key) => {
|
|
urlObj.searchParams.set(key, value);
|
|
});
|
|
return {
|
|
...srcSet,
|
|
url: stringifyPlaceholderURL(urlObj)
|
|
};
|
|
});
|
|
}
|
|
return {
|
|
rawOptions: resolvedOptions,
|
|
options: validatedOptions,
|
|
get src() {
|
|
return lazyImageURL();
|
|
},
|
|
srcSet: {
|
|
values: srcSets,
|
|
attribute: srcSets.map((srcSet) => `${srcSet.url} ${srcSet.descriptor}`).join(", ")
|
|
},
|
|
attributes: service.getHTMLAttributes !== void 0 ? await service.getHTMLAttributes(validatedOptions, imageConfig) : {}
|
|
};
|
|
}
|
|
|
|
Function.prototype.toString.call(Object);
|
|
|
|
const $$Image = createComponent(async ($$result, $$props, $$slots) => {
|
|
const Astro2 = $$result.createAstro($$props, $$slots);
|
|
Astro2.self = $$Image;
|
|
const props = Astro2.props;
|
|
if (props.alt === void 0 || props.alt === null) {
|
|
throw new AstroError(ImageMissingAlt);
|
|
}
|
|
if (typeof props.width === "string") {
|
|
props.width = Number.parseInt(props.width);
|
|
}
|
|
if (typeof props.height === "string") {
|
|
props.height = Number.parseInt(props.height);
|
|
}
|
|
const layout = props.layout ?? imageConfig.layout ?? "none";
|
|
if (layout !== "none") {
|
|
props.layout ??= imageConfig.layout;
|
|
props.fit ??= imageConfig.objectFit ?? "cover";
|
|
props.position ??= imageConfig.objectPosition ?? "center";
|
|
} else if (imageConfig.objectFit || imageConfig.objectPosition) {
|
|
props.fit ??= imageConfig.objectFit;
|
|
props.position ??= imageConfig.objectPosition;
|
|
}
|
|
const image = await getImage(props);
|
|
const additionalAttributes = {};
|
|
if (image.srcSet.values.length > 0) {
|
|
additionalAttributes.srcset = image.srcSet.attribute;
|
|
}
|
|
const { class: className, ...attributes } = { ...additionalAttributes, ...image.attributes };
|
|
return renderTemplate`${maybeRenderHead()}<img${addAttribute(image.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}>`;
|
|
}, "/Users/kntdgrtnnly/Documents/upiecep/upiecep-website/node_modules/.pnpm/astro@6.1.10_@types+node@24.12.2_@vercel+functions@3.4.4_rollup@4.60.2_sass@1.99.0_typescript@5.9.3_yaml@2.8.3/node_modules/astro/components/Image.astro", void 0);
|
|
|
|
const mimes = {
|
|
"3g2": "video/3gpp2",
|
|
"3gp": "video/3gpp",
|
|
"3gpp": "video/3gpp",
|
|
"3mf": "model/3mf",
|
|
"aac": "audio/aac",
|
|
"ac": "application/pkix-attr-cert",
|
|
"adp": "audio/adpcm",
|
|
"adts": "audio/aac",
|
|
"ai": "application/postscript",
|
|
"aml": "application/automationml-aml+xml",
|
|
"amlx": "application/automationml-amlx+zip",
|
|
"amr": "audio/amr",
|
|
"apng": "image/apng",
|
|
"appcache": "text/cache-manifest",
|
|
"appinstaller": "application/appinstaller",
|
|
"appx": "application/appx",
|
|
"appxbundle": "application/appxbundle",
|
|
"asc": "application/pgp-keys",
|
|
"atom": "application/atom+xml",
|
|
"atomcat": "application/atomcat+xml",
|
|
"atomdeleted": "application/atomdeleted+xml",
|
|
"atomsvc": "application/atomsvc+xml",
|
|
"au": "audio/basic",
|
|
"avci": "image/avci",
|
|
"avcs": "image/avcs",
|
|
"avif": "image/avif",
|
|
"aw": "application/applixware",
|
|
"bdoc": "application/bdoc",
|
|
"bin": "application/octet-stream",
|
|
"bmp": "image/bmp",
|
|
"bpk": "application/octet-stream",
|
|
"btf": "image/prs.btif",
|
|
"btif": "image/prs.btif",
|
|
"buffer": "application/octet-stream",
|
|
"ccxml": "application/ccxml+xml",
|
|
"cdfx": "application/cdfx+xml",
|
|
"cdmia": "application/cdmi-capability",
|
|
"cdmic": "application/cdmi-container",
|
|
"cdmid": "application/cdmi-domain",
|
|
"cdmio": "application/cdmi-object",
|
|
"cdmiq": "application/cdmi-queue",
|
|
"cer": "application/pkix-cert",
|
|
"cgm": "image/cgm",
|
|
"cjs": "application/node",
|
|
"class": "application/java-vm",
|
|
"coffee": "text/coffeescript",
|
|
"conf": "text/plain",
|
|
"cpl": "application/cpl+xml",
|
|
"cpt": "application/mac-compactpro",
|
|
"crl": "application/pkix-crl",
|
|
"css": "text/css",
|
|
"csv": "text/csv",
|
|
"cu": "application/cu-seeme",
|
|
"cwl": "application/cwl",
|
|
"cww": "application/prs.cww",
|
|
"davmount": "application/davmount+xml",
|
|
"dbk": "application/docbook+xml",
|
|
"deb": "application/octet-stream",
|
|
"def": "text/plain",
|
|
"deploy": "application/octet-stream",
|
|
"dib": "image/bmp",
|
|
"disposition-notification": "message/disposition-notification",
|
|
"dist": "application/octet-stream",
|
|
"distz": "application/octet-stream",
|
|
"dll": "application/octet-stream",
|
|
"dmg": "application/octet-stream",
|
|
"dms": "application/octet-stream",
|
|
"doc": "application/msword",
|
|
"dot": "application/msword",
|
|
"dpx": "image/dpx",
|
|
"drle": "image/dicom-rle",
|
|
"dsc": "text/prs.lines.tag",
|
|
"dssc": "application/dssc+der",
|
|
"dtd": "application/xml-dtd",
|
|
"dump": "application/octet-stream",
|
|
"dwd": "application/atsc-dwd+xml",
|
|
"ear": "application/java-archive",
|
|
"ecma": "application/ecmascript",
|
|
"elc": "application/octet-stream",
|
|
"emf": "image/emf",
|
|
"eml": "message/rfc822",
|
|
"emma": "application/emma+xml",
|
|
"emotionml": "application/emotionml+xml",
|
|
"eps": "application/postscript",
|
|
"epub": "application/epub+zip",
|
|
"exe": "application/octet-stream",
|
|
"exi": "application/exi",
|
|
"exp": "application/express",
|
|
"exr": "image/aces",
|
|
"ez": "application/andrew-inset",
|
|
"fdf": "application/fdf",
|
|
"fdt": "application/fdt+xml",
|
|
"fits": "image/fits",
|
|
"g3": "image/g3fax",
|
|
"gbr": "application/rpki-ghostbusters",
|
|
"geojson": "application/geo+json",
|
|
"gif": "image/gif",
|
|
"glb": "model/gltf-binary",
|
|
"gltf": "model/gltf+json",
|
|
"gml": "application/gml+xml",
|
|
"gpx": "application/gpx+xml",
|
|
"gram": "application/srgs",
|
|
"grxml": "application/srgs+xml",
|
|
"gxf": "application/gxf",
|
|
"gz": "application/gzip",
|
|
"h261": "video/h261",
|
|
"h263": "video/h263",
|
|
"h264": "video/h264",
|
|
"heic": "image/heic",
|
|
"heics": "image/heic-sequence",
|
|
"heif": "image/heif",
|
|
"heifs": "image/heif-sequence",
|
|
"hej2": "image/hej2k",
|
|
"held": "application/atsc-held+xml",
|
|
"hjson": "application/hjson",
|
|
"hlp": "application/winhlp",
|
|
"hqx": "application/mac-binhex40",
|
|
"hsj2": "image/hsj2",
|
|
"htm": "text/html",
|
|
"html": "text/html",
|
|
"ics": "text/calendar",
|
|
"ief": "image/ief",
|
|
"ifb": "text/calendar",
|
|
"iges": "model/iges",
|
|
"igs": "model/iges",
|
|
"img": "application/octet-stream",
|
|
"in": "text/plain",
|
|
"ini": "text/plain",
|
|
"ink": "application/inkml+xml",
|
|
"inkml": "application/inkml+xml",
|
|
"ipfix": "application/ipfix",
|
|
"iso": "application/octet-stream",
|
|
"its": "application/its+xml",
|
|
"jade": "text/jade",
|
|
"jar": "application/java-archive",
|
|
"jhc": "image/jphc",
|
|
"jls": "image/jls",
|
|
"jp2": "image/jp2",
|
|
"jpe": "image/jpeg",
|
|
"jpeg": "image/jpeg",
|
|
"jpf": "image/jpx",
|
|
"jpg": "image/jpeg",
|
|
"jpg2": "image/jp2",
|
|
"jpgm": "image/jpm",
|
|
"jpgv": "video/jpeg",
|
|
"jph": "image/jph",
|
|
"jpm": "image/jpm",
|
|
"jpx": "image/jpx",
|
|
"js": "text/javascript",
|
|
"json": "application/json",
|
|
"json5": "application/json5",
|
|
"jsonld": "application/ld+json",
|
|
"jsonml": "application/jsonml+json",
|
|
"jsx": "text/jsx",
|
|
"jt": "model/jt",
|
|
"jxl": "image/jxl",
|
|
"jxr": "image/jxr",
|
|
"jxra": "image/jxra",
|
|
"jxrs": "image/jxrs",
|
|
"jxs": "image/jxs",
|
|
"jxsc": "image/jxsc",
|
|
"jxsi": "image/jxsi",
|
|
"jxss": "image/jxss",
|
|
"kar": "audio/midi",
|
|
"ktx": "image/ktx",
|
|
"ktx2": "image/ktx2",
|
|
"less": "text/less",
|
|
"lgr": "application/lgr+xml",
|
|
"list": "text/plain",
|
|
"litcoffee": "text/coffeescript",
|
|
"log": "text/plain",
|
|
"lostxml": "application/lost+xml",
|
|
"lrf": "application/octet-stream",
|
|
"m1v": "video/mpeg",
|
|
"m21": "application/mp21",
|
|
"m2a": "audio/mpeg",
|
|
"m2t": "video/mp2t",
|
|
"m2ts": "video/mp2t",
|
|
"m2v": "video/mpeg",
|
|
"m3a": "audio/mpeg",
|
|
"m4a": "audio/mp4",
|
|
"m4p": "application/mp4",
|
|
"m4s": "video/iso.segment",
|
|
"ma": "application/mathematica",
|
|
"mads": "application/mads+xml",
|
|
"maei": "application/mmt-aei+xml",
|
|
"man": "text/troff",
|
|
"manifest": "text/cache-manifest",
|
|
"map": "application/json",
|
|
"mar": "application/octet-stream",
|
|
"markdown": "text/markdown",
|
|
"mathml": "application/mathml+xml",
|
|
"mb": "application/mathematica",
|
|
"mbox": "application/mbox",
|
|
"md": "text/markdown",
|
|
"mdx": "text/mdx",
|
|
"me": "text/troff",
|
|
"mesh": "model/mesh",
|
|
"meta4": "application/metalink4+xml",
|
|
"metalink": "application/metalink+xml",
|
|
"mets": "application/mets+xml",
|
|
"mft": "application/rpki-manifest",
|
|
"mid": "audio/midi",
|
|
"midi": "audio/midi",
|
|
"mime": "message/rfc822",
|
|
"mj2": "video/mj2",
|
|
"mjp2": "video/mj2",
|
|
"mjs": "text/javascript",
|
|
"mml": "text/mathml",
|
|
"mods": "application/mods+xml",
|
|
"mov": "video/quicktime",
|
|
"mp2": "audio/mpeg",
|
|
"mp21": "application/mp21",
|
|
"mp2a": "audio/mpeg",
|
|
"mp3": "audio/mpeg",
|
|
"mp4": "video/mp4",
|
|
"mp4a": "audio/mp4",
|
|
"mp4s": "application/mp4",
|
|
"mp4v": "video/mp4",
|
|
"mpd": "application/dash+xml",
|
|
"mpe": "video/mpeg",
|
|
"mpeg": "video/mpeg",
|
|
"mpf": "application/media-policy-dataset+xml",
|
|
"mpg": "video/mpeg",
|
|
"mpg4": "video/mp4",
|
|
"mpga": "audio/mpeg",
|
|
"mpp": "application/dash-patch+xml",
|
|
"mrc": "application/marc",
|
|
"mrcx": "application/marcxml+xml",
|
|
"ms": "text/troff",
|
|
"mscml": "application/mediaservercontrol+xml",
|
|
"msh": "model/mesh",
|
|
"msi": "application/octet-stream",
|
|
"msix": "application/msix",
|
|
"msixbundle": "application/msixbundle",
|
|
"msm": "application/octet-stream",
|
|
"msp": "application/octet-stream",
|
|
"mtl": "model/mtl",
|
|
"mts": "video/mp2t",
|
|
"musd": "application/mmt-usd+xml",
|
|
"mxf": "application/mxf",
|
|
"mxmf": "audio/mobile-xmf",
|
|
"mxml": "application/xv+xml",
|
|
"n3": "text/n3",
|
|
"nb": "application/mathematica",
|
|
"nq": "application/n-quads",
|
|
"nt": "application/n-triples",
|
|
"obj": "model/obj",
|
|
"oda": "application/oda",
|
|
"oga": "audio/ogg",
|
|
"ogg": "audio/ogg",
|
|
"ogv": "video/ogg",
|
|
"ogx": "application/ogg",
|
|
"omdoc": "application/omdoc+xml",
|
|
"onepkg": "application/onenote",
|
|
"onetmp": "application/onenote",
|
|
"onetoc": "application/onenote",
|
|
"onetoc2": "application/onenote",
|
|
"opf": "application/oebps-package+xml",
|
|
"opus": "audio/ogg",
|
|
"otf": "font/otf",
|
|
"owl": "application/rdf+xml",
|
|
"oxps": "application/oxps",
|
|
"p10": "application/pkcs10",
|
|
"p7c": "application/pkcs7-mime",
|
|
"p7m": "application/pkcs7-mime",
|
|
"p7s": "application/pkcs7-signature",
|
|
"p8": "application/pkcs8",
|
|
"pdf": "application/pdf",
|
|
"pfr": "application/font-tdpfr",
|
|
"pgp": "application/pgp-encrypted",
|
|
"pkg": "application/octet-stream",
|
|
"pki": "application/pkixcmp",
|
|
"pkipath": "application/pkix-pkipath",
|
|
"pls": "application/pls+xml",
|
|
"png": "image/png",
|
|
"prc": "model/prc",
|
|
"prf": "application/pics-rules",
|
|
"provx": "application/provenance+xml",
|
|
"ps": "application/postscript",
|
|
"pskcxml": "application/pskc+xml",
|
|
"pti": "image/prs.pti",
|
|
"qt": "video/quicktime",
|
|
"raml": "application/raml+yaml",
|
|
"rapd": "application/route-apd+xml",
|
|
"rdf": "application/rdf+xml",
|
|
"relo": "application/p2p-overlay+xml",
|
|
"rif": "application/reginfo+xml",
|
|
"rl": "application/resource-lists+xml",
|
|
"rld": "application/resource-lists-diff+xml",
|
|
"rmi": "audio/midi",
|
|
"rnc": "application/relax-ng-compact-syntax",
|
|
"rng": "application/xml",
|
|
"roa": "application/rpki-roa",
|
|
"roff": "text/troff",
|
|
"rq": "application/sparql-query",
|
|
"rs": "application/rls-services+xml",
|
|
"rsat": "application/atsc-rsat+xml",
|
|
"rsd": "application/rsd+xml",
|
|
"rsheet": "application/urc-ressheet+xml",
|
|
"rss": "application/rss+xml",
|
|
"rtf": "text/rtf",
|
|
"rtx": "text/richtext",
|
|
"rusd": "application/route-usd+xml",
|
|
"s3m": "audio/s3m",
|
|
"sbml": "application/sbml+xml",
|
|
"scq": "application/scvp-cv-request",
|
|
"scs": "application/scvp-cv-response",
|
|
"sdp": "application/sdp",
|
|
"senmlx": "application/senml+xml",
|
|
"sensmlx": "application/sensml+xml",
|
|
"ser": "application/java-serialized-object",
|
|
"setpay": "application/set-payment-initiation",
|
|
"setreg": "application/set-registration-initiation",
|
|
"sgi": "image/sgi",
|
|
"sgm": "text/sgml",
|
|
"sgml": "text/sgml",
|
|
"shex": "text/shex",
|
|
"shf": "application/shf+xml",
|
|
"shtml": "text/html",
|
|
"sieve": "application/sieve",
|
|
"sig": "application/pgp-signature",
|
|
"sil": "audio/silk",
|
|
"silo": "model/mesh",
|
|
"siv": "application/sieve",
|
|
"slim": "text/slim",
|
|
"slm": "text/slim",
|
|
"sls": "application/route-s-tsid+xml",
|
|
"smi": "application/smil+xml",
|
|
"smil": "application/smil+xml",
|
|
"snd": "audio/basic",
|
|
"so": "application/octet-stream",
|
|
"spdx": "text/spdx",
|
|
"spp": "application/scvp-vp-response",
|
|
"spq": "application/scvp-vp-request",
|
|
"spx": "audio/ogg",
|
|
"sql": "application/sql",
|
|
"sru": "application/sru+xml",
|
|
"srx": "application/sparql-results+xml",
|
|
"ssdl": "application/ssdl+xml",
|
|
"ssml": "application/ssml+xml",
|
|
"stk": "application/hyperstudio",
|
|
"stl": "model/stl",
|
|
"stpx": "model/step+xml",
|
|
"stpxz": "model/step-xml+zip",
|
|
"stpz": "model/step+zip",
|
|
"styl": "text/stylus",
|
|
"stylus": "text/stylus",
|
|
"svg": "image/svg+xml",
|
|
"svgz": "image/svg+xml",
|
|
"swidtag": "application/swid+xml",
|
|
"t": "text/troff",
|
|
"t38": "image/t38",
|
|
"td": "application/urc-targetdesc+xml",
|
|
"tei": "application/tei+xml",
|
|
"teicorpus": "application/tei+xml",
|
|
"text": "text/plain",
|
|
"tfi": "application/thraud+xml",
|
|
"tfx": "image/tiff-fx",
|
|
"tif": "image/tiff",
|
|
"tiff": "image/tiff",
|
|
"toml": "application/toml",
|
|
"tr": "text/troff",
|
|
"trig": "application/trig",
|
|
"ts": "video/mp2t",
|
|
"tsd": "application/timestamped-data",
|
|
"tsv": "text/tab-separated-values",
|
|
"ttc": "font/collection",
|
|
"ttf": "font/ttf",
|
|
"ttl": "text/turtle",
|
|
"ttml": "application/ttml+xml",
|
|
"txt": "text/plain",
|
|
"u3d": "model/u3d",
|
|
"u8dsn": "message/global-delivery-status",
|
|
"u8hdr": "message/global-headers",
|
|
"u8mdn": "message/global-disposition-notification",
|
|
"u8msg": "message/global",
|
|
"ubj": "application/ubjson",
|
|
"uri": "text/uri-list",
|
|
"uris": "text/uri-list",
|
|
"urls": "text/uri-list",
|
|
"vcard": "text/vcard",
|
|
"vrml": "model/vrml",
|
|
"vtt": "text/vtt",
|
|
"vxml": "application/voicexml+xml",
|
|
"war": "application/java-archive",
|
|
"wasm": "application/wasm",
|
|
"wav": "audio/wav",
|
|
"weba": "audio/webm",
|
|
"webm": "video/webm",
|
|
"webmanifest": "application/manifest+json",
|
|
"webp": "image/webp",
|
|
"wgsl": "text/wgsl",
|
|
"wgt": "application/widget",
|
|
"wif": "application/watcherinfo+xml",
|
|
"wmf": "image/wmf",
|
|
"woff": "font/woff",
|
|
"woff2": "font/woff2",
|
|
"wrl": "model/vrml",
|
|
"wsdl": "application/wsdl+xml",
|
|
"wspolicy": "application/wspolicy+xml",
|
|
"x3d": "model/x3d+xml",
|
|
"x3db": "model/x3d+fastinfoset",
|
|
"x3dbz": "model/x3d+binary",
|
|
"x3dv": "model/x3d-vrml",
|
|
"x3dvz": "model/x3d+vrml",
|
|
"x3dz": "model/x3d+xml",
|
|
"xaml": "application/xaml+xml",
|
|
"xav": "application/xcap-att+xml",
|
|
"xca": "application/xcap-caps+xml",
|
|
"xcs": "application/calendar+xml",
|
|
"xdf": "application/xcap-diff+xml",
|
|
"xdssc": "application/dssc+xml",
|
|
"xel": "application/xcap-el+xml",
|
|
"xenc": "application/xenc+xml",
|
|
"xer": "application/patch-ops-error+xml",
|
|
"xfdf": "application/xfdf",
|
|
"xht": "application/xhtml+xml",
|
|
"xhtml": "application/xhtml+xml",
|
|
"xhvml": "application/xv+xml",
|
|
"xlf": "application/xliff+xml",
|
|
"xm": "audio/xm",
|
|
"xml": "text/xml",
|
|
"xns": "application/xcap-ns+xml",
|
|
"xop": "application/xop+xml",
|
|
"xpl": "application/xproc+xml",
|
|
"xsd": "application/xml",
|
|
"xsf": "application/prs.xsf+xml",
|
|
"xsl": "application/xml",
|
|
"xslt": "application/xml",
|
|
"xspf": "application/xspf+xml",
|
|
"xvm": "application/xv+xml",
|
|
"xvml": "application/xv+xml",
|
|
"yaml": "text/yaml",
|
|
"yang": "application/yang",
|
|
"yin": "application/yin+xml",
|
|
"yml": "text/yaml",
|
|
"zip": "application/zip"
|
|
};
|
|
|
|
function lookup(extn) {
|
|
let tmp = ('' + extn).trim().toLowerCase();
|
|
let idx = tmp.lastIndexOf('.');
|
|
return mimes[!~idx ? tmp : tmp.substring(++idx)];
|
|
}
|
|
|
|
const $$Picture = createComponent(async ($$result, $$props, $$slots) => {
|
|
const Astro2 = $$result.createAstro($$props, $$slots);
|
|
Astro2.self = $$Picture;
|
|
const defaultFormats = ["webp"];
|
|
const defaultFallbackFormat = "png";
|
|
const specialFormatsFallback = ["gif", "svg", "jpg", "jpeg"];
|
|
const { formats = defaultFormats, pictureAttributes = {}, fallbackFormat, ...props } = Astro2.props;
|
|
if (props.alt === void 0 || props.alt === null) {
|
|
throw new AstroError(ImageMissingAlt);
|
|
}
|
|
const scopedStyleClass = props.class?.match(/\bastro-\w{8}\b/)?.[0];
|
|
if (scopedStyleClass) {
|
|
if (pictureAttributes.class) {
|
|
pictureAttributes.class = `${pictureAttributes.class} ${scopedStyleClass}`;
|
|
} else {
|
|
pictureAttributes.class = scopedStyleClass;
|
|
}
|
|
}
|
|
const layout = props.layout ?? imageConfig.layout ?? "none";
|
|
const useResponsive = layout !== "none";
|
|
if (useResponsive) {
|
|
props.layout ??= imageConfig.layout;
|
|
props.fit ??= imageConfig.objectFit ?? "cover";
|
|
props.position ??= imageConfig.objectPosition ?? "center";
|
|
} else if (imageConfig.objectFit || imageConfig.objectPosition) {
|
|
props.fit ??= imageConfig.objectFit;
|
|
props.position ??= imageConfig.objectPosition;
|
|
}
|
|
for (const key in props) {
|
|
if (key.startsWith("data-astro-cid")) {
|
|
pictureAttributes[key] = props[key];
|
|
}
|
|
}
|
|
const originalSrc = await resolveSrc(props.src);
|
|
const optimizedImages = await Promise.all(
|
|
formats.map(
|
|
async (format) => await getImage({
|
|
...props,
|
|
src: originalSrc,
|
|
format,
|
|
widths: props.widths,
|
|
densities: props.densities
|
|
})
|
|
)
|
|
);
|
|
const clonedSrc = isESMImportedImage(originalSrc) ? (
|
|
// @ts-expect-error - clone is a private, hidden prop
|
|
originalSrc.clone ?? originalSrc
|
|
) : originalSrc;
|
|
let resultFallbackFormat = fallbackFormat ?? defaultFallbackFormat;
|
|
if (!fallbackFormat && isESMImportedImage(clonedSrc) && specialFormatsFallback.includes(clonedSrc.format)) {
|
|
resultFallbackFormat = clonedSrc.format;
|
|
}
|
|
const fallbackImage = await getImage({
|
|
...props,
|
|
format: resultFallbackFormat,
|
|
widths: props.widths,
|
|
densities: props.densities
|
|
});
|
|
const imgAdditionalAttributes = {};
|
|
const sourceAdditionalAttributes = {};
|
|
if (props.sizes) {
|
|
sourceAdditionalAttributes.sizes = props.sizes;
|
|
}
|
|
if (fallbackImage.srcSet.values.length > 0) {
|
|
imgAdditionalAttributes.srcset = fallbackImage.srcSet.attribute;
|
|
}
|
|
const { class: className, ...attributes } = {
|
|
...imgAdditionalAttributes,
|
|
...fallbackImage.attributes
|
|
};
|
|
return renderTemplate`${maybeRenderHead()}<picture${spreadAttributes(pictureAttributes)}> ${Object.entries(optimizedImages).map(([_, image]) => {
|
|
const srcsetAttribute = props.densities || !props.densities && !props.widths && !useResponsive ? `${image.src}${image.srcSet.values.length > 0 ? ", " + image.srcSet.attribute : ""}` : image.srcSet.attribute;
|
|
return renderTemplate`<source${addAttribute(srcsetAttribute, "srcset")}${addAttribute(lookup(image.options.format ?? image.src) ?? `image/${image.options.format}`, "type")}${spreadAttributes(sourceAdditionalAttributes)}>`;
|
|
})} <img${addAttribute(fallbackImage.src, "src")}${spreadAttributes(attributes)}${addAttribute(className, "class")}> </picture>`;
|
|
}, "/Users/kntdgrtnnly/Documents/upiecep/upiecep-website/node_modules/.pnpm/astro@6.1.10_@types+node@24.12.2_@vercel+functions@3.4.4_rollup@4.60.2_sass@1.99.0_typescript@5.9.3_yaml@2.8.3/node_modules/astro/components/Picture.astro", void 0);
|
|
|
|
const componentDataByCssVariable = new Map([]);
|
|
|
|
function filterPreloads(data, preload) {
|
|
if (!preload) {
|
|
return null;
|
|
}
|
|
if (preload === true) {
|
|
return data;
|
|
}
|
|
return data.filter(
|
|
({ weight, style, subset }) => preload.some((p) => {
|
|
if (p.weight !== void 0 && weight !== void 0 && !checkWeight(p.weight.toString(), weight)) {
|
|
return false;
|
|
}
|
|
if (p.style !== void 0 && p.style !== style) {
|
|
return false;
|
|
}
|
|
if (p.subset !== void 0 && p.subset !== subset) {
|
|
return false;
|
|
}
|
|
return true;
|
|
})
|
|
);
|
|
}
|
|
function checkWeight(input, target) {
|
|
const trimmedInput = input.trim();
|
|
if (trimmedInput.includes(" ")) {
|
|
return trimmedInput === target;
|
|
}
|
|
if (target.includes(" ")) {
|
|
const [a, b] = target.split(" ");
|
|
const parsedInput = Number.parseInt(input);
|
|
return parsedInput >= Number.parseInt(a) && parsedInput <= Number.parseInt(b);
|
|
}
|
|
return input === target;
|
|
}
|
|
|
|
const $$Font = createComponent(($$result, $$props, $$slots) => {
|
|
const Astro2 = $$result.createAstro($$props, $$slots);
|
|
Astro2.self = $$Font;
|
|
const { cssVariable, preload = false } = Astro2.props;
|
|
const data = componentDataByCssVariable.get(cssVariable);
|
|
if (!data) {
|
|
throw new AstroError({
|
|
...FontFamilyNotFound,
|
|
message: FontFamilyNotFound.message(cssVariable)
|
|
});
|
|
}
|
|
const filteredPreloadData = filterPreloads(data.preloads, preload);
|
|
return renderTemplate`<style>${unescapeHTML(data.css)}</style>${filteredPreloadData?.map(({ url, type }) => renderTemplate`<link rel="preload"${addAttribute(url, "href")} as="font"${addAttribute(`font/${type}`, "type")} crossorigin>`)}`;
|
|
}, "/Users/kntdgrtnnly/Documents/upiecep/upiecep-website/node_modules/.pnpm/astro@6.1.10_@types+node@24.12.2_@vercel+functions@3.4.4_rollup@4.60.2_sass@1.99.0_typescript@5.9.3_yaml@2.8.3/node_modules/astro/components/Font.astro", void 0);
|
|
|
|
const assetQueryParams = undefined;
|
|
const imageConfig = {"endpoint":{"route":"/_image"},"service":{"entrypoint":"astro/assets/services/sharp","config":{}},"domains":[],"remotePatterns":[],"responsiveStyles":false};
|
|
Object.defineProperty(imageConfig, 'assetQueryParams', {
|
|
value: assetQueryParams,
|
|
enumerable: false,
|
|
configurable: true,
|
|
});
|
|
const getImage = async (options) => await getImage$1(options, imageConfig);
|
|
|
|
const fnv1a52 = (str) => {
|
|
const len = str.length;
|
|
let i = 0, t0 = 0, v0 = 8997, t1 = 0, v1 = 33826, t2 = 0, v2 = 40164, t3 = 0, v3 = 52210;
|
|
while (i < len) {
|
|
v0 ^= str.charCodeAt(i++);
|
|
t0 = v0 * 435;
|
|
t1 = v1 * 435;
|
|
t2 = v2 * 435;
|
|
t3 = v3 * 435;
|
|
t2 += v0 << 8;
|
|
t3 += v1 << 8;
|
|
t1 += t0 >>> 16;
|
|
v0 = t0 & 65535;
|
|
t2 += t1 >>> 16;
|
|
v1 = t1 & 65535;
|
|
v3 = t3 + (t2 >>> 16) & 65535;
|
|
v2 = t2 & 65535;
|
|
}
|
|
return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
|
|
};
|
|
const etag = (payload, weak = false) => {
|
|
const prefix = weak ? 'W/"' : '"';
|
|
return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
|
|
};
|
|
|
|
async function loadRemoteImage(src, headers) {
|
|
try {
|
|
const res = await fetch(src, {
|
|
// Forward all headers from the original request
|
|
headers,
|
|
redirect: "manual"
|
|
});
|
|
if (res.status >= 300 && res.status < 400) {
|
|
return void 0;
|
|
}
|
|
if (!res.ok) {
|
|
return void 0;
|
|
}
|
|
return await res.arrayBuffer();
|
|
} catch {
|
|
return void 0;
|
|
}
|
|
}
|
|
const GET = async ({ request }) => {
|
|
try {
|
|
const imageService = await getConfiguredImageService();
|
|
if (!("transform" in imageService)) {
|
|
throw new Error("Configured image service is not a local service");
|
|
}
|
|
const url = new URL(request.url);
|
|
const transform = await imageService.parseURL(url, imageConfig);
|
|
if (!transform?.src) {
|
|
throw new Error("Incorrect transform returned by `parseURL`");
|
|
}
|
|
let inputBuffer = void 0;
|
|
const isRemoteImage = isRemotePath(transform.src);
|
|
if (isRemoteImage && isRemoteAllowed(transform.src, imageConfig) === false) {
|
|
return new Response("Forbidden", { status: 403 });
|
|
}
|
|
const sourceUrl = new URL(transform.src, url.origin);
|
|
if (!isRemoteImage && sourceUrl.origin !== url.origin) {
|
|
return new Response("Forbidden", { status: 403 });
|
|
}
|
|
inputBuffer = await loadRemoteImage(sourceUrl, isRemoteImage ? new Headers() : request.headers);
|
|
if (!inputBuffer) {
|
|
return new Response("Not Found", { status: 404 });
|
|
}
|
|
const { data, format } = await imageService.transform(
|
|
new Uint8Array(inputBuffer),
|
|
transform,
|
|
imageConfig
|
|
);
|
|
return new Response(data, {
|
|
status: 200,
|
|
headers: {
|
|
"Content-Type": lookup(format) ?? `image/${format}`,
|
|
"Cache-Control": "public, max-age=31536000",
|
|
ETag: etag(data.toString()),
|
|
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
}
|
|
});
|
|
} catch (err) {
|
|
console.error("Could not process image request:", err);
|
|
return new Response(`Server Error: ${err}`, { status: 500 });
|
|
}
|
|
};
|
|
|
|
const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
__proto__: null,
|
|
GET
|
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
|
|
const page = () => _page;
|
|
|
|
const generic___js = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
__proto__: null,
|
|
page
|
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
|
|
export { baseService as b, generic___js as g, parseQuality as p };
|