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ACrC,EAAI,QAAQ,wBAAwB,GACpC,kBAAkB,EAAM,IAEnB,EAAI,QAAQ,mBAAmB,GACpC,EAAM,KAAK,IAEN,EAAI,QAAQ,mBAAmB,GACpC,EAAM,KAAK,IAEN,EAAI,QAAQ,sBAAsB,IACvC,EAAS,KAAK,EAClB,IAGA,EAAM,OAAS,GAAK,EAAM,OAAS,GAAK,EAAS,OAAS,EAAG,CAC7D,MAAM,EAAY,EAAM,KAAK,IAAS,EAAI,QAAQ,aAAa,EAAM,KAC/D,EAAe,EAAS,IAAI,WAAW,gBAC7C,IAAI,KAAc,GAAc,SAAS,IACrC,EAAS,QAAQ,SAAQ,EAAG,OAAM,WACzB,EAAQ,IAAI,IACb,EAAQ,IAAI,EAAM,IAAI,KAE1B,EAAQ,IAAI,IAAO,IAAI,EAAK,GAC9B,IAEN,MAAM,EAAO,WAAW,QAAQ,OAAO,oDAEjC,EAAI,QAAQ,iBAAiB,qBAE7B,EAAM,IAAI,QAAQ,aAAa,KAAK,0BAEpC,EAAU,KAAK,GAAS,EAAK,aAAY,KAAK,0BAE9C,EAAa,KAAK,GAAS,EAAK,aAAY,KAAK,oBACpD,IAAK,EAAQ,eAAgB,OAAQ,eAElC,GAAW,EAAI,QAAQ,iBAAiB,EAAU,WACxD,EAAI,WAAW,gBAAgB,GAAG,OAAO,QAAQ,KAAK,EAAQ,OAAQ,QAAgB,EAC1F,CACJ,CAlDA,QAAQ,iBAAmB","file":"/npm/protobufjs-typescript-gen@1.0.5/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/protobufjs-typescript-gen@1.0.5/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateProtocol = void 0;\nconst protobufjs_1 = __importDefault(require(\"@cldcvr/protobufjs\"));\nconst fs_extra_1 = require(\"fs-extra\");\nconst glob_1 = require(\"glob\");\nconst path_1 = __importDefault(require(\"path\"));\nconst prettier_1 = __importDefault(require(\"prettier\"));\nconst enums_1 = require(\"./enums\");\nconst options_1 = require(\"./options\");\nconst services_1 = require(\"./services\");\nconst types_1 = require(\"./types\");\nconst utils_1 = require(\"./utils\");\nconst root = new protobufjs_1.default.Root();\nfunction generateProtocol(options) {\n    const finalOptions = (0, options_1.vaidateOptions)(options);\n    root.resolvePath = function (_origin, target) {\n        return path_1.default.join(finalOptions.protocolDir, target);\n    };\n    const files = glob_1.glob.sync('**/*.proto', {\n        cwd: options.protocolDir,\n        ignore: options.ignoreFiles,\n    });\n    files.forEach((file) => {\n        root.loadSync(file, {\n            alternateCommentMode: true,\n        });\n    });\n    // Clear output directory\n    (0, fs_extra_1.emptyDirSync)(finalOptions.outDir);\n    // Generate the code\n    if (!root.nested) {\n        throw new Error('Could not find any protocols in root');\n    }\n    // We only generate namespaces in the root\n    Object.values(root.nested).forEach((type) => {\n        if ((0, utils_1.isNamespaceConstructor)(type)) {\n            generateNamespace(type, finalOptions);\n        }\n    });\n    console.log(`Generated ${files.length} protocol files.`);\n}\nexports.generateProtocol = generateProtocol;\nfunction generateNamespace(namespace, options) {\n    if (!namespace.nested) {\n        console.warn(`Namespace ${namespace.name} has no nested members to be generated`);\n        return;\n    }\n    const types = [];\n    const enums = [];\n    const services = [];\n    const imports = new Map();\n    Object.entries(namespace.nested).forEach(([, type]) => {\n        if ((0, utils_1.isNamespaceConstructor)(type)) {\n            generateNamespace(type, options);\n        }\n        else if ((0, utils_1.isTypeConstructor)(type)) {\n            types.push(type);\n        }\n        else if ((0, utils_1.isEnumConstructor)(type)) {\n            enums.push(type);\n        }\n        else if ((0, utils_1.isServiceConstructor)(type)) {\n            services.push(type);\n        }\n    });\n    // We have types in this namespace, we need to generate a file\n    if (types.length > 0 || enums.length > 0 || services.length > 0) {\n        const typeInfos = types.map((type) => (0, types_1.getTypeInfo)(type, options));\n        const serviceInfos = services.map(services_1.getServiceInfo);\n        [...typeInfos, ...serviceInfos].forEach((typeInfo) => {\n            typeInfo.imports.forEach(({ path, name }) => {\n                if (!imports.has(path)) {\n                    imports.set(path, new Set());\n                }\n                imports.get(path)?.add(name);\n            });\n        });\n        const file = prettier_1.default.format(`\n            /* eslint-disable */\n            ${(0, utils_1.getImportString)(imports)}\n\n            ${enums.map(enums_1.getEnumCode).join('\\n\\n')}\n\n            ${typeInfos.map((info) => info.typeString).join('\\n\\n')}\n\n            ${serviceInfos.map((info) => info.typeString).join('\\n\\n')}\n        `, { ...options.prettierConfig, parser: 'typescript' });\n        // Ensure that type's parent has a file\n        const filePath = (0, utils_1.namespaceToPath)(namespace.fullName);\n        (0, fs_extra_1.outputFileSync)(`${path_1.default.join(options.outDir, filePath)}.ts`, file);\n    }\n}\n"]}