function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}
function _async_to_generator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}
function _ts_generator(thisArg, body) {
    var f, y, t, _ = {
        label: 0,
        sent: function() {
            if (t[0] & 1) throw t[1];
            return t[1];
        },
        trys: [],
        ops: []
    }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
    return d(g, "next", {
        value: verb(0)
    }), d(g, "throw", {
        value: verb(1)
    }), d(g, "return", {
        value: verb(2)
    }), typeof Symbol === "function" && d(g, Symbol.iterator, {
        value: function() {
            return this;
        }
    }), g;
    function verb(n) {
        return function(v) {
            return step([
                n,
                v
            ]);
        };
    }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while(g && (g = 0, op[0] && (_ = 0)), _)try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [
                op[0] & 2,
                t.value
            ];
            switch(op[0]){
                case 0:
                case 1:
                    t = op;
                    break;
                case 4:
                    _.label++;
                    return {
                        value: op[1],
                        done: false
                    };
                case 5:
                    _.label++;
                    y = op[1];
                    op = [
                        0
                    ];
                    continue;
                case 7:
                    op = _.ops.pop();
                    _.trys.pop();
                    continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                        _ = 0;
                        continue;
                    }
                    if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
                        _.label = op[1];
                        break;
                    }
                    if (op[0] === 6 && _.label < t[1]) {
                        _.label = t[1];
                        t = op;
                        break;
                    }
                    if (t && _.label < t[2]) {
                        _.label = t[2];
                        _.ops.push(op);
                        break;
                    }
                    if (t[2]) _.ops.pop();
                    _.trys.pop();
                    continue;
            }
            op = body.call(thisArg, _);
        } catch (e) {
            op = [
                6,
                e
            ];
            y = 0;
        } finally{
            f = t = 0;
        }
        if (op[0] & 5) throw op[1];
        return {
            value: op[0] ? op[1] : void 0,
            done: true
        };
    }
}
/**
 * @fileoverview Ace Editor 工具函数
 *
 * 提供语言模式映射和异步加载 Ace Editor 相关资源的功能
 * 所有 ace-builds 相关的导入都改为异步，避免同步加载导致的错误
 */ /**
 * 语言模式映射表
 * 将常见的语言别名映射到 Ace Editor 支持的标准模式名称
 */ export var modeMap = new Map([
    [
        'ts',
        'typescript'
    ],
    [
        'js',
        'javascript'
    ],
    [
        'c',
        'c_cpp'
    ],
    [
        'c++',
        'c_cpp'
    ],
    [
        'cpp',
        'c_cpp'
    ],
    [
        'objective-c',
        'objectivec'
    ],
    [
        'objc',
        'objectivec'
    ],
    [
        'yml',
        'yaml'
    ],
    [
        'styl',
        'stylus'
    ],
    [
        'shell',
        'sh'
    ],
    [
        'shellsession',
        'sh'
    ],
    [
        'console',
        'sh'
    ],
    [
        'bash',
        'sh'
    ],
    [
        'zsh',
        'sh'
    ],
    [
        'py',
        'python'
    ],
    [
        'proto',
        'protobuf'
    ],
    [
        'ps',
        'powershell'
    ],
    [
        'md',
        'markdown'
    ],
    [
        'make',
        'makefile'
    ],
    [
        'apach',
        'apache_conf'
    ],
    [
        'cjl',
        'clojure'
    ],
    [
        'c#',
        'csharp'
    ],
    [
        'cs',
        'csharp'
    ],
    [
        'docker',
        'dockerfile'
    ],
    [
        'erl',
        'erlang'
    ],
    [
        'f#',
        'fsharp'
    ],
    [
        'fs',
        'fsharp'
    ],
    [
        'go',
        'golang'
    ],
    [
        'graphql',
        'graphqlschema'
    ],
    [
        'hbs',
        'handlebars'
    ],
    [
        'hs',
        'haskell'
    ],
    [
        'kt',
        'kotlin'
    ],
    [
        'kts',
        'kotlin'
    ]
]);
/**
 * 缓存已加载的 aceLangs
 */ var aceLangsCache = null;
var aceLangsLoader = null;
/**
 * 异步加载所有 Ace Editor 语言模式
 * 这些导入主要用于注册模式，不需要直接使用返回值
 */ var loadAceModes = function loadAceModes() {
    return _async_to_generator(function() {
        return _ts_generator(this, function(_state) {
            switch(_state.label){
                case 0:
                    return [
                        4,
                        Promise.all([
                            import("ace-builds/src-noconflict/mode-abap"),
                            import("ace-builds/src-noconflict/mode-abc"),
                            import("ace-builds/src-noconflict/mode-actionscript"),
                            import("ace-builds/src-noconflict/mode-ada"),
                            import("ace-builds/src-noconflict/mode-apache_conf"),
                            import("ace-builds/src-noconflict/mode-apex"),
                            import("ace-builds/src-noconflict/mode-applescript"),
                            import("ace-builds/src-noconflict/mode-aql"),
                            import("ace-builds/src-noconflict/mode-asciidoc"),
                            import("ace-builds/src-noconflict/mode-asl"),
                            import("ace-builds/src-noconflict/mode-assembly_x86"),
                            import("ace-builds/src-noconflict/mode-astro"),
                            import("ace-builds/src-noconflict/mode-basic"),
                            import("ace-builds/src-noconflict/mode-c_cpp"),
                            import("ace-builds/src-noconflict/mode-cirru"),
                            import("ace-builds/src-noconflict/mode-clojure"),
                            import("ace-builds/src-noconflict/mode-cobol"),
                            import("ace-builds/src-noconflict/mode-coffee"),
                            import("ace-builds/src-noconflict/mode-crystal"),
                            import("ace-builds/src-noconflict/mode-csharp"),
                            import("ace-builds/src-noconflict/mode-css"),
                            import("ace-builds/src-noconflict/mode-d"),
                            import("ace-builds/src-noconflict/mode-dart"),
                            import("ace-builds/src-noconflict/mode-diff"),
                            import("ace-builds/src-noconflict/mode-dockerfile"),
                            import("ace-builds/src-noconflict/mode-dot"),
                            import("ace-builds/src-noconflict/mode-elixir"),
                            import("ace-builds/src-noconflict/mode-elm"),
                            import("ace-builds/src-noconflict/mode-erlang"),
                            import("ace-builds/src-noconflict/mode-fsharp"),
                            import("ace-builds/src-noconflict/mode-glsl"),
                            import("ace-builds/src-noconflict/mode-golang"),
                            import("ace-builds/src-noconflict/mode-graphqlschema"),
                            import("ace-builds/src-noconflict/mode-groovy"),
                            import("ace-builds/src-noconflict/mode-haml"),
                            import("ace-builds/src-noconflict/mode-handlebars"),
                            import("ace-builds/src-noconflict/mode-haskell"),
                            import("ace-builds/src-noconflict/mode-hjson"),
                            import("ace-builds/src-noconflict/mode-html"),
                            import("ace-builds/src-noconflict/mode-ini"),
                            import("ace-builds/src-noconflict/mode-jade"),
                            import("ace-builds/src-noconflict/mode-java"),
                            import("ace-builds/src-noconflict/mode-javascript"),
                            import("ace-builds/src-noconflict/mode-json"),
                            import("ace-builds/src-noconflict/mode-json5"),
                            import("ace-builds/src-noconflict/mode-jsx"),
                            import("ace-builds/src-noconflict/mode-julia"),
                            import("ace-builds/src-noconflict/mode-kotlin"),
                            import("ace-builds/src-noconflict/mode-latex"),
                            import("ace-builds/src-noconflict/mode-less"),
                            import("ace-builds/src-noconflict/mode-liquid"),
                            import("ace-builds/src-noconflict/mode-lisp"),
                            import("ace-builds/src-noconflict/mode-livescript"),
                            import("ace-builds/src-noconflict/mode-lua"),
                            import("ace-builds/src-noconflict/mode-makefile"),
                            import("ace-builds/src-noconflict/mode-markdown"),
                            import("ace-builds/src-noconflict/mode-matlab"),
                            import("ace-builds/src-noconflict/mode-nginx"),
                            import("ace-builds/src-noconflict/mode-nim"),
                            import("ace-builds/src-noconflict/mode-nix"),
                            import("ace-builds/src-noconflict/mode-objectivec"),
                            import("ace-builds/src-noconflict/mode-ocaml"),
                            import("ace-builds/src-noconflict/mode-pascal"),
                            import("ace-builds/src-noconflict/mode-perl"),
                            import("ace-builds/src-noconflict/mode-php"),
                            import("ace-builds/src-noconflict/mode-powershell"),
                            import("ace-builds/src-noconflict/mode-prisma"),
                            import("ace-builds/src-noconflict/mode-prolog"),
                            import("ace-builds/src-noconflict/mode-protobuf"),
                            import("ace-builds/src-noconflict/mode-puppet"),
                            import("ace-builds/src-noconflict/mode-python"),
                            import("ace-builds/src-noconflict/mode-r"),
                            import("ace-builds/src-noconflict/mode-raku"),
                            import("ace-builds/src-noconflict/mode-razor"),
                            import("ace-builds/src-noconflict/mode-rhtml"),
                            import("ace-builds/src-noconflict/mode-ruby"),
                            import("ace-builds/src-noconflict/mode-rust"),
                            import("ace-builds/src-noconflict/mode-sass"),
                            import("ace-builds/src-noconflict/mode-scala"),
                            import("ace-builds/src-noconflict/mode-scheme"),
                            import("ace-builds/src-noconflict/mode-scss"),
                            import("ace-builds/src-noconflict/mode-sh"),
                            import("ace-builds/src-noconflict/mode-sparql"),
                            import("ace-builds/src-noconflict/mode-sql"),
                            import("ace-builds/src-noconflict/mode-stylus"),
                            import("ace-builds/src-noconflict/mode-svg"),
                            import("ace-builds/src-noconflict/mode-swift"),
                            import("ace-builds/src-noconflict/mode-tcl"),
                            import("ace-builds/src-noconflict/mode-tex"),
                            import("ace-builds/src-noconflict/mode-toml"),
                            import("ace-builds/src-noconflict/mode-tsx"),
                            import("ace-builds/src-noconflict/mode-twig"),
                            import("ace-builds/src-noconflict/mode-typescript"),
                            import("ace-builds/src-noconflict/mode-vbscript"),
                            import("ace-builds/src-noconflict/mode-verilog"),
                            import("ace-builds/src-noconflict/mode-vhdl"),
                            import("ace-builds/src-noconflict/mode-vue"),
                            import("ace-builds/src-noconflict/mode-xml"),
                            import("ace-builds/src-noconflict/mode-yaml"),
                            import("ace-builds/src-noconflict/mode-zig"),
                            import("ace-builds/src-noconflict/theme-cloud9_night"),
                            import("ace-builds/src-noconflict/theme-cloud_editor")
                        ])
                    ];
                case 1:
                    _state.sent();
                    return [
                        2
                    ];
            }
        });
    })();
};
/**
 * 异步获取 Ace Editor 支持的语言列表
 * 使用单例模式确保只加载一次
 *
 * @returns {Promise<Set<string>>} Ace Editor 支持的语言名称集合
 */ export var getAceLangs = function getAceLangs() {
    return _async_to_generator(function() {
        return _ts_generator(this, function(_state) {
            if (aceLangsCache) {
                return [
                    2,
                    aceLangsCache
                ];
            }
            if (!aceLangsLoader) {
                aceLangsLoader = function() {
                    return _async_to_generator(function() {
                        var ext;
                        return _ts_generator(this, function(_state) {
                            switch(_state.label){
                                case 0:
                                    // 先加载所有模式
                                    return [
                                        4,
                                        loadAceModes()
                                    ];
                                case 1:
                                    _state.sent();
                                    return [
                                        4,
                                        import("ace-builds/src-noconflict/ext-modelist")
                                    ];
                                case 2:
                                    ext = _state.sent();
                                    aceLangsCache = new Set(ext.default.modes.map(function(m) {
                                        return m.name;
                                    }));
                                    return [
                                        2,
                                        aceLangsCache
                                    ];
                            }
                        });
                    })();
                }();
            }
            return [
                2,
                aceLangsLoader
            ];
        });
    })();
};
/**
 * 预加载 Ace Editor 语言模式
 * 可以在应用启动时调用，提前开始加载
 */ export var preloadAceModes = function preloadAceModes() {
    if (typeof window === 'undefined') return;
    if (aceLangsLoader) return;
    // 触发加载但不等待结果
    getAceLangs().catch(function() {
    // 静默处理错误，预加载失败不影响后续使用
    });
};
