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KAAK,UAAY,SAAS,EAAU,IACpC,KAAK,SAAW,YAAuC,IAA3B,WAAW,EAAU,KAAW,QAAQ,IACpE,KAAK,MAAQ,EAAU,GACvB,KAAK,SAAW,EAAU,GAC1B,KAAK,UAAY,uCAAuC,YAAY,WAAW,OAC1E,OAAO,KAAK,MAAM,OAAO,eACzB,OAAO,eACZ,KAAK,KAAO,EAAI,KAChB,MAAM,EAAS,EAAI,OACnB,IAAK,MAAM,KAAQ,EAAQ,CAEvB,MAAM,EAAO,IAAI,KAA8B,KAAxB,EAAK,KAAO,QAC7B,EAAK,EACN,eAAe,KAAM,CACtB,SAAU,gBACV,UAAW,SAEV,MAAM,KACN,OAAO,GAAG,GACT,EAAa,EAAK,WAClB,EAAW,KAAK,MAAM,GAAG,SAC3B,KAAK,MAAM,GAAG,KAAc,KAChC,KAAK,YAAY,KAAK,IAAI,MAAM,CAC5B,IAAK,KAAK,IACV,SAAU,KAAK,SACf,QAAS,EAAK,QACd,MAAO,EAAK,MACZ,SAAU,IAAI,QAAQ,SAAS,CAC3B,KAAM,EAAK,QACX,KAAM,EAAK,KACX,IAAK,EAAK,IACV,MAAO,EAAK,OAEhB,KAAM,EAAK,KACX,MAAO,EAAK,MACZ,MAAO,EAAK,SACZ,KAAM,EAAK,UAAY,EACvB,KAAM,EAAK,KACX,KAAM,EAAK,OAEnB,CACA,OAAO,IACX,CAIA,QAAA,GACI,MAAO,aAAa,KAAK,kBAAkB,KAAK,cAAc,KAAK,gBAAgB,KAAK,sBAAsB,KAAK,WACvH,EAGJ,QAAQ,OAAS,OACjB,QAAQ,MAAQ","file":"/npm/@rian8337/osu-droid-utilities@3.3.2/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@rian8337/osu-droid-utilities@3.3.2/dist/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","'use strict';\n\nvar osuBase = require('@rian8337/osu-base');\nvar osuDroidReplayAnalyzer = require('@rian8337/osu-droid-replay-analyzer');\nvar node_crypto = require('node:crypto');\n\n/**\n * Represents an osu!droid score.\n */\nclass Score {\n    /**\n     * The uid of the player.\n     */\n    uid;\n    /**\n     * The ID of the score.\n     */\n    scoreID;\n    /**\n     * The player's name.\n     */\n    username;\n    /**\n     * The title of the beatmap.\n     */\n    title;\n    /**\n     * The maximum combo achieved in the play.\n     */\n    combo;\n    /**\n     * The score achieved in the play.\n     */\n    score;\n    /**\n     * The rank achieved in the play.\n     */\n    rank;\n    /**\n     * The date of which the play was set.\n     */\n    date;\n    /**\n     * The accuracy achieved in the play.\n     */\n    accuracy;\n    /**\n     * Enabled modifications in the score.\n     */\n    mods;\n    /**\n     * MD5 hash of the play.\n     */\n    hash;\n    /**\n     * The speed multiplier of the play.\n     */\n    speedMultiplier = 1;\n    /**\n     * Whether to use old statistics for this score when calculating with `MapStats`.\n     *\n     * Otherwise, this denotes whether the score was set in version 1.6.7 or lower.\n     */\n    oldStatistics;\n    /**\n     * The forced AR of the play.\n     */\n    forcedAR;\n    /**\n     * The replay of the score.\n     */\n    replay;\n    /**\n     * The complete mod string of this score (mods, speed multiplier, and force AR combined).\n     */\n    get completeModString() {\n        let finalString = `+${this.mods.length > 0 ? this.mods.map((v) => v.acronym) : \"No Mod\"}`;\n        if (this.forcedAR !== undefined || this.speedMultiplier !== 1) {\n            finalString += \" (\";\n            if (this.forcedAR !== undefined) {\n                finalString += `AR${this.forcedAR}`;\n            }\n            if (this.speedMultiplier !== 1) {\n                if (this.forcedAR !== undefined) {\n                    finalString += \", \";\n                }\n                finalString += `${this.speedMultiplier}x`;\n            }\n            finalString += \")\";\n        }\n        return finalString;\n    }\n    constructor(values) {\n        this.uid = values?.uid ?? 0;\n        this.scoreID = values?.scoreID ?? 0;\n        this.username = values?.username ?? \"\";\n        this.title = values?.title ?? \"\";\n        this.combo = values?.combo ?? 0;\n        this.score = values?.score ?? 0;\n        this.rank = values?.rank ?? \"\";\n        this.date = new Date(values?.date ?? 0);\n        this.accuracy = values?.accuracy ?? new osuBase.Accuracy({});\n        this.hash = values?.hash ?? \"\";\n        const modstrings = (values?.mods ?? \"\").split(\"|\");\n        let actualMods = \"\";\n        for (const str of modstrings) {\n            if (!str) {\n                continue;\n            }\n            if (str.startsWith(\"AR\")) {\n                this.forcedAR = parseFloat(str.replace(\"AR\", \"\"));\n            }\n            else if (str.startsWith(\"x\")) {\n                this.speedMultiplier = parseFloat(str.replace(\"x\", \"\"));\n            }\n            else {\n                actualMods += str;\n            }\n        }\n        this.mods = osuBase.ModUtil.droidStringToMods(actualMods);\n        // The pipe was added in 1.6.8 first pre-release (https://github.com/osudroid/osu-droid/commit/c08c406f4b2e535ed1ec43607a72fd8f70f8e316),\n        // so we can use that information to infer whether the score was set on version 1.6.7 or lower.\n        this.oldStatistics = !(values?.mods ?? \"\").includes(\"|\");\n    }\n    /**\n     * Retrieves score information on a beatmap from a player.\n     *\n     * @param uid The uid of the player.\n     * @param hash The MD5 hash of the beatmap.\n     * @returns The score, `null` if the score is not found.\n     */\n    static async getFromHash(uid, hash) {\n        const score = new Score();\n        const apiRequestBuilder = new osuBase.DroidAPIRequestBuilder()\n            .setEndpoint(\"scoresearchv2.php\")\n            .addParameter(\"uid\", uid)\n            .addParameter(\"hash\", hash);\n        const result = await apiRequestBuilder.sendRequest();\n        if (result.statusCode !== 200) {\n            throw new Error(\"Error retrieving score data\");\n        }\n        const entry = result.data.toString(\"utf-8\").split(\"<br>\");\n        entry.shift();\n        if (entry.length === 0) {\n            return null;\n        }\n        score.fillInformation(entry[0]);\n        return score;\n    }\n    /**\n     * Fills this instance with score information.\n     *\n     * @param info The score information from API response to fill with.\n     */\n    fillInformation(info) {\n        const play = info.split(\" \");\n        this.scoreID = parseInt(play[0]);\n        this.uid = parseInt(play[1]);\n        this.username = play[2];\n        this.score = parseInt(play[3]);\n        this.combo = parseInt(play[4]);\n        this.rank = play[5];\n        const modstrings = play[6].split(\"|\");\n        let actualMods = \"\";\n        for (const str of modstrings) {\n            if (!str) {\n                continue;\n            }\n            if (str.startsWith(\"AR\")) {\n                this.forcedAR = parseFloat(str.replace(\"AR\", \"\"));\n            }\n            else if (str.startsWith(\"x\")) {\n                this.speedMultiplier = parseFloat(str.replace(\"x\", \"\"));\n            }\n            else {\n                actualMods += str;\n            }\n        }\n        this.mods = osuBase.ModUtil.droidStringToMods(actualMods);\n        this.oldStatistics = !play[6].includes(\"|\");\n        this.accuracy = new osuBase.Accuracy({\n            n300: parseInt(play[8]),\n            n100: parseInt(play[9]),\n            n50: parseInt(play[10]),\n            nmiss: parseInt(play[11]),\n        });\n        const date = new Date(parseInt(play[12]) * 1000);\n        date.setUTCHours(date.getUTCHours() + 8);\n        // https://stackoverflow.com/a/63199512\n        const tz = date\n            .toLocaleString(\"en\", {\n            timeZone: \"Europe/Berlin\",\n            timeStyle: \"long\",\n        })\n            .split(\" \")\n            .slice(-1)[0];\n        const dateString = date.toString();\n        const msOffset = Date.parse(`${dateString} UTC`) - Date.parse(`${dateString} ${tz}`);\n        date.setUTCMilliseconds(date.getUTCMilliseconds() - msOffset);\n        this.date = date;\n        this.title = play[13]\n            .substring(0, play[13].length - 4)\n            .replace(/_/g, \" \");\n        this.hash = play[14];\n        return this;\n    }\n    /**\n     * Downloads the replay of this score.\n     */\n    async downloadReplay() {\n        if (!this.scoreID || this.replay) {\n            return;\n        }\n        this.replay = await new osuDroidReplayAnalyzer.ReplayAnalyzer({\n            scoreID: this.scoreID,\n        }).analyze();\n    }\n    /**\n     * Returns a string representative of the class.\n     */\n    toString() {\n        return `Player: ${this.username}, uid: ${this.uid}, title: ${this.title}, score: ${this.score}, combo: ${this.combo}, rank: ${this.rank}, acc: ${this.accuracy}%, date: ${this.date}, mods: ${this.mods}, hash: ${this.hash}`;\n    }\n}\n\n/**\n * Represents an osu!droid player.\n */\nclass Player {\n    /**\n     * The uid of the player.\n     */\n    uid = 0;\n    /**\n     * The username of the player.\n     */\n    username = \"\";\n    /**\n     * The avatar URL of the player.\n     */\n    avatarURL = \"\";\n    /**\n     * The location of the player based on ISO 3166-1 country codes. See {@link https://en.wikipedia.org/wiki/ISO_3166-1 this} Wikipedia page for more information.\n     */\n    location = \"\";\n    /**\n     * The email that is attached to the player's account.\n     */\n    email = \"\";\n    /**\n     * The overall rank of the player.\n     */\n    rank = 0;\n    /**\n     * The total score of the player.\n     */\n    score = 0;\n    /**\n     * The overall accuracy of the player.\n     */\n    accuracy = 0;\n    /**\n     * The amount of times the player has played.\n     */\n    playCount = 0;\n    /**\n     * Recent plays of the player.\n     */\n    recentPlays = [];\n    /**\n     * Retrieves a player's info based on their username.\n     *\n     * @param uidOrUsername The uid or username of the player.\n     * @returns The player, `null` if the player is not found.\n     */\n    static async getInformation(uidOrUsername) {\n        const player = new Player();\n        const apiRequestBuilder = new osuBase.DroidAPIRequestBuilder()\n            .setEndpoint(\"getuserinfo.php\")\n            .addParameter(typeof uidOrUsername === \"number\" ? \"uid\" : \"username\", uidOrUsername);\n        const result = await apiRequestBuilder.sendRequest();\n        if (result.statusCode !== 200) {\n            throw new Error(\"Error retrieving player data\");\n        }\n        const data = result.data.toString(\"utf-8\");\n        const resArr = data.split(\"<br>\");\n        const headerRes = resArr[0].split(\" \");\n        if (headerRes[0] === \"FAILED\") {\n            return null;\n        }\n        player.fillInformation(data);\n        return player;\n    }\n    /**\n     * Fills this instance with player information.\n     *\n     * @param info The player information from API response to fill with.\n     */\n    fillInformation(info) {\n        const resArr = info.split(\"<br>\");\n        const headerRes = resArr[0].split(\" \");\n        if (headerRes[0] === \"FAILED\") {\n            return this;\n        }\n        const obj = JSON.parse(resArr[1]);\n        this.uid = parseInt(headerRes[1]);\n        this.username = headerRes[2];\n        this.score = parseInt(headerRes[3]);\n        this.playCount = parseInt(headerRes[4]);\n        this.accuracy = parseFloat((parseFloat(headerRes[5]) * 100).toFixed(2));\n        this.email = headerRes[6];\n        this.location = headerRes[7];\n        this.avatarURL = `https://osudroid.moe/user/avatar?id=${node_crypto.createHash(\"md5\")\n            .update(this.email.trim().toLowerCase())\n            .digest(\"hex\")}&s=200`;\n        this.rank = obj.rank;\n        const recent = obj.recent;\n        for (const play of recent) {\n            // https://stackoverflow.com/a/63199512\n            const date = new Date((play.date + 3600 * 8) * 1000);\n            const tz = date\n                .toLocaleString(\"en\", {\n                timeZone: \"Europe/Berlin\",\n                timeStyle: \"long\",\n            })\n                .split(\" \")\n                .slice(-1)[0];\n            const dateString = date.toString();\n            const msOffset = Date.parse(`${dateString} UTC`) -\n                Date.parse(`${dateString} ${tz}`);\n            this.recentPlays.push(new Score({\n                uid: this.uid,\n                username: this.username,\n                scoreID: play.scoreid,\n                score: play.score,\n                accuracy: new osuBase.Accuracy({\n                    n300: play.perfect,\n                    n100: play.good,\n                    n50: play.bad,\n                    nmiss: play.miss,\n                }),\n                rank: play.mark,\n                combo: play.combo,\n                title: play.filename,\n                date: date.getTime() - msOffset,\n                mods: play.mode,\n                hash: play.hash,\n            }));\n        }\n        return this;\n    }\n    /**\n     * Returns a string representative of the class.\n     */\n    toString() {\n        return `Username: ${this.username}\\nUID: ${this.uid}\\nRank: ${this.rank}\\nScore: ${this.score}\\nPlay count: ${this.playCount}`;\n    }\n}\n\nexports.Player = Player;\nexports.Score = Score;\n\n"]}