"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.fetchInlineAsset = fetchInlineAsset;
var _fs = require("fs");
var _path = _interopRequireDefault(require("path"));
var _bodyStreams = require("../../body-streams");
function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
async function fetchInlineAsset(options) {
    var ref;
    const inputString = String(options.input);
    if (!inputString.startsWith("blob:")) {
        return;
    }
    const hash = inputString.replace("blob:", "");
    const asset = (ref = options.assets) == null ? void 0 : ref.find((x)=>x.name === hash);
    if (!asset) {
        return;
    }
    const filePath = _path.default.resolve(options.distDir, asset.filePath);
    const fileIsReadable = await _fs.promises.access(filePath).then(()=>true, ()=>false);
    if (fileIsReadable) {
        const readStream = (0, _fs).createReadStream(filePath);
        return new options.context.Response((0, _bodyStreams).requestToBodyStream(readStream));
    }
}

//# sourceMappingURL=fetch-inline-assets.js.map