"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
var image_1 = __importDefault(require("next/image"));
var util_1 = require("./util");
var base_path_1 = __importDefault(require("lib/base-path"));
var path_1 = require("path");
function Image(_a) {
    var _b;
    var src = _a.src, style = _a.style, alt = _a.alt, width = _a.width, height = _a.height, _c = _a.priority, priority = _c === void 0 ? false : _c;
    if (typeof src == "string") {
        return ((0, jsx_runtime_1.jsx)("img", { src: (0, util_1.MediaURL)(src), style: __assign(__assign({}, style), { maxWidth: "100%" }), alt: alt, width: width, height: height }));
    }
    if (base_path_1.default.length > 1 && !((_b = src.src) === null || _b === void 0 ? void 0 : _b.startsWith(base_path_1.default))) {
        // This is a hack to workaround the very annoying fact that
        // next/image does NOT properly support the nextjs basePath
        // option.  This is definitely a bug in nextjs, and when it
        // gets fixed, this workaround will break our site!
        // The next/image implementation is in packages/next/client/image.tsx of nextjs itself.
        // Here's the issue: https://github.com/vercel/next.js/issues/22244
        src.src = (0, path_1.join)(base_path_1.default, src.src);
    }
    if (height != null && width != null) {
        return (0, jsx_runtime_1.jsx)(image_1.default, { src: src, alt: alt, height: height, width: width });
    }
    return ((0, jsx_runtime_1.jsx)("div", __assign({ style: __assign(__assign({ width: "100%" }, style), { display: "inline-block" }) }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ style: { position: "relative", width: "100%" } }, { children: (0, jsx_runtime_1.jsx)(image_1.default, { src: src, alt: alt, layout: "responsive", width: width, priority: priority }) })) })));
}
exports.default = Image;
//# sourceMappingURL=image.js.map