/**
 * Minified by jsDelivr using Terser v5.19.2.
 * Original file: /npm/license-checker-custom@25.0.3/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var UNKNOWN="UNKNOWN",UNLICENSED="UNLICENSED",fs=require("fs"),path=require("path"),read=require("read-installed"),chalk=require("chalk"),treeify=require("treeify"),license=require("./license"),licenseFiles=require("./license-files"),debug=require("debug"),mkdirp=require("mkdirp"),spdxSatisfies=require("spdx-satisfies"),spdxCorrect=require("spdx-correct"),debugError=debug("license-checker:error"),debugLog=debug("license-checker:log");debugLog.log=console.log.bind(console);var flatten=function(e){var t,r,n,s,i={licenses:UNKNOWN},o=e.deps,c=e.data,a=o.name+"@"+o.version,l=e.color,u=e.unknown,p=[],f=[];if(o.private&&(i.private=!0),c[a])return c;if(e.production&&o.extraneous||e.development&&!o.extraneous&&!o.root)return c;c[a]=i;var h=function(t){return void 0===e.customFormat||!1!==e.customFormat[t]};return h("repository")&&o.repository&&"object"==typeof o.repository&&"string"==typeof o.repository.url&&(i.repository=o.repository.url.replace("git+ssh://git@","git://"),i.repository=i.repository.replace("git+https://github.com","https://github.com"),i.repository=i.repository.replace("git://github.com","https://github.com"),i.repository=i.repository.replace("git@github.com:","https://github.com/"),i.repository=i.repository.replace(/\.git$/,"")),h("url")&&o.url&&"object"==typeof o.url&&(i.url=o.url.web),o.author&&"object"==typeof o.author&&(h("publisher")&&o.author.name&&(i.publisher=o.author.name),h("email")&&o.author.email&&(i.email=o.author.email),h("url")&&o.author.url&&(i.url=o.author.url)),u&&(i.dependencyPath=o.path),e.customFormat&&Object.keys(e.customFormat).forEach((function(t){h(t)&&o[t]?"string"==typeof o[t]&&(i[t]=o[t]):h(t)&&(i[t]=e.customFormat[t])})),h("path")&&o.path&&"string"==typeof o.path&&(i.path=o.path),r=o.license||o.licenses||void 0,o.path&&(!o.readme||o.readme.toLowerCase().indexOf("no readme data found")>-1)&&(t=path.join(o.path,"README.md"),fs.existsSync(t)&&(o.readme=fs.readFileSync(t,"utf8").toString())),r?Array.isArray(r)&&r.length>0?i.licenses=r.map((function(e){return"object"==typeof e?e.type||e.name:"string"==typeof e?e:void 0})):"object"==typeof r&&(r.type||r.name)?i.licenses=license(e._args,r.type||r.name):"string"==typeof r&&(i.licenses=license(e._args,r)):license(e._args,o.readme)&&(i.licenses=license(e._args,o.readme)),Array.isArray(i.licenses)&&1===i.licenses.length&&(i.licenses=i.licenses[0]),o.path&&fs.existsSync(o.path)&&(n=fs.readdirSync(o.path),p=licenseFiles(n),f=n.filter((function(e){return e=e.toUpperCase(),"NOTICE"===path.basename(e).replace(path.extname(e),"")}))),p.forEach((function(t,r){var n;if((s=path.join(o.path,t),fs.lstatSync(s).isFile())&&((!i.licenses||i.licenses.indexOf(UNKNOWN)>-1||0===i.licenses.indexOf("Custom:"))&&(n=fs.readFileSync(s,{encoding:"utf8"}),i.licenses=license(e._args,n)),0===r&&(h("licenseFile")&&(i.licenseFile=e.basePath?path.relative(e.basePath,s):s),h("licenseText")&&e.customFormat&&(n||(n=fs.readFileSync(s,{encoding:"utf8"})),e._args&&!e._args.csv?i.licenseText=n.trim():i.licenseText=n.replace(/"/g,"'").replace(/\r?\n|\r/g," ").trim()),h("copyright")&&e.customFormat))){n||(n=fs.readFileSync(s,{encoding:"utf8"}));var c=n.replace(/\r\n/g,"\n").split("\n\n").filter((function(e){return e.startsWith("opyright",1)&&!e.startsWith("opyright notice",1)&&!e.startsWith("opyright and related rights",1)})).filter((function(e,t,r){return 0===t||e!==r[0]}));c.length>0&&(i.copyright=c[0].replace(/\n/g,". ").trim()),c.length>1&&(i.copyright+="*")}})),f.forEach((function(t){var r=path.join(o.path,t);fs.lstatSync(r).isFile()&&(i.noticeFile=e.basePath?path.relative(e.basePath,r):r)})),o.dependencies&&Object.keys(o.dependencies).forEach((function(t){var r=o.dependencies[t],n=r.name+"@"+r.version;c[n]||(c=flatten({deps:r,data:c,color:l,unknown:u,customFormat:e.customFormat,production:e.production,development:e.development,basePath:e.basePath,_args:e._args}))})),o.name&&o.version||delete c[a],c};exports.init=function(e,t){debugLog("scanning %s",e.start),e.customPath&&(e.customFormat=this.parseJson(e.customPath));var r={dev:!0,log:debugLog,depth:e.direct};(e.production||e.development)&&(r.dev=!1);var n,s,i=[],o=[];e.onlyAllow&&(n=e.onlyAllow,s=o),e.failOn&&(n=e.failOn,s=i),n&&s&&n.split(";").forEach((function(e){var t=e.trim();t.length>0&&s.push(t)})),read(e.start,r,(function(r,n){var s,c=flatten({deps:n,data:{},color:e.color,unknown:e.unknown,customFormat:e.customFormat,production:e.production,development:e.development,basePath:e.relativeLicensePath?n.path:null,_args:e}),a=e.color,l={},u={},p=e.exclude&&e.exclude.match(/([^\\\][^,]|\\,)+/g).map((function(e){return e.replace(/\\,/g,",").replace(/^\s+|\s+$/g,"")})),f=null,h=function(e){return a?chalk.bold.red(e):e};if(Object.keys(c).sort().forEach((function(t){c[t].private&&(c[t].licenses=h(UNLICENSED)),c[t].licenses||(c[t].licenses=h(UNKNOWN)),e.unknown&&c[t].licenses&&c[t].licenses!==UNKNOWN&&c[t].licenses.indexOf("*")>-1&&(c[t].licenses=h(UNKNOWN)),c[t]&&(e.onlyunknown?(c[t].licenses.indexOf("*")>-1||c[t].licenses.indexOf(UNKNOWN)>-1)&&(l[t]=c[t]):l[t]=c[t])})),Object.keys(l).length||(r=new Error("No packages found in this path..")),p){var d=function(e){return"BSD"===e?"(0BSD OR BSD-2-Clause OR BSD-3-Clause OR BSD-4-Clause)":e},g=function(e){return spdxCorrect(e)===e},y=p.map(d).filter(g),m=p.map(d).filter((s=g,function(e){return!s(e)})),b="( "+y.join(" OR ")+" )";Object.keys(l).forEach((function(e){var t=l[e].licenses;if(t){t=[].concat(t);var r=!1;t.forEach((function(t){t.indexOf(UNKNOWN)>=0?u[e]=l[e]:(t.indexOf("*")>=0&&(t=t.substring(0,t.length-1)),"BSD"===t&&(t="(0BSD OR BSD-2-Clause OR BSD-3-Clause OR BSD-4-Clause)"),(m.indexOf(t)>=0||spdxCorrect(t)&&spdxSatisfies(spdxCorrect(t),b))&&(r=!0))})),r||(u[e]=l[e])}else u[e]=l[e]}))}else u=l;var O=u;if(e.packages){var v=e.packages.split(";");O={},Object.keys(u).map((function(e){v.includes(e)&&(O[e]=u[e])}))}if(e.excludePackages){var x=e.excludePackages.split(";");O={},Object.keys(u).map((function(e){x.includes(e)||(O[e]=u[e])}))}e.excludePrivatePackages&&Object.keys(u).forEach((function(e){O[e]&&O[e].private&&delete O[e]})),Object.keys(O).forEach((function(e){if(i.length>0&&i.indexOf(O[e].licenses)>-1&&(console.error('Found license defined by the --failOn flag: "'+O[e].licenses+'". Exiting.'),process.exit(1)),o.length>0){var t=!1;o.forEach((function(r){t=!(-1===O[e].licenses.indexOf(r)&&!t)})),t||(console.error('Package "'+e+'" is licensed under "'+O[e].licenses+'" which is not permitted by the --onlyAllow flag. Exiting.'),process.exit(1))}})),r&&(debugError(r),f=r),t(f,O)}))},exports.print=function(e){console.log(exports.asTree(e))},exports.asTree=function(e){return treeify.asTree(e,!0)},exports.asSummary=function(e){var t={},r=[],n={};return Object.keys(e).forEach((function(r){e[r].licenses&&(t[e[r].licenses]=t[e[r].licenses]||0,t[e[r].licenses]++)})),Object.keys(t).forEach((function(e){r.push({license:e,count:t[e]})})),r.sort((function(e,t){return t.count-e.count})),r.forEach((function(e){n[e.license]=e.count})),treeify.asTree(n,!0)},exports.asCSV=function(e,t,r){var n=[],s=[],i=[],o='"component"',c=r;return t&&Object.keys(t).length>0?(s=[],r&&s.push(o),s.push('"module name"'),Object.keys(t).forEach((function(e){s.push('"'+e+'"')})),n.push(s.join(","))):(s=[],r&&s.push(o),['"module name"','"license"','"repository"'].forEach((function(e){s.push(e)})),n.push(s.join(","))),Object.keys(e).forEach((function(s){var o=e[s],a="";i=[],t&&Object.keys(t).length>0?(r&&i.push('"'+c+'"'),i.push('"'+s+'"'),Object.keys(t).forEach((function(e){i.push('"'+o[e]+'"')})),a=i.join(",")):(r&&i.push('"'+c+'"'),i.push(['"'+s+'"','"'+(o.licenses||"")+'"','"'+(o.repository||"")+'"']),a=i.join(",")),n.push(a)})),n.join("\n")},exports.asMarkDown=function(e,t){var r=[];return t&&Object.keys(t).length>0?(Object.keys(e).forEach((function(n){r.push(" - **["+n+"]("+e[n].repository+")**"),Object.keys(t).forEach((function(t){r.push("    - "+t+": "+e[n][t])}))})),r=r.join("\n")):(Object.keys(e).forEach((function(t){var n=e[t];r.push("["+t+"]("+n.repository+") - "+n.licenses)})),r=r.join("\n")),r},exports.parseJson=function(e){if("string"!=typeof e)return new Error("did not specify a path");var t="",r={};try{t=fs.readFileSync(e,{encoding:"utf8"}),r=JSON.parse(t)}catch(e){r=e}return r},exports.asFiles=function(e,t){mkdirp.sync(t),Object.keys(e).forEach((function(r){var n,s,i,o,c=e[r].licenseFile;c&&fs.existsSync(c)?(n=fs.readFileSync(c),s=r+"-LICENSE.txt",i=path.join(t,s),o=path.dirname(i),mkdirp.sync(o),fs.writeFileSync(i,n,"utf8")):console.warn("no license file found for: "+r)}))};
//# sourceMappingURL=/sm/02efa8d1ced6353b0c98dc8b46eae24fe4a57fc2e262704c58b5f702ba94918c.map