globalThis.IMBA_MANIFEST={} "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); // src/index.imba var src_exports = {}; __export(src_exports, { imba: () => imba }); module.exports = __toCommonJS(src_exports); // src/utils/compile.ts var import_compiler = require("imba/compiler"); // src/utils/hash.ts var crypto = __toESM(require("crypto"), 1), hashes = /* @__PURE__ */ Object.create(null), hash_length = 12; function safeBase64Hash(input) { if (hashes[input]) return hashes[input]; let md5 = crypto.createHash("md5"); md5.update(input); let hash = toSafe(md5.digest("base64")).slice(0, hash_length); return hashes[input] = hash, hash; } var replacements = { "+": "-", "/": "_", "=": "" }, replaceRE = new RegExp(`[${Object.keys(replacements).join("")}]`, "g"); function toSafe(base64) { return base64.replace(replaceRE, (x) => replacements[x]); } // src/utils/log.ts var import_colors = require("kleur/colors"), import_debug = __toESM(require("debug"), 1), levels = ["debug", "info", "warn", "error", "silent"], prefix = "vite-plugin-imba", loggers = { debug: { log: (0, import_debug.default)(`vite:${prefix}`), enabled: !1, isDebug: !0 }, info: { color: import_colors.cyan, log: console.log, enabled: !0 }, warn: { color: import_colors.yellow, log: console.warn, enabled: !0 }, error: { color: import_colors.red, log: console.error, enabled: !0 }, silent: { enabled: !1 } }, _level = "info"; function setLevel(level) { if (level === _level) return; let levelIndex = levels.indexOf(level); if (levelIndex > -1) { _level = level; for (let i = 0; i < levels.length; i++) loggers[levels[i]].enabled = i >= levelIndex; } else _log(loggers.error, `invalid log level: ${level} `); } function _log(logger, message, payload) { !logger.enabled || (logger.isDebug ? payload !== void 0 ? logger.log(message, payload) : logger.log(message) : (logger.log(logger.color(`${new Date().toLocaleTimeString()} [${prefix}] ${message}`)), payload && logger.log(payload))); } function createLogger(level) { let logger = loggers[level], logFn = _log.bind(null, logger), logged = /* @__PURE__ */ new Set(), once = function(message, payload) { logged.has(message) || (logged.add(message), logFn.apply(null, [message, payload])); }; return Object.defineProperty(logFn, "enabled", { get() { return logger.enabled; } }), Object.defineProperty(logFn, "once", { get() { return once; } }), logFn; } var log = { debug: createLogger("debug"), info: createLogger("info"), warn: createLogger("warn"), error: createLogger("error"), setLevel }; function logCompilerWarnings(imbaRequest, warnings, options) { var _a, _b, _c; let { emitCss, onwarn, isBuild } = options, sendViaWS = !isBuild && ((_a = options.experimental) == null ? void 0 : _a.sendWarningsToBrowser), warn = isBuild ? warnBuild : warnDev, handledByDefaultWarn = [], notIgnored = warnings == null ? void 0 : warnings.filter((w) => !ignoreCompilerWarning(w, isBuild, emitCss)), extra = buildExtraWarnings(warnings, isBuild), allWarnings = [...notIgnored, ...extra]; if (sendViaWS) { let _warn = warn; warn = (w) => { handledByDefaultWarn.push(w), _warn(w); }; } if (allWarnings.forEach((warning) => { onwarn ? onwarn(warning, warn) : warn(warning); }), sendViaWS) { let message = { id: imbaRequest.id, filename: imbaRequest.filename, normalizedFilename: imbaRequest.normalizedFilename, timestamp: imbaRequest.timestamp, warnings: handledByDefaultWarn, allWarnings, rawWarnings: warnings }; log.debug(`sending imba:warnings message for ${imbaRequest.normalizedFilename}`), (_c = (_b = options.server) == null ? void 0 : _b.ws) == null || _c.send("imba:warnings", message); } } function ignoreCompilerWarning(warning, isBuild, emitCss) { return !emitCss && warning.code === "css-unused-selector" || !isBuild && isNoScopableElementWarning(warning); } function isNoScopableElementWarning(warning) { return warning.code === "css-unused-selector" && warning.message.includes('"*"'); } function buildExtraWarnings(warnings, isBuild) { let extraWarnings = []; if (!isBuild) { let noScopableElementWarnings = warnings.filter((w) => isNoScopableElementWarning(w)); if (noScopableElementWarnings.length > 0) { let noScopableElementWarning = noScopableElementWarnings[noScopableElementWarnings.length - 1]; extraWarnings.push({ ...noScopableElementWarning, code: "vite-plugin-imba-css-no-scopable-elements", message: "No scopable elements found in template. If you're using global styles in the style tag, you should move it into an external stylesheet file and import it in JS. See https://github.com/imbajs/vite-plugin-imba/blob/main/docs/faq.md#where-should-i-put-my-global-styles." }); } } return extraWarnings; } function warnDev(w) { log.info.enabled && log.info(buildExtendedLogMessage(w)); } function warnBuild(w) { log.warn.enabled && log.warn(buildExtendedLogMessage(w), w.frame); } function buildExtendedLogMessage(w) { let parts = []; return w.filename && parts.push(w.filename), w.start && parts.push(":", w.start.line, ":", w.start.column), w.message && (parts.length > 0 && parts.push(" "), parts.push(w.message)), parts.join(""); } // src/utils/compile.ts var scriptLangRE = /