"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(n){if(n&&n.__esModule)return n;var o={};if(null!=n)for(var i in n)"default"!==i&&Object.prototype.hasOwnProperty.call(n,i)&&e(o,n,i);return t(o,n),o},o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,a){function r(e){try{s(o.next(e))}catch(e){a(e)}}function l(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.validateCompability=void 0;const a=i(require("../../../log")),r=require("../../../config"),l=n(require("tar")),s=i(require("fs-extra")),c=require("../../../common/Constants"),u=["compatibleSdkVersion","compatibleSdkType","obfuscated"],d=["name","compatibleSdkVersion","compatibleSdkType"];function f(e,t){switch(e){case"info":a.default.info("",t);break;case"warn":a.default.warn("",t);break;case"error":throw new Error(t);default:a.default.debug("","level not match the compability_log_level.")}}exports.validateCompability=function(e,t){return o(this,void 0,void 0,(function*(){a.default.debug("","start validateCompability.");const n=r.config.get(r.types.COMPABILITY_LOG_LEVEL);if("close"===n)return void a.default.debug("",'the value of "compability_log_level" is "close", ignore validateCompability.');!function(e,t){a.default.debug("",`validateCommonFields, level: ${t}.`),u.forEach((n=>{const o=e[`${n}`];o?"string"==typeof o&&o.length>64&&f("error",`The length of "${n}" field must range [1, 64] in ${c.Constants.MyPackageJson}`):"boolean"!=typeof o&&f(t,`The "${n}" field is empty or not exist in ${c.Constants.MyPackageJson}`)}))}(t,n);const i=yield function(e){return o(this,void 0,void 0,(function*(){const t=[];return l.t({onentry(e){if("Directory"!==e.type&&e.path.startsWith("package/libs")&&e.path.endsWith(".so")){const n=e.path.lastIndexOf("/");t.push(e.path.slice(n+1))}}}).end(yield s.default.readFileSync(e)),t}))}(e);i&&i.length&&(yield function(e,t,n){return o(this,void 0,void 0,(function*(){a.default.debug("",`validateNativeComponents, level: ${n}.`),e&&e.length?e.forEach((e=>{for(const o of d){const i=e[`${o}`];i?"name"!==o||t.includes(i)||f(n,`not found the so target in the publish package with name: "${i}" configed in "nativeComponents"`):f(n,`The "${o}" field is empty or not exist in "nativeComponents" node of oh-package.json5`)}})):f(n,`The "nativeComponents" field is empty or not exist in ${c.Constants.MyPackageJson}`)}))}(t.nativeComponents,i,n)),a.default.debug("","validateCompability completed.")}))};