"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NEW_CHECK_JSON_WAY=exports.config=void 0,exports.schemaValidate=schemaValidate,exports.transValidateResult=transValidateResult;const tslib_1=require("tslib"),jsonschema_1=require("jsonschema"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),validator=new jsonschema_1.Validator,app=require("../../../../schema/dist/app.js"),ext=require("../../../../schema/dist/ext.js"),game=require("../../../../schema/dist/game.js"),page=require("../../../../schema/dist/page.js"),plugin=require("../../../../schema/dist/plugin.js"),pluginpage=require("../../../../schema/dist/pluginpage.js"),projectconfig=require("../../../../schema/dist/projectconfig.js"),sitemap=require("../../../../schema/dist/sitemap.js"),theme=require("../../../../schema/dist/theme.js");exports.config={app:app,ext:ext,game:game,page:page,plugin:plugin,pluginpage:pluginpage,projectconfig:projectconfig,sitemap:sitemap,theme:theme};const SchemaMap=Object.assign({},exports.config);function schemaValidate(e,r){const t=validator.validate(r,SchemaMap[e]).errors,a=t.filter(e=>"additionalProperties"===e.name),o=t.filter(e=>"additionalProperties"!==e.name).map(e=>{if("type"===e.name||"enum"===e.name||"anyOf"===e.name){let r=e.argument;if("string"==typeof r&&(r=[r]),"anyOf"===e.name){r=[(e.schema.anyOf||[]).map(e=>e.type).join(", ")]}const t=e.property.replace(/^instance\.?/,"");return{errorType:e.name,errorProperty:t,correctType:r}}return{errorType:e.name,errorProperty:e.property.replace(/^instance\.?/,""),requireProperty:e.argument}});return{warning:a.map(r=>{const t=r.property.replace(/^instance\.?/,"");return`${e}.json ${t.length?t:""}["${r.argument}"]`}).join("、")||"",error:o}}function transValidateResult(e,r,t=!1){var a;if(null===(a=null==r?void 0:r.error)||void 0===a?void 0:a.length){const a=r.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);const r=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([r])}).join("\n");return t||(0,common_1.throwError)({msg:a,filePath:e}),a}return""}exports.NEW_CHECK_JSON_WAY=!0;