const{existsSync,readFileSync}=require("fs"),{join}=require("path"),{platform,arch}=process;let nativeBinding=null,localFileExisted=!1,loadError=null;function isMusl(){if(process.report&&"function"==typeof process.report.getReport){const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}try{const e=require("child_process").execSync("which ldd").toString().trim();return readFileSync(e,"utf8").includes("musl")}catch(e){return!0}}switch(platform){case"android":switch(arch){case"arm64":localFileExisted=existsSync(join(__dirname,"whichlang-node.android-arm64.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.android-arm64.node"):require("whichlang-node-android-arm64")}catch(e){loadError=e}break;case"arm":localFileExisted=existsSync(join(__dirname,"whichlang-node.android-arm-eabi.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.android-arm-eabi.node"):require("whichlang-node-android-arm-eabi")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Android ${arch}`)}break;case"win32":switch(arch){case"x64":localFileExisted=existsSync(join(__dirname,"whichlang-node.win32-x64-msvc.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.win32-x64-msvc.node"):require("whichlang-node-win32-x64-msvc")}catch(e){loadError=e}break;case"ia32":localFileExisted=existsSync(join(__dirname,"whichlang-node.win32-ia32-msvc.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.win32-ia32-msvc.node"):require("whichlang-node-win32-ia32-msvc")}catch(e){loadError=e}break;case"arm64":localFileExisted=existsSync(join(__dirname,"whichlang-node.win32-arm64-msvc.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.win32-arm64-msvc.node"):require("whichlang-node-win32-arm64-msvc")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Windows: ${arch}`)}break;case"darwin":localFileExisted=existsSync(join(__dirname,"whichlang-node.darwin-universal.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.darwin-universal.node"):require("whichlang-node-darwin-universal");break}catch{}switch(arch){case"x64":localFileExisted=existsSync(join(__dirname,"whichlang-node.darwin-x64.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.darwin-x64.node"):require("whichlang-node-darwin-x64")}catch(e){loadError=e}break;case"arm64":localFileExisted=existsSync(join(__dirname,"whichlang-node.darwin-arm64.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.darwin-arm64.node"):require("whichlang-node-darwin-arm64")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on macOS: ${arch}`)}break;case"freebsd":if("x64"!==arch)throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);localFileExisted=existsSync(join(__dirname,"whichlang-node.freebsd-x64.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.freebsd-x64.node"):require("whichlang-node-freebsd-x64")}catch(e){loadError=e}break;case"linux":switch(arch){case"x64":if(isMusl()){localFileExisted=existsSync(join(__dirname,"whichlang-node.linux-x64-musl.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.linux-x64-musl.node"):require("whichlang-node-linux-x64-musl")}catch(e){loadError=e}}else{localFileExisted=existsSync(join(__dirname,"whichlang-node.linux-x64-gnu.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.linux-x64-gnu.node"):require("whichlang-node-linux-x64-gnu")}catch(e){loadError=e}}break;case"arm64":if(isMusl()){localFileExisted=existsSync(join(__dirname,"whichlang-node.linux-arm64-musl.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.linux-arm64-musl.node"):require("whichlang-node-linux-arm64-musl")}catch(e){loadError=e}}else{localFileExisted=existsSync(join(__dirname,"whichlang-node.linux-arm64-gnu.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.linux-arm64-gnu.node"):require("whichlang-node-linux-arm64-gnu")}catch(e){loadError=e}}break;case"arm":localFileExisted=existsSync(join(__dirname,"whichlang-node.linux-arm-gnueabihf.node"));try{nativeBinding=localFileExisted?require("./whichlang-node.linux-arm-gnueabihf.node"):require("whichlang-node-linux-arm-gnueabihf")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Linux: ${arch}`)}break;default:throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)}if(!nativeBinding){if(loadError)throw loadError;throw new Error("Failed to load native binding")}const{Language,Lang,detectLanguage,detectLang,LangISO6391,detectLangISO6391}=nativeBinding;module.exports.Language=Language,module.exports.Lang=Lang,module.exports.detectLanguage=detectLanguage,module.exports.detectLang=detectLang,module.exports.LangISO6391=LangISO6391,module.exports.detectLangISO6391=detectLangISO6391;