"use strict";
var __webpack_modules__ = {
    "@swc/core" (module) {
        module.exports = require("@swc/core");
    }
};
var __webpack_module_cache__ = {};
function __webpack_require__(moduleId) {
    var cachedModule = __webpack_module_cache__[moduleId];
    if (void 0 !== cachedModule) return cachedModule.exports;
    var module = __webpack_module_cache__[moduleId] = {
        exports: {}
    };
    __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
    return module.exports;
}
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
(()=>{
    __webpack_require__.r(__webpack_exports__);
    __webpack_require__.d(__webpack_exports__, {
        default: ()=>resolvePathsLoader
    });
    const external_path_namespaceObject = require("path");
    const external_fs_namespaceObject = require("fs");
    const external_magic_string_namespaceObject = require("magic-string");
    var external_magic_string_default = /*#__PURE__*/ __webpack_require__.n(external_magic_string_namespaceObject);
    function getFilename(feature, filePath) {
        const entryExt = external_path_namespaceObject.extname(filePath);
        let fileOutputpath = feature;
        if ([
            '.js',
            '.jsx',
            '.tsx',
            '.ts'
        ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.js');
        if ([
            '.html',
            '.njk',
            '.nunjucks'
        ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.html');
        if ([
            '.css',
            '.scss',
            '.sass',
            '.less'
        ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.css');
        return unixify(fileOutputpath || '');
    }
    function unixify(filePath) {
        return filePath.replace(/\\/g, '/');
    }
    function memberChainFromCallee(callee) {
        const memberParts = [];
        let currentExpression = callee;
        while(currentExpression && 'ParenExpression' === currentExpression.type)currentExpression = currentExpression.expression;
        while(currentExpression){
            if ('Identifier' === currentExpression.type) {
                memberParts.unshift(currentExpression.value);
                break;
            }
            if ('MemberExpression' === currentExpression.type) {
                const propertyNode = currentExpression.property;
                if (propertyNode?.type === 'Identifier') memberParts.unshift(propertyNode.value);
                currentExpression = currentExpression.object;
                continue;
            }
            break;
        }
        return memberParts;
    }
    function getPropName(propertyNode) {
        if (!propertyNode || 'KeyValueProperty' !== propertyNode.type) return;
        const keyNode = propertyNode.key;
        if (keyNode?.type === 'Identifier') return keyNode.value;
        if (keyNode?.type === 'StringLiteral') return keyNode.value;
    }
    function isHttpLike(input) {
        return /^https?:\/\//i.test(input) || /^data:/i.test(input) || /^chrome:\/\//i.test(input) || /^moz-extension:\/\//i.test(input);
    }
    function hasGlob(input) {
        return /[*?\[\]{}]/.test(input);
    }
    function resolveLiteralToOutput(literal, opts) {
        const { manifestPath, packageJsonDir, authorFilePath } = opts;
        const root = packageJsonDir || external_path_namespaceObject.dirname(manifestPath);
        const canonicalUnixPath = unixify(literal || '');
        if (!literal || isHttpLike(literal) || hasGlob(literal)) return;
        if (/^\/public\//i.test(canonicalUnixPath)) {
            const out = canonicalUnixPath.replace(/^\/public\//i, '');
            return out;
        }
        if (/^(?:\.\/)?public\//i.test(canonicalUnixPath)) {
            const out = canonicalUnixPath.replace(/^(?:\.\/)?public\//i, '');
            return out;
        }
        if (/^\//.test(canonicalUnixPath)) {
            const trimmed = canonicalUnixPath.replace(/^\//, '');
            if (/^(?:pages|scripts)\//i.test(trimmed)) {
                const abs = external_path_namespaceObject.join(root, trimmed);
                return unixify(getFilename(trimmed, abs));
            }
            return trimmed;
        }
        const baseDir = /^(\.\/|\.\.\/)/.test(canonicalUnixPath) && authorFilePath ? external_path_namespaceObject.dirname(authorFilePath) : root;
        const candidateAbsolutePath = external_path_namespaceObject.isAbsolute(literal) ? literal : external_path_namespaceObject.resolve(baseDir, literal);
        const pathWithoutDotPrefix = canonicalUnixPath.replace(/^\.\//, '');
        if (/^pages\//i.test(pathWithoutDotPrefix)) return unixify(getFilename(pathWithoutDotPrefix, candidateAbsolutePath));
        if (/^scripts\//i.test(pathWithoutDotPrefix)) return unixify(getFilename(pathWithoutDotPrefix, candidateAbsolutePath));
        try {
            const normalizedRel = unixify(external_path_namespaceObject.relative(root, candidateAbsolutePath));
            const relNoDotPrefix = normalizedRel.replace(/^\.\//, '');
            if (/^public\//i.test(relNoDotPrefix)) return relNoDotPrefix.replace(/^public\//i, '');
            if (/^pages\//i.test(relNoDotPrefix)) return unixify(getFilename(relNoDotPrefix, candidateAbsolutePath));
            if (/^scripts\//i.test(relNoDotPrefix)) return unixify(getFilename(relNoDotPrefix, candidateAbsolutePath));
        } catch  {}
    }
    function isStringLiteral(node) {
        return node && 'StringLiteral' === node.type && 'string' == typeof node.value;
    }
    function isStaticTemplate(node) {
        return node && 'TemplateLiteral' === node.type && Array.isArray(node.expressions) && 0 === node.expressions.length;
    }
    function evalStaticString(node) {
        if (!node) return;
        if (node && 'ParenExpression' === node.type) return evalStaticString(node.expression);
        if (isStringLiteral(node)) return node.value;
        if (isStaticTemplate(node)) return node.quasis?.map((quasi)=>quasi.raw ?? '').join('');
        if (node && 'BinaryExpression' === node.type && '+' === node.operator) {
            const left = evalStaticString(node.left);
            const right = evalStaticString(node.right);
            if ('string' == typeof left && 'string' == typeof right) return left + right;
        }
    }
    function handleRuntimeCalls(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if ((method.endsWith('runtime.getURL') || method.endsWith('extension.getURL')) && node.arguments?.[0]) {
            const firstArgument = node.arguments[0].expression;
            if (isStringLiteral(firstArgument)) {
                const resolved = resolveLiteralToOutput(firstArgument.value, {
                    manifestPath
                });
                rewriteValue(firstArgument, resolved, firstArgument.value);
            } else if (isStaticTemplate(firstArgument)) {
                const rawTemplate = source.slice(firstArgument.span.start + 1, firstArgument.span.end - 1);
                const resolved = resolveLiteralToOutput(rawTemplate, {
                    manifestPath
                });
                rewriteValue(firstArgument, resolved, rawTemplate);
            }
            return true;
        }
        return false;
    }
    function handleActionAndPopup(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('action.setIcon') || method.endsWith('pageAction.setIcon') || method.endsWith('browserAction.setIcon')) {
            const firstArgument = node.arguments?.[0]?.expression;
            if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyName = getPropName(propertyNode);
                if ('path' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (isStringLiteral(valueNode)) {
                    const resolved = resolveLiteralToOutput(valueNode.value, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, valueNode.value);
                } else if (valueNode?.type === 'ObjectExpression') {
                    for (const innerProperty of valueNode.properties || [])if ('KeyValueProperty' === innerProperty.type && isStringLiteral(innerProperty.value)) {
                        const resolved = resolveLiteralToOutput(innerProperty.value.value, {
                            manifestPath
                        });
                        rewriteValue(innerProperty.value, resolved, innerProperty.value.value);
                    } else if ('KeyValueProperty' === innerProperty.type && isStaticTemplate(innerProperty.value)) {
                        const raw = source.slice(innerProperty.value.span.start + 1, innerProperty.value.span.end - 1);
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        rewriteValue(innerProperty.value, resolved, raw);
                    } else if ('KeyValueProperty' === innerProperty.type) {
                        const raw = evalStaticString(innerProperty.value);
                        if ('string' == typeof raw) {
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            const originalExpr = source.slice(innerProperty.value.span.start, innerProperty.value.span.end);
                            rewriteValue(innerProperty.value, resolved, originalExpr);
                        }
                    }
                } else if (isStaticTemplate(valueNode)) {
                    const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                    const resolved = resolveLiteralToOutput(raw, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, raw);
                } else {
                    const raw = evalStaticString(valueNode);
                    if ('string' == typeof raw) {
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                        rewriteValue(valueNode, resolved, originalExpr);
                    }
                }
            }
            return true;
        }
        if (method.endsWith('action.setPopup') || method.endsWith('pageAction.setPopup') || method.endsWith('browserAction.setPopup')) {
            const firstArgument = node.arguments?.[0]?.expression;
            if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyName = getPropName(propertyNode);
                if ('popup' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (isStringLiteral(valueNode)) {
                    const resolved = resolveLiteralToOutput(valueNode.value, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved);
                } else if (isStaticTemplate(valueNode)) {
                    const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                    const resolved = resolveLiteralToOutput(raw, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved);
                } else {
                    const raw = evalStaticString(valueNode);
                    if ('string' == typeof raw) {
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                        rewriteValue(valueNode, resolved, originalExpr);
                    }
                }
            }
            return true;
        }
        return false;
    }
    function handleDevtools(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('devtools.panels.create')) {
            const iconArg = node.arguments?.[1]?.expression;
            const pageArg = node.arguments?.[2]?.expression;
            let touched = false;
            if (isStringLiteral(iconArg)) {
                const resolved = resolveLiteralToOutput(iconArg.value, {
                    manifestPath
                });
                rewriteValue(iconArg, resolved, iconArg.value);
                touched = true;
            } else if (isStaticTemplate(iconArg)) {
                const rawTemplate = source.slice(iconArg.span.start + 1, iconArg.span.end - 1);
                const resolved = resolveLiteralToOutput(rawTemplate, {
                    manifestPath
                });
                rewriteValue(iconArg, resolved, rawTemplate);
            } else {
                const staticallyEvaluated = evalStaticString(iconArg);
                if ('string' == typeof staticallyEvaluated) {
                    const resolved = resolveLiteralToOutput(staticallyEvaluated, {
                        manifestPath
                    });
                    const originalExpr = source.slice(iconArg.span.start, iconArg.span.end);
                    rewriteValue(iconArg, resolved, originalExpr);
                    touched = true;
                }
            }
            if (isStringLiteral(pageArg)) {
                const resolved = resolveLiteralToOutput(pageArg.value, {
                    manifestPath
                });
                rewriteValue(pageArg, resolved, pageArg.value);
                touched = true;
            } else if (isStaticTemplate(pageArg)) {
                const rawTemplate = source.slice(pageArg.span.start + 1, pageArg.span.end - 1);
                const resolved = resolveLiteralToOutput(rawTemplate, {
                    manifestPath
                });
                rewriteValue(pageArg, resolved, rawTemplate);
            } else {
                const staticallyEvaluated = evalStaticString(pageArg);
                if ('string' == typeof staticallyEvaluated) {
                    const resolved = resolveLiteralToOutput(staticallyEvaluated, {
                        manifestPath
                    });
                    const originalExpr = source.slice(pageArg.span.start, pageArg.span.end);
                    rewriteValue(pageArg, resolved, originalExpr);
                    touched = true;
                }
            }
            return touched;
        }
        return false;
    }
    function handleTabsAndWindows(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('tabs.create') || method.endsWith('windows.create')) {
            const firstArgument = node.arguments?.[0]?.expression;
            if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyName = getPropName(propertyNode);
                if ('url' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (isStringLiteral(valueNode)) {
                    const resolved = resolveLiteralToOutput(valueNode.value, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, valueNode.value);
                } else if (valueNode?.type === 'ArrayExpression') for (const arrayElement of valueNode.elements || []){
                    const literalNode = arrayElement?.expression;
                    if (isStringLiteral(literalNode)) {
                        const resolved = resolveLiteralToOutput(literalNode.value, {
                            manifestPath
                        });
                        rewriteValue(literalNode, resolved, literalNode.value);
                    } else if (isStaticTemplate(literalNode)) {
                        const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        rewriteValue(literalNode, resolved, raw);
                    } else {
                        const raw = evalStaticString(literalNode);
                        if ('string' == typeof raw) {
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
                            rewriteValue(literalNode, resolved, originalExpr);
                        }
                    }
                }
                else if (isStaticTemplate(valueNode)) {
                    const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                    const resolved = resolveLiteralToOutput(raw, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, raw);
                } else {
                    const raw = evalStaticString(valueNode);
                    if ('string' == typeof raw) {
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                        rewriteValue(valueNode, resolved, originalExpr);
                    }
                }
            }
            return true;
        }
        if (method.endsWith('tabs.update')) {
            const optionsArgument = node.arguments?.[1]?.expression || node.arguments?.[0]?.expression;
            if (optionsArgument?.type === 'ObjectExpression') for (const propertyNode of optionsArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyName = getPropName(propertyNode);
                if ('url' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (isStringLiteral(valueNode)) {
                    const resolved = resolveLiteralToOutput(valueNode.value, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, valueNode.value);
                } else if (isStaticTemplate(valueNode)) {
                    const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                    const resolved = resolveLiteralToOutput(raw, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, raw);
                } else {
                    const raw = evalStaticString(valueNode);
                    if ('string' == typeof raw) {
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                        rewriteValue(valueNode, resolved, originalExpr);
                    }
                }
            }
            return true;
        }
        return false;
    }
    function handleScripting(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith("scripting.registerContentScripts")) {
            for (const argumentNode of node.arguments || []){
                const arrayExpressionNode = argumentNode?.expression;
                if (arrayExpressionNode && 'ArrayExpression' === arrayExpressionNode.type) for (const arrayElement of arrayExpressionNode.elements || []){
                    const objectExpressionNode = arrayElement?.expression;
                    if (objectExpressionNode && 'ObjectExpression' === objectExpressionNode.type) for (const propertyNode of objectExpressionNode.properties || []){
                        if ('KeyValueProperty' !== propertyNode.type) continue;
                        const keyName = getPropName(propertyNode);
                        if ('js' !== keyName && 'css' !== keyName) continue;
                        const valueNode = propertyNode.value;
                        if ('ArrayExpression' === valueNode.type) for (const innerItem of valueNode.elements || []){
                            const literalNode = innerItem?.expression;
                            if (isStringLiteral(literalNode)) {
                                const resolved = resolveLiteralToOutput(literalNode.value, {
                                    manifestPath
                                });
                                rewriteValue(literalNode, resolved, literalNode.value);
                            } else if (isStaticTemplate(literalNode)) {
                                const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
                                const resolved = resolveLiteralToOutput(raw, {
                                    manifestPath
                                });
                                rewriteValue(literalNode, resolved, raw);
                            } else {
                                const raw = evalStaticString(literalNode);
                                if ('string' == typeof raw) {
                                    const resolved = resolveLiteralToOutput(raw, {
                                        manifestPath
                                    });
                                    const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
                                    rewriteValue(literalNode, resolved, originalExpr);
                                }
                            }
                        }
                        else if (isStringLiteral(valueNode)) {
                            const resolved = resolveLiteralToOutput(valueNode.value, {
                                manifestPath
                            });
                            rewriteValue(valueNode, resolved, valueNode.value);
                        } else if (isStaticTemplate(valueNode)) {
                            const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            rewriteValue(valueNode, resolved, raw);
                        } else {
                            const raw = evalStaticString(valueNode);
                            if ('string' == typeof raw) {
                                const resolved = resolveLiteralToOutput(raw, {
                                    manifestPath
                                });
                                const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                                rewriteValue(valueNode, resolved, originalExpr);
                            }
                        }
                    }
                }
            }
            return true;
        }
        if (method.endsWith("scripting.executeScript") || method.endsWith("scripting.insertCSS")) {
            const firstArgument = node.arguments?.[0]?.expression;
            if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyName = getPropName(propertyNode);
                if ('files' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (valueNode?.type === 'ArrayExpression') for (const arrayElement of valueNode.elements || []){
                    const literalNode = arrayElement?.expression;
                    if (isStringLiteral(literalNode)) {
                        const resolved = resolveLiteralToOutput(literalNode.value, {
                            manifestPath
                        });
                        rewriteValue(literalNode, resolved, literalNode.value);
                    } else if (isStaticTemplate(literalNode)) {
                        const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        rewriteValue(literalNode, resolved, raw);
                    } else {
                        const raw = evalStaticString(literalNode);
                        if ('string' == typeof raw) {
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
                            rewriteValue(literalNode, resolved, originalExpr);
                        }
                    }
                }
            }
            return true;
        }
        return false;
    }
    function handleMv2Tabs(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('tabs.executeScript') || method.endsWith('tabs.insertCSS')) {
            const firstArgument = node.arguments?.[0]?.expression;
            if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyName = getPropName(propertyNode);
                if ('file' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (isStringLiteral(valueNode)) {
                    const resolved = resolveLiteralToOutput(valueNode.value, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, valueNode.value);
                } else if (isStaticTemplate(valueNode)) {
                    const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                    const resolved = resolveLiteralToOutput(raw, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, raw);
                } else {
                    const raw = evalStaticString(valueNode);
                    if ('string' == typeof raw) {
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                        rewriteValue(valueNode, resolved, originalExpr);
                    }
                }
            }
            return true;
        }
        return false;
    }
    function handlePanels(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('sidePanel.setOptions') || method.endsWith('sidebarAction.setPanel')) {
            const firstArgument = node.arguments?.[0]?.expression;
            if (method.endsWith('sidebarAction.setPanel')) {
                const arg = firstArgument;
                if (isStringLiteral(arg)) {
                    const resolved = resolveLiteralToOutput(arg.value, {
                        manifestPath
                    });
                    rewriteValue(arg, resolved, arg.value);
                    return true;
                }
                if (isStaticTemplate(arg)) {
                    const raw = source.slice(arg.span.start + 1, arg.span.end - 1);
                    const resolved = resolveLiteralToOutput(raw, {
                        manifestPath
                    });
                    rewriteValue(arg, resolved, raw);
                    return true;
                }
                {
                    const raw = evalStaticString(arg);
                    if ('string' == typeof raw) {
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        const originalExpr = source.slice(arg.span.start, arg.span.end);
                        rewriteValue(arg, resolved, originalExpr);
                        return true;
                    }
                }
            }
            if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyName = getPropName(propertyNode);
                if ('path' === keyName || 'panel' === keyName || 'page' === keyName) {
                    const valueNode = propertyNode.value;
                    if (isStringLiteral(valueNode)) {
                        const resolved = resolveLiteralToOutput(valueNode.value, {
                            manifestPath
                        });
                        rewriteValue(valueNode, resolved, valueNode.value);
                    } else if (isStaticTemplate(valueNode)) {
                        const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        rewriteValue(valueNode, resolved, raw);
                    } else {
                        const raw = evalStaticString(valueNode);
                        if ('string' == typeof raw) {
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                            rewriteValue(valueNode, resolved, originalExpr);
                        }
                    }
                }
            }
            return true;
        }
        return false;
    }
    function handleNotifications(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('notifications.create') || method.endsWith('notifications.update')) {
            const optionsArgument = node.arguments?.[1]?.expression || node.arguments?.[0]?.expression;
            if (optionsArgument?.type === 'ObjectExpression') {
                let touched = false;
                for (const propertyNode of optionsArgument.properties || []){
                    if ('KeyValueProperty' !== propertyNode.type) continue;
                    const keyName = getPropName(propertyNode);
                    if ('iconUrl' === keyName || 'imageUrl' === keyName) {
                        const valueNode = propertyNode.value;
                        if (isStringLiteral(valueNode)) {
                            const resolved = resolveLiteralToOutput(valueNode.value, {
                                manifestPath
                            });
                            rewriteValue(valueNode, resolved, valueNode.value);
                            touched = true;
                        } else if (isStaticTemplate(valueNode)) {
                            const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            rewriteValue(valueNode, resolved, raw);
                            touched = true;
                        } else {
                            const raw = evalStaticString(valueNode);
                            if ('string' == typeof raw) {
                                const resolved = resolveLiteralToOutput(raw, {
                                    manifestPath
                                });
                                const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                                rewriteValue(valueNode, resolved, originalExpr);
                                touched = true;
                            }
                        }
                    }
                }
                if (touched) return true;
            }
        }
        return false;
    }
    function handleMenus(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('contextMenus.create') || method.endsWith('contextMenus.update') || method.endsWith('menus.create') || method.endsWith('menus.update')) {
            const firstArgument = node.arguments?.[0]?.expression;
            if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyNode = propertyNode.key;
                const keyName = keyNode?.type === 'Identifier' ? keyNode.value : keyNode?.value;
                if ('icons' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (valueNode?.type === 'ObjectExpression') for (const innerProperty of valueNode.properties || []){
                    if ('KeyValueProperty' !== innerProperty.type) continue;
                    const innerValue = innerProperty.value;
                    if (isStringLiteral(innerValue)) {
                        const resolved = resolveLiteralToOutput(innerValue.value, {
                            manifestPath
                        });
                        rewriteValue(innerValue, resolved, innerValue.value);
                    } else if (isStaticTemplate(innerValue)) {
                        const raw = source.slice(innerValue.span.start + 1, innerValue.span.end - 1);
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        rewriteValue(innerValue, resolved, raw);
                    } else {
                        const raw = evalStaticString(innerValue);
                        if ('string' == typeof raw) {
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            const originalExpr = source.slice(innerValue.span.start, innerValue.span.end);
                            rewriteValue(innerValue, resolved, originalExpr);
                        }
                    }
                }
            }
            return true;
        }
        return false;
    }
    function handleDeclarativeContent(node, source, rewriteValue, manifestPath) {
        if ('NewExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        const method = memberChain.join('.');
        if (method.endsWith('declarativeContent.SetIcon')) {
            const arg0 = node.arguments?.[0];
            const optionsArgument = arg0 && arg0.expression || arg0;
            if (optionsArgument?.type === 'ObjectExpression') for (const propertyNode of optionsArgument.properties || []){
                if ('KeyValueProperty' !== propertyNode.type) continue;
                const keyNode = propertyNode.key;
                const keyName = keyNode?.type === 'Identifier' ? keyNode.value : keyNode?.value;
                if ('path' !== keyName) continue;
                const valueNode = propertyNode.value;
                if (isStringLiteral(valueNode)) {
                    const resolved = resolveLiteralToOutput(valueNode.value, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, valueNode.value);
                } else if (valueNode?.type === 'ObjectExpression') for (const innerProperty of valueNode.properties || []){
                    if ('KeyValueProperty' !== innerProperty.type) continue;
                    const innerValue = innerProperty.value;
                    if (isStringLiteral(innerValue)) {
                        const resolved = resolveLiteralToOutput(innerValue.value, {
                            manifestPath
                        });
                        rewriteValue(innerValue, resolved, innerValue.value);
                    } else if (isStaticTemplate(innerValue)) {
                        const raw = source.slice(innerValue.span.start + 1, innerValue.span.end - 1);
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        rewriteValue(innerValue, resolved, raw);
                    } else {
                        const raw = evalStaticString(innerValue);
                        if ('string' == typeof raw) {
                            const resolved = resolveLiteralToOutput(raw, {
                                manifestPath
                            });
                            const originalExpr = source.slice(innerValue.span.start, innerValue.span.end);
                            rewriteValue(innerValue, resolved, originalExpr);
                        }
                    }
                }
                else if (isStaticTemplate(valueNode)) {
                    const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
                    const resolved = resolveLiteralToOutput(raw, {
                        manifestPath
                    });
                    rewriteValue(valueNode, resolved, raw);
                } else {
                    const raw = evalStaticString(valueNode);
                    if ('string' == typeof raw) {
                        const resolved = resolveLiteralToOutput(raw, {
                            manifestPath
                        });
                        const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
                        rewriteValue(valueNode, resolved, originalExpr);
                    }
                }
            }
            return true;
        }
        return false;
    }
    const ALLOWED_KEYS = new Set([
        'url',
        'file',
        'files',
        'path',
        'popup',
        'panel',
        'page',
        'iconUrl',
        'imageUrl',
        'default_icon',
        'default_popup',
        'default_panel'
    ]);
    function processValue(valueNode, source, rewriteValue, manifestPath) {
        if (!valueNode) return;
        if (isStringLiteral(valueNode)) {
            const out = resolveLiteralToOutput(valueNode.value, {
                manifestPath
            });
            rewriteValue(valueNode, out, valueNode.value);
            return;
        }
        if (isStaticTemplate(valueNode)) {
            const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
            const out = resolveLiteralToOutput(raw, {
                manifestPath
            });
            rewriteValue(valueNode, out, raw);
            return;
        }
        const raw = evalStaticString(valueNode);
        if ('string' == typeof raw) {
            const out = resolveLiteralToOutput(raw, {
                manifestPath
            });
            const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
            rewriteValue(valueNode, out, originalExpr);
            return;
        }
    }
    function walkCandidate(containerNode, onCandidateValue) {
        if (!containerNode) return;
        if ('ArrayExpression' === containerNode.type) {
            for (const elementNode of containerNode.elements || [])onCandidateValue(elementNode?.expression);
            return;
        }
        if ('ObjectExpression' === containerNode.type) for (const propertyNode of containerNode.properties || []){
            if ('KeyValueProperty' !== propertyNode.type) continue;
            const key = getPropName(propertyNode);
            if (key) {
                if (ALLOWED_KEYS.has(key)) onCandidateValue(propertyNode.value);
                if (propertyNode.value?.type === 'ArrayExpression' || propertyNode.value?.type === 'ObjectExpression') if (('default_icon' === key || 'path' === key) && propertyNode.value?.type === 'ObjectExpression') {
                    for (const sizeProp of propertyNode.value.properties || [])if ('KeyValueProperty' === sizeProp.type) onCandidateValue(sizeProp.value);
                } else walkCandidate(propertyNode.value, onCandidateValue);
            }
        }
    }
    function handleGenericApiPaths(node, source, rewriteValue, manifestPath) {
        if ('CallExpression' !== node.type) return false;
        const memberChain = memberChainFromCallee(node.callee);
        const apiRoot = memberChain[0];
        if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
        let touched = false;
        for (const argumentNode of node.arguments || []){
            const expressionNode = argumentNode?.expression;
            if (expressionNode) {
                if ('ObjectExpression' === expressionNode.type || 'ArrayExpression' === expressionNode.type) walkCandidate(expressionNode, (candidateValue)=>{
                    const touchedBefore = touched;
                    processValue(candidateValue, source, rewriteValue, manifestPath);
                    if (!touchedBefore) touched = true;
                });
            }
        }
        return touched;
    }
    function handleCallExpression(node, source, rewriteValue, manifestPath) {
        if (handleRuntimeCalls(node, source, rewriteValue, manifestPath)) return;
        if (handleActionAndPopup(node, source, rewriteValue, manifestPath)) return;
        if (handleDevtools(node, source, rewriteValue, manifestPath)) return;
        if (handleTabsAndWindows(node, source, rewriteValue, manifestPath)) return;
        if (handleScripting(node, source, rewriteValue, manifestPath)) return;
        if (handleMv2Tabs(node, source, rewriteValue, manifestPath)) return;
        if (handlePanels(node, source, rewriteValue, manifestPath)) return;
        if (handleNotifications(node, source, rewriteValue, manifestPath)) return;
        if (handleMenus(node, source, rewriteValue, manifestPath)) return;
        if (handleDeclarativeContent(node, source, rewriteValue, manifestPath)) return;
        try {
            handleGenericApiPaths(node, source, rewriteValue, manifestPath);
        } catch  {}
    }
    function isJsxLikePath(filePath) {
        return 'string' == typeof filePath && /\.[cm]?[jt]sx$/.test(String(filePath));
    }
    function stripNestedQuotes(value) {
        const match = /^(['"])(.*)\1$/.exec(value);
        return match ? match[2] : value;
    }
    function normalizeLiteralPayload(value) {
        const withForwardSlashes = value.replace(/\\/g, '/');
        const withCollapsed = withForwardSlashes.replace(/\/{2,}/g, '/');
        return stripNestedQuotes(withCollapsed);
    }
    function isLikelyApiContextAt(source, atIndex) {
        if ('number' != typeof atIndex) return false;
        const start = Math.max(0, atIndex - 200);
        const neighborhood = source.slice(start, atIndex);
        return /(chrome|browser)\s*\.(?:tabs|windows|scripting|action|sidePanel|sidebarAction|devtools|runtime|extension)\b/.test(neighborhood);
    }
    function resolveAndNormalizeLiteral(literal, ctx) {
        const normalizedInput = normalizeLiteralPayload(literal);
        const resolved = resolveLiteralToOutput(normalizedInput, {
            manifestPath: ctx.manifestPath,
            packageJsonDir: ctx.packageJsonDir,
            authorFilePath: ctx.authorFilePath
        });
        return normalizeLiteralPayload(resolved ?? normalizedInput);
    }
    function replaceRuntimeGetURL(source, input, ctx) {
        const rx = /(\.(?:runtime|extension)\.getURL\()\s*(['"])(.*?)\2(\))/g;
        function onMatch(full, pre, q, p, post, offset) {
            try {
                const resolved = resolveLiteralToOutput(normalizeLiteralPayload(p), {
                    manifestPath: ctx.manifestPath,
                    packageJsonDir: ctx.packageJsonDir,
                    authorFilePath: ctx.authorFilePath
                });
                const computed = normalizeLiteralPayload(resolved ?? p);
                try {
                    ctx.onResolvedLiteral?.(p, resolved ?? void 0, offset);
                } catch  {}
                return `${pre}${q}${computed}${q}${post}`;
            } catch  {
                return full;
            }
        }
        return input.replace(rx, onMatch);
    }
    function replaceObjectKeyLiterals(source, input, keys, ctx) {
        for (const key of keys){
            const rx = new RegExp(`(${key}\\s*:\\s*)(['"])(.*?)\\2`, 'g');
            function onMatch(full, pre, q, p, offset) {
                try {
                    const resolved = resolveLiteralToOutput(normalizeLiteralPayload(p), {
                        manifestPath: ctx.manifestPath,
                        packageJsonDir: ctx.packageJsonDir,
                        authorFilePath: ctx.authorFilePath
                    });
                    const computed = normalizeLiteralPayload(resolved ?? p);
                    try {
                        if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(p, resolved ?? void 0, offset);
                    } catch  {}
                    return `${pre}${q}${computed}${q}`;
                } catch  {
                    return full;
                }
            }
            input = input.replace(rx, onMatch);
        }
        return input;
    }
    function replaceStaticTemplateForKeys(source, input, keys, ctx) {
        const rx = new RegExp(`((?:${keys.join('|')})\\s*:\\s*)\`([^\\\`$]*)\``, 'g');
        function onMatch(full, pre, inner, offset) {
            try {
                const resolved = resolveLiteralToOutput(normalizeLiteralPayload(inner), {
                    manifestPath: ctx.manifestPath,
                    packageJsonDir: ctx.packageJsonDir,
                    authorFilePath: ctx.authorFilePath
                });
                const computed = normalizeLiteralPayload(resolved ?? inner);
                try {
                    if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(inner, resolved ?? void 0, offset);
                } catch  {}
                return `${pre}'${computed}'`;
            } catch  {
                return full;
            }
        }
        return input.replace(rx, onMatch);
    }
    function replaceConcatForKeys(source, input, keys, ctx) {
        const rx = new RegExp(`((?:${keys.join('|')})\\s*:\\s*)((?:['"][^'"]*['"]\\s*\\+\\s*)+['"][^'"]*['"])`, 'g');
        function onMatch(full, pre, expr, offset) {
            try {
                const partRe = /(['"])([^'"]*?)\1/g;
                let m;
                let concatenated = '';
                while(m = partRe.exec(expr))concatenated += m[2];
                const resolved = resolveLiteralToOutput(normalizeLiteralPayload(concatenated), {
                    manifestPath: ctx.manifestPath,
                    packageJsonDir: ctx.packageJsonDir,
                    authorFilePath: ctx.authorFilePath
                });
                const computed = normalizeLiteralPayload(resolved ?? concatenated);
                try {
                    if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(concatenated, resolved ?? void 0, offset);
                } catch  {}
                return `${pre}'${computed}'`;
            } catch  {
                return full;
            }
        }
        return input.replace(rx, onMatch);
    }
    function replaceFilesArray(source, input, ctx) {
        const rx = /(files\s*:\s*\[)([^\]]*)(\])/g;
        function onMatch(full, pre, inner, post, offset) {
            try {
                const replacedInner = inner.replace(/(['"])(.*?)(\1)/g, function(_m, q, p) {
                    try {
                        const computed = resolveAndNormalizeLiteral(p, ctx);
                        return `${q}${computed ?? p}${q}`;
                    } catch  {
                        return `${q}${p}${q}`;
                    }
                });
                try {
                    if (isLikelyApiContextAt(source, offset)) {
                        const re = /(['"])(.*?)(\1)/g;
                        let match;
                        while(match = re.exec(inner)){
                            const raw = match[2];
                            const resolved = resolveLiteralToOutput(normalizeLiteralPayload(raw), {
                                manifestPath: ctx.manifestPath,
                                packageJsonDir: ctx.packageJsonDir,
                                authorFilePath: ctx.authorFilePath
                            });
                            ctx.onResolvedLiteral?.(raw, resolved ?? void 0, offset + match.index);
                        }
                    }
                } catch  {}
                return `${pre}${replacedInner}${post}`;
            } catch  {
                return full;
            }
        }
        return input.replace(rx, onMatch);
    }
    function replaceJsCssArrays(source, input, ctx) {
        for (const key of [
            'js',
            'css'
        ]){
            const rxArr = new RegExp(`(${key}\\s*:\\s*\\[)([^\\]]*)(\\])`, 'g');
            function onMatch(full, pre, inner, post, offset) {
                try {
                    const replacedInner = String(inner).replace(/(['"])(.*?)(\1)/g, function(_m, q, p) {
                        try {
                            const computed = resolveAndNormalizeLiteral(p, ctx);
                            return `${q}${computed ?? p}${q}`;
                        } catch  {
                            return `${q}${p}${q}`;
                        }
                    });
                    try {
                        if (isLikelyApiContextAt(source, offset)) {
                            const re = /(['"])(.*?)(\1)/g;
                            let match;
                            while(match = re.exec(inner)){
                                const raw = match[2];
                                const resolved = resolveLiteralToOutput(normalizeLiteralPayload(raw), {
                                    manifestPath: ctx.manifestPath,
                                    packageJsonDir: ctx.packageJsonDir,
                                    authorFilePath: ctx.authorFilePath
                                });
                                ctx.onResolvedLiteral?.(raw, resolved ?? void 0, offset + match.index);
                            }
                        }
                    } catch  {}
                    return `${pre}${replacedInner}${post}`;
                } catch  {
                    return full;
                }
            }
            input = input.replace(rxArr, onMatch);
        }
        return input;
    }
    function cleanupPublicRootLiterals(input) {
        input = input.replace(/(['"])\/public\/([^'"]+?)\1/g, function(_m, q, p) {
            return `${q}${normalizeLiteralPayload(p)}${q}`;
        });
        input = input.replace(/(['"])public\/(.*?)\1/g, function(_m, q, p) {
            return `${q}${normalizeLiteralPayload(p)}${q}`;
        });
        return input;
    }
    function normalizeSpecialFolderExtensions(input) {
        input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(ts|tsx)\1/g, function(_m, q, p) {
            return `${q}${p}.js${q}`;
        });
        input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(njk|nunjucks)\1/g, function(_m, q, p) {
            return `${q}${p}.html${q}`;
        });
        input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(scss|sass|less)\1/g, function(_m, q, p) {
            return `${q}${p}.css${q}`;
        });
        return input;
    }
    function collapseAccidentalDoubleQuotes(input, keys) {
        const keyUnion = `(?:${keys.join('|')})`;
        input = input.replace(new RegExp(`(${keyUnion}\\s*:\\s*)''`, 'g'), "$1'");
        input = input.replace(new RegExp(`(${keyUnion}\\s*:\\s*)""`, 'g'), '$1"');
        input = input.replace(/:\s*''/g, ": '");
        input = input.replace(/:\s*""/g, ': "');
        input = input.replace(/:\s*''([^']+)'/g, ": '$1'");
        input = input.replace(/:\s*\"\"([^\"]+)\"/g, ': "$1"');
        input = input.replace(/''([^']*?)''/g, "'$1'");
        input = input.replace(/""([^"]*?)""/g, '"$1"');
        return input;
    }
    function textFallbackTransform(source, opts) {
        let output = String(source);
        const ctx = {
            manifestPath: opts.manifestPath,
            packageJsonDir: opts.packageJsonDir,
            authorFilePath: opts.authorFilePath,
            onResolvedLiteral: opts.onResolvedLiteral
        };
        output = replaceRuntimeGetURL(source, output, ctx);
        const supportedKeys = [
            'url',
            'file',
            'path',
            'iconUrl',
            'imageUrl',
            'default_icon'
        ];
        output = replaceObjectKeyLiterals(source, output, supportedKeys, ctx);
        output = replaceStaticTemplateForKeys(source, output, supportedKeys, ctx);
        output = replaceConcatForKeys(source, output, supportedKeys, ctx);
        output = replaceFilesArray(source, output, ctx);
        output = replaceJsCssArrays(source, output, ctx);
        if (!isJsxLikePath(opts.authorFilePath)) output = cleanupPublicRootLiterals(output);
        output = normalizeSpecialFolderExtensions(output);
        output = collapseAccidentalDoubleQuotes(output, supportedKeys);
        return output;
    }
    const external_module_namespaceObject = require("module");
    let swcRuntimeModule;
    async function loadSwc() {
        if (swcRuntimeModule) return swcRuntimeModule;
        try {
            const mod = await import("@swc/core");
            swcRuntimeModule = mod?.default && mod.default.parse ? mod.default : mod;
        } catch  {
            try {
                const mod = __webpack_require__("@swc/core") || (0, external_module_namespaceObject.createRequire)(__filename)('@swc/core');
                swcRuntimeModule = mod?.default && mod.default.parse ? mod.default : mod;
            } catch  {}
        }
        return swcRuntimeModule || null;
    }
    async function parseWithSwc(swc, source, flags) {
        return swc.parse(source, {
            syntax: flags.isTS ? "typescript" : "ecmascript",
            tsx: flags.isTS && flags.isJSX,
            jsx: !flags.isTS && flags.isJSX,
            target: 'es2022',
            isModule: true
        });
    }
    async function resolvePathsLoader(source) {
        const callback = this.async();
        const options = this.getOptions?.() || {};
        const manifestPath = options.manifestPath;
        const packageJsonDir = options.packageJsonDir;
        const outputPath = String(options.outputPath || '');
        const sourceMapsOpt = 'boolean' == typeof options.sourceMaps || 'auto' === options.sourceMaps ? options.sourceMaps : 'auto';
        this.cacheable && this.cacheable();
        const emittedBodies = new Set();
        const emitStandardWarning = (headerFilePath, bodyLines)=>{
            const bodyMessage = bodyLines.join('\n');
            if (emittedBodies.has(bodyMessage)) return;
            emittedBodies.add(bodyMessage);
            const warning = new Error(bodyMessage);
            warning.file = headerFilePath;
            this.emitWarning?.(warning);
        };
        const warnIfMissingPublic = (original, computed)=>{
            try {
                const canonical = unixify(original || '');
                const authorUsedRoot = /^\//.test(canonical);
                if (computed) {
                    if (/^(?:pages|scripts)\//i.test(computed)) return;
                    const root = packageJsonDir || external_path_namespaceObject.dirname(manifestPath);
                    const sourcePublicAbs = external_path_namespaceObject.join(root, 'public', computed);
                    if (!external_fs_namespaceObject.existsSync(sourcePublicAbs)) {
                        const displayPath = authorUsedRoot && outputPath ? external_path_namespaceObject.join(outputPath, computed) : sourcePublicAbs;
                        const lines = [
                            'Check the path used in your extension API call.',
                            'The path must point to an existing file that will be packaged with the extension.',
                            `Found value: ${original ?? ''}`,
                            `Resolved path: ${authorUsedRoot && outputPath ? external_path_namespaceObject.join(outputPath, computed) : sourcePublicAbs}`
                        ];
                        if (authorUsedRoot) lines.push("Paths starting with '/' are resolved from the extension output root (served from public/), not your source directory.");
                        lines.push('', `NOT FOUND ${displayPath}`);
                        emitStandardWarning(String(this.resourcePath), lines);
                    }
                } else if (original) {
                    const looksNested = /(^|\/)src\/pages\//i.test(canonical) || /(^|\/)src\/scripts\//i.test(canonical);
                    if (looksNested) {
                        const root = packageJsonDir || external_path_namespaceObject.dirname(manifestPath);
                        const abs = external_path_namespaceObject.join(root, canonical);
                        const lines = [
                            'Check the path used in your extension API call.',
                            'The path must point to an existing file that will be packaged with the extension.',
                            `Found value: ${original}`
                        ];
                        lines.push('', `NOT FOUND ${abs}`);
                        emitStandardWarning(String(this.resourcePath), lines);
                    }
                }
            } catch  {}
        };
        try {
            const resourcePathUnix = unixify(String(this.resourcePath || ''));
            if (resourcePathUnix.split('/').includes('public')) return callback(null, source);
        } catch  {}
        try {
            const sourceString = String(source);
            const containsEligiblePatterns = /(?:^|[^A-Za-z0-9_$])(chrome|browser)\s*\./.test(sourceString) || /(?:^|[^A-Za-z0-9_$])(?:runtime|extension)\s*\.?\s*getURL\s*\(/.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/public\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])public\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/pages\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])pages\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/scripts\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])scripts\//.test(sourceString);
            if (!containsEligiblePatterns) return callback(null, source);
        } catch  {}
        let postTextSource;
        try {
            const out = textFallbackTransform(String(source), {
                manifestPath,
                packageJsonDir,
                authorFilePath: String(this.resourcePath || ''),
                onResolvedLiteral: (original, computed)=>warnIfMissingPublic(original, computed)
            });
            postTextSource = out;
            const hasStaticTemplates = /`[^$`]*`/.test(out);
            const hasBinaryConcats = /(['"`][^'"`]*['"`]\s*\+\s*['"`][^'"`]*['"`])/.test(out);
            const hasApiRoots = /(?:^|[^A-Za-z0-9_$])(chrome|browser)\s*\./.test(out);
            const needsStaticEval = (hasStaticTemplates || hasBinaryConcats) && hasApiRoots;
            const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
            if (!needsStaticEval) {
                if (out !== String(source) || enableMaps && /\.[cm]?tsx?$/.test(String(this.resourcePath || ''))) {
                    const msAll = new (external_magic_string_default())(String(source));
                    msAll.overwrite(0, String(source).length, out);
                    const map = enableMaps ? msAll.generateMap({
                        hires: true,
                        source: String(this.resourcePath),
                        includeContent: true
                    }) : void 0;
                    return callback(null, out, map);
                }
            }
        } catch  {}
        const swc = await loadSwc();
        if (!swc) return callback(null, source);
        let programAst;
        try {
            const isTS = /\.[cm]?tsx?$/.test(this.resourcePath);
            const isJSX = /\.[cm]?[jt]sx$/.test(this.resourcePath);
            const parseSource = 'string' == typeof postTextSource ? postTextSource : source;
            programAst = await parseWithSwc(swc, parseSource, {
                isTS,
                isJSX
            });
        } catch  {
            return callback(null, source);
        }
        const inputSource = 'string' == typeof postTextSource ? postTextSource : String(source);
        const ms = new (external_magic_string_default())(inputSource);
        let edited = false;
        const rewriteValue = (node, computed, rawInput)=>{
            if (!computed && 'string' == typeof rawInput) try {
                const recomputed = resolveLiteralToOutput(rawInput, {
                    manifestPath,
                    packageJsonDir,
                    authorFilePath: String(this.resourcePath || '')
                });
                if (recomputed) computed = recomputed;
            } catch  {}
            if (!computed) return;
            try {
                const span = node?.span;
                if (span && 'number' == typeof span.start && 'number' == typeof span.end) {
                    const src = String(inputSource);
                    const before = src[span.start - 1];
                    const after = src[span.end];
                    const isQuote = (c)=>"'" === c || '"' === c;
                    if (isQuote(before) && before === after) {
                        let start = span.start - 1;
                        let end = span.end + 1;
                        const q = before;
                        const json = JSON.stringify(String(computed));
                        if ('"' === q) ms.overwrite(start, end, json);
                        else {
                            const inner = json.slice(1, -1).replace(/'/g, "\\'");
                            ms.overwrite(start, end, `'${inner}'`);
                        }
                    } else ms.overwrite(span.start, span.end, JSON.stringify(computed));
                    edited = true;
                }
            } catch  {}
        };
        const walk = (currentNode)=>{
            if (!currentNode || 'object' != typeof currentNode) return;
            if ('CallExpression' === currentNode.type) try {
                handleCallExpression(currentNode, String(inputSource), rewriteValue, manifestPath);
            } catch  {}
            for(const key in currentNode){
                if (!Object.prototype.hasOwnProperty.call(currentNode, key)) continue;
                const childNode = currentNode[key];
                if (childNode) {
                    if (Array.isArray(childNode)) childNode.forEach(walk);
                    else if (childNode && 'string' == typeof childNode.type) walk(childNode);
                }
            }
        };
        walk(programAst);
        try {
            if (!edited) {
                if ('string' == typeof postTextSource && postTextSource !== String(source)) {
                    const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
                    const msAll = new (external_magic_string_default())(String(source));
                    msAll.overwrite(0, String(source).length, postTextSource);
                    const map = enableMaps ? msAll.generateMap({
                        hires: true,
                        source: String(this.resourcePath),
                        includeContent: true
                    }) : void 0;
                    return callback(null, postTextSource, map);
                }
                return callback(null, source);
            }
            const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
            const code = ms.toString();
            const map = enableMaps ? ms.generateMap({
                hires: true,
                source: String(this.resourcePath),
                includeContent: true
            }) : void 0;
            return callback(null, code, map);
        } catch  {
            return callback(null, source);
        }
    }
})();
exports["default"] = __webpack_exports__["default"];
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "default"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
