globalThis.IMBA_MANIFEST={} var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, { get: (a, b) => (typeof require < "u" ? require : a)[b] }) : x)(function(x) { if (typeof require < "u") return require.apply(this, arguments); throw new Error('Dynamic require of "' + x + '" is not supported'); }); // src/utils/compile.ts import { compile } from "imba/compiler"; // src/utils/hash.ts import * as crypto from "crypto"; var 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 import { cyan, yellow, red } from "kleur/colors"; import debug from "debug"; var levels = ["debug", "info", "warn", "error", "silent"], prefix = "vite-plugin-imba", loggers = { debug: { log: debug(`vite:${prefix}`), enabled: !1, isDebug: !0 }, info: { color: cyan, log: console.log, enabled: !0 }, warn: { color: yellow, log: console.warn, enabled: !0 }, error: { color: 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 = /