var fs=require("fs"),path=require("path"),os=require("os"),runtimeRequire="function"==typeof __webpack_require__?__non_webpack_require__:require,vars=process.config&&process.config.variables||{},prebuildsOnly=!!process.env.PREBUILDS_ONLY,abi=process.versions.modules,runtime=isElectron()?"electron":isNwjs()?"node-webkit":"node",arch=process.env.npm_config_arch||os.arch(),platform=process.env.npm_config_platform||os.platform(),libc=process.env.LIBC||(isAlpine(platform)?"musl":"glibc"),armv=process.env.ARM_VERSION||("arm64"===arch?"8":vars.arm_version)||"",uv=(process.versions.uv||"").split(".")[0];function load(e){return runtimeRequire(load.resolve(e))}function readdirSync(e){try{return fs.readdirSync(e)}catch(e){return[]}}function getFirst(e,r){var i=readdirSync(e).filter(r);return i[0]&&path.join(e,i[0])}function matchBuild(e){return/\.node$/.test(e)}function parseTuple(e){var r=e.split("-");if(2===r.length){var i=r[0],n=r[1].split("+");if(i&&n.length&&n.every(Boolean))return{name:e,platform:i,architectures:n}}}function matchTuple(e,r){return function(i){return null!=i&&i.platform===e&&i.architectures.includes(r)}}function compareTuples(e,r){return e.architectures.length-r.architectures.length}function parseTags(e){var r=e.split("."),i={file:e,specificity:0};if("node"===r.pop()){for(var n=0;n<r.length;n++){var t=r[n];if("node"===t||"electron"===t||"node-webkit"===t)i.runtime=t;else if("napi"===t)i.napi=!0;else if("abi"===t.slice(0,3))i.abi=t.slice(3);else if("uv"===t.slice(0,2))i.uv=t.slice(2);else if("armv"===t.slice(0,4))i.armv=t.slice(4);else{if("glibc"!==t&&"musl"!==t)continue;i.libc=t}i.specificity++}return i}}function matchTags(e,r){return function(i){return!(null==i||i.runtime&&i.runtime!==e&&!runtimeAgnostic(i)||i.abi&&i.abi!==r&&!i.napi||i.uv&&i.uv!==uv||i.armv&&i.armv!==armv||i.libc&&i.libc!==libc)}}function runtimeAgnostic(e){return"node"===e.runtime&&e.napi}function compareTags(e){return function(r,i){return r.runtime!==i.runtime?r.runtime===e?-1:1:r.abi!==i.abi?r.abi?-1:1:r.specificity!==i.specificity?r.specificity>i.specificity?-1:1:0}}function isNwjs(){return!(!process.versions||!process.versions.nw)}function isElectron(){return!(!process.versions||!process.versions.electron)||!!process.env.ELECTRON_RUN_AS_NODE||"undefined"!=typeof window&&window.process&&"renderer"===window.process.type}function isAlpine(e){return"linux"===e&&fs.existsSync("/etc/alpine-release")}module.exports=load,load.resolve=load.path=function(e){e=path.resolve(e||".");try{var r=runtimeRequire(path.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[r+"_PREBUILD"]&&(e=process.env[r+"_PREBUILD"])}catch(e){}if(!prebuildsOnly){var i=getFirst(path.join(e,"build/Release"),matchBuild);if(i)return i;var n=getFirst(path.join(e,"build/Debug"),matchBuild);if(n)return n}var t=o(e);if(t)return t;var s=o(path.dirname(process.execPath));if(s)return s;var a=["platform="+platform,"arch="+arch,"runtime="+runtime,"abi="+abi,"uv="+uv,armv?"armv="+armv:"","libc="+libc,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"","function"==typeof __webpack_require__?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+a+"\n    loaded from: "+e+"\n");function o(e){var r=readdirSync(path.join(e,"prebuilds")).map(parseTuple).filter(matchTuple(platform,arch)).sort(compareTuples)[0];if(r){var i=path.join(e,"prebuilds",r.name),n=readdirSync(i).map(parseTags).filter(matchTags(runtime,abi)).sort(compareTags(runtime))[0];return n?path.join(i,n.file):void 0}}},load.parseTags=parseTags,load.matchTags=matchTags,load.compareTags=compareTags,load.parseTuple=parseTuple,load.matchTuple=matchTuple,load.compareTuples=compareTuples;