diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..2d68f55 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,15 @@ +.tmp +.idea +.vscode +.npmrc +.nvmrc +node_modules/ +build/ +build-tools/ +reports/ +coverage/ +dist/ +**/*.md +**/*.yml +package.json +package-lock.json diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..feaf5a0 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "printWidth": 140, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true, + "trailingComma": "all", + "bracketSpacing": true, + "arrowParens": "always" +} diff --git a/package-lock.json b/package-lock.json index 510b931..07cf4c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "@types/uuid": "^8.3.4", "concurrently": "^7.0.0", "nodemon": "^2.0.15", + "prettier": "^2.6.0", "rimraf": "^3.0.2", "typescript": "^4.5.5" } @@ -3644,6 +3645,21 @@ "node": ">=4" } }, + "node_modules/prettier": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.0.tgz", + "integrity": "sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-ms": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz", @@ -7983,6 +7999,12 @@ "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", "dev": true }, + "prettier": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.0.tgz", + "integrity": "sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A==", + "dev": true + }, "pretty-ms": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz", diff --git a/package.json b/package.json index 25e6073..0fecc01 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@types/uuid": "^8.3.4", "concurrently": "^7.0.0", "nodemon": "^2.0.15", + "prettier": "^2.6.0", "rimraf": "^3.0.2", "typescript": "^4.5.5" }, diff --git a/src/armory/Armory.ts b/src/armory/Armory.ts index dc94a85..e063537 100644 --- a/src/armory/Armory.ts +++ b/src/armory/Armory.ts @@ -1,254 +1,259 @@ -import * as path from "path"; -import * as uuid from "uuid"; -import { Express } from "express"; -import * as express from "express"; -import * as winston from "winston"; -import * as morgan from "morgan"; -import { Pool, createPool } from "mysql2/promise"; -import { engine as handlebarsEngine } from "express-handlebars"; +import * as path from 'path'; +import * as uuid from 'uuid'; +import { Express } from 'express'; +import * as express from 'express'; +import * as winston from 'winston'; +import * as morgan from 'morgan'; +import { Pool, createPool } from 'mysql2/promise'; +import { engine as handlebarsEngine } from 'express-handlebars'; -import { Config, IRealmConfig } from "./Config"; -import { DbcManager } from "./data/DbcReader"; -import { CharacterCustomization } from "./data/CharacterCustomization"; -import { IndexController } from "./controllers/IndexController"; -import { CharacterController } from "./controllers/CharacterController"; -import { GuildController } from "./controllers/GuildController"; +import { Config, IRealmConfig } from './Config'; +import { DbcManager } from './data/DbcReader'; +import { CharacterCustomization } from './data/CharacterCustomization'; +import { IndexController } from './controllers/IndexController'; +import { CharacterController } from './controllers/CharacterController'; +import { GuildController } from './controllers/GuildController'; export class Armory { - public characterCustomization: CharacterCustomization; - public dbc: DbcManager; - public config: Config; - public worldDb: Pool; - public logger: winston.Logger; - public charsetCache: { [key: string]: string }; + public characterCustomization: CharacterCustomization; + public dbc: DbcManager; + public config: Config; + public worldDb: Pool; + public logger: winston.Logger; + public charsetCache: { [key: string]: string }; - private charsDbs: { [key: string]: Pool }; - private errorNames: { [key: number]: string }; - private errorDescriptions: { [key: number]: string }; + private charsDbs: { [key: string]: Pool }; + private errorNames: { [key: number]: string }; + private errorDescriptions: { [key: number]: string }; - public constructor() { - this.dbc = new DbcManager(); - this.characterCustomization = new CharacterCustomization(); - this.charsDbs = {}; - this.logger = winston.createLogger({ - level: "info", - format: winston.format.combine( - winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss:ms" }), - winston.format.printf((info) => `[${info.timestamp}] [${info.level.toUpperCase()}]: ${info.message}`), - ), - transports: [ - new winston.transports.Console({ level: "debug" }), - new winston.transports.File({ filename: path.join("logs", "armory.error.log"), level: "error" }), - new winston.transports.File({ filename: path.join("logs", "armory.combined.log"), level: "http" }), - ], - }); - this.charsetCache = {}; + public constructor() { + this.dbc = new DbcManager(); + this.characterCustomization = new CharacterCustomization(); + this.charsDbs = {}; + this.logger = winston.createLogger({ + level: 'info', + format: winston.format.combine( + winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }), + winston.format.printf((info) => `[${info.timestamp}] [${info.level.toUpperCase()}]: ${info.message}`), + ), + transports: [ + new winston.transports.Console({ level: 'debug' }), + new winston.transports.File({ filename: path.join('logs', 'armory.error.log'), level: 'error' }), + new winston.transports.File({ filename: path.join('logs', 'armory.combined.log'), level: 'http' }), + ], + }); + this.charsetCache = {}; - this.errorNames = { - 400: "Bad Request", - 401: "Unauthorized", - 403: "Forbidden", - 404: "Not Found", - 500: "Internal Server Error", - }; - this.errorDescriptions = { - 400: "Invalid request.", - 404: "Sorry, we could not find what you were looking for.", - 500: "An unexpected internal error has occurred. Please contact the site owner.", - }; - } + this.errorNames = { + 400: 'Bad Request', + 401: 'Unauthorized', + 403: 'Forbidden', + 404: 'Not Found', + 500: 'Internal Server Error', + }; + this.errorDescriptions = { + 400: 'Invalid request.', + 404: 'Sorry, we could not find what you were looking for.', + 500: 'An unexpected internal error has occurred. Please contact the site owner.', + }; + } - public async start(): Promise { - const app: Express = express(); - const listenPort = 48733; + public async start(): Promise { + const app: Express = express(); + const listenPort = 48733; - this.logger.info("Loading config..."); - this.config = await Config.load(this.logger); - this.logger.info("Loading data files..."); - if (this.config.loadDbcs) { - await this.dbc.loadAllFiles(); - } - await this.characterCustomization.loadData(); + this.logger.info('Loading config...'); + this.config = await Config.load(this.logger); + this.logger.info('Loading data files...'); + if (this.config.loadDbcs) { + await this.dbc.loadAllFiles(); + } + await this.characterCustomization.loadData(); - this.logger.info("Connecting to databases..."); - this.worldDb = createPool(this.config.worldDatabase); - for (const realm of this.config.realms) { - this.charsDbs[realm.name.toLowerCase()] = createPool(realm.charactersDatabase); - } + this.logger.info('Connecting to databases...'); + this.worldDb = createPool(this.config.worldDatabase); + for (const realm of this.config.realms) { + this.charsDbs[realm.name.toLowerCase()] = createPool(realm.charactersDatabase); + } - this.logger.info("Starting server..."); + this.logger.info('Starting server...'); - const locals = { - aowow: this.config.aowowUrl, - websiteUrl: this.config.websiteUrl, - websiteName: this.config.websiteName, - websiteRoot: this.config.websiteRoot, - iframeMode: this.config.iframeMode, - }; - for (const key in locals) { - if (locals.hasOwnProperty(key)) { - app.locals[key] = locals[key]; - } - } - app.locals.locals = locals; + const locals = { + aowow: this.config.aowowUrl, + websiteUrl: this.config.websiteUrl, + websiteName: this.config.websiteName, + websiteRoot: this.config.websiteRoot, + iframeMode: this.config.iframeMode, + }; + for (const key in locals) { + if (locals.hasOwnProperty(key)) { + app.locals[key] = locals[key]; + } + } + app.locals.locals = locals; - app.engine(".hbs", handlebarsEngine({ - extname: "hbs", - partialsDir: path.join(process.cwd(), "static", "partials"), - layoutsDir: path.join(process.cwd(), "static"), - defaultLayout: "layout.hbs", - helpers: { - ...require("handlebars-helpers")(), - }, - })); - app.set("view engine", "handlebars"); - app.set("views", path.join(process.cwd(), "static")); + app.engine( + '.hbs', + handlebarsEngine({ + extname: 'hbs', + partialsDir: path.join(process.cwd(), 'static', 'partials'), + layoutsDir: path.join(process.cwd(), 'static'), + defaultLayout: 'layout.hbs', + helpers: { + ...require('handlebars-helpers')(), + }, + }), + ); + app.set('view engine', 'handlebars'); + app.set('views', path.join(process.cwd(), 'static')); - app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { - req.id = uuid.v4(); - next(); - }); + app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { + req.id = uuid.v4(); + next(); + }); - morgan.token("id", (req: express.Request) => { - return req.id; - }); - morgan.token("ip", (req: express.Request) => { - const forwardedFor = req.headers["x-forwarded-for"]; - if (forwardedFor) { - if (typeof forwardedFor === "string") { - return forwardedFor; - } - return forwardedFor.join(", "); - } - return req.socket.remoteAddress; - }); - app.use(morgan(":method :url :status - ID :id - IP :ip - :response-time ms", { - stream: { - write: (msg) => this.logger.http(msg.trim()), - }, - })); + morgan.token('id', (req: express.Request) => { + return req.id; + }); + morgan.token('ip', (req: express.Request) => { + const forwardedFor = req.headers['x-forwarded-for']; + if (forwardedFor) { + if (typeof forwardedFor === 'string') { + return forwardedFor; + } + return forwardedFor.join(', '); + } + return req.socket.remoteAddress; + }); + app.use( + morgan(':method :url :status - ID :id - IP :ip - :response-time ms', { + stream: { + write: (msg) => this.logger.http(msg.trim()), + }, + }), + ); - app.use("/js", express.static(`static/js`)); - app.use("/css", express.static(`static/css`)); - app.use("/img", express.static(`static/img`)); - app.use("/data/mo3", express.static(`data/mo3`)); - app.use("/data/meta", express.static(`data/meta`)); - app.use("/data/bone", express.static(`data/bone`)); - app.use("/data/textures", express.static(`data/textures`)); - app.use("/data/background.png", express.static(`data/modelviewer-background.png`)); + app.use('/js', express.static(`static/js`)); + app.use('/css', express.static(`static/css`)); + app.use('/img', express.static(`static/img`)); + app.use('/data/mo3', express.static(`data/mo3`)); + app.use('/data/meta', express.static(`data/meta`)); + app.use('/data/bone', express.static(`data/bone`)); + app.use('/data/textures', express.static(`data/textures`)); + app.use('/data/background.png', express.static(`data/modelviewer-background.png`)); - const indexController = new IndexController(this); - app.get("/", this.wrapRoute(indexController.index.bind(indexController))); - app.get("/search", this.wrapRoute(indexController.search.bind(indexController))); + const indexController = new IndexController(this); + app.get('/', this.wrapRoute(indexController.index.bind(indexController))); + app.get('/search', this.wrapRoute(indexController.search.bind(indexController))); - const charsController = new CharacterController(this); - await charsController.load(); - app.get("/character/:realm/:name", this.wrapRoute(charsController.character.bind(charsController))); - app.get("/character/:realm/:name/talents", this.wrapRoute(charsController.talents.bind(charsController))); - app.get("/character/:realm/:name/achievements", this.wrapRoute(charsController.achievements.bind(charsController))); - app.get("/character/:realm/:character/achievements/data", this.wrapRoute(charsController.achievementsData.bind(charsController))); - app.get("/character/:realm/:name/pvp", this.wrapRoute(charsController.pvp.bind(charsController))); + const charsController = new CharacterController(this); + await charsController.load(); + app.get('/character/:realm/:name', this.wrapRoute(charsController.character.bind(charsController))); + app.get('/character/:realm/:name/talents', this.wrapRoute(charsController.talents.bind(charsController))); + app.get('/character/:realm/:name/achievements', this.wrapRoute(charsController.achievements.bind(charsController))); + app.get('/character/:realm/:character/achievements/data', this.wrapRoute(charsController.achievementsData.bind(charsController))); + app.get('/character/:realm/:name/pvp', this.wrapRoute(charsController.pvp.bind(charsController))); - const guildsController = new GuildController(this); - app.get("/guild/:realm/:name", this.wrapRoute(guildsController.guild.bind(guildsController))); - app.get("/guild/:realm/:guild/members", this.wrapRoute(guildsController.members.bind(guildsController))); + const guildsController = new GuildController(this); + app.get('/guild/:realm/:name', this.wrapRoute(guildsController.guild.bind(guildsController))); + app.get('/guild/:realm/:guild/members', this.wrapRoute(guildsController.members.bind(guildsController))); - app.use((err, req: express.Request, res: express.Response, next: express.NextFunction) => { - // Error handler + app.use((err, req: express.Request, res: express.Response, next: express.NextFunction) => { + // Error handler - if (err instanceof Error) { - const contents = err.stack ?? `${err.name}: ${err.message}`; - this.logger.error(`Error on request ${req.id}. ${contents}`); - } + if (err instanceof Error) { + const contents = err.stack ?? `${err.name}: ${err.message}`; + this.logger.error(`Error on request ${req.id}. ${contents}`); + } - let status = 500; - if (typeof err === "number") { - status = err; - } + let status = 500; + if (typeof err === 'number') { + status = err; + } - res.status(status).render("error.hbs", this.getErrorViewData(status, req)); - }); + res.status(status).render('error.hbs', this.getErrorViewData(status, req)); + }); - app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { - // 404 handler - res.status(404); + app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { + // 404 handler + res.status(404); - // Respond with html page - if (req.accepts("html")) { - return res.render("error.hbs", this.getErrorViewData(404, req)); - } + // Respond with html page + if (req.accepts('html')) { + return res.render('error.hbs', this.getErrorViewData(404, req)); + } - // Respond with json - if (req.accepts("json")) { - return res.json({ error: this.errorNames[404] }); - } + // Respond with json + if (req.accepts('json')) { + return res.json({ error: this.errorNames[404] }); + } - // Default to plain-text - res.type("txt").send(this.errorNames[404]); - }); + // Default to plain-text + res.type('txt').send(this.errorNames[404]); + }); - this.gc(); - app.listen(listenPort, "0.0.0.0", () => { - this.logger.info(`Server is listening on 0.0.0.0:${listenPort}.`); - }); - } + this.gc(); + app.listen(listenPort, '0.0.0.0', () => { + this.logger.info(`Server is listening on 0.0.0.0:${listenPort}.`); + }); + } - public getCharactersDb(realm: string): Pool { - return this.charsDbs[realm.toLowerCase()]; - } + public getCharactersDb(realm: string): Pool { + return this.charsDbs[realm.toLowerCase()]; + } - public getRealm(realm: string): IRealmConfig { - return this.config.realms.find(r => r.name.toLowerCase() === realm.toLowerCase()); - } + public getRealm(realm: string): IRealmConfig { + return this.config.realms.find((r) => r.name.toLowerCase() === realm.toLowerCase()); + } - public async getDatabaseCharset(realm: string): Promise { - const db = this.getCharactersDb(realm); + public async getDatabaseCharset(realm: string): Promise { + const db = this.getCharactersDb(realm); - if (!(realm in this.charsetCache)) { - const [rows, fields] = await db.query({ - sql: ` + if (!(realm in this.charsetCache)) { + const [rows, fields] = await db.query({ + sql: ` SELECT CCSA.character_set_name AS charset FROM information_schema.\`TABLES\` T, information_schema.\`COLLATION_CHARACTER_SET_APPLICABILITY\` CCSA WHERE CCSA.collation_name = T.table_collation AND T.table_schema = "${(await db.getConnection()).config.database}" AND T.table_name = "characters" `, - timeout: this.config.dbQueryTimeout, - }); - this.charsetCache[realm] = rows[0].charset; - } - return this.charsetCache[realm]; - } + timeout: this.config.dbQueryTimeout, + }); + this.charsetCache[realm] = rows[0].charset; + } + return this.charsetCache[realm]; + } - public gc(): void { - if (this.config.loadDbcs) { - return; - } + public gc(): void { + if (this.config.loadDbcs) { + return; + } - setTimeout(() => { - if (global.gc) { - global.gc(); - } - }, 500); - } + setTimeout(() => { + if (global.gc) { + global.gc(); + } + }, 500); + } - private wrapRoute(fn: (req: express.Request, res: express.Response, next: express.NextFunction) => Promise) { - // Adds error handling for promise-based controller methods - return async (req: express.Request, res: express.Response, next: express.NextFunction) => { - try { - await fn(req, res, next); - } catch (e) { - next(e); - } - }; - } + private wrapRoute(fn: (req: express.Request, res: express.Response, next: express.NextFunction) => Promise) { + // Adds error handling for promise-based controller methods + return async (req: express.Request, res: express.Response, next: express.NextFunction) => { + try { + await fn(req, res, next); + } catch (e) { + next(e); + } + }; + } - private getErrorViewData(status: number, req: express.Request) { - return { - status, - name: this.errorNames[status] || "An error occurred", - description: this.errorDescriptions[status] || "", - reqId: req.id, - }; - } + private getErrorViewData(status: number, req: express.Request) { + return { + status, + name: this.errorNames[status] || 'An error occurred', + description: this.errorDescriptions[status] || '', + reqId: req.id, + }; + } } diff --git a/src/armory/Config.ts b/src/armory/Config.ts index 3a9427f..ab8170e 100644 --- a/src/armory/Config.ts +++ b/src/armory/Config.ts @@ -1,176 +1,180 @@ -import * as fs from "fs"; +import * as fs from 'fs'; const fsp = fs.promises; -import * as winston from "winston"; +import * as winston from 'winston'; export interface IDatabaseConfig { - host: string; - port: number; - user: string; - password: string; - database: string; + host: string; + port: number; + user: string; + password: string; + database: string; } export interface IRealmConfig { - name: string; - realmId: number; - authDatabase: string; - charactersDatabase: IDatabaseConfig; + name: string; + realmId: number; + authDatabase: string; + charactersDatabase: IDatabaseConfig; } export interface IIframeModeConfig { - enabled: boolean; - url: string; + enabled: boolean; + url: string; } export class Config { - public aowowUrl: string; - public websiteUrl: string; - public websiteName: string; - public websiteRoot: string; - public iframeMode: IIframeModeConfig; - public loadDbcs: boolean; - public hideGameMasters: boolean; - public realms: IRealmConfig[]; - public worldDatabase: IDatabaseConfig; - public dbQueryTimeout: number; + public aowowUrl: string; + public websiteUrl: string; + public websiteName: string; + public websiteRoot: string; + public iframeMode: IIframeModeConfig; + public loadDbcs: boolean; + public hideGameMasters: boolean; + public realms: IRealmConfig[]; + public worldDatabase: IDatabaseConfig; + public dbQueryTimeout: number; - private static envPrefix: string = "ACORE_ARMORY"; - private static checkedMissingField: boolean = false; + private static envPrefix: string = 'ACORE_ARMORY'; + private static checkedMissingField: boolean = false; - public static async load(logger: winston.Logger): Promise { - try { - await fsp.access("config.json"); - return await Config.loadFromFile(logger); - } catch (err) { - return await Config.loadFromEnv(logger); - } - } + public static async load(logger: winston.Logger): Promise { + try { + await fsp.access('config.json'); + return await Config.loadFromFile(logger); + } catch (err) { + return await Config.loadFromEnv(logger); + } + } - private static async loadFromFile(logger: winston.Logger): Promise { - const json: Buffer = await fsp.readFile("config.json"); - const config = JSON.parse(json.toString()) as Config; + private static async loadFromFile(logger: winston.Logger): Promise { + const json: Buffer = await fsp.readFile('config.json'); + const config = JSON.parse(json.toString()) as Config; - if (!Config.checkedMissingField) { - const defaultConfigJson = await fsp.readFile("config.default.json"); - const defaultConfig = JSON.parse(defaultConfigJson.toString()); - Config.checkAllMissingFields(logger, config, defaultConfig); - Config.checkedMissingField = true; - } + if (!Config.checkedMissingField) { + const defaultConfigJson = await fsp.readFile('config.default.json'); + const defaultConfig = JSON.parse(defaultConfigJson.toString()); + Config.checkAllMissingFields(logger, config, defaultConfig); + Config.checkedMissingField = true; + } - return config; - } + return config; + } - private static async loadFromEnv(logger: winston.Logger): Promise { - const config = {}; - const json = await fsp.readFile("config.default.json"); - const defaultConfig = JSON.parse(json.toString()); - Config.loadObjFromEnv(logger, config, defaultConfig); - Config.checkedMissingField = true; - return config as Config; - } + private static async loadFromEnv(logger: winston.Logger): Promise { + const config = {}; + const json = await fsp.readFile('config.default.json'); + const defaultConfig = JSON.parse(json.toString()); + Config.loadObjFromEnv(logger, config, defaultConfig); + Config.checkedMissingField = true; + return config as Config; + } - private static loadObjFromEnv(logger: winston.Logger, obj: object, model: object, parentName: string = "") { - if (parentName !== "") { - parentName += "."; - } + private static loadObjFromEnv(logger: winston.Logger, obj: object, model: object, parentName: string = '') { + if (parentName !== '') { + parentName += '.'; + } - for (const field in model) { - if (!model.hasOwnProperty(field)) { - continue; - } + for (const field in model) { + if (!model.hasOwnProperty(field)) { + continue; + } - if (Array.isArray(model[field])) { - obj[field] = Config.loadArrayFromEnv(logger, model[field][0], parentName + field); - } else if (typeof model[field] === "object") { - obj[field] = {}; - Config.loadObjFromEnv(logger, obj[field], model[field], parentName + field); - } else if (!obj.hasOwnProperty(field)) { - const key = Config.getEnvKey(parentName + field); - if (process.env.hasOwnProperty(key)) { - obj[field] = Config.parseEnvValue(process.env[key], model[field]); - } else if (!Config.checkedMissingField) { - logger.warn(`Config field ${key} is missing from .env!`); - } - } - } - } + if (Array.isArray(model[field])) { + obj[field] = Config.loadArrayFromEnv(logger, model[field][0], parentName + field); + } else if (typeof model[field] === 'object') { + obj[field] = {}; + Config.loadObjFromEnv(logger, obj[field], model[field], parentName + field); + } else if (!obj.hasOwnProperty(field)) { + const key = Config.getEnvKey(parentName + field); + if (process.env.hasOwnProperty(key)) { + obj[field] = Config.parseEnvValue(process.env[key], model[field]); + } else if (!Config.checkedMissingField) { + logger.warn(`Config field ${key} is missing from .env!`); + } + } + } + } - private static loadArrayFromEnv(logger: winston.Logger, model: any, parentName: string = ""): any[] { - if (parentName !== "") { - parentName += "."; - } + private static loadArrayFromEnv(logger: winston.Logger, model: any, parentName: string = ''): any[] { + if (parentName !== '') { + parentName += '.'; + } - const arr = []; - let i = 0; - while (true) { - const key = Config.getEnvKey(parentName + i); - const found = Object.keys(process.env).some(k => k.startsWith(key)); - if (!found) { - break; - } + const arr = []; + let i = 0; + while (true) { + const key = Config.getEnvKey(parentName + i); + const found = Object.keys(process.env).some((k) => k.startsWith(key)); + if (!found) { + break; + } - if (Array.isArray(model)) { - arr.push(Config.loadArrayFromEnv(logger, model[0], parentName + i)); - } else if (typeof model === "object") { - const obj = {}; - Config.loadObjFromEnv(logger, obj, model, parentName + i); - if (Object.keys(obj).length > 0) { - arr.push(obj); - } - } else if (process.env.hasOwnProperty(key)) { - arr.push(Config.parseEnvValue(process.env[key], model)); - } else { - break; - } + if (Array.isArray(model)) { + arr.push(Config.loadArrayFromEnv(logger, model[0], parentName + i)); + } else if (typeof model === 'object') { + const obj = {}; + Config.loadObjFromEnv(logger, obj, model, parentName + i); + if (Object.keys(obj).length > 0) { + arr.push(obj); + } + } else if (process.env.hasOwnProperty(key)) { + arr.push(Config.parseEnvValue(process.env[key], model)); + } else { + break; + } - ++i; - } + ++i; + } - return arr; - } + return arr; + } - private static getEnvKey(key: string): string { - return Config.envPrefix + "_" + key - .replace(/\./g, "__") - .replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`) - .toUpperCase(); - } + private static getEnvKey(key: string): string { + return ( + Config.envPrefix + + '_' + + key + .replace(/\./g, '__') + .replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`) + .toUpperCase() + ); + } - private static parseEnvValue(value: string, model: any): any { - const type = typeof model; - const lower = value.toLowerCase(); - if (type === "boolean") { - return lower === "true" || value === "1"; - } - if (type === "number") { - return parseFloat(value); - } - return value; - } + private static parseEnvValue(value: string, model: any): any { + const type = typeof model; + const lower = value.toLowerCase(); + if (type === 'boolean') { + return lower === 'true' || value === '1'; + } + if (type === 'number') { + return parseFloat(value); + } + return value; + } - private static checkAllMissingFields(logger: winston.Logger, obj: object, model: object, parentName: string = "") { - const missing = Config.hasMissingFields(obj, model); - if (parentName !== "") { - parentName += "."; - } - for (const field of missing) { - logger.warn(`Field ${parentName}${field} is missing from config.json!`); - } - for (const key in model) { - if (typeof model[key] === "object" && obj.hasOwnProperty(key)) { - Config.checkAllMissingFields(logger, obj[key], model[key], parentName + key); - } - } - } + private static checkAllMissingFields(logger: winston.Logger, obj: object, model: object, parentName: string = '') { + const missing = Config.hasMissingFields(obj, model); + if (parentName !== '') { + parentName += '.'; + } + for (const field of missing) { + logger.warn(`Field ${parentName}${field} is missing from config.json!`); + } + for (const key in model) { + if (typeof model[key] === 'object' && obj.hasOwnProperty(key)) { + Config.checkAllMissingFields(logger, obj[key], model[key], parentName + key); + } + } + } - private static hasMissingFields(obj: object, model: object): string[] { - const missing = []; - for (const key in model) { - if (!obj.hasOwnProperty(key)) { - missing.push(key); - } - } - return missing; - } -}; + private static hasMissingFields(obj: object, model: object): string[] { + const missing = []; + for (const key in model) { + if (!obj.hasOwnProperty(key)) { + missing.push(key); + } + } + return missing; + } +} diff --git a/src/armory/DataTablesSsp.ts b/src/armory/DataTablesSsp.ts index 36324f9..f82e9f6 100644 --- a/src/armory/DataTablesSsp.ts +++ b/src/armory/DataTablesSsp.ts @@ -1,173 +1,170 @@ -import { Pool } from "mysql2/promise"; -import { Query } from "express-serve-static-core"; +import { Pool } from 'mysql2/promise'; +import { Query } from 'express-serve-static-core'; export interface IResult { - recordsTotal: number; - recordsFiltered: number; - draw: number; - data: any[][]; + recordsTotal: number; + recordsFiltered: number; + draw: number; + data: any[][]; } export interface IColumnSettings { - name: string; - collation?: string; - formatter?: (data: string | number | null, row: any) => string; - table?: string; - database?: string; + name: string; + collation?: string; + formatter?: (data: string | number | null, row: any) => string; + table?: string; + database?: string; } export interface IColumnJoin { - table1: string; - column1: string; - table2: string; - column2: string; - database2?: string; - kind: "INNER" | "FULL OUTER" | "LEFT" | "RIGHT"; + table1: string; + column1: string; + table2: string; + column2: string; + database2?: string; + kind: 'INNER' | 'FULL OUTER' | 'LEFT' | 'RIGHT'; } export class DataTablesSsp { - public draw: number; - public joins: IColumnJoin[] = []; - public extraDataColumns: string[] = []; + public draw: number; + public joins: IColumnJoin[] = []; + public extraDataColumns: string[] = []; - private db: Pool; - private table: string; - private primaryKey: string; - private columnSettings: IColumnSettings[]; + private db: Pool; + private table: string; + private primaryKey: string; + private columnSettings: IColumnSettings[]; - private start: number; - private length: number; - private _order: { - column: number, - dir: string, - }[]; - private columns: { - data: number, - name: string, - searchable: boolean, - orderable: boolean, - search: { - value: string, - regex: boolean, - } - }[]; - private search: { - value: string, - regex: boolean, - }; + private start: number; + private length: number; + private _order: { + column: number; + dir: string; + }[]; + private columns: { + data: number; + name: string; + searchable: boolean; + orderable: boolean; + search: { + value: string; + regex: boolean; + }; + }[]; + private search: { + value: string; + regex: boolean; + }; - private wheres: string[] = []; - private filterBindings: (string | number)[] = []; - private customBindings: (string | number)[] = []; - private filterWhereSql: string = "1"; - private customWhereSql: string = "1"; - private limitSql: string = ""; - private orderSql: string = ""; - private joinSql: string = ""; + private wheres: string[] = []; + private filterBindings: (string | number)[] = []; + private customBindings: (string | number)[] = []; + private filterWhereSql: string = '1'; + private customWhereSql: string = '1'; + private limitSql: string = ''; + private orderSql: string = ''; + private joinSql: string = ''; - public constructor(query: Query, db: Pool, table: string, primaryKey: string, columnSettings: IColumnSettings[]) { - this.start = parseInt(query.start as string, 10); - this.length = parseInt(query.length as string, 10); - this.draw = parseInt(query.draw as string, 10); - this._order = (query.order as { column: string, dir: string }[]) - .map(order => { return { column: parseInt(order.column, 10), dir: order.dir, }; }); - this.columns = (query.columns as { data: string, name: string, searchable: string, orderable: string, search: any }[]) - .map(column => { - return { - data: parseInt(column.data, 10), - name: column.name, - searchable: column.searchable === "true", - orderable: column.orderable === "true", - search: { value: column.search.value, regex: column.search.regex === "true" }, - }; - }); - this.search = { - value: (query.search as any).value as string, - regex: (query.search as any).regex === "true", - }; + public constructor(query: Query, db: Pool, table: string, primaryKey: string, columnSettings: IColumnSettings[]) { + this.start = parseInt(query.start as string, 10); + this.length = parseInt(query.length as string, 10); + this.draw = parseInt(query.draw as string, 10); + this._order = (query.order as { column: string; dir: string }[]).map((order) => { + return { column: parseInt(order.column, 10), dir: order.dir }; + }); + this.columns = (query.columns as { data: string; name: string; searchable: string; orderable: string; search: any }[]).map((column) => { + return { + data: parseInt(column.data, 10), + name: column.name, + searchable: column.searchable === 'true', + orderable: column.orderable === 'true', + search: { value: column.search.value, regex: column.search.regex === 'true' }, + }; + }); + this.search = { + value: (query.search as any).value as string, + regex: (query.search as any).regex === 'true', + }; - this.db = db; - this.table = table; - this.primaryKey = primaryKey; - this.columnSettings = columnSettings; - } + this.db = db; + this.table = table; + this.primaryKey = primaryKey; + this.columnSettings = columnSettings; + } - private colSettingsToStr(colSettings: IColumnSettings) { - const db = colSettings.database ? ("`" + colSettings.database + "`.") : ""; - return `${db}\`${colSettings.table || this.table}\`.\`${colSettings.name}\``; - } + private colSettingsToStr(colSettings: IColumnSettings) { + const db = colSettings.database ? '`' + colSettings.database + '`.' : ''; + return `${db}\`${colSettings.table || this.table}\`.\`${colSettings.name}\``; + } - private limit() { - if (this.start !== undefined && this.length !== -1) { - this.limitSql = `LIMIT ${this.length} OFFSET ${this.start}`; - } - return this; - } + private limit() { + if (this.start !== undefined && this.length !== -1) { + this.limitSql = `LIMIT ${this.length} OFFSET ${this.start}`; + } + return this; + } - private order() { - if (this._order === undefined) { - return this; - } + private order() { + if (this._order === undefined) { + return this; + } - const orderBy = []; - for (const order of this._order) { - const requestColumn = this.columns[order.column]; - if (!requestColumn.orderable) { - continue; - } + const orderBy = []; + for (const order of this._order) { + const requestColumn = this.columns[order.column]; + if (!requestColumn.orderable) { + continue; + } - const colSettings = this.columnSettings[requestColumn.data]; - orderBy.push(`${this.colSettingsToStr(colSettings)} ${order.dir}`); - } - orderBy.push(`\`${this.table}\`.\`${this.primaryKey}\``); + const colSettings = this.columnSettings[requestColumn.data]; + orderBy.push(`${this.colSettingsToStr(colSettings)} ${order.dir}`); + } + orderBy.push(`\`${this.table}\`.\`${this.primaryKey}\``); - if (orderBy.length > 0) { - this.orderSql = "ORDER BY " + orderBy.join(", "); - } + if (orderBy.length > 0) { + this.orderSql = 'ORDER BY ' + orderBy.join(', '); + } - return this; - } + return this; + } - private join() { - for (const join of this.joins) { - const db2 = join.database2 ? "`" + join.database2 + "`." : ""; - this.joinSql += `${join.kind} JOIN ${db2}\`${join.table2}\` ON ${db2}\`${join.table2}\`.\`${join.column2}\` = \`${join.table1}\`.\`${join.column1}\`\n`; - } + private join() { + for (const join of this.joins) { + const db2 = join.database2 ? '`' + join.database2 + '`.' : ''; + this.joinSql += `${join.kind} JOIN ${db2}\`${join.table2}\` ON ${db2}\`${join.table2}\`.\`${join.column2}\` = \`${join.table1}\`.\`${join.column1}\`\n`; + } - return this; - } + return this; + } - private filter() { - if (this.search.value?.length > 0) { - const filterWheres = []; - this.filterBindings = []; + private filter() { + if (this.search.value?.length > 0) { + const filterWheres = []; + this.filterBindings = []; - for (const col of this.columns) { - if (!col.searchable) { - continue; - } + for (const col of this.columns) { + if (!col.searchable) { + continue; + } - const colSettings = this.columnSettings[col.data]; - const collate = colSettings.collation !== undefined ? `COLLATE ${colSettings.collation} ` : ""; - filterWheres.push(`${this.colSettingsToStr(colSettings)} ${collate}LIKE ?`); - this.filterBindings.push(`%${this.search.value}%`); - } - if (filterWheres.length > 0) { - this.filterWhereSql = "(" + filterWheres.map(w => `(${w})`).join(" OR ") + ")"; - } - } + const colSettings = this.columnSettings[col.data]; + const collate = colSettings.collation !== undefined ? `COLLATE ${colSettings.collation} ` : ''; + filterWheres.push(`${this.colSettingsToStr(colSettings)} ${collate}LIKE ?`); + this.filterBindings.push(`%${this.search.value}%`); + } + if (filterWheres.length > 0) { + this.filterWhereSql = '(' + filterWheres.map((w) => `(${w})`).join(' OR ') + ')'; + } + } - this.customWhereSql = this.wheres.map(w => `(${w})`).join(" AND "); - return this; - } + this.customWhereSql = this.wheres.map((w) => `(${w})`).join(' AND '); + return this; + } - public sql(): string { - const columns = [ - ...this.columnSettings.map(c => this.colSettingsToStr(c)), - ...this.extraDataColumns, - ]; - return ` - SELECT ${columns.join(", ")} + public sql(): string { + const columns = [...this.columnSettings.map((c) => this.colSettingsToStr(c)), ...this.extraDataColumns]; + return ` + SELECT ${columns.join(', ')} FROM ${this.table} ${this.joinSql} WHERE @@ -176,19 +173,19 @@ export class DataTablesSsp { ${this.orderSql} ${this.limitSql} `; - } + } - private buildTotalCountSql(): string { - return ` + private buildTotalCountSql(): string { + return ` SELECT COUNT(\`${this.table}\`.\`${this.primaryKey}\`) AS \`count\` FROM ${this.table} ${this.joinSql} WHERE ${this.customWhereSql} `; - } + } - private buildFilteredCountSql(): string { - return ` + private buildFilteredCountSql(): string { + return ` SELECT COUNT(\`${this.table}\`.\`${this.primaryKey}\`) AS \`count\` FROM ${this.table} ${this.joinSql} @@ -196,59 +193,56 @@ export class DataTablesSsp { ${this.filterWhereSql} AND ${this.customWhereSql} `; - } + } - public async run(queryTimeout: number = 10_000): Promise { - this.limit() - .order() - .join() - .filter(); + public async run(queryTimeout: number = 10_000): Promise { + this.limit().order().join().filter(); - const bindings = [...this.filterBindings, ...this.customBindings]; + const bindings = [...this.filterBindings, ...this.customBindings]; - let [rows, fields] = await this.db.query({ - sql: this.buildTotalCountSql(), - values: this.customBindings, - timeout: queryTimeout, - }); - const recordsTotal = rows[0].count; + let [rows, fields] = await this.db.query({ + sql: this.buildTotalCountSql(), + values: this.customBindings, + timeout: queryTimeout, + }); + const recordsTotal = rows[0].count; - [rows, fields] = await this.db.query({ - sql: this.buildFilteredCountSql(), - values: bindings, - timeout: queryTimeout, - }); - const recordsFiltered = rows[0].count; + [rows, fields] = await this.db.query({ + sql: this.buildFilteredCountSql(), + values: bindings, + timeout: queryTimeout, + }); + const recordsFiltered = rows[0].count; - [rows, fields] = await this.db.query({ - sql: this.sql(), - rowsAsArray: true, - values: bindings, - timeout: queryTimeout, - }); - rows = (rows as any[][]).map(row => { - for (let i = 0; i < this.columnSettings.length; ++i) { - const col = this.columnSettings[i]; - if (col.formatter !== undefined) { - row[i] = col.formatter(row[i], row); - } - } - return row; - }); + [rows, fields] = await this.db.query({ + sql: this.sql(), + rowsAsArray: true, + values: bindings, + timeout: queryTimeout, + }); + rows = (rows as any[][]).map((row) => { + for (let i = 0; i < this.columnSettings.length; ++i) { + const col = this.columnSettings[i]; + if (col.formatter !== undefined) { + row[i] = col.formatter(row[i], row); + } + } + return row; + }); - return { - recordsTotal, - recordsFiltered, - draw: this.draw, - data: rows, - }; - } + return { + recordsTotal, + recordsFiltered, + draw: this.draw, + data: rows, + }; + } - public where(condition: string, binding?: string | number) { - this.wheres.push(condition); - if (binding !== undefined) { - this.customBindings.push(binding); - } - return this; - } + public where(condition: string, binding?: string | number) { + this.wheres.push(condition); + if (binding !== undefined) { + this.customBindings.push(binding); + } + return this; + } } diff --git a/src/armory/Utils.ts b/src/armory/Utils.ts index 7f0c427..05d158f 100644 --- a/src/armory/Utils.ts +++ b/src/armory/Utils.ts @@ -1,54 +1,54 @@ export enum EFaction { - Horde = 0, - Alliance = 1, + Horde = 0, + Alliance = 1, } export interface IEmblem { - icon: string; - iconColor: string; - border: string; - borderColor: string; - background: string; + icon: string; + iconColor: string; + border: string; + borderColor: string; + background: string; } export class Utils { - public static raceNames = { - 1: "human", - 2: "orc", - 3: "dwarf", - 4: "nightelf", - 5: "scourge", - 6: "tauren", - 7: "gnome", - 8: "troll", - 10: "bloodelf", - 11: "draenei", - }; - public static classNames = { - 1: "warrior", - 2: "paladin", - 3: "hunter", - 4: "rogue", - 5: "priest", - 6: "deathknight", - 7: "shaman", - 8: "mage", - 9: "warlock", - 11: "druid", - }; + public static raceNames = { + 1: 'human', + 2: 'orc', + 3: 'dwarf', + 4: 'nightelf', + 5: 'scourge', + 6: 'tauren', + 7: 'gnome', + 8: 'troll', + 10: 'bloodelf', + 11: 'draenei', + }; + public static classNames = { + 1: 'warrior', + 2: 'paladin', + 3: 'hunter', + 4: 'rogue', + 5: 'priest', + 6: 'deathknight', + 7: 'shaman', + 8: 'mage', + 9: 'warlock', + 11: 'druid', + }; - public static getFactionFromRaceId(race: number): EFaction { - return [1, 3, 4, 7, 11].includes(race) ? EFaction.Alliance : EFaction.Horde; - } + public static getFactionFromRaceId(race: number): EFaction { + return [1, 3, 4, 7, 11].includes(race) ? EFaction.Alliance : EFaction.Horde; + } - public static makeEmblemObject(obj: any, padWithZeroes: boolean = true): IEmblem { - const padLength = padWithZeroes ? 2 : 0; - return { - icon: obj.emblemStyle.toString().padStart(padLength, "0"), - iconColor: obj.emblemColor.toString().padStart(padLength, "0"), - border: obj.borderStyle.toString().padStart(padLength, "0"), - borderColor: obj.borderColor.toString().padStart(padLength, "0"), - background: obj.background.toString().padStart(padLength, "0"), - }; - } + public static makeEmblemObject(obj: any, padWithZeroes: boolean = true): IEmblem { + const padLength = padWithZeroes ? 2 : 0; + return { + icon: obj.emblemStyle.toString().padStart(padLength, '0'), + iconColor: obj.emblemColor.toString().padStart(padLength, '0'), + border: obj.borderStyle.toString().padStart(padLength, '0'), + borderColor: obj.borderColor.toString().padStart(padLength, '0'), + background: obj.background.toString().padStart(padLength, '0'), + }; + } } diff --git a/src/armory/controllers/CharacterController.ts b/src/armory/controllers/CharacterController.ts index fcdbf19..1a7d37d 100644 --- a/src/armory/controllers/CharacterController.ts +++ b/src/armory/controllers/CharacterController.ts @@ -1,315 +1,316 @@ -import * as express from "express"; -import { RowDataPacket } from "mysql2/promise"; +import * as express from 'express'; +import { RowDataPacket } from 'mysql2/promise'; -import { Utils } from "../Utils"; -import { Armory } from "../Armory"; -import { IRealmConfig } from "../Config"; -import { IAchievement } from "../data/DbcReader"; +import { Utils } from '../Utils'; +import { Armory } from '../Armory'; +import { IRealmConfig } from '../Config'; +import { IAchievement } from '../data/DbcReader'; interface ICharacterData { - guid: number; - name: string; - race: number; - class: number; - gender: number; - level: number; - skin: number; - face: number; - hairStyle: number; - hairColor: number; - facialStyle: number; - playerFlags: number; - online: number; - guild: string; + guid: number; + name: string; + race: number; + class: number; + gender: number; + level: number; + skin: number; + face: number; + hairStyle: number; + hairColor: number; + facialStyle: number; + playerFlags: number; + online: number; + guild: string; } interface IEquipmentData { - slot: number; - itemEntry: number; - flags: number; - enchantments: string; - randomPropertyId: number; - classId: number; - subclassId: number; + slot: number; + itemEntry: number; + flags: number; + enchantments: string; + randomPropertyId: number; + classId: number; + subclassId: number; } interface ICustomizationOption { - optionId: number; - choiceId: number; + optionId: number; + choiceId: number; } interface IMount { - creatureDisplayId: number; - spell: number; - icon: string; + creatureDisplayId: number; + spell: number; + icon: string; } const ItemClassGem = 3; const SpellMechanicMounted = 21; const RaceDisplayName = { - 1: "Human", - 2: "Orc", - 3: "Dwarf", - 4: "Night Elf", - 5: "Undead", - 6: "Tauren", - 7: "Gnome", - 8: "Troll", - 10: "Blood Elf", - 11: "Draenei", + 1: 'Human', + 2: 'Orc', + 3: 'Dwarf', + 4: 'Night Elf', + 5: 'Undead', + 6: 'Tauren', + 7: 'Gnome', + 8: 'Troll', + 10: 'Blood Elf', + 11: 'Draenei', }; const ClassDisplayName = { - 1: "Warrior", - 2: "Paladin", - 3: "Hunter", - 4: "Rogue", - 5: "Priest", - 6: "Death Knight", - 7: "Shaman", - 8: "Mage", - 9: "Warlock", - 11: "Druid", + 1: 'Warrior', + 2: 'Paladin', + 3: 'Hunter', + 4: 'Rogue', + 5: 'Priest', + 6: 'Death Knight', + 7: 'Shaman', + 8: 'Mage', + 9: 'Warlock', + 11: 'Druid', }; export class CharacterController { - private armory: Armory; - private itemInventoryTypes: { [key: number]: number }; - private itemIcons: { [key: number]: number }; - private gemItems: { [key: number]: boolean }; - private enchantSrcItems: { [key: number]: number }; - private itemSocketBonuses: { [key: number]: number }; - private mountSpells: number[]; - private mountBySpellId: { [key: number]: IMount }; - private achievementById: { [key: number]: IAchievement }; + private armory: Armory; + private itemInventoryTypes: { [key: number]: number }; + private itemIcons: { [key: number]: number }; + private gemItems: { [key: number]: boolean }; + private enchantSrcItems: { [key: number]: number }; + private itemSocketBonuses: { [key: number]: number }; + private mountSpells: number[]; + private mountBySpellId: { [key: number]: IMount }; + private achievementById: { [key: number]: IAchievement }; - public constructor(armory: Armory) { - this.armory = armory; - } + public constructor(armory: Armory) { + this.armory = armory; + } - public async load(): Promise { - this.itemInventoryTypes = {}; - const itemsRetail = await this.armory.dbc.itemRetail().toArray(); - for await (const item of this.armory.dbc.item()) { - const retailItem = itemsRetail.find(row => row.id === item.id); - if (retailItem !== undefined) { - this.itemInventoryTypes[item.id] = retailItem.inventoryType; - } - } + public async load(): Promise { + this.itemInventoryTypes = {}; + const itemsRetail = await this.armory.dbc.itemRetail().toArray(); + for await (const item of this.armory.dbc.item()) { + const retailItem = itemsRetail.find((row) => row.id === item.id); + if (retailItem !== undefined) { + this.itemInventoryTypes[item.id] = retailItem.inventoryType; + } + } - this.itemIcons = {}; - const itemIconsByDisplayInfoId: { [key: number]: number } = {}; - for await (const row of this.armory.dbc.itemDisplayInfo()) { - itemIconsByDisplayInfoId[row.id] = row.inventoryIcon0; - } - for await (const item of this.armory.dbc.item()) { - const icon = itemIconsByDisplayInfoId[item.displayInfoId]; - if (icon !== undefined) { - this.itemIcons[item.id] = icon; - } - } + this.itemIcons = {}; + const itemIconsByDisplayInfoId: { [key: number]: number } = {}; + for await (const row of this.armory.dbc.itemDisplayInfo()) { + itemIconsByDisplayInfoId[row.id] = row.inventoryIcon0; + } + for await (const item of this.armory.dbc.item()) { + const icon = itemIconsByDisplayInfoId[item.displayInfoId]; + if (icon !== undefined) { + this.itemIcons[item.id] = icon; + } + } - this.gemItems = {}; - for await (const row of this.armory.dbc.item().filter(item => item.classId === ItemClassGem)) { - this.gemItems[row.id] = true; - } + this.gemItems = {}; + for await (const row of this.armory.dbc.item().filter((item) => item.classId === ItemClassGem)) { + this.gemItems[row.id] = true; + } - this.enchantSrcItems = {}; - for await (const row of this.armory.dbc.spellItemEnchantment()) { - this.enchantSrcItems[row.id] = row.srcItemId; - } + this.enchantSrcItems = {}; + for await (const row of this.armory.dbc.spellItemEnchantment()) { + this.enchantSrcItems[row.id] = row.srcItemId; + } - this.itemSocketBonuses = {}; - let [rows, fields] = await this.armory.worldDb.query({ - sql: "SELECT entry, socketBonus FROM item_template WHERE socketBonus <> 0", - timeout: this.armory.config.dbQueryTimeout, - }); - for (const row of rows as RowDataPacket[]) { - this.itemSocketBonuses[row.entry] = row.socketBonus; - } + this.itemSocketBonuses = {}; + let [rows, fields] = await this.armory.worldDb.query({ + sql: 'SELECT entry, socketBonus FROM item_template WHERE socketBonus <> 0', + timeout: this.armory.config.dbQueryTimeout, + }); + for (const row of rows as RowDataPacket[]) { + this.itemSocketBonuses[row.entry] = row.socketBonus; + } - const mountSpells = await this.armory.dbc.spell() - .filter(m => m.mechanic === SpellMechanicMounted) - .toArray(); - this.mountSpells = mountSpells.map(spell => spell.id); - this.mountBySpellId = {}; - for (const spell of mountSpells) { - const mount = await this.armory.dbc.mount().find(m => m.sourceSpellId === spell.id); - const icon = await this.armory.dbc.spellIcon().find(icon => icon.id === spell.spellIconId); - if (mount !== undefined) { - const display = await this.armory.dbc.mountDisplay().find(d => d.mountId === mount.id); - if (display !== undefined) { - this.mountBySpellId[spell.id] = { - creatureDisplayId: display.creatureDisplayInfoId, - spell: spell.id, - icon: this.processSpellIconTexture(icon?.textureFilename ?? ""), - }; - } - } - } + const mountSpells = await this.armory.dbc + .spell() + .filter((m) => m.mechanic === SpellMechanicMounted) + .toArray(); + this.mountSpells = mountSpells.map((spell) => spell.id); + this.mountBySpellId = {}; + for (const spell of mountSpells) { + const mount = await this.armory.dbc.mount().find((m) => m.sourceSpellId === spell.id); + const icon = await this.armory.dbc.spellIcon().find((icon) => icon.id === spell.spellIconId); + if (mount !== undefined) { + const display = await this.armory.dbc.mountDisplay().find((d) => d.mountId === mount.id); + if (display !== undefined) { + this.mountBySpellId[spell.id] = { + creatureDisplayId: display.creatureDisplayInfoId, + spell: spell.id, + icon: this.processSpellIconTexture(icon?.textureFilename ?? ''), + }; + } + } + } - this.achievementById = {}; - for await (const achievement of this.armory.dbc.achievement()) { - this.achievementById[achievement.id] = achievement; - } - } + this.achievementById = {}; + for await (const achievement of this.armory.dbc.achievement()) { + this.achievementById[achievement.id] = achievement; + } + } - public async character(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.params.realm; - const charName = req.params.name; + public async character(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const charName = req.params.name; - const realm = this.armory.getRealm(realmName); - if (realm === undefined) { - // Could not find realm - return next(404); - } + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } - const charData = await this.getCharacterData(realm, charName); - if (charData === null) { - // Could not find character - return next(404); - } + const charData = await this.getCharacterData(realm, charName); + if (charData === null) { + // Could not find character + return next(404); + } - const equipmentData = await this.getEquipmentData(realmName, charData.guid); - const customization = this.getCustomizationOptions(charData); - const equipment = equipmentData.map(row => { - (row as any).icon = this.itemIcons[row.itemEntry]; - (row as any).gems = this.getGemsFromEnchantments(row.enchantments); - (row as any).enchantments = this.filterEnchantments(row.itemEntry, row.enchantments); - return row; - }); - const mounts = await this.getMounts(realmName, charData.guid); + const equipmentData = await this.getEquipmentData(realmName, charData.guid); + const customization = this.getCustomizationOptions(charData); + const equipment = equipmentData.map((row) => { + (row as any).icon = this.itemIcons[row.itemEntry]; + (row as any).gems = this.getGemsFromEnchantments(row.enchantments); + (row as any).enchantments = this.filterEnchantments(row.itemEntry, row.enchantments); + return row; + }); + const mounts = await this.getMounts(realmName, charData.guid); - res.render("character.hbs", { - title: `Armory - ${charData.name}`, - ...this.makeSharedDataObject(realm, charData), - data: { - race: charData.race, - gender: charData.gender, - class: charData.class, - flags: charData.playerFlags, - characterModelItems: await this.getModelViewerItems(equipmentData, charData.class), - customizationOptions: customization, - equipment, - mounts, - }, - }); + res.render('character.hbs', { + title: `Armory - ${charData.name}`, + ...this.makeSharedDataObject(realm, charData), + data: { + race: charData.race, + gender: charData.gender, + class: charData.class, + flags: charData.playerFlags, + characterModelItems: await this.getModelViewerItems(equipmentData, charData.class), + customizationOptions: customization, + equipment, + mounts, + }, + }); - this.armory.gc(); - } + this.armory.gc(); + } - public async talents(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.params.realm; - const charName = req.params.name; + public async talents(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const charName = req.params.name; - const realm = this.armory.getRealm(realmName); - if (realm === undefined) { - // Could not find realm - return next(404); - } + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } - const charData = await this.getCharacterData(realm, charName); - if (charData === null) { - // Could not find character - return next(404); - } + const charData = await this.getCharacterData(realm, charName); + if (charData === null) { + // Could not find character + return next(404); + } - res.render("character-talents.hbs", { - title: `Armory - ${charData.name} - Talents`, - ...this.makeSharedDataObject(realm, charData), - data: { - talents: await this.getTalents(realm.name, charData.guid), - trees: await this.getTalentTrees(charData.class), - glyphs: await this.getGlyphs(realm.name, charData.guid), - }, - }); - } + res.render('character-talents.hbs', { + title: `Armory - ${charData.name} - Talents`, + ...this.makeSharedDataObject(realm, charData), + data: { + talents: await this.getTalents(realm.name, charData.guid), + trees: await this.getTalentTrees(charData.class), + glyphs: await this.getGlyphs(realm.name, charData.guid), + }, + }); + } - public async achievements(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.params.realm; - const charName = req.params.name; + public async achievements(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const charName = req.params.name; - const realm = this.armory.getRealm(realmName); - if (realm === undefined) { - // Could not find realm - return next(404); - } + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } - const charData = await this.getCharacterData(realm, charName); - if (charData === null) { - // Could not find character - return next(404); - } + const charData = await this.getCharacterData(realm, charName); + if (charData === null) { + // Could not find character + return next(404); + } - res.render("character-achievements.hbs", { - title: `Armory - ${charData.name} - Achievements`, - ...this.makeSharedDataObject(realm, charData), - }); - } + res.render('character-achievements.hbs', { + title: `Armory - ${charData.name} - Achievements`, + ...this.makeSharedDataObject(realm, charData), + }); + } - public async achievementsData(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.params.realm; - const character = parseInt(req.params.character) || -1; + public async achievementsData(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const character = parseInt(req.params.character) || -1; - const realm = this.armory.getRealm(realmName); - if (realm === undefined) { - // Could not find realm - return next(404); - } + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } - const charData = await this.getCharacterData(realm, character); - if (charData === null) { - // Could not find character - return next(404); - } + const charData = await this.getCharacterData(realm, character); + if (charData === null) { + // Could not find character + return next(404); + } - res.json({ - categories: await this.armory.dbc.achievementCategory().toArray(), - ...await this.getAchievements(realm.name, charData), - }); - } + res.json({ + categories: await this.armory.dbc.achievementCategory().toArray(), + ...(await this.getAchievements(realm.name, charData)), + }); + } - public async pvp(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.params.realm; - const charName = req.params.name; + public async pvp(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const charName = req.params.name; - const realm = this.armory.getRealm(realmName); - if (realm === undefined) { - // Could not find realm - return next(404); - } + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } - const charData = await this.getCharacterData(realm, charName); - if (charData === null) { - // Could not find character - return next(404); - } + const charData = await this.getCharacterData(realm, charName); + if (charData === null) { + // Could not find character + return next(404); + } - res.render("character-pvp.hbs", { - title: `Armory - ${charData.name} - PvP`, - ...this.makeSharedDataObject(realm, charData), - faction: Utils.getFactionFromRaceId(charData.race), - kills: await this.getPvpKills(realm.name, charData.guid), - arenaTeams: await this.getArenaTeams(realm.name, charData.guid), - }); - } + res.render('character-pvp.hbs', { + title: `Armory - ${charData.name} - PvP`, + ...this.makeSharedDataObject(realm, charData), + faction: Utils.getFactionFromRaceId(charData.race), + kills: await this.getPvpKills(realm.name, charData.guid), + arenaTeams: await this.getArenaTeams(realm.name, charData.guid), + }); + } - private makeSharedDataObject(realm: IRealmConfig, charData: ICharacterData) { - return { - realm: realm.name, - name: charData.name, - guid: charData.guid, - race: RaceDisplayName[charData.race], - class: ClassDisplayName[charData.class], - level: charData.level, - online: charData.online === 1, - guild: charData.guild, - }; - } + private makeSharedDataObject(realm: IRealmConfig, charData: ICharacterData) { + return { + realm: realm.name, + name: charData.name, + guid: charData.guid, + race: RaceDisplayName[charData.race], + class: ClassDisplayName[charData.class], + level: charData.level, + online: charData.online === 1, + guild: charData.guild, + }; + } - private async getCharacterData(realm: IRealmConfig, character: string | number): Promise { - const where = typeof character === "string" ? "LOWER(`characters`.`name`) = LOWER(?)" : "`characters`.`guid` = ?"; - const [rows, fields] = await this.armory.getCharactersDb(realm.name).query({ - sql: ` + private async getCharacterData(realm: IRealmConfig, character: string | number): Promise { + const where = typeof character === 'string' ? 'LOWER(`characters`.`name`) = LOWER(?)' : '`characters`.`guid` = ?'; + const [rows, fields] = await this.armory.getCharactersDb(realm.name).query({ + sql: ` SELECT \`characters\`.\`guid\`, \`characters\`.\`name\`, \`race\`, \`class\`, \`gender\`, \`level\`, \`skin\`, \`face\`, \`hairStyle\`, \`hairColor\`, \`facialStyle\`, \`playerFlags\`, \`online\`, \`guild\`.\`name\` AS \`guild\` FROM \`characters\` LEFT JOIN \`guild_member\` ON \`guild_member\`.\`guid\` = \`characters\`.\`guid\` @@ -319,516 +320,698 @@ export class CharacterController { ${where} AND (\`account_access\`.\`id\` IS NULL OR \`account_access\`.\`RealmID\` NOT IN (-1, ${realm.realmId}) OR \`account_access\`.\`gmlevel\` = 0 OR ? = 0) `, - values: [character, this.armory.config.hideGameMasters ? 1 : 0], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [character, this.armory.config.hideGameMasters ? 1 : 0], + timeout: this.armory.config.dbQueryTimeout, + }); - if ((rows as RowDataPacket[]).length === 0) { - return null; - } - return rows[0]; - } + if ((rows as RowDataPacket[]).length === 0) { + return null; + } + return rows[0]; + } - private async getEquipmentData(realm: string, charGuid: number): Promise { - const [rows, fields] = await this.armory.getCharactersDb(realm).query({ - sql: ` + private async getEquipmentData(realm: string, charGuid: number): Promise { + const [rows, fields] = await this.armory.getCharactersDb(realm).query({ + sql: ` SELECT character_inventory.slot, item_instance.itemEntry, item_instance.flags, item_instance.enchantments, item_instance.randomPropertyId FROM character_inventory JOIN item_instance ON item_instance.guid = character_inventory.item WHERE character_inventory.guid = ? AND character_inventory.bag = 0 AND character_inventory.slot IN (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18) `, - values: [charGuid], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [charGuid], + timeout: this.armory.config.dbQueryTimeout, + }); - const data = rows as RowDataPacket[] as IEquipmentData[]; + const data = rows as RowDataPacket[] as IEquipmentData[]; - for (const row of data) { - const item = await this.armory.dbc.item().find(item => item.id === row.itemEntry); - row.classId = item.classId; - row.subclassId = item.subclassId; - } + for (const row of data) { + const item = await this.armory.dbc.item().find((item) => item.id === row.itemEntry); + row.classId = item.classId; + row.subclassId = item.subclassId; + } - return data; - } + return data; + } - private async getMounts(realm: string, charGuid: number): Promise { - const [rows, fields] = await this.armory.getCharactersDb(realm).query({ - sql: ` + private async getMounts(realm: string, charGuid: number): Promise { + const [rows, fields] = await this.armory.getCharactersDb(realm).query({ + sql: ` SELECT spell FROM character_spell WHERE guid = ? AND spell IN (?) `, - values: [charGuid, this.mountSpells], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [charGuid, this.mountSpells], + timeout: this.armory.config.dbQueryTimeout, + }); - return (rows as RowDataPacket[]) - .map(row => this.mountBySpellId[row.spell]) - .filter(m => m !== undefined); - } + return (rows as RowDataPacket[]).map((row) => this.mountBySpellId[row.spell]).filter((m) => m !== undefined); + } - private async getModelViewerItems(equipmentData: IEquipmentData[], charClass: number): Promise { - if (charClass !== 3) { - // Keep ranged weapon only if the character is a hunter - equipmentData = equipmentData.filter(row => row.slot !== 17); - } - const visibleEquipment = equipmentData. - filter(item => - [0, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15, 16, 17, 18].includes(item.slot) && // visible slots - item.itemEntry !== 5976 // filter out Guild Tabard (displays blank otherwise) - ); + private async getModelViewerItems(equipmentData: IEquipmentData[], charClass: number): Promise { + if (charClass !== 3) { + // Keep ranged weapon only if the character is a hunter + equipmentData = equipmentData.filter((row) => row.slot !== 17); + } + const visibleEquipment = equipmentData.filter( + (item) => + [0, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15, 16, 17, 18].includes(item.slot) && // visible slots + item.itemEntry !== 5976, // filter out Guild Tabard (displays blank otherwise) + ); - const items: number[][] = []; - for (const equipment of visibleEquipment) { - const modifiedAppearance = await this.armory.dbc.itemModifiedAppearance().find(row => row.itemId === equipment.itemEntry); - if (modifiedAppearance === undefined) { - continue; - } - const appearance = await this.armory.dbc.itemAppearance().find(row => row.id === modifiedAppearance.itemAppearanceId); - if (appearance === undefined) { - continue; - } + const items: number[][] = []; + for (const equipment of visibleEquipment) { + const modifiedAppearance = await this.armory.dbc.itemModifiedAppearance().find((row) => row.itemId === equipment.itemEntry); + if (modifiedAppearance === undefined) { + continue; + } + const appearance = await this.armory.dbc.itemAppearance().find((row) => row.id === modifiedAppearance.itemAppearanceId); + if (appearance === undefined) { + continue; + } - items.push([this.itemInventoryTypes[equipment.itemEntry], appearance.itemDisplayInfoId]); - } + items.push([this.itemInventoryTypes[equipment.itemEntry], appearance.itemDisplayInfoId]); + } - return items; - } + return items; + } - private parseEnchantmentsString(enchantments: string): number[] { - return enchantments - .trim() - .split(" ") - .map(enchant => parseInt(enchant)) - .filter(enchant => enchant !== 0); - } + private parseEnchantmentsString(enchantments: string): number[] { + return enchantments + .trim() + .split(' ') + .map((enchant) => parseInt(enchant)) + .filter((enchant) => enchant !== 0); + } - private getGemsFromEnchantments(enchantments: string): number[] { - return this.parseEnchantmentsString(enchantments) - .filter(enchant => enchant in this.enchantSrcItems && this.enchantSrcItems[enchant] in this.gemItems) - .map(enchant => this.enchantSrcItems[enchant]); - } + private getGemsFromEnchantments(enchantments: string): number[] { + return this.parseEnchantmentsString(enchantments) + .filter((enchant) => enchant in this.enchantSrcItems && this.enchantSrcItems[enchant] in this.gemItems) + .map((enchant) => this.enchantSrcItems[enchant]); + } - private filterEnchantments(item: number, enchantments: string): number[] { - const socketBonus = this.itemSocketBonuses[item]; - return this.parseEnchantmentsString(enchantments) - .filter(enchant => enchant in this.enchantSrcItems && !(this.enchantSrcItems[enchant] in this.gemItems) && enchant !== socketBonus); - } + private filterEnchantments(item: number, enchantments: string): number[] { + const socketBonus = this.itemSocketBonuses[item]; + return this.parseEnchantmentsString(enchantments).filter( + (enchant) => enchant in this.enchantSrcItems && !(this.enchantSrcItems[enchant] in this.gemItems) && enchant !== socketBonus, + ); + } - private getCustomizationOptions(charData: ICharacterData): ICustomizationOption[] { - const data = this.armory.characterCustomization.getCharacterCustomizationData(charData.race, charData.gender); - const options = []; - const setOptionByChoiceIndex = (optionName: string, choiceIndex: number) => { - const option = data.Options.find(opt => opt.Name === optionName); - if (option !== undefined) { - const choice = option.Choices.find(choice => choice.OrderIndex === choiceIndex); - if (choice !== undefined) { - options.push({ optionId: option.Id, choiceId: choice.Id }); - } - } - }; - const setOptionByChoiceName = (optionName: string, choiceName: string) => { - const option = data.Options.find(opt => opt.Name === optionName); - if (option !== undefined) { - const choice = option.Choices.find(ch => ch.Name === choiceName); - if (choice !== undefined) { - options.push({ optionId: option.Id, choiceId: choice.Id }); - } - } - }; - const setOptionByChoiceId = (optionName: string, choiceId: number) => { - const option = data.Options.find(opt => opt.Name === optionName); - if (option !== undefined) { - options.push({ optionId: option.Id, choiceId: choiceId }); - } - }; + private getCustomizationOptions(charData: ICharacterData): ICustomizationOption[] { + const data = this.armory.characterCustomization.getCharacterCustomizationData(charData.race, charData.gender); + const options = []; + const setOptionByChoiceIndex = (optionName: string, choiceIndex: number) => { + const option = data.Options.find((opt) => opt.Name === optionName); + if (option !== undefined) { + const choice = option.Choices.find((choice) => choice.OrderIndex === choiceIndex); + if (choice !== undefined) { + options.push({ optionId: option.Id, choiceId: choice.Id }); + } + } + }; + const setOptionByChoiceName = (optionName: string, choiceName: string) => { + const option = data.Options.find((opt) => opt.Name === optionName); + if (option !== undefined) { + const choice = option.Choices.find((ch) => ch.Name === choiceName); + if (choice !== undefined) { + options.push({ optionId: option.Id, choiceId: choice.Id }); + } + } + }; + const setOptionByChoiceId = (optionName: string, choiceId: number) => { + const option = data.Options.find((opt) => opt.Name === optionName); + if (option !== undefined) { + options.push({ optionId: option.Id, choiceId: choiceId }); + } + }; - const optionMapping = { - "Face": charData.face, - "Skin Color": charData.skin, - "Hair Style": charData.hairStyle, - "Hair Color": charData.hairColor, - }; - for (const optionName in optionMapping) { - setOptionByChoiceIndex(optionName, optionMapping[optionName]); - } + const optionMapping = { + Face: charData.face, + 'Skin Color': charData.skin, + 'Hair Style': charData.hairStyle, + 'Hair Color': charData.hairColor, + }; + for (const optionName in optionMapping) { + setOptionByChoiceIndex(optionName, optionMapping[optionName]); + } - // Race-specific customization options - switch (charData.race) { - case 1: // Human - if (charData.gender === 0) { - setOptionByChoiceName("Mustache", { 0: "Horseshoe", 1: "Brush", 2: "Horseshoe", 3: "None", 4: "Brush", 5: "Brush", 6: "Horseshoe", 7: "Brush", 8: "None" }[charData.facialStyle]); - setOptionByChoiceName("Beard", { 0: "Short", 1: "Chin Puff", 2: "Soul Patch", 3: "Goatee", 4: "Goatee", 5: "None", 6: "Goatee", 7: "None", 8: "None" }[charData.facialStyle]); - setOptionByChoiceName("Sideburns", { 0: "Medium", 1: "None", 2: "None", 3: "Medium", 4: "Long", 5: "Long", 6: "None", 8: "None", 7: "None" }[charData.facialStyle]); - setOptionByChoiceName("Eyebrows", "Natural"); - setOptionByChoiceName("Face Shape", "Narrow"); - setOptionByChoiceId("Eye Color", { 0: 4138, 1: 4140, 2: 4130, 3: 4136, 4: 4141, 5: 4134, 6: 4130, 7: 4138, 8: 4144, 9: 4135, 10: 4126, 11: 4136 }[charData.face]); - } else { - setOptionByChoiceIndex("Piercings", charData.facialStyle); - setOptionByChoiceName("Eyebrows", "Natural"); - setOptionByChoiceName("Face Shape", "Narrow"); - setOptionByChoiceName("Makeup", "None"); - setOptionByChoiceName("Necklace", "None"); - setOptionByChoiceId("Eye Color", { 0: 4162, 1: 4153, 2: 4161, 3: 4164, 4: 4154, 5: 4160, 6: 4160, 7: 4157, 8: 4152, 9: 4154, 10: 4155, 11: 4165, 12: 4163, 13: 4155, 14: 4151 }[charData.face]); - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 4534 : 4535); - } - break; - case 3: // Dwarf - setOptionByChoiceName("Tattoo", "None"); - setOptionByChoiceIndex("Tattoo Color", 0); - setOptionByChoiceIndex("Eyebrows", 0); - if (charData.gender === 0) { - setOptionByChoiceName("Mustache", { 0: "Trimmed", 1: "Bushy", 2: "Grand", 3: "Thin Braids", 4: "Wise", 5: "Thick Braids", 6: "Fancy", 7: "Bold", 8: "Tied", 9: "None", 10: "None", }[charData.facialStyle]); - setOptionByChoiceIndex("Beard", charData.facialStyle); - setOptionByChoiceName("Earrings", "None"); - setOptionByChoiceName("Nose Ring", "None"); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } else { - setOptionByChoiceIndex("Earrings", { 0: 0, 1: 1, 2: 2, 3: 3, 4: 0, 5: 4 }[charData.facialStyle]); - setOptionByChoiceName("Piercings", { 0: "None", 1: "None", 2: "None", 3: "None", 4: "Right Nostril", 5: "None" }[charData.facialStyle]); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 5559 : 5587); - } - break; - case 7: // Gnome - if (charData.gender === 0) { - setOptionByChoiceIndex("Mustache", charData.facialStyle > 1 ? charData.facialStyle - 1 : 0); - setOptionByChoiceIndex("Beard", charData.facialStyle < 7 ? charData.facialStyle : 0); - setOptionByChoiceIndex("Eyebrows", charData.facialStyle < 6 ? charData.facialStyle : 1); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } else { - setOptionByChoiceIndex("Earrings", charData.facialStyle); - setOptionByChoiceId("Earring Color", 8796); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 5629 : 5643); - } - break; - case 4: // Night Elf - setOptionByChoiceName("Vines", "None"); - setOptionByChoiceIndex("Vine Color", 0); - setOptionByChoiceName("Ears", "Thin"); - setOptionByChoiceName("Scars", "None"); - if (charData.gender === 0) { - setOptionByChoiceName("Sideburns", { 0: "None", 1: "Groomed", 2: "None", 3: "Short", 4: "Medium", 5: "Groomed" }[charData.facialStyle]); - setOptionByChoiceName("Mustache", { 0: "None", 1: "Groomed", 2: "None", 3: "Thin", 4: "None", 5: "None" }[charData.facialStyle]); - setOptionByChoiceName("Beard", { 0: "None", 1: "Trimmed", 2: "Full", 3: "None", 4: "Short", 5: "Long" }[charData.facialStyle]); - setOptionByChoiceName("Eyebrows", { 0: "Shaved", 1: "Short", 2: "Long", 3: "Flat", 4: "Short", 5: "Owl" }[charData.facialStyle]); - } else { - setOptionByChoiceName("Eyebrows", "Long"); - setOptionByChoiceIndex("Markings", charData.facialStyle + 1); - setOptionByChoiceIndex("Markings Color", { 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 3, 6: 6, 7: 7 }[charData.hairColor]); - } - setOptionByChoiceName("Blindfold", ""); - setOptionByChoiceName("Headdress", "None"); - setOptionByChoiceName("Earrings", "None"); - setOptionByChoiceName("Nose Ring", "None"); - setOptionByChoiceName("Necklace", "None"); - setOptionByChoiceName("Horns", "None"); - setOptionByChoiceName("Tattoo", "None"); - setOptionByChoiceName("Tattoo Color", "None"); - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 7618 : 7634); - } else { - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 7610 : 7619); - } - break; - case 11: // Draenei - setOptionByChoiceName("Circlet", "None"); - setOptionByChoiceId("Jewelry Color", charData.gender === 0 ? 8707 : 8646); - setOptionByChoiceName("Horn Decoration", "None"); - setOptionByChoiceName("Tail", charData.gender === 0 ? "Long" : "Short"); - if (charData.gender === 0) { - setOptionByChoiceName("Facial Hair", { 0: "Bare", 1: "Bare", 2: "Burns", 3: "Chops", 4: "Mustache", 5: "Soul Patch", 6: "Handlebar", 7: "Bare" }[charData.facialStyle]); - setOptionByChoiceName("Tendrils", { 0: "None", 1: "Splayed", 2: "Double", 3: "Fanned", 4: "Single", 5: "Paired", 6: "Uniform", 7: "Twin" }[charData.facialStyle]); - } else { - setOptionByChoiceName("Horns", { 0: "Sweeping", 1: "Curled", 2: "Curved", 3: "Thick", 4: "Wide", 5: "Grand", 6: "Short" }[charData.facialStyle]); - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 6977 : 6979); - } else { - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 6976 : 6978); - } - break; - case 2: // Orc - setOptionByChoiceName("Scars", "None"); - setOptionByChoiceName("Grime", "None"); - setOptionByChoiceName("Tattoo", "None"); - setOptionByChoiceName("War Paint", "None"); - setOptionByChoiceName("War Paint Color", "None"); - if (charData.gender === 0) { - setOptionByChoiceName("Beard", { 0: "None", 1: "Stubble", 2: "Thick", 3: "Full", 4: "Tied", 5: "Braid", 6: "Twin Braids", 7: "None", 8: "Ringed", 9: "Split", 10: "Goatee" }[charData.facialStyle]); - setOptionByChoiceName("Sideburns", { 0: "None", 1: "None", 2: "Full", 3: "Low", 4: "Full", 5: "None", 6: "None", 7: "Braids", 8: "None", 9: "Full", 10: "Thick" }[charData.facialStyle]); - setOptionByChoiceName("Earrings", "None"); - setOptionByChoiceName("Nose Ring", "None"); - setOptionByChoiceName("Tusks", "Natural"); - setOptionByChoiceName("Upright", "Hunched"); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } else { - setOptionByChoiceIndex("Earrings", { 0: 0, 1: 1, 2: 2, 3: 0, 4: 1, 5: 2, 6: 4 }[charData.facialStyle]); - setOptionByChoiceIndex("Nose Ring", { 0: 0, 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 0 }[charData.facialStyle]); - setOptionByChoiceName("Necklace", "None"); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 9289 : 9313); - } - break; - case 5: // Undead - setOptionByChoiceName("Skin Type", "Bony"); - if (charData.gender === 0) { - setOptionByChoiceName("Jaw Features", { 0: "Intact", 1: "Rot-Kissed", 2: "Intact", 3: "Slackjawed", 4: "Drooler", 5: "Intact", 6: "Slackjawed", 7: "Drooler", 8: "Bonejawed", 9: "Jawsome", 10: "Toothy", 11: "Unhinged", 12: "Cheeky", 13: "Loose", 14: "Intact", 15: "Slackjawed", 16: "Slobber" }[charData.facialStyle]); - setOptionByChoiceIndex("Face Features", { 0: 0, 1: 0, 2: 1, 3: 1, 4: 1, 5: 2, 6: 3, 7: 3, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 4, 15: 4, 16: 0 }[charData.facialStyle]); - setOptionByChoiceId("Eye Color", { 0: 5330, 1: 5330, 2: 6304, 3: 6304, 4: 6304, 5: 5330, 6: 5330, 7: 5330, 8: 5330, 9: 5330, 10: 6304, 11: 6304, 12: 5330, 13: 5330, 14: 5330, 15: 5330, 16: 5330 }[charData.facialStyle]); - } else { - setOptionByChoiceName("Face Features", { 0: "None", 1: "None", 2: "Strapped", 3: "Rotting", 4: "None", 5: "None", 6: "None", 7: "Putrid" }[charData.facialStyle]); - setOptionByChoiceName("Jaw Features", { 0: "Intact", 1: "Stitched", 2: "Intact", 3: "Intact", 4: "Bonejawed", 5: "Toothy", 6: "Cheeky", 7: "Intact" }[charData.facialStyle]); - setOptionByChoiceId("Eye Color", { 0: 5337, 1: 5337, 2: 6305, 3: 5337, 4: 5337, 5: 6305, 6: 5337, 7: 5337 }[charData.facialStyle]); - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 5344 : 5345); - } - break; - case 6: // Tauren - setOptionByChoiceIndex("Horn Style", charData.hairStyle); - setOptionByChoiceIndex("Horn Color", charData.hairColor); - setOptionByChoiceName("Foremane", "Short"); - setOptionByChoiceName("Face Paint", "None"); - setOptionByChoiceName("Headdress", "None"); - setOptionByChoiceName("Necklace", "None"); - setOptionByChoiceIndex("Jewelry Color", 0); - setOptionByChoiceName("Flower", "None"); - setOptionByChoiceName("Body Paint", "None"); - setOptionByChoiceIndex("Paint Color", 0); - if (charData.gender === 0) { - setOptionByChoiceName("Hair", { 0: "Mane", 1: "Braids", 2: "Chops", 3: "Sideburns", 4: "Mane", 5: "Wrapped", 6: "Braids" }[charData.facialStyle]); - setOptionByChoiceName("Facial Hair", { 0: "Clean", 1: "Braid", 2: "Beard", 3: "Wrapped", 4: "Curtain", 5: "Clean", 6: "Split" }[charData.facialStyle]); - setOptionByChoiceName("Nose Ring", { 0: "None", 1: "Small", 2: "Open", 3: "None", 4: "None", 5: "Bead", 6: "Open" }[charData.facialStyle]); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } else { - setOptionByChoiceIndex("Hair", charData.facialStyle); - setOptionByChoiceName("Earrings", "None"); - setOptionByChoiceName("Nose Ring", "None"); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 7281 : 7289); - } - break; - case 8: // Troll - setOptionByChoiceName("Body Paint", "None"); - setOptionByChoiceName("Body Paint Color", "None"); - setOptionByChoiceName("Piercing", "None"); - if (charData.gender === 0) { - setOptionByChoiceName("Tusks", { 0: "Tusked", 1: "Gougers", 2: "Mammoth", 3: "Spears", 4: "Bridle", 5: "Tusked", 6: "Gougers", 7: "Mammoth", 8: "Spears", 9: "Bridle", 10: "Gougers" }[charData.facialStyle]); - setOptionByChoiceName("Face Paint", { 0: "None", 1: "None", 2: "None", 3: "None", 4: "None", 5: "Berserker", 6: "Fangs", 7: "Mask", 8: "Oni", 9: "Prophet", 10: "War" }[charData.facialStyle]); - setOptionByChoiceIndex("Face Paint Color", charData.hairColor + 1); - setOptionByChoiceName("Earrings", "None"); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } else { - setOptionByChoiceIndex("Tusks", charData.facialStyle); - setOptionByChoiceName("Face Paint", "None"); - setOptionByChoiceIndex("Face Paint Color", 0); - setOptionByChoiceName("Earrings", "Hoops"); - setOptionByChoiceIndex("Eye Color", 0); // TODO - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 8451 : 8468); - } - break; - case 10: // Blood Elf - setOptionByChoiceName("Ears", "Long"); - setOptionByChoiceName("Horns", "None"); - setOptionByChoiceName("Blindfold", "None"); - setOptionByChoiceName("Tattoo", "None"); - setOptionByChoiceIndex("Tattoo Color", 0); - if (charData.gender === 0) { - setOptionByChoiceIndex("Facial Hair", charData.facialStyle); - } else { - setOptionByChoiceIndex("Earrings", charData.facialStyle); - setOptionByChoiceIndex("Jewelry Color", 0); - setOptionByChoiceName("Necklace", "None"); - setOptionByChoiceName("Armbands", "None"); - setOptionByChoiceName("Bracelets", "None"); - } - if (charData.class === 6) { - // Death Knight - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 6586 : 6605); - } else { - setOptionByChoiceId("Eye Color", charData.gender === 0 ? 6570 : 6589); - } - break; - } - if ([4, 6].includes(charData.race)) { - // Races that can choose the druid class - setOptionByChoiceIndex("Bear Form", 0); - setOptionByChoiceIndex("Cat Form", 0); - setOptionByChoiceIndex("Aquatic Form", 0); - setOptionByChoiceIndex("Travel Form", 0); - setOptionByChoiceIndex("Flight Form", 0); - setOptionByChoiceIndex("Moonkin Form", 0); - } + // Race-specific customization options + switch (charData.race) { + case 1: // Human + if (charData.gender === 0) { + setOptionByChoiceName( + 'Mustache', + { 0: 'Horseshoe', 1: 'Brush', 2: 'Horseshoe', 3: 'None', 4: 'Brush', 5: 'Brush', 6: 'Horseshoe', 7: 'Brush', 8: 'None' }[ + charData.facialStyle + ], + ); + setOptionByChoiceName( + 'Beard', + { 0: 'Short', 1: 'Chin Puff', 2: 'Soul Patch', 3: 'Goatee', 4: 'Goatee', 5: 'None', 6: 'Goatee', 7: 'None', 8: 'None' }[ + charData.facialStyle + ], + ); + setOptionByChoiceName( + 'Sideburns', + { 0: 'Medium', 1: 'None', 2: 'None', 3: 'Medium', 4: 'Long', 5: 'Long', 6: 'None', 8: 'None', 7: 'None' }[charData.facialStyle], + ); + setOptionByChoiceName('Eyebrows', 'Natural'); + setOptionByChoiceName('Face Shape', 'Narrow'); + setOptionByChoiceId( + 'Eye Color', + { 0: 4138, 1: 4140, 2: 4130, 3: 4136, 4: 4141, 5: 4134, 6: 4130, 7: 4138, 8: 4144, 9: 4135, 10: 4126, 11: 4136 }[charData.face], + ); + } else { + setOptionByChoiceIndex('Piercings', charData.facialStyle); + setOptionByChoiceName('Eyebrows', 'Natural'); + setOptionByChoiceName('Face Shape', 'Narrow'); + setOptionByChoiceName('Makeup', 'None'); + setOptionByChoiceName('Necklace', 'None'); + setOptionByChoiceId( + 'Eye Color', + { + 0: 4162, + 1: 4153, + 2: 4161, + 3: 4164, + 4: 4154, + 5: 4160, + 6: 4160, + 7: 4157, + 8: 4152, + 9: 4154, + 10: 4155, + 11: 4165, + 12: 4163, + 13: 4155, + 14: 4151, + }[charData.face], + ); + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 4534 : 4535); + } + break; + case 3: // Dwarf + setOptionByChoiceName('Tattoo', 'None'); + setOptionByChoiceIndex('Tattoo Color', 0); + setOptionByChoiceIndex('Eyebrows', 0); + if (charData.gender === 0) { + setOptionByChoiceName( + 'Mustache', + { + 0: 'Trimmed', + 1: 'Bushy', + 2: 'Grand', + 3: 'Thin Braids', + 4: 'Wise', + 5: 'Thick Braids', + 6: 'Fancy', + 7: 'Bold', + 8: 'Tied', + 9: 'None', + 10: 'None', + }[charData.facialStyle], + ); + setOptionByChoiceIndex('Beard', charData.facialStyle); + setOptionByChoiceName('Earrings', 'None'); + setOptionByChoiceName('Nose Ring', 'None'); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } else { + setOptionByChoiceIndex('Earrings', { 0: 0, 1: 1, 2: 2, 3: 3, 4: 0, 5: 4 }[charData.facialStyle]); + setOptionByChoiceName( + 'Piercings', + { 0: 'None', 1: 'None', 2: 'None', 3: 'None', 4: 'Right Nostril', 5: 'None' }[charData.facialStyle], + ); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 5559 : 5587); + } + break; + case 7: // Gnome + if (charData.gender === 0) { + setOptionByChoiceIndex('Mustache', charData.facialStyle > 1 ? charData.facialStyle - 1 : 0); + setOptionByChoiceIndex('Beard', charData.facialStyle < 7 ? charData.facialStyle : 0); + setOptionByChoiceIndex('Eyebrows', charData.facialStyle < 6 ? charData.facialStyle : 1); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } else { + setOptionByChoiceIndex('Earrings', charData.facialStyle); + setOptionByChoiceId('Earring Color', 8796); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 5629 : 5643); + } + break; + case 4: // Night Elf + setOptionByChoiceName('Vines', 'None'); + setOptionByChoiceIndex('Vine Color', 0); + setOptionByChoiceName('Ears', 'Thin'); + setOptionByChoiceName('Scars', 'None'); + if (charData.gender === 0) { + setOptionByChoiceName( + 'Sideburns', + { 0: 'None', 1: 'Groomed', 2: 'None', 3: 'Short', 4: 'Medium', 5: 'Groomed' }[charData.facialStyle], + ); + setOptionByChoiceName('Mustache', { 0: 'None', 1: 'Groomed', 2: 'None', 3: 'Thin', 4: 'None', 5: 'None' }[charData.facialStyle]); + setOptionByChoiceName('Beard', { 0: 'None', 1: 'Trimmed', 2: 'Full', 3: 'None', 4: 'Short', 5: 'Long' }[charData.facialStyle]); + setOptionByChoiceName('Eyebrows', { 0: 'Shaved', 1: 'Short', 2: 'Long', 3: 'Flat', 4: 'Short', 5: 'Owl' }[charData.facialStyle]); + } else { + setOptionByChoiceName('Eyebrows', 'Long'); + setOptionByChoiceIndex('Markings', charData.facialStyle + 1); + setOptionByChoiceIndex('Markings Color', { 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 3, 6: 6, 7: 7 }[charData.hairColor]); + } + setOptionByChoiceName('Blindfold', ''); + setOptionByChoiceName('Headdress', 'None'); + setOptionByChoiceName('Earrings', 'None'); + setOptionByChoiceName('Nose Ring', 'None'); + setOptionByChoiceName('Necklace', 'None'); + setOptionByChoiceName('Horns', 'None'); + setOptionByChoiceName('Tattoo', 'None'); + setOptionByChoiceName('Tattoo Color', 'None'); + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 7618 : 7634); + } else { + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 7610 : 7619); + } + break; + case 11: // Draenei + setOptionByChoiceName('Circlet', 'None'); + setOptionByChoiceId('Jewelry Color', charData.gender === 0 ? 8707 : 8646); + setOptionByChoiceName('Horn Decoration', 'None'); + setOptionByChoiceName('Tail', charData.gender === 0 ? 'Long' : 'Short'); + if (charData.gender === 0) { + setOptionByChoiceName( + 'Facial Hair', + { 0: 'Bare', 1: 'Bare', 2: 'Burns', 3: 'Chops', 4: 'Mustache', 5: 'Soul Patch', 6: 'Handlebar', 7: 'Bare' }[ + charData.facialStyle + ], + ); + setOptionByChoiceName( + 'Tendrils', + { 0: 'None', 1: 'Splayed', 2: 'Double', 3: 'Fanned', 4: 'Single', 5: 'Paired', 6: 'Uniform', 7: 'Twin' }[charData.facialStyle], + ); + } else { + setOptionByChoiceName( + 'Horns', + { 0: 'Sweeping', 1: 'Curled', 2: 'Curved', 3: 'Thick', 4: 'Wide', 5: 'Grand', 6: 'Short' }[charData.facialStyle], + ); + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 6977 : 6979); + } else { + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 6976 : 6978); + } + break; + case 2: // Orc + setOptionByChoiceName('Scars', 'None'); + setOptionByChoiceName('Grime', 'None'); + setOptionByChoiceName('Tattoo', 'None'); + setOptionByChoiceName('War Paint', 'None'); + setOptionByChoiceName('War Paint Color', 'None'); + if (charData.gender === 0) { + setOptionByChoiceName( + 'Beard', + { + 0: 'None', + 1: 'Stubble', + 2: 'Thick', + 3: 'Full', + 4: 'Tied', + 5: 'Braid', + 6: 'Twin Braids', + 7: 'None', + 8: 'Ringed', + 9: 'Split', + 10: 'Goatee', + }[charData.facialStyle], + ); + setOptionByChoiceName( + 'Sideburns', + { 0: 'None', 1: 'None', 2: 'Full', 3: 'Low', 4: 'Full', 5: 'None', 6: 'None', 7: 'Braids', 8: 'None', 9: 'Full', 10: 'Thick' }[ + charData.facialStyle + ], + ); + setOptionByChoiceName('Earrings', 'None'); + setOptionByChoiceName('Nose Ring', 'None'); + setOptionByChoiceName('Tusks', 'Natural'); + setOptionByChoiceName('Upright', 'Hunched'); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } else { + setOptionByChoiceIndex('Earrings', { 0: 0, 1: 1, 2: 2, 3: 0, 4: 1, 5: 2, 6: 4 }[charData.facialStyle]); + setOptionByChoiceIndex('Nose Ring', { 0: 0, 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 0 }[charData.facialStyle]); + setOptionByChoiceName('Necklace', 'None'); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 9289 : 9313); + } + break; + case 5: // Undead + setOptionByChoiceName('Skin Type', 'Bony'); + if (charData.gender === 0) { + setOptionByChoiceName( + 'Jaw Features', + { + 0: 'Intact', + 1: 'Rot-Kissed', + 2: 'Intact', + 3: 'Slackjawed', + 4: 'Drooler', + 5: 'Intact', + 6: 'Slackjawed', + 7: 'Drooler', + 8: 'Bonejawed', + 9: 'Jawsome', + 10: 'Toothy', + 11: 'Unhinged', + 12: 'Cheeky', + 13: 'Loose', + 14: 'Intact', + 15: 'Slackjawed', + 16: 'Slobber', + }[charData.facialStyle], + ); + setOptionByChoiceIndex( + 'Face Features', + { 0: 0, 1: 0, 2: 1, 3: 1, 4: 1, 5: 2, 6: 3, 7: 3, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 4, 15: 4, 16: 0 }[ + charData.facialStyle + ], + ); + setOptionByChoiceId( + 'Eye Color', + { + 0: 5330, + 1: 5330, + 2: 6304, + 3: 6304, + 4: 6304, + 5: 5330, + 6: 5330, + 7: 5330, + 8: 5330, + 9: 5330, + 10: 6304, + 11: 6304, + 12: 5330, + 13: 5330, + 14: 5330, + 15: 5330, + 16: 5330, + }[charData.facialStyle], + ); + } else { + setOptionByChoiceName( + 'Face Features', + { 0: 'None', 1: 'None', 2: 'Strapped', 3: 'Rotting', 4: 'None', 5: 'None', 6: 'None', 7: 'Putrid' }[charData.facialStyle], + ); + setOptionByChoiceName( + 'Jaw Features', + { 0: 'Intact', 1: 'Stitched', 2: 'Intact', 3: 'Intact', 4: 'Bonejawed', 5: 'Toothy', 6: 'Cheeky', 7: 'Intact' }[ + charData.facialStyle + ], + ); + setOptionByChoiceId( + 'Eye Color', + { 0: 5337, 1: 5337, 2: 6305, 3: 5337, 4: 5337, 5: 6305, 6: 5337, 7: 5337 }[charData.facialStyle], + ); + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 5344 : 5345); + } + break; + case 6: // Tauren + setOptionByChoiceIndex('Horn Style', charData.hairStyle); + setOptionByChoiceIndex('Horn Color', charData.hairColor); + setOptionByChoiceName('Foremane', 'Short'); + setOptionByChoiceName('Face Paint', 'None'); + setOptionByChoiceName('Headdress', 'None'); + setOptionByChoiceName('Necklace', 'None'); + setOptionByChoiceIndex('Jewelry Color', 0); + setOptionByChoiceName('Flower', 'None'); + setOptionByChoiceName('Body Paint', 'None'); + setOptionByChoiceIndex('Paint Color', 0); + if (charData.gender === 0) { + setOptionByChoiceName( + 'Hair', + { 0: 'Mane', 1: 'Braids', 2: 'Chops', 3: 'Sideburns', 4: 'Mane', 5: 'Wrapped', 6: 'Braids' }[charData.facialStyle], + ); + setOptionByChoiceName( + 'Facial Hair', + { 0: 'Clean', 1: 'Braid', 2: 'Beard', 3: 'Wrapped', 4: 'Curtain', 5: 'Clean', 6: 'Split' }[charData.facialStyle], + ); + setOptionByChoiceName( + 'Nose Ring', + { 0: 'None', 1: 'Small', 2: 'Open', 3: 'None', 4: 'None', 5: 'Bead', 6: 'Open' }[charData.facialStyle], + ); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } else { + setOptionByChoiceIndex('Hair', charData.facialStyle); + setOptionByChoiceName('Earrings', 'None'); + setOptionByChoiceName('Nose Ring', 'None'); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 7281 : 7289); + } + break; + case 8: // Troll + setOptionByChoiceName('Body Paint', 'None'); + setOptionByChoiceName('Body Paint Color', 'None'); + setOptionByChoiceName('Piercing', 'None'); + if (charData.gender === 0) { + setOptionByChoiceName( + 'Tusks', + { + 0: 'Tusked', + 1: 'Gougers', + 2: 'Mammoth', + 3: 'Spears', + 4: 'Bridle', + 5: 'Tusked', + 6: 'Gougers', + 7: 'Mammoth', + 8: 'Spears', + 9: 'Bridle', + 10: 'Gougers', + }[charData.facialStyle], + ); + setOptionByChoiceName( + 'Face Paint', + { + 0: 'None', + 1: 'None', + 2: 'None', + 3: 'None', + 4: 'None', + 5: 'Berserker', + 6: 'Fangs', + 7: 'Mask', + 8: 'Oni', + 9: 'Prophet', + 10: 'War', + }[charData.facialStyle], + ); + setOptionByChoiceIndex('Face Paint Color', charData.hairColor + 1); + setOptionByChoiceName('Earrings', 'None'); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } else { + setOptionByChoiceIndex('Tusks', charData.facialStyle); + setOptionByChoiceName('Face Paint', 'None'); + setOptionByChoiceIndex('Face Paint Color', 0); + setOptionByChoiceName('Earrings', 'Hoops'); + setOptionByChoiceIndex('Eye Color', 0); // TODO + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 8451 : 8468); + } + break; + case 10: // Blood Elf + setOptionByChoiceName('Ears', 'Long'); + setOptionByChoiceName('Horns', 'None'); + setOptionByChoiceName('Blindfold', 'None'); + setOptionByChoiceName('Tattoo', 'None'); + setOptionByChoiceIndex('Tattoo Color', 0); + if (charData.gender === 0) { + setOptionByChoiceIndex('Facial Hair', charData.facialStyle); + } else { + setOptionByChoiceIndex('Earrings', charData.facialStyle); + setOptionByChoiceIndex('Jewelry Color', 0); + setOptionByChoiceName('Necklace', 'None'); + setOptionByChoiceName('Armbands', 'None'); + setOptionByChoiceName('Bracelets', 'None'); + } + if (charData.class === 6) { + // Death Knight + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 6586 : 6605); + } else { + setOptionByChoiceId('Eye Color', charData.gender === 0 ? 6570 : 6589); + } + break; + } + if ([4, 6].includes(charData.race)) { + // Races that can choose the druid class + setOptionByChoiceIndex('Bear Form', 0); + setOptionByChoiceIndex('Cat Form', 0); + setOptionByChoiceIndex('Aquatic Form', 0); + setOptionByChoiceIndex('Travel Form', 0); + setOptionByChoiceIndex('Flight Form', 0); + setOptionByChoiceIndex('Moonkin Form', 0); + } - return options; - } + return options; + } - private async getTalents(realm: string, character: number): Promise { - const [rows, fields] = await this.armory.getCharactersDb(realm).query({ - sql: ` + private async getTalents(realm: string, character: number): Promise { + const [rows, fields] = await this.armory.getCharactersDb(realm).query({ + sql: ` SELECT spell, specMask FROM character_talent WHERE guid = ? `, - values: [character], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [character], + timeout: this.armory.config.dbQueryTimeout, + }); - const talents: number[][] = [[], []]; - for (const row of rows as RowDataPacket[]) { - if (row.specMask === 1 || row.specMask === 3) { - talents[0].push(row.spell); - } - if (row.specMask === 2 || row.specMask === 3) { - talents[1].push(row.spell); - } - } + const talents: number[][] = [[], []]; + for (const row of rows as RowDataPacket[]) { + if (row.specMask === 1 || row.specMask === 3) { + talents[0].push(row.spell); + } + if (row.specMask === 2 || row.specMask === 3) { + talents[1].push(row.spell); + } + } - return talents; - } + return talents; + } - private async getTalentTrees(classId: number) { - const items = await this.armory.dbc.talentTab() - .filter(tab => tab.classMask === Math.pow(2, classId - 1)) - .map(async tab => { - const icon = await this.armory.dbc.spellIcon().find(icon => icon.id === tab.spellIconId); - const spells = await this.armory.dbc.talent() - .filter(row => row.tabId === tab.id) - .map(async row => { - const spell = await this.armory.dbc.spell().find(spell => spell.id === row.spellRank0); - const icon = await this.armory.dbc.spellIcon().find(icon => icon.id === spell?.spellIconId); - return { ...row, icon: this.processSpellIconTexture(icon?.textureFilename ?? ""), }; - }) - .toArray(); - return { - name: tab.nameLang0, - icon: this.processSpellIconTexture(icon.textureFilename), - spells: await Promise.all(spells), - }; - }) - .toArray(); - return await Promise.all(items); - } + private async getTalentTrees(classId: number) { + const items = await this.armory.dbc + .talentTab() + .filter((tab) => tab.classMask === Math.pow(2, classId - 1)) + .map(async (tab) => { + const icon = await this.armory.dbc.spellIcon().find((icon) => icon.id === tab.spellIconId); + const spells = await this.armory.dbc + .talent() + .filter((row) => row.tabId === tab.id) + .map(async (row) => { + const spell = await this.armory.dbc.spell().find((spell) => spell.id === row.spellRank0); + const icon = await this.armory.dbc.spellIcon().find((icon) => icon.id === spell?.spellIconId); + return { ...row, icon: this.processSpellIconTexture(icon?.textureFilename ?? '') }; + }) + .toArray(); + return { + name: tab.nameLang0, + icon: this.processSpellIconTexture(icon.textureFilename), + spells: await Promise.all(spells), + }; + }) + .toArray(); + return await Promise.all(items); + } - private processSpellIconTexture(texturePath: string): string { - return texturePath - .toLowerCase() - .replace("interface\\icons\\", "") - .replace("interface\\spellbook\\", "") - .replace(/\.$/, ""); - } + private processSpellIconTexture(texturePath: string): string { + return texturePath.toLowerCase().replace('interface\\icons\\', '').replace('interface\\spellbook\\', '').replace(/\.$/, ''); + } - private async getGlyphs(realm: string, character: number): Promise { - const [rows, fields] = await this.armory.getCharactersDb(realm).query({ - sql: ` + private async getGlyphs(realm: string, character: number): Promise { + const [rows, fields] = await this.armory.getCharactersDb(realm).query({ + sql: ` SELECT guid, talentGroup, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 FROM character_glyphs WHERE guid = ? `, - values: [character], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [character], + timeout: this.armory.config.dbQueryTimeout, + }); - const glyphs = [[], []]; - for (const row of rows as RowDataPacket[]) { - const glyphIds = [row.glyph1, row.glyph2, row.glyph3, row.glyph4, row.glyph5, row.glyph6].filter(id => id !== 0); - for (const glyphId of glyphIds) { - const glyph = await this.armory.dbc.glyphProperties().find(g => g.id === glyphId); - if (glyph === undefined) { - continue; - } - glyphs[row.talentGroup].push(glyph.spellId); - } - } + const glyphs = [[], []]; + for (const row of rows as RowDataPacket[]) { + const glyphIds = [row.glyph1, row.glyph2, row.glyph3, row.glyph4, row.glyph5, row.glyph6].filter((id) => id !== 0); + for (const glyphId of glyphIds) { + const glyph = await this.armory.dbc.glyphProperties().find((g) => g.id === glyphId); + if (glyph === undefined) { + continue; + } + glyphs[row.talentGroup].push(glyph.spellId); + } + } - return glyphs; - } + return glyphs; + } - private async getAchievements(realm: string, charData: ICharacterData): Promise<{ achievements: any[]; earned: { [key: number]: any }; }> { - const promises = await this.armory.dbc.achievement() - .filter(ach => ach.faction === -1 || ach.faction === Utils.getFactionFromRaceId(charData.race)) - .map(async (ach) => { - const icon = await this.armory.dbc.spellIcon().find(icon => icon.id === ach.iconId); - return { - id: ach.id, - category: ach.category, - title: ach.titleLang0, - description: ach.descriptionLang0, - points: ach.points, - icon: this.processSpellIconTexture(icon?.textureFilename ?? ""), - }; - }) - .toArray(); - const achievements = await Promise.all(promises); + private async getAchievements(realm: string, charData: ICharacterData): Promise<{ achievements: any[]; earned: { [key: number]: any } }> { + const promises = await this.armory.dbc + .achievement() + .filter((ach) => ach.faction === -1 || ach.faction === Utils.getFactionFromRaceId(charData.race)) + .map(async (ach) => { + const icon = await this.armory.dbc.spellIcon().find((icon) => icon.id === ach.iconId); + return { + id: ach.id, + category: ach.category, + title: ach.titleLang0, + description: ach.descriptionLang0, + points: ach.points, + icon: this.processSpellIconTexture(icon?.textureFilename ?? ''), + }; + }) + .toArray(); + const achievements = await Promise.all(promises); - const [rows, fields] = await this.armory.getCharactersDb(realm).query({ - sql: ` + const [rows, fields] = await this.armory.getCharactersDb(realm).query({ + sql: ` SELECT achievement, date FROM character_achievement WHERE guid = ? `, - values: [charData.guid], - timeout: this.armory.config.dbQueryTimeout, - }); - const earned = {}; - for (const row of rows as RowDataPacket[]) { - earned[row.achievement] = { - date: row.date, - }; - } + values: [charData.guid], + timeout: this.armory.config.dbQueryTimeout, + }); + const earned = {}; + for (const row of rows as RowDataPacket[]) { + earned[row.achievement] = { + date: row.date, + }; + } - return { - achievements, - earned, - }; - } + return { + achievements, + earned, + }; + } - private async getPvpKills(realm: string, charGuid: number): Promise<{ total: number, today: number, yesterday: number }> { - const [rows, fields] = await this.armory.getCharactersDb(realm).query({ - sql: ` + private async getPvpKills(realm: string, charGuid: number): Promise<{ total: number; today: number; yesterday: number }> { + const [rows, fields] = await this.armory.getCharactersDb(realm).query({ + sql: ` SELECT totalKills, todayKills, yesterdayKills FROM characters WHERE guid = ? `, - values: [charGuid], - timeout: this.armory.config.dbQueryTimeout, - }); - const row = rows[0]; + values: [charGuid], + timeout: this.armory.config.dbQueryTimeout, + }); + const row = rows[0]; - return { - total: row.totalKills, - today: row.todayKills, - yesterday: row.yesterdayKills, - }; - } + return { + total: row.totalKills, + today: row.todayKills, + yesterday: row.yesterdayKills, + }; + } - private async getArenaTeams(realm: string, charGuid: number): Promise { - const [rows, fields] = await this.armory.getCharactersDb(realm).query({ - sql: ` + private async getArenaTeams(realm: string, charGuid: number): Promise { + const [rows, fields] = await this.armory.getCharactersDb(realm).query({ + sql: ` SELECT arena_team.arenaTeamId AS id, arena_team.name, arena_team.type, arena_team.rating, arena_team.seasonWins, arena_team.seasonGames, arena_team.backgroundColor AS background, arena_team.emblemStyle, arena_team.emblemColor, arena_team.borderStyle, arena_team.borderColor @@ -837,13 +1020,13 @@ export class CharacterController { WHERE guid = ? ORDER BY arena_team.type ASC `, - values: [charGuid], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [charGuid], + timeout: this.armory.config.dbQueryTimeout, + }); - return (rows as RowDataPacket[]).map(row => { - row.emblem = Utils.makeEmblemObject(row, false); - return row; - }); - } + return (rows as RowDataPacket[]).map((row) => { + row.emblem = Utils.makeEmblemObject(row, false); + return row; + }); + } } diff --git a/src/armory/controllers/GuildController.ts b/src/armory/controllers/GuildController.ts index df92261..3fda8ca 100644 --- a/src/armory/controllers/GuildController.ts +++ b/src/armory/controllers/GuildController.ts @@ -1,184 +1,188 @@ -import * as express from "express"; -import { encode } from "html-entities"; -import { RowDataPacket } from "mysql2/promise"; +import * as express from 'express'; +import { encode } from 'html-entities'; +import { RowDataPacket } from 'mysql2/promise'; -import { Utils } from "../Utils"; -import { Armory } from "../Armory"; -import { IRealmConfig } from "../Config"; -import { DataTablesSsp } from "../DataTablesSsp"; +import { Utils } from '../Utils'; +import { Armory } from '../Armory'; +import { IRealmConfig } from '../Config'; +import { DataTablesSsp } from '../DataTablesSsp'; interface IGuildRank { - id: number; - name: string; + id: number; + name: string; } export class GuildController { - private armory: Armory; + private armory: Armory; - public constructor(armory: Armory) { - this.armory = armory; - } + public constructor(armory: Armory) { + this.armory = armory; + } - public async guild(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.params.realm; - const guildName = req.params.name; + public async guild(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const guildName = req.params.name; - const realm = this.armory.getRealm(realmName); - if (realm === undefined) { - // Could not find realm - return next(404); - } + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } - const guildData = await this.getGuildData(realm, guildName); - if (guildData === null) { - // Could not find guild - return next(404); - } + const guildData = await this.getGuildData(realm, guildName); + if (guildData === null) { + // Could not find guild + return next(404); + } - res.render("guild.hbs", { - title: `Armory - ${guildName}`, - realm: realm.name, - ...guildData, - }); - } + res.render('guild.hbs', { + title: `Armory - ${guildName}`, + realm: realm.name, + ...guildData, + }); + } - public async members(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.params.realm; - const guildId = parseInt(req.params.guild); + public async members(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.params.realm; + const guildId = parseInt(req.params.guild); - const realm = this.armory.getRealm(realmName); - if (realm === undefined) { - // Could not find realm - return next(404); - } + const realm = this.armory.getRealm(realmName); + if (realm === undefined) { + // Could not find realm + return next(404); + } - if (isNaN(guildId) || !(await this.guildExists(realm, guildId))) { - // Could not find guild - return next(404); - } + if (isNaN(guildId) || !(await this.guildExists(realm, guildId))) { + // Could not find guild + return next(404); + } - const db = this.armory.getCharactersDb(realm.name); - const charSet = await this.armory.getDatabaseCharset(realm.name); + const db = this.armory.getCharactersDb(realm.name); + const charSet = await this.armory.getDatabaseCharset(realm.name); - let ssp = new DataTablesSsp(req.query, db, "guild_member", "guid", [ - { name: "name", table: "characters", collation: `${charSet}_general_ci` }, - { name: "rank" }, - { name: "level", table: "characters" }, - { name: "class", table: "characters", formatter: cls => Utils.classNames[cls] }, - { name: "race", table: "characters", formatter: (race, row) => `${Utils.raceNames[race]}_${row[6] === 0 ? "male" : "female"}` }, - { name: "online", table: "characters", formatter: online => online === 1 }, - ]); - ssp.joins = [ - { table1: "guild_member", column1: "guid", table2: "characters", column2: "guid", kind: "LEFT" }, - ]; - ssp.extraDataColumns = ["`characters`.`gender`"]; + let ssp = new DataTablesSsp(req.query, db, 'guild_member', 'guid', [ + { name: 'name', table: 'characters', collation: `${charSet}_general_ci` }, + { name: 'rank' }, + { name: 'level', table: 'characters' }, + { name: 'class', table: 'characters', formatter: (cls) => Utils.classNames[cls] }, + { name: 'race', table: 'characters', formatter: (race, row) => `${Utils.raceNames[race]}_${row[6] === 0 ? 'male' : 'female'}` }, + { name: 'online', table: 'characters', formatter: (online) => online === 1 }, + ]); + ssp.joins = [{ table1: 'guild_member', column1: 'guid', table2: 'characters', column2: 'guid', kind: 'LEFT' }]; + ssp.extraDataColumns = ['`characters`.`gender`']; - if (this.armory.config.hideGameMasters) { - ssp.joins.push({ table1: "characters", column1: "account", table2: "account_access", column2: "id", database2: realm.authDatabase, kind: "LEFT" }); - ssp = ssp.where(`\`account_access\`.\`id\` IS NULL OR \`account_access\`.\`RealmID\` NOT IN (-1, ${realm.realmId}) OR \`account_access\`.\`gmlevel\` = 0`); - } + if (this.armory.config.hideGameMasters) { + ssp.joins.push({ + table1: 'characters', + column1: 'account', + table2: 'account_access', + column2: 'id', + database2: realm.authDatabase, + kind: 'LEFT', + }); + ssp = ssp.where( + `\`account_access\`.\`id\` IS NULL OR \`account_access\`.\`RealmID\` NOT IN (-1, ${realm.realmId}) OR \`account_access\`.\`gmlevel\` = 0`, + ); + } - const result = await ssp - .where("`guildid` = ?", guildId) - .where("`deleteInfos_Account` IS NULL") - .run(this.armory.config.dbQueryTimeout); + const result = await ssp.where('`guildid` = ?', guildId).where('`deleteInfos_Account` IS NULL').run(this.armory.config.dbQueryTimeout); - const ranks = await this.getGuildRanks(realm, guildId); - (result as any).ranks = {}; - for (const rank of ranks) { - (result as any).ranks[rank.id] = encode(rank.name); - } + const ranks = await this.getGuildRanks(realm, guildId); + (result as any).ranks = {}; + for (const rank of ranks) { + (result as any).ranks[rank.id] = encode(rank.name); + } - res.json(result); - } + res.json(result); + } - private async getGuildData(realm: IRealmConfig, name: string): Promise { - const db = this.armory.getCharactersDb(realm.name); - let [rows, fields] = await db.query({ - sql: ` + private async getGuildData(realm: IRealmConfig, name: string): Promise { + const db = this.armory.getCharactersDb(realm.name); + let [rows, fields] = await db.query({ + sql: ` SELECT guildid, name, leaderguid, EmblemStyle AS emblemStyle, EmblemColor AS emblemColor, BorderStyle AS borderStyle, BorderColor AS borderColor, BackgroundColor AS background FROM guild WHERE name = ? `, - values: [name], - timeout: this.armory.config.dbQueryTimeout, - }); - if ((rows as RowDataPacket[]).length === 0) { - return null; - } - const guild = rows[0]; + values: [name], + timeout: this.armory.config.dbQueryTimeout, + }); + if ((rows as RowDataPacket[]).length === 0) { + return null; + } + const guild = rows[0]; - [rows, fields] = await db.query({ - sql: ` + [rows, fields] = await db.query({ + sql: ` SELECT name, race FROM characters WHERE guid = ? `, - values: [guild.leaderguid], - timeout: this.armory.config.dbQueryTimeout, - }); - const leader = rows[0]; + values: [guild.leaderguid], + timeout: this.armory.config.dbQueryTimeout, + }); + const leader = rows[0]; - [rows, fields] = await db.query({ - sql: ` + [rows, fields] = await db.query({ + sql: ` SELECT COUNT(guid) AS \`count\` FROM guild_member WHERE guildid = ? `, - values: [guild.guildid], - timeout: this.armory.config.dbQueryTimeout, - }); - const membersCount = rows[0].count; + values: [guild.guildid], + timeout: this.armory.config.dbQueryTimeout, + }); + const membersCount = rows[0].count; - return { - id: guild.guildid, - name: guild.name, - leader: leader.name, - faction: Utils.getFactionFromRaceId(leader.race), - emblem: Utils.makeEmblemObject(guild), - membersCount, - }; - } + return { + id: guild.guildid, + name: guild.name, + leader: leader.name, + faction: Utils.getFactionFromRaceId(leader.race), + emblem: Utils.makeEmblemObject(guild), + membersCount, + }; + } - private async getGuildId(realm: IRealmConfig, name: string): Promise { - const db = this.armory.getCharactersDb(realm.name); - const [rows, fields] = await db.query({ - sql: ` + private async getGuildId(realm: IRealmConfig, name: string): Promise { + const db = this.armory.getCharactersDb(realm.name); + const [rows, fields] = await db.query({ + sql: ` SELECT guildid FROM guild WHERE name = ? `, - values: [name], - timeout: this.armory.config.dbQueryTimeout, - }); - if ((rows as RowDataPacket[]).length === 0) { - return null; - } + values: [name], + timeout: this.armory.config.dbQueryTimeout, + }); + if ((rows as RowDataPacket[]).length === 0) { + return null; + } - return rows[0].guildid; - } + return rows[0].guildid; + } - private async guildExists(realm: IRealmConfig, id: number): Promise { - const db = this.armory.getCharactersDb(realm.name); - const [rows, fields] = await db.query({ - sql: ` + private async guildExists(realm: IRealmConfig, id: number): Promise { + const db = this.armory.getCharactersDb(realm.name); + const [rows, fields] = await db.query({ + sql: ` SELECT guildid FROM guild WHERE guildid `, - values: [id], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [id], + timeout: this.armory.config.dbQueryTimeout, + }); - return (rows as RowDataPacket[]).length !== 0; - } + return (rows as RowDataPacket[]).length !== 0; + } - private async getGuildRanks(realm: IRealmConfig, id: number): Promise { - const db = this.armory.getCharactersDb(realm.name); - const [rows, fields] = await db.query({ - sql: ` + private async getGuildRanks(realm: IRealmConfig, id: number): Promise { + const db = this.armory.getCharactersDb(realm.name); + const [rows, fields] = await db.query({ + sql: ` SELECT rid AS id, rname AS name FROM guild_rank WHERE guildid = ? `, - values: [id], - timeout: this.armory.config.dbQueryTimeout, - }); + values: [id], + timeout: this.armory.config.dbQueryTimeout, + }); - return rows as IGuildRank[]; - } + return rows as IGuildRank[]; + } } diff --git a/src/armory/controllers/IndexController.ts b/src/armory/controllers/IndexController.ts index 0322a6f..01ffe32 100644 --- a/src/armory/controllers/IndexController.ts +++ b/src/armory/controllers/IndexController.ts @@ -1,59 +1,64 @@ -import * as express from "express"; +import * as express from 'express'; -import { Utils } from "../Utils"; -import { Armory } from "../Armory"; -import { DataTablesSsp } from "../DataTablesSsp"; +import { Utils } from '../Utils'; +import { Armory } from '../Armory'; +import { DataTablesSsp } from '../DataTablesSsp'; export class IndexController { - private armory: Armory; + private armory: Armory; - public constructor(armory: Armory) { - this.armory = armory; - } + public constructor(armory: Armory) { + this.armory = armory; + } - public async index(req: express.Request, res: express.Response): Promise { - res.render("index.hbs", { - title: "Armory", - realms: this.armory.config.realms.map(r => r.name), - }); - } + public async index(req: express.Request, res: express.Response): Promise { + res.render('index.hbs', { + title: 'Armory', + realms: this.armory.config.realms.map((r) => r.name), + }); + } - public async search(req: express.Request, res: express.Response, next: express.NextFunction): Promise { - const realmName = req.query.realm as string; - const realm = realmName === undefined ? - this.armory.config.realms[0] : - this.armory.config.realms.find(r => r.name === realmName); - if (realm === undefined) { - return next(400); - } + public async search(req: express.Request, res: express.Response, next: express.NextFunction): Promise { + const realmName = req.query.realm as string; + const realm = realmName === undefined ? this.armory.config.realms[0] : this.armory.config.realms.find((r) => r.name === realmName); + if (realm === undefined) { + return next(400); + } - const db = this.armory.getCharactersDb(realm.name); - const charSet = await this.armory.getDatabaseCharset(realm.name); + const db = this.armory.getCharactersDb(realm.name); + const charSet = await this.armory.getDatabaseCharset(realm.name); - let ssp = new DataTablesSsp(req.query, db, "characters", "guid", [ - { name: "name", collation: `${charSet}_general_ci` }, - { table: "guild", name: "name" }, - { name: "level" }, - { name: "class", formatter: cls => Utils.classNames[cls] }, - { name: "race", formatter: (race, row) => `${Utils.raceNames[race]}_${row[6] === 0 ? "male" : "female"}` }, - { name: "online", formatter: online => online === 1 }, - ]); - ssp.joins = [ - { table1: "characters", column1: "guid", table2: "guild_member", column2: "guid", kind: "LEFT" }, - { table1: "guild_member", column1: "guildid", table2: "guild", column2: "guildid", kind: "LEFT" }, - ]; - ssp.extraDataColumns = ["`characters`.`gender`"]; + let ssp = new DataTablesSsp(req.query, db, 'characters', 'guid', [ + { name: 'name', collation: `${charSet}_general_ci` }, + { table: 'guild', name: 'name' }, + { name: 'level' }, + { name: 'class', formatter: (cls) => Utils.classNames[cls] }, + { name: 'race', formatter: (race, row) => `${Utils.raceNames[race]}_${row[6] === 0 ? 'male' : 'female'}` }, + { name: 'online', formatter: (online) => online === 1 }, + ]); + ssp.joins = [ + { table1: 'characters', column1: 'guid', table2: 'guild_member', column2: 'guid', kind: 'LEFT' }, + { table1: 'guild_member', column1: 'guildid', table2: 'guild', column2: 'guildid', kind: 'LEFT' }, + ]; + ssp.extraDataColumns = ['`characters`.`gender`']; - if (this.armory.config.hideGameMasters) { - ssp.joins.push({ table1: "characters", column1: "account", table2: "account_access", column2: "id", database2: realm.authDatabase, kind: "LEFT" }); - ssp = ssp.where(`\`account_access\`.\`id\` IS NULL OR \`account_access\`.\`RealmID\` NOT IN (-1, ${realm.realmId}) OR \`account_access\`.\`gmlevel\` = 0`); - } + if (this.armory.config.hideGameMasters) { + ssp.joins.push({ + table1: 'characters', + column1: 'account', + table2: 'account_access', + column2: 'id', + database2: realm.authDatabase, + kind: 'LEFT', + }); + ssp = ssp.where( + `\`account_access\`.\`id\` IS NULL OR \`account_access\`.\`RealmID\` NOT IN (-1, ${realm.realmId}) OR \`account_access\`.\`gmlevel\` = 0`, + ); + } - const result = await ssp - .where("`deleteInfos_Account` IS NULL") - .run(this.armory.config.dbQueryTimeout); - (result as any).realm = realm.name; + const result = await ssp.where('`deleteInfos_Account` IS NULL').run(this.armory.config.dbQueryTimeout); + (result as any).realm = realm.name; - res.json(result); - } + res.json(result); + } } diff --git a/src/armory/data/CharacterCustomization.ts b/src/armory/data/CharacterCustomization.ts index 2c45318..4f92637 100644 --- a/src/armory/data/CharacterCustomization.ts +++ b/src/armory/data/CharacterCustomization.ts @@ -1,27 +1,27 @@ -import * as fs from "fs"; +import * as fs from 'fs'; const fsp = fs.promises; -import * as path from "path"; +import * as path from 'path'; export class CharacterCustomization { - private data: { [key: number]: { [key: number]: any } }; + private data: { [key: number]: { [key: number]: any } }; - public async loadData(): Promise { - this.data = {}; - const races = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11]; - const genders = [0, 1]; + public async loadData(): Promise { + this.data = {}; + const races = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11]; + const genders = [0, 1]; - for (const race of races) { - this.data[race] = {}; + for (const race of races) { + this.data[race] = {}; - for (const gender of genders) { - const buffer = await fsp.readFile(path.join(process.cwd(), `data/meta/charactercustomization2/${race}_${gender}.json`)); - const customizationData = JSON.parse(buffer.toString()); - this.data[race][gender] = customizationData; - } - } - } + for (const gender of genders) { + const buffer = await fsp.readFile(path.join(process.cwd(), `data/meta/charactercustomization2/${race}_${gender}.json`)); + const customizationData = JSON.parse(buffer.toString()); + this.data[race][gender] = customizationData; + } + } + } - public getCharacterCustomizationData(race: number, gender: number): any { - return this.data[race][gender]; - } + public getCharacterCustomizationData(race: number, gender: number): any { + return this.data[race][gender]; + } } diff --git a/src/armory/data/DbcReader.ts b/src/armory/data/DbcReader.ts index 212e502..dff3360 100644 --- a/src/armory/data/DbcReader.ts +++ b/src/armory/data/DbcReader.ts @@ -1,437 +1,460 @@ -import * as fs from "fs"; -import * as path from "path"; +import * as fs from 'fs'; +import * as path from 'path'; -import * as camelCase from "camelcase"; +import * as camelCase from 'camelcase'; export interface IGlyphProperties { - id: number; - spellId: number; + id: number; + spellId: number; } export interface IAchievement { - id: number; - faction: number; - titleLang0: string; - descriptionLang0: string; - category: number; - points: number; - flags: number; - iconId: number; + id: number; + faction: number; + titleLang0: string; + descriptionLang0: string; + category: number; + points: number; + flags: number; + iconId: number; } export interface IAchievementCategory { - id: number; - parent: number; - nameLang0: string; + id: number; + parent: number; + nameLang0: string; } export interface IItemDbc { - id: number; - classId: number; - subclassId: number; - displayInfoId: number; - inventoryType: number; + id: number; + classId: number; + subclassId: number; + displayInfoId: number; + inventoryType: number; } export interface IItemRetailDbc { - id: number; - inventoryType: number; + id: number; + inventoryType: number; } export interface IItemAppearanceDbc { - id: number; - itemDisplayInfoId: number; + id: number; + itemDisplayInfoId: number; } export interface IItemModifiedAppearanceDbc { - id: number; - itemId: number; - itemAppearanceId: number; + id: number; + itemId: number; + itemAppearanceId: number; } export interface IItemDisplayInfoDbc { - id: number; - inventoryIcon0: number; + id: number; + inventoryIcon0: number; } export interface IMountDbc { - id: number; - sourceSpellId: number; + id: number; + sourceSpellId: number; } export interface IMountXDisplayDbc { - id: number; - creatureDisplayInfoId: number; - mountId: number; + id: number; + creatureDisplayInfoId: number; + mountId: number; } export interface ISpellDbc { - id: number; - mechanic: number; - spellIconId: number; + id: number; + mechanic: number; + spellIconId: number; } export interface ISpellItemEnchantmentDbc { - id: number; - srcItemId: number; + id: number; + srcItemId: number; } export interface ISpellIcon { - id: number; - textureFilename: string; + id: number; + textureFilename: string; } export interface ITalent { - id: number; - tabId: number; - tierId: number; - columnIndex: number; - spellRank0: number; - spellRank1: number; - spellRank2: number; - spellRank3: number; - spellRank4: number; - prereqTalent0: number; - prereqRank0: number; + id: number; + tabId: number; + tierId: number; + columnIndex: number; + spellRank0: number; + spellRank1: number; + spellRank2: number; + spellRank3: number; + spellRank4: number; + prereqTalent0: number; + prereqRank0: number; } export interface ITalentTab { - id: number; - nameLang0: string; - spellIconId: number; - classMask: number; + id: number; + nameLang0: string; + spellIconId: number; + classMask: number; } interface IAsyncGeneratorWithArrayMethods { - [Symbol.asyncIterator](): AsyncGenerator; - toArray(): Promise; - map(fn: (t: T) => M): IAsyncGeneratorWithArrayMethods; - filter(fn: (t: T) => boolean): IAsyncGeneratorWithArrayMethods; - find(fn: (t: T) => boolean): Promise; + [Symbol.asyncIterator](): AsyncGenerator; + toArray(): Promise; + map(fn: (t: T) => M): IAsyncGeneratorWithArrayMethods; + filter(fn: (t: T) => boolean): IAsyncGeneratorWithArrayMethods; + find(fn: (t: T) => boolean): Promise; } class ArrayAsAsyncGenerator implements IAsyncGeneratorWithArrayMethods { - private data: T[]; + private data: T[]; - public constructor(data: T[]) { - this.data = data; - } + public constructor(data: T[]) { + this.data = data; + } - async toArray(): Promise { - return this.data; - } + async toArray(): Promise { + return this.data; + } - async *[Symbol.asyncIterator](): AsyncGenerator { - for (const x of this.data) { - yield x; - } - } + async *[Symbol.asyncIterator](): AsyncGenerator { + for (const x of this.data) { + yield x; + } + } - public map(fn: (t: T) => M): ArrayAsAsyncGenerator { - return new ArrayAsAsyncGenerator(this.data.map(fn)); - } + public map(fn: (t: T) => M): ArrayAsAsyncGenerator { + return new ArrayAsAsyncGenerator(this.data.map(fn)); + } - filter(fn: (t: T) => boolean): ArrayAsAsyncGenerator { - return new ArrayAsAsyncGenerator(this.data.filter(fn)); - } + filter(fn: (t: T) => boolean): ArrayAsAsyncGenerator { + return new ArrayAsAsyncGenerator(this.data.filter(fn)); + } - async find(fn: (t: T) => boolean): Promise { - return this.data.find(fn); - } + async find(fn: (t: T) => boolean): Promise { + return this.data.find(fn); + } } class AsyncGenWrapper implements IAsyncGeneratorWithArrayMethods { - private gen: AsyncGenerator; + private gen: AsyncGenerator; - public constructor(gen: AsyncGenerator) { - this.gen = gen; - } + public constructor(gen: AsyncGenerator) { + this.gen = gen; + } - public static from(array: T[]): AsyncGenWrapper { - return new AsyncGenWrapper(async function* () { - for (const x of array) { - yield x; - } - }()); - } + public static from(array: T[]): AsyncGenWrapper { + return new AsyncGenWrapper( + (async function* () { + for (const x of array) { + yield x; + } + })(), + ); + } - public async *[Symbol.asyncIterator](): AsyncGenerator { - for await (const x of this.gen) { - yield x; - } - } + public async *[Symbol.asyncIterator](): AsyncGenerator { + for await (const x of this.gen) { + yield x; + } + } - public async toArray(): Promise { - const values = []; - for await (const x of this) { - values.push(x); - } - return values; - } + public async toArray(): Promise { + const values = []; + for await (const x of this) { + values.push(x); + } + return values; + } - private wrap(g: (that: AsyncGenWrapper) => AsyncGenerator): AsyncGenWrapper { - return new AsyncGenWrapper(g(this)); - } + private wrap(g: (that: AsyncGenWrapper) => AsyncGenerator): AsyncGenWrapper { + return new AsyncGenWrapper(g(this)); + } - public map(fn: (t: T) => M): AsyncGenWrapper { - return this.wrap(async function* (me) { - for await (const x of me) { - yield fn(x); - } - }); - } + public map(fn: (t: T) => M): AsyncGenWrapper { + return this.wrap(async function* (me) { + for await (const x of me) { + yield fn(x); + } + }); + } - public filter(fn: (t: T) => boolean): AsyncGenWrapper { - return this.wrap(async function* (me) { - for await (const x of me) { - if (fn(x)) { - yield x; - } - } - }); - } + public filter(fn: (t: T) => boolean): AsyncGenWrapper { + return this.wrap(async function* (me) { + for await (const x of me) { + if (fn(x)) { + yield x; + } + } + }); + } - public async find(fn: (t: T) => boolean): Promise { - for await (const x of this) { - if (fn(x)) { - return x; - } - } - } + public async find(fn: (t: T) => boolean): Promise { + for await (const x of this) { + if (fn(x)) { + return x; + } + } + } } class DbcReader { - private filePath: string; - private fields: string[]; + private filePath: string; + private fields: string[]; - public constructor(filePath: string, keepFields: string[] = []) { - this.filePath = filePath; - this.fields = keepFields; - } + public constructor(filePath: string, keepFields: string[] = []) { + this.filePath = filePath; + this.fields = keepFields; + } - public async *read(): AsyncGenerator { - const stream = fs.createReadStream(this.filePath); - const itr = this.parseCsv(stream); - const headerLine = await itr.next(); - if (headerLine.done === true) { - return; - } + public async *read(): AsyncGenerator { + const stream = fs.createReadStream(this.filePath); + const itr = this.parseCsv(stream); + const headerLine = await itr.next(); + if (headerLine.done === true) { + return; + } - const headerCols = headerLine.value - .map(header => camelCase(header).replace(/[\[\]]/g, "")); + const headerCols = headerLine.value.map((header) => camelCase(header).replace(/[\[\]]/g, '')); - for await (const arr of itr) { - const cols = arr.map(value => isNaN(value as any) ? value : parseInt(value, 10)); - const row = {}; - headerCols.forEach((header, headerIdx) => { - if (this.fields.length === 0 || this.fields.includes(header)) { - row[header] = cols[headerIdx]; - } - }); - yield row as T; - } - } + for await (const arr of itr) { + const cols = arr.map((value) => (isNaN(value as any) ? value : parseInt(value, 10))); + const row = {}; + headerCols.forEach((header, headerIdx) => { + if (this.fields.length === 0 || this.fields.includes(header)) { + row[header] = cols[headerIdx]; + } + }); + yield row as T; + } + } - private async *parseCsv(stream: fs.ReadStream): AsyncGenerator { - // Adapted from https://stackoverflow.com/a/14991797 - const arr = []; - let col = 0; - let quote = false; // 'true' means we're inside a quoted field + private async *parseCsv(stream: fs.ReadStream): AsyncGenerator { + // Adapted from https://stackoverflow.com/a/14991797 + const arr = []; + let col = 0; + let quote = false; // 'true' means we're inside a quoted field - for await (const chunk of stream) { - const str = chunk.toString(); - // Iterate over each character, keep track of current column (of the returned array) - for (let c = 0; c < str.length; ++c) { - let ch = str[c], nch = str[c + 1]; // Current character, next character - if (!(col in arr)) { - arr[col] = ""; // Create a new column (start with empty string) if necessary - } + for await (const chunk of stream) { + const str = chunk.toString(); + // Iterate over each character, keep track of current column (of the returned array) + for (let c = 0; c < str.length; ++c) { + let ch = str[c], + nch = str[c + 1]; // Current character, next character + if (!(col in arr)) { + arr[col] = ''; // Create a new column (start with empty string) if necessary + } - // If the current character is a quotation mark, and we're inside a - // quoted field, and the next character is also a quotation mark, - // add a quotation mark to the current column and skip the next character - if (ch == '"' && quote && nch == '"') { - arr[col] += ch; - ++c; - continue; - } + // If the current character is a quotation mark, and we're inside a + // quoted field, and the next character is also a quotation mark, + // add a quotation mark to the current column and skip the next character + if (ch == '"' && quote && nch == '"') { + arr[col] += ch; + ++c; + continue; + } - // If it's just one quotation mark, begin/end quoted field - if (ch == '"') { - quote = !quote; - continue; - } + // If it's just one quotation mark, begin/end quoted field + if (ch == '"') { + quote = !quote; + continue; + } - // If it's a comma and we're not in a quoted field, move on to the next column - if (ch == ',' && !quote) { - ++col; - continue; - } + // If it's a comma and we're not in a quoted field, move on to the next column + if (ch == ',' && !quote) { + ++col; + continue; + } - // If it's a newline (CRLF) and we're not in a quoted field, skip the next character - // and move on to the next row and move to column 0 of that new row - if (ch == '\r' && nch == '\n' && !quote) { - yield arr; - arr.length = 0; // Clear the row - col = 0; - ++c; - continue; - } + // If it's a newline (CRLF) and we're not in a quoted field, skip the next character + // and move on to the next row and move to column 0 of that new row + if (ch == '\r' && nch == '\n' && !quote) { + yield arr; + arr.length = 0; // Clear the row + col = 0; + ++c; + continue; + } - // If it's a newline (LF or CR) and we're not in a quoted field, - // move on to the next row and move to column 0 of that new row - if (!quote && (ch == '\r' || ch == '\n')) { - yield arr; - arr.length = 0; // Clear the row - col = 0; - continue; - } + // If it's a newline (LF or CR) and we're not in a quoted field, + // move on to the next row and move to column 0 of that new row + if (!quote && (ch == '\r' || ch == '\n')) { + yield arr; + arr.length = 0; // Clear the row + col = 0; + continue; + } - // Otherwise, append the current character to the current column - arr[col] += ch; - } - } - } + // Otherwise, append the current character to the current column + arr[col] += ch; + } + } + } } -const dir = path.join(process.cwd(), "data"); +const dir = path.join(process.cwd(), 'data'); export const DbcFiles = { - achievement: path.join(dir, "Achievement_3.3.5_12340.csv"), - achievementCategory: path.join(dir, "AchievementCategory_3.3.5_12340.csv"), - glyphProperties: path.join(dir, "GlyphProperties_3.3.5_12340.csv"), - item: path.join(dir, "Item_3.3.5_12340.csv"), - itemRetail: path.join(dir, "Item_9.2.0_41462.csv"), - itemAppearance: path.join(dir, "ItemAppearance_9.2.0_41462.csv"), - itemModifiedAppearance: path.join(dir, "ItemModifiedAppearance_9.2.0_41462.csv"), - itemDisplayInfo: path.join(dir, "ItemDisplayInfo_3.3.5_12340.csv"), - mount: path.join(dir, "Mount_9.2.0_41462.csv"), - mountDisplay: path.join(dir, "MountXDisplay_9.2.0_41462.csv"), - spell: path.join(dir, "Spell_3.3.5_12340.csv"), - spellItemEnchantment: path.join(dir, "SpellItemEnchantment_3.3.5_12340.csv"), - spellIcon: path.join(dir, "SpellIcon_3.3.5_12340.csv"), - talent: path.join(dir, "Talent_3.3.5_12340.csv"), - talentTab: path.join(dir, "TalentTab_3.3.5_12340.csv"), + achievement: path.join(dir, 'Achievement_3.3.5_12340.csv'), + achievementCategory: path.join(dir, 'AchievementCategory_3.3.5_12340.csv'), + glyphProperties: path.join(dir, 'GlyphProperties_3.3.5_12340.csv'), + item: path.join(dir, 'Item_3.3.5_12340.csv'), + itemRetail: path.join(dir, 'Item_9.2.0_41462.csv'), + itemAppearance: path.join(dir, 'ItemAppearance_9.2.0_41462.csv'), + itemModifiedAppearance: path.join(dir, 'ItemModifiedAppearance_9.2.0_41462.csv'), + itemDisplayInfo: path.join(dir, 'ItemDisplayInfo_3.3.5_12340.csv'), + mount: path.join(dir, 'Mount_9.2.0_41462.csv'), + mountDisplay: path.join(dir, 'MountXDisplay_9.2.0_41462.csv'), + spell: path.join(dir, 'Spell_3.3.5_12340.csv'), + spellItemEnchantment: path.join(dir, 'SpellItemEnchantment_3.3.5_12340.csv'), + spellIcon: path.join(dir, 'SpellIcon_3.3.5_12340.csv'), + talent: path.join(dir, 'Talent_3.3.5_12340.csv'), + talentTab: path.join(dir, 'TalentTab_3.3.5_12340.csv'), }; const dbcFields = { - achievement: ["id", "faction", "titleLang0", "descriptionLang0", "category", "points", "flags", "iconId"], - achievementCategory: ["id", "parent", "nameLang0"], - glyphProperties: ["id", "spellId"], - item: ["id", "classId", "subclassId", "displayInfoId", "inventoryType"], - itemRetail: ["id", "inventoryType"], - itemAppearance: ["id", "itemDisplayInfoId"], - itemModifiedAppearance: ["id", "itemId", "itemAppearanceId"], - itemDisplayInfo: ["id", "inventoryIcon0"], - mount: ["id", "sourceSpellId"], - mountDisplay: ["id", "creatureDisplayInfoId", "mountId"], - spell: ["id", "mechanic", "spellIconId"], - spellItemEnchantment: ["id", "srcItemId"], - spellIcon: ["id", "textureFilename"], - talent: ["id", "tabId", "tierId", "columnIndex", "spellRank0", "spellRank1", "spellRank2", "spellRank3", "spellRank4", "prereqTalent0", "prereqRank0"], - talentTab: ["id", "nameLang0", "spellIconId", "classMask"], + achievement: ['id', 'faction', 'titleLang0', 'descriptionLang0', 'category', 'points', 'flags', 'iconId'], + achievementCategory: ['id', 'parent', 'nameLang0'], + glyphProperties: ['id', 'spellId'], + item: ['id', 'classId', 'subclassId', 'displayInfoId', 'inventoryType'], + itemRetail: ['id', 'inventoryType'], + itemAppearance: ['id', 'itemDisplayInfoId'], + itemModifiedAppearance: ['id', 'itemId', 'itemAppearanceId'], + itemDisplayInfo: ['id', 'inventoryIcon0'], + mount: ['id', 'sourceSpellId'], + mountDisplay: ['id', 'creatureDisplayInfoId', 'mountId'], + spell: ['id', 'mechanic', 'spellIconId'], + spellItemEnchantment: ['id', 'srcItemId'], + spellIcon: ['id', 'textureFilename'], + talent: [ + 'id', + 'tabId', + 'tierId', + 'columnIndex', + 'spellRank0', + 'spellRank1', + 'spellRank2', + 'spellRank3', + 'spellRank4', + 'prereqTalent0', + 'prereqRank0', + ], + talentTab: ['id', 'nameLang0', 'spellIconId', 'classMask'], }; export class DbcManager { - private _achievement: IAchievement[]; - private _achievementCategory: IAchievementCategory[]; - private _glyphProperties: IGlyphProperties[]; - private _item: IItemDbc[]; - private _itemRetail: IItemRetailDbc[]; - private _itemAppearance: IItemAppearanceDbc[]; - private _itemModifiedAppearance: IItemModifiedAppearanceDbc[]; - private _itemDisplayInfo: IItemDisplayInfoDbc[]; - private _mount: IMountDbc[]; - private _mountDisplay: IMountXDisplayDbc[]; - private _spell: ISpellDbc[]; - private _spellItemEnchantment: ISpellItemEnchantmentDbc[]; - private _spellIcon: ISpellIcon[]; - private _talent: ITalent[]; - private _talentTab: ITalentTab[]; + private _achievement: IAchievement[]; + private _achievementCategory: IAchievementCategory[]; + private _glyphProperties: IGlyphProperties[]; + private _item: IItemDbc[]; + private _itemRetail: IItemRetailDbc[]; + private _itemAppearance: IItemAppearanceDbc[]; + private _itemModifiedAppearance: IItemModifiedAppearanceDbc[]; + private _itemDisplayInfo: IItemDisplayInfoDbc[]; + private _mount: IMountDbc[]; + private _mountDisplay: IMountXDisplayDbc[]; + private _spell: ISpellDbc[]; + private _spellItemEnchantment: ISpellItemEnchantmentDbc[]; + private _spellIcon: ISpellIcon[]; + private _talent: ITalent[]; + private _talentTab: ITalentTab[]; - public async loadAllFiles(): Promise { - this._achievement = await this.read(DbcFiles.achievement, dbcFields.achievement).toArray(); - this._achievementCategory = await this.read(DbcFiles.achievementCategory, dbcFields.achievementCategory).toArray(); - this._glyphProperties = await this.read(DbcFiles.glyphProperties, dbcFields.glyphProperties).toArray(); - this._item = await this.read(DbcFiles.item, dbcFields.item).toArray(); - this._itemRetail = await this.read(DbcFiles.itemRetail, dbcFields.itemRetail).toArray(); - this._itemAppearance = await this.read(DbcFiles.itemAppearance, dbcFields.itemAppearance).toArray(); - this._itemModifiedAppearance = await this.read(DbcFiles.itemModifiedAppearance, dbcFields.itemModifiedAppearance).toArray(); - this._itemDisplayInfo = await this.read(DbcFiles.itemDisplayInfo, dbcFields.itemDisplayInfo).toArray(); - this._mount = await this.read(DbcFiles.mount, dbcFields.mount).toArray(); - this._mountDisplay = await this.read(DbcFiles.mountDisplay, dbcFields.mountDisplay).toArray(); - this._spell = await this.read(DbcFiles.spell, dbcFields.spell).toArray(); - this._spellItemEnchantment = await this.read(DbcFiles.spellItemEnchantment, dbcFields.spellItemEnchantment).toArray(); - this._spellIcon = await this.read(DbcFiles.spellIcon, dbcFields.spellIcon).toArray(); - this._talent = await this.read(DbcFiles.talent, dbcFields.talent).toArray(); - this._talentTab = await this.read(DbcFiles.talentTab, dbcFields.talentTab).toArray(); - } + public async loadAllFiles(): Promise { + this._achievement = await this.read(DbcFiles.achievement, dbcFields.achievement).toArray(); + this._achievementCategory = await this.read( + DbcFiles.achievementCategory, + dbcFields.achievementCategory, + ).toArray(); + this._glyphProperties = await this.read(DbcFiles.glyphProperties, dbcFields.glyphProperties).toArray(); + this._item = await this.read(DbcFiles.item, dbcFields.item).toArray(); + this._itemRetail = await this.read(DbcFiles.itemRetail, dbcFields.itemRetail).toArray(); + this._itemAppearance = await this.read(DbcFiles.itemAppearance, dbcFields.itemAppearance).toArray(); + this._itemModifiedAppearance = await this.read( + DbcFiles.itemModifiedAppearance, + dbcFields.itemModifiedAppearance, + ).toArray(); + this._itemDisplayInfo = await this.read(DbcFiles.itemDisplayInfo, dbcFields.itemDisplayInfo).toArray(); + this._mount = await this.read(DbcFiles.mount, dbcFields.mount).toArray(); + this._mountDisplay = await this.read(DbcFiles.mountDisplay, dbcFields.mountDisplay).toArray(); + this._spell = await this.read(DbcFiles.spell, dbcFields.spell).toArray(); + this._spellItemEnchantment = await this.read( + DbcFiles.spellItemEnchantment, + dbcFields.spellItemEnchantment, + ).toArray(); + this._spellIcon = await this.read(DbcFiles.spellIcon, dbcFields.spellIcon).toArray(); + this._talent = await this.read(DbcFiles.talent, dbcFields.talent).toArray(); + this._talentTab = await this.read(DbcFiles.talentTab, dbcFields.talentTab).toArray(); + } - public achievement() { - return this.getLoadedDataOrRead(DbcFiles.achievement, this._achievement, dbcFields.achievement); - } + public achievement() { + return this.getLoadedDataOrRead(DbcFiles.achievement, this._achievement, dbcFields.achievement); + } - public achievementCategory() { - return this.getLoadedDataOrRead(DbcFiles.achievementCategory, this._achievementCategory, dbcFields.achievementCategory); - } + public achievementCategory() { + return this.getLoadedDataOrRead(DbcFiles.achievementCategory, this._achievementCategory, dbcFields.achievementCategory); + } - public glyphProperties() { - return this.getLoadedDataOrRead(DbcFiles.glyphProperties, this._glyphProperties, dbcFields.glyphProperties); - } + public glyphProperties() { + return this.getLoadedDataOrRead(DbcFiles.glyphProperties, this._glyphProperties, dbcFields.glyphProperties); + } - public item() { - return this.getLoadedDataOrRead(DbcFiles.item, this._item, dbcFields.item); - } + public item() { + return this.getLoadedDataOrRead(DbcFiles.item, this._item, dbcFields.item); + } - public itemRetail() { - return this.getLoadedDataOrRead(DbcFiles.itemRetail, this._itemRetail, dbcFields.itemRetail); - } + public itemRetail() { + return this.getLoadedDataOrRead(DbcFiles.itemRetail, this._itemRetail, dbcFields.itemRetail); + } - public itemAppearance() { - return this.getLoadedDataOrRead(DbcFiles.itemAppearance, this._itemAppearance, dbcFields.itemAppearance); - } + public itemAppearance() { + return this.getLoadedDataOrRead(DbcFiles.itemAppearance, this._itemAppearance, dbcFields.itemAppearance); + } - public itemModifiedAppearance() { - return this.getLoadedDataOrRead(DbcFiles.itemModifiedAppearance, this._itemModifiedAppearance, dbcFields.itemModifiedAppearance); - } + public itemModifiedAppearance() { + return this.getLoadedDataOrRead(DbcFiles.itemModifiedAppearance, this._itemModifiedAppearance, dbcFields.itemModifiedAppearance); + } - public itemDisplayInfo() { - return this.getLoadedDataOrRead(DbcFiles.itemDisplayInfo, this._itemDisplayInfo, dbcFields.itemDisplayInfo); - } + public itemDisplayInfo() { + return this.getLoadedDataOrRead(DbcFiles.itemDisplayInfo, this._itemDisplayInfo, dbcFields.itemDisplayInfo); + } - public mount() { - return this.getLoadedDataOrRead(DbcFiles.mount, this._mount, dbcFields.mount); - } + public mount() { + return this.getLoadedDataOrRead(DbcFiles.mount, this._mount, dbcFields.mount); + } - public mountDisplay() { - return this.getLoadedDataOrRead(DbcFiles.mountDisplay, this._mountDisplay, dbcFields.mountDisplay); - } + public mountDisplay() { + return this.getLoadedDataOrRead(DbcFiles.mountDisplay, this._mountDisplay, dbcFields.mountDisplay); + } - public spell() { - return this.getLoadedDataOrRead(DbcFiles.spell, this._spell, dbcFields.spell); - } + public spell() { + return this.getLoadedDataOrRead(DbcFiles.spell, this._spell, dbcFields.spell); + } - public spellItemEnchantment() { - return this.getLoadedDataOrRead(DbcFiles.spellItemEnchantment, this._spellItemEnchantment, dbcFields.spellItemEnchantment); - } + public spellItemEnchantment() { + return this.getLoadedDataOrRead(DbcFiles.spellItemEnchantment, this._spellItemEnchantment, dbcFields.spellItemEnchantment); + } - public spellIcon() { - return this.getLoadedDataOrRead(DbcFiles.spellIcon, this._spellIcon, dbcFields.spellIcon); - } + public spellIcon() { + return this.getLoadedDataOrRead(DbcFiles.spellIcon, this._spellIcon, dbcFields.spellIcon); + } - public talent() { - return this.getLoadedDataOrRead(DbcFiles.talent, this._talent, dbcFields.talent); - } + public talent() { + return this.getLoadedDataOrRead(DbcFiles.talent, this._talent, dbcFields.talent); + } - public talentTab() { - return this.getLoadedDataOrRead(DbcFiles.talentTab, this._talentTab, dbcFields.talentTab); - } + public talentTab() { + return this.getLoadedDataOrRead(DbcFiles.talentTab, this._talentTab, dbcFields.talentTab); + } - private read(file: string, keepFields: string[] = []): AsyncGenWrapper { - const reader = new DbcReader(file, keepFields); - return new AsyncGenWrapper(reader.read()); - } + private read(file: string, keepFields: string[] = []): AsyncGenWrapper { + const reader = new DbcReader(file, keepFields); + return new AsyncGenWrapper(reader.read()); + } - private getLoadedDataOrRead(path: string, data: T[], keepFields: string[] = []): IAsyncGeneratorWithArrayMethods { - return data === undefined ? this.read(path, keepFields) : new ArrayAsAsyncGenerator(data); - } + private getLoadedDataOrRead(path: string, data: T[], keepFields: string[] = []): IAsyncGeneratorWithArrayMethods { + return data === undefined ? this.read(path, keepFields) : new ArrayAsAsyncGenerator(data); + } } diff --git a/src/armory/main.ts b/src/armory/main.ts index cc8312e..d4e88ba 100644 --- a/src/armory/main.ts +++ b/src/armory/main.ts @@ -1,11 +1,11 @@ -import "dotenv/config"; -import { Armory } from "./Armory"; +import 'dotenv/config'; +import { Armory } from './Armory'; async function main(): Promise { - require("source-map-support").install(); + require('source-map-support').install(); - const armory = new Armory(); - await armory.start(); + const armory = new Armory(); + await armory.start(); } main(); diff --git a/src/index.d.ts b/src/index.d.ts index b862ee6..5f9d2e4 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,5 +1,5 @@ declare module Express { - export interface Request { - id: string; - } + export interface Request { + id: string; + } } diff --git a/src/tools/fetchdata.ts b/src/tools/fetchdata.ts index 9e6b412..e0c6181 100644 --- a/src/tools/fetchdata.ts +++ b/src/tools/fetchdata.ts @@ -1,76 +1,79 @@ -import * as fs from "fs"; +import * as fs from 'fs'; const fsp = fs.promises; -import * as path from "path"; +import * as path from 'path'; -import * as pako from "pako"; -import fetch from "node-fetch"; -import * as mkdirp from "mkdirp"; -import * as glob from "glob-promise"; -import { Response } from "node-fetch"; -import * as prettyMs from "pretty-ms"; -import * as cliProgress from "cli-progress"; -import promisepool = require("@supercharge/promise-pool"); +import * as pako from 'pako'; +import fetch from 'node-fetch'; +import * as mkdirp from 'mkdirp'; +import * as glob from 'glob-promise'; +import { Response } from 'node-fetch'; +import * as prettyMs from 'pretty-ms'; +import * as cliProgress from 'cli-progress'; +import promisepool = require('@supercharge/promise-pool'); -import { DbcManager, IItemAppearanceDbc, IItemModifiedAppearanceDbc, IMountDbc, IMountXDisplayDbc } from "../armory/data/DbcReader"; +import { DbcManager, IItemAppearanceDbc, IItemModifiedAppearanceDbc, IMountDbc, IMountXDisplayDbc } from '../armory/data/DbcReader'; -require("source-map-support").install(); +require('source-map-support').install(); -const baseUrl = "https://wow.zamimg.com/modelviewer/live"; +const baseUrl = 'https://wow.zamimg.com/modelviewer/live'; class Stopwatch { - private startTime: number; + private startTime: number; - public constructor() { - this.start(); - } + public constructor() { + this.start(); + } - public start(): void { - this.startTime = Date.now(); - } + public start(): void { + this.startTime = Date.now(); + } - public stop(text?: string): void { - const dt = Date.now() - this.startTime; - const txt = text ?? "Done in {time}"; - console.log(txt.replace("{time}", prettyMs(dt))); - } + public stop(text?: string): void { + const dt = Date.now() - this.startTime; + const txt = text ?? 'Done in {time}'; + console.log(txt.replace('{time}', prettyMs(dt))); + } } class Progress { - private bar: cliProgress.SingleBar; - private stopwatch: Stopwatch; + private bar: cliProgress.SingleBar; + private stopwatch: Stopwatch; - public constructor(text: string, operations: number) { - this.bar = this.createProgressBar(text, operations); - this.stopwatch = new Stopwatch(); - } + public constructor(text: string, operations: number) { + this.bar = this.createProgressBar(text, operations); + this.stopwatch = new Stopwatch(); + } - public increment(step?: number): void { - this.bar.increment(step); - } + public increment(step?: number): void { + this.bar.increment(step); + } - public stop(): void { - this.bar.stop(); - this.stopwatch.stop(); - } + public stop(): void { + this.bar.stop(); + this.stopwatch.stop(); + } - private createProgressBar(text: string, total: number): cliProgress.SingleBar { - const progress = new cliProgress.SingleBar({ - format: `${text} {bar} {percentage}% ({value} / {total})`, - }, cliProgress.Presets.shades_classic); - progress.start(total, 0); - return progress; - } + private createProgressBar(text: string, total: number): cliProgress.SingleBar { + const progress = new cliProgress.SingleBar( + { + format: `${text} {bar} {percentage}% ({value} / {total})`, + }, + cliProgress.Presets.shades_classic, + ); + progress.start(total, 0); + return progress; + } } class HttpRequestError extends Error { - public response: Response; + public response: Response; - public constructor(response: Response) { - super(`Could not download ${response.url} (${response.status})`); - this.name = "HttpRequestError"; - this.response = response; - Object.setPrototypeOf(this, HttpRequestError.prototype); - } + public constructor(response: Response) { + super(`Could not download ${response.url} (${response.status})`); + this.name = 'HttpRequestError'; + this.response = response; + Object.setPrototypeOf(this, HttpRequestError.prototype); + } } let dbc: DbcManager; @@ -90,345 +93,339 @@ const texturesDownloadQueue = new Set(); const bonesDownloadQueue = new Set(); async function download(dir: string, file: string): Promise { - const dataDir = path.join(process.cwd(), "data"); - const fullPath = `${dir}/${file}`; + const dataDir = path.join(process.cwd(), 'data'); + const fullPath = `${dir}/${file}`; - try { - const res = await fetch(`${baseUrl}/${fullPath}`); - if (res.status !== 200) { - throw new HttpRequestError(res); - } + try { + const res = await fetch(`${baseUrl}/${fullPath}`); + if (res.status !== 200) { + throw new HttpRequestError(res); + } - await mkdirp(path.join(dataDir, dir)); + await mkdirp(path.join(dataDir, dir)); - if (res.headers.get("Content-Type") === "application/json") { - const json = await res.json(); - fsp.writeFile(path.join(dataDir, fullPath), JSON.stringify(json)); - return json; - } else { - const fileStream = fs.createWriteStream(path.join(dataDir, fullPath)); - await new Promise((resolve, rej) => { - res.body.pipe(fileStream); - res.body.on("error", rej); - fileStream.on("finish", resolve); - }); + if (res.headers.get('Content-Type') === 'application/json') { + const json = await res.json(); + fsp.writeFile(path.join(dataDir, fullPath), JSON.stringify(json)); + return json; + } else { + const fileStream = fs.createWriteStream(path.join(dataDir, fullPath)); + await new Promise((resolve, rej) => { + res.body.pipe(fileStream); + res.body.on('error', rej); + fileStream.on('finish', resolve); + }); - return fileStream.path.toString(); - } - } catch (err) { - throw err; - } + return fileStream.path.toString(); + } + } catch (err) { + throw err; + } } function queueTexturesAndModels(item: any): void { - if (item.TextureFiles !== null) { - for (const key in item.TextureFiles) { - for (const file of item.TextureFiles[key]) { - if (file.FileDataId !== 0) { - texturesDownloadQueue.add(file.FileDataId); - } - } - } - } + if (item.TextureFiles !== null) { + for (const key in item.TextureFiles) { + for (const file of item.TextureFiles[key]) { + if (file.FileDataId !== 0) { + texturesDownloadQueue.add(file.FileDataId); + } + } + } + } - if (item.ModelFiles !== null) { - for (const key in item.ModelFiles) { - for (const file of item.ModelFiles[key]) { - if (file.FileDataId !== 0) { - modelsDownloadQueue.add(file.FileDataId); - } - } - } - } + if (item.ModelFiles !== null) { + for (const key in item.ModelFiles) { + for (const file of item.ModelFiles[key]) { + if (file.FileDataId !== 0) { + modelsDownloadQueue.add(file.FileDataId); + } + } + } + } - if (typeof item.Model === "number" && item.Model !== 0) { - modelsDownloadQueue.add(item.Model); - } + if (typeof item.Model === 'number' && item.Model !== 0) { + modelsDownloadQueue.add(item.Model); + } - if (item.Textures !== null) { - for (const key in item.Textures) { - if (item.Textures[key] !== 0) { - texturesDownloadQueue.add(item.Textures[key]); - } - } - } + if (item.Textures !== null) { + for (const key in item.Textures) { + if (item.Textures[key] !== 0) { + texturesDownloadQueue.add(item.Textures[key]); + } + } + } - if (item.Textures2 !== null) { - for (const key in item.Textures2) { - if (item.Textures2[key] !== 0) { - texturesDownloadQueue.add(item.Textures2[key]); - } - } - } + if (item.Textures2 !== null) { + for (const key in item.Textures2) { + if (item.Textures2[key] !== 0) { + texturesDownloadQueue.add(item.Textures2[key]); + } + } + } } async function downloadRaces(): Promise { - const races = [ - "human", - "nightelf", - "dwarf", - "gnome", - "draenei", - "orc", - "troll", - "tauren", - "bloodelf", - "scourge", - ]; - const genders = ["male", "female"]; - const raceGenderCombo = races.map((race) => [race + genders[0], race + genders[1]]).flat(); + const races = ['human', 'nightelf', 'dwarf', 'gnome', 'draenei', 'orc', 'troll', 'tauren', 'bloodelf', 'scourge']; + const genders = ['male', 'female']; + const raceGenderCombo = races.map((race) => [race + genders[0], race + genders[1]]).flat(); - const progress = new Progress("Downloading races data...", raceGenderCombo.length); + const progress = new Progress('Downloading races data...', raceGenderCombo.length); - await promisepool.PromisePool - .for(raceGenderCombo) - .withConcurrency(4) - .process(async (race) => { - const characterJson = await download("meta/character", `${race}.json`); - modelsDownloadQueue.add(characterJson.Model); + await promisepool.PromisePool.for(raceGenderCombo) + .withConcurrency(4) + .process(async (race) => { + const characterJson = await download('meta/character', `${race}.json`); + modelsDownloadQueue.add(characterJson.Model); - const customizationJson = await download("meta/charactercustomization2", `${characterJson.Race}_${characterJson.Gender}.json`); - for (const option of customizationJson.Options) { - for (const choice of option.Choices) { - for (const element of choice.Elements) { - if (element.SkinnedModel !== null && typeof element.SkinnedModel.CollectionFileDataID === "number" && element.SkinnedModel.CollectionFileDataID !== 0) { - modelsDownloadQueue.add(element.SkinnedModel.CollectionFileDataID); - } - if (element.BoneSet !== null && typeof element.BoneSet.BoneFileDataID === "number" && element.BoneSet.BoneFileDataID !== 0) { - bonesDownloadQueue.add(element.BoneSet.BoneFileDataID); - } - } - } - } + const customizationJson = await download('meta/charactercustomization2', `${characterJson.Race}_${characterJson.Gender}.json`); + for (const option of customizationJson.Options) { + for (const choice of option.Choices) { + for (const element of choice.Elements) { + if ( + element.SkinnedModel !== null && + typeof element.SkinnedModel.CollectionFileDataID === 'number' && + element.SkinnedModel.CollectionFileDataID !== 0 + ) { + modelsDownloadQueue.add(element.SkinnedModel.CollectionFileDataID); + } + if (element.BoneSet !== null && typeof element.BoneSet.BoneFileDataID === 'number' && element.BoneSet.BoneFileDataID !== 0) { + bonesDownloadQueue.add(element.BoneSet.BoneFileDataID); + } + } + } + } - const textureFiles = Object.keys(customizationJson.TextureFiles) - .map(key => customizationJson.TextureFiles[key]) - .flat(); - for (const file of textureFiles) { - texturesDownloadQueue.add(file.FileDataId); - } + const textureFiles = Object.keys(customizationJson.TextureFiles) + .map((key) => customizationJson.TextureFiles[key]) + .flat(); + for (const file of textureFiles) { + texturesDownloadQueue.add(file.FileDataId); + } - progress.increment(); - }); + progress.increment(); + }); - progress.stop(); + progress.stop(); } async function downloadArmors(): Promise { - const rows = await dbc.item().filter((row) => row.classId === classIdArmor).toArray(); + const rows = await dbc + .item() + .filter((row) => row.classId === classIdArmor) + .toArray(); - const progress = new Progress("Downloading armor data...", rows.length); + const progress = new Progress('Downloading armor data...', rows.length); - await promisepool.PromisePool - .for(rows) - .withConcurrency(50) - .process(async (row) => { - const modifiedAppearance = dbcItemModifiedAppearanceByItemId[row.id]; - if (modifiedAppearance === undefined) { - progress.increment(); - return; - } - const appearance = dbcItemAppearanceById[modifiedAppearance.itemAppearanceId]; - const metaPath = [invTypeShield, invTypeOffHand].includes(row.inventoryType) ? "item" : `armor/${row.inventoryType}`; - try { - const itemJson = await download(`meta/${metaPath}`, `${appearance.itemDisplayInfoId}.json`); - queueTexturesAndModels(itemJson); - progress.increment(); - } catch (err) { - if (err instanceof HttpRequestError && err.response.status === 404) { - progress.increment(); - return; - } - throw err; - } - }); + await promisepool.PromisePool.for(rows) + .withConcurrency(50) + .process(async (row) => { + const modifiedAppearance = dbcItemModifiedAppearanceByItemId[row.id]; + if (modifiedAppearance === undefined) { + progress.increment(); + return; + } + const appearance = dbcItemAppearanceById[modifiedAppearance.itemAppearanceId]; + const metaPath = [invTypeShield, invTypeOffHand].includes(row.inventoryType) ? 'item' : `armor/${row.inventoryType}`; + try { + const itemJson = await download(`meta/${metaPath}`, `${appearance.itemDisplayInfoId}.json`); + queueTexturesAndModels(itemJson); + progress.increment(); + } catch (err) { + if (err instanceof HttpRequestError && err.response.status === 404) { + progress.increment(); + return; + } + throw err; + } + }); - progress.stop(); + progress.stop(); } async function downloadWeapons(): Promise { - const rows = await dbc.item().filter((row) => row.classId === classIdWeapon).toArray(); + const rows = await dbc + .item() + .filter((row) => row.classId === classIdWeapon) + .toArray(); - const progress = new Progress("Downloading weapon data...", rows.length); + const progress = new Progress('Downloading weapon data...', rows.length); - await promisepool.PromisePool - .for(rows) - .withConcurrency(50) - .process(async (row) => { - const modifiedAppearance = dbcItemModifiedAppearanceByItemId[row.id]; - if (modifiedAppearance === undefined) { - progress.increment(); - return; - } - const appearance = dbcItemAppearanceById[modifiedAppearance.itemAppearanceId]; - try { - const itemJson = await download(`meta/item`, `${appearance.itemDisplayInfoId}.json`); - queueTexturesAndModels(itemJson); - progress.increment(); - } catch (err) { - if (err instanceof HttpRequestError && err.response.status === 404) { - progress.increment(); - return; - } - throw err; - } - }); + await promisepool.PromisePool.for(rows) + .withConcurrency(50) + .process(async (row) => { + const modifiedAppearance = dbcItemModifiedAppearanceByItemId[row.id]; + if (modifiedAppearance === undefined) { + progress.increment(); + return; + } + const appearance = dbcItemAppearanceById[modifiedAppearance.itemAppearanceId]; + try { + const itemJson = await download(`meta/item`, `${appearance.itemDisplayInfoId}.json`); + queueTexturesAndModels(itemJson); + progress.increment(); + } catch (err) { + if (err instanceof HttpRequestError && err.response.status === 404) { + progress.increment(); + return; + } + throw err; + } + }); - progress.stop(); + progress.stop(); } async function readDbcData(): Promise { - console.log("Reading DBC data..."); + console.log('Reading DBC data...'); - dbc = new DbcManager(); - await dbc.loadAllFiles(); + dbc = new DbcManager(); + await dbc.loadAllFiles(); - dbcItemAppearanceById = {}; - for await (const row of dbc.itemAppearance()) { - dbcItemAppearanceById[row.id] = row; - } + dbcItemAppearanceById = {}; + for await (const row of dbc.itemAppearance()) { + dbcItemAppearanceById[row.id] = row; + } - dbcItemModifiedAppearanceByItemId = {}; - for await (const row of dbc.itemModifiedAppearance()) { - dbcItemModifiedAppearanceByItemId[row.itemId] = row; - } + dbcItemModifiedAppearanceByItemId = {}; + for await (const row of dbc.itemModifiedAppearance()) { + dbcItemModifiedAppearanceByItemId[row.itemId] = row; + } - dbcMountBySourceSpellId = {}; - for await (const row of dbc.mount()) { - dbcMountBySourceSpellId[row.sourceSpellId] = row; - } + dbcMountBySourceSpellId = {}; + for await (const row of dbc.mount()) { + dbcMountBySourceSpellId[row.sourceSpellId] = row; + } - dbcMountDisplayByMountId = {}; - for await (const row of dbc.mountDisplay()) { - if (!(row.mountId in dbcMountDisplayByMountId)) { - dbcMountDisplayByMountId[row.mountId] = row; - } - } + dbcMountDisplayByMountId = {}; + for await (const row of dbc.mountDisplay()) { + if (!(row.mountId in dbcMountDisplayByMountId)) { + dbcMountDisplayByMountId[row.mountId] = row; + } + } } async function downloadMounts(): Promise { - const mountSpells = await dbc.spell().filter(spell => spell.mechanic === spellMechanicMounted).toArray(); - const progress = new Progress("Downloading mount data...", mountSpells.length); + const mountSpells = await dbc + .spell() + .filter((spell) => spell.mechanic === spellMechanicMounted) + .toArray(); + const progress = new Progress('Downloading mount data...', mountSpells.length); - await promisepool.PromisePool - .for(mountSpells) - .withConcurrency(50) - .process(async (spell) => { - const mount = dbcMountBySourceSpellId[spell.id]; - if (mount === undefined) { - progress.increment(); - return; - } + await promisepool.PromisePool.for(mountSpells) + .withConcurrency(50) + .process(async (spell) => { + const mount = dbcMountBySourceSpellId[spell.id]; + if (mount === undefined) { + progress.increment(); + return; + } - const display = dbcMountDisplayByMountId[mount.id]; - const json = await download("meta/npc", `${display.creatureDisplayInfoId}.json`); - queueTexturesAndModels(json); + const display = dbcMountDisplayByMountId[mount.id]; + const json = await download('meta/npc', `${display.creatureDisplayInfoId}.json`); + queueTexturesAndModels(json); - progress.increment(); - }); + progress.increment(); + }); - progress.stop(); + progress.stop(); } async function downloadTextures(): Promise { - const progress = new Progress("Downloading textures...", texturesDownloadQueue.size); + const progress = new Progress('Downloading textures...', texturesDownloadQueue.size); - await promisepool.PromisePool - .for(Array.from(texturesDownloadQueue)) - .withConcurrency(25) - .process(async (fileDataId) => { - await download("textures", `${fileDataId}.png`); - progress.increment(); - }); + await promisepool.PromisePool.for(Array.from(texturesDownloadQueue)) + .withConcurrency(25) + .process(async (fileDataId) => { + await download('textures', `${fileDataId}.png`); + progress.increment(); + }); - progress.stop(); + progress.stop(); } async function downloadModels(): Promise { - const progress = new Progress("Downloading models...", modelsDownloadQueue.size); + const progress = new Progress('Downloading models...', modelsDownloadQueue.size); - await promisepool.PromisePool - .for(Array.from(modelsDownloadQueue)) - .withConcurrency(25) - .process(async (fileDataId) => { - await download("mo3", `${fileDataId}.mo3`); - progress.increment(); - }); + await promisepool.PromisePool.for(Array.from(modelsDownloadQueue)) + .withConcurrency(25) + .process(async (fileDataId) => { + await download('mo3', `${fileDataId}.mo3`); + progress.increment(); + }); - progress.stop(); + progress.stop(); } async function downloadBones(): Promise { - const progress = new Progress("Downloading bones...", bonesDownloadQueue.size); + const progress = new Progress('Downloading bones...', bonesDownloadQueue.size); - await promisepool.PromisePool - .for(Array.from(bonesDownloadQueue)) - .withConcurrency(25) - .process(async (fileDataId) => { - try { - await download("bone", `${fileDataId}.bone`); - progress.increment(); - } catch (err) { - if (err instanceof HttpRequestError && err.response.status === 404) { - progress.increment(); - return; - } - throw err; - } - }); + await promisepool.PromisePool.for(Array.from(bonesDownloadQueue)) + .withConcurrency(25) + .process(async (fileDataId) => { + try { + await download('bone', `${fileDataId}.bone`); + progress.increment(); + } catch (err) { + if (err instanceof HttpRequestError && err.response.status === 404) { + progress.increment(); + return; + } + throw err; + } + }); - progress.stop(); + progress.stop(); } async function parseModels(): Promise { - const files = await glob("data/mo3/*.mo3"); - const progress = new Progress("Reading model files for texture references...", files.length); + const files = await glob('data/mo3/*.mo3'); + const progress = new Progress('Reading model files for texture references...', files.length); - await promisepool.PromisePool - .for(files) - .withConcurrency(20) - .process(async (file) => { - const buffer = await fsp.readFile(file); + await promisepool.PromisePool.for(files) + .withConcurrency(20) + .process(async (file) => { + const buffer = await fsp.readFile(file); - const texturesOffset = buffer.readUInt32LE(60); - const uncompressedSize = buffer.readUInt32LE(112); - const compressedData = buffer.slice(116); - const data = Buffer.from(pako.inflate(compressedData)); - if (data.length !== uncompressedSize) { - throw `Unexpected data size ${data.length}, expected ${uncompressedSize}`; - } + const texturesOffset = buffer.readUInt32LE(60); + const uncompressedSize = buffer.readUInt32LE(112); + const compressedData = buffer.slice(116); + const data = Buffer.from(pako.inflate(compressedData)); + if (data.length !== uncompressedSize) { + throw `Unexpected data size ${data.length}, expected ${uncompressedSize}`; + } - const nbTextures = data.readInt32LE(texturesOffset); - let offset = texturesOffset + 4; - for (let i = 0; i < nbTextures; ++i) { - const textureId = data.readUInt32LE(offset + 4 + 4); - if (textureId !== 0) { - texturesDownloadQueue.add(textureId); - } + const nbTextures = data.readInt32LE(texturesOffset); + let offset = texturesOffset + 4; + for (let i = 0; i < nbTextures; ++i) { + const textureId = data.readUInt32LE(offset + 4 + 4); + if (textureId !== 0) { + texturesDownloadQueue.add(textureId); + } - offset += 4 + 4 + 4; - } + offset += 4 + 4 + 4; + } - progress.increment(); - }); + progress.increment(); + }); - progress.stop(); + progress.stop(); } async function main(): Promise { - const sw = new Stopwatch(); + const sw = new Stopwatch(); - await readDbcData(); - await downloadRaces(); // Download info for all races - await downloadArmors(); // Download info for all armors - await downloadWeapons(); // Download info for all weapons - await downloadMounts(); // Download info for all mounts - await downloadModels(); // Download all queued models - await parseModels(); // Read model files to find texture references - await downloadTextures(); // Download all queued textures - await downloadBones(); // Download all queued bones + await readDbcData(); + await downloadRaces(); // Download info for all races + await downloadArmors(); // Download info for all armors + await downloadWeapons(); // Download info for all weapons + await downloadMounts(); // Download info for all mounts + await downloadModels(); // Download all queued models + await parseModels(); // Read model files to find texture references + await downloadTextures(); // Download all queued textures + await downloadBones(); // Download all queued bones - sw.stop("Everything done in {time}"); + sw.stop('Everything done in {time}'); } main(); diff --git a/static/js/emblems.js b/static/js/emblems.js index ed1d9d3..8d278eb 100644 --- a/static/js/emblems.js +++ b/static/js/emblems.js @@ -1,112 +1,118 @@ function waitForEmblemImages($emblem) { - return Promise.all($emblem.find(".images img").map((idx, img) => { - return new Promise((res, rej) => { - if (img.complete) { - res(); - } else { - img.addEventListener("load", res); - img.addEventListener("error", rej); - } - }); - })); + return Promise.all( + $emblem.find('.images img').map((idx, img) => { + return new Promise((res, rej) => { + if (img.complete) { + res(); + } else { + img.addEventListener('load', res); + img.addEventListener('error', rej); + } + }); + }), + ); } function createGuildEmblem(emblem, el) { - const $emblem = $(el); - const canvas = $emblem.find("canvas")[0]; - const ctx = canvas.getContext("2d"); + const $emblem = $(el); + const canvas = $emblem.find('canvas')[0]; + const ctx = canvas.getContext('2d'); - const imgUrl = (type, section, value, value2) => `${handlebarsData.websiteRoot}/img/guild-emblems/${type}_${value}${value2 ? ("_" + value2) : ""}_T${section}_U.PNG`; + const imgUrl = (type, section, value, value2) => + `${handlebarsData.websiteRoot}/img/guild-emblems/${type}_${value}${value2 ? '_' + value2 : ''}_T${section}_U.PNG`; - const $images = $("
").addClass("images").appendTo($emblem); - const bgUpper = $("").attr("src", imgUrl("Background", "U", emblem.background)).appendTo($images)[0]; - const bgLower = $("").attr("src", imgUrl("Background", "L", emblem.background)).appendTo($images)[0]; - const iconUpper = $("").attr("src", imgUrl("Emblem", "U", emblem.icon, emblem.iconColor)).appendTo($images)[0]; - const iconLower = $("").attr("src", imgUrl("Emblem", "L", emblem.icon, emblem.iconColor)).appendTo($images)[0]; - const borderUpper = $("").attr("src", imgUrl("Border", "U", emblem.border, emblem.borderColor)).appendTo($images)[0]; - const borderLower = $("").attr("src", imgUrl("Border", "L", emblem.border, emblem.borderColor)).appendTo($images)[0]; + const $images = $('
').addClass('images').appendTo($emblem); + const bgUpper = $('').attr('src', imgUrl('Background', 'U', emblem.background)).appendTo($images)[0]; + const bgLower = $('').attr('src', imgUrl('Background', 'L', emblem.background)).appendTo($images)[0]; + const iconUpper = $('').attr('src', imgUrl('Emblem', 'U', emblem.icon, emblem.iconColor)).appendTo($images)[0]; + const iconLower = $('').attr('src', imgUrl('Emblem', 'L', emblem.icon, emblem.iconColor)).appendTo($images)[0]; + const borderUpper = $('').attr('src', imgUrl('Border', 'U', emblem.border, emblem.borderColor)).appendTo($images)[0]; + const borderLower = $('').attr('src', imgUrl('Border', 'L', emblem.border, emblem.borderColor)).appendTo($images)[0]; - const drawEmblemLayer = (ctx, layer) => { - const [upper, lower] = layer; + const drawEmblemLayer = (ctx, layer) => { + const [upper, lower] = layer; - const w = upper.width / 2; - const uh = upper.height; - const lh = lower.height; + const w = upper.width / 2; + const uh = upper.height; + const lh = lower.height; - ctx.drawImage(upper, 0, 0, w, uh, w, 0, w, uh); - ctx.drawImage(lower, 0, 0, w, lh, w, upper.height, w, lh); - ctx.save(); - ctx.scale(-1, 1); - ctx.drawImage(upper, 0, 0, w, uh, 0, 0, -w, uh); - ctx.drawImage(lower, 0, 0, w, lh, 0, upper.height, -w, lh); - ctx.restore(); - }; + ctx.drawImage(upper, 0, 0, w, uh, w, 0, w, uh); + ctx.drawImage(lower, 0, 0, w, lh, w, upper.height, w, lh); + ctx.save(); + ctx.scale(-1, 1); + ctx.drawImage(upper, 0, 0, w, uh, 0, 0, -w, uh); + ctx.drawImage(lower, 0, 0, w, lh, 0, upper.height, -w, lh); + ctx.restore(); + }; - waitForEmblemImages($emblem).then(() => { - ctx.beginPath(); - ctx.moveTo(0, 0); - ctx.lineTo(26, 0); - ctx.lineTo(64, 28); - ctx.lineTo(102, 0); - ctx.lineTo(128, 0); - ctx.lineTo(128, 96); - ctx.lineTo(0, 96); - ctx.closePath(); - ctx.clip(); - drawEmblemLayer(ctx, [bgUpper, bgLower]); - drawEmblemLayer(ctx, [iconUpper, iconLower]); - drawEmblemLayer(ctx, [borderUpper, borderLower]); - }); + waitForEmblemImages($emblem).then(() => { + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(26, 0); + ctx.lineTo(64, 28); + ctx.lineTo(102, 0); + ctx.lineTo(128, 0); + ctx.lineTo(128, 96); + ctx.lineTo(0, 96); + ctx.closePath(); + ctx.clip(); + drawEmblemLayer(ctx, [bgUpper, bgLower]); + drawEmblemLayer(ctx, [iconUpper, iconLower]); + drawEmblemLayer(ctx, [borderUpper, borderLower]); + }); } function createArenaEmblem(teamSize, emblem, el) { - const $emblem = $(el); - const canvas = $emblem.find("canvas")[0]; - const ctx = canvas.getContext("2d"); + const $emblem = $(el); + const canvas = $emblem.find('canvas')[0]; + const ctx = canvas.getContext('2d'); - const imgUrl = (teamSize, type, value) => `${handlebarsData.websiteRoot}/img/arena-banners/PVP-Banner${teamSize ? ("-" + teamSize) : ""}${type ? ("-" + type) : ""}${value ? ("-" + value) : ""}.PNG`; + const imgUrl = (teamSize, type, value) => + `${handlebarsData.websiteRoot}/img/arena-banners/PVP-Banner${teamSize ? '-' + teamSize : ''}${type ? '-' + type : ''}${ + value ? '-' + value : '' + }.PNG`; - const $images = $("
").addClass("images").appendTo($emblem); - const banner = $("").attr("src", imgUrl(teamSize)).appendTo($images)[0]; - const bannerCrop = $("").attr("src", imgUrl(teamSize, "Crop")).appendTo($images)[0]; - const border = $("").attr("src", imgUrl(teamSize, "Border", emblem.border)).appendTo($images)[0]; - const icon = $("").attr("src", imgUrl(undefined, "Emblem", emblem.icon)).appendTo($images)[0]; + const $images = $('
').addClass('images').appendTo($emblem); + const banner = $('').attr('src', imgUrl(teamSize)).appendTo($images)[0]; + const bannerCrop = $('').attr('src', imgUrl(teamSize, 'Crop')).appendTo($images)[0]; + const border = $('').attr('src', imgUrl(teamSize, 'Border', emblem.border)).appendTo($images)[0]; + const icon = $('').attr('src', imgUrl(undefined, 'Emblem', emblem.icon)).appendTo($images)[0]; - const colorToHex = (color) => "#" + parseInt(color).toString(16).substring(2); + const colorToHex = (color) => '#' + parseInt(color).toString(16).substring(2); - waitForEmblemImages($emblem).then(() => { - const srcH = 224; - const h = 128; - const w = (banner.width / srcH) * h; - const iconW = icon.width * 0.35; - const iconH = icon.height * 0.35; - ctx.drawImage(banner, 0, 0, banner.width, srcH, 0, 0, w, h); - ctx.drawImage(tintImage(bannerCrop, colorToHex(emblem.background)), 0, 0, banner.width, srcH, 0, 0, w, h); - ctx.drawImage(tintImage(border, colorToHex(emblem.borderColor)), 0, 0, border.width, srcH, 0, 0, w, h); - ctx.drawImage(tintImage(icon, colorToHex(emblem.iconColor)), w * 0.385 - iconW / 2, h * 0.325 - iconH / 2, iconW, iconH); - }); + waitForEmblemImages($emblem).then(() => { + const srcH = 224; + const h = 128; + const w = (banner.width / srcH) * h; + const iconW = icon.width * 0.35; + const iconH = icon.height * 0.35; + ctx.drawImage(banner, 0, 0, banner.width, srcH, 0, 0, w, h); + ctx.drawImage(tintImage(bannerCrop, colorToHex(emblem.background)), 0, 0, banner.width, srcH, 0, 0, w, h); + ctx.drawImage(tintImage(border, colorToHex(emblem.borderColor)), 0, 0, border.width, srcH, 0, 0, w, h); + ctx.drawImage(tintImage(icon, colorToHex(emblem.iconColor)), w * 0.385 - iconW / 2, h * 0.325 - iconH / 2, iconW, iconH); + }); } -const tintCanvas = document.createElement("canvas"); -const tintContext = tintCanvas.getContext("2d"); +const tintCanvas = document.createElement('canvas'); +const tintContext = tintCanvas.getContext('2d'); function tintImage(image, color, opacity = 1.0) { - const ctx = tintContext; + const ctx = tintContext; - ctx.canvas.width = image.width; - ctx.canvas.height = image.height; + ctx.canvas.width = image.width; + ctx.canvas.height = image.height; - // First draw the image to the buffer - ctx.drawImage(image, 0, 0); + // First draw the image to the buffer + ctx.drawImage(image, 0, 0); - // Multiply with a rectangle of the specified color - ctx.fillStyle = color; - ctx.globalCompositeOperation = "multiply"; - ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); + // Multiply with a rectangle of the specified color + ctx.fillStyle = color; + ctx.globalCompositeOperation = 'multiply'; + ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); - // Finally, fix masking issues and globalAlpha - ctx.globalAlpha = opacity; - ctx.globalCompositeOperation = "destination-in"; - ctx.drawImage(image, 0, 0); + // Finally, fix masking issues and globalAlpha + ctx.globalAlpha = opacity; + ctx.globalCompositeOperation = 'destination-in'; + ctx.drawImage(image, 0, 0); - return ctx.canvas; + return ctx.canvas; } diff --git a/static/js/sync-url.js b/static/js/sync-url.js index cb2401a..ae3845b 100644 --- a/static/js/sync-url.js +++ b/static/js/sync-url.js @@ -1,3 +1,6 @@ -window.parent.postMessage({ - url: window.location.pathname.replace(handlebarsData.websiteRoot, ""), -}, "*"); +window.parent.postMessage( + { + url: window.location.pathname.replace(handlebarsData.websiteRoot, ''), + }, + '*', +); diff --git a/static/js/viewer.min.js b/static/js/viewer.min.js index c430945..ca79573 100644 --- a/static/js/viewer.min.js +++ b/static/js/viewer.min.js @@ -1,2 +1,10203 @@ /*! For license information please see viewer.min.js.LICENSE.txt */ -(()=>{var t={591:(t,e,i)=>{"use strict";var r={};(0,i(236).assign)(r,i(555),i(843),i(619)),t.exports=r},555:(t,e,i)=>{"use strict";var r=i(405),n=i(236),a=i(373),s=i(898),o=i(292),l=Object.prototype.toString;function h(t){if(!(this instanceof h))return new h(t);this.options=n.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var i=r.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==i)throw new Error(s[i]);if(e.header&&r.deflateSetHeader(this.strm,e.header),e.dictionary){var u;if(u="string"==typeof e.dictionary?a.string2buf(e.dictionary):"[object ArrayBuffer]"===l.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,0!==(i=r.deflateSetDictionary(this.strm,u)))throw new Error(s[i]);this._dict_set=!0}}function u(t,e){var i=new h(e);if(i.push(t,!0),i.err)throw i.msg||s[i.err];return i.result}h.prototype.push=function(t,e){var i,s,o=this.strm,h=this.options.chunkSize;if(this.ended)return!1;s=e===~~e?e:!0===e?4:0,"string"==typeof t?o.input=a.string2buf(t):"[object ArrayBuffer]"===l.call(t)?o.input=new Uint8Array(t):o.input=t,o.next_in=0,o.avail_in=o.input.length;do{if(0===o.avail_out&&(o.output=new n.Buf8(h),o.next_out=0,o.avail_out=h),1!==(i=r.deflate(o,s))&&0!==i)return this.onEnd(i),this.ended=!0,!1;0!==o.avail_out&&(0!==o.avail_in||4!==s&&2!==s)||("string"===this.options.to?this.onData(a.buf2binstring(n.shrinkBuf(o.output,o.next_out))):this.onData(n.shrinkBuf(o.output,o.next_out)))}while((o.avail_in>0||0===o.avail_out)&&1!==i);return 4===s?(i=r.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,0===i):2!==s||(this.onEnd(0),o.avail_out=0,!0)},h.prototype.onData=function(t){this.chunks.push(t)},h.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Deflate=h,e.deflate=u,e.deflateRaw=function(t,e){return(e=e||{}).raw=!0,u(t,e)},e.gzip=function(t,e){return(e=e||{}).gzip=!0,u(t,e)}},843:(t,e,i)=>{"use strict";var r=i(948),n=i(236),a=i(373),s=i(619),o=i(898),l=i(292),h=i(401),u=Object.prototype.toString;function c(t){if(!(this instanceof c))return new c(t);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var i=r.inflateInit2(this.strm,e.windowBits);if(i!==s.Z_OK)throw new Error(o[i]);if(this.header=new h,r.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=a.string2buf(e.dictionary):"[object ArrayBuffer]"===u.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=r.inflateSetDictionary(this.strm,e.dictionary))!==s.Z_OK))throw new Error(o[i])}function f(t,e){var i=new c(e);if(i.push(t,!0),i.err)throw i.msg||o[i.err];return i.result}c.prototype.push=function(t,e){var i,o,l,h,c,f=this.strm,d=this.options.chunkSize,b=this.options.dictionary,g=!1;if(this.ended)return!1;o=e===~~e?e:!0===e?s.Z_FINISH:s.Z_NO_FLUSH,"string"==typeof t?f.input=a.binstring2buf(t):"[object ArrayBuffer]"===u.call(t)?f.input=new Uint8Array(t):f.input=t,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new n.Buf8(d),f.next_out=0,f.avail_out=d),(i=r.inflate(f,s.Z_NO_FLUSH))===s.Z_NEED_DICT&&b&&(i=r.inflateSetDictionary(this.strm,b)),i===s.Z_BUF_ERROR&&!0===g&&(i=s.Z_OK,g=!1),i!==s.Z_STREAM_END&&i!==s.Z_OK)return this.onEnd(i),this.ended=!0,!1;f.next_out&&(0!==f.avail_out&&i!==s.Z_STREAM_END&&(0!==f.avail_in||o!==s.Z_FINISH&&o!==s.Z_SYNC_FLUSH)||("string"===this.options.to?(l=a.utf8border(f.output,f.next_out),h=f.next_out-l,c=a.buf2string(f.output,l),f.next_out=h,f.avail_out=d-h,h&&n.arraySet(f.output,f.output,l,h,0),this.onData(c)):this.onData(n.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(g=!0)}while((f.avail_in>0||0===f.avail_out)&&i!==s.Z_STREAM_END);return i===s.Z_STREAM_END&&(o=s.Z_FINISH),o===s.Z_FINISH?(i=r.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===s.Z_OK):o!==s.Z_SYNC_FLUSH||(this.onEnd(s.Z_OK),f.avail_out=0,!0)},c.prototype.onData=function(t){this.chunks.push(t)},c.prototype.onEnd=function(t){t===s.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Inflate=c,e.inflate=f,e.inflateRaw=function(t,e){return(e=e||{}).raw=!0,f(t,e)},e.ungzip=f},236:(t,e)=>{"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var n in i)r(i,n)&&(t[n]=i[n])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var n={arraySet:function(t,e,i,r,n){if(e.subarray&&t.subarray)t.set(e.subarray(i,i+r),n);else for(var a=0;a{"use strict";var r=i(236),n=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch(t){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){a=!1}for(var s=new r.Buf8(256),o=0;o<256;o++)s[o]=o>=252?6:o>=248?5:o>=240?4:o>=224?3:o>=192?2:1;function l(t,e){if(e<65534&&(t.subarray&&a||!t.subarray&&n))return String.fromCharCode.apply(null,r.shrinkBuf(t,e));for(var i="",s=0;s>>6,e[s++]=128|63&i):i<65536?(e[s++]=224|i>>>12,e[s++]=128|i>>>6&63,e[s++]=128|63&i):(e[s++]=240|i>>>18,e[s++]=128|i>>>12&63,e[s++]=128|i>>>6&63,e[s++]=128|63&i);return e},e.buf2binstring=function(t){return l(t,t.length)},e.binstring2buf=function(t){for(var e=new r.Buf8(t.length),i=0,n=e.length;i4)h[r++]=65533,i+=a-1;else{for(n&=2===a?31:3===a?15:7;a>1&&i1?h[r++]=65533:n<65536?h[r++]=n:(n-=65536,h[r++]=55296|n>>10&1023,h[r++]=56320|1023&n)}return l(h,r)},e.utf8border=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+s[t[i]]>e?i:e}},69:t=>{"use strict";t.exports=function(t,e,i,r){for(var n=65535&t|0,a=t>>>16&65535|0,s=0;0!==i;){i-=s=i>2e3?2e3:i;do{a=a+(n=n+e[r++]|0)|0}while(--s);n%=65521,a%=65521}return n|a<<16|0}},619:t=>{"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},869:t=>{"use strict";var e=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();t.exports=function(t,i,r,n){var a=e,s=n+r;t^=-1;for(var o=n;o>>8^a[255&(t^i[o])];return-1^t}},405:(t,e,i)=>{"use strict";var r,n=i(236),a=i(342),s=i(69),o=i(869),l=i(898),h=-2,u=258,c=262,f=103,d=113,b=666;function g(t,e){return t.msg=l[e],e}function _(t){return(t<<1)-(t>4?9:0)}function p(t){for(var e=t.length;--e>=0;)t[e]=0}function m(t){var e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(n.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function v(t,e){a._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,m(t.strm)}function x(t,e){t.pending_buf[t.pending++]=e}function T(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function w(t,e){var i,r,n=t.max_chain_length,a=t.strstart,s=t.prev_length,o=t.nice_match,l=t.strstart>t.w_size-c?t.strstart-(t.w_size-c):0,h=t.window,f=t.w_mask,d=t.prev,b=t.strstart+u,g=h[a+s-1],_=h[a+s];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(h[(i=e)+s]===_&&h[i+s-1]===g&&h[i]===h[a]&&h[++i]===h[a+1]){a+=2,i++;do{}while(h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&h[++a]===h[++i]&&as){if(t.match_start=e,s=r,r>=o)break;g=h[a+s-1],_=h[a+s]}}}while((e=d[e&f])>l&&0!=--n);return s<=t.lookahead?s:t.lookahead}function y(t){var e,i,r,a,l,h,u,f,d,b,g=t.w_size;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=g+(g-c)){n.arraySet(t.window,t.window,g,g,0),t.match_start-=g,t.strstart-=g,t.block_start-=g,e=i=t.hash_size;do{r=t.head[--e],t.head[e]=r>=g?r-g:0}while(--i);e=i=g;do{r=t.prev[--e],t.prev[e]=r>=g?r-g:0}while(--i);a+=g}if(0===t.strm.avail_in)break;if(h=t.strm,u=t.window,f=t.strstart+t.lookahead,d=a,b=void 0,(b=h.avail_in)>d&&(b=d),i=0===b?0:(h.avail_in-=b,n.arraySet(u,h.input,h.next_in,b,f),1===h.state.wrap?h.adler=s(h.adler,u,b,f):2===h.state.wrap&&(h.adler=o(h.adler,u,b,f)),h.next_in+=b,h.total_in+=b,b),t.lookahead+=i,t.lookahead+t.insert>=3)for(l=t.strstart-t.insert,t.ins_h=t.window[l],t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3)if(r=a._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,r=a._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=(t.ins_h<15&&(o=2,r-=16),a<1||a>9||8!==i||r<8||r>15||e<0||e>9||s<0||s>4)return g(t,h);8===r&&(r=9);var l=new S;return t.state=l,l.strm=t,l.wrap=o,l.gzhead=null,l.w_bits=r,l.w_size=1<t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(y(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+i;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,v(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-c&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(v(t,!1),t.strm.avail_out),1)})),new C(4,4,8,4,A),new C(4,5,16,8,A),new C(4,6,32,32,A),new C(4,4,16,16,E),new C(8,16,32,32,E),new C(8,16,128,128,E),new C(8,32,128,256,E),new C(32,128,258,1024,E),new C(32,258,258,4096,E)],e.deflateInit=function(t,e){return F(t,e,8,15,8,0)},e.deflateInit2=F,e.deflateReset=k,e.deflateResetKeep=M,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?h:(t.state.gzhead=e,0):h},e.deflate=function(t,e){var i,n,s,l;if(!t||!t.state||e>5||e<0)return t?g(t,h):h;if(n=t.state,!t.output||!t.input&&0!==t.avail_in||n.status===b&&4!==e)return g(t,0===t.avail_out?-5:h);if(n.strm=t,i=n.last_flush,n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,x(n,31),x(n,139),x(n,8),n.gzhead?(x(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),x(n,255&n.gzhead.time),x(n,n.gzhead.time>>8&255),x(n,n.gzhead.time>>16&255),x(n,n.gzhead.time>>24&255),x(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),x(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(x(n,255&n.gzhead.extra.length),x(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=o(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(x(n,0),x(n,0),x(n,0),x(n,0),x(n,0),x(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),x(n,3),n.status=d);else{var c=8+(n.w_bits-8<<4)<<8;c|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(c|=32),c+=31-c%31,n.status=d,T(n,c),0!==n.strstart&&(T(n,t.adler>>>16),T(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(s=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>s&&(t.adler=o(t.adler,n.pending_buf,n.pending-s,s)),m(t),s=n.pending,n.pending!==n.pending_buf_size));)x(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>s&&(t.adler=o(t.adler,n.pending_buf,n.pending-s,s)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){s=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>s&&(t.adler=o(t.adler,n.pending_buf,n.pending-s,s)),m(t),s=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexs&&(t.adler=o(t.adler,n.pending_buf,n.pending-s,s)),0===l&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){s=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>s&&(t.adler=o(t.adler,n.pending_buf,n.pending-s,s)),m(t),s=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindexs&&(t.adler=o(t.adler,n.pending_buf,n.pending-s,s)),0===l&&(n.status=f)}else n.status=f;if(n.status===f&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&m(t),n.pending+2<=n.pending_buf_size&&(x(n,255&t.adler),x(n,t.adler>>8&255),t.adler=0,n.status=d)):n.status=d),0!==n.pending){if(m(t),0===t.avail_out)return n.last_flush=-1,0}else if(0===t.avail_in&&_(e)<=_(i)&&4!==e)return g(t,-5);if(n.status===b&&0!==t.avail_in)return g(t,-5);if(0!==t.avail_in||0!==n.lookahead||0!==e&&n.status!==b){var w=2===n.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(y(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,i=a._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(n,e):3===n.strategy?function(t,e){for(var i,r,n,s,o=t.window;;){if(t.lookahead<=u){if(y(t),t.lookahead<=u&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=o[n=t.strstart-1])===o[++n]&&r===o[++n]&&r===o[++n]){s=t.strstart+u;do{}while(r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&r===o[++n]&&nt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=a._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=a._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(n,e):r[n.level].func(n,e);if(3!==w&&4!==w||(n.status=b),1===w||3===w)return 0===t.avail_out&&(n.last_flush=-1),0;if(2===w&&(1===e?a._tr_align(n):5!==e&&(a._tr_stored_block(n,0,0,!1),3===e&&(p(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),m(t),0===t.avail_out))return n.last_flush=-1,0}return 4!==e?0:n.wrap<=0?1:(2===n.wrap?(x(n,255&t.adler),x(n,t.adler>>8&255),x(n,t.adler>>16&255),x(n,t.adler>>24&255),x(n,255&t.total_in),x(n,t.total_in>>8&255),x(n,t.total_in>>16&255),x(n,t.total_in>>24&255)):(T(n,t.adler>>>16),T(n,65535&t.adler)),m(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==f&&e!==d&&e!==b?g(t,h):(t.state=null,e===d?g(t,-3):0):h},e.deflateSetDictionary=function(t,e){var i,r,a,o,l,u,c,f,d=e.length;if(!t||!t.state)return h;if(2===(o=(i=t.state).wrap)||1===o&&42!==i.status||i.lookahead)return h;for(1===o&&(t.adler=s(t.adler,e,d,0)),i.wrap=0,d>=i.w_size&&(0===o&&(p(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new n.Buf8(i.w_size),n.arraySet(f,e,d-i.w_size,i.w_size,0),e=f,d=i.w_size),l=t.avail_in,u=t.next_in,c=t.input,t.avail_in=d,t.next_in=0,t.input=e,y(i);i.lookahead>=3;){r=i.strstart,a=i.lookahead-2;do{i.ins_h=(i.ins_h<{"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},264:t=>{"use strict";t.exports=function(t,e){var i,r,n,a,s,o,l,h,u,c,f,d,b,g,_,p,m,v,x,T,w,y,A,E,C;i=t.state,r=t.next_in,E=t.input,n=r+(t.avail_in-5),a=t.next_out,C=t.output,s=a-(e-t.avail_out),o=a+(t.avail_out-257),l=i.dmax,h=i.wsize,u=i.whave,c=i.wnext,f=i.window,d=i.hold,b=i.bits,g=i.lencode,_=i.distcode,p=(1<>>=x=v>>>24,b-=x,0===(x=v>>>16&255))C[a++]=65535&v;else{if(!(16&x)){if(0==(64&x)){v=g[(65535&v)+(d&(1<>>=x,b-=x),b<15&&(d+=E[r++]<>>=x=v>>>24,b-=x,!(16&(x=v>>>16&255))){if(0==(64&x)){v=_[(65535&v)+(d&(1<l){t.msg="invalid distance too far back",i.mode=30;break t}if(d>>>=x,b-=x,w>(x=a-s)){if((x=w-x)>u&&i.sane){t.msg="invalid distance too far back",i.mode=30;break t}if(y=0,A=f,0===c){if(y+=h-x,x2;)C[a++]=A[y++],C[a++]=A[y++],C[a++]=A[y++],T-=3;T&&(C[a++]=A[y++],T>1&&(C[a++]=A[y++]))}else{y=a-w;do{C[a++]=C[y++],C[a++]=C[y++],C[a++]=C[y++],T-=3}while(T>2);T&&(C[a++]=C[y++],T>1&&(C[a++]=C[y++]))}break}}break}}while(r>3,d&=(1<<(b-=T<<3))-1,t.next_in=r,t.next_out=a,t.avail_in=r{"use strict";var r=i(236),n=i(69),a=i(869),s=i(264),o=i(241),l=-2,h=12,u=30;function c(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function f(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new r.Buf32(852),e.distcode=e.distdyn=new r.Buf32(592),e.sane=1,e.back=-1,0):l}function b(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,d(t)):l}function g(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?l:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,b(t))):l}function _(t,e){var i,r;return t?(r=new f,t.state=r,r.window=null,0!==(i=g(t,e))&&(t.state=null),i):l}var p,m,v=!0;function x(t){if(v){var e;for(p=new r.Buf32(512),m=new r.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(o(1,t.lens,0,288,p,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;o(2,t.lens,0,32,m,0,t.work,{bits:5}),v=!1}t.lencode=p,t.lenbits=9,t.distcode=m,t.distbits=5}function T(t,e,i,n){var a,s=t.state;return null===s.window&&(s.wsize=1<=s.wsize?(r.arraySet(s.window,e,i-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((a=s.wsize-s.wnext)>n&&(a=n),r.arraySet(s.window,e,i-n,a,s.wnext),(n-=a)?(r.arraySet(s.window,e,i-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=a,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,i.check=a(i.check,O,2,0),m=0,v=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&m)<<8)+(m>>8))%31){t.msg="incorrect header check",i.mode=u;break}if(8!=(15&m)){t.msg="unknown compression method",i.mode=u;break}if(v-=4,I=8+(15&(m>>>=4)),0===i.wbits)i.wbits=I;else if(I>i.wbits){t.msg="invalid window size",i.mode=u;break}i.dmax=1<>8&1),512&i.flags&&(O[0]=255&m,O[1]=m>>>8&255,i.check=a(i.check,O,2,0)),m=0,v=0,i.mode=3;case 3:for(;v<32;){if(0===_)break t;_--,m+=f[b++]<>>8&255,O[2]=m>>>16&255,O[3]=m>>>24&255,i.check=a(i.check,O,4,0)),m=0,v=0,i.mode=4;case 4:for(;v<16;){if(0===_)break t;_--,m+=f[b++]<>8),512&i.flags&&(O[0]=255&m,O[1]=m>>>8&255,i.check=a(i.check,O,2,0)),m=0,v=0,i.mode=5;case 5:if(1024&i.flags){for(;v<16;){if(0===_)break t;_--,m+=f[b++]<>>8&255,i.check=a(i.check,O,2,0)),m=0,v=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((A=i.length)>_&&(A=_),A&&(i.head&&(I=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),r.arraySet(i.head.extra,f,b,A,I)),512&i.flags&&(i.check=a(i.check,f,A,b)),_-=A,b+=A,i.length-=A),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===_)break t;A=0;do{I=f[b+A++],i.head&&I&&i.length<65536&&(i.head.name+=String.fromCharCode(I))}while(I&&A<_);if(512&i.flags&&(i.check=a(i.check,f,A,b)),_-=A,b+=A,I)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===_)break t;A=0;do{I=f[b+A++],i.head&&I&&i.length<65536&&(i.head.comment+=String.fromCharCode(I))}while(I&&A<_);if(512&i.flags&&(i.check=a(i.check,f,A,b)),_-=A,b+=A,I)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;v<16;){if(0===_)break t;_--,m+=f[b++]<>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=h;break;case 10:for(;v<32;){if(0===_)break t;_--,m+=f[b++]<>>=7&v,v-=7&v,i.mode=27;break}for(;v<3;){if(0===_)break t;_--,m+=f[b++]<>>=1)){case 0:i.mode=14;break;case 1:if(x(i),i.mode=20,6===e){m>>>=2,v-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=u}m>>>=2,v-=2;break;case 14:for(m>>>=7&v,v-=7&v;v<32;){if(0===_)break t;_--,m+=f[b++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=u;break}if(i.length=65535&m,m=0,v=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(A=i.length){if(A>_&&(A=_),A>p&&(A=p),0===A)break t;r.arraySet(d,f,b,A,g),_-=A,b+=A,p-=A,g+=A,i.length-=A;break}i.mode=h;break;case 17:for(;v<14;){if(0===_)break t;_--,m+=f[b++]<>>=5,v-=5,i.ndist=1+(31&m),m>>>=5,v-=5,i.ncode=4+(15&m),m>>>=4,v-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=u;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,v-=3}for(;i.have<19;)i.lens[N[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,B={bits:i.lenbits},U=o(0,i.lens,0,19,i.lencode,0,i.work,B),i.lenbits=B.bits,U){t.msg="invalid code lengths set",i.mode=u;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,k=65535&z,!((S=z>>>24)<=v);){if(0===_)break t;_--,m+=f[b++]<>>=S,v-=S,i.lens[i.have++]=k;else{if(16===k){for(P=S+2;v>>=S,v-=S,0===i.have){t.msg="invalid bit length repeat",i.mode=u;break}I=i.lens[i.have-1],A=3+(3&m),m>>>=2,v-=2}else if(17===k){for(P=S+3;v>>=S)),m>>>=3,v-=3}else{for(P=S+7;v>>=S)),m>>>=7,v-=7}if(i.have+A>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=u;break}for(;A--;)i.lens[i.have++]=I}}if(i.mode===u)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=u;break}if(i.lenbits=9,B={bits:i.lenbits},U=o(1,i.lens,0,i.nlen,i.lencode,0,i.work,B),i.lenbits=B.bits,U){t.msg="invalid literal/lengths set",i.mode=u;break}if(i.distbits=6,i.distcode=i.distdyn,B={bits:i.distbits},U=o(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,B),i.distbits=B.bits,U){t.msg="invalid distances set",i.mode=u;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(_>=6&&p>=258){t.next_out=g,t.avail_out=p,t.next_in=b,t.avail_in=_,i.hold=m,i.bits=v,s(t,y),g=t.next_out,d=t.output,p=t.avail_out,b=t.next_in,f=t.input,_=t.avail_in,m=i.hold,v=i.bits,i.mode===h&&(i.back=-1);break}for(i.back=0;M=(z=i.lencode[m&(1<>>16&255,k=65535&z,!((S=z>>>24)<=v);){if(0===_)break t;_--,m+=f[b++]<>F)])>>>16&255,k=65535&z,!(F+(S=z>>>24)<=v);){if(0===_)break t;_--,m+=f[b++]<>>=F,v-=F,i.back+=F}if(m>>>=S,v-=S,i.back+=S,i.length=k,0===M){i.mode=26;break}if(32&M){i.back=-1,i.mode=h;break}if(64&M){t.msg="invalid literal/length code",i.mode=u;break}i.extra=15&M,i.mode=22;case 22:if(i.extra){for(P=i.extra;v>>=i.extra,v-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;M=(z=i.distcode[m&(1<>>16&255,k=65535&z,!((S=z>>>24)<=v);){if(0===_)break t;_--,m+=f[b++]<>F)])>>>16&255,k=65535&z,!(F+(S=z>>>24)<=v);){if(0===_)break t;_--,m+=f[b++]<>>=F,v-=F,i.back+=F}if(m>>>=S,v-=S,i.back+=S,64&M){t.msg="invalid distance code",i.mode=u;break}i.offset=k,i.extra=15&M,i.mode=24;case 24:if(i.extra){for(P=i.extra;v>>=i.extra,v-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=u;break}i.mode=25;case 25:if(0===p)break t;if(A=y-p,i.offset>A){if((A=i.offset-A)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=u;break}A>i.wnext?(A-=i.wnext,E=i.wsize-A):E=i.wnext-A,A>i.length&&(A=i.length),C=i.window}else C=d,E=g-i.offset,A=i.length;A>p&&(A=p),p-=A,i.length-=A;do{d[g++]=C[E++]}while(--A);0===i.length&&(i.mode=21);break;case 26:if(0===p)break t;d[g++]=i.length,p--,i.mode=21;break;case 27:if(i.wrap){for(;v<32;){if(0===_)break t;_--,m|=f[b++]<{"use strict";var r=i(236),n=15,a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,i,h,u,c,f,d){var b,g,_,p,m,v,x,T,w,y=d.bits,A=0,E=0,C=0,S=0,M=0,k=0,F=0,R=0,D=0,I=0,U=null,B=0,P=new r.Buf16(16),z=new r.Buf16(16),O=null,N=0;for(A=0;A<=n;A++)P[A]=0;for(E=0;E=1&&0===P[S];S--);if(M>S&&(M=S),0===S)return u[c++]=20971520,u[c++]=20971520,d.bits=1,0;for(C=1;C0&&(0===t||1!==S))return-1;for(z[1]=0,A=1;A852||2===t&&D>592)return 1;for(;;){x=A-F,f[E]v?(T=O[N+f[E]],w=U[B+f[E]]):(T=96,w=0),b=1<>F)+(g-=b)]=x<<24|T<<16|w|0}while(0!==g);for(b=1<>=1;if(0!==b?(I&=b-1,I+=b):I=0,E++,0==--P[A]){if(A===S)break;A=e[i+f[E]]}if(A>M&&(I&p)!==_){for(0===F&&(F=M),m+=C,R=1<<(k=A-F);k+F852||2===t&&D>592)return 1;u[_=I&p]=M<<24|k<<16|m-c|0}}return 0!==I&&(u[m+I]=A-F<<24|64<<16|0),d.bits=M,0}},898:t=>{"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},342:(t,e,i)=>{"use strict";var r=i(236);function n(t){for(var e=t.length;--e>=0;)t[e]=0}var a=256,s=286,o=30,l=15,h=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],u=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],f=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],d=new Array(576);n(d);var b=new Array(60);n(b);var g=new Array(512);n(g);var _=new Array(256);n(_);var p=new Array(29);n(p);var m,v,x,T=new Array(o);function w(t,e,i,r,n){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=t&&t.length}function y(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function A(t){return t<256?g[t]:g[256+(t>>>7)]}function E(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function C(t,e,i){t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<>>=1,i<<=1}while(--e>0);return i>>>1}function k(t,e,i){var r,n,a=new Array(16),s=0;for(r=1;r<=l;r++)a[r]=s=s+i[r-1]<<1;for(n=0;n<=e;n++){var o=t[2*n+1];0!==o&&(t[2*n]=M(a[o]++,o))}}function F(t){var e;for(e=0;e8?E(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function D(t,e,i,r){var n=2*e,a=2*i;return t[n]>1;i>=1;i--)I(t,a,i);n=h;do{i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],I(t,a,1),r=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=r,a[2*n]=a[2*i]+a[2*r],t.depth[n]=(t.depth[i]>=t.depth[r]?t.depth[i]:t.depth[r])+1,a[2*i+1]=a[2*r+1]=n,t.heap[1]=n++,I(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var i,r,n,a,s,o,h=e.dyn_tree,u=e.max_code,c=e.stat_desc.static_tree,f=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,b=e.stat_desc.extra_base,g=e.stat_desc.max_length,_=0;for(a=0;a<=l;a++)t.bl_count[a]=0;for(h[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i<573;i++)(a=h[2*h[2*(r=t.heap[i])+1]+1]+1)>g&&(a=g,_++),h[2*r+1]=a,r>u||(t.bl_count[a]++,s=0,r>=b&&(s=d[r-b]),o=h[2*r],t.opt_len+=o*(a+s),f&&(t.static_len+=o*(c[2*r+1]+s)));if(0!==_){do{for(a=g-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[g]--,_-=2}while(_>0);for(a=g;0!==a;a--)for(r=t.bl_count[a];0!==r;)(n=t.heap[--i])>u||(h[2*n+1]!==a&&(t.opt_len+=(a-h[2*n+1])*h[2*n],h[2*n+1]=a),r--)}}(t,e),k(a,u,t.bl_count)}function P(t,e,i){var r,n,a=-1,s=e[1],o=0,l=7,h=4;for(0===s&&(l=138,h=3),e[2*(i+1)+1]=65535,r=0;r<=i;r++)n=s,s=e[2*(r+1)+1],++o>=7;r0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e=3&&0===t.bl_tree[2*f[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),n=t.opt_len+3+7>>>3,(s=t.static_len+3+7>>>3)<=n&&(n=s)):n=s=i+5,i+4<=n&&-1!==e?N(t,e,i,r):4===t.strategy||s===n?(C(t,2+(r?1:0),3),U(t,d,b)):(C(t,4+(r?1:0),3),function(t,e,i,r){var n;for(C(t,e-257,5),C(t,i-1,5),C(t,r-4,4),n=0;n>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(_[i]+a+1)]++,t.dyn_dtree[2*A(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){C(t,2,3),S(t,256,d),function(t){16===t.bi_valid?(E(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},292:t=>{"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},287:()=>{var t,e;window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t,e){window.setTimeout(t,1e3/60)},jQuery.support.cors=!0,$.ajaxTransport?($.ajaxSetup({flatOptions:{renderer:!0}}),$.ajaxTransport("+binary",(function(t,e,i){if(window.FormData&&(t.dataType&&"binary"==t.dataType||t.data&&(window.ArrayBuffer&&t.data instanceof ArrayBuffer||window.Blob&&t.data instanceof Blob)))return{send:function(e,i){var r=new XMLHttpRequest,n=t.url,a=t.type,s=t.responseType||"blob",o=t.data||null;t.renderer&&r.addEventListener("progress",(function(e){e.lengthComputable&&(t.renderer.downloads[this.responseURL]?t.renderer.downloads[this.responseURL].loaded=e.loaded:t.renderer.downloads[this.responseURL]={loaded:e.loaded,total:e.total},t.renderer.updateProgress())})),r.addEventListener("load",(function(){t.renderer&&(delete t.renderer.downloads[this.responseURL],t.renderer.updateProgress());var e={};e[t.dataType]=r.response,i(r.status,r.statusText,e,r.getAllResponseHeaders())})),r.open(a,n,!0),r.responseType=s,r.send(o)},abort:function(){i.abort()}}}))):(t=$.httpData,$.httpData=function(e,i,r){return"binary"==i?e.response:t(e,i,r)},$.ajaxSetup({beforeSend:function(t,e){"binary"==e.dataType&&(t.responseType=e.responseType||"arraybuffer",t.addEventListener("progress",(function(t){e.renderer&&t.lengthComputable&&(e.renderer.downloads[this.responseURL]?e.renderer.downloads[this.responseURL].loaded=t.loaded:e.renderer.downloads[this.responseURL]={loaded:t.loaded,total:t.total},e.renderer.updateProgress())}),!1),t.addEventListener("load",(function(){e.renderer&&(delete e.renderer.downloads[this.responseURL],e.renderer.updateProgress())}),!1))}})),Math.randomInt=Math.randomInt||function(t,e){return Math.floor(Math.random()*(e-t))+t},"function"!=typeof Object.create&&(Object.create=(e=function(){},function(t){if(arguments.length>1)throw Error("Second argument not supported");if("object"!=typeof t)throw TypeError("Argument must be an object");e.prototype=t;var i=new e;return e.prototype=null,i})),window.console=window.console||{log:function(){},error:function(){},warn:function(){}}}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,i),a.exports}(()=>{"use strict";i(287);let t=Float32Array;function e(e,i,r){const n=new t(3);return e&&(n[0]=e),i&&(n[1]=i),r&&(n[2]=r),n}function r(e,i,r){return(r=r||new t(3))[0]=e[0]+i[0],r[1]=e[1]+i[1],r[2]=e[2]+i[2],r}function n(e,i,r){return(r=r||new t(3))[0]=e[0]*i[0],r[1]=e[1]*i[1],r[2]=e[2]*i[2],r}let a=Float32Array;function s(t){return(t=t||new a(16))[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function o(t,e){e=e||new a(16);const i=t[0],r=t[1],n=t[2],s=t[3],o=t[4],l=t[5],h=t[6],u=t[7],c=t[8],f=t[9],d=t[10],b=t[11],g=t[12],_=t[13],p=t[14],m=t[15],v=d*m,x=p*b,T=h*m,w=p*u,y=h*b,A=d*u,E=n*m,C=p*s,S=n*b,M=d*s,k=n*u,F=h*s,R=c*_,D=g*f,I=o*_,U=g*l,B=o*f,P=c*l,z=i*_,O=g*r,N=i*f,L=c*r,H=i*l,V=o*r,j=v*l+w*f+y*_-(x*l+T*f+A*_),G=x*r+E*f+M*_-(v*r+C*f+S*_),X=T*r+C*l+k*_-(w*r+E*l+F*_),q=A*r+S*l+F*f-(y*r+M*l+k*f),W=1/(i*j+o*G+c*X+g*q);return e[0]=W*j,e[1]=W*G,e[2]=W*X,e[3]=W*q,e[4]=W*(x*o+T*c+A*g-(v*o+w*c+y*g)),e[5]=W*(v*i+C*c+S*g-(x*i+E*c+M*g)),e[6]=W*(w*i+E*o+F*g-(T*i+C*o+k*g)),e[7]=W*(y*i+M*o+k*c-(A*i+S*o+F*c)),e[8]=W*(R*u+U*b+B*m-(D*u+I*b+P*m)),e[9]=W*(D*s+z*b+L*m-(R*s+O*b+N*m)),e[10]=W*(I*s+O*u+H*m-(U*s+z*u+V*m)),e[11]=W*(P*s+N*u+V*b-(B*s+L*u+H*b)),e[12]=W*(I*d+P*p+D*h-(B*p+R*h+U*d)),e[13]=W*(N*p+R*n+O*d-(z*d+L*p+D*n)),e[14]=W*(z*h+V*p+U*n-(H*p+I*n+O*h)),e[15]=W*(H*d+B*n+L*h-(N*h+V*d+P*n)),e}function l(t,i,r){r=r||e();const n=i[0],a=i[1],s=i[2],o=n*t[3]+a*t[7]+s*t[11]+t[15];return r[0]=(n*t[0]+a*t[4]+s*t[8]+t[12])/o,r[1]=(n*t[1]+a*t[5]+s*t[9]+t[13])/o,r[2]=(n*t[2]+a*t[6]+s*t[10]+t[14])/o,r}function h(t,i,r){r=r||e();const n=i[0],a=i[1],s=i[2];return r[0]=n*t[0]+a*t[4]+s*t[8],r[1]=n*t[1]+a*t[5]+s*t[9],r[2]=n*t[2]+a*t[6]+s*t[10],r}const u=5120,c=5121,f=5122,d=5123,b=5124,g=5125,_=5126,p={};{const t=p;t[u]=Int8Array,t[5121]=Uint8Array,t[5122]=Int16Array,t[5123]=Uint16Array,t[b]=Int32Array,t[5125]=Uint32Array,t[5126]=Float32Array,t[32819]=Uint16Array,t[32820]=Uint16Array,t[33635]=Uint16Array,t[5131]=Uint16Array,t[33640]=Uint32Array,t[35899]=Uint32Array,t[35902]=Uint32Array,t[36269]=Uint32Array,t[34042]=Uint32Array}function m(t){if(t instanceof Int8Array)return u;if(t instanceof Uint8Array)return c;if(t instanceof Uint8ClampedArray)return c;if(t instanceof Int16Array)return f;if(t instanceof Uint16Array)return d;if(t instanceof Int32Array)return b;if(t instanceof Uint32Array)return g;if(t instanceof Float32Array)return _;throw new Error("unsupported typed array type")}function v(t){if(t===Int8Array)return u;if(t===Uint8Array)return c;if(t===Uint8ClampedArray)return c;if(t===Int16Array)return f;if(t===Uint16Array)return d;if(t===Int32Array)return b;if(t===Uint32Array)return g;if(t===Float32Array)return _;throw new Error("unsupported typed array type")}const x="undefined"!=typeof SharedArrayBuffer?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer};function T(...t){console.error(...t)}function w(t,e){return"undefined"!=typeof WebGLTexture&&e instanceof WebGLTexture}const y=34962,A={attribPrefix:""};function E(t,e,i,r,n){t.bindBuffer(e,i),t.bufferData(e,r,n||35044)}function C(t,e,i,r){if(n=e,"undefined"!=typeof WebGLBuffer&&n instanceof WebGLBuffer)return e;var n;i=i||y;const a=t.createBuffer();return E(t,i,a,e,r),a}function S(t){return"indices"===t}function M(t){return t.length?t:t.data}const k=/coord|texture/i,F=/color|colour/i;function R(t,e){let i;if(i=k.test(t)?2:F.test(t)?4:3,e%i>0)throw new Error(`Can not guess numComponents for attribute '${t}'. Tried ${i} but ${e} values is not evenly divisible by ${i}. You should specify it.`);return i}function D(t,e){return t.numComponents||t.size||R(e,M(t).length)}function I(t,e){if(x(t))return t;if(x(t.data))return t.data;Array.isArray(t)&&(t={data:t});let i=t.type;return i||(i=S(e)?Uint16Array:Float32Array),new i(t.data)}function U(t,e){const i={};return Object.keys(e).forEach((function(r){if(!S(r)){const a=e[r],s=a.attrib||a.name||a.attribName||A.attribPrefix+r;if(a.value){if(!Array.isArray(a.value)&&!x(a.value))throw new Error("array.value is not array or typedarray");i[s]={value:a.value}}else{let e,o,l,h;if(a.buffer&&a.buffer instanceof WebGLBuffer)e=a.buffer,h=a.numComponents||a.size,o=a.type,l=a.normalize;else if("number"==typeof a||"number"==typeof a.data){const i=a.data||a,s=a.type||Float32Array,u=i*s.BYTES_PER_ELEMENT;o=v(s),l=void 0!==a.normalize?a.normalize:(n=s)===Int8Array||n===Uint8Array,h=a.numComponents||a.size||R(r,i),e=t.createBuffer(),t.bindBuffer(y,e),t.bufferData(y,u,a.drawType||35044)}else{const i=I(a,r);e=C(t,i,void 0,a.drawType),o=m(i),l=void 0!==a.normalize?a.normalize:function(t){return t instanceof Int8Array||t instanceof Uint8Array}(i),h=D(a,r)}i[s]={buffer:e,numComponents:h,type:o,normalize:l,stride:a.stride||0,offset:a.offset||0,divisor:void 0===a.divisor?void 0:a.divisor,drawType:a.drawType}}}var n})),t.bindBuffer(y,null),i}const B=["position","positions","a_position"];function P(t,e,i){const r=U(t,e),n=Object.assign({},i||{});n.attribs=Object.assign({},i?i.attribs:{},r);const a=e.indices;if(a){const e=I(a,"indices");n.indices=C(t,e,34963),n.numElements=e.length,n.elementType=m(e)}else n.numElements||(n.numElements=function(t,e){let i,r;for(r=0;r0)throw new Error(`numComponents ${a} not correct for length ${n}`);return s}(e),i}function N(t,e){let i=0;return t.push=function(){for(let e=0;e=0?X(r,e):i.indexOf("tan")>=0||i.indexOf("binorm")>=0?j(r,e):i.indexOf("norm")>=0&&G(r,e)})),t}function W(t,e,i){return t=t||2,{position:{numComponents:2,data:[(e=e||0)+-1*(t*=.5),(i=i||0)+-1*t,e+1*t,i+-1*t,e+-1*t,i+1*t,e+1*t,i+1*t]},normal:[0,0,1,0,0,1,0,0,1,0,0,1],texcoord:[0,0,1,0,0,1,1,1],indices:[0,1,2,2,1,3]}}function Y(t,e,i,r,n){t=t||1,e=e||1,i=i||1,r=r||1,n=n||s();const a=(i+1)*(r+1),o=L(3,a),l=L(3,a),h=L(2,a);for(let n=0;n<=r;n++)for(let a=0;a<=i;a++){const s=a/i,u=n/r;o.push(t*s-.5*t,0,e*u-.5*e),l.push(0,1,0),h.push(s,u)}const u=i+1,c=L(3,i*r*2,Uint16Array);for(let t=0;t 0");r=r||0,a=a||0;const o=(n=n||Math.PI)-r,l=(s=s||2*Math.PI)-a,h=(e+1)*(i+1),u=L(3,h),c=L(3,h),f=L(2,h);for(let n=0;n<=i;n++)for(let s=0;s<=e;s++){const h=s/e,d=n/i,b=l*h+a,g=o*d+r,_=Math.sin(b),p=Math.cos(b),m=Math.sin(g),v=p*m,x=Math.cos(g),T=_*m;u.push(t*v,t*x,t*T),c.push(v,x,T),f.push(1-h,d)}const d=e+1,b=L(3,e*i*2,Uint16Array);for(let t=0;tn?(l=i,o=1,s=e):s=t+a/n*(e-t),-2!==a&&a!==n+2||(s=0,o=0),l-=i/2;for(let t=0;tn?f.push(0,1,0):0===s?f.push(0,0,0):f.push(e*p,m,i*p),d.push(t/r,1-o)}}for(let t=0;t 0");const h=(l=l||1)-(o=o||0),u=2*(s+1)*4,c=L(3,u),f=L(3,u),d=L(2,u);function b(t,e,i){return t+(e-t)*i}function g(e,i,l,u,g,_){for(let p=0;p<=s;p++){const m=i/1,v=p/s,x=2*(m-.5),T=(o+v*h)*Math.PI,w=Math.sin(T),y=Math.cos(T),A=b(t,e,w),E=x*a,C=y*t,S=w*A;c.push(E,C,S);const M=r(n([0,w,y],l),u);f.push(M),d.push(m*g+_,v)}}for(let t=0;t<2;t++){const r=2*(t/1-.5);g(e,t,[1,1,1],[0,0,0],1,0),g(e,t,[0,0,0],[r,0,0],0,0),g(i,t,[1,1,1],[0,0,0],1,0),g(i,t,[0,0,0],[r,0,0],0,1)}const _=L(3,2*s*4,Uint16Array);function p(t,e){for(let i=0;i0&&r!==e){const t=u+(r+1),e=u+r,i=u+r-f,n=u+(r+1)-f;h.push(t,e,i),h.push(t,i,n)}}u+=e+1}return{position:s,normal:o,texcoord:l,indices:h}}function st(t){return function(e){const i=t.apply(this,Array.prototype.slice.call(arguments,1));return O(e,i)}}function ot(t){return function(e){const i=t.apply(null,Array.prototype.slice.call(arguments,1));return P(e,i)}}ot(et),st(et),ot(K),st(K),ot(Y),st(Y),ot(Z),st(Z),ot(Q),st(Q),ot(W),st(W),ot(it),st(it),ot(rt),st(rt),ot(nt),st(nt),ot(at),st(at);function lt(t){return!!t.texStorage2D}const ht=function(){const t={},e={};return function(i,r){return function(i){const r=i.constructor.name;if(!t[r]){for(const t in i)if("number"==typeof i[t]){const r=e[i[t]];e[i[t]]=r?`${r} | ${t}`:t}t[r]=!0}}(i),e[r]||("number"==typeof r?`0x${r.toString(16)}`:r)}}();new Uint8Array([128,192,255,255]),function(){let t}();const ut=6407,ct=6408,ft=33319,dt=6403,bt={};{const t=bt;t[6406]={numColorComponents:1},t[6409]={numColorComponents:1},t[6410]={numColorComponents:2},t[ut]={numColorComponents:3},t[ct]={numColorComponents:4},t[dt]={numColorComponents:1},t[36244]={numColorComponents:1},t[ft]={numColorComponents:2},t[33320]={numColorComponents:2},t[ut]={numColorComponents:3},t[36248]={numColorComponents:3},t[ct]={numColorComponents:4},t[36249]={numColorComponents:4},t[6402]={numColorComponents:1},t[34041]={numColorComponents:2}}const gt=T;function _t(t){return"undefined"!=typeof document&&document.getElementById?document.getElementById(t):null}const pt=33984,mt=34962,vt=5126,xt=5124,Tt=5125,wt=3553,yt=34067,At=32879,Et=35866,Ct={};function St(t,e){return Ct[e].bindPoint}function Mt(t,e){return function(i){t.uniform1i(e,i)}}function kt(t,e){return function(i){t.uniform1iv(e,i)}}function Ft(t,e){return function(i){t.uniform2iv(e,i)}}function Rt(t,e){return function(i){t.uniform3iv(e,i)}}function Dt(t,e){return function(i){t.uniform4iv(e,i)}}function It(t,e,i,r){const n=St(0,e);return lt(t)?function(e){let a,s;w(0,e)?(a=e,s=null):(a=e.texture,s=e.sampler),t.uniform1i(r,i),t.activeTexture(pt+i),t.bindTexture(n,a),t.bindSampler(i,s)}:function(e){t.uniform1i(r,i),t.activeTexture(pt+i),t.bindTexture(n,e)}}function Ut(t,e,i,r,n){const a=St(0,e),s=new Int32Array(n);for(let t=0;t{const n=parseInt(t[1]),a=r[i+1],s=a?a.index:e.length;return[n-1,e.substring(t.index,s)]})));return t.split("\n").map(((t,e)=>{const r=n.get(e);return`${e+1+i}: ${t}${r?`\n\n^^^ ${r}`:""}`})).join("\n")}const Vt=/^[ \t]*\n/;function jt(t,e,i,r){const n=r||gt,a=t.createShader(i);let s=0;Vt.test(e)&&(s=1,e=e.replace(Vt,"")),t.shaderSource(a,e),t.compileShader(a);if(!t.getShaderParameter(a,35713)){const r=t.getShaderInfoLog(a);return n(`${Ht(e,r,s)}\nError compiling ${ht(t,i)}: ${r}`),t.deleteShader(a),null}return a}function Gt(t,e,i){let r,n;if("function"==typeof e&&(i=e,e=void 0),"function"==typeof t)i=t,t=void 0;else if(t&&!Array.isArray(t)){if(t.errorCallback)return t;const e=t;i=e.errorCallback,t=e.attribLocations,r=e.transformFeedbackVaryings,n=e.transformFeedbackMode}const a={errorCallback:i||gt,transformFeedbackVaryings:r,transformFeedbackMode:n};if(t){let i={};Array.isArray(t)?t.forEach((function(t,r){i[t]=e?e[r]:r})):i=t,a.attribLocations=i}return a}const Xt=["VERTEX_SHADER","FRAGMENT_SHADER"];function qt(t,e){return e.indexOf("frag")>=0?35632:e.indexOf("vert")>=0?35633:void 0}function Wt(t,e){e.forEach((function(e){t.deleteShader(e)}))}function Yt(t,e,i,r,n){const a=Gt(i,r,n),s=[],o=[];for(let i=0;i{const i=Ht(t.getShaderSource(e),"",0),r=t.getShaderParameter(e,t.SHADER_TYPE);return`${ht(t,r)}\n${i}}`})).join("\n")}\nError in program linking: ${e}`),t.deleteProgram(h),Wt(t,o),null}return h}function Zt(t,e,i,r,n){const a=Gt(i,r,n),s=[];for(let i=0;i""!==t));let a=0,s="";for(;;){const t=n[a++];s+=t;const l=(o=t[0])>="0"&&o<="9",h=l?parseInt(t):t;l&&(s+=n[a++]);if(a===n.length){i[h]=e;break}{const t=n[a++],e="["===t,o=i[h]||(e?[]:{});i[h]=o,i=o,r[s]=r[s]||function(t){return function(e){ie(t,e)}}(o),s+=t}}var o}function Qt(t,e){let i=0;function r(e,r,n){const a=r.name.endsWith("[0]"),s=r.type,o=Ct[s];if(!o)throw new Error(`unknown type: 0x${s.toString(16)}`);let l;if(o.bindPoint){const e=i;i+=r.size,l=a?o.arraySetter(t,s,e,n,r.size):o.setter(t,s,e,n,r.size)}else l=o.arraySetter&&a?o.arraySetter(t,n):o.setter(t,n);return l.location=n,l}const n={},a={},s=t.getProgramParameter(e,35718);for(let i=0;i0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t}function Be(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Pe(t,e,i){var r=e[0],n=e[1],a=e[2],s=i[0],o=i[1],l=i[2];return t[0]=n*l-a*o,t[1]=a*s-r*l,t[2]=r*o-n*s,t}function ze(t,e,i,r){var n=e[0],a=e[1],s=e[2];return t[0]=n+r*(i[0]-n),t[1]=a+r*(i[1]-a),t[2]=s+r*(i[2]-s),t}function Oe(t,e,i){var r=e[0],n=e[1],a=e[2],s=i[3]*r+i[7]*n+i[11]*a+i[15];return s=s||1,t[0]=(i[0]*r+i[4]*n+i[8]*a+i[12])/s,t[1]=(i[1]*r+i[5]*n+i[9]*a+i[13])/s,t[2]=(i[2]*r+i[6]*n+i[10]*a+i[14])/s,t}function Ne(t,e,i){var r=e[0],n=e[1],a=e[2];return t[0]=r*i[0]+n*i[3]+a*i[6],t[1]=r*i[1]+n*i[4]+a*i[7],t[2]=r*i[2]+n*i[5]+a*i[8],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var Le,He=Ce,Ve=Te;Le=ve();function je(){var t=new me(16);return me!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function Ge(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Xe(t,e,i,r,n,a,s,o,l,h,u,c,f,d,b,g){var _=new me(16);return _[0]=t,_[1]=e,_[2]=i,_[3]=r,_[4]=n,_[5]=a,_[6]=s,_[7]=o,_[8]=l,_[9]=h,_[10]=u,_[11]=c,_[12]=f,_[13]=d,_[14]=b,_[15]=g,_}function qe(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function We(t,e){var i=e[0],r=e[1],n=e[2],a=e[3],s=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],f=e[10],d=e[11],b=e[12],g=e[13],_=e[14],p=e[15],m=i*o-r*s,v=i*l-n*s,x=i*h-a*s,T=r*l-n*o,w=r*h-a*o,y=n*h-a*l,A=u*g-c*b,E=u*_-f*b,C=u*p-d*b,S=c*_-f*g,M=c*p-d*g,k=f*p-d*_,F=m*k-v*M+x*S+T*C-w*E+y*A;return F?(F=1/F,t[0]=(o*k-l*M+h*S)*F,t[1]=(n*M-r*k-a*S)*F,t[2]=(g*y-_*w+p*T)*F,t[3]=(f*w-c*y-d*T)*F,t[4]=(l*C-s*k-h*E)*F,t[5]=(i*k-n*C+a*E)*F,t[6]=(_*x-b*y-p*v)*F,t[7]=(u*y-f*x+d*v)*F,t[8]=(s*M-o*C+h*A)*F,t[9]=(r*C-i*M-a*A)*F,t[10]=(b*w-g*x+p*m)*F,t[11]=(c*x-u*w-d*m)*F,t[12]=(o*E-s*S-l*A)*F,t[13]=(i*S-r*E+n*A)*F,t[14]=(g*v-b*T-_*m)*F,t[15]=(u*T-c*v+f*m)*F,t):null}function Ye(t,e,i){var r=e[0],n=e[1],a=e[2],s=e[3],o=e[4],l=e[5],h=e[6],u=e[7],c=e[8],f=e[9],d=e[10],b=e[11],g=e[12],_=e[13],p=e[14],m=e[15],v=i[0],x=i[1],T=i[2],w=i[3];return t[0]=v*r+x*o+T*c+w*g,t[1]=v*n+x*l+T*f+w*_,t[2]=v*a+x*h+T*d+w*p,t[3]=v*s+x*u+T*b+w*m,v=i[4],x=i[5],T=i[6],w=i[7],t[4]=v*r+x*o+T*c+w*g,t[5]=v*n+x*l+T*f+w*_,t[6]=v*a+x*h+T*d+w*p,t[7]=v*s+x*u+T*b+w*m,v=i[8],x=i[9],T=i[10],w=i[11],t[8]=v*r+x*o+T*c+w*g,t[9]=v*n+x*l+T*f+w*_,t[10]=v*a+x*h+T*d+w*p,t[11]=v*s+x*u+T*b+w*m,v=i[12],x=i[13],T=i[14],w=i[15],t[12]=v*r+x*o+T*c+w*g,t[13]=v*n+x*l+T*f+w*_,t[14]=v*a+x*h+T*d+w*p,t[15]=v*s+x*u+T*b+w*m,t}function Ze(t,e,i){var r,n,a,s,o,l,h,u,c,f,d,b,g=i[0],_=i[1],p=i[2];return e===t?(t[12]=e[0]*g+e[4]*_+e[8]*p+e[12],t[13]=e[1]*g+e[5]*_+e[9]*p+e[13],t[14]=e[2]*g+e[6]*_+e[10]*p+e[14],t[15]=e[3]*g+e[7]*_+e[11]*p+e[15]):(r=e[0],n=e[1],a=e[2],s=e[3],o=e[4],l=e[5],h=e[6],u=e[7],c=e[8],f=e[9],d=e[10],b=e[11],t[0]=r,t[1]=n,t[2]=a,t[3]=s,t[4]=o,t[5]=l,t[6]=h,t[7]=u,t[8]=c,t[9]=f,t[10]=d,t[11]=b,t[12]=r*g+o*_+c*p+e[12],t[13]=n*g+l*_+f*p+e[13],t[14]=a*g+h*_+d*p+e[14],t[15]=s*g+u*_+b*p+e[15]),t}function Je(t,e,i){var r=i[0],n=i[1],a=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ke(t,e,i){var r=Math.sin(i),n=Math.cos(i),a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],u=e[9],c=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*n+h*r,t[5]=s*n+u*r,t[6]=o*n+c*r,t[7]=l*n+f*r,t[8]=h*n-a*r,t[9]=u*n-s*r,t[10]=c*n-o*r,t[11]=f*n-l*r,t}function $e(t,e,i){var r=Math.sin(i),n=Math.cos(i),a=e[0],s=e[1],o=e[2],l=e[3],h=e[8],u=e[9],c=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*n-h*r,t[1]=s*n-u*r,t[2]=o*n-c*r,t[3]=l*n-f*r,t[8]=a*r+h*n,t[9]=s*r+u*n,t[10]=o*r+c*n,t[11]=l*r+f*n,t}function Qe(t,e,i){var r=Math.sin(i),n=Math.cos(i),a=e[0],s=e[1],o=e[2],l=e[3],h=e[4],u=e[5],c=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*n+h*r,t[1]=s*n+u*r,t[2]=o*n+c*r,t[3]=l*n+f*r,t[4]=h*n-a*r,t[5]=u*n-s*r,t[6]=c*n-o*r,t[7]=f*n-l*r,t}function ti(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function ei(t,e,i){var r=e[0],n=e[1],a=e[2],s=e[3],o=r+r,l=n+n,h=a+a,u=r*o,c=r*l,f=r*h,d=n*l,b=n*h,g=a*h,_=s*o,p=s*l,m=s*h;return t[0]=1-(d+g),t[1]=c+m,t[2]=f-p,t[3]=0,t[4]=c-m,t[5]=1-(u+g),t[6]=b+_,t[7]=0,t[8]=f+p,t[9]=b-_,t[10]=1-(u+d),t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1,t}function ii(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function ri(t,e){var i=e[0],r=e[1],n=e[2],a=e[4],s=e[5],o=e[6],l=e[8],h=e[9],u=e[10];return t[0]=Math.hypot(i,r,n),t[1]=Math.hypot(a,s,o),t[2]=Math.hypot(l,h,u),t}var ni=function(t,e,i,r,n){var a,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0?(a=1/(r-n),t[10]=(n+r)*a,t[14]=2*n*r*a):(t[10]=-1,t[14]=-2*r),t};var ai=Ye;const si={147259:!0},oi={28060:!0,28063:!0,28082:!0,41903:!0,42147:!0,44808:!0,45271:!0};const li={2:{GeosetType:15,Original:2,Override:11},3:{GeosetType:15,Original:3,Override:12},4:{GeosetType:15,Original:4,Override:13},5:{GeosetType:15,Original:5,Override:14},6:{GeosetType:15,Original:6,Override:15},7:{GeosetType:15,Original:7,Override:16},8:{GeosetType:15,Original:8,Override:17},9:{GeosetType:15,Original:9,Override:18},10:{GeosetType:15,Original:10,Override:19}},hi={ITEM:1,HELM:2,SHOULDER:4,NPC:8,CHARACTER:16,HUMANOIDNPC:32,OBJECT:64,ARMOR:128,PATH:256,ITEMVISUAL:512,COLLECTION:1024},ui={MALE:0,FEMALE:1,0:"male",1:"female"},ci=5,fi=15,di=21,bi=27,gi=30,_i={1:"human",2:"orc",3:"dwarf",4:"nightelf",5:"scourge",6:"tauren",7:"gnome",8:"troll",9:"goblin",10:"bloodelf",11:"draenei",12:"felorc",13:"naga_",14:"broken",15:"skeleton",16:"vrykul",17:"tuskarr",18:"foresttroll",19:"taunka",20:"northrendskeleton",21:"icetroll",22:"worgen",23:"gilnean",24:"pandaren",25:"pandarena",26:"pandarenh",27:"nightborne",28:"highmountaintauren",29:"voidelf",30:"lightforgeddraenei",31:"zandalaritroll",32:"kultiran",33:"thinhuman",34:"darkirondwarf",35:"vulpera",36:"magharorc",37:"mechagnome"},pi=[0,1,0,3,4,5,6,7,8,9,10,0,0,21,22,22,16,21,0,19,5,21,22,22,0,21,21,27],mi=[0,16,0,15,1,8,10,5,6,6,7,0,0,17,18,19,14,20,0,9,8,21,22,23,0,24,25,0],vi=[0,0,0,0,0,0,0,0,0,0,0,0,0,22,0,0,0,22,0,0,0,0,0,0,0,0,0,0],xi=[0,2,0,4,128,128,128,128,128,128,128,0,0,1,1,1,128,1,0,128,128,1,1,1,0,1,1,2],Ti=1,wi=3,yi=4,Ai=5,Ei=6,Ci=7,Si=8,Mi=9,ki=10,Fi=13,Ri=14,Di=15,Ii=16,Ui=19,Bi=20,Pi=21,zi=22,Oi=23,Ni=26,Li=1,Hi=10,Vi=[13,14,15,16,17,88,89],ji=[8,9,10,11,12,86,87],Gi=3,Xi=5,qi=7,Wi=12,Yi=[{x:0,y:0,w:.5,h:.25},{x:0,y:.25,w:.5,h:.25},{x:0,y:.5,w:.5,h:.125},{x:.5,y:0,w:.5,h:.25},{x:.5,y:.25,w:.5,h:.125},{x:.5,y:.375,w:.5,h:.25},{x:.5,y:.625,w:.5,h:.25},{x:.5,y:.875,w:.5,h:.125},{},{x:0,y:.625,w:.5,h:.125},{x:0,y:.75,w:.5,h:.25},{},{x:0,y:0,w:1,h:1},{x:0,y:0,w:1,h:1}],Zi=[{x:0,y:0,w:.25,h:.25},{x:0,y:.25,w:.25,h:.25},{x:0,y:.5,w:.25,h:.125},{x:.25,y:0,w:.25,h:.25},{x:.25,y:.25,w:.25,h:.125},{x:.25,y:.375,w:.25,h:.25},{x:.25,y:.625,w:.25,h:.25},{x:.25,y:.875,w:.25,h:.125},{x:.75,y:.75,w:.25,h:.25},{x:.5,y:0,w:.5,h:1},{x:.5,y:0,w:.5,h:1},{x:.5,y:0,w:.5,h:1},{x:0,y:0,w:.5,h:1},{x:0,y:0,w:1,h:1},{x:0,y:0,w:.5,h:1}],Ji={40:[5,0,5,1,5,0,5,1],37:[7,0,7,1,7,0,7,1],36:[2,0,2,1,2,0,2,1],35:[9,0,9,1,9,0,9,1],34:[3,0,3,1,3,0,3,1],33:[5,1,0,-1,5,0,0,-1],31:[0,-1,8,1,0,-1,8,1],30:[11,0,11,1,11,0,11,1],29:[10,0,10,1,10,0,10,1],28:[6,0,6,1,6,0,6,1],27:[4,0,4,1,4,0,4,1],26:[24,0,24,1,24,0,24,1],25:[24,0,24,1,24,0,24,1],23:[1,0,1,1,1,0,1,1],15:[5,0,5,1,5,0,5,1]},Ki={21:26,22:27,15:28,17:26,25:32,13:32,23:33,14:28,26:26},$i={0:{21:26,22:27},1:{21:26,22:27},2:{21:30,22:31},3:{21:32,22:33},4:{21:26,22:27,15:28},5:{21:26},6:{21:26,22:27},7:{21:26,22:27},8:{21:26,22:27},9:{21:33,22:28}};function Qi(){var t=new me(4);return me!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function tr(t){var e=new me(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function er(t,e,i,r){var n=new me(4);return n[0]=t,n[1]=e,n[2]=i,n[3]=r,n}function ir(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function rr(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t}function nr(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t}function ar(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function sr(t){var e=t[0],i=t[1],r=t[2],n=t[3];return Math.hypot(e,i,r,n)}function or(t,e){var i=e[0],r=e[1],n=e[2],a=e[3],s=i*i+r*r+n*n+a*a;return s>0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=r*s,t[2]=n*s,t[3]=a*s,t}function lr(t,e,i){var r=e[0],n=e[1],a=e[2],s=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*a+i[12]*s,t[1]=i[1]*r+i[5]*n+i[9]*a+i[13]*s,t[2]=i[2]*r+i[6]*n+i[10]*a+i[14]*s,t[3]=i[3]*r+i[7]*n+i[11]*a+i[15]*s,t}var hr=sr;!function(){var t=Qi()}();const ur=class{constructor(t){var e=this;e.a=we(t.getFloat(),t.getFloat(),t.getFloat()),e.b=er(t.getFloat(),t.getFloat(),t.getFloat(),0),e.c=t.getFloat(),e.d=t.getFloat(),e.e=t.getFloat(),e.f=t.getFloat(),e.g=[t.getUint8(),t.getUint8(),t.getUint8(),t.getUint8()],e.h=[t.getUint8(),t.getUint8(),t.getUint8(),t.getUint8()],e.i=xe(e.a),e.j=tr(e.b)}l(){var t=this;t.a=null,t.b=null,t.g=null,t.h=null,t.i=null,t.j=null}};const cr=class{constructor(t){var e=this;e.a=t.getUint16(),e.b=t.getUint16(),e.g=t.getUint32(),e.c=t.getUint32(),e.d=t.getUint16(),e.e=t.getUint16(),e.f=t.getUint16(),e.h=t.getInt16(),e.i=t.getUint16(),t.getBool()&&(e.j=t.getString())}k(){}};function fr(){var t=new me(2);return me!=Float32Array&&(t[0]=0,t[1]=0),t}function dr(t,e){var i=new me(2);return i[0]=t,i[1]=e,i}function br(t,e,i){return t[0]=e,t[1]=i,t}function gr(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t}function _r(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t}!function(){var t=fr()}();function pr(){var t=new me(9);return me!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function mr(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function vr(t,e,i){var r=e[0],n=e[1],a=e[2],s=e[3],o=e[4],l=e[5],h=e[6],u=e[7],c=e[8],f=i[0],d=i[1],b=i[2],g=i[3],_=i[4],p=i[5],m=i[6],v=i[7],x=i[8];return t[0]=f*r+d*s+b*h,t[1]=f*n+d*o+b*u,t[2]=f*a+d*l+b*c,t[3]=g*r+_*s+p*h,t[4]=g*n+_*o+p*u,t[5]=g*a+_*l+p*c,t[6]=m*r+v*s+x*h,t[7]=m*n+v*o+x*u,t[8]=m*a+v*l+x*c,t}function xr(){var t=new me(4);return me!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Tr(t,e,i){i*=.5;var r=Math.sin(i);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(i),t}function wr(t,e,i,r){var n,a,s,o,l,h=e[0],u=e[1],c=e[2],f=e[3],d=i[0],b=i[1],g=i[2],_=i[3];return(a=h*d+u*b+c*g+f*_)<0&&(a=-a,d=-d,b=-b,g=-g,_=-_),1-a>pe?(n=Math.acos(a),s=Math.sin(n),o=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(o=1-r,l=r),t[0]=o*h+l*d,t[1]=o*u+l*b,t[2]=o*c+l*g,t[3]=o*f+l*_,t}var yr,Ar,Er,Cr,Sr,Mr,kr=ir,Fr=function(t,e,i,r,n){return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t},Rr=or;yr=ve(),Ar=we(1,0,0),Er=we(0,1,0),Cr=xr(),Sr=xr(),Mr=pr();class Dr{constructor(){this.a=-1,this.b=null,this.c=0}}class Ir{constructor(){this.a=new Dr,this.b=new Dr,this.c=0,this.d=!1}}class Ur{f(){var t=this;if(t.b)for(var e=0;e=0&&(t=this.d1){if(n.a.length>1){var a=n.a[n.a.length-1];a>0&&t>a&&this.d<0&&(t%=a);for(var s=0,o=n.a.length,l=0;l=n.a[l]&&t0?r=n.i(r,n.b[0]):i}return 0==n.b.length?r:r=n.i(r,n.b[0])}l(t){var e,i=this;i.c=t.getInt16(),i.d=t.getInt16(),i.e=t.getBool();var r=t.getInt32();for(i.a=new Array(r),e=0;e1&&n.a.length>1){var s=n.a[n.a.length-1];s>0&&t>s&&(t%=s);for(var o=0,l=n.a.length,h=0;hn.a[h]&&t<=n.a[h+1]){o=h;break}var u=n.a[o],c=n.a[o+1],f=0;return u!=c&&(f=(t-u)/(c-u)),n.f(a[o],a[o+1],f,i)}return a.length>0?i=n.g(i,a[0]):e}j(t){var e,i=this,r=t.getInt32();for(i.a=new Array(r),e=0;e=this.a.length&&(t=0),this.a[t].e)}d(t,e,i,r){if(!this.a||0==this.a.length)return i;let n=t.a.a;n>=this.a.length&&(n=0);let a=this.a[n].k(t.a.c,e,i,r);if(t.c>0&&t.c<1){let n=this.a[0].g(),s=t.b.a;s>=this.a.length&&(s=0);let o=this.a[s].k(t.b.c,e,i,n);o||(o=n),n=this.a[0].g(),a=this.a[0].h(o,a,t.c,n),r&&this.a[0].i(r,n)}return a}e(){if(this.a&&0!=this.a.length){for(var t=0;t-1){e.a.ap[e.e].C(t);let i=je();if(Ge(i,e.a.ap[e.e].m),Ye(i,r,i),1&e.d||2&e.d||4&e.d){if(4&e.d&&2&e.d)qr(i,0,Xr(r,0)),qr(i,1,Xr(r,1)),qr(i,2,Xr(r,2));else if(4&e.d){{let t=Xr(r,0),e=sr(t);ar(t,t,sr(Xr(i,0))/e),qr(i,0,t)}{let t=Xr(r,1),e=sr(t);ar(t,t,sr(Xr(i,1))/e),qr(i,1,t)}{let t=Xr(r,2),e=sr(t);ar(t,t,sr(Xr(i,2))/e),qr(i,2,t)}}else if(2&e.d){{let t=Xr(r,0);ar(t,t,1/sr(Xr(i,0))),ar(t,t,sr(Xr(r,0))),qr(i,0,t)}{let t=Xr(r,1);ar(t,t,1/sr(Xr(i,1))),ar(t,t,sr(Xr(r,1))),qr(i,1,t)}{let t=Xr(r,2);ar(t,t,1/sr(Xr(i,2))),ar(t,t,sr(Xr(r,2))),qr(i,2,t)}}if(1&e.d)qr(i,3,Xr(r,3));else{let t=er(e.h[0],e.h[1],e.h[2],1),n=Qi();ir(n,t),n[3]=0;let a=Qi(),s=Qi();lr(a,t,e.a.ap[e.e].m),lr(a,a,r),lr(s,n,i),nr(a,a,s),a[3]=1,qr(i,3,a)}}let n=je();We(n,r),Ye(i,n,i),Ye(e.m,e.m,i)}let n=null;if(null!=this.t){let t=this.D(this.t);this.a.S||(this.w=t),n=this.a.S?this.w:t}else{let t=this.D(i);this.a.S||(this.w=t),n=this.a.S?this.w:t}let a=null;if(null!=this.u){let t=this.D(this.u);this.a.S||(this.x=t),a=this.a.S?this.x:t}let s=null!=n||null!=a,o=je();s&&(null!=n&&Ye(o,o,n),null!=a&&Ye(o,o,a)),null!=this.v&&(Ze(o,o,this.h),Ye(o,o,this.v),Ze(o,o,Ie(this.n,this.h))),Ye(e.m,e.m,o);let l=120&e.d;if(l){let t=je();Ge(t,e.m);let i=e.m,r=ve();ri(r,e.m);let n=Qi();if(16==l){let t=Xr(e.m,0);ar(t,t,1/Te(t)),qr(e.m,0,t);let r=er(i[4],-i[0],0,0);qr(i,1,or(r,r)),Pe(n,r,t),n[3]=0,qr(i,2,n)}else if(l>16){if(32==l){let t=Xr(i,1);ar(t,t,1/sr(t)),qr(e.m,1,t);let r=er(-i[5],i[1],0,0);qr(i,0,or(r,r)),n[3]=0,qr(i,2,n)}else if(64==l){let t=Xr(i,2);or(t,t),qr(i,2,t);let e=er(t[1],-t[0],0,0);or(e,e),qr(i,1,e),Pe(n,t,e),n[3]=0,qr(i,0,n)}}else if(8==l){let t=this.a.h;if(s){let e=Xr(o,0);e=er(e[1],e[2],-e[0],0),or(e,e),qr(i,0,e);let r=Xr(o,1);r=er(t?-r[1]:r[1],t?-r[2]:r[2],t?r[0]:-r[0],0),or(r,r),qr(i,1,r);let n=Xr(o,2);n=er(n[1],n[2],-n[0],0),or(n,n),qr(i,2,n)}else{qr(i,0,er(0,0,-1,0)),qr(i,1,er(t?-1:1,0,0,0)),qr(i,2,er(0,1,0,0))}}let a=er(this.h[0],this.h[1],this.h[2],1),h=er(this.h[0],this.h[1],this.h[2],0),u=Xr(i,0),c=Xr(i,1),f=Xr(i,2);ar(u,u,r[0]),ar(c,c,r[1]),ar(f,f,r[2]),qr(i,0,u),qr(i,1,c),qr(i,2,f),lr(a,a,t),lr(h,h,i);let d=Qi();nr(d,a,h),d[3]=1,qr(i,3,d)}We(r,r),Ye(e.m,r,e.m),Oe(e.l,e.h,e.m)}D(t){var e=this.i.c(t.a.a),i=this.j.c(t.a.a),r=this.k.c(t.a.a);if(0!=(640&this.d)){let w=je();return qe(w),Ze(w,w,this.h),e&&(this.n=this.i.d(t,this.a.aX),Ze(w,w,this.n)),i&&(this.o=this.j.d(t,this.a.aX,xr()),n=this.p,a=this.o,s=a[0],o=a[1],l=a[2],h=a[3],d=s*(u=s+s),b=o*u,g=o*(c=o+o),_=l*u,p=l*c,m=l*(f=l+l),v=h*u,x=h*c,T=h*f,n[0]=1-g-m,n[1]=b+T,n[2]=_-x,n[3]=0,n[4]=b-T,n[5]=1-d-m,n[6]=p+v,n[7]=0,n[8]=_+x,n[9]=p-v,n[10]=1-d-g,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,Ye(w,w,this.p)),r&&(this.n=this.k.d(t,this.a.aX),Je(w,w,this.n)),Ze(w,w,Ie(this.n,this.h)),w}var n,a,s,o,l,h,u,c,f,d,b,g,_,p,m,v,x,T;return null}};const Yr=class{constructor(t){var e=this;e.a=t.getUint16(),e.b=t.getUint16(),e.c=t.getUint16(),e.d=t.getUint16(),e.e=t.getUint16()+65536*e.b,e.f=t.getUint16(),e.g=t.getUint16(),e.h=we(t.getFloat(),t.getFloat(),t.getFloat()),e.i=we(t.getFloat(),t.getFloat(),t.getFloat()),e.j=t.getFloat()}k(){this.h=null,this.i=null}};var Zr=i(591);const Jr=class{constructor(t){this.a=t.getUint16(),this.b=t.getUint16()}static c(t){t.E=!1,t.o.av&&t.g 1) {\n // if (_output.a < (1.0/255.0)) {\n // discard;\n // }\n // }\n if (!uUnlit) { vec4 litColor = uAmbientColor; vec3 normal = normalize(vNormal); float dp = max(0.0, dot(normal, uLightDir1)); litColor += uPrimaryColor * dp; dp = max(0.0, dot(normal, uLightDir2)); litColor += uSecondaryColor * dp; dp = max(0.0, dot(normal, uLightDir3)); litColor += uSecondaryColor * dp; litColor = clamp(litColor, vec4(0,0,0,0), vec4(1,1,1,1)); _output *= (litColor * uDiffuseColor); } _output += vec4(_specular, 0.0); gl_FragColor = _output.xyzw;\n }"}}const $r=[["PS_Combiners_Opaque_Mod2xNA_Alpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_AddAlpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_AddAlpha_Alpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_Mod2xNA_Alpha_Add","VS_Diffuse_T1_Env_T1","HS_T1_T2_T3","DS_T1_T2_T3"],["PS_Combiners_Mod_AddAlpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_AddAlpha","VS_Diffuse_T1_T1","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod_AddAlpha","VS_Diffuse_T1_T1","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod_AddAlpha_Alpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_Alpha_Alpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_Mod2xNA_Alpha_3s","VS_Diffuse_T1_Env_T1","HS_T1_T2_T3","DS_T1_T2_T3"],["PS_Combiners_Opaque_AddAlpha_Wgt","VS_Diffuse_T1_T1","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod_Add_Alpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_ModNA_Alpha","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod_AddAlpha_Wgt","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod_AddAlpha_Wgt","VS_Diffuse_T1_T1","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_AddAlpha_Wgt","VS_Diffuse_T1_T2","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_Mod_Add_Wgt","VS_Diffuse_T1_Env","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_Mod2xNA_Alpha_UnshAlpha","VS_Diffuse_T1_Env_T1","HS_T1_T2_T3","DS_T1_T2_T3"],["PS_Combiners_Mod_Dual_Crossfade","VS_Diffuse_T1","HS_T1","DS_T1"],["PS_Combiners_Mod_Depth","VS_Diffuse_EdgeFade_T1","HS_T1","DS_T1"],["PS_Combiners_Opaque_Mod2xNA_Alpha_Alpha","VS_Diffuse_T1_Env_T2","HS_T1_T2_T3","DS_T1_T2_T3"],["PS_Combiners_Mod_Mod","VS_Diffuse_EdgeFade_T1_T2","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod_Masked_Dual_Crossfade","VS_Diffuse_T1_T2","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_Alpha","VS_Diffuse_T1_T1","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Opaque_Mod2xNA_Alpha_UnshAlpha","VS_Diffuse_T1_Env_T2","HS_T1_T2_T3","DS_T1_T2_T3"],["PS_Combiners_Mod_Depth","VS_Diffuse_EdgeFade_Env","HS_T1","DS_T1"],["PS_Guild","VS_Diffuse_T1_T2_T1","HS_T1_T2_T3","DS_T1_T2"],["PS_Guild_NoBorder","VS_Diffuse_T1_T2","HS_T1_T2","DS_T1_T2_T3"],["PS_Guild_Opaque","VS_Diffuse_T1_T2_T1","HS_T1_T2_T3","DS_T1_T2"],["PS_Illum","VS_Diffuse_T1_T1","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod_Mod_Mod_Const","VS_Diffuse_T1_T2_T3","HS_T1_T2_T3","DS_T1_T2_T3"],["PS_Combiners_Mod_Mod_Mod_Const","VS_Color_T1_T2_T3","HS_T1_T2_T3","DS_T1_T2_T3"],["PS_Combiners_Opaque","VS_Diffuse_T1","HS_T1","DS_T1"],["PS_Combiners_Mod_Mod2x","VS_Diffuse_EdgeFade_T1_T2","HS_T1_T2","DS_T1_T2"],["PS_Combiners_Mod","VS_Diffuse_EdgeFade_T1","HS_T1_T2","DS_T1_T2"],["PS_Unknown_34821","VS_Diffuse_EdgeFade_T1_T2","HS_T1_T2","DS_T1_T2"]],Qr={PS_Combiners_Add:[1,"_output.rgb = _input.rgb + tex0.rgb;","_output.a = _input.a + tex0.a;"],PS_Combiners_Decal:[1,"_output.rgb = mix(_input.rgb, tex0.rgb, _input.a);","_output.a = _input.a;"],PS_Combiners_Fade:[1,"_output.rgb = mix(tex0.rgb, _input.rgb, _input.a);","_output.a = _input.a;"],PS_Combiners_Mod:[1,"_output.rgb = _input.rgb * tex0.rgb;","_output.a = tex0.a;"],PS_Combiners_Mod2x:[1,"_output.rgb = _input.rgb * tex0.rgb * 2.0;","_output.a = tex0.a * 2.0;"],PS_Combiners_Opaque:[1,"_output.rgb = _input.rgb * tex0.rgb;","_output.a = 1.0;"],PS_Combiners_Add_Add:[2,"_output.rgb = (_input.rgb + tex0.rgb) + tex1.rgb;","_output.a = (_input.a + tex0.a) + tex1.a;"],PS_Combiners_Add_Mod:[2,"_output.rgb = (_input.rgb + tex0.rgb) * tex1.rgb;","_output.a = (_input.a + tex0.a) * tex1.a;"],PS_Combiners_Add_Mod2x:[2,"_output.rgb = (_input.rgb + tex0.rgb) * tex1.rgb * 2.0;","_output.a = (_input.a + tex0.a) * tex1.a * 2.0;"],PS_Combiners_Add_Opaque:[2,"_output.rgb = (_input.rgb + tex0.rgb) * tex1.rgb;","_output.a = _input.a + tex0.a;"],PS_Combiners_Mod_AddNA:[2,"_output.rgb = (_input.rgb * tex0.rgb);","_output.a = tex0.a;","_specular = tex1.rgb;"],PS_Combiners_Mod_Mod:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;","_output.a = tex0.a * tex1.a;"],PS_Combiners_Mod_Mod2x:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;","_output.a = tex0.a * tex1.a * 2.0;"],PS_Combiners_Mod_Add:[2,"_output.rgb = (_input.rgb * tex0.rgb);","_output.a = tex0.a + tex1.a;","_specular = tex1.rgb;"],PS_Combiners_Mod_Mod2xNA:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;","_output.a = tex0.a;"],PS_Combiners_Mod_Opaque:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;","_output.a = tex0.a;"],PS_Combiners_Mod2x_Add:[2,"_output.rgb = (_input.rgb * tex0.rgb) * 2.0 + tex1.rgb;","_output.a = (tex0.a) * 2.0 + tex1.a;"],PS_Combiners_Mod2x_Mod2x:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 4.0;","_output.a = (tex0.a) * tex1.a * 4.0;"],PS_Combiners_Mod2x_Opaque:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;","_output.a = tex0.a * 2.0;"],PS_Combiners_Opaque_Add:[2,"_output.rgb = (_input.rgb * tex0.rgb) + tex1.rgb;","_output.a = _input.a + tex1.a;"],PS_Combiners_Opaque_AddAlpha:[2,"_output.rgb = (_input.rgb * tex0.rgb);","_specular = (tex1.rgb * tex1.a);"],PS_Combiners_Opaque_AddAlpha_Wgt:[2,"_output.rgb = (_input.rgb * tex0.rgb);","_specular = (tex1.rgb * tex1.a) * uTexSampleAlpha.g;"],PS_Combiners_Opaque_AddAlpha_Alpha:[2,"_output.rgb = (_input.rgb * tex0.rgb);","_specular = (tex1.rgb * tex1.a * (1.0 - tex0.a));"],PS_Combiners_Opaque_AddNA:[2,"_output.rgb = (_input.rgb * tex0.rgb) + tex1.rgb;","_output.a = _input.a;"],PS_Combiners_Opaque_Mod:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;","_output.a = tex1.a;"],PS_Combiners_Opaque_Mod2x:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;","_output.a = tex1.a * 2.0;"],PS_Combiners_Opaque_Mod2xNA:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;",""],PS_Combiners_Opaque_Mod2xNA_Alpha:[2,"_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.0, tex0.rgb, vec3(tex0.a));",""],PS_Combiners_Opaque_Opaque:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;",""],PS_Combiners_Opaque_Mod2xNA_Alpha_Add:[3,"_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.0, tex0.rgb, vec3(tex0.a));","_specular = tex2.rgb * tex2.a * uTexSampleAlpha.b; "],PS_Combiners_Mod_Mod_Mod_Const:[3,"_output.rgb = _input.rgb * (tex0 * tex1 * tex2).rgb;","_output.a = (tex0 * tex1 * tex2).a;"],PS_Combiners_Mod_AddAlpha:[2,"_output.rgb = (_input.rgb * tex0.rgb);","_output.a = tex0.a;","_specular = tex1.rgb * tex1.a;"],PS_Combiners_Mod_AddAlpha_Wgt:[2,"_output.rgb = (_input.rgb * tex0.rgb);","_output.a = tex0.a;","_specular = tex1.rgb * tex1.a * uTexSampleAlpha.g;"],PS_Combiners_Mod_AddAlpha_Alpha:[2,"_output.rgb = _input.rgb * tex0.rgb;","_output.a = (tex0.a + tex1.a * (0.3 * tex1.r + 0.59 * tex1.g + 0.11 * tex1.b));","_specular = tex1.rgb * tex1.a * (1.0 - tex0.a);"],PS_Combiners_Opaque_Mod_Add_Wgt:[2,"_output.rgb = _input.rgb * mix(tex0.rgb, tex1.rgb, vec3(tex1.a));","_specular = (tex0.rgb * tex0.a) * uTexSampleAlpha.r;"],PS_Guild:[3,"_output.rgb = _input.rgb * mix(tex0.rgb * mix(vec3(1.0, 1.0, 1.0), tex1.rgb * vec3(1.0, 1.0, 1.0), vec3(tex1.a)), tex2.rgb * vec3(1.0, 1.0, 1.0), vec3(tex2.a));","_output.a = tex0.a;"],PS_Guild_Opaque:[3,"_output.rgb = _input.rgb * mix(tex0.rgb * mix(vec3(1.0, 1.0, 1.0), tex1.rgb * vec3(1.0, 1.0, 1.0), vec3(tex1.a)), tex2.rgb * vec3(1.0, 1.0, 1.0), vec3(tex2.a));",""],PS_Guild_NoBorder:[2,"_output.rgb = _input.rgb * tex0.rgb * mix(vec3(1.0, 1.0, 1.0), tex1.rgb * vec3(1.0, 1.0, 1.0), vec3(tex1.a));","_output.a = tex0.a;"],PS_Combiners_Opaque_Alpha_Alpha:[2,"_output.rgb = _input.rgb * mix(mix(tex0.rgb, tex1.rgb, vec3(tex1.a)), tex0.rgb, vec3(tex0.a));",""],PS_Combiners_Opaque_Mod2xNA_Alpha_3s:[3,"_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.0, tex2.rgb, vec3(tex2.a));"],PS_Combiners_Mod_Add_Alpha:[2,"_output.rgb = _input.rgb * tex0.rgb;","_output.a = (tex0.a + tex1.a);","_specular = tex1.rgb * (1.0 - tex0.a);"],PS_Combiners_Opaque_ModNA_Alpha:[2,"_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb, tex0.rgb, vec3(tex0.a));",""],PS_Combiners_Opaque_Mod2xNA_Alpha_UnshAlpha:[3,"float glowOpacity = clamp((tex2.a * vec4(1.0, 1.0, 1.0, 1.0).z), 0.0, 1.0); _output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.000000, tex0.rgb, vec3(tex0.a)) * (1.0 - glowOpacity);","_specular = tex2.rgb * glowOpacity;"],PS_Combiners_Opaque_Mod2xNA_Alpha_Alpha:[3,"_output.rgb = _input.rgb * mix(mix(tex0.rgb * tex1.rgb * 2.000000, tex2.rgb, vec3(tex2.a)), tex0.rgb, vec3(tex0.a));",""],PS_Combiners_Mod_Depth:[1,"_output.rgb = _input.rgb * tex0.rgb;","_output.a = tex0.a;"],PS_Combiners_Opaque_Alpha:[2,"_output.rgb = _input.rgb * mix(tex0.rgb, tex1.rgb, vec3(tex1.a));",""],Skin:[3,"//Fresnel Rim\r\nif (uHasSpecEmiss) {\r\n vec3 emissiveColor = tex2.rgb;\r\n vec3 emissiveTerm = tex2.rgb;\r\n if (uHasEmissiveGlowing) {\r\n vec3 eyeVec_120 = vPosition.xyz;\r\n vec3 t121 = -(eyeVec_120);\r\n vec2 term_126 = vec2(dot(t121, vNormal), dot(normalize(t121), (vNormal * vec3(0.0500000007, 0.0500000007, 1.0))));\r\n vec2 invTerm_128 = (vec2(1.0) - clamp(term_126, 0.0, 1.0));\r\n vec2 f_129 = (invTerm_128 * invTerm_128);\r\n float fresnel_rim_133 = pow((f_129.x + f_129.y), 0.600000024);\r\n vec3 t136 = (tex2.rgb /*+ ((vec3(0.0500000007, 0.0, 0.400000006) * 1.0) * fresnel_rim_133)*/);\r\n emissiveColor = vec3(t136.r, tex2.g, t136.b);\r\n\r\n float t267 = dot(normalize(vNormal), normalize(-(vPosition.xyz)));\r\n emissiveTerm = mix(vec3(0.0), 2.0*emissiveColor, vec3(pow(clamp(t267, 0.0, 1.0), (( 128.0 * (tex2.a)) + 9.99999975e-006))));\r\n }\r\n\r\n _output.rgb = _input.rgb * tex0.rgb + tex1.rgb + emissiveTerm.rgb;\r\n} else {\r\n _output.rgb = _input.rgb * tex0.rgb;\r\n}\r\n_output.a = tex0.a; //"],PS_Combiners_Mod_Dual_Crossfade:[3,"_output.rgb = _input.rgb * mix(mix(tex0, texture2D(uTexture2,vTexCoord1), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,vTexCoord1), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).rgb;","_output.a = mix(mix(tex0, texture2D(uTexture2,vTexCoord1), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,vTexCoord1), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).a;"],PS_Combiners_Mod_Masked_Dual_Crossfade:[4,"_output.rgb = _input.rgb * mix(mix(tex0, texture2D(uTexture2,texCoord), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,texCoord), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).rgb;","_output.a = mix(mix(tex0, texture2D(uTexture2,texCoord), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,texCoord), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).a * texture(uTexture4,texCoord2).a;"],PS_Unknown_34821:[2,"_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;","_output.a = tex0.a * tex1.a;"]},tn=Kr;const en=class{constructor(){this.h=!1,this.i=!0}},rn=[0,1,2,10,3,4,5,13];const nn=class{constructor(t){this.E=!1,this.F=!1;var e=this;e.a=t.getUint8(),e.b=t.getInt8(),e.c=t.getUint16(),e.d=t.getUint16(),e.e=t.getUint16(),e.f=t.getInt16(),e.g=t.getUint16(),e.h=t.getUint16(),e.i=t.getUint16(),e.j=t.getInt16(),e.k=t.getUint16(),e.l=t.getInt16(),e.m=t.getInt16(),e.n=!0,e.o=null,e.p=null,e.q=0,e.r=null,e.s=[],e.t=[],e.u=new Array,e.v=null,e.w=[],e.x=!1,e.y=!1,e.z=!1,e.A=Qi(),e.B=ve(),e.C=xr()}K(t){var e=this;e.o=t,e.p=t.as[e.d],e.q=e.p.a,Jr.c(e);let i=this.o.ax[e.j];1==this.i&&i>-1&&1==this.o.aw[i].c&&(this.c=-1e3,this.i=3);const r=tn.d(e.c,e.i,e.r);e.H=r;for(let i=0;i-1&&e.j-1&&r-1&&e.m-1&&t.ay&&r-1&&e.l-1&&r-1&&e.f1}L(){const t=this,e=t.o.aS.context,i=ge.GetProgram(e,t.H.name,t.H.config);t.G=i,t.H=i.program,t.I=i.uniforms}M(){let t=er(this.p.i[0],this.p.i[1],this.p.i[2],1),e=this.o.ap[this.p.g].m,i=je();Ye(i,i,this.o.aW.uViewMatrix),Ye(i,i,this.o.U),Ye(i,i,e),lr(t,t,i),t[3]=0;let r=hr(t);if((3&this.a)>0){let e=Qi();r>0?ar(e,t,1/r):ir(e,t),ar(e,e,Te(we(i[8],i[9],i[10]))*this.p.j),1&this.a?nr(e,t,e):rr(e,t,e),r=sr(e)}return r}N(t){const e=this,i=e.o,r=e.o.aS.context,n=e.o.R;if(e.G||e.L(),!e.G.program)return;if(this.J||(this.J=new en,this.J.a=e.G,this.J.b=Object.assign({},i.aW)),this.J.c=i.aU,this.J.d=i.aV,this.J.b=Object.assign({},i.aW),e.A[0]=e.A[1]=e.A[2]=e.A[3]=1,e.v&&e.v.g(n,e.o.aX,e.A),e.w[0]&&(e.A[3]*=e.w[0].d(n,e.o.aX)),e.A[3]<=.001)return;let a=e.r.b;const s=[0,0,0];for(let t=0;t{if(!e.o.S&&(qe(e.u[i]),e.t[i])){let t=!1,r=!1;e.t[i].a&&e.t[i].a.c(n.a.a)?(e.B=e.t[i].a.d(n,e.o.aX),r=!0):Ae(e.B,0,0,0),e.t[i].b&&e.t[i].b.c(n.a.a)?(e.C=e.t[i].b.d(n,e.o.aX),t=!0):Fr(e.C,0,0,0,1);let a,s=!1;if(e.t[i].c&&e.t[i].c.c(n.a.a)&&(a=e.t[i].c.d(n,e.o.aX),s=!0),qe(e.u[i]),Ze(e.u[i],e.u[i],we(.5,.5,0)),s&&Je(e.u[i],e.u[i],a),t){let t=je();ei(t,e.C,[0,0,0]),Ye(e.u[i],e.u[i],t)}r&&Ze(e.u[i],e.u[i],e.B),Ze(e.u[i],e.u[i],we(-.5,-.5,0))}this.J.b["uTextureMatrix"+(i+1).toString()]=e.u[i]})),this.J.h=e.y,this.J.f=!e.z,this.J.j=r.TRIANGLES,this.J.l=2*e.p.e,this.J.k=e.p.f,t.push(this.J)}O(){let t=0;const e=[];this.s.forEach(((i,r)=>{const n=r;let a=null;if(this.s[n])if(this.s[0]&&1==this.s[0].c&&r>0)1==r?a=this.o.aJ&&this.o.aJ.b?{d:this.o.aJ.b}:{d:this.o.aS.blackPixelTexture}:2==r&&(a=this.o.aJ&&this.o.aJ.c?{d:this.o.aJ.c}:{d:this.o.aS.blackPixelTexture});else if(1==this.s[n].c)this.o.aK?a=this.o.aK.a:this.o.aJ&&this.o.aJ.a&&(a={d:this.o.aJ.a});else if(this.s[n].f)a=this.s[n].f;else if(((this.o.a.type<8||this.o.a.type>32)&&2==this.s[n].c||[2,11,12,13].includes(this.s[n].c))&&this.o.B[this.s[n].b])a=this.o.B[this.s[n].b];else if(-1!=this.s[n].c&&this.o.B[this.s[n].c])a=this.o.B[this.s[n].c];else if(-1!=this.s[n].c&&this.o.C[this.s[n].c][n])a=this.o.C[this.s[n].c][n].a;else if(8==this.s[n].c&&this.o.v)a=this.o.v.C[this.s[n].c][0].a;else if(!this.s[n].e&&this.j+t1?i=1:i<0&&(i=0),i}};const cn=class{constructor(){this.a=0,this.b=0,this.c=-1,this.d=null,this.e=null}};class fn extends cn{}const dn=class{constructor(t,e){this.d=!1,this.a=t,this.b=e,this.c=new Array(e.length)}e(t){for(let e=0;e>16&255)/255,(t>>8&255)/255,(255&t)/255,this.a.V[3])}else if(14==this.b[e].ProcEffectType){let t=Math.min(Math.max(this.b[e].Value[0],0),1);this.a.V[3]=t}else if(22==this.b[e].ProcEffectType){let t=this.b[e].Value[3];this.a.V=er((t>>16&255)/255,(t>>8&255)/255,(255&t)/255,this.a.V[3])}break;case 2:this.h(e,t)}}h(t,e){if(!this.a)return;if(!this.a.d)return;if(!this.c[t]){let e=this.b[t].AttachmentID;this.b[t].Positioner>-1&&(e=this.b[t].Positioner),e<0&&(e=19);let i=this.a.bV(e);if(this.c[t]=new fn,this.c[t].d=i,this.c[t].c=i?i.b:-1,0==this.b[t].ModelType){let e={type:hi.PATH,id:this.b[t].Model,parent:this.a,shoulder:-1};this.c[t].e=new $n(this.a.aS,this.a.k,e,0,!1,!0,!1)}else if(1==this.b[t].ModelType){let e=this.a.n>0?this.a.n:1,i=-1!=this.a.o?this.a.o:0;this.a.n=e,this.a.o=i,this.c[t].ba=new _n(this.a,this.b[t].InvType,this.b[t].Model,e,i)}else if(2==this.b[t].ModelType){let e={type:hi.NPC,id:this.b[t].Model,parent:this.a,shoulder:-1};this.c[t].e=new $n(this.a.aS,this.a.k,e,0,!1,!0,!1)}}if(!(0!=this.b[t].ModelType||this.c[t].e&&this.c[t].e.d))return;if(!(1!=this.b[t].ModelType||this.c[t].ba&&this.c[t].ba.m))return;if(!(2!=this.b[t].ModelType||this.c[t].e&&this.c[t].e.d))return;let i=je();Qe(i,i,-this.b[t].Yaw),$e(i,i,this.b[t].Pitch),Ke(i,i,this.b[t].Roll),Je(i,i,[this.b[t].Scale1,this.b[t].Scale1,this.b[t].Scale1]),Je(i,i,[this.b[t].Scale2,this.b[t].Scale2,this.b[t].Scale2]);let r=je();if(this.c[t].d){let e=this.c[t].d.c;Ye(r,r,this.a.ap[this.c[t].c].m),Ze(r,r,we(e[0],e[1],e[2]))}if(Ze(r,r,we(this.b[t].Offset[0],-this.b[t].Offset[1],this.b[t].Offset[2])),Ye(r,r,i),0==this.b[t].ModelType){let i=this.c[t].e;i.setAnimPaused(this.d),i.bs(this.a.U,r,null,null),i.bY(e)}else if(1==this.b[t].ModelType)for(let i=0;i=5||r&&r.d&&(e=r.d.c),-1!=r.c){let i=this.a.ap[r.c].m;r.e.bs(this.a.U,i,e,null),r.e.bY(t)}}}}}};class gn{static a(t,e,i,r,n){let a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];if(!e)return WH.debug("selectBestTexture:","textures are null"),null;for(let t=0;t1||o!=i){if(o<2)continue;c=0}else c=2;let f=1;if(r>0&&l==r)f=0;else if(l>0)continue;let d=1;if(n>0&&h==n)d=0;else if(h>0)continue;a[u+3*(d+2*(c+f))]=s.FileDataId}for(let t=0;t<2;t++)for(let e=0;e<2;e++)for(let i=0;i<2;i++){let r=3*(t+2*(e+2*i));if(a[r]>0){let t;return t={a:a[r],b:a[r+1],c:a[r+2]},t}}if(t){let a=t.bR(i,n,!0);if(a&&0!=a[0])return n=a[0],i=a[1],gn.a(t,e,i,r,n)}return null}static b(t,e,i,r,n,a){let s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(let t=0;t1||l!=r){if(l<2)continue;f=0}else f=2;let d=1;if(n>0&&h==n)d=0;else if(h>0)continue;let b=1;if(a>0&&u==a)b=0;else if(u>0)continue;let g=1;if(-1==i||c!=i){if(-1!=c&&-1!=i)continue}else g=0;s[g+2*(b+2*(f+d))]=o.FileDataId}for(let t=0;t<2;t++)for(let e=0;e<2;e++)for(let i=0;i<2;i++)for(let r=0;r<2;r++){let n=r+2*(t+2*(e+2*i));if(s[n])return s[n]}if(t){var o=t.bR(r,a,!1);if(o&&0!=o[0])return a=o[0],r=o[1],gn.b(t,e,i,r,n,a)}return 0}}const _n=class{constructor(t,e,i,r,n){this.q=null,this.r=[],WH.debug("Creating item",i),this.a=t,this.b=e,this.s=i,this.t=r,this.u=n,this.e=pi[e],this.f=mi[e],this.i=null,this.j=null,this.k=null,this.g=0,this.h=0,this.m=!1,this.n=!1,this.o=0,this.p=3,i&&this.y()}x(){var t=this;if(t.i){for(let e=0;e0&&(this.f+=2),0!=this.o){const t=2==this.c?this.d:-1;for(let e=0;ee){let i=this.a.aB[t[e]];if(this.i[e].c=i.b,this.i[e].d=i,this.r[e]&&this.r[e].b){const t=this.i[e].e;for(let r=0;r-1&&n.c>17,t^=t<<5,this.b=t,t}e(){let t,e=this.d();return this.a.setInt32(0,1065353216|8388607&e),t=2147483648&e?2-this.a.getFloat32(0):this.a.getFloat32(0)-2,t}f(){let t=this.d();return this.a.setInt32(0,1065353216|8388607&t),this.a.getFloat32(0)-1}};const mn=class{constructor(){this.a=0,this.b=0,this.c=0,this.d=0,this.e=ve(),this.f=0,this.g=0,this.h=0,this.i=0,this.j=0}};const vn=class{constructor(t,e){this.b=t,this.c=e,this.a=new mn}d(){return this.a.d+this.b.e()*this.c.u}e(){return this.a.d+this.c.u}f(){return this.a.c+this.c.s}g(t){return this.a.c+30518509e-12*t*this.c.s}h(){let t=this.a.a;return t*=1+this.a.b*this.b.e(),t}i(){return this.a}j(t){ye(t,this.a.e)}};const xn=class extends vn{k(t,e){let i,r=e*this.b.f(),n=this.b.e();i=n<1?n>-1?Math.trunc(32767*n+.5):-32767:32767,t.d=i;let a=this.g(i);a<.001&&(a=.001),t.b=function(t,e){let i=Math.abs(t),r=Math.abs(e);return Number((i-Math.floor(i/r)*r).toPrecision(8))*Math.sign(t)}(r,a),t.e=65535&this.b.d(),Ae(t.a,this.b.e()*this.a.g*.5,this.b.e()*this.a.h*.5,0);let s=this.h(),o=this.a.f;if(o<.001){let e=this.a.i*this.b.e(),i=this.a.j*this.b.e(),r=Math.sin(e),n=Math.sin(i),a=Math.cos(e),o=Math.cos(i);Ae(t.c,o*r*s,n*r*s,a*s)}else{let e=ve();ye(e,t.a),e[2]=e[2]-o,Te(e)>1e-4&&(Ue(e,e),Fe(t.c,e,s))}}};const Tn=class extends vn{constructor(t,e,i){super(t,e),this.ba=i}k(t,e){let i,r=e*this.b.f(),n=this.b.e();i=n<1?n>-1?Math.trunc(32767*n+.5):-32767:32767,t.d=i;let a=this.g(i);a<.001&&(a=.001),t.b=function(t,e){let i=Math.abs(t),r=Math.abs(e);return Number((i-Math.floor(i/r)*r).toPrecision(8))*Math.sign(t)}(r,a),t.e=65535&this.b.d();let s=this.a.h-this.a.g,o=this.a.g+s*this.b.f(),l=this.a.i*this.b.e(),h=this.a.j*this.b.e(),u=Math.cos(l),c=we(u*Math.cos(h),u*Math.sin(h),Math.sin(l));Fe(t.a,c,o);let f=this.h(),d=this.a.f,b=we(.5,.5,.5);0==d?this.ba?Ae(b,0,0,1):Ae(b,u*Math.cos(h),u*Math.sin(h),Math.sin(l)):(Ae(b,0,0,d),Ce(b,t.a,b),Te(b)>1e-4&&Ue(b,b)),Fe(t.c,b,f)}};const wn=class{constructor(t){this.a=t.getInt32(),this.b=t.getUint32(),this.c=we(t.getFloat(),t.getFloat(),t.getFloat()),this.d=t.getInt16(),this.e=t.getInt16(),0!=(268435456&this.b)&&(this.f=[0,0,0],this.f[0]=31&this.e,this.f[1]=this.e>>5&31,this.f[2]=this.e>>10&31),this.g=t.getUint8(),this.h=t.getUint8(),this.i=t.getUint16(),this.j=t.getUint16(),this.k=t.getUint16(),this.l=t.getUint16(),this.m=new Gr(t,Or),this.n=new Gr(t,Or),this.o=new Gr(t,Or),this.p=new Gr(t,Or),this.q=new Gr(t,Br),this.r=new Gr(t,Or),this.s=t.getFloat(),this.t=new Gr(t,Or),this.u=t.getFloat(),this.v=new Gr(t,Or),this.w=new Gr(t,Or),this.x=new Gr(t,Or),this.y=new Vr(t),this.z=new jr(t),this.A=new Hr(t),this.B=[t.getFloat(),t.getFloat()],this.C=new jr(t),this.D=new jr(t),this.E=t.getFloat(),this.F=t.getFloat(),this.G=t.getFloat(),this.H=[t.getFloat(),t.getFloat()],this.I=t.getFloat(),this.J=t.getFloat(),this.K=t.getFloat(),this.L=t.getFloat(),this.M=t.getFloat(),this.N=t.getFloat(),this.O=we(t.getFloat(),t.getFloat(),t.getFloat()),this.P=we(t.getFloat(),t.getFloat(),t.getFloat()),this.Q=we(t.getFloat(),t.getFloat(),t.getFloat()),this.R=t.getFloat(),this.S=t.getFloat(),this.T=t.getFloat(),this.U=t.getFloat(),this.V=t.getFloat();var e=t.getInt32();this.W=new Array(e);for(var i=0;i>0,this.f=[fr(),fr()],this.g=[fr(),fr()]}};let An=new Array(128);for(let t=0;t<128;t++)An[t]=Math.random();const En=Xe(0,1,0,0,-1,0,0,0,0,0,1,0,0,0,0,1);class Cn{}class Sn{constructor(){this.a=ve(),this.b=0,this.c={a:fr(),b:ve(),c:0,d:0,e:0}}}function Mn(t){return er((t>>16&255)/255,(t>>8&255)/255,(t>>0&255)/255,(t>>24&255)/255)}const kn=class{constructor(t,e){this.E=0,this.U=!1,this.a=(new Date).getTime(),this.b=t;let i=new wn(e);if(i.i>=11&&i.i<=13){let e;t.u.Item&&t.u.Item.ParticleColor?e=t.u.Item.ParticleColor:t.u.Creature&&t.u.Creature.ParticleColor&&(e=t.u.Creature.ParticleColor),e&&(this.H=[Qi(),Qi(),Qi()],ir(this.H[0],Mn(e.Start[i.i-11])),ir(this.H[1],Mn(e.Mid[i.i-11])),ir(this.H[2],Mn(e.End[i.i-11])))}this.c=i,this.d=je(),this.e=je(),this.f=je(),this.g=je(),this.h=Qi(),this.i=pr(),this.j=ve(),this.k=1,this.l=ve(),this.m=0,this.n=ve(),this.o=ve(),this.p=[],this.q=ve(),this.r=0,this.s=0,this.t=0,this.u=0,this.v=ve(),this.w=ve(),this.x=0,this.y=0,this.z=0,this.A=0,this.B=0,this.C=0,this.D=0,this.F=[],this.G=[];for(let t=0;t<1e3;t++)this.G.push(4*t+0),this.G.push(4*t+1),this.G.push(4*t+2),this.G.push(4*t+3),this.G.push(4*t+2),this.G.push(4*t+1);switch(this.J=new pn(2147483647*Math.random()>>0),this.c.h){case 1:this.I=new xn(this.J,i);break;case 2:this.I=new Tn(this.J,i,0!=(256&this.c.b));break;default:this.I=null,WH.debug("Found unimplemented generator ",this.c.h)}const r=this.c.U-this.c.S;0!=r?(this.s=(this.c.V-this.c.T)/r,this.t=this.c.T-this.c.S*this.s):(this.s=0,this.t=0);let n=this.c.l;n<=0&&(n=1);let a=this.c.k;a<=0&&(a=1),this.y=n*a-1,this.z=0;let s=n,o=-1;do{++o,s>>=1}while(s);if(this.A=o,this.B=n-1,this.z=0,(32768&this.c.b)>0){let t=(this.y+1)*this.J.d();this.z=t/4294967296|0}if(this.C=1/n,this.D=1/a,(269484032&this.c.b)>0){const t=0!=(1&this.c.b>>28);this.r=t?2:3}else this.r=0;this.K=i.g>1}W(){var t=this;t.b=null,t.c.c=null,t.c.O=null,t.c.P=null,t.c.m=t.c.m.e(),t.c.n=t.c.n.e(),t.c.o=t.c.o.e(),t.c.p=t.c.p.e(),t.c.q=t.c.q.e(),t.c.r=t.c.r.e(),t.c.t=t.c.t.e(),t.c.v=t.c.v.e(),t.c.w=t.c.w.e(),t.c.x=t.c.x.e(),t.c.X=t.c.X.e(),t.c.y=t.c.y.d(),t.c.z=t.c.z.d(),t.c.A=t.c.A.d(),t.c.C=t.c.C.d(),t.c.D=t.c.D.d(),t.p=null}X(t,e,i){if(!this.I)return;let r=je(),n=this.I.i(),a=!0;this.c.X.c(t.a.a)&&(a=this.c.X.d(t,this.b.aX)>0),this.T=a;const s=we(0,0,0);a&&(n.a=this.c.m.d(t,this.b.aX,0),n.b=this.c.n.d(t,this.b.aX,0),n.i=this.c.o.d(t,this.b.aX,0),n.j=this.c.p.d(t,this.b.aX,0),this.c.q.d(t,this.b.aX,s,n.e),n.c=this.c.r.d(t,this.b.aX,0),n.d=this.c.t.d(t,this.b.aX,0),n.h=this.c.w.d(t,this.b.aX,0),n.g=this.c.v.d(t,this.b.aX,0),n.f=i?i.a:this.c.x.d(t,this.b.aX,0)),Ye(r,r,this.b.U),Ye(r,r,this.b.ap[this.c.d].m);let o=je();ti(o,we(this.c.c[0],this.c.c[1],this.c.c[2])),Ye(r,r,o),Ye(r,r,En);let l=je(),h=ve();We(l,this.b.aS.viewMatrix),ii(h,l),this.aa(e,r,h,null,this.b.aS.viewMatrix),this.ak(this.b.aS.viewMatrix);let u=this.b.aS.context;this.L?(u.bindBuffer(u.ARRAY_BUFFER,this.L),u.bufferData(u.ARRAY_BUFFER,new Float32Array(this.F),u.DYNAMIC_DRAW)):(this.L=u.createBuffer(),u.bindBuffer(u.ARRAY_BUFFER,this.L),u.bufferData(u.ARRAY_BUFFER,new Float32Array(this.F),u.DYNAMIC_DRAW)),this.M||(this.M=u.createBuffer(),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,this.M),u.bufferData(u.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.G),u.DYNAMIC_DRAW))}Y(t){if(this.p.length<=0)return;const e=this.b.aS.context;if(this.V||(this.V=new en,this.V.a=se(e,[" attribute vec3 aPosition;\n attribute vec4 aColor; attribute vec2 aTexcoord0; attribute vec2 aTexcoord1; attribute vec2 aTexcoord2; varying vec4 vColor; varying vec2 vTexcoord0; varying vec2 vTexcoord1; varying vec2 vTexcoord2; uniform mat4 uModelMatrix; uniform mat4 uViewMatrix; uniform mat4 uProjMatrix; void main(void) { vec4 pos = vec4(aPosition, 1); gl_Position = uProjMatrix * pos; vColor = aColor; vTexcoord0 = aTexcoord0; vTexcoord1 = aTexcoord1; vTexcoord2 = aTexcoord2; } "," precision mediump float;\n varying vec4 vColor; varying vec2 vTexcoord0; varying vec2 vTexcoord1; varying vec2 vTexcoord2; uniform bool uHasTexture; uniform bool uHasTexture2; uniform bool uHasTexture3; uniform bool uHasAlpha; uniform int uBlendMode; uniform int uPixelShader; uniform sampler2D uTexture; uniform sampler2D uTexture2; uniform sampler2D uTexture3; uniform float uAlphaTreshold; void main(void) { float lo_thresh = 0.01; vec4 color = vec4(1, 1, 1, 1); vec4 tex = vec4(1, 1, 1, 1); vec4 tex2 = vec4(1, 1, 1, 1); vec4 tex3 = vec4(1, 1, 1, 1); if (uHasTexture) { tex = texture2D(uTexture, vTexcoord0).rgba; } if (uHasTexture2) { tex2 = texture2D(uTexture2, vTexcoord1).rgba; } if (uHasTexture3) { tex3 = texture2D(uTexture3, vTexcoord2).rgba; } vec4 finalColor = vec4((tex * vColor ).rgb, tex.a*vColor.a ); if (uPixelShader == 0) { vec3 matDiffuse = vColor.xyz * tex.rgb; finalColor = vec4(matDiffuse.rgb, tex.a*vColor.a); } else if (uPixelShader == 1) { vec4 textureMod = tex*tex2; float texAlpha = (textureMod.w * tex3.w); float opacity = texAlpha*vColor.a; vec3 matDiffuse = vColor.xyz * textureMod.rgb; finalColor = vec4(matDiffuse.rgb, opacity); } else if (uPixelShader == 2) { vec4 textureMod = tex*tex2*tex3; float texAlpha = (textureMod.w); float opacity = texAlpha*vColor.a; vec3 matDiffuse = vColor.xyz * textureMod.rgb; finalColor = vec4(matDiffuse.rgb, opacity); } else if (uPixelShader == 3) { vec4 textureMod = tex*tex2*tex3; float texAlpha = (textureMod.w); float opacity = texAlpha*vColor.a; vec3 matDiffuse = vColor.xyz * textureMod.rgb; finalColor = vec4(matDiffuse.rgb, opacity); }; if (finalColor.a < uAlphaTreshold ) discard; gl_FragColor = finalColor; } "],null,null),this.V.b={},this.V.a.attributes=[{loc:e.getAttribLocation(this.V.a.program,"aPosition"),type:e.FLOAT,size:3,offset:0,stride:52},{loc:e.getAttribLocation(this.V.a.program,"aColor"),type:e.FLOAT,size:4,offset:12,stride:52},{loc:e.getAttribLocation(this.V.a.program,"aTexcoord0"),type:e.FLOAT,size:2,offset:28,stride:52},{loc:e.getAttribLocation(this.V.a.program,"aTexcoord1"),type:e.FLOAT,size:2,offset:36,stride:52},{loc:e.getAttribLocation(this.V.a.program,"aTexcoord2"),type:e.FLOAT,size:2,offset:44,stride:52}],this.V.c=this.L,this.V.d=this.M,this.V.m=this.c.j),!this.S)if(this.S=[null,null,null],0!=(268435456&this.c.b)){WH.debug("multitexture particle",this.c.f[0],this.c.f[1],this.c.f[2],this);for(let t=0;t-1&&e-1&&this.c.e1?this.r-1:0;let i=[this.S[0]&&this.S[0].f&&this.S[0].f.f,this.S[1]&&this.S[1].f&&this.S[1].f.f,this.S[2]&&this.S[2].f&&this.S[2].f.f];this.V.b.uTexture=this.S[0].f.d,this.V.b.uTexture2=i[1]?this.S[1].f.d:null,this.V.b.uTexture3=i[2]?this.S[2].f.d:null,this.V.b.uHasTexture=i[0]?1:0,this.V.b.uHasTexture2=i[1]?1:0,this.V.b.uHasTexture3=i[2]?1:0;let r=this.c.g;4==r&&(r=3),this.V.e=r,this.V.i=!this.b.aY;let n=-1;1==r?n=.501960814:r>1&&(n=1/255),this.V.b.uAlphaTreshold=n,this.V.h=!1,this.V.f=!1,this.V.j=e.TRIANGLES,this.V.k=6*this.E>>0,this.V.l=0,t.push(this.V)}Z(t,e){if(0==(16&this.c.b))for(let i=0;i0){let e=ve();if(ii(e,this.d),16384&this.c.b){Ce(this.o,e,this.l);let i=this.s*(Te(this.o)/t)+this.t;i>=0&&(i=Math.min(i,1)),Fe(this.n,this.o,i)}if(64&this.c.b){this.u+=t;let i=.03;if(this.u>i)if(this.u=0,0==this.p.length){let t=i/this.u,r=ve();Ce(r,e,this.l);let n=t*this.c.I;Se(this.v,r,we(n,n,n))}else Ae(this.v,0,0,0)}this.ac(t)}}ab(t,e,i){if(ye(this.w,e),null==i||16&this.c.b)Ge(this.d,t);else{let e=je();We(e,i),Ye(this.d,e,t)}let r=ve();ri(r,t),this.k=r[0]}ac(t){if((t=Math.max(t,0))<.1)ye(this.n,this.o);else{let e=Math.floor(t/.1);t=-.1*e+t;let i=Math.min(Math.floor(this.I.i().lifespan/.1),e),r=i+1,n=1;n=r<0?(1&r|r>>1)+(1&r|r>>1):r,Fe(this.n,this.o,1/n);for(let t=0;tMath.max(this.I.g(r.e),.001)?(this.ai(i),i--):this.aj(r,t,e)||(this.ai(i),i--),i++}}ae(t,e){t.a=ve(),t.b=ve(),t.c=ve(),t.d=0;let i=we(e,e,e),r=e*e*.5,n=we(r,r,r);Se(t.a,this.c.Q,i);let a=ve();this.I.j(a),Se(t.b,a,i),Se(t.c,a,n),t.d=this.c.J*e}af(t){if(!this.T)return;let e=this.I.d();for(this.x=this.x+t*e;this.x>1;)this.ag(t),this.x-=1}ag(t){let e=this.ah();if(this.I.k(e,t),!(16&this.c.b)){let t=er(e.a[0],e.a[1],e.a[2],1),i=er(e.c[0],e.c[1],e.c[2],0);lr(t,t,this.d),lr(i,i,this.d),ye(e.a,t),ye(e.c,i),8192&this.c.b&&(e.a[2]=0)}if(64&this.c.b){let t=1+this.I.i().speedVariation*this.J.e(),i=ve();Fe(i,this.v,t),Ee(e.c,e.c,i)}if(this.r>=2)for(let t=0;t<2;t++){e.f[t][0]=this.J.f(),e.f[t][1]=this.J.f();let a=fr();_r(a,this.c.aa[t],this.J.e()),i=e.g[t],r=a,n=this.c.Z[t],i[0]=r[0]+n[0],i[1]=r[1]+n[1]}var i,r,n}ah(){let t=new yn;return this.p.push(t),t}ai(t){this.p.splice(t,1)}aj(t,e,i){if(this.r>=2)for(let i=0;i<2;i++){let r=t.f[i][0]+e*t.g[i][0];t.f[i][0]=r-Math.floor(r),r=t.f[i][1]+e*t.g[i][1],t.f[i][1]=r-Math.floor(r)}Ee(t.c,t.c,i.a),16384&this.c.b&&2*e0)return!1}else{let i=ve();if(ii(i,this.d),Ce(e,t.a,i),Be(e,n)>0)return!1}}return!0}ak(t){if(this.F.length=0,0==this.p.length&&null!=this.I)return;We(this.f,t),mr(pr(),t),this.al(null,t);let e=0;for(let t=0;t=1e3)break}this.E=e}al(t,e){var i,r,n;16&this.c.b?Ye(this.g,e,this.d):null!=t?Ye(this.g,e,t):Ge(this.g,e),ii(this.h,e),4096&this.c.b&&(mr(this.i,this.g),16&this.c.b&&Math.abs(this.k)>0&&(i=this.i,r=this.i,n=1/this.k,i[0]=r[0]*n,i[1]=r[1]*n,i[2]=r[2]*n,i[3]=r[3]*n,i[4]=r[4]*n,i[5]=r[5]*n,i[6]=r[6]*n,i[7]=r[7]*n,i[8]=r[8]*n),Ae(this.j,this.i[6],this.i[7],this.i[8]),De(this.j)<=2.3841858e-7?Ae(this.j,0,0,1):Ue(this.j,this.j))}am(t){let e=0,i=0;if(0!=this.c.K||0!=this.c.N){let r=new pn(t.e);e=0==this.c.L?this.c.K:this.c.K+r.e()*this.c.L,i=0==this.c.N?this.c.M:this.c.M+r.e()*this.c.N}else e=this.c.K,i=this.c.M;return{deltaSpin:i,baseSpin:e}}an(t,e){let i=this.c.G,r=this.c.H,n=r[0],a=r[1]-n,s=0,o=t.e,l=t.b;if((i<1||0!=a)&&(s=127&l*this.c.F+o),i=1&&(r=1);let a=we(255,255,255),s=dr(1,1),o=1,l=e.c;this.c.y.i(r,a,l.b,this.H),this.H||Fe(l.b,l.b,1/255),this.c.A.i(r,s,l.a),l.e=this.c.z.i(r,1)/32767;let h=0;this.c.C.a.length>0?(o=0,l.c=this.c.C.i(r,o),l.c=this.y&l.c+this.z):65536&this.c.b?(h=(this.y+1)*n.d(),l.c=h/4294967296|0):l.c=0,o=0,l.d=this.c.D.i(r,o),l.d=l.d+this.z&this.y;let u=1;524288&this.c.b?(u=Math.max(1+n.e()*this.c.B[1],99999997e-12),l.a[0]=Math.max(1+n.e()*this.c.B[0],99999997e-12)*l.a[0]):(u=Math.max(1+n.e()*this.c.B[0],99999997e-12),l.a[0]=u*l.a[0]),l.a[1]=u*l.a[1]}ap(t,e){let i=dr((e.c.c&this.B)*this.C,(e.c.c>>this.A)*this.D),r=0,n=0,a=this.am(t);r=a.baseSpin,n=a.deltaSpin;let s=0,o=we(0,0,0),l=we(0,0,0),h=!1,u=!1;if(4&this.c.b&&De(t.c)>2.3841858e-7)if(s=1,4096&this.c.b)h=!0;else{let i=er(-t.c[0],-t.c[1],-t.c[2],0);lr(i,i,this.g);let r=ve();ye(r,i);let n=0,a=De(r);n=a<=2.3841858e-7?0:1/Math.sqrt(a);let s=ve();ye(s,r),Fe(s,s,n),ye(o,s),Fe(o,o,e.c.a[0]),l=we(s[1],-s[0],0),Fe(l,l,e.c.a[1]),u=!0,h=!1}if((4096&this.c.b||h)&&!u){let i=pr();c=i,f=this.i,c[0]=f[0],c[1]=f[1],c[2]=f[2],c[3]=f[3],c[4]=f[4],c[5]=f[5],c[6]=f[6],c[7]=f[7],c[8]=f[8];let a=e.c.a[0];if(s){let r=0,n=we(-t.c[0],-t.c[1],-t.c[2]),s=De(n);r=s<=2.3841858e-7?0:1/Math.sqrt(s),vr(i,this.i,function(t,e,i,r,n,a,s,o,l){var h=new me(9);return h[0]=t,h[1]=e,h[2]=i,h[3]=r,h[4]=n,h[5]=a,h[6]=s,h[7]=o,h[8]=l,h}(n[0]*r,n[1]*r,0,-n[1]*r,n[0]*r,0,0,0,1)),r>2.3841858e-7&&(a=e.c.a[0]*(1/Math.sqrt(De(t.c))/r))}if(this.r,Ae(o,i[0],i[1],i[2]),Fe(o,o,a),Ae(l,i[3],i[4],i[5]),Fe(l,l,e.c.a[1]),n=l[0],u=!0,0!=this.c.M||0!=this.c.N){let e=r+n*t.b;512&this.c.b&&1&t.e&&(e=-e);let i=ve();ye(i,this.j),this.r;let a=pr(),s=xr();Tr(s,i,e),function(t,e){var i=e[0],r=e[1],n=e[2],a=e[3],s=i+i,o=r+r,l=n+n,h=i*s,u=r*s,c=r*o,f=n*s,d=n*o,b=n*l,g=a*s,_=a*o,p=a*l;t[0]=1-c-b,t[3]=u-p,t[6]=f+_,t[1]=u+p,t[4]=1-h-b,t[7]=d-g,t[2]=f-_,t[5]=d+g,t[8]=1-h-c}(a,s),Ne(o,o,a),Ae(l,n,l[1],l[2]),Ne(l,l,a)}}var c,f;if(!u)if(0!=this.c.M||0!=this.c.N){let i=r+n*t.b;512&this.c.b&&1&t.e&&(i=-i);let a=Math.cos(i),s=Math.sin(i);Ae(o,a,s,0),Fe(o,o,e.c.a[0]),Ae(l,-s,a,0),Fe(l,l,e.c.a[1]),134217728&this.c.b&&Ee(e.a,e.a,we(l[0],l[1],0))}else Ae(o,e.c.a[0],0,0),Ae(l,0,e.c.a[1],0);return this.ar(o,l,e.a,e.c.b,e.c.e,i[0],i[1],t.f),0}aq(t,e){let i=dr((e.c.d&this.B)*this.C,(e.c.d>>this.A)*this.D),r=we(0,0,0),n=we(0,0,0),a=this.c.E;1024&this.c.b&&(a=Math.min(t.b,a));let s=Qi();Fe(s,t.c,-1),s[3]=0,lr(s,s,this.g),Fe(s,s,a);let o=we(s[0],s[1],0);if(Be(o,o)>1e-4){let t=1/Te(o);_r(e.c.a,e.c.a,t),gr(o,o,e.c.a),n=we(-o[1],o[0],0),Fe(r,s,.5),Ee(e.a,e.a,r)}else r=we(.05*e.c.a[0],0,0),n=we(0,.05*e.c.a[1],0);return this.ar(r,n,e.a,e.c.b,e.c.e,i[0],i[1],t.f),1}ar(t,e,i,r,n,a,s,o){const l=[-1,-1,1,1],h=[1,-1,1,-1],u=[0,0,1,1],c=[0,1,0,1];let f=ve(),d=fr(),b=fr(),g=fr();for(let _=0;_<4;_++)Ae(f,0,0,0),Re(f,f,t,l[_]),Re(f,f,e,h[_]),Ee(f,f,i),br(d,u[_]*this.C+a,c[_]*this.D+s),br(b,u[_]*this.c.Y[0]+o[0][0],c[_]*this.c.Y[0]+o[0][1]),br(g,u[_]*this.c.Y[1]+o[1][0],c[_]*this.c.Y[1]+o[1][1]),this.F.push(f[0]),this.F.push(f[1]),this.F.push(f[2]),this.F.push(r[0]),this.F.push(r[1]),this.F.push(r[2]),this.F.push(n),this.F.push(d[0]),this.F.push(d[1]),this.F.push(b[0]),this.F.push(b[1]),this.F.push(g[0]),this.F.push(g[1])}};const Fn=class{constructor(t){this.a=t.getFloat()}};const Rn=class{constructor(t){this.buffer=new DataView(t),this.position=0}getBool(){var t=0!=this.buffer.getUint8(this.position);return this.position+=1,t}getUint8(){var t=this.buffer.getUint8(this.position);return this.position+=1,t}getInt8(){var t=this.buffer.getInt8(this.position);return this.position+=1,t}getUint16(){var t=this.buffer.getUint16(this.position,!0);return this.position+=2,t}getInt16(){var t=this.buffer.getInt16(this.position,!0);return this.position+=2,t}getUint32(){var t=this.buffer.getUint32(this.position,!0);return this.position+=4,t}getInt32(){var t=this.buffer.getInt32(this.position,!0);return this.position+=4,t}getFloat(){var t=this.buffer.getFloat32(this.position,!0);return this.position+=4,t}getString(t){void 0===t&&(t=this.getUint16());for(var e="",i=0;i0){i.j=new Array(r);for(let t=0;t0){i.k=new Array(r);for(let t=0;t>1)+(1&e|e>>1));let r=i*this.l+this.G.b;this.p.b=r;let n=t/this.I,a=n;0!=(2147483648&n)&&(n=1&n|n>>1,a=n+n,r=this.p.b);let s=a*this.m+this.G.a;this.p.a=s,this.p.d=r+this.l,this.p.c=s+this.m}}aq(t,e,i){let r,n=this.i[2*this.d],a=this.i[2*this.d+1],s=ve();Fe(s,this.v,1-e),Ce(s,this.x,s),Fe(n.a,s,e),Fe(s,this.u,e),Ee(s,this.w,s),Fe(s,s,1-e),Ee(n.a,n.a,s),Fe(s,this.v,1-e),Ce(s,this.z,s),Fe(a.a,s,e),Fe(s,this.u,e),Ee(s,this.y,s),Fe(s,s,1-e),Ee(a.a,a.a,s),this.c[this.d]=t,r=i,this.d=this.d+r,this.d>=this.c.length&&(this.d-=this.c.length)}ar(t,e){if(this.a.S)return;let i=ve(),r=1;i=this.U.l.d(t,this.a.aX,i),r=this.U.m.d(t,this.a.aX),this.ao(i[0],i[1],i[2]),this.ak(r/32767);let n=this.U.n.d(t,this.a.aX);this.aj(n);let a=this.U.o.d(t,this.a.aX);this.ai(a);let s=this.U.p.d(t,this.a.aX);this.ap(s);let o=this.U.q.d(t,this.a.aX,1);this.af(0!=o);let l=je();ai(l,this.a.U,this.a.ap[this.U.b].m),Ze(l,l,this.U.c);let h=ve();this.am(l,h,null),this.as(e,!1)}as(t,e){let i,r,n,a,s,o,l,h,u,c,f,d,b,g,_,p,m,v,x,T,w,y,A,E,C,S,M,k,F,R,D,I,U,B,P,z,O,N,L,H,V,j,G,X,q,W,Y,Z;for(this.N||this.C>0&&(t=1/this.C+99999997e-12),t>=0?this.D<=t&&(t=this.D):t=0,v=this.e;v!=this.d&&!(t+this.c[v]<=this.D);v=this.e)this.e=this.at(this.e,1);if(!e&&this.M&&this.L&&this.J){D=t*this.C+this.f,Z=this.F,this.al();let e=!1;if(B=0,D<1?e=!0:(Y=this.f,U=1/(D-Y),m=Math.floor(D-1),B=Math.ceil(Math.max(m,0))),-1==B||e);else for(I=1,v=1;R=this.d,N=this.i.length,this.i[2*R].b=Z,x=2*this.d+1,L=this.i.length,this.i[x].b=Z,this.aq((v-Y)*U*-t,(v-Y)*U,1),-1!=--B;v=I)I+=1,Y=this.f;T=Math.floor(D),this.f=D-T,this.aq(0,1,0),F=this.d,H=this.i.length,w=this.i[2*F],y=this.p.b,w.c[1]=this.p.a,w.c[0]=y,A=2*this.d+1,V=this.i.length,E=this.i[A],C=this.p.b,E.c[1]=this.p.c,E.c[0]=C,k=this.d,j=this.i.length,this.i[2*k].b=Z,S=2*this.d+1,G=this.i.length,this.i[S].b=Z}this.A[2]=34028235e31,this.A[1]=34028235e31,this.A[0]=34028235e31,this.B[2]=-34028235e31,this.B[1]=-34028235e31,this.B[0]=-34028235e31,P=this.e;for(let e=this.e;e!=this.d;P=e)p=2*e,W=this.i.length,M=P,O=this.i[2*e],i=p+1,r=this.i[2*e+1],n=(this.S+this.S)*this.c[M]*t+t*this.S*t,O.a[2]=O.a[2]+n,r.a[2]=n+r.a[2],a=O.a[0],s=this.A[0],s>O.a[0]&&(s=O.a[0],this.A[0]=a,a=O.a[0]),o=O.a[1],l=this.A[1],l>o&&(l=O.a[1],this.A[1]=o,o=O.a[1]),h=O.a[2],u=this.A[2],u>h&&(u=O.a[2],this.A[2]=h,h=O.a[2]),a>this.B[0]&&(this.B[0]=a),o>this.B[1]&&(this.B[1]=o),h>this.B[2]&&(this.B[2]=h),c=r.a[0],s>r.a[0]&&(this.A[0]=c,c=r.a[0]),f=r.a[1],l>f&&(this.A[1]=f,f=r.a[1]),d=r.a[2],u>d&&(this.A[2]=d,d=r.a[2]),c>this.B[0]&&(this.B[0]=c),f>this.B[1]&&(this.B[1]=f),d>this.B[2]&&(this.B[2]=d),X=this.c.length,this.c[M]=t+this.c[M],b=this.l,q=this.c.length,g=b*this.c[M]*this.k+this.p.b,O.c[1]=this.p.a,O.c[0]=g,r.c[1]=this.p.c,r.c[0]=g,_=this.c.length,z=P+1,e=z-_,_>z&&(e=z);this.N=!0}at(t,e){let i=e+t;t=i;let r=this.c.length;return i>=r&&(t=i-r),t}au(t,e,i,r,n,a){let s,o,l,h,u,c,f,d;f=Math.ceil(t),d=Math.max(.25,e),s=Math.ceil(d*f),o=Math.ceil(Math.max(s+1+1,0)),this.c=new Array(o),this.e=0,this.d=0,this.f=0,this.J=!1,this.i=new Array(2*o);for(let t=0;t>1)+(1&a|a>>1)),this.l=(r.d-r.b)/l,h=n,0!=(2147483648&n)&&(h=(1&n|n>>1)+(1&n|n>>1)),this.m=(r.c-r.a)/h,this.n=1/this.l,this.o=1/this.m,this.C=f,this.D=d,ar(i,i,1/255),this.F=i,this.G=r,this.H=n,this.I=a,this.P=0,u=0*this.l+this.G.b,this.p.b=u,c=0*this.m+this.G.a,this.p.a=c,this.p.d=u+this.l,this.p.c=c+this.m,this.Q=10,this.R=10,this.S=0,this.M=!0,this.L=!0,this.K=!0}av(){let t=new Array(this.i.length);for(let e=0,i=0;ethis.a.aw.length)continue;let n=this.a.aw[i];if(!n.f||!n.f.f)continue;let a=r;a>=this.U.k.length&&(a=0);let s=this.a.av[this.U.k[a]];this.ab[r].b.uViewMatrix=this.a.aS.viewMatrix,this.ab[r].b.uProjMatrix=this.a.aS.projMatrix,this.ab[r].b.uTexture=n.f.d,this.ab[r].h=!1,this.ab[r].f=!1,this.ab[r].e=Un[s.b],this.ab[r].i=!this.a.aY;let o=this.d>this.e?2*(this.d-this.e)+2:2*(this.c.length+this.d-this.e)+2;this.ab[r].j=e.TRIANGLE_STRIP,this.ab[r].k=o,this.ab[r].l=2*this.e*2,t.push(this.ab[r])}}},On="uniform float x;\r\nuniform float y;\r\nuniform float width;\r\nuniform float height;\r\n\r\nattribute vec2 aTextCoord;\r\nvarying vec2 vTextCoords;\r\nvoid main() {\r\n vTextCoords = aTextCoord;\r\n\r\n vec2 pos = vec2(\r\n (x + aTextCoord.x*width)* 2.0 - 1.0,\r\n (y + aTextCoord.y*height)* 2.0 - 1.0\r\n );\r\n\r\n gl_Position = vec4(pos.x, pos.y, 0, 1);\r\n}";class Nn{constructor(){this.a=null,this.b=null,this.c=null}d(){null!=this.a&&this.a.h(),null!=this.b&&this.b.h(),null!=this.c&&this.c.h()}e(){return!(this.a&&!this.a.g())&&(!(this.b&&!this.b.g())&&!(this.c&&!this.c.g()))}}class Ln{constructor(){this.a=null,this.b=null,this.c=null,this.d={},this.i=new be}}let Hn=null,Vn=null,jn=null;class Gn{constructor(t,e,i){this.h=!1,this.e=t,this.f=e,this.g=i,function(t){Vn=t.createTexture(),t.bindTexture(t.TEXTURE_2D,Vn),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([0,0,0,0])),t.bindTexture(t.TEXTURE_2D,null),jn=t.createTexture(),t.bindTexture(t.TEXTURE_2D,jn),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([0,0,0,255])),t.bindTexture(t.TEXTURE_2D,null),Hn=new Ln;let e=Hn;e.a=se(t,[On,"precision mediump float;\r\nvarying vec2 vTextCoords;\r\nuniform sampler2D uDiffuseTexture;\r\nuniform sampler2D uSpecularTexture;\r\nuniform sampler2D uEmissiveTexture;\r\nuniform sampler2D renderResultTexture;\r\nuniform int uBlendMode;\r\nuniform int layer;\r\nuniform vec2 screenResolution;\r\n\r\nfloat overlayBlend(float a, float b) {\r\n if (b <= 0.5) {\r\n return 2.0 * a * b;\r\n } else {\r\n return 1.0 - ((2.0 * (1.0 - a) * (1.0 - b)));\r\n// return (1.0 - (1.0 - 2.0 * (a - 0.5)) * (1.0 - b));\r\n }\r\n}\r\n\r\nfloat alphaStraightBlend(float a, float b, float alpha) {\r\n return (a * alpha) + (b * (1.0 - alpha));\r\n}\r\n\r\nvoid main() {\r\n vec4 diffuse = texture2D( uDiffuseTexture, vTextCoords.xy );\r\n vec4 backGround = texture2D( renderResultTexture, gl_FragCoord.xy / screenResolution );\r\n\r\n //Blit and Inferior Alpha\r\n if (uBlendMode == 0 || uBlendMode == 4) {\r\n if (diffuse.a < 0.001) discard;\r\n\r\n vec3 finalColor = mix(backGround.rgb, diffuse.rgb, diffuse.a);\r\n\r\n diffuse = vec4(finalColor.rgb, 1.0);\r\n } else\r\n if (uBlendMode == 1) {\r\n // Multiply blending //\r\n if (diffuse.a < 0.001) discard;\r\n\r\n vec4 multTexture = diffuse;\r\n vec3 finalColor = (diffuse.rgb * backGround.rgb);\r\n\r\n diffuse = vec4(finalColor.rgb, 1.0);\r\n } else if (uBlendMode == 2) {\r\n // Overlay Blending //\r\n if (diffuse.a < 0.001) discard;\r\n\r\n vec4 overlayTex = diffuse;\r\n\r\n vec3 finalColor = vec3(\r\n overlayBlend(overlayTex.r, backGround.r),\r\n overlayBlend(overlayTex.g, backGround.g),\r\n overlayBlend(overlayTex.b, backGround.b)\r\n );\r\n\r\n diffuse = vec4(finalColor, 1.0);\r\n// diffuse = vec4(finalColor.rgb, overlayTex.a);\r\n } else if (uBlendMode == 3) {\r\n// if (diffuse.a > 0.5) discard;\r\n // Alpha Straight //\r\n vec4 overlayTex = diffuse;\r\n\r\n float alphaMult = 1.0;\r\n vec3 finalColor = vec3(\r\n alphaStraightBlend(overlayTex.r, backGround.r, alphaMult*overlayTex.a),\r\n alphaStraightBlend(overlayTex.g, backGround.g, alphaMult*overlayTex.a),\r\n alphaStraightBlend(overlayTex.b, backGround.b, alphaMult*overlayTex.a)\r\n );\r\n\r\n diffuse = vec4(finalColor.rgb, 1.0);\r\n// diffuse = vec4(1.0,1.0,1.0, 1.0-overlayTex.a);\r\n }\r\n\r\n gl_FragColor = diffuse;\r\n}"],null,null),e.b=se(t,[On,"precision mediump float;\r\n\r\nvarying vec2 vTextCoords;\r\nuniform sampler2D uDiffuseTexture;\r\nuniform sampler2D uSpecularTexture;\r\nuniform sampler2D uEmissiveTexture;\r\nuniform sampler2D renderResultTexture;\r\nuniform int uBlendMode;\r\n\r\nvoid main() {\r\n vec4 diffuse = texture2D( uDiffuseTexture, vTextCoords.xy );\r\n vec4 specular = texture2D( uSpecularTexture, vTextCoords.xy );\r\n if (diffuse.a < 0.001) discard;\r\n gl_FragColor = vec4(specular.rgb, 1.0);\r\n}"],null,null),e.c=se(t,[On,"precision mediump float;\r\n\r\nvarying vec2 vTextCoords;\r\nuniform sampler2D uDiffuseTexture;\r\nuniform sampler2D uSpecularTexture;\r\nuniform sampler2D uEmissiveTexture;\r\nuniform sampler2D renderResultTexture;\r\nuniform vec2 screenResolution;\r\nuniform int uBlendMode;\r\nuniform float emissiveAlphaOverride;\r\nuniform int layer;\r\n\r\nvoid main() {\r\n vec4 diffuse = texture2D( uDiffuseTexture, vTextCoords.xy );\r\n vec4 emissive = texture2D( uEmissiveTexture, vTextCoords.xy );\r\n vec4 backGround = texture2D( renderResultTexture, gl_FragCoord.xy / screenResolution );\r\n\r\n if (diffuse.a < 0.001) discard;\r\n// if (emissive.a < 0.001) discard;\r\n\r\n //TODO: This is a hack from what was obeserved in Nightbourn texture customization with tatoos.\r\n //TODO: But Maybe switch should be over layer or something else instead of blend\r\n float alpha = 1.0;\r\n\r\n if (emissiveAlphaOverride > -1.0) {\r\n alpha = emissiveAlphaOverride;\r\n } else if (layer <= 1) {\r\n alpha = 0.0;\r\n } else {\r\n alpha = emissive.a;\r\n }\r\n\r\n\r\n gl_FragColor = vec4(emissive.rgb, alpha);\r\n}"],null,null),e.d={},e.f=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,e.f),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),e.e=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.e),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Int16Array([0,1,2,1,3,2]),t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),e.g=t.createFramebuffer(),e.h={loc:t.getAttribLocation(e.a.program,"aTextCoord"),type:t.FLOAT,size:2,offset:0,stride:0}}(t)}i(){let t=this.e;this.d&&t.deleteTexture(this.d),this.a&&t.deleteTexture(this.a),this.b&&t.deleteTexture(this.b),this.c&&t.deleteTexture(this.c),this.d=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.d),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.f,this.g,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),this.a=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.a),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.f,this.g,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),this.b=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.b),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.f,this.g,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),this.c=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.c),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.f,this.g,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,Hn.g),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.a,0),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.b,0),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.c,0),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),t.useProgram(Hn.b.program),t.bindBuffer(t.ARRAY_BUFFER,Hn.f),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,Hn.e),Hn.i.disableAll(),Hn.i.enable(t,[Hn.h]),t.viewport(0,0,this.f,this.g)}j(t,e,i,r,n,a,s,o){let l=this.e;Hn.d.x=e,Hn.d.y=i,Hn.d.width=r,Hn.d.height=n,null==t.b&&null==t.c||(this.h=!0);let h=0;4==a?h=1:6==a?h=2:9==a?h=3:15==a&&(h=4),Hn.d.uBlendMode=h,Hn.d.screenResolution=new Float32Array([this.f,this.g]),Hn.d.uDiffuseTexture=null!=t.a?t.a.d:Vn,Hn.d.uSpecularTexture=null!=t.b?t.b.d:Vn,Hn.d.uEmissiveTexture=null!=t.c?t.c.d:jn,Hn.d.renderResultTexture=null!=this.d?this.d:Vn,Hn.d.layer=s,Hn.d.emissiveAlphaOverride=o,l.disable(l.CULL_FACE),l.disable(l.DEPTH_TEST),l.disable(l.BLEND),l.useProgram(Hn.a.program),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,this.a,0),l.bindTexture(l.TEXTURE_2D,this.d),l.copyTexImage2D(l.TEXTURE_2D,0,l.RGBA,0,0,this.f,this.g,0),l.bindTexture(l.TEXTURE_2D,null),re(Hn.a,Hn.d),l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0),l.useProgram(Hn.b.program),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,this.b,0),l.bindTexture(l.TEXTURE_2D,this.d),l.copyTexImage2D(l.TEXTURE_2D,0,l.RGBA,0,0,this.f,this.g,0),l.bindTexture(l.TEXTURE_2D,null),re(Hn.b,Hn.d),l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0),l.useProgram(Hn.c.program),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,this.c,0),l.bindTexture(l.TEXTURE_2D,this.d),l.copyTexImage2D(l.TEXTURE_2D,0,l.RGBA,0,0,this.f,this.g,0),l.bindTexture(l.TEXTURE_2D,null),re(Hn.c,Hn.d),l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0),l.useProgram(null)}k(){let t=this.e;t.bindFramebuffer(t.FRAMEBUFFER,null),t.enable(t.CULL_FACE),t.enable(t.DEPTH_TEST)}}class Xn{constructor(t,e){this.a=t,this.b=e}c(){const t=[];for(let e of this.b.Options)for(let i of e.Choices)for(let e of i.Elements)e.SkinnedModel&&t.push(e.SkinnedModel.CollectionFileDataID);const e=new Set(t);if(0!=e.size){e.size>1&&WH.debug("more than 1 skinned model detected!");let i=t[0],r={type:hi.PATH,id:i,parent:this.a,shoulder:0};this.a.aR=new $n(this.a.aS,this.a.k,r,0,!1,!1,!1)}}d(t){return gn.a(this.a,this.b.TextureFiles[t],this.a.o,this.a.p,this.a.n)}e(t){WH.debug("applyCustomization options",t),this.a.M=[],this.a.bu(0);for(let t=0;ti.Id==t[e].optionId));if(WH.debug("option",i),i){let r=i.Choices.find((i=>i.Id==t[e].choiceId));if(WH.debug("choice",r),r){let e=r.Elements.filter((e=>e.BoneSet&&e.BoneSet.BoneFileDataID&&(0==e.VariationChoiceID||t.some((t=>t.choiceId==e.VariationChoiceID)))));e.length>0&&this.a.bu(e[0].BoneSet.BoneFileDataID);let n=r.Elements.filter((e=>e.Material&&(0==e.VariationChoiceID||t.some((t=>t.choiceId==e.VariationChoiceID)))));n.sort(((t,e)=>e.VariationChoiceID-t.VariationChoiceID)),n.forEach((t=>{WH.debug("element material",t);let e=this.d(t.Material.MaterialResourcesID);if(!e)return void WH.debug("element material: can't get texture files for material",t);let i=this.b.TextureLayers.find((e=>e.ChrModelTextureTargetID==t.Material.TextureTarget));i?1==i.TextureType?t.Material.TextureTarget==Li?this.a.C[1][0]=this.a.bA(1,e):this.a.D[t.Material.TextureTarget]||(this.a.D[t.Material.TextureTarget]=this.a.bA(i.TextureSection,e)):6==i.TextureType?this.a.C[6][0]=this.a.bA(6,e):7==i.TextureType?this.a.C[7][0]=this.a.bA(7,e):8==i.TextureType?this.a.C[8][0]=this.a.bA(8,e):10==i.TextureType?this.a.C[10][0]=this.a.bA(10,e):19==i.TextureType?this.a.C[19][0]=this.a.bA(19,e):20==i.TextureType?this.a.C[20][0]=this.a.bA(20,e):21==i.TextureType?this.a.C[21][0]=this.a.bA(21,e):22==i.TextureType?this.a.C[22][0]=this.a.bA(22,e):WH.debug("unhandled texture type",i.TextureType,"target",t.Material.TextureTarget):WH.debug("element material: can't get texture layer for material",t)})),r.Elements.filter((e=>e.Geoset&&(0==e.VariationChoiceID||t.some((t=>t.choiceId==e.VariationChoiceID))))).forEach((t=>{WH.debug("element geoset",t),this.a.bD(t.Geoset)})),r.Elements.filter((e=>e.SkinnedModel&&(0==e.VariationChoiceID||t.some((t=>t.choiceId==e.VariationChoiceID))))).forEach((t=>{WH.debug("element skinnedmodel",t),this.a.aR&&this.a.aR.bD(t.SkinnedModel)}));let a=r.Elements.find((e=>0!=e.CondModelFileDataId&&(0==e.VariationChoiceID||t.some((t=>t.choiceId==e.VariationChoiceID)))));if(24==i.Id||353==i.Id)if(a&&!this.a.c){WH.debug("element condModel",a);let e=this.a.aS,i=this.a.a,r=e.models.indexOf(this.a);if(r>-1){e.models.splice(r,1),WH.debug("test 1!",t,e.options,i),e.options.charCustomization=this.a.q;let n=new $n(e,e.options,i,r,!0,!1,!1,a.CondModelFileDataId);return n.q=this.a.q,e.models.push(n),void this.a.ba()}}else if(!a&&this.a.c){let e=this.a.aS,i=this.a.a,r=e.models.indexOf(this.a);if(r>-1){e.models.splice(r,1),WH.debug("test 2!",t,e.options,i),e.options.charCustomization=this.a.q;let n=new $n(e,e.options,i,r,!0,!1,!1);return n.q=this.a.q,e.models.push(n),void this.a.ba()}}r.Elements.filter((e=>e.ChrCustItemGeoModifyID&&(0==e.VariationChoiceID||t.some((t=>t.choiceId==e.VariationChoiceID))))).forEach((t=>{WH.debug("element ChrCustItemGeoModify",t),this.a&&this.a.M.push(t.ChrCustItemGeoModifyID)}))}}}if(!this.a.C[6][0]){let e=this.b.Options.find((t=>t.Id==this.b.HairStyleOptionId));if(e){let i=e.Choices[1];if(i){let e=i.Elements.filter((e=>e.Material&&e.Material.TextureTarget==Hi&&(0==e.VariationChoiceID||t.some((t=>t.choiceId==e.VariationChoiceID)))));if(e.length>0){let t=this.d(e[0].Material.MaterialResourcesID);t&&(this.a.C[6][0]=this.a.bA(6,t))}}}}}f(){let t=[];for(let e=0;ee.optionId==t.Id))||e.options.push({optionId:t.Id,choiceId:t.Choices[0].Id});return e}}const qn=function(t,e){const i=Math.abs(t),r=Math.abs(e);return Number((i-Math.floor(i/r)*r).toPrecision(8))*Math.sign(t)},Wn=44,Yn=4400,Zn="DressingRoom",Jn="Stand";class Kn{constructor(t,e,i,r,n,a,s,o){this.e=!1,this.r=0,this.s=null,this.t=null,this.E=[],this.M=[],this.R=new Ir,this.T=!1,this.an=[],this.aG=[],this.aH=[],this.aJ=null,this.aQ=!1,this.aT=null,this.aU=null,this.aV=null,this.aX=[],this.aY=!1;var l=this;if(l.e=n,l.aS=t,l.a=i,l.b=r,l.c=o,l.d=!1,l.f=!0,l.g=!0,this.h=!1,l.ad=a,l.k=e,"classic"==l.k.gameDataEnv?(pi[14]=14,pi[15]=15):(pi[14]=22,pi[15]=22),l.i=null,l.l=l.k.mount&&l.k.mount.type==hi.NPC&&l.k.mount.id==l.a.id,l.j=null,l.m=l.k.pet&&l.k.pet.type==hi.NPC&&l.k.pet.id==l.a.id,l.a.type==hi.CHARACTER&&l.k.mount&&l.k.mount.type==hi.NPC&&l.k.mount.id&&(l.k.mount.parent=l,l.i=new Kn(t,e,l.k.mount,0,!1,!1,!1)),l.a.type==hi.CHARACTER&&l.k.pet&&l.k.pet.type==hi.NPC&&l.k.pet.id&&(l.k.pet.parent=l,l.j=new Kn(t,e,l.k.pet,0,!1,!1,!1)),l.k.extraModels&&!l.a.parent){l.A=[];const i=l.k.extraModels;if($.isArray(i))for(let r=0;r{e.x(),t.x.set(i,null)})),t.i&&t.i.ba(),t.i=null,t.j&&t.j.ba(),t.j=null,t.aR&&t.aR.ba(),t.aR=null,t.a=null,t.x=null,t.B=null,t.C=null,t.J=null,t.U=null,t.W=null,t.X=null,t.Y=null,t.Z=null,t.aa=null,t.ab=null,t.ae=null,t.af=null,t.ag=null,t.boundsSize=null,t.aM=null,t.aN=null,t.aO=null,t.aP=null}getNumAnimations(){const t=this.i?this.i:this;return t.an?t.an.length+1:0}getAnimation(t){const e=this.i?this.i:this;return e.an&&t>-1&&te.f(t)))}setAnimNoSubAnim(t){this.T=t}bg(t){var e;null===(e=this.j)||void 0===e||e.setAnimation(t)}setItems(t){WH.debug("setItems",t);const e=[];for(let i=0;i{const e=[parseInt(t[0]),parseInt(t[1])];this.k.items.push(e)})),this.bK(e),this.w=!0}attachList(t){WH.debug("attachList",t);const e=t.split(","),i=[];for(let t=0;t{const e=[parseInt(t[0]),parseInt(t[1])];this.k.items.push(e)})),this.bK(i),this.w=!0}clearSlots(t){WH.debug("clearSlots",t);const e=t.split(",");for(let t=0;t{0!=this.k.items[t].indexOf(parseInt(e))&&i.push(e)})),this.k.items=i}this.bJ(),this.w=!0}setShouldersOverride(t){if(WH.debug("setShouldersOverride",t),!t||2!=t.length)return;for(let t=0;t<2;t++){const e=this.y[t];e&&e.x(),this.y[t]=null}for(let e=0;e<2;e++)if(null!=t[e]){const i=new _n(this,wi,t[e],this.n,this.o);let r=0;r=0==e?1:2,i.B(r),this.y[e]=i}const e=this.x.get(wi);if(e){let t=3;for(let e=0;e<2;e++)this.y[e]&&(t&=~(1<{if(e.i)for(let i=0;ie.e(t))))}by(t){let e=this,i=e.aS.context;if(!e.ak||!e.al)return;const r=10*e.ak.length;if(e.aT||(e.aT=new Float32Array(r)),t){var n=e.aT,a=e.ak;for(let t=0,e=0;t0&&(s.v&&(i=s.v.g(e.R,this.aX)),s.w[0]&&(i[3]*=s.w[0].d(e.R,this.aX))),i[3]<.01)continue;let o=s.p;for(let i=0;i0)for(let e=0;e0&&(i.a=new an(this,t,e.a)),e.b>0&&(i.b=new an(this,t,e.b)),e.c>0&&(i.c=new an(this,t,e.c)),i}bB(){this.aQ||(this.a.type!=hi.CHARACTER&&this.a.type!=hi.NPC&&this.a.type!=hi.HUMANOIDNPC||this.n<1?this.bF():(this.bH(),this.aK||(this.w=!0)))}bC(t){t&&(this.J[t.geosetType]=100*t.geosetType+t.geosetID)}bD(t){t&&(this.K[t.GeosetType]=100*t.GeosetType+t.GeosetID)}bE(t,e,i){if(!this.at||0==this.at.length)return!1;let r;for(let n=0;n=t&&r.meshId<=e&&(r.show=i);return!0}bF(){if(this.bE(0,0,!0),0!=this.O&&(this.bE(1,1699,!1),this.N))for(let t of this.N){let e=100*(t.GeosetIndex+1),i=e+t.GeosetValue;this.bE(e,e+99,!1),this.bE(i,i,!0)}}bG(t,e){let i=[];for(let t=0;t0?i+e:r,a=t.at.some((t=>t.meshId==n));n=a?n:r,t.bE(n,n,!0)}function f(t,e,i){if(!t.at)return;let r=100*i,n=r+t.L[i]+e;t.bE(r,r+99,!1),t.bE(n,n,!0)}if(t.x.forEach((t=>{if(t&&t.q){let e=t.q;e.bE(0,Yn,!1),t.b==Ti?(c(e,t.k[0],2700),c(e,t.k[1],2100)):t.b==wi?c(e,t.k[0],2600):t.b==yi?(c(e,t.k[0],800),c(e,t.k[1],1e3)):t.b==Ai||t.b==Bi?(c(e,t.k[0],800),c(e,t.k[1],1e3),c(e,t.k[2],1300),c(e,t.k[3],2200),c(e,t.k[4],2800)):t.b==Ei?c(e,t.k[0],1800):t.b==Ci?(c(e,t.k[0],1100),c(e,t.k[1],900),c(e,t.k[2],1300)):t.b==Si?(c(e,t.k[0],500),c(e,t.k[1],2e3)):t.b==ki?(c(e,t.k[0],400),c(e,t.k[1],2300)):t.b==Ii?c(e,t.k[0],1500):t.b==Ui&&c(e,t.k[0],1200)}})),t.x.forEach((t=>{if(t&&t.i)for(let e of t.i){let i=e.e;t.b==Ti?(f(i,t.l[0],27),f(i,t.l[1],21)):t.b==wi?f(i,t.l[0],26):t.b==yi?(f(i,t.l[0],8),f(i,t.l[1],10)):t.b==Ai||t.b==Bi?(f(i,t.l[0],8),f(i,t.l[1],10),f(i,t.l[2],13),f(i,t.l[3],22),f(i,t.l[4],28)):t.b==Ei?f(i,t.l[0],18):t.b==Ci?(f(i,t.l[0],11),f(i,t.l[1],9),f(i,t.l[2],13)):t.b==Si?(f(i,t.l[0],5),f(i,t.l[1],20)):t.b==ki?(f(i,t.l[0],4),f(i,t.l[1],23)):t.b==Ii?f(i,t.l[0],15):t.b==Ui&&f(i,t.l[0],12)}})),e){const i=t.n,r=t.o==ui.MALE?e.v:e.w;if(r)for(let e=0;e2?(t.bE(1300,1399,!1),t.bE(i,i,!0)):m||t.bE(i,i,!0)}if(u&&u.k&&u.k[0]){t.bE(1500,1599,!1);let e=1501+u.k[0];if(this.M.length>0)for(let t of this.M){const i=li[t];i&&15==i.a&&i.b==u.k[0]+1&&(e=1500+i.c)}t.bE(e,e,!0)}if(n&&n.k&&n.k[0]){t.bE(1800,1899,!1);let e=1801+n.k[0];t.bE(e,e,!0)}if(a||p||_||m||b?t.bE(1400,1499,!1):t.bE(1401,1401,!0),t.aR){let e=t.aR;e.bE(0,Yn,!1);for(let t=0;tt.meshId==i))){let e=100*t;this.bE(e,e+99,!1)}}}}bI(){var t=this;let e=!1;if(t.x.forEach((t=>{if(t.m||t.n){if(t.j)for(let i=0;i{let e=t.e;e!=yi&&e!=Ai&&e!=Ui||(s=!1),e==Ci&&(o=!1)}));let l,h=Yi;a.f!=a.g&&(h=Zi);let u=this.F.b.TextureLayers,c=this.F.b.TextureSections,f=-1;if(this.n==bi)for(let t of u)9==t.BlendMode&&1==t.TextureType&&t.Layer>f&&(f=t.Layer);for(let e of u){if(1!=e.TextureType)continue;if(0==e.Layer){a.j(t.C[1][0],0,0,1,1,0,0,0);continue}let i=-1;e.Layer==f&&(i=0);let r=this.D[e.ChrModelTextureTargetID];if(r){if(!r.e())return void WH.debug("texture target",e.ChrModelTextureTargetID,"layer",e.Layer,"not ready!");let t=e.TextureSection;if(t!=Gi&&t!=Xi||s&&t==Gi||o&&t==Xi){let n=0,s=0,o=1,u=1;if(-1!=t)if(c){let e=c.find((e=>e.SectionType==t));n=e.X,s=e.Y,o=e.Width,u=e.Height}else l=h[t],n=l.x,s=l.y,o=l.w,u=l.h;a.j(r,n,s,o,u,e.BlendMode,e.Layer,i)}}}let d=[];t.x.forEach((t=>{d.push(t)})),d.sort((function(t,e){return t.f-e.f}));for(let e=0;e0&&i0&&i[0],[Ni]:t=>2==t.c&&18==t.d?[1]:null};if(this.aB&&this.aC){const n={1:t=>[11],3:t=>[6,5],22:t=>{var e;return(null===(e=r[t.b])||void 0===e?void 0:e.call(r,t))||[2]},21:t=>[1],17:t=>[1],15:t=>[2],25:t=>[1],13:t=>[1],14:t=>[0],23:t=>[2],6:t=>[53],26:t=>[1],16:t=>[57],27:t=>[55]};if(n[t]){const r=n[t](e);for(let n=0;n=0||this.I>=0||this.i)&&Ki[t]&&(a=Ki[t]),this.H>=0&&t==Pi&&$i[this.H][t]&&(a=$i[this.H][t]),this.I>=0&&t==zi&&$i[this.I][t]&&(a=$i[this.I][t]),e.g==Di&&this.I>=0&&t==zi&&$i[this.I][e.b]&&(a=$i[this.I][e.b]),a>=this.aC.length||-1==this.aC[a]||i.push(this.aC[a])}}}return i}bO(){if(this.at){for(let t=0;t0&&(null===(r=null===(i=n.u)||void 0===i?void 0:i.Creature)||void 0===r?void 0:r.CreatureCustomizations)){let t=n.F.g(n.u.Creature.CreatureCustomizations);n.setAppearance(t)}else n.F.f();n.w&&n.bB()})),n.u.Creature&&n.u.Creature.Texture&&(n.aK=this.bA(-1,gn.a(null,n.u.TextureFiles[n.u.Creature.Texture],3,0,0))),n.bQ(hi.PATH,e),n.u.Equipment&&n.bK(n.u.Equipment),n.k.items&&n.bK(n.k.items),n.k.shouldersOverride&&n.setShouldersOverride(n.k.shouldersOverride),n.a.type!=hi.CHARACTER&&n.u.Race>0){if(n.F&&(null===(r=null===(i=n.u)||void 0===i?void 0:i.Creature)||void 0===r?void 0:r.CreatureCustomizations)){let t=n.F.g(n.u.Creature.CreatureCustomizations);n.q=t}}else n.k.charCustomization&&(n.q=n.k.charCustomization)}else if(e==hi.HELM){let e=1,i=0,r=1;if(n.v&&(e=n.v.n,i=n.v.o,r=n.v.p),t.ComponentModels){let a=t.ComponentModels[0];a&&t.ModelFiles&&t.ModelFiles[a]&&(27==t.Item.InventoryType?n.bQ(hi.PATH,t.ModelFiles[a][0].FileDataId):(n.v||t.ModelFiles[a].some((t=>t.Race==e))||(e=t.ModelFiles[a][0].Race),n.bQ(hi.PATH,gn.b(n,t.ModelFiles[a],-1,i,r,e))))}if(t.Textures)for(let e in t.Textures)0!=t.Textures[e]&&(n.B[parseInt(e)]=new an(n,parseInt(e),t.Textures[e]))}else if(e==hi.SHOULDER){let e=1,i=0,r=1;if(n.v&&(e=n.v.n,i=n.v.o,r=n.v.p),t.ComponentModels){let a=t.ComponentModels[0],s=t.ComponentModels[1];if(1==n.a.shoulder||void 0===n.a.shoulder&&a){if(a&&t.ModelFiles[a]&&n.bQ(hi.PATH,gn.b(n,t.ModelFiles[a],0,i,r,e)),t.Textures)for(let e in t.Textures)0!=t.Textures[e]&&(n.B[+e]=new an(n,parseInt(e),t.Textures[e]))}else if((2==n.a.shoulder||void 0===n.a.shoulder&&s)&&(s&&t.ModelFiles[s]&&n.bQ(hi.PATH,gn.b(n,t.ModelFiles[s],1,i,r,e)),t.Textures2))for(let e in t.Textures2)0!=t.Textures2[e]&&(n.B[+e]=new an(n,parseInt(e),t.Textures2[e]))}}else if(e==hi.ITEMVISUAL)n.bQ(hi.PATH,t.Equipment[n.b]);else if(e==hi.ITEM){let e=1,i=0,r=1;if(n.v&&(e=n.v.n,i=n.v.o,r=n.v.p),t.ComponentModels){let a=t.ComponentModels[0];a&&t.ModelFiles&&t.ModelFiles[a]&&n.bQ(hi.PATH,gn.b(n,t.ModelFiles[a],-1,i,r,e))}if(t.Textures)for(let e in t.Textures)0!=t.Textures[e]&&(n.B[+e]=new an(n,parseInt(e),t.Textures[e]))}else{if(t.stateKit&&this.E.push(new dn(this,t.stateKit.effects)),t.Creature&&(n.N=t.Creature.CreatureGeosetData,n.O=t.Creature.CreatureGeosetDataID),t.Textures)for(let e in t.Textures)0!=t.Textures[e]&&(n.B[+e]=new an(n,parseInt(e),t.Textures[e]));else if(t.ComponentTextures&&n.v){let e=n.v.o;for(let i in t.ComponentTextures){let r=t.TextureFiles[t.ComponentTextures[i]];for(let t=0;t0){const e=_i[t.Race]+ui[t.Gender];n.n=t.Race,n.o=t.Gender,n.bQ(hi.CHARACTER,e)}}}bT(t){if(!t)return void console.error("Bad buffer for DataView");let e=this,i=new Rn(t);if(604210112!=i.getUint32())return void console.log("Bad magic value");if(i.getUint32()<2e3)return void console.log("Bad version");e.aj=i.getUint32();var r=i.getUint32(),n=i.getUint32(),a=i.getUint32(),s=i.getUint32(),o=i.getUint32(),l=i.getUint32(),h=i.getUint32(),u=i.getUint32(),c=i.getUint32(),f=i.getUint32(),d=i.getUint32(),b=i.getUint32(),g=i.getUint32(),_=i.getUint32(),p=i.getUint32(),m=i.getUint32(),v=i.getUint32(),x=i.getUint32(),T=i.getUint32(),w=i.getUint32(),y=i.getUint32(),A=i.getUint32(),E=i.getUint32(),C=i.getUint32(),S=i.getUint32(),M=i.getUint32();let k=new Uint8Array(t,i.position),F=null;try{F=(0,Zr.inflate)(k)}catch(t){return void console.log("Decompression error: "+t)}if(F.length0){e.ak=new Array(D);for(let t=0;t0){e.al=new Array(R);for(let t=0;t0){e.am=new Array(R),e.aX=new Array(R);for(let t=0;t0){e.an=new Array(I);for(let t=0;t0){e.ao=new Array(U);for(let t=0;t0){e.ap=new Array(B);for(let t=0;t0){e.aq=new Array(P);for(let t=0;t0){e.ar=new Array(z);for(let t=0;t0){e.as=new Array(O);for(let t=0;t0){e.at=new Array(N);for(let t=0;t0){e.au=new Array(L);for(let t=0;t0){e.av=new Array(H);for(let t=0;t0){e.aw=new Array(V);for(let t=0;t0){e.ax=new Array(j);for(let t=0;t0){e.ay=new Array(G);for(let t=0;t0){e.az=new Array(X);for(let t=0;t0){e.aA=new Array(q);for(let t=0;t0){e.aB=new Array(W);for(let t=0;t0){e.aC=new Array(Y);for(let t=0;t0){e.aD=new Array(Z);for(let t=0;t0){e.aE=new Array(J);for(let t=0;t0){e.aF=new Array(K);for(let t=0;t0){e.aG=new Array($);for(let t=0;t<$;++t)e.aG[t]=new kn(e,i)}i.position=S;var Q=i.getInt32();if(Q>0&&S>0){e.aI=new Array(Q);for(let t=0;t0){e.aH=new Array(tt);for(let t=0;t0&&(t.P=t.aS.time),this.e&&this.R.a&&this.R.a.b){let i=ve();const r=[4,119,233,242,348,526,527,544,545];[5,143,234,524,525,540,541,556,557].indexOf(this.R.a.b.a)>-1?i=we(0,-5*e/1e3,0):r.indexOf(this.R.a.b.a)>-1&&(i=we(0,-3*e/1e3,0));let n=je();if(ti(n,i),this.bU(n),this.i&&this.i.bU(n),this.aR&&this.aR.bU(n),t.A)for(let e=0;e-1){let t=e;for(let e=0;e0&&(this.aX[e]%=this.am[e]);this.bX(this.R,t)}let i,r,n,a=t.at?t.at.length:0;for(let e=0;e0&&(i=t.ap[e.h[a]],Oe(s,e.a,i.m),lr(l,e.b,i.m),o[n+0]+=s[0]*r,o[n+1]+=s[1]*r,o[n+2]+=s[2]*r,o[n+3]+=l[0]*r,o[n+4]+=l[1]*r,o[n+5]+=l[2]*r);e.i[0]=o[n+0],e.i[1]=o[n+1],e.i[2]=o[n+2],e.j[0]=o[n+3],e.j[1]=o[n+4],e.j[2]=o[n+5]}t.by(!1),t.ac||(t.ac=!0,t.bz())}}if(t.i&&t.i.d){const e=t.i.aB[t.i.aC[0]],i=1/t.i.u.Scale;Ae(t.aN,i,i,i),qe(t.aM),Je(t.aM,t.aM,t.aN),t.bs(t.i.U,t.i.ap[e.b].m,e.c,t.aM)}if(t.j&&t.j.d){const e=t.aB[t.aC[19]],i=t.k.pet.scale||.2/t.j.u.Scale;Ae(t.aN,i,i,i),qe(t.aM),Je(t.aM,t.aM,t.aN);const r=xe(e.c);Ee(r,r,t.k.pet.offset||we(0,-1.25,0)),t.j.bs(t.U,t.ap[e.b].m,r,t.aM)}si[t.a.id]&&!t.v&&(qe(t.U),Ae(t.aN,1,1,-1),Je(t.U,t.U,t.aN)),t.w&&t.bI()}bX(t,e){if(t.a.c+=e,t.b.a<0&&!this.T&&!t.d)if(t.a.b.h>-1){let e=32767*Math.random(),i=0,r=t.a.a,n=this.an[r];for(i+=n.d;i-1;)r=n.h,n=this.an[r],i+=n.d;t.b.a=r,t.b.b=this.an[r],t.b.c=0}else{let e=this.an.find((e=>e.a==t.a.b.a&&0==e.b));e&&(t.b.a=e.i,t.b.b=e,t.b.c=0)}let i=t.a,r=t.b,n=i.b.g-i.c,a=0,s=null;if(r.a>-1&&(s=this.an[r.a],a=s.e),a>0&&n=i.b.g)if(r.a>-1){if(r.a>-1)for(;0==(32&this.an[r.a].c)&&(64&this.an[r.a].c)>0&&(r.a=this.an[r.a].i,r.b=this.an[r.a],!(r.a<0)););t.a=r,t.b=new Dr,t.c=1}else i.b.g>0&&(i.c=qn(i.c,i.b.g))}bY(t){var e=this;if(this.v?ir(e.V,this.v.V):e.V=er(1,1,1,1),e.i&&e.i.bY(t),e.d){if(e.j&&e.j.bY(t),e.bW(),this.E&&this.E.forEach((e=>e.g(t))),e.aW={uModelMatrix:e.U,uViewMatrix:e.aS.viewMatrix,uProjMatrix:e.aS.projMatrix,uCameraPos:e.aS.eye,uAmbientColor:e.W,uDiffuseColor:e.V,uPrimaryColor:e.X,uSecondaryColor:e.Y,uLightDir1:e.Z,uLightDir2:e.aa,uLightDir3:e.ab},e.aU&&e.aL)for(let i=0;i{if(i){if(2==i.c&&13==i.d){if(i.e==Pi&&-1!=e.H)return;if(i.e==zi&&-1!=e.I)return}i.C(t)}})),e.y.forEach(((e,i)=>{e&&e.i&&e.C(t)})),e.A)for(let i=0;i{i&&i.q&&e.bG(i.q,t)}))}}}const $n=Kn,Qn={2:"Wowhead",3:"LolKing",6:"HeroKing",7:"DestinyDB"};class ta{constructor(t){if(!t.type||!Qn[t.type])throw"Viewer error: Bad viewer type given";if(!t.container)throw"Viewer error: Bad container given";if(!t.aspect)throw"Viewer error: Bad aspect ratio given";if(!t.contentPath)throw"Viewer error: No content path given";console.log("Creating viewer with options",t),this.type=t.type,this.container=t.container,this.aspect=parseFloat(t.aspect),this.renderer=null,this.options=t;const e=this.container.width(),i=Math.round(e/this.aspect);this.init(e,i)}destroy(){this.renderer&&this.renderer.destroy(),this.options=null,this.container=null}init(t,e){if(void 0!==typeof window.Uint8Array&&void 0!==typeof window.DataView)try{const t=document.createElement("canvas");if(!(t.getContext("webgl",{alpha:!1})||t.getContext("experimental-webgl",{alpha:!1})))return void console.log("viewer init failed")}catch(t){return void console.log("viewer init failed")}this.mode=1,this.renderer=new ia(this),this.renderer.resize(t,e),this.renderer.init()}setAdaptiveMode(t){this.renderer.setAdaptiveMode(t)}setZoom(t){this.renderer.zoom.target=t}setOffset(t,e){this.renderer.setTranslation(t,e,0)}setFullscreen(t){t?ta.requestFullscreen(this.renderer.canvas[0]):ta.exitFullscreen()}method(t,e){return void 0===e&&(e=[]),this.renderer?this.renderer.method(t,[].concat(e)):null}option(t,e){return void 0!==e&&(this.options[t]=e),this.options[t]}static isFullscreen(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}static requestFullscreen(t){document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||(t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen&&t.msRequestFullscreen())}static exitFullscreen(){(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)&&(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen())}}const ea=ta;const ia=class{constructor(t){this.currFrame=0,this.clearColor=we(0,0,0),this.addedCss=!1,this.progressShown=!1,this.attributeState=new be,this.onContextMenu=function(t){return!1};var e=this;e.viewer=t,e.options=t.options,e.downloads={},e.context=null,e.width=0,e.height=0,e.time=0,e.delta=0,e.models=[],e.screenshotDataURL=null,e.makeDataURL=!1,e.screenshotCallback=null,e.azimuth=1.5*Math.PI,e.zenith=Math.PI/2,e.distance=15,e.fov=30,e.zoom={rateStep:.1,rateAccelerationDecay:.4,interpolationRate:.3,range:[.3,4],rateCurrent:0,target:1,current:1},e.zoom.range=e.zoom.range.map((function(t){return Math.log(t)/Math.log(1+e.zoom.rateStep)})),e.translation=we(0,0,0),e.target=we(0,0,0),e.eye=we(0,0,0),e.up=we(0,0,1),e.lookDir=ve(),e.fullscreen=!1,e.projMatrix=je(),e.viewMatrix=je(),e.panningMatrix=je(),e.viewOffset=ve(),e.aniFilterExt=null,e.aniFilterMax=0,this.addedCss||(this.addedCss=!0,$("head").append(''))}updateProgress(){var t=this,e=0,i=0;for(var r in t.downloads)e+=t.downloads[r].total,i+=t.downloads[r].loaded;if(e<=0)t.progressShown&&(t.progressBg.hide(),t.progressBar.hide(),t.progressShown=!1);else{t.progressShown||(t.progressBg.show(),t.progressBar.show(),t.progressShown=!0);var n=i/e;t.progressBar.width(Math.round(t.width*n)+"px")}}destroy(){var t=this;if(t.stop=!0,t.canvas&&(t.canvas.detach(),t.progressBg.detach(),t.progressBar.detach(),t.canvas.off("mousedown touchstart",t.onMouseDown).off("DOMMouseScroll",t.onMouseScroll).off("mousewheel",t.onMouseWheel).off("dblclick",t.onDoubleClick).off("contextmenu",t.onContextMenu),$(window).off("resize",t.onFullscreen),$(document).off("mouseup touchend",t.onMouseUp).off("mousemove touchmove",t.onMouseMove),t.canvas=t.progressBg=t.progressBar=null),t.context){var e=t.context;t.bgTexture&&e.deleteTexture(t.bgTexture),t.bgTexture=null,t.program&&e.deleteProgram(t.program),t.program=null,t.vb&&e.deleteBuffer(t.vb),t.vs&&e.deleteShader(t.vs),t.fs&&e.deleteShader(t.fs),t.vb=t.vs=t.fs=null}t.bgImg&&(t.bgImg=null);for(var i=0;i0&&this.models[0]){const i=this.models[0][t];return i?i.apply(this.models[0],e):void WH.debug("Unknown viewer method",t,"args",e)}}getTime(){return window.performance&&window.performance.now?window.performance.now():Date.now()}draw(t){var e,i=this,r=i.context;i.delta=.001*(t-i.time),i.time=t,i.currFrame++,i.updateCamera(),r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,i.width,i.height),r.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],0),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),i.bgTexture&&i.program&&(r.useProgram(i.program),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,i.bgTexture),r.uniform1i(i.uTexture,0),r.bindBuffer(r.ARRAY_BUFFER,i.vb),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null),r.enableVertexAttribArray(i.aPosition),r.vertexAttribPointer(i.aPosition,2,r.FLOAT,!1,16,0),r.enableVertexAttribArray(i.aTexCoord),r.vertexAttribPointer(i.aTexCoord,2,r.FLOAT,!1,16,8),r.depthMask(!1),r.disable(r.CULL_FACE),r.blendFunc(r.ONE,r.ZERO),r.drawArrays(r.TRIANGLE_STRIP,0,4),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),r.enable(r.CULL_FACE),r.depthMask(!0),r.disableVertexAttribArray(i.aPosition),r.disableVertexAttribArray(i.aTexCoord));let n=new Array;for(e=0;e{let i=t.e>1,r=e.e>1;return i>r?1:it.m?-1:1:t.n>e.n?-1:t.n{r.useProgram(t.a.program),r.bindBuffer(r.ARRAY_BUFFER,t.c),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.d),this.attributeState.enable(r,t.a.attributes),re(t.a,t.b),t.h?r.enable(r.CULL_FACE):r.disable(r.CULL_FACE),t.i?r.frontFace(r.CCW):r.frontFace(r.CW),this.setBlendMode(r,t.e),r.depthMask(t.f),r.drawElements(t.j,t.k,r.UNSIGNED_SHORT,t.l)})),this.attributeState.disableAll()}setAdaptiveMode(t){this.addaptiveMode=t,t&&$(window).trigger("resize")}setTranslation(t,e,i){this.translation=we(t,e,i)}setBlendMode(t,e){switch(0==e?t.disable(t.BLEND):(t.enable(t.BLEND),t.blendEquation(t.FUNC_ADD)),e){case 0:break;case 1:t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ONE);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE);break;case 5:t.blendFuncSeparate(t.DST_COLOR,t.SRC_COLOR,t.ONE,t.ONE);break;case 6:t.blendFuncSeparate(t.DST_COLOR,t.ONE,t.ONE,t.ONE);break;case 10:t.blendFunc(t.ONE,t.ONE);break;case 7:t.blendFuncSeparate(t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 8:t.blendFuncSeparate(t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE,t.ONE);break;case 13:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE);break;default:throw 3735927486}}updateCamera(){var t=this;t.zoom.target+=t.zoom.rateCurrent,t.zoom.rateCurrent*=1-t.zoom.rateAccelerationDecay,t.zoom.target=-Math.max(Math.min(-t.zoom.target,t.zoom.range[1]),t.zoom.range[0]),t.zoom.current+=(t.zoom.target-t.zoom.current)*t.zoom.interpolationRate;var e=t.distance*Math.pow(t.zoom.rateStep+1,-t.zoom.current),i=t.azimuth,r=t.zenith;1==t.up[2]?(t.eye[0]=-e*Math.sin(r)*Math.cos(i)+t.target[0],t.eye[1]=-e*Math.sin(r)*Math.sin(i)+t.target[1],t.eye[2]=-e*Math.cos(r)+t.target[2]):(t.eye[0]=-e*Math.sin(r)*Math.cos(i)+t.target[0],t.eye[1]=-e*Math.cos(r)+t.target[1],t.eye[2]=-e*Math.sin(r)*Math.sin(i)+t.target[2]),Ce(t.lookDir,t.target,t.eye),Ue(t.lookDir,t.lookDir),function(t,e,i,r){var n,a,s,o,l,h,u,c,f,d,b=e[0],g=e[1],_=e[2],p=r[0],m=r[1],v=r[2],x=i[0],T=i[1],w=i[2];Math.abs(b-x)0)for(t=0;t=0;u--)for(var c=0;c0?1:-1,t.preventDefault(),!1}onMouseWheel(t){if(!this.options.wheelEventValidation||this.options.wheelEventValidation.call(this,t))return this.zoom.rateCurrent+=t.originalEvent.wheelDelta>0?1:-1,t.preventDefault(),!1}onMouseUp(t){let e=this;(e.mouseDown||e.rightMouseDown)&&($("body").removeClass("unselectable"),e.mouseDown=!1,e.rightMouseDown=!1)}onMouseMove(t){let e=this;if((e.mouseDown||e.rightMouseDown)&&void 0!==e.mouseX){var i,r;"touchmove"==t.type?(t.preventDefault(),i=t.originalEvent.touches[0].clientX,r=t.originalEvent.touches[0].clientY):(i=t.clientX,r=t.clientY);var n=(i-e.mouseX)/e.width*Math.PI*2,a=(r-e.mouseY)/e.width*Math.PI*2;if(e.mouseDown){1==e.up[2]?e.azimuth-=n:e.azimuth+=n,e.zenith+=a;for(var s=2*Math.PI;e.azimuth<0;)e.azimuth+=s;for(;e.azimuth>s;)e.azimuth-=s;e.zenith<1e-4&&(e.zenith=1e-4),e.zenith>=Math.PI&&(e.zenith=Math.PI-1e-4)}else e.translation[0]+=n,e.translation[1]+=a;e.mouseX=i,e.mouseY=r}}resize(t,e){var i=this;if(i.width!==t||i.height!==e){if(i.fullscreen||i.viewer.container.css({height:e+"px",position:"relative"}),i.width=t,i.height=e,i.canvas)i.canvas.attr({width:t,height:e}),i.canvas.css({width:t+"px",height:e+"px"}),i.context.viewport(0,0,i.width,i.height);else{if(i.canvas=$(""),i.canvas.attr({width:t,height:e}),i.viewer.container.append(i.canvas),i.context=i.canvas[0].getContext("webgl",{alpha:!0,premultipliedAlpha:!1})||i.canvas[0].getContext("experimental-webgl",{alpha:!0,premultipliedAlpha:!1}),i.progressBg=$("
",{css:{display:"none",position:"absolute",bottom:0,left:0,right:0,height:"10px",backgroundColor:"#000"}}),i.progressBar=$("
",{css:{display:"none",position:"absolute",bottom:0,left:0,width:0,height:"10px",backgroundColor:"#ccc"}}),i.viewer.container.append(i.progressBg),i.viewer.container.append(i.progressBar),!i.context)return alert("No WebGL support, sorry! You should totally use Chrome."),i.canvas.detach(),void(i.canvas=null);const r=i.context.getExtension("EXT_texture_filter_anisotropic")||i.context.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.context.getExtension("WEBKIT_EXT_texture_filter_anisotropic");r?(i.aniFilterExt=r,i.aniFilterMax=i.context.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT),WH.debug("Texture anisotropy enabled",i.aniFilterMax)):WH.debug("Texture anisotropy disabled (not supported)"),i.canvas.on("mousedown touchstart",i.onMouseDown.bind(i)).on("DOMMouseScroll",i.onMouseScroll.bind(i)).on("mousewheel",i.onMouseWheel.bind(i)).on("dblclick",i.onDoubleClick.bind(i)).on("contextmenu",i.onContextMenu.bind(i)),$(window).on("resize",i.onFullscreen.bind(i)),$(document).on("mouseup touchend",i.onMouseUp.bind(i)).on("mousemove touchmove",i.onMouseMove.bind(i)),i.onFullscreen(null)}i.options.background&&i.loadBackground()}}loadBackground(){var t=this,e=t.context;const i=function(){t.vb=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,t.vb),e.bufferData(e.ARRAY_BUFFER,new Float32Array(16),e.DYNAMIC_DRAW);var i=t.compileShader(e.VERTEX_SHADER," attribute vec2 aPosition; attribute vec2 aTexCoord; varying vec2 vTexCoord; void main(void) { vTexCoord = aTexCoord; gl_Position = vec4(aPosition, 0, 1); } "),r=t.compileShader(e.FRAGMENT_SHADER," precision mediump float; varying vec2 vTexCoord; uniform sampler2D uTexture; void main(void) { gl_FragColor = texture2D(uTexture, vTexCoord); } "),n=e.createProgram();e.attachShader(n,i),e.attachShader(n,r),e.linkProgram(n),e.getProgramParameter(n,e.LINK_STATUS)?(t.vs=i,t.fs=r,t.program=n,t.uTexture=e.getUniformLocation(n,"uTexture"),t.aPosition=e.getAttribLocation(n,"aPosition"),t.aTexCoord=e.getAttribLocation(n,"aTexCoord")):console.error("Error linking shaders")},r=function(){var i=t.width/t.bgImg.width,r=t.height/t.bgImg.height;const n=[-1,-1,0,r,1,-1,i,r,-1,1,0,0,1,1,i,0];e.bindBuffer(e.ARRAY_BUFFER,t.vb),e.bufferSubData(e.ARRAY_BUFFER,0,new Float32Array(n))};t.bgImg?t.bgImg.loaded&&(t.vb||i(),r()):(t.bgImg=new Image,t.bgImg.crossOrigin="",t.bgImg.onload=function(){t.bgImg.loaded=!0,t.bgTexture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,t.bgTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.bgImg),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),t.vb||i(),r()},t.bgImg.onerror=function(){t.bgImg=null},t.bgImg.src=t.options.contentPath+t.options.background)}compileShader(t,e){var i=this.context,r=i.createShader(t);if(i.shaderSource(r,e),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw"Shader compile error: "+i.getShaderInfoLog(r);return r}};let ra={Types:hi};const na=Object.assign(ea,{Tools:_e,WebGL:ia,WEBGL:1,WOW:2,FLASH:2,Wow:ra});window.ZamModelViewer=na})()})(); +(() => { + var t = { + 591: (t, e, i) => { + 'use strict'; + var r = {}; + (0, i(236).assign)(r, i(555), i(843), i(619)), (t.exports = r); + }, + 555: (t, e, i) => { + 'use strict'; + var r = i(405), + n = i(236), + a = i(373), + s = i(898), + o = i(292), + l = Object.prototype.toString; + function h(t) { + if (!(this instanceof h)) return new h(t); + this.options = n.assign({ level: -1, method: 8, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: 0, to: '' }, t || {}); + var e = this.options; + e.raw && e.windowBits > 0 + ? (e.windowBits = -e.windowBits) + : e.gzip && e.windowBits > 0 && e.windowBits < 16 && (e.windowBits += 16), + (this.err = 0), + (this.msg = ''), + (this.ended = !1), + (this.chunks = []), + (this.strm = new o()), + (this.strm.avail_out = 0); + var i = r.deflateInit2(this.strm, e.level, e.method, e.windowBits, e.memLevel, e.strategy); + if (0 !== i) throw new Error(s[i]); + if ((e.header && r.deflateSetHeader(this.strm, e.header), e.dictionary)) { + var u; + if ( + ((u = + 'string' == typeof e.dictionary + ? a.string2buf(e.dictionary) + : '[object ArrayBuffer]' === l.call(e.dictionary) + ? new Uint8Array(e.dictionary) + : e.dictionary), + 0 !== (i = r.deflateSetDictionary(this.strm, u))) + ) + throw new Error(s[i]); + this._dict_set = !0; + } + } + function u(t, e) { + var i = new h(e); + if ((i.push(t, !0), i.err)) throw i.msg || s[i.err]; + return i.result; + } + (h.prototype.push = function (t, e) { + var i, + s, + o = this.strm, + h = this.options.chunkSize; + if (this.ended) return !1; + (s = e === ~~e ? e : !0 === e ? 4 : 0), + 'string' == typeof t + ? (o.input = a.string2buf(t)) + : '[object ArrayBuffer]' === l.call(t) + ? (o.input = new Uint8Array(t)) + : (o.input = t), + (o.next_in = 0), + (o.avail_in = o.input.length); + do { + if ( + (0 === o.avail_out && ((o.output = new n.Buf8(h)), (o.next_out = 0), (o.avail_out = h)), + 1 !== (i = r.deflate(o, s)) && 0 !== i) + ) + return this.onEnd(i), (this.ended = !0), !1; + (0 !== o.avail_out && (0 !== o.avail_in || (4 !== s && 2 !== s))) || + ('string' === this.options.to + ? this.onData(a.buf2binstring(n.shrinkBuf(o.output, o.next_out))) + : this.onData(n.shrinkBuf(o.output, o.next_out))); + } while ((o.avail_in > 0 || 0 === o.avail_out) && 1 !== i); + return 4 === s + ? ((i = r.deflateEnd(this.strm)), this.onEnd(i), (this.ended = !0), 0 === i) + : 2 !== s || (this.onEnd(0), (o.avail_out = 0), !0); + }), + (h.prototype.onData = function (t) { + this.chunks.push(t); + }), + (h.prototype.onEnd = function (t) { + 0 === t && ('string' === this.options.to ? (this.result = this.chunks.join('')) : (this.result = n.flattenChunks(this.chunks))), + (this.chunks = []), + (this.err = t), + (this.msg = this.strm.msg); + }), + (e.Deflate = h), + (e.deflate = u), + (e.deflateRaw = function (t, e) { + return ((e = e || {}).raw = !0), u(t, e); + }), + (e.gzip = function (t, e) { + return ((e = e || {}).gzip = !0), u(t, e); + }); + }, + 843: (t, e, i) => { + 'use strict'; + var r = i(948), + n = i(236), + a = i(373), + s = i(619), + o = i(898), + l = i(292), + h = i(401), + u = Object.prototype.toString; + function c(t) { + if (!(this instanceof c)) return new c(t); + this.options = n.assign({ chunkSize: 16384, windowBits: 0, to: '' }, t || {}); + var e = this.options; + e.raw && e.windowBits >= 0 && e.windowBits < 16 && ((e.windowBits = -e.windowBits), 0 === e.windowBits && (e.windowBits = -15)), + !(e.windowBits >= 0 && e.windowBits < 16) || (t && t.windowBits) || (e.windowBits += 32), + e.windowBits > 15 && e.windowBits < 48 && 0 == (15 & e.windowBits) && (e.windowBits |= 15), + (this.err = 0), + (this.msg = ''), + (this.ended = !1), + (this.chunks = []), + (this.strm = new l()), + (this.strm.avail_out = 0); + var i = r.inflateInit2(this.strm, e.windowBits); + if (i !== s.Z_OK) throw new Error(o[i]); + if ( + ((this.header = new h()), + r.inflateGetHeader(this.strm, this.header), + e.dictionary && + ('string' == typeof e.dictionary + ? (e.dictionary = a.string2buf(e.dictionary)) + : '[object ArrayBuffer]' === u.call(e.dictionary) && (e.dictionary = new Uint8Array(e.dictionary)), + e.raw && (i = r.inflateSetDictionary(this.strm, e.dictionary)) !== s.Z_OK)) + ) + throw new Error(o[i]); + } + function f(t, e) { + var i = new c(e); + if ((i.push(t, !0), i.err)) throw i.msg || o[i.err]; + return i.result; + } + (c.prototype.push = function (t, e) { + var i, + o, + l, + h, + c, + f = this.strm, + d = this.options.chunkSize, + b = this.options.dictionary, + g = !1; + if (this.ended) return !1; + (o = e === ~~e ? e : !0 === e ? s.Z_FINISH : s.Z_NO_FLUSH), + 'string' == typeof t + ? (f.input = a.binstring2buf(t)) + : '[object ArrayBuffer]' === u.call(t) + ? (f.input = new Uint8Array(t)) + : (f.input = t), + (f.next_in = 0), + (f.avail_in = f.input.length); + do { + if ( + (0 === f.avail_out && ((f.output = new n.Buf8(d)), (f.next_out = 0), (f.avail_out = d)), + (i = r.inflate(f, s.Z_NO_FLUSH)) === s.Z_NEED_DICT && b && (i = r.inflateSetDictionary(this.strm, b)), + i === s.Z_BUF_ERROR && !0 === g && ((i = s.Z_OK), (g = !1)), + i !== s.Z_STREAM_END && i !== s.Z_OK) + ) + return this.onEnd(i), (this.ended = !0), !1; + f.next_out && + ((0 !== f.avail_out && i !== s.Z_STREAM_END && (0 !== f.avail_in || (o !== s.Z_FINISH && o !== s.Z_SYNC_FLUSH))) || + ('string' === this.options.to + ? ((l = a.utf8border(f.output, f.next_out)), + (h = f.next_out - l), + (c = a.buf2string(f.output, l)), + (f.next_out = h), + (f.avail_out = d - h), + h && n.arraySet(f.output, f.output, l, h, 0), + this.onData(c)) + : this.onData(n.shrinkBuf(f.output, f.next_out)))), + 0 === f.avail_in && 0 === f.avail_out && (g = !0); + } while ((f.avail_in > 0 || 0 === f.avail_out) && i !== s.Z_STREAM_END); + return ( + i === s.Z_STREAM_END && (o = s.Z_FINISH), + o === s.Z_FINISH + ? ((i = r.inflateEnd(this.strm)), this.onEnd(i), (this.ended = !0), i === s.Z_OK) + : o !== s.Z_SYNC_FLUSH || (this.onEnd(s.Z_OK), (f.avail_out = 0), !0) + ); + }), + (c.prototype.onData = function (t) { + this.chunks.push(t); + }), + (c.prototype.onEnd = function (t) { + t === s.Z_OK && + ('string' === this.options.to ? (this.result = this.chunks.join('')) : (this.result = n.flattenChunks(this.chunks))), + (this.chunks = []), + (this.err = t), + (this.msg = this.strm.msg); + }), + (e.Inflate = c), + (e.inflate = f), + (e.inflateRaw = function (t, e) { + return ((e = e || {}).raw = !0), f(t, e); + }), + (e.ungzip = f); + }, + 236: (t, e) => { + 'use strict'; + var i = 'undefined' != typeof Uint8Array && 'undefined' != typeof Uint16Array && 'undefined' != typeof Int32Array; + function r(t, e) { + return Object.prototype.hasOwnProperty.call(t, e); + } + (e.assign = function (t) { + for (var e = Array.prototype.slice.call(arguments, 1); e.length; ) { + var i = e.shift(); + if (i) { + if ('object' != typeof i) throw new TypeError(i + 'must be non-object'); + for (var n in i) r(i, n) && (t[n] = i[n]); + } + } + return t; + }), + (e.shrinkBuf = function (t, e) { + return t.length === e ? t : t.subarray ? t.subarray(0, e) : ((t.length = e), t); + }); + var n = { + arraySet: function (t, e, i, r, n) { + if (e.subarray && t.subarray) t.set(e.subarray(i, i + r), n); + else for (var a = 0; a < r; a++) t[n + a] = e[i + a]; + }, + flattenChunks: function (t) { + var e, i, r, n, a, s; + for (r = 0, e = 0, i = t.length; e < i; e++) r += t[e].length; + for (s = new Uint8Array(r), n = 0, e = 0, i = t.length; e < i; e++) (a = t[e]), s.set(a, n), (n += a.length); + return s; + }, + }, + a = { + arraySet: function (t, e, i, r, n) { + for (var a = 0; a < r; a++) t[n + a] = e[i + a]; + }, + flattenChunks: function (t) { + return [].concat.apply([], t); + }, + }; + (e.setTyped = function (t) { + t + ? ((e.Buf8 = Uint8Array), (e.Buf16 = Uint16Array), (e.Buf32 = Int32Array), e.assign(e, n)) + : ((e.Buf8 = Array), (e.Buf16 = Array), (e.Buf32 = Array), e.assign(e, a)); + }), + e.setTyped(i); + }, + 373: (t, e, i) => { + 'use strict'; + var r = i(236), + n = !0, + a = !0; + try { + String.fromCharCode.apply(null, [0]); + } catch (t) { + n = !1; + } + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch (t) { + a = !1; + } + for (var s = new r.Buf8(256), o = 0; o < 256; o++) + s[o] = o >= 252 ? 6 : o >= 248 ? 5 : o >= 240 ? 4 : o >= 224 ? 3 : o >= 192 ? 2 : 1; + function l(t, e) { + if (e < 65534 && ((t.subarray && a) || (!t.subarray && n))) return String.fromCharCode.apply(null, r.shrinkBuf(t, e)); + for (var i = '', s = 0; s < e; s++) i += String.fromCharCode(t[s]); + return i; + } + (s[254] = s[254] = 1), + (e.string2buf = function (t) { + var e, + i, + n, + a, + s, + o = t.length, + l = 0; + for (a = 0; a < o; a++) + 55296 == (64512 & (i = t.charCodeAt(a))) && + a + 1 < o && + 56320 == (64512 & (n = t.charCodeAt(a + 1))) && + ((i = 65536 + ((i - 55296) << 10) + (n - 56320)), a++), + (l += i < 128 ? 1 : i < 2048 ? 2 : i < 65536 ? 3 : 4); + for (e = new r.Buf8(l), s = 0, a = 0; s < l; a++) + 55296 == (64512 & (i = t.charCodeAt(a))) && + a + 1 < o && + 56320 == (64512 & (n = t.charCodeAt(a + 1))) && + ((i = 65536 + ((i - 55296) << 10) + (n - 56320)), a++), + i < 128 + ? (e[s++] = i) + : i < 2048 + ? ((e[s++] = 192 | (i >>> 6)), (e[s++] = 128 | (63 & i))) + : i < 65536 + ? ((e[s++] = 224 | (i >>> 12)), (e[s++] = 128 | ((i >>> 6) & 63)), (e[s++] = 128 | (63 & i))) + : ((e[s++] = 240 | (i >>> 18)), + (e[s++] = 128 | ((i >>> 12) & 63)), + (e[s++] = 128 | ((i >>> 6) & 63)), + (e[s++] = 128 | (63 & i))); + return e; + }), + (e.buf2binstring = function (t) { + return l(t, t.length); + }), + (e.binstring2buf = function (t) { + for (var e = new r.Buf8(t.length), i = 0, n = e.length; i < n; i++) e[i] = t.charCodeAt(i); + return e; + }), + (e.buf2string = function (t, e) { + var i, + r, + n, + a, + o = e || t.length, + h = new Array(2 * o); + for (r = 0, i = 0; i < o; ) + if ((n = t[i++]) < 128) h[r++] = n; + else if ((a = s[n]) > 4) (h[r++] = 65533), (i += a - 1); + else { + for (n &= 2 === a ? 31 : 3 === a ? 15 : 7; a > 1 && i < o; ) (n = (n << 6) | (63 & t[i++])), a--; + a > 1 + ? (h[r++] = 65533) + : n < 65536 + ? (h[r++] = n) + : ((n -= 65536), (h[r++] = 55296 | ((n >> 10) & 1023)), (h[r++] = 56320 | (1023 & n))); + } + return l(h, r); + }), + (e.utf8border = function (t, e) { + var i; + for ((e = e || t.length) > t.length && (e = t.length), i = e - 1; i >= 0 && 128 == (192 & t[i]); ) i--; + return i < 0 || 0 === i ? e : i + s[t[i]] > e ? i : e; + }); + }, + 69: (t) => { + 'use strict'; + t.exports = function (t, e, i, r) { + for (var n = (65535 & t) | 0, a = ((t >>> 16) & 65535) | 0, s = 0; 0 !== i; ) { + i -= s = i > 2e3 ? 2e3 : i; + do { + a = (a + (n = (n + e[r++]) | 0)) | 0; + } while (--s); + (n %= 65521), (a %= 65521); + } + return n | (a << 16) | 0; + }; + }, + 619: (t) => { + 'use strict'; + t.exports = { + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_BUF_ERROR: -5, + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + Z_BINARY: 0, + Z_TEXT: 1, + Z_UNKNOWN: 2, + Z_DEFLATED: 8, + }; + }, + 869: (t) => { + 'use strict'; + var e = (function () { + for (var t, e = [], i = 0; i < 256; i++) { + t = i; + for (var r = 0; r < 8; r++) t = 1 & t ? 3988292384 ^ (t >>> 1) : t >>> 1; + e[i] = t; + } + return e; + })(); + t.exports = function (t, i, r, n) { + var a = e, + s = n + r; + t ^= -1; + for (var o = n; o < s; o++) t = (t >>> 8) ^ a[255 & (t ^ i[o])]; + return -1 ^ t; + }; + }, + 405: (t, e, i) => { + 'use strict'; + var r, + n = i(236), + a = i(342), + s = i(69), + o = i(869), + l = i(898), + h = -2, + u = 258, + c = 262, + f = 103, + d = 113, + b = 666; + function g(t, e) { + return (t.msg = l[e]), e; + } + function _(t) { + return (t << 1) - (t > 4 ? 9 : 0); + } + function p(t) { + for (var e = t.length; --e >= 0; ) t[e] = 0; + } + function m(t) { + var e = t.state, + i = e.pending; + i > t.avail_out && (i = t.avail_out), + 0 !== i && + (n.arraySet(t.output, e.pending_buf, e.pending_out, i, t.next_out), + (t.next_out += i), + (e.pending_out += i), + (t.total_out += i), + (t.avail_out -= i), + (e.pending -= i), + 0 === e.pending && (e.pending_out = 0)); + } + function v(t, e) { + a._tr_flush_block(t, t.block_start >= 0 ? t.block_start : -1, t.strstart - t.block_start, e), + (t.block_start = t.strstart), + m(t.strm); + } + function x(t, e) { + t.pending_buf[t.pending++] = e; + } + function T(t, e) { + (t.pending_buf[t.pending++] = (e >>> 8) & 255), (t.pending_buf[t.pending++] = 255 & e); + } + function w(t, e) { + var i, + r, + n = t.max_chain_length, + a = t.strstart, + s = t.prev_length, + o = t.nice_match, + l = t.strstart > t.w_size - c ? t.strstart - (t.w_size - c) : 0, + h = t.window, + f = t.w_mask, + d = t.prev, + b = t.strstart + u, + g = h[a + s - 1], + _ = h[a + s]; + t.prev_length >= t.good_match && (n >>= 2), o > t.lookahead && (o = t.lookahead); + do { + if (h[(i = e) + s] === _ && h[i + s - 1] === g && h[i] === h[a] && h[++i] === h[a + 1]) { + (a += 2), i++; + do {} while ( + h[++a] === h[++i] && + h[++a] === h[++i] && + h[++a] === h[++i] && + h[++a] === h[++i] && + h[++a] === h[++i] && + h[++a] === h[++i] && + h[++a] === h[++i] && + h[++a] === h[++i] && + a < b + ); + if (((r = u - (b - a)), (a = b - u), r > s)) { + if (((t.match_start = e), (s = r), r >= o)) break; + (g = h[a + s - 1]), (_ = h[a + s]); + } + } + } while ((e = d[e & f]) > l && 0 != --n); + return s <= t.lookahead ? s : t.lookahead; + } + function y(t) { + var e, + i, + r, + a, + l, + h, + u, + f, + d, + b, + g = t.w_size; + do { + if (((a = t.window_size - t.lookahead - t.strstart), t.strstart >= g + (g - c))) { + n.arraySet(t.window, t.window, g, g, 0), (t.match_start -= g), (t.strstart -= g), (t.block_start -= g), (e = i = t.hash_size); + do { + (r = t.head[--e]), (t.head[e] = r >= g ? r - g : 0); + } while (--i); + e = i = g; + do { + (r = t.prev[--e]), (t.prev[e] = r >= g ? r - g : 0); + } while (--i); + a += g; + } + if (0 === t.strm.avail_in) break; + if ( + ((h = t.strm), + (u = t.window), + (f = t.strstart + t.lookahead), + (d = a), + (b = void 0), + (b = h.avail_in) > d && (b = d), + (i = + 0 === b + ? 0 + : ((h.avail_in -= b), + n.arraySet(u, h.input, h.next_in, b, f), + 1 === h.state.wrap ? (h.adler = s(h.adler, u, b, f)) : 2 === h.state.wrap && (h.adler = o(h.adler, u, b, f)), + (h.next_in += b), + (h.total_in += b), + b)), + (t.lookahead += i), + t.lookahead + t.insert >= 3) + ) + for ( + l = t.strstart - t.insert, t.ins_h = t.window[l], t.ins_h = ((t.ins_h << t.hash_shift) ^ t.window[l + 1]) & t.hash_mask; + t.insert && + ((t.ins_h = ((t.ins_h << t.hash_shift) ^ t.window[l + 3 - 1]) & t.hash_mask), + (t.prev[l & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = l), + l++, + t.insert--, + !(t.lookahead + t.insert < 3)); + + ); + } while (t.lookahead < c && 0 !== t.strm.avail_in); + } + function A(t, e) { + for (var i, r; ; ) { + if (t.lookahead < c) { + if ((y(t), t.lookahead < c && 0 === e)) return 1; + if (0 === t.lookahead) break; + } + if ( + ((i = 0), + t.lookahead >= 3 && + ((t.ins_h = ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + 3 - 1]) & t.hash_mask), + (i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart)), + 0 !== i && t.strstart - i <= t.w_size - c && (t.match_length = w(t, i)), + t.match_length >= 3) + ) + if ( + ((r = a._tr_tally(t, t.strstart - t.match_start, t.match_length - 3)), + (t.lookahead -= t.match_length), + t.match_length <= t.max_lazy_match && t.lookahead >= 3) + ) { + t.match_length--; + do { + t.strstart++, + (t.ins_h = ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + 3 - 1]) & t.hash_mask), + (i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart); + } while (0 != --t.match_length); + t.strstart++; + } else + (t.strstart += t.match_length), + (t.match_length = 0), + (t.ins_h = t.window[t.strstart]), + (t.ins_h = ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + 1]) & t.hash_mask); + else (r = a._tr_tally(t, 0, t.window[t.strstart])), t.lookahead--, t.strstart++; + if (r && (v(t, !1), 0 === t.strm.avail_out)) return 1; + } + return ( + (t.insert = t.strstart < 2 ? t.strstart : 2), + 4 === e ? (v(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (v(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + ); + } + function E(t, e) { + for (var i, r, n; ; ) { + if (t.lookahead < c) { + if ((y(t), t.lookahead < c && 0 === e)) return 1; + if (0 === t.lookahead) break; + } + if ( + ((i = 0), + t.lookahead >= 3 && + ((t.ins_h = ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + 3 - 1]) & t.hash_mask), + (i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart)), + (t.prev_length = t.match_length), + (t.prev_match = t.match_start), + (t.match_length = 2), + 0 !== i && + t.prev_length < t.max_lazy_match && + t.strstart - i <= t.w_size - c && + ((t.match_length = w(t, i)), + t.match_length <= 5 && + (1 === t.strategy || (3 === t.match_length && t.strstart - t.match_start > 4096)) && + (t.match_length = 2)), + t.prev_length >= 3 && t.match_length <= t.prev_length) + ) { + (n = t.strstart + t.lookahead - 3), + (r = a._tr_tally(t, t.strstart - 1 - t.prev_match, t.prev_length - 3)), + (t.lookahead -= t.prev_length - 1), + (t.prev_length -= 2); + do { + ++t.strstart <= n && + ((t.ins_h = ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + 3 - 1]) & t.hash_mask), + (i = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart)); + } while (0 != --t.prev_length); + if (((t.match_available = 0), (t.match_length = 2), t.strstart++, r && (v(t, !1), 0 === t.strm.avail_out))) return 1; + } else if (t.match_available) { + if (((r = a._tr_tally(t, 0, t.window[t.strstart - 1])) && v(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out)) + return 1; + } else (t.match_available = 1), t.strstart++, t.lookahead--; + } + return ( + t.match_available && ((r = a._tr_tally(t, 0, t.window[t.strstart - 1])), (t.match_available = 0)), + (t.insert = t.strstart < 2 ? t.strstart : 2), + 4 === e ? (v(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (v(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + ); + } + function C(t, e, i, r, n) { + (this.good_length = t), (this.max_lazy = e), (this.nice_length = i), (this.max_chain = r), (this.func = n); + } + function S() { + (this.strm = null), + (this.status = 0), + (this.pending_buf = null), + (this.pending_buf_size = 0), + (this.pending_out = 0), + (this.pending = 0), + (this.wrap = 0), + (this.gzhead = null), + (this.gzindex = 0), + (this.method = 8), + (this.last_flush = -1), + (this.w_size = 0), + (this.w_bits = 0), + (this.w_mask = 0), + (this.window = null), + (this.window_size = 0), + (this.prev = null), + (this.head = null), + (this.ins_h = 0), + (this.hash_size = 0), + (this.hash_bits = 0), + (this.hash_mask = 0), + (this.hash_shift = 0), + (this.block_start = 0), + (this.match_length = 0), + (this.prev_match = 0), + (this.match_available = 0), + (this.strstart = 0), + (this.match_start = 0), + (this.lookahead = 0), + (this.prev_length = 0), + (this.max_chain_length = 0), + (this.max_lazy_match = 0), + (this.level = 0), + (this.strategy = 0), + (this.good_match = 0), + (this.nice_match = 0), + (this.dyn_ltree = new n.Buf16(1146)), + (this.dyn_dtree = new n.Buf16(122)), + (this.bl_tree = new n.Buf16(78)), + p(this.dyn_ltree), + p(this.dyn_dtree), + p(this.bl_tree), + (this.l_desc = null), + (this.d_desc = null), + (this.bl_desc = null), + (this.bl_count = new n.Buf16(16)), + (this.heap = new n.Buf16(573)), + p(this.heap), + (this.heap_len = 0), + (this.heap_max = 0), + (this.depth = new n.Buf16(573)), + p(this.depth), + (this.l_buf = 0), + (this.lit_bufsize = 0), + (this.last_lit = 0), + (this.d_buf = 0), + (this.opt_len = 0), + (this.static_len = 0), + (this.matches = 0), + (this.insert = 0), + (this.bi_buf = 0), + (this.bi_valid = 0); + } + function M(t) { + var e; + return t && t.state + ? ((t.total_in = t.total_out = 0), + (t.data_type = 2), + ((e = t.state).pending = 0), + (e.pending_out = 0), + e.wrap < 0 && (e.wrap = -e.wrap), + (e.status = e.wrap ? 42 : d), + (t.adler = 2 === e.wrap ? 0 : 1), + (e.last_flush = 0), + a._tr_init(e), + 0) + : g(t, h); + } + function k(t) { + var e, + i = M(t); + return ( + 0 === i && + (((e = t.state).window_size = 2 * e.w_size), + p(e.head), + (e.max_lazy_match = r[e.level].max_lazy), + (e.good_match = r[e.level].good_length), + (e.nice_match = r[e.level].nice_length), + (e.max_chain_length = r[e.level].max_chain), + (e.strstart = 0), + (e.block_start = 0), + (e.lookahead = 0), + (e.insert = 0), + (e.match_length = e.prev_length = 2), + (e.match_available = 0), + (e.ins_h = 0)), + i + ); + } + function F(t, e, i, r, a, s) { + if (!t) return h; + var o = 1; + if ( + (-1 === e && (e = 6), + r < 0 ? ((o = 0), (r = -r)) : r > 15 && ((o = 2), (r -= 16)), + a < 1 || a > 9 || 8 !== i || r < 8 || r > 15 || e < 0 || e > 9 || s < 0 || s > 4) + ) + return g(t, h); + 8 === r && (r = 9); + var l = new S(); + return ( + (t.state = l), + (l.strm = t), + (l.wrap = o), + (l.gzhead = null), + (l.w_bits = r), + (l.w_size = 1 << l.w_bits), + (l.w_mask = l.w_size - 1), + (l.hash_bits = a + 7), + (l.hash_size = 1 << l.hash_bits), + (l.hash_mask = l.hash_size - 1), + (l.hash_shift = ~~((l.hash_bits + 3 - 1) / 3)), + (l.window = new n.Buf8(2 * l.w_size)), + (l.head = new n.Buf16(l.hash_size)), + (l.prev = new n.Buf16(l.w_size)), + (l.lit_bufsize = 1 << (a + 6)), + (l.pending_buf_size = 4 * l.lit_bufsize), + (l.pending_buf = new n.Buf8(l.pending_buf_size)), + (l.d_buf = 1 * l.lit_bufsize), + (l.l_buf = 3 * l.lit_bufsize), + (l.level = e), + (l.strategy = s), + (l.method = i), + k(t) + ); + } + (r = [ + new C(0, 0, 0, 0, function (t, e) { + var i = 65535; + for (i > t.pending_buf_size - 5 && (i = t.pending_buf_size - 5); ; ) { + if (t.lookahead <= 1) { + if ((y(t), 0 === t.lookahead && 0 === e)) return 1; + if (0 === t.lookahead) break; + } + (t.strstart += t.lookahead), (t.lookahead = 0); + var r = t.block_start + i; + if ( + (0 === t.strstart || t.strstart >= r) && + ((t.lookahead = t.strstart - r), (t.strstart = r), v(t, !1), 0 === t.strm.avail_out) + ) + return 1; + if (t.strstart - t.block_start >= t.w_size - c && (v(t, !1), 0 === t.strm.avail_out)) return 1; + } + return ( + (t.insert = 0), + 4 === e ? (v(t, !0), 0 === t.strm.avail_out ? 3 : 4) : (t.strstart > t.block_start && (v(t, !1), t.strm.avail_out), 1) + ); + }), + new C(4, 4, 8, 4, A), + new C(4, 5, 16, 8, A), + new C(4, 6, 32, 32, A), + new C(4, 4, 16, 16, E), + new C(8, 16, 32, 32, E), + new C(8, 16, 128, 128, E), + new C(8, 32, 128, 256, E), + new C(32, 128, 258, 1024, E), + new C(32, 258, 258, 4096, E), + ]), + (e.deflateInit = function (t, e) { + return F(t, e, 8, 15, 8, 0); + }), + (e.deflateInit2 = F), + (e.deflateReset = k), + (e.deflateResetKeep = M), + (e.deflateSetHeader = function (t, e) { + return t && t.state ? (2 !== t.state.wrap ? h : ((t.state.gzhead = e), 0)) : h; + }), + (e.deflate = function (t, e) { + var i, n, s, l; + if (!t || !t.state || e > 5 || e < 0) return t ? g(t, h) : h; + if (((n = t.state), !t.output || (!t.input && 0 !== t.avail_in) || (n.status === b && 4 !== e))) + return g(t, 0 === t.avail_out ? -5 : h); + if (((n.strm = t), (i = n.last_flush), (n.last_flush = e), 42 === n.status)) + if (2 === n.wrap) + (t.adler = 0), + x(n, 31), + x(n, 139), + x(n, 8), + n.gzhead + ? (x( + n, + (n.gzhead.text ? 1 : 0) + + (n.gzhead.hcrc ? 2 : 0) + + (n.gzhead.extra ? 4 : 0) + + (n.gzhead.name ? 8 : 0) + + (n.gzhead.comment ? 16 : 0), + ), + x(n, 255 & n.gzhead.time), + x(n, (n.gzhead.time >> 8) & 255), + x(n, (n.gzhead.time >> 16) & 255), + x(n, (n.gzhead.time >> 24) & 255), + x(n, 9 === n.level ? 2 : n.strategy >= 2 || n.level < 2 ? 4 : 0), + x(n, 255 & n.gzhead.os), + n.gzhead.extra && + n.gzhead.extra.length && + (x(n, 255 & n.gzhead.extra.length), x(n, (n.gzhead.extra.length >> 8) & 255)), + n.gzhead.hcrc && (t.adler = o(t.adler, n.pending_buf, n.pending, 0)), + (n.gzindex = 0), + (n.status = 69)) + : (x(n, 0), + x(n, 0), + x(n, 0), + x(n, 0), + x(n, 0), + x(n, 9 === n.level ? 2 : n.strategy >= 2 || n.level < 2 ? 4 : 0), + x(n, 3), + (n.status = d)); + else { + var c = (8 + ((n.w_bits - 8) << 4)) << 8; + (c |= (n.strategy >= 2 || n.level < 2 ? 0 : n.level < 6 ? 1 : 6 === n.level ? 2 : 3) << 6), + 0 !== n.strstart && (c |= 32), + (c += 31 - (c % 31)), + (n.status = d), + T(n, c), + 0 !== n.strstart && (T(n, t.adler >>> 16), T(n, 65535 & t.adler)), + (t.adler = 1); + } + if (69 === n.status) + if (n.gzhead.extra) { + for ( + s = n.pending; + n.gzindex < (65535 & n.gzhead.extra.length) && + (n.pending !== n.pending_buf_size || + (n.gzhead.hcrc && n.pending > s && (t.adler = o(t.adler, n.pending_buf, n.pending - s, s)), + m(t), + (s = n.pending), + n.pending !== n.pending_buf_size)); + + ) + x(n, 255 & n.gzhead.extra[n.gzindex]), n.gzindex++; + n.gzhead.hcrc && n.pending > s && (t.adler = o(t.adler, n.pending_buf, n.pending - s, s)), + n.gzindex === n.gzhead.extra.length && ((n.gzindex = 0), (n.status = 73)); + } else n.status = 73; + if (73 === n.status) + if (n.gzhead.name) { + s = n.pending; + do { + if ( + n.pending === n.pending_buf_size && + (n.gzhead.hcrc && n.pending > s && (t.adler = o(t.adler, n.pending_buf, n.pending - s, s)), + m(t), + (s = n.pending), + n.pending === n.pending_buf_size) + ) { + l = 1; + break; + } + (l = n.gzindex < n.gzhead.name.length ? 255 & n.gzhead.name.charCodeAt(n.gzindex++) : 0), x(n, l); + } while (0 !== l); + n.gzhead.hcrc && n.pending > s && (t.adler = o(t.adler, n.pending_buf, n.pending - s, s)), + 0 === l && ((n.gzindex = 0), (n.status = 91)); + } else n.status = 91; + if (91 === n.status) + if (n.gzhead.comment) { + s = n.pending; + do { + if ( + n.pending === n.pending_buf_size && + (n.gzhead.hcrc && n.pending > s && (t.adler = o(t.adler, n.pending_buf, n.pending - s, s)), + m(t), + (s = n.pending), + n.pending === n.pending_buf_size) + ) { + l = 1; + break; + } + (l = n.gzindex < n.gzhead.comment.length ? 255 & n.gzhead.comment.charCodeAt(n.gzindex++) : 0), x(n, l); + } while (0 !== l); + n.gzhead.hcrc && n.pending > s && (t.adler = o(t.adler, n.pending_buf, n.pending - s, s)), 0 === l && (n.status = f); + } else n.status = f; + if ( + (n.status === f && + (n.gzhead.hcrc + ? (n.pending + 2 > n.pending_buf_size && m(t), + n.pending + 2 <= n.pending_buf_size && (x(n, 255 & t.adler), x(n, (t.adler >> 8) & 255), (t.adler = 0), (n.status = d))) + : (n.status = d)), + 0 !== n.pending) + ) { + if ((m(t), 0 === t.avail_out)) return (n.last_flush = -1), 0; + } else if (0 === t.avail_in && _(e) <= _(i) && 4 !== e) return g(t, -5); + if (n.status === b && 0 !== t.avail_in) return g(t, -5); + if (0 !== t.avail_in || 0 !== n.lookahead || (0 !== e && n.status !== b)) { + var w = + 2 === n.strategy + ? (function (t, e) { + for (var i; ; ) { + if (0 === t.lookahead && (y(t), 0 === t.lookahead)) { + if (0 === e) return 1; + break; + } + if ( + ((t.match_length = 0), + (i = a._tr_tally(t, 0, t.window[t.strstart])), + t.lookahead--, + t.strstart++, + i && (v(t, !1), 0 === t.strm.avail_out)) + ) + return 1; + } + return ( + (t.insert = 0), + 4 === e ? (v(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (v(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + ); + })(n, e) + : 3 === n.strategy + ? (function (t, e) { + for (var i, r, n, s, o = t.window; ; ) { + if (t.lookahead <= u) { + if ((y(t), t.lookahead <= u && 0 === e)) return 1; + if (0 === t.lookahead) break; + } + if ( + ((t.match_length = 0), + t.lookahead >= 3 && t.strstart > 0 && (r = o[(n = t.strstart - 1)]) === o[++n] && r === o[++n] && r === o[++n]) + ) { + s = t.strstart + u; + do {} while ( + r === o[++n] && + r === o[++n] && + r === o[++n] && + r === o[++n] && + r === o[++n] && + r === o[++n] && + r === o[++n] && + r === o[++n] && + n < s + ); + (t.match_length = u - (s - n)), t.match_length > t.lookahead && (t.match_length = t.lookahead); + } + if ( + (t.match_length >= 3 + ? ((i = a._tr_tally(t, 1, t.match_length - 3)), + (t.lookahead -= t.match_length), + (t.strstart += t.match_length), + (t.match_length = 0)) + : ((i = a._tr_tally(t, 0, t.window[t.strstart])), t.lookahead--, t.strstart++), + i && (v(t, !1), 0 === t.strm.avail_out)) + ) + return 1; + } + return ( + (t.insert = 0), + 4 === e ? (v(t, !0), 0 === t.strm.avail_out ? 3 : 4) : t.last_lit && (v(t, !1), 0 === t.strm.avail_out) ? 1 : 2 + ); + })(n, e) + : r[n.level].func(n, e); + if (((3 !== w && 4 !== w) || (n.status = b), 1 === w || 3 === w)) return 0 === t.avail_out && (n.last_flush = -1), 0; + if ( + 2 === w && + (1 === e + ? a._tr_align(n) + : 5 !== e && + (a._tr_stored_block(n, 0, 0, !1), + 3 === e && (p(n.head), 0 === n.lookahead && ((n.strstart = 0), (n.block_start = 0), (n.insert = 0)))), + m(t), + 0 === t.avail_out) + ) + return (n.last_flush = -1), 0; + } + return 4 !== e + ? 0 + : n.wrap <= 0 + ? 1 + : (2 === n.wrap + ? (x(n, 255 & t.adler), + x(n, (t.adler >> 8) & 255), + x(n, (t.adler >> 16) & 255), + x(n, (t.adler >> 24) & 255), + x(n, 255 & t.total_in), + x(n, (t.total_in >> 8) & 255), + x(n, (t.total_in >> 16) & 255), + x(n, (t.total_in >> 24) & 255)) + : (T(n, t.adler >>> 16), T(n, 65535 & t.adler)), + m(t), + n.wrap > 0 && (n.wrap = -n.wrap), + 0 !== n.pending ? 0 : 1); + }), + (e.deflateEnd = function (t) { + var e; + return t && t.state + ? 42 !== (e = t.state.status) && 69 !== e && 73 !== e && 91 !== e && e !== f && e !== d && e !== b + ? g(t, h) + : ((t.state = null), e === d ? g(t, -3) : 0) + : h; + }), + (e.deflateSetDictionary = function (t, e) { + var i, + r, + a, + o, + l, + u, + c, + f, + d = e.length; + if (!t || !t.state) return h; + if (2 === (o = (i = t.state).wrap) || (1 === o && 42 !== i.status) || i.lookahead) return h; + for ( + 1 === o && (t.adler = s(t.adler, e, d, 0)), + i.wrap = 0, + d >= i.w_size && + (0 === o && (p(i.head), (i.strstart = 0), (i.block_start = 0), (i.insert = 0)), + (f = new n.Buf8(i.w_size)), + n.arraySet(f, e, d - i.w_size, i.w_size, 0), + (e = f), + (d = i.w_size)), + l = t.avail_in, + u = t.next_in, + c = t.input, + t.avail_in = d, + t.next_in = 0, + t.input = e, + y(i); + i.lookahead >= 3; + + ) { + (r = i.strstart), (a = i.lookahead - 2); + do { + (i.ins_h = ((i.ins_h << i.hash_shift) ^ i.window[r + 3 - 1]) & i.hash_mask), + (i.prev[r & i.w_mask] = i.head[i.ins_h]), + (i.head[i.ins_h] = r), + r++; + } while (--a); + (i.strstart = r), (i.lookahead = 2), y(i); + } + return ( + (i.strstart += i.lookahead), + (i.block_start = i.strstart), + (i.insert = i.lookahead), + (i.lookahead = 0), + (i.match_length = i.prev_length = 2), + (i.match_available = 0), + (t.next_in = u), + (t.input = c), + (t.avail_in = l), + (i.wrap = o), + 0 + ); + }), + (e.deflateInfo = 'pako deflate (from Nodeca project)'); + }, + 401: (t) => { + 'use strict'; + t.exports = function () { + (this.text = 0), + (this.time = 0), + (this.xflags = 0), + (this.os = 0), + (this.extra = null), + (this.extra_len = 0), + (this.name = ''), + (this.comment = ''), + (this.hcrc = 0), + (this.done = !1); + }; + }, + 264: (t) => { + 'use strict'; + t.exports = function (t, e) { + var i, r, n, a, s, o, l, h, u, c, f, d, b, g, _, p, m, v, x, T, w, y, A, E, C; + (i = t.state), + (r = t.next_in), + (E = t.input), + (n = r + (t.avail_in - 5)), + (a = t.next_out), + (C = t.output), + (s = a - (e - t.avail_out)), + (o = a + (t.avail_out - 257)), + (l = i.dmax), + (h = i.wsize), + (u = i.whave), + (c = i.wnext), + (f = i.window), + (d = i.hold), + (b = i.bits), + (g = i.lencode), + (_ = i.distcode), + (p = (1 << i.lenbits) - 1), + (m = (1 << i.distbits) - 1); + t: do { + b < 15 && ((d += E[r++] << b), (b += 8), (d += E[r++] << b), (b += 8)), (v = g[d & p]); + e: for (;;) { + if (((d >>>= x = v >>> 24), (b -= x), 0 === (x = (v >>> 16) & 255))) C[a++] = 65535 & v; + else { + if (!(16 & x)) { + if (0 == (64 & x)) { + v = g[(65535 & v) + (d & ((1 << x) - 1))]; + continue e; + } + if (32 & x) { + i.mode = 12; + break t; + } + (t.msg = 'invalid literal/length code'), (i.mode = 30); + break t; + } + (T = 65535 & v), + (x &= 15) && (b < x && ((d += E[r++] << b), (b += 8)), (T += d & ((1 << x) - 1)), (d >>>= x), (b -= x)), + b < 15 && ((d += E[r++] << b), (b += 8), (d += E[r++] << b), (b += 8)), + (v = _[d & m]); + i: for (;;) { + if (((d >>>= x = v >>> 24), (b -= x), !(16 & (x = (v >>> 16) & 255)))) { + if (0 == (64 & x)) { + v = _[(65535 & v) + (d & ((1 << x) - 1))]; + continue i; + } + (t.msg = 'invalid distance code'), (i.mode = 30); + break t; + } + if ( + ((w = 65535 & v), + b < (x &= 15) && ((d += E[r++] << b), (b += 8) < x && ((d += E[r++] << b), (b += 8))), + (w += d & ((1 << x) - 1)) > l) + ) { + (t.msg = 'invalid distance too far back'), (i.mode = 30); + break t; + } + if (((d >>>= x), (b -= x), w > (x = a - s))) { + if ((x = w - x) > u && i.sane) { + (t.msg = 'invalid distance too far back'), (i.mode = 30); + break t; + } + if (((y = 0), (A = f), 0 === c)) { + if (((y += h - x), x < T)) { + T -= x; + do { + C[a++] = f[y++]; + } while (--x); + (y = a - w), (A = C); + } + } else if (c < x) { + if (((y += h + c - x), (x -= c) < T)) { + T -= x; + do { + C[a++] = f[y++]; + } while (--x); + if (((y = 0), c < T)) { + T -= x = c; + do { + C[a++] = f[y++]; + } while (--x); + (y = a - w), (A = C); + } + } + } else if (((y += c - x), x < T)) { + T -= x; + do { + C[a++] = f[y++]; + } while (--x); + (y = a - w), (A = C); + } + for (; T > 2; ) (C[a++] = A[y++]), (C[a++] = A[y++]), (C[a++] = A[y++]), (T -= 3); + T && ((C[a++] = A[y++]), T > 1 && (C[a++] = A[y++])); + } else { + y = a - w; + do { + (C[a++] = C[y++]), (C[a++] = C[y++]), (C[a++] = C[y++]), (T -= 3); + } while (T > 2); + T && ((C[a++] = C[y++]), T > 1 && (C[a++] = C[y++])); + } + break; + } + } + break; + } + } while (r < n && a < o); + (r -= T = b >> 3), + (d &= (1 << (b -= T << 3)) - 1), + (t.next_in = r), + (t.next_out = a), + (t.avail_in = r < n ? n - r + 5 : 5 - (r - n)), + (t.avail_out = a < o ? o - a + 257 : 257 - (a - o)), + (i.hold = d), + (i.bits = b); + }; + }, + 948: (t, e, i) => { + 'use strict'; + var r = i(236), + n = i(69), + a = i(869), + s = i(264), + o = i(241), + l = -2, + h = 12, + u = 30; + function c(t) { + return ((t >>> 24) & 255) + ((t >>> 8) & 65280) + ((65280 & t) << 8) + ((255 & t) << 24); + } + function f() { + (this.mode = 0), + (this.last = !1), + (this.wrap = 0), + (this.havedict = !1), + (this.flags = 0), + (this.dmax = 0), + (this.check = 0), + (this.total = 0), + (this.head = null), + (this.wbits = 0), + (this.wsize = 0), + (this.whave = 0), + (this.wnext = 0), + (this.window = null), + (this.hold = 0), + (this.bits = 0), + (this.length = 0), + (this.offset = 0), + (this.extra = 0), + (this.lencode = null), + (this.distcode = null), + (this.lenbits = 0), + (this.distbits = 0), + (this.ncode = 0), + (this.nlen = 0), + (this.ndist = 0), + (this.have = 0), + (this.next = null), + (this.lens = new r.Buf16(320)), + (this.work = new r.Buf16(288)), + (this.lendyn = null), + (this.distdyn = null), + (this.sane = 0), + (this.back = 0), + (this.was = 0); + } + function d(t) { + var e; + return t && t.state + ? ((e = t.state), + (t.total_in = t.total_out = e.total = 0), + (t.msg = ''), + e.wrap && (t.adler = 1 & e.wrap), + (e.mode = 1), + (e.last = 0), + (e.havedict = 0), + (e.dmax = 32768), + (e.head = null), + (e.hold = 0), + (e.bits = 0), + (e.lencode = e.lendyn = new r.Buf32(852)), + (e.distcode = e.distdyn = new r.Buf32(592)), + (e.sane = 1), + (e.back = -1), + 0) + : l; + } + function b(t) { + var e; + return t && t.state ? (((e = t.state).wsize = 0), (e.whave = 0), (e.wnext = 0), d(t)) : l; + } + function g(t, e) { + var i, r; + return t && t.state + ? ((r = t.state), + e < 0 ? ((i = 0), (e = -e)) : ((i = 1 + (e >> 4)), e < 48 && (e &= 15)), + e && (e < 8 || e > 15) ? l : (null !== r.window && r.wbits !== e && (r.window = null), (r.wrap = i), (r.wbits = e), b(t))) + : l; + } + function _(t, e) { + var i, r; + return t ? ((r = new f()), (t.state = r), (r.window = null), 0 !== (i = g(t, e)) && (t.state = null), i) : l; + } + var p, + m, + v = !0; + function x(t) { + if (v) { + var e; + for (p = new r.Buf32(512), m = new r.Buf32(32), e = 0; e < 144; ) t.lens[e++] = 8; + for (; e < 256; ) t.lens[e++] = 9; + for (; e < 280; ) t.lens[e++] = 7; + for (; e < 288; ) t.lens[e++] = 8; + for (o(1, t.lens, 0, 288, p, 0, t.work, { bits: 9 }), e = 0; e < 32; ) t.lens[e++] = 5; + o(2, t.lens, 0, 32, m, 0, t.work, { bits: 5 }), (v = !1); + } + (t.lencode = p), (t.lenbits = 9), (t.distcode = m), (t.distbits = 5); + } + function T(t, e, i, n) { + var a, + s = t.state; + return ( + null === s.window && ((s.wsize = 1 << s.wbits), (s.wnext = 0), (s.whave = 0), (s.window = new r.Buf8(s.wsize))), + n >= s.wsize + ? (r.arraySet(s.window, e, i - s.wsize, s.wsize, 0), (s.wnext = 0), (s.whave = s.wsize)) + : ((a = s.wsize - s.wnext) > n && (a = n), + r.arraySet(s.window, e, i - n, a, s.wnext), + (n -= a) + ? (r.arraySet(s.window, e, i - n, n, 0), (s.wnext = n), (s.whave = s.wsize)) + : ((s.wnext += a), s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += a))), + 0 + ); + } + (e.inflateReset = b), + (e.inflateReset2 = g), + (e.inflateResetKeep = d), + (e.inflateInit = function (t) { + return _(t, 15); + }), + (e.inflateInit2 = _), + (e.inflate = function (t, e) { + var i, + f, + d, + b, + g, + _, + p, + m, + v, + w, + y, + A, + E, + C, + S, + M, + k, + F, + R, + D, + I, + U, + B, + P, + z = 0, + O = new r.Buf8(4), + N = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + if (!t || !t.state || !t.output || (!t.input && 0 !== t.avail_in)) return l; + (i = t.state).mode === h && (i.mode = 13), + (g = t.next_out), + (d = t.output), + (p = t.avail_out), + (b = t.next_in), + (f = t.input), + (_ = t.avail_in), + (m = i.hold), + (v = i.bits), + (w = _), + (y = p), + (U = 0); + t: for (;;) + switch (i.mode) { + case 1: + if (0 === i.wrap) { + i.mode = 13; + break; + } + for (; v < 16; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (2 & i.wrap && 35615 === m) { + (i.check = 0), + (O[0] = 255 & m), + (O[1] = (m >>> 8) & 255), + (i.check = a(i.check, O, 2, 0)), + (m = 0), + (v = 0), + (i.mode = 2); + break; + } + if (((i.flags = 0), i.head && (i.head.done = !1), !(1 & i.wrap) || (((255 & m) << 8) + (m >> 8)) % 31)) { + (t.msg = 'incorrect header check'), (i.mode = u); + break; + } + if (8 != (15 & m)) { + (t.msg = 'unknown compression method'), (i.mode = u); + break; + } + if (((v -= 4), (I = 8 + (15 & (m >>>= 4))), 0 === i.wbits)) i.wbits = I; + else if (I > i.wbits) { + (t.msg = 'invalid window size'), (i.mode = u); + break; + } + (i.dmax = 1 << I), (t.adler = i.check = 1), (i.mode = 512 & m ? 10 : h), (m = 0), (v = 0); + break; + case 2: + for (; v < 16; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (((i.flags = m), 8 != (255 & i.flags))) { + (t.msg = 'unknown compression method'), (i.mode = u); + break; + } + if (57344 & i.flags) { + (t.msg = 'unknown header flags set'), (i.mode = u); + break; + } + i.head && (i.head.text = (m >> 8) & 1), + 512 & i.flags && ((O[0] = 255 & m), (O[1] = (m >>> 8) & 255), (i.check = a(i.check, O, 2, 0))), + (m = 0), + (v = 0), + (i.mode = 3); + case 3: + for (; v < 32; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + i.head && (i.head.time = m), + 512 & i.flags && + ((O[0] = 255 & m), + (O[1] = (m >>> 8) & 255), + (O[2] = (m >>> 16) & 255), + (O[3] = (m >>> 24) & 255), + (i.check = a(i.check, O, 4, 0))), + (m = 0), + (v = 0), + (i.mode = 4); + case 4: + for (; v < 16; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + i.head && ((i.head.xflags = 255 & m), (i.head.os = m >> 8)), + 512 & i.flags && ((O[0] = 255 & m), (O[1] = (m >>> 8) & 255), (i.check = a(i.check, O, 2, 0))), + (m = 0), + (v = 0), + (i.mode = 5); + case 5: + if (1024 & i.flags) { + for (; v < 16; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (i.length = m), + i.head && (i.head.extra_len = m), + 512 & i.flags && ((O[0] = 255 & m), (O[1] = (m >>> 8) & 255), (i.check = a(i.check, O, 2, 0))), + (m = 0), + (v = 0); + } else i.head && (i.head.extra = null); + i.mode = 6; + case 6: + if ( + 1024 & i.flags && + ((A = i.length) > _ && (A = _), + A && + (i.head && + ((I = i.head.extra_len - i.length), + i.head.extra || (i.head.extra = new Array(i.head.extra_len)), + r.arraySet(i.head.extra, f, b, A, I)), + 512 & i.flags && (i.check = a(i.check, f, A, b)), + (_ -= A), + (b += A), + (i.length -= A)), + i.length) + ) + break t; + (i.length = 0), (i.mode = 7); + case 7: + if (2048 & i.flags) { + if (0 === _) break t; + A = 0; + do { + (I = f[b + A++]), i.head && I && i.length < 65536 && (i.head.name += String.fromCharCode(I)); + } while (I && A < _); + if ((512 & i.flags && (i.check = a(i.check, f, A, b)), (_ -= A), (b += A), I)) break t; + } else i.head && (i.head.name = null); + (i.length = 0), (i.mode = 8); + case 8: + if (4096 & i.flags) { + if (0 === _) break t; + A = 0; + do { + (I = f[b + A++]), i.head && I && i.length < 65536 && (i.head.comment += String.fromCharCode(I)); + } while (I && A < _); + if ((512 & i.flags && (i.check = a(i.check, f, A, b)), (_ -= A), (b += A), I)) break t; + } else i.head && (i.head.comment = null); + i.mode = 9; + case 9: + if (512 & i.flags) { + for (; v < 16; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (m !== (65535 & i.check)) { + (t.msg = 'header crc mismatch'), (i.mode = u); + break; + } + (m = 0), (v = 0); + } + i.head && ((i.head.hcrc = (i.flags >> 9) & 1), (i.head.done = !0)), (t.adler = i.check = 0), (i.mode = h); + break; + case 10: + for (; v < 32; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (t.adler = i.check = c(m)), (m = 0), (v = 0), (i.mode = 11); + case 11: + if (0 === i.havedict) + return (t.next_out = g), (t.avail_out = p), (t.next_in = b), (t.avail_in = _), (i.hold = m), (i.bits = v), 2; + (t.adler = i.check = 1), (i.mode = h); + case h: + if (5 === e || 6 === e) break t; + case 13: + if (i.last) { + (m >>>= 7 & v), (v -= 7 & v), (i.mode = 27); + break; + } + for (; v < 3; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + switch (((i.last = 1 & m), (v -= 1), 3 & (m >>>= 1))) { + case 0: + i.mode = 14; + break; + case 1: + if ((x(i), (i.mode = 20), 6 === e)) { + (m >>>= 2), (v -= 2); + break t; + } + break; + case 2: + i.mode = 17; + break; + case 3: + (t.msg = 'invalid block type'), (i.mode = u); + } + (m >>>= 2), (v -= 2); + break; + case 14: + for (m >>>= 7 & v, v -= 7 & v; v < 32; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if ((65535 & m) != ((m >>> 16) ^ 65535)) { + (t.msg = 'invalid stored block lengths'), (i.mode = u); + break; + } + if (((i.length = 65535 & m), (m = 0), (v = 0), (i.mode = 15), 6 === e)) break t; + case 15: + i.mode = 16; + case 16: + if ((A = i.length)) { + if ((A > _ && (A = _), A > p && (A = p), 0 === A)) break t; + r.arraySet(d, f, b, A, g), (_ -= A), (b += A), (p -= A), (g += A), (i.length -= A); + break; + } + i.mode = h; + break; + case 17: + for (; v < 14; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if ( + ((i.nlen = 257 + (31 & m)), + (m >>>= 5), + (v -= 5), + (i.ndist = 1 + (31 & m)), + (m >>>= 5), + (v -= 5), + (i.ncode = 4 + (15 & m)), + (m >>>= 4), + (v -= 4), + i.nlen > 286 || i.ndist > 30) + ) { + (t.msg = 'too many length or distance symbols'), (i.mode = u); + break; + } + (i.have = 0), (i.mode = 18); + case 18: + for (; i.have < i.ncode; ) { + for (; v < 3; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (i.lens[N[i.have++]] = 7 & m), (m >>>= 3), (v -= 3); + } + for (; i.have < 19; ) i.lens[N[i.have++]] = 0; + if ( + ((i.lencode = i.lendyn), + (i.lenbits = 7), + (B = { bits: i.lenbits }), + (U = o(0, i.lens, 0, 19, i.lencode, 0, i.work, B)), + (i.lenbits = B.bits), + U) + ) { + (t.msg = 'invalid code lengths set'), (i.mode = u); + break; + } + (i.have = 0), (i.mode = 19); + case 19: + for (; i.have < i.nlen + i.ndist; ) { + for (; (M = ((z = i.lencode[m & ((1 << i.lenbits) - 1)]) >>> 16) & 255), (k = 65535 & z), !((S = z >>> 24) <= v); ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (k < 16) (m >>>= S), (v -= S), (i.lens[i.have++] = k); + else { + if (16 === k) { + for (P = S + 2; v < P; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (((m >>>= S), (v -= S), 0 === i.have)) { + (t.msg = 'invalid bit length repeat'), (i.mode = u); + break; + } + (I = i.lens[i.have - 1]), (A = 3 + (3 & m)), (m >>>= 2), (v -= 2); + } else if (17 === k) { + for (P = S + 3; v < P; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (v -= S), (I = 0), (A = 3 + (7 & (m >>>= S))), (m >>>= 3), (v -= 3); + } else { + for (P = S + 7; v < P; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (v -= S), (I = 0), (A = 11 + (127 & (m >>>= S))), (m >>>= 7), (v -= 7); + } + if (i.have + A > i.nlen + i.ndist) { + (t.msg = 'invalid bit length repeat'), (i.mode = u); + break; + } + for (; A--; ) i.lens[i.have++] = I; + } + } + if (i.mode === u) break; + if (0 === i.lens[256]) { + (t.msg = 'invalid code -- missing end-of-block'), (i.mode = u); + break; + } + if ( + ((i.lenbits = 9), + (B = { bits: i.lenbits }), + (U = o(1, i.lens, 0, i.nlen, i.lencode, 0, i.work, B)), + (i.lenbits = B.bits), + U) + ) { + (t.msg = 'invalid literal/lengths set'), (i.mode = u); + break; + } + if ( + ((i.distbits = 6), + (i.distcode = i.distdyn), + (B = { bits: i.distbits }), + (U = o(2, i.lens, i.nlen, i.ndist, i.distcode, 0, i.work, B)), + (i.distbits = B.bits), + U) + ) { + (t.msg = 'invalid distances set'), (i.mode = u); + break; + } + if (((i.mode = 20), 6 === e)) break t; + case 20: + i.mode = 21; + case 21: + if (_ >= 6 && p >= 258) { + (t.next_out = g), + (t.avail_out = p), + (t.next_in = b), + (t.avail_in = _), + (i.hold = m), + (i.bits = v), + s(t, y), + (g = t.next_out), + (d = t.output), + (p = t.avail_out), + (b = t.next_in), + (f = t.input), + (_ = t.avail_in), + (m = i.hold), + (v = i.bits), + i.mode === h && (i.back = -1); + break; + } + for ( + i.back = 0; + (M = ((z = i.lencode[m & ((1 << i.lenbits) - 1)]) >>> 16) & 255), (k = 65535 & z), !((S = z >>> 24) <= v); + + ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (M && 0 == (240 & M)) { + for ( + F = S, R = M, D = k; + (M = ((z = i.lencode[D + ((m & ((1 << (F + R)) - 1)) >> F)]) >>> 16) & 255), + (k = 65535 & z), + !(F + (S = z >>> 24) <= v); + + ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (m >>>= F), (v -= F), (i.back += F); + } + if (((m >>>= S), (v -= S), (i.back += S), (i.length = k), 0 === M)) { + i.mode = 26; + break; + } + if (32 & M) { + (i.back = -1), (i.mode = h); + break; + } + if (64 & M) { + (t.msg = 'invalid literal/length code'), (i.mode = u); + break; + } + (i.extra = 15 & M), (i.mode = 22); + case 22: + if (i.extra) { + for (P = i.extra; v < P; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (i.length += m & ((1 << i.extra) - 1)), (m >>>= i.extra), (v -= i.extra), (i.back += i.extra); + } + (i.was = i.length), (i.mode = 23); + case 23: + for (; (M = ((z = i.distcode[m & ((1 << i.distbits) - 1)]) >>> 16) & 255), (k = 65535 & z), !((S = z >>> 24) <= v); ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (0 == (240 & M)) { + for ( + F = S, R = M, D = k; + (M = ((z = i.distcode[D + ((m & ((1 << (F + R)) - 1)) >> F)]) >>> 16) & 255), + (k = 65535 & z), + !(F + (S = z >>> 24) <= v); + + ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (m >>>= F), (v -= F), (i.back += F); + } + if (((m >>>= S), (v -= S), (i.back += S), 64 & M)) { + (t.msg = 'invalid distance code'), (i.mode = u); + break; + } + (i.offset = k), (i.extra = 15 & M), (i.mode = 24); + case 24: + if (i.extra) { + for (P = i.extra; v < P; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + (i.offset += m & ((1 << i.extra) - 1)), (m >>>= i.extra), (v -= i.extra), (i.back += i.extra); + } + if (i.offset > i.dmax) { + (t.msg = 'invalid distance too far back'), (i.mode = u); + break; + } + i.mode = 25; + case 25: + if (0 === p) break t; + if (((A = y - p), i.offset > A)) { + if ((A = i.offset - A) > i.whave && i.sane) { + (t.msg = 'invalid distance too far back'), (i.mode = u); + break; + } + A > i.wnext ? ((A -= i.wnext), (E = i.wsize - A)) : (E = i.wnext - A), A > i.length && (A = i.length), (C = i.window); + } else (C = d), (E = g - i.offset), (A = i.length); + A > p && (A = p), (p -= A), (i.length -= A); + do { + d[g++] = C[E++]; + } while (--A); + 0 === i.length && (i.mode = 21); + break; + case 26: + if (0 === p) break t; + (d[g++] = i.length), p--, (i.mode = 21); + break; + case 27: + if (i.wrap) { + for (; v < 32; ) { + if (0 === _) break t; + _--, (m |= f[b++] << v), (v += 8); + } + if ( + ((y -= p), + (t.total_out += y), + (i.total += y), + y && (t.adler = i.check = i.flags ? a(i.check, d, y, g - y) : n(i.check, d, y, g - y)), + (y = p), + (i.flags ? m : c(m)) !== i.check) + ) { + (t.msg = 'incorrect data check'), (i.mode = u); + break; + } + (m = 0), (v = 0); + } + i.mode = 28; + case 28: + if (i.wrap && i.flags) { + for (; v < 32; ) { + if (0 === _) break t; + _--, (m += f[b++] << v), (v += 8); + } + if (m !== (4294967295 & i.total)) { + (t.msg = 'incorrect length check'), (i.mode = u); + break; + } + (m = 0), (v = 0); + } + i.mode = 29; + case 29: + U = 1; + break t; + case u: + U = -3; + break t; + case 31: + return -4; + default: + return l; + } + return ( + (t.next_out = g), + (t.avail_out = p), + (t.next_in = b), + (t.avail_in = _), + (i.hold = m), + (i.bits = v), + (i.wsize || (y !== t.avail_out && i.mode < u && (i.mode < 27 || 4 !== e))) && T(t, t.output, t.next_out, y - t.avail_out) + ? ((i.mode = 31), -4) + : ((w -= t.avail_in), + (y -= t.avail_out), + (t.total_in += w), + (t.total_out += y), + (i.total += y), + i.wrap && y && (t.adler = i.check = i.flags ? a(i.check, d, y, t.next_out - y) : n(i.check, d, y, t.next_out - y)), + (t.data_type = i.bits + (i.last ? 64 : 0) + (i.mode === h ? 128 : 0) + (20 === i.mode || 15 === i.mode ? 256 : 0)), + ((0 === w && 0 === y) || 4 === e) && 0 === U && (U = -5), + U) + ); + }), + (e.inflateEnd = function (t) { + if (!t || !t.state) return l; + var e = t.state; + return e.window && (e.window = null), (t.state = null), 0; + }), + (e.inflateGetHeader = function (t, e) { + var i; + return t && t.state ? (0 == (2 & (i = t.state).wrap) ? l : ((i.head = e), (e.done = !1), 0)) : l; + }), + (e.inflateSetDictionary = function (t, e) { + var i, + r = e.length; + return t && t.state + ? 0 !== (i = t.state).wrap && 11 !== i.mode + ? l + : 11 === i.mode && n(1, e, r, 0) !== i.check + ? -3 + : T(t, e, r, r) + ? ((i.mode = 31), -4) + : ((i.havedict = 1), 0) + : l; + }), + (e.inflateInfo = 'pako inflate (from Nodeca project)'); + }, + 241: (t, e, i) => { + 'use strict'; + var r = i(236), + n = 15, + a = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0], + s = [16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78], + o = [ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, + 16385, 24577, 0, 0, + ], + l = [ + 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64, + ]; + t.exports = function (t, e, i, h, u, c, f, d) { + var b, + g, + _, + p, + m, + v, + x, + T, + w, + y = d.bits, + A = 0, + E = 0, + C = 0, + S = 0, + M = 0, + k = 0, + F = 0, + R = 0, + D = 0, + I = 0, + U = null, + B = 0, + P = new r.Buf16(16), + z = new r.Buf16(16), + O = null, + N = 0; + for (A = 0; A <= n; A++) P[A] = 0; + for (E = 0; E < h; E++) P[e[i + E]]++; + for (M = y, S = n; S >= 1 && 0 === P[S]; S--); + if ((M > S && (M = S), 0 === S)) return (u[c++] = 20971520), (u[c++] = 20971520), (d.bits = 1), 0; + for (C = 1; C < S && 0 === P[C]; C++); + for (M < C && (M = C), R = 1, A = 1; A <= n; A++) if (((R <<= 1), (R -= P[A]) < 0)) return -1; + if (R > 0 && (0 === t || 1 !== S)) return -1; + for (z[1] = 0, A = 1; A < n; A++) z[A + 1] = z[A] + P[A]; + for (E = 0; E < h; E++) 0 !== e[i + E] && (f[z[e[i + E]]++] = E); + if ( + (0 === t + ? ((U = O = f), (v = 19)) + : 1 === t + ? ((U = a), (B -= 257), (O = s), (N -= 257), (v = 256)) + : ((U = o), (O = l), (v = -1)), + (I = 0), + (E = 0), + (A = C), + (m = c), + (k = M), + (F = 0), + (_ = -1), + (p = (D = 1 << M) - 1), + (1 === t && D > 852) || (2 === t && D > 592)) + ) + return 1; + for (;;) { + (x = A - F), + f[E] < v ? ((T = 0), (w = f[E])) : f[E] > v ? ((T = O[N + f[E]]), (w = U[B + f[E]])) : ((T = 96), (w = 0)), + (b = 1 << (A - F)), + (C = g = 1 << k); + do { + u[m + (I >> F) + (g -= b)] = (x << 24) | (T << 16) | w | 0; + } while (0 !== g); + for (b = 1 << (A - 1); I & b; ) b >>= 1; + if ((0 !== b ? ((I &= b - 1), (I += b)) : (I = 0), E++, 0 == --P[A])) { + if (A === S) break; + A = e[i + f[E]]; + } + if (A > M && (I & p) !== _) { + for (0 === F && (F = M), m += C, R = 1 << (k = A - F); k + F < S && !((R -= P[k + F]) <= 0); ) k++, (R <<= 1); + if (((D += 1 << k), (1 === t && D > 852) || (2 === t && D > 592))) return 1; + u[(_ = I & p)] = (M << 24) | (k << 16) | (m - c) | 0; + } + } + return 0 !== I && (u[m + I] = ((A - F) << 24) | (64 << 16) | 0), (d.bits = M), 0; + }; + }, + 898: (t) => { + 'use strict'; + t.exports = { + 2: 'need dictionary', + 1: 'stream end', + 0: '', + '-1': 'file error', + '-2': 'stream error', + '-3': 'data error', + '-4': 'insufficient memory', + '-5': 'buffer error', + '-6': 'incompatible version', + }; + }, + 342: (t, e, i) => { + 'use strict'; + var r = i(236); + function n(t) { + for (var e = t.length; --e >= 0; ) t[e] = 0; + } + var a = 256, + s = 286, + o = 30, + l = 15, + h = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], + u = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13], + c = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], + f = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], + d = new Array(576); + n(d); + var b = new Array(60); + n(b); + var g = new Array(512); + n(g); + var _ = new Array(256); + n(_); + var p = new Array(29); + n(p); + var m, + v, + x, + T = new Array(o); + function w(t, e, i, r, n) { + (this.static_tree = t), + (this.extra_bits = e), + (this.extra_base = i), + (this.elems = r), + (this.max_length = n), + (this.has_stree = t && t.length); + } + function y(t, e) { + (this.dyn_tree = t), (this.max_code = 0), (this.stat_desc = e); + } + function A(t) { + return t < 256 ? g[t] : g[256 + (t >>> 7)]; + } + function E(t, e) { + (t.pending_buf[t.pending++] = 255 & e), (t.pending_buf[t.pending++] = (e >>> 8) & 255); + } + function C(t, e, i) { + t.bi_valid > 16 - i + ? ((t.bi_buf |= (e << t.bi_valid) & 65535), E(t, t.bi_buf), (t.bi_buf = e >> (16 - t.bi_valid)), (t.bi_valid += i - 16)) + : ((t.bi_buf |= (e << t.bi_valid) & 65535), (t.bi_valid += i)); + } + function S(t, e, i) { + C(t, i[2 * e], i[2 * e + 1]); + } + function M(t, e) { + var i = 0; + do { + (i |= 1 & t), (t >>>= 1), (i <<= 1); + } while (--e > 0); + return i >>> 1; + } + function k(t, e, i) { + var r, + n, + a = new Array(16), + s = 0; + for (r = 1; r <= l; r++) a[r] = s = (s + i[r - 1]) << 1; + for (n = 0; n <= e; n++) { + var o = t[2 * n + 1]; + 0 !== o && (t[2 * n] = M(a[o]++, o)); + } + } + function F(t) { + var e; + for (e = 0; e < s; e++) t.dyn_ltree[2 * e] = 0; + for (e = 0; e < o; e++) t.dyn_dtree[2 * e] = 0; + for (e = 0; e < 19; e++) t.bl_tree[2 * e] = 0; + (t.dyn_ltree[512] = 1), (t.opt_len = t.static_len = 0), (t.last_lit = t.matches = 0); + } + function R(t) { + t.bi_valid > 8 ? E(t, t.bi_buf) : t.bi_valid > 0 && (t.pending_buf[t.pending++] = t.bi_buf), (t.bi_buf = 0), (t.bi_valid = 0); + } + function D(t, e, i, r) { + var n = 2 * e, + a = 2 * i; + return t[n] < t[a] || (t[n] === t[a] && r[e] <= r[i]); + } + function I(t, e, i) { + for ( + var r = t.heap[i], n = i << 1; + n <= t.heap_len && (n < t.heap_len && D(e, t.heap[n + 1], t.heap[n], t.depth) && n++, !D(e, r, t.heap[n], t.depth)); + + ) + (t.heap[i] = t.heap[n]), (i = n), (n <<= 1); + t.heap[i] = r; + } + function U(t, e, i) { + var r, + n, + s, + o, + l = 0; + if (0 !== t.last_lit) + do { + (r = (t.pending_buf[t.d_buf + 2 * l] << 8) | t.pending_buf[t.d_buf + 2 * l + 1]), + (n = t.pending_buf[t.l_buf + l]), + l++, + 0 === r + ? S(t, n, e) + : (S(t, (s = _[n]) + a + 1, e), + 0 !== (o = h[s]) && C(t, (n -= p[s]), o), + S(t, (s = A(--r)), i), + 0 !== (o = u[s]) && C(t, (r -= T[s]), o)); + } while (l < t.last_lit); + S(t, 256, e); + } + function B(t, e) { + var i, + r, + n, + a = e.dyn_tree, + s = e.stat_desc.static_tree, + o = e.stat_desc.has_stree, + h = e.stat_desc.elems, + u = -1; + for (t.heap_len = 0, t.heap_max = 573, i = 0; i < h; i++) + 0 !== a[2 * i] ? ((t.heap[++t.heap_len] = u = i), (t.depth[i] = 0)) : (a[2 * i + 1] = 0); + for (; t.heap_len < 2; ) + (a[2 * (n = t.heap[++t.heap_len] = u < 2 ? ++u : 0)] = 1), (t.depth[n] = 0), t.opt_len--, o && (t.static_len -= s[2 * n + 1]); + for (e.max_code = u, i = t.heap_len >> 1; i >= 1; i--) I(t, a, i); + n = h; + do { + (i = t.heap[1]), + (t.heap[1] = t.heap[t.heap_len--]), + I(t, a, 1), + (r = t.heap[1]), + (t.heap[--t.heap_max] = i), + (t.heap[--t.heap_max] = r), + (a[2 * n] = a[2 * i] + a[2 * r]), + (t.depth[n] = (t.depth[i] >= t.depth[r] ? t.depth[i] : t.depth[r]) + 1), + (a[2 * i + 1] = a[2 * r + 1] = n), + (t.heap[1] = n++), + I(t, a, 1); + } while (t.heap_len >= 2); + (t.heap[--t.heap_max] = t.heap[1]), + (function (t, e) { + var i, + r, + n, + a, + s, + o, + h = e.dyn_tree, + u = e.max_code, + c = e.stat_desc.static_tree, + f = e.stat_desc.has_stree, + d = e.stat_desc.extra_bits, + b = e.stat_desc.extra_base, + g = e.stat_desc.max_length, + _ = 0; + for (a = 0; a <= l; a++) t.bl_count[a] = 0; + for (h[2 * t.heap[t.heap_max] + 1] = 0, i = t.heap_max + 1; i < 573; i++) + (a = h[2 * h[2 * (r = t.heap[i]) + 1] + 1] + 1) > g && ((a = g), _++), + (h[2 * r + 1] = a), + r > u || + (t.bl_count[a]++, + (s = 0), + r >= b && (s = d[r - b]), + (o = h[2 * r]), + (t.opt_len += o * (a + s)), + f && (t.static_len += o * (c[2 * r + 1] + s))); + if (0 !== _) { + do { + for (a = g - 1; 0 === t.bl_count[a]; ) a--; + t.bl_count[a]--, (t.bl_count[a + 1] += 2), t.bl_count[g]--, (_ -= 2); + } while (_ > 0); + for (a = g; 0 !== a; a--) + for (r = t.bl_count[a]; 0 !== r; ) + (n = t.heap[--i]) > u || + (h[2 * n + 1] !== a && ((t.opt_len += (a - h[2 * n + 1]) * h[2 * n]), (h[2 * n + 1] = a)), r--); + } + })(t, e), + k(a, u, t.bl_count); + } + function P(t, e, i) { + var r, + n, + a = -1, + s = e[1], + o = 0, + l = 7, + h = 4; + for (0 === s && ((l = 138), (h = 3)), e[2 * (i + 1) + 1] = 65535, r = 0; r <= i; r++) + (n = s), + (s = e[2 * (r + 1) + 1]), + (++o < l && n === s) || + (o < h + ? (t.bl_tree[2 * n] += o) + : 0 !== n + ? (n !== a && t.bl_tree[2 * n]++, t.bl_tree[32]++) + : o <= 10 + ? t.bl_tree[34]++ + : t.bl_tree[36]++, + (o = 0), + (a = n), + 0 === s ? ((l = 138), (h = 3)) : n === s ? ((l = 6), (h = 3)) : ((l = 7), (h = 4))); + } + function z(t, e, i) { + var r, + n, + a = -1, + s = e[1], + o = 0, + l = 7, + h = 4; + for (0 === s && ((l = 138), (h = 3)), r = 0; r <= i; r++) + if (((n = s), (s = e[2 * (r + 1) + 1]), !(++o < l && n === s))) { + if (o < h) + do { + S(t, n, t.bl_tree); + } while (0 != --o); + else + 0 !== n + ? (n !== a && (S(t, n, t.bl_tree), o--), S(t, 16, t.bl_tree), C(t, o - 3, 2)) + : o <= 10 + ? (S(t, 17, t.bl_tree), C(t, o - 3, 3)) + : (S(t, 18, t.bl_tree), C(t, o - 11, 7)); + (o = 0), (a = n), 0 === s ? ((l = 138), (h = 3)) : n === s ? ((l = 6), (h = 3)) : ((l = 7), (h = 4)); + } + } + n(T); + var O = !1; + function N(t, e, i, n) { + C(t, 0 + (n ? 1 : 0), 3), + (function (t, e, i, n) { + R(t), n && (E(t, i), E(t, ~i)), r.arraySet(t.pending_buf, t.window, e, i, t.pending), (t.pending += i); + })(t, e, i, !0); + } + (e._tr_init = function (t) { + O || + (!(function () { + var t, + e, + i, + r, + n, + a = new Array(16); + for (i = 0, r = 0; r < 28; r++) for (p[r] = i, t = 0; t < 1 << h[r]; t++) _[i++] = r; + for (_[i - 1] = r, n = 0, r = 0; r < 16; r++) for (T[r] = n, t = 0; t < 1 << u[r]; t++) g[n++] = r; + for (n >>= 7; r < o; r++) for (T[r] = n << 7, t = 0; t < 1 << (u[r] - 7); t++) g[256 + n++] = r; + for (e = 0; e <= l; e++) a[e] = 0; + for (t = 0; t <= 143; ) (d[2 * t + 1] = 8), t++, a[8]++; + for (; t <= 255; ) (d[2 * t + 1] = 9), t++, a[9]++; + for (; t <= 279; ) (d[2 * t + 1] = 7), t++, a[7]++; + for (; t <= 287; ) (d[2 * t + 1] = 8), t++, a[8]++; + for (k(d, 287, a), t = 0; t < o; t++) (b[2 * t + 1] = 5), (b[2 * t] = M(t, 5)); + (m = new w(d, h, 257, s, l)), (v = new w(b, u, 0, o, l)), (x = new w(new Array(0), c, 0, 19, 7)); + })(), + (O = !0)), + (t.l_desc = new y(t.dyn_ltree, m)), + (t.d_desc = new y(t.dyn_dtree, v)), + (t.bl_desc = new y(t.bl_tree, x)), + (t.bi_buf = 0), + (t.bi_valid = 0), + F(t); + }), + (e._tr_stored_block = N), + (e._tr_flush_block = function (t, e, i, r) { + var n, + s, + o = 0; + t.level > 0 + ? (2 === t.strm.data_type && + (t.strm.data_type = (function (t) { + var e, + i = 4093624447; + for (e = 0; e <= 31; e++, i >>>= 1) if (1 & i && 0 !== t.dyn_ltree[2 * e]) return 0; + if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return 1; + for (e = 32; e < a; e++) if (0 !== t.dyn_ltree[2 * e]) return 1; + return 0; + })(t)), + B(t, t.l_desc), + B(t, t.d_desc), + (o = (function (t) { + var e; + for ( + P(t, t.dyn_ltree, t.l_desc.max_code), P(t, t.dyn_dtree, t.d_desc.max_code), B(t, t.bl_desc), e = 18; + e >= 3 && 0 === t.bl_tree[2 * f[e] + 1]; + e-- + ); + return (t.opt_len += 3 * (e + 1) + 5 + 5 + 4), e; + })(t)), + (n = (t.opt_len + 3 + 7) >>> 3), + (s = (t.static_len + 3 + 7) >>> 3) <= n && (n = s)) + : (n = s = i + 5), + i + 4 <= n && -1 !== e + ? N(t, e, i, r) + : 4 === t.strategy || s === n + ? (C(t, 2 + (r ? 1 : 0), 3), U(t, d, b)) + : (C(t, 4 + (r ? 1 : 0), 3), + (function (t, e, i, r) { + var n; + for (C(t, e - 257, 5), C(t, i - 1, 5), C(t, r - 4, 4), n = 0; n < r; n++) C(t, t.bl_tree[2 * f[n] + 1], 3); + z(t, t.dyn_ltree, e - 1), z(t, t.dyn_dtree, i - 1); + })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, o + 1), + U(t, t.dyn_ltree, t.dyn_dtree)), + F(t), + r && R(t); + }), + (e._tr_tally = function (t, e, i) { + return ( + (t.pending_buf[t.d_buf + 2 * t.last_lit] = (e >>> 8) & 255), + (t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e), + (t.pending_buf[t.l_buf + t.last_lit] = 255 & i), + t.last_lit++, + 0 === e ? t.dyn_ltree[2 * i]++ : (t.matches++, e--, t.dyn_ltree[2 * (_[i] + a + 1)]++, t.dyn_dtree[2 * A(e)]++), + t.last_lit === t.lit_bufsize - 1 + ); + }), + (e._tr_align = function (t) { + C(t, 2, 3), + S(t, 256, d), + (function (t) { + 16 === t.bi_valid + ? (E(t, t.bi_buf), (t.bi_buf = 0), (t.bi_valid = 0)) + : t.bi_valid >= 8 && ((t.pending_buf[t.pending++] = 255 & t.bi_buf), (t.bi_buf >>= 8), (t.bi_valid -= 8)); + })(t); + }); + }, + 292: (t) => { + 'use strict'; + t.exports = function () { + (this.input = null), + (this.next_in = 0), + (this.avail_in = 0), + (this.total_in = 0), + (this.output = null), + (this.next_out = 0), + (this.avail_out = 0), + (this.total_out = 0), + (this.msg = ''), + (this.state = null), + (this.data_type = 2), + (this.adler = 0); + }; + }, + 287: () => { + var t, e; + (window.requestAnimFrame = + window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function (t, e) { + window.setTimeout(t, 1e3 / 60); + }), + (jQuery.support.cors = !0), + $.ajaxTransport + ? ($.ajaxSetup({ flatOptions: { renderer: !0 } }), + $.ajaxTransport('+binary', function (t, e, i) { + if ( + window.FormData && + ((t.dataType && 'binary' == t.dataType) || + (t.data && ((window.ArrayBuffer && t.data instanceof ArrayBuffer) || (window.Blob && t.data instanceof Blob)))) + ) + return { + send: function (e, i) { + var r = new XMLHttpRequest(), + n = t.url, + a = t.type, + s = t.responseType || 'blob', + o = t.data || null; + t.renderer && + r.addEventListener('progress', function (e) { + e.lengthComputable && + (t.renderer.downloads[this.responseURL] + ? (t.renderer.downloads[this.responseURL].loaded = e.loaded) + : (t.renderer.downloads[this.responseURL] = { loaded: e.loaded, total: e.total }), + t.renderer.updateProgress()); + }), + r.addEventListener('load', function () { + t.renderer && (delete t.renderer.downloads[this.responseURL], t.renderer.updateProgress()); + var e = {}; + (e[t.dataType] = r.response), i(r.status, r.statusText, e, r.getAllResponseHeaders()); + }), + r.open(a, n, !0), + (r.responseType = s), + r.send(o); + }, + abort: function () { + i.abort(); + }, + }; + })) + : ((t = $.httpData), + ($.httpData = function (e, i, r) { + return 'binary' == i ? e.response : t(e, i, r); + }), + $.ajaxSetup({ + beforeSend: function (t, e) { + 'binary' == e.dataType && + ((t.responseType = e.responseType || 'arraybuffer'), + t.addEventListener( + 'progress', + function (t) { + e.renderer && + t.lengthComputable && + (e.renderer.downloads[this.responseURL] + ? (e.renderer.downloads[this.responseURL].loaded = t.loaded) + : (e.renderer.downloads[this.responseURL] = { loaded: t.loaded, total: t.total }), + e.renderer.updateProgress()); + }, + !1, + ), + t.addEventListener( + 'load', + function () { + e.renderer && (delete e.renderer.downloads[this.responseURL], e.renderer.updateProgress()); + }, + !1, + )); + }, + })), + (Math.randomInt = + Math.randomInt || + function (t, e) { + return Math.floor(Math.random() * (e - t)) + t; + }), + 'function' != typeof Object.create && + (Object.create = + ((e = function () {}), + function (t) { + if (arguments.length > 1) throw Error('Second argument not supported'); + if ('object' != typeof t) throw TypeError('Argument must be an object'); + e.prototype = t; + var i = new e(); + return (e.prototype = null), i; + })), + (window.console = window.console || { log: function () {}, error: function () {}, warn: function () {} }); + }, + }, + e = {}; + function i(r) { + var n = e[r]; + if (void 0 !== n) return n.exports; + var a = (e[r] = { exports: {} }); + return t[r](a, a.exports, i), a.exports; + } + (() => { + 'use strict'; + i(287); + let t = Float32Array; + function e(e, i, r) { + const n = new t(3); + return e && (n[0] = e), i && (n[1] = i), r && (n[2] = r), n; + } + function r(e, i, r) { + return ((r = r || new t(3))[0] = e[0] + i[0]), (r[1] = e[1] + i[1]), (r[2] = e[2] + i[2]), r; + } + function n(e, i, r) { + return ((r = r || new t(3))[0] = e[0] * i[0]), (r[1] = e[1] * i[1]), (r[2] = e[2] * i[2]), r; + } + let a = Float32Array; + function s(t) { + return ( + ((t = t || new a(16))[0] = 1), + (t[1] = 0), + (t[2] = 0), + (t[3] = 0), + (t[4] = 0), + (t[5] = 1), + (t[6] = 0), + (t[7] = 0), + (t[8] = 0), + (t[9] = 0), + (t[10] = 1), + (t[11] = 0), + (t[12] = 0), + (t[13] = 0), + (t[14] = 0), + (t[15] = 1), + t + ); + } + function o(t, e) { + e = e || new a(16); + const i = t[0], + r = t[1], + n = t[2], + s = t[3], + o = t[4], + l = t[5], + h = t[6], + u = t[7], + c = t[8], + f = t[9], + d = t[10], + b = t[11], + g = t[12], + _ = t[13], + p = t[14], + m = t[15], + v = d * m, + x = p * b, + T = h * m, + w = p * u, + y = h * b, + A = d * u, + E = n * m, + C = p * s, + S = n * b, + M = d * s, + k = n * u, + F = h * s, + R = c * _, + D = g * f, + I = o * _, + U = g * l, + B = o * f, + P = c * l, + z = i * _, + O = g * r, + N = i * f, + L = c * r, + H = i * l, + V = o * r, + j = v * l + w * f + y * _ - (x * l + T * f + A * _), + G = x * r + E * f + M * _ - (v * r + C * f + S * _), + X = T * r + C * l + k * _ - (w * r + E * l + F * _), + q = A * r + S * l + F * f - (y * r + M * l + k * f), + W = 1 / (i * j + o * G + c * X + g * q); + return ( + (e[0] = W * j), + (e[1] = W * G), + (e[2] = W * X), + (e[3] = W * q), + (e[4] = W * (x * o + T * c + A * g - (v * o + w * c + y * g))), + (e[5] = W * (v * i + C * c + S * g - (x * i + E * c + M * g))), + (e[6] = W * (w * i + E * o + F * g - (T * i + C * o + k * g))), + (e[7] = W * (y * i + M * o + k * c - (A * i + S * o + F * c))), + (e[8] = W * (R * u + U * b + B * m - (D * u + I * b + P * m))), + (e[9] = W * (D * s + z * b + L * m - (R * s + O * b + N * m))), + (e[10] = W * (I * s + O * u + H * m - (U * s + z * u + V * m))), + (e[11] = W * (P * s + N * u + V * b - (B * s + L * u + H * b))), + (e[12] = W * (I * d + P * p + D * h - (B * p + R * h + U * d))), + (e[13] = W * (N * p + R * n + O * d - (z * d + L * p + D * n))), + (e[14] = W * (z * h + V * p + U * n - (H * p + I * n + O * h))), + (e[15] = W * (H * d + B * n + L * h - (N * h + V * d + P * n))), + e + ); + } + function l(t, i, r) { + r = r || e(); + const n = i[0], + a = i[1], + s = i[2], + o = n * t[3] + a * t[7] + s * t[11] + t[15]; + return ( + (r[0] = (n * t[0] + a * t[4] + s * t[8] + t[12]) / o), + (r[1] = (n * t[1] + a * t[5] + s * t[9] + t[13]) / o), + (r[2] = (n * t[2] + a * t[6] + s * t[10] + t[14]) / o), + r + ); + } + function h(t, i, r) { + r = r || e(); + const n = i[0], + a = i[1], + s = i[2]; + return (r[0] = n * t[0] + a * t[4] + s * t[8]), (r[1] = n * t[1] + a * t[5] + s * t[9]), (r[2] = n * t[2] + a * t[6] + s * t[10]), r; + } + const u = 5120, + c = 5121, + f = 5122, + d = 5123, + b = 5124, + g = 5125, + _ = 5126, + p = {}; + { + const t = p; + (t[u] = Int8Array), + (t[5121] = Uint8Array), + (t[5122] = Int16Array), + (t[5123] = Uint16Array), + (t[b] = Int32Array), + (t[5125] = Uint32Array), + (t[5126] = Float32Array), + (t[32819] = Uint16Array), + (t[32820] = Uint16Array), + (t[33635] = Uint16Array), + (t[5131] = Uint16Array), + (t[33640] = Uint32Array), + (t[35899] = Uint32Array), + (t[35902] = Uint32Array), + (t[36269] = Uint32Array), + (t[34042] = Uint32Array); + } + function m(t) { + if (t instanceof Int8Array) return u; + if (t instanceof Uint8Array) return c; + if (t instanceof Uint8ClampedArray) return c; + if (t instanceof Int16Array) return f; + if (t instanceof Uint16Array) return d; + if (t instanceof Int32Array) return b; + if (t instanceof Uint32Array) return g; + if (t instanceof Float32Array) return _; + throw new Error('unsupported typed array type'); + } + function v(t) { + if (t === Int8Array) return u; + if (t === Uint8Array) return c; + if (t === Uint8ClampedArray) return c; + if (t === Int16Array) return f; + if (t === Uint16Array) return d; + if (t === Int32Array) return b; + if (t === Uint32Array) return g; + if (t === Float32Array) return _; + throw new Error('unsupported typed array type'); + } + const x = + 'undefined' != typeof SharedArrayBuffer + ? function (t) { + return t && t.buffer && (t.buffer instanceof ArrayBuffer || t.buffer instanceof SharedArrayBuffer); + } + : function (t) { + return t && t.buffer && t.buffer instanceof ArrayBuffer; + }; + function T(...t) { + console.error(...t); + } + function w(t, e) { + return 'undefined' != typeof WebGLTexture && e instanceof WebGLTexture; + } + const y = 34962, + A = { attribPrefix: '' }; + function E(t, e, i, r, n) { + t.bindBuffer(e, i), t.bufferData(e, r, n || 35044); + } + function C(t, e, i, r) { + if (((n = e), 'undefined' != typeof WebGLBuffer && n instanceof WebGLBuffer)) return e; + var n; + i = i || y; + const a = t.createBuffer(); + return E(t, i, a, e, r), a; + } + function S(t) { + return 'indices' === t; + } + function M(t) { + return t.length ? t : t.data; + } + const k = /coord|texture/i, + F = /color|colour/i; + function R(t, e) { + let i; + if (((i = k.test(t) ? 2 : F.test(t) ? 4 : 3), e % i > 0)) + throw new Error( + `Can not guess numComponents for attribute '${t}'. Tried ${i} but ${e} values is not evenly divisible by ${i}. You should specify it.`, + ); + return i; + } + function D(t, e) { + return t.numComponents || t.size || R(e, M(t).length); + } + function I(t, e) { + if (x(t)) return t; + if (x(t.data)) return t.data; + Array.isArray(t) && (t = { data: t }); + let i = t.type; + return i || (i = S(e) ? Uint16Array : Float32Array), new i(t.data); + } + function U(t, e) { + const i = {}; + return ( + Object.keys(e).forEach(function (r) { + if (!S(r)) { + const a = e[r], + s = a.attrib || a.name || a.attribName || A.attribPrefix + r; + if (a.value) { + if (!Array.isArray(a.value) && !x(a.value)) throw new Error('array.value is not array or typedarray'); + i[s] = { value: a.value }; + } else { + let e, o, l, h; + if (a.buffer && a.buffer instanceof WebGLBuffer) + (e = a.buffer), (h = a.numComponents || a.size), (o = a.type), (l = a.normalize); + else if ('number' == typeof a || 'number' == typeof a.data) { + const i = a.data || a, + s = a.type || Float32Array, + u = i * s.BYTES_PER_ELEMENT; + (o = v(s)), + (l = void 0 !== a.normalize ? a.normalize : (n = s) === Int8Array || n === Uint8Array), + (h = a.numComponents || a.size || R(r, i)), + (e = t.createBuffer()), + t.bindBuffer(y, e), + t.bufferData(y, u, a.drawType || 35044); + } else { + const i = I(a, r); + (e = C(t, i, void 0, a.drawType)), + (o = m(i)), + (l = + void 0 !== a.normalize + ? a.normalize + : (function (t) { + return t instanceof Int8Array || t instanceof Uint8Array; + })(i)), + (h = D(a, r)); + } + i[s] = { + buffer: e, + numComponents: h, + type: o, + normalize: l, + stride: a.stride || 0, + offset: a.offset || 0, + divisor: void 0 === a.divisor ? void 0 : a.divisor, + drawType: a.drawType, + }; + } + } + var n; + }), + t.bindBuffer(y, null), + i + ); + } + const B = ['position', 'positions', 'a_position']; + function P(t, e, i) { + const r = U(t, e), + n = Object.assign({}, i || {}); + n.attribs = Object.assign({}, i ? i.attribs : {}, r); + const a = e.indices; + if (a) { + const e = I(a, 'indices'); + (n.indices = C(t, e, 34963)), (n.numElements = e.length), (n.elementType = m(e)); + } else + n.numElements || + (n.numElements = (function (t, e) { + let i, r; + for (r = 0; r < B.length && ((i = B[r]), !(i in e)) && ((i = A.attribPrefix + i), !(i in e)); ++r); + r === B.length && (i = Object.keys(e)[0]); + const n = e[i]; + t.bindBuffer(y, n.buffer); + const a = t.getBufferParameter(y, 34660); + var s; + t.bindBuffer(y, null); + const o = + a / + (5120 === (s = n.type) || 5121 === s ? 1 : 5122 === s || 5123 === s ? 2 : 5124 === s || 5125 === s || 5126 === s ? 4 : 0), + l = n.numComponents || n.size, + h = o / l; + if (h % 1 != 0) throw new Error(`numComponents ${l} not correct for length ${length}`); + return h; + })(t, n.attribs)); + return n; + } + function z(t, e, i) { + const r = 'indices' === i ? 34963 : y; + return C(t, I(e, i), r); + } + function O(t, e) { + const i = {}; + return ( + Object.keys(e).forEach(function (r) { + i[r] = z(t, e[r], r); + }), + e.indices + ? ((i.numElements = e.indices.length), (i.elementType = m(I(e.indices)))) + : (i.numElements = (function (t) { + let e, i; + for (i = 0; i < B.length && ((e = B[i]), !(e in t)); ++i); + i === B.length && (e = Object.keys(t)[0]); + const r = t[e], + n = M(r).length, + a = D(r, e), + s = n / a; + if (n % a > 0) throw new Error(`numComponents ${a} not correct for length ${n}`); + return s; + })(e)), + i + ); + } + function N(t, e) { + let i = 0; + return ( + (t.push = function () { + for (let e = 0; e < arguments.length; ++e) { + const r = arguments[e]; + if (r instanceof Array || x(r)) for (let e = 0; e < r.length; ++e) t[i++] = r[e]; + else t[i++] = r; + } + }), + (t.reset = function (t) { + i = t || 0; + }), + (t.numComponents = e), + Object.defineProperty(t, 'numElements', { + get: function () { + return (this.length / this.numComponents) | 0; + }, + }), + t + ); + } + function L(t, e, i) { + return N(new (i || Float32Array)(t * e), t); + } + function H(t, e, i) { + const r = t.length, + n = new Float32Array(3); + for (let a = 0; a < r; a += 3) i(e, [t[a], t[a + 1], t[a + 2]], n), (t[a] = n[0]), (t[a + 1] = n[1]), (t[a + 2] = n[2]); + } + function V(t, i, r) { + r = r || e(); + const n = i[0], + a = i[1], + s = i[2]; + return (r[0] = n * t[0] + a * t[1] + s * t[2]), (r[1] = n * t[4] + a * t[5] + s * t[6]), (r[2] = n * t[8] + a * t[9] + s * t[10]), r; + } + function j(t, e) { + return H(t, e, h), t; + } + function G(t, e) { + return H(t, o(e), V), t; + } + function X(t, e) { + return H(t, e, l), t; + } + function q(t, e) { + return ( + Object.keys(t).forEach(function (i) { + const r = t[i]; + i.indexOf('pos') >= 0 ? X(r, e) : i.indexOf('tan') >= 0 || i.indexOf('binorm') >= 0 ? j(r, e) : i.indexOf('norm') >= 0 && G(r, e); + }), + t + ); + } + function W(t, e, i) { + return ( + (t = t || 2), + { + position: { + numComponents: 2, + data: [ + (e = e || 0) + -1 * (t *= 0.5), + (i = i || 0) + -1 * t, + e + 1 * t, + i + -1 * t, + e + -1 * t, + i + 1 * t, + e + 1 * t, + i + 1 * t, + ], + }, + normal: [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], + texcoord: [0, 0, 1, 0, 0, 1, 1, 1], + indices: [0, 1, 2, 2, 1, 3], + } + ); + } + function Y(t, e, i, r, n) { + (t = t || 1), (e = e || 1), (i = i || 1), (r = r || 1), (n = n || s()); + const a = (i + 1) * (r + 1), + o = L(3, a), + l = L(3, a), + h = L(2, a); + for (let n = 0; n <= r; n++) + for (let a = 0; a <= i; a++) { + const s = a / i, + u = n / r; + o.push(t * s - 0.5 * t, 0, e * u - 0.5 * e), l.push(0, 1, 0), h.push(s, u); + } + const u = i + 1, + c = L(3, i * r * 2, Uint16Array); + for (let t = 0; t < r; t++) + for (let e = 0; e < i; e++) + c.push((t + 0) * u + e, (t + 1) * u + e, (t + 0) * u + e + 1), c.push((t + 1) * u + e, (t + 1) * u + e + 1, (t + 0) * u + e + 1); + return q({ position: o, normal: l, texcoord: h, indices: c }, n); + } + function Z(t, e, i, r, n, a, s) { + if (e <= 0 || i <= 0) throw new Error('subdivisionAxis and subdivisionHeight must be > 0'); + (r = r || 0), (a = a || 0); + const o = (n = n || Math.PI) - r, + l = (s = s || 2 * Math.PI) - a, + h = (e + 1) * (i + 1), + u = L(3, h), + c = L(3, h), + f = L(2, h); + for (let n = 0; n <= i; n++) + for (let s = 0; s <= e; s++) { + const h = s / e, + d = n / i, + b = l * h + a, + g = o * d + r, + _ = Math.sin(b), + p = Math.cos(b), + m = Math.sin(g), + v = p * m, + x = Math.cos(g), + T = _ * m; + u.push(t * v, t * x, t * T), c.push(v, x, T), f.push(1 - h, d); + } + const d = e + 1, + b = L(3, e * i * 2, Uint16Array); + for (let t = 0; t < e; t++) + for (let e = 0; e < i; e++) + b.push((e + 0) * d + t, (e + 0) * d + t + 1, (e + 1) * d + t), b.push((e + 1) * d + t, (e + 0) * d + t + 1, (e + 1) * d + t + 1); + return { position: u, normal: c, texcoord: f, indices: b }; + } + const J = [ + [3, 7, 5, 1], + [6, 2, 0, 4], + [6, 7, 3, 2], + [0, 1, 5, 4], + [7, 6, 4, 5], + [2, 3, 1, 0], + ]; + function K(t) { + const e = (t = t || 1) / 2, + i = [ + [-e, -e, -e], + [+e, -e, -e], + [-e, +e, -e], + [+e, +e, -e], + [-e, -e, +e], + [+e, -e, +e], + [-e, +e, +e], + [+e, +e, +e], + ], + r = [ + [1, 0, 0], + [-1, 0, 0], + [0, 1, 0], + [0, -1, 0], + [0, 0, 1], + [0, 0, -1], + ], + n = [ + [1, 0], + [0, 0], + [0, 1], + [1, 1], + ], + a = L(3, 24), + s = L(3, 24), + o = L(2, 24), + l = L(3, 12, Uint16Array); + for (let t = 0; t < 6; ++t) { + const e = J[t]; + for (let l = 0; l < 4; ++l) { + const h = i[e[l]], + u = r[t], + c = n[l]; + a.push(h), s.push(u), o.push(c); + } + const h = 4 * t; + l.push(h + 0, h + 1, h + 2), l.push(h + 0, h + 2, h + 3); + } + return { position: a, normal: s, texcoord: o, indices: l }; + } + function Q(t, e, i, r, n, a, s) { + if (r < 3) throw new Error('radialSubdivisions must be 3 or greater'); + if (n < 1) throw new Error('verticalSubdivisions must be 1 or greater'); + const o = void 0 === a || a, + l = void 0 === s || s, + h = (o ? 2 : 0) + (l ? 2 : 0), + u = (r + 1) * (n + 1 + h), + c = L(3, u), + f = L(3, u), + d = L(2, u), + b = L(3, r * (n + h / 2) * 2, Uint16Array), + g = r + 1, + _ = Math.atan2(t - e, i), + p = Math.cos(_), + m = Math.sin(_), + v = n + (l ? 2 : 0); + for (let a = o ? -2 : 0; a <= v; ++a) { + let s, + o = a / n, + l = i * o; + a < 0 ? ((l = 0), (o = 1), (s = t)) : a > n ? ((l = i), (o = 1), (s = e)) : (s = t + (a / n) * (e - t)), + (-2 !== a && a !== n + 2) || ((s = 0), (o = 0)), + (l -= i / 2); + for (let t = 0; t < g; ++t) { + const e = Math.sin((t * Math.PI * 2) / r), + i = Math.cos((t * Math.PI * 2) / r); + c.push(e * s, l, i * s), + a < 0 ? f.push(0, -1, 0) : a > n ? f.push(0, 1, 0) : 0 === s ? f.push(0, 0, 0) : f.push(e * p, m, i * p), + d.push(t / r, 1 - o); + } + } + for (let t = 0; t < n + h; ++t) + if (!((1 === t && o) || (t === n + h - 2 && l))) + for (let e = 0; e < r; ++e) + b.push(g * (t + 0) + 0 + e, g * (t + 0) + 1 + e, g * (t + 1) + 1 + e), + b.push(g * (t + 0) + 0 + e, g * (t + 1) + 1 + e, g * (t + 1) + 0 + e); + return { position: c, normal: f, texcoord: d, indices: b }; + } + function tt(t, e) { + e = e || []; + const i = []; + for (let r = 0; r < t.length; r += 4) { + const n = t[r], + a = t.slice(r + 1, r + 4); + a.push.apply(a, e); + for (let t = 0; t < n; ++t) i.push.apply(i, a); + } + return i; + } + function et() { + const t = [ + 0, 0, 0, 0, 150, 0, 30, 0, 0, 0, 150, 0, 30, 150, 0, 30, 0, 0, 30, 0, 0, 30, 30, 0, 100, 0, 0, 30, 30, 0, 100, 30, 0, 100, 0, 0, + 30, 60, 0, 30, 90, 0, 67, 60, 0, 30, 90, 0, 67, 90, 0, 67, 60, 0, 0, 0, 30, 30, 0, 30, 0, 150, 30, 0, 150, 30, 30, 0, 30, 30, 150, + 30, 30, 0, 30, 100, 0, 30, 30, 30, 30, 30, 30, 30, 100, 0, 30, 100, 30, 30, 30, 60, 30, 67, 60, 30, 30, 90, 30, 30, 90, 30, 67, + 60, 30, 67, 90, 30, 0, 0, 0, 100, 0, 0, 100, 0, 30, 0, 0, 0, 100, 0, 30, 0, 0, 30, 100, 0, 0, 100, 30, 0, 100, 30, 30, 100, 0, 0, + 100, 30, 30, 100, 0, 30, 30, 30, 0, 30, 30, 30, 100, 30, 30, 30, 30, 0, 100, 30, 30, 100, 30, 0, 30, 30, 0, 30, 60, 30, 30, 30, + 30, 30, 30, 0, 30, 60, 0, 30, 60, 30, 30, 60, 0, 67, 60, 30, 30, 60, 30, 30, 60, 0, 67, 60, 0, 67, 60, 30, 67, 60, 0, 67, 90, 30, + 67, 60, 30, 67, 60, 0, 67, 90, 0, 67, 90, 30, 30, 90, 0, 30, 90, 30, 67, 90, 30, 30, 90, 0, 67, 90, 30, 67, 90, 0, 30, 90, 0, 30, + 150, 30, 30, 90, 30, 30, 90, 0, 30, 150, 0, 30, 150, 30, 0, 150, 0, 0, 150, 30, 30, 150, 30, 0, 150, 0, 30, 150, 30, 30, 150, 0, + 0, 0, 0, 0, 0, 30, 0, 150, 30, 0, 0, 0, 0, 150, 30, 0, 150, 0, + ], + e = tt([ + 18, 0, 0, 1, 18, 0, 0, -1, 6, 0, 1, 0, 6, 1, 0, 0, 6, 0, -1, 0, 6, 1, 0, 0, 6, 0, 1, 0, 6, 1, 0, 0, 6, 0, -1, 0, 6, 1, 0, 0, 6, 0, + -1, 0, 6, -1, 0, 0, + ]), + i = tt( + [ + 18, 200, 70, 120, 18, 80, 70, 200, 6, 70, 200, 210, 6, 200, 200, 70, 6, 210, 100, 70, 6, 210, 160, 70, 6, 70, 180, 210, 6, 100, + 70, 210, 6, 76, 210, 100, 6, 140, 210, 80, 6, 90, 130, 110, 6, 160, 160, 220, + ], + [255], + ), + r = t.length / 3, + n = { position: L(3, r), texcoord: L(2, r), normal: L(3, r), color: L(4, r, Uint8Array), indices: L(3, r / 3, Uint16Array) }; + n.position.push(t), + n.texcoord.push([ + 0.22, 0.19, 0.22, 0.79, 0.34, 0.19, 0.22, 0.79, 0.34, 0.79, 0.34, 0.19, 0.34, 0.19, 0.34, 0.31, 0.62, 0.19, 0.34, 0.31, 0.62, + 0.31, 0.62, 0.19, 0.34, 0.43, 0.34, 0.55, 0.49, 0.43, 0.34, 0.55, 0.49, 0.55, 0.49, 0.43, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, + 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, + 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, + 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, + 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, + ]), + n.normal.push(e), + n.color.push(i); + for (let t = 0; t < r; ++t) n.indices.push(t); + return n; + } + function it(t, e, i, a, s, o, l) { + if (s <= 0) throw new Error('subdivisionDown must be > 0'); + const h = (l = l || 1) - (o = o || 0), + u = 2 * (s + 1) * 4, + c = L(3, u), + f = L(3, u), + d = L(2, u); + function b(t, e, i) { + return t + (e - t) * i; + } + function g(e, i, l, u, g, _) { + for (let p = 0; p <= s; p++) { + const m = i / 1, + v = p / s, + x = 2 * (m - 0.5), + T = (o + v * h) * Math.PI, + w = Math.sin(T), + y = Math.cos(T), + A = b(t, e, w), + E = x * a, + C = y * t, + S = w * A; + c.push(E, C, S); + const M = r(n([0, w, y], l), u); + f.push(M), d.push(m * g + _, v); + } + } + for (let t = 0; t < 2; t++) { + const r = 2 * (t / 1 - 0.5); + g(e, t, [1, 1, 1], [0, 0, 0], 1, 0), + g(e, t, [0, 0, 0], [r, 0, 0], 0, 0), + g(i, t, [1, 1, 1], [0, 0, 0], 1, 0), + g(i, t, [0, 0, 0], [r, 0, 0], 0, 1); + } + const _ = L(3, 2 * s * 4, Uint16Array); + function p(t, e) { + for (let i = 0; i < s; ++i) _.push(t + i + 0, t + i + 1, e + i + 0), _.push(t + i + 1, e + i + 1, e + i + 0); + } + const m = s + 1; + return p(0 * m, 4 * m), p(5 * m, 7 * m), p(6 * m, 2 * m), p(3 * m, 1 * m), { position: c, normal: f, texcoord: d, indices: _ }; + } + function rt(t, e, i, r, n, a) { + return Q(t, t, e, i, r, n, a); + } + function nt(t, e, i, r, n, a) { + if (i < 3) throw new Error('radialSubdivisions must be 3 or greater'); + if (r < 3) throw new Error('verticalSubdivisions must be 3 or greater'); + n = n || 0; + const s = (a = a || 2 * Math.PI) - n, + o = i + 1, + l = r + 1, + h = o * l, + u = L(3, h), + c = L(3, h), + f = L(2, h), + d = L(3, i * r * 2, Uint16Array); + for (let a = 0; a < l; ++a) { + const l = a / r, + h = l * Math.PI * 2, + d = Math.sin(h), + b = t + d * e, + g = Math.cos(h), + _ = g * e; + for (let t = 0; t < o; ++t) { + const e = t / i, + r = n + e * s, + a = Math.sin(r), + o = Math.cos(r), + h = a * b, + p = o * b, + m = a * d, + v = o * d; + u.push(h, _, p), c.push(m, g, v), f.push(e, 1 - l); + } + } + for (let t = 0; t < r; ++t) + for (let e = 0; e < i; ++e) { + const i = 1 + e, + r = 1 + t; + d.push(o * t + e, o * r + e, o * t + i), d.push(o * r + e, o * r + i, o * t + i); + } + return { position: u, normal: c, texcoord: f, indices: d }; + } + function at(t, e, i, r, n) { + if (e < 3) throw new Error('divisions must be at least 3'); + (n = n || 1), (r = r || 0); + const a = (e + 1) * ((i = i || 1) + 1), + s = L(3, a), + o = L(3, a), + l = L(2, a), + h = L(3, i * e * 2, Uint16Array); + let u = 0; + const c = t - r, + f = e + 1; + for (let t = 0; t <= i; ++t) { + const a = r + c * Math.pow(t / i, n); + for (let r = 0; r <= e; ++r) { + const n = (2 * Math.PI * r) / e, + c = a * Math.cos(n), + d = a * Math.sin(n); + if ((s.push(c, 0, d), o.push(0, 1, 0), l.push(1 - r / e, t / i), t > 0 && r !== e)) { + const t = u + (r + 1), + e = u + r, + i = u + r - f, + n = u + (r + 1) - f; + h.push(t, e, i), h.push(t, i, n); + } + } + u += e + 1; + } + return { position: s, normal: o, texcoord: l, indices: h }; + } + function st(t) { + return function (e) { + const i = t.apply(this, Array.prototype.slice.call(arguments, 1)); + return O(e, i); + }; + } + function ot(t) { + return function (e) { + const i = t.apply(null, Array.prototype.slice.call(arguments, 1)); + return P(e, i); + }; + } + ot(et), + st(et), + ot(K), + st(K), + ot(Y), + st(Y), + ot(Z), + st(Z), + ot(Q), + st(Q), + ot(W), + st(W), + ot(it), + st(it), + ot(rt), + st(rt), + ot(nt), + st(nt), + ot(at), + st(at); + function lt(t) { + return !!t.texStorage2D; + } + const ht = (function () { + const t = {}, + e = {}; + return function (i, r) { + return ( + (function (i) { + const r = i.constructor.name; + if (!t[r]) { + for (const t in i) + if ('number' == typeof i[t]) { + const r = e[i[t]]; + e[i[t]] = r ? `${r} | ${t}` : t; + } + t[r] = !0; + } + })(i), + e[r] || ('number' == typeof r ? `0x${r.toString(16)}` : r) + ); + }; + })(); + new Uint8Array([128, 192, 255, 255]), + (function () { + let t; + })(); + const ut = 6407, + ct = 6408, + ft = 33319, + dt = 6403, + bt = {}; + { + const t = bt; + (t[6406] = { numColorComponents: 1 }), + (t[6409] = { numColorComponents: 1 }), + (t[6410] = { numColorComponents: 2 }), + (t[ut] = { numColorComponents: 3 }), + (t[ct] = { numColorComponents: 4 }), + (t[dt] = { numColorComponents: 1 }), + (t[36244] = { numColorComponents: 1 }), + (t[ft] = { numColorComponents: 2 }), + (t[33320] = { numColorComponents: 2 }), + (t[ut] = { numColorComponents: 3 }), + (t[36248] = { numColorComponents: 3 }), + (t[ct] = { numColorComponents: 4 }), + (t[36249] = { numColorComponents: 4 }), + (t[6402] = { numColorComponents: 1 }), + (t[34041] = { numColorComponents: 2 }); + } + const gt = T; + function _t(t) { + return 'undefined' != typeof document && document.getElementById ? document.getElementById(t) : null; + } + const pt = 33984, + mt = 34962, + vt = 5126, + xt = 5124, + Tt = 5125, + wt = 3553, + yt = 34067, + At = 32879, + Et = 35866, + Ct = {}; + function St(t, e) { + return Ct[e].bindPoint; + } + function Mt(t, e) { + return function (i) { + t.uniform1i(e, i); + }; + } + function kt(t, e) { + return function (i) { + t.uniform1iv(e, i); + }; + } + function Ft(t, e) { + return function (i) { + t.uniform2iv(e, i); + }; + } + function Rt(t, e) { + return function (i) { + t.uniform3iv(e, i); + }; + } + function Dt(t, e) { + return function (i) { + t.uniform4iv(e, i); + }; + } + function It(t, e, i, r) { + const n = St(0, e); + return lt(t) + ? function (e) { + let a, s; + w(0, e) ? ((a = e), (s = null)) : ((a = e.texture), (s = e.sampler)), + t.uniform1i(r, i), + t.activeTexture(pt + i), + t.bindTexture(n, a), + t.bindSampler(i, s); + } + : function (e) { + t.uniform1i(r, i), t.activeTexture(pt + i), t.bindTexture(n, e); + }; + } + function Ut(t, e, i, r, n) { + const a = St(0, e), + s = new Int32Array(n); + for (let t = 0; t < n; ++t) s[t] = i + t; + return lt(t) + ? function (e) { + t.uniform1iv(r, s), + e.forEach(function (e, r) { + let n, o; + t.activeTexture(pt + s[r]), + w(0, e) ? ((n = e), (o = null)) : ((n = e.texture), (o = e.sampler)), + t.bindSampler(i, o), + t.bindTexture(a, n); + }); + } + : function (e) { + t.uniform1iv(r, s), + e.forEach(function (e, i) { + t.activeTexture(pt + s[i]), t.bindTexture(a, e); + }); + }; + } + function Bt(t, e) { + return function (i) { + if (i.value) + switch ((t.disableVertexAttribArray(e), i.value.length)) { + case 4: + t.vertexAttrib4fv(e, i.value); + break; + case 3: + t.vertexAttrib3fv(e, i.value); + break; + case 2: + t.vertexAttrib2fv(e, i.value); + break; + case 1: + t.vertexAttrib1fv(e, i.value); + break; + default: + throw new Error('the length of a float constant value must be between 1 and 4!'); + } + else + t.bindBuffer(mt, i.buffer), + t.enableVertexAttribArray(e), + t.vertexAttribPointer(e, i.numComponents || i.size, i.type || vt, i.normalize || !1, i.stride || 0, i.offset || 0), + void 0 !== i.divisor && t.vertexAttribDivisor(e, i.divisor); + }; + } + function Pt(t, e) { + return function (i) { + if (i.value) { + if ((t.disableVertexAttribArray(e), 4 !== i.value.length)) throw new Error('The length of an integer constant value must be 4!'); + t.vertexAttrib4iv(e, i.value); + } else + t.bindBuffer(mt, i.buffer), + t.enableVertexAttribArray(e), + t.vertexAttribIPointer(e, i.numComponents || i.size, i.type || xt, i.stride || 0, i.offset || 0), + void 0 !== i.divisor && t.vertexAttribDivisor(e, i.divisor); + }; + } + function zt(t, e) { + return function (i) { + if (i.value) { + if ((t.disableVertexAttribArray(e), 4 !== i.value.length)) + throw new Error('The length of an unsigned integer constant value must be 4!'); + t.vertexAttrib4uiv(e, i.value); + } else + t.bindBuffer(mt, i.buffer), + t.enableVertexAttribArray(e), + t.vertexAttribIPointer(e, i.numComponents || i.size, i.type || Tt, i.stride || 0, i.offset || 0), + void 0 !== i.divisor && t.vertexAttribDivisor(e, i.divisor); + }; + } + function Ot(t, e, i) { + const r = i.size, + n = i.count; + return function (i) { + t.bindBuffer(mt, i.buffer); + const a = i.size || i.numComponents || r, + s = a / n, + o = i.type || vt, + l = Ct[o].size * a, + h = i.normalize || !1, + u = i.offset || 0, + c = l / n; + for (let r = 0; r < n; ++r) + t.enableVertexAttribArray(e + r), + t.vertexAttribPointer(e + r, s, o, h, l, u + c * r), + void 0 !== i.divisor && t.vertexAttribDivisor(e + r, i.divisor); + }; + } + (Ct[5126] = { + Type: Float32Array, + size: 4, + setter: function (t, e) { + return function (i) { + t.uniform1f(e, i); + }; + }, + arraySetter: function (t, e) { + return function (i) { + t.uniform1fv(e, i); + }; + }, + }), + (Ct[35664] = { + Type: Float32Array, + size: 8, + setter: function (t, e) { + return function (i) { + t.uniform2fv(e, i); + }; + }, + cols: 2, + }), + (Ct[35665] = { + Type: Float32Array, + size: 12, + setter: function (t, e) { + return function (i) { + t.uniform3fv(e, i); + }; + }, + cols: 3, + }), + (Ct[35666] = { + Type: Float32Array, + size: 16, + setter: function (t, e) { + return function (i) { + t.uniform4fv(e, i); + }; + }, + cols: 4, + }), + (Ct[5124] = { Type: Int32Array, size: 4, setter: Mt, arraySetter: kt }), + (Ct[35667] = { Type: Int32Array, size: 8, setter: Ft, cols: 2 }), + (Ct[35668] = { Type: Int32Array, size: 12, setter: Rt, cols: 3 }), + (Ct[35669] = { Type: Int32Array, size: 16, setter: Dt, cols: 4 }), + (Ct[5125] = { + Type: Uint32Array, + size: 4, + setter: function (t, e) { + return function (i) { + t.uniform1ui(e, i); + }; + }, + arraySetter: function (t, e) { + return function (i) { + t.uniform1uiv(e, i); + }; + }, + }), + (Ct[36294] = { + Type: Uint32Array, + size: 8, + setter: function (t, e) { + return function (i) { + t.uniform2uiv(e, i); + }; + }, + cols: 2, + }), + (Ct[36295] = { + Type: Uint32Array, + size: 12, + setter: function (t, e) { + return function (i) { + t.uniform3uiv(e, i); + }; + }, + cols: 3, + }), + (Ct[36296] = { + Type: Uint32Array, + size: 16, + setter: function (t, e) { + return function (i) { + t.uniform4uiv(e, i); + }; + }, + cols: 4, + }), + (Ct[35670] = { Type: Uint32Array, size: 4, setter: Mt, arraySetter: kt }), + (Ct[35671] = { Type: Uint32Array, size: 8, setter: Ft, cols: 2 }), + (Ct[35672] = { Type: Uint32Array, size: 12, setter: Rt, cols: 3 }), + (Ct[35673] = { Type: Uint32Array, size: 16, setter: Dt, cols: 4 }), + (Ct[35674] = { + Type: Float32Array, + size: 32, + setter: function (t, e) { + return function (i) { + t.uniformMatrix2fv(e, !1, i); + }; + }, + rows: 2, + cols: 2, + }), + (Ct[35675] = { + Type: Float32Array, + size: 48, + setter: function (t, e) { + return function (i) { + t.uniformMatrix3fv(e, !1, i); + }; + }, + rows: 3, + cols: 3, + }), + (Ct[35676] = { + Type: Float32Array, + size: 64, + setter: function (t, e) { + return function (i) { + t.uniformMatrix4fv(e, !1, i); + }; + }, + rows: 4, + cols: 4, + }), + (Ct[35685] = { + Type: Float32Array, + size: 32, + setter: function (t, e) { + return function (i) { + t.uniformMatrix2x3fv(e, !1, i); + }; + }, + rows: 2, + cols: 3, + }), + (Ct[35686] = { + Type: Float32Array, + size: 32, + setter: function (t, e) { + return function (i) { + t.uniformMatrix2x4fv(e, !1, i); + }; + }, + rows: 2, + cols: 4, + }), + (Ct[35687] = { + Type: Float32Array, + size: 48, + setter: function (t, e) { + return function (i) { + t.uniformMatrix3x2fv(e, !1, i); + }; + }, + rows: 3, + cols: 2, + }), + (Ct[35688] = { + Type: Float32Array, + size: 48, + setter: function (t, e) { + return function (i) { + t.uniformMatrix3x4fv(e, !1, i); + }; + }, + rows: 3, + cols: 4, + }), + (Ct[35689] = { + Type: Float32Array, + size: 64, + setter: function (t, e) { + return function (i) { + t.uniformMatrix4x2fv(e, !1, i); + }; + }, + rows: 4, + cols: 2, + }), + (Ct[35690] = { + Type: Float32Array, + size: 64, + setter: function (t, e) { + return function (i) { + t.uniformMatrix4x3fv(e, !1, i); + }; + }, + rows: 4, + cols: 3, + }), + (Ct[35678] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: wt }), + (Ct[35680] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: yt }), + (Ct[35679] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: At }), + (Ct[35682] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: wt }), + (Ct[36289] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: Et }), + (Ct[36292] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: Et }), + (Ct[36293] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: yt }), + (Ct[36298] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: wt }), + (Ct[36299] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: At }), + (Ct[36300] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: yt }), + (Ct[36303] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: Et }), + (Ct[36306] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: wt }), + (Ct[36307] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: At }), + (Ct[36308] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: yt }), + (Ct[36311] = { Type: null, size: 0, setter: It, arraySetter: Ut, bindPoint: Et }); + const Nt = {}; + (Nt[5126] = { size: 4, setter: Bt }), + (Nt[35664] = { size: 8, setter: Bt }), + (Nt[35665] = { size: 12, setter: Bt }), + (Nt[35666] = { size: 16, setter: Bt }), + (Nt[5124] = { size: 4, setter: Pt }), + (Nt[35667] = { size: 8, setter: Pt }), + (Nt[35668] = { size: 12, setter: Pt }), + (Nt[35669] = { size: 16, setter: Pt }), + (Nt[5125] = { size: 4, setter: zt }), + (Nt[36294] = { size: 8, setter: zt }), + (Nt[36295] = { size: 12, setter: zt }), + (Nt[36296] = { size: 16, setter: zt }), + (Nt[35670] = { size: 4, setter: Pt }), + (Nt[35671] = { size: 8, setter: Pt }), + (Nt[35672] = { size: 12, setter: Pt }), + (Nt[35673] = { size: 16, setter: Pt }), + (Nt[35674] = { size: 4, setter: Ot, count: 2 }), + (Nt[35675] = { size: 9, setter: Ot, count: 3 }), + (Nt[35676] = { size: 16, setter: Ot, count: 4 }); + const Lt = /ERROR:\s*\d+:(\d+)/gi; + function Ht(t, e = '', i = 0) { + const r = [...e.matchAll(Lt)], + n = new Map( + r.map((t, i) => { + const n = parseInt(t[1]), + a = r[i + 1], + s = a ? a.index : e.length; + return [n - 1, e.substring(t.index, s)]; + }), + ); + return t + .split('\n') + .map((t, e) => { + const r = n.get(e); + return `${e + 1 + i}: ${t}${r ? `\n\n^^^ ${r}` : ''}`; + }) + .join('\n'); + } + const Vt = /^[ \t]*\n/; + function jt(t, e, i, r) { + const n = r || gt, + a = t.createShader(i); + let s = 0; + Vt.test(e) && ((s = 1), (e = e.replace(Vt, ''))), t.shaderSource(a, e), t.compileShader(a); + if (!t.getShaderParameter(a, 35713)) { + const r = t.getShaderInfoLog(a); + return n(`${Ht(e, r, s)}\nError compiling ${ht(t, i)}: ${r}`), t.deleteShader(a), null; + } + return a; + } + function Gt(t, e, i) { + let r, n; + if (('function' == typeof e && ((i = e), (e = void 0)), 'function' == typeof t)) (i = t), (t = void 0); + else if (t && !Array.isArray(t)) { + if (t.errorCallback) return t; + const e = t; + (i = e.errorCallback), (t = e.attribLocations), (r = e.transformFeedbackVaryings), (n = e.transformFeedbackMode); + } + const a = { errorCallback: i || gt, transformFeedbackVaryings: r, transformFeedbackMode: n }; + if (t) { + let i = {}; + Array.isArray(t) + ? t.forEach(function (t, r) { + i[t] = e ? e[r] : r; + }) + : (i = t), + (a.attribLocations = i); + } + return a; + } + const Xt = ['VERTEX_SHADER', 'FRAGMENT_SHADER']; + function qt(t, e) { + return e.indexOf('frag') >= 0 ? 35632 : e.indexOf('vert') >= 0 ? 35633 : void 0; + } + function Wt(t, e) { + e.forEach(function (e) { + t.deleteShader(e); + }); + } + function Yt(t, e, i, r, n) { + const a = Gt(i, r, n), + s = [], + o = []; + for (let i = 0; i < e.length; ++i) { + let r = e[i]; + if ('string' == typeof r) { + const e = _t(r), + n = e ? e.text : r; + let s = t[Xt[i]]; + e && e.type && (s = qt(0, e.type) || s), (r = jt(t, n, s, a.errorCallback)), o.push(r); + } + (l = r), 'undefined' != typeof WebGLShader && l instanceof WebGLShader && s.push(r); + } + var l; + if (s.length !== e.length) return a.errorCallback('not enough shaders for program'), Wt(t, o), null; + const h = t.createProgram(); + s.forEach(function (e) { + t.attachShader(h, e); + }), + a.attribLocations && + Object.keys(a.attribLocations).forEach(function (e) { + t.bindAttribLocation(h, a.attribLocations[e], e); + }); + let u = a.transformFeedbackVaryings; + u && + (u.attribs && (u = u.attribs), + Array.isArray(u) || (u = Object.keys(u)), + t.transformFeedbackVaryings(h, u, a.transformFeedbackMode || 35981)), + t.linkProgram(h); + if (!t.getProgramParameter(h, 35714)) { + const e = t.getProgramInfoLog(h); + return ( + a.errorCallback( + `${s + .map((e) => { + const i = Ht(t.getShaderSource(e), '', 0), + r = t.getShaderParameter(e, t.SHADER_TYPE); + return `${ht(t, r)}\n${i}}`; + }) + .join('\n')}\nError in program linking: ${e}`, + ), + t.deleteProgram(h), + Wt(t, o), + null + ); + } + return h; + } + function Zt(t, e, i, r, n) { + const a = Gt(i, r, n), + s = []; + for (let i = 0; i < e.length; ++i) { + const r = jt(t, e[i], t[Xt[i]], a.errorCallback); + if (!r) return null; + s.push(r); + } + return Yt(t, s, a); + } + function Jt(t) { + const e = t.name; + return e.startsWith('gl_') || e.startsWith('webgl_'); + } + const Kt = /(\.|\[|]|\w+)/g; + function $t(t, e, i, r) { + const n = t.split(Kt).filter((t) => '' !== t); + let a = 0, + s = ''; + for (;;) { + const t = n[a++]; + s += t; + const l = (o = t[0]) >= '0' && o <= '9', + h = l ? parseInt(t) : t; + l && (s += n[a++]); + if (a === n.length) { + i[h] = e; + break; + } + { + const t = n[a++], + e = '[' === t, + o = i[h] || (e ? [] : {}); + (i[h] = o), + (i = o), + (r[s] = + r[s] || + (function (t) { + return function (e) { + ie(t, e); + }; + })(o)), + (s += t); + } + } + var o; + } + function Qt(t, e) { + let i = 0; + function r(e, r, n) { + const a = r.name.endsWith('[0]'), + s = r.type, + o = Ct[s]; + if (!o) throw new Error(`unknown type: 0x${s.toString(16)}`); + let l; + if (o.bindPoint) { + const e = i; + (i += r.size), (l = a ? o.arraySetter(t, s, e, n, r.size) : o.setter(t, s, e, n, r.size)); + } else l = o.arraySetter && a ? o.arraySetter(t, n) : o.setter(t, n); + return (l.location = n), l; + } + const n = {}, + a = {}, + s = t.getProgramParameter(e, 35718); + for (let i = 0; i < s; ++i) { + const s = t.getActiveUniform(e, i); + if (Jt(s)) continue; + let o = s.name; + o.endsWith('[0]') && (o = o.substr(0, o.length - 3)); + const l = t.getUniformLocation(e, s.name); + if (l) { + const t = r(0, s, l); + (n[o] = t), $t(o, t, a, n); + } + } + return n; + } + function te(t, e) { + const i = {}, + r = t.getProgramParameter(e, 35971); + for (let n = 0; n < r; ++n) { + const r = t.getTransformFeedbackVarying(e, n); + i[r.name] = { index: n, type: r.type, size: r.size }; + } + return i; + } + function ee(t, e) { + const i = t.getProgramParameter(e, 35718), + r = [], + n = []; + for (let a = 0; a < i; ++a) { + n.push(a), r.push({}); + const i = t.getActiveUniform(e, a); + r[a].name = i.name; + } + [ + ['UNIFORM_TYPE', 'type'], + ['UNIFORM_SIZE', 'size'], + ['UNIFORM_BLOCK_INDEX', 'blockNdx'], + ['UNIFORM_OFFSET', 'offset'], + ].forEach(function (i) { + const a = i[0], + s = i[1]; + t.getActiveUniforms(e, n, t[a]).forEach(function (t, e) { + r[e][s] = t; + }); + }); + const a = {}, + s = t.getProgramParameter(e, 35382); + for (let i = 0; i < s; ++i) { + const r = t.getActiveUniformBlockName(e, i), + n = { + index: t.getUniformBlockIndex(e, r), + usedByVertexShader: t.getActiveUniformBlockParameter(e, i, 35396), + usedByFragmentShader: t.getActiveUniformBlockParameter(e, i, 35398), + size: t.getActiveUniformBlockParameter(e, i, 35392), + uniformIndices: t.getActiveUniformBlockParameter(e, i, 35395), + }; + (n.used = n.usedByVertexShader || n.usedByFragmentShader), (a[r] = n); + } + return { blockSpecs: a, uniformData: r }; + } + function ie(t, e) { + for (const i in e) { + const r = t[i]; + 'function' == typeof r ? r(e[i]) : ie(t[i], e[i]); + } + } + function re(t, ...e) { + const i = t.uniformSetters || t, + r = e.length; + for (let t = 0; t < r; ++t) { + const r = e[t]; + if (Array.isArray(r)) { + const t = r.length; + for (let e = 0; e < t; ++e) re(i, r[e]); + } else + for (const t in r) { + const e = i[t]; + e && e(r[t]); + } + } + } + function ne(t, e) { + const i = {}, + r = t.getProgramParameter(e, 35721); + for (let n = 0; n < r; ++n) { + const r = t.getActiveAttrib(e, n); + if (Jt(r)) continue; + const a = t.getAttribLocation(e, r.name), + s = Nt[r.type], + o = s.setter(t, a, s); + (o.location = a), (i[r.name] = o); + } + return i; + } + function ae(t, e) { + const i = { program: e, uniformSetters: Qt(t, e), attribSetters: ne(t, e) }; + return lt(t) && ((i.uniformBlockSpec = ee(t, e)), (i.transformFeedbackInfo = te(t, e))), i; + } + function se(t, e, i, r, n) { + const a = Gt(i, r, n); + let s = !0; + if ( + ((e = e.map(function (t) { + if (t.indexOf('\n') < 0) { + const e = _t(t); + e ? (t = e.text) : (a.errorCallback('no element with id: ' + t), (s = !1)); + } + return t; + })), + !s) + ) + return null; + const o = Zt(t, e, a); + return o ? ae(t, o) : null; + } + const oe = 36096, + le = 33306, + he = {}; + (he[34041] = le), + (he[6401] = 36128), + (he[36168] = 36128), + (he[6402] = oe), + (he[33189] = oe), + (he[33190] = oe), + (he[36012] = oe), + (he[35056] = le), + (he[36013] = le); + const ue = {}; + (ue[32854] = !0), (ue[32855] = !0), (ue[36194] = !0), (ue[34041] = !0), (ue[33189] = !0), (ue[6401] = !0), (ue[36168] = !0); + var ce = {}; + const fe = { position: 3, normal: 3, tangent: 3, texcoord: 2, texcoord0: 2, texcoord1: 2, texcoord2: 2 }; + var de = {}; + class be { + constructor() { + this.attribs = {}; + } + disableAll() { + for (let t in this.attribs) this.gl.disableVertexAttribArray(this.attribs[t]); + this.attribs = {}; + } + enable(t, e) { + this.gl = t; + var i = {}; + for (let n in e) { + var r = e[n]; + void 0 !== r.loc && + (void 0 === this.attribs[r.loc] && t.enableVertexAttribArray(r.loc), + t.vertexAttribPointer(r.loc, r.size, r.type, !1, r.stride, r.offset), + (i[r.loc] = r.loc), + (this.attribs[n] = null)); + } + for (let t in this.attribs); + this.attribs = i; + } + } + class ge { + static CreateProgramAttributes(t, e) { + var i = {}, + r = 0; + for (let s in e) { + var n = e[s], + a = fe[s]; + (i[n] = { type: t.FLOAT, size: a, offset: 4 * r }), (r += a); + } + for (let t in i) i[t].stride = 4 * r; + return i; + } + CleanUpPrograms() { + de = {}; + } + ReleaseProgram(t) {} + static _GetProgram(t) { + return de[t]; + } + static RegisterProgram(t, e) { + if (!de[t]) { + var i = e.shaders; + de[t] = { shaders: [i[0], i[1]], attributes: e.attributes }; + } + return de[t]; + } + static GetProgram(t, e, i, r) { + var n = de[e], + a = ''; + for (var s in i) a += s + ':' + i[s] + '-'; + if (!n) { + var o = e.split('.'), + l = ce[o[0]][o[1]]; + l && (n = ge.RegisterProgram(e, l)); + } + if (!n) throw 'Program not registered: ' + o; + n.programInfo || (n.programInfo = {}), + (n.programInfo[a] = ge.CompileProgram(t, n.shaders, i)), + (r = r || (n.attributes && ge.CreateProgramAttributes(t, n.attributes))); + var h = n.programInfo[a]; + if (r) + for (var s in r) { + var u = h.attribSetters[s]; + u && ((r[s] = r[s] || {}), (r[s].loc = u.location)); + } + return (h.attributes = r), h; + } + static CompileProgram(t, e, i, r) { + var n = ''; + for (var a in i) { + var s = i[a]; + n = '#define ' + a + ' ' + (null === s ? '' : s) + '\n'; + } + var o = {}; + const l = se(t, [n + e[0], n + e[1]], null, null); + if (r) + for (var a in r) { + var h = l.attribSetters[a]; + h && ((r[a] = r[a] || {}), (r[a].loc = h.location)); + } + for (var a in l.uniformSetters) o[a] = l.uniformSetters[a].location; + return (l.uniforms = o), l; + } + } + var _e = new ge(), + pe = 1e-6, + me = 'undefined' != typeof Float32Array ? Float32Array : Array; + Math.random; + Math.PI; + function ve() { + var t = new me(3); + return me != Float32Array && ((t[0] = 0), (t[1] = 0), (t[2] = 0)), t; + } + function xe(t) { + var e = new me(3); + return (e[0] = t[0]), (e[1] = t[1]), (e[2] = t[2]), e; + } + function Te(t) { + var e = t[0], + i = t[1], + r = t[2]; + return Math.hypot(e, i, r); + } + function we(t, e, i) { + var r = new me(3); + return (r[0] = t), (r[1] = e), (r[2] = i), r; + } + function ye(t, e) { + return (t[0] = e[0]), (t[1] = e[1]), (t[2] = e[2]), t; + } + function Ae(t, e, i, r) { + return (t[0] = e), (t[1] = i), (t[2] = r), t; + } + function Ee(t, e, i) { + return (t[0] = e[0] + i[0]), (t[1] = e[1] + i[1]), (t[2] = e[2] + i[2]), t; + } + function Ce(t, e, i) { + return (t[0] = e[0] - i[0]), (t[1] = e[1] - i[1]), (t[2] = e[2] - i[2]), t; + } + function Se(t, e, i) { + return (t[0] = e[0] * i[0]), (t[1] = e[1] * i[1]), (t[2] = e[2] * i[2]), t; + } + function Me(t, e, i) { + return (t[0] = Math.min(e[0], i[0])), (t[1] = Math.min(e[1], i[1])), (t[2] = Math.min(e[2], i[2])), t; + } + function ke(t, e, i) { + return (t[0] = Math.max(e[0], i[0])), (t[1] = Math.max(e[1], i[1])), (t[2] = Math.max(e[2], i[2])), t; + } + function Fe(t, e, i) { + return (t[0] = e[0] * i), (t[1] = e[1] * i), (t[2] = e[2] * i), t; + } + function Re(t, e, i, r) { + return (t[0] = e[0] + i[0] * r), (t[1] = e[1] + i[1] * r), (t[2] = e[2] + i[2] * r), t; + } + function De(t) { + var e = t[0], + i = t[1], + r = t[2]; + return e * e + i * i + r * r; + } + function Ie(t, e) { + return (t[0] = -e[0]), (t[1] = -e[1]), (t[2] = -e[2]), t; + } + function Ue(t, e) { + var i = e[0], + r = e[1], + n = e[2], + a = i * i + r * r + n * n; + return a > 0 && (a = 1 / Math.sqrt(a)), (t[0] = e[0] * a), (t[1] = e[1] * a), (t[2] = e[2] * a), t; + } + function Be(t, e) { + return t[0] * e[0] + t[1] * e[1] + t[2] * e[2]; + } + function Pe(t, e, i) { + var r = e[0], + n = e[1], + a = e[2], + s = i[0], + o = i[1], + l = i[2]; + return (t[0] = n * l - a * o), (t[1] = a * s - r * l), (t[2] = r * o - n * s), t; + } + function ze(t, e, i, r) { + var n = e[0], + a = e[1], + s = e[2]; + return (t[0] = n + r * (i[0] - n)), (t[1] = a + r * (i[1] - a)), (t[2] = s + r * (i[2] - s)), t; + } + function Oe(t, e, i) { + var r = e[0], + n = e[1], + a = e[2], + s = i[3] * r + i[7] * n + i[11] * a + i[15]; + return ( + (s = s || 1), + (t[0] = (i[0] * r + i[4] * n + i[8] * a + i[12]) / s), + (t[1] = (i[1] * r + i[5] * n + i[9] * a + i[13]) / s), + (t[2] = (i[2] * r + i[6] * n + i[10] * a + i[14]) / s), + t + ); + } + function Ne(t, e, i) { + var r = e[0], + n = e[1], + a = e[2]; + return (t[0] = r * i[0] + n * i[3] + a * i[6]), (t[1] = r * i[1] + n * i[4] + a * i[7]), (t[2] = r * i[2] + n * i[5] + a * i[8]), t; + } + Math.hypot || + (Math.hypot = function () { + for (var t = 0, e = arguments.length; e--; ) t += arguments[e] * arguments[e]; + return Math.sqrt(t); + }); + var Le, + He = Ce, + Ve = Te; + Le = ve(); + function je() { + var t = new me(16); + return ( + me != Float32Array && + ((t[1] = 0), + (t[2] = 0), + (t[3] = 0), + (t[4] = 0), + (t[6] = 0), + (t[7] = 0), + (t[8] = 0), + (t[9] = 0), + (t[11] = 0), + (t[12] = 0), + (t[13] = 0), + (t[14] = 0)), + (t[0] = 1), + (t[5] = 1), + (t[10] = 1), + (t[15] = 1), + t + ); + } + function Ge(t, e) { + return ( + (t[0] = e[0]), + (t[1] = e[1]), + (t[2] = e[2]), + (t[3] = e[3]), + (t[4] = e[4]), + (t[5] = e[5]), + (t[6] = e[6]), + (t[7] = e[7]), + (t[8] = e[8]), + (t[9] = e[9]), + (t[10] = e[10]), + (t[11] = e[11]), + (t[12] = e[12]), + (t[13] = e[13]), + (t[14] = e[14]), + (t[15] = e[15]), + t + ); + } + function Xe(t, e, i, r, n, a, s, o, l, h, u, c, f, d, b, g) { + var _ = new me(16); + return ( + (_[0] = t), + (_[1] = e), + (_[2] = i), + (_[3] = r), + (_[4] = n), + (_[5] = a), + (_[6] = s), + (_[7] = o), + (_[8] = l), + (_[9] = h), + (_[10] = u), + (_[11] = c), + (_[12] = f), + (_[13] = d), + (_[14] = b), + (_[15] = g), + _ + ); + } + function qe(t) { + return ( + (t[0] = 1), + (t[1] = 0), + (t[2] = 0), + (t[3] = 0), + (t[4] = 0), + (t[5] = 1), + (t[6] = 0), + (t[7] = 0), + (t[8] = 0), + (t[9] = 0), + (t[10] = 1), + (t[11] = 0), + (t[12] = 0), + (t[13] = 0), + (t[14] = 0), + (t[15] = 1), + t + ); + } + function We(t, e) { + var i = e[0], + r = e[1], + n = e[2], + a = e[3], + s = e[4], + o = e[5], + l = e[6], + h = e[7], + u = e[8], + c = e[9], + f = e[10], + d = e[11], + b = e[12], + g = e[13], + _ = e[14], + p = e[15], + m = i * o - r * s, + v = i * l - n * s, + x = i * h - a * s, + T = r * l - n * o, + w = r * h - a * o, + y = n * h - a * l, + A = u * g - c * b, + E = u * _ - f * b, + C = u * p - d * b, + S = c * _ - f * g, + M = c * p - d * g, + k = f * p - d * _, + F = m * k - v * M + x * S + T * C - w * E + y * A; + return F + ? ((F = 1 / F), + (t[0] = (o * k - l * M + h * S) * F), + (t[1] = (n * M - r * k - a * S) * F), + (t[2] = (g * y - _ * w + p * T) * F), + (t[3] = (f * w - c * y - d * T) * F), + (t[4] = (l * C - s * k - h * E) * F), + (t[5] = (i * k - n * C + a * E) * F), + (t[6] = (_ * x - b * y - p * v) * F), + (t[7] = (u * y - f * x + d * v) * F), + (t[8] = (s * M - o * C + h * A) * F), + (t[9] = (r * C - i * M - a * A) * F), + (t[10] = (b * w - g * x + p * m) * F), + (t[11] = (c * x - u * w - d * m) * F), + (t[12] = (o * E - s * S - l * A) * F), + (t[13] = (i * S - r * E + n * A) * F), + (t[14] = (g * v - b * T - _ * m) * F), + (t[15] = (u * T - c * v + f * m) * F), + t) + : null; + } + function Ye(t, e, i) { + var r = e[0], + n = e[1], + a = e[2], + s = e[3], + o = e[4], + l = e[5], + h = e[6], + u = e[7], + c = e[8], + f = e[9], + d = e[10], + b = e[11], + g = e[12], + _ = e[13], + p = e[14], + m = e[15], + v = i[0], + x = i[1], + T = i[2], + w = i[3]; + return ( + (t[0] = v * r + x * o + T * c + w * g), + (t[1] = v * n + x * l + T * f + w * _), + (t[2] = v * a + x * h + T * d + w * p), + (t[3] = v * s + x * u + T * b + w * m), + (v = i[4]), + (x = i[5]), + (T = i[6]), + (w = i[7]), + (t[4] = v * r + x * o + T * c + w * g), + (t[5] = v * n + x * l + T * f + w * _), + (t[6] = v * a + x * h + T * d + w * p), + (t[7] = v * s + x * u + T * b + w * m), + (v = i[8]), + (x = i[9]), + (T = i[10]), + (w = i[11]), + (t[8] = v * r + x * o + T * c + w * g), + (t[9] = v * n + x * l + T * f + w * _), + (t[10] = v * a + x * h + T * d + w * p), + (t[11] = v * s + x * u + T * b + w * m), + (v = i[12]), + (x = i[13]), + (T = i[14]), + (w = i[15]), + (t[12] = v * r + x * o + T * c + w * g), + (t[13] = v * n + x * l + T * f + w * _), + (t[14] = v * a + x * h + T * d + w * p), + (t[15] = v * s + x * u + T * b + w * m), + t + ); + } + function Ze(t, e, i) { + var r, + n, + a, + s, + o, + l, + h, + u, + c, + f, + d, + b, + g = i[0], + _ = i[1], + p = i[2]; + return ( + e === t + ? ((t[12] = e[0] * g + e[4] * _ + e[8] * p + e[12]), + (t[13] = e[1] * g + e[5] * _ + e[9] * p + e[13]), + (t[14] = e[2] * g + e[6] * _ + e[10] * p + e[14]), + (t[15] = e[3] * g + e[7] * _ + e[11] * p + e[15])) + : ((r = e[0]), + (n = e[1]), + (a = e[2]), + (s = e[3]), + (o = e[4]), + (l = e[5]), + (h = e[6]), + (u = e[7]), + (c = e[8]), + (f = e[9]), + (d = e[10]), + (b = e[11]), + (t[0] = r), + (t[1] = n), + (t[2] = a), + (t[3] = s), + (t[4] = o), + (t[5] = l), + (t[6] = h), + (t[7] = u), + (t[8] = c), + (t[9] = f), + (t[10] = d), + (t[11] = b), + (t[12] = r * g + o * _ + c * p + e[12]), + (t[13] = n * g + l * _ + f * p + e[13]), + (t[14] = a * g + h * _ + d * p + e[14]), + (t[15] = s * g + u * _ + b * p + e[15])), + t + ); + } + function Je(t, e, i) { + var r = i[0], + n = i[1], + a = i[2]; + return ( + (t[0] = e[0] * r), + (t[1] = e[1] * r), + (t[2] = e[2] * r), + (t[3] = e[3] * r), + (t[4] = e[4] * n), + (t[5] = e[5] * n), + (t[6] = e[6] * n), + (t[7] = e[7] * n), + (t[8] = e[8] * a), + (t[9] = e[9] * a), + (t[10] = e[10] * a), + (t[11] = e[11] * a), + (t[12] = e[12]), + (t[13] = e[13]), + (t[14] = e[14]), + (t[15] = e[15]), + t + ); + } + function Ke(t, e, i) { + var r = Math.sin(i), + n = Math.cos(i), + a = e[4], + s = e[5], + o = e[6], + l = e[7], + h = e[8], + u = e[9], + c = e[10], + f = e[11]; + return ( + e !== t && + ((t[0] = e[0]), (t[1] = e[1]), (t[2] = e[2]), (t[3] = e[3]), (t[12] = e[12]), (t[13] = e[13]), (t[14] = e[14]), (t[15] = e[15])), + (t[4] = a * n + h * r), + (t[5] = s * n + u * r), + (t[6] = o * n + c * r), + (t[7] = l * n + f * r), + (t[8] = h * n - a * r), + (t[9] = u * n - s * r), + (t[10] = c * n - o * r), + (t[11] = f * n - l * r), + t + ); + } + function $e(t, e, i) { + var r = Math.sin(i), + n = Math.cos(i), + a = e[0], + s = e[1], + o = e[2], + l = e[3], + h = e[8], + u = e[9], + c = e[10], + f = e[11]; + return ( + e !== t && + ((t[4] = e[4]), (t[5] = e[5]), (t[6] = e[6]), (t[7] = e[7]), (t[12] = e[12]), (t[13] = e[13]), (t[14] = e[14]), (t[15] = e[15])), + (t[0] = a * n - h * r), + (t[1] = s * n - u * r), + (t[2] = o * n - c * r), + (t[3] = l * n - f * r), + (t[8] = a * r + h * n), + (t[9] = s * r + u * n), + (t[10] = o * r + c * n), + (t[11] = l * r + f * n), + t + ); + } + function Qe(t, e, i) { + var r = Math.sin(i), + n = Math.cos(i), + a = e[0], + s = e[1], + o = e[2], + l = e[3], + h = e[4], + u = e[5], + c = e[6], + f = e[7]; + return ( + e !== t && + ((t[8] = e[8]), + (t[9] = e[9]), + (t[10] = e[10]), + (t[11] = e[11]), + (t[12] = e[12]), + (t[13] = e[13]), + (t[14] = e[14]), + (t[15] = e[15])), + (t[0] = a * n + h * r), + (t[1] = s * n + u * r), + (t[2] = o * n + c * r), + (t[3] = l * n + f * r), + (t[4] = h * n - a * r), + (t[5] = u * n - s * r), + (t[6] = c * n - o * r), + (t[7] = f * n - l * r), + t + ); + } + function ti(t, e) { + return ( + (t[0] = 1), + (t[1] = 0), + (t[2] = 0), + (t[3] = 0), + (t[4] = 0), + (t[5] = 1), + (t[6] = 0), + (t[7] = 0), + (t[8] = 0), + (t[9] = 0), + (t[10] = 1), + (t[11] = 0), + (t[12] = e[0]), + (t[13] = e[1]), + (t[14] = e[2]), + (t[15] = 1), + t + ); + } + function ei(t, e, i) { + var r = e[0], + n = e[1], + a = e[2], + s = e[3], + o = r + r, + l = n + n, + h = a + a, + u = r * o, + c = r * l, + f = r * h, + d = n * l, + b = n * h, + g = a * h, + _ = s * o, + p = s * l, + m = s * h; + return ( + (t[0] = 1 - (d + g)), + (t[1] = c + m), + (t[2] = f - p), + (t[3] = 0), + (t[4] = c - m), + (t[5] = 1 - (u + g)), + (t[6] = b + _), + (t[7] = 0), + (t[8] = f + p), + (t[9] = b - _), + (t[10] = 1 - (u + d)), + (t[11] = 0), + (t[12] = i[0]), + (t[13] = i[1]), + (t[14] = i[2]), + (t[15] = 1), + t + ); + } + function ii(t, e) { + return (t[0] = e[12]), (t[1] = e[13]), (t[2] = e[14]), t; + } + function ri(t, e) { + var i = e[0], + r = e[1], + n = e[2], + a = e[4], + s = e[5], + o = e[6], + l = e[8], + h = e[9], + u = e[10]; + return (t[0] = Math.hypot(i, r, n)), (t[1] = Math.hypot(a, s, o)), (t[2] = Math.hypot(l, h, u)), t; + } + var ni = function (t, e, i, r, n) { + var a, + s = 1 / Math.tan(e / 2); + return ( + (t[0] = s / i), + (t[1] = 0), + (t[2] = 0), + (t[3] = 0), + (t[4] = 0), + (t[5] = s), + (t[6] = 0), + (t[7] = 0), + (t[8] = 0), + (t[9] = 0), + (t[11] = -1), + (t[12] = 0), + (t[13] = 0), + (t[15] = 0), + null != n && n !== 1 / 0 ? ((a = 1 / (r - n)), (t[10] = (n + r) * a), (t[14] = 2 * n * r * a)) : ((t[10] = -1), (t[14] = -2 * r)), + t + ); + }; + var ai = Ye; + const si = { 147259: !0 }, + oi = { 28060: !0, 28063: !0, 28082: !0, 41903: !0, 42147: !0, 44808: !0, 45271: !0 }; + const li = { + 2: { GeosetType: 15, Original: 2, Override: 11 }, + 3: { GeosetType: 15, Original: 3, Override: 12 }, + 4: { GeosetType: 15, Original: 4, Override: 13 }, + 5: { GeosetType: 15, Original: 5, Override: 14 }, + 6: { GeosetType: 15, Original: 6, Override: 15 }, + 7: { GeosetType: 15, Original: 7, Override: 16 }, + 8: { GeosetType: 15, Original: 8, Override: 17 }, + 9: { GeosetType: 15, Original: 9, Override: 18 }, + 10: { GeosetType: 15, Original: 10, Override: 19 }, + }, + hi = { + ITEM: 1, + HELM: 2, + SHOULDER: 4, + NPC: 8, + CHARACTER: 16, + HUMANOIDNPC: 32, + OBJECT: 64, + ARMOR: 128, + PATH: 256, + ITEMVISUAL: 512, + COLLECTION: 1024, + }, + ui = { MALE: 0, FEMALE: 1, 0: 'male', 1: 'female' }, + ci = 5, + fi = 15, + di = 21, + bi = 27, + gi = 30, + _i = { + 1: 'human', + 2: 'orc', + 3: 'dwarf', + 4: 'nightelf', + 5: 'scourge', + 6: 'tauren', + 7: 'gnome', + 8: 'troll', + 9: 'goblin', + 10: 'bloodelf', + 11: 'draenei', + 12: 'felorc', + 13: 'naga_', + 14: 'broken', + 15: 'skeleton', + 16: 'vrykul', + 17: 'tuskarr', + 18: 'foresttroll', + 19: 'taunka', + 20: 'northrendskeleton', + 21: 'icetroll', + 22: 'worgen', + 23: 'gilnean', + 24: 'pandaren', + 25: 'pandarena', + 26: 'pandarenh', + 27: 'nightborne', + 28: 'highmountaintauren', + 29: 'voidelf', + 30: 'lightforgeddraenei', + 31: 'zandalaritroll', + 32: 'kultiran', + 33: 'thinhuman', + 34: 'darkirondwarf', + 35: 'vulpera', + 36: 'magharorc', + 37: 'mechagnome', + }, + pi = [0, 1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 21, 22, 22, 16, 21, 0, 19, 5, 21, 22, 22, 0, 21, 21, 27], + mi = [0, 16, 0, 15, 1, 8, 10, 5, 6, 6, 7, 0, 0, 17, 18, 19, 14, 20, 0, 9, 8, 21, 22, 23, 0, 24, 25, 0], + vi = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + xi = [0, 2, 0, 4, 128, 128, 128, 128, 128, 128, 128, 0, 0, 1, 1, 1, 128, 1, 0, 128, 128, 1, 1, 1, 0, 1, 1, 2], + Ti = 1, + wi = 3, + yi = 4, + Ai = 5, + Ei = 6, + Ci = 7, + Si = 8, + Mi = 9, + ki = 10, + Fi = 13, + Ri = 14, + Di = 15, + Ii = 16, + Ui = 19, + Bi = 20, + Pi = 21, + zi = 22, + Oi = 23, + Ni = 26, + Li = 1, + Hi = 10, + Vi = [13, 14, 15, 16, 17, 88, 89], + ji = [8, 9, 10, 11, 12, 86, 87], + Gi = 3, + Xi = 5, + qi = 7, + Wi = 12, + Yi = [ + { x: 0, y: 0, w: 0.5, h: 0.25 }, + { x: 0, y: 0.25, w: 0.5, h: 0.25 }, + { x: 0, y: 0.5, w: 0.5, h: 0.125 }, + { x: 0.5, y: 0, w: 0.5, h: 0.25 }, + { x: 0.5, y: 0.25, w: 0.5, h: 0.125 }, + { x: 0.5, y: 0.375, w: 0.5, h: 0.25 }, + { x: 0.5, y: 0.625, w: 0.5, h: 0.25 }, + { x: 0.5, y: 0.875, w: 0.5, h: 0.125 }, + {}, + { x: 0, y: 0.625, w: 0.5, h: 0.125 }, + { x: 0, y: 0.75, w: 0.5, h: 0.25 }, + {}, + { x: 0, y: 0, w: 1, h: 1 }, + { x: 0, y: 0, w: 1, h: 1 }, + ], + Zi = [ + { x: 0, y: 0, w: 0.25, h: 0.25 }, + { x: 0, y: 0.25, w: 0.25, h: 0.25 }, + { x: 0, y: 0.5, w: 0.25, h: 0.125 }, + { x: 0.25, y: 0, w: 0.25, h: 0.25 }, + { x: 0.25, y: 0.25, w: 0.25, h: 0.125 }, + { x: 0.25, y: 0.375, w: 0.25, h: 0.25 }, + { x: 0.25, y: 0.625, w: 0.25, h: 0.25 }, + { x: 0.25, y: 0.875, w: 0.25, h: 0.125 }, + { x: 0.75, y: 0.75, w: 0.25, h: 0.25 }, + { x: 0.5, y: 0, w: 0.5, h: 1 }, + { x: 0.5, y: 0, w: 0.5, h: 1 }, + { x: 0.5, y: 0, w: 0.5, h: 1 }, + { x: 0, y: 0, w: 0.5, h: 1 }, + { x: 0, y: 0, w: 1, h: 1 }, + { x: 0, y: 0, w: 0.5, h: 1 }, + ], + Ji = { + 40: [5, 0, 5, 1, 5, 0, 5, 1], + 37: [7, 0, 7, 1, 7, 0, 7, 1], + 36: [2, 0, 2, 1, 2, 0, 2, 1], + 35: [9, 0, 9, 1, 9, 0, 9, 1], + 34: [3, 0, 3, 1, 3, 0, 3, 1], + 33: [5, 1, 0, -1, 5, 0, 0, -1], + 31: [0, -1, 8, 1, 0, -1, 8, 1], + 30: [11, 0, 11, 1, 11, 0, 11, 1], + 29: [10, 0, 10, 1, 10, 0, 10, 1], + 28: [6, 0, 6, 1, 6, 0, 6, 1], + 27: [4, 0, 4, 1, 4, 0, 4, 1], + 26: [24, 0, 24, 1, 24, 0, 24, 1], + 25: [24, 0, 24, 1, 24, 0, 24, 1], + 23: [1, 0, 1, 1, 1, 0, 1, 1], + 15: [5, 0, 5, 1, 5, 0, 5, 1], + }, + Ki = { 21: 26, 22: 27, 15: 28, 17: 26, 25: 32, 13: 32, 23: 33, 14: 28, 26: 26 }, + $i = { + 0: { 21: 26, 22: 27 }, + 1: { 21: 26, 22: 27 }, + 2: { 21: 30, 22: 31 }, + 3: { 21: 32, 22: 33 }, + 4: { 21: 26, 22: 27, 15: 28 }, + 5: { 21: 26 }, + 6: { 21: 26, 22: 27 }, + 7: { 21: 26, 22: 27 }, + 8: { 21: 26, 22: 27 }, + 9: { 21: 33, 22: 28 }, + }; + function Qi() { + var t = new me(4); + return me != Float32Array && ((t[0] = 0), (t[1] = 0), (t[2] = 0), (t[3] = 0)), t; + } + function tr(t) { + var e = new me(4); + return (e[0] = t[0]), (e[1] = t[1]), (e[2] = t[2]), (e[3] = t[3]), e; + } + function er(t, e, i, r) { + var n = new me(4); + return (n[0] = t), (n[1] = e), (n[2] = i), (n[3] = r), n; + } + function ir(t, e) { + return (t[0] = e[0]), (t[1] = e[1]), (t[2] = e[2]), (t[3] = e[3]), t; + } + function rr(t, e, i) { + return (t[0] = e[0] + i[0]), (t[1] = e[1] + i[1]), (t[2] = e[2] + i[2]), (t[3] = e[3] + i[3]), t; + } + function nr(t, e, i) { + return (t[0] = e[0] - i[0]), (t[1] = e[1] - i[1]), (t[2] = e[2] - i[2]), (t[3] = e[3] - i[3]), t; + } + function ar(t, e, i) { + return (t[0] = e[0] * i), (t[1] = e[1] * i), (t[2] = e[2] * i), (t[3] = e[3] * i), t; + } + function sr(t) { + var e = t[0], + i = t[1], + r = t[2], + n = t[3]; + return Math.hypot(e, i, r, n); + } + function or(t, e) { + var i = e[0], + r = e[1], + n = e[2], + a = e[3], + s = i * i + r * r + n * n + a * a; + return s > 0 && (s = 1 / Math.sqrt(s)), (t[0] = i * s), (t[1] = r * s), (t[2] = n * s), (t[3] = a * s), t; + } + function lr(t, e, i) { + var r = e[0], + n = e[1], + a = e[2], + s = e[3]; + return ( + (t[0] = i[0] * r + i[4] * n + i[8] * a + i[12] * s), + (t[1] = i[1] * r + i[5] * n + i[9] * a + i[13] * s), + (t[2] = i[2] * r + i[6] * n + i[10] * a + i[14] * s), + (t[3] = i[3] * r + i[7] * n + i[11] * a + i[15] * s), + t + ); + } + var hr = sr; + !(function () { + var t = Qi(); + })(); + const ur = class { + constructor(t) { + var e = this; + (e.a = we(t.getFloat(), t.getFloat(), t.getFloat())), + (e.b = er(t.getFloat(), t.getFloat(), t.getFloat(), 0)), + (e.c = t.getFloat()), + (e.d = t.getFloat()), + (e.e = t.getFloat()), + (e.f = t.getFloat()), + (e.g = [t.getUint8(), t.getUint8(), t.getUint8(), t.getUint8()]), + (e.h = [t.getUint8(), t.getUint8(), t.getUint8(), t.getUint8()]), + (e.i = xe(e.a)), + (e.j = tr(e.b)); + } + l() { + var t = this; + (t.a = null), (t.b = null), (t.g = null), (t.h = null), (t.i = null), (t.j = null); + } + }; + const cr = class { + constructor(t) { + var e = this; + (e.a = t.getUint16()), + (e.b = t.getUint16()), + (e.g = t.getUint32()), + (e.c = t.getUint32()), + (e.d = t.getUint16()), + (e.e = t.getUint16()), + (e.f = t.getUint16()), + (e.h = t.getInt16()), + (e.i = t.getUint16()), + t.getBool() && (e.j = t.getString()); + } + k() {} + }; + function fr() { + var t = new me(2); + return me != Float32Array && ((t[0] = 0), (t[1] = 0)), t; + } + function dr(t, e) { + var i = new me(2); + return (i[0] = t), (i[1] = e), i; + } + function br(t, e, i) { + return (t[0] = e), (t[1] = i), t; + } + function gr(t, e, i) { + return (t[0] = e[0] * i[0]), (t[1] = e[1] * i[1]), t; + } + function _r(t, e, i) { + return (t[0] = e[0] * i), (t[1] = e[1] * i), t; + } + !(function () { + var t = fr(); + })(); + function pr() { + var t = new me(9); + return ( + me != Float32Array && ((t[1] = 0), (t[2] = 0), (t[3] = 0), (t[5] = 0), (t[6] = 0), (t[7] = 0)), + (t[0] = 1), + (t[4] = 1), + (t[8] = 1), + t + ); + } + function mr(t, e) { + return ( + (t[0] = e[0]), + (t[1] = e[1]), + (t[2] = e[2]), + (t[3] = e[4]), + (t[4] = e[5]), + (t[5] = e[6]), + (t[6] = e[8]), + (t[7] = e[9]), + (t[8] = e[10]), + t + ); + } + function vr(t, e, i) { + var r = e[0], + n = e[1], + a = e[2], + s = e[3], + o = e[4], + l = e[5], + h = e[6], + u = e[7], + c = e[8], + f = i[0], + d = i[1], + b = i[2], + g = i[3], + _ = i[4], + p = i[5], + m = i[6], + v = i[7], + x = i[8]; + return ( + (t[0] = f * r + d * s + b * h), + (t[1] = f * n + d * o + b * u), + (t[2] = f * a + d * l + b * c), + (t[3] = g * r + _ * s + p * h), + (t[4] = g * n + _ * o + p * u), + (t[5] = g * a + _ * l + p * c), + (t[6] = m * r + v * s + x * h), + (t[7] = m * n + v * o + x * u), + (t[8] = m * a + v * l + x * c), + t + ); + } + function xr() { + var t = new me(4); + return me != Float32Array && ((t[0] = 0), (t[1] = 0), (t[2] = 0)), (t[3] = 1), t; + } + function Tr(t, e, i) { + i *= 0.5; + var r = Math.sin(i); + return (t[0] = r * e[0]), (t[1] = r * e[1]), (t[2] = r * e[2]), (t[3] = Math.cos(i)), t; + } + function wr(t, e, i, r) { + var n, + a, + s, + o, + l, + h = e[0], + u = e[1], + c = e[2], + f = e[3], + d = i[0], + b = i[1], + g = i[2], + _ = i[3]; + return ( + (a = h * d + u * b + c * g + f * _) < 0 && ((a = -a), (d = -d), (b = -b), (g = -g), (_ = -_)), + 1 - a > pe + ? ((n = Math.acos(a)), (s = Math.sin(n)), (o = Math.sin((1 - r) * n) / s), (l = Math.sin(r * n) / s)) + : ((o = 1 - r), (l = r)), + (t[0] = o * h + l * d), + (t[1] = o * u + l * b), + (t[2] = o * c + l * g), + (t[3] = o * f + l * _), + t + ); + } + var yr, + Ar, + Er, + Cr, + Sr, + Mr, + kr = ir, + Fr = function (t, e, i, r, n) { + return (t[0] = e), (t[1] = i), (t[2] = r), (t[3] = n), t; + }, + Rr = or; + (yr = ve()), (Ar = we(1, 0, 0)), (Er = we(0, 1, 0)), (Cr = xr()), (Sr = xr()), (Mr = pr()); + class Dr { + constructor() { + (this.a = -1), (this.b = null), (this.c = 0); + } + } + class Ir { + constructor() { + (this.a = new Dr()), (this.b = new Dr()), (this.c = 0), (this.d = !1); + } + } + class Ur { + f() { + var t = this; + if (t.b) for (var e = 0; e < t.b.length; ++e) t.b[e] = null; + return (t.a = null), (t.b = null), null; + } + k(t, e, i, r) { + let n = this; + if ((null == r && (r = this.g()), this.d >= 0 && (t = this.d < e.length ? e[this.d] : e[0]), 0 != n.c || n.b.length > 1)) { + if (n.a.length > 1) { + var a = n.a[n.a.length - 1]; + a > 0 && t > a && this.d < 0 && (t %= a); + for (var s = 0, o = n.a.length, l = 0; l < o; ++l) + if (t >= n.a[l] && t < n.a[l + 1]) { + s = l; + break; + } + var h = n.a[s], + u = n.a[s + 1], + c = 0; + return h != u && (c = (t - h) / (u - h)), 1 == n.c ? n.h(n.b[s], n.b[s + 1], c, r) : (r = n.i(r, n.b[s])); + } + return n.b.length > 0 ? (r = n.i(r, n.b[0])) : i; + } + return 0 == n.b.length ? r : (r = n.i(r, n.b[0])); + } + l(t) { + var e, + i = this; + (i.c = t.getInt16()), (i.d = t.getInt16()), (i.e = t.getBool()); + var r = t.getInt32(); + for (i.a = new Array(r), e = 0; e < r; ++e) i.a[e] = t.getInt32(); + var n = t.getInt32(); + for (i.b = new Array(n), e = 0; e < n; ++e) i.b[e] = i.j(t); + } + } + class Br extends Ur { + constructor(t) { + super(); + (this.ba = ve()), this.l(t); + } + g() { + return ve(); + } + h(t, e, i, r) { + return ze(r, t, e, i); + } + i(t, e) { + return ye(t, e), t; + } + j(t) { + return Ae(ve(), t.getFloat(), t.getFloat(), t.getFloat()); + } + } + class Pr extends Ur { + constructor(t) { + super(); + this.l(t), (this.ba = xr()); + } + g() { + return xr(); + } + h(t, e, i, r) { + return wr(r, t, e, i); + } + i(t, e) { + return kr(t, e), t; + } + j(t) { + return Fr(xr(), -t.getFloat(), -t.getFloat(), -t.getFloat(), t.getFloat()); + } + } + class zr extends Ur { + constructor(t) { + super(); + this.l(t); + } + j(t) { + return t.getUint16(); + } + g() { + return 0; + } + h(t, e, i, r) { + return t + (e - t) * i; + } + i(t, e) { + return e; + } + } + class Or extends zr { + j(t) { + return t.getFloat(); + } + } + class Nr extends zr { + j(t) { + return t.getUint8(); + } + } + class Lr { + d() { + for (var t = this, e = 0; e < t.b.length; ++e) t.b[e] = null; + return (t.a = null), (t.b = null), (t.c = null), null; + } + i(t, e, i, r) { + let n = this; + i || (i = this.e()); + let a = r || n.b; + if (n.b.length > 1 && n.a.length > 1) { + var s = n.a[n.a.length - 1]; + s > 0 && t > s && (t %= s); + for (var o = 0, l = n.a.length, h = 0; h < l - 1; ++h) + if (t > n.a[h] && t <= n.a[h + 1]) { + o = h; + break; + } + var u = n.a[o], + c = n.a[o + 1], + f = 0; + return u != c && (f = (t - u) / (c - u)), n.f(a[o], a[o + 1], f, i); + } + return a.length > 0 ? (i = n.g(i, a[0])) : e; + } + j(t) { + var e, + i = this, + r = t.getInt32(); + for (i.a = new Array(r), e = 0; e < r; ++e) i.a[e] = t.getInt16() / 32767; + var n = t.getInt32(); + for (i.b = new Array(n), e = 0; e < n; ++e) i.b[e] = i.h(t); + } + } + class Hr extends Lr { + constructor(t) { + super(); + (this.ba = fr()), this.j(t); + } + e() { + return fr(); + } + f(t, e, i, r) { + return (n = r), (s = e), (o = i), (l = (a = t)[0]), (h = a[1]), (n[0] = l + o * (s[0] - l)), (n[1] = h + o * (s[1] - h)), n; + var n, a, s, o, l, h; + } + g(t, e) { + var i, r; + return (r = e), ((i = t)[0] = r[0]), (i[1] = r[1]), t; + } + h(t) { + return br(fr(), t.getFloat(), t.getFloat()); + } + } + class Vr extends Lr { + constructor(t) { + super(); + this.j(t); + } + e() { + return ve(); + } + f(t, e, i, r) { + return ze(r, t, e, i); + } + g(t, e) { + return ye(t, e), t; + } + h(t) { + return Ae(ve(), t.getFloat(), t.getFloat(), t.getFloat()); + } + } + class jr extends Lr { + constructor(t) { + super(); + this.j(t); + } + e() { + return 0; + } + f(t, e, i, r) { + return t + (e - t) * i; + } + g(t, e) { + return t; + } + h(t) { + return t.getUint16(); + } + } + class Gr { + constructor(t, e) { + this.b(t, e); + } + b(t, e) { + var i = t.getInt32(); + this.a = new Array(i); + for (let r = 0; r < i; ++r) this.a[r] = new e(t); + } + c(t) { + return !(!this.a || 0 == this.a.length) && (t >= this.a.length && (t = 0), this.a[t].e); + } + d(t, e, i, r) { + if (!this.a || 0 == this.a.length) return i; + let n = t.a.a; + n >= this.a.length && (n = 0); + let a = this.a[n].k(t.a.c, e, i, r); + if (t.c > 0 && t.c < 1) { + let n = this.a[0].g(), + s = t.b.a; + s >= this.a.length && (s = 0); + let o = this.a[s].k(t.b.c, e, i, n); + o || (o = n), (n = this.a[0].g()), (a = this.a[0].h(o, a, t.c, n)), r && this.a[0].i(r, n); + } + return a; + } + e() { + if (this.a && 0 != this.a.length) { + for (var t = 0; t < this.a.length; ++t) this.a[t].f(), (this.a[t] = null); + return null; + } + } + } + function Xr(t, e) { + return er(t[4 * e + 0], t[4 * e + 1], t[4 * e + 2], 0); + } + function qr(t, e, i) { + for (let r = 0; r < 4; r++) t[4 * e + r] = i[r]; + } + const Wr = class { + constructor(t, e, i) { + (this.t = null), (this.u = null), (this.v = null); + var r = this; + (r.a = t), + (r.b = e), + (r.c = i.getInt32()), + (r.d = i.getUint32()), + (r.e = i.getInt16()), + (r.f = i.getUint16()), + (r.g = i.getUint32()), + (r.h = we(i.getFloat(), i.getFloat(), i.getFloat())), + (r.i = new Gr(i, Br)), + (r.j = new Gr(i, Pr)), + (r.k = new Gr(i, Br)), + (r.l = ve()), + (r.m = je()), + (r.n = ve()), + (r.o = xr()), + (r.p = je()), + (r.q = !1), + (r.r = !1), + (r.s = !1); + } + y() { + var t = this; + (t.a = null), + (t.h = null), + (t.l = null), + (t.m = null), + (t.n = null), + (t.o = null), + (t.p = null), + t.i.e(), + t.j.e(), + t.k.e(), + (t.i = null), + (t.j = null), + (t.k = null); + } + z() { + this.q = !0; + for (var t = 0; t < 16; ++t) this.m[t] = 0; + } + A(t) { + t ? (null == this.t && (this.t = new Ir()), this.a.bt(t, this.t)) : (this.t = null); + let e = this.a.ai[this.b]; + for (let i = 0; i < e.length; i++) this.a.ap[e[i]].A(t); + } + B(t) { + t ? (null == this.u && (this.u = new Ir()), this.a.bt(t, this.u)) : (this.u = null); + let e = this.a.ai[this.b]; + for (let i = 0; i < e.length; i++) this.a.ap[e[i]].B(t); + } + C(t) { + var e = this; + if (e.q) return void e.z(); + if ((null != this.t && this.a.bX(this.t, t), e.r || e.s)) return; + if (((e.r = !0), !e.a)) return; + qe(e.m); + var i = e.a.R; + if (!i) return; + let r = je(); + if ((Ye(r, r, this.a.aS.viewMatrix), Ye(r, r, this.a.U), Ye(e.m, e.m, r), e.e > -1)) { + e.a.ap[e.e].C(t); + let i = je(); + if ((Ge(i, e.a.ap[e.e].m), Ye(i, r, i), 1 & e.d || 2 & e.d || 4 & e.d)) { + if (4 & e.d && 2 & e.d) qr(i, 0, Xr(r, 0)), qr(i, 1, Xr(r, 1)), qr(i, 2, Xr(r, 2)); + else if (4 & e.d) { + { + let t = Xr(r, 0), + e = sr(t); + ar(t, t, sr(Xr(i, 0)) / e), qr(i, 0, t); + } + { + let t = Xr(r, 1), + e = sr(t); + ar(t, t, sr(Xr(i, 1)) / e), qr(i, 1, t); + } + { + let t = Xr(r, 2), + e = sr(t); + ar(t, t, sr(Xr(i, 2)) / e), qr(i, 2, t); + } + } else if (2 & e.d) { + { + let t = Xr(r, 0); + ar(t, t, 1 / sr(Xr(i, 0))), ar(t, t, sr(Xr(r, 0))), qr(i, 0, t); + } + { + let t = Xr(r, 1); + ar(t, t, 1 / sr(Xr(i, 1))), ar(t, t, sr(Xr(r, 1))), qr(i, 1, t); + } + { + let t = Xr(r, 2); + ar(t, t, 1 / sr(Xr(i, 2))), ar(t, t, sr(Xr(r, 2))), qr(i, 2, t); + } + } + if (1 & e.d) qr(i, 3, Xr(r, 3)); + else { + let t = er(e.h[0], e.h[1], e.h[2], 1), + n = Qi(); + ir(n, t), (n[3] = 0); + let a = Qi(), + s = Qi(); + lr(a, t, e.a.ap[e.e].m), lr(a, a, r), lr(s, n, i), nr(a, a, s), (a[3] = 1), qr(i, 3, a); + } + } + let n = je(); + We(n, r), Ye(i, n, i), Ye(e.m, e.m, i); + } + let n = null; + if (null != this.t) { + let t = this.D(this.t); + this.a.S || (this.w = t), (n = this.a.S ? this.w : t); + } else { + let t = this.D(i); + this.a.S || (this.w = t), (n = this.a.S ? this.w : t); + } + let a = null; + if (null != this.u) { + let t = this.D(this.u); + this.a.S || (this.x = t), (a = this.a.S ? this.x : t); + } + let s = null != n || null != a, + o = je(); + s && (null != n && Ye(o, o, n), null != a && Ye(o, o, a)), + null != this.v && (Ze(o, o, this.h), Ye(o, o, this.v), Ze(o, o, Ie(this.n, this.h))), + Ye(e.m, e.m, o); + let l = 120 & e.d; + if (l) { + let t = je(); + Ge(t, e.m); + let i = e.m, + r = ve(); + ri(r, e.m); + let n = Qi(); + if (16 == l) { + let t = Xr(e.m, 0); + ar(t, t, 1 / Te(t)), qr(e.m, 0, t); + let r = er(i[4], -i[0], 0, 0); + qr(i, 1, or(r, r)), Pe(n, r, t), (n[3] = 0), qr(i, 2, n); + } else if (l > 16) { + if (32 == l) { + let t = Xr(i, 1); + ar(t, t, 1 / sr(t)), qr(e.m, 1, t); + let r = er(-i[5], i[1], 0, 0); + qr(i, 0, or(r, r)), (n[3] = 0), qr(i, 2, n); + } else if (64 == l) { + let t = Xr(i, 2); + or(t, t), qr(i, 2, t); + let e = er(t[1], -t[0], 0, 0); + or(e, e), qr(i, 1, e), Pe(n, t, e), (n[3] = 0), qr(i, 0, n); + } + } else if (8 == l) { + let t = this.a.h; + if (s) { + let e = Xr(o, 0); + (e = er(e[1], e[2], -e[0], 0)), or(e, e), qr(i, 0, e); + let r = Xr(o, 1); + (r = er(t ? -r[1] : r[1], t ? -r[2] : r[2], t ? r[0] : -r[0], 0)), or(r, r), qr(i, 1, r); + let n = Xr(o, 2); + (n = er(n[1], n[2], -n[0], 0)), or(n, n), qr(i, 2, n); + } else { + qr(i, 0, er(0, 0, -1, 0)), qr(i, 1, er(t ? -1 : 1, 0, 0, 0)), qr(i, 2, er(0, 1, 0, 0)); + } + } + let a = er(this.h[0], this.h[1], this.h[2], 1), + h = er(this.h[0], this.h[1], this.h[2], 0), + u = Xr(i, 0), + c = Xr(i, 1), + f = Xr(i, 2); + ar(u, u, r[0]), ar(c, c, r[1]), ar(f, f, r[2]), qr(i, 0, u), qr(i, 1, c), qr(i, 2, f), lr(a, a, t), lr(h, h, i); + let d = Qi(); + nr(d, a, h), (d[3] = 1), qr(i, 3, d); + } + We(r, r), Ye(e.m, r, e.m), Oe(e.l, e.h, e.m); + } + D(t) { + var e = this.i.c(t.a.a), + i = this.j.c(t.a.a), + r = this.k.c(t.a.a); + if (0 != (640 & this.d)) { + let w = je(); + return ( + qe(w), + Ze(w, w, this.h), + e && ((this.n = this.i.d(t, this.a.aX)), Ze(w, w, this.n)), + i && + ((this.o = this.j.d(t, this.a.aX, xr())), + (n = this.p), + (a = this.o), + (s = a[0]), + (o = a[1]), + (l = a[2]), + (h = a[3]), + (d = s * (u = s + s)), + (b = o * u), + (g = o * (c = o + o)), + (_ = l * u), + (p = l * c), + (m = l * (f = l + l)), + (v = h * u), + (x = h * c), + (T = h * f), + (n[0] = 1 - g - m), + (n[1] = b + T), + (n[2] = _ - x), + (n[3] = 0), + (n[4] = b - T), + (n[5] = 1 - d - m), + (n[6] = p + v), + (n[7] = 0), + (n[8] = _ + x), + (n[9] = p - v), + (n[10] = 1 - d - g), + (n[11] = 0), + (n[12] = 0), + (n[13] = 0), + (n[14] = 0), + (n[15] = 1), + Ye(w, w, this.p)), + r && ((this.n = this.k.d(t, this.a.aX)), Je(w, w, this.n)), + Ze(w, w, Ie(this.n, this.h)), + w + ); + } + var n, a, s, o, l, h, u, c, f, d, b, g, _, p, m, v, x, T; + return null; + } + }; + const Yr = class { + constructor(t) { + var e = this; + (e.a = t.getUint16()), + (e.b = t.getUint16()), + (e.c = t.getUint16()), + (e.d = t.getUint16()), + (e.e = t.getUint16() + 65536 * e.b), + (e.f = t.getUint16()), + (e.g = t.getUint16()), + (e.h = we(t.getFloat(), t.getFloat(), t.getFloat())), + (e.i = we(t.getFloat(), t.getFloat(), t.getFloat())), + (e.j = t.getFloat()); + } + k() { + (this.h = null), (this.i = null); + } + }; + var Zr = i(591); + const Jr = class { + constructor(t) { + (this.a = t.getUint16()), (this.b = t.getUint16()); + } + static c(t) { + (t.E = !1), + t.o.av && t.g < t.o.av.length ? (t.r = t.o.av[t.g]) : (t.r = { a: 0, b: 0 }), + (t.x = 0 != (1 & t.r.a)), + (t.y = 0 == (4 & t.r.a)), + (t.z = 0 != (16 & t.r.a)); + } + }; + class Kr { + static a(t) { + const e = 32767 & t; + return e < $r.length ? $r[e] : (WH.debug('Unknown shader effect:', e), ['PS_Combiners_Opaque', 'VS_Diffuse_T1']); + } + static b(t, e) { + var i = ''; + if (-1e3 == t && 3 == e) return 'Skin'; + if (32768 & t) return Kr.a(t)[0]; + if (1 == e) i = 112 & t ? 'PS_Combiners_Mod' : 'PS_Combiners_Opaque'; + else { + i = + (112 & t ? 'PS_Combiners_Mod' : 'PS_Combiners_Opaque') + + '_' + + (112 & t + ? ['Opaque', 'Mod', 'Mod', 'Add', 'Mod2x', 'Mod', 'Mod2xNA', 'AddNA'] + : ['Opaque', 'Mod', 'Mod', 'AddAlpha', 'Mod2x', 'Mod', 'Mod2xNA', 'AddAlpha'])[7 & t]; + } + return i; + } + static c(t, e) { + var i = ''; + if (-1e3 == t && 3 == e) i = 'T1_T1_T1'; + else { + if (32768 & t) return Kr.a(t)[1]; + i = + 1 == e + ? 128 & t + ? 'Env' + : 16384 & t + ? 'T2' + : 'T1' + : 128 & t + ? 8 & t + ? 'Env_Env' + : 'Env_T1' + : 8 & t + ? 'T1_Env' + : 16384 & t + ? 'T1_T2' + : 'T1_T1'; + } + return 'VS_Diffuse_' + i; + } + static d(t, e, i) { + var r = Kr.b(t, e), + n = Kr.c(t, e), + a = 'Wow.' + n + '_' + r; + if (ge._GetProgram(a)) return { name: a }; + var s = { + shaders: [Kr.f(n), Kr.g(r, i)], + attributes: { position: 'aPosition', normal: 'aNormal', texcoord0: 'aTexCoord0', texcoord1: 'aTexCoord1' }, + }; + return ge.RegisterProgram(a, s), { name: a }; + } + static e(t) { + var e = {}, + i = { + texcoord1: function (t, e) { + t.INPUT_TEXCOORD1 = 'aTexCoord' + e; + }, + }; + for (var r in t.options) { + var n = t.options[r]; + i[r](e, n); + } + return { name: 'Wow.' + t.name, config: e }; + } + static f(t) { + var e = ''; + if ( + ((e += 'vTexCoord1 = (uTextureMatrix1 * vec4(aTexCoord0, 0, 1)).st;\n'), + (e += 'vTexCoord2 = (uTextureMatrix2 * vec4(aTexCoord1, 0, 1)).st;\n'), + 'VS' === t.substr(0, 2)) + ) { + var i = (t = t.substr(3)).split('_'), + r = i[0]; + if ('Diffuse' === r || 'Color' === r) { + (e = ''), i.splice(0, 1); + var n = { + T1: ['uTextureMatrix1', 'aTexCoord0'], + T2: ['uTextureMatrix2', 'aTexCoord1'], + T3: ['', 'aTexCoord2'], + Env: ['', 'texEnv'], + }, + a = 1; + for (var s in i) + n[i[s]] + ? (n[i[s]][0] && 'texEnv' != n[i[s]][1] + ? (e += 'vTexCoord' + a + ' = (' + n[i[s]][0] + ' * vec4(' + n[i[s]][1] + ', 0, 1)).st;\n') + : 'texEnv' == n[i[s]][1] + ? (e += 'vTexCoord' + a + ' = texEnv;\n') + : (e += 'vTexCoord' + a + ' = (uTextureMatrix' + a + ' * vec4(' + n[i[s]][1] + ', 0, 1)).st;\n'), + a++) + : WH.debug('Missing vertex shader def?', t); + } + } + return ( + ' attribute vec3 aPosition;\n attribute vec3 aNormal;\n attribute vec2 aTexCoord0;\n attribute vec2 aTexCoord1;\n attribute vec3 aColor;\n \n varying vec3 vPosition;\n varying vec3 vNormal;\n varying vec2 vTexCoord1;\n varying vec2 vTexCoord2;\n varying vec2 vTexCoord3;\n varying vec2 vTexCoord4;\n \n uniform mat4 uModelMatrix;\n uniform mat4 uPanningMatrix;\n uniform mat4 uViewMatrix;\n uniform mat4 uProjMatrix;\n uniform mat4 uTextureMatrix1;\n uniform mat4 uTextureMatrix2;\n uniform mat4 uTextureMatrix3;\n uniform mat4 uTextureMatrix4;\n uniform vec3 uCameraPos;\n uniform bool uHasTexture1;\n uniform bool uHasTexture2;\n uniform bool uHasTexture3;\n uniform bool uHasTexture4;\n \n vec2 sphereMap(vec3 vertex, vec3 normal)\n {\n vec3 normPos = -(normalize(vertex.xyz));\n vec3 temp = (normPos - (normal * (2.0 * dot(normPos, normal))));\n temp = vec3(temp.x, temp.y, temp.z + 1.0);\n vec2 texCoord = ((normalize(temp).xy * 0.5) + vec2(0.5));\n return texCoord;\n }\n void main(void) {\n vec4 pos = uViewMatrix * uModelMatrix * vec4(aPosition, 1);\n vPosition = pos.rgb;\n vNormal = normalize(mat3(uViewMatrix * uModelMatrix) * aNormal);\n vec2 texEnv = sphereMap(pos.xyz,vNormal.xyz);\n gl_Position = uProjMatrix * uViewMatrix * uModelMatrix * vec4(aPosition, 1);\n \n ' + + e + + '\n vNormal = mat3(uViewMatrix * uModelMatrix) * aNormal; }' + ); + } + static g(t, e) { + var i = Qr[t]; + i || (WH.debug('Missing pixel shader def', t), (i = Qr[(t = 'PS_Combiners_Opaque_Mod')])); + for (var r = '\t\t' + i.slice(1, i.length).join('\n\t\t'), n = 0; n < i[0]; n++) { + var a = n + 1; + r = 'vec4 tex' + n + ' = texture2D(uTexture' + a + ', vTexCoord' + a + '.st);\n' + r; + } + return ( + ' precision mediump float; \n varying vec3 vPosition;\n varying vec3 vNormal;\n varying vec2 vTexCoord1;\n varying vec2 vTexCoord2;\n varying vec2 vTexCoord3;\n varying vec2 vTexCoord4;\n \n uniform bool uHasTexture1;\n uniform bool uHasTexture2;\n uniform bool uHasTexture3;\n uniform bool uHasTexture4;\n uniform bool uHasAlpha;\n uniform bool uHasSpecEmiss;\n uniform bool uHasEmissiveGlowing;\n uniform int uBlendMode;\n uniform bool uUnlit;\n uniform vec4 uColor;\n uniform vec4 uAmbientColor;\n uniform vec4 uDiffuseColor;\n uniform vec4 uPrimaryColor;\n uniform vec4 uSecondaryColor;\n uniform vec3 uLightDir1;\n uniform vec3 uLightDir2;\n uniform vec3 uLightDir3;\n uniform sampler2D uTexture1;\n uniform sampler2D uTexture2;\n uniform sampler2D uTexture3;\n uniform sampler2D uTexture4;\n uniform sampler2D uAlpha;\n uniform vec4 uTexSampleAlpha;\n \n void main(void) {\n vec4 _output = vec4(1.0);\n vec4 _input = uColor;\n vec3 _specular = vec3(0.0); ' + + r + + '\n \n if (uBlendMode == 13) {\n _output.a = _output.a * _input.a;\n } else if (uBlendMode == 1) {\n if (_output.a < (128.0/255.0))\n discard;\n _output.a = _input.a;\n } else if (uBlendMode == 0) {\n _output.a = _input.a;\n } else {\n _output.a = _output.a * _input.a;\n }\n // if (uBlendMode > 1) {\n // if (_output.a < (1.0/255.0)) {\n // discard;\n // }\n // }\n if (!uUnlit) { vec4 litColor = uAmbientColor; vec3 normal = normalize(vNormal); float dp = max(0.0, dot(normal, uLightDir1)); litColor += uPrimaryColor * dp; dp = max(0.0, dot(normal, uLightDir2)); litColor += uSecondaryColor * dp; dp = max(0.0, dot(normal, uLightDir3)); litColor += uSecondaryColor * dp; litColor = clamp(litColor, vec4(0,0,0,0), vec4(1,1,1,1)); _output *= (litColor * uDiffuseColor); } _output += vec4(_specular, 0.0); gl_FragColor = _output.xyzw;\n }' + ); + } + } + const $r = [ + ['PS_Combiners_Opaque_Mod2xNA_Alpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_AddAlpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_AddAlpha_Alpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_Mod2xNA_Alpha_Add', 'VS_Diffuse_T1_Env_T1', 'HS_T1_T2_T3', 'DS_T1_T2_T3'], + ['PS_Combiners_Mod_AddAlpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_AddAlpha', 'VS_Diffuse_T1_T1', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod_AddAlpha', 'VS_Diffuse_T1_T1', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod_AddAlpha_Alpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_Alpha_Alpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_Mod2xNA_Alpha_3s', 'VS_Diffuse_T1_Env_T1', 'HS_T1_T2_T3', 'DS_T1_T2_T3'], + ['PS_Combiners_Opaque_AddAlpha_Wgt', 'VS_Diffuse_T1_T1', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod_Add_Alpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_ModNA_Alpha', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod_AddAlpha_Wgt', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod_AddAlpha_Wgt', 'VS_Diffuse_T1_T1', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_AddAlpha_Wgt', 'VS_Diffuse_T1_T2', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_Mod_Add_Wgt', 'VS_Diffuse_T1_Env', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_Mod2xNA_Alpha_UnshAlpha', 'VS_Diffuse_T1_Env_T1', 'HS_T1_T2_T3', 'DS_T1_T2_T3'], + ['PS_Combiners_Mod_Dual_Crossfade', 'VS_Diffuse_T1', 'HS_T1', 'DS_T1'], + ['PS_Combiners_Mod_Depth', 'VS_Diffuse_EdgeFade_T1', 'HS_T1', 'DS_T1'], + ['PS_Combiners_Opaque_Mod2xNA_Alpha_Alpha', 'VS_Diffuse_T1_Env_T2', 'HS_T1_T2_T3', 'DS_T1_T2_T3'], + ['PS_Combiners_Mod_Mod', 'VS_Diffuse_EdgeFade_T1_T2', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod_Masked_Dual_Crossfade', 'VS_Diffuse_T1_T2', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_Alpha', 'VS_Diffuse_T1_T1', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Opaque_Mod2xNA_Alpha_UnshAlpha', 'VS_Diffuse_T1_Env_T2', 'HS_T1_T2_T3', 'DS_T1_T2_T3'], + ['PS_Combiners_Mod_Depth', 'VS_Diffuse_EdgeFade_Env', 'HS_T1', 'DS_T1'], + ['PS_Guild', 'VS_Diffuse_T1_T2_T1', 'HS_T1_T2_T3', 'DS_T1_T2'], + ['PS_Guild_NoBorder', 'VS_Diffuse_T1_T2', 'HS_T1_T2', 'DS_T1_T2_T3'], + ['PS_Guild_Opaque', 'VS_Diffuse_T1_T2_T1', 'HS_T1_T2_T3', 'DS_T1_T2'], + ['PS_Illum', 'VS_Diffuse_T1_T1', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod_Mod_Mod_Const', 'VS_Diffuse_T1_T2_T3', 'HS_T1_T2_T3', 'DS_T1_T2_T3'], + ['PS_Combiners_Mod_Mod_Mod_Const', 'VS_Color_T1_T2_T3', 'HS_T1_T2_T3', 'DS_T1_T2_T3'], + ['PS_Combiners_Opaque', 'VS_Diffuse_T1', 'HS_T1', 'DS_T1'], + ['PS_Combiners_Mod_Mod2x', 'VS_Diffuse_EdgeFade_T1_T2', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Combiners_Mod', 'VS_Diffuse_EdgeFade_T1', 'HS_T1_T2', 'DS_T1_T2'], + ['PS_Unknown_34821', 'VS_Diffuse_EdgeFade_T1_T2', 'HS_T1_T2', 'DS_T1_T2'], + ], + Qr = { + PS_Combiners_Add: [1, '_output.rgb = _input.rgb + tex0.rgb;', '_output.a = _input.a + tex0.a;'], + PS_Combiners_Decal: [1, '_output.rgb = mix(_input.rgb, tex0.rgb, _input.a);', '_output.a = _input.a;'], + PS_Combiners_Fade: [1, '_output.rgb = mix(tex0.rgb, _input.rgb, _input.a);', '_output.a = _input.a;'], + PS_Combiners_Mod: [1, '_output.rgb = _input.rgb * tex0.rgb;', '_output.a = tex0.a;'], + PS_Combiners_Mod2x: [1, '_output.rgb = _input.rgb * tex0.rgb * 2.0;', '_output.a = tex0.a * 2.0;'], + PS_Combiners_Opaque: [1, '_output.rgb = _input.rgb * tex0.rgb;', '_output.a = 1.0;'], + PS_Combiners_Add_Add: [2, '_output.rgb = (_input.rgb + tex0.rgb) + tex1.rgb;', '_output.a = (_input.a + tex0.a) + tex1.a;'], + PS_Combiners_Add_Mod: [2, '_output.rgb = (_input.rgb + tex0.rgb) * tex1.rgb;', '_output.a = (_input.a + tex0.a) * tex1.a;'], + PS_Combiners_Add_Mod2x: [ + 2, + '_output.rgb = (_input.rgb + tex0.rgb) * tex1.rgb * 2.0;', + '_output.a = (_input.a + tex0.a) * tex1.a * 2.0;', + ], + PS_Combiners_Add_Opaque: [2, '_output.rgb = (_input.rgb + tex0.rgb) * tex1.rgb;', '_output.a = _input.a + tex0.a;'], + PS_Combiners_Mod_AddNA: [2, '_output.rgb = (_input.rgb * tex0.rgb);', '_output.a = tex0.a;', '_specular = tex1.rgb;'], + PS_Combiners_Mod_Mod: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;', '_output.a = tex0.a * tex1.a;'], + PS_Combiners_Mod_Mod2x: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;', '_output.a = tex0.a * tex1.a * 2.0;'], + PS_Combiners_Mod_Add: [2, '_output.rgb = (_input.rgb * tex0.rgb);', '_output.a = tex0.a + tex1.a;', '_specular = tex1.rgb;'], + PS_Combiners_Mod_Mod2xNA: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;', '_output.a = tex0.a;'], + PS_Combiners_Mod_Opaque: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;', '_output.a = tex0.a;'], + PS_Combiners_Mod2x_Add: [2, '_output.rgb = (_input.rgb * tex0.rgb) * 2.0 + tex1.rgb;', '_output.a = (tex0.a) * 2.0 + tex1.a;'], + PS_Combiners_Mod2x_Mod2x: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 4.0;', '_output.a = (tex0.a) * tex1.a * 4.0;'], + PS_Combiners_Mod2x_Opaque: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;', '_output.a = tex0.a * 2.0;'], + PS_Combiners_Opaque_Add: [2, '_output.rgb = (_input.rgb * tex0.rgb) + tex1.rgb;', '_output.a = _input.a + tex1.a;'], + PS_Combiners_Opaque_AddAlpha: [2, '_output.rgb = (_input.rgb * tex0.rgb);', '_specular = (tex1.rgb * tex1.a);'], + PS_Combiners_Opaque_AddAlpha_Wgt: [ + 2, + '_output.rgb = (_input.rgb * tex0.rgb);', + '_specular = (tex1.rgb * tex1.a) * uTexSampleAlpha.g;', + ], + PS_Combiners_Opaque_AddAlpha_Alpha: [ + 2, + '_output.rgb = (_input.rgb * tex0.rgb);', + '_specular = (tex1.rgb * tex1.a * (1.0 - tex0.a));', + ], + PS_Combiners_Opaque_AddNA: [2, '_output.rgb = (_input.rgb * tex0.rgb) + tex1.rgb;', '_output.a = _input.a;'], + PS_Combiners_Opaque_Mod: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;', '_output.a = tex1.a;'], + PS_Combiners_Opaque_Mod2x: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;', '_output.a = tex1.a * 2.0;'], + PS_Combiners_Opaque_Mod2xNA: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb * 2.0;', ''], + PS_Combiners_Opaque_Mod2xNA_Alpha: [2, '_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.0, tex0.rgb, vec3(tex0.a));', ''], + PS_Combiners_Opaque_Opaque: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;', ''], + PS_Combiners_Opaque_Mod2xNA_Alpha_Add: [ + 3, + '_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.0, tex0.rgb, vec3(tex0.a));', + '_specular = tex2.rgb * tex2.a * uTexSampleAlpha.b; ', + ], + PS_Combiners_Mod_Mod_Mod_Const: [3, '_output.rgb = _input.rgb * (tex0 * tex1 * tex2).rgb;', '_output.a = (tex0 * tex1 * tex2).a;'], + PS_Combiners_Mod_AddAlpha: [2, '_output.rgb = (_input.rgb * tex0.rgb);', '_output.a = tex0.a;', '_specular = tex1.rgb * tex1.a;'], + PS_Combiners_Mod_AddAlpha_Wgt: [ + 2, + '_output.rgb = (_input.rgb * tex0.rgb);', + '_output.a = tex0.a;', + '_specular = tex1.rgb * tex1.a * uTexSampleAlpha.g;', + ], + PS_Combiners_Mod_AddAlpha_Alpha: [ + 2, + '_output.rgb = _input.rgb * tex0.rgb;', + '_output.a = (tex0.a + tex1.a * (0.3 * tex1.r + 0.59 * tex1.g + 0.11 * tex1.b));', + '_specular = tex1.rgb * tex1.a * (1.0 - tex0.a);', + ], + PS_Combiners_Opaque_Mod_Add_Wgt: [ + 2, + '_output.rgb = _input.rgb * mix(tex0.rgb, tex1.rgb, vec3(tex1.a));', + '_specular = (tex0.rgb * tex0.a) * uTexSampleAlpha.r;', + ], + PS_Guild: [ + 3, + '_output.rgb = _input.rgb * mix(tex0.rgb * mix(vec3(1.0, 1.0, 1.0), tex1.rgb * vec3(1.0, 1.0, 1.0), vec3(tex1.a)), tex2.rgb * vec3(1.0, 1.0, 1.0), vec3(tex2.a));', + '_output.a = tex0.a;', + ], + PS_Guild_Opaque: [ + 3, + '_output.rgb = _input.rgb * mix(tex0.rgb * mix(vec3(1.0, 1.0, 1.0), tex1.rgb * vec3(1.0, 1.0, 1.0), vec3(tex1.a)), tex2.rgb * vec3(1.0, 1.0, 1.0), vec3(tex2.a));', + '', + ], + PS_Guild_NoBorder: [ + 2, + '_output.rgb = _input.rgb * tex0.rgb * mix(vec3(1.0, 1.0, 1.0), tex1.rgb * vec3(1.0, 1.0, 1.0), vec3(tex1.a));', + '_output.a = tex0.a;', + ], + PS_Combiners_Opaque_Alpha_Alpha: [ + 2, + '_output.rgb = _input.rgb * mix(mix(tex0.rgb, tex1.rgb, vec3(tex1.a)), tex0.rgb, vec3(tex0.a));', + '', + ], + PS_Combiners_Opaque_Mod2xNA_Alpha_3s: [3, '_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.0, tex2.rgb, vec3(tex2.a));'], + PS_Combiners_Mod_Add_Alpha: [ + 2, + '_output.rgb = _input.rgb * tex0.rgb;', + '_output.a = (tex0.a + tex1.a);', + '_specular = tex1.rgb * (1.0 - tex0.a);', + ], + PS_Combiners_Opaque_ModNA_Alpha: [2, '_output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb, tex0.rgb, vec3(tex0.a));', ''], + PS_Combiners_Opaque_Mod2xNA_Alpha_UnshAlpha: [ + 3, + 'float glowOpacity = clamp((tex2.a * vec4(1.0, 1.0, 1.0, 1.0).z), 0.0, 1.0); _output.rgb = _input.rgb * mix(tex0.rgb * tex1.rgb * 2.000000, tex0.rgb, vec3(tex0.a)) * (1.0 - glowOpacity);', + '_specular = tex2.rgb * glowOpacity;', + ], + PS_Combiners_Opaque_Mod2xNA_Alpha_Alpha: [ + 3, + '_output.rgb = _input.rgb * mix(mix(tex0.rgb * tex1.rgb * 2.000000, tex2.rgb, vec3(tex2.a)), tex0.rgb, vec3(tex0.a));', + '', + ], + PS_Combiners_Mod_Depth: [1, '_output.rgb = _input.rgb * tex0.rgb;', '_output.a = tex0.a;'], + PS_Combiners_Opaque_Alpha: [2, '_output.rgb = _input.rgb * mix(tex0.rgb, tex1.rgb, vec3(tex1.a));', ''], + Skin: [ + 3, + '//Fresnel Rim\r\nif (uHasSpecEmiss) {\r\n vec3 emissiveColor = tex2.rgb;\r\n vec3 emissiveTerm = tex2.rgb;\r\n if (uHasEmissiveGlowing) {\r\n vec3 eyeVec_120 = vPosition.xyz;\r\n vec3 t121 = -(eyeVec_120);\r\n vec2 term_126 = vec2(dot(t121, vNormal), dot(normalize(t121), (vNormal * vec3(0.0500000007, 0.0500000007, 1.0))));\r\n vec2 invTerm_128 = (vec2(1.0) - clamp(term_126, 0.0, 1.0));\r\n vec2 f_129 = (invTerm_128 * invTerm_128);\r\n float fresnel_rim_133 = pow((f_129.x + f_129.y), 0.600000024);\r\n vec3 t136 = (tex2.rgb /*+ ((vec3(0.0500000007, 0.0, 0.400000006) * 1.0) * fresnel_rim_133)*/);\r\n emissiveColor = vec3(t136.r, tex2.g, t136.b);\r\n\r\n float t267 = dot(normalize(vNormal), normalize(-(vPosition.xyz)));\r\n emissiveTerm = mix(vec3(0.0), 2.0*emissiveColor, vec3(pow(clamp(t267, 0.0, 1.0), (( 128.0 * (tex2.a)) + 9.99999975e-006))));\r\n }\r\n\r\n _output.rgb = _input.rgb * tex0.rgb + tex1.rgb + emissiveTerm.rgb;\r\n} else {\r\n _output.rgb = _input.rgb * tex0.rgb;\r\n}\r\n_output.a = tex0.a; //', + ], + PS_Combiners_Mod_Dual_Crossfade: [ + 3, + '_output.rgb = _input.rgb * mix(mix(tex0, texture2D(uTexture2,vTexCoord1), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,vTexCoord1), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).rgb;', + '_output.a = mix(mix(tex0, texture2D(uTexture2,vTexCoord1), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,vTexCoord1), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).a;', + ], + PS_Combiners_Mod_Masked_Dual_Crossfade: [ + 4, + '_output.rgb = _input.rgb * mix(mix(tex0, texture2D(uTexture2,texCoord), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,texCoord), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).rgb;', + '_output.a = mix(mix(tex0, texture2D(uTexture2,texCoord), vec4(clamp(uTexSampleAlpha.g, 0.000000, 1.000000))), texture2D(uTexture3,texCoord), vec4(clamp(uTexSampleAlpha.b, 0.000000, 1.000000))).a * texture(uTexture4,texCoord2).a;', + ], + PS_Unknown_34821: [2, '_output.rgb = (_input.rgb * tex0.rgb) * tex1.rgb;', '_output.a = tex0.a * tex1.a;'], + }, + tn = Kr; + const en = class { + constructor() { + (this.h = !1), (this.i = !0); + } + }, + rn = [0, 1, 2, 10, 3, 4, 5, 13]; + const nn = class { + constructor(t) { + (this.E = !1), (this.F = !1); + var e = this; + (e.a = t.getUint8()), + (e.b = t.getInt8()), + (e.c = t.getUint16()), + (e.d = t.getUint16()), + (e.e = t.getUint16()), + (e.f = t.getInt16()), + (e.g = t.getUint16()), + (e.h = t.getUint16()), + (e.i = t.getUint16()), + (e.j = t.getInt16()), + (e.k = t.getUint16()), + (e.l = t.getInt16()), + (e.m = t.getInt16()), + (e.n = !0), + (e.o = null), + (e.p = null), + (e.q = 0), + (e.r = null), + (e.s = []), + (e.t = []), + (e.u = new Array()), + (e.v = null), + (e.w = []), + (e.x = !1), + (e.y = !1), + (e.z = !1), + (e.A = Qi()), + (e.B = ve()), + (e.C = xr()); + } + K(t) { + var e = this; + (e.o = t), (e.p = t.as[e.d]), (e.q = e.p.a), Jr.c(e); + let i = this.o.ax[e.j]; + 1 == this.i && i > -1 && 1 == this.o.aw[i].c && ((this.c = -1e3), (this.i = 3)); + const r = tn.d(e.c, e.i, e.r); + e.H = r; + for (let i = 0; i < e.i; i++) { + if (e.j > -1 && e.j < t.ax.length) { + let r = t.ax[e.j + i]; + r > -1 && r < t.aw.length && e.s.splice(i, 0, t.aw[r]); + } + if (e.m > -1 && e.m < t.az.length) { + let r = t.az[e.m + i]; + r > -1 && t.ay && r < t.ay.length ? e.t.splice(i, 0, t.ay[r]) : e.t.splice(i, 0, null); + } + if (e.l > -1 && e.l < t.aF.length) { + let r = t.aF[e.l + i]; + r > -1 && r < t.aE.length ? e.w.splice(i, 0, t.aE[r]) : e.w.splice(i, 0, null); + } + } + this.u = new Array(e.t.length); + for (let t = 0; t < this.u.length; t++) this.u[t] = je(); + e.E && ((e.s = e.s.reverse()), (e.t = e.t.reverse())), + t.aD && e.f > -1 && e.f < t.aD.length && (e.v = t.aD[e.f]), + (e.D = this.r.b > 1); + } + L() { + const t = this, + e = t.o.aS.context, + i = ge.GetProgram(e, t.H.name, t.H.config); + (t.G = i), (t.H = i.program), (t.I = i.uniforms); + } + M() { + let t = er(this.p.i[0], this.p.i[1], this.p.i[2], 1), + e = this.o.ap[this.p.g].m, + i = je(); + Ye(i, i, this.o.aW.uViewMatrix), Ye(i, i, this.o.U), Ye(i, i, e), lr(t, t, i), (t[3] = 0); + let r = hr(t); + if ((3 & this.a) > 0) { + let e = Qi(); + r > 0 ? ar(e, t, 1 / r) : ir(e, t), + ar(e, e, Te(we(i[8], i[9], i[10])) * this.p.j), + 1 & this.a ? nr(e, t, e) : rr(e, t, e), + (r = sr(e)); + } + return r; + } + N(t) { + const e = this, + i = e.o, + r = e.o.aS.context, + n = e.o.R; + if ((e.G || e.L(), !e.G.program)) return; + if ( + (this.J || ((this.J = new en()), (this.J.a = e.G), (this.J.b = Object.assign({}, i.aW))), + (this.J.c = i.aU), + (this.J.d = i.aV), + (this.J.b = Object.assign({}, i.aW)), + (e.A[0] = e.A[1] = e.A[2] = e.A[3] = 1), + e.v && e.v.g(n, e.o.aX, e.A), + e.w[0] && (e.A[3] *= e.w[0].d(n, e.o.aX)), + e.A[3] <= 0.001) + ) + return; + let a = e.r.b; + const s = [0, 0, 0]; + for (let t = 0; t < e.w.length; t++) { + const i = e.w[t]; + i && (s[t] = i.d(n, e.o.aX)); + } + (this.J.b.uColor = e.A), + (this.J.b.uTexSampleAlpha = er(s[0], s[1], s[2], 0)), + (this.J.b.uBlendMode = a), + (this.J.b.uHasSpecEmiss = i.aJ && i.aJ.h), + (this.J.b.uHasEmissiveGlowing = i.n == bi || i.n == gi), + (this.J.e = rn[a]), + (this.J.i = !this.o.aY), + (this.J.b.uUnlit = e.x ? 1 : 0), + (this.J.n = this.M()), + (this.J.m = this.b), + (this.J.o = this.h); + const o = this.O(); + let l = !0; + for (const t in o) { + const e = o[t], + i = e.a && e.a.d; + (l = l && (null == e.a || null != i)), i && (this.J.b[e.c] = i); + } + l && !e.F && (e.F = !0), + e.t.forEach((t, i) => { + if (!e.o.S && (qe(e.u[i]), e.t[i])) { + let t = !1, + r = !1; + e.t[i].a && e.t[i].a.c(n.a.a) ? ((e.B = e.t[i].a.d(n, e.o.aX)), (r = !0)) : Ae(e.B, 0, 0, 0), + e.t[i].b && e.t[i].b.c(n.a.a) ? ((e.C = e.t[i].b.d(n, e.o.aX)), (t = !0)) : Fr(e.C, 0, 0, 0, 1); + let a, + s = !1; + if ( + (e.t[i].c && e.t[i].c.c(n.a.a) && ((a = e.t[i].c.d(n, e.o.aX)), (s = !0)), + qe(e.u[i]), + Ze(e.u[i], e.u[i], we(0.5, 0.5, 0)), + s && Je(e.u[i], e.u[i], a), + t) + ) { + let t = je(); + ei(t, e.C, [0, 0, 0]), Ye(e.u[i], e.u[i], t); + } + r && Ze(e.u[i], e.u[i], e.B), Ze(e.u[i], e.u[i], we(-0.5, -0.5, 0)); + } + this.J.b['uTextureMatrix' + (i + 1).toString()] = e.u[i]; + }), + (this.J.h = e.y), + (this.J.f = !e.z), + (this.J.j = r.TRIANGLES), + (this.J.l = 2 * e.p.e), + (this.J.k = e.p.f), + t.push(this.J); + } + O() { + let t = 0; + const e = []; + this.s.forEach((i, r) => { + const n = r; + let a = null; + if (this.s[n]) + if (this.s[0] && 1 == this.s[0].c && r > 0) + 1 == r + ? (a = this.o.aJ && this.o.aJ.b ? { d: this.o.aJ.b } : { d: this.o.aS.blackPixelTexture }) + : 2 == r && (a = this.o.aJ && this.o.aJ.c ? { d: this.o.aJ.c } : { d: this.o.aS.blackPixelTexture }); + else if (1 == this.s[n].c) this.o.aK ? (a = this.o.aK.a) : this.o.aJ && this.o.aJ.a && (a = { d: this.o.aJ.a }); + else if (this.s[n].f) a = this.s[n].f; + else if ( + (((this.o.a.type < 8 || this.o.a.type > 32) && 2 == this.s[n].c) || [2, 11, 12, 13].includes(this.s[n].c)) && + this.o.B[this.s[n].b] + ) + a = this.o.B[this.s[n].b]; + else if (-1 != this.s[n].c && this.o.B[this.s[n].c]) a = this.o.B[this.s[n].c]; + else if (-1 != this.s[n].c && this.o.C[this.s[n].c][n]) a = this.o.C[this.s[n].c][n].a; + else if (8 == this.s[n].c && this.o.v) a = this.o.v.C[this.s[n].c][0].a; + else if (!this.s[n].e && this.j + t < this.o.aw.length) { + let e = this.o.aw[this.j + t]; + e && e.f && (a = e.f); + } else this.s[n].g || WH.debug("can't find texture for material", n, 'type', this.s[n].c), (this.s[n].g = !0); + (e[n] = a), t++; + }); + const i = {}; + for (let r = 0; r < t; r++) i['Texture' + (r + 1)] = { a: e[r], b: r, c: 'uTexture' + (r + 1), d: 'TEXTURE' + r }; + return i; + } + get show() { + return this.n; + } + set show(t) { + this.n = t; + } + get meshId() { + return this.q; + } + P() { + (this.o = null), + (this.p = null), + (this.r = null), + (this.s = null), + (this.t = null), + (this.v = null), + (this.w = null), + (this.A = null), + (this.u = null), + (this.B = null), + (this.C = null); + } + }; + const an = class { + constructor(t, e, i) { + var r = this; + t.aS.context; + 0 == i && console.log('Texture file is 0'), + (r.b = t), + (r.c = t.k.contentPath + 'textures/' + i + '.png'), + (r.d = null), + (r.f = !1), + (function (t, e) { + (t.a = new Image()), + (t.a.crossOrigin = ''), + (t.a.onload = function () { + t.i(); + }), + (t.a.onerror = function () { + t.a = null; + }), + (t.a.src = t.c); + })(r); + } + g() { + return this.f; + } + h() { + var t = this; + if (t.b) { + var e = t.b.aS.context; + t.d && e.deleteTexture(t.d), (t.d = null), (t.b = null); + } + } + i() { + var t = this; + if (t.b) { + var e = t.b.aS.context; + (t.d = e.createTexture()), + e.bindTexture(e.TEXTURE_2D, t.d), + e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), + e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t.a), + r(t.a.width) && r(t.a.height) + ? e.generateMipmap(e.TEXTURE_2D) + : (e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), + e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), + e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR)); + var i = t.b.aS.aniFilterExt; + i && e.texParameteri(e.TEXTURE_2D, i.TEXTURE_MAX_ANISOTROPY_EXT, t.b.aS.aniFilterMax), (t.f = !0); + } + function r(t) { + return 0 == (t & (t - 1)); + } + } + }; + const sn = class { + constructor(t, e, i) { + var r = this; + (r.a = t), (r.b = e), (r.c = i.getInt32()), (r.d = i.getUint32()), (r.e = i.getUint32()), (r.f = null), (r.g = !1), r.i(); + } + h() { + var t = this; + (t.a = null), t.f && t.f.h(), (t.f = null); + } + i() { + var t = this; + 0 != t.e && (t.f = new an(t.a, 0, t.e)); + } + }; + const on = class { + constructor(t) { + (this.a = new Gr(t, Br)), (this.b = new Gr(t, Pr)), (this.c = new Gr(t, Br)); + } + d() { + var t = this; + t.a && (t.a.e(), (t.a = null)), t.b && (t.b.e(), (t.b = null)), t.c && (t.c.e(), (t.c = null)); + } + }; + const ln = class { + constructor(t) { + var e = this; + (e.a = t.getInt32()), (e.b = t.getInt32()), (e.c = we(t.getFloat(), t.getFloat(), t.getFloat())), (e.d = -1); + } + e() { + this.c = null; + } + }; + const hn = class { + constructor(t) { + (this.a = new Gr(t, Br)), (this.b = new Gr(t, zr)); + } + c() { + var t = this; + t.a && t.a.e(), t.b && t.b.e(); + } + d(t) { + return !!this.a && this.a.c(t); + } + e(t) { + return !!this.b && this.b.c(t); + } + f(t) { + return this.d(t) || this.e(t); + } + g(t, e, i) { + var r = this; + i ? (i[0] = i[1] = i[2] = i[3] = 1) : (i = er(1, 1, 1, 1)); + let n = we(1, 1, 1); + return ( + r.d(t.a.a) && r.a.d(t, e, n, n), r.e(t.a.a) && (i[3] = r.b.d(t, e, i[3]) / 32767), (i[0] = n[0]), (i[1] = n[1]), (i[2] = n[2]), i + ); + } + }; + const un = class { + constructor(t) { + this.a = new Gr(t, zr); + } + b() { + this.a.e(), (this.a = null); + } + c(t) { + return this.a.c(t); + } + d(t, e) { + var i = 1; + this.c(t.a.a) && (i = this.a.d(t, e, i) / 32767); + return i > 1 ? (i = 1) : i < 0 && (i = 0), i; + } + }; + const cn = class { + constructor() { + (this.a = 0), (this.b = 0), (this.c = -1), (this.d = null), (this.e = null); + } + }; + class fn extends cn {} + const dn = class { + constructor(t, e) { + (this.d = !1), (this.a = t), (this.b = e), (this.c = new Array(e.length)); + } + e(t) { + for (let e = 0; e < this.b.length; e++) this.c[e] && this.c[e].e && this.c[e].e.setAnimation(t); + } + f(t) { + this.d = t; + } + g(t) { + for (let e = 0; e < this.b.length; e++) + switch (this.b[e].EffectType) { + case 1: + if (1 == this.b[e].ProcEffectType) { + let t = this.b[e].Value[0]; + this.a.V = er(((t >> 16) & 255) / 255, ((t >> 8) & 255) / 255, (255 & t) / 255, this.a.V[3]); + } else if (14 == this.b[e].ProcEffectType) { + let t = Math.min(Math.max(this.b[e].Value[0], 0), 1); + this.a.V[3] = t; + } else if (22 == this.b[e].ProcEffectType) { + let t = this.b[e].Value[3]; + this.a.V = er(((t >> 16) & 255) / 255, ((t >> 8) & 255) / 255, (255 & t) / 255, this.a.V[3]); + } + break; + case 2: + this.h(e, t); + } + } + h(t, e) { + if (!this.a) return; + if (!this.a.d) return; + if (!this.c[t]) { + let e = this.b[t].AttachmentID; + this.b[t].Positioner > -1 && (e = this.b[t].Positioner), e < 0 && (e = 19); + let i = this.a.bV(e); + if (((this.c[t] = new fn()), (this.c[t].d = i), (this.c[t].c = i ? i.b : -1), 0 == this.b[t].ModelType)) { + let e = { type: hi.PATH, id: this.b[t].Model, parent: this.a, shoulder: -1 }; + this.c[t].e = new $n(this.a.aS, this.a.k, e, 0, !1, !0, !1); + } else if (1 == this.b[t].ModelType) { + let e = this.a.n > 0 ? this.a.n : 1, + i = -1 != this.a.o ? this.a.o : 0; + (this.a.n = e), (this.a.o = i), (this.c[t].ba = new _n(this.a, this.b[t].InvType, this.b[t].Model, e, i)); + } else if (2 == this.b[t].ModelType) { + let e = { type: hi.NPC, id: this.b[t].Model, parent: this.a, shoulder: -1 }; + this.c[t].e = new $n(this.a.aS, this.a.k, e, 0, !1, !0, !1); + } + } + if (!(0 != this.b[t].ModelType || (this.c[t].e && this.c[t].e.d))) return; + if (!(1 != this.b[t].ModelType || (this.c[t].ba && this.c[t].ba.m))) return; + if (!(2 != this.b[t].ModelType || (this.c[t].e && this.c[t].e.d))) return; + let i = je(); + Qe(i, i, -this.b[t].Yaw), + $e(i, i, this.b[t].Pitch), + Ke(i, i, this.b[t].Roll), + Je(i, i, [this.b[t].Scale1, this.b[t].Scale1, this.b[t].Scale1]), + Je(i, i, [this.b[t].Scale2, this.b[t].Scale2, this.b[t].Scale2]); + let r = je(); + if (this.c[t].d) { + let e = this.c[t].d.c; + Ye(r, r, this.a.ap[this.c[t].c].m), Ze(r, r, we(e[0], e[1], e[2])); + } + if ((Ze(r, r, we(this.b[t].Offset[0], -this.b[t].Offset[1], this.b[t].Offset[2])), Ye(r, r, i), 0 == this.b[t].ModelType)) { + let i = this.c[t].e; + i.setAnimPaused(this.d), i.bs(this.a.U, r, null, null), i.bY(e); + } else if (1 == this.b[t].ModelType) + for (let i = 0; i < this.c[t].ba.i.length; i++) { + let n = this.c[t].ba.i[i].e; + n.d && (n.setAnimPaused(this.d), n.bs(this.a.U, r, null, null), n.bY(e)); + } + else if (2 == this.b[t].ModelType) { + let i = this.c[t].e; + i.setAnimPaused(this.d), i.bs(this.a.U, r, null, null), i.bY(e); + } + } + }; + const bn = class { + constructor(t, e, i) { + var r = this; + (r.a = t), (r.d = e), (r.b = []), (r.c = !1), (r.f = []), i && r.h(i); + } + g() { + var t = this; + if (((t.a = null), t.b)) { + for (var e = 0; e < t.b.length; ++e) { + var i = t.b[e]; + i && (i.e && i.e.ba(), (i.e = null), (i.d = null), (t.b[e] = null)); + } + t.b = null; + } + } + h(t) { + var e = this; + e.e = t; + var i = e.a.k.contentPath + 'meta/itemvisual/' + e.e + '.json'; + $.getJSON(i, function (t) { + e.i(t); + }); + } + i(t) { + var e = this; + if (((e.b = new Array(7)), t.ItemEffects)) + for (let r = 0; r < t.ItemEffects.length; ++r) { + let n = t.ItemEffects[r]; + if (-1 == n.SubClass || this.d == n.SubClass) { + if (n.Model) { + e.b[n.Slot - 1] = new cn(); + var i = { type: hi.PATH, id: n.Model, parent: e.a, shoulder: -1 }; + e.b[n.Slot - 1].e = new $n(e.a.aS, e.a.k, i, 0, !1, !0, !1); + } + n.kit && (this.a.E, this.a.E.push(new dn(this.a, n.kit.effects))); + } + } + for (var r = 0; r < e.b.length; ++r) + if (t.Equipment[r] && null == e.b[r]) { + e.b[r] = new cn(); + i = { type: hi.PATH, id: t.Equipment[r], parent: e.a, shoulder: -1 }; + e.b[r].e = new $n(e.a.aS, e.a.k, i, r, !1, !0, !1); + } + (e.c = !0), e.a.bH(); + } + j(t) { + if (this.a.d) { + for (var e = 0; e < this.f.length; e++) this.f[e].g(t); + for (var i = 0; i < this.b.length; i++) { + var r = this.b[i]; + if (r) { + let e = we(0, 0, 0); + if ((i >= 5 || (r && r.d && (e = r.d.c)), -1 != r.c)) { + let i = this.a.ap[r.c].m; + r.e.bs(this.a.U, i, e, null), r.e.bY(t); + } + } + } + } + } + }; + class gn { + static a(t, e, i, r, n) { + let a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + if (!e) return WH.debug('selectBestTexture:', 'textures are null'), null; + for (let t = 0; t < e.length; t++) { + let s = e[t], + o = s.Gender, + l = s.Class, + h = s.Race, + u = s.ExtraData, + c = 0; + if (i > 1 || o != i) { + if (o < 2) continue; + c = 0; + } else c = 2; + let f = 1; + if (r > 0 && l == r) f = 0; + else if (l > 0) continue; + let d = 1; + if (n > 0 && h == n) d = 0; + else if (h > 0) continue; + a[u + 3 * (d + 2 * (c + f))] = s.FileDataId; + } + for (let t = 0; t < 2; t++) + for (let e = 0; e < 2; e++) + for (let i = 0; i < 2; i++) { + let r = 3 * (t + 2 * (e + 2 * i)); + if (a[r] > 0) { + let t; + return (t = { a: a[r], b: a[r + 1], c: a[r + 2] }), t; + } + } + if (t) { + let a = t.bR(i, n, !0); + if (a && 0 != a[0]) return (n = a[0]), (i = a[1]), gn.a(t, e, i, r, n); + } + return null; + } + static b(t, e, i, r, n, a) { + let s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + for (let t = 0; t < e.length; t++) { + let o = e[t], + l = o.Gender, + h = o.Class, + u = o.Race, + c = o.ExtraData, + f = 0; + if (r > 1 || l != r) { + if (l < 2) continue; + f = 0; + } else f = 2; + let d = 1; + if (n > 0 && h == n) d = 0; + else if (h > 0) continue; + let b = 1; + if (a > 0 && u == a) b = 0; + else if (u > 0) continue; + let g = 1; + if (-1 == i || c != i) { + if (-1 != c && -1 != i) continue; + } else g = 0; + s[g + 2 * (b + 2 * (f + d))] = o.FileDataId; + } + for (let t = 0; t < 2; t++) + for (let e = 0; e < 2; e++) + for (let i = 0; i < 2; i++) + for (let r = 0; r < 2; r++) { + let n = r + 2 * (t + 2 * (e + 2 * i)); + if (s[n]) return s[n]; + } + if (t) { + var o = t.bR(r, a, !1); + if (o && 0 != o[0]) return (a = o[0]), (r = o[1]), gn.b(t, e, i, r, n, a); + } + return 0; + } + } + const _n = class { + constructor(t, e, i, r, n) { + (this.q = null), + (this.r = []), + WH.debug('Creating item', i), + (this.a = t), + (this.b = e), + (this.s = i), + (this.t = r), + (this.u = n), + (this.e = pi[e]), + (this.f = mi[e]), + (this.i = null), + (this.j = null), + (this.k = null), + (this.g = 0), + (this.h = 0), + (this.m = !1), + (this.n = !1), + (this.o = 0), + (this.p = 3), + i && this.y(); + } + x() { + var t = this; + if (t.i) { + for (let e = 0; e < t.i.length; ++e) t.i[e].e && t.i[e].e.ba(), (t.i[e].e = null), (t.i[e].d = null), (t.i[e] = null); + t.i = null; + } + if (t.j) { + for (let e = 0; e < t.j.length; ++e) t.j[e].texture && t.j[e].texture.h(), (t.j[e].texture = null), (t.j[e] = null); + t.j = null; + } + if (((t.k = null), (t.l = null), t.r)) { + for (let e = 0; e < t.r.length; e++) t.r[e].g(); + t.r = null; + } + (t.m = !1), t.q && (t.q.ba(), (t.q = null)), t.a && (t.a.bB(), (t.a = null)), WH.debug('Destroyed item', this.s); + } + y() { + let t = this; + WH.debug('Loading item', this.s); + let e = 'meta/item/'; + const i = this.b; + (i != Ti && + i != wi && + i != yi && + i != Ai && + i != Ei && + i != Ci && + i != Si && + i != Mi && + i != ki && + i != Ii && + i != Ui && + i != Bi) || + (e = 'meta/armor/' + i + '/'); + let r = t.a.k.contentPath + e + t.s + '.json'; + $.getJSON(r) + .done(function (e) { + t.z(e); + }) + .fail(function (e, i, r) { + let n = i + ', ' + r; + WH.debug('Error loading item metadata', t.s, n), (t.n = !0); + }); + } + z(t) { + if (!this.a) return void WH.debug('Item was destroyed before it was loaded', this.s); + if ( + ((this.h = parseInt(t.Item.Flags)), + (this.g = parseInt(t.Item.InventoryType)), + (this.c = parseInt(t.Item.ItemClass)), + (this.d = parseInt(t.Item.ItemSubClass)), + t.ComponentTextures) + ) { + this.j = []; + for (let e in t.ComponentTextures) { + const i = parseInt(e), + r = gn.a(this.a, t.TextureFiles[t.ComponentTextures[e]], this.a.o, this.a.p, this.a.n); + if (r) { + let t; + (t = { region: i, gender: this.a.o, file: r.a, texture: null }), + i != Wi ? (t.texture = new an(this.a, i, r.a)) : this.b == Ii && (this.a.B[2] = new an(this.a, 2, r.a)), + this.j.push(t); + } + } + } + if (((this.k = t.Item.GeosetGroup), (this.l = t.Item.AttachGeosetGroup), this.b == Ti)) { + 0 == this.a.o ? (this.v = t.Item.HideGeosetMale) : (this.w = t.Item.HideGeosetFemale); + } + if ((this.b == wi ? (this.i = new Array(2)) : xi[this.b] != hi.ARMOR && (this.i = new Array(1)), this.i)) + for (let e = 0; e < this.i.length; ++e) { + const i = { race: this.t, gender: this.u, bone: -1, attachment: null, model: null }, + r = { type: xi[this.b], id: this.s, parent: this.a, shoulder: 0 }; + this.b == wi && (r.shoulder = e + 1), + (i.e = new $n(this.a.aS, this.a.k, r, e, !1, !1, !0)), + (i.e.n = this.t), + (i.e.o = this.u), + i.e.bS(t, r.type), + (this.i[e] = i); + } + if ((this.b == Ei || this.b == Ii) && t.ComponentModels) { + let e = 0; + if ((this.b == Ii && (e = 1), t.ComponentModels[e])) { + const i = { type: xi[this.b], id: this.s, parent: this.a, shoulder: 0 }, + r = new $n(this.a.aS, this.a.k, i, 0, !1, !1, !0); + r.u = t; + const n = { race: 0, gender: 0, bone: -1, attachment: null, model: null }; + (n.e = r), (this.i = [n]); + let a = 1, + s = 0, + o = 1; + this.a && ((a = this.a.n), (s = this.a.o), (o = this.a.p)); + const l = t.ComponentModels[e], + h = gn.b(r, t.ModelFiles[l], -1, s, o, a); + if (h) { + r.bQ(hi.PATH, h); + const i = 0 == e ? t.Textures : t.Textures2; + if (i) for (let t in i) 0 != i[t] && (r.B[+t] = new an(r, parseInt(t), i[t])); + } + } + } + const e = this.b; + if ((e == yi || e == Ai || e == Bi || e == Ei || e == Ci || e == ki || e == Si || e == Ti || e == Ii) && t.ComponentModels) { + let i = 0; + if (((e != Ti && e != Ei) || (i = 1), t.ComponentModels[i])) { + const r = t.ComponentModels[i]; + if (r && t.ModelFiles && t.ModelFiles[r]) { + const n = { type: xi[e], id: this.s, parent: this.a, shoulder: 0 }, + a = new $n(this.a.aS, this.a.k, n, 0, !1, !1, !0); + a.u = t; + let s = 1, + o = 0, + l = 1; + this.a && ((s = this.a.n), (o = this.a.o), (l = this.a.p)); + const h = gn.b(a, t.ModelFiles[r], -1, o, l, s); + if (h) { + (this.q = a), a.bQ(hi.PATH, h); + const e = 0 == i ? t.Textures : t.Textures2; + if (e) for (let t in e) 0 != e[t] && (a.B[+t] = new an(a, parseInt(t), e[t])); + } + } + } + } + if ((e == Ci && this.k[2] > 0 && (this.f += 2), 0 != this.o)) { + const t = 2 == this.c ? this.d : -1; + for (let e = 0; e < this.i.length; e++) this.r.push(new bn(this.i[e].e, t, this.o)); + } + this.a.bH(), (this.m = !0), WH.debug('Loaded item', this.s); + } + A(t) { + for (let t = 0; t < this.r.length; t++) this.r[t].g(); + (this.r = []), (this.o = t); + } + B(t) { + this.p = t; + } + C(t) { + if (!this.i) return; + if (this.a.d) { + const t = this.a.bN(this.e, this); + for (let e = 0; e < this.i.length; ++e) + if (this.i[e] && t.length > e) { + let i = this.a.aB[t[e]]; + if (((this.i[e].c = i.b), (this.i[e].d = i), this.r[e] && this.r[e].b)) { + const t = this.i[e].e; + for (let r = 0; r < this.r[e].b.length; r++) + if (t.aB && this.r[e].b[r]) { + if (r < 5) { + if (!t.aB[r]) continue; + i = t.aB[r]; + } else i = t.bV(19); + (this.r[e].b[r].c = i.b), (this.r[e].b[r].d = i); + } + } + } + } + let e = je(), + i = ve(); + for (let r = 0; r < this.i.length; ++r) { + const n = this.i[r]; + if (n && n.e) { + if (this.b == wi) { + if (1 == n.e.a.shoulder && 0 == (1 & this.p)) continue; + if (2 == n.e.a.shoulder && 0 == (2 & this.p)) continue; + } + if (n.c > -1 && n.c < this.a.ap.length) { + this.r[r] && n.e.d && this.r[r].j(t); + let a = !1, + s = si[n.e.a.id]; + if ( + (qe(e), + s && (Ae(i, 1, 1, -1), Je(e, e, i), (a = !0)), + (this.b != zi && this.b != Oi && this.e != zi) || + 0 == (256 & this.h) || + (Ae(i, 1, -1, 1), Je(e, e, i), (a = !0), (n.e.h = !0)), + (n.e.aY = a), + 5 == this.a.H && this.b == Ni && 2 == this.c && 18 == this.d && (qe(e), Ke(e, e, -Math.PI / 2)), + 27 == this.b) + ) { + let t = n.e.u.Scale; + Ae(i, t, t, t), Je(e, e, i); + } + n.e.bs(this.a.U, this.a.ap[n.c].m, n.d.c, e), n.e.bW(), n.e.bY(t); + } else -1 == n.c && this.a.bG(n.e, t); + } + } + } + }; + const pn = class { + constructor(t) { + (this.c = t), (this.b = 267320826 ^ t); + let e = new ArrayBuffer(4); + this.a = new DataView(e); + } + d() { + let t = this.b; + return (t ^= t << 13), (t ^= t >> 17), (t ^= t << 5), (this.b = t), t; + } + e() { + let t, + e = this.d(); + return ( + this.a.setInt32(0, 1065353216 | (8388607 & e)), (t = 2147483648 & e ? 2 - this.a.getFloat32(0) : this.a.getFloat32(0) - 2), t + ); + } + f() { + let t = this.d(); + return this.a.setInt32(0, 1065353216 | (8388607 & t)), this.a.getFloat32(0) - 1; + } + }; + const mn = class { + constructor() { + (this.a = 0), + (this.b = 0), + (this.c = 0), + (this.d = 0), + (this.e = ve()), + (this.f = 0), + (this.g = 0), + (this.h = 0), + (this.i = 0), + (this.j = 0); + } + }; + const vn = class { + constructor(t, e) { + (this.b = t), (this.c = e), (this.a = new mn()); + } + d() { + return this.a.d + this.b.e() * this.c.u; + } + e() { + return this.a.d + this.c.u; + } + f() { + return this.a.c + this.c.s; + } + g(t) { + return this.a.c + 30518509e-12 * t * this.c.s; + } + h() { + let t = this.a.a; + return (t *= 1 + this.a.b * this.b.e()), t; + } + i() { + return this.a; + } + j(t) { + ye(t, this.a.e); + } + }; + const xn = class extends vn { + k(t, e) { + let i, + r = e * this.b.f(), + n = this.b.e(); + (i = n < 1 ? (n > -1 ? Math.trunc(32767 * n + 0.5) : -32767) : 32767), (t.d = i); + let a = this.g(i); + a < 0.001 && (a = 0.001), + (t.b = (function (t, e) { + let i = Math.abs(t), + r = Math.abs(e); + return Number((i - Math.floor(i / r) * r).toPrecision(8)) * Math.sign(t); + })(r, a)), + (t.e = 65535 & this.b.d()), + Ae(t.a, this.b.e() * this.a.g * 0.5, this.b.e() * this.a.h * 0.5, 0); + let s = this.h(), + o = this.a.f; + if (o < 0.001) { + let e = this.a.i * this.b.e(), + i = this.a.j * this.b.e(), + r = Math.sin(e), + n = Math.sin(i), + a = Math.cos(e), + o = Math.cos(i); + Ae(t.c, o * r * s, n * r * s, a * s); + } else { + let e = ve(); + ye(e, t.a), (e[2] = e[2] - o), Te(e) > 1e-4 && (Ue(e, e), Fe(t.c, e, s)); + } + } + }; + const Tn = class extends vn { + constructor(t, e, i) { + super(t, e), (this.ba = i); + } + k(t, e) { + let i, + r = e * this.b.f(), + n = this.b.e(); + (i = n < 1 ? (n > -1 ? Math.trunc(32767 * n + 0.5) : -32767) : 32767), (t.d = i); + let a = this.g(i); + a < 0.001 && (a = 0.001), + (t.b = (function (t, e) { + let i = Math.abs(t), + r = Math.abs(e); + return Number((i - Math.floor(i / r) * r).toPrecision(8)) * Math.sign(t); + })(r, a)), + (t.e = 65535 & this.b.d()); + let s = this.a.h - this.a.g, + o = this.a.g + s * this.b.f(), + l = this.a.i * this.b.e(), + h = this.a.j * this.b.e(), + u = Math.cos(l), + c = we(u * Math.cos(h), u * Math.sin(h), Math.sin(l)); + Fe(t.a, c, o); + let f = this.h(), + d = this.a.f, + b = we(0.5, 0.5, 0.5); + 0 == d + ? this.ba + ? Ae(b, 0, 0, 1) + : Ae(b, u * Math.cos(h), u * Math.sin(h), Math.sin(l)) + : (Ae(b, 0, 0, d), Ce(b, t.a, b), Te(b) > 1e-4 && Ue(b, b)), + Fe(t.c, b, f); + } + }; + const wn = class { + constructor(t) { + (this.a = t.getInt32()), + (this.b = t.getUint32()), + (this.c = we(t.getFloat(), t.getFloat(), t.getFloat())), + (this.d = t.getInt16()), + (this.e = t.getInt16()), + 0 != (268435456 & this.b) && + ((this.f = [0, 0, 0]), (this.f[0] = 31 & this.e), (this.f[1] = (this.e >> 5) & 31), (this.f[2] = (this.e >> 10) & 31)), + (this.g = t.getUint8()), + (this.h = t.getUint8()), + (this.i = t.getUint16()), + (this.j = t.getUint16()), + (this.k = t.getUint16()), + (this.l = t.getUint16()), + (this.m = new Gr(t, Or)), + (this.n = new Gr(t, Or)), + (this.o = new Gr(t, Or)), + (this.p = new Gr(t, Or)), + (this.q = new Gr(t, Br)), + (this.r = new Gr(t, Or)), + (this.s = t.getFloat()), + (this.t = new Gr(t, Or)), + (this.u = t.getFloat()), + (this.v = new Gr(t, Or)), + (this.w = new Gr(t, Or)), + (this.x = new Gr(t, Or)), + (this.y = new Vr(t)), + (this.z = new jr(t)), + (this.A = new Hr(t)), + (this.B = [t.getFloat(), t.getFloat()]), + (this.C = new jr(t)), + (this.D = new jr(t)), + (this.E = t.getFloat()), + (this.F = t.getFloat()), + (this.G = t.getFloat()), + (this.H = [t.getFloat(), t.getFloat()]), + (this.I = t.getFloat()), + (this.J = t.getFloat()), + (this.K = t.getFloat()), + (this.L = t.getFloat()), + (this.M = t.getFloat()), + (this.N = t.getFloat()), + (this.O = we(t.getFloat(), t.getFloat(), t.getFloat())), + (this.P = we(t.getFloat(), t.getFloat(), t.getFloat())), + (this.Q = we(t.getFloat(), t.getFloat(), t.getFloat())), + (this.R = t.getFloat()), + (this.S = t.getFloat()), + (this.T = t.getFloat()), + (this.U = t.getFloat()), + (this.V = t.getFloat()); + var e = t.getInt32(); + this.W = new Array(e); + for (var i = 0; i < e; i++) this.W[i] = we(t.getFloat(), t.getFloat(), t.getFloat()); + (this.X = new Gr(t, Nr)), + (this.Y = dr(t.getFloat(), t.getFloat())), + (this.Z = [dr(t.getFloat(), t.getFloat()), dr(t.getFloat(), t.getFloat())]), + (this.aa = [dr(t.getFloat(), t.getFloat()), dr(t.getFloat(), t.getFloat())]); + } + }; + const yn = class { + constructor() { + (this.a = ve()), + (this.b = 0), + (this.c = ve()), + (this.d = 0), + (this.e = (2147483647 * Math.random()) >> 0), + (this.f = [fr(), fr()]), + (this.g = [fr(), fr()]); + } + }; + let An = new Array(128); + for (let t = 0; t < 128; t++) An[t] = Math.random(); + const En = Xe(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); + class Cn {} + class Sn { + constructor() { + (this.a = ve()), (this.b = 0), (this.c = { a: fr(), b: ve(), c: 0, d: 0, e: 0 }); + } + } + function Mn(t) { + return er(((t >> 16) & 255) / 255, ((t >> 8) & 255) / 255, ((t >> 0) & 255) / 255, ((t >> 24) & 255) / 255); + } + const kn = class { + constructor(t, e) { + (this.E = 0), (this.U = !1), (this.a = new Date().getTime()), (this.b = t); + let i = new wn(e); + if (i.i >= 11 && i.i <= 13) { + let e; + t.u.Item && t.u.Item.ParticleColor + ? (e = t.u.Item.ParticleColor) + : t.u.Creature && t.u.Creature.ParticleColor && (e = t.u.Creature.ParticleColor), + e && + ((this.H = [Qi(), Qi(), Qi()]), + ir(this.H[0], Mn(e.Start[i.i - 11])), + ir(this.H[1], Mn(e.Mid[i.i - 11])), + ir(this.H[2], Mn(e.End[i.i - 11]))); + } + (this.c = i), + (this.d = je()), + (this.e = je()), + (this.f = je()), + (this.g = je()), + (this.h = Qi()), + (this.i = pr()), + (this.j = ve()), + (this.k = 1), + (this.l = ve()), + (this.m = 0), + (this.n = ve()), + (this.o = ve()), + (this.p = []), + (this.q = ve()), + (this.r = 0), + (this.s = 0), + (this.t = 0), + (this.u = 0), + (this.v = ve()), + (this.w = ve()), + (this.x = 0), + (this.y = 0), + (this.z = 0), + (this.A = 0), + (this.B = 0), + (this.C = 0), + (this.D = 0), + (this.F = []), + (this.G = []); + for (let t = 0; t < 1e3; t++) + this.G.push(4 * t + 0), + this.G.push(4 * t + 1), + this.G.push(4 * t + 2), + this.G.push(4 * t + 3), + this.G.push(4 * t + 2), + this.G.push(4 * t + 1); + switch (((this.J = new pn((2147483647 * Math.random()) >> 0)), this.c.h)) { + case 1: + this.I = new xn(this.J, i); + break; + case 2: + this.I = new Tn(this.J, i, 0 != (256 & this.c.b)); + break; + default: + (this.I = null), WH.debug('Found unimplemented generator ', this.c.h); + } + const r = this.c.U - this.c.S; + 0 != r ? ((this.s = (this.c.V - this.c.T) / r), (this.t = this.c.T - this.c.S * this.s)) : ((this.s = 0), (this.t = 0)); + let n = this.c.l; + n <= 0 && (n = 1); + let a = this.c.k; + a <= 0 && (a = 1), (this.y = n * a - 1), (this.z = 0); + let s = n, + o = -1; + do { + ++o, (s >>= 1); + } while (s); + if (((this.A = o), (this.B = n - 1), (this.z = 0), (32768 & this.c.b) > 0)) { + let t = (this.y + 1) * this.J.d(); + this.z = (t / 4294967296) | 0; + } + if (((this.C = 1 / n), (this.D = 1 / a), (269484032 & this.c.b) > 0)) { + const t = 0 != (1 & (this.c.b >> 28)); + this.r = t ? 2 : 3; + } else this.r = 0; + this.K = i.g > 1; + } + W() { + var t = this; + (t.b = null), + (t.c.c = null), + (t.c.O = null), + (t.c.P = null), + (t.c.m = t.c.m.e()), + (t.c.n = t.c.n.e()), + (t.c.o = t.c.o.e()), + (t.c.p = t.c.p.e()), + (t.c.q = t.c.q.e()), + (t.c.r = t.c.r.e()), + (t.c.t = t.c.t.e()), + (t.c.v = t.c.v.e()), + (t.c.w = t.c.w.e()), + (t.c.x = t.c.x.e()), + (t.c.X = t.c.X.e()), + (t.c.y = t.c.y.d()), + (t.c.z = t.c.z.d()), + (t.c.A = t.c.A.d()), + (t.c.C = t.c.C.d()), + (t.c.D = t.c.D.d()), + (t.p = null); + } + X(t, e, i) { + if (!this.I) return; + let r = je(), + n = this.I.i(), + a = !0; + this.c.X.c(t.a.a) && (a = this.c.X.d(t, this.b.aX) > 0), (this.T = a); + const s = we(0, 0, 0); + a && + ((n.a = this.c.m.d(t, this.b.aX, 0)), + (n.b = this.c.n.d(t, this.b.aX, 0)), + (n.i = this.c.o.d(t, this.b.aX, 0)), + (n.j = this.c.p.d(t, this.b.aX, 0)), + this.c.q.d(t, this.b.aX, s, n.e), + (n.c = this.c.r.d(t, this.b.aX, 0)), + (n.d = this.c.t.d(t, this.b.aX, 0)), + (n.h = this.c.w.d(t, this.b.aX, 0)), + (n.g = this.c.v.d(t, this.b.aX, 0)), + (n.f = i ? i.a : this.c.x.d(t, this.b.aX, 0))), + Ye(r, r, this.b.U), + Ye(r, r, this.b.ap[this.c.d].m); + let o = je(); + ti(o, we(this.c.c[0], this.c.c[1], this.c.c[2])), Ye(r, r, o), Ye(r, r, En); + let l = je(), + h = ve(); + We(l, this.b.aS.viewMatrix), ii(h, l), this.aa(e, r, h, null, this.b.aS.viewMatrix), this.ak(this.b.aS.viewMatrix); + let u = this.b.aS.context; + this.L + ? (u.bindBuffer(u.ARRAY_BUFFER, this.L), u.bufferData(u.ARRAY_BUFFER, new Float32Array(this.F), u.DYNAMIC_DRAW)) + : ((this.L = u.createBuffer()), + u.bindBuffer(u.ARRAY_BUFFER, this.L), + u.bufferData(u.ARRAY_BUFFER, new Float32Array(this.F), u.DYNAMIC_DRAW)), + this.M || + ((this.M = u.createBuffer()), + u.bindBuffer(u.ELEMENT_ARRAY_BUFFER, this.M), + u.bufferData(u.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.G), u.DYNAMIC_DRAW)); + } + Y(t) { + if (this.p.length <= 0) return; + const e = this.b.aS.context; + if ( + (this.V || + ((this.V = new en()), + (this.V.a = se( + e, + [ + ' attribute vec3 aPosition;\n attribute vec4 aColor; attribute vec2 aTexcoord0; attribute vec2 aTexcoord1; attribute vec2 aTexcoord2; varying vec4 vColor; varying vec2 vTexcoord0; varying vec2 vTexcoord1; varying vec2 vTexcoord2; uniform mat4 uModelMatrix; uniform mat4 uViewMatrix; uniform mat4 uProjMatrix; void main(void) { vec4 pos = vec4(aPosition, 1); gl_Position = uProjMatrix * pos; vColor = aColor; vTexcoord0 = aTexcoord0; vTexcoord1 = aTexcoord1; vTexcoord2 = aTexcoord2; } ', + ' precision mediump float;\n varying vec4 vColor; varying vec2 vTexcoord0; varying vec2 vTexcoord1; varying vec2 vTexcoord2; uniform bool uHasTexture; uniform bool uHasTexture2; uniform bool uHasTexture3; uniform bool uHasAlpha; uniform int uBlendMode; uniform int uPixelShader; uniform sampler2D uTexture; uniform sampler2D uTexture2; uniform sampler2D uTexture3; uniform float uAlphaTreshold; void main(void) { float lo_thresh = 0.01; vec4 color = vec4(1, 1, 1, 1); vec4 tex = vec4(1, 1, 1, 1); vec4 tex2 = vec4(1, 1, 1, 1); vec4 tex3 = vec4(1, 1, 1, 1); if (uHasTexture) { tex = texture2D(uTexture, vTexcoord0).rgba; } if (uHasTexture2) { tex2 = texture2D(uTexture2, vTexcoord1).rgba; } if (uHasTexture3) { tex3 = texture2D(uTexture3, vTexcoord2).rgba; } vec4 finalColor = vec4((tex * vColor ).rgb, tex.a*vColor.a ); if (uPixelShader == 0) { vec3 matDiffuse = vColor.xyz * tex.rgb; finalColor = vec4(matDiffuse.rgb, tex.a*vColor.a); } else if (uPixelShader == 1) { vec4 textureMod = tex*tex2; float texAlpha = (textureMod.w * tex3.w); float opacity = texAlpha*vColor.a; vec3 matDiffuse = vColor.xyz * textureMod.rgb; finalColor = vec4(matDiffuse.rgb, opacity); } else if (uPixelShader == 2) { vec4 textureMod = tex*tex2*tex3; float texAlpha = (textureMod.w); float opacity = texAlpha*vColor.a; vec3 matDiffuse = vColor.xyz * textureMod.rgb; finalColor = vec4(matDiffuse.rgb, opacity); } else if (uPixelShader == 3) { vec4 textureMod = tex*tex2*tex3; float texAlpha = (textureMod.w); float opacity = texAlpha*vColor.a; vec3 matDiffuse = vColor.xyz * textureMod.rgb; finalColor = vec4(matDiffuse.rgb, opacity); }; if (finalColor.a < uAlphaTreshold ) discard; gl_FragColor = finalColor; } ', + ], + null, + null, + )), + (this.V.b = {}), + (this.V.a.attributes = [ + { loc: e.getAttribLocation(this.V.a.program, 'aPosition'), type: e.FLOAT, size: 3, offset: 0, stride: 52 }, + { loc: e.getAttribLocation(this.V.a.program, 'aColor'), type: e.FLOAT, size: 4, offset: 12, stride: 52 }, + { loc: e.getAttribLocation(this.V.a.program, 'aTexcoord0'), type: e.FLOAT, size: 2, offset: 28, stride: 52 }, + { loc: e.getAttribLocation(this.V.a.program, 'aTexcoord1'), type: e.FLOAT, size: 2, offset: 36, stride: 52 }, + { loc: e.getAttribLocation(this.V.a.program, 'aTexcoord2'), type: e.FLOAT, size: 2, offset: 44, stride: 52 }, + ]), + (this.V.c = this.L), + (this.V.d = this.M), + (this.V.m = this.c.j)), + !this.S) + ) + if (((this.S = [null, null, null]), 0 != (268435456 & this.c.b))) { + WH.debug('multitexture particle', this.c.f[0], this.c.f[1], this.c.f[2], this); + for (let t = 0; t < this.c.f.length; t++) { + const e = this.c.f[t]; + e > -1 && e < this.b.aw.length && (this.S[t] = this.b.aw[e]); + } + } else this.c.e > -1 && this.c.e < this.b.aw.length && (this.S[0] = this.b.aw[this.c.e]); + if (!this.S[0].f || !this.S[0].f.f) return; + (this.V.b.uViewMatrix = this.b.aS.viewMatrix), + (this.V.b.uProjMatrix = this.b.aS.projMatrix), + (this.V.b.uBlendMode = this.c.g), + (this.V.b.uPixelShader = this.r > 1 ? this.r - 1 : 0); + let i = [ + this.S[0] && this.S[0].f && this.S[0].f.f, + this.S[1] && this.S[1].f && this.S[1].f.f, + this.S[2] && this.S[2].f && this.S[2].f.f, + ]; + (this.V.b.uTexture = this.S[0].f.d), + (this.V.b.uTexture2 = i[1] ? this.S[1].f.d : null), + (this.V.b.uTexture3 = i[2] ? this.S[2].f.d : null), + (this.V.b.uHasTexture = i[0] ? 1 : 0), + (this.V.b.uHasTexture2 = i[1] ? 1 : 0), + (this.V.b.uHasTexture3 = i[2] ? 1 : 0); + let r = this.c.g; + 4 == r && (r = 3), (this.V.e = r), (this.V.i = !this.b.aY); + let n = -1; + 1 == r ? (n = 0.501960814) : r > 1 && (n = 1 / 255), + (this.V.b.uAlphaTreshold = n), + (this.V.h = !1), + (this.V.f = !1), + (this.V.j = e.TRIANGLES), + (this.V.k = (6 * this.E) >> 0), + (this.V.l = 0), + t.push(this.V); + } + Z(t, e) { + if (0 == (16 & this.c.b)) + for (let i = 0; i < this.p.length; i++) { + const r = this.p[i]; + Oe(r.a, r.a, t), Ne(r.c, r.c, e); + } + } + aa(t, e, i, r, n) { + if (null == this.I) return; + if (this.b.S) return; + ii(this.l, this.d); + let a = Qi(); + ii(a, e), (a[3] = 1), lr(a, a, n), (this.m = a[2]); + let s = ve(); + if ((ii(s, n), this.ab(e, s, r), t > 0)) { + let e = ve(); + if ((ii(e, this.d), 16384 & this.c.b)) { + Ce(this.o, e, this.l); + let i = this.s * (Te(this.o) / t) + this.t; + i >= 0 && (i = Math.min(i, 1)), Fe(this.n, this.o, i); + } + if (64 & this.c.b) { + this.u += t; + let i = 0.03; + if (this.u > i) + if (((this.u = 0), 0 == this.p.length)) { + let t = i / this.u, + r = ve(); + Ce(r, e, this.l); + let n = t * this.c.I; + Se(this.v, r, we(n, n, n)); + } else Ae(this.v, 0, 0, 0); + } + this.ac(t); + } + } + ab(t, e, i) { + if ((ye(this.w, e), null == i || 16 & this.c.b)) Ge(this.d, t); + else { + let e = je(); + We(e, i), Ye(this.d, e, t); + } + let r = ve(); + ri(r, t), (this.k = r[0]); + } + ac(t) { + if ((t = Math.max(t, 0)) < 0.1) ye(this.n, this.o); + else { + let e = Math.floor(t / 0.1); + t = -0.1 * e + t; + let i = Math.min(Math.floor(this.I.i().lifespan / 0.1), e), + r = i + 1, + n = 1; + (n = r < 0 ? ((1 & r) | (r >> 1)) + ((1 & r) | (r >> 1)) : r), Fe(this.n, this.o, 1 / n); + for (let t = 0; t < i; t++) this.ad(0.1); + } + this.ad(t); + } + ad(t) { + let e = new Cn(); + if (t < 0) return; + this.c.b, this.ae(e, t), this.af(t); + let i = 0; + for (; i < this.p.length; ) { + let r = this.p[i]; + (r.b = r.b + t), r.b > Math.max(this.I.g(r.e), 0.001) ? (this.ai(i), i--) : this.aj(r, t, e) || (this.ai(i), i--), i++; + } + } + ae(t, e) { + (t.a = ve()), (t.b = ve()), (t.c = ve()), (t.d = 0); + let i = we(e, e, e), + r = e * e * 0.5, + n = we(r, r, r); + Se(t.a, this.c.Q, i); + let a = ve(); + this.I.j(a), Se(t.b, a, i), Se(t.c, a, n), (t.d = this.c.J * e); + } + af(t) { + if (!this.T) return; + let e = this.I.d(); + for (this.x = this.x + t * e; this.x > 1; ) this.ag(t), (this.x -= 1); + } + ag(t) { + let e = this.ah(); + if ((this.I.k(e, t), !(16 & this.c.b))) { + let t = er(e.a[0], e.a[1], e.a[2], 1), + i = er(e.c[0], e.c[1], e.c[2], 0); + lr(t, t, this.d), lr(i, i, this.d), ye(e.a, t), ye(e.c, i), 8192 & this.c.b && (e.a[2] = 0); + } + if (64 & this.c.b) { + let t = 1 + this.I.i().speedVariation * this.J.e(), + i = ve(); + Fe(i, this.v, t), Ee(e.c, e.c, i); + } + if (this.r >= 2) + for (let t = 0; t < 2; t++) { + (e.f[t][0] = this.J.f()), (e.f[t][1] = this.J.f()); + let a = fr(); + _r(a, this.c.aa[t], this.J.e()), (i = e.g[t]), (r = a), (n = this.c.Z[t]), (i[0] = r[0] + n[0]), (i[1] = r[1] + n[1]); + } + var i, r, n; + } + ah() { + let t = new yn(); + return this.p.push(t), t; + } + ai(t) { + this.p.splice(t, 1); + } + aj(t, e, i) { + if (this.r >= 2) + for (let i = 0; i < 2; i++) { + let r = t.f[i][0] + e * t.g[i][0]; + (t.f[i][0] = r - Math.floor(r)), (r = t.f[i][1] + e * t.g[i][1]), (t.f[i][1] = r - Math.floor(r)); + } + Ee(t.c, t.c, i.a), 16384 & this.c.b && 2 * e < t.b && Ee(t.a, t.a, this.n); + let r = we(e, e, e), + n = ve(); + if ( + (Se(n, t.c, r), Ee(t.c, t.c, i.b), Fe(t.c, t.c, 1 - i.d), Ee(t.a, t.a, n), Ee(t.a, t.a, i.c), 2 == this.c.h && 128 & this.c.b) + ) { + let e = ve(); + if ((ye(e, t.a), 16 & this.c.b)) { + if (Be(e, n) > 0) return !1; + } else { + let i = ve(); + if ((ii(i, this.d), Ce(e, t.a, i), Be(e, n) > 0)) return !1; + } + } + return !0; + } + ak(t) { + if (((this.F.length = 0), 0 == this.p.length && null != this.I)) return; + We(this.f, t), mr(pr(), t), this.al(null, t); + let e = 0; + for (let t = 0; t < this.p.length; t++) { + let i = this.p[t], + r = new Sn(); + if ((this.an(i, r) && (131072 & this.c.b && (this.ap(i, r), e++), 262144 & this.c.b && (this.aq(i, r), e++)), e >= 1e3)) break; + } + this.E = e; + } + al(t, e) { + var i, r, n; + 16 & this.c.b ? Ye(this.g, e, this.d) : null != t ? Ye(this.g, e, t) : Ge(this.g, e), + ii(this.h, e), + 4096 & this.c.b && + (mr(this.i, this.g), + 16 & this.c.b && + Math.abs(this.k) > 0 && + ((i = this.i), + (r = this.i), + (n = 1 / this.k), + (i[0] = r[0] * n), + (i[1] = r[1] * n), + (i[2] = r[2] * n), + (i[3] = r[3] * n), + (i[4] = r[4] * n), + (i[5] = r[5] * n), + (i[6] = r[6] * n), + (i[7] = r[7] * n), + (i[8] = r[8] * n)), + Ae(this.j, this.i[6], this.i[7], this.i[8]), + De(this.j) <= 2.3841858e-7 ? Ae(this.j, 0, 0, 1) : Ue(this.j, this.j)); + } + am(t) { + let e = 0, + i = 0; + if (0 != this.c.K || 0 != this.c.N) { + let r = new pn(t.e); + (e = 0 == this.c.L ? this.c.K : this.c.K + r.e() * this.c.L), (i = 0 == this.c.N ? this.c.M : this.c.M + r.e() * this.c.N); + } else (e = this.c.K), (i = this.c.M); + return { deltaSpin: i, baseSpin: e }; + } + an(t, e) { + let i = this.c.G, + r = this.c.H, + n = r[0], + a = r[1] - n, + s = 0, + o = t.e, + l = t.b; + if (((i < 1 || 0 != a) && (s = 127 & (l * this.c.F + o)), i < An[s])) return 0; + this.ao(t, e, o); + let h = a * An[s] + n; + _r(e.c.a, e.c.a, h), 32 & this.c.b && _r(e.c.a, e.c.a, this.k); + let u = er(t.a[0], t.a[1], t.a[2], 1); + return lr(u, u, this.g), ye(e.a, u), (e.b = 1), 1; + } + ao(t, e, i) { + let r = t.b / this.I.f(), + n = new pn(i); + Math.min(r, 1) <= 0 ? (r = 0) : r >= 1 && (r = 1); + let a = we(255, 255, 255), + s = dr(1, 1), + o = 1, + l = e.c; + this.c.y.i(r, a, l.b, this.H), this.H || Fe(l.b, l.b, 1 / 255), this.c.A.i(r, s, l.a), (l.e = this.c.z.i(r, 1) / 32767); + let h = 0; + this.c.C.a.length > 0 + ? ((o = 0), (l.c = this.c.C.i(r, o)), (l.c = this.y & (l.c + this.z))) + : 65536 & this.c.b + ? ((h = (this.y + 1) * n.d()), (l.c = (h / 4294967296) | 0)) + : (l.c = 0), + (o = 0), + (l.d = this.c.D.i(r, o)), + (l.d = (l.d + this.z) & this.y); + let u = 1; + 524288 & this.c.b + ? ((u = Math.max(1 + n.e() * this.c.B[1], 99999997e-12)), (l.a[0] = Math.max(1 + n.e() * this.c.B[0], 99999997e-12) * l.a[0])) + : ((u = Math.max(1 + n.e() * this.c.B[0], 99999997e-12)), (l.a[0] = u * l.a[0])), + (l.a[1] = u * l.a[1]); + } + ap(t, e) { + let i = dr((e.c.c & this.B) * this.C, (e.c.c >> this.A) * this.D), + r = 0, + n = 0, + a = this.am(t); + (r = a.baseSpin), (n = a.deltaSpin); + let s = 0, + o = we(0, 0, 0), + l = we(0, 0, 0), + h = !1, + u = !1; + if (4 & this.c.b && De(t.c) > 2.3841858e-7) + if (((s = 1), 4096 & this.c.b)) h = !0; + else { + let i = er(-t.c[0], -t.c[1], -t.c[2], 0); + lr(i, i, this.g); + let r = ve(); + ye(r, i); + let n = 0, + a = De(r); + n = a <= 2.3841858e-7 ? 0 : 1 / Math.sqrt(a); + let s = ve(); + ye(s, r), Fe(s, s, n), ye(o, s), Fe(o, o, e.c.a[0]), (l = we(s[1], -s[0], 0)), Fe(l, l, e.c.a[1]), (u = !0), (h = !1); + } + if ((4096 & this.c.b || h) && !u) { + let i = pr(); + (c = i), + (f = this.i), + (c[0] = f[0]), + (c[1] = f[1]), + (c[2] = f[2]), + (c[3] = f[3]), + (c[4] = f[4]), + (c[5] = f[5]), + (c[6] = f[6]), + (c[7] = f[7]), + (c[8] = f[8]); + let a = e.c.a[0]; + if (s) { + let r = 0, + n = we(-t.c[0], -t.c[1], -t.c[2]), + s = De(n); + (r = s <= 2.3841858e-7 ? 0 : 1 / Math.sqrt(s)), + vr( + i, + this.i, + (function (t, e, i, r, n, a, s, o, l) { + var h = new me(9); + return (h[0] = t), (h[1] = e), (h[2] = i), (h[3] = r), (h[4] = n), (h[5] = a), (h[6] = s), (h[7] = o), (h[8] = l), h; + })(n[0] * r, n[1] * r, 0, -n[1] * r, n[0] * r, 0, 0, 0, 1), + ), + r > 2.3841858e-7 && (a = e.c.a[0] * (1 / Math.sqrt(De(t.c)) / r)); + } + if ( + (this.r, + Ae(o, i[0], i[1], i[2]), + Fe(o, o, a), + Ae(l, i[3], i[4], i[5]), + Fe(l, l, e.c.a[1]), + (n = l[0]), + (u = !0), + 0 != this.c.M || 0 != this.c.N) + ) { + let e = r + n * t.b; + 512 & this.c.b && 1 & t.e && (e = -e); + let i = ve(); + ye(i, this.j), this.r; + let a = pr(), + s = xr(); + Tr(s, i, e), + (function (t, e) { + var i = e[0], + r = e[1], + n = e[2], + a = e[3], + s = i + i, + o = r + r, + l = n + n, + h = i * s, + u = r * s, + c = r * o, + f = n * s, + d = n * o, + b = n * l, + g = a * s, + _ = a * o, + p = a * l; + (t[0] = 1 - c - b), + (t[3] = u - p), + (t[6] = f + _), + (t[1] = u + p), + (t[4] = 1 - h - b), + (t[7] = d - g), + (t[2] = f - _), + (t[5] = d + g), + (t[8] = 1 - h - c); + })(a, s), + Ne(o, o, a), + Ae(l, n, l[1], l[2]), + Ne(l, l, a); + } + } + var c, f; + if (!u) + if (0 != this.c.M || 0 != this.c.N) { + let i = r + n * t.b; + 512 & this.c.b && 1 & t.e && (i = -i); + let a = Math.cos(i), + s = Math.sin(i); + Ae(o, a, s, 0), + Fe(o, o, e.c.a[0]), + Ae(l, -s, a, 0), + Fe(l, l, e.c.a[1]), + 134217728 & this.c.b && Ee(e.a, e.a, we(l[0], l[1], 0)); + } else Ae(o, e.c.a[0], 0, 0), Ae(l, 0, e.c.a[1], 0); + return this.ar(o, l, e.a, e.c.b, e.c.e, i[0], i[1], t.f), 0; + } + aq(t, e) { + let i = dr((e.c.d & this.B) * this.C, (e.c.d >> this.A) * this.D), + r = we(0, 0, 0), + n = we(0, 0, 0), + a = this.c.E; + 1024 & this.c.b && (a = Math.min(t.b, a)); + let s = Qi(); + Fe(s, t.c, -1), (s[3] = 0), lr(s, s, this.g), Fe(s, s, a); + let o = we(s[0], s[1], 0); + if (Be(o, o) > 1e-4) { + let t = 1 / Te(o); + _r(e.c.a, e.c.a, t), gr(o, o, e.c.a), (n = we(-o[1], o[0], 0)), Fe(r, s, 0.5), Ee(e.a, e.a, r); + } else (r = we(0.05 * e.c.a[0], 0, 0)), (n = we(0, 0.05 * e.c.a[1], 0)); + return this.ar(r, n, e.a, e.c.b, e.c.e, i[0], i[1], t.f), 1; + } + ar(t, e, i, r, n, a, s, o) { + const l = [-1, -1, 1, 1], + h = [1, -1, 1, -1], + u = [0, 0, 1, 1], + c = [0, 1, 0, 1]; + let f = ve(), + d = fr(), + b = fr(), + g = fr(); + for (let _ = 0; _ < 4; _++) + Ae(f, 0, 0, 0), + Re(f, f, t, l[_]), + Re(f, f, e, h[_]), + Ee(f, f, i), + br(d, u[_] * this.C + a, c[_] * this.D + s), + br(b, u[_] * this.c.Y[0] + o[0][0], c[_] * this.c.Y[0] + o[0][1]), + br(g, u[_] * this.c.Y[1] + o[1][0], c[_] * this.c.Y[1] + o[1][1]), + this.F.push(f[0]), + this.F.push(f[1]), + this.F.push(f[2]), + this.F.push(r[0]), + this.F.push(r[1]), + this.F.push(r[2]), + this.F.push(n), + this.F.push(d[0]), + this.F.push(d[1]), + this.F.push(b[0]), + this.F.push(b[1]), + this.F.push(g[0]), + this.F.push(g[1]); + } + }; + const Fn = class { + constructor(t) { + this.a = t.getFloat(); + } + }; + const Rn = class { + constructor(t) { + (this.buffer = new DataView(t)), (this.position = 0); + } + getBool() { + var t = 0 != this.buffer.getUint8(this.position); + return (this.position += 1), t; + } + getUint8() { + var t = this.buffer.getUint8(this.position); + return (this.position += 1), t; + } + getInt8() { + var t = this.buffer.getInt8(this.position); + return (this.position += 1), t; + } + getUint16() { + var t = this.buffer.getUint16(this.position, !0); + return (this.position += 2), t; + } + getInt16() { + var t = this.buffer.getInt16(this.position, !0); + return (this.position += 2), t; + } + getUint32() { + var t = this.buffer.getUint32(this.position, !0); + return (this.position += 4), t; + } + getInt32() { + var t = this.buffer.getInt32(this.position, !0); + return (this.position += 4), t; + } + getFloat() { + var t = this.buffer.getFloat32(this.position, !0); + return (this.position += 4), t; + } + getString(t) { + void 0 === t && (t = this.getUint16()); + for (var e = '', i = 0; i < t; ++i) e += String.fromCharCode(this.getUint8()); + return e; + } + setBool(t) { + this.buffer.setUint8(this.position, t ? 1 : 0), (this.position += 1); + } + setUint8(t) { + this.buffer.setUint8(this.position, t), (this.position += 1); + } + setInt8(t) { + this.buffer.setInt8(this.position, t), (this.position += 1); + } + setUint16(t) { + this.buffer.setUint16(this.position, t, !0), (this.position += 2); + } + setInt16(t) { + this.buffer.setInt16(this.position, t, !0), (this.position += 2); + } + setUint32(t) { + this.buffer.setUint32(this.position, t, !0), (this.position += 4); + } + setInt32(t) { + this.buffer.setInt32(this.position, t, !0), (this.position += 4); + } + setFloat(t) { + this.buffer.setFloat32(this.position, t, !0), (this.position += 4); + } + }; + class Dn { + constructor() { + (this.a = ve()), (this.b = Qi()), (this.c = fr()); + } + } + class In {} + const Un = [0, 1, 2, 10, 3, 4, 5, 13]; + function Bn(t, e) { + return we(t[4 * e + 0], t[4 * e + 1], t[4 * e + 2]); + } + class Pn {} + const zn = class { + constructor(t, e) { + (this.g = ve()), + (this.h = ve()), + (this.p = new In()), + (this.q = ve()), + (this.r = ve()), + (this.s = ve()), + (this.t = ve()), + (this.u = ve()), + (this.v = ve()), + (this.w = ve()), + (this.x = ve()), + (this.y = ve()), + (this.z = ve()), + (this.A = ve()), + (this.B = ve()), + (this.O = ve()), + (this.V = t.aS.context), + (this.a = t); + let i = new Pn(); + var r; + if (((i.a = e.getInt32()), (i.b = e.getInt32()), (i.c = we(e.getFloat(), e.getFloat(), e.getFloat())), (r = e.getInt32()) > 0)) { + i.j = new Array(r); + for (let t = 0; t < r; ++t) i.j[t] = e.getInt16(); + } + if ((r = e.getInt32()) > 0) { + i.k = new Array(r); + for (let t = 0; t < r; ++t) i.k[t] = e.getInt16(); + } + (i.l = new Gr(e, Br)), + (i.m = new Gr(e, zr)), + (i.n = new Gr(e, Or)), + (i.o = new Gr(e, Or)), + (i.d = e.getFloat()), + (i.e = e.getFloat()), + (i.f = e.getFloat()), + (i.g = e.getInt16()), + (i.h = e.getInt16()), + (i.p = new Gr(e, zr)), + (i.q = new Gr(e, Nr)), + (i.r = e.getInt16()), + (this.U = i), + (this.ab = new Array(i.k.length)), + (this.ae = new Array(i.k.length)); + for (let e = 0; e < i.k.length; e++) this.ae[e] = t.av[i.k[e]]; + let n = er(255, 255, 255, 255), + a = new In(); + (a.a = 0), (a.b = 0), (a.c = 1), (a.d = 1), this.au(i.d, i.e, n, a, i.h, i.g), this.ag(i.f), this.af(!1); + } + af(t) { + (this.L = t), this.L || (this.J = !1); + } + ag(t) { + this.S = t; + } + ah() { + return this.e == this.d; + } + ai(t) { + this.R = t; + } + aj(t) { + this.Q = t; + } + ak(t) { + this.F[3] = Math.max(t, 0); + } + al() { + let t = ve(); + He(t, this.g, this.O); + let e = De(t); + Fe(t, this.q, this.R), + Ce(this.w, this.g, t), + Fe(t, this.r, this.R), + Ce(this.x, this.O, t), + Fe(t, this.q, this.Q), + Ee(this.y, this.g, t), + Fe(t, this.r, this.Q), + Ee(this.z, this.O, t), + Fe(this.u, this.s, e), + Fe(this.v, this.t, e); + } + am(t, e, i) { + let r; + if (this.M && this.L) { + r = t; + let i = ve(); + ii(i, r), + Ee(i, i, e), + ye(this.h, e), + this.J + ? (ye(this.g, this.O), ye(this.s, this.t), ye(this.q, this.r)) + : (ye(this.g, i), (this.s = Bn(r, 2)), (this.q = Bn(r, 1)), (this.f = 0), (this.J = !0)), + (this.O = i), + (this.t = Bn(r, 2)), + (this.r = Bn(r, 1)); + } + } + an(t) { + var e = pr(); + mr(e, t), + (this.s = Ne(this.s, this.s, e)), + (this.q = Ne(this.q, this.q, e)), + (this.t = Ne(this.t, this.t, e)), + (this.r = Ne(this.r, this.r, e)), + (this.g = Oe(this.g, this.g, t)), + (this.O = Oe(this.O, this.O, t)); + for (var i = 0; i < this.i.length; i++) Oe(this.i[i].a, this.i[i].a, t); + } + ao(t, e, i) { + (this.F[2] = i), (this.F[1] = e), (this.F[0] = t); + } + ap(t) { + if (this.P != t) { + this.P = t; + let e = t % this.I, + i = e; + 0 != (2147483648 & e) && (i = ((1 & e) | (e >> 1)) + ((1 & e) | (e >> 1))); + let r = i * this.l + this.G.b; + this.p.b = r; + let n = t / this.I, + a = n; + 0 != (2147483648 & n) && ((n = (1 & n) | (n >> 1)), (a = n + n), (r = this.p.b)); + let s = a * this.m + this.G.a; + (this.p.a = s), (this.p.d = r + this.l), (this.p.c = s + this.m); + } + } + aq(t, e, i) { + let r, + n = this.i[2 * this.d], + a = this.i[2 * this.d + 1], + s = ve(); + Fe(s, this.v, 1 - e), + Ce(s, this.x, s), + Fe(n.a, s, e), + Fe(s, this.u, e), + Ee(s, this.w, s), + Fe(s, s, 1 - e), + Ee(n.a, n.a, s), + Fe(s, this.v, 1 - e), + Ce(s, this.z, s), + Fe(a.a, s, e), + Fe(s, this.u, e), + Ee(s, this.y, s), + Fe(s, s, 1 - e), + Ee(a.a, a.a, s), + (this.c[this.d] = t), + (r = i), + (this.d = this.d + r), + this.d >= this.c.length && (this.d -= this.c.length); + } + ar(t, e) { + if (this.a.S) return; + let i = ve(), + r = 1; + (i = this.U.l.d(t, this.a.aX, i)), (r = this.U.m.d(t, this.a.aX)), this.ao(i[0], i[1], i[2]), this.ak(r / 32767); + let n = this.U.n.d(t, this.a.aX); + this.aj(n); + let a = this.U.o.d(t, this.a.aX); + this.ai(a); + let s = this.U.p.d(t, this.a.aX); + this.ap(s); + let o = this.U.q.d(t, this.a.aX, 1); + this.af(0 != o); + let l = je(); + ai(l, this.a.U, this.a.ap[this.U.b].m), Ze(l, l, this.U.c); + let h = ve(); + this.am(l, h, null), this.as(e, !1); + } + as(t, e) { + let i, + r, + n, + a, + s, + o, + l, + h, + u, + c, + f, + d, + b, + g, + _, + p, + m, + v, + x, + T, + w, + y, + A, + E, + C, + S, + M, + k, + F, + R, + D, + I, + U, + B, + P, + z, + O, + N, + L, + H, + V, + j, + G, + X, + q, + W, + Y, + Z; + for ( + this.N || (this.C > 0 && (t = 1 / this.C + 99999997e-12)), t >= 0 ? this.D <= t && (t = this.D) : (t = 0), v = this.e; + v != this.d && !(t + this.c[v] <= this.D); + v = this.e + ) + this.e = this.at(this.e, 1); + if (!e && this.M && this.L && this.J) { + (D = t * this.C + this.f), (Z = this.F), this.al(); + let e = !1; + if ( + ((B = 0), + D < 1 ? (e = !0) : ((Y = this.f), (U = 1 / (D - Y)), (m = Math.floor(D - 1)), (B = Math.ceil(Math.max(m, 0)))), + -1 == B || e) + ); + else + for ( + I = 1, v = 1; + (R = this.d), + (N = this.i.length), + (this.i[2 * R].b = Z), + (x = 2 * this.d + 1), + (L = this.i.length), + (this.i[x].b = Z), + this.aq((v - Y) * U * -t, (v - Y) * U, 1), + -1 != --B; + v = I + ) + (I += 1), (Y = this.f); + (T = Math.floor(D)), + (this.f = D - T), + this.aq(0, 1, 0), + (F = this.d), + (H = this.i.length), + (w = this.i[2 * F]), + (y = this.p.b), + (w.c[1] = this.p.a), + (w.c[0] = y), + (A = 2 * this.d + 1), + (V = this.i.length), + (E = this.i[A]), + (C = this.p.b), + (E.c[1] = this.p.c), + (E.c[0] = C), + (k = this.d), + (j = this.i.length), + (this.i[2 * k].b = Z), + (S = 2 * this.d + 1), + (G = this.i.length), + (this.i[S].b = Z); + } + (this.A[2] = 34028235e31), + (this.A[1] = 34028235e31), + (this.A[0] = 34028235e31), + (this.B[2] = -34028235e31), + (this.B[1] = -34028235e31), + (this.B[0] = -34028235e31), + (P = this.e); + for (let e = this.e; e != this.d; P = e) + (p = 2 * e), + (W = this.i.length), + (M = P), + (O = this.i[2 * e]), + (i = p + 1), + (r = this.i[2 * e + 1]), + (n = (this.S + this.S) * this.c[M] * t + t * this.S * t), + (O.a[2] = O.a[2] + n), + (r.a[2] = n + r.a[2]), + (a = O.a[0]), + (s = this.A[0]), + s > O.a[0] && ((s = O.a[0]), (this.A[0] = a), (a = O.a[0])), + (o = O.a[1]), + (l = this.A[1]), + l > o && ((l = O.a[1]), (this.A[1] = o), (o = O.a[1])), + (h = O.a[2]), + (u = this.A[2]), + u > h && ((u = O.a[2]), (this.A[2] = h), (h = O.a[2])), + a > this.B[0] && (this.B[0] = a), + o > this.B[1] && (this.B[1] = o), + h > this.B[2] && (this.B[2] = h), + (c = r.a[0]), + s > r.a[0] && ((this.A[0] = c), (c = r.a[0])), + (f = r.a[1]), + l > f && ((this.A[1] = f), (f = r.a[1])), + (d = r.a[2]), + u > d && ((this.A[2] = d), (d = r.a[2])), + c > this.B[0] && (this.B[0] = c), + f > this.B[1] && (this.B[1] = f), + d > this.B[2] && (this.B[2] = d), + (X = this.c.length), + (this.c[M] = t + this.c[M]), + (b = this.l), + (q = this.c.length), + (g = b * this.c[M] * this.k + this.p.b), + (O.c[1] = this.p.a), + (O.c[0] = g), + (r.c[1] = this.p.c), + (r.c[0] = g), + (_ = this.c.length), + (z = P + 1), + (e = z - _), + _ > z && (e = z); + this.N = !0; + } + at(t, e) { + let i = e + t; + t = i; + let r = this.c.length; + return i >= r && (t = i - r), t; + } + au(t, e, i, r, n, a) { + let s, o, l, h, u, c, f, d; + (f = Math.ceil(t)), + (d = Math.max(0.25, e)), + (s = Math.ceil(d * f)), + (o = Math.ceil(Math.max(s + 1 + 1, 0))), + (this.c = new Array(o)), + (this.e = 0), + (this.d = 0), + (this.f = 0), + (this.J = !1), + (this.i = new Array(2 * o)); + for (let t = 0; t < this.i.length; t++) { + this.i[t] = new Dn(); + let e = this.i[t]; + (e.a[0] = 0), (e.a[1] = 0), (e.a[2] = 0), (e.b = er(0, 0, 0, 0)), (e.c[0] = 0), (e.c[1] = 0); + } + this.j = new Array(4 * o); + for (let t = 0; t < this.j.length; t++) this.j[t] = t % (2 * o); + (this.k = 1 / d), + (l = a), + 0 != (2147483648 & a) && (l = ((1 & a) | (a >> 1)) + ((1 & a) | (a >> 1))), + (this.l = (r.d - r.b) / l), + (h = n), + 0 != (2147483648 & n) && (h = ((1 & n) | (n >> 1)) + ((1 & n) | (n >> 1))), + (this.m = (r.c - r.a) / h), + (this.n = 1 / this.l), + (this.o = 1 / this.m), + (this.C = f), + (this.D = d), + ar(i, i, 1 / 255), + (this.F = i), + (this.G = r), + (this.H = n), + (this.I = a), + (this.P = 0), + (u = 0 * this.l + this.G.b), + (this.p.b = u), + (c = 0 * this.m + this.G.a), + (this.p.a = c), + (this.p.d = u + this.l), + (this.p.c = c + this.m), + (this.Q = 10), + (this.R = 10), + (this.S = 0), + (this.M = !0), + (this.L = !0), + (this.K = !0); + } + av() { + let t = new Array(this.i.length); + for (let e = 0, i = 0; e < this.i.length; ++e) + (t[i++] = this.i[e].a[0]), + (t[i++] = this.i[e].a[1]), + (t[i++] = this.i[e].a[2]), + (t[i++] = this.i[e].b[0]), + (t[i++] = this.i[e].b[1]), + (t[i++] = this.i[e].b[2]), + (t[i++] = this.i[e].b[3]), + (t[i++] = this.i[e].c[0]), + (t[i++] = this.i[e].c[1]); + if (this.ah()) return; + let e = this.V; + this.W + ? (e.bindBuffer(e.ARRAY_BUFFER, this.W), e.bufferData(e.ARRAY_BUFFER, new Float32Array(t), e.DYNAMIC_DRAW)) + : ((this.W = e.createBuffer()), + e.bindBuffer(e.ARRAY_BUFFER, this.W), + e.bufferData(e.ARRAY_BUFFER, new Float32Array(t), e.DYNAMIC_DRAW)), + this.X + ? (e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.X), + e.bufferData(e.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.j), e.DYNAMIC_DRAW)) + : ((this.X = e.createBuffer()), + e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.X), + e.bufferData(e.ELEMENT_ARRAY_BUFFER, new Uint16Array(this.j), e.DYNAMIC_DRAW)); + } + aw(t) { + if (this.ah()) return; + let e = this.V; + for (let r = 0; r < this.U.j.length; r++) { + if (!this.ab[r]) { + let t = new en(); + (t.a = se( + e, + [ + ' attribute vec3 aPosition;\n attribute vec4 aColor;\n attribute vec2 aTexcoord0;\n uniform mat4 uViewMatrix;\n uniform mat4 uProjMatrix;\n varying vec4 vColor;\n varying vec2 vTexcoord0;\n void main() {\n vec4 aPositionVec4 = vec4(aPosition, 1);\n vColor = aColor;\n vTexcoord0 = aTexcoord0;\n gl_Position = uProjMatrix * uViewMatrix * aPositionVec4;\n }', + ' precision mediump float; varying vec4 vColor;\n varying vec2 vTexcoord0;\n uniform sampler2D uTexture;\n void main() {\n vec4 tex = texture2D(uTexture, vTexcoord0).rgba;\n gl_FragColor = vec4((vColor.rgb*tex.rgb), tex.a * vColor.a );\n }', + ], + null, + null, + )), + (t.b = {}), + (t.a.attributes = [ + { loc: e.getAttribLocation(t.a.program, 'aPosition'), type: e.FLOAT, size: 3, offset: 0, stride: 36 }, + { loc: e.getAttribLocation(t.a.program, 'aColor'), type: e.FLOAT, size: 4, offset: 12, stride: 36 }, + { loc: e.getAttribLocation(t.a.program, 'aTexcoord0'), type: e.FLOAT, size: 2, offset: 28, stride: 36 }, + ]), + (t.c = this.W), + (t.d = this.X), + (this.ab[r] = t); + } + var i = this.U.j[r]; + if (i <= -1 || i > this.a.aw.length) continue; + let n = this.a.aw[i]; + if (!n.f || !n.f.f) continue; + let a = r; + a >= this.U.k.length && (a = 0); + let s = this.a.av[this.U.k[a]]; + (this.ab[r].b.uViewMatrix = this.a.aS.viewMatrix), + (this.ab[r].b.uProjMatrix = this.a.aS.projMatrix), + (this.ab[r].b.uTexture = n.f.d), + (this.ab[r].h = !1), + (this.ab[r].f = !1), + (this.ab[r].e = Un[s.b]), + (this.ab[r].i = !this.a.aY); + let o = this.d > this.e ? 2 * (this.d - this.e) + 2 : 2 * (this.c.length + this.d - this.e) + 2; + (this.ab[r].j = e.TRIANGLE_STRIP), (this.ab[r].k = o), (this.ab[r].l = 2 * this.e * 2), t.push(this.ab[r]); + } + } + }, + On = + 'uniform float x;\r\nuniform float y;\r\nuniform float width;\r\nuniform float height;\r\n\r\nattribute vec2 aTextCoord;\r\nvarying vec2 vTextCoords;\r\nvoid main() {\r\n vTextCoords = aTextCoord;\r\n\r\n vec2 pos = vec2(\r\n (x + aTextCoord.x*width)* 2.0 - 1.0,\r\n (y + aTextCoord.y*height)* 2.0 - 1.0\r\n );\r\n\r\n gl_Position = vec4(pos.x, pos.y, 0, 1);\r\n}'; + class Nn { + constructor() { + (this.a = null), (this.b = null), (this.c = null); + } + d() { + null != this.a && this.a.h(), null != this.b && this.b.h(), null != this.c && this.c.h(); + } + e() { + return !(this.a && !this.a.g()) && !(this.b && !this.b.g()) && !(this.c && !this.c.g()); + } + } + class Ln { + constructor() { + (this.a = null), (this.b = null), (this.c = null), (this.d = {}), (this.i = new be()); + } + } + let Hn = null, + Vn = null, + jn = null; + class Gn { + constructor(t, e, i) { + (this.h = !1), + (this.e = t), + (this.f = e), + (this.g = i), + (function (t) { + (Vn = t.createTexture()), + t.bindTexture(t.TEXTURE_2D, Vn), + t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, 1, 1, 0, t.RGBA, t.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0])), + t.bindTexture(t.TEXTURE_2D, null), + (jn = t.createTexture()), + t.bindTexture(t.TEXTURE_2D, jn), + t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, 1, 1, 0, t.RGBA, t.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 255])), + t.bindTexture(t.TEXTURE_2D, null), + (Hn = new Ln()); + let e = Hn; + (e.a = se( + t, + [ + On, + 'precision mediump float;\r\nvarying vec2 vTextCoords;\r\nuniform sampler2D uDiffuseTexture;\r\nuniform sampler2D uSpecularTexture;\r\nuniform sampler2D uEmissiveTexture;\r\nuniform sampler2D renderResultTexture;\r\nuniform int uBlendMode;\r\nuniform int layer;\r\nuniform vec2 screenResolution;\r\n\r\nfloat overlayBlend(float a, float b) {\r\n if (b <= 0.5) {\r\n return 2.0 * a * b;\r\n } else {\r\n return 1.0 - ((2.0 * (1.0 - a) * (1.0 - b)));\r\n// return (1.0 - (1.0 - 2.0 * (a - 0.5)) * (1.0 - b));\r\n }\r\n}\r\n\r\nfloat alphaStraightBlend(float a, float b, float alpha) {\r\n return (a * alpha) + (b * (1.0 - alpha));\r\n}\r\n\r\nvoid main() {\r\n vec4 diffuse = texture2D( uDiffuseTexture, vTextCoords.xy );\r\n vec4 backGround = texture2D( renderResultTexture, gl_FragCoord.xy / screenResolution );\r\n\r\n //Blit and Inferior Alpha\r\n if (uBlendMode == 0 || uBlendMode == 4) {\r\n if (diffuse.a < 0.001) discard;\r\n\r\n vec3 finalColor = mix(backGround.rgb, diffuse.rgb, diffuse.a);\r\n\r\n diffuse = vec4(finalColor.rgb, 1.0);\r\n } else\r\n if (uBlendMode == 1) {\r\n // Multiply blending //\r\n if (diffuse.a < 0.001) discard;\r\n\r\n vec4 multTexture = diffuse;\r\n vec3 finalColor = (diffuse.rgb * backGround.rgb);\r\n\r\n diffuse = vec4(finalColor.rgb, 1.0);\r\n } else if (uBlendMode == 2) {\r\n // Overlay Blending //\r\n if (diffuse.a < 0.001) discard;\r\n\r\n vec4 overlayTex = diffuse;\r\n\r\n vec3 finalColor = vec3(\r\n overlayBlend(overlayTex.r, backGround.r),\r\n overlayBlend(overlayTex.g, backGround.g),\r\n overlayBlend(overlayTex.b, backGround.b)\r\n );\r\n\r\n diffuse = vec4(finalColor, 1.0);\r\n// diffuse = vec4(finalColor.rgb, overlayTex.a);\r\n } else if (uBlendMode == 3) {\r\n// if (diffuse.a > 0.5) discard;\r\n // Alpha Straight //\r\n vec4 overlayTex = diffuse;\r\n\r\n float alphaMult = 1.0;\r\n vec3 finalColor = vec3(\r\n alphaStraightBlend(overlayTex.r, backGround.r, alphaMult*overlayTex.a),\r\n alphaStraightBlend(overlayTex.g, backGround.g, alphaMult*overlayTex.a),\r\n alphaStraightBlend(overlayTex.b, backGround.b, alphaMult*overlayTex.a)\r\n );\r\n\r\n diffuse = vec4(finalColor.rgb, 1.0);\r\n// diffuse = vec4(1.0,1.0,1.0, 1.0-overlayTex.a);\r\n }\r\n\r\n gl_FragColor = diffuse;\r\n}', + ], + null, + null, + )), + (e.b = se( + t, + [ + On, + 'precision mediump float;\r\n\r\nvarying vec2 vTextCoords;\r\nuniform sampler2D uDiffuseTexture;\r\nuniform sampler2D uSpecularTexture;\r\nuniform sampler2D uEmissiveTexture;\r\nuniform sampler2D renderResultTexture;\r\nuniform int uBlendMode;\r\n\r\nvoid main() {\r\n vec4 diffuse = texture2D( uDiffuseTexture, vTextCoords.xy );\r\n vec4 specular = texture2D( uSpecularTexture, vTextCoords.xy );\r\n if (diffuse.a < 0.001) discard;\r\n gl_FragColor = vec4(specular.rgb, 1.0);\r\n}', + ], + null, + null, + )), + (e.c = se( + t, + [ + On, + 'precision mediump float;\r\n\r\nvarying vec2 vTextCoords;\r\nuniform sampler2D uDiffuseTexture;\r\nuniform sampler2D uSpecularTexture;\r\nuniform sampler2D uEmissiveTexture;\r\nuniform sampler2D renderResultTexture;\r\nuniform vec2 screenResolution;\r\nuniform int uBlendMode;\r\nuniform float emissiveAlphaOverride;\r\nuniform int layer;\r\n\r\nvoid main() {\r\n vec4 diffuse = texture2D( uDiffuseTexture, vTextCoords.xy );\r\n vec4 emissive = texture2D( uEmissiveTexture, vTextCoords.xy );\r\n vec4 backGround = texture2D( renderResultTexture, gl_FragCoord.xy / screenResolution );\r\n\r\n if (diffuse.a < 0.001) discard;\r\n// if (emissive.a < 0.001) discard;\r\n\r\n //TODO: This is a hack from what was obeserved in Nightbourn texture customization with tatoos.\r\n //TODO: But Maybe switch should be over layer or something else instead of blend\r\n float alpha = 1.0;\r\n\r\n if (emissiveAlphaOverride > -1.0) {\r\n alpha = emissiveAlphaOverride;\r\n } else if (layer <= 1) {\r\n alpha = 0.0;\r\n } else {\r\n alpha = emissive.a;\r\n }\r\n\r\n\r\n gl_FragColor = vec4(emissive.rgb, alpha);\r\n}', + ], + null, + null, + )), + (e.d = {}), + (e.f = t.createBuffer()), + t.bindBuffer(t.ARRAY_BUFFER, e.f), + t.bufferData(t.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), t.STATIC_DRAW), + t.bindBuffer(t.ARRAY_BUFFER, null), + (e.e = t.createBuffer()), + t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, e.e), + t.bufferData(t.ELEMENT_ARRAY_BUFFER, new Int16Array([0, 1, 2, 1, 3, 2]), t.STATIC_DRAW), + t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, null), + (e.g = t.createFramebuffer()), + (e.h = { loc: t.getAttribLocation(e.a.program, 'aTextCoord'), type: t.FLOAT, size: 2, offset: 0, stride: 0 }); + })(t); + } + i() { + let t = this.e; + this.d && t.deleteTexture(this.d), + this.a && t.deleteTexture(this.a), + this.b && t.deleteTexture(this.b), + this.c && t.deleteTexture(this.c), + (this.d = t.createTexture()), + t.bindTexture(t.TEXTURE_2D, this.d), + t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.f, this.g, 0, t.RGBA, t.UNSIGNED_BYTE, null), + t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), + (this.a = t.createTexture()), + t.bindTexture(t.TEXTURE_2D, this.a), + t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.f, this.g, 0, t.RGBA, t.UNSIGNED_BYTE, null), + t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), + (this.b = t.createTexture()), + t.bindTexture(t.TEXTURE_2D, this.b), + t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.f, this.g, 0, t.RGBA, t.UNSIGNED_BYTE, null), + t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), + (this.c = t.createTexture()), + t.bindTexture(t.TEXTURE_2D, this.c), + t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.f, this.g, 0, t.RGBA, t.UNSIGNED_BYTE, null), + t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), + t.bindTexture(t.TEXTURE_2D, null), + t.bindFramebuffer(t.FRAMEBUFFER, Hn.g), + t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.a, 0), + t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT), + t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.b, 0), + t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT), + t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.c, 0), + t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT), + t.useProgram(Hn.b.program), + t.bindBuffer(t.ARRAY_BUFFER, Hn.f), + t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, Hn.e), + Hn.i.disableAll(), + Hn.i.enable(t, [Hn.h]), + t.viewport(0, 0, this.f, this.g); + } + j(t, e, i, r, n, a, s, o) { + let l = this.e; + (Hn.d.x = e), (Hn.d.y = i), (Hn.d.width = r), (Hn.d.height = n), (null == t.b && null == t.c) || (this.h = !0); + let h = 0; + 4 == a ? (h = 1) : 6 == a ? (h = 2) : 9 == a ? (h = 3) : 15 == a && (h = 4), + (Hn.d.uBlendMode = h), + (Hn.d.screenResolution = new Float32Array([this.f, this.g])), + (Hn.d.uDiffuseTexture = null != t.a ? t.a.d : Vn), + (Hn.d.uSpecularTexture = null != t.b ? t.b.d : Vn), + (Hn.d.uEmissiveTexture = null != t.c ? t.c.d : jn), + (Hn.d.renderResultTexture = null != this.d ? this.d : Vn), + (Hn.d.layer = s), + (Hn.d.emissiveAlphaOverride = o), + l.disable(l.CULL_FACE), + l.disable(l.DEPTH_TEST), + l.disable(l.BLEND), + l.useProgram(Hn.a.program), + l.framebufferTexture2D(l.FRAMEBUFFER, l.COLOR_ATTACHMENT0, l.TEXTURE_2D, this.a, 0), + l.bindTexture(l.TEXTURE_2D, this.d), + l.copyTexImage2D(l.TEXTURE_2D, 0, l.RGBA, 0, 0, this.f, this.g, 0), + l.bindTexture(l.TEXTURE_2D, null), + re(Hn.a, Hn.d), + l.drawElements(l.TRIANGLES, 6, l.UNSIGNED_SHORT, 0), + l.useProgram(Hn.b.program), + l.framebufferTexture2D(l.FRAMEBUFFER, l.COLOR_ATTACHMENT0, l.TEXTURE_2D, this.b, 0), + l.bindTexture(l.TEXTURE_2D, this.d), + l.copyTexImage2D(l.TEXTURE_2D, 0, l.RGBA, 0, 0, this.f, this.g, 0), + l.bindTexture(l.TEXTURE_2D, null), + re(Hn.b, Hn.d), + l.drawElements(l.TRIANGLES, 6, l.UNSIGNED_SHORT, 0), + l.useProgram(Hn.c.program), + l.framebufferTexture2D(l.FRAMEBUFFER, l.COLOR_ATTACHMENT0, l.TEXTURE_2D, this.c, 0), + l.bindTexture(l.TEXTURE_2D, this.d), + l.copyTexImage2D(l.TEXTURE_2D, 0, l.RGBA, 0, 0, this.f, this.g, 0), + l.bindTexture(l.TEXTURE_2D, null), + re(Hn.c, Hn.d), + l.drawElements(l.TRIANGLES, 6, l.UNSIGNED_SHORT, 0), + l.useProgram(null); + } + k() { + let t = this.e; + t.bindFramebuffer(t.FRAMEBUFFER, null), t.enable(t.CULL_FACE), t.enable(t.DEPTH_TEST); + } + } + class Xn { + constructor(t, e) { + (this.a = t), (this.b = e); + } + c() { + const t = []; + for (let e of this.b.Options) + for (let i of e.Choices) for (let e of i.Elements) e.SkinnedModel && t.push(e.SkinnedModel.CollectionFileDataID); + const e = new Set(t); + if (0 != e.size) { + e.size > 1 && WH.debug('more than 1 skinned model detected!'); + let i = t[0], + r = { type: hi.PATH, id: i, parent: this.a, shoulder: 0 }; + this.a.aR = new $n(this.a.aS, this.a.k, r, 0, !1, !1, !1); + } + } + d(t) { + return gn.a(this.a, this.b.TextureFiles[t], this.a.o, this.a.p, this.a.n); + } + e(t) { + WH.debug('applyCustomization options', t), (this.a.M = []), this.a.bu(0); + for (let t = 0; t < this.a.K.length; t++) this.a.K[t] = -1; + if (this.a.aR) for (let t = 0; t < this.a.aR.K.length; t++) this.a.aR.K[t] = -1; + for (let e = 0; e < t.length; e++) { + let i = this.b.Options.find((i) => i.Id == t[e].optionId); + if ((WH.debug('option', i), i)) { + let r = i.Choices.find((i) => i.Id == t[e].choiceId); + if ((WH.debug('choice', r), r)) { + let e = r.Elements.filter( + (e) => + e.BoneSet && e.BoneSet.BoneFileDataID && (0 == e.VariationChoiceID || t.some((t) => t.choiceId == e.VariationChoiceID)), + ); + e.length > 0 && this.a.bu(e[0].BoneSet.BoneFileDataID); + let n = r.Elements.filter( + (e) => e.Material && (0 == e.VariationChoiceID || t.some((t) => t.choiceId == e.VariationChoiceID)), + ); + n.sort((t, e) => e.VariationChoiceID - t.VariationChoiceID), + n.forEach((t) => { + WH.debug('element material', t); + let e = this.d(t.Material.MaterialResourcesID); + if (!e) return void WH.debug("element material: can't get texture files for material", t); + let i = this.b.TextureLayers.find((e) => e.ChrModelTextureTargetID == t.Material.TextureTarget); + i + ? 1 == i.TextureType + ? t.Material.TextureTarget == Li + ? (this.a.C[1][0] = this.a.bA(1, e)) + : this.a.D[t.Material.TextureTarget] || (this.a.D[t.Material.TextureTarget] = this.a.bA(i.TextureSection, e)) + : 6 == i.TextureType + ? (this.a.C[6][0] = this.a.bA(6, e)) + : 7 == i.TextureType + ? (this.a.C[7][0] = this.a.bA(7, e)) + : 8 == i.TextureType + ? (this.a.C[8][0] = this.a.bA(8, e)) + : 10 == i.TextureType + ? (this.a.C[10][0] = this.a.bA(10, e)) + : 19 == i.TextureType + ? (this.a.C[19][0] = this.a.bA(19, e)) + : 20 == i.TextureType + ? (this.a.C[20][0] = this.a.bA(20, e)) + : 21 == i.TextureType + ? (this.a.C[21][0] = this.a.bA(21, e)) + : 22 == i.TextureType + ? (this.a.C[22][0] = this.a.bA(22, e)) + : WH.debug('unhandled texture type', i.TextureType, 'target', t.Material.TextureTarget) + : WH.debug("element material: can't get texture layer for material", t); + }), + r.Elements.filter( + (e) => e.Geoset && (0 == e.VariationChoiceID || t.some((t) => t.choiceId == e.VariationChoiceID)), + ).forEach((t) => { + WH.debug('element geoset', t), this.a.bD(t.Geoset); + }), + r.Elements.filter( + (e) => e.SkinnedModel && (0 == e.VariationChoiceID || t.some((t) => t.choiceId == e.VariationChoiceID)), + ).forEach((t) => { + WH.debug('element skinnedmodel', t), this.a.aR && this.a.aR.bD(t.SkinnedModel); + }); + let a = r.Elements.find( + (e) => 0 != e.CondModelFileDataId && (0 == e.VariationChoiceID || t.some((t) => t.choiceId == e.VariationChoiceID)), + ); + if (24 == i.Id || 353 == i.Id) + if (a && !this.a.c) { + WH.debug('element condModel', a); + let e = this.a.aS, + i = this.a.a, + r = e.models.indexOf(this.a); + if (r > -1) { + e.models.splice(r, 1), WH.debug('test 1!', t, e.options, i), (e.options.charCustomization = this.a.q); + let n = new $n(e, e.options, i, r, !0, !1, !1, a.CondModelFileDataId); + return (n.q = this.a.q), e.models.push(n), void this.a.ba(); + } + } else if (!a && this.a.c) { + let e = this.a.aS, + i = this.a.a, + r = e.models.indexOf(this.a); + if (r > -1) { + e.models.splice(r, 1), WH.debug('test 2!', t, e.options, i), (e.options.charCustomization = this.a.q); + let n = new $n(e, e.options, i, r, !0, !1, !1); + return (n.q = this.a.q), e.models.push(n), void this.a.ba(); + } + } + r.Elements.filter( + (e) => e.ChrCustItemGeoModifyID && (0 == e.VariationChoiceID || t.some((t) => t.choiceId == e.VariationChoiceID)), + ).forEach((t) => { + WH.debug('element ChrCustItemGeoModify', t), this.a && this.a.M.push(t.ChrCustItemGeoModifyID); + }); + } + } + } + if (!this.a.C[6][0]) { + let e = this.b.Options.find((t) => t.Id == this.b.HairStyleOptionId); + if (e) { + let i = e.Choices[1]; + if (i) { + let e = i.Elements.filter( + (e) => + e.Material && + e.Material.TextureTarget == Hi && + (0 == e.VariationChoiceID || t.some((t) => t.choiceId == e.VariationChoiceID)), + ); + if (e.length > 0) { + let t = this.d(e[0].Material.MaterialResourcesID); + t && (this.a.C[6][0] = this.a.bA(6, t)); + } + } + } + } + } + f() { + let t = []; + for (let e = 0; e < this.b.Options.length; e++) { + let i = this.b.Options[e]; + if (i) { + let e = i.Choices[0]; + e && t.push({ optionId: i.Id, choiceId: e.Id }); + } + } + this.e(t); + } + g(t) { + let e = { options: t, sheathMain: -1, sheathOff: -1 }; + for (let t of this.b.Options) + e.options.some((e) => e.optionId == t.Id) || e.options.push({ optionId: t.Id, choiceId: t.Choices[0].Id }); + return e; + } + } + const qn = function (t, e) { + const i = Math.abs(t), + r = Math.abs(e); + return Number((i - Math.floor(i / r) * r).toPrecision(8)) * Math.sign(t); + }, + Wn = 44, + Yn = 4400, + Zn = 'DressingRoom', + Jn = 'Stand'; + class Kn { + constructor(t, e, i, r, n, a, s, o) { + (this.e = !1), + (this.r = 0), + (this.s = null), + (this.t = null), + (this.E = []), + (this.M = []), + (this.R = new Ir()), + (this.T = !1), + (this.an = []), + (this.aG = []), + (this.aH = []), + (this.aJ = null), + (this.aQ = !1), + (this.aT = null), + (this.aU = null), + (this.aV = null), + (this.aX = []), + (this.aY = !1); + var l = this; + if ( + ((l.e = n), + (l.aS = t), + (l.a = i), + (l.b = r), + (l.c = o), + (l.d = !1), + (l.f = !0), + (l.g = !0), + (this.h = !1), + (l.ad = a), + (l.k = e), + 'classic' == l.k.gameDataEnv ? ((pi[14] = 14), (pi[15] = 15)) : ((pi[14] = 22), (pi[15] = 22)), + (l.i = null), + (l.l = l.k.mount && l.k.mount.type == hi.NPC && l.k.mount.id == l.a.id), + (l.j = null), + (l.m = l.k.pet && l.k.pet.type == hi.NPC && l.k.pet.id == l.a.id), + l.a.type == hi.CHARACTER && + l.k.mount && + l.k.mount.type == hi.NPC && + l.k.mount.id && + ((l.k.mount.parent = l), (l.i = new Kn(t, e, l.k.mount, 0, !1, !1, !1))), + l.a.type == hi.CHARACTER && + l.k.pet && + l.k.pet.type == hi.NPC && + l.k.pet.id && + ((l.k.pet.parent = l), (l.j = new Kn(t, e, l.k.pet, 0, !1, !1, !1))), + l.k.extraModels && !l.a.parent) + ) { + l.A = []; + const i = l.k.extraModels; + if ($.isArray(i)) + for (let r = 0; r < i.length; ++r) { + const n = { type: hi.PATH, id: i[r][0], parent: l, shoulder: -1 }; + l.A.push(new Kn(t, e, n, 0, !1, !1, !1)); + } + } + (l.n = 0), + (l.o = -1), + (l.p = l.k.cls ? parseInt(l.k.cls) : 0), + (l.u = null), + (l.v = l.a.parent || null), + (l.x = new Map()), + (this.y = [null, null]), + (l.w = !1), + (l.B = {}), + (l.aJ = null), + (l.aK = null), + (l.C = []); + for (let t = 0; t < 25; t++) l.C.push({}); + (l.D = {}), + (l.H = -1), + (l.I = -1), + (l.J = new Array(Wn)), + (l.K = new Array(Wn)), + (l.L = [ + 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, + 1, + ]), + (l.N = null), + (l.O = 0); + for (let t = 0; t < Wn; t++) l.J[t] = 100 * t + l.L[t]; + (l.P = 0), + (l.Q = 0), + (l.R.c = 0), + (l.R.a.a = -1), + (l.S = !1), + (l.U = je()), + (l.V = er(1, 1, 1, 1)), + (l.W = [0.35, 0.35, 0.35, 1]), + (l.X = [1, 1, 1, 1]), + (l.Y = [0.35, 0.35, 0.35, 1]), + (l.Z = ve()), + (l.aa = ve()), + (l.ab = ve()), + Ue(l.Z, [5, -3, 3]), + Ue(l.aa, [5, 5, 5]), + Ue(l.ab, [-5, -5, -5]), + (l.ac = !1), + (l.ae = we(0, 0, 0)), + (l.af = we(0, 0, 0)), + (l.ag = we(0, 0, 0)), + (l.boundsSize = we(0, 0, 0)), + (l.ak = null), + (l.al = null), + (l.an = null), + (l.ao = null), + (l.ap = null), + (l.aq = null), + (l.ar = null), + (l.as = null), + (l.at = null), + (l.au = null), + (l.av = null), + (l.aw = null), + (l.ax = null), + (l.ay = null), + (l.az = null), + (l.aA = null), + (l.aB = null), + (l.aC = null), + (l.aD = null), + (l.aE = null), + (l.aF = null), + (l.aG = null), + (l.aH = null), + (l.aM = je()), + (l.aN = ve()), + (l.aO = ve()), + (l.aP = Qi()), + s || l.bP(); + } + bZ(t) { + if (this[t]) { + for (var e = this[t], i = 0; i < e.length; ++i) e[i] && e[i].destroy && e[i].destroy(), (e[i] = null); + this[t] = null; + } + } + ba() { + var t = this; + if (((this.aQ = !0), (this.d = !1), t.aK && t.aK.d(), t.C)) + for (let e = 0; e < t.C.length; ++e) for (const i in t.C[e]) t.C[e][i].d(); + if (t.B) for (const e in t.B) t.B[e].h(); + if ( + (t.al && (t.al = null), + t.ao && (t.ao = null), + t.aq && (t.aq = null), + t.ar && (t.ar = null), + t.au && (t.au = null), + t.ax && (t.ax = null), + t.az && (t.az = null), + t.aA && (t.aA = null), + t.aC && (t.aC = null), + t.aF && (t.aF = null), + t.av) + ) + for (let e = 0; e < t.av.length; ++e) t.av[e] = null; + (t.av = null), + this.bZ('vertices'), + this.bZ('animations'), + this.bZ('bones'), + this.bZ('meshes'), + this.bZ('texUnits'), + this.bZ('materials'), + this.bZ('textureAnims'), + this.bZ('attachments'), + this.bZ('colors'), + this.bZ('alphas'), + this.bZ('particleEmitters'), + this.bZ('ribbonEmitters'), + this.bZ('skins'), + this.bZ('faces'), + this.bZ('hairs'), + (this.an = null), + t.x && + t.x.forEach((e, i) => { + e.x(), t.x.set(i, null); + }), + t.i && t.i.ba(), + (t.i = null), + t.j && t.j.ba(), + (t.j = null), + t.aR && t.aR.ba(), + (t.aR = null), + (t.a = null), + (t.x = null), + (t.B = null), + (t.C = null), + (t.J = null), + (t.U = null), + (t.W = null), + (t.X = null), + (t.Y = null), + (t.Z = null), + (t.aa = null), + (t.ab = null), + (t.ae = null), + (t.af = null), + (t.ag = null), + (t.boundsSize = null), + (t.aM = null), + (t.aN = null), + (t.aO = null), + (t.aP = null); + } + getNumAnimations() { + const t = this.i ? this.i : this; + return t.an ? t.an.length + 1 : 0; + } + getAnimation(t) { + const e = this.i ? this.i : this; + return e.an && t > -1 && t < e.an.length ? e.an[t].j : t == e.an.length ? Zn : ''; + } + resetAnimation() { + (this.i ? this.i : this).setAnimation(Jn); + } + setAnimPaused(t) { + var e; + (this.S = t), null === (e = this.i) || void 0 === e || e.setAnimPaused(t), this.E.forEach((e) => e.f(t)); + } + setAnimNoSubAnim(t) { + this.T = t; + } + bg(t) { + var e; + null === (e = this.j) || void 0 === e || e.setAnimation(t); + } + setItems(t) { + WH.debug('setItems', t); + const e = []; + for (let i = 0; i < t.length; i++) e.push([t[i].slot, t[i].display, t[i].visual]); + e.forEach((t) => { + const e = [parseInt(t[0]), parseInt(t[1])]; + this.k.items.push(e); + }), + this.bK(e), + (this.w = !0); + } + attachList(t) { + WH.debug('attachList', t); + const e = t.split(','), + i = []; + for (let t = 0; t < e.length; t += 2) i.push([e[t], e[t + 1]]); + i.forEach((t) => { + const e = [parseInt(t[0]), parseInt(t[1])]; + this.k.items.push(e); + }), + this.bK(i), + (this.w = !0); + } + clearSlots(t) { + WH.debug('clearSlots', t); + const e = t.split(','); + for (let t = 0; t < e.length; ++t) { + this.bM(parseInt(e[t])); + const i = []; + this.k.items.forEach((e) => { + 0 != this.k.items[t].indexOf(parseInt(e)) && i.push(e); + }), + (this.k.items = i); + } + this.bJ(), (this.w = !0); + } + setShouldersOverride(t) { + if ((WH.debug('setShouldersOverride', t), !t || 2 != t.length)) return; + for (let t = 0; t < 2; t++) { + const e = this.y[t]; + e && e.x(), (this.y[t] = null); + } + for (let e = 0; e < 2; e++) + if (null != t[e]) { + const i = new _n(this, wi, t[e], this.n, this.o); + let r = 0; + (r = 0 == e ? 1 : 2), i.B(r), (this.y[e] = i); + } + const e = this.x.get(wi); + if (e) { + let t = 3; + for (let e = 0; e < 2; e++) this.y[e] && (t &= ~(1 << e)); + e.B(t); + } + } + setSheath(t, e) { + (this.H = t), (this.I = e), this.bJ(); + } + setAppearance(t) { + var e; + const i = function (t, e) { + t[e].d(), delete t[e]; + }; + if ( + (this.C[1][0] && i(this.C[1], 0), + this.C[6][0] && i(this.C[6], 0), + this.C[8][0] && i(this.C[8], 0), + this.C[19][0] && i(this.C[19], 0), + this.C[19][1] && i(this.C[19], 1), + this.D) + ) + for (const t in this.D) this.D[t].d(), delete this.D[t]; + (this.q = t), + (this.H = t.sheathMain), + (this.I = t.sheathOff), + null === (e = this.F) || void 0 === e || e.e(t.options), + (this.w = !0), + this.bB(), + this.bJ(); + } + setCustomizationsLoadedCallback(t) { + this.G = t; + } + isLoaded() { + return this.i ? this.i.d && this.d : this.d; + } + setParticlesEnabled(t) { + (this.f = t), + this.x.forEach(function (e) { + if (e.i) + for (let i = 0; i < e.i.length; ++i) + if (e.i[i] && (e.i[i].e.setParticlesEnabled(t), e.r[i] && e.r[i].b)) { + const r = e.i[i].e; + for (let n = 0; n < e.r[i].b.length; n++) r.aB && r.aB[n] && e.r[i].b[n] && e.r[i].b[n].e.setParticlesEnabled(t); + } + }); + } + setRibbonsEnabled(t) { + this.g = t; + } + getTexUnits() { + return this.aL; + } + bs(t, e, i, r) { + Ge(this.U, t), Ye(this.U, this.U, e), i && Ze(this.U, this.U, i), r && Ye(this.U, this.U, r); + } + bt(t, e) { + let i = !1; + const r = t == Zn; + r && (t = Jn); + for (let n = 0; n < this.an.length; ++n) { + const a = this.an[n]; + if (a.j && a.j == t && 0 == a.b) { + (i = !0), (e.a.a = n), (e.a.b = a), (e.a.c = 0), (e.b = new Dr()), (e.c = 0), (e.d = r), WH.debug('Set animation to', a.a, a.j); + break; + } + } + t == Jn || i || this.bt(Jn, e); + } + bu(t) { + if (this.r == t) return; + if (this.d) for (let t = 0; t < this.ap.length; t++) this.ap[t].v = null; + if (((this.r = t), t <= 0)) return; + let e = this.k.contentPath + 'bone/' + t + '.bone', + i = this; + $.ajax({ + url: e, + type: 'GET', + dataType: 'binary', + responseType: 'arraybuffer', + processData: !1, + renderer: this.aS, + success: function (t) { + i.bv(t); + }, + error: function (t, e, i) { + console.log(i); + }, + }); + } + bv(t) { + let e = new Rn(t); + e.getInt32(); + for (; e.position < e.buffer.byteLength; ) { + let t = String.fromCharCode(e.getUint8(), e.getUint8(), e.getUint8(), e.getUint8()), + i = e.getUint32(); + if ('BIDA' == t) { + let t = i / 2; + this.s = new Array(t); + for (let i = 0; i < t; i++) this.s[i] = e.getUint16(); + } + if ('BOMT' == t) { + let t = i / 64; + this.t = new Array(t); + for (let i = 0; i < t; i++) { + let t = Xe( + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + e.getFloat(), + ); + this.t[i] = t; + } + } + } + this.d && this.bw(); + } + bw() { + if (!(this.r <= 0) && this.s && this.s.length) for (let t = 0; t < this.s.length; t++) this.ap[this.s[t]].v = this.t[t]; + } + setAnimation(t) { + this.an && + (this.i && (this.i.setAnimation(t), (t = oi[this.i.a.id] ? 'StealthStand' : 'Mount')), + this.bt(t, this.R), + this.x.forEach((e) => { + if (e.i) for (let i = 0; i < e.i.length; i++) e.i[i].e.setAnimation(t); + }), + this.E && this.E.forEach((e) => e.e(t))); + } + by(t) { + let e = this, + i = e.aS.context; + if (!e.ak || !e.al) return; + const r = 10 * e.ak.length; + if ((e.aT || (e.aT = new Float32Array(r)), t)) { + var n = e.aT, + a = e.ak; + for (let t = 0, e = 0; t < r; ++e) + (n[t + 0] = a[e].i[0]), + (n[t + 1] = a[e].i[1]), + (n[t + 2] = a[e].i[2]), + (n[t + 3] = a[e].j[0]), + (n[t + 4] = a[e].j[1]), + (n[t + 5] = a[e].j[2]), + (n[t + 6] = a[e].c), + (n[t + 7] = a[e].d), + (n[t + 8] = a[e].e), + (n[t + 9] = a[e].f), + (t += 10); + } + e.aU + ? (i.bindBuffer(i.ARRAY_BUFFER, e.aU), i.bufferSubData(i.ARRAY_BUFFER, 0, e.aT)) + : ((e.aU = i.createBuffer()), + i.bindBuffer(i.ARRAY_BUFFER, e.aU), + i.bufferData(i.ARRAY_BUFFER, e.aT, i.DYNAMIC_DRAW), + (e.aV = i.createBuffer()), + i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, e.aV), + i.bufferData(i.ELEMENT_ARRAY_BUFFER, new Uint16Array(e.al), i.STATIC_DRAW)); + } + bz() { + let t, + e = this, + i = er(1, 1, 1, 1), + r = e.ae, + n = e.af, + a = e.aN; + if ((Ae(r, 9999, 9999, 999), Ae(n, -9999, -9999, -9999), !e.at)) return qe(e.U), e.v || (e.aS.distance = 1), !1; + for (let a = 0; a < e.at.length; ++a) { + let s = e.at[a]; + if (!s.show) continue; + if ( + ((i[0] = i[1] = i[2] = i[3] = 1), + e.R.a.a > 0 && (s.v && (i = s.v.g(e.R, this.aX)), s.w[0] && (i[3] *= s.w[0].d(e.R, this.aX))), + i[3] < 0.01) + ) + continue; + let o = s.p; + for (let i = 0; i < o.f; ++i) (t = e.ak[e.al[o.e + i]].i), Me(r, r, t), ke(n, n, t); + } + const s = e.aR; + if (s && s.d && s.at && s.at.length > 0) + for (let e = 0; e < s.at.length; ++e) { + let i = s.at[e]; + if (!i.show) continue; + let a = i.p; + for (let e = 0; e < a.f; ++e) (t = s.ak[s.al[a.e + e]].i), Me(r, r, t), ke(n, n, t); + } + e.i && e.i.d && e.i.bz() && (ye(r, Fe(r, e.i.ae, 1.1)), ye(n, Fe(n, e.i.af, 1.1)), (n[2] *= 1.75)), + e.a.type == hi.NPC && (Fe(r, r, e.u.Scale), Fe(n, n, e.u.Scale)), + Ce(e.boundsSize, n, r), + Re(e.ag, r, e.boundsSize, 0.5); + let o, + l, + h = e.boundsSize[2]; + const u = e.u && e.u.Scale ? e.u.Scale : 1; + if ((e.a.type != hi.ITEM ? ((o = e.boundsSize[1]), (l = e.boundsSize[0])) : ((o = e.boundsSize[0]), (l = e.boundsSize[1])), !e.v)) { + const t = e.aS.width / e.aS.height, + i = 2 * Math.tan((e.aS.fov / 2) * 0.0174532925), + r = (1.2 * h) / i, + n = (1.2 * o) / (i * t); + e.aS.distance = Math.max(Math.max(r, n), 2 * l); + } + return ( + qe(e.U), e.a.type != hi.ITEM && Qe(e.U, e.U, Math.PI / 2), Ze(e.U, e.U, Ie(a, e.ag)), Ae(e.aN, u, u, u), Je(e.U, e.U, e.aN), !0 + ); + } + bA(t, e) { + let i = new Nn(); + return e.a > 0 && (i.a = new an(this, t, e.a)), e.b > 0 && (i.b = new an(this, t, e.b)), e.c > 0 && (i.c = new an(this, t, e.c)), i; + } + bB() { + this.aQ || + ((this.a.type != hi.CHARACTER && this.a.type != hi.NPC && this.a.type != hi.HUMANOIDNPC) || this.n < 1 + ? this.bF() + : (this.bH(), this.aK || (this.w = !0))); + } + bC(t) { + t && (this.J[t.geosetType] = 100 * t.geosetType + t.geosetID); + } + bD(t) { + t && (this.K[t.GeosetType] = 100 * t.GeosetType + t.GeosetID); + } + bE(t, e, i) { + if (!this.at || 0 == this.at.length) return !1; + let r; + for (let n = 0; n < this.at.length; ++n) (r = this.at[n]), r.meshId >= t && r.meshId <= e && (r.show = i); + return !0; + } + bF() { + if ((this.bE(0, 0, !0), 0 != this.O && (this.bE(1, 1699, !1), this.N))) + for (let t of this.N) { + let e = 100 * (t.GeosetIndex + 1), + i = e + t.GeosetValue; + this.bE(e, e + 99, !1), this.bE(i, i, !0); + } + } + bG(t, e) { + let i = []; + for (let t = 0; t < this.ap.length; t++) i[this.ap[t].g] = t; + let r = t.ap; + if (r) { + for (let t = 0; t < r.length; t++) { + let e = i[r[t].g]; + if ('number' != typeof e) continue; + let n = r[t].m, + a = this.ap[e].m; + (r[t].s = !0), Ge(n, a); + } + qe(this.aM), t.bs(this.U, this.aM), t.bW(), t.bY(e); + } + } + bH() { + var t = this; + if (!t.at || 0 == t.at.length) return; + for (let e = 0; e < Wn; e++) t.J[e] = 100 * e + t.L[e]; + t.bE(0, Yn, !1), t.bE(0, 0, !0); + for (let e = 0; e < t.K.length; e++) -1 != this.K[e] && (this.J[e] = this.K[e]); + for (let e = 0; e < t.J.length; e++) t.bE(t.J[e], t.J[e], !0); + let e = t.x.get(Ti), + i = t.x.get(yi), + r = t.x.get(Ai), + n = t.x.get(Ei), + a = t.x.get(Ci), + s = t.x.get(Si), + o = t.x.get(Mi), + l = t.x.get(ki), + h = t.x.get(Ui), + u = t.x.get(Ii); + function c(t, e, i) { + if (!t.at) return; + let r = i + 1, + n = e > 0 ? i + e : r, + a = t.at.some((t) => t.meshId == n); + (n = a ? n : r), t.bE(n, n, !0); + } + function f(t, e, i) { + if (!t.at) return; + let r = 100 * i, + n = r + t.L[i] + e; + t.bE(r, r + 99, !1), t.bE(n, n, !0); + } + if ( + (t.x.forEach((t) => { + if (t && t.q) { + let e = t.q; + e.bE(0, Yn, !1), + t.b == Ti + ? (c(e, t.k[0], 2700), c(e, t.k[1], 2100)) + : t.b == wi + ? c(e, t.k[0], 2600) + : t.b == yi + ? (c(e, t.k[0], 800), c(e, t.k[1], 1e3)) + : t.b == Ai || t.b == Bi + ? (c(e, t.k[0], 800), c(e, t.k[1], 1e3), c(e, t.k[2], 1300), c(e, t.k[3], 2200), c(e, t.k[4], 2800)) + : t.b == Ei + ? c(e, t.k[0], 1800) + : t.b == Ci + ? (c(e, t.k[0], 1100), c(e, t.k[1], 900), c(e, t.k[2], 1300)) + : t.b == Si + ? (c(e, t.k[0], 500), c(e, t.k[1], 2e3)) + : t.b == ki + ? (c(e, t.k[0], 400), c(e, t.k[1], 2300)) + : t.b == Ii + ? c(e, t.k[0], 1500) + : t.b == Ui && c(e, t.k[0], 1200); + } + }), + t.x.forEach((t) => { + if (t && t.i) + for (let e of t.i) { + let i = e.e; + t.b == Ti + ? (f(i, t.l[0], 27), f(i, t.l[1], 21)) + : t.b == wi + ? f(i, t.l[0], 26) + : t.b == yi + ? (f(i, t.l[0], 8), f(i, t.l[1], 10)) + : t.b == Ai || t.b == Bi + ? (f(i, t.l[0], 8), f(i, t.l[1], 10), f(i, t.l[2], 13), f(i, t.l[3], 22), f(i, t.l[4], 28)) + : t.b == Ei + ? f(i, t.l[0], 18) + : t.b == Ci + ? (f(i, t.l[0], 11), f(i, t.l[1], 9), f(i, t.l[2], 13)) + : t.b == Si + ? (f(i, t.l[0], 5), f(i, t.l[1], 20)) + : t.b == ki + ? (f(i, t.l[0], 4), f(i, t.l[1], 23)) + : t.b == Ii + ? f(i, t.l[0], 15) + : t.b == Ui && f(i, t.l[0], 12); + } + }), + e) + ) { + const i = t.n, + r = t.o == ui.MALE ? e.v : e.w; + if (r) + for (let e = 0; e < r.length; e++) + if (r[e].RaceId == i) { + const n = r[e].GeosetGroup; + if (i == ci && (1 == n || 2 == n)) continue; + if (n < Wn) + if (0 == n) t.bE(1, 99, !1); + else { + const e = 100 * n; + t.bE(e, e + 99, !1); + } + } + } + let d = 0; + if ((h && (d |= 16), l && l.k && l.k[0])) { + let e = 401 + l.k[0]; + t.bE(401, 499, !1), t.bE(e, e, !0), (l.f += 2); + } else if (r && r.k && r.k[0]) { + let e = 801 + r.k[0]; + t.bE(e, e, !0); + } + if (!(r || n || o) && i && i.k && i.k[0]) { + let e = 801 + i.k[0]; + t.bE(e, e, !0); + } + if (h) 0 == (1048576 & h.h) && (t.bE(2200, 2299, !1), t.bE(2202, 2202, !0)); + else if (r && r.k && r.k[3]) { + let e = 2201 + r.k[3]; + t.bE(2200, 2299, !1), t.bE(e, e, !0); + } + let b = !1; + n && n.k && n.k[0] && (b = 0 != (512 & n.h)); + let g, + _ = !1, + p = !1; + if (r && r.k && r.k[2]) { + (p = !0), t.bE(501, 599, !1), t.bE(902, 999, !1), t.bE(1100, 1199, !1), t.bE(1300, 1399, !1); + let e = 1301 + r.k[2]; + t.bE(e, e, !0); + } else if (a && a.k && a.k[2]) { + (_ = !0), t.bE(501, 599, !1), t.bE(902, 999, !1), t.bE(1100, 1199, !1), t.bE(1300, 1399, !1); + let e = 1301 + a.k[2]; + t.bE(e, e, !0); + } else if (s && s.k && s.k[0]) { + t.bE(501, 599, !1), t.bE(901, 901, !0); + let e = 501 + s.k[0]; + t.bE(e, e, !0); + } else { + let e; + (e = a && a.k && a.k[1] ? 901 + a.k[1] : 901), t.bE(e, e, !0); + } + (g = s && s.k && s.k[1] ? 2e3 + s.k[1] : s && 0 == (1048576 & s.h) ? 2002 : 2001), t.bE(2001, 2099, !1), t.bE(g, g, !0); + let m = !1, + v = p || _; + if (!v && h && h.k && h.k[0]) { + let e; + (m = !1), b ? ((m = !0), (e = 1203)) : ((m = !0), (e = 1201 + h.k[0])), t.bE(e, e, !0); + } else 16 & d && (t.bE(1201, 1201, !0), v || (t.bE(1202, 1202, !0), (m = !0))); + if (!m && !p) + if (r && r.k && r.k[1]) { + let e = 1001 + r.k[1]; + t.bE(e, e, !0); + } else if (i && i.k && i.k[1]) { + let e = 1001 + i.k[1]; + t.bE(e, e, !0); + } + if (!p && a && a.k && a.k[0]) { + let e = a.k[0], + i = 1101 + e; + e > 2 ? (t.bE(1300, 1399, !1), t.bE(i, i, !0)) : m || t.bE(i, i, !0); + } + if (u && u.k && u.k[0]) { + t.bE(1500, 1599, !1); + let e = 1501 + u.k[0]; + if (this.M.length > 0) + for (let t of this.M) { + const i = li[t]; + i && 15 == i.a && i.b == u.k[0] + 1 && (e = 1500 + i.c); + } + t.bE(e, e, !0); + } + if (n && n.k && n.k[0]) { + t.bE(1800, 1899, !1); + let e = 1801 + n.k[0]; + t.bE(e, e, !0); + } + if ((a || p || _ || m || b ? t.bE(1400, 1499, !1) : t.bE(1401, 1401, !0), t.aR)) { + let e = t.aR; + e.bE(0, Yn, !1); + for (let t = 0; t < e.K.length; t++) + if ((e.bE(e.K[t], e.K[t], !0), e.at)) { + let i = e.K[t]; + if (e.at.some((t) => t.meshId == i)) { + let e = 100 * t; + this.bE(e, e + 99, !1); + } + } + } + } + bI() { + var t = this; + let e = !1; + if ( + (t.x.forEach((t) => { + if (t.m || t.n) { + if (t.j) for (let i = 0; i < t.j.length; ++i) t.j[i].texture && !t.j[i].texture.g() && (e = !0); + } else e = !0; + }), + e) + ) + return; + if (!t.C[1][0] || (t.C[1][0] && !t.C[1][0].e())) return; + if (!this.aJ) { + var i = t.C[1][0].a, + r = i.a.width, + n = i.a.height; + this.aJ = new Gn(t.aS.context, r, n); + } + let a = this.aJ; + a.i(); + let s = !0, + o = !0; + (t.n != fi && t.n != di) || (o = !1), + t.x.forEach((t) => { + let e = t.e; + (e != yi && e != Ai && e != Ui) || (s = !1), e == Ci && (o = !1); + }); + let l, + h = Yi; + a.f != a.g && (h = Zi); + let u = this.F.b.TextureLayers, + c = this.F.b.TextureSections, + f = -1; + if (this.n == bi) for (let t of u) 9 == t.BlendMode && 1 == t.TextureType && t.Layer > f && (f = t.Layer); + for (let e of u) { + if (1 != e.TextureType) continue; + if (0 == e.Layer) { + a.j(t.C[1][0], 0, 0, 1, 1, 0, 0, 0); + continue; + } + let i = -1; + e.Layer == f && (i = 0); + let r = this.D[e.ChrModelTextureTargetID]; + if (r) { + if (!r.e()) return void WH.debug('texture target', e.ChrModelTextureTargetID, 'layer', e.Layer, 'not ready!'); + let t = e.TextureSection; + if ((t != Gi && t != Xi) || (s && t == Gi) || (o && t == Xi)) { + let n = 0, + s = 0, + o = 1, + u = 1; + if (-1 != t) + if (c) { + let e = c.find((e) => e.SectionType == t); + (n = e.X), (s = e.Y), (o = e.Width), (u = e.Height); + } else (l = h[t]), (n = l.x), (s = l.y), (o = l.w), (u = l.h); + a.j(r, n, s, o, u, e.BlendMode, e.Layer, i); + } + } + } + let d = []; + t.x.forEach((t) => { + d.push(t); + }), + d.sort(function (t, e) { + return t.f - e.f; + }); + for (let e = 0; e < d.length; ++e) { + let i = d[e]; + if (i.j) + for (let e = 0; e < i.j.length; ++e) { + let r = i.j[e]; + if (r.gender == t.o && r.texture && r.texture.g() && r.region != Wi) { + if (0 != (2 & t.u.RaceFlags) && r.region == qi) continue; + l = h[r.region]; + let e = new Nn(); + (e.a = r.texture), a.j(e, l.x, l.y, l.w, l.h, 0, -1, -1); + } + } + } + a.k(), (t.w = !1); + } + bJ() { + if (!this.d) return; + let t = (-1 == this.I || !this.I) && null != this.x.get(zi), + e = !((-1 != this.H && this.H) || (null == this.x.get(Fi) && null == this.x.get(Pi))); + for (let e of Vi) { + let i = this.ar[e]; + i > 0 && i < this.ap.length && this.ap[i].A(t ? 'HandsClosed' : ''); + } + for (let t of ji) { + let i = this.ar[t]; + i > 0 && i < this.ap.length && this.ap[i].A(e ? 'HandsClosed' : ''); + } + } + bK(t) { + if ($.isArray(t)) for (let e = 0; e < t.length; ++e) this.bL(t[e][0], t[e][1], t[e][2]); + else for (let e in t) this.bL(parseInt(e), t[e]); + this.bJ(); + } + bL(t, e, i) { + let r = new _n(this, t, e, this.n, this.o); + i && r.A(i); + let n = r.e, + a = vi[t]; + this.x.get(n) && 0 != a ? ((r.e = a), this.x.set(a, r)) : this.x.set(n, r); + } + bM(t) { + var e = this.x.get(t); + e || ((t = pi[t]), (e = this.x.get(t))), e && (this.x.delete(t), e.x()); + } + bN(t, e) { + const i = [], + r = { [Ri]: (t) => [0], [Ni]: (t) => (2 == t.c && 18 == t.d ? [1] : null) }; + if (this.aB && this.aC) { + const n = { + 1: (t) => [11], + 3: (t) => [6, 5], + 22: (t) => { + var e; + return (null === (e = r[t.b]) || void 0 === e ? void 0 : e.call(r, t)) || [2]; + }, + 21: (t) => [1], + 17: (t) => [1], + 15: (t) => [2], + 25: (t) => [1], + 13: (t) => [1], + 14: (t) => [0], + 23: (t) => [2], + 6: (t) => [53], + 26: (t) => [1], + 16: (t) => [57], + 27: (t) => [55], + }; + if (n[t]) { + const r = n[t](e); + for (let n = 0; n < r.length; ++n) { + let a = r[n]; + (this.H >= 0 || this.I >= 0 || this.i) && Ki[t] && (a = Ki[t]), + this.H >= 0 && t == Pi && $i[this.H][t] && (a = $i[this.H][t]), + this.I >= 0 && t == zi && $i[this.I][t] && (a = $i[this.I][t]), + e.g == Di && this.I >= 0 && t == zi && $i[this.I][e.b] && (a = $i[this.I][e.b]), + a >= this.aC.length || -1 == this.aC[a] || i.push(this.aC[a]); + } + } + } + return i; + } + bO() { + if (this.at) { + for (let t = 0; t < this.at.length; ++t) this.at[t].K(this); + this.aL = this.at.concat(); + } + this.setAnimation(Jn), + this.by(!0), + this.bz(), + this.bB(), + (this.d = !0), + this.bw(), + this.bJ(), + this.l && this.v.d && this.v.bz(), + this.m && this.v.d && this.v.bz(), + this.v && this.v.d && !this.ad && this.v.bH(); + } + bP() { + this.a && this.a.type && this.a.id && this.bQ(this.a.type, this.a.id); + } + bQ(t, e) { + let i, + r = this; + t == hi.ITEM + ? (i = 'meta/item/') + : t == hi.HELM + ? (i = 'meta/armor/1/') + : t == hi.SHOULDER + ? (i = 'meta/armor/3/') + : t == hi.NPC || t == hi.HUMANOIDNPC + ? (i = 'meta/npc/') + : t == hi.OBJECT + ? (i = 'meta/object/') + : t == hi.CHARACTER + ? (i = 'meta/character/') + : t == hi.ITEMVISUAL && (i = 'meta/itemvisual/'), + i + ? ((i = this.k.contentPath + i + e + '.json'), + (function (t) { + $.getJSON(i) + .done(function (e) { + r.bS(e, t); + }) + .fail(function (t, e, i) { + let r = e + ', ' + i; + console.log('Model:_load Error loading metadata: ' + r); + }); + })(t)) + : t == hi.PATH && + (this.u || (this.u = {}), + (i = this.k.contentPath + 'mo3/' + e + '.mo3'), + $.ajax({ + url: i, + type: 'GET', + dataType: 'binary', + responseType: 'arraybuffer', + processData: !1, + renderer: this.aS, + success: function (t) { + r.bT(t); + }, + error: function (t, e, i) { + console.log(i); + }, + })); + } + bR(t, e, i) { + const r = Ji[e]; + if (r) { + const e = i ? 4 : 0; + return r.slice(2 * t + e, 2 * t + e + 2); + } + } + bS(t, e) { + var i, + r, + n = this; + if ((e || (e = n.a.type), n.u || (n.u = t), e == hi.CHARACTER)) { + let e = this.c ? this.c : t.Model; + (n.n = t.Race), (n.o = t.Gender), n.k.cls && (n.p = parseInt(n.k.cls)); + let a = n.k.contentPath + 'meta/charactercustomization2/' + t.Race + '_' + t.Gender + '.json'; + if ( + ($.getJSON(a, function (t) { + var e, i, r; + if ( + (WH.debug('Got customization data v2', t), + (n.F = new Xn(n, t)), + null === (e = n.G) || void 0 === e || e.call(n, n.F.b), + n.F.c(), + n.q) + ) + n.setAppearance(n.q); + else if ( + n.a.type != hi.CHARACTER && + n.u.Race > 0 && + (null === (r = null === (i = n.u) || void 0 === i ? void 0 : i.Creature) || void 0 === r + ? void 0 + : r.CreatureCustomizations) + ) { + let t = n.F.g(n.u.Creature.CreatureCustomizations); + n.setAppearance(t); + } else n.F.f(); + n.w && n.bB(); + }), + n.u.Creature && n.u.Creature.Texture && (n.aK = this.bA(-1, gn.a(null, n.u.TextureFiles[n.u.Creature.Texture], 3, 0, 0))), + n.bQ(hi.PATH, e), + n.u.Equipment && n.bK(n.u.Equipment), + n.k.items && n.bK(n.k.items), + n.k.shouldersOverride && n.setShouldersOverride(n.k.shouldersOverride), + n.a.type != hi.CHARACTER && n.u.Race > 0) + ) { + if ( + n.F && + (null === (r = null === (i = n.u) || void 0 === i ? void 0 : i.Creature) || void 0 === r ? void 0 : r.CreatureCustomizations) + ) { + let t = n.F.g(n.u.Creature.CreatureCustomizations); + n.q = t; + } + } else n.k.charCustomization && (n.q = n.k.charCustomization); + } else if (e == hi.HELM) { + let e = 1, + i = 0, + r = 1; + if ((n.v && ((e = n.v.n), (i = n.v.o), (r = n.v.p)), t.ComponentModels)) { + let a = t.ComponentModels[0]; + a && + t.ModelFiles && + t.ModelFiles[a] && + (27 == t.Item.InventoryType + ? n.bQ(hi.PATH, t.ModelFiles[a][0].FileDataId) + : (n.v || t.ModelFiles[a].some((t) => t.Race == e) || (e = t.ModelFiles[a][0].Race), + n.bQ(hi.PATH, gn.b(n, t.ModelFiles[a], -1, i, r, e)))); + } + if (t.Textures) for (let e in t.Textures) 0 != t.Textures[e] && (n.B[parseInt(e)] = new an(n, parseInt(e), t.Textures[e])); + } else if (e == hi.SHOULDER) { + let e = 1, + i = 0, + r = 1; + if ((n.v && ((e = n.v.n), (i = n.v.o), (r = n.v.p)), t.ComponentModels)) { + let a = t.ComponentModels[0], + s = t.ComponentModels[1]; + if (1 == n.a.shoulder || (void 0 === n.a.shoulder && a)) { + if ((a && t.ModelFiles[a] && n.bQ(hi.PATH, gn.b(n, t.ModelFiles[a], 0, i, r, e)), t.Textures)) + for (let e in t.Textures) 0 != t.Textures[e] && (n.B[+e] = new an(n, parseInt(e), t.Textures[e])); + } else if ( + (2 == n.a.shoulder || (void 0 === n.a.shoulder && s)) && + (s && t.ModelFiles[s] && n.bQ(hi.PATH, gn.b(n, t.ModelFiles[s], 1, i, r, e)), t.Textures2) + ) + for (let e in t.Textures2) 0 != t.Textures2[e] && (n.B[+e] = new an(n, parseInt(e), t.Textures2[e])); + } + } else if (e == hi.ITEMVISUAL) n.bQ(hi.PATH, t.Equipment[n.b]); + else if (e == hi.ITEM) { + let e = 1, + i = 0, + r = 1; + if ((n.v && ((e = n.v.n), (i = n.v.o), (r = n.v.p)), t.ComponentModels)) { + let a = t.ComponentModels[0]; + a && t.ModelFiles && t.ModelFiles[a] && n.bQ(hi.PATH, gn.b(n, t.ModelFiles[a], -1, i, r, e)); + } + if (t.Textures) for (let e in t.Textures) 0 != t.Textures[e] && (n.B[+e] = new an(n, parseInt(e), t.Textures[e])); + } else { + if ( + (t.stateKit && this.E.push(new dn(this, t.stateKit.effects)), + t.Creature && ((n.N = t.Creature.CreatureGeosetData), (n.O = t.Creature.CreatureGeosetDataID)), + t.Textures) + ) + for (let e in t.Textures) 0 != t.Textures[e] && (n.B[+e] = new an(n, parseInt(e), t.Textures[e])); + else if (t.ComponentTextures && n.v) { + let e = n.v.o; + for (let i in t.ComponentTextures) { + let r = t.TextureFiles[t.ComponentTextures[i]]; + for (let t = 0; t < r.length; t++) { + let a = r[t]; + (a.Gender != e && 3 != a.Gender) || (n.B[+i] = new an(n, parseInt(i), a.FileDataId)); + } + } + } + if (t.Model) n.bQ(hi.PATH, t.Model); + else if (t.Race > 0) { + const e = _i[t.Race] + ui[t.Gender]; + (n.n = t.Race), (n.o = t.Gender), n.bQ(hi.CHARACTER, e); + } + } + } + bT(t) { + if (!t) return void console.error('Bad buffer for DataView'); + let e = this, + i = new Rn(t); + if (604210112 != i.getUint32()) return void console.log('Bad magic value'); + if (i.getUint32() < 2e3) return void console.log('Bad version'); + e.aj = i.getUint32(); + var r = i.getUint32(), + n = i.getUint32(), + a = i.getUint32(), + s = i.getUint32(), + o = i.getUint32(), + l = i.getUint32(), + h = i.getUint32(), + u = i.getUint32(), + c = i.getUint32(), + f = i.getUint32(), + d = i.getUint32(), + b = i.getUint32(), + g = i.getUint32(), + _ = i.getUint32(), + p = i.getUint32(), + m = i.getUint32(), + v = i.getUint32(), + x = i.getUint32(), + T = i.getUint32(), + w = i.getUint32(), + y = i.getUint32(), + A = i.getUint32(), + E = i.getUint32(), + C = i.getUint32(), + S = i.getUint32(), + M = i.getUint32(); + let k = new Uint8Array(t, i.position), + F = null; + try { + F = (0, Zr.inflate)(k); + } catch (t) { + return void console.log('Decompression error: ' + t); + } + if (F.length < M) console.log('Unexpected data size', F.length, M); + else { + (i = new Rn(F.buffer)), (i.position = r); + var R, + D = i.getInt32(); + if (D > 0) { + e.ak = new Array(D); + for (let t = 0; t < D; ++t) e.ak[t] = new ur(i); + } + if (((i.position = n), (R = i.getInt32()) > 0)) { + e.al = new Array(R); + for (let t = 0; t < R; ++t) e.al[t] = i.getUint16(); + } + if (((i.position = a), (R = i.getInt32()) > 0)) { + (e.am = new Array(R)), (e.aX = new Array(R)); + for (let t = 0; t < R; ++t) (e.am[t] = i.getUint32()), (e.aX[t] = 0); + } + i.position = s; + var I = i.getInt32(); + if (I > 0) { + e.an = new Array(I); + for (let t = 0; t < I; ++t) e.an[t] = new cr(i); + } + i.position = o; + var U = i.getInt32(); + if (U > 0) { + e.ao = new Array(U); + for (let t = 0; t < U; ++t) e.ao[t] = i.getInt16(); + } + i.position = l; + var B = i.getInt32(); + if (B > 0) { + e.ap = new Array(B); + for (let t = 0; t < B; ++t) e.ap[t] = new Wr(e, t, i); + this.ai = new Array(B); + for (let t = 0; t < B; t++) { + this.ai[t] = []; + for (let i = 0; i < B; i++) e.ap[i].e == t && this.ai[t].push(i); + } + } + i.position = h; + var P = i.getInt32(); + if (P > 0) { + e.aq = new Array(P); + for (let t = 0; t < P; ++t) e.aq[t] = i.getInt16(); + } + i.position = u; + var z = i.getInt32(); + if (z > 0) { + e.ar = new Array(z); + for (let t = 0; t < z; ++t) e.ar[t] = i.getInt16(); + } + i.position = c; + var O = i.getInt32(); + if (O > 0) { + e.as = new Array(O); + for (let t = 0; t < O; ++t) e.as[t] = new Yr(i); + } + i.position = f; + var N = i.getInt32(); + if (N > 0) { + e.at = new Array(N); + for (let t = 0; t < N; ++t) e.at[t] = new nn(i); + } + i.position = d; + var L = i.getInt32(); + if (L > 0) { + e.au = new Array(L); + for (let t = 0; t < L; ++t) e.au[t] = i.getInt16(); + } + i.position = b; + var H = i.getInt32(); + if (H > 0) { + e.av = new Array(H); + for (let t = 0; t < H; ++t) e.av[t] = new Jr(i); + } + i.position = g; + var V = i.getInt32(); + if (V > 0) { + e.aw = new Array(V); + for (let t = 0; t < V; ++t) e.aw[t] = new sn(e, t, i); + } + i.position = _; + var j = i.getInt32(); + if (j > 0) { + e.ax = new Array(j); + for (let t = 0; t < j; ++t) e.ax[t] = i.getInt16(); + } + i.position = p; + var G = i.getInt32(); + if (G > 0) { + e.ay = new Array(G); + for (let t = 0; t < G; ++t) e.ay[t] = new on(i); + } + i.position = m; + var X = i.getInt32(); + if (X > 0) { + e.az = new Array(X); + for (let t = 0; t < X; ++t) e.az[t] = i.getInt16(); + } + i.position = v; + var q = i.getInt32(); + if (q > 0) { + e.aA = new Array(q); + for (let t = 0; t < q; ++t) e.aA[t] = i.getInt16(); + } + i.position = x; + var W = i.getInt32(); + if (W > 0) { + e.aB = new Array(W); + for (let t = 0; t < W; ++t) e.aB[t] = new ln(i); + } + i.position = T; + var Y = i.getInt32(); + if (Y > 0) { + e.aC = new Array(Y); + for (let t = 0; t < Y; ++t) e.aC[t] = i.getInt16(); + } + i.position = w; + var Z = i.getInt32(); + if (Z > 0) { + e.aD = new Array(Z); + for (let t = 0; t < Z; ++t) e.aD[t] = new hn(i); + } + i.position = y; + var J = i.getInt32(); + if (J > 0) { + e.aE = new Array(J); + for (let t = 0; t < J; ++t) e.aE[t] = new un(i); + } + i.position = A; + var K = i.getInt32(); + if (K > 0) { + e.aF = new Array(K); + for (let t = 0; t < K; ++t) e.aF[t] = i.getInt16(); + } + i.position = E; + var $ = i.getInt32(); + if ($ > 0) { + e.aG = new Array($); + for (let t = 0; t < $; ++t) e.aG[t] = new kn(e, i); + } + i.position = S; + var Q = i.getInt32(); + if (Q > 0 && S > 0) { + e.aI = new Array(Q); + for (let t = 0; t < Q; ++t) e.aI[t] = new Fn(i); + } + i.position = C; + var tt = i.getInt32(); + if (tt > 0) { + e.aH = new Array(tt); + for (let t = 0; t < tt; ++t) e.aH[t] = new zn(e, i); + } + e.bO(); + } + } + bU(t) { + var e = pr(); + if ((mr(e, t), this.aG)) for (var i = 0; i < this.aG.length; i++) this.aG[i].Z(t, e); + if (this.aH) for (i = 0; i < this.aH.length; i++) this.aH[i].an(t); + } + bV(t) { + let e = null; + return this.aC && this.aC.length ? ((e = t < this.aC.length ? this.aB[this.aC[t]] : this.aB[this.aC[0]]), e) : null; + } + bW() { + const t = this; + if (!t.d) return; + t.Q++; + let e = t.aS.time - t.P; + if ((e > 0 && (t.P = t.aS.time), this.e && this.R.a && this.R.a.b)) { + let i = ve(); + const r = [4, 119, 233, 242, 348, 526, 527, 544, 545]; + [5, 143, 234, 524, 525, 540, 541, 556, 557].indexOf(this.R.a.b.a) > -1 + ? (i = we(0, (-5 * e) / 1e3, 0)) + : r.indexOf(this.R.a.b.a) > -1 && (i = we(0, (-3 * e) / 1e3, 0)); + let n = je(); + if ((ti(n, i), this.bU(n), this.i && this.i.bU(n), this.aR && this.aR.bU(n), t.A)) + for (let e = 0; e < t.A.length; e++) this.aR.bU(n); + } + if (!this.S && t.R.a.a > -1) { + let t = e; + for (let e = 0; e < this.aX.length; e++) (this.aX[e] += t), this.am[e] > 0 && (this.aX[e] %= this.am[e]); + this.bX(this.R, t); + } + let i, + r, + n, + a = t.at ? t.at.length : 0; + for (let e = 0; e < a; ++e) + if (((n = t.at[e]), n.show)) { + (i = n.p.f), (r = n.p.e); + for (let e = 0; e < i; ++e) t.ak[t.al[r + e]].k = t.Q; + } + t.aL && + t.aL.sort(function (t, e) { + return t.b != e.b ? t.b - e.b : t.meshId - e.meshId; + }); + let s = t.ap.length, + o = t.aT; + if (t.ap && t.an) { + for (let e = 0; e < s; ++e) t.ap[e].r = !1; + for (let i = 0; i < s; ++i) t.ap[i].C(e); + if (t.ak) { + let e, + i, + r, + n, + a = t.ak.length, + s = t.aO, + l = t.aP; + for (let h = 0; h < a; ++h) { + if (((e = t.ak[h]), e.k != t.Q)) continue; + (n = h * 10), (o[n] = o[n + 1] = o[n + 2] = o[n + 3] = o[n + 4] = o[n + 5] = 0); + for (let a = 0; a < 4; ++a) + (r = e.g[a] / 255), + r > 0 && + ((i = t.ap[e.h[a]]), + Oe(s, e.a, i.m), + lr(l, e.b, i.m), + (o[n + 0] += s[0] * r), + (o[n + 1] += s[1] * r), + (o[n + 2] += s[2] * r), + (o[n + 3] += l[0] * r), + (o[n + 4] += l[1] * r), + (o[n + 5] += l[2] * r)); + (e.i[0] = o[n + 0]), (e.i[1] = o[n + 1]), (e.i[2] = o[n + 2]), (e.j[0] = o[n + 3]), (e.j[1] = o[n + 4]), (e.j[2] = o[n + 5]); + } + t.by(!1), t.ac || ((t.ac = !0), t.bz()); + } + } + if (t.i && t.i.d) { + const e = t.i.aB[t.i.aC[0]], + i = 1 / t.i.u.Scale; + Ae(t.aN, i, i, i), qe(t.aM), Je(t.aM, t.aM, t.aN), t.bs(t.i.U, t.i.ap[e.b].m, e.c, t.aM); + } + if (t.j && t.j.d) { + const e = t.aB[t.aC[19]], + i = t.k.pet.scale || 0.2 / t.j.u.Scale; + Ae(t.aN, i, i, i), qe(t.aM), Je(t.aM, t.aM, t.aN); + const r = xe(e.c); + Ee(r, r, t.k.pet.offset || we(0, -1.25, 0)), t.j.bs(t.U, t.ap[e.b].m, r, t.aM); + } + si[t.a.id] && !t.v && (qe(t.U), Ae(t.aN, 1, 1, -1), Je(t.U, t.U, t.aN)), t.w && t.bI(); + } + bX(t, e) { + if (((t.a.c += e), t.b.a < 0 && !this.T && !t.d)) + if (t.a.b.h > -1) { + let e = 32767 * Math.random(), + i = 0, + r = t.a.a, + n = this.an[r]; + for (i += n.d; i < e && n.h > -1; ) (r = n.h), (n = this.an[r]), (i += n.d); + (t.b.a = r), (t.b.b = this.an[r]), (t.b.c = 0); + } else { + let e = this.an.find((e) => e.a == t.a.b.a && 0 == e.b); + e && ((t.b.a = e.i), (t.b.b = e), (t.b.c = 0)); + } + let i = t.a, + r = t.b, + n = i.b.g - i.c, + a = 0, + s = null; + if ( + (r.a > -1 && ((s = this.an[r.a]), (a = s.e)), a > 0 && n < a ? ((r.c = qn(a - n, s.g)), (t.c = n / a)) : (t.c = 1), i.c >= i.b.g) + ) + if (r.a > -1) { + if (r.a > -1) + for ( + ; + 0 == (32 & this.an[r.a].c) && (64 & this.an[r.a].c) > 0 && ((r.a = this.an[r.a].i), (r.b = this.an[r.a]), !(r.a < 0)); + + ); + (t.a = r), (t.b = new Dr()), (t.c = 1); + } else i.b.g > 0 && (i.c = qn(i.c, i.b.g)); + } + bY(t) { + var e = this; + if ((this.v ? ir(e.V, this.v.V) : (e.V = er(1, 1, 1, 1)), e.i && e.i.bY(t), e.d)) { + if ( + (e.j && e.j.bY(t), + e.bW(), + this.E && this.E.forEach((e) => e.g(t)), + (e.aW = { + uModelMatrix: e.U, + uViewMatrix: e.aS.viewMatrix, + uProjMatrix: e.aS.projMatrix, + uCameraPos: e.aS.eye, + uAmbientColor: e.W, + uDiffuseColor: e.V, + uPrimaryColor: e.X, + uSecondaryColor: e.Y, + uLightDir1: e.Z, + uLightDir2: e.aa, + uLightDir3: e.ab, + }), + e.aU && e.aL) + ) + for (let i = 0; i < e.aL.length; ++i) e.aL[i].show && e.aL[i].N(t); + if (e.aG && e.f) + for (let i = 0; i < e.aG.length; ++i) { + let r = e.aI ? e.aI[i] : null; + e.aG[i].X(e.R, e.aS.delta, r), e.aG[i].Y(t); + } + if (e.aH && e.g) for (let i = 0; i < e.aH.length; ++i) e.aH[i].ar(e.R, e.aS.delta), e.aH[i].av(), e.aH[i].aw(t); + if ( + (e.aR && e.bG(e.aR, t), + e.x.forEach((i, r) => { + if (i) { + if (2 == i.c && 13 == i.d) { + if (i.e == Pi && -1 != e.H) return; + if (i.e == zi && -1 != e.I) return; + } + i.C(t); + } + }), + e.y.forEach((e, i) => { + e && e.i && e.C(t); + }), + e.A) + ) + for (let i = 0; i < e.A.length; i++) + for (let i = 0; i < e.A.length; i++) { + let r = e.A[i]; + if (!r.d) continue; + let n = e.aC[e.k.extraModels[i][1]]; + if (-1 == n) { + console.log('invalid extra model attachment', e.k.extraModels[i][1]); + continue; + } + let a = e.aB[n], + s = e.k.extraModels[i][2]; + Ae(e.aN, s, s, s), + qe(e.aM), + Je(e.aM, e.aM, e.aN), + Ke(e.aM, e.aM, e.k.extraModels[i][3]), + $e(e.aM, e.aM, e.k.extraModels[i][4]), + Qe(e.aM, e.aM, e.k.extraModels[i][5]), + r.bs(e.U, e.ap[a.b].m, a.c, e.aM), + r.bW(), + r.bY(t); + } + e.x.forEach((i, r) => { + i && i.q && e.bG(i.q, t); + }); + } + } + } + const $n = Kn, + Qn = { 2: 'Wowhead', 3: 'LolKing', 6: 'HeroKing', 7: 'DestinyDB' }; + class ta { + constructor(t) { + if (!t.type || !Qn[t.type]) throw 'Viewer error: Bad viewer type given'; + if (!t.container) throw 'Viewer error: Bad container given'; + if (!t.aspect) throw 'Viewer error: Bad aspect ratio given'; + if (!t.contentPath) throw 'Viewer error: No content path given'; + console.log('Creating viewer with options', t), + (this.type = t.type), + (this.container = t.container), + (this.aspect = parseFloat(t.aspect)), + (this.renderer = null), + (this.options = t); + const e = this.container.width(), + i = Math.round(e / this.aspect); + this.init(e, i); + } + destroy() { + this.renderer && this.renderer.destroy(), (this.options = null), (this.container = null); + } + init(t, e) { + if (void 0 !== typeof window.Uint8Array && void 0 !== typeof window.DataView) + try { + const t = document.createElement('canvas'); + if (!(t.getContext('webgl', { alpha: !1 }) || t.getContext('experimental-webgl', { alpha: !1 }))) + return void console.log('viewer init failed'); + } catch (t) { + return void console.log('viewer init failed'); + } + (this.mode = 1), (this.renderer = new ia(this)), this.renderer.resize(t, e), this.renderer.init(); + } + setAdaptiveMode(t) { + this.renderer.setAdaptiveMode(t); + } + setZoom(t) { + this.renderer.zoom.target = t; + } + setOffset(t, e) { + this.renderer.setTranslation(t, e, 0); + } + setFullscreen(t) { + t ? ta.requestFullscreen(this.renderer.canvas[0]) : ta.exitFullscreen(); + } + method(t, e) { + return void 0 === e && (e = []), this.renderer ? this.renderer.method(t, [].concat(e)) : null; + } + option(t, e) { + return void 0 !== e && (this.options[t] = e), this.options[t]; + } + static isFullscreen() { + return !!( + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement + ); + } + static requestFullscreen(t) { + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement || + (t.requestFullscreen + ? t.requestFullscreen() + : t.webkitRequestFullscreen + ? t.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT) + : t.mozRequestFullScreen + ? t.mozRequestFullScreen() + : t.msRequestFullscreen && t.msRequestFullscreen()); + } + static exitFullscreen() { + (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) && + (document.exitFullscreen + ? document.exitFullscreen() + : document.webkitExitFullscreen + ? document.webkitExitFullscreen() + : document.mozCancelFullScreen + ? document.mozCancelFullScreen() + : document.msExitFullscreen && document.msExitFullscreen()); + } + } + const ea = ta; + const ia = class { + constructor(t) { + (this.currFrame = 0), + (this.clearColor = we(0, 0, 0)), + (this.addedCss = !1), + (this.progressShown = !1), + (this.attributeState = new be()), + (this.onContextMenu = function (t) { + return !1; + }); + var e = this; + (e.viewer = t), + (e.options = t.options), + (e.downloads = {}), + (e.context = null), + (e.width = 0), + (e.height = 0), + (e.time = 0), + (e.delta = 0), + (e.models = []), + (e.screenshotDataURL = null), + (e.makeDataURL = !1), + (e.screenshotCallback = null), + (e.azimuth = 1.5 * Math.PI), + (e.zenith = Math.PI / 2), + (e.distance = 15), + (e.fov = 30), + (e.zoom = { + rateStep: 0.1, + rateAccelerationDecay: 0.4, + interpolationRate: 0.3, + range: [0.3, 4], + rateCurrent: 0, + target: 1, + current: 1, + }), + (e.zoom.range = e.zoom.range.map(function (t) { + return Math.log(t) / Math.log(1 + e.zoom.rateStep); + })), + (e.translation = we(0, 0, 0)), + (e.target = we(0, 0, 0)), + (e.eye = we(0, 0, 0)), + (e.up = we(0, 0, 1)), + (e.lookDir = ve()), + (e.fullscreen = !1), + (e.projMatrix = je()), + (e.viewMatrix = je()), + (e.panningMatrix = je()), + (e.viewOffset = ve()), + (e.aniFilterExt = null), + (e.aniFilterMax = 0), + this.addedCss || + ((this.addedCss = !0), + $('head').append('')); + } + updateProgress() { + var t = this, + e = 0, + i = 0; + for (var r in t.downloads) (e += t.downloads[r].total), (i += t.downloads[r].loaded); + if (e <= 0) t.progressShown && (t.progressBg.hide(), t.progressBar.hide(), (t.progressShown = !1)); + else { + t.progressShown || (t.progressBg.show(), t.progressBar.show(), (t.progressShown = !0)); + var n = i / e; + t.progressBar.width(Math.round(t.width * n) + 'px'); + } + } + destroy() { + var t = this; + if ( + ((t.stop = !0), + t.canvas && + (t.canvas.detach(), + t.progressBg.detach(), + t.progressBar.detach(), + t.canvas + .off('mousedown touchstart', t.onMouseDown) + .off('DOMMouseScroll', t.onMouseScroll) + .off('mousewheel', t.onMouseWheel) + .off('dblclick', t.onDoubleClick) + .off('contextmenu', t.onContextMenu), + $(window).off('resize', t.onFullscreen), + $(document).off('mouseup touchend', t.onMouseUp).off('mousemove touchmove', t.onMouseMove), + (t.canvas = t.progressBg = t.progressBar = null)), + t.context) + ) { + var e = t.context; + t.bgTexture && e.deleteTexture(t.bgTexture), + (t.bgTexture = null), + t.program && e.deleteProgram(t.program), + (t.program = null), + t.vb && e.deleteBuffer(t.vb), + t.vs && e.deleteShader(t.vs), + t.fs && e.deleteShader(t.fs), + (t.vb = t.vs = t.fs = null); + } + t.bgImg && (t.bgImg = null); + for (var i = 0; i < t.models.length; ++i) t.models[i].ba(), (t.models[i] = null); + t.models = []; + } + method(t, e) { + if (this.models.length > 0 && this.models[0]) { + const i = this.models[0][t]; + return i ? i.apply(this.models[0], e) : void WH.debug('Unknown viewer method', t, 'args', e); + } + } + getTime() { + return window.performance && window.performance.now ? window.performance.now() : Date.now(); + } + draw(t) { + var e, + i = this, + r = i.context; + (i.delta = 0.001 * (t - i.time)), + (i.time = t), + i.currFrame++, + i.updateCamera(), + r.bindFramebuffer(r.FRAMEBUFFER, null), + r.viewport(0, 0, i.width, i.height), + r.clearColor(this.clearColor[0], this.clearColor[1], this.clearColor[2], 0), + r.clear(r.COLOR_BUFFER_BIT | r.DEPTH_BUFFER_BIT), + i.bgTexture && + i.program && + (r.useProgram(i.program), + r.activeTexture(r.TEXTURE0), + r.bindTexture(r.TEXTURE_2D, i.bgTexture), + r.uniform1i(i.uTexture, 0), + r.bindBuffer(r.ARRAY_BUFFER, i.vb), + r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, null), + r.enableVertexAttribArray(i.aPosition), + r.vertexAttribPointer(i.aPosition, 2, r.FLOAT, !1, 16, 0), + r.enableVertexAttribArray(i.aTexCoord), + r.vertexAttribPointer(i.aTexCoord, 2, r.FLOAT, !1, 16, 8), + r.depthMask(!1), + r.disable(r.CULL_FACE), + r.blendFunc(r.ONE, r.ZERO), + r.drawArrays(r.TRIANGLE_STRIP, 0, 4), + r.blendFunc(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA), + r.enable(r.CULL_FACE), + r.depthMask(!0), + r.disableVertexAttribArray(i.aPosition), + r.disableVertexAttribArray(i.aTexCoord)); + let n = new Array(); + for (e = 0; e < i.models.length; ++e) i.models[e].bY(n); + n.sort((t, e) => { + let i = t.e > 1, + r = e.e > 1; + return i > r + ? 1 + : i < r + ? -1 + : t.m != e.m + ? e.m > t.m + ? -1 + : 1 + : t.n > e.n + ? -1 + : t.n < e.n + ? 1 + : e.o != t.o + ? e.o < t.o + ? 1 + : -1 + : e.e != t.e + ? t.e < e.e + ? -1 + : 1 + : 0; + }), + r.viewport(0, 0, i.width, i.height), + this.attributeState.disableAll(), + n.forEach((t) => { + r.useProgram(t.a.program), + r.bindBuffer(r.ARRAY_BUFFER, t.c), + r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, t.d), + this.attributeState.enable(r, t.a.attributes), + re(t.a, t.b), + t.h ? r.enable(r.CULL_FACE) : r.disable(r.CULL_FACE), + t.i ? r.frontFace(r.CCW) : r.frontFace(r.CW), + this.setBlendMode(r, t.e), + r.depthMask(t.f), + r.drawElements(t.j, t.k, r.UNSIGNED_SHORT, t.l); + }), + this.attributeState.disableAll(); + } + setAdaptiveMode(t) { + (this.addaptiveMode = t), t && $(window).trigger('resize'); + } + setTranslation(t, e, i) { + this.translation = we(t, e, i); + } + setBlendMode(t, e) { + switch ((0 == e ? t.disable(t.BLEND) : (t.enable(t.BLEND), t.blendEquation(t.FUNC_ADD)), e)) { + case 0: + break; + case 1: + t.blendFuncSeparate(t.ONE, t.ZERO, t.ONE, t.ONE); + break; + case 2: + t.blendFuncSeparate(t.SRC_ALPHA, t.ONE_MINUS_SRC_ALPHA, t.ONE, t.ONE); + break; + case 3: + t.blendFuncSeparate(t.SRC_ALPHA, t.ONE, t.ONE, t.ONE); + break; + case 4: + t.blendFuncSeparate(t.DST_COLOR, t.ZERO, t.ONE, t.ONE); + break; + case 5: + t.blendFuncSeparate(t.DST_COLOR, t.SRC_COLOR, t.ONE, t.ONE); + break; + case 6: + t.blendFuncSeparate(t.DST_COLOR, t.ONE, t.ONE, t.ONE); + break; + case 10: + t.blendFunc(t.ONE, t.ONE); + break; + case 7: + t.blendFuncSeparate(t.ONE_MINUS_SRC_ALPHA, t.ONE, t.ONE, t.ONE); + break; + case 8: + t.blendFuncSeparate(t.ONE_MINUS_SRC_ALPHA, t.ZERO, t.ONE, t.ONE); + break; + case 13: + t.blendFuncSeparate(t.ONE, t.ONE_MINUS_SRC_ALPHA, t.ONE, t.ONE); + break; + default: + throw 3735927486; + } + } + updateCamera() { + var t = this; + (t.zoom.target += t.zoom.rateCurrent), + (t.zoom.rateCurrent *= 1 - t.zoom.rateAccelerationDecay), + (t.zoom.target = -Math.max(Math.min(-t.zoom.target, t.zoom.range[1]), t.zoom.range[0])), + (t.zoom.current += (t.zoom.target - t.zoom.current) * t.zoom.interpolationRate); + var e = t.distance * Math.pow(t.zoom.rateStep + 1, -t.zoom.current), + i = t.azimuth, + r = t.zenith; + 1 == t.up[2] + ? ((t.eye[0] = -e * Math.sin(r) * Math.cos(i) + t.target[0]), + (t.eye[1] = -e * Math.sin(r) * Math.sin(i) + t.target[1]), + (t.eye[2] = -e * Math.cos(r) + t.target[2])) + : ((t.eye[0] = -e * Math.sin(r) * Math.cos(i) + t.target[0]), + (t.eye[1] = -e * Math.cos(r) + t.target[1]), + (t.eye[2] = -e * Math.sin(r) * Math.sin(i) + t.target[2])), + Ce(t.lookDir, t.target, t.eye), + Ue(t.lookDir, t.lookDir), + (function (t, e, i, r) { + var n, + a, + s, + o, + l, + h, + u, + c, + f, + d, + b = e[0], + g = e[1], + _ = e[2], + p = r[0], + m = r[1], + v = r[2], + x = i[0], + T = i[1], + w = i[2]; + Math.abs(b - x) < pe && Math.abs(g - T) < pe && Math.abs(_ - w) < pe + ? qe(t) + : ((u = b - x), + (c = g - T), + (f = _ - w), + (n = m * (f *= d = 1 / Math.hypot(u, c, f)) - v * (c *= d)), + (a = v * (u *= d) - p * f), + (s = p * c - m * u), + (d = Math.hypot(n, a, s)) ? ((n *= d = 1 / d), (a *= d), (s *= d)) : ((n = 0), (a = 0), (s = 0)), + (o = c * s - f * a), + (l = f * n - u * s), + (h = u * a - c * n), + (d = Math.hypot(o, l, h)) ? ((o *= d = 1 / d), (l *= d), (h *= d)) : ((o = 0), (l = 0), (h = 0)), + (t[0] = n), + (t[1] = o), + (t[2] = u), + (t[3] = 0), + (t[4] = a), + (t[5] = l), + (t[6] = c), + (t[7] = 0), + (t[8] = s), + (t[9] = h), + (t[10] = f), + (t[11] = 0), + (t[12] = -(n * b + a * g + s * _)), + (t[13] = -(o * b + l * g + h * _)), + (t[14] = -(u * b + c * g + f * _)), + (t[15] = 1)); + })(t.viewMatrix, t.eye, t.target, t.up), + qe(t.panningMatrix), + 1 == t.up[2] ? Ae(t.viewOffset, t.translation[0], -t.translation[1], 0) : Ae(t.viewOffset, t.translation[0], 0, t.translation[1]), + Ze(t.panningMatrix, t.panningMatrix, t.viewOffset), + Ye(t.viewMatrix, t.panningMatrix, t.viewMatrix); + } + init() { + var t, + e = this, + i = e.context; + (this.blackPixelTexture = i.createTexture()), + i.bindTexture(i.TEXTURE_2D, this.blackPixelTexture), + i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, 1, 1, 0, i.RGBA, i.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 1])), + i.bindTexture(i.TEXTURE_2D, null), + ni(e.projMatrix, 0.0174532925 * e.fov, e.viewer.aspect, 0.1, 5e3), + e.updateCamera(), + i.clearColor(this.clearColor[0], this.clearColor[1], this.clearColor[2], 0), + i.enable(i.DEPTH_TEST), + i.depthFunc(i.LEQUAL), + i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA), + i.enable(i.BLEND); + var r = null; + if (2 === e.viewer.type) r = $n; + if ((e.options.models || e.options.items) && r) { + var n = [].concat(e.options.models); + if (n.length > 0) for (t = 0; t < n.length; ++t) e.models.push(new r(e, e.options, n[t], t, !0, !1, !1)); + } + !(function t() { + if (!e.stop) { + window.requestAnimationFrame(t); + var r = e.getTime(); + if (!1 !== e.makeDataURL) { + if (e.canvas[0].toDataURL) { + var n = e.clearColor, + a = e.bgTexture; + e.options.transparent && ((e.bgTexture = null), (e.clearColor = we(0, 0, 0))), e.draw(r); + var s = e.width * e.height * 4, + o = new Uint8Array(s); + i.readPixels(0, 0, e.width, e.height, i.RGBA, i.UNSIGNED_BYTE, o); + let t = null; + e.options.transparent + ? ((e.clearColor = we(1, 1, 1)), + e.draw(r), + (t = new Uint8Array(s)), + i.readPixels(0, 0, e.width, e.height, i.RGBA, i.UNSIGNED_BYTE, t)) + : (t = o); + for (var l = new Uint8Array(s), h = 0, u = e.height - 1; u >= 0; u--) + for (var c = 0; c < e.width; c++) { + var f = 4 * (u * e.width + c), + d = 255 - (t[h + 0] - o[h + 0]), + b = o[h + 0], + g = o[h + 1], + _ = o[h + 2]; + o[h + 3]; + (l[f + 0] = b), (l[f + 1] = g), (l[f + 2] = _), (l[f + 3] = d), (h += 4); + } + var p = document.createElement('canvas'), + m = p.getContext('2d'); + (p.width = e.width), (p.height = e.height); + var v = m.createImageData(e.width, e.height); + v.data.set(l), + m.putImageData(v, 0, 0), + (e.screenshotDataURL = p.toDataURL.apply(p, e.makeDataURL)), + e.screenshotCallback && (e.screenshotCallback(), (e.screenshotCallback = null)), + (e.clearColor = n), + (e.bgTexture = a); + } + e.makeDataURL = !1; + } + e.draw(r); + } + })(); + } + onDoubleClick(t) { + ea.isFullscreen() ? ea.exitFullscreen() : ea.requestFullscreen(this.canvas[0]); + } + onFullscreen(t) { + let e = this; + if (e.viewer.container) + if ((!e.fullscreen && ea.isFullscreen()) || this.addaptiveMode) { + if (((e.restoreWidth = e.width), (e.restoreHeight = e.height), (e.fullscreen = !0), ea.isFullscreen())) { + var i = $(window); + let t = window.screen.width || i.width(), + e = window.screen.height || i.height(); + this.onResize(t, e, t / e); + } else if (this.addaptiveMode) { + var r = e.viewer.container; + this.onResize(r.width(), r.height(), r.width() / r.height()); + } + } else + e.fullscreen && !ea.isFullscreen() && ((e.fullscreen = !1), this.onResize(e.restoreWidth, e.restoreHeight, e.viewer.aspect)); + } + onResize(t, e, i) { + this.resize(t, e), ni(this.projMatrix, 0.0174532925 * this.fov, i, 0.1, 5e3); + } + onMouseDown(t) { + let e = this; + 3 == t.which || t.ctrlKey ? (e.rightMouseDown = !0) : (e.mouseDown = !0), + 'touchstart' == t.type + ? ((e.mouseX = t.originalEvent.touches[0].clientX), (e.mouseY = t.originalEvent.touches[0].clientY)) + : ((e.mouseX = t.clientX), (e.mouseY = t.clientY)), + $('body').addClass('unselectable'); + } + onMouseScroll(t) { + return (this.zoom.rateCurrent += t.originalEvent.detail > 0 ? 1 : -1), t.preventDefault(), !1; + } + onMouseWheel(t) { + if (!this.options.wheelEventValidation || this.options.wheelEventValidation.call(this, t)) + return (this.zoom.rateCurrent += t.originalEvent.wheelDelta > 0 ? 1 : -1), t.preventDefault(), !1; + } + onMouseUp(t) { + let e = this; + (e.mouseDown || e.rightMouseDown) && ($('body').removeClass('unselectable'), (e.mouseDown = !1), (e.rightMouseDown = !1)); + } + onMouseMove(t) { + let e = this; + if ((e.mouseDown || e.rightMouseDown) && void 0 !== e.mouseX) { + var i, r; + 'touchmove' == t.type + ? (t.preventDefault(), (i = t.originalEvent.touches[0].clientX), (r = t.originalEvent.touches[0].clientY)) + : ((i = t.clientX), (r = t.clientY)); + var n = ((i - e.mouseX) / e.width) * Math.PI * 2, + a = ((r - e.mouseY) / e.width) * Math.PI * 2; + if (e.mouseDown) { + 1 == e.up[2] ? (e.azimuth -= n) : (e.azimuth += n), (e.zenith += a); + for (var s = 2 * Math.PI; e.azimuth < 0; ) e.azimuth += s; + for (; e.azimuth > s; ) e.azimuth -= s; + e.zenith < 1e-4 && (e.zenith = 1e-4), e.zenith >= Math.PI && (e.zenith = Math.PI - 1e-4); + } else (e.translation[0] += n), (e.translation[1] += a); + (e.mouseX = i), (e.mouseY = r); + } + } + resize(t, e) { + var i = this; + if (i.width !== t || i.height !== e) { + if ((i.fullscreen || i.viewer.container.css({ height: e + 'px', position: 'relative' }), (i.width = t), (i.height = e), i.canvas)) + i.canvas.attr({ width: t, height: e }), + i.canvas.css({ width: t + 'px', height: e + 'px' }), + i.context.viewport(0, 0, i.width, i.height); + else { + if ( + ((i.canvas = $('')), + i.canvas.attr({ width: t, height: e }), + i.viewer.container.append(i.canvas), + (i.context = + i.canvas[0].getContext('webgl', { alpha: !0, premultipliedAlpha: !1 }) || + i.canvas[0].getContext('experimental-webgl', { alpha: !0, premultipliedAlpha: !1 })), + (i.progressBg = $('
', { + css: { display: 'none', position: 'absolute', bottom: 0, left: 0, right: 0, height: '10px', backgroundColor: '#000' }, + })), + (i.progressBar = $('
', { + css: { display: 'none', position: 'absolute', bottom: 0, left: 0, width: 0, height: '10px', backgroundColor: '#ccc' }, + })), + i.viewer.container.append(i.progressBg), + i.viewer.container.append(i.progressBar), + !i.context) + ) + return alert('No WebGL support, sorry! You should totally use Chrome.'), i.canvas.detach(), void (i.canvas = null); + const r = + i.context.getExtension('EXT_texture_filter_anisotropic') || + i.context.getExtension('MOZ_EXT_texture_filter_anisotropic') || + i.context.getExtension('WEBKIT_EXT_texture_filter_anisotropic'); + r + ? ((i.aniFilterExt = r), + (i.aniFilterMax = i.context.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)), + WH.debug('Texture anisotropy enabled', i.aniFilterMax)) + : WH.debug('Texture anisotropy disabled (not supported)'), + i.canvas + .on('mousedown touchstart', i.onMouseDown.bind(i)) + .on('DOMMouseScroll', i.onMouseScroll.bind(i)) + .on('mousewheel', i.onMouseWheel.bind(i)) + .on('dblclick', i.onDoubleClick.bind(i)) + .on('contextmenu', i.onContextMenu.bind(i)), + $(window).on('resize', i.onFullscreen.bind(i)), + $(document).on('mouseup touchend', i.onMouseUp.bind(i)).on('mousemove touchmove', i.onMouseMove.bind(i)), + i.onFullscreen(null); + } + i.options.background && i.loadBackground(); + } + } + loadBackground() { + var t = this, + e = t.context; + const i = function () { + (t.vb = e.createBuffer()), + e.bindBuffer(e.ARRAY_BUFFER, t.vb), + e.bufferData(e.ARRAY_BUFFER, new Float32Array(16), e.DYNAMIC_DRAW); + var i = t.compileShader( + e.VERTEX_SHADER, + ' attribute vec2 aPosition; attribute vec2 aTexCoord; varying vec2 vTexCoord; void main(void) { vTexCoord = aTexCoord; gl_Position = vec4(aPosition, 0, 1); } ', + ), + r = t.compileShader( + e.FRAGMENT_SHADER, + ' precision mediump float; varying vec2 vTexCoord; uniform sampler2D uTexture; void main(void) { gl_FragColor = texture2D(uTexture, vTexCoord); } ', + ), + n = e.createProgram(); + e.attachShader(n, i), + e.attachShader(n, r), + e.linkProgram(n), + e.getProgramParameter(n, e.LINK_STATUS) + ? ((t.vs = i), + (t.fs = r), + (t.program = n), + (t.uTexture = e.getUniformLocation(n, 'uTexture')), + (t.aPosition = e.getAttribLocation(n, 'aPosition')), + (t.aTexCoord = e.getAttribLocation(n, 'aTexCoord'))) + : console.error('Error linking shaders'); + }, + r = function () { + var i = t.width / t.bgImg.width, + r = t.height / t.bgImg.height; + const n = [-1, -1, 0, r, 1, -1, i, r, -1, 1, 0, 0, 1, 1, i, 0]; + e.bindBuffer(e.ARRAY_BUFFER, t.vb), e.bufferSubData(e.ARRAY_BUFFER, 0, new Float32Array(n)); + }; + t.bgImg + ? t.bgImg.loaded && (t.vb || i(), r()) + : ((t.bgImg = new Image()), + (t.bgImg.crossOrigin = ''), + (t.bgImg.onload = function () { + (t.bgImg.loaded = !0), + (t.bgTexture = e.createTexture()), + e.bindTexture(e.TEXTURE_2D, t.bgTexture), + e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t.bgImg), + e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), + t.vb || i(), + r(); + }), + (t.bgImg.onerror = function () { + t.bgImg = null; + }), + (t.bgImg.src = t.options.contentPath + t.options.background)); + } + compileShader(t, e) { + var i = this.context, + r = i.createShader(t); + if ((i.shaderSource(r, e), i.compileShader(r), !i.getShaderParameter(r, i.COMPILE_STATUS))) + throw 'Shader compile error: ' + i.getShaderInfoLog(r); + return r; + } + }; + let ra = { Types: hi }; + const na = Object.assign(ea, { Tools: _e, WebGL: ia, WEBGL: 1, WOW: 2, FLASH: 2, Wow: ra }); + window.ZamModelViewer = na; + })(); +})();