{"version":3,"sources":["jsdelivr-header.js","/npm/ip2countrycode@1.0.0/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,GAAK,QAAQ,MAEnB,OAAO,QAAU,MAAM,EACnB,WAAA,CAAY,GACe,iBAAZ,IACP,EAAU,CAAC,KAAM,IAErB,KAAK,SAAW,GAAG,aAAa,EAAQ,MAAM,WAAW,MAAM,QAAQ,KAAI,IACvE,IAAK,EAAO,EAAK,EAAM,GAAW,EAAK,MAAM,OAI7C,OAHA,EAAQ,SAAS,OAAO,GAAO,OAAO,GAAI,IAC1C,EAAM,SAAS,EAAK,IACpB,EAAU,OAAO,GAAS,MAAM,GAAI,GAC7B,CAAC,QAAO,MAAK,OAAM,UAAQ,GAE1C,CACA,qBAAO,CAAe,GAClB,MAAM,EAAQ,OAAO,GAAY,MAAM,KACvC,IAAI,EAAU,EACd,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,IACnB,GAAY,KAAK,IAAI,IAAK,GAAK,EAAM,EAAI,GAE7C,OAAO,CACX,CACA,aAAA,CAAc,EAAS,EAAO,EAAK,EAAY,QACtB,IAAV,IACP,EAAQ,QAEO,IAAR,IACP,EAAM,KAAK,SAAS,OAAS,GAEjC,IAAI,EAAM,EAAQ,KAAK,OAAO,EAAM,GAAS,GAC7C,OAAI,GAAW,KAAK,SAAS,GAAK,OAAS,GAAW,KAAK,SAAS,GAAK,IAC9D,KAAK,SAAS,GAEpB,EAAM,EAAS,EACT,CAAC,KAAM,IAAK,QAAS,KAE5B,EAAU,KAAK,SAAS,GAAK,MACtB,KAAK,cAAc,EAAS,EAAO,IAAO,GAEjD,EAAU,KAAK,SAAS,GAAK,IACtB,KAAK,cAAc,EAAS,EAAK,IAAO,QADnD,CAGJ,CACA,MAAA,CAAO,GACH,OAAO,OAAO,OAAO,CAAC,WAAU,KAAK,cAAc,EAAM,eAAe,IAC5E","file":"/npm/ip2countrycode@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ip2countrycode@1.0.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const fs = require('fs');\n\nmodule.exports = class ip2cc {\n    constructor(options) {\n        if (typeof options === 'string') {\n            options = {file: options};\n        }\n        this.database = fs.readFileSync(options.file).toString().split('\\r\\n').map(line => {\n            let [start, end, code, country] = line.split('\",\"');\n            start = parseInt(String(start).substr(1), 10);\n            end = parseInt(end, 10);\n            country = String(country).slice(0, -1);\n            return {start, end, code, country};\n        });\n    }\n    static convertAddress(strAddress) {\n        const bytes = String(strAddress).split('.');\n        let address = 0;\n        for (let i = 0; i < 4; i++) {\n            address += (Math.pow(256, i) * bytes[3 - i]);\n        }\n        return address;\n    }\n    bisectCountry(address, start, end, recursion = 0) {\n        if (typeof start === 'undefined') {\n            start = 0;\n        }\n        if (typeof end === 'undefined') {\n            end = this.database.length - 1;\n        }\n        let pos = start + Math.floor((end - start) / 2);\n        if (address >= this.database[pos].start && address <= this.database[pos].end) {\n            return this.database[pos];\n        }\n        if ((end - start) < 3) {\n            return {code: '-', country: '-'};\n        }\n        if (address < this.database[pos].start) {\n            return this.bisectCountry(address, start, pos, ++recursion);\n        }\n        if (address > this.database[pos].end) {\n            return this.bisectCountry(address, pos, end, ++recursion);\n        }\n    }\n    lookup(address) {\n        return Object.assign({address}, this.bisectCountry(ip2cc.convertAddress(address)));\n    }\n};\n"]}