[
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.yaml",
    "content": "name: Bug Report\ndescription: Report of critical bug such as UX inconsistencies, logical contradictions and functional shortcomings.\nlabels: 'Bug Report'\nbody:\n  - type: dropdown\n    id: bug_type\n    attributes:\n      label: Bug Type\n      description: Select the bug type\n      options:\n        - Functional\n        - UX\n        - UI\n        - Performance\n        - Security\n        - Localization\n        - Other\n    validations:\n      required: true\n  - type: textarea\n    id: reproduction-steps\n    attributes:\n      label: Reproduction steps\n      description: Steps to reproduce a bug (you are welcome to attach screenshots here)\n      placeholder: 1. Click diamond 2. HODL\n    validations:\n      required: true\n  - type: textarea\n    id: actual-result\n    attributes:\n      label: Actual result\n      description: What was seen\n      placeholder: When action is done, something happens\n    validations:\n      required: true\n  - type: textarea\n    id: expected-result\n    attributes:\n      label: Expected result\n      description: What was expected\n      placeholder: When action is done, nothing happens\n    validations:\n      required: true\n  - type: dropdown\n    id: suggested-severity\n    attributes:\n      label: Suggested Severity\n      description: Severity of the bug\n      options:\n        - Vulnerability\n        - Critical\n        - High\n        - Medium\n        - Low\n    validations:\n      required: true\n  # - type: dropdown\n  #   id: browsers\n  #   attributes:\n  #     label: \"Browsers\"\n  #     description: What browsers are you seeing the problem on ?\n  #     multiple: true\n  #     options:\n  #       - Chrome\n  #       - Safari\n  #       - Firefox\n  #       - Microsoft Edge\n  #       - Brave\n  #   validations:\n  #     required: false\n  # - type: dropdown\n  #   id: os\n  #   attributes:\n  #     label: \"OS\"\n  #     description: What is the impacted environment ?\n  #     multiple: true\n  #     options:\n  #       - Windows\n  #       - Linux\n  #       - Mac\n  #   validations:\n  #     required: false\n  - type: textarea\n    id: device\n    attributes:\n      label: Device\n      description: Information about device\n      value: |\n        Desktop (please complete the following information):\n        - OS: [e.g. iOS]\n        - Browser [e.g. chrome, safari]\n        - Version [e.g. 22]\n\n        Smartphone (please complete the following information):\n        - Device: [e.g. iPhone6]\n        - OS: [e.g. iOS8.1]\n        - Browser [e.g. stock browser, safari]\n        - Version [e.g. 22]\n    validations:\n      required: true\n  - type: textarea\n    id: additional-context\n    attributes:\n      label: Additional Context\n      description: Add any other context about the problem here. You can also attach any extra screenshots or screencasts here.\n      placeholder: e.g. device was rooted\n    validations:\n      required: false"
  },
  {
    "path": ".gitignore",
    "content": ".idea\n.vscode\nartifacts\nnode_modules\n.DS_Store\n.env"
  },
  {
    "path": "build/gulp/config.js",
    "content": "/**\n * Path to \".env\" file relative to project root directory\n */\nconst DOTENV_PATH = '.env';\n\n/**\n * Required for any task environment variables (see .env.example file in project root directory)\n * keys   - required environment variable name\n * values - task and target mask kind \"{task_name}.{target_name}\", any part of it or full mask\n *          may be replaced by \"*\" symbol which mean any of task, target or its combination\n */\n const REQUIRED_ENV_VARS = {\n    'TONCENTER_API_KEY_WEB_MAIN': '*',\n    'TONCENTER_API_KEY_WEB_TEST': '*',\n    'TONCENTER_API_KEY_EXT_MAIN': '*',\n    'TONCENTER_API_KEY_EXT_TEST': '*',\n    'MOZILLA_ADDONS_API_KEY': 'publish.firefox',\n    'MOZILLA_ADDONS_API_SECRET': 'publish.firefox',\n    'MOZILLA_EXTENSION_ID': 'publish.firefox'\n};\n\n/**\n * Possible build targets identifiers to names map\n */\nconst TARGETS = {\n    WEB: 'web',\n    CHROMIUM: 'chromium',\n    FIREFOX: 'firefox',\n    SAFARI: 'safari'\n};\n\n/**\n * Possible build destinations identifiers to paths map\n * Different targets can match same destinations, for example,\n * FIREFOX and SAFARI require V2 build destination\n */\nconst BUILD_DESTS = {\n    WEB: 'docs',\n    V3: 'artifacts/v3',\n    V2: 'artifacts/v2'\n};\n\n/**\n * Targets and build destinations conformity\n */\nconst TARGETS_BUILD_DESTS = {\n    [TARGETS.WEB]: BUILD_DESTS.WEB,\n    [TARGETS.CHROMIUM]: BUILD_DESTS.V3,\n    [TARGETS.FIREFOX]: BUILD_DESTS.V2,\n    [TARGETS.SAFARI]: BUILD_DESTS.V2\n};\n\n/**\n * Globs for watch task\n */\nconst WATCH_GLOBS = ['src/**/*'];\n\n/**\n * Port for web wallet start task HTTP server\n */\nconst START_WEB_PORT = 8080;\n\nmodule.exports = {\n    DOTENV_PATH,\n    REQUIRED_ENV_VARS,\n    TARGETS,\n    BUILD_DESTS,\n    TARGETS_BUILD_DESTS,\n    WATCH_GLOBS,\n    START_WEB_PORT\n};\n"
  },
  {
    "path": "build/gulp/copy.js",
    "content": "const { dest, src } = require('gulp');\nconst { BUILD_DESTS } = require('./config');\n\n/**\n * Build destinations and required files conformity\n * keys  - build destination or \"*\" for all\n * value - list of required files globs\n */\nconst BUILD_DESTS_GLOBS = {\n    '*': [\n        'src/assets/fonts/**/*',\n        'src/assets/lottie/**/*',\n        'src/assets/ui/**/*',\n        'src/libs/**/*'\n    ],\n    [BUILD_DESTS.WEB]: [\n        'src/assets/favicon/**/*'\n    ],\n    [BUILD_DESTS.V3]: [\n        'src/assets/extension/**/*',\n        'src/js/extension/**/*',\n        // Favicons need only for Chromium-based browsers (it show favicon as window icon),\n        // if other browser full migrate to manifest v3, need create separate destination\n        // for Chromium with favicons, now v3 used only for Chromium and its ok\n        // to add favicons to v3 destination\n        'src/assets/favicon/favicon.ico',\n        'src/assets/favicon/favicon-32x32.png',\n        'src/assets/favicon/favicon-16x16.png',\n        'src/assets/favicon/192x192.png'\n    ],\n    [BUILD_DESTS.V2]: [\n        'src/assets/extension/**/*',\n        'src/js/extension/**/*'\n    ]\n};\n\nconst copy = buildDest => {\n    return src([...BUILD_DESTS_GLOBS['*'], ...BUILD_DESTS_GLOBS[buildDest]], { base: 'src' })\n        .pipe(dest(buildDest));\n};\n\nmodule.exports = copy;\n"
  },
  {
    "path": "build/gulp/css.js",
    "content": "const { dest, src } = require('gulp');\n\nconst css = buildDest => {\n    return src('src/css/**/*.css').pipe(dest(buildDest));\n};\n\nmodule.exports = css;\n"
  },
  {
    "path": "build/gulp/env.js",
    "content": "const { existsSync, readFileSync } = require('fs');\nconst { DOTENV_PATH, REQUIRED_ENV_VARS } = require('./config');\n\n/**\n * RegExp for matching rows in \".env\" file\n *\n * @example\n * # Comment\n * KEY1 = VALUE1 # Trim spaces around key and value\n * # Replace \"\\n\" combination by newline symbol in value\n * KEY2 = First line\\nSecond line\n * # Newline symbols inside quoted value (by any of ', \" or ` quotes types)\n * KEY3 = \"Multiline\n * quoted\n * value\"\n */\nconst ROW_REGEXP =\n    /^\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*=\\s*(('|\"|`)(?:\\\\\\3|(?!\\3)[\\s\\S])*\\3|[^#\\n]+)?\\s*(?:#.*)?$/gm;\n\n/**\n * Read \".env\" file in project root directory and set parsed rows to environment variables\n */\nconst loadEnvFile = () => {\n    if (!existsSync(DOTENV_PATH)) return;\n\n    const source = readFileSync(DOTENV_PATH, 'utf8').replace(/\\r\\n?/g, '\\n');\n\n    [...source.matchAll(ROW_REGEXP)].forEach(match => {\n        let value = match[2];\n\n        const maybeQuote = value[0];\n        // If value was quoted, replace escaped quotes inside\n        if (maybeQuote === \"'\" || maybeQuote === '\"' || maybeQuote === '`') {\n            value = value.replace(new RegExp('\\\\\\\\' + maybeQuote, 'g'), maybeQuote);\n        }\n\n        // Unquote value\n        value = value.replace(/^(['\"`])([\\s\\S]*)\\1$/g, '$2');\n\n        // Replace \"\\n\" in value by newline symbol\n        value = value.replace(/\\\\n/g, '\\n');\n\n        process.env[match[1]] = value;\n    });\n};\n\n/**\n * Check passed environment variables names exists in shell environment\n *\n * @param {string} taskName\n * @param {string} targetName\n */\nconst checkRequiredEnvVars = (taskName, targetName) => {\n    const requiredEnvVarsNames = [];\n\n    // Filter required environment variables by passed task and target names\n    Object.keys(REQUIRED_ENV_VARS).forEach(envVarName => {\n        let mask = REQUIRED_ENV_VARS[envVarName];\n        if (mask === '*') mask = '*.*';\n\n        const [taskMask, targetMask] = mask.split('.');\n\n        const taskMatch = taskMask === '*' || taskMask === taskName;\n        const targetMatch = targetMask === '*' || targetName === 'all' || targetMask === targetName;\n\n        if (!taskMatch || !targetMatch) return;\n\n        requiredEnvVarsNames.push(envVarName);\n    });\n\n    let haveUnspecifiedEnvVars = false;\n\n    requiredEnvVarsNames.forEach(envVarName => {\n        if (process.env[envVarName]) return;\n\n        console.error(`Specify \"${envVarName}\" environment variable`);\n        haveUnspecifiedEnvVars = true;\n    });\n\n    if (haveUnspecifiedEnvVars) {\n        console.error('See \".env.example\" file in project root directory for more');\n        process.exit(1);\n    }\n};\n\nmodule.exports = {\n    loadEnvFile,\n    checkRequiredEnvVars\n};\n"
  },
  {
    "path": "build/gulp/html.js",
    "content": "const { dest, src } = require('gulp');\nconst replace = require('gulp-replace');\nconst { BUILD_DESTS } = require('./config');\nconst { version } = require('../../package.json');\n\nconst html = buildDest => {\n    let stream = src('src/index.html').pipe(replace('{{VERSION}}', version));\n\n    // For extensions add body class and remove Controller.js including\n    if (buildDest !== BUILD_DESTS.WEB) {\n        stream = stream.pipe(replace('<body>', '<body class=\"plugin\">'))\n                       .pipe(replace(/^.*<script.*src=\".*Controller.js.*\".*$(\\r\\n|\\r|\\n)/gm, ''));\n    }\n\n    return stream.pipe(dest(buildDest));\n};\n\nmodule.exports = html;\n"
  },
  {
    "path": "build/gulp/manifest.js",
    "content": "const { writeFileSync } = require('fs');\nconst { BUILD_DESTS } = require('./config');\nconst { version } = require('../../package.json');\n\nconst matches = [\n    'file://*/*',\n    'http://*/*',\n    'https://*/*'\n];\n\n/**\n * Manifest V2 content\n */\nconst base = {\n    manifest_version: 2,\n    version,\n    name: 'TON Wallet',\n    description: 'Set up your own TON Wallet on The Open Network',\n    icons: {\n      16: 'assets/extension/icon-16.png',\n      19: 'assets/extension/icon-19.png',\n      24: 'assets/extension/icon-24.png',\n      32: 'assets/extension/icon-32.png',\n      38: 'assets/extension/icon-38.png',\n      48: 'assets/extension/icon-48.png',\n      64: 'assets/extension/icon-64.png',\n      96: 'assets/extension/icon-96.png',\n      128: 'assets/extension/icon-128.png',\n      256: 'assets/extension/icon-256.png',\n      512: 'assets/extension/icon-512.png'\n    },\n    permissions: ['webRequest'],\n    browser_action: {\n        default_title: 'TON Wallet'\n    },\n    background: {\n        scripts: ['js/extension/background.js'],\n        persistent: true\n    },\n    content_scripts: [{\n        matches,\n        js: ['js/extension/content.js'],\n        run_at: 'document_start',\n        all_frames: true\n    }],\n    web_accessible_resources: ['js/extension/provider.js'],\n    content_security_policy: \"default-src 'none'; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self' data: https://nft.ton.diamonds/; connect-src https://toncenter.com/api/ https://testnet.toncenter.com/api/ https://stage.toncenter.com/api/ https://stage-testnet.toncenter.com/api/ https://ton.diamonds/api/wallet/diamond_nfts\"\n};\n\nconst manifest = async buildDest => {\n    if (buildDest === BUILD_DESTS.WEB) return;\n\n    const content = JSON.parse(JSON.stringify(base));\n\n    // Changes to manifest V3\n    if (buildDest === BUILD_DESTS.V3) {\n        // Change manifest version\n        content.manifest_version = 3;\n\n        // New storage API permissions\n        content.permissions.push('storage');\n        // Permissions for content script and provider update\n        // content.permissions.push('tabs', 'scripting');\n\n        // Matches for content script and provider update\n        content.host_permissions = matches;\n\n        // Browser action field name change\n        content.action = content.browser_action;\n        delete(content.browser_action);\n\n        // Background script field change\n        const backgroundScript = content.background.scripts[0];\n        content.background = { service_worker: backgroundScript };\n\n        // Web accessible resources field change\n        const webAccessibleResources = content.web_accessible_resources;\n        content.web_accessible_resources = [{\n            resources: webAccessibleResources,\n            matches: matches\n        }];\n\n        // Extension page content security policy field change\n        content.content_security_policy = { extension_pages: content.content_security_policy };\n    }\n\n    writeFileSync(`${buildDest}/manifest.json`, JSON.stringify(content, null, 4));\n};\n\nmodule.exports = manifest;\n"
  },
  {
    "path": "build/gulp/pack.js",
    "content": "const { spawn } = require('child_process');\nconst { dest, src } = require('gulp');\nconst zip = require('gulp-zip');\nconst { TARGETS, TARGETS_BUILD_DESTS } = require('./config');\nconst { version } = require('../../package.json');\n\nconst pack = async targetName => {\n    if (targetName === TARGETS.WEB) {\n        console.log('Pack target \"web\" not available now');\n        return;\n    }\n\n    if (targetName === TARGETS.SAFARI) {\n        if (process.platform !== 'darwin') {\n            console.log('Pack target \"safari\" available only on MacOS');\n            return;\n        }\n\n        return new Promise((resolve, reject) => {\n            const child = spawn(\n                'xcodebuild',\n                [\n                    '-project', 'build/safari/TON Wallet.xcodeproj',\n                    'BUILD_DIR=../../artifacts/safari',\n                    'CONFIGURATION_BUILD_DIR=../../artifacts/safari',\n                    'SYMROOT=../../artifacts/safari'\n                ],\n                { stdio: 'inherit' }\n            );\n\n            child.on('close', code => {\n                if (code === 0) resolve();\n                else reject(new Error(`Child process fail with code ${code}`));\n            });\n        });\n    }\n\n    return src(`${TARGETS_BUILD_DESTS[targetName]}/**/*`)\n        .pipe(zip(`${targetName}-ton-wallet-${version}.zip`))\n        .pipe(dest('artifacts'));\n};\n\nmodule.exports = pack;\n"
  },
  {
    "path": "build/gulp/remove.js",
    "content": "const { existsSync, rmSync, rmdirSync } = require('fs');\n\nconst remove = async buildDest => {\n  if (!existsSync(buildDest)) return;\n\n  // fs.rm api was added in Node.js v14, in v16 recursive fs.rmdir is deprecated\n  (rmSync ? rmSync : rmdirSync)(buildDest, { recursive: true });\n};\n\nmodule.exports = remove;\n"
  },
  {
    "path": "build/gulp/script.js",
    "content": "const { resolve } = require('path');\nconst webpack = require('webpack');\n\nconst script = (buildDest, done) => {\n    webpack({\n        mode: 'none',\n        entry: {\n            Controller: './src/js/Controller.js',\n            View: './src/js/view/View.js'\n        },\n        plugins: [new webpack.DefinePlugin({\n            TONCENTER_API_KEY_WEB_MAIN: `'${process.env.TONCENTER_API_KEY_WEB_MAIN}'`,\n            TONCENTER_API_KEY_WEB_TEST: `'${process.env.TONCENTER_API_KEY_WEB_TEST}'`,\n            TONCENTER_API_KEY_EXT_MAIN: `'${process.env.TONCENTER_API_KEY_EXT_MAIN}'`,\n            TONCENTER_API_KEY_EXT_TEST: `'${process.env.TONCENTER_API_KEY_EXT_TEST}'`\n        })],\n        optimization: {\n            concatenateModules: true,\n            minimize: false\n        },\n        output: {\n            filename: '[name].js',\n            path: resolve(process.cwd(), `./${buildDest}/js`)\n        },\n    }, (err, stats) => {\n        if (err) return done(err);\n        if (stats.hasErrors()) return done(new Error(stats));\n\n        done();\n    });\n};\n\nmodule.exports = script;\n"
  },
  {
    "path": "build/gulp/start.js",
    "content": "const { access, readFile } = require('fs');\nconst { createServer } = require('http');\nconst open = require('open');\nconst { join, normalize, parse } = require('path');\nconst { TARGETS, START_WEB_PORT } = require('./config');\n\nconst cwd = process.cwd();\n\nconst mimeTypes = {\n    '.html': 'text/html',\n    '.js': 'text/javascript',\n    '.css': 'text/css',\n    '.ico': 'image/x-icon',\n    '.png': 'image/png',\n    '.svg': 'image/svg+xml',\n    '.xml': 'text/xml',\n    '.webmanifest': 'application/manifest+json'\n};\n\nconst startServer = (port, basePath) => {\n    const server = createServer();\n\n    server.on('request', (req, res) => {\n        const url = new URL(req.url, 'http://localhost');\n\n        if(url.pathname === '/') url.pathname = '/index.html';\n\n        const path = join(cwd, basePath, normalize(url.pathname).replace(/^(\\.\\.[\\/\\\\])+/, ''));\n\n        access(path, err => {\n            if (err) {\n                res.statusCode = 404;\n                res.end(`File ${path} not found`);\n                return;\n            }\n\n            readFile(path, (err, data) => {\n                if(err){\n                    res.statusCode = 500;\n                    res.end(`Error in reading file ${path}`);\n                    return;\n                }\n\n                res.setHeader(\n                    'Content-type', mimeTypes[parse(path).ext] || 'application/octet-stream'\n                );\n                res.end(data);\n            });\n        });\n    });\n\n    return new Promise((resolve, reject) => {\n        server.on('error', reject);\n        server.listen(port, resolve);\n    });\n};\n\nconst start = async targetName => {\n    if (targetName !== TARGETS.WEB) {\n        console.log(`Start target \"${targetName}\" not available`);\n        return;\n    }\n\n    const port = +process.env.START_WEB_PORT || START_WEB_PORT;\n\n    await startServer(port, 'docs');\n\n    const address = `http://localhost:${port}`;\n    console.log(`App available on ${address}`);\n    await open(address);\n};\n\nmodule.exports = start;\n"
  },
  {
    "path": "build/gulpfile.js",
    "content": "const { series, task, watch } = require('gulp');\nconst { TARGETS, BUILD_DESTS, TARGETS_BUILD_DESTS, WATCH_GLOBS } = require('./gulp/config');\nconst { checkRequiredEnvVars, loadEnvFile } = require('./gulp/env');\nconst copy = require('./gulp/copy');\nconst css = require('./gulp/css');\nconst html = require('./gulp/html');\nconst manifest = require('./gulp/manifest');\nconst pack = require('./gulp/pack');\nconst remove = require('./gulp/remove');\nconst script = require('./gulp/script');\nconst start = require('./gulp/start');\n\nconst taskName = process.argv[2];\nconst targetName = process.argv.pop();\n\nconst targetNames = ['all', ...Object.values(TARGETS)];\nif (!targetName || !targetNames.includes(targetName)) {\n    console.error(`Pass one of possible target names: \"${targetNames.join('\", \"')}\"`);\n    process.exit(1);\n}\n\nloadEnvFile();\ncheckRequiredEnvVars(taskName, targetName);\n\nconst createBuildDestSeries = buildDest => {\n    return series(\n        remove.bind(null, buildDest),\n        copy.bind(null, buildDest),\n        css.bind(null, buildDest),\n        script.bind(null, buildDest),\n        html.bind(null, buildDest),\n        manifest.bind(null, buildDest)\n    );\n};\n\nlet buildTasks;\nlet startTasks;\nlet packTasks;\n\nif (targetName === 'all') {\n    buildTasks = series(\n        ...Object.values(BUILD_DESTS).map(buildDest => createBuildDestSeries(buildDest))\n    );\n    startTasks = series(...Object.values(TARGETS).map(targetName => start.bind(null, targetName)));\n    packTasks = series(...Object.values(TARGETS).map(targetName => pack.bind(null, targetName)));\n} else {\n    buildTasks = createBuildDestSeries(TARGETS_BUILD_DESTS[targetName]);\n    startTasks = start.bind(null, targetName);\n    packTasks = pack.bind(null, targetName);\n}\n\ntask('dev', buildTasks);\n\ntask('watch', watch.bind(null, WATCH_GLOBS, { ignoreInitial: false }, buildTasks));\n\ntask('start', series(buildTasks, startTasks, watch.bind(null, WATCH_GLOBS, buildTasks)));\n\ntask('build', buildTasks);\n\ntask('pack', series(buildTasks, packTasks));\n"
  },
  {
    "path": "build/readme.md",
    "content": "# Source code\n\nWe deliberately use plain js and do not use frameworks, due to the direct access to the user's private keys. We also try to use the minimum number of third party libraries and consciously include them as static files rather than NPM packages to prevent accidental upgrade to a potentially malicious versions.\n\n# Preparation\n\nSet required for build environment variables in shell or `.env` file in project root directory. See `.env.example` with required variables names and their description.\n\nIf need, update `version` field in `package.json` to increase version in output manifest.json files, source files and update anti-cache parameters values.\n\nInstall development dependencies:\n\n```\nnpm install\n```\n\n# Tasks\n\nTo run build task use next template:\n\n```\nnpm run {task} {target}\n```\n\nPossible tasks:\n- `build` - create bundles in targets destination directories\n- `watch` - autorebuild bundles on sources change\n- `start` - open target in web-browser and autorebuild bundles on sources change (only for `web` target to test website wallet local)\n- `pack` - create bundles and prepare it to publuish-ready form\n\nPossible targets and bundle files destinations folder:\n- `web` - docs\n- `chromium` - artifacts/v3\n- `firefox` - artifacts/v2\n- `safari` - artifacts/v2\n- `all` - run all targets\n\nPossible targets for pack task and output files destinations:\n- `chromium` - artifacts/chromium-ton-wallet-{version}.zip\n- `firefox` - artifacts/firefox-ton-wallet-{version}.zip\n- `safari` - build xcode project to ton-wallet/artifacts/safari\n- `all` - run all targets\n\nWhere {version} - value from package.json \"version\" field\n\n# Chromium-based browsers Extension Developer Mode\n\n- Open web browser\n- Go to `chrome://extensions/`\n- Enable \"Developer Mode\" in top right corner\n- Click \"Load unpacked extension\" and specify `artifacts/v3` folder\n\n# Mozilla Firefox Add-on Developer Mode\n\n- Open Mozilla Firefox\n- Go to `about:debugging#/runtime/this-firefox`\n- Click \"Load Temporary Add-on\" and select `artifacts/v2/manifest.json` file\n\n# Safari Extension Developer Mode\n\n- Install Xcode Command Line Tools\n- Open Safari and choose Safari > Preferences\n- Select the Advanced tab, then select the \"Show Develop menu in menu bar\" checkbox\n- Choose Develop > Allow Unsigned Extensions (the Allow Unsigned Extensions setting is reset when a user quits Safari, you must set it again the next time Safari is launched)\n- Pack extension for Safari by command `npm run pack safari`\n- Extension will automatically added to Safari\n\n## Switch between clear console and debug mode\n\n- Support from 1.1.36 version\n- Open menu in right-top corner and select `About` item\n- Click on `Version:` label with Alt key pressed\n"
  },
  {
    "path": "build/safari/TON Wallet/AppDelegate.swift",
    "content": "//\n//  AppDelegate.swift\n//  TON Wallet\n//\n//  Created by Сергей Иваньков on 15.03.2022.\n//\n\nimport Cocoa\n\n@main\nclass AppDelegate: NSObject, NSApplicationDelegate {\n\n    func applicationDidFinishLaunching(_ notification: Notification) {\n        // Override point for customization after application launch.\n    }\n\n    func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {\n        return true\n    }\n\n}\n"
  },
  {
    "path": "build/safari/TON Wallet/Assets.xcassets/AccentColor.colorset/Contents.json",
    "content": "{\n  \"colors\" : [\n    {\n      \"color\" : {\n        \"color-space\" : \"srgb\",\n        \"components\" : {\n          \"alpha\" : \"1.000\",\n          \"blue\" : \"0.799\",\n          \"green\" : \"0.533\",\n          \"red\" : \"0.000\"\n        }\n      },\n      \"idiom\" : \"universal\"\n    }\n  ],\n  \"info\" : {\n    \"author\" : \"xcode\",\n    \"version\" : 1\n  }\n}\n"
  },
  {
    "path": "build/safari/TON Wallet/Assets.xcassets/AppIcon.appiconset/Contents.json",
    "content": "{\n  \"images\" : [\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"1x\",\n      \"size\" : \"16x16\",\n      \"filename\": \"16.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"2x\",\n      \"size\" : \"16x16\",\n      \"filename\": \"32.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"1x\",\n      \"size\" : \"32x32\",\n      \"filename\": \"32.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"2x\",\n      \"size\" : \"32x32\",\n      \"filename\": \"64.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"1x\",\n      \"size\" : \"128x128\",\n      \"filename\": \"128.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"2x\",\n      \"size\" : \"128x128\",\n      \"filename\": \"256.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"1x\",\n      \"size\" : \"256x256\",\n      \"filename\": \"256.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"2x\",\n      \"size\" : \"256x256\",\n      \"filename\": \"512.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"1x\",\n      \"size\" : \"512x512\",\n      \"filename\": \"512.png\"\n    },\n    {\n      \"idiom\" : \"mac\",\n      \"scale\" : \"2x\",\n      \"size\" : \"512x512\",\n      \"filename\": \"1024.png\"\n    }\n  ],\n  \"info\" : {\n    \"author\" : \"xcode\",\n    \"version\" : 1\n  }\n}\n"
  },
  {
    "path": "build/safari/TON Wallet/Assets.xcassets/Contents.json",
    "content": "{\n  \"info\" : {\n    \"author\" : \"xcode\",\n    \"version\" : 1\n  }\n}\n"
  },
  {
    "path": "build/safari/TON Wallet/Base.lproj/Main.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self'\">\n\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">\n\n    <link rel=\"stylesheet\" href=\"../Style.css\">\n    <script src=\"../Script.js\" defer></script>\n</head>\n<body>\n    <img src=\"../Icon.png\" width=\"128\" height=\"128\" alt=\"TON Wallet Icon\">\n    <p class=\"state-unknown\">You can turn on TON Wallet’s extension in Safari Extensions preferences.</p>\n    <p class=\"state-on\">TON Wallet’s extension is currently on. You can turn it off in Safari Extensions preferences.</p>\n    <p class=\"state-off\">TON Wallet’s extension is currently off. You can turn it on in Safari Extensions preferences.</p>\n    <button class=\"open-preferences\">Quit and Open Safari Extensions Preferences…</button>\n</body>\n</html>\n"
  },
  {
    "path": "build/safari/TON Wallet/Base.lproj/Main.storyboard",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB\" version=\"3.0\" toolsVersion=\"19529\" targetRuntime=\"MacOSX.Cocoa\" propertyAccessControl=\"none\" useAutolayout=\"YES\" initialViewController=\"B8D-0N-5wS\">\n    <dependencies>\n        <deployment identifier=\"macosx\"/>\n        <plugIn identifier=\"com.apple.InterfaceBuilder.CocoaPlugin\" version=\"19529\"/>\n        <plugIn identifier=\"com.apple.WebKit2IBPlugin\" version=\"19529\"/>\n        <capability name=\"documents saved in the Xcode 8 format\" minToolsVersion=\"8.0\"/>\n    </dependencies>\n    <scenes>\n        <!--Application-->\n        <scene sceneID=\"JPo-4y-FX3\">\n            <objects>\n                <application id=\"hnw-xV-0zn\" sceneMemberID=\"viewController\">\n                    <menu key=\"mainMenu\" title=\"Main Menu\" systemMenu=\"main\" id=\"AYu-sK-qS6\">\n                        <items>\n                            <menuItem title=\"TON Wallet\" id=\"1Xt-HY-uBw\">\n                                <modifierMask key=\"keyEquivalentModifierMask\"/>\n                                <menu key=\"submenu\" title=\"TON Wallet\" systemMenu=\"apple\" id=\"uQy-DD-JDr\">\n                                    <items>\n                                        <menuItem title=\"About TON Wallet\" id=\"5kV-Vb-QxS\">\n                                            <modifierMask key=\"keyEquivalentModifierMask\"/>\n                                            <connections>\n                                                <action selector=\"orderFrontStandardAboutPanel:\" target=\"Ady-hI-5gd\" id=\"Exp-CZ-Vem\"/>\n                                            </connections>\n                                        </menuItem>\n                                        <menuItem isSeparatorItem=\"YES\" id=\"VOq-y0-SEH\"/>\n                                        <menuItem title=\"Hide TON Wallet\" keyEquivalent=\"h\" id=\"Olw-nP-bQN\">\n                                            <connections>\n                                                <action selector=\"hide:\" target=\"Ady-hI-5gd\" id=\"PnN-Uc-m68\"/>\n                                            </connections>\n                                        </menuItem>\n                                        <menuItem title=\"Hide Others\" keyEquivalent=\"h\" id=\"Vdr-fp-XzO\">\n                                            <modifierMask key=\"keyEquivalentModifierMask\" option=\"YES\" command=\"YES\"/>\n                                            <connections>\n                                                <action selector=\"hideOtherApplications:\" target=\"Ady-hI-5gd\" id=\"VT4-aY-XCT\"/>\n                                            </connections>\n                                        </menuItem>\n                                        <menuItem title=\"Show All\" id=\"Kd2-mp-pUS\">\n                                            <modifierMask key=\"keyEquivalentModifierMask\"/>\n                                            <connections>\n                                                <action selector=\"unhideAllApplications:\" target=\"Ady-hI-5gd\" id=\"Dhg-Le-xox\"/>\n                                            </connections>\n                                        </menuItem>\n                                        <menuItem isSeparatorItem=\"YES\" id=\"kCx-OE-vgT\"/>\n                                        <menuItem title=\"Quit TON Wallet\" keyEquivalent=\"q\" id=\"4sb-4s-VLi\">\n                                            <connections>\n                                                <action selector=\"terminate:\" target=\"Ady-hI-5gd\" id=\"Te7-pn-YzF\"/>\n                                            </connections>\n                                        </menuItem>\n                                    </items>\n                                </menu>\n                            </menuItem>\n                            <menuItem title=\"Help\" id=\"wpr-3q-Mcd\">\n                                <modifierMask key=\"keyEquivalentModifierMask\"/>\n                                <menu key=\"submenu\" title=\"Help\" systemMenu=\"help\" id=\"F2S-fz-NVQ\">\n                                    <items>\n                                        <menuItem title=\"TON Wallet Help\" keyEquivalent=\"?\" id=\"FKE-Sm-Kum\">\n                                            <connections>\n                                                <action selector=\"showHelp:\" target=\"Ady-hI-5gd\" id=\"y7X-2Q-9no\"/>\n                                            </connections>\n                                        </menuItem>\n                                    </items>\n                                </menu>\n                            </menuItem>\n                        </items>\n                    </menu>\n                    <connections>\n                        <outlet property=\"delegate\" destination=\"Voe-Tx-rLC\" id=\"PrD-fu-P6m\"/>\n                    </connections>\n                </application>\n                <customObject id=\"Voe-Tx-rLC\" customClass=\"AppDelegate\" customModule=\"TON_Wallet\" customModuleProvider=\"target\"/>\n                <customObject id=\"YLy-65-1bz\" customClass=\"NSFontManager\"/>\n                <customObject id=\"Ady-hI-5gd\" userLabel=\"First Responder\" customClass=\"NSResponder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"76\" y=\"-134\"/>\n        </scene>\n        <!--Window Controller-->\n        <scene sceneID=\"R2V-B0-nI4\">\n            <objects>\n                <windowController showSeguePresentationStyle=\"single\" id=\"B8D-0N-5wS\" sceneMemberID=\"viewController\">\n                    <window key=\"window\" title=\"TON Wallet\" allowsToolTipsWhenApplicationIsInactive=\"NO\" autorecalculatesKeyViewLoop=\"NO\" restorable=\"NO\" releasedWhenClosed=\"NO\" animationBehavior=\"default\" id=\"IQv-IB-iLA\">\n                        <windowStyleMask key=\"styleMask\" titled=\"YES\" closable=\"YES\"/>\n                        <windowCollectionBehavior key=\"collectionBehavior\" fullScreenNone=\"YES\"/>\n                        <rect key=\"contentRect\" x=\"196\" y=\"240\" width=\"425\" height=\"325\"/>\n                        <rect key=\"screenRect\" x=\"0.0\" y=\"0.0\" width=\"1680\" height=\"1027\"/>\n                        <connections>\n                            <outlet property=\"delegate\" destination=\"B8D-0N-5wS\" id=\"98r-iN-zZc\"/>\n                        </connections>\n                    </window>\n                    <connections>\n                        <segue destination=\"XfG-lQ-9wD\" kind=\"relationship\" relationship=\"window.shadowedContentViewController\" id=\"cq2-FE-JQM\"/>\n                    </connections>\n                </windowController>\n                <customObject id=\"Oky-zY-oP4\" userLabel=\"First Responder\" customClass=\"NSResponder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"75\" y=\"250\"/>\n        </scene>\n        <!--View Controller-->\n        <scene sceneID=\"hIz-AP-VOD\">\n            <objects>\n                <viewController id=\"XfG-lQ-9wD\" customClass=\"ViewController\" customModule=\"TON_Wallet\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <view key=\"view\" id=\"m2S-Jp-Qdl\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"425\" height=\"325\"/>\n                        <autoresizingMask key=\"autoresizingMask\"/>\n                        <subviews>\n                            <wkWebView wantsLayer=\"YES\" fixedFrame=\"YES\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"eOr-cG-IQY\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"425\" height=\"325\"/>\n                                <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                                <wkWebViewConfiguration key=\"configuration\">\n                                    <audiovisualMediaTypes key=\"mediaTypesRequiringUserActionForPlayback\" none=\"YES\"/>\n                                    <wkPreferences key=\"preferences\"/>\n                                </wkWebViewConfiguration>\n                            </wkWebView>\n                        </subviews>\n                    </view>\n                    <connections>\n                        <outlet property=\"webView\" destination=\"eOr-cG-IQY\" id=\"GFe-mU-dBY\"/>\n                    </connections>\n                </viewController>\n                <customObject id=\"rPt-NT-nkU\" userLabel=\"First Responder\" customClass=\"NSResponder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"75\" y=\"655\"/>\n        </scene>\n    </scenes>\n</document>\n"
  },
  {
    "path": "build/safari/TON Wallet/Resources/Script.js",
    "content": "function show(enabled) {\n    if (typeof enabled === \"boolean\") {\n        document.body.classList.toggle(`state-on`, enabled);\n        document.body.classList.toggle(`state-off`, !enabled);\n    } else {\n        document.body.classList.remove(`state-on`);\n        document.body.classList.remove(`state-off`);\n    }\n}\n\nfunction openPreferences() {\n    webkit.messageHandlers.controller.postMessage(\"open-preferences\");\n}\n\ndocument.querySelector(\"button.open-preferences\").addEventListener(\"click\", openPreferences);\n"
  },
  {
    "path": "build/safari/TON Wallet/Resources/Style.css",
    "content": "* {\n    -webkit-user-select: none;\n    -webkit-user-drag: none;\n    cursor: default;\n}\n\n:root {\n    color-scheme: light dark;\n\n    --spacing: 20px;\n}\n\nhtml {\n    height: 100%;\n}\n\nbody {\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    flex-direction: column;\n\n    gap: var(--spacing);\n    margin: 0 calc(var(--spacing) * 2);\n    height: 100%;\n\n    font: -apple-system-short-body;\n    text-align: center;\n}\n\nbody:not(.state-on, .state-off) :is(.state-on, .state-off) {\n    display: none;\n}\n\nbody.state-on :is(.state-off, .state-unknown) {\n    display: none;\n}\n\nbody.state-off :is(.state-on, .state-unknown) {\n    display: none;\n}\n\nbutton {\n    font-size: 1em;\n}\n"
  },
  {
    "path": "build/safari/TON Wallet/TON_Wallet.entitlements",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n    <key>com.apple.security.app-sandbox</key>\n    <true/>\n    <key>com.apple.security.files.user-selected.read-only</key>\n    <true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "build/safari/TON Wallet/ViewController.swift",
    "content": "//\n//  ViewController.swift\n//  TON Wallet\n//\n//  Created by Сергей Иваньков on 15.03.2022.\n//\n\nimport Cocoa\nimport SafariServices\nimport WebKit\n\nlet extensionBundleIdentifier = \"org.ton.wallet.extension\"\n\nclass ViewController: NSViewController, WKNavigationDelegate, WKScriptMessageHandler {\n\n    @IBOutlet var webView: WKWebView!\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        self.webView.navigationDelegate = self\n\n        self.webView.configuration.userContentController.add(self, name: \"controller\")\n\n        self.webView.loadFileURL(Bundle.main.url(forResource: \"Main\", withExtension: \"html\")!, allowingReadAccessTo: Bundle.main.resourceURL!)\n    }\n\n    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {\n        SFSafariExtensionManager.getStateOfSafariExtension(withIdentifier: extensionBundleIdentifier) { (state, error) in\n            guard let state = state, error == nil else {\n                // Insert code to inform the user that something went wrong.\n                return\n            }\n\n            DispatchQueue.main.async {\n                webView.evaluateJavaScript(\"show(\\(state.isEnabled))\")\n            }\n        }\n    }\n\n    func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {\n        if (message.body as! String != \"open-preferences\") {\n            return;\n        }\n\n        SFSafariApplication.showPreferencesForExtension(withIdentifier: extensionBundleIdentifier) { error in\n            DispatchQueue.main.async {\n                NSApplication.shared.terminate(nil)\n            }\n        }\n    }\n\n}\n"
  },
  {
    "path": "build/safari/TON Wallet Extension/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>NSExtension</key>\n\t<dict>\n\t\t<key>NSExtensionPointIdentifier</key>\n\t\t<string>com.apple.Safari.web-extension</string>\n\t\t<key>NSExtensionPrincipalClass</key>\n\t\t<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "build/safari/TON Wallet Extension/SafariWebExtensionHandler.swift",
    "content": "//\n//  SafariWebExtensionHandler.swift\n//  TON Wallet Extension\n//\n//  Created by Сергей Иваньков on 15.03.2022.\n//\n\nimport SafariServices\nimport os.log\n\nlet SFExtensionMessageKey = \"message\"\n\nclass SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {\n\n\tfunc beginRequest(with context: NSExtensionContext) {\n        let item = context.inputItems[0] as! NSExtensionItem\n        let message = item.userInfo?[SFExtensionMessageKey]\n        os_log(.default, \"Received message from browser.runtime.sendNativeMessage: %@\", message as! CVarArg)\n\n        let response = NSExtensionItem()\n        response.userInfo = [ SFExtensionMessageKey: [ \"Response to\": message ] ]\n\n        context.completeRequest(returningItems: [response], completionHandler: nil)\n    }\n    \n}\n"
  },
  {
    "path": "build/safari/TON Wallet Extension/TON_Wallet_Extension.entitlements",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n    <key>com.apple.security.app-sandbox</key>\n    <true/>\n    <key>com.apple.security.files.user-selected.read-only</key>\n    <true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "build/safari/TON Wallet.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 55;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t850824D227E0F882005B1F54 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 850824D127E0F882005B1F54 /* AppDelegate.swift */; };\n\t\t850824D627E0F882005B1F54 /* Main.html in Resources */ = {isa = PBXBuildFile; fileRef = 850824D427E0F882005B1F54 /* Main.html */; };\n\t\t850824D827E0F882005B1F54 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 850824D727E0F882005B1F54 /* Icon.png */; };\n\t\t850824DA27E0F882005B1F54 /* Style.css in Resources */ = {isa = PBXBuildFile; fileRef = 850824D927E0F882005B1F54 /* Style.css */; };\n\t\t850824DC27E0F882005B1F54 /* Script.js in Resources */ = {isa = PBXBuildFile; fileRef = 850824DB27E0F882005B1F54 /* Script.js */; };\n\t\t850824DE27E0F882005B1F54 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 850824DD27E0F882005B1F54 /* ViewController.swift */; };\n\t\t850824E127E0F882005B1F54 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 850824DF27E0F882005B1F54 /* Main.storyboard */; };\n\t\t850824E327E0F885005B1F54 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 850824E227E0F885005B1F54 /* Assets.xcassets */; };\n\t\t850824EB27E0F885005B1F54 /* TON Wallet Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 850824EA27E0F885005B1F54 /* TON Wallet Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };\n\t\t850824F027E0F885005B1F54 /* SafariWebExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 850824EF27E0F885005B1F54 /* SafariWebExtensionHandler.swift */; };\n\t\t858F762C27E794CB0020E363 /* js in Resources */ = {isa = PBXBuildFile; fileRef = 858F762627E794CB0020E363 /* js */; };\n\t\t858F762D27E794CB0020E363 /* main.css in Resources */ = {isa = PBXBuildFile; fileRef = 858F762727E794CB0020E363 /* main.css */; };\n\t\t858F762E27E794CB0020E363 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 858F762827E794CB0020E363 /* index.html */; };\n\t\t858F762F27E794CB0020E363 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 858F762927E794CB0020E363 /* assets */; };\n\t\t858F763027E794CB0020E363 /* libs in Resources */ = {isa = PBXBuildFile; fileRef = 858F762A27E794CB0020E363 /* libs */; };\n\t\t858F763127E794CB0020E363 /* manifest.json in Resources */ = {isa = PBXBuildFile; fileRef = 858F762B27E794CB0020E363 /* manifest.json */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t850824EC27E0F885005B1F54 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 850824C627E0F882005B1F54 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 850824E927E0F885005B1F54;\n\t\t\tremoteInfo = \"TON Wallet Extension\";\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t8508250927E0F885005B1F54 /* Embed App Extensions */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 13;\n\t\t\tfiles = (\n\t\t\t\t850824EB27E0F885005B1F54 /* TON Wallet Extension.appex in Embed App Extensions */,\n\t\t\t);\n\t\t\tname = \"Embed App Extensions\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t850824CE27E0F882005B1F54 /* TON Wallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \"TON Wallet.app\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t850824D127E0F882005B1F54 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = \"<group>\"; };\n\t\t850824D527E0F882005B1F54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = Base; path = ../Base.lproj/Main.html; sourceTree = \"<group>\"; };\n\t\t850824D727E0F882005B1F54 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = \"<group>\"; };\n\t\t850824D927E0F882005B1F54 /* Style.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = Style.css; sourceTree = \"<group>\"; };\n\t\t850824DB27E0F882005B1F54 /* Script.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Script.js; sourceTree = \"<group>\"; };\n\t\t850824DD27E0F882005B1F54 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = \"<group>\"; };\n\t\t850824E027E0F882005B1F54 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = \"<group>\"; };\n\t\t850824E227E0F885005B1F54 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = \"<group>\"; };\n\t\t850824E427E0F885005B1F54 /* TON_Wallet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TON_Wallet.entitlements; sourceTree = \"<group>\"; };\n\t\t850824EA27E0F885005B1F54 /* TON Wallet Extension.appex */ = {isa = PBXFileReference; explicitFileType = \"wrapper.app-extension\"; includeInIndex = 0; path = \"TON Wallet Extension.appex\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t850824EF27E0F885005B1F54 /* SafariWebExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariWebExtensionHandler.swift; sourceTree = \"<group>\"; };\n\t\t8508250227E0F885005B1F54 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t8508250327E0F885005B1F54 /* TON_Wallet_Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TON_Wallet_Extension.entitlements; sourceTree = \"<group>\"; };\n\t\t858F762627E794CB0020E363 /* js */ = {isa = PBXFileReference; lastKnownFileType = folder; name = js; path = ../../../artifacts/v2/js; sourceTree = \"<group>\"; };\n\t\t858F762727E794CB0020E363 /* main.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = main.css; path = ../../../artifacts/v2/main.css; sourceTree = \"<group>\"; };\n\t\t858F762827E794CB0020E363 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = index.html; path = ../../../artifacts/v2/index.html; sourceTree = \"<group>\"; };\n\t\t858F762927E794CB0020E363 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = ../../../artifacts/v2/assets; sourceTree = \"<group>\"; };\n\t\t858F762A27E794CB0020E363 /* libs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = libs; path = ../../../artifacts/v2/libs; sourceTree = \"<group>\"; };\n\t\t858F762B27E794CB0020E363 /* manifest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = manifest.json; path = ../../../artifacts/v2/manifest.json; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t850824CB27E0F882005B1F54 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t850824E727E0F885005B1F54 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t850824C527E0F882005B1F54 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t850824D027E0F882005B1F54 /* TON Wallet */,\n\t\t\t\t850824EE27E0F885005B1F54 /* TON Wallet Extension */,\n\t\t\t\t850824CF27E0F882005B1F54 /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t850824CF27E0F882005B1F54 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t850824CE27E0F882005B1F54 /* TON Wallet.app */,\n\t\t\t\t850824EA27E0F885005B1F54 /* TON Wallet Extension.appex */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t850824D027E0F882005B1F54 /* TON Wallet */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t850824D127E0F882005B1F54 /* AppDelegate.swift */,\n\t\t\t\t850824DD27E0F882005B1F54 /* ViewController.swift */,\n\t\t\t\t850824DF27E0F882005B1F54 /* Main.storyboard */,\n\t\t\t\t850824E227E0F885005B1F54 /* Assets.xcassets */,\n\t\t\t\t850824E427E0F885005B1F54 /* TON_Wallet.entitlements */,\n\t\t\t\t850824D327E0F882005B1F54 /* Resources */,\n\t\t\t);\n\t\t\tpath = \"TON Wallet\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t850824D327E0F882005B1F54 /* Resources */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t850824D427E0F882005B1F54 /* Main.html */,\n\t\t\t\t850824D727E0F882005B1F54 /* Icon.png */,\n\t\t\t\t850824D927E0F882005B1F54 /* Style.css */,\n\t\t\t\t850824DB27E0F882005B1F54 /* Script.js */,\n\t\t\t);\n\t\t\tpath = Resources;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t850824EE27E0F885005B1F54 /* TON Wallet Extension */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t858E09B927E1038E00500609 /* Resources */,\n\t\t\t\t850824EF27E0F885005B1F54 /* SafariWebExtensionHandler.swift */,\n\t\t\t\t8508250227E0F885005B1F54 /* Info.plist */,\n\t\t\t\t8508250327E0F885005B1F54 /* TON_Wallet_Extension.entitlements */,\n\t\t\t);\n\t\t\tpath = \"TON Wallet Extension\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t858E09B927E1038E00500609 /* Resources */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t858F762927E794CB0020E363 /* assets */,\n\t\t\t\t858F762827E794CB0020E363 /* index.html */,\n\t\t\t\t858F762627E794CB0020E363 /* js */,\n\t\t\t\t858F762A27E794CB0020E363 /* libs */,\n\t\t\t\t858F762727E794CB0020E363 /* main.css */,\n\t\t\t\t858F762B27E794CB0020E363 /* manifest.json */,\n\t\t\t);\n\t\t\tname = Resources;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\t850824CD27E0F882005B1F54 /* TON Wallet */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 8508250A27E0F885005B1F54 /* Build configuration list for PBXNativeTarget \"TON Wallet\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t850824CA27E0F882005B1F54 /* Sources */,\n\t\t\t\t850824CB27E0F882005B1F54 /* Frameworks */,\n\t\t\t\t850824CC27E0F882005B1F54 /* Resources */,\n\t\t\t\t8508250927E0F885005B1F54 /* Embed App Extensions */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t850824ED27E0F885005B1F54 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"TON Wallet\";\n\t\t\tproductName = \"TON Wallet\";\n\t\t\tproductReference = 850824CE27E0F882005B1F54 /* TON Wallet.app */;\n\t\t\tproductType = \"com.apple.product-type.application\";\n\t\t};\n\t\t850824E927E0F885005B1F54 /* TON Wallet Extension */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 8508250627E0F885005B1F54 /* Build configuration list for PBXNativeTarget \"TON Wallet Extension\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t850824E627E0F885005B1F54 /* Sources */,\n\t\t\t\t850824E727E0F885005B1F54 /* Frameworks */,\n\t\t\t\t850824E827E0F885005B1F54 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"TON Wallet Extension\";\n\t\t\tproductName = \"TON Wallet Extension\";\n\t\t\tproductReference = 850824EA27E0F885005B1F54 /* TON Wallet Extension.appex */;\n\t\t\tproductType = \"com.apple.product-type.app-extension\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t850824C627E0F882005B1F54 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tBuildIndependentTargetsInParallel = 1;\n\t\t\t\tLastSwiftUpdateCheck = 1320;\n\t\t\t\tLastUpgradeCheck = 1320;\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t850824CD27E0F882005B1F54 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 13.2.1;\n\t\t\t\t\t};\n\t\t\t\t\t850824E927E0F885005B1F54 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 13.2.1;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 850824C927E0F882005B1F54 /* Build configuration list for PBXProject \"TON Wallet\" */;\n\t\t\tcompatibilityVersion = \"Xcode 13.0\";\n\t\t\tdevelopmentRegion = en;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = 850824C527E0F882005B1F54;\n\t\t\tproductRefGroup = 850824CF27E0F882005B1F54 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t850824CD27E0F882005B1F54 /* TON Wallet */,\n\t\t\t\t850824E927E0F885005B1F54 /* TON Wallet Extension */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t850824CC27E0F882005B1F54 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t850824D827E0F882005B1F54 /* Icon.png in Resources */,\n\t\t\t\t850824E127E0F882005B1F54 /* Main.storyboard in Resources */,\n\t\t\t\t850824DC27E0F882005B1F54 /* Script.js in Resources */,\n\t\t\t\t850824D627E0F882005B1F54 /* Main.html in Resources */,\n\t\t\t\t850824E327E0F885005B1F54 /* Assets.xcassets in Resources */,\n\t\t\t\t850824DA27E0F882005B1F54 /* Style.css in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t850824E827E0F885005B1F54 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t858F763027E794CB0020E363 /* libs in Resources */,\n\t\t\t\t858F762E27E794CB0020E363 /* index.html in Resources */,\n\t\t\t\t858F762F27E794CB0020E363 /* assets in Resources */,\n\t\t\t\t858F762D27E794CB0020E363 /* main.css in Resources */,\n\t\t\t\t858F763127E794CB0020E363 /* manifest.json in Resources */,\n\t\t\t\t858F762C27E794CB0020E363 /* js in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t850824CA27E0F882005B1F54 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t850824DE27E0F882005B1F54 /* ViewController.swift in Sources */,\n\t\t\t\t850824D227E0F882005B1F54 /* AppDelegate.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t850824E627E0F885005B1F54 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t850824F027E0F885005B1F54 /* SafariWebExtensionHandler.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t850824ED27E0F885005B1F54 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 850824E927E0F885005B1F54 /* TON Wallet Extension */;\n\t\t\ttargetProxy = 850824EC27E0F885005B1F54 /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin PBXVariantGroup section */\n\t\t850824D427E0F882005B1F54 /* Main.html */ = {\n\t\t\tisa = PBXVariantGroup;\n\t\t\tchildren = (\n\t\t\t\t850824D527E0F882005B1F54 /* Base */,\n\t\t\t);\n\t\t\tname = Main.html;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t850824DF27E0F882005B1F54 /* Main.storyboard */ = {\n\t\t\tisa = PBXVariantGroup;\n\t\t\tchildren = (\n\t\t\t\t850824E027E0F882005B1F54 /* Base */,\n\t\t\t);\n\t\t\tname = Main.storyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXVariantGroup section */\n\n/* Begin XCBuildConfiguration section */\n\t\t8508250427E0F885005B1F54 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++17\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 12.1;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t8508250527E0F885005B1F54 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++17\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 12.1;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tSWIFT_COMPILATION_MODE = wholemodule;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-O\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t8508250727E0F885005B1F54 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_ENTITLEMENTS = \"TON Wallet Extension/TON_Wallet_Extension.entitlements\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1;\n\t\t\t\tENABLE_HARDENED_RUNTIME = YES;\n\t\t\t\tGENERATE_INFOPLIST_FILE = YES;\n\t\t\t\tINFOPLIST_FILE = \"TON Wallet Extension/Info.plist\";\n\t\t\t\tINFOPLIST_KEY_CFBundleDisplayName = \"TON Wallet\";\n\t\t\t\tINFOPLIST_KEY_NSHumanReadableCopyright = \"\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/../Frameworks\",\n\t\t\t\t\t\"@executable_path/../../../../Frameworks\",\n\t\t\t\t);\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.14;\n\t\t\t\tMARKETING_VERSION = 1.1.35;\n\t\t\t\tOTHER_LDFLAGS = (\n\t\t\t\t\t\"-framework\",\n\t\t\t\t\tSafariServices,\n\t\t\t\t);\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = org.ton.wallet.extension;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_EMIT_LOC_STRINGS = YES;\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t8508250827E0F885005B1F54 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_ENTITLEMENTS = \"TON Wallet Extension/TON_Wallet_Extension.entitlements\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1;\n\t\t\t\tENABLE_HARDENED_RUNTIME = YES;\n\t\t\t\tGENERATE_INFOPLIST_FILE = YES;\n\t\t\t\tINFOPLIST_FILE = \"TON Wallet Extension/Info.plist\";\n\t\t\t\tINFOPLIST_KEY_CFBundleDisplayName = \"TON Wallet\";\n\t\t\t\tINFOPLIST_KEY_NSHumanReadableCopyright = \"\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/../Frameworks\",\n\t\t\t\t\t\"@executable_path/../../../../Frameworks\",\n\t\t\t\t);\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.14;\n\t\t\t\tMARKETING_VERSION = 1.1.35;\n\t\t\t\tOTHER_LDFLAGS = (\n\t\t\t\t\t\"-framework\",\n\t\t\t\t\tSafariServices,\n\t\t\t\t);\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = org.ton.wallet.extension;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_EMIT_LOC_STRINGS = YES;\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t8508250B27E0F885005B1F54 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;\n\t\t\t\tCODE_SIGN_ENTITLEMENTS = \"TON Wallet/TON Wallet.entitlements\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1;\n\t\t\t\tENABLE_HARDENED_RUNTIME = YES;\n\t\t\t\tGENERATE_INFOPLIST_FILE = YES;\n\t\t\t\tINFOPLIST_KEY_CFBundleDisplayName = \"TON Wallet\";\n\t\t\t\tINFOPLIST_KEY_NSHumanReadableCopyright = \"\";\n\t\t\t\tINFOPLIST_KEY_NSMainStoryboardFile = Main;\n\t\t\t\tINFOPLIST_KEY_NSPrincipalClass = NSApplication;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/../Frameworks\",\n\t\t\t\t);\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.14;\n\t\t\t\tMARKETING_VERSION = 1.1.35;\n\t\t\t\tOTHER_LDFLAGS = (\n\t\t\t\t\t\"-framework\",\n\t\t\t\t\tSafariServices,\n\t\t\t\t\t\"-framework\",\n\t\t\t\t\tWebKit,\n\t\t\t\t);\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = org.ton.wallet;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_EMIT_LOC_STRINGS = YES;\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t8508250C27E0F885005B1F54 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;\n\t\t\t\tCODE_SIGN_ENTITLEMENTS = \"TON Wallet/TON Wallet.entitlements\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1;\n\t\t\t\tENABLE_HARDENED_RUNTIME = YES;\n\t\t\t\tGENERATE_INFOPLIST_FILE = YES;\n\t\t\t\tINFOPLIST_KEY_CFBundleDisplayName = \"TON Wallet\";\n\t\t\t\tINFOPLIST_KEY_NSHumanReadableCopyright = \"\";\n\t\t\t\tINFOPLIST_KEY_NSMainStoryboardFile = Main;\n\t\t\t\tINFOPLIST_KEY_NSPrincipalClass = NSApplication;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/../Frameworks\",\n\t\t\t\t);\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.14;\n\t\t\t\tMARKETING_VERSION = 1.1.35;\n\t\t\t\tOTHER_LDFLAGS = (\n\t\t\t\t\t\"-framework\",\n\t\t\t\t\tSafariServices,\n\t\t\t\t\t\"-framework\",\n\t\t\t\t\tWebKit,\n\t\t\t\t);\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = org.ton.wallet;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_EMIT_LOC_STRINGS = YES;\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t850824C927E0F882005B1F54 /* Build configuration list for PBXProject \"TON Wallet\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t8508250427E0F885005B1F54 /* Debug */,\n\t\t\t\t8508250527E0F885005B1F54 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t8508250627E0F885005B1F54 /* Build configuration list for PBXNativeTarget \"TON Wallet Extension\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t8508250727E0F885005B1F54 /* Debug */,\n\t\t\t\t8508250827E0F885005B1F54 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t8508250A27E0F885005B1F54 /* Build configuration list for PBXNativeTarget \"TON Wallet\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t8508250B27E0F885005B1F54 /* Debug */,\n\t\t\t\t8508250C27E0F885005B1F54 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 850824C627E0F882005B1F54 /* Project object */;\n}\n"
  },
  {
    "path": "build/safari/TON Wallet.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:\">\n   </FileRef>\n</Workspace>\n"
  },
  {
    "path": "build/safari/TON Wallet.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDEDidComputeMac32BitWarning</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "build/safari/TON Wallet.xcodeproj/xcuserdata/sergei.xcuserdatad/xcschemes/xcschememanagement.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>SchemeUserState</key>\n\t<dict>\n\t\t<key>TON Wallet.xcscheme_^#shared#^_</key>\n\t\t<dict>\n\t\t\t<key>orderHint</key>\n\t\t\t<integer>0</integer>\n\t\t</dict>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "docs/assets/favicon/browserconfig.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<browserconfig>\n    <msapplication>\n        <tile>\n            <square70x70logo src=\"assets/favicon/mstile-70x70.png\"/>\n            <square150x150logo src=\"assets/favicon/mstile-150x150.png\"/>\n            <square310x310logo src=\"assets/favicon/mstile-310x310.png\"/>\n            <wide310x150logo src=\"assets/favicon/mstile-310x150.png\"/>\n            <TileColor>#ffffff</TileColor>\n        </tile>\n    </msapplication>\n</browserconfig>\n"
  },
  {
    "path": "docs/assets/favicon/site.webmanifest",
    "content": "{\n    \"name\": \"TON Wallet\",\n    \"short_name\": \"TON Wallet\",\n    \"icons\": [\n        {\n            \"src\": \"36x36.png\",\n            \"sizes\": \"36x36\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"48x48.png\",\n            \"sizes\": \"48x48\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"72x72.png\",\n            \"sizes\": \"72x72\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"96x96.png\",\n            \"sizes\": \"96x96\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"144x144.png\",\n            \"sizes\": \"144x144\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"192x192.png\",\n            \"sizes\": \"192x192\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"256x256.png\",\n            \"sizes\": \"256x256\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"384x384.png\",\n            \"sizes\": \"384x384\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"512x512.png\",\n            \"sizes\": \"512x512\",\n            \"type\": \"image/png\"\n        }\n    ],\n    \"theme_color\": \"#ffffff\",\n    \"background_color\": \"#ffffff\",\n    \"display\": \"standalone\"\n}\n"
  },
  {
    "path": "docs/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\" translate=\"no\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta http-equiv=\"Content-Security-Policy\"\n          content=\"default-src 'none'; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self' data: https://nft.ton.diamonds/; manifest-src 'self'; connect-src 'self' https://toncenter.com/api/ https://testnet.toncenter.com/api/ https://stage.toncenter.com/api/ https://stage-testnet.toncenter.com/api/ https://ton.diamonds/api/wallet/diamond_nfts\">\n    <meta name=\"viewport\"\n          content=\"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover\">\n\n    <title>TON Wallet</title>\n\n    <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n    <meta name=\"format-detection\" content=\"telephone=no\">\n    <meta name=\"google\" content=\"notranslate\">\n\n    <meta name=\"description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta name=\"image\" content=\"assets/favicon/512x512.png\">\n\n    <meta itemprop=\"name\" content=\"TON Wallet\">\n    <meta itemprop=\"description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta itemprop=\"image\" content=\"assets/favicon/512x512.png\">\n    <meta name=\"twitter:card\" content=\"summary\">\n    <meta name=\"twitter:title\" content=\"TON Wallet\">\n    <meta name=\"twitter:description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta name=\"og:title\" content=\"TON Wallet\">\n    <meta name=\"og:description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta name=\"og:type\" content=\"website\">\n\n    <link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"assets/favicon/apple-touch-icon.png\">\n    <link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"assets/favicon/favicon-32x32.png\">\n    <link rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"assets/favicon/192x192.png\">\n    <link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"assets/favicon/favicon-16x16.png\">\n    <link rel=\"manifest\" href=\"assets/favicon/site.webmanifest\">\n    <link rel=\"mask-icon\" href=\"assets/favicon/safari-pinned-tab.svg\" color=\"#0088cc\">\n    <link rel=\"shortcut icon\" href=\"assets/favicon/favicon.ico\">\n    <meta name=\"apple-mobile-web-app-title\" content=\"TON Wallet\">\n    <meta name=\"application-name\" content=\"TON Wallet\">\n    <meta name=\"msapplication-TileColor\" content=\"#ffffff\">\n    <meta name=\"msapplication-TileImage\" content=\"assets/favicon/mstile-144x144.png\">\n    <meta name=\"msapplication-config\" content=\"assets/favicon/browserconfig.xml\">\n    <meta name=\"theme-color\" content=\"#ffffff\">\n\n    <link rel=\"stylesheet\" href=\"main.css?v=1.1.50\">\n</head>\n<body>\n\n<div class=\"body-container\">\n\n    <!-- Start Screen -->\n\n    <div id=\"start\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"start\" src=\"assets/lottie/intro.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">TON Wallet</div>\n                <div class=\"screen-text\">\n                    TON wallet allows you to make fast and<br>\n                    secure blockchain-based payments<br>\n                    without intermediaries.\n                </div>\n\n                <div class=\"mt-95\">\n                    <button id=\"start_createBtn\" class=\"btn-blue screen-btn\">Create My Wallet</button>\n                </div>\n                <div class=\"mt-20\">\n                    <button id=\"start_importBtn\" class=\"btn-lite font-weight-normal\">Import existing wallet\n                    </button>\n                </div>\n                <div class=\"mt-10\">\n                    <button id=\"start_importLedgerHidBtn\" class=\"btn-lite font-weight-normal\">Connect Ledger\n                    </button>\n                </div>\n\n        <!--            <div class=\"mt-10\">-->\n        <!--                <button id=\"start_importLedgerBleBtn\" class=\"btn-lite font-weight-normal\">Connect Ledger via Bluetooth-->\n        <!--                </button>-->\n        <!--            </div>-->\n            </div>\n        </div>\n    </div>\n\n    <!-- Import Screen -->\n\n    <div id=\"import\" class=\"screen text-align-center visibility-hidden\">\n        <button id=\"import_backBtn\" class=\"btn-back\"></button>\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n\n                <div class=\"screen-title mt-80\">24 Secret Words</div>\n                <div class=\"screen-text mb-10\">\n                    Please restore access to your <b>non-hardware</b> wallet by<br>\n                    entering the 24 secret words you wrote<br>\n                    down when creating the wallet.\n                </div>\n\n                <button id=\"import_alertBtn\" class=\"btn-lite\">I don't have them</button>\n\n                <div id=\"importWords\">\n\n                </div>\n\n                <div id=\"wordsPopup\" class=\"display-none\">\n                </div>\n\n                <div class=\"clear-both\">\n                    <button id=\"import_continueBtn\" class=\"btn-blue screen-btn mt-30 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Created Screen -->\n\n    <div id=\"created\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"created\" src=\"assets/lottie/created.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Congratulations</div>\n\n                <div class=\"screen-text\">\n                    Your TON wallet has just been created.<br>\n                    Only you control it.\n                </div>\n\n                <div class=\"screen-text\">\n                    To be able to always have access to it,<br>\n                    please set up a secure password and write<br>\n                    down secret words.\n                </div>\n\n                <div>\n                    <button id=\"createdContinueButton\" class=\"btn-blue screen-btn mt-18 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Backup Screen -->\n\n    <div id=\"backup\" class=\"screen text-align-center visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"backup\" src=\"assets/lottie/paper.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie mt-30\">\n                </tgs-player>\n\n                <div class=\"screen-title\">24 secret words</div>\n\n                <div class=\"screen-text\">\n                    Write down these 24 words in the correct<br>\n                    order and store them in secret place.\n                </div>\n\n                <div class=\"screen-text\">\n                    Use these secret words to restore access to<br>\n                    your wallet if you lose your password or<br>\n                    access to this device.\n                </div>\n\n                <div id=\"createWords\" class=\"mt-10\">\n\n                </div>\n\n                <div class=\"clear-both\">\n                    <button id=\"backup_continueBtn\" class=\"btn-blue screen-btn mt-26 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Words Confirm Screen -->\n\n    <div id=\"wordsConfirm\" class=\"screen text-align-center visibility-hidden\">\n        <button id=\"wordsConfirm_backBtn\" class=\"btn-back\"></button>\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n\n                <tgs-player data-name=\"wordsConfirm\" src=\"assets/lottie/confirm.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie mt-30\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Test Time!</div>\n\n                <div class=\"screen-text\">\n                    Now let's check that you wrote your secret<br/>words correctly.<br/>\n                </div>\n\n                <div id=\"confirmWordsNums\" class=\"screen-text\">\n                    Please enter the words <span></span>, <span></span> and <span></span> below:\n                </div>\n\n                <div id=\"confirmWords\">\n                </div>\n\n                <div id=\"wordsConfirmPopup\" class=\"display-none\">\n                </div>\n\n                <div class=\"clear-both\">\n                    <button id=\"wordsConfirm_continueBtn\" class=\"btn-blue screen-btn mt-26 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Create Password Screen -->\n\n    <div id=\"createPassword\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"createPassword\" src=\"assets/lottie/lock.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Secure Password</div>\n\n                <div class=\"screen-text\">\n                    Please choose a secure password<br>\n                    for confirming your payments\n                </div>\n\n                <div class=\"mt-54\">\n                    <input id=\"createPassword_input\" placeholder=\"Enter your password\" type=\"password\">\n                </div>\n                <div>\n                    <input id=\"createPassword_repeatInput\" placeholder=\"Repeat your password\" type=\"password\">\n                </div>\n\n                <div>\n                    <button id=\"createPassword_continueBtn\" class=\"btn-blue screen-btn mt-38 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Ready To Go Screen -->\n\n    <div id=\"readyToGo\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"readyToGo\" src=\"assets/lottie/done.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Ready to go!</div>\n\n                <div class=\"screen-text\">\n                    You're all set. Now you have a wallet that<br>\n                    only you control - directly, without<br>\n                    middlemen or bankers.\n                </div>\n\n                <div>\n                    <button id=\"readyToGo_continueBtn\" class=\"btn-blue screen-btn mt-170 mb-20\">\n                        View My Wallet\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Main Screen -->\n\n    <div id=\"main\" class=\"screen visibility-hidden\">\n        <div class=\"head\">\n            <div class=\"head-row\">\n                <button id=\"main_refreshBtn\" class=\"btn-round bg-refresh\"></button>\n\n                <div id=\"updateLabel\"></div>\n\n                <button id=\"main_settingsButton\" class=\"btn-round bg-menu\"></button>\n            </div>\n\n            <div class=\"balance-container\">\n                <div id=\"balance\"></div>\n                <tgs-player data-name=\"symbol\" src=\"assets/lottie/diamond.tgs\"\n                            width=\"32\" height=\"32\"\n                            class=\"balance-symbol\">\n                </tgs-player>\n                <div class=\"balance-diamond-container\">\n                    <div id=\"diamond\"></div>\n                </div>\n            </div>\n            <div class=\"your-balance\">Your balance</div>\n\n<!--            <button id=\"main_buyBtn\" class=\"btn-blue\">-->\n<!--                <div class=\"btn-icon bg-down-left\"></div>-->\n<!--                Buy-->\n<!--            </button>-->\n\n            <button id=\"main_receiveBtn\" class=\"btn-blue\">\n                <div class=\"btn-icon bg-down-left\"></div>\n                Receive\n            </button>\n\n            <button id=\"sendButton\" class=\"btn-blue display-none\">\n                <div class=\"btn-icon bg-down-left rotate-180\"></div>\n                Send\n            </button>\n        </div>\n\n        <div id=\"transactionsContainer\">\n            <div id=\"transactionsList\">\n            </div>\n            <div id=\"walletCreated\" class=\"display-none\">\n                <tgs-player data-name=\"main\"\n                            width=\"150\" height=\"150\"\n                            src=\"assets/lottie/empty.tgs\">\n                </tgs-player>\n                <div>Wallet Created</div>\n            </div>\n        </div>\n\n    </div>\n\n    <!-- Modal -->\n\n    <div id=\"modal\" class=\"visibility-hidden\"></div>\n\n    <!-- Menu Dropdown -->\n\n    <div id=\"menuDropdown\" class=\"visibility-hidden\">\n        <div id=\"menu_extension_chrome\" class=\"dropdown-item\">Chrome Extension</div>\n        <div id=\"menu_extension_firefox\" class=\"dropdown-item\">Firefox Add-on</div>\n        <div id=\"menu_about\" class=\"dropdown-item\">About</div>\n        <div id=\"menu_magic\" class=\"dropdown-item\">TON Magic <div class=\"dropdown-toggle\"></div></div>\n        <div id=\"menu_telegram\" class=\"dropdown-item\">Open Telegram Web »</div>\n        <div id=\"menu_proxy\" class=\"dropdown-item\">TON Proxy <div class=\"dropdown-toggle\"></div></div>\n        <div id=\"menu_changePassword\" class=\"dropdown-item\">Change password</div>\n        <div id=\"menu_backupWallet\" class=\"dropdown-item\">Back up wallet</div>\n        <div id=\"menu_delete\" class=\"dropdown-item\">Log Out</div>\n    </div>\n\n    <!-- Alert Popup-->\n\n    <div id=\"alert\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\"></div>\n        <div class=\"popup-black-text\"></div>\n        <div class=\"popup-footer\"></div>\n    </div>\n\n    <!-- Receive Popup-->\n\n    <div id=\"receive\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Receive TON</div>\n        <div class=\"popup-text\">Share this address to receive TON.\n        </div>\n\n        <div class=\"qr-container\">\n            <div id=\"qr\"></div>\n        </div>\n\n        <div class=\"my-addr addr\"></div>\n\n        <button id=\"receive_showAddressOnDeviceBtn\" class=\"btn-lite btn-lite-first\">Show Address on Device</button>\n\n        <button id=\"receive_invoiceBtn\" class=\"btn-lite\">Create Invoice</button>\n\n        <button id=\"receive_shareBtn\" class=\"btn-blue\">Share Wallet Address</button>\n\n        <button id=\"receive_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Invoice Popup -->\n\n    <div id=\"invoice\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Create Invoice</div>\n\n        <div>\n            <div class=\"input-label\">Amount</div>\n        </div>\n\n        <input id=\"invoice_amountInput\" type=\"number\" placeholder=\"Amount in TON you expect to receive\">\n        <input id=\"invoice_commentInput\" type=\"text\" placeholder=\"Comment (optional)\">\n\n        <div class=\"popup-grey-text\">\n            You can specify the amount and purpose of<br>\n            the payment to save the sender some time.\n        </div>\n\n        <div class=\"input-label mt-24 mb-18\">Invoice URL</div>\n\n        <div id=\"invoice_link\" class=\"popup-black-text\">\n            ton://transfer/\n        </div>\n\n        <div class=\"popup-grey-text mt-24\">\n            Share this address to receive TON.\n        </div>\n\n        <button id=\"invoice_qrBtn\" class=\"btn-lite\">Generate QR Code</button>\n        <button id=\"invoice_shareBtn\" class=\"btn-blue\">Share Invoice URL</button>\n\n        <button id=\"invoice_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Invoice QR Popup-->\n\n    <div id=\"invoiceQr\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Invoice QR</div>\n\n        <div class=\"qr-container\">\n            <div id=\"invoiceQrImg\"></div>\n        </div>\n\n        <div class=\"input-label\">Expected Amount</div>\n\n        <div id=\"invoiceQrAmount\" class=\"popup-black-text\">\n            1\n        </div>\n\n        <button id=\"invoiceQr_shareBtn\" class=\"btn-blue\">Share QR Code</button>\n\n        <button id=\"invoiceQr_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Transaction Popup -->\n\n    <div id=\"transaction\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Transaction</div>\n\n        <div id=\"transactionAmount\">+0.1 TON</div>\n        <div id=\"transactionFee\">0.1 transaction fee</div>\n\n        <div id=\"transactionSenderLabel\" class=\"input-label mt-20\">Sender</div>\n\n        <div id=\"transactionSender\" class=\"addr\">\n\n        </div>\n\n        <div class=\"input-label\">Date</div>\n\n        <div id=\"transactionDate\" class=\"popup-black-text\">\n\n        </div>\n\n        <div id=\"transactionCommentLabel\" class=\"input-label\">Comment</div>\n\n        <div id=\"transactionComment\" class=\"popup-black-text\"></div>\n\n        <div id=\"transactionDecryptCommentButton\" class=\"btn-lite\">Enter password to view comment</div>\n\n        <button id=\"transaction_sendBtn\" class=\"btn-blue mt-20\">Send TON to this address</button>\n\n        <button id=\"transaction_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Send Popup -->\n\n    <div id=\"send\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Send TON</div>\n\n        <div class=\"input-label\">Recipient wallet address</div>\n        <input id=\"toWalletInput\" type=\"text\" placeholder=\"Enter wallet address\">\n\n        <div class=\"popup-grey-text\">\n            Copy the 48-letter wallet address of the\n            recipient here or ask them to send you a\n            ton:// link\n        </div>\n\n        <div class=\"position-relative w-100\">\n            <div class=\"input-label\">Amount</div>\n            <div id=\"sendBalance\">Balance:</div>\n        </div>\n\n        <input id=\"amountInput\" type=\"number\" placeholder=\"0.0\">\n        <input id=\"commentInput\" type=\"text\" placeholder=\"Comment (optional)\">\n\n        <label id=\"encryptCommentCheckboxContainer\" class=\"checkbox-container\"> Encrypt Comment\n            <input type=\"checkbox\" id=\"encryptCommentCheckbox\">\n            <span class=\"checkmark\"></span>\n        </label>\n\n        <button id=\"send_btn\" class=\"btn-blue\">Send TON</button>\n\n        <button id=\"send_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Send Confirm Popup -->\n\n    <div id=\"sendConfirm\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Confirmation</div>\n        <div class=\"popup-black-text\">Do you want to send <b id=\"sendConfirmAmount\">x TON</b> to:</div>\n\n        <div id=\"sendConfirmAddr\" class=\"addr\"></div>\n\n        <div id=\"sendConfirmFee\" class=\"popup-grey-text text-align-center\">Fee: ~x TON</div>\n\n        <div id=\"sendConfirmNotEncryptedNote\" class=\"popup-grey-text text-align-center\">Note: Your comment will <b>not</b> be encrypted</div>\n\n        <button id=\"sendConfirm_closeBtn\" class=\"popup-close-btn\"></button>\n\n        <div class=\"popup-footer\">\n            <button id=\"sendConfirm_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"sendConfirm_okBtn\" class=\"btn-lite\">SEND TON</button>\n        </div>\n    </div>\n\n    <!-- Sign Confirm Popup -->\n\n    <div id=\"signConfirm\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Confirmation</div>\n        <div id=\"signConfirmText\" class=\"popup-black-text\">Do you want to sign:</div>\n\n        <div id=\"signConfirmData\" class=\"addr\"></div>\n\n        <div id=\"signConfirmAlert\" class=\"popup-grey-text text-align-center font-weight-bold text-danger\">Signing custom data is very dangerous. Use only if you know what you are doing.</div>\n\n        <button id=\"signConfirm_closeBtn\" class=\"popup-close-btn\"></button>\n\n        <div class=\"popup-footer\">\n            <button id=\"signConfirm_cancelBtn\" class=\"btn-lite\">NO</button>\n            <button id=\"signConfirm_okBtn\" class=\"btn-lite\">YES</button>\n        </div>\n    </div>\n\n    <!-- Connect Confirm Popup -->\n\n    <div id=\"connectConfirm\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Confirmation</div>\n        <div class=\"popup-black-text\">Do you want to connect your wallet to this page?</div>\n\n        <button id=\"connectConfirm_closeBtn\" class=\"popup-close-btn\"></button>\n\n        <div class=\"popup-footer\">\n            <button id=\"connectConfirm_cancelBtn\" class=\"btn-lite\">NO</button>\n            <button id=\"connectConfirm_okBtn\" class=\"btn-lite\">YES</button>\n        </div>\n    </div>\n\n    <!-- Processing Popup -->\n\n    <div id=\"processing\" class=\"popup text-align-center visibility-hidden\">\n        <tgs-player data-name=\"processing\" src=\"assets/lottie/money.tgs\" width=\"150\" height=\"150\"></tgs-player>\n        <div class=\"popup-title\">Sending TON</div>\n        <div class=\"popup-grey-text\">Please wait a few seconds for your<br>transaction to be processed..</div>\n\n        <button id=\"processing_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Done Popup -->\n\n    <div id=\"done\" class=\"popup text-align-center pb-10 visibility-hidden\">\n        <tgs-player data-name=\"done\" src=\"assets/lottie/done.tgs\" width=\"150\" height=\"150\"></tgs-player>\n        <div class=\"popup-title\">Done!</div>\n        <div class=\"popup-grey-text\">1 TON have been send</div>\n\n        <div class=\"popup-footer\">\n            <button id=\"done_closeBtn\" class=\"btn-lite\">CLOSE</button>\n        </div>\n    </div>\n\n    <!-- About Popup -->\n\n    <div id=\"about\" class=\"popup text-align-center pb-10 visibility-hidden\">\n        <div class=\"popup-title\">TON Wallet</div>\n        <div id=\"about_version\" class=\"popup-grey-text\">\n            Version: 1.1.50\n        </div>\n        <tgs-player data-name=\"about\" src=\"assets/lottie/intro.tgs\" width=\"150\" height=\"150\"></tgs-player>\n\n        <div class=\"popup-grey-text line-height-24\">\n            API provider: <a href=\"https://toncenter.com\" target=\"_blank\">toncenter.com</a><br>\n            <a href=\"https://github.com/toncenter/ton-wallet\" target=\"_blank\">GitHub</a>,\n            <a href=\"https://github.com/toncenter/ton-wallet/issues\" target=\"_blank\">Issue Tracker</a>\n        </div>\n\n        <div class=\"popup-black-text about-magic\">\n            <h4>What is TON Magic?</h4>\n            <p>\n                TON Magic provides native <b>Telegram integration</b> by patching the official Telegram web app (Z version).\n            </p>\n            <p>\n                Turn it on to send and receive Toncoins from any Telegram user. <a href=\"https://telegra.ph/Telegram--TON-11-10\" id=\"about-magic-video\" target=\"_blank\">More info and demo</a>.\n            </p>\n        </div>\n\n        <div class=\"popup-footer\">\n            <button id=\"about_closeBtn\" class=\"btn-lite\">CLOSE</button>\n        </div>\n    </div>\n\n    <!-- Change Password Popup -->\n\n    <div id=\"changePassword\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Change Password</div>\n\n        <tgs-player data-name=\"changePassword\" src=\"assets/lottie/lock.tgs\" width=\"150\" height=\"150\"></tgs-player>\n\n        <input id=\"changePassword_oldInput\" placeholder=\"Enter your old password\" type=\"password\"\n               class=\"input-password\">\n        <input id=\"changePassword_newInput\" placeholder=\"Enter a new password\" type=\"password\"\n               class=\"input-password mt-20\">\n        <input id=\"changePassword_repeatInput\" placeholder=\"Repeat the new password\" type=\"password\"\n               class=\"input-password\">\n\n        <div class=\"popup-footer\">\n            <button id=\"changePassword_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"changePassword_okBtn\" class=\"btn-lite\">SAVE</button>\n        </div>\n    </div>\n\n    <!-- Enter Password Popup -->\n\n    <div id=\"enterPassword\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Password</div>\n\n        <tgs-player data-name=\"enterPassword\" src=\"assets/lottie/lock.tgs\" width=\"150\" height=\"150\"></tgs-player>\n        <input id=\"enterPassword_input\" placeholder=\"Enter your password\" type=\"password\"\n               class=\"input-password\">\n\n        <div class=\"popup-footer\">\n            <button id=\"enterPassword_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"enterPassword_okBtn\" class=\"btn-lite\">NEXT</button>\n        </div>\n    </div>\n\n    <!-- Log Out Popup -->\n\n    <div id=\"delete\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Log Out</div>\n        <div class=\"popup-black-text\">\n            This will disconnect the wallet from this<br>\n            app. You will be able to restore your<br>\n            wallet using <b>24 secret words</b> - or import<br>\n            another wallet.\n        </div>\n        <div class=\"popup-black-text mt-20\">\n            Wallets are located in the decentralized<br>\n            TON Blockchain. If you want the wallet to<br>\n            be deleted simply transfer all the TON<br>\n            from it and leave it empty.\n        </div>\n\n        <div class=\"popup-footer\">\n            <button id=\"delete_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"delete_okBtn\" class=\"btn-lite btn-lite-red\">DISCONNECT</button>\n        </div>\n    </div>\n\n    <!-- Connect Ledger Popup -->\n\n    <div id=\"connectLedger\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Connect Ledger</div>\n        <div class=\"popup-black-text\">\n            Please use Edge/Google Chrome v89 or later.\n        </div>\n        <div class=\"popup-black-text mt-20\">\n            Turn off Ledger Live.\n        </div>\n        <div class=\"popup-black-text mt-20\">\n            If it does not connect, then try reconnecting the device.\n        </div>\n\n        <div class=\"popup-footer\">\n            <button id=\"connectLedger_cancelBtn\" class=\"btn-lite\">OK</button>\n        </div>\n    </div>\n\n    <!-- Notify-->\n\n    <div id=\"notify\" class=\"visibility-hidden\"></div>\n\n    <!-- Loader Popup -->\n\n    <div id=\"loader\" class=\"popup text-align-center pb-10 visibility-hidden\">\n        <tgs-player data-name=\"loader\" src=\"assets/lottie/intro.tgs\" width=\"150\" height=\"150\"></tgs-player>\n    </div>\n</div>\n\n<!-- Scripts -->\n\n<script type=\"text/javascript\" src=\"libs/pako.min.js?v=1.1.50\"></script>\n<script type=\"text/javascript\" src=\"libs/lottie.min.js?v=1.1.50\"></script>\n<script type=\"text/javascript\" src=\"libs/easy.qrcode.min.js?v=1.1.50\"></script>\n\n<script type=\"text/javascript\" src=\"libs/aes-js-3.1.2.js\"></script>\n<script type=\"text/javascript\" src=\"libs/noble-ed25519-1.7.3.js\"></script>\n\n<script type=\"text/javascript\" src=\"libs/tonweb.min.js?v=1.1.50\"></script>\n<script type=\"text/javascript\" src=\"libs/tonweb-mnemonic.min.js?v=1.1.50\"></script>\n\n<script src=\"js/View.js?v=1.1.50\" type=\"module\"></script>\n<script src=\"js/Controller.js?v=1.1.50\" type=\"module\"></script>\n\n</body>\n</html>\n"
  },
  {
    "path": "docs/js/Controller.js",
    "content": "/******/ (() => { // webpackBootstrap\n/******/ \t\"use strict\";\n/******/ \t// The require scope\n/******/ \tvar __webpack_require__ = {};\n/******/ \t\n/************************************************************************/\n/******/ \t/* webpack/runtime/make namespace object */\n/******/ \t(() => {\n/******/ \t\t// define __esModule on exports\n/******/ \t\t__webpack_require__.r = (exports) => {\n/******/ \t\t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t\t}\n/******/ \t\t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t\t};\n/******/ \t})();\n/******/ \t\n/************************************************************************/\nvar __webpack_exports__ = {};\n// ESM COMPAT FLAG\n__webpack_require__.r(__webpack_exports__);\n\n;// CONCATENATED MODULE: ./src/js/util/storage.js\n/**\n *  `localStorage` polyfill for Chrome Extension environment\n */\n\n/* harmony default export */ const storage = (self.localStorage || {\n    /**\n     * @param key   {string}\n     * @param value {string}\n     * @return {Promise<void>}\n     */\n    setItem(key, value) {\n        return chrome.storage.local.set({[key]: value});\n    },\n\n    /**\n     * @param key   {string}\n     * @return {Promise<string | null>}\n     */\n    getItem(key) {\n        return chrome.storage.local.get(key)\n            .then(({[key]: value}) => value);\n    },\n\n    /**\n     * @param key   {string}\n     * @return {Promise<void>}\n     */\n    removeItem(key) {\n        return chrome.storage.local.remove(key);\n    },\n\n    /**\n     * @return {Promise<void>}\n     */\n    clear() {\n        return chrome.storage.local.clear();\n    },\n});\n\n;// CONCATENATED MODULE: ./src/js/util/encryption.js\n// This JS library implements TON message comment encryption and decryption for Web\n// Reference C++ code - SimpleEncryptionV2 - https://github.com/ton-blockchain/ton/blob/cc0eb453cb3bf69f92693160103d33112856c056/tonlib/tonlib/keys/SimpleEncryption.cpp#L110\n// Dependencies:\n// - TonWeb 0.0.60\n// - aes-js - 3.1.2 - https://github.com/ricmoo/aes-js/releases/tag/v3.1.2 - for aes-cbc without padding\n// - noble-ed25519 - 1.7.3 - // https://github.com/paulmillr/noble-ed25519/releases/tag/1.7.3 - for getSharedKey\n\nconst ed25519 = self.nobleEd25519;\n\n/**\n * @param key {Uint8Array}\n * @param data {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst hmac_sha512 = async (key, data) => {\n    const hmacAlgo = {name: \"HMAC\", hash: \"SHA-512\"};\n    /** @type {CryptoKey} */\n    const hmacKey = await self.crypto.subtle.importKey(\"raw\", key, hmacAlgo, false, [\"sign\"]);\n    /** @type {ArrayBuffer} */\n    const signature = await self.crypto.subtle.sign(hmacAlgo, hmacKey, data);\n    const result = new Uint8Array(signature);\n    if (result.length !== 512 / 8) throw new Error();\n    return result;\n}\n\n/**\n * @param hash  {Uint8Array}\n * @return {Promise<any>} aesjs.ModeOfOperation.cbc\n */\nconst getAesCbcState = async (hash) => {\n    if (hash.length < 48) throw new Error();\n    const key = hash.slice(0, 32);\n    const iv = hash.slice(32, 32 + 16);\n\n    // Note that native crypto.subtle AES-CBC not suitable here because\n    // even if the data IS a multiple of 16 bytes, padding will still be added\n    // So we use aes-js\n\n    return new aesjs.ModeOfOperation.cbc(key, iv);\n}\n\n/**\n * @param dataLength    {number}\n * @param minPadding    {number}\n * @return {Uint8Array}\n */\nconst getRandomPrefix = (dataLength, minPadding) => {\n    const prefixLength = ((minPadding + 15 + dataLength) & -16) - dataLength;\n    /** @type {Uint8Array} */\n    const prefix = self.crypto.getRandomValues(new Uint8Array(prefixLength));\n    prefix[0] = prefixLength;\n    if ((prefixLength + dataLength) % 16 !== 0) throw new Error();\n    return prefix;\n}\n\n/**\n * @param a {Uint8Array}\n * @param b {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst combineSecrets = async (a, b) => {\n    return hmac_sha512(a, b);\n}\n\n/**\n * @param data  {Uint8Array}\n * @param sharedSecret {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst encryptDataWithPrefix = async (data, sharedSecret, salt) => {\n    if (data.length % 16 !== 0) throw new Error();\n    /** @type {Uint8Array} */\n    const dataHash = await combineSecrets(salt, data);\n    /** @type {Uint8Array} */\n    const msgKey = dataHash.slice(0, 16);\n\n    const res = new Uint8Array(data.length + 16);\n    res.set(msgKey, 0);\n\n    /** @type {Uint8Array} */\n    const cbcStateSecret = await combineSecrets(sharedSecret, msgKey);\n    /** @type {Uint8Array} */\n    const encrypted = (await getAesCbcState(cbcStateSecret)).encrypt(data);\n    res.set(encrypted, 16);\n\n    return res;\n}\n\n/**\n * @param data  {Uint8Array}\n * @param sharedSecret {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst encryptDataImpl = async (data, sharedSecret, salt) => {\n    /** @type {Uint8Array} */\n    const prefix = await getRandomPrefix(data.length, 16);\n    const combined = new Uint8Array(prefix.length + data.length);\n    combined.set(prefix, 0);\n    combined.set(data, prefix.length);\n    return encryptDataWithPrefix(combined, sharedSecret, salt);\n}\n\n/**\n * @param data  {Uint8Array}\n * @param myPublicKey {Uint8Array}\n * @param theirPublicKey {Uint8Array}\n * @param privateKey    {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst encryptData = async (data, myPublicKey, theirPublicKey, privateKey, salt) => {\n    /** @type {Uint8Array} */\n    const sharedSecret = await ed25519.getSharedSecret(privateKey, theirPublicKey);\n\n    /** @type {Uint8Array} */\n    const encrypted = await encryptDataImpl(data, sharedSecret, salt);\n    const prefixedEncrypted = new Uint8Array(myPublicKey.length + encrypted.length);\n    for (let i = 0; i < myPublicKey.length; i++) {\n        prefixedEncrypted[i] = theirPublicKey[i] ^ myPublicKey[i];\n    }\n    prefixedEncrypted.set(encrypted, myPublicKey.length);\n    return prefixedEncrypted;\n}\n\n/**\n * @param bytes {Uint8Array}\n * @return {Cell}\n */\nconst makeSnakeCells = (bytes) => {\n    const ROOT_CELL_BYTE_LENGTH = 35 + 4;\n    const CELL_BYTE_LENGTH = 127;\n    /** @type {Cell} */\n    const root = new TonWeb.boc.Cell();\n    root.bits.writeBytes(bytes.slice(0, Math.min(bytes.length, ROOT_CELL_BYTE_LENGTH)));\n\n    const cellCount = Math.ceil((bytes.length - ROOT_CELL_BYTE_LENGTH) / CELL_BYTE_LENGTH);\n    if (cellCount > 16) {\n        throw new Error('Text too long');\n    }\n\n    /** @type {Cell} */\n    let cell = root;\n    for (let i = 0; i < cellCount; i++) {\n        /** @type {Cell} */\n        const prevCell = cell;\n        cell = new TonWeb.boc.Cell();\n        const cursor = ROOT_CELL_BYTE_LENGTH + i * CELL_BYTE_LENGTH;\n        cell.bits.writeBytes(bytes.slice(cursor, Math.min(bytes.length, cursor + CELL_BYTE_LENGTH)));\n        prevCell.refs[0] = cell;\n    }\n\n    return root;\n}\n\n/**\n * @param cell  {Cell}\n * @return {Uint8Array}\n */\nconst parseSnakeCells = (cell) => {\n    /** @type {Cell} */\n   let c = cell;\n    /** @type {Uint8Array} */\n   let result = new Uint8Array(0);\n   while (c) {\n       /** @type {Uint8Array} */\n       const newResult = new Uint8Array(result.length + c.bits.array.length);\n       newResult.set(result);\n       newResult.set(c.bits.array, result.length);\n\n       result = newResult;\n       c = c.refs[0];\n   }\n   return result;\n}\n\n/**\n * @param comment   {string}\n * @param myPublicKey   {Uint8Array}\n * @param theirPublicKey    {Uint8Array}\n * @param myPrivateKey  {Uint8Array}\n * @param senderAddress   {string | Address}\n * @return {Promise<Cell>} full message binary payload with 0x2167da4b prefix\n */\nconst encryptMessageComment = async (comment, myPublicKey, theirPublicKey, myPrivateKey, senderAddress) => {\n    if (!comment || !comment.length) throw new Error('empty comment');\n\n    if (myPrivateKey.length === 64) {\n        myPrivateKey = myPrivateKey.slice(0, 32); // convert nacl private key\n    }\n\n    /** @type {Uint8Array} */\n    const commentBytes = new TextEncoder().encode(comment);\n\n    /** @type {Uint8Array} */\n    const salt = new TextEncoder().encode(new TonWeb.utils.Address(senderAddress).toString(true, true, true, false));\n\n    /** @type {Uint8Array} */\n    const encryptedBytes = await encryptData(commentBytes, myPublicKey, theirPublicKey, myPrivateKey, salt);\n\n    const payload = new Uint8Array(encryptedBytes.length + 4);\n    payload[0] = 0x21; // encrypted text prefix\n    payload[1] = 0x67;\n    payload[2] = 0xda;\n    payload[3] = 0x4b;\n    payload.set(encryptedBytes, 4);\n\n    return makeSnakeCells(payload);\n}\n\n/**\n * @param cbcStateSecret {Uint8Array}\n * @param msgKey {Uint8Array}\n * @param encryptedData {Uint8Array}\n * @param salt {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst doDecrypt = async (cbcStateSecret, msgKey, encryptedData, salt) => {\n    /** @type {Uint8Array} */\n    const decryptedData = (await getAesCbcState(cbcStateSecret)).decrypt(encryptedData);\n    /** @type {Uint8Array} */\n    const dataHash = await combineSecrets(salt, decryptedData);\n    /** @type {Uint8Array} */\n    const gotMsgKey = dataHash.slice(0, 16);\n    if (msgKey.join(',') !== gotMsgKey.join(',')) {\n        throw new Error('Failed to decrypt: hash mismatch')\n    }\n    const prefixLength = decryptedData[0];\n    if (prefixLength > decryptedData.length || prefixLength < 16) {\n        throw new Error('Failed to decrypt: invalid prefix size');\n    }\n    return decryptedData.slice(prefixLength);\n}\n\n/**\n * @param encryptedData {Uint8Array}\n * @param sharedSecret {Uint8Array}\n * @param salt {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst decryptDataImpl = async (encryptedData, sharedSecret, salt) => {\n    if (encryptedData.length < 16) throw new Error('Failed to decrypt: data is too small');\n    if (encryptedData.length % 16 !== 0) throw new Error('Failed to decrypt: data size is not divisible by 16');\n    /** @type {Uint8Array} */\n    const msgKey = encryptedData.slice(0, 16);\n    /** @type {Uint8Array} */\n    const data = encryptedData.slice(16);\n    /** @type {Uint8Array} */\n    const cbcStateSecret = await combineSecrets(sharedSecret, msgKey);\n    /** @type {Uint8Array} */\n    const res = await doDecrypt(cbcStateSecret, msgKey, data, salt);\n    return res;\n}\n\n/**\n * @param data  {Uint8Array}\n * @param publicKey  {Uint8Array}\n * @param privateKey  {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst decryptData = async (data, publicKey, privateKey, salt) => {\n    if (data.length < publicKey.length) {\n        throw new Error('Failed to decrypt: data is too small');\n    }\n    const theirPublicKey = new Uint8Array(publicKey.length);\n    for (let i = 0; i < publicKey.length; i++) {\n        theirPublicKey[i] = data[i] ^ publicKey[i];\n    }\n    /** @type {Uint8Array} */\n    const sharedSecret = await ed25519.getSharedSecret(privateKey, theirPublicKey);\n\n    /** @type {Uint8Array} */\n    const decrypted = await decryptDataImpl(data.slice(publicKey.length), sharedSecret, salt);\n    return decrypted;\n}\n\n/**\n * @param encryptedData {Uint8Array}    encrypted data without 0x2167da4b prefix\n * @param myPublicKey   {Uint8Array}\n * @param myPrivateKey  {Uint8Array}\n * @param senderAddress   {string | Address}\n * @return {Promise<string>}    decrypted text comment\n */\nconst decryptMessageComment = async (encryptedData, myPublicKey, myPrivateKey, senderAddress) => {\n    if (myPrivateKey.length === 64) {\n        myPrivateKey = myPrivateKey.slice(0, 32); // convert nacl private key\n    }\n\n    /** @type {Uint8Array} */\n    const salt = new TextEncoder().encode(new TonWeb.utils.Address(senderAddress).toString(true, true, true, false));\n\n    /** @type {Uint8Array} */\n    const decryptedBytes = await decryptData(encryptedData, myPublicKey, myPrivateKey, salt);\n    return new TextDecoder().decode(decryptedBytes);\n}\n;// CONCATENATED MODULE: ./src/js/Controller.js\n\n\n\nconst TONCONNECT_MAINNET = '-239';\nconst TONCONNECT_TESTNET = '-3';\n\nlet extensionWindowId = -1;\nlet contentScriptPorts = new Set();\nlet popupPort = null;\nconst queueToPopup = [];\n\n/**\n * @type {Promise<void> | null}\n */\nlet dAppPromise = null;\n\nconst createDappPromise = () => {\n    if (dAppPromise) dAppPromise.resolve(false);\n\n    let resolve;\n    let reject;\n\n    dAppPromise = new Promise((localResolve, localReject) => {\n        resolve = localResolve;\n        reject = localReject;\n    });\n\n    dAppPromise.resolve = (...args) => {\n        resolve(...args);\n        dAppPromise = null;\n    };\n    dAppPromise.reject = (...args) => {\n        reject(...args);\n        dAppPromise = null;\n    };\n};\n\nconst showExtensionWindow = () => {\n    return new Promise(async resolve => {\n        if (extensionWindowId > -1) {\n            chrome.windows.update(extensionWindowId, {focused: true});\n            return resolve();\n        }\n\n        const windowState = (await storage.getItem('windowState')) || {};\n\n        windowState.top = windowState.top || 0;\n        windowState.left = windowState.left || 0;\n        windowState.height = windowState.height || 800;\n        windowState.width = windowState.width || 480;\n\n        chrome.windows.create(Object.assign(windowState, {\n            url: 'index.html',\n            type: 'popup',\n            focused: true\n        }), window => {\n            extensionWindowId = window.id;\n            resolve();\n        });\n    });\n};\n\nconst BN = TonWeb.utils.BN;\nconst nacl = TonWeb.utils.nacl;\nconst Address = TonWeb.utils.Address;\nconst formatNanograms = TonWeb.utils.fromNano;\n\n// ENCRYPTION\n\n/**\n * @param plaintext {string}\n * @param password {string}\n * @return {Promise<string>}\n */\nasync function encrypt(plaintext, password) {\n    const pwUtf8 = new TextEncoder().encode(password);                                 // encode password as UTF-8\n    const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8);                      // hash the password\n\n    const iv = crypto.getRandomValues(new Uint8Array(12));                             // get 96-bit random iv\n\n    const alg = {name: 'AES-GCM', iv: iv};                                           // specify algorithm to use\n\n    const key = await crypto.subtle.importKey('raw', pwHash, alg, false, ['encrypt']); // generate key from pw\n\n    const ptUint8 = new TextEncoder().encode(plaintext);                               // encode plaintext as UTF-8\n    const ctBuffer = await crypto.subtle.encrypt(alg, key, ptUint8);                   // encrypt plaintext using key\n\n    const ctArray = Array.from(new Uint8Array(ctBuffer));                              // ciphertext as byte array\n    const ctStr = ctArray.map(byte => String.fromCharCode(byte)).join('');             // ciphertext as string\n    const ctBase64 = btoa(ctStr);                                                      // encode ciphertext as base64\n\n    const ivHex = Array.from(iv).map(b => ('00' + b.toString(16)).slice(-2)).join(''); // iv as hex string\n\n    return ivHex + ctBase64;                                                             // return iv+ciphertext\n}\n\n/**\n * @param ciphertext {string}\n * @param password {string}\n * @return {Promise<string>}\n */\nasync function decrypt(ciphertext, password) {\n    const pwUtf8 = new TextEncoder().encode(password);                                  // encode password as UTF-8\n    const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8);                       // hash the password\n\n    const iv = ciphertext.slice(0, 24).match(/.{2}/g).map(byte => parseInt(byte, 16));   // get iv from ciphertext\n\n    const alg = {name: 'AES-GCM', iv: new Uint8Array(iv)};                            // specify algorithm to use\n\n    const key = await crypto.subtle.importKey('raw', pwHash, alg, false, ['decrypt']);  // use pw to generate key\n\n    const ctStr = atob(ciphertext.slice(24));                                           // decode base64 ciphertext\n    const ctUint8 = new Uint8Array(ctStr.match(/[\\s\\S]/g).map(ch => ch.charCodeAt(0))); // ciphertext as Uint8Array\n    // note: why doesn't ctUint8 = new TextEncoder().encode(ctStr) work?\n\n    const plainBuffer = await crypto.subtle.decrypt(alg, key, ctUint8);                 // decrypt ciphertext using key\n    const plaintext = new TextDecoder().decode(plainBuffer);                            // decode password from UTF-8\n\n    return plaintext;                                                                   // return the plaintext\n}\n\n// CONTROLLER\n\nconst IS_EXTENSION = !!(self.chrome && chrome.runtime && chrome.runtime.onConnect);\n\nconst ACCOUNT_NUMBER = 0;\n\nconst DEFAULT_WALLET_VERSION = 'v3R2';\nconst DEFAULT_LEDGER_WALLET_VERSION = 'v3R1';\n\nclass Controller {\n    constructor() {\n        /** @type {boolean} */\n        this.isTestnet = false;\n        /** @type {boolean} */\n        this.isDebug = false;\n        /** @type {string} */\n        this.myAddress = null;\n        /** @type {string} */\n        this.publicKeyHex = null;\n        /** @type {string[]} */\n        this.myMnemonicWords = null;\n        /** @type   {BN | null} */\n        this.balance = null;\n        /** @type {WalletContract} */\n        this.walletContract = null;\n        this.transactions = [];\n        /** @type {number} */\n        this.updateIntervalId = 0;\n\n        /** @type {null | {totalAmount: BN, bodyHashBase64: string }} */\n        this.sendingData = null;\n\n        /** @type {boolean} */\n        this.processingVisible = false;\n\n        this.ledgerApp = null;\n        /** @type {boolean} */\n        this.isLedger = false;\n\n        /** @type {(words: string[]) => Promise<void> | null} */\n        this.afterEnterPassword = null;\n\n        if (self.view) {\n            self.view.controller = this;\n        }\n\n        this.pendingMessageResolvers = new Map();\n        this._lastMsgId = 1;\n\n        if (IS_EXTENSION) {\n            setInterval(() => storage.setItem('__time', Date.now()), 5 * 1000);\n        }\n\n        this.whenReady = this._init();\n    }\n\n    debug(...args) {\n        if (!this.isDebug) return;\n        console.log(...args);\n    }\n\n    /**\n     * @param words {string[]}\n     * @return {Promise<string>} base64\n     */\n    static async wordsToPrivateKey(words) {\n        const keyPair = await TonWeb.mnemonic.mnemonicToKeyPair(words);\n        return TonWeb.utils.bytesToBase64(keyPair.secretKey.slice(0, 32));\n    }\n\n    /**\n     * @param words {string[]}\n     * @param password  {string}\n     * @return {Promise<void>}\n     */\n    static async saveWords(words, password) {\n        await storage.setItem('words', await encrypt(words.join(','), password));\n    }\n\n    /**\n     * @param password  {string}\n     * @return {Promise<string[]>}\n     */\n    static async loadWords(password) {\n        return (await decrypt(await storage.getItem('words'), password)).split(',');\n    }\n\n    /**\n     * @param isTestnet {boolean}\n     * @return {string}\n     */\n    getApiKey(isTestnet) {\n        const webApiKey = isTestnet\n            ? '4f96a149e04e0821d20f9e99ee716e20ff52db7238f38663226b1c0f303003e0'\n            : '4f96a149e04e0821d20f9e99ee716e20ff52db7238f38663226b1c0f303003e0';\n        const extensionApiKey = isTestnet\n            ? '503af517296765c3f1729fcb301b063a00650a50a881eeaddb6307d5d45e21aa'\n            : '503af517296765c3f1729fcb301b063a00650a50a881eeaddb6307d5d45e21aa';\n        return IS_EXTENSION ? extensionApiKey : webApiKey;\n    }\n\n    async _init() {\n        return new Promise(async (resolve) => {\n            await storage.removeItem('pwdHash');\n\n            this.isTestnet = IS_EXTENSION ? (await storage.getItem('isTestnet')) : (self.location.href.indexOf('testnet') > -1);\n            this.isDebug = IS_EXTENSION ? (await storage.getItem('isDebug')) : (self.location.href.indexOf('debug') > -1);\n\n            const mainnetRpc = 'https://toncenter.com/api/v2/jsonRPC';\n            const testnetRpc = 'https://testnet.toncenter.com/api/v2/jsonRPC';\n\n            if (IS_EXTENSION && !(await storage.getItem('address'))) {\n                await this._restoreDeprecatedStorage();\n            }\n\n            this.ton = new TonWeb(new TonWeb.HttpProvider(this.isTestnet ? testnetRpc : mainnetRpc, {apiKey: this.getApiKey(this.isTestnet)}));\n            this.myAddress = await storage.getItem('address');\n            if (this.myAddress) {\n                this.myAddress = new TonWeb.utils.Address(this.myAddress).toString(true, true, false, this.isTestnet);\n            }\n            this.publicKeyHex = await storage.getItem('publicKey');\n\n            if (!this.myAddress || !(await storage.getItem('words'))) {\n                await storage.clear();\n                this.sendToView('showScreen', {name: 'start', noAnimation: true});\n            } else {\n                if ((await storage.getItem('isLedger')) === 'true') {\n                    this.isLedger = true;\n                    this.sendToView('setIsLedger', this.isLedger);\n                }\n\n                await this.showMain();\n            }\n            this.sendToView('setIsTestnet', this.isTestnet);\n\n            resolve();\n        });\n    }\n\n    async _restoreDeprecatedStorage() {\n        const {\n            address, words, walletVersion, magic, proxy,\n        } = await this.sendToView('restoreDeprecatedStorage', undefined, true, true);\n\n        if (!address || !words) {\n            return;\n        }\n\n        await Promise.all([\n            storage.setItem('address', address),\n            storage.setItem('words', words),\n            storage.setItem('walletVersion', walletVersion),\n            storage.setItem('magic', magic),\n            storage.setItem('proxy', proxy),\n        ]);\n    }\n\n    async toggleTestnet() {\n        this.isTestnet = !this.isTestnet;\n        if (this.isTestnet) {\n            await storage.setItem('isTestnet', 'true');\n        } else {\n            await storage.removeItem('isTestnet');\n        }\n        this.clearVars();\n        await this._init();\n        await this.sendToView('setIsTestnet', this.isTestnet);\n    }\n\n    async toggleDebug() {\n        this.isDebug = !this.isDebug;\n        if (this.isDebug) {\n            await storage.setItem('isDebug', 'true');\n        } else {\n            await storage.removeItem('isDebug');\n        }\n    }\n\n    // INDEXED API\n\n    /**\n     * @private\n     * @param method   {string}\n     * @param params   {any}\n     * @return {Promise<any>}\n     */\n    async sendToIndex(method, params) {\n        const mainnetRpc = 'https://toncenter.com/api/v3/';\n        const testnetRpc = 'https://testnet.toncenter.com/api/v3/';\n        const rpc = this.isTestnet ? testnetRpc : mainnetRpc;\n\n        const headers = {\n            'Content-Type': 'application/json',\n            'X-API-Key': this.getApiKey(this.isTestnet)\n        };\n\n        const response = await fetch(rpc + method + '?' + new URLSearchParams(params), {\n            method: 'GET',\n            headers: headers,\n        });\n        return await response.json();\n    }\n\n    /**\n     * @private\n     * @param address   {string}\n     * @return {Promise<{seqno: number | null}>}\n     */\n    async getWalletInfoFromIndex(address) {\n        return this.sendToIndex('wallet', {\n            address: address\n        });\n    }\n\n    /**\n     * @private\n     * @param address   {string}\n     * @return {Promise<{balance: string, status: string}>}\n     */\n    async getAccountInfoFromIndex(address) {\n        return this.sendToIndex('account', {\n            address: address\n        });\n    }\n\n    /**\n     * @return {Promise<number>} seqno\n     */\n    async getMySeqno() {\n        const walletInfo = await this.getWalletInfoFromIndex(this.myAddress);\n        return walletInfo.seqno || 0;\n    }\n\n    /**\n     * @param address   {string}\n     * @return {Promise<BN>} in nanotons\n     */\n    async getBalance(address) {\n        const accountInfo = await this.getAccountInfoFromIndex(address);\n        return new BN(accountInfo.balance);\n    }\n\n    /**\n     * @param address   {string}\n     * @return {Promise<boolean>}\n     */\n    async checkContractInitialized(address) {\n        const accountInfo = await this.getAccountInfoFromIndex(address);\n        return accountInfo.status === \"active\";\n    }\n\n    /**\n     * @private\n     * @param address   {string}\n     * @param limit {number}\n     * @return {Promise<void>}\n     */\n    async getTransactionsFromIndex(address, limit) {\n        return this.sendToIndex('transactions', {\n            account: address,\n            limit: limit\n        });\n    }\n\n    /**\n     * @param limit? {number}\n     * @return {Promise<any[]>} transactions\n     */\n    async getTransactions(limit = 10) {\n\n        /**\n         * @param msg   {any} raw.message\n         * @return {string}\n         */\n        function getComment(msg) {\n            if (!msg.message_content) return '';\n            if (!msg.message_content.decoded) return '';\n            if (msg.message_content.decoded['type'] !== 'text_comment') return '';\n            return msg.message_content.decoded.comment;\n        }\n\n        /**\n         * @param msg {any} raw.message\n         * @return {string} '' or base64\n         */\n        function getEncryptedComment(msg) {\n            if (!msg.message_content) return '';\n            if (!msg.message_content.body) return '';\n            if (msg.opcode !== \"0x2167da4b\") return '';\n            /** @type {string} */\n            const cellBase64 = msg.message_content.body;\n            /** @type {Cell} */\n            const cell = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(cellBase64));\n            return TonWeb.utils.bytesToBase64(parseSnakeCells(cell).slice(4)); // skip 4 bytes of prefix 0x2167da4b\n        }\n\n        const arr = [];\n        const transactionsResponse= await this.getTransactionsFromIndex(this.myAddress, limit);\n        const transactions = transactionsResponse.transactions; // index.transaction[]\n        const addressBook = transactionsResponse.address_book;\n\n        /**\n         * @param rawAddress    {string}\n         * @return {string}\n         */\n        const formatTxAddress = (rawAddress) => {\n            return addressBook[rawAddress].user_friendly;\n        }\n\n        for (const t of transactions) {\n            let amount = new BN(t.in_msg.value);\n            for (const outMsg of t.out_msgs) {\n                amount = amount.sub(new BN(outMsg.value));\n            }\n\n            let from_addr = \"\";\n            let to_addr = \"\";\n            let comment = \"\";\n            let encryptedComment = \"\";\n            let inbound = false;\n\n            if (t.in_msg.source) { // internal message with Toncoins, set source\n                inbound = true;\n                from_addr = formatTxAddress(t.in_msg.source);\n                to_addr = formatTxAddress(t.in_msg.destination);\n                comment = getComment(t.in_msg);\n                encryptedComment = getEncryptedComment(t.in_msg);\n            } else if (t.out_msgs.length) { // external message, we sending Toncoins\n                inbound = false;\n                from_addr = formatTxAddress(t.out_msgs[0].source);\n                to_addr = formatTxAddress(t.out_msgs[0].destination);\n                comment = getComment(t.out_msgs[0]);\n                encryptedComment = getEncryptedComment(t.out_msgs[0]);\n                //TODO support many out messages. We need to show separate outgoing payment for each? How to show fees?\n            } else {\n                // Deploying wallet contract onchain\n            }\n\n            /** @type {BN} */\n            let fee = new BN(t.total_fees);\n            for (let outMsg of t.out_msgs) {\n                fee = fee.add(new BN(outMsg.fwd_fee));\n                fee = fee.add(new BN(outMsg.ihr_fee));\n            }\n\n            if (to_addr) {\n                arr.push({\n                    bodyHashBase64: t.in_msg.message_content.hash, // base64\n                    inbound,\n                    hash: t.hash, // base64\n                    amount: amount.toString(),\n                    from_addr: from_addr,\n                    to_addr: to_addr,\n                    fee: fee.toString(), // string BN\n                    comment: comment,\n                    encryptedComment: encryptedComment,\n                    date: t.now * 1000\n                });\n            }\n        }\n        return arr;\n    }\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @param keyPair    {nacl.KeyPair | null} null if estimates fee, keyPair if real sending\n     * @return Promise<{{send: () => Promise<*>, getQuery: () => Promise<Cell>, estimateFee: () => Promise<*>}}> transfer object\n     */\n    async sign(request, keyPair) {\n        /** @type {number} */\n        const seqno = await this.getMySeqno();\n\n        /** @type {Uint8Array | null} */\n        const secretKey = keyPair ? keyPair.secretKey : null;\n\n        return this.walletContract.methods.transfers({\n            secretKey: secretKey,\n            seqno: seqno,\n            expireAt: request.expireAt,\n            messages: request.messages.map(message => {\n                return {\n                    toAddress: message.toAddress,\n                    amount: message.amount,\n                    payload: message.comment,\n                    sendMode: 3,\n                    stateInit: message.stateInit\n                }\n            })\n        });\n    }\n\n    // CREATE WALLET\n\n    async showCreated() {\n        this.sendToView('showScreen', {name: 'created'});\n        this.sendToView('disableCreated', true);\n        this.myMnemonicWords = await TonWeb.mnemonic.generateMnemonic();\n        const privateKey = await Controller.wordsToPrivateKey(this.myMnemonicWords);\n        const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n        const walletVersion = DEFAULT_WALLET_VERSION;\n        const WalletClass = this.ton.wallet.all[walletVersion];\n        this.walletContract = new WalletClass(this.ton.provider, {\n            publicKey: keyPair.publicKey,\n            wc: 0\n        });\n        this.myAddress = (await this.walletContract.getAddress()).toString(true, true, false, this.isTestnet);\n        this.publicKeyHex = TonWeb.utils.bytesToHex(keyPair.publicKey);\n        await storage.setItem('publicKey', this.publicKeyHex);\n        await storage.setItem('walletVersion', walletVersion);\n        this.sendToView('disableCreated', false);\n    }\n\n    async createPrivateKey() {\n        this.showBackup(this.myMnemonicWords, true);\n    }\n\n    // BACKUP WALLET\n\n    onBackupWalletClick() {\n        this.afterEnterPassword = async mnemonicWords => {\n            this.showBackup(mnemonicWords);\n        };\n        this.sendToView('showPopup', {name: 'enterPassword'});\n    }\n\n    showBackup(words, isFirst) {\n        this.sendToView('showScreen', {name: 'backup', words, isFirst});\n    }\n\n    async onBackupDone() {\n        if (await storage.getItem('words')) {\n            this.sendToView('showScreen', {name: 'main'});\n        } else {\n            this.sendToView('showScreen', {name: 'wordsConfirm', words: this.myMnemonicWords});\n        }\n    }\n\n    onConfirmDone(words) {\n        if (words) {\n            let isValid = true;\n\n            Object.keys(words).forEach(index => {\n                if (this.myMnemonicWords[index] !== words[index]) {\n                    isValid = false;\n                }\n            });\n\n            if (!isValid) {\n                return;\n            }\n\n            this.showCreatePassword();\n        }\n    }\n\n    // IMPORT LEDGER\n\n    async createLedger(transportType) {\n        let transport;\n\n        switch (transportType) {\n            case 'hid':\n                transport = await TonWeb.ledger.TransportWebHID.create();\n                break;\n            case 'ble':\n                transport = await TonWeb.ledger.BluetoothTransport.create();\n                break;\n            default:\n                throw new Error('unknown transportType' + transportType);\n        }\n\n        transport.setDebugMode(true);\n        this.isLedger = true;\n        this.ledgerApp = new TonWeb.ledger.AppTon(transport, this.ton);\n        const ledgerVersion = (await this.ledgerApp.getAppConfiguration()).version;\n        this.debug('ledgerAppConfig=', ledgerVersion);\n        if (!ledgerVersion.startsWith('2')) {\n            alert('Please update your Ledger TON-app to v2.0.1 or upper or use old wallet version https://tonwallet.me/prev/');\n            throw new Error('outdated ledger ton-app version');\n        }\n        const {publicKey} = await this.ledgerApp.getPublicKey(ACCOUNT_NUMBER, false); // todo: можно сохранять publicKey и не запрашивать это\n\n        const WalletClass = this.ton.wallet.all[DEFAULT_LEDGER_WALLET_VERSION];\n        const wallet = new WalletClass(this.ton.provider, {\n            publicKey: publicKey,\n            wc: 0\n        });\n        this.walletContract = wallet;\n\n        const address = await wallet.getAddress();\n        this.myAddress = address.toString(true, true, false, this.isTestnet);\n        this.publicKeyHex = TonWeb.utils.bytesToHex(publicKey);\n    }\n\n    async importLedger(transportType) {\n        await this.createLedger(transportType);\n        await storage.setItem('walletVersion', this.walletContract.getName());\n        await storage.setItem('address', this.myAddress);\n        await storage.setItem('isLedger', 'true');\n        await storage.setItem('ledgerTransportType', transportType);\n        await storage.setItem('words', 'ledger');\n        await storage.setItem('publicKey', this.publicKeyHex);\n        this.sendToView('setIsLedger', this.isLedger);\n        this.sendToView('showScreen', {name: 'readyToGo'});\n    }\n\n    // IMPORT WALLET\n\n    showImport() {\n        this.sendToView('showScreen', {name: 'import'});\n    }\n\n    async import(words) {\n        this.myMnemonicWords = words;\n        if (this.myMnemonicWords) {\n            try {\n                const privateKey = await Controller.wordsToPrivateKey(this.myMnemonicWords);\n                const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n\n                let hasBalance = [];\n\n                for (let WalletClass of this.ton.wallet.list) {\n                    const wallet = new WalletClass(this.ton.provider, {\n                        publicKey: keyPair.publicKey,\n                        wc: 0\n                    });\n                    const walletAddress = (await wallet.getAddress()).toString(true, true, false, this.isTestnet);\n                    const walletBalance = await this.getBalance(walletAddress);\n                    if (walletBalance.gt(new BN(0))) {\n                        hasBalance.push({balance: walletBalance, clazz: WalletClass});\n                    }\n                    this.debug(wallet.getName(), walletAddress, walletBalance.toString());\n                }\n\n                let walletClass = this.ton.wallet.all[DEFAULT_WALLET_VERSION];\n\n                if (hasBalance.length > 0) {\n                    hasBalance.sort((a, b) => {\n                        return a.balance.cmp(b.balance);\n                    });\n                    walletClass = hasBalance[hasBalance.length - 1].clazz;\n                }\n\n                await this.importImpl(keyPair, walletClass);\n\n                this.sendToView('importCompleted', {state: 'success'});\n            } catch (e) {\n                this.debug(e);\n                this.sendToView('importCompleted', {state: 'failure'});\n            }\n        } else {\n            this.sendToView('importCompleted', {state: 'failure'});\n        }\n    }\n\n    async importImpl(keyPair, WalletClass) {\n        this.walletContract = new WalletClass(this.ton.provider, {\n            publicKey: keyPair.publicKey,\n            wc: 0\n        });\n        this.myAddress = (await this.walletContract.getAddress()).toString(true, true, false, this.isTestnet);\n        this.publicKeyHex = TonWeb.utils.bytesToHex(keyPair.publicKey);\n        await storage.setItem('publicKey', this.publicKeyHex);\n        await storage.setItem('walletVersion', this.walletContract.getName());\n        this.showCreatePassword();\n    }\n\n    // PASSWORD\n\n    showCreatePassword() {\n        this.sendToView('showScreen', {name: 'createPassword'});\n    }\n\n    /**\n     * @param password  {string}\n     * @return {Promise<void>}\n     */\n    async savePrivateKey(password) {\n        this.isLedger = false;\n        await storage.setItem('isLedger', 'false');\n        await storage.setItem('address', this.myAddress);\n        await Controller.saveWords(this.myMnemonicWords, password);\n        this.myMnemonicWords = null;\n\n        this.sendToView('setIsLedger', this.isLedger);\n        this.sendToView('showScreen', {name: 'readyToGo'});\n        this.sendToView('privateKeySaved');\n    }\n\n    /**\n     * @param oldPassword   {string}\n     * @param newPassword   {string}\n     * @return {Promise<void>}\n     */\n    async onChangePassword(oldPassword, newPassword) {\n        let words;\n        try {\n            words = await Controller.loadWords(oldPassword);\n        } catch (e) {\n            this.sendToView('showChangePasswordError');\n            return;\n        }\n        await Controller.saveWords(words, newPassword);\n\n        this.sendToView('closePopup');\n        this.sendToView('passwordChanged');\n    }\n\n    /**\n     * @param password  {string}\n     * @return {Promise<void>}\n     */\n    async onEnterPassword(password) {\n        let words;\n        try {\n            words = await Controller.loadWords(password);\n        } catch (e) {\n            this.sendToView('showEnterPasswordError');\n            return;\n        }\n\n        this.afterEnterPassword(words);\n        this.sendToView('passwordEntered');\n    }\n\n    // MAIN\n\n    /**\n     * @return {Promise<void>}\n     */\n    async showMain() {\n        this.sendToView('showScreen', {name: 'main', myAddress: this.myAddress});\n        if (!this.walletContract) {\n            const walletVersion = await storage.getItem('walletVersion');\n            const walletClass = walletVersion ? this.ton.wallet.all[walletVersion] : this.ton.wallet.default;\n\n            this.walletContract = new walletClass(this.ton.provider, {\n                address: this.myAddress,\n                publicKey: this.publicKeyHex ? TonWeb.utils.hexToBytes(this.publicKeyHex) : undefined,\n                wc: 0\n            });\n        }\n        this.updateIntervalId = setInterval(() => this.update(false), 5000);\n        this.update(true);\n        this.sendToDapp('ton_accounts', [this.myAddress]);\n    }\n\n    /**\n     * @return {Promise<void>}\n     */\n    async initDapp() {\n        this.sendToDapp('ton_accounts', this.myAddress ? [this.myAddress] : []);\n        this.doMagic((await storage.getItem('magic')) === 'true');\n        this.doProxy((await storage.getItem('proxy')) === 'true');\n    }\n\n    /**\n     * @return {Promise<void>}\n     */\n    async initView() {\n        if (!this.myAddress || !(await storage.getItem('words'))) {\n            this.sendToView('showScreen', {name: 'start', noAnimation: true});\n        } else {\n            this.sendToView('showScreen', {name: 'main', myAddress: this.myAddress});\n            if (this.balance !== null) {\n                this.sendToView('setBalance', {balance: this.balance.toString(), txs: this.transactions});\n            }\n        }\n        this.sendToView('setIsMagic', (await storage.getItem('magic')) === 'true');\n        this.sendToView('setIsProxy', (await storage.getItem('proxy')) === 'true');\n        this.sendToView('setIsTestnet', this.isTestnet);\n    }\n\n    /**\n     * @return {Promise<boolean>} successfully updated\n     */\n    async updateBalance() {\n        try {\n            this.balance = await this.getBalance(this.myAddress);\n            return true;\n        } catch (e) {\n            console.error(e);\n            return false;\n        }\n    }\n\n    /**\n     * @param force {boolean}\n     * @return {Promise<boolean>} successfully updated\n     */\n    async update(force) {\n        try {\n            // if (!document.hasFocus()) {\n            //     return true;\n            // }\n            const needUpdate = (this.processingVisible && this.sendingData) || (this.balance === null) || force;\n\n            if (!needUpdate) return true;\n\n            if (!(await this.updateBalance())) return false;\n\n            const txs = await this.getTransactions();\n            if (txs.length > 0) {\n                this.transactions = txs;\n\n                if (this.processingVisible && this.sendingData) {\n                    for (let tx of txs) {\n                        if (tx.bodyHashBase64 === this.sendingData.bodyHashBase64) {\n                            this.sendToView('showPopup', {\n                                name: 'done',\n                                message: formatNanograms(this.sendingData.totalAmount) + ' TON have been sent'\n                            });\n                            this.processingVisible = false;\n                            this.sendingData = null;\n                            break;\n                        }\n                    }\n                }\n            }\n\n            this.sendToView('setBalance', {balance: this.balance.toString(), txs: this.transactions});\n            return true;\n\n        } catch (e) {\n            console.error(e);\n            return false;\n        }\n    }\n\n    async showAddressOnDevice() {\n        if (!this.ledgerApp) {\n            await this.createLedger((await storage.getItem('ledgerTransportType')) || 'hid');\n        }\n        const {address} = await this.ledgerApp.getAddress(ACCOUNT_NUMBER, true, this.ledgerApp.ADDRESS_FORMAT_USER_FRIENDLY + this.ledgerApp.ADDRESS_FORMAT_URL_SAFE + this.ledgerApp.ADDRESS_FORMAT_BOUNCEABLE);\n        this.debug(address.toString(true, true, true));\n    }\n\n    // DECRYPT MESSAGE COMMENT\n\n    /**\n     * @param hash  {string}\n     * @param encryptedComment  {string} base64\n     * @param senderAddress {string | Address}\n     */\n    onDecryptComment(hash, encryptedComment, senderAddress) {\n        this.afterEnterPassword = async mnemonicWords => {\n            const keyPair = await TonWeb.mnemonic.mnemonicToKeyPair(mnemonicWords);\n            let decryptedComment = ''\n            try {\n                decryptedComment = await decryptMessageComment(TonWeb.utils.base64ToBytes(encryptedComment), keyPair.publicKey, keyPair.secretKey, senderAddress);\n            } catch (e) {\n                console.error(e);\n            }\n            this.sendToView('decryptedComment', {hash, decryptedComment});\n        };\n        this.sendToView('showPopup', {name: 'enterPassword'});\n    }\n\n    // SEND TONCOIN\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @return {Promise<BN>} total fees in nanotons\n     */\n    async getFees(request) {\n        /** @type {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}} */\n        const tempRequest = {\n            expireAt: request.expireAt,\n            messages: []\n        };\n\n        for (const message of request.messages) {\n            let tempComment = message.comment\n\n            if (message.needEncryptComment) {\n                const tempKeyPair = TonWeb.utils.newKeyPair();  // encrypt with random key just to get estimage fees\n                const tempEncryptedCommentCell = await encryptMessageComment(message.comment, tempKeyPair.publicKey, tempKeyPair.publicKey, tempKeyPair.secretKey, this.myAddress);\n                tempComment = tempEncryptedCommentCell;\n\n            }\n            tempRequest.messages.push({\n                amount: message.amount,\n                toAddress: message.toAddress,\n                comment: tempComment,\n                needEncryptComment: message.needEncryptComment,\n                stateInit: message.stateInit\n            });\n        }\n\n        const query = await this.sign(tempRequest, null);\n        const all_fees = await query.estimateFee();\n        const fees = all_fees.source_fees;\n        const in_fwd_fee = new BN(fees.in_fwd_fee); // External processing fee\n        const storage_fee = new BN(fees.storage_fee);\n        const gas_fee = new BN(fees.gas_fee);\n        const fwd_fee = new BN(fees.fwd_fee);\n\n        return in_fwd_fee.add(storage_fee).add(gas_fee).add(fwd_fee);\n    };\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @param needQueue? {boolean}\n     * @return {Promise<Cell | null>} successfully sent BoC\n     */\n    async showSendConfirm(request, needQueue) {\n        createDappPromise();\n\n        if (!request.messages) throw new Error('no messages');\n        if (!request.messages.length) throw new Error('no messages to send');\n        if (request.messages.length > 4) throw new Error('maximum 4 message at once');\n\n        /** @type {BN} */\n        let totalAmount = new BN(0);\n\n        for (const message of request.messages) {\n\n            // message.address\n\n            if (!message.amount) throw new Error('no amount');\n\n            if (!message.amount.gte(new BN(0))) {\n                this.sendToView('sendCheckFailed', {message: 'Amount must be positive'});\n                return null;\n            }\n\n            if (message.amount.eq(new BN(0)) && !message.comment) {\n                this.sendToView('sendCheckFailed', {message: 'You can send 0 TON only with comment'});\n                return null;\n            }\n\n            totalAmount = totalAmount.add(message.amount);\n\n            // message.toAddress\n\n            if (!message.toAddress) throw new Error('no toAddress');\n\n            if (!Address.isValid(message.toAddress)) {\n                try {\n                    message.toAddress = message.toAddress.toLowerCase();\n                    if (!message.toAddress.endsWith('.ton') && !message.toAddress.endsWith('.t.me')) {\n                        throw new Error();\n                    }\n\n                    message.toAddress = await this.ton.dns.getWalletAddress(message.toAddress);\n                    if (!message.toAddress) {\n                        throw new Error();\n                    }\n                    if (!Address.isValid(message.toAddress)) {\n                        throw new Error();\n                    }\n                    message.toAddress = message.toAddress.toString(true, true, true, this.isTestnet);\n\n                } catch (e) {\n                    this.sendToView('sendCheckFailed', {message: 'Invalid address or domain'});\n                    return null;\n                }\n            }\n\n            // make toAddress non-bounceable if destination contract uninitialized\n            if (!(await this.checkContractInitialized(message.toAddress))) {\n                message.toAddress = (new Address(message.toAddress)).toString(true, true, false);\n            }\n\n            // message.payload\n\n            if (!message.comment) {\n                message.needEncryptComment = false;\n            }\n\n            // serialize long text comment\n            if (!message.needEncryptComment && (typeof message.comment === 'string')) {\n                if (message.comment.length > 0) {\n                    const commentBytes = new TextEncoder().encode(message.comment);\n                    const payloadBytes = new Uint8Array(4 + commentBytes.length);\n                    payloadBytes[0] = 0; // zero uint32 means simple text message\n                    payloadBytes[1] = 0;\n                    payloadBytes[2] = 0;\n                    payloadBytes[3] = 0;\n                    payloadBytes.set(commentBytes, 4);\n                    message.comment = makeSnakeCells(payloadBytes);\n                }\n            }\n\n            // get destination public key for encryption\n\n            if (message.needEncryptComment) {\n                let toPublicKey = null;\n\n                try {\n                    const toPublicKeyBN = await this.ton.provider.call2(message.toAddress, 'get_public_key');\n                    let toPublicKeyHex = toPublicKeyBN.toString(16);\n                    if (toPublicKeyHex.length % 2 !== 0) {\n                        toPublicKeyHex = '0' + toPublicKeyHex;\n                    }\n                    toPublicKey = TonWeb.utils.hexToBytes(toPublicKeyHex);\n                } catch (e) {\n                    console.error(e);\n                }\n\n                if (!toPublicKey) {\n                    this.sendToView('sendCheckCantPublicKey', {});\n                    return null;\n                }\n\n                message.toPublicKey = toPublicKey;\n            }\n        }\n\n        // check balance\n\n        if (!(await this.updateBalance())) {\n            this.sendToView('sendCheckFailed', {message: 'API request error'});\n            return null;\n        }\n\n        if (this.balance.lt(totalAmount)) {\n            this.sendToView('sendCheckFailed', {\n                message: 'Not enough balance'\n            });\n            return null;\n        }\n\n        let fee;\n\n        try {\n            fee = await this.getFees(request);\n        } catch (e) {\n            console.error(e);\n            this.sendToView('sendCheckFailed', {message: 'API request error'});\n            return null;\n        }\n\n        if (this.balance.sub(fee).lt(totalAmount)) {\n            this.sendToView('sendCheckCantPayFee', {fee});\n            return null;\n        }\n\n        // start\n\n        if (this.isLedger) {\n            const message = request.messages[0];\n\n            this.sendToView('showPopup', {\n                name: 'sendConfirm',\n                amount: message.amount.toString(),\n                toAddress: message.toAddress,\n                needEncryptComment: false,\n                fee: fee.toString()\n            }, needQueue);\n\n            const sentBoc = await this.send(request, null, totalAmount);\n\n            if (sentBoc) {\n                dAppPromise.resolve(sentBoc);\n            } else {\n                this.sendToView('sendCheckFailed', {message: 'API request error'});\n                dAppPromise.resolve(null);\n            }\n        } else {\n            this.afterEnterPassword = async words => {\n                this.processingVisible = true;\n                this.sendToView('showPopup', {name: 'processing'});\n\n                const keyPair = await TonWeb.mnemonic.mnemonicToKeyPair(words);\n\n                for (const message of request.messages) {\n                    if (message.needEncryptComment) {\n                        const encryptedCommentCell = await encryptMessageComment(message.comment, keyPair.publicKey, message.toPublicKey, keyPair.secretKey, this.myAddress);\n                        message.comment = encryptedCommentCell;\n                    }\n                }\n\n                const privateKeyBase64 = await Controller.wordsToPrivateKey(words);\n                const sentBoc = await this.send(request, privateKeyBase64, totalAmount);\n\n                this.onCancelAction = null;\n\n                if (sentBoc) {\n                    dAppPromise.resolve(sentBoc);\n                } else {\n                    this.sendToView('sendCheckFailed', {message: 'API request error'});\n                    dAppPromise.resolve(null);\n                }\n            };\n\n            this.onCancelAction = () => {\n                dAppPromise.resolve(null);\n            };\n\n            this.sendToView('showPopup', {\n                name: 'sendConfirm',\n                amount: totalAmount.toString(),\n                toAddress: request.messages.length === 1 ? request.messages[0].toAddress : `${request.messages.length} addresses`,\n                fee: fee.toString(),\n                needEncryptComment: request.messages[0].needEncryptComment // todo\n            }, needQueue);\n        }\n\n        this.sendToView('sendCheckSucceeded');\n\n        return dAppPromise;\n    }\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @param privateKeyBase64 {string | null} null if Ledger\n     * @param totalAmount {BN}\n     * @return  {Promise<Cell | null>} successfully sent BoC\n     */\n    async send(request, privateKeyBase64, totalAmount) {\n        try {\n            let query;\n\n            if (this.isLedger) {\n                if (request.messages.length !== 1) {\n                    throw new Error('Ledger support only 1 message at once');\n                }\n\n                const message = request.messages[0];\n\n                if (message.needEncryptComment) {\n                    throw new Error('encrypted comment dont supported by Ledger');\n                }\n\n                if (message.stateInit) {\n                    throw new Error('stateInit dont supported by Ledger');\n                }\n\n                if (!this.ledgerApp) {\n                    await this.createLedger((await storage.getItem('ledgerTransportType')) || 'hid');\n                }\n\n                let addressFormat = 0;\n\n                const toAddress = new Address(message.toAddress);\n                if (toAddress.isUserFriendly) {\n                    addressFormat += this.ledgerApp.ADDRESS_FORMAT_USER_FRIENDLY;\n                    if (toAddress.isUrlSafe) {\n                        addressFormat += this.ledgerApp.ADDRESS_FORMAT_URL_SAFE;\n                    }\n                    if (toAddress.isBounceable) {\n                        addressFormat += this.ledgerApp.ADDRESS_FORMAT_BOUNCEABLE;\n                    }\n                    if (toAddress.isTestOnly) {\n                        addressFormat += this.ledgerApp.ADDRESS_FORMAT_TEST_ONLY;\n                    }\n                }\n\n                const seqno = await this.getMySeqno();\n\n                query = await this.ledgerApp.transfer(ACCOUNT_NUMBER, this.walletContract, message.toAddress, message.amount, seqno, addressFormat);\n                this.sendToView('showPopup', {name: 'processing'});\n                this.processingVisible = true;\n\n            } else {\n\n                const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKeyBase64));\n                query = await this.sign(request, keyPair);\n\n            }\n\n            /** @type {Cell | null} */\n            const sentBoc = await this.sendQuery(query);\n\n            if (!sentBoc) return null;\n\n            /** @type {Cell} */\n            const bodyCell = await query.getBody();\n            /** @type {Uint8Array} */\n            const bodyHash = await bodyCell.hash();\n\n            this.sendingData = {\n                bodyHashBase64: TonWeb.utils.bytesToBase64(bodyHash),\n                totalAmount: totalAmount\n            };\n\n            return sentBoc;\n\n        } catch (e) {\n            this.debug(e);\n            this.sendToView('closePopup');\n            alert('Error sending');\n            return null;\n        }\n    }\n\n    /**\n     * @param hexToSign   {string} hex to sign\n     * @param privateKey    {string}\n     * @returns {Promise<string>} signature in hex\n     */\n    rawSign(hexToSign, privateKey) {\n        const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n        const signature = nacl.sign.detached(TonWeb.utils.hexToBytes(hexToSign), keyPair.secretKey);\n        return TonWeb.utils.bytesToHex(signature);\n    }\n\n    /**\n     * @param query {{send: () => Promise<*>, getQuery: () => Promise<Cell>}}\n     * @return {Promise<Cell | null>} successfully sent BoC\n     */\n    async sendQuery(query) {\n        const sendResponse = await query.send();\n        if (sendResponse[\"@type\"] === \"ok\") { // response from ton-http-api\n            // wait for transaction, then show Done popup\n            return query.getQuery();\n        } else {\n            this.sendToView('closePopup');\n            alert('Send error');\n            return null;\n        }\n    }\n\n    // RAW SIGN\n\n    /**\n     * @param hexToSign  {string} hex data to sign\n     * @param isConnect {boolean}\n     * @param needQueue {boolean}\n     * @returns {Promise<string>} signature in hex\n     */\n    showSignConfirm(hexToSign, isConnect, needQueue) {\n        return new Promise((resolve, reject) => {\n            if (this.isLedger) {\n                alert('sign not supported by Ledger');\n                reject();\n            } else {\n\n                this.onCancelAction = () => {\n                    reject('User cancel');\n                };\n\n                this.afterEnterPassword = async words => {\n                    this.sendToView('closePopup');\n                    const privateKeyBase64 = await Controller.wordsToPrivateKey(words);\n                    const signature = this.rawSign(hexToSign, privateKeyBase64);\n                    resolve(signature);\n                };\n\n                this.sendToView('showPopup', {\n                    name: 'signConfirm',\n                    data: hexToSign,\n                    isConnect: isConnect\n                }, needQueue);\n\n            }\n        });\n    }\n\n    /**\n     * Ask user for password and set `this.publicKeyHex`\n     * @param needQueue {boolean}\n     * @return {Promise<void>}\n     */\n    requestPublicKey(needQueue) {\n        return new Promise(async (resolve, reject) => {\n            await showExtensionWindow();\n\n            this.onCancelAction = () => {\n                reject('User cancel');\n            };\n\n            this.afterEnterPassword = async words => {\n                const privateKey = await Controller.wordsToPrivateKey(words);\n                const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n                this.publicKeyHex = TonWeb.utils.bytesToHex(keyPair.publicKey);\n                await storage.setItem('publicKey', this.publicKeyHex);\n                resolve();\n            };\n\n            this.sendToView('showPopup', {name: 'enterPassword'}, needQueue);\n        });\n    }\n\n    /**\n     * @param needQueue {boolean}\n     * @returns {Promise<void>}\n     */\n    showConnectConfirm(needQueue) {\n        return new Promise((resolve, reject) => {\n            this.onCancelAction = () => {\n                reject({\n                    message: 'Reject request',\n                    code: 300 // USER_REJECTS_ERROR\n                });\n            };\n\n            this.onConnectConfirmed = async () => {\n                this.sendToView('closePopup');\n                resolve();\n            };\n\n            this.sendToView('showPopup', {\n                name: 'connectConfirm',\n            }, needQueue);\n        });\n    }\n\n    // DISCONNECT WALLET\n\n    clearVars() {\n        this.myAddress = null;\n        this.publicKeyHex = null;\n        this.balance = null;\n        this.walletContract = null;\n        this.transactions = [];\n        this.sendingData = null;\n        this.processingVisible = false;\n        this.isLedger = false;\n        this.ledgerApp = null;\n        clearInterval(this.updateIntervalId);\n    }\n\n    async onDisconnectClick() {\n        this.clearVars();\n        await storage.clear();\n        this.sendToView('showScreen', {name: 'start'});\n        this.sendToDapp('ton_accounts', []);\n    }\n\n    // MAGIC\n\n    doMagic(enabled) {\n        try {\n            this.sendToDapp('ton_doMagic', enabled);\n        } catch (e) {\n\n        }\n    }\n\n    // PROXY\n\n    doProxy(enabled) {\n\n    }\n\n    // TRANSPORT WITH VIEW\n\n    /**\n     * @param method    {string}\n     * @param params?   {any}  boolean or object, not array\n     * @param needQueue? {boolean}\n     * @param needResult? {boolean}\n     * @return {void | Promise<{magic: (string|null), proxy: (string|null), address: (string|null), words: (string|null), walletVersion: (string|null)}>}\n     */\n    sendToView(method, params, needQueue, needResult) {\n        if (self.view) {\n            const result = self.view.onMessage(method, params);\n            if (needResult) {\n                return result;\n            }\n        } else {\n            const msg = {method, params};\n            const exec = () => {\n                if (popupPort) {\n                    popupPort.postMessage(msg);\n                } else if (needQueue) {\n                    queueToPopup.push(msg);\n                }\n            };\n\n            if (!needResult) {\n                exec();\n                return;\n            }\n\n            return new Promise((resolve) => {\n                msg.id = this._lastMsgId++;\n                this.pendingMessageResolvers.set(msg.id, resolve);\n                exec();\n            });\n        }\n    }\n\n    /**\n     * @param method    {string}\n     * @param params?   {any}  boolean or object, not array\n     * @return {Promise<void>}\n     */\n    async onViewMessage(method, params) {\n        switch (method) {\n            case 'showScreen':\n                switch (params.name) {\n                    case 'created':\n                        await this.showCreated();\n                        break;\n                    case 'import':\n                        this.showImport();\n                        break;\n                    case 'importLedger':\n                        await this.importLedger(params.transportType);\n                        break;\n                }\n                break;\n            case 'import':\n                await this.import(params.words);\n                break;\n            case 'createPrivateKey':\n                await this.createPrivateKey();\n                break;\n            case 'passwordCreated':\n                await this.savePrivateKey(params.password);\n                break;\n            case 'update':\n                this.update(true);\n                break;\n            case 'showAddressOnDevice':\n                await this.showAddressOnDevice();\n                break;\n            case 'onCancelAction':\n                if (this.onCancelAction) {\n                    await this.onCancelAction();\n                    this.onCancelAction = null;\n                }\n                break;\n            case 'onConnectConfirmed':\n                if (this.onConnectConfirmed) {\n                    this.onConnectConfirmed();\n                    this.onConnectConfirmed = null;\n                }\n                break;\n            case 'onEnterPassword':\n                await this.onEnterPassword(params.password);\n                break;\n            case 'decryptComment':\n                await this.onDecryptComment(params.hash, params.encryptedComment, params.senderAddress);\n                break;\n            case 'onChangePassword':\n                await this.onChangePassword(params.oldPassword, params.newPassword);\n                break;\n            case 'onSend':\n                await this.showSendConfirm({\n                    messages: [\n                        {\n                            amount: new BN(params.amount),\n                            toAddress: params.toAddress,\n                            comment: params.comment,\n                            needEncryptComment: params.needEncryptComment\n                        }\n                    ]\n                }, false);\n                break;\n            case 'onBackupDone':\n                await this.onBackupDone();\n                break;\n            case 'onConfirmBack':\n                this.showBackup(this.myMnemonicWords);\n                break;\n            case 'onImportBack':\n                this.sendToView('showScreen', {name: 'start'});\n                break;\n            case 'onConfirmDone':\n                this.onConfirmDone(params.words);\n                break;\n            case 'showMain':\n                await this.showMain();\n                break;\n            case 'onBackupWalletClick':\n                this.onBackupWalletClick();\n                break;\n            case 'disconnect':\n                await this.onDisconnectClick();\n                break;\n            case 'onClosePopup':\n                this.processingVisible = false;\n                break;\n            case 'onMagicClick':\n                await storage.setItem('magic', params ? 'true' : 'false');\n                this.doMagic(params);\n                break;\n            case 'onProxyClick':\n                await storage.setItem('proxy', params ? 'true' : 'false');\n                this.doProxy(params);\n                break;\n            case 'toggleTestnet':\n                await this.toggleTestnet();\n                break;\n            case 'toggleDebug':\n                await this.toggleDebug();\n                break;\n            case 'onWindowUpdate':\n                await storage.setItem('windowState', {\n                    top: params.top,\n                    left: params.left,\n                    // -2 need for remove frames size\n                    // TODO: check in linux and macos\n                    height: params.height - 2,\n                    width: params.width - 2\n                });\n                break;\n        }\n    }\n\n    // TRANSPORT WITH DAPP\n\n    /**\n     * @param method    {string}\n     * @param params    {any | any[]}\n     */\n    sendToDapp(method, params) {\n        contentScriptPorts.forEach(port => {\n            port.postMessage(JSON.stringify({\n                type: 'gramWalletAPI',\n                message: {jsonrpc: '2.0', method: method, params: params}\n            }));\n        });\n    }\n\n    /**\n     * @param needQueue {boolean}\n     * @return {Promise<{name: 'ton_addr', address: string, network: string, walletStateInit: string, publicKey: string }>}\n     */\n    async createTonAddrItemReply(needQueue) {\n        if (!this.myAddress) {\n            throw {\n                message: 'Missing connection',\n                code: 1 // BAD_REQUEST_ERROR\n            };\n        }\n        if (!this.publicKeyHex) {\n            await this.requestPublicKey(needQueue);\n        }\n        const walletVersion = await storage.getItem('walletVersion');\n\n        const rawAddressString = new TonWeb.utils.Address(this.myAddress).toString(false);\n        const WalletClass = walletVersion ? this.ton.wallet.all[walletVersion] : this.ton.wallet.default;\n        const wallet = new WalletClass(this.ton.provider, {\n            publicKey: TonWeb.utils.hexToBytes(this.publicKeyHex),\n            wc: 0\n        });\n        const {stateInit} = await wallet.createStateInit();\n        const stateInitBase64 = TonWeb.utils.bytesToBase64(await stateInit.toBoc(false));\n\n        return {\n            name: 'ton_addr',\n            address: rawAddressString,\n            network: this.isTestnet ? TONCONNECT_TESTNET : TONCONNECT_MAINNET,\n            walletStateInit: stateInitBase64,\n            publicKey: this.publicKeyHex\n        };\n    }\n\n    /**\n     * @param origin    {string}\n     * @param payload   {string}\n     * @param needQueue {boolean}\n     * @return {any} ton_proof item\n     */\n    async createTonProofItemReply(origin, payload, needQueue) {\n        if (!this.myAddress) {\n            throw {\n                message: 'Missing connection',\n                code: 1 // BAD_REQUEST_ERROR\n            };\n        }\n\n        const timestamp = Math.round(Date.now() / 1000);\n        const timestampBuffer = new BigInt64Array(1);\n        timestampBuffer[0] = BigInt(timestamp);\n\n        const domain = new URL(origin).host;\n        const domainBuffer = new TextEncoder().encode(domain);\n        const domainLengthBuffer = new Int32Array(1);\n        domainLengthBuffer[0] = domainBuffer.byteLength;\n\n        const address = new TonWeb.utils.Address(this.myAddress);\n\n        const addressWorkchainBuffer = new Int32Array(1);\n        addressWorkchainBuffer[0] = address.wc;\n\n        const addressBuffer = new Uint8Array(4 + address.hashPart.length);\n        addressBuffer.set(addressWorkchainBuffer, 0);\n        addressBuffer.set(address.hashPart, 4);\n\n        const prefixBuffer = new TextEncoder().encode('ton-proof-item-v2/');\n        const payloadBuffer = new TextEncoder().encode(payload);\n        const messageBuffer = new Uint8Array(prefixBuffer.byteLength + addressBuffer.byteLength + domainLengthBuffer.byteLength + domainBuffer.byteLength + timestampBuffer.byteLength + payloadBuffer.byteLength);\n\n        let offset = 0;\n        messageBuffer.set(prefixBuffer, offset);\n        offset += prefixBuffer.byteLength;\n        messageBuffer.set(addressBuffer, offset);\n        offset += addressBuffer.byteLength;\n        messageBuffer.set(domainLengthBuffer, offset);\n        offset += domainLengthBuffer.byteLength;\n        messageBuffer.set(domainBuffer, offset);\n        offset += domainBuffer.byteLength;\n        messageBuffer.set(new Uint8Array(timestampBuffer.buffer), offset);\n        offset += 8;\n        messageBuffer.set(payloadBuffer, offset);\n\n        const ffffPrefix = new Uint8Array([0xff, 0xff]);\n        const tonconnectPrefix = new TextEncoder().encode('ton-connect')\n\n        const messageBufferHash = new Uint8Array(await TonWeb.utils.sha256(messageBuffer));\n        const bufferToSign = new Uint8Array(ffffPrefix.byteLength + tonconnectPrefix.byteLength + messageBufferHash.byteLength);\n        offset = 0;\n        bufferToSign.set(ffffPrefix, offset);\n        offset += ffffPrefix.byteLength;\n        bufferToSign.set(tonconnectPrefix, offset);\n        offset += tonconnectPrefix.byteLength;\n        bufferToSign.set(messageBufferHash, offset);\n\n        const hexToSign = TonWeb.utils.bytesToHex(new Uint8Array(await TonWeb.utils.sha256(bufferToSign)));\n        const signatureHex = await this.showSignConfirm(hexToSign, true, needQueue);\n        console.log({signatureHex});\n        const signatureBase64 = TonWeb.utils.bytesToBase64(TonWeb.utils.hexToBytes(signatureHex));\n        console.log({signatureBase64});\n\n        return {\n            name: 'ton_proof',\n            proof: {\n                timestamp: timestamp, // 64-bit unix epoch time of the signing operation (seconds)\n                domain: {\n                    lengthBytes: domainBuffer.byteLength, // AppDomain Length\n                    value: domain, // app domain name (as url part, without encoding)\n                },\n                signature: signatureBase64, // base64-encoded signature\n                payload: payload, // payload from the request\n            },\n        }\n    }\n\n    async onDappMessage(method, params, origin) {\n        // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md\n        // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1102.md\n        await this.whenReady;\n\n        const needQueue = !popupPort;\n\n        switch (method) {\n            case 'tonConnect_connect':\n                await showExtensionWindow();\n                if (!this.myAddress) {\n                    throw {\n                        message: 'Missing connection',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                const data = params[0];\n                const tonProof = data.items.find((item) => item.name === 'ton_proof');\n\n\n                if (!tonProof &&\n                    !(await storage.getItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin))) {\n\n                    await this.showConnectConfirm(needQueue);\n                }\n\n                await storage.setItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin, 'true');\n\n                const connectResult = [\n                    await this.createTonAddrItemReply(needQueue),\n                ];\n                if (tonProof) {\n                    connectResult.push(await this.createTonProofItemReply(origin, tonProof.payload, needQueue))\n                }\n\n                return connectResult;\n\n            case 'tonConnect_reconnect':\n                if (!this.myAddress ||\n                    !(await storage.getItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin))) {\n                    throw {\n                        message: 'Missing connection',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                return [\n                    await this.createTonAddrItemReply(needQueue)\n                ];\n\n            case 'tonConnect_disconnect':\n                await storage.removeItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin);\n                return;\n\n            case 'tonConnect_sendTransaction':\n                await showExtensionWindow();\n\n                const tx = params[0];\n                console.log('tonConnect_sendTransaction', params, origin, tx);\n\n                // check is dapp connected to wallet\n\n                if (!this.myAddress) {\n                    throw {\n                        message: 'Missing connection',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n                if (!(await storage.getItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin))) {\n                    throw {\n                        message: 'dApp don\\'t have an access to wallet',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                // check tonConnect_sendTransaction request\n\n                /** @type {number | undefined} */\n                let expireAt = undefined;\n\n                if (tx.valid_until) {\n                    expireAt = Number(tx.valid_until);\n                    if (isNaN(expireAt)) {\n                        throw {\n                            message: 'invalid validUntil',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                    if (expireAt > 9999999999) {\n                        expireAt = expireAt / 1000; // convert millis to seconds, todo: it's not good\n                    }\n                    if (expireAt < Date.now() / 1000) {\n                        throw {\n                            message: 'expired',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                if (tx.from) {\n                    if (!Address.isValid(tx.from)) {\n                        throw {\n                            message: 'Invalid source address',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n\n                    if (new TonWeb.utils.Address(tx.from).toString(false) !== new TonWeb.utils.Address(this.myAddress).toString(false)) {\n                        throw {\n                            message: 'Different source address',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                if (tx.network) {\n                    if (tx.network !== TONCONNECT_TESTNET && tx.network !== TONCONNECT_MAINNET) {\n                        throw {\n                            message: 'Invalid network',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n\n                    if ((tx.network === TONCONNECT_TESTNET) !== !!this.isTestnet) {\n                        throw {\n                            message: 'Different network',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                if (!tx.messages || !tx.messages.length) {\n                    throw {\n                        message: 'no messages',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                const convertTonconnectMessage = (message) => {\n                    try {\n                        if (!message.address) {\n                            throw new Error('no address')\n                        }\n                        if (!Address.isValid(message.address)) {\n                            throw new Error('invalid address');\n                        }\n                        if (!message.amount) {\n                            throw new Error('no amount')\n                        }\n                        message.amount = new BN(message.amount);\n                        if (message.payload) {\n                            message.payload = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(message.payload));\n                        }\n                        if (message.stateInit) {\n                            message.stateInit = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(message.stateInit));\n                        }\n\n                        return {\n                            amount: message.amount,\n                            toAddress: message.address,\n                            comment: message.payload,\n                            needEncryptComment: false,\n                            stateInit: message.stateInit\n                        }\n                    } catch (e) {\n                        throw {\n                            message: e.message,\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                const messages = [];\n                for (const message of tx.messages) {\n                    messages.push(convertTonconnectMessage(message));\n                }\n\n                this.sendToView('showPopup', {\n                    name: 'loader',\n                });\n\n                /** @type {Cell | null} */\n                const sentBoc = await this.showSendConfirm(\n                    {\n                        expireAt: expireAt,\n                        messages\n                    },\n                    needQueue\n                );\n\n                if (!sentBoc) {\n                    this.sendToView('closePopup');\n                    throw {\n                        message: 'Reject request',\n                        code: 300 // USER_REJECTS_ERROR\n                    }\n                }\n\n                return TonWeb.utils.bytesToBase64(await sentBoc.toBoc(false));\n\n            case 'ton_requestAccounts':\n                return (this.myAddress ? [this.myAddress] : []);\n            case 'ton_requestWallets':\n                if (!this.myAddress) {\n                    return [];\n                }\n                if (!this.publicKeyHex) {\n                    await this.requestPublicKey(needQueue);\n                }\n                const walletVersion = await storage.getItem('walletVersion');\n                return [{\n                    address: this.myAddress,\n                    publicKey: this.publicKeyHex,\n                    walletVersion: walletVersion\n                }];\n            case 'ton_getBalance':\n                await this.updateBalance();\n                return (this.balance ? this.balance.toString() : '');\n            case 'ton_sendTransaction':\n                const param = params[0];\n                await showExtensionWindow();\n\n                if (param.data) {\n                    if (param.dataType === 'hex') {\n                        param.data = TonWeb.utils.hexToBytes(param.data);\n                    } else if (param.dataType === 'base64') {\n                        param.data = TonWeb.utils.base64ToBytes(param.data);\n                    } else if (param.dataType === 'boc') {\n                        param.data = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(param.data));\n                    }\n                }\n                if (param.stateInit) {\n                    param.stateInit = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(param.stateInit));\n                }\n\n                this.sendToView('showPopup', {\n                    name: 'loader',\n                });\n\n                const result = await this.showSendConfirm(\n                    {\n                        messages: [{\n                            amount: new BN(param.value),\n                            toAddress: param.to,\n                            comment: param.data,\n                            needEncryptComment: false,\n                            stateInit: param.stateInit,\n                        }]\n                    },\n                    needQueue\n                );\n                if (!result) {\n                    this.sendToView('closePopup');\n                }\n                return !!result;\n            case 'ton_rawSign':\n                const signParam = params[0];\n                await showExtensionWindow();\n\n                return this.showSignConfirm(signParam.data, false, needQueue);\n            case 'flushMemoryCache':\n                await chrome.webRequest.handlerBehaviorChanged();\n                return true;\n            default:\n                throw {\n                    message: `Method \"${method}\" not implemented`,\n                    code: 400 // METHOD_NOT_SUPPORTED\n                };\n        }\n    }\n}\n\nconst controller = new Controller();\n\nif (IS_EXTENSION) {\n    chrome.runtime.onConnect.addListener(port => {\n        if (port.name === 'gramWalletContentScript') { // dapp\n            contentScriptPorts.add(port)\n            port.onMessage.addListener(async (msg, port) => {\n                if (msg.type === 'gramWalletAPI_ton_provider_connect') {\n                    controller.whenReady.then(() => {\n                        controller.initDapp();\n                    });\n                }\n\n                if (!msg.message) return;\n\n                const origin = decodeURIComponent(msg.message.origin);\n\n                let result = undefined;\n                let error = undefined;\n                try {\n                    result = await controller.onDappMessage(msg.message.method, msg.message.params, origin);\n                } catch (e) {\n                    console.error(e);\n                    error = {\n                        message: e.message,\n                        code: e.code || 0\n                    };\n                }\n                if (port) {\n                    port.postMessage(JSON.stringify({\n                        type: 'gramWalletAPI',\n                        message: {jsonrpc: '2.0', id: msg.message.id, method: msg.message.method, result, error}\n                    }));\n                }\n            });\n            port.onDisconnect.addListener(port => {\n                contentScriptPorts.delete(port)\n            })\n        } else if (port.name === 'gramWalletPopup') { // view\n            popupPort = port;\n            popupPort.onMessage.addListener(function (msg) {\n                if (msg.method === 'response') {\n                    const resolver = controller.pendingMessageResolvers.get(msg.id);\n                    if (resolver) {\n                        resolver(msg.result);\n                        controller.pendingMessageResolvers.delete(msg.id);\n                    }\n                } else {\n                    controller.onViewMessage(msg.method, msg.params);\n                }\n            });\n            popupPort.onDisconnect.addListener(() => {\n                popupPort = null;\n            });\n\n            const runQueueToPopup = () => {\n                queueToPopup.forEach(msg => popupPort.postMessage(msg));\n                queueToPopup.length = 0;\n            };\n\n            if (!controller.myAddress) { // if controller not initialized yet\n                runQueueToPopup();\n            }\n\n            controller.whenReady.then(async () => {\n                await controller.initView();\n                runQueueToPopup();\n            });\n        }\n    });\n\n    let actionApiName = 'action';\n    if (chrome.runtime.getManifest().manifest_version === 2) actionApiName = 'browserAction';\n\n    chrome[actionApiName].onClicked.addListener(showExtensionWindow);\n\n    chrome.windows.onRemoved.addListener(removedWindowId => {\n        if (dAppPromise) dAppPromise.resolve(false);\n\n        if (removedWindowId !== extensionWindowId) return;\n        extensionWindowId = -1;\n    });\n}\n\n/******/ })()\n;"
  },
  {
    "path": "docs/js/View.js",
    "content": "/******/ (() => { // webpackBootstrap\n/******/ \t\"use strict\";\n/******/ \t// The require scope\n/******/ \tvar __webpack_require__ = {};\n/******/ \t\n/************************************************************************/\n/******/ \t/* webpack/runtime/make namespace object */\n/******/ \t(() => {\n/******/ \t\t// define __esModule on exports\n/******/ \t\t__webpack_require__.r = (exports) => {\n/******/ \t\t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t\t}\n/******/ \t\t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t\t};\n/******/ \t})();\n/******/ \t\n/************************************************************************/\nvar __webpack_exports__ = {};\n// ESM COMPAT FLAG\n__webpack_require__.r(__webpack_exports__);\n\n;// CONCATENATED MODULE: ./src/js/view/Utils.js\n// UI Utils\n\n/**\n * @param selector  {string}\n * @return {HTMLElement | null}\n */\nfunction $(selector) {\n    return document.querySelector(selector);\n}\n\n/**\n * @param selector  {string}\n * @return {NodeListOf<HTMLElement>}\n */\nfunction $$(selector) {\n    return document.querySelectorAll(selector);\n}\n\n/**\n * @param div   {HTMLElement}\n * @param visible {boolean | 'none' | 'block' | 'flex' | 'inline-block'}\n */\nfunction toggle(div, visible) {\n    let d = visible;\n    if (visible === true) d = 'block';\n    if (visible === false) d = 'none';\n\n    div.style.display = d;\n}\n\n/**\n * @param div   {HTMLElement}\n * @param isVisible {boolean}\n * @param params?    {{isBack?: boolean}}\n */\nfunction toggleFaded(div, isVisible, params) {\n    params = params || {};\n    if (params.isBack) {\n        div.classList.add('isBack');\n    } else {\n        div.classList.remove('isBack');\n    }\n    if (isVisible) {\n        div.classList.add('faded-show');\n        div.classList.remove('faded-hide');\n    } else {\n        div.classList.remove('faded-show');\n        div.classList.add('faded-hide');\n    }\n}\n\n/**\n * @param div   {HTMLElement}\n * @param className {string}\n * @param duration  {number}\n */\nfunction triggerClass(div, className, duration) {\n    div.classList.add(className);\n\n    setTimeout(() => {\n        div.classList.remove(className);\n    }, duration);\n}\n\n/**\n * @param params    {{tag: string, clazz?: string | (string | undefined)[], text?: string, child?: (HTMLElement | undefined)[], style?: Object<string, string>}}\n * @return {HTMLElement}\n */\nfunction createElement(params) {\n    const item = document.createElement(params.tag);\n    if (params.clazz) {\n        if (Array.isArray(params.clazz)) {\n            for (let c of params.clazz) {\n                if (c) {\n                    item.classList.add(c);\n                }\n            }\n        } else {\n            item.classList.add(params.clazz);\n        }\n    }\n    if (params.text) item.innerText = params.text;\n    if (params.child) {\n        for (let c of params.child) {\n            if (c) {\n                item.appendChild(c);\n            }\n        }\n    }\n    if (params.style) {\n        for (let key in params.style) {\n            item.style[key] = params.style[key];\n        }\n    }\n    return item;\n}\n\n/**\n * @param el {HTMLElement}\n * @param s  {string}\n * @return {HTMLElement}\n */\nfunction setAddr(el, s) {\n    el.innerHTML = '';\n    el.appendChild(document.createTextNode(s.substring(0, s.length / 2)));\n    el.appendChild(document.createElement('wbr'));\n    el.appendChild(document.createTextNode(s.substring(s.length / 2)));\n    return el;\n}\n\n/**\n * @param el    {HTMLElement}\n */\nfunction clearElement(el) {\n    el.innerHTML = '';\n}\n\n/**\n * @param input {HTMLElement}\n * @param handler   {(e: Event) => void}\n */\nfunction onInput(input, handler) {\n    input.addEventListener('change', handler);\n    input.addEventListener('input', handler);\n    input.addEventListener('cut', handler);\n    input.addEventListener('paste', handler);\n}\n\n/**\n * @param n {number}\n * @return {string}\n */\nfunction doubleZero(n) {\n    if (n < 10) return '0' + n;\n    return n.toString();\n}\n\n/**\n * @param date  {Date}\n * @return {string}\n */\nfunction formatTime(date) {\n    return doubleZero(date.getHours()) + ':' + doubleZero(date.getMinutes());\n}\n\nconst MONTH_NAMES = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\n\n/**\n * @param date  {Date}\n * @return {string}\n */\nfunction formatDate(date) {\n    return MONTH_NAMES[date.getMonth()] + ' ' + date.getDate();\n}\n\n/**\n * @param date  {Date}\n * @return {string}\n */\nfunction formatDateFull(date) {\n    return date.toString();\n}\n\n/**\n * @param text  {string}\n * @return {boolean}\n */\nfunction copyToClipboard(text) {\n    /** @type {HTMLTextAreaElement} */\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";  //avoid scrolling to bottom\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n\n    /** @type {boolean} */\n    let result = false;\n    try {\n        result = document.execCommand('copy');\n    } catch (err) {\n    }\n\n    document.body.removeChild(textArea);\n    return result;\n}\n\nconst IMPORT_WORDS_COUNT = 24;\nconst CONFIRM_WORDS_COUNT = 3;\n\n\n\n;// CONCATENATED MODULE: ./src/js/view/Lottie.js\n\n\n/**\n * @type {Object<string, any>} lottie name -> lottie element\n */\nconst lotties = {};\n\n/**\n * @param div   {HTMLElement}\n * @return {Promise<void>}\n */\nfunction initLottie(div) {\n    return new Promise((resolve, reject) => {\n        const url = div.getAttribute('src');\n        const name = div.getAttribute('data-name');\n        const w = Number(div.getAttribute('width'));\n        const h = Number(div.getAttribute('height'));\n\n        const xmlHttp = new XMLHttpRequest();\n        xmlHttp.responseType = 'arraybuffer';\n        xmlHttp.onreadystatechange = function () {\n            if (xmlHttp.readyState === 4) {\n                if (xmlHttp.status === 200) {\n                    const canvas = document.createElement('canvas');\n                    canvas.setAttribute('width', w * window.devicePixelRatio);\n                    canvas.setAttribute('height', h * window.devicePixelRatio);\n                    canvas.style.width = w + 'px';\n                    canvas.style.height = h + 'px';\n                    div.appendChild(canvas);\n                    const ctx = canvas.getContext('2d');\n\n                    const animationData = JSON.parse(new TextDecoder('utf-8').decode(pako.inflate(xmlHttp.response)));\n                    lotties[name] = {\n                        ctx: ctx,\n                        player: lottie.loadAnimation({\n                            renderer: 'canvas',\n                            loop: name === 'processing' || name === 'start' || name === 'about' || name === 'symbol',\n                            autoplay: false,\n                            animationData,\n                            rendererSettings: {\n                                context: ctx,\n                                scaleMode: 'noScale',\n                                clearCanvas: true\n                            },\n                        })\n                    };\n                    ctx.clearRect(0, 0, 1000, 1000);\n                    resolve();\n                } else {\n                    reject();\n                }\n            }\n        };\n        xmlHttp.open(\"GET\", url, true);\n        xmlHttp.send(null);\n    });\n}\n\n/**\n * @return {Promise<void>}\n */\nasync function initLotties() {\n    const divs = $$('tgs-player');\n    for (let i = 0; i < divs.length; i++) {\n        try {\n            await initLottie(divs[i]);\n        } catch (e) {\n        }\n    }\n}\n\n/**\n * @param lottie?   {any}\n * @param visible   {boolean}\n * @param params?    {{hideDelay?: number}}\n */\nfunction toggleLottie(lottie, visible, params) {\n    if (!lottie) return;\n\n    params = params || {};\n    clearTimeout(lottie.hideTimeout);\n    if (visible) {\n        lottie.player.play();\n    } else {\n        lottie.player.stop();\n\n        if (params.hideDelay) {\n            lottie.hideTimeout = setTimeout(() => {\n                lottie.ctx.clearRect(0, 0, 1000, 1000);\n            }, params.hideDelay);\n        } else {\n            lottie.ctx.clearRect(0, 0, 1000, 1000);\n        }\n    }\n}\n\n\n;// CONCATENATED MODULE: ./src/js/view/DropDown.js\n\n\nclass DropDown {\n    /**\n     * @param container {HTMLElement}\n     * @param onEnter   {(input: HTMLInputElement) => void}\n     * @param mnemonicWords {string[]}\n     */\n    constructor(container, onEnter, mnemonicWords) {\n        /** @type {HTMLElement} */\n        this.container = container;\n        /** @type {(input: HTMLInputElement) => void} */\n        this.onEnter = onEnter;\n        /** @type {string[]} */\n        this.mnemonicWords = mnemonicWords;\n        /** @type {number} */\n        this.selectedI = -1;\n    }\n\n    /**\n     * @param input {HTMLInputElement}\n     * @param text  {string}\n     */\n    show(input, text) {\n        clearElement(this.container);\n\n        /**\n         * @param e {MouseEvent}\n         */\n        const onMouseDown = e => {\n            input.value = e.target.innerText;\n            input.classList.remove('error');\n            this.hide();\n            e.preventDefault();\n            this.onEnter(input);\n        };\n\n        this.mnemonicWords\n            .filter(w => w.indexOf(text) === 0)\n            .forEach(w => {\n                const item = createElement({tag: 'div', clazz: 'words-popup-item', text: w});\n                item.addEventListener('mousedown', onMouseDown);\n                this.container.appendChild(item);\n            });\n\n        this.selectedI = -1;\n        if (this.container.children.length > 0) this.select(0);\n\n        this.container.style.left = input.offsetLeft + 'px';\n        this.container.style.top = (input.offsetTop + input.offsetHeight) + 'px';\n        toggle(this.container, true);\n    };\n\n    hide() {\n        toggle(this.container, false);\n        clearElement(this.container);\n        this.selectedI = -1;\n    }\n\n    /**\n     * @param i {number}\n     */\n    select(i) {\n        if (this.selectedI > -1) {\n            this.container.children[this.selectedI].classList.remove('selected');\n        }\n        this.selectedI = i;\n        if (this.selectedI > -1) {\n            this.container.children[this.selectedI].classList.add('selected');\n            const ITEM_HEIGHT = 30;\n            this.container.scrollTo(0, ITEM_HEIGHT * this.selectedI);\n        }\n    }\n\n    /**\n     * @return {null | string}\n     */\n    getSelectedText() {\n        if (this.selectedI === -1) return null;\n        return this.container.children[this.selectedI].innerText;\n    }\n\n    up() {\n        if (this.selectedI === -1) return;\n\n        if (this.selectedI > 0) {\n            this.select(this.selectedI - 1);\n        }\n    }\n\n    down() {\n        if (this.selectedI === -1) return;\n\n        if (this.selectedI < this.container.children.length - 1) {\n            this.select(this.selectedI + 1);\n        }\n    }\n}\n\n;// CONCATENATED MODULE: ./src/js/view/View.js\n\n\n\n\n\nconst toNano = TonWeb.utils.toNano;\nconst fromNano = TonWeb.utils.fromNano;\nconst BN = TonWeb.utils.BN;\n\nconst IS_EXTENSION = !!(self.chrome && chrome.runtime && chrome.runtime.onConnect);\nconst IS_FIREFOX = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\n/**\n * @param text  {string}\n * @param containerSelector {string}\n */\nconst drawQRCode = (text, containerSelector) => {\n    const $container = $(containerSelector);\n\n    clearElement($container);\n\n    new QRCode($container, {\n        text: text,\n        width: 185 * window.devicePixelRatio,\n        height: 185 * window.devicePixelRatio,\n        colorDark: '#303757',\n        logo: \"assets/ui/qr-logo.png\",\n        logoBackgroundTransparent: false,\n        logoWidth: 44 * window.devicePixelRatio,\n        logoHeight: 44 * window.devicePixelRatio,\n        correctLevel: QRCode.CorrectLevel.L\n    });\n\n    const canvas = $container.querySelector('canvas');\n    canvas.style.width = '185px';\n    canvas.style.height = '185px';\n};\n\nclass View {\n    /**\n     * @param mnemonicWords {string[]}\n     */\n    constructor(mnemonicWords) {\n        /** @type   {string[]} */\n        this.mnemonicWords = mnemonicWords;\n        /** @type {Controller | null} */\n        this.controller = null;\n        /** @type {any | null} */\n        this.port = null;\n        /** @type   {string | null} */\n        this.myAddress = null;\n        /** @type   {string | null} */\n        this.address = null;\n        /** @type   {BN | null} */\n        this.balance = null;\n        /** @type   {string | null} */\n        this.currentScreenName = null;\n        /** @type   {boolean} */\n        this.isTestnet = false;\n        /** @type   {string} */\n        this.popup = ''; // current opened popup name\n\n        /** @type   {boolean} */\n        this.isBack = false;\n        /** @type   {number} */\n        this.backupShownTime = 0;\n\n        /** @type {any | null} */\n        this.currentOpenTransaction = null;\n\n        /** @type {string | null} */\n        this.currentTransactionAddr = null;\n\n        this.createWordInputs({\n            count: IMPORT_WORDS_COUNT,\n            dropdownId: '#wordsPopup',\n            inputId: '#importsInput',\n            containerId: '#importWords',\n            multiColumns: true\n        });\n        this.createWordInputs({\n            count: CONFIRM_WORDS_COUNT,\n            dropdownId: '#wordsConfirmPopup',\n            inputId: '#confirmInput',\n            containerId: '#confirmWords',\n            multiColumns: false\n        });\n\n        /** @type {Promise<void>} */\n        this._initLotties = initLotties().then(() => {\n            if (this.currentScreenName) {\n                toggleLottie(lotties[this.currentScreenName], true);\n                toggleLottie(lotties.symbol, this.currentScreenName === 'main');\n            }\n        });\n\n        /**\n         * @param e {Event}\n         */\n        function resetErrors(e) {\n            const input = e.target;\n            input.classList.remove('error');\n        }\n\n        onInput($('#amountInput'), resetErrors);\n        onInput($('#toWalletInput'), resetErrors);\n        onInput($('#commentInput'), resetErrors);\n        onInput($('#createPassword_repeatInput'), resetErrors);\n        onInput($('#enterPassword_input'), resetErrors);\n        onInput($('#changePassword_oldInput'), resetErrors);\n        onInput($('#changePassword_newInput'), resetErrors);\n        onInput($('#changePassword_repeatInput'), resetErrors);\n\n        /**\n         * @param e {ClipboardEvent}\n         * @return {string}\n         */\n        function getClipboardData(e) {\n            const s = (e.clipboardData || window.clipboardData).getData('text');\n            try {\n                return decodeURI(s).replaceAll(/%23/g, '#');\n            } catch (e) { // URIError\n                return s;\n            }\n        }\n\n        $('#toWalletInput').addEventListener('paste', e => {\n            const urlString = getClipboardData(e);\n\n            if (!urlString.startsWith('ton://')) return;\n\n            /** @type {{address: string, amount?: string, text?: string} | null } */\n            let parsedTransferUrl = null;\n            try {\n                parsedTransferUrl = TonWeb.utils.parseTransferUrl(urlString);\n            } catch (e) {\n                $('#notify').innerText = 'Parse transfer URL error';\n                triggerClass($('#notify'), 'faded-show', 2000);\n                return;\n            }\n\n            $('#toWalletInput').value = parsedTransferUrl.address;\n\n            if (parsedTransferUrl.amount) {\n                $('#amountInput').value = fromNano(new BN(parsedTransferUrl.amount));\n            }\n\n            if (parsedTransferUrl.text) {\n                $('#commentInput').value = parsedTransferUrl.text;\n            }\n\n            e.preventDefault();\n        });\n\n        onInput($('#invoice_amountInput'), () => this.updateInvoiceLink());\n        onInput($('#invoice_commentInput'), () => this.updateInvoiceLink());\n\n        $(\"#start_createBtn\").addEventListener('click', () => this.sendMessage('showScreen', {name: 'created'}));\n        $(\"#start_importBtn\").addEventListener('click', () => this.sendMessage('showScreen', {name: 'import'}));\n\n        /** @type {boolean} */\n        let needShowLedger = false;\n        try {\n            needShowLedger = window.location.href.indexOf('ledgerReview') > -1;\n        } catch (e) {\n\n        }\n        if (needShowLedger) {\n            toggle($(\"#start_importLedgerHidBtn\"), 'inline-block');\n        }\n\n        $(\"#start_importLedgerHidBtn\").addEventListener('click', () => {\n            this.showPopup('connectLedger');\n            this.sendMessage('showScreen', {name: 'importLedger', transportType: 'hid'});\n        });\n        // $(\"#start_importLedgerBleBtn\").addEventListener('click', () => this.sendMessage('showScreen', {name: 'importLedger', transportType: 'ble'}));\n\n        // $('#main_buyBtn').addEventListener('click', () => {\n        //     window.open('https://exchange.mercuryo.io/?currency=TONCOIN&address=' + this.myAddress, '_blank');\n        // });\n\n        $('#import_backBtn').addEventListener('click', () => {\n            this.isBack = true;\n            this.sendMessage('onImportBack');\n        });\n\n        $('#import_alertBtn').addEventListener('click', () => {\n            this.showAlert({\n                title: 'Too Bad',\n                message: 'Without the secret words, you can\\'t restore access to your wallet.',\n                buttons: [\n                    {\n                        label: 'CANCEL',\n                        callback: () => {\n                            this.isBack = true;\n                            this.sendMessage('onImportBack');\n                        }\n                    },\n                    {\n                        label: 'ENTER WORDS',\n                        callback: () => {\n                            this.closePopup();\n                        }\n                    },\n                ]\n            });\n        });\n        $('#import_continueBtn').addEventListener('click', async (e) => {\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('import', {words: await this.getImportWords()});\n        });\n\n        $('#createdContinueButton').addEventListener('click', () => this.sendMessage('createPrivateKey'));\n\n        $('#backup_continueBtn').addEventListener('click', () => {\n            const currentTime = Date.now();\n            if (currentTime - this.backupShownTime < 60000) { // 1 minute\n                this.showAlert({\n                    title: 'Sure done?',\n                    message: 'You didn\\'t have enough time to write these words down.',\n                    buttons: [\n                        {\n                            label: 'I\\'M SURE',\n                            callback: () => {\n                                this.sendMessage('onBackupDone');\n                            }\n                        },\n                        {\n                            label: 'OK, SORRY',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            } else {\n                this.sendMessage('onBackupDone');\n            }\n        });\n\n        $('#wordsConfirm_backBtn').addEventListener('click', () => {\n            this.isBack = true;\n            this.sendMessage('onConfirmBack');\n        });\n\n        $('#wordsConfirm_continueBtn').addEventListener('click', () => {\n            const confirmWords = this.getConfirmWords();\n\n            if (!confirmWords.isWordsFromList) {\n                return;\n            }\n\n            if (!confirmWords.isRightWords) {\n                this.showAlert({\n                    title: 'Incorrect words',\n                    message: 'The secret words you have entered do not match the ones in the list.',\n                    buttons: [\n                        {\n                            label: 'SEE WORDS',\n                            callback: () => {\n                                this.isBack = true;\n                                this.sendMessage('onConfirmBack');\n                            }\n                        },\n                        {\n                            label: 'TRY AGAIN',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            } else {\n                this.sendMessage('onConfirmDone', {words: confirmWords.words});\n            }\n        });\n\n\n        $('#createPassword_continueBtn').addEventListener('click', (e) => {\n            /** @type {string} */\n            const password = $('#createPassword_input').value;\n            /** @type {string} */\n            const passwordRepeat = $('#createPassword_repeatInput').value;\n\n            const isEmpty = password.length === 0 && !this.isTestnet;\n\n            if (isEmpty) {\n                $('#createPassword_input').classList.add('error');\n            } else if (password !== passwordRepeat) {\n                $('#createPassword_repeatInput').classList.add('error');\n            } else {\n                this.toggleButtonLoader(e.currentTarget, true);\n                this.sendMessage('passwordCreated', {password});\n            }\n        });\n\n        $('#readyToGo_continueBtn').addEventListener('click', () => this.sendMessage('showMain'));\n\n        $('#main_refreshBtn').addEventListener('click', () => {\n            this.setUpdating(true);\n            this.sendMessage('update');\n        });\n        $('#main_settingsButton').addEventListener('click', () => this.onSettingsClick());\n\n        $('#main_receiveBtn').addEventListener('click', () => {\n            toggle($('#receive_showAddressOnDeviceBtn'), !!this.isLedger);\n            this.showPopup('receive');\n        });\n        $('#sendButton').addEventListener('click', () => this.onMessage('showPopup', {name: 'send'}));\n\n        $('#modal').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n\n        if (IS_FIREFOX) {\n            toggle($('#menu_magic'), false);\n            toggle($('.about-magic'), false);\n        }\n\n        $('#menu_magic').addEventListener('click', () => {\n            $('#menu_magic .dropdown-toggle').classList.toggle('toggle-on');\n            const isTurnedOn = $('#menu_magic .dropdown-toggle').classList.contains('toggle-on');\n            $('#menu_telegram').classList.toggle('menu_telegram-show', isTurnedOn);\n            this.sendMessage('onMagicClick', isTurnedOn);\n        });\n\n        $('#menu_telegram').addEventListener('click', () => {\n            window.open('https://web.telegram.org/z', '_blank');\n        });\n\n        $('#menu_proxy').addEventListener('click', () => {\n            $('#menu_proxy .dropdown-toggle').classList.toggle('toggle-on');\n            this.sendMessage('onProxyClick', $('#menu_proxy .dropdown-toggle').classList.contains('toggle-on'));\n        });\n\n        $('#menu_extension_chrome').addEventListener('click', () => window.open('https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd', '_blank'));\n        $('#menu_extension_firefox').addEventListener('click', () => window.open('https://addons.mozilla.org/ru/firefox/addon/', '_blank'));\n        $('#menu_about').addEventListener('click', () => this.showPopup('about'));\n        $('#menu_changePassword').addEventListener('click', () => this.onMessage('showPopup', {name: 'changePassword'}));\n        $('#menu_backupWallet').addEventListener('click', () => this.sendMessage('onBackupWalletClick'));\n        $('#menu_delete').addEventListener('click', () => this.showPopup('delete'));\n\n        $('#receive_showAddressOnDeviceBtn').addEventListener('click', () => this.onShowAddressOnDevice());\n        $('#receive_invoiceBtn').addEventListener('click', () => this.onCreateInvoiceClick());\n        $('#receive_shareBtn').addEventListener('click', () => this.onShareAddressClick(false));\n        $('#receive .addr').addEventListener('click', () => this.onShareAddressClick(true));\n        $('#receive_closeBtn').addEventListener('click', () => this.closePopup());\n\n        $('#invoice_qrBtn').addEventListener('click', () => this.onCreateInvoiceQrClick());\n        $('#invoice_shareBtn').addEventListener('click', () => this.onShareInvoiceClick());\n        $('#invoice_closeBtn').addEventListener('click', () => this.showPopup('receive'));\n\n        $('#invoiceQr_shareBtn').addEventListener('click', () => this.onShareInvoiceClick());\n        $('#invoiceQr_closeBtn').addEventListener('click', () => this.showPopup('invoice'));\n\n        $('#transaction_sendBtn').addEventListener('click', () => this.onTransactionButtonClick());\n        $('#transaction_closeBtn').addEventListener('click', () => this.closePopup());\n\n        $('#connectLedger_cancelBtn').addEventListener('click', () => this.closePopup());\n\n        $('#send_btn').addEventListener('click', (e) => {\n            /** @type {string} */\n            const amount = $('#amountInput').value;\n            /** @type {BN} */\n            const amountNano = toNano(amount);\n            if (!amountNano.gt(new BN(0)) || this.balance.lt(amountNano)) {\n                $('#amountInput').classList.add('error');\n                return;\n            }\n\n            /** @type {string} */\n            const toAddressString = $('#toWalletInput').value;\n            /** @type {Address | null} */\n            let toAddress = null;\n            try {\n                toAddress = new TonWeb.utils.Address(toAddressString);\n            } catch (e) {\n            }\n            if (!toAddressString.toLowerCase().endsWith('.ton') && !toAddressString.toLowerCase().endsWith('.t.me') && !toAddress) {\n                $('#toWalletInput').classList.add('error');\n                return;\n            }\n\n            /** @type {string} */\n            const comment = $('#commentInput').value;\n            /** @type {boolean} */\n            const needEncryptComment = $('#encryptCommentCheckbox').checked;\n            if (comment.length > 1024) {\n                $('#commentInput').classList.add('error');\n                $('#notify').innerText = 'Maximum 1024 symbols';\n                triggerClass($('#notify'), 'faded-show', 2000);\n                return;\n            }\n\n            // from https://github.com/tonkeeper/ton-assets/blob/main/accounts.json with \"require_memo\": true\n            const exchangeAddresses = [\n                '0:5f00decb7da51881764dc3959cec60609045f6ca1b89e646bde49d492705d77f', // OKX\n                '0:b31535e934db05bbc220267467903c8108bdabcbc2a06588838b726ddf589ef0', // FTX\n                '0:57eb74407604a19f7e04005315ef70aeb7b675e6551977586756f6baf12125ee', // MEXC\n                '0:7994848c1fcbcbc57a6a5a987b66eb424b8b54e10759b6b514a66b600c2b0eef', // EXMO\n                '0:8d195793baad9a08c46dc353aebe999341dabd07721b9725f19e18abc3d10d92', // EXMO Cold Storage 1\n                '0:26ab8ae763a3a7c3067d882b7b01cd5d37254cb8768f57b6a47c00028effc7b8', // EXMO Cold Storage 2\n                '0:0130c77346e9ed82df677d107ad6a775c11f9c18f6a05c0dd17906b355850dad', // EXMO Deposit\n                '0:342a359e38357c083968129fddddf049ef5c47315bfbef27505a356bf9f02d65', // CoinEx\n                '0:555f3053e257130374bb831ae0e219e5e5f9ec0ca8f8a0d133369d3d690c64c2', // Huobi Deposit\n                '0:85af78e8d035e920117cda654615cdf371d464480b629e110d3c5310d85ab362', // Huobi\n                '0:80d4123841167ca989ac912443cc99a4b9c1a87584536427ff6fd85c92395ae9', // Kucoin\n                '0:a14b1f452385b2bb984ad2c4441e1d23cae071fdfc096dfba53ebba3b6ff1d10', // Lbank.info\n                '0:c3f1da8ecda8f8cd42bace224ea3f1b6971eaa7f54c492d4d190527b4f573f7c', // Bybit\n                '0:008bb088e81e38d583826901093567027cc1575ec744ac354fa4eeec302d166d', // bit.com\n            ]\n\n            const isExchange = toAddress && (exchangeAddresses.indexOf(toAddress.toString(false)) > -1);\n\n            if (isExchange) {\n                if (!comment) {\n                    $('#notify').innerText = 'Exchange require text comment (MEMO) for deposit';\n                    triggerClass($('#notify'), 'faded-show', 2000);\n                    return;\n                }\n\n                if (comment && needEncryptComment) {\n                    $('#notify').innerText = `Can't encrypt comment when depositing on exchange`;\n                    triggerClass($('#notify'), 'faded-show', 2000);\n                    return;\n                }\n            }\n\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('onSend', {\n                amount: amountNano.toString(),\n                toAddress: toAddressString,\n                comment,\n                needEncryptComment\n            });\n        });\n        $('#send_closeBtn').addEventListener('click', () => this.closePopup());\n\n        $('#sendConfirm_closeBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n        $('#sendConfirm_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n        $('#sendConfirm_okBtn').addEventListener('click', () => this.onMessage('showPopup', {name: 'enterPassword'}));\n\n        $('#signConfirm_closeBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#signConfirm_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#signConfirm_okBtn').addEventListener('click', () => this.onMessage('showPopup', {name: 'enterPassword'}));\n\n        $('#connectConfirm_closeBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#connectConfirm_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#connectConfirm_okBtn').addEventListener('click', () => {\n            this.sendMessage('onConnectConfirmed', {});\n        });\n\n        $('#processing_closeBtn').addEventListener('click', () => this.closePopup());\n        $('#done_closeBtn').addEventListener('click', () => this.closePopup());\n        $('#about_closeBtn').addEventListener('click', () => this.closePopup());\n        $('#about_version').addEventListener('click', (e) => {\n            if (e.shiftKey) {\n                this.showAlert({\n                    title: 'Are you sure you want to switch between mainnet/testnet?',\n                    message: 'You can switch back the network by clicking on the version with the Shift key pressed',\n                    buttons: [\n                        {\n                            label: 'I\\'M SURE',\n                            callback: () => {\n                                this.sendMessage('toggleTestnet');\n                            }\n                        },\n                        {\n                            label: 'BACK',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            } else if (e.altKey) {\n                this.showAlert({\n                    title: 'Are you sure you want to switch between clear console/debug mode?',\n                    message: 'You can switch back the clear console by clicking on the version with the Alt key pressed',\n                    buttons: [\n                        {\n                            label: 'I\\'M SURE',\n                            callback: () => {\n                                this.sendMessage('toggleDebug');\n                            }\n                        },\n                        {\n                            label: 'BACK',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            }\n        });\n\n        $('#changePassword_cancelBtn').addEventListener('click', () => this.closePopup());\n        $('#changePassword_okBtn').addEventListener('click', async (e) => {\n            /** @type {string} */\n            const oldPassword = $('#changePassword_oldInput').value;\n            /** @type {string} */\n            const newPassword = $('#changePassword_newInput').value;\n            /** @type {string} */\n            const passwordRepeat = $('#changePassword_repeatInput').value;\n\n            const isEmpty = newPassword.length === 0 && !this.isTestnet;\n\n            if (isEmpty) {\n                $('#changePassword_newInput').classList.add('error');\n                return;\n            }\n\n            if (newPassword !== passwordRepeat) {\n                $('#changePassword_repeatInput').classList.add('error');\n                return;\n            }\n\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('onChangePassword', {oldPassword, newPassword});\n        });\n\n        $('#enterPassword_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n        $('#enterPassword_okBtn').addEventListener('click', async (e) => {\n            /** @type {string} */\n            const password = $('#enterPassword_input').value;\n\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('onEnterPassword', {password});\n        });\n\n        $('#delete_cancelBtn').addEventListener('click', () => this.closePopup());\n        $('#delete_okBtn').addEventListener('click', () => this.sendMessage('disconnect'));\n\n        $('#transactionDecryptCommentButton').addEventListener('click', () => {\n            if (!this.currentOpenTransaction) return;\n\n            this.sendMessage('decryptComment', {\n                hash: this.currentOpenTransaction.hash,\n                senderAddress: this.currentOpenTransaction.from_addr,\n                encryptedComment: this.currentOpenTransaction.encryptedComment,\n            });\n        });\n    }\n\n    // COMMON\n\n    /**\n     * @param name  {string}\n     */\n    showScreen(name) {\n        this.closePopup();\n\n        const screens = ['start', 'created', 'backup', 'wordsConfirm', 'import', 'createPassword', 'readyToGo', 'main'];\n\n        screens.forEach(screen => {\n            toggleFaded($('#' + screen), name === screen, {\n                isBack: this.isBack,\n            });\n\n            toggleLottie(lotties[screen], name === screen, {hideDelay: 300}); // 300ms, as for screen show/hide animation duration in CSS\n        });\n        toggleLottie(lotties.symbol, name === 'main', {hideDelay: 300});\n        this.currentScreenName = name;\n\n        this.isBack = false;\n\n        window.scrollTo(0, 0);\n    }\n\n    /**\n     * @param el    {HTMLElement}\n     * @param enable    {boolean}\n     */\n    toggleButtonLoader(el, enable) {\n        el.disabled = enable;\n        enable ? el.classList.add('btn-loader') : el.classList.remove('btn-loader');\n    }\n\n    /**\n     * @param params    {{title: string, message: string, buttons?: {label: string, callback: () => void}[]}}\n     */\n    showAlert(params) {\n        $('#alert .popup-title').innerText = params.title;\n        $('#alert .popup-black-text').innerText = params.message;\n        $('#alert .popup-footer').innerHTML = '';\n\n        if (params.buttons) {\n            params.buttons.forEach(button => {\n                const el = createElement({\n                    tag: 'button',\n                    clazz: 'btn-lite',\n                    text: button.label\n                });\n                $('#alert .popup-footer').appendChild(el);\n                el.addEventListener('click', button.callback);\n            });\n        }\n\n        this.showPopup('alert');\n    }\n\n    /**\n     * @param name  {string}\n     */\n    showPopup(name) {\n        this.popup = name;\n\n        $('#enterPassword_input').value = '';\n\n        //popups switching without animations\n        if (this.popup && name) {\n            triggerClass(document.body, 'disable-animations', 20);\n        }\n\n        toggleFaded($('#modal'), name !== '');\n\n        const popups = ['alert', 'receive', 'invoice', 'invoiceQr', 'send', 'sendConfirm', 'signConfirm', 'connectConfirm', 'processing', 'done', 'menuDropdown', 'about', 'delete', 'changePassword', 'enterPassword', 'transaction', 'connectLedger', 'loader'];\n\n        popups.forEach(popup => {\n            toggleFaded($('#' + popup), name === popup);\n            toggleLottie(lotties[popup], name === popup);\n        });\n    }\n\n    closePopup() {\n        this.currentOpenTransaction = null;\n        this.showPopup('');\n        this.sendMessage('onClosePopup');\n    }\n\n    // BACKUP SCREEN\n\n    /**\n     * @param words {string[]}\n     */\n    setBackupWords(words) {\n        /**\n         * @param n {number}\n         */\n        const createBackupWord = n => {\n            $('#createWords').appendChild(\n                createElement({\n                    tag: 'div',\n                    clazz: 'create-word-item',\n                    child: [\n                        createElement({\n                            tag: 'span',\n                            clazz: 'word-num',\n                            text: (n + 1) + '.'\n                        }),\n                        createElement({\n                            tag: 'span',\n                            style: {\n                                'font-weight': 'bold'\n                            },\n                            text: words[n]\n                        })\n                    ]\n                })\n            );\n        };\n\n        clearElement($('#createWords'));\n        for (let i = 0; i < words.length / 2; i++) {\n            createBackupWord(i);\n            createBackupWord(i + 12);\n        }\n    }\n\n    clearBackupWords() {\n        clearElement($('#createWords'));\n    }\n\n    // IMPORT && CONFIRM SCREENS\n\n    /**\n     * @param params    {{count: number, containerId: string, inputId: string, dropdownId: string, multiColumns: boolean}}\n     */\n    createWordInputs(params) {\n\n        /**\n         * @param input {HTMLInputElement}\n         */\n        const onEnter = input => {\n            const i = Number(input.getAttribute('tabindex'));\n            if (i === params.count) {\n\n            } else {\n                $(params.inputId + i).focus();\n            }\n        };\n\n        const dropdown = new DropDown($(params.dropdownId), onEnter, this.mnemonicWords);\n\n        /** @type {HTMLInputElement | null} */\n        let lastInput = null;\n\n        /**\n         * @param input {HTMLInputElement}\n         */\n        const showWordsPopup = input => {\n            const text = input.value;\n            if (text === null || text.length === 0) {\n                toggle($(params.dropdownId), false);\n                return;\n            }\n\n            dropdown.show(input, text.toLowerCase());\n        };\n\n        /**\n         * @param e {Event}\n         */\n        function onWordInput(e) {\n            /** @type {HTMLInputElement} */\n            const input = e.target;\n            input.classList.remove('error');\n\n            showWordsPopup(input);\n        }\n\n        /**\n         * @param e {Event}\n         */\n        const onFocusIn = (e) => {\n            /** @type {HTMLInputElement} */\n            const input = e.target;\n            lastInput = input;\n            showWordsPopup(input);\n        };\n\n        /**\n         * @param e {Event}\n         */\n        const onFocusOut = (e) => {\n            toggle($(params.dropdownId), false);\n            if (lastInput) {\n                const value = lastInput.value.toLowerCase().trim();\n                if (value.length > 0 && this.mnemonicWords.indexOf(value) === -1) {\n                    lastInput.classList.add('error');\n                } else {\n                    lastInput.classList.remove('error');\n                }\n            }\n        };\n\n        /**\n         * @param e {KeyboardEvent}\n         */\n        const onKeyDown = (e) => {\n            /** @type {HTMLInputElement} */\n            const input = e.target;\n            switch (e.key) {\n                case 'Enter':\n                    const selectedText = dropdown.getSelectedText();\n                    if (selectedText) {\n                        input.value = selectedText;\n                        input.classList.remove('error');\n                        dropdown.hide();\n                    }\n                    onEnter(input);\n                    break;\n                case 'ArrowUp':\n                    dropdown.up();\n                    break;\n                case 'ArrowDown':\n                    dropdown.down();\n                    break;\n            }\n        };\n\n        /**\n         * @param event {ClipboardEvent}\n         */\n        const onPaste = (event) => {\n            const text = (event.clipboardData || window.clipboardData).getData('text');\n            let arr = text.split(' ');\n            if (arr.length !== params.count) {\n                arr = text.split(',');\n            }\n            if (arr.length === params.count) {\n                for (let i = 0; i < params.count; i++) {\n                    /** @type {HTMLInputElement} */\n                    const input = $(params.inputId + i);\n                    const value = arr[i].toLowerCase().trim();\n                    if (!value || this.mnemonicWords.indexOf(value) === -1) {\n                        input.classList.add('error');\n                    } else {\n                        input.classList.remove('error');\n                    }\n                    input.value = value;\n                }\n                event.preventDefault();\n            }\n        };\n\n        /**\n         * @param n {number}\n         */\n        const createInput = (n) => {\n            const inputContainer = createElement({tag: 'div', clazz: 'word-item'});\n            const span = createElement({tag: 'span', clazz: 'word-num', text: (n + 1) + '.'});\n            inputContainer.appendChild(span);\n            /** @type {HTMLInputElement} */\n            const input = createElement({tag: 'input'});\n            input.id = params.inputId.slice(1) + n;\n            input.type = 'text';\n            input.tabIndex = n + 1;\n            input.autocomplete = 'off';\n            inputContainer.appendChild(input);\n\n            input.addEventListener('focusin', onFocusIn);\n            input.addEventListener('focusout', onFocusOut);\n            input.addEventListener('keydown', onKeyDown);\n            input.addEventListener('paste', onPaste);\n            onInput(input, onWordInput);\n\n            $(params.containerId).appendChild(inputContainer);\n        };\n\n        if (params.multiColumns) {\n            for (let i = 0; i < params.count / 2; i++) {\n                createInput(i);\n                createInput(i + params.count / 2);\n            }\n        } else {\n            for (let i = 0; i < params.count; i++) {\n                createInput(i);\n            }\n        }\n    }\n\n    clearImportWords() {\n        toggle($('#wordsPopup'), false);\n        for (let i = 0; i < IMPORT_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#importsInput' + i);\n            input.value = '';\n            input.classList.remove('error');\n        }\n    }\n\n    clearConfirmWords() {\n        toggle($('#wordsConfirmPopup'), false);\n        for (let i = 0; i < CONFIRM_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#confirmInput' + i);\n            input.value = '';\n            input.setAttribute('data-word', '');\n            input.classList.remove('error');\n        }\n    }\n\n    /**\n     * @param words {string[]}\n     */\n    setConfirmWords(words) {\n        /** @type {number[]} */\n        const nums = Array(IMPORT_WORDS_COUNT)\n            .fill(0)\n            .map((_, index) => ({index, rnd: Math.random()}))\n            .sort((a, b) => a.rnd - b.rnd)\n            .map(item => item.index)\n            .slice(0, CONFIRM_WORDS_COUNT)\n            .sort((a, b) => a - b);\n\n        const spans = $$('#confirmWordsNums span');\n        for (let i = 0; i < CONFIRM_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#confirmInput' + i);\n            input.setAttribute('data-index', nums[i].toString());\n            input.setAttribute('data-word', words[nums[i]]);\n            spans[i].innerText = (nums[i] + 1).toString();\n            input.parentNode.children[0].innerText = (nums[i] + 1) + '.';\n        }\n    }\n\n    /**\n     * @return {Promise<string[] | null>}\n     */\n    async getImportWords() {\n        /** @type {boolean} */\n        let isValid = true;\n        /** @type {string[]} */\n        const words = [];\n        for (let i = 0; i < IMPORT_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#importsInput' + i);\n            /** @type {string} */\n            const value = input.value.toLowerCase().trim();\n            if (!value || this.mnemonicWords.indexOf(value) === -1) {\n                input.classList.add('error');\n                isValid = false;\n            }\n            words.push(value);\n        }\n\n        if (isValid) {\n            isValid = await TonWeb.mnemonic.validateMnemonic(words);\n            if (!isValid) {\n                for (let i = 0; i < IMPORT_WORDS_COUNT; i++) {\n                    const input = $('#importsInput' + i);\n                    input.classList.add('error');\n                }\n            }\n        }\n\n        return isValid ? words : null;\n    }\n\n    /**\n     * @return {{isWordsFromList: boolean, isRightWords: boolean, words: null | Object<string, string>}} words - index to word\n     */\n    getConfirmWords() {\n        /** @type {boolean} */\n        let isWordsFromList = true;\n        /** @type {boolean} */\n        let isRightWords = true;\n        /** @type {Object<string, string>} */\n        const words = {};\n\n        for (let i = 0; i < CONFIRM_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#confirmInput' + i);\n            /** @type {string} */\n            const value = input.value.toLowerCase().trim();\n            /** @type {string} */\n            const index = input.getAttribute('data-index');\n            /** @type {string} */\n            const validValue = input.getAttribute('data-word');\n            if (!value || this.mnemonicWords.indexOf(value) === -1) {\n                input.classList.add('error');\n                isWordsFromList = false;\n            }\n            if (value !== validValue) {\n                isRightWords = false;\n            }\n            words[index] = value;\n        }\n\n        return {\n            isWordsFromList,\n            isRightWords,\n            words: isWordsFromList && isRightWords ? words : null\n        };\n    }\n\n    // CREATE PASSWORD SCREEN\n\n    clearCreatePassword() {\n        $('#createPassword_input').value = '';\n        $('#createPassword_repeatInput').value = '';\n    }\n\n    // CHANGE PASSWORD POPUP\n\n    clearChangePassword() {\n        $('#changePassword_oldInput').value = '';\n        $('#changePassword_newInput').value = '';\n        $('#changePassword_repeatInput').value = '';\n    }\n\n    // MAIN SCREEN\n\n    /**\n     * @param updating  {boolean}\n     */\n    setUpdating(updating) {\n        $('#updateLabel').innerText = updating ? 'updating..' : 'updated just now';\n    }\n\n    onSettingsClick() {\n        toggleFaded($('#modal'), true);\n        toggleFaded($('#menuDropdown'), true);\n        toggle($('#menu_changePassword'), !this.isLedger);\n        toggle($('#menu_backupWallet'), !this.isLedger);\n    }\n\n    clearBalance() {\n        clearElement($('#balance'));\n        clearElement($('#transactionsList'));\n        toggle($('#walletCreated'), false);\n    }\n\n    /**\n     * @param balance   {BN}\n     * @param txs   {any[]}\n     */\n    setBalance(balance, txs) {\n        this.balance = balance;\n        /** @type {string} */\n        let s = fromNano(balance);\n        if (s === '0') s = '0.00';\n        const i = s.indexOf('.');\n        const first = s.substring(0, i);\n        const last = s.substring(i);\n\n        clearElement($('#balance'));\n        $('#balance').appendChild(createElement({tag: 'span', text: first}));\n        $('#balance').appendChild(createElement({tag: 'span', style: {'font-size': '24px'}, text: last}));\n\n        $('#sendBalance').innerText = 'Balance: ' + s + ' 💎';\n        toggle($('#sendButton'), balance.gt(new BN(0)) ? 'inline-block' : 'none');\n        this.setTransactions(txs);\n        this.setUpdating(false);\n    }\n\n    /**\n     * @param txs   {any[]}\n     */\n    setTransactions(txs) {\n        clearElement($('#transactionsList'));\n        /** @type {string} */\n        let date = '';\n\n        toggle($('#walletCreated'), txs.length === 0);\n\n        txs.forEach(tx => {\n            tx.amount = new BN(tx.amount);\n            tx.fee = new BN(tx.fee);\n            tx.date = new Date(tx.date);\n\n            /** @type {string} */\n            const txDate = formatDate(tx.date);\n            if (date !== txDate) {\n                this.addDateSeparator(txDate);\n                date = txDate;\n            }\n            this.addTx(tx);\n        });\n    }\n\n    /**\n     * @param dateString    {string}\n     */\n    addDateSeparator(dateString) {\n        $('#transactionsList').appendChild(createElement({tag: 'div', clazz: 'date-separator', text: dateString}));\n    }\n\n    /**\n     * @param tx    {any}\n     */\n    addTx(tx) {\n        /** @type {boolean} */\n        const isReceive = tx.inbound;\n        /** @type {string} */\n        const amountFormatted = fromNano(tx.amount);\n        /** @type {string} */\n        const addr = isReceive ? tx.from_addr : tx.to_addr;\n\n        const item = createElement({\n            tag: 'div',\n            clazz: 'tx-item',\n            child: [\n                createElement({\n                    tag: 'div',\n                    child: isReceive ? [\n                        createElement({\n                            tag: 'span',\n                            clazz: ['tx-amount', 'tx-amount-green'],\n                            text: '+' + amountFormatted\n                        }),\n                        createElement({tag: 'span', text: ' 💎'}),\n                        createElement({tag: 'span', clazz: 'tx-from', text: ' from:'})\n                    ] : [\n                        createElement({tag: 'span', clazz: 'tx-amount', text: amountFormatted}),\n                        createElement({tag: 'span', text: ' 💎'}),\n                        createElement({tag: 'span', clazz: 'tx-from', text: ' to:'})\n                    ]\n                }),\n                setAddr(createElement({tag: 'div', clazz: ['tx-addr', 'addr']}), addr),\n                tx.encryptedComment ? createElement({tag: 'div', clazz: 'tx-item-encrypted-icon'}) : undefined,\n                tx.comment ? createElement({tag: 'div', clazz: 'tx-comment', text: tx.comment}) : undefined,\n                createElement({tag: 'div', clazz: 'tx-fee', text: `blockchain fees: ${fromNano(tx.fee)}`}),\n                createElement({tag: 'div', clazz: 'tx-item-date', text: formatTime(tx.date)})\n            ]\n        });\n\n        item.addEventListener('click', () => this.onTransactionClick(tx));\n\n        $('#transactionsList').appendChild(item);\n    }\n\n    // TRANSACTION POPUP\n\n    /**\n     * @param tx    {any}\n     */\n    onTransactionClick(tx) {\n        this.currentOpenTransaction = tx;\n        this.showPopup('transaction');\n        /** @type {boolean} */\n        const isReceive = tx.inbound;\n        /** @type {string} */\n        const amountFormatted = fromNano(tx.amount);\n        /** @type {string} */\n        const addr = isReceive ? tx.from_addr : tx.to_addr;\n        this.currentTransactionAddr = addr;\n        $('#transactionAmount').innerText = (isReceive ? '+' + amountFormatted : amountFormatted) + ' 💎';\n        $('#transactionFee').innerText = fromNano(tx.fee) + ' transaction fee';\n        $('#transactionSenderLabel').innerText = isReceive ? 'Sender' : 'Recipient';\n        setAddr($('#transactionSender'), addr);\n        toggle($('#transactionCommentLabel'), !!tx.comment || !!tx.encryptedComment);\n        toggle($('#transactionDecryptCommentButton'), !!tx.encryptedComment);\n        toggle($('#transactionComment'), !!tx.comment);\n        $('#transactionComment').innerText = tx.comment;\n        $('#transactionDate').innerText = formatDateFull(tx.date);\n    }\n\n    onTransactionButtonClick() {\n        this.onMessage('showPopup', {name: 'send', toAddr: this.currentTransactionAddr});\n    }\n\n    // SEND POPUP\n\n    clearSend() {\n        $('#toWalletInput').value = '';\n        $('#amountInput').value = '';\n        $('#commentInput').value = '';\n        $('#encryptCommentCheckbox').checked = false;\n    }\n\n    // RECEIVE POPUP\n\n    /**\n     * @param address   {string}\n     */\n    setMyAddress(address) {\n        setAddr($('#receive .addr'), address);\n        drawQRCode(TonWeb.utils.formatTransferUrl(address), '#qr');\n        this.address = address;\n        this.loadDiamond(address);\n    }\n\n    /**\n     * @param address   {string}\n     * @return {Promise<void>}\n     */\n    async loadDiamond(address) {\n        toggle($('.balance-symbol'), true);\n        toggle($('.balance-diamond-container'), false);\n        toggle($('#diamond'), false);\n\n        try {\n            if (this.isTestnet) return;\n            const res = await fetch('https://ton.diamonds/api/wallet/diamond_nfts?address=' + address + '&perPage=1&current=1');\n            if (res.status !== 200) return;\n            const json = await res.json();\n            if (json.ok !== true) return;\n            if (json.result.total < 1) return;\n            const nftNumber = json.result.rows[0].nftNumber;\n            const diamondImageUrl = 'https://nft.ton.diamonds/nft/' + nftNumber + '/' + nftNumber + '_diamond.svg';\n            if (address === this.address) {\n                toggle($('.balance-symbol'), false);\n                $('#diamond').style.backgroundImage = 'url(\"' + diamondImageUrl + '\")';\n                toggle($('.balance-diamond-container'), true);\n                toggle($('#diamond'), true);\n            }\n        } catch (e) {\n            console.error('Diamonds Error', e);\n        }\n    }\n\n    /**\n     * @param onyAddress    {boolean} share address or transfer link\n     */\n    onShareAddressClick(onyAddress) {\n        const data = onyAddress ? this.myAddress : TonWeb.utils.formatTransferUrl(this.myAddress);\n        const text = onyAddress ? 'Wallet address copied to clipboard' : 'Transfer link copied to clipboard';\n        $('#notify').innerText = copyToClipboard(data) ? text : 'Can\\'t copy link';\n        triggerClass($('#notify'), 'faded-show', 2000);\n    }\n\n    onShowAddressOnDevice() {\n        this.sendMessage('showAddressOnDevice');\n        $('#notify').innerText = 'Please check the address on your device';\n        triggerClass($('#notify'), 'faded-show', 2000);\n    }\n\n    // RECEIVE INVOICE POPUP\n\n    onCreateInvoiceClick() {\n        this.onMessage('showPopup', {name: 'invoice'});\n    }\n\n    updateInvoiceLink() {\n        $('#invoice_link').innerText = this.getInvoiceLink();\n    };\n\n    /**\n     * @return {string}\n     */\n    getInvoiceLink() {\n        const amountString = $('#invoice_amountInput').value;\n        /** @type {string | undefined} */\n        const amount = amountString ? toNano(amountString).toString() : undefined;\n        return TonWeb.utils.formatTransferUrl(this.myAddress, amount, $('#invoice_commentInput').value);\n    }\n\n    onShareInvoiceClick() {\n        $('#notify').innerText = copyToClipboard(this.getInvoiceLink()) ? 'Transfer link copied to clipboard' : 'Can\\'t copy link';\n        triggerClass($('#notify'), 'faded-show', 2000);\n    }\n\n    // RECEIVE INVOICE QR POPUP\n\n    onCreateInvoiceQrClick() {\n        this.onMessage('showPopup', {name: 'invoiceQr'});\n    }\n\n    /**\n     * @param link  {string}\n     */\n    drawInvoiceQr(link) {\n        drawQRCode(link, '#invoiceQrImg');\n    }\n\n    // TRANSPORT WITH CONTROLLER\n\n    /**\n     * Send message to Controller.js\n     * @param method    {string}\n     * @param params?    {any}  boolean or object, not array\n     */\n    sendMessage(method, params) {\n        if (this.controller) {\n            this.controller.onViewMessage(method, params);\n        } else {\n            this.port.postMessage({method, params});\n        }\n    }\n\n    /**\n     * Receive message from Controller.js\n     * @param method    {string}\n     * @param params?    {any} boolean or object, not array\n     * @return {undefined | {magic: string | null, proxy: string | null, address: string | null, words: string | null, walletVersion: string | null}}\n     */\n    onMessage(method, params) {\n        switch (method) {\n            case 'disableCreated':\n                $('#createdContinueButton').disabled = params;\n                break;\n\n            case 'setIsTestnet':\n                this.isTestnet = params;\n                $('.your-balance').innerText = params ? 'Your testnet balance' : 'Your mainnet balance';\n                break;\n\n            case 'setBalance':\n                this.setBalance(new BN(params.balance), params.txs);\n                break;\n\n            case 'setIsLedger':\n                this.isLedger = params;\n                break;\n\n            case 'setIsMagic':\n                const isTurnedOn = params;\n                $('#menu_magic .dropdown-toggle').classList.toggle('toggle-on', isTurnedOn && !IS_FIREFOX);\n                $('#menu_telegram').classList.toggle('menu_telegram-show', isTurnedOn && !IS_FIREFOX);\n                break;\n\n            case 'setIsProxy':\n                if (params) {\n                    $('#menu_proxy .dropdown-toggle').classList.add('toggle-on');\n                } else {\n                    $('#menu_proxy .dropdown-toggle').classList.remove('toggle-on');\n                }\n                break;\n\n            case 'privateKeySaved':\n                this.toggleButtonLoader($('#createPassword_continueBtn'), false);\n                break;\n\n            case 'passwordChanged':\n                this.toggleButtonLoader($('#changePassword_okBtn'), false);\n                break;\n\n            case 'showChangePasswordError':\n                this.toggleButtonLoader($('#changePassword_okBtn'), false);\n                $('#changePassword_oldInput').classList.add('error');\n                break;\n\n            case 'passwordEntered':\n                this.toggleButtonLoader($('#enterPassword_okBtn'), false);\n                break;\n\n            case 'showEnterPasswordError':\n                this.toggleButtonLoader($('#enterPassword_okBtn'), false);\n                $('#enterPassword_input').classList.add('error');\n                break;\n\n            case 'importCompleted':\n                this.toggleButtonLoader($('#import_continueBtn'), false);\n                break;\n\n            case 'sendCheckFailed':\n                if (params && params.message) {\n                    $('#notify').innerText = params.message;\n                    triggerClass($('#notify'), 'faded-show', 3000);\n                }\n\n                this.toggleButtonLoader($('#send_btn'), false);\n                break;\n\n            case 'sendCheckSucceeded':\n                this.toggleButtonLoader($('#send_btn'), false);\n                break;\n\n            case 'sendCheckCantPublicKey':\n                this.toggleButtonLoader($('#send_btn'), false);\n                $('#notify').innerText = `To encrypt a message, the destination wallet must have at least one outgoing transfer`;\n                triggerClass($('#notify'), 'faded-show', 3000);\n                break;\n\n            case 'sendCheckCantPayFee':\n                this.toggleButtonLoader($('#send_btn'), false);\n                $('#amountInput').classList.add('error');\n\n                $('#notify').innerText = `Estimated fee is ~${fromNano(params.fee)} TON`;\n                triggerClass($('#notify'), 'faded-show', 3000);\n                break;\n\n            case 'decryptedComment':\n                if (this.currentOpenTransaction && this.currentOpenTransaction.hash === params.hash) {\n                    this.currentOpenTransaction.encryptedComment = null;\n                    this.currentOpenTransaction.comment = params.decryptedComment;\n                    this.onTransactionClick(this.currentOpenTransaction);\n                }\n                break;\n\n            case 'showScreen':\n                if (params.noAnimation) {\n                    triggerClass(document.body, 'disable-animations', 300);\n                }\n\n                this.showScreen(params.name);\n\n                switch (params.name) {\n                    case 'start':\n                        this.clearBalance();\n                        this.clearImportWords();\n                        break;\n                    case 'created':\n                        break;\n                    case 'import':\n                        this.clearImportWords();\n                        $('#importsInput0').focus();\n                        break;\n                    case 'backup':\n                        this.clearConfirmWords();\n                        this.setBackupWords(params.words);\n                        this.backupShownTime = params.isFirst ? (+new Date()) : 0;\n                        break;\n                    case 'wordsConfirm':\n                        this.clearConfirmWords();\n                        this.clearBackupWords();\n                        $('#confirmInput0').focus();\n                        this.setConfirmWords(params.words);\n                        break;\n                    case 'createPassword':\n                        this.clearImportWords();\n                        this.clearConfirmWords();\n                        this.clearCreatePassword();\n                        $('#createPassword_input').focus();\n                        break;\n                    case 'readyToGo':\n                        this.clearCreatePassword();\n                        break;\n                    case 'main':\n                        this.clearBackupWords();\n                        if (params.myAddress) {\n                            this.myAddress = params.myAddress;\n                            this.setMyAddress(params.myAddress);\n                        }\n                        break;\n                }\n                break;\n\n            case 'showPopup':\n                this.showPopup(params.name);\n\n                switch (params.name) {\n                    case 'changePassword':\n                        this.clearChangePassword();\n                        $('#changePassword_oldInput').focus();\n                        break;\n                    case 'enterPassword':\n                        $('#enterPassword_input').focus();\n                        break;\n                    case 'done':\n                        $('#done .popup-grey-text').innerText = params.message;\n                        break;\n                    case 'invoice':\n                        $('#invoice_amountInput').value = '';\n                        $('#invoice_commentInput').value = '';\n                        this.updateInvoiceLink();\n                        $('#invoice_amountInput').focus();\n                        break;\n                    case 'invoiceQr':\n                        this.drawInvoiceQr(this.getInvoiceLink());\n                        $('#invoiceQrAmount').innerText = $('#invoice_amountInput').value;\n                        break;\n                    case 'send':\n                        this.clearSend();\n                        if (params.toAddr) {\n                            $('#toWalletInput').value = params.toAddr;\n                        }\n                        toggle($('#commentInput'), !this.isLedger);\n                        toggle($('#encryptCommentCheckboxContainer'), !this.isLedger ? 'flex' : false);\n                        $('#toWalletInput').focus();\n                        break;\n                    case 'sendConfirm':\n                        $('#sendConfirmAmount').innerText = fromNano(new BN(params.amount)) + ' TON';\n                        setAddr($('#sendConfirmAddr'), params.toAddress);\n                        $('#sendConfirmFee').innerText = params.fee ? 'Fee: ~' + fromNano(new BN(params.fee)) + ' TON' : '';\n\n                        toggle($('#sendConfirmNotEncryptedNote'), !params.needEncryptComment);\n                        toggle($('#sendConfirm .popup-footer'), !this.isLedger);\n                        toggle($('#sendConfirm_closeBtn'), !this.isLedger);\n                        // todo: show label 'Please approve on device'\n                        break;\n                    case 'signConfirm':\n                        $('#signConfirmText').innerText = params.isConnect ? 'Do you want to connect your wallet to this page?' : 'Do you want to sign:';\n                        toggle($('#signConfirmData'), !params.isConnect);\n                        toggle($('#signConfirmAlert'), !params.isConnect);\n\n                        const hex = params.data.length > 48 ? params.data.substring(0, 47) + '…' : params.data;\n                        setAddr($('#signConfirmData'), hex);\n                        break;\n                    case 'connectConfirm':\n                        break;\n                }\n                break;\n\n            case 'closePopup':\n                this.closePopup();\n                break;\n\n            case 'restoreDeprecatedStorage':\n                const address = localStorage.getItem('address');\n                const words = localStorage.getItem('words');\n                const walletVersion = localStorage.getItem('walletVersion');\n                const magic = localStorage.getItem('magic');\n                const proxy = localStorage.getItem('proxy');\n                localStorage.clear();\n\n                return {address, words, walletVersion, magic, proxy};\n\n        }\n    }\n}\n\nwindow.view = new View(TonWeb.mnemonic.wordlists.EN);\n\nif (IS_EXTENSION) {\n\n    // connect to background process\n\n    const connectToBackground = () => {\n        const port = chrome.runtime.connect({name: 'gramWalletPopup'});\n        window.view.port = port;\n\n        port.onMessage.addListener(data => {\n            const result = window.view.onMessage(data.method, data.params);\n            if (result && data.id) {\n                port.postMessage({method: 'response', id: data.id, result});\n            }\n        });\n\n        port.onDisconnect.addListener(() => {\n            connectToBackground();\n        });\n    }\n\n    connectToBackground();\n\n    // remember extension position and size\n\n    const startTrackWindowPositionAndSize = async () => {\n        let prevWindow = await chrome.windows.getCurrent();\n\n        setInterval(async () => {\n            const currentWindow = await chrome.windows.getCurrent();\n\n            if (\n                currentWindow.top !== prevWindow.top ||\n                currentWindow.left !== prevWindow.left ||\n                currentWindow.height !== prevWindow.height ||\n                currentWindow.width !== prevWindow.width\n            ) {\n                prevWindow = currentWindow;\n\n                window.view.sendMessage('onWindowUpdate', {\n                    top: currentWindow.top,\n                    left: currentWindow.left,\n                    height: currentWindow.height,\n                    width: currentWindow.width\n                });\n            }\n        }, 3000);\n    }\n\n    startTrackWindowPositionAndSize();\n}\n\n// show attention message in browser console\n\nif (window.top == window && window.console) {\n    /** @type {Object<string, string[]>} */\n    const selfXssAttentions = {\n        'ru-RU': ['Внимание!', 'Используя эту консоль, вы можете подвергнуться атаке Self-XSS, что позволит злоумышленникам завладеть вашим кошельком.\\nНе вводите и не вставляйте программный код, который не понимаете.'],\n        '*': ['Attention!', 'Using this console, you can be exposed to a Self-XSS attack, allowing attackers to take over your wallet.\\nDo not enter or paste program code that you do not understand.']\n    };\n\n    /** @type {string} */\n    const userLanguage = navigator.language || navigator.userLanguage;\n    /** @type {string[]} */\n    let localizedSelfXssAttention = selfXssAttentions[userLanguage];\n    if (!localizedSelfXssAttention) localizedSelfXssAttention = selfXssAttentions['*'];\n\n    console.log(\n        '%c%s', 'color: red; background: yellow; font-size: 24px;', localizedSelfXssAttention[0]\n    );\n    console.log('%c%s', 'font-size: 18px;', localizedSelfXssAttention[1]);\n}\n\n/******/ })()\n;"
  },
  {
    "path": "docs/libs/aes-js-3.1.2.js",
    "content": "/*! MIT License. Copyright 2015-2018 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */\n(function(root) {\n    \"use strict\";\n\n    function checkInt(value) {\n        return (parseInt(value) === value);\n    }\n\n    function checkInts(arrayish) {\n        if (!checkInt(arrayish.length)) { return false; }\n\n        for (var i = 0; i < arrayish.length; i++) {\n            if (!checkInt(arrayish[i]) || arrayish[i] < 0 || arrayish[i] > 255) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    function coerceArray(arg, copy) {\n\n        // ArrayBuffer view\n        if (arg.buffer && arg.name === 'Uint8Array') {\n\n            if (copy) {\n                if (arg.slice) {\n                    arg = arg.slice();\n                } else {\n                    arg = Array.prototype.slice.call(arg);\n                }\n            }\n\n            return arg;\n        }\n\n        // It's an array; check it is a valid representation of a byte\n        if (Array.isArray(arg)) {\n            if (!checkInts(arg)) {\n                throw new Error('Array contains invalid value: ' + arg);\n            }\n\n            return new Uint8Array(arg);\n        }\n\n        // Something else, but behaves like an array (maybe a Buffer? Arguments?)\n        if (checkInt(arg.length) && checkInts(arg)) {\n            return new Uint8Array(arg);\n        }\n\n        throw new Error('unsupported array-like object');\n    }\n\n    function createArray(length) {\n        return new Uint8Array(length);\n    }\n\n    function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {\n        if (sourceStart != null || sourceEnd != null) {\n            if (sourceArray.slice) {\n                sourceArray = sourceArray.slice(sourceStart, sourceEnd);\n            } else {\n                sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);\n            }\n        }\n        targetArray.set(sourceArray, targetStart);\n    }\n\n\n\n    var convertUtf8 = (function() {\n        function toBytes(text) {\n            var result = [], i = 0;\n            text = encodeURI(text);\n            while (i < text.length) {\n                var c = text.charCodeAt(i++);\n\n                // if it is a % sign, encode the following 2 bytes as a hex value\n                if (c === 37) {\n                    result.push(parseInt(text.substr(i, 2), 16))\n                    i += 2;\n\n                // otherwise, just the actual byte\n                } else {\n                    result.push(c)\n                }\n            }\n\n            return coerceArray(result);\n        }\n\n        function fromBytes(bytes) {\n            var result = [], i = 0;\n\n            while (i < bytes.length) {\n                var c = bytes[i];\n\n                if (c < 128) {\n                    result.push(String.fromCharCode(c));\n                    i++;\n                } else if (c > 191 && c < 224) {\n                    result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f)));\n                    i += 2;\n                } else {\n                    result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f)));\n                    i += 3;\n                }\n            }\n\n            return result.join('');\n        }\n\n        return {\n            toBytes: toBytes,\n            fromBytes: fromBytes,\n        }\n    })();\n\n    var convertHex = (function() {\n        function toBytes(text) {\n            var result = [];\n            for (var i = 0; i < text.length; i += 2) {\n                result.push(parseInt(text.substr(i, 2), 16));\n            }\n\n            return result;\n        }\n\n        // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html\n        var Hex = '0123456789abcdef';\n\n        function fromBytes(bytes) {\n                var result = [];\n                for (var i = 0; i < bytes.length; i++) {\n                    var v = bytes[i];\n                    result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]);\n                }\n                return result.join('');\n        }\n\n        return {\n            toBytes: toBytes,\n            fromBytes: fromBytes,\n        }\n    })();\n\n\n    // Number of rounds by keysize\n    var numberOfRounds = {16: 10, 24: 12, 32: 14}\n\n    // Round constant words\n    var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91];\n\n    // S-box and Inverse S-box (S is for Substitution)\n    var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16];\n    var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d];\n\n    // Transformations for encryption\n    var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a];\n    var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616];\n    var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16];\n    var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c];\n\n    // Transformations for decryption\n    var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742];\n    var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857];\n    var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8];\n    var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0];\n\n    // Transformations for decryption key expansion\n    var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3];\n    var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697];\n    var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46];\n    var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d];\n\n    function convertToInt32(bytes) {\n        var result = [];\n        for (var i = 0; i < bytes.length; i += 4) {\n            result.push(\n                (bytes[i    ] << 24) |\n                (bytes[i + 1] << 16) |\n                (bytes[i + 2] <<  8) |\n                 bytes[i + 3]\n            );\n        }\n        return result;\n    }\n\n    var AES = function(key) {\n        if (!(this instanceof AES)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        Object.defineProperty(this, 'key', {\n            value: coerceArray(key, true)\n        });\n\n        this._prepare();\n    }\n\n\n    AES.prototype._prepare = function() {\n\n        var rounds = numberOfRounds[this.key.length];\n        if (rounds == null) {\n            throw new Error('invalid key size (must be 16, 24 or 32 bytes)');\n        }\n\n        // encryption round keys\n        this._Ke = [];\n\n        // decryption round keys\n        this._Kd = [];\n\n        for (var i = 0; i <= rounds; i++) {\n            this._Ke.push([0, 0, 0, 0]);\n            this._Kd.push([0, 0, 0, 0]);\n        }\n\n        var roundKeyCount = (rounds + 1) * 4;\n        var KC = this.key.length / 4;\n\n        // convert the key into ints\n        var tk = convertToInt32(this.key);\n\n        // copy values into round key arrays\n        var index;\n        for (var i = 0; i < KC; i++) {\n            index = i >> 2;\n            this._Ke[index][i % 4] = tk[i];\n            this._Kd[rounds - index][i % 4] = tk[i];\n        }\n\n        // key expansion (fips-197 section 5.2)\n        var rconpointer = 0;\n        var t = KC, tt;\n        while (t < roundKeyCount) {\n            tt = tk[KC - 1];\n            tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^\n                      (S[(tt >>  8) & 0xFF] << 16) ^\n                      (S[ tt        & 0xFF] <<  8) ^\n                       S[(tt >> 24) & 0xFF]        ^\n                      (rcon[rconpointer] << 24));\n            rconpointer += 1;\n\n            // key expansion (for non-256 bit)\n            if (KC != 8) {\n                for (var i = 1; i < KC; i++) {\n                    tk[i] ^= tk[i - 1];\n                }\n\n            // key expansion for 256-bit keys is \"slightly different\" (fips-197)\n            } else {\n                for (var i = 1; i < (KC / 2); i++) {\n                    tk[i] ^= tk[i - 1];\n                }\n                tt = tk[(KC / 2) - 1];\n\n                tk[KC / 2] ^= (S[ tt        & 0xFF]        ^\n                              (S[(tt >>  8) & 0xFF] <<  8) ^\n                              (S[(tt >> 16) & 0xFF] << 16) ^\n                              (S[(tt >> 24) & 0xFF] << 24));\n\n                for (var i = (KC / 2) + 1; i < KC; i++) {\n                    tk[i] ^= tk[i - 1];\n                }\n            }\n\n            // copy values into round key arrays\n            var i = 0, r, c;\n            while (i < KC && t < roundKeyCount) {\n                r = t >> 2;\n                c = t % 4;\n                this._Ke[r][c] = tk[i];\n                this._Kd[rounds - r][c] = tk[i++];\n                t++;\n            }\n        }\n\n        // inverse-cipher-ify the decryption round key (fips-197 section 5.3)\n        for (var r = 1; r < rounds; r++) {\n            for (var c = 0; c < 4; c++) {\n                tt = this._Kd[r][c];\n                this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^\n                                  U2[(tt >> 16) & 0xFF] ^\n                                  U3[(tt >>  8) & 0xFF] ^\n                                  U4[ tt        & 0xFF]);\n            }\n        }\n    }\n\n    AES.prototype.encrypt = function(plaintext) {\n        if (plaintext.length != 16) {\n            throw new Error('invalid plaintext size (must be 16 bytes)');\n        }\n\n        var rounds = this._Ke.length - 1;\n        var a = [0, 0, 0, 0];\n\n        // convert plaintext to (ints ^ key)\n        var t = convertToInt32(plaintext);\n        for (var i = 0; i < 4; i++) {\n            t[i] ^= this._Ke[0][i];\n        }\n\n        // apply round transforms\n        for (var r = 1; r < rounds; r++) {\n            for (var i = 0; i < 4; i++) {\n                a[i] = (T1[(t[ i         ] >> 24) & 0xff] ^\n                        T2[(t[(i + 1) % 4] >> 16) & 0xff] ^\n                        T3[(t[(i + 2) % 4] >>  8) & 0xff] ^\n                        T4[ t[(i + 3) % 4]        & 0xff] ^\n                        this._Ke[r][i]);\n            }\n            t = a.slice();\n        }\n\n        // the last round is special\n        var result = createArray(16), tt;\n        for (var i = 0; i < 4; i++) {\n            tt = this._Ke[rounds][i];\n            result[4 * i    ] = (S[(t[ i         ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;\n            result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;\n            result[4 * i + 2] = (S[(t[(i + 2) % 4] >>  8) & 0xff] ^ (tt >>  8)) & 0xff;\n            result[4 * i + 3] = (S[ t[(i + 3) % 4]        & 0xff] ^  tt       ) & 0xff;\n        }\n\n        return result;\n    }\n\n    AES.prototype.decrypt = function(ciphertext) {\n        if (ciphertext.length != 16) {\n            throw new Error('invalid ciphertext size (must be 16 bytes)');\n        }\n\n        var rounds = this._Kd.length - 1;\n        var a = [0, 0, 0, 0];\n\n        // convert plaintext to (ints ^ key)\n        var t = convertToInt32(ciphertext);\n        for (var i = 0; i < 4; i++) {\n            t[i] ^= this._Kd[0][i];\n        }\n\n        // apply round transforms\n        for (var r = 1; r < rounds; r++) {\n            for (var i = 0; i < 4; i++) {\n                a[i] = (T5[(t[ i          ] >> 24) & 0xff] ^\n                        T6[(t[(i + 3) % 4] >> 16) & 0xff] ^\n                        T7[(t[(i + 2) % 4] >>  8) & 0xff] ^\n                        T8[ t[(i + 1) % 4]        & 0xff] ^\n                        this._Kd[r][i]);\n            }\n            t = a.slice();\n        }\n\n        // the last round is special\n        var result = createArray(16), tt;\n        for (var i = 0; i < 4; i++) {\n            tt = this._Kd[rounds][i];\n            result[4 * i    ] = (Si[(t[ i         ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;\n            result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;\n            result[4 * i + 2] = (Si[(t[(i + 2) % 4] >>  8) & 0xff] ^ (tt >>  8)) & 0xff;\n            result[4 * i + 3] = (Si[ t[(i + 1) % 4]        & 0xff] ^  tt       ) & 0xff;\n        }\n\n        return result;\n    }\n\n\n    /**\n     *  Mode Of Operation - Electonic Codebook (ECB)\n     */\n    var ModeOfOperationECB = function(key) {\n        if (!(this instanceof ModeOfOperationECB)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Electronic Code Block\";\n        this.name = \"ecb\";\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationECB.prototype.encrypt = function(plaintext) {\n        plaintext = coerceArray(plaintext);\n\n        if ((plaintext.length % 16) !== 0) {\n            throw new Error('invalid plaintext size (must be multiple of 16 bytes)');\n        }\n\n        var ciphertext = createArray(plaintext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < plaintext.length; i += 16) {\n            copyArray(plaintext, block, 0, i, i + 16);\n            block = this._aes.encrypt(block);\n            copyArray(block, ciphertext, i);\n        }\n\n        return ciphertext;\n    }\n\n    ModeOfOperationECB.prototype.decrypt = function(ciphertext) {\n        ciphertext = coerceArray(ciphertext);\n\n        if ((ciphertext.length % 16) !== 0) {\n            throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');\n        }\n\n        var plaintext = createArray(ciphertext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < ciphertext.length; i += 16) {\n            copyArray(ciphertext, block, 0, i, i + 16);\n            block = this._aes.decrypt(block);\n            copyArray(block, plaintext, i);\n        }\n\n        return plaintext;\n    }\n\n\n    /**\n     *  Mode Of Operation - Cipher Block Chaining (CBC)\n     */\n    var ModeOfOperationCBC = function(key, iv) {\n        if (!(this instanceof ModeOfOperationCBC)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Cipher Block Chaining\";\n        this.name = \"cbc\";\n\n        if (!iv) {\n            iv = createArray(16);\n\n        } else if (iv.length != 16) {\n            throw new Error('invalid initialation vector size (must be 16 bytes)');\n        }\n\n        this._lastCipherblock = coerceArray(iv, true);\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationCBC.prototype.encrypt = function(plaintext) {\n        plaintext = coerceArray(plaintext);\n\n        if ((plaintext.length % 16) !== 0) {\n            throw new Error('invalid plaintext size (must be multiple of 16 bytes)');\n        }\n\n        var ciphertext = createArray(plaintext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < plaintext.length; i += 16) {\n            copyArray(plaintext, block, 0, i, i + 16);\n\n            for (var j = 0; j < 16; j++) {\n                block[j] ^= this._lastCipherblock[j];\n            }\n\n            this._lastCipherblock = this._aes.encrypt(block);\n            copyArray(this._lastCipherblock, ciphertext, i);\n        }\n\n        return ciphertext;\n    }\n\n    ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {\n        ciphertext = coerceArray(ciphertext);\n\n        if ((ciphertext.length % 16) !== 0) {\n            throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');\n        }\n\n        var plaintext = createArray(ciphertext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < ciphertext.length; i += 16) {\n            copyArray(ciphertext, block, 0, i, i + 16);\n            block = this._aes.decrypt(block);\n\n            for (var j = 0; j < 16; j++) {\n                plaintext[i + j] = block[j] ^ this._lastCipherblock[j];\n            }\n\n            copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16);\n        }\n\n        return plaintext;\n    }\n\n\n    /**\n     *  Mode Of Operation - Cipher Feedback (CFB)\n     */\n    var ModeOfOperationCFB = function(key, iv, segmentSize) {\n        if (!(this instanceof ModeOfOperationCFB)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Cipher Feedback\";\n        this.name = \"cfb\";\n\n        if (!iv) {\n            iv = createArray(16);\n\n        } else if (iv.length != 16) {\n            throw new Error('invalid initialation vector size (must be 16 size)');\n        }\n\n        if (!segmentSize) { segmentSize = 1; }\n\n        this.segmentSize = segmentSize;\n\n        this._shiftRegister = coerceArray(iv, true);\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationCFB.prototype.encrypt = function(plaintext) {\n        if ((plaintext.length % this.segmentSize) != 0) {\n            throw new Error('invalid plaintext size (must be segmentSize bytes)');\n        }\n\n        var encrypted = coerceArray(plaintext, true);\n\n        var xorSegment;\n        for (var i = 0; i < encrypted.length; i += this.segmentSize) {\n            xorSegment = this._aes.encrypt(this._shiftRegister);\n            for (var j = 0; j < this.segmentSize; j++) {\n                encrypted[i + j] ^= xorSegment[j];\n            }\n\n            // Shift the register\n            copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);\n            copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);\n        }\n\n        return encrypted;\n    }\n\n    ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {\n        if ((ciphertext.length % this.segmentSize) != 0) {\n            throw new Error('invalid ciphertext size (must be segmentSize bytes)');\n        }\n\n        var plaintext = coerceArray(ciphertext, true);\n\n        var xorSegment;\n        for (var i = 0; i < plaintext.length; i += this.segmentSize) {\n            xorSegment = this._aes.encrypt(this._shiftRegister);\n\n            for (var j = 0; j < this.segmentSize; j++) {\n                plaintext[i + j] ^= xorSegment[j];\n            }\n\n            // Shift the register\n            copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);\n            copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);\n        }\n\n        return plaintext;\n    }\n\n    /**\n     *  Mode Of Operation - Output Feedback (OFB)\n     */\n    var ModeOfOperationOFB = function(key, iv) {\n        if (!(this instanceof ModeOfOperationOFB)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Output Feedback\";\n        this.name = \"ofb\";\n\n        if (!iv) {\n            iv = createArray(16);\n\n        } else if (iv.length != 16) {\n            throw new Error('invalid initialation vector size (must be 16 bytes)');\n        }\n\n        this._lastPrecipher = coerceArray(iv, true);\n        this._lastPrecipherIndex = 16;\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationOFB.prototype.encrypt = function(plaintext) {\n        var encrypted = coerceArray(plaintext, true);\n\n        for (var i = 0; i < encrypted.length; i++) {\n            if (this._lastPrecipherIndex === 16) {\n                this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);\n                this._lastPrecipherIndex = 0;\n            }\n            encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++];\n        }\n\n        return encrypted;\n    }\n\n    // Decryption is symetric\n    ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;\n\n\n    /**\n     *  Counter object for CTR common mode of operation\n     */\n    var Counter = function(initialValue) {\n        if (!(this instanceof Counter)) {\n            throw Error('Counter must be instanitated with `new`');\n        }\n\n        // We allow 0, but anything false-ish uses the default 1\n        if (initialValue !== 0 && !initialValue) { initialValue = 1; }\n\n        if (typeof(initialValue) === 'number') {\n            this._counter = createArray(16);\n            this.setValue(initialValue);\n\n        } else {\n            this.setBytes(initialValue);\n        }\n    }\n\n    Counter.prototype.setValue = function(value) {\n        if (typeof(value) !== 'number' || parseInt(value) != value) {\n            throw new Error('invalid counter value (must be an integer)');\n        }\n\n        // We cannot safely handle numbers beyond the safe range for integers\n        if (value > Number.MAX_SAFE_INTEGER) {\n            throw new Error('integer value out of safe range');\n        }\n\n        for (var index = 15; index >= 0; --index) {\n            this._counter[index] = value % 256;\n            value = parseInt(value / 256);\n        }\n    }\n\n    Counter.prototype.setBytes = function(bytes) {\n        bytes = coerceArray(bytes, true);\n\n        if (bytes.length != 16) {\n            throw new Error('invalid counter bytes size (must be 16 bytes)');\n        }\n\n        this._counter = bytes;\n    };\n\n    Counter.prototype.increment = function() {\n        for (var i = 15; i >= 0; i--) {\n            if (this._counter[i] === 255) {\n                this._counter[i] = 0;\n            } else {\n                this._counter[i]++;\n                break;\n            }\n        }\n    }\n\n\n    /**\n     *  Mode Of Operation - Counter (CTR)\n     */\n    var ModeOfOperationCTR = function(key, counter) {\n        if (!(this instanceof ModeOfOperationCTR)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Counter\";\n        this.name = \"ctr\";\n\n        if (!(counter instanceof Counter)) {\n            counter = new Counter(counter)\n        }\n\n        this._counter = counter;\n\n        this._remainingCounter = null;\n        this._remainingCounterIndex = 16;\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationCTR.prototype.encrypt = function(plaintext) {\n        var encrypted = coerceArray(plaintext, true);\n\n        for (var i = 0; i < encrypted.length; i++) {\n            if (this._remainingCounterIndex === 16) {\n                this._remainingCounter = this._aes.encrypt(this._counter._counter);\n                this._remainingCounterIndex = 0;\n                this._counter.increment();\n            }\n            encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++];\n        }\n\n        return encrypted;\n    }\n\n    // Decryption is symetric\n    ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;\n\n\n    ///////////////////////\n    // Padding\n\n    // See:https://tools.ietf.org/html/rfc2315\n    function pkcs7pad(data) {\n        data = coerceArray(data, true);\n        var padder = 16 - (data.length % 16);\n        var result = createArray(data.length + padder);\n        copyArray(data, result);\n        for (var i = data.length; i < result.length; i++) {\n            result[i] = padder;\n        }\n        return result;\n    }\n\n    function pkcs7strip(data) {\n        data = coerceArray(data, true);\n        if (data.length < 16) { throw new Error('PKCS#7 invalid length'); }\n\n        var padder = data[data.length - 1];\n        if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); }\n\n        var length = data.length - padder;\n        for (var i = 0; i < padder; i++) {\n            if (data[length + i] !== padder) {\n                throw new Error('PKCS#7 invalid padding byte');\n            }\n        }\n\n        var result = createArray(length);\n        copyArray(data, result, 0, 0, length);\n        return result;\n    }\n\n    ///////////////////////\n    // Exporting\n\n\n    // The block cipher\n    var aesjs = {\n        AES: AES,\n        Counter: Counter,\n\n        ModeOfOperation: {\n            ecb: ModeOfOperationECB,\n            cbc: ModeOfOperationCBC,\n            cfb: ModeOfOperationCFB,\n            ofb: ModeOfOperationOFB,\n            ctr: ModeOfOperationCTR\n        },\n\n        utils: {\n            hex: convertHex,\n            utf8: convertUtf8\n        },\n\n        padding: {\n            pkcs7: {\n                pad: pkcs7pad,\n                strip: pkcs7strip\n            }\n        },\n\n        _arrayTest: {\n            coerceArray: coerceArray,\n            createArray: createArray,\n            copyArray: copyArray,\n        }\n    };\n\n\n    // node.js\n    if (typeof exports !== 'undefined') {\n        module.exports = aesjs\n\n    // RequireJS/AMD\n    // http://www.requirejs.org/docs/api.html\n    // https://github.com/amdjs/amdjs-api/wiki/AMD\n    } else if (typeof(define) === 'function' && define.amd) {\n        define([], function() { return aesjs; });\n\n    // Web Browsers\n    } else {\n\n        // If there was an existing library at \"aesjs\" make sure it's still available\n        if (root.aesjs) {\n            aesjs._aesjs = root.aesjs;\n        }\n\n        root.aesjs = aesjs;\n    }\n\n\n})(this);\n"
  },
  {
    "path": "docs/libs/noble-ed25519-1.7.3.js",
    "content": "(function (global, factory) {\n    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n    typeof define === 'function' && define.amd ? define(['exports'], factory) :\n    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.nobleEd25519 = {}));\n})(this, (function (exports) { 'use strict';\n\n    const _nodeResolve_empty = {};\n\n    const nodeCrypto = /*#__PURE__*/Object.freeze({\n        __proto__: null,\n        'default': _nodeResolve_empty\n    });\n\n    /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */\n    const _0n = BigInt(0);\n    const _1n = BigInt(1);\n    const _2n = BigInt(2);\n    const _8n = BigInt(8);\n    const CU_O = BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989');\n    const CURVE = Object.freeze({\n        a: BigInt(-1),\n        d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),\n        P: BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949'),\n        l: CU_O,\n        n: CU_O,\n        h: BigInt(8),\n        Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),\n        Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),\n    });\n    const POW_2_256 = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000');\n    const SQRT_M1 = BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');\n    BigInt('6853475219497561581579357271197624642482790079785650197046958215289687604742');\n    const SQRT_AD_MINUS_ONE = BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235');\n    const INVSQRT_A_MINUS_D = BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578');\n    const ONE_MINUS_D_SQ = BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838');\n    const D_MINUS_ONE_SQ = BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952');\n    class ExtendedPoint {\n        constructor(x, y, z, t) {\n            this.x = x;\n            this.y = y;\n            this.z = z;\n            this.t = t;\n        }\n        static fromAffine(p) {\n            if (!(p instanceof Point)) {\n                throw new TypeError('ExtendedPoint#fromAffine: expected Point');\n            }\n            if (p.equals(Point.ZERO))\n                return ExtendedPoint.ZERO;\n            return new ExtendedPoint(p.x, p.y, _1n, mod(p.x * p.y));\n        }\n        static toAffineBatch(points) {\n            const toInv = invertBatch(points.map((p) => p.z));\n            return points.map((p, i) => p.toAffine(toInv[i]));\n        }\n        static normalizeZ(points) {\n            return this.toAffineBatch(points).map(this.fromAffine);\n        }\n        equals(other) {\n            assertExtPoint(other);\n            const { x: X1, y: Y1, z: Z1 } = this;\n            const { x: X2, y: Y2, z: Z2 } = other;\n            const X1Z2 = mod(X1 * Z2);\n            const X2Z1 = mod(X2 * Z1);\n            const Y1Z2 = mod(Y1 * Z2);\n            const Y2Z1 = mod(Y2 * Z1);\n            return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;\n        }\n        negate() {\n            return new ExtendedPoint(mod(-this.x), this.y, this.z, mod(-this.t));\n        }\n        double() {\n            const { x: X1, y: Y1, z: Z1 } = this;\n            const { a } = CURVE;\n            const A = mod(X1 * X1);\n            const B = mod(Y1 * Y1);\n            const C = mod(_2n * mod(Z1 * Z1));\n            const D = mod(a * A);\n            const x1y1 = X1 + Y1;\n            const E = mod(mod(x1y1 * x1y1) - A - B);\n            const G = D + B;\n            const F = G - C;\n            const H = D - B;\n            const X3 = mod(E * F);\n            const Y3 = mod(G * H);\n            const T3 = mod(E * H);\n            const Z3 = mod(F * G);\n            return new ExtendedPoint(X3, Y3, Z3, T3);\n        }\n        add(other) {\n            assertExtPoint(other);\n            const { x: X1, y: Y1, z: Z1, t: T1 } = this;\n            const { x: X2, y: Y2, z: Z2, t: T2 } = other;\n            const A = mod((Y1 - X1) * (Y2 + X2));\n            const B = mod((Y1 + X1) * (Y2 - X2));\n            const F = mod(B - A);\n            if (F === _0n)\n                return this.double();\n            const C = mod(Z1 * _2n * T2);\n            const D = mod(T1 * _2n * Z2);\n            const E = D + C;\n            const G = B + A;\n            const H = D - C;\n            const X3 = mod(E * F);\n            const Y3 = mod(G * H);\n            const T3 = mod(E * H);\n            const Z3 = mod(F * G);\n            return new ExtendedPoint(X3, Y3, Z3, T3);\n        }\n        subtract(other) {\n            return this.add(other.negate());\n        }\n        precomputeWindow(W) {\n            const windows = 1 + 256 / W;\n            const points = [];\n            let p = this;\n            let base = p;\n            for (let window = 0; window < windows; window++) {\n                base = p;\n                points.push(base);\n                for (let i = 1; i < 2 ** (W - 1); i++) {\n                    base = base.add(p);\n                    points.push(base);\n                }\n                p = base.double();\n            }\n            return points;\n        }\n        wNAF(n, affinePoint) {\n            if (!affinePoint && this.equals(ExtendedPoint.BASE))\n                affinePoint = Point.BASE;\n            const W = (affinePoint && affinePoint._WINDOW_SIZE) || 1;\n            if (256 % W) {\n                throw new Error('Point#wNAF: Invalid precomputation window, must be power of 2');\n            }\n            let precomputes = affinePoint && pointPrecomputes.get(affinePoint);\n            if (!precomputes) {\n                precomputes = this.precomputeWindow(W);\n                if (affinePoint && W !== 1) {\n                    precomputes = ExtendedPoint.normalizeZ(precomputes);\n                    pointPrecomputes.set(affinePoint, precomputes);\n                }\n            }\n            let p = ExtendedPoint.ZERO;\n            let f = ExtendedPoint.BASE;\n            const windows = 1 + 256 / W;\n            const windowSize = 2 ** (W - 1);\n            const mask = BigInt(2 ** W - 1);\n            const maxNumber = 2 ** W;\n            const shiftBy = BigInt(W);\n            for (let window = 0; window < windows; window++) {\n                const offset = window * windowSize;\n                let wbits = Number(n & mask);\n                n >>= shiftBy;\n                if (wbits > windowSize) {\n                    wbits -= maxNumber;\n                    n += _1n;\n                }\n                const offset1 = offset;\n                const offset2 = offset + Math.abs(wbits) - 1;\n                const cond1 = window % 2 !== 0;\n                const cond2 = wbits < 0;\n                if (wbits === 0) {\n                    f = f.add(constTimeNegate(cond1, precomputes[offset1]));\n                }\n                else {\n                    p = p.add(constTimeNegate(cond2, precomputes[offset2]));\n                }\n            }\n            return ExtendedPoint.normalizeZ([p, f])[0];\n        }\n        multiply(scalar, affinePoint) {\n            return this.wNAF(normalizeScalar(scalar, CURVE.l), affinePoint);\n        }\n        multiplyUnsafe(scalar) {\n            let n = normalizeScalar(scalar, CURVE.l, false);\n            const G = ExtendedPoint.BASE;\n            const P0 = ExtendedPoint.ZERO;\n            if (n === _0n)\n                return P0;\n            if (this.equals(P0) || n === _1n)\n                return this;\n            if (this.equals(G))\n                return this.wNAF(n);\n            let p = P0;\n            let d = this;\n            while (n > _0n) {\n                if (n & _1n)\n                    p = p.add(d);\n                d = d.double();\n                n >>= _1n;\n            }\n            return p;\n        }\n        isSmallOrder() {\n            return this.multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n        }\n        isTorsionFree() {\n            let p = this.multiplyUnsafe(CURVE.l / _2n).double();\n            if (CURVE.l % _2n)\n                p = p.add(this);\n            return p.equals(ExtendedPoint.ZERO);\n        }\n        toAffine(invZ) {\n            const { x, y, z } = this;\n            const is0 = this.equals(ExtendedPoint.ZERO);\n            if (invZ == null)\n                invZ = is0 ? _8n : invert(z);\n            const ax = mod(x * invZ);\n            const ay = mod(y * invZ);\n            const zz = mod(z * invZ);\n            if (is0)\n                return Point.ZERO;\n            if (zz !== _1n)\n                throw new Error('invZ was invalid');\n            return new Point(ax, ay);\n        }\n        fromRistrettoBytes() {\n            legacyRist();\n        }\n        toRistrettoBytes() {\n            legacyRist();\n        }\n        fromRistrettoHash() {\n            legacyRist();\n        }\n    }\n    ExtendedPoint.BASE = new ExtendedPoint(CURVE.Gx, CURVE.Gy, _1n, mod(CURVE.Gx * CURVE.Gy));\n    ExtendedPoint.ZERO = new ExtendedPoint(_0n, _1n, _1n, _0n);\n    function constTimeNegate(condition, item) {\n        const neg = item.negate();\n        return condition ? neg : item;\n    }\n    function assertExtPoint(other) {\n        if (!(other instanceof ExtendedPoint))\n            throw new TypeError('ExtendedPoint expected');\n    }\n    function assertRstPoint(other) {\n        if (!(other instanceof RistrettoPoint))\n            throw new TypeError('RistrettoPoint expected');\n    }\n    function legacyRist() {\n        throw new Error('Legacy method: switch to RistrettoPoint');\n    }\n    class RistrettoPoint {\n        constructor(ep) {\n            this.ep = ep;\n        }\n        static calcElligatorRistrettoMap(r0) {\n            const { d } = CURVE;\n            const r = mod(SQRT_M1 * r0 * r0);\n            const Ns = mod((r + _1n) * ONE_MINUS_D_SQ);\n            let c = BigInt(-1);\n            const D = mod((c - d * r) * mod(r + d));\n            let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D);\n            let s_ = mod(s * r0);\n            if (!edIsNegative(s_))\n                s_ = mod(-s_);\n            if (!Ns_D_is_sq)\n                s = s_;\n            if (!Ns_D_is_sq)\n                c = r;\n            const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D);\n            const s2 = s * s;\n            const W0 = mod((s + s) * D);\n            const W1 = mod(Nt * SQRT_AD_MINUS_ONE);\n            const W2 = mod(_1n - s2);\n            const W3 = mod(_1n + s2);\n            return new ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));\n        }\n        static hashToCurve(hex) {\n            hex = ensureBytes(hex, 64);\n            const r1 = bytes255ToNumberLE(hex.slice(0, 32));\n            const R1 = this.calcElligatorRistrettoMap(r1);\n            const r2 = bytes255ToNumberLE(hex.slice(32, 64));\n            const R2 = this.calcElligatorRistrettoMap(r2);\n            return new RistrettoPoint(R1.add(R2));\n        }\n        static fromHex(hex) {\n            hex = ensureBytes(hex, 32);\n            const { a, d } = CURVE;\n            const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';\n            const s = bytes255ToNumberLE(hex);\n            if (!equalBytes(numberTo32BytesLE(s), hex) || edIsNegative(s))\n                throw new Error(emsg);\n            const s2 = mod(s * s);\n            const u1 = mod(_1n + a * s2);\n            const u2 = mod(_1n - a * s2);\n            const u1_2 = mod(u1 * u1);\n            const u2_2 = mod(u2 * u2);\n            const v = mod(a * d * u1_2 - u2_2);\n            const { isValid, value: I } = invertSqrt(mod(v * u2_2));\n            const Dx = mod(I * u2);\n            const Dy = mod(I * Dx * v);\n            let x = mod((s + s) * Dx);\n            if (edIsNegative(x))\n                x = mod(-x);\n            const y = mod(u1 * Dy);\n            const t = mod(x * y);\n            if (!isValid || edIsNegative(t) || y === _0n)\n                throw new Error(emsg);\n            return new RistrettoPoint(new ExtendedPoint(x, y, _1n, t));\n        }\n        toRawBytes() {\n            let { x, y, z, t } = this.ep;\n            const u1 = mod(mod(z + y) * mod(z - y));\n            const u2 = mod(x * y);\n            const u2sq = mod(u2 * u2);\n            const { value: invsqrt } = invertSqrt(mod(u1 * u2sq));\n            const D1 = mod(invsqrt * u1);\n            const D2 = mod(invsqrt * u2);\n            const zInv = mod(D1 * D2 * t);\n            let D;\n            if (edIsNegative(t * zInv)) {\n                let _x = mod(y * SQRT_M1);\n                let _y = mod(x * SQRT_M1);\n                x = _x;\n                y = _y;\n                D = mod(D1 * INVSQRT_A_MINUS_D);\n            }\n            else {\n                D = D2;\n            }\n            if (edIsNegative(x * zInv))\n                y = mod(-y);\n            let s = mod((z - y) * D);\n            if (edIsNegative(s))\n                s = mod(-s);\n            return numberTo32BytesLE(s);\n        }\n        toHex() {\n            return bytesToHex(this.toRawBytes());\n        }\n        toString() {\n            return this.toHex();\n        }\n        equals(other) {\n            assertRstPoint(other);\n            const a = this.ep;\n            const b = other.ep;\n            const one = mod(a.x * b.y) === mod(a.y * b.x);\n            const two = mod(a.y * b.y) === mod(a.x * b.x);\n            return one || two;\n        }\n        add(other) {\n            assertRstPoint(other);\n            return new RistrettoPoint(this.ep.add(other.ep));\n        }\n        subtract(other) {\n            assertRstPoint(other);\n            return new RistrettoPoint(this.ep.subtract(other.ep));\n        }\n        multiply(scalar) {\n            return new RistrettoPoint(this.ep.multiply(scalar));\n        }\n        multiplyUnsafe(scalar) {\n            return new RistrettoPoint(this.ep.multiplyUnsafe(scalar));\n        }\n    }\n    RistrettoPoint.BASE = new RistrettoPoint(ExtendedPoint.BASE);\n    RistrettoPoint.ZERO = new RistrettoPoint(ExtendedPoint.ZERO);\n    const pointPrecomputes = new WeakMap();\n    class Point {\n        constructor(x, y) {\n            this.x = x;\n            this.y = y;\n        }\n        _setWindowSize(windowSize) {\n            this._WINDOW_SIZE = windowSize;\n            pointPrecomputes.delete(this);\n        }\n        static fromHex(hex, strict = true) {\n            const { d, P } = CURVE;\n            hex = ensureBytes(hex, 32);\n            const normed = hex.slice();\n            normed[31] = hex[31] & ~0x80;\n            const y = bytesToNumberLE(normed);\n            if (strict && y >= P)\n                throw new Error('Expected 0 < hex < P');\n            if (!strict && y >= POW_2_256)\n                throw new Error('Expected 0 < hex < 2**256');\n            const y2 = mod(y * y);\n            const u = mod(y2 - _1n);\n            const v = mod(d * y2 + _1n);\n            let { isValid, value: x } = uvRatio(u, v);\n            if (!isValid)\n                throw new Error('Point.fromHex: invalid y coordinate');\n            const isXOdd = (x & _1n) === _1n;\n            const isLastByteOdd = (hex[31] & 0x80) !== 0;\n            if (isLastByteOdd !== isXOdd) {\n                x = mod(-x);\n            }\n            return new Point(x, y);\n        }\n        static async fromPrivateKey(privateKey) {\n            return (await getExtendedPublicKey(privateKey)).point;\n        }\n        toRawBytes() {\n            const bytes = numberTo32BytesLE(this.y);\n            bytes[31] |= this.x & _1n ? 0x80 : 0;\n            return bytes;\n        }\n        toHex() {\n            return bytesToHex(this.toRawBytes());\n        }\n        toX25519() {\n            const { y } = this;\n            const u = mod((_1n + y) * invert(_1n - y));\n            return numberTo32BytesLE(u);\n        }\n        isTorsionFree() {\n            return ExtendedPoint.fromAffine(this).isTorsionFree();\n        }\n        equals(other) {\n            return this.x === other.x && this.y === other.y;\n        }\n        negate() {\n            return new Point(mod(-this.x), this.y);\n        }\n        add(other) {\n            return ExtendedPoint.fromAffine(this).add(ExtendedPoint.fromAffine(other)).toAffine();\n        }\n        subtract(other) {\n            return this.add(other.negate());\n        }\n        multiply(scalar) {\n            return ExtendedPoint.fromAffine(this).multiply(scalar, this).toAffine();\n        }\n    }\n    Point.BASE = new Point(CURVE.Gx, CURVE.Gy);\n    Point.ZERO = new Point(_0n, _1n);\n    class Signature {\n        constructor(r, s) {\n            this.r = r;\n            this.s = s;\n            this.assertValidity();\n        }\n        static fromHex(hex) {\n            const bytes = ensureBytes(hex, 64);\n            const r = Point.fromHex(bytes.slice(0, 32), false);\n            const s = bytesToNumberLE(bytes.slice(32, 64));\n            return new Signature(r, s);\n        }\n        assertValidity() {\n            const { r, s } = this;\n            if (!(r instanceof Point))\n                throw new Error('Expected Point instance');\n            normalizeScalar(s, CURVE.l, false);\n            return this;\n        }\n        toRawBytes() {\n            const u8 = new Uint8Array(64);\n            u8.set(this.r.toRawBytes());\n            u8.set(numberTo32BytesLE(this.s), 32);\n            return u8;\n        }\n        toHex() {\n            return bytesToHex(this.toRawBytes());\n        }\n    }\n    function concatBytes(...arrays) {\n        if (!arrays.every((a) => a instanceof Uint8Array))\n            throw new Error('Expected Uint8Array list');\n        if (arrays.length === 1)\n            return arrays[0];\n        const length = arrays.reduce((a, arr) => a + arr.length, 0);\n        const result = new Uint8Array(length);\n        for (let i = 0, pad = 0; i < arrays.length; i++) {\n            const arr = arrays[i];\n            result.set(arr, pad);\n            pad += arr.length;\n        }\n        return result;\n    }\n    const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));\n    function bytesToHex(uint8a) {\n        if (!(uint8a instanceof Uint8Array))\n            throw new Error('Uint8Array expected');\n        let hex = '';\n        for (let i = 0; i < uint8a.length; i++) {\n            hex += hexes[uint8a[i]];\n        }\n        return hex;\n    }\n    function hexToBytes(hex) {\n        if (typeof hex !== 'string') {\n            throw new TypeError('hexToBytes: expected string, got ' + typeof hex);\n        }\n        if (hex.length % 2)\n            throw new Error('hexToBytes: received invalid unpadded hex');\n        const array = new Uint8Array(hex.length / 2);\n        for (let i = 0; i < array.length; i++) {\n            const j = i * 2;\n            const hexByte = hex.slice(j, j + 2);\n            const byte = Number.parseInt(hexByte, 16);\n            if (Number.isNaN(byte) || byte < 0)\n                throw new Error('Invalid byte sequence');\n            array[i] = byte;\n        }\n        return array;\n    }\n    function numberTo32BytesBE(num) {\n        const length = 32;\n        const hex = num.toString(16).padStart(length * 2, '0');\n        return hexToBytes(hex);\n    }\n    function numberTo32BytesLE(num) {\n        return numberTo32BytesBE(num).reverse();\n    }\n    function edIsNegative(num) {\n        return (mod(num) & _1n) === _1n;\n    }\n    function bytesToNumberLE(uint8a) {\n        if (!(uint8a instanceof Uint8Array))\n            throw new Error('Expected Uint8Array');\n        return BigInt('0x' + bytesToHex(Uint8Array.from(uint8a).reverse()));\n    }\n    const MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');\n    function bytes255ToNumberLE(bytes) {\n        return mod(bytesToNumberLE(bytes) & MAX_255B);\n    }\n    function mod(a, b = CURVE.P) {\n        const res = a % b;\n        return res >= _0n ? res : b + res;\n    }\n    function invert(number, modulo = CURVE.P) {\n        if (number === _0n || modulo <= _0n) {\n            throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);\n        }\n        let a = mod(number, modulo);\n        let b = modulo;\n        let x = _0n, u = _1n;\n        while (a !== _0n) {\n            const q = b / a;\n            const r = b % a;\n            const m = x - u * q;\n            b = a, a = r, x = u, u = m;\n        }\n        const gcd = b;\n        if (gcd !== _1n)\n            throw new Error('invert: does not exist');\n        return mod(x, modulo);\n    }\n    function invertBatch(nums, p = CURVE.P) {\n        const tmp = new Array(nums.length);\n        const lastMultiplied = nums.reduce((acc, num, i) => {\n            if (num === _0n)\n                return acc;\n            tmp[i] = acc;\n            return mod(acc * num, p);\n        }, _1n);\n        const inverted = invert(lastMultiplied, p);\n        nums.reduceRight((acc, num, i) => {\n            if (num === _0n)\n                return acc;\n            tmp[i] = mod(acc * tmp[i], p);\n            return mod(acc * num, p);\n        }, inverted);\n        return tmp;\n    }\n    function pow2(x, power) {\n        const { P } = CURVE;\n        let res = x;\n        while (power-- > _0n) {\n            res *= res;\n            res %= P;\n        }\n        return res;\n    }\n    function pow_2_252_3(x) {\n        const { P } = CURVE;\n        const _5n = BigInt(5);\n        const _10n = BigInt(10);\n        const _20n = BigInt(20);\n        const _40n = BigInt(40);\n        const _80n = BigInt(80);\n        const x2 = (x * x) % P;\n        const b2 = (x2 * x) % P;\n        const b4 = (pow2(b2, _2n) * b2) % P;\n        const b5 = (pow2(b4, _1n) * x) % P;\n        const b10 = (pow2(b5, _5n) * b5) % P;\n        const b20 = (pow2(b10, _10n) * b10) % P;\n        const b40 = (pow2(b20, _20n) * b20) % P;\n        const b80 = (pow2(b40, _40n) * b40) % P;\n        const b160 = (pow2(b80, _80n) * b80) % P;\n        const b240 = (pow2(b160, _80n) * b80) % P;\n        const b250 = (pow2(b240, _10n) * b10) % P;\n        const pow_p_5_8 = (pow2(b250, _2n) * x) % P;\n        return { pow_p_5_8, b2 };\n    }\n    function uvRatio(u, v) {\n        const v3 = mod(v * v * v);\n        const v7 = mod(v3 * v3 * v);\n        const pow = pow_2_252_3(u * v7).pow_p_5_8;\n        let x = mod(u * v3 * pow);\n        const vx2 = mod(v * x * x);\n        const root1 = x;\n        const root2 = mod(x * SQRT_M1);\n        const useRoot1 = vx2 === u;\n        const useRoot2 = vx2 === mod(-u);\n        const noRoot = vx2 === mod(-u * SQRT_M1);\n        if (useRoot1)\n            x = root1;\n        if (useRoot2 || noRoot)\n            x = root2;\n        if (edIsNegative(x))\n            x = mod(-x);\n        return { isValid: useRoot1 || useRoot2, value: x };\n    }\n    function invertSqrt(number) {\n        return uvRatio(_1n, number);\n    }\n    function modlLE(hash) {\n        return mod(bytesToNumberLE(hash), CURVE.l);\n    }\n    function equalBytes(b1, b2) {\n        if (b1.length !== b2.length) {\n            return false;\n        }\n        for (let i = 0; i < b1.length; i++) {\n            if (b1[i] !== b2[i]) {\n                return false;\n            }\n        }\n        return true;\n    }\n    function ensureBytes(hex, expectedLength) {\n        const bytes = hex instanceof Uint8Array ? Uint8Array.from(hex) : hexToBytes(hex);\n        if (typeof expectedLength === 'number' && bytes.length !== expectedLength)\n            throw new Error(`Expected ${expectedLength} bytes`);\n        return bytes;\n    }\n    function normalizeScalar(num, max, strict = true) {\n        if (!max)\n            throw new TypeError('Specify max value');\n        if (typeof num === 'number' && Number.isSafeInteger(num))\n            num = BigInt(num);\n        if (typeof num === 'bigint' && num < max) {\n            if (strict) {\n                if (_0n < num)\n                    return num;\n            }\n            else {\n                if (_0n <= num)\n                    return num;\n            }\n        }\n        throw new TypeError('Expected valid scalar: 0 < scalar < max');\n    }\n    function adjustBytes25519(bytes) {\n        bytes[0] &= 248;\n        bytes[31] &= 127;\n        bytes[31] |= 64;\n        return bytes;\n    }\n    function decodeScalar25519(n) {\n        return bytesToNumberLE(adjustBytes25519(ensureBytes(n, 32)));\n    }\n    function checkPrivateKey(key) {\n        key =\n            typeof key === 'bigint' || typeof key === 'number'\n                ? numberTo32BytesBE(normalizeScalar(key, POW_2_256))\n                : ensureBytes(key);\n        if (key.length !== 32)\n            throw new Error(`Expected 32 bytes`);\n        return key;\n    }\n    function getKeyFromHash(hashed) {\n        const head = adjustBytes25519(hashed.slice(0, 32));\n        const prefix = hashed.slice(32, 64);\n        const scalar = modlLE(head);\n        const point = Point.BASE.multiply(scalar);\n        const pointBytes = point.toRawBytes();\n        return { head, prefix, scalar, point, pointBytes };\n    }\n    let _sha512Sync;\n    function sha512s(...m) {\n        if (typeof _sha512Sync !== 'function')\n            throw new Error('utils.sha512Sync must be set to use sync methods');\n        return _sha512Sync(...m);\n    }\n    async function getExtendedPublicKey(key) {\n        return getKeyFromHash(await utils.sha512(checkPrivateKey(key)));\n    }\n    function getExtendedPublicKeySync(key) {\n        return getKeyFromHash(sha512s(checkPrivateKey(key)));\n    }\n    async function getPublicKey(privateKey) {\n        return (await getExtendedPublicKey(privateKey)).pointBytes;\n    }\n    function getPublicKeySync(privateKey) {\n        return getExtendedPublicKeySync(privateKey).pointBytes;\n    }\n    async function sign(message, privateKey) {\n        message = ensureBytes(message);\n        const { prefix, scalar, pointBytes } = await getExtendedPublicKey(privateKey);\n        const r = modlLE(await utils.sha512(prefix, message));\n        const R = Point.BASE.multiply(r);\n        const k = modlLE(await utils.sha512(R.toRawBytes(), pointBytes, message));\n        const s = mod(r + k * scalar, CURVE.l);\n        return new Signature(R, s).toRawBytes();\n    }\n    function signSync(message, privateKey) {\n        message = ensureBytes(message);\n        const { prefix, scalar, pointBytes } = getExtendedPublicKeySync(privateKey);\n        const r = modlLE(sha512s(prefix, message));\n        const R = Point.BASE.multiply(r);\n        const k = modlLE(sha512s(R.toRawBytes(), pointBytes, message));\n        const s = mod(r + k * scalar, CURVE.l);\n        return new Signature(R, s).toRawBytes();\n    }\n    function prepareVerification(sig, message, publicKey) {\n        message = ensureBytes(message);\n        if (!(publicKey instanceof Point))\n            publicKey = Point.fromHex(publicKey, false);\n        const { r, s } = sig instanceof Signature ? sig.assertValidity() : Signature.fromHex(sig);\n        const SB = ExtendedPoint.BASE.multiplyUnsafe(s);\n        return { r, s, SB, pub: publicKey, msg: message };\n    }\n    function finishVerification(publicKey, r, SB, hashed) {\n        const k = modlLE(hashed);\n        const kA = ExtendedPoint.fromAffine(publicKey).multiplyUnsafe(k);\n        const RkA = ExtendedPoint.fromAffine(r).add(kA);\n        return RkA.subtract(SB).multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n    }\n    async function verify(sig, message, publicKey) {\n        const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n        const hashed = await utils.sha512(r.toRawBytes(), pub.toRawBytes(), msg);\n        return finishVerification(pub, r, SB, hashed);\n    }\n    function verifySync(sig, message, publicKey) {\n        const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n        const hashed = sha512s(r.toRawBytes(), pub.toRawBytes(), msg);\n        return finishVerification(pub, r, SB, hashed);\n    }\n    const sync = {\n        getExtendedPublicKey: getExtendedPublicKeySync,\n        getPublicKey: getPublicKeySync,\n        sign: signSync,\n        verify: verifySync,\n    };\n    async function getSharedSecret(privateKey, publicKey) {\n        const { head } = await getExtendedPublicKey(privateKey);\n        const u = Point.fromHex(publicKey).toX25519();\n        return curve25519.scalarMult(head, u);\n    }\n    Point.BASE._setWindowSize(8);\n    function cswap(swap, x_2, x_3) {\n        const dummy = mod(swap * (x_2 - x_3));\n        x_2 = mod(x_2 - dummy);\n        x_3 = mod(x_3 + dummy);\n        return [x_2, x_3];\n    }\n    function montgomeryLadder(pointU, scalar) {\n        const { P } = CURVE;\n        const u = normalizeScalar(pointU, P);\n        const k = normalizeScalar(scalar, P);\n        const a24 = BigInt(121665);\n        const x_1 = u;\n        let x_2 = _1n;\n        let z_2 = _0n;\n        let x_3 = u;\n        let z_3 = _1n;\n        let swap = _0n;\n        let sw;\n        for (let t = BigInt(255 - 1); t >= _0n; t--) {\n            const k_t = (k >> t) & _1n;\n            swap ^= k_t;\n            sw = cswap(swap, x_2, x_3);\n            x_2 = sw[0];\n            x_3 = sw[1];\n            sw = cswap(swap, z_2, z_3);\n            z_2 = sw[0];\n            z_3 = sw[1];\n            swap = k_t;\n            const A = x_2 + z_2;\n            const AA = mod(A * A);\n            const B = x_2 - z_2;\n            const BB = mod(B * B);\n            const E = AA - BB;\n            const C = x_3 + z_3;\n            const D = x_3 - z_3;\n            const DA = mod(D * A);\n            const CB = mod(C * B);\n            const dacb = DA + CB;\n            const da_cb = DA - CB;\n            x_3 = mod(dacb * dacb);\n            z_3 = mod(x_1 * mod(da_cb * da_cb));\n            x_2 = mod(AA * BB);\n            z_2 = mod(E * (AA + mod(a24 * E)));\n        }\n        sw = cswap(swap, x_2, x_3);\n        x_2 = sw[0];\n        x_3 = sw[1];\n        sw = cswap(swap, z_2, z_3);\n        z_2 = sw[0];\n        z_3 = sw[1];\n        const { pow_p_5_8, b2 } = pow_2_252_3(z_2);\n        const xp2 = mod(pow2(pow_p_5_8, BigInt(3)) * b2);\n        return mod(x_2 * xp2);\n    }\n    function encodeUCoordinate(u) {\n        return numberTo32BytesLE(mod(u, CURVE.P));\n    }\n    function decodeUCoordinate(uEnc) {\n        const u = ensureBytes(uEnc, 32);\n        u[31] &= 127;\n        return bytesToNumberLE(u);\n    }\n    const curve25519 = {\n        BASE_POINT_U: '0900000000000000000000000000000000000000000000000000000000000000',\n        scalarMult(privateKey, publicKey) {\n            const u = decodeUCoordinate(publicKey);\n            const p = decodeScalar25519(privateKey);\n            const pu = montgomeryLadder(u, p);\n            if (pu === _0n)\n                throw new Error('Invalid private or public key received');\n            return encodeUCoordinate(pu);\n        },\n        scalarMultBase(privateKey) {\n            return curve25519.scalarMult(privateKey, curve25519.BASE_POINT_U);\n        },\n    };\n    const crypto = {\n        node: nodeCrypto,\n        web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,\n    };\n    const utils = {\n        bytesToHex,\n        hexToBytes,\n        concatBytes,\n        getExtendedPublicKey,\n        mod,\n        invert,\n        TORSION_SUBGROUP: [\n            '0100000000000000000000000000000000000000000000000000000000000000',\n            'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a',\n            '0000000000000000000000000000000000000000000000000000000000000080',\n            '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05',\n            'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',\n            '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85',\n            '0000000000000000000000000000000000000000000000000000000000000000',\n            'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',\n        ],\n        hashToPrivateScalar: (hash) => {\n            hash = ensureBytes(hash);\n            if (hash.length < 40 || hash.length > 1024)\n                throw new Error('Expected 40-1024 bytes of private key as per FIPS 186');\n            return mod(bytesToNumberLE(hash), CURVE.l - _1n) + _1n;\n        },\n        randomBytes: (bytesLength = 32) => {\n            if (crypto.web) {\n                return crypto.web.getRandomValues(new Uint8Array(bytesLength));\n            }\n            else if (crypto.node) {\n                const { randomBytes } = crypto.node;\n                return new Uint8Array(randomBytes(bytesLength).buffer);\n            }\n            else {\n                throw new Error(\"The environment doesn't have randomBytes function\");\n            }\n        },\n        randomPrivateKey: () => {\n            return utils.randomBytes(32);\n        },\n        sha512: async (...messages) => {\n            const message = concatBytes(...messages);\n            if (crypto.web) {\n                const buffer = await crypto.web.subtle.digest('SHA-512', message.buffer);\n                return new Uint8Array(buffer);\n            }\n            else if (crypto.node) {\n                return Uint8Array.from(crypto.node.createHash('sha512').update(message).digest());\n            }\n            else {\n                throw new Error(\"The environment doesn't have sha512 function\");\n            }\n        },\n        precompute(windowSize = 8, point = Point.BASE) {\n            const cached = point.equals(Point.BASE) ? point : new Point(point.x, point.y);\n            cached._setWindowSize(windowSize);\n            cached.multiply(_2n);\n            return cached;\n        },\n        sha512Sync: undefined,\n    };\n    Object.defineProperties(utils, {\n        sha512Sync: {\n            configurable: false,\n            get() {\n                return _sha512Sync;\n            },\n            set(val) {\n                if (!_sha512Sync)\n                    _sha512Sync = val;\n            },\n        },\n    });\n\n    exports.CURVE = CURVE;\n    exports.ExtendedPoint = ExtendedPoint;\n    exports.Point = Point;\n    exports.RistrettoPoint = RistrettoPoint;\n    exports.Signature = Signature;\n    exports.curve25519 = curve25519;\n    exports.getPublicKey = getPublicKey;\n    exports.getSharedSecret = getSharedSecret;\n    exports.sign = sign;\n    exports.sync = sync;\n    exports.utils = utils;\n    exports.verify = verify;\n\n    Object.defineProperty(exports, '__esModule', { value: true });\n\n}));\n"
  },
  {
    "path": "docs/main.css",
    "content": "@font-face {\n    font-family: Helvetica, Arial, sans-serif;\n    /*src: local('Mulish Regular'), local('Mulish-Regular'),*/\n    /*     url('assets/fonts/mulish-regular.woff2') format('woff2');*/\n    font-weight: 400;\n    font-style: normal;\n    font-display: block;\n}\n\n@font-face {\n    font-family: Helvetica, Arial, sans-serif;\n    /*src: local('Mulish Bold'), local('Mulish-Bold'),*/\n    /*     url('assets/fonts/mulish-bold.woff2') format('woff2');*/\n    font-weight: 700;\n    font-style: normal;\n    font-display: block;\n}\n\nhtml {\n    -moz-osx-font-smoothing: grayscale;\n    -webkit-font-smoothing: antialiased;\n    text-rendering: optimizeLegibility;\n}\n\nbody, button, input, optgroup, select, textarea {\n    font-family: Helvetica, Arial, sans-serif;\n}\n\nbody {\n    margin: 0;\n}\n\nbody.plugin {\n    min-width: 400px;\n    min-height: 600px;\n}\n\nbody.disable-animations * {\n    transition-duration: 0s !important;\n    animation-duration: 0s !important;\n}\n\n.body-container {\n    position: absolute;\n    left: 0;\n    top: 0;\n    width: 100%;\n    height: 100%;\n    background: white;\n    overflow-x: hidden;\n    overflow-y: scroll;\n}\n\n* {\n    box-sizing: border-box;\n    user-select: none;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n}\n\na, a:focus, a:active, a:after {\n    color: #3CA4DB;\n}\n\ninput {\n    width: 100%;\n    border: none;\n    border-bottom: 1px solid transparent;\n    height: 40px;\n    margin-top: 10px;\n    margin-bottom: 10px;\n    font-size: 14px;\n    outline: none;\n    border-radius: 0;\n    padding-left: 0;\n    padding-right: 0;\n    user-select: auto;\n    -webkit-user-select: auto;\n    -moz-user-select: auto;\n\n    background-image: linear-gradient(rgba(215, 77, 77, 0), rgba(215, 77, 77, 0)), linear-gradient(rgba(60, 164, 219, 0), rgba(60, 164, 219, 0)), linear-gradient(#e7e7e7, #e7e7e7);\n    background-size: 0% 1px, 0% 1px, 100% 1px;\n    background-position: bottom center;\n    background-repeat: no-repeat;\n    transition: 0.2s background-image, 0s 0.2s background-size;\n}\n\ninput:focus {\n    background-image: linear-gradient(rgba(215, 77, 77, 0), rgba(215, 77, 77, 0)), linear-gradient(rgba(60, 164, 219, 1), rgba(60, 164, 219, 1)), linear-gradient(#e7e7e7, #e7e7e7);\n    background-size: 100% 1px, 100% 1px, 100% 1px;\n    transition: 0.2s background-image, 0.2s background-size;\n}\n\ninput.error {\n    background-image: linear-gradient(rgba(215, 77, 77, 1), rgba(215, 77, 77, 1)), linear-gradient(rgba(60, 164, 219, 0), rgba(60, 164, 219, 0)), linear-gradient(#e7e7e7, #e7e7e7);\n    background-size: 100% 1px, 100% 1px, 100% 1px;\n    transition: 0.2s background-image, 0.2s background-size;\n}\n\n\n::-webkit-input-placeholder { /* Edge */\n    color: #999999;\n}\n\n::placeholder {\n    color: #999999;\n}\n\n.input-label {\n    font-weight: 700;\n    color: #3CA4DB;\n}\n\nbutton {\n    cursor: pointer;\n    outline: none;\n}\n\n.btn-blue {\n    border: none;\n    background: #3CA4DB;\n    color: white;\n    border-radius: 2px;\n    height: 39px;\n    font-size: 15px;\n    font-weight: 700;\n}\n\n.btn-lite {\n    border: none;\n    color: #3CA4DB;\n    height: 40px;\n    font-size: 15px;\n    font-weight: 700;\n    background: none;\n}\n\n.btn-lite-red {\n    color: #D74D4D;\n}\n\n.btn-round {\n    border: none;\n    border-radius: 50%;\n    color: #919191;\n    width: 40px;\n    height: 40px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: 50%;\n    background-color: transparent;\n    opacity: .5;\n}\n\n.btn-round:hover, .btn-round:active {\n    background-color: #2E2F31;\n}\n\n.btn-loader {\n    pointer-events: none;\n}\n\n.btn-loader:after {\n    content: '';\n    position: absolute;\n    transform: translate(8px, 2px);\n    width: 8px;\n    height: 8px;\n    border: 3px solid white;\n    border-left: 3px solid transparent;\n    border-radius: 50%;\n    animation: loading-animation-spin 2s infinite linear;\n}\n\n.btn-lite.btn-loader:after {\n    transform: translate(6px, 3px);\n    width: 6px;\n    height: 6px;\n    border: 2px solid #3CA4DB;\n    border-left: 2px solid transparent;\n    animation: loading-animation-spin-small 2s infinite linear;\n}\n\n.btn-back {\n    position: fixed;\n    top: 10px;\n    left: 10px;\n    width: 40px;\n    height: 40px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: 20px 20px;\n    border: none;\n    background-color: transparent;\n    background-image: url(\"../assets/ui/arrow.svg\");\n    transform: scaleX(-1);\n    border-radius: 100%;\n    background-color: white;\n}\n\n.btn-back:hover {\n    background-color: #F7F7F7;\n}\n\n@keyframes loading-animation-spin {\n    to {\n        transform: translate(8px, 2px) rotate(1turn);\n    }\n}\n\n@keyframes loading-animation-spin-small {\n    to {\n        transform: translate(6px, 3px) rotate(1turn);\n    }\n}\n\n.screen {\n    position: absolute;\n    left: 0;\n    top: 0;\n    width: 100%;\n    height: 100%;\n    background: white;\n}\n\n.middle {\n    width: 100%;\n    min-height: 100%;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: center;\n}\n\n.middle-content {\n    text-align: center;\n}\n\n.screen.faded-show {\n    opacity: 1;\n    visibility: inherit !important;\n    transition: 0.3s opacity, 0.3s visibility step-start;\n}\n\n.screen.faded-hide {\n    opacity: 0;\n    visibility: hidden;\n    transition: 0.3s opacity, 0.3s visibility step-end;\n    animation: 99999999s 0.3s screen-delayed-overflow;\n}\n\n.screen.faded-show .middle {\n    animation: screen-show-left 0.3s ease-out;\n}\n\n.screen.faded-hide .middle {\n    animation: screen-hide-left 0.3s ease-in;\n}\n\n.screen.faded-show.isBack .middle {\n    animation: screen-show-right 0.3s ease-out;\n}\n\n.screen.faded-hide.isBack .middle {\n    animation: screen-hide-right 0.3s ease-in;\n}\n\n.screen.faded-show .screen-lottie {\n    opacity: 1;\n    transform: scale(1);\n    transition: 0.2s opacity, transform 0.2s;\n}\n\n.screen.faded-hide .screen-lottie {\n    opacity: 0;\n    transform: scale(0.3);\n    transition: 0.2s opacity, transform 0.25s;\n}\n\n\n@keyframes screen-delayed-overflow {\n    from {\n        overflow: hidden\n    }\n}\n\n@keyframes screen-hide-left {\n    from {\n        transform: translateX(0px)\n    }\n    to {\n        transform: translateX(-25px)\n    }\n}\n\n@keyframes screen-hide-right {\n    from {\n        transform: translateX(0px)\n    }\n    to {\n        transform: translateX(25px)\n    }\n}\n\n@keyframes screen-show-left {\n    from {\n        transform: translateX(25px)\n    }\n    to {\n        transform: translateX(0px)\n    }\n}\n\n@keyframes screen-show-right {\n    from {\n        transform: translateX(-25px)\n    }\n    to {\n        transform: translateX(0px)\n    }\n}\n\n.addr {\n    min-width: 24ch;\n    max-width: 24ch;\n    hyphens: manual;\n    user-select: text;\n    -webkit-user-select: text;\n    -moz-user-select: text;\n    cursor: text;\n}\n\n/* SCREENS */\n\n.screen-lottie {\n    display: block;\n    width: 120px;\n    height: 120px;\n    margin-left: auto;\n    margin-right: auto;\n    margin-top: 15px;\n    margin-bottom: 13px;\n}\n\n.screen-title {\n    font-size: 20px;\n    font-weight: 700;\n}\n\n.screen-text {\n    font-size: 15px;\n    line-height: 19px;\n    color: #999;\n    margin-top: 8px;\n    margin-bottom: 20px\n}\n\n.screen-btn {\n    width: 190px;\n}\n\n#notify {\n    position: absolute;\n    left: 50%;\n    top: 50%;\n    transform: translate(-50%, -50%);\n    padding: 10px;\n    background-color: rgba(0, 0, 0, 0.8);\n    border-radius: 4px;\n    color: white;\n    font-size: 14px;\n    text-align: center;\n\n    opacity: 0;\n    visibility: hidden;\n    transition: 0.15s opacity, 0.15s visibility step-end;\n}\n\n#notify.faded-show {\n    opacity: 1;\n    visibility: inherit !important;\n    transition: 0.15s opacity, 0.15s visibility step-start;\n}\n\n/* SET PASSWORD */\n\n#createPassword input {\n    width: 200px;\n    text-align: center;\n    font-size: 15px;\n}\n\n/* IMPORT && BACKUP && CONFIRM */\n\n#import .btn-lite {\n    font-weight: 400;\n    font-size: 14px;\n    margin-bottom: 10px;\n}\n\n#importWords,\n#confirmWords,\n#createWords {\n    max-width: 276px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n#wordsPopup,\n#wordsConfirmPopup {\n    position: absolute;\n    background: white;\n    padding-top: 4px;\n    padding-bottom: 4px;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    width: 92px;\n\n    max-height: 100px;\n    overflow-x: hidden;\n    overflow-y: scroll;\n    -webkit-overflow-scrolling: touch;\n    text-align: left;\n\n    border: 1px solid #DCDCDC;\n}\n\n#wordsConfirmPopup {\n    width: 190px;\n}\n\n.words-popup-item {\n    font-size: 14px;\n    line-height: 30px;\n    cursor: pointer;\n    padding-left: 20px;\n    padding-right: 20px;\n}\n\n.words-popup-item:hover {\n    background: #f0f0f0;\n}\n\n.words-popup-item.selected {\n    background: #f0f0f0;\n}\n\n.word-item {\n    float: left;\n}\n\n.word-num {\n    display: inline-block;\n    width: 20px;\n    text-align: right;\n    font-size: 14px;\n    color: #999;\n    margin-right: 4px;\n}\n\n#import .word-num,\n#wordsConfirm .word-num {\n    margin-right: 8px;\n    margin-left: 16px;\n}\n\n#import input,\n#wordsConfirm input {\n    width: 92px;\n    height: 32px;\n    margin-top: 0;\n    margin-bottom: 0;\n}\n\n#wordsConfirm input {\n    width: 190px;\n}\n\n.create-word-item {\n    float: left;\n    width: 136px;\n    margin-top: 8px;\n    margin-bottom: 8px;\n    font-size: 14px;\n    text-align: left;\n}\n\n/* MAIN> */\n\n#main {\n    display: flex;\n    flex-direction: column;\n}\n\n.head {\n    width: 100%;\n    background: #000;\n    color: white;\n    text-align: center;\n    padding-bottom: 25px;\n}\n\n.head-row {\n    color: #919191;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    padding: 10px;\n    margin-bottom: 44px\n}\n\n#updateLabel {\n    flex-grow: 1;\n    font-size: 14px\n}\n\n.balance-container {\n    margin-bottom: 6px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n\n#balance {\n    font-size: 32px;\n}\n\n.balance-symbol {\n    width: 32px;\n    height: 32px;\n}\n\n@keyframes MoveUpDown {\n    0%, 100% {\n        transform: translate(0, -2px);\n    }\n    50% {\n        transform: translate(0, 2px);\n    }\n}\n\n.balance-diamond-container {\n    position: relative;\n    width: 48px;\n    height: 48px;\n    margin-left: -4px;\n}\n\n#diamond {\n    position: absolute;\n    left: 0;\n    top: 0;\n    width: 48px;\n    height: 48px;\n    background-repeat: no-repeat;\n    background-position: center;\n    background-size: 110%;\n    animation: MoveUpDown 3s linear infinite;\n}\n\n.your-balance {\n    font-size: 14px;\n    margin-bottom: 49px;\n    color: #eee\n}\n\n#main .btn-blue {\n    width: 140px;\n    margin-left: 10px;\n    margin-right: 10px;\n}\n\n@media (max-width: 450px) {\n    #main .btn-blue {\n        width: 100px;\n        margin-left: 4px;\n        margin-right: 4px;\n    }\n}\n\n@media (max-width: 320px) {\n    #main .btn-blue {\n        width: 85px;\n        margin-left: 2px;\n        margin-right: 2px;\n    }\n}\n\n.btn-icon {\n    display: inline-block;\n    width: 10px;\n    height: 10px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: contain;\n    margin-right: 4px;\n}\n\n#walletCreated {\n    text-align: center;\n    position: absolute;\n    top: 70px;\n    left: 50%;\n    margin-left: -75px;\n    font-weight: 700;\n    font-size: 20px;\n}\n\n#walletCreated tgs-player {\n    display: block;\n    width: 150px;\n    height: 150px;\n    margin-bottom: 20px;\n}\n\n/* menu dropdown */\n\n#menuDropdown {\n    position: absolute;\n    right: 50px;\n    top: 50px;\n\n    background: white;\n    padding-top: 10px;\n    padding-bottom: 10px;\n    border-radius: 4px;\n    min-width: 180px;\n}\n\n.dropdown-item {\n    font-size: 14px;\n    line-height: 30px;\n    cursor: pointer;\n    padding-left: 20px;\n    padding-right: 20px;\n    position: relative;\n}\n\n.dropdown-item:hover {\n    background: #f0f0f0;\n}\n\n/* menu dropdown toggle */\n\n.dropdown-toggle {\n    position: absolute;\n    top: 4px;\n    right: 8px;\n    width: 46px;\n    height: 24px;\n    background-color: #ddd;\n    border-radius: 16px;\n}\n\n.dropdown-toggle:after {\n    content: '';\n    position: absolute;\n    left: 2px;\n    top: 2px;\n    border-radius: 50%;\n    width: 20px;\n    height: 20px;\n    background-color: #fff;\n    box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);\n    transition: left 0.2s cubic-bezier(0, 1, 0.5, 1);\n}\n\n.dropdown-toggle.toggle-on {\n    background-color: #3CA4DB;\n}\n\n.toggle-on.dropdown-toggle:after {\n    left: 24px;\n}\n\n/* TRANSACTIONS */\n\n#transactionsContainer {\n    position: relative;\n    width: 100%;\n    flex-grow: 1;\n    overflow-x: hidden;\n    overflow-y: scroll;\n    -webkit-overflow-scrolling: touch;\n}\n\n#transactionsList {\n    padding-left: 20px;\n    padding-right: 20px;\n    padding-top: 10px;\n}\n\n.date-separator {\n    font-weight: 700;\n    padding-top: 10px;\n    padding-bottom: 10px;\n    font-size: 14px;\n    width: 100%;\n    max-width: 480px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n.tx-item {\n    position: relative;\n    padding-bottom: 10px;\n    margin-bottom: 10px;\n    border-bottom: 1px solid #E7E7E7;\n    cursor: pointer;\n    width: 100%;\n    max-width: 480px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n.tx-item-encrypted-icon {\n    position: absolute;\n    right: 0px;\n    top: 30px;\n    width: 32px;\n    height: 32px;\n    background-image: url(\"../assets/ui/encrypted-message.png\");\n    background-size: contain;\n    background-repeat: no-repeat;\n}\n\n.tx-amount {\n    font-weight: 700;\n    font-size: 16px;\n    color: #D74D4D;\n}\n\n.tx-amount-green {\n    color: #39B139;\n}\n\n.tx-from {\n    font-size: 13px;\n}\n\n.tx-addr {\n    font-family: monospace;\n    font-size: 15px;\n    margin-top: 4px;\n    margin-bottom: 4px;\n    word-break: keep-all;\n}\n\n.tx-comment {\n    color: #000;\n    font-size: 13px;\n    margin-top: 8px;\n    margin-bottom: 8px;\n}\n\n.tx-fee {\n    color: #999999;\n    font-size: 13px;\n}\n\n.tx-item-date {\n    position: absolute;\n    top: 0;\n    right: 0;\n    color: #999999;\n    font-size: 13px;\n    line-height: 26px;\n}\n\n/* POPUP */\n\n#modal {\n    position: fixed;\n    left: 0;\n    top: 0;\n    width: 100%;\n    height: 100%;\n    background-color: rgba(0, 0, 0, 0.2);\n}\n\n.popup {\n    position: absolute;\n    left: 50%;\n    top: 50%;\n    transform: translate(-50%, -50%);\n    box-shadow: 0px 8px 24px rgba(0, 0, 0, .25);\n\n    width: 320px;\n    background-color: white;\n    border-radius: 4px;\n    padding: 20px;\n    font-size: 14px;\n}\n\n.popup#alert {\n    position: fixed;\n}\n\n.popup.faded-show,\n#menuDropdown.faded-show,\n#modal.faded-show {\n    opacity: 1;\n    visibility: inherit !important;\n    transition: 0.15s opacity, 0.15s visibility step-start;\n}\n\n.popup.faded-hide,\n#menuDropdown.faded-hide,\n#modal.faded-hide {\n    opacity: 0;\n    visibility: hidden;\n    transition: 0.15s opacity, 0.15s visibility step-end;\n}\n\n.popup-title {\n    font-weight: 700;\n    margin-bottom: 20px;\n    font-size: 17px;\n}\n\n.popup-text {\n    font-size: 14px;\n    line-height: 18px;\n}\n\n.popup-black-text {\n    font-size: 14px;\n    line-height: 18px;\n}\n\n.about-magic {\n    display: none;\n    text-align: left;\n}\n\n.plugin .about-magic {\n    display: block;\n}\n\n.about-magic h4 {\n    margin-bottom: 12px;\n}\n\n.about-magic p {\n    margin-top: 12px;\n}\n\n.popup-grey-text {\n    line-height: 18px;\n    color: #999999;\n    font-size: 14px;\n    margin-bottom: 20px\n}\n\n.popup-close-btn {\n    position: absolute;\n    top: 10px;\n    right: 10px;\n    width: 32px;\n    height: 32px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: 40%;\n    border: none;\n    background-color: transparent;\n    background-image: url(\"../assets/ui/close.svg\");\n}\n\n.popup-footer {\n    text-align: right;\n    margin-top: 10px;\n}\n\n.popup .btn-blue {\n    width: 100%;\n}\n\n.popup tgs-player {\n    display: block;\n    width: 150px;\n    height: 150px;\n    margin-left: auto;\n    margin-right: auto\n}\n\n.popup input {\n    margin-top: 6px;\n    margin-bottom: 6px;\n    height: 36px;\n}\n\n/* RECEIVE POPUP */\n\n.qr-container {\n    text-align: center;\n    margin: 20px 0px 20px 0px;\n}\n\n#qr, #invoiceQrImg {\n    width: 185px;\n    height: 185px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n#qr img, #invoiceQrImg img, #invoiceQrImg canvas {\n    width: 185px;\n    height: 185px;\n}\n\n#receive .my-addr {\n    font-family: monospace;\n    text-align: center;\n    font-size: 18px;\n    margin-top: -4px;\n    max-width: 280px;\n    height: 42px;\n    cursor: pointer;\n}\n\n#receive .btn-lite {\n    text-align: center;\n    width: 100%;\n    font-weight: 400;\n}\n\n#receive .btn-lite-first {\n    margin-top: 20px;\n}\n\n#receive .btn-blue {\n    margin-top: 10px;\n}\n\n/* SEND POPUP */\n\n#send .btn-blue {\n    margin-top: 20px;\n}\n\n#sendBalance {\n    position: absolute;\n    right: 0;\n    top: 0;\n    color: #999999;\n    font-size: 14px;\n}\n\n\n#sendConfirm .addr, #signConfirm .addr {\n    font-family: monospace;\n    text-align: center;\n    font-size: 18px;\n    margin-top: 10px;\n    margin-bottom: 10px;\n    max-width: 280px;\n    padding: 10px;\n    background-color: #F1F1F1;\n}\n\n#encryptCommentCheckboxContainer {\n    display: flex;\n    flex-direction: row;\n    align-items: center;\n    margin-top: 12px;\n}\n\n#encryptCommentCheckbox {\n}\n\n/* INVOICE POPUP */\n\n#invoice .popup-black-text {\n    margin-top: 10px;\n    margin-bottom: 10px;\n    word-break: break-all;\n}\n\n#invoice .btn-lite {\n    text-align: center;\n    width: 100%;\n    font-weight: 400;\n}\n\n#invoice .btn-blue {\n    margin-top: 10px;\n}\n\n#invoiceQr .btn-blue {\n    margin-top: 20px;\n}\n\n#invoice_link {\n    user-select: text;\n    -webkit-user-select: text;\n    -moz-user-select: text;\n    cursor: text;\n}\n\n/* TRANSACTION POPUP */\n\n#transactionSender {\n    font-family: monospace;\n    max-width: 280px;\n    font-size: 18px;\n    margin-top: 4px;\n    margin-bottom: 4px;\n}\n\n#transactionComment {\n    word-break: break-all;\n}\n\n#transactionDecryptCommentButton {\n    margin-top: 10px;\n    margin-bottom: 10px;\n    font-weight: normal;\n    height: auto;\n    cursor: pointer;\n}\n\n#transactionAmount {\n    font-size: 28px;\n    text-align: center;\n    margin-bottom: 8px;\n}\n\n#transactionFee {\n    color: #999;\n    text-align: center;\n}\n\n#transaction .input-label {\n    margin-top: 20px;\n    margin-bottom: 10px;\n}\n\n/* EXTENSION */\n\n#menu_magic {\n    display: none;\n}\n\n#menu_proxy {\n    display: none;\n    pointer-events: none;\n}\n\n#menu_telegram {\n    display: none;\n}\n\n.plugin .menu_telegram-show {\n    display: block !important;\n}\n\n#menu_proxy:after {\n    position: absolute;\n    top: 4px;\n    line-height: 8px;\n    right: 70px;\n    width: 14px;\n    height: 8px;\n    font-size: 10px;\n    color: #1d98dc;\n    border-radius: 4px;\n    padding: 4px;\n    content: 'Soon';\n}\n\n.plugin #menu_magic {\n    display: block;\n}\n\n.plugin #menu_proxy {\n    display: block;\n}\n\n\n.plugin #menu_extension_chrome {\n    display: none;\n}\n\n#menu_extension_firefox {\n    display: none;\n}\n\n.plugin #start_importLedgerHidBtn {\n    display: none;\n}\n\n#start_importLedgerHidBtn {\n    display: none;\n}\n\n.input-password {\n    text-align: center;\n    width: 200px;\n    margin-left: 40px;\n    font-size: 15px;\n}\n\n.display-none {\n    display: none;\n}\n\n.visibility-hidden {\n    visibility: hidden;\n}\n\n.rotate-180 {\n    transform: rotate(180deg);\n}\n\n.position-relative {\n    position: relative;\n}\n\n.clear-both {\n    clear: both;\n}\n\n.font-weight-normal {\n    font-weight: 400;\n}\n\n.font-weight-bold {\n    font-weight: 700;\n}\n\n.text-danger {\n    color: #D74D4D;\n}\n\n.line-height-24 {\n    line-height: 24px;\n}\n\n.text-align-center {\n    text-align: center;\n}\n\n.bg-down-left {\n    background-image: url('../assets/ui/down-left.svg')\n}\n\n.bg-menu {\n    background-image: url('../assets/ui/menu.svg')\n}\n\n.bg-refresh {\n    background-image: url('../assets/ui/refresh.svg')\n}\n\n.w-100 {\n    width: 100%;\n}\n\n.mb-10 {\n    margin-bottom: 10px;\n}\n\n.mb-18 {\n    margin-bottom: 18px;\n}\n\n.mb-20 {\n    margin-bottom: 20px;\n}\n\n.mt-10 {\n    margin-top: 10px;\n}\n\n.mt-18 {\n    margin-top: 18px;\n}\n\n.mt-20 {\n    margin-top: 20px;\n}\n\n.mt-24 {\n    margin-top: 24px;\n}\n\n.mt-26 {\n    margin-top: 26px;\n}\n\n.mt-30 {\n    margin-top: 30px;\n}\n\n.mt-38 {\n    margin-top: 38px;\n}\n\n.mt-54 {\n    margin-top: 54px;\n}\n\n.mt-80 {\n    margin-top: 95px;\n}\n\n.mt-95 {\n    margin-top: 95px;\n}\n\n.mt-170 {\n    margin-top: 170px;\n}\n\n.pb-10 {\n    padding-bottom: 10px;\n}\n\n/* checkbox */\n\n.checkbox-container {\n    display: block;\n    position: relative;\n    padding-left: 24px;\n    line-height: 18px;\n    cursor: pointer;\n\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n}\n\n.checkbox-container input {\n    position: absolute;\n    opacity: 0;\n    cursor: pointer;\n    height: 0;\n    width: 0;\n}\n\n.checkmark {\n    position: absolute;\n    top: 0;\n    left: 0;\n    height: 18px;\n    width: 18px;\n    background-color: #eee;\n}\n\n.checkbox-container input:checked ~ .checkmark {\n    background-color: #3CA4DB;\n}\n\n.checkmark:after {\n    content: \"\";\n    position: absolute;\n    display: none;\n}\n\n.checkbox-container input:checked ~ .checkmark:after {\n    display: block;\n}\n\n.checkbox-container .checkmark:after {\n    left: 6px;\n    top: 2px;\n    width: 4px;\n    height: 8px;\n    border: solid white;\n    border-width: 0 3px 3px 0;\n    -webkit-transform: rotate(45deg);\n    -ms-transform: rotate(45deg);\n    transform: rotate(45deg);\n}"
  },
  {
    "path": "license",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"ton-wallet\",\n  \"version\": \"1.1.50\",\n  \"devDependencies\": {\n    \"gulp\": \"4.0.2\",\n    \"gulp-replace\": \"1.1.3\",\n    \"gulp-zip\": \"5.1.0\",\n    \"open\": \"8.4.0\",\n    \"webpack\": \"5.70.0\"\n  },\n  \"scripts\": {\n    \"dev\": \"gulp dev --gulpfile build/gulpfile.js --cwd . --target\",\n    \"watch\": \"gulp watch --gulpfile build/gulpfile.js --cwd . --target\",\n    \"start\": \"gulp start --gulpfile build/gulpfile.js --cwd . --target\",\n    \"build\": \"gulp build --gulpfile build/gulpfile.js --cwd . --target\",\n    \"pack\": \"gulp pack --gulpfile build/gulpfile.js --cwd . --target\"\n  }\n}\n"
  },
  {
    "path": "readme.md",
    "content": "# ⚠️ Archived\n\nThis is the first web wallet in TON. The code may be useful for learning or nostalgia. The actual code of wallet.ton.org is available at https://github.com/ton-blockchain/ton-wallet.\n\n# TON Wallet\n\nTON Wallet is a free client-side interface for interact with The Open Network blockchain.\n\n- [Website (wallet.ton.org)](https://wallet.ton.org)\n- [Chrome extension (also available for any Chromium-based browser)](https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd)\n- Firefox Add-on (so far only manual build from source)\n- Safari extension (so far only manual build from source)\n\n## Security\n\nPrivate keys do not leave your device, the keys are stored in the browser memory, encrypted with a password that is entered during transaction generation.\n\n## Issues and proposals\n\nPlease, post your issues and proposals as Issues in this repository.\n\n## Switch between mainnet and testnet\n\n- Support from 1.1.35 version\n- Open menu in right-top corner and select `About` item\n- Click on `Version:` label with Shift key pressed\n\n## Development\n\nSee [build](build) project directory.\n\n## Support browsers:\n\n- Chrome (and Chromium-based) 55+ for website version, 88+ for extension\n- Firefox 63+\n- Safari 11+ (MacOS 10.12+) for website version, 14+ for extension\n- Safari iOS 11+\n- Edge 79+\n- Opera 42+\n- Chrome for Android 55+\n- Android 5+ browser\n- Samsung Internet 6+\n- Opera Mobile 64+\n- UC Browser 12.12+\n- Firefox for Android 63+"
  },
  {
    "path": "src/assets/favicon/browserconfig.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<browserconfig>\n    <msapplication>\n        <tile>\n            <square70x70logo src=\"assets/favicon/mstile-70x70.png\"/>\n            <square150x150logo src=\"assets/favicon/mstile-150x150.png\"/>\n            <square310x310logo src=\"assets/favicon/mstile-310x310.png\"/>\n            <wide310x150logo src=\"assets/favicon/mstile-310x150.png\"/>\n            <TileColor>#ffffff</TileColor>\n        </tile>\n    </msapplication>\n</browserconfig>\n"
  },
  {
    "path": "src/assets/favicon/site.webmanifest",
    "content": "{\n    \"name\": \"TON Wallet\",\n    \"short_name\": \"TON Wallet\",\n    \"icons\": [\n        {\n            \"src\": \"36x36.png\",\n            \"sizes\": \"36x36\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"48x48.png\",\n            \"sizes\": \"48x48\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"72x72.png\",\n            \"sizes\": \"72x72\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"96x96.png\",\n            \"sizes\": \"96x96\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"144x144.png\",\n            \"sizes\": \"144x144\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"192x192.png\",\n            \"sizes\": \"192x192\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"256x256.png\",\n            \"sizes\": \"256x256\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"384x384.png\",\n            \"sizes\": \"384x384\",\n            \"type\": \"image/png\"\n        },\n        {\n            \"src\": \"512x512.png\",\n            \"sizes\": \"512x512\",\n            \"type\": \"image/png\"\n        }\n    ],\n    \"theme_color\": \"#ffffff\",\n    \"background_color\": \"#ffffff\",\n    \"display\": \"standalone\"\n}\n"
  },
  {
    "path": "src/css/main.css",
    "content": "@font-face {\n    font-family: Helvetica, Arial, sans-serif;\n    /*src: local('Mulish Regular'), local('Mulish-Regular'),*/\n    /*     url('assets/fonts/mulish-regular.woff2') format('woff2');*/\n    font-weight: 400;\n    font-style: normal;\n    font-display: block;\n}\n\n@font-face {\n    font-family: Helvetica, Arial, sans-serif;\n    /*src: local('Mulish Bold'), local('Mulish-Bold'),*/\n    /*     url('assets/fonts/mulish-bold.woff2') format('woff2');*/\n    font-weight: 700;\n    font-style: normal;\n    font-display: block;\n}\n\nhtml {\n    -moz-osx-font-smoothing: grayscale;\n    -webkit-font-smoothing: antialiased;\n    text-rendering: optimizeLegibility;\n}\n\nbody, button, input, optgroup, select, textarea {\n    font-family: Helvetica, Arial, sans-serif;\n}\n\nbody {\n    margin: 0;\n}\n\nbody.plugin {\n    min-width: 400px;\n    min-height: 600px;\n}\n\nbody.disable-animations * {\n    transition-duration: 0s !important;\n    animation-duration: 0s !important;\n}\n\n.body-container {\n    position: absolute;\n    left: 0;\n    top: 0;\n    width: 100%;\n    height: 100%;\n    background: white;\n    overflow-x: hidden;\n    overflow-y: scroll;\n}\n\n* {\n    box-sizing: border-box;\n    user-select: none;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n}\n\na, a:focus, a:active, a:after {\n    color: #3CA4DB;\n}\n\ninput {\n    width: 100%;\n    border: none;\n    border-bottom: 1px solid transparent;\n    height: 40px;\n    margin-top: 10px;\n    margin-bottom: 10px;\n    font-size: 14px;\n    outline: none;\n    border-radius: 0;\n    padding-left: 0;\n    padding-right: 0;\n    user-select: auto;\n    -webkit-user-select: auto;\n    -moz-user-select: auto;\n\n    background-image: linear-gradient(rgba(215, 77, 77, 0), rgba(215, 77, 77, 0)), linear-gradient(rgba(60, 164, 219, 0), rgba(60, 164, 219, 0)), linear-gradient(#e7e7e7, #e7e7e7);\n    background-size: 0% 1px, 0% 1px, 100% 1px;\n    background-position: bottom center;\n    background-repeat: no-repeat;\n    transition: 0.2s background-image, 0s 0.2s background-size;\n}\n\ninput:focus {\n    background-image: linear-gradient(rgba(215, 77, 77, 0), rgba(215, 77, 77, 0)), linear-gradient(rgba(60, 164, 219, 1), rgba(60, 164, 219, 1)), linear-gradient(#e7e7e7, #e7e7e7);\n    background-size: 100% 1px, 100% 1px, 100% 1px;\n    transition: 0.2s background-image, 0.2s background-size;\n}\n\ninput.error {\n    background-image: linear-gradient(rgba(215, 77, 77, 1), rgba(215, 77, 77, 1)), linear-gradient(rgba(60, 164, 219, 0), rgba(60, 164, 219, 0)), linear-gradient(#e7e7e7, #e7e7e7);\n    background-size: 100% 1px, 100% 1px, 100% 1px;\n    transition: 0.2s background-image, 0.2s background-size;\n}\n\n\n::-webkit-input-placeholder { /* Edge */\n    color: #999999;\n}\n\n::placeholder {\n    color: #999999;\n}\n\n.input-label {\n    font-weight: 700;\n    color: #3CA4DB;\n}\n\nbutton {\n    cursor: pointer;\n    outline: none;\n}\n\n.btn-blue {\n    border: none;\n    background: #3CA4DB;\n    color: white;\n    border-radius: 2px;\n    height: 39px;\n    font-size: 15px;\n    font-weight: 700;\n}\n\n.btn-lite {\n    border: none;\n    color: #3CA4DB;\n    height: 40px;\n    font-size: 15px;\n    font-weight: 700;\n    background: none;\n}\n\n.btn-lite-red {\n    color: #D74D4D;\n}\n\n.btn-round {\n    border: none;\n    border-radius: 50%;\n    color: #919191;\n    width: 40px;\n    height: 40px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: 50%;\n    background-color: transparent;\n    opacity: .5;\n}\n\n.btn-round:hover, .btn-round:active {\n    background-color: #2E2F31;\n}\n\n.btn-loader {\n    pointer-events: none;\n}\n\n.btn-loader:after {\n    content: '';\n    position: absolute;\n    transform: translate(8px, 2px);\n    width: 8px;\n    height: 8px;\n    border: 3px solid white;\n    border-left: 3px solid transparent;\n    border-radius: 50%;\n    animation: loading-animation-spin 2s infinite linear;\n}\n\n.btn-lite.btn-loader:after {\n    transform: translate(6px, 3px);\n    width: 6px;\n    height: 6px;\n    border: 2px solid #3CA4DB;\n    border-left: 2px solid transparent;\n    animation: loading-animation-spin-small 2s infinite linear;\n}\n\n.btn-back {\n    position: fixed;\n    top: 10px;\n    left: 10px;\n    width: 40px;\n    height: 40px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: 20px 20px;\n    border: none;\n    background-color: transparent;\n    background-image: url(\"../assets/ui/arrow.svg\");\n    transform: scaleX(-1);\n    border-radius: 100%;\n    background-color: white;\n}\n\n.btn-back:hover {\n    background-color: #F7F7F7;\n}\n\n@keyframes loading-animation-spin {\n    to {\n        transform: translate(8px, 2px) rotate(1turn);\n    }\n}\n\n@keyframes loading-animation-spin-small {\n    to {\n        transform: translate(6px, 3px) rotate(1turn);\n    }\n}\n\n.screen {\n    position: absolute;\n    left: 0;\n    top: 0;\n    width: 100%;\n    height: 100%;\n    background: white;\n}\n\n.middle {\n    width: 100%;\n    min-height: 100%;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: center;\n}\n\n.middle-content {\n    text-align: center;\n}\n\n.screen.faded-show {\n    opacity: 1;\n    visibility: inherit !important;\n    transition: 0.3s opacity, 0.3s visibility step-start;\n}\n\n.screen.faded-hide {\n    opacity: 0;\n    visibility: hidden;\n    transition: 0.3s opacity, 0.3s visibility step-end;\n    animation: 99999999s 0.3s screen-delayed-overflow;\n}\n\n.screen.faded-show .middle {\n    animation: screen-show-left 0.3s ease-out;\n}\n\n.screen.faded-hide .middle {\n    animation: screen-hide-left 0.3s ease-in;\n}\n\n.screen.faded-show.isBack .middle {\n    animation: screen-show-right 0.3s ease-out;\n}\n\n.screen.faded-hide.isBack .middle {\n    animation: screen-hide-right 0.3s ease-in;\n}\n\n.screen.faded-show .screen-lottie {\n    opacity: 1;\n    transform: scale(1);\n    transition: 0.2s opacity, transform 0.2s;\n}\n\n.screen.faded-hide .screen-lottie {\n    opacity: 0;\n    transform: scale(0.3);\n    transition: 0.2s opacity, transform 0.25s;\n}\n\n\n@keyframes screen-delayed-overflow {\n    from {\n        overflow: hidden\n    }\n}\n\n@keyframes screen-hide-left {\n    from {\n        transform: translateX(0px)\n    }\n    to {\n        transform: translateX(-25px)\n    }\n}\n\n@keyframes screen-hide-right {\n    from {\n        transform: translateX(0px)\n    }\n    to {\n        transform: translateX(25px)\n    }\n}\n\n@keyframes screen-show-left {\n    from {\n        transform: translateX(25px)\n    }\n    to {\n        transform: translateX(0px)\n    }\n}\n\n@keyframes screen-show-right {\n    from {\n        transform: translateX(-25px)\n    }\n    to {\n        transform: translateX(0px)\n    }\n}\n\n.addr {\n    min-width: 24ch;\n    max-width: 24ch;\n    hyphens: manual;\n    user-select: text;\n    -webkit-user-select: text;\n    -moz-user-select: text;\n    cursor: text;\n}\n\n/* SCREENS */\n\n.screen-lottie {\n    display: block;\n    width: 120px;\n    height: 120px;\n    margin-left: auto;\n    margin-right: auto;\n    margin-top: 15px;\n    margin-bottom: 13px;\n}\n\n.screen-title {\n    font-size: 20px;\n    font-weight: 700;\n}\n\n.screen-text {\n    font-size: 15px;\n    line-height: 19px;\n    color: #999;\n    margin-top: 8px;\n    margin-bottom: 20px\n}\n\n.screen-btn {\n    width: 190px;\n}\n\n#notify {\n    position: absolute;\n    left: 50%;\n    top: 50%;\n    transform: translate(-50%, -50%);\n    padding: 10px;\n    background-color: rgba(0, 0, 0, 0.8);\n    border-radius: 4px;\n    color: white;\n    font-size: 14px;\n    text-align: center;\n\n    opacity: 0;\n    visibility: hidden;\n    transition: 0.15s opacity, 0.15s visibility step-end;\n}\n\n#notify.faded-show {\n    opacity: 1;\n    visibility: inherit !important;\n    transition: 0.15s opacity, 0.15s visibility step-start;\n}\n\n/* SET PASSWORD */\n\n#createPassword input {\n    width: 200px;\n    text-align: center;\n    font-size: 15px;\n}\n\n/* IMPORT && BACKUP && CONFIRM */\n\n#import .btn-lite {\n    font-weight: 400;\n    font-size: 14px;\n    margin-bottom: 10px;\n}\n\n#importWords,\n#confirmWords,\n#createWords {\n    max-width: 276px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n#wordsPopup,\n#wordsConfirmPopup {\n    position: absolute;\n    background: white;\n    padding-top: 4px;\n    padding-bottom: 4px;\n    border-bottom-left-radius: 4px;\n    border-bottom-right-radius: 4px;\n    width: 92px;\n\n    max-height: 100px;\n    overflow-x: hidden;\n    overflow-y: scroll;\n    -webkit-overflow-scrolling: touch;\n    text-align: left;\n\n    border: 1px solid #DCDCDC;\n}\n\n#wordsConfirmPopup {\n    width: 190px;\n}\n\n.words-popup-item {\n    font-size: 14px;\n    line-height: 30px;\n    cursor: pointer;\n    padding-left: 20px;\n    padding-right: 20px;\n}\n\n.words-popup-item:hover {\n    background: #f0f0f0;\n}\n\n.words-popup-item.selected {\n    background: #f0f0f0;\n}\n\n.word-item {\n    float: left;\n}\n\n.word-num {\n    display: inline-block;\n    width: 20px;\n    text-align: right;\n    font-size: 14px;\n    color: #999;\n    margin-right: 4px;\n}\n\n#import .word-num,\n#wordsConfirm .word-num {\n    margin-right: 8px;\n    margin-left: 16px;\n}\n\n#import input,\n#wordsConfirm input {\n    width: 92px;\n    height: 32px;\n    margin-top: 0;\n    margin-bottom: 0;\n}\n\n#wordsConfirm input {\n    width: 190px;\n}\n\n.create-word-item {\n    float: left;\n    width: 136px;\n    margin-top: 8px;\n    margin-bottom: 8px;\n    font-size: 14px;\n    text-align: left;\n}\n\n/* MAIN> */\n\n#main {\n    display: flex;\n    flex-direction: column;\n}\n\n.head {\n    width: 100%;\n    background: #000;\n    color: white;\n    text-align: center;\n    padding-bottom: 25px;\n}\n\n.head-row {\n    color: #919191;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    padding: 10px;\n    margin-bottom: 44px\n}\n\n#updateLabel {\n    flex-grow: 1;\n    font-size: 14px\n}\n\n.balance-container {\n    margin-bottom: 6px;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n}\n\n#balance {\n    font-size: 32px;\n}\n\n.balance-symbol {\n    width: 32px;\n    height: 32px;\n}\n\n@keyframes MoveUpDown {\n    0%, 100% {\n        transform: translate(0, -2px);\n    }\n    50% {\n        transform: translate(0, 2px);\n    }\n}\n\n.balance-diamond-container {\n    position: relative;\n    width: 48px;\n    height: 48px;\n    margin-left: -4px;\n}\n\n#diamond {\n    position: absolute;\n    left: 0;\n    top: 0;\n    width: 48px;\n    height: 48px;\n    background-repeat: no-repeat;\n    background-position: center;\n    background-size: 110%;\n    animation: MoveUpDown 3s linear infinite;\n}\n\n.your-balance {\n    font-size: 14px;\n    margin-bottom: 49px;\n    color: #eee\n}\n\n#main .btn-blue {\n    width: 140px;\n    margin-left: 10px;\n    margin-right: 10px;\n}\n\n@media (max-width: 450px) {\n    #main .btn-blue {\n        width: 100px;\n        margin-left: 4px;\n        margin-right: 4px;\n    }\n}\n\n@media (max-width: 320px) {\n    #main .btn-blue {\n        width: 85px;\n        margin-left: 2px;\n        margin-right: 2px;\n    }\n}\n\n.btn-icon {\n    display: inline-block;\n    width: 10px;\n    height: 10px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: contain;\n    margin-right: 4px;\n}\n\n#walletCreated {\n    text-align: center;\n    position: absolute;\n    top: 70px;\n    left: 50%;\n    margin-left: -75px;\n    font-weight: 700;\n    font-size: 20px;\n}\n\n#walletCreated tgs-player {\n    display: block;\n    width: 150px;\n    height: 150px;\n    margin-bottom: 20px;\n}\n\n/* menu dropdown */\n\n#menuDropdown {\n    position: absolute;\n    right: 50px;\n    top: 50px;\n\n    background: white;\n    padding-top: 10px;\n    padding-bottom: 10px;\n    border-radius: 4px;\n    min-width: 180px;\n}\n\n.dropdown-item {\n    font-size: 14px;\n    line-height: 30px;\n    cursor: pointer;\n    padding-left: 20px;\n    padding-right: 20px;\n    position: relative;\n}\n\n.dropdown-item:hover {\n    background: #f0f0f0;\n}\n\n/* menu dropdown toggle */\n\n.dropdown-toggle {\n    position: absolute;\n    top: 4px;\n    right: 8px;\n    width: 46px;\n    height: 24px;\n    background-color: #ddd;\n    border-radius: 16px;\n}\n\n.dropdown-toggle:after {\n    content: '';\n    position: absolute;\n    left: 2px;\n    top: 2px;\n    border-radius: 50%;\n    width: 20px;\n    height: 20px;\n    background-color: #fff;\n    box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);\n    transition: left 0.2s cubic-bezier(0, 1, 0.5, 1);\n}\n\n.dropdown-toggle.toggle-on {\n    background-color: #3CA4DB;\n}\n\n.toggle-on.dropdown-toggle:after {\n    left: 24px;\n}\n\n/* TRANSACTIONS */\n\n#transactionsContainer {\n    position: relative;\n    width: 100%;\n    flex-grow: 1;\n    overflow-x: hidden;\n    overflow-y: scroll;\n    -webkit-overflow-scrolling: touch;\n}\n\n#transactionsList {\n    padding-left: 20px;\n    padding-right: 20px;\n    padding-top: 10px;\n}\n\n.date-separator {\n    font-weight: 700;\n    padding-top: 10px;\n    padding-bottom: 10px;\n    font-size: 14px;\n    width: 100%;\n    max-width: 480px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n.tx-item {\n    position: relative;\n    padding-bottom: 10px;\n    margin-bottom: 10px;\n    border-bottom: 1px solid #E7E7E7;\n    cursor: pointer;\n    width: 100%;\n    max-width: 480px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n.tx-item-encrypted-icon {\n    position: absolute;\n    right: 0px;\n    top: 30px;\n    width: 32px;\n    height: 32px;\n    background-image: url(\"../assets/ui/encrypted-message.png\");\n    background-size: contain;\n    background-repeat: no-repeat;\n}\n\n.tx-amount {\n    font-weight: 700;\n    font-size: 16px;\n    color: #D74D4D;\n}\n\n.tx-amount-green {\n    color: #39B139;\n}\n\n.tx-from {\n    font-size: 13px;\n}\n\n.tx-addr {\n    font-family: monospace;\n    font-size: 15px;\n    margin-top: 4px;\n    margin-bottom: 4px;\n    word-break: keep-all;\n}\n\n.tx-comment {\n    color: #000;\n    font-size: 13px;\n    margin-top: 8px;\n    margin-bottom: 8px;\n}\n\n.tx-fee {\n    color: #999999;\n    font-size: 13px;\n}\n\n.tx-item-date {\n    position: absolute;\n    top: 0;\n    right: 0;\n    color: #999999;\n    font-size: 13px;\n    line-height: 26px;\n}\n\n/* POPUP */\n\n#modal {\n    position: fixed;\n    left: 0;\n    top: 0;\n    width: 100%;\n    height: 100%;\n    background-color: rgba(0, 0, 0, 0.2);\n}\n\n.popup {\n    position: absolute;\n    left: 50%;\n    top: 50%;\n    transform: translate(-50%, -50%);\n    box-shadow: 0px 8px 24px rgba(0, 0, 0, .25);\n\n    width: 320px;\n    background-color: white;\n    border-radius: 4px;\n    padding: 20px;\n    font-size: 14px;\n}\n\n.popup#alert {\n    position: fixed;\n}\n\n.popup.faded-show,\n#menuDropdown.faded-show,\n#modal.faded-show {\n    opacity: 1;\n    visibility: inherit !important;\n    transition: 0.15s opacity, 0.15s visibility step-start;\n}\n\n.popup.faded-hide,\n#menuDropdown.faded-hide,\n#modal.faded-hide {\n    opacity: 0;\n    visibility: hidden;\n    transition: 0.15s opacity, 0.15s visibility step-end;\n}\n\n.popup-title {\n    font-weight: 700;\n    margin-bottom: 20px;\n    font-size: 17px;\n}\n\n.popup-text {\n    font-size: 14px;\n    line-height: 18px;\n}\n\n.popup-black-text {\n    font-size: 14px;\n    line-height: 18px;\n}\n\n.about-magic {\n    display: none;\n    text-align: left;\n}\n\n.plugin .about-magic {\n    display: block;\n}\n\n.about-magic h4 {\n    margin-bottom: 12px;\n}\n\n.about-magic p {\n    margin-top: 12px;\n}\n\n.popup-grey-text {\n    line-height: 18px;\n    color: #999999;\n    font-size: 14px;\n    margin-bottom: 20px\n}\n\n.popup-close-btn {\n    position: absolute;\n    top: 10px;\n    right: 10px;\n    width: 32px;\n    height: 32px;\n    background-position: center;\n    background-repeat: no-repeat;\n    background-size: 40%;\n    border: none;\n    background-color: transparent;\n    background-image: url(\"../assets/ui/close.svg\");\n}\n\n.popup-footer {\n    text-align: right;\n    margin-top: 10px;\n}\n\n.popup .btn-blue {\n    width: 100%;\n}\n\n.popup tgs-player {\n    display: block;\n    width: 150px;\n    height: 150px;\n    margin-left: auto;\n    margin-right: auto\n}\n\n.popup input {\n    margin-top: 6px;\n    margin-bottom: 6px;\n    height: 36px;\n}\n\n/* RECEIVE POPUP */\n\n.qr-container {\n    text-align: center;\n    margin: 20px 0px 20px 0px;\n}\n\n#qr, #invoiceQrImg {\n    width: 185px;\n    height: 185px;\n    margin-left: auto;\n    margin-right: auto;\n}\n\n#qr img, #invoiceQrImg img, #invoiceQrImg canvas {\n    width: 185px;\n    height: 185px;\n}\n\n#receive .my-addr {\n    font-family: monospace;\n    text-align: center;\n    font-size: 18px;\n    margin-top: -4px;\n    max-width: 280px;\n    height: 42px;\n    cursor: pointer;\n}\n\n#receive .btn-lite {\n    text-align: center;\n    width: 100%;\n    font-weight: 400;\n}\n\n#receive .btn-lite-first {\n    margin-top: 20px;\n}\n\n#receive .btn-blue {\n    margin-top: 10px;\n}\n\n/* SEND POPUP */\n\n#send .btn-blue {\n    margin-top: 20px;\n}\n\n#sendBalance {\n    position: absolute;\n    right: 0;\n    top: 0;\n    color: #999999;\n    font-size: 14px;\n}\n\n\n#sendConfirm .addr, #signConfirm .addr {\n    font-family: monospace;\n    text-align: center;\n    font-size: 18px;\n    margin-top: 10px;\n    margin-bottom: 10px;\n    max-width: 280px;\n    padding: 10px;\n    background-color: #F1F1F1;\n}\n\n#encryptCommentCheckboxContainer {\n    display: flex;\n    flex-direction: row;\n    align-items: center;\n    margin-top: 12px;\n}\n\n#encryptCommentCheckbox {\n}\n\n/* INVOICE POPUP */\n\n#invoice .popup-black-text {\n    margin-top: 10px;\n    margin-bottom: 10px;\n    word-break: break-all;\n}\n\n#invoice .btn-lite {\n    text-align: center;\n    width: 100%;\n    font-weight: 400;\n}\n\n#invoice .btn-blue {\n    margin-top: 10px;\n}\n\n#invoiceQr .btn-blue {\n    margin-top: 20px;\n}\n\n#invoice_link {\n    user-select: text;\n    -webkit-user-select: text;\n    -moz-user-select: text;\n    cursor: text;\n}\n\n/* TRANSACTION POPUP */\n\n#transactionSender {\n    font-family: monospace;\n    max-width: 280px;\n    font-size: 18px;\n    margin-top: 4px;\n    margin-bottom: 4px;\n}\n\n#transactionComment {\n    word-break: break-all;\n}\n\n#transactionDecryptCommentButton {\n    margin-top: 10px;\n    margin-bottom: 10px;\n    font-weight: normal;\n    height: auto;\n    cursor: pointer;\n}\n\n#transactionAmount {\n    font-size: 28px;\n    text-align: center;\n    margin-bottom: 8px;\n}\n\n#transactionFee {\n    color: #999;\n    text-align: center;\n}\n\n#transaction .input-label {\n    margin-top: 20px;\n    margin-bottom: 10px;\n}\n\n/* EXTENSION */\n\n#menu_magic {\n    display: none;\n}\n\n#menu_proxy {\n    display: none;\n    pointer-events: none;\n}\n\n#menu_telegram {\n    display: none;\n}\n\n.plugin .menu_telegram-show {\n    display: block !important;\n}\n\n#menu_proxy:after {\n    position: absolute;\n    top: 4px;\n    line-height: 8px;\n    right: 70px;\n    width: 14px;\n    height: 8px;\n    font-size: 10px;\n    color: #1d98dc;\n    border-radius: 4px;\n    padding: 4px;\n    content: 'Soon';\n}\n\n.plugin #menu_magic {\n    display: block;\n}\n\n.plugin #menu_proxy {\n    display: block;\n}\n\n\n.plugin #menu_extension_chrome {\n    display: none;\n}\n\n#menu_extension_firefox {\n    display: none;\n}\n\n.plugin #start_importLedgerHidBtn {\n    display: none;\n}\n\n#start_importLedgerHidBtn {\n    display: none;\n}\n\n.input-password {\n    text-align: center;\n    width: 200px;\n    margin-left: 40px;\n    font-size: 15px;\n}\n\n.display-none {\n    display: none;\n}\n\n.visibility-hidden {\n    visibility: hidden;\n}\n\n.rotate-180 {\n    transform: rotate(180deg);\n}\n\n.position-relative {\n    position: relative;\n}\n\n.clear-both {\n    clear: both;\n}\n\n.font-weight-normal {\n    font-weight: 400;\n}\n\n.font-weight-bold {\n    font-weight: 700;\n}\n\n.text-danger {\n    color: #D74D4D;\n}\n\n.line-height-24 {\n    line-height: 24px;\n}\n\n.text-align-center {\n    text-align: center;\n}\n\n.bg-down-left {\n    background-image: url('../assets/ui/down-left.svg')\n}\n\n.bg-menu {\n    background-image: url('../assets/ui/menu.svg')\n}\n\n.bg-refresh {\n    background-image: url('../assets/ui/refresh.svg')\n}\n\n.w-100 {\n    width: 100%;\n}\n\n.mb-10 {\n    margin-bottom: 10px;\n}\n\n.mb-18 {\n    margin-bottom: 18px;\n}\n\n.mb-20 {\n    margin-bottom: 20px;\n}\n\n.mt-10 {\n    margin-top: 10px;\n}\n\n.mt-18 {\n    margin-top: 18px;\n}\n\n.mt-20 {\n    margin-top: 20px;\n}\n\n.mt-24 {\n    margin-top: 24px;\n}\n\n.mt-26 {\n    margin-top: 26px;\n}\n\n.mt-30 {\n    margin-top: 30px;\n}\n\n.mt-38 {\n    margin-top: 38px;\n}\n\n.mt-54 {\n    margin-top: 54px;\n}\n\n.mt-80 {\n    margin-top: 95px;\n}\n\n.mt-95 {\n    margin-top: 95px;\n}\n\n.mt-170 {\n    margin-top: 170px;\n}\n\n.pb-10 {\n    padding-bottom: 10px;\n}\n\n/* checkbox */\n\n.checkbox-container {\n    display: block;\n    position: relative;\n    padding-left: 24px;\n    line-height: 18px;\n    cursor: pointer;\n\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n}\n\n.checkbox-container input {\n    position: absolute;\n    opacity: 0;\n    cursor: pointer;\n    height: 0;\n    width: 0;\n}\n\n.checkmark {\n    position: absolute;\n    top: 0;\n    left: 0;\n    height: 18px;\n    width: 18px;\n    background-color: #eee;\n}\n\n.checkbox-container input:checked ~ .checkmark {\n    background-color: #3CA4DB;\n}\n\n.checkmark:after {\n    content: \"\";\n    position: absolute;\n    display: none;\n}\n\n.checkbox-container input:checked ~ .checkmark:after {\n    display: block;\n}\n\n.checkbox-container .checkmark:after {\n    left: 6px;\n    top: 2px;\n    width: 4px;\n    height: 8px;\n    border: solid white;\n    border-width: 0 3px 3px 0;\n    -webkit-transform: rotate(45deg);\n    -ms-transform: rotate(45deg);\n    transform: rotate(45deg);\n}"
  },
  {
    "path": "src/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\" translate=\"no\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta http-equiv=\"Content-Security-Policy\"\n          content=\"default-src 'none'; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self' data: https://nft.ton.diamonds/; manifest-src 'self'; connect-src 'self' https://toncenter.com/api/ https://testnet.toncenter.com/api/ https://stage.toncenter.com/api/ https://stage-testnet.toncenter.com/api/ https://ton.diamonds/api/wallet/diamond_nfts\">\n    <meta name=\"viewport\"\n          content=\"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover\">\n\n    <title>TON Wallet</title>\n\n    <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n    <meta name=\"format-detection\" content=\"telephone=no\">\n    <meta name=\"google\" content=\"notranslate\">\n\n    <meta name=\"description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta name=\"image\" content=\"assets/favicon/512x512.png\">\n\n    <meta itemprop=\"name\" content=\"TON Wallet\">\n    <meta itemprop=\"description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta itemprop=\"image\" content=\"assets/favicon/512x512.png\">\n    <meta name=\"twitter:card\" content=\"summary\">\n    <meta name=\"twitter:title\" content=\"TON Wallet\">\n    <meta name=\"twitter:description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta name=\"og:title\" content=\"TON Wallet\">\n    <meta name=\"og:description\" content=\"Set up your own TON Wallet on The Open Network\">\n    <meta name=\"og:type\" content=\"website\">\n\n    <link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"assets/favicon/apple-touch-icon.png\">\n    <link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"assets/favicon/favicon-32x32.png\">\n    <link rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"assets/favicon/192x192.png\">\n    <link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"assets/favicon/favicon-16x16.png\">\n    <link rel=\"manifest\" href=\"assets/favicon/site.webmanifest\">\n    <link rel=\"mask-icon\" href=\"assets/favicon/safari-pinned-tab.svg\" color=\"#0088cc\">\n    <link rel=\"shortcut icon\" href=\"assets/favicon/favicon.ico\">\n    <meta name=\"apple-mobile-web-app-title\" content=\"TON Wallet\">\n    <meta name=\"application-name\" content=\"TON Wallet\">\n    <meta name=\"msapplication-TileColor\" content=\"#ffffff\">\n    <meta name=\"msapplication-TileImage\" content=\"assets/favicon/mstile-144x144.png\">\n    <meta name=\"msapplication-config\" content=\"assets/favicon/browserconfig.xml\">\n    <meta name=\"theme-color\" content=\"#ffffff\">\n\n    <link rel=\"stylesheet\" href=\"main.css?v={{VERSION}}\">\n</head>\n<body>\n\n<div class=\"body-container\">\n\n    <!-- Start Screen -->\n\n    <div id=\"start\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"start\" src=\"assets/lottie/intro.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">TON Wallet</div>\n                <div class=\"screen-text\">\n                    TON wallet allows you to make fast and<br>\n                    secure blockchain-based payments<br>\n                    without intermediaries.\n                </div>\n\n                <div class=\"mt-95\">\n                    <button id=\"start_createBtn\" class=\"btn-blue screen-btn\">Create My Wallet</button>\n                </div>\n                <div class=\"mt-20\">\n                    <button id=\"start_importBtn\" class=\"btn-lite font-weight-normal\">Import existing wallet\n                    </button>\n                </div>\n                <div class=\"mt-10\">\n                    <button id=\"start_importLedgerHidBtn\" class=\"btn-lite font-weight-normal\">Connect Ledger\n                    </button>\n                </div>\n\n        <!--            <div class=\"mt-10\">-->\n        <!--                <button id=\"start_importLedgerBleBtn\" class=\"btn-lite font-weight-normal\">Connect Ledger via Bluetooth-->\n        <!--                </button>-->\n        <!--            </div>-->\n            </div>\n        </div>\n    </div>\n\n    <!-- Import Screen -->\n\n    <div id=\"import\" class=\"screen text-align-center visibility-hidden\">\n        <button id=\"import_backBtn\" class=\"btn-back\"></button>\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n\n                <div class=\"screen-title mt-80\">24 Secret Words</div>\n                <div class=\"screen-text mb-10\">\n                    Please restore access to your <b>non-hardware</b> wallet by<br>\n                    entering the 24 secret words you wrote<br>\n                    down when creating the wallet.\n                </div>\n\n                <button id=\"import_alertBtn\" class=\"btn-lite\">I don't have them</button>\n\n                <div id=\"importWords\">\n\n                </div>\n\n                <div id=\"wordsPopup\" class=\"display-none\">\n                </div>\n\n                <div class=\"clear-both\">\n                    <button id=\"import_continueBtn\" class=\"btn-blue screen-btn mt-30 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Created Screen -->\n\n    <div id=\"created\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"created\" src=\"assets/lottie/created.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Congratulations</div>\n\n                <div class=\"screen-text\">\n                    Your TON wallet has just been created.<br>\n                    Only you control it.\n                </div>\n\n                <div class=\"screen-text\">\n                    To be able to always have access to it,<br>\n                    please set up a secure password and write<br>\n                    down secret words.\n                </div>\n\n                <div>\n                    <button id=\"createdContinueButton\" class=\"btn-blue screen-btn mt-18 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Backup Screen -->\n\n    <div id=\"backup\" class=\"screen text-align-center visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"backup\" src=\"assets/lottie/paper.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie mt-30\">\n                </tgs-player>\n\n                <div class=\"screen-title\">24 secret words</div>\n\n                <div class=\"screen-text\">\n                    Write down these 24 words in the correct<br>\n                    order and store them in secret place.\n                </div>\n\n                <div class=\"screen-text\">\n                    Use these secret words to restore access to<br>\n                    your wallet if you lose your password or<br>\n                    access to this device.\n                </div>\n\n                <div id=\"createWords\" class=\"mt-10\">\n\n                </div>\n\n                <div class=\"clear-both\">\n                    <button id=\"backup_continueBtn\" class=\"btn-blue screen-btn mt-26 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Words Confirm Screen -->\n\n    <div id=\"wordsConfirm\" class=\"screen text-align-center visibility-hidden\">\n        <button id=\"wordsConfirm_backBtn\" class=\"btn-back\"></button>\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n\n                <tgs-player data-name=\"wordsConfirm\" src=\"assets/lottie/confirm.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie mt-30\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Test Time!</div>\n\n                <div class=\"screen-text\">\n                    Now let's check that you wrote your secret<br/>words correctly.<br/>\n                </div>\n\n                <div id=\"confirmWordsNums\" class=\"screen-text\">\n                    Please enter the words <span></span>, <span></span> and <span></span> below:\n                </div>\n\n                <div id=\"confirmWords\">\n                </div>\n\n                <div id=\"wordsConfirmPopup\" class=\"display-none\">\n                </div>\n\n                <div class=\"clear-both\">\n                    <button id=\"wordsConfirm_continueBtn\" class=\"btn-blue screen-btn mt-26 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Create Password Screen -->\n\n    <div id=\"createPassword\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"createPassword\" src=\"assets/lottie/lock.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Secure Password</div>\n\n                <div class=\"screen-text\">\n                    Please choose a secure password<br>\n                    for confirming your payments\n                </div>\n\n                <div class=\"mt-54\">\n                    <input id=\"createPassword_input\" placeholder=\"Enter your password\" type=\"password\">\n                </div>\n                <div>\n                    <input id=\"createPassword_repeatInput\" placeholder=\"Repeat your password\" type=\"password\">\n                </div>\n\n                <div>\n                    <button id=\"createPassword_continueBtn\" class=\"btn-blue screen-btn mt-38 mb-20\">\n                        Continue\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Ready To Go Screen -->\n\n    <div id=\"readyToGo\" class=\"screen visibility-hidden\">\n        <div class=\"middle\">\n            <div class=\"middle-content\">\n                <tgs-player data-name=\"readyToGo\" src=\"assets/lottie/done.tgs\"\n                            width=\"120\" height=\"120\"\n                            class=\"screen-lottie\">\n                </tgs-player>\n\n                <div class=\"screen-title\">Ready to go!</div>\n\n                <div class=\"screen-text\">\n                    You're all set. Now you have a wallet that<br>\n                    only you control - directly, without<br>\n                    middlemen or bankers.\n                </div>\n\n                <div>\n                    <button id=\"readyToGo_continueBtn\" class=\"btn-blue screen-btn mt-170 mb-20\">\n                        View My Wallet\n                    </button>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <!-- Main Screen -->\n\n    <div id=\"main\" class=\"screen visibility-hidden\">\n        <div class=\"head\">\n            <div class=\"head-row\">\n                <button id=\"main_refreshBtn\" class=\"btn-round bg-refresh\"></button>\n\n                <div id=\"updateLabel\"></div>\n\n                <button id=\"main_settingsButton\" class=\"btn-round bg-menu\"></button>\n            </div>\n\n            <div class=\"balance-container\">\n                <div id=\"balance\"></div>\n                <tgs-player data-name=\"symbol\" src=\"assets/lottie/diamond.tgs\"\n                            width=\"32\" height=\"32\"\n                            class=\"balance-symbol\">\n                </tgs-player>\n                <div class=\"balance-diamond-container\">\n                    <div id=\"diamond\"></div>\n                </div>\n            </div>\n            <div class=\"your-balance\">Your balance</div>\n\n<!--            <button id=\"main_buyBtn\" class=\"btn-blue\">-->\n<!--                <div class=\"btn-icon bg-down-left\"></div>-->\n<!--                Buy-->\n<!--            </button>-->\n\n            <button id=\"main_receiveBtn\" class=\"btn-blue\">\n                <div class=\"btn-icon bg-down-left\"></div>\n                Receive\n            </button>\n\n            <button id=\"sendButton\" class=\"btn-blue display-none\">\n                <div class=\"btn-icon bg-down-left rotate-180\"></div>\n                Send\n            </button>\n        </div>\n\n        <div id=\"transactionsContainer\">\n            <div id=\"transactionsList\">\n            </div>\n            <div id=\"walletCreated\" class=\"display-none\">\n                <tgs-player data-name=\"main\"\n                            width=\"150\" height=\"150\"\n                            src=\"assets/lottie/empty.tgs\">\n                </tgs-player>\n                <div>Wallet Created</div>\n            </div>\n        </div>\n\n    </div>\n\n    <!-- Modal -->\n\n    <div id=\"modal\" class=\"visibility-hidden\"></div>\n\n    <!-- Menu Dropdown -->\n\n    <div id=\"menuDropdown\" class=\"visibility-hidden\">\n        <div id=\"menu_extension_chrome\" class=\"dropdown-item\">Chrome Extension</div>\n        <div id=\"menu_extension_firefox\" class=\"dropdown-item\">Firefox Add-on</div>\n        <div id=\"menu_about\" class=\"dropdown-item\">About</div>\n        <div id=\"menu_magic\" class=\"dropdown-item\">TON Magic <div class=\"dropdown-toggle\"></div></div>\n        <div id=\"menu_telegram\" class=\"dropdown-item\">Open Telegram Web »</div>\n        <div id=\"menu_proxy\" class=\"dropdown-item\">TON Proxy <div class=\"dropdown-toggle\"></div></div>\n        <div id=\"menu_changePassword\" class=\"dropdown-item\">Change password</div>\n        <div id=\"menu_backupWallet\" class=\"dropdown-item\">Back up wallet</div>\n        <div id=\"menu_delete\" class=\"dropdown-item\">Log Out</div>\n    </div>\n\n    <!-- Alert Popup-->\n\n    <div id=\"alert\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\"></div>\n        <div class=\"popup-black-text\"></div>\n        <div class=\"popup-footer\"></div>\n    </div>\n\n    <!-- Receive Popup-->\n\n    <div id=\"receive\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Receive TON</div>\n        <div class=\"popup-text\">Share this address to receive TON.\n        </div>\n\n        <div class=\"qr-container\">\n            <div id=\"qr\"></div>\n        </div>\n\n        <div class=\"my-addr addr\"></div>\n\n        <button id=\"receive_showAddressOnDeviceBtn\" class=\"btn-lite btn-lite-first\">Show Address on Device</button>\n\n        <button id=\"receive_invoiceBtn\" class=\"btn-lite\">Create Invoice</button>\n\n        <button id=\"receive_shareBtn\" class=\"btn-blue\">Share Wallet Address</button>\n\n        <button id=\"receive_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Invoice Popup -->\n\n    <div id=\"invoice\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Create Invoice</div>\n\n        <div>\n            <div class=\"input-label\">Amount</div>\n        </div>\n\n        <input id=\"invoice_amountInput\" type=\"number\" placeholder=\"Amount in TON you expect to receive\">\n        <input id=\"invoice_commentInput\" type=\"text\" placeholder=\"Comment (optional)\">\n\n        <div class=\"popup-grey-text\">\n            You can specify the amount and purpose of<br>\n            the payment to save the sender some time.\n        </div>\n\n        <div class=\"input-label mt-24 mb-18\">Invoice URL</div>\n\n        <div id=\"invoice_link\" class=\"popup-black-text\">\n            ton://transfer/\n        </div>\n\n        <div class=\"popup-grey-text mt-24\">\n            Share this address to receive TON.\n        </div>\n\n        <button id=\"invoice_qrBtn\" class=\"btn-lite\">Generate QR Code</button>\n        <button id=\"invoice_shareBtn\" class=\"btn-blue\">Share Invoice URL</button>\n\n        <button id=\"invoice_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Invoice QR Popup-->\n\n    <div id=\"invoiceQr\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Invoice QR</div>\n\n        <div class=\"qr-container\">\n            <div id=\"invoiceQrImg\"></div>\n        </div>\n\n        <div class=\"input-label\">Expected Amount</div>\n\n        <div id=\"invoiceQrAmount\" class=\"popup-black-text\">\n            1\n        </div>\n\n        <button id=\"invoiceQr_shareBtn\" class=\"btn-blue\">Share QR Code</button>\n\n        <button id=\"invoiceQr_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Transaction Popup -->\n\n    <div id=\"transaction\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Transaction</div>\n\n        <div id=\"transactionAmount\">+0.1 TON</div>\n        <div id=\"transactionFee\">0.1 transaction fee</div>\n\n        <div id=\"transactionSenderLabel\" class=\"input-label mt-20\">Sender</div>\n\n        <div id=\"transactionSender\" class=\"addr\">\n\n        </div>\n\n        <div class=\"input-label\">Date</div>\n\n        <div id=\"transactionDate\" class=\"popup-black-text\">\n\n        </div>\n\n        <div id=\"transactionCommentLabel\" class=\"input-label\">Comment</div>\n\n        <div id=\"transactionComment\" class=\"popup-black-text\"></div>\n\n        <div id=\"transactionDecryptCommentButton\" class=\"btn-lite\">Enter password to view comment</div>\n\n        <button id=\"transaction_sendBtn\" class=\"btn-blue mt-20\">Send TON to this address</button>\n\n        <button id=\"transaction_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Send Popup -->\n\n    <div id=\"send\" class=\"popup visibility-hidden\">\n        <div class=\"popup-title\">Send TON</div>\n\n        <div class=\"input-label\">Recipient wallet address</div>\n        <input id=\"toWalletInput\" type=\"text\" placeholder=\"Enter wallet address\">\n\n        <div class=\"popup-grey-text\">\n            Copy the 48-letter wallet address of the\n            recipient here or ask them to send you a\n            ton:// link\n        </div>\n\n        <div class=\"position-relative w-100\">\n            <div class=\"input-label\">Amount</div>\n            <div id=\"sendBalance\">Balance:</div>\n        </div>\n\n        <input id=\"amountInput\" type=\"number\" placeholder=\"0.0\">\n        <input id=\"commentInput\" type=\"text\" placeholder=\"Comment (optional)\">\n\n        <label id=\"encryptCommentCheckboxContainer\" class=\"checkbox-container\"> Encrypt Comment\n            <input type=\"checkbox\" id=\"encryptCommentCheckbox\">\n            <span class=\"checkmark\"></span>\n        </label>\n\n        <button id=\"send_btn\" class=\"btn-blue\">Send TON</button>\n\n        <button id=\"send_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Send Confirm Popup -->\n\n    <div id=\"sendConfirm\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Confirmation</div>\n        <div class=\"popup-black-text\">Do you want to send <b id=\"sendConfirmAmount\">x TON</b> to:</div>\n\n        <div id=\"sendConfirmAddr\" class=\"addr\"></div>\n\n        <div id=\"sendConfirmFee\" class=\"popup-grey-text text-align-center\">Fee: ~x TON</div>\n\n        <div id=\"sendConfirmNotEncryptedNote\" class=\"popup-grey-text text-align-center\">Note: Your comment will <b>not</b> be encrypted</div>\n\n        <button id=\"sendConfirm_closeBtn\" class=\"popup-close-btn\"></button>\n\n        <div class=\"popup-footer\">\n            <button id=\"sendConfirm_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"sendConfirm_okBtn\" class=\"btn-lite\">SEND TON</button>\n        </div>\n    </div>\n\n    <!-- Sign Confirm Popup -->\n\n    <div id=\"signConfirm\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Confirmation</div>\n        <div id=\"signConfirmText\" class=\"popup-black-text\">Do you want to sign:</div>\n\n        <div id=\"signConfirmData\" class=\"addr\"></div>\n\n        <div id=\"signConfirmAlert\" class=\"popup-grey-text text-align-center font-weight-bold text-danger\">Signing custom data is very dangerous. Use only if you know what you are doing.</div>\n\n        <button id=\"signConfirm_closeBtn\" class=\"popup-close-btn\"></button>\n\n        <div class=\"popup-footer\">\n            <button id=\"signConfirm_cancelBtn\" class=\"btn-lite\">NO</button>\n            <button id=\"signConfirm_okBtn\" class=\"btn-lite\">YES</button>\n        </div>\n    </div>\n\n    <!-- Connect Confirm Popup -->\n\n    <div id=\"connectConfirm\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Confirmation</div>\n        <div class=\"popup-black-text\">Do you want to connect your wallet to this page?</div>\n\n        <button id=\"connectConfirm_closeBtn\" class=\"popup-close-btn\"></button>\n\n        <div class=\"popup-footer\">\n            <button id=\"connectConfirm_cancelBtn\" class=\"btn-lite\">NO</button>\n            <button id=\"connectConfirm_okBtn\" class=\"btn-lite\">YES</button>\n        </div>\n    </div>\n\n    <!-- Processing Popup -->\n\n    <div id=\"processing\" class=\"popup text-align-center visibility-hidden\">\n        <tgs-player data-name=\"processing\" src=\"assets/lottie/money.tgs\" width=\"150\" height=\"150\"></tgs-player>\n        <div class=\"popup-title\">Sending TON</div>\n        <div class=\"popup-grey-text\">Please wait a few seconds for your<br>transaction to be processed..</div>\n\n        <button id=\"processing_closeBtn\" class=\"popup-close-btn\"></button>\n    </div>\n\n    <!-- Done Popup -->\n\n    <div id=\"done\" class=\"popup text-align-center pb-10 visibility-hidden\">\n        <tgs-player data-name=\"done\" src=\"assets/lottie/done.tgs\" width=\"150\" height=\"150\"></tgs-player>\n        <div class=\"popup-title\">Done!</div>\n        <div class=\"popup-grey-text\">1 TON have been send</div>\n\n        <div class=\"popup-footer\">\n            <button id=\"done_closeBtn\" class=\"btn-lite\">CLOSE</button>\n        </div>\n    </div>\n\n    <!-- About Popup -->\n\n    <div id=\"about\" class=\"popup text-align-center pb-10 visibility-hidden\">\n        <div class=\"popup-title\">TON Wallet</div>\n        <div id=\"about_version\" class=\"popup-grey-text\">\n            Version: {{VERSION}}\n        </div>\n        <tgs-player data-name=\"about\" src=\"assets/lottie/intro.tgs\" width=\"150\" height=\"150\"></tgs-player>\n\n        <div class=\"popup-grey-text line-height-24\">\n            API provider: <a href=\"https://toncenter.com\" target=\"_blank\">toncenter.com</a><br>\n            <a href=\"https://github.com/toncenter/ton-wallet\" target=\"_blank\">GitHub</a>,\n            <a href=\"https://github.com/toncenter/ton-wallet/issues\" target=\"_blank\">Issue Tracker</a>\n        </div>\n\n        <div class=\"popup-black-text about-magic\">\n            <h4>What is TON Magic?</h4>\n            <p>\n                TON Magic provides native <b>Telegram integration</b> by patching the official Telegram web app (Z version).\n            </p>\n            <p>\n                Turn it on to send and receive Toncoins from any Telegram user. <a href=\"https://telegra.ph/Telegram--TON-11-10\" id=\"about-magic-video\" target=\"_blank\">More info and demo</a>.\n            </p>\n        </div>\n\n        <div class=\"popup-footer\">\n            <button id=\"about_closeBtn\" class=\"btn-lite\">CLOSE</button>\n        </div>\n    </div>\n\n    <!-- Change Password Popup -->\n\n    <div id=\"changePassword\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Change Password</div>\n\n        <tgs-player data-name=\"changePassword\" src=\"assets/lottie/lock.tgs\" width=\"150\" height=\"150\"></tgs-player>\n\n        <input id=\"changePassword_oldInput\" placeholder=\"Enter your old password\" type=\"password\"\n               class=\"input-password\">\n        <input id=\"changePassword_newInput\" placeholder=\"Enter a new password\" type=\"password\"\n               class=\"input-password mt-20\">\n        <input id=\"changePassword_repeatInput\" placeholder=\"Repeat the new password\" type=\"password\"\n               class=\"input-password\">\n\n        <div class=\"popup-footer\">\n            <button id=\"changePassword_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"changePassword_okBtn\" class=\"btn-lite\">SAVE</button>\n        </div>\n    </div>\n\n    <!-- Enter Password Popup -->\n\n    <div id=\"enterPassword\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Password</div>\n\n        <tgs-player data-name=\"enterPassword\" src=\"assets/lottie/lock.tgs\" width=\"150\" height=\"150\"></tgs-player>\n        <input id=\"enterPassword_input\" placeholder=\"Enter your password\" type=\"password\"\n               class=\"input-password\">\n\n        <div class=\"popup-footer\">\n            <button id=\"enterPassword_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"enterPassword_okBtn\" class=\"btn-lite\">NEXT</button>\n        </div>\n    </div>\n\n    <!-- Log Out Popup -->\n\n    <div id=\"delete\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Log Out</div>\n        <div class=\"popup-black-text\">\n            This will disconnect the wallet from this<br>\n            app. You will be able to restore your<br>\n            wallet using <b>24 secret words</b> - or import<br>\n            another wallet.\n        </div>\n        <div class=\"popup-black-text mt-20\">\n            Wallets are located in the decentralized<br>\n            TON Blockchain. If you want the wallet to<br>\n            be deleted simply transfer all the TON<br>\n            from it and leave it empty.\n        </div>\n\n        <div class=\"popup-footer\">\n            <button id=\"delete_cancelBtn\" class=\"btn-lite\">CANCEL</button>\n            <button id=\"delete_okBtn\" class=\"btn-lite btn-lite-red\">DISCONNECT</button>\n        </div>\n    </div>\n\n    <!-- Connect Ledger Popup -->\n\n    <div id=\"connectLedger\" class=\"popup pb-10 visibility-hidden\">\n        <div class=\"popup-title\">Connect Ledger</div>\n        <div class=\"popup-black-text\">\n            Please use Edge/Google Chrome v89 or later.\n        </div>\n        <div class=\"popup-black-text mt-20\">\n            Turn off Ledger Live.\n        </div>\n        <div class=\"popup-black-text mt-20\">\n            If it does not connect, then try reconnecting the device.\n        </div>\n\n        <div class=\"popup-footer\">\n            <button id=\"connectLedger_cancelBtn\" class=\"btn-lite\">OK</button>\n        </div>\n    </div>\n\n    <!-- Notify-->\n\n    <div id=\"notify\" class=\"visibility-hidden\"></div>\n\n    <!-- Loader Popup -->\n\n    <div id=\"loader\" class=\"popup text-align-center pb-10 visibility-hidden\">\n        <tgs-player data-name=\"loader\" src=\"assets/lottie/intro.tgs\" width=\"150\" height=\"150\"></tgs-player>\n    </div>\n</div>\n\n<!-- Scripts -->\n\n<script type=\"text/javascript\" src=\"libs/pako.min.js?v={{VERSION}}\"></script>\n<script type=\"text/javascript\" src=\"libs/lottie.min.js?v={{VERSION}}\"></script>\n<script type=\"text/javascript\" src=\"libs/easy.qrcode.min.js?v={{VERSION}}\"></script>\n\n<script type=\"text/javascript\" src=\"libs/aes-js-3.1.2.js\"></script>\n<script type=\"text/javascript\" src=\"libs/noble-ed25519-1.7.3.js\"></script>\n\n<script type=\"text/javascript\" src=\"libs/tonweb.min.js?v={{VERSION}}\"></script>\n<script type=\"text/javascript\" src=\"libs/tonweb-mnemonic.min.js?v={{VERSION}}\"></script>\n\n<script src=\"js/View.js?v={{VERSION}}\" type=\"module\"></script>\n<script src=\"js/Controller.js?v={{VERSION}}\" type=\"module\"></script>\n\n</body>\n</html>\n"
  },
  {
    "path": "src/js/Controller.js",
    "content": "import storage from './util/storage.js';\nimport {decryptMessageComment, encryptMessageComment, makeSnakeCells, parseSnakeCells} from \"./util/encryption.js\";\n\nconst TONCONNECT_MAINNET = '-239';\nconst TONCONNECT_TESTNET = '-3';\n\nlet extensionWindowId = -1;\nlet contentScriptPorts = new Set();\nlet popupPort = null;\nconst queueToPopup = [];\n\n/**\n * @type {Promise<void> | null}\n */\nlet dAppPromise = null;\n\nconst createDappPromise = () => {\n    if (dAppPromise) dAppPromise.resolve(false);\n\n    let resolve;\n    let reject;\n\n    dAppPromise = new Promise((localResolve, localReject) => {\n        resolve = localResolve;\n        reject = localReject;\n    });\n\n    dAppPromise.resolve = (...args) => {\n        resolve(...args);\n        dAppPromise = null;\n    };\n    dAppPromise.reject = (...args) => {\n        reject(...args);\n        dAppPromise = null;\n    };\n};\n\nconst showExtensionWindow = () => {\n    return new Promise(async resolve => {\n        if (extensionWindowId > -1) {\n            chrome.windows.update(extensionWindowId, {focused: true});\n            return resolve();\n        }\n\n        const windowState = (await storage.getItem('windowState')) || {};\n\n        windowState.top = windowState.top || 0;\n        windowState.left = windowState.left || 0;\n        windowState.height = windowState.height || 800;\n        windowState.width = windowState.width || 480;\n\n        chrome.windows.create(Object.assign(windowState, {\n            url: 'index.html',\n            type: 'popup',\n            focused: true\n        }), window => {\n            extensionWindowId = window.id;\n            resolve();\n        });\n    });\n};\n\nconst BN = TonWeb.utils.BN;\nconst nacl = TonWeb.utils.nacl;\nconst Address = TonWeb.utils.Address;\nconst formatNanograms = TonWeb.utils.fromNano;\n\n// ENCRYPTION\n\n/**\n * @param plaintext {string}\n * @param password {string}\n * @return {Promise<string>}\n */\nasync function encrypt(plaintext, password) {\n    const pwUtf8 = new TextEncoder().encode(password);                                 // encode password as UTF-8\n    const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8);                      // hash the password\n\n    const iv = crypto.getRandomValues(new Uint8Array(12));                             // get 96-bit random iv\n\n    const alg = {name: 'AES-GCM', iv: iv};                                           // specify algorithm to use\n\n    const key = await crypto.subtle.importKey('raw', pwHash, alg, false, ['encrypt']); // generate key from pw\n\n    const ptUint8 = new TextEncoder().encode(plaintext);                               // encode plaintext as UTF-8\n    const ctBuffer = await crypto.subtle.encrypt(alg, key, ptUint8);                   // encrypt plaintext using key\n\n    const ctArray = Array.from(new Uint8Array(ctBuffer));                              // ciphertext as byte array\n    const ctStr = ctArray.map(byte => String.fromCharCode(byte)).join('');             // ciphertext as string\n    const ctBase64 = btoa(ctStr);                                                      // encode ciphertext as base64\n\n    const ivHex = Array.from(iv).map(b => ('00' + b.toString(16)).slice(-2)).join(''); // iv as hex string\n\n    return ivHex + ctBase64;                                                             // return iv+ciphertext\n}\n\n/**\n * @param ciphertext {string}\n * @param password {string}\n * @return {Promise<string>}\n */\nasync function decrypt(ciphertext, password) {\n    const pwUtf8 = new TextEncoder().encode(password);                                  // encode password as UTF-8\n    const pwHash = await crypto.subtle.digest('SHA-256', pwUtf8);                       // hash the password\n\n    const iv = ciphertext.slice(0, 24).match(/.{2}/g).map(byte => parseInt(byte, 16));   // get iv from ciphertext\n\n    const alg = {name: 'AES-GCM', iv: new Uint8Array(iv)};                            // specify algorithm to use\n\n    const key = await crypto.subtle.importKey('raw', pwHash, alg, false, ['decrypt']);  // use pw to generate key\n\n    const ctStr = atob(ciphertext.slice(24));                                           // decode base64 ciphertext\n    const ctUint8 = new Uint8Array(ctStr.match(/[\\s\\S]/g).map(ch => ch.charCodeAt(0))); // ciphertext as Uint8Array\n    // note: why doesn't ctUint8 = new TextEncoder().encode(ctStr) work?\n\n    const plainBuffer = await crypto.subtle.decrypt(alg, key, ctUint8);                 // decrypt ciphertext using key\n    const plaintext = new TextDecoder().decode(plainBuffer);                            // decode password from UTF-8\n\n    return plaintext;                                                                   // return the plaintext\n}\n\n// CONTROLLER\n\nconst IS_EXTENSION = !!(self.chrome && chrome.runtime && chrome.runtime.onConnect);\n\nconst ACCOUNT_NUMBER = 0;\n\nconst DEFAULT_WALLET_VERSION = 'v3R2';\nconst DEFAULT_LEDGER_WALLET_VERSION = 'v3R1';\n\nclass Controller {\n    constructor() {\n        /** @type {boolean} */\n        this.isTestnet = false;\n        /** @type {boolean} */\n        this.isDebug = false;\n        /** @type {string} */\n        this.myAddress = null;\n        /** @type {string} */\n        this.publicKeyHex = null;\n        /** @type {string[]} */\n        this.myMnemonicWords = null;\n        /** @type   {BN | null} */\n        this.balance = null;\n        /** @type {WalletContract} */\n        this.walletContract = null;\n        this.transactions = [];\n        /** @type {number} */\n        this.updateIntervalId = 0;\n\n        /** @type {null | {totalAmount: BN, bodyHashBase64: string }} */\n        this.sendingData = null;\n\n        /** @type {boolean} */\n        this.processingVisible = false;\n\n        this.ledgerApp = null;\n        /** @type {boolean} */\n        this.isLedger = false;\n\n        /** @type {(words: string[]) => Promise<void> | null} */\n        this.afterEnterPassword = null;\n\n        if (self.view) {\n            self.view.controller = this;\n        }\n\n        this.pendingMessageResolvers = new Map();\n        this._lastMsgId = 1;\n\n        if (IS_EXTENSION) {\n            setInterval(() => storage.setItem('__time', Date.now()), 5 * 1000);\n        }\n\n        this.whenReady = this._init();\n    }\n\n    debug(...args) {\n        if (!this.isDebug) return;\n        console.log(...args);\n    }\n\n    /**\n     * @param words {string[]}\n     * @return {Promise<string>} base64\n     */\n    static async wordsToPrivateKey(words) {\n        const keyPair = await TonWeb.mnemonic.mnemonicToKeyPair(words);\n        return TonWeb.utils.bytesToBase64(keyPair.secretKey.slice(0, 32));\n    }\n\n    /**\n     * @param words {string[]}\n     * @param password  {string}\n     * @return {Promise<void>}\n     */\n    static async saveWords(words, password) {\n        await storage.setItem('words', await encrypt(words.join(','), password));\n    }\n\n    /**\n     * @param password  {string}\n     * @return {Promise<string[]>}\n     */\n    static async loadWords(password) {\n        return (await decrypt(await storage.getItem('words'), password)).split(',');\n    }\n\n    /**\n     * @param isTestnet {boolean}\n     * @return {string}\n     */\n    getApiKey(isTestnet) {\n        const webApiKey = isTestnet\n            ? TONCENTER_API_KEY_WEB_TEST\n            : TONCENTER_API_KEY_WEB_MAIN;\n        const extensionApiKey = isTestnet\n            ? TONCENTER_API_KEY_EXT_TEST\n            : TONCENTER_API_KEY_EXT_MAIN;\n        return IS_EXTENSION ? extensionApiKey : webApiKey;\n    }\n\n    async _init() {\n        return new Promise(async (resolve) => {\n            await storage.removeItem('pwdHash');\n\n            this.isTestnet = IS_EXTENSION ? (await storage.getItem('isTestnet')) : (self.location.href.indexOf('testnet') > -1);\n            this.isDebug = IS_EXTENSION ? (await storage.getItem('isDebug')) : (self.location.href.indexOf('debug') > -1);\n\n            const mainnetRpc = 'https://toncenter.com/api/v2/jsonRPC';\n            const testnetRpc = 'https://testnet.toncenter.com/api/v2/jsonRPC';\n\n            if (IS_EXTENSION && !(await storage.getItem('address'))) {\n                await this._restoreDeprecatedStorage();\n            }\n\n            this.ton = new TonWeb(new TonWeb.HttpProvider(this.isTestnet ? testnetRpc : mainnetRpc, {apiKey: this.getApiKey(this.isTestnet)}));\n            this.myAddress = await storage.getItem('address');\n            if (this.myAddress) {\n                this.myAddress = new TonWeb.utils.Address(this.myAddress).toString(true, true, false, this.isTestnet);\n            }\n            this.publicKeyHex = await storage.getItem('publicKey');\n\n            if (!this.myAddress || !(await storage.getItem('words'))) {\n                await storage.clear();\n                this.sendToView('showScreen', {name: 'start', noAnimation: true});\n            } else {\n                if ((await storage.getItem('isLedger')) === 'true') {\n                    this.isLedger = true;\n                    this.sendToView('setIsLedger', this.isLedger);\n                }\n\n                await this.showMain();\n            }\n            this.sendToView('setIsTestnet', this.isTestnet);\n\n            resolve();\n        });\n    }\n\n    async _restoreDeprecatedStorage() {\n        const {\n            address, words, walletVersion, magic, proxy,\n        } = await this.sendToView('restoreDeprecatedStorage', undefined, true, true);\n\n        if (!address || !words) {\n            return;\n        }\n\n        await Promise.all([\n            storage.setItem('address', address),\n            storage.setItem('words', words),\n            storage.setItem('walletVersion', walletVersion),\n            storage.setItem('magic', magic),\n            storage.setItem('proxy', proxy),\n        ]);\n    }\n\n    async toggleTestnet() {\n        this.isTestnet = !this.isTestnet;\n        if (this.isTestnet) {\n            await storage.setItem('isTestnet', 'true');\n        } else {\n            await storage.removeItem('isTestnet');\n        }\n        this.clearVars();\n        await this._init();\n        await this.sendToView('setIsTestnet', this.isTestnet);\n    }\n\n    async toggleDebug() {\n        this.isDebug = !this.isDebug;\n        if (this.isDebug) {\n            await storage.setItem('isDebug', 'true');\n        } else {\n            await storage.removeItem('isDebug');\n        }\n    }\n\n    // INDEXED API\n\n    /**\n     * @private\n     * @param method   {string}\n     * @param params   {any}\n     * @return {Promise<any>}\n     */\n    async sendToIndex(method, params) {\n        const mainnetRpc = 'https://toncenter.com/api/v3/';\n        const testnetRpc = 'https://testnet.toncenter.com/api/v3/';\n        const rpc = this.isTestnet ? testnetRpc : mainnetRpc;\n\n        const headers = {\n            'Content-Type': 'application/json',\n            'X-API-Key': this.getApiKey(this.isTestnet)\n        };\n\n        const response = await fetch(rpc + method + '?' + new URLSearchParams(params), {\n            method: 'GET',\n            headers: headers,\n        });\n        return await response.json();\n    }\n\n    /**\n     * @private\n     * @param address   {string}\n     * @return {Promise<{seqno: number | null}>}\n     */\n    async getWalletInfoFromIndex(address) {\n        return this.sendToIndex('wallet', {\n            address: address\n        });\n    }\n\n    /**\n     * @private\n     * @param address   {string}\n     * @return {Promise<{balance: string, status: string}>}\n     */\n    async getAccountInfoFromIndex(address) {\n        return this.sendToIndex('account', {\n            address: address\n        });\n    }\n\n    /**\n     * @return {Promise<number>} seqno\n     */\n    async getMySeqno() {\n        const walletInfo = await this.getWalletInfoFromIndex(this.myAddress);\n        return walletInfo.seqno || 0;\n    }\n\n    /**\n     * @param address   {string}\n     * @return {Promise<BN>} in nanotons\n     */\n    async getBalance(address) {\n        const accountInfo = await this.getAccountInfoFromIndex(address);\n        return new BN(accountInfo.balance);\n    }\n\n    /**\n     * @param address   {string}\n     * @return {Promise<boolean>}\n     */\n    async checkContractInitialized(address) {\n        const accountInfo = await this.getAccountInfoFromIndex(address);\n        return accountInfo.status === \"active\";\n    }\n\n    /**\n     * @private\n     * @param address   {string}\n     * @param limit {number}\n     * @return {Promise<void>}\n     */\n    async getTransactionsFromIndex(address, limit) {\n        return this.sendToIndex('transactions', {\n            account: address,\n            limit: limit\n        });\n    }\n\n    /**\n     * @param limit? {number}\n     * @return {Promise<any[]>} transactions\n     */\n    async getTransactions(limit = 10) {\n\n        /**\n         * @param msg   {any} raw.message\n         * @return {string}\n         */\n        function getComment(msg) {\n            if (!msg.message_content) return '';\n            if (!msg.message_content.decoded) return '';\n            if (msg.message_content.decoded['type'] !== 'text_comment') return '';\n            return msg.message_content.decoded.comment;\n        }\n\n        /**\n         * @param msg {any} raw.message\n         * @return {string} '' or base64\n         */\n        function getEncryptedComment(msg) {\n            if (!msg.message_content) return '';\n            if (!msg.message_content.body) return '';\n            if (msg.opcode !== \"0x2167da4b\") return '';\n            /** @type {string} */\n            const cellBase64 = msg.message_content.body;\n            /** @type {Cell} */\n            const cell = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(cellBase64));\n            return TonWeb.utils.bytesToBase64(parseSnakeCells(cell).slice(4)); // skip 4 bytes of prefix 0x2167da4b\n        }\n\n        const arr = [];\n        const transactionsResponse= await this.getTransactionsFromIndex(this.myAddress, limit);\n        const transactions = transactionsResponse.transactions; // index.transaction[]\n        const addressBook = transactionsResponse.address_book;\n\n        /**\n         * @param rawAddress    {string}\n         * @return {string}\n         */\n        const formatTxAddress = (rawAddress) => {\n            return addressBook[rawAddress].user_friendly;\n        }\n\n        for (const t of transactions) {\n            let amount = new BN(t.in_msg.value);\n            for (const outMsg of t.out_msgs) {\n                amount = amount.sub(new BN(outMsg.value));\n            }\n\n            let from_addr = \"\";\n            let to_addr = \"\";\n            let comment = \"\";\n            let encryptedComment = \"\";\n            let inbound = false;\n\n            if (t.in_msg.source) { // internal message with Toncoins, set source\n                inbound = true;\n                from_addr = formatTxAddress(t.in_msg.source);\n                to_addr = formatTxAddress(t.in_msg.destination);\n                comment = getComment(t.in_msg);\n                encryptedComment = getEncryptedComment(t.in_msg);\n            } else if (t.out_msgs.length) { // external message, we sending Toncoins\n                inbound = false;\n                from_addr = formatTxAddress(t.out_msgs[0].source);\n                to_addr = formatTxAddress(t.out_msgs[0].destination);\n                comment = getComment(t.out_msgs[0]);\n                encryptedComment = getEncryptedComment(t.out_msgs[0]);\n                //TODO support many out messages. We need to show separate outgoing payment for each? How to show fees?\n            } else {\n                // Deploying wallet contract onchain\n            }\n\n            /** @type {BN} */\n            let fee = new BN(t.total_fees);\n            for (let outMsg of t.out_msgs) {\n                fee = fee.add(new BN(outMsg.fwd_fee));\n                fee = fee.add(new BN(outMsg.ihr_fee));\n            }\n\n            if (to_addr) {\n                arr.push({\n                    bodyHashBase64: t.in_msg.message_content.hash, // base64\n                    inbound,\n                    hash: t.hash, // base64\n                    amount: amount.toString(),\n                    from_addr: from_addr,\n                    to_addr: to_addr,\n                    fee: fee.toString(), // string BN\n                    comment: comment,\n                    encryptedComment: encryptedComment,\n                    date: t.now * 1000\n                });\n            }\n        }\n        return arr;\n    }\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @param keyPair    {nacl.KeyPair | null} null if estimates fee, keyPair if real sending\n     * @return Promise<{{send: () => Promise<*>, getQuery: () => Promise<Cell>, estimateFee: () => Promise<*>}}> transfer object\n     */\n    async sign(request, keyPair) {\n        /** @type {number} */\n        const seqno = await this.getMySeqno();\n\n        /** @type {Uint8Array | null} */\n        const secretKey = keyPair ? keyPair.secretKey : null;\n\n        return this.walletContract.methods.transfers({\n            secretKey: secretKey,\n            seqno: seqno,\n            expireAt: request.expireAt,\n            messages: request.messages.map(message => {\n                return {\n                    toAddress: message.toAddress,\n                    amount: message.amount,\n                    payload: message.comment,\n                    sendMode: 3,\n                    stateInit: message.stateInit\n                }\n            })\n        });\n    }\n\n    // CREATE WALLET\n\n    async showCreated() {\n        this.sendToView('showScreen', {name: 'created'});\n        this.sendToView('disableCreated', true);\n        this.myMnemonicWords = await TonWeb.mnemonic.generateMnemonic();\n        const privateKey = await Controller.wordsToPrivateKey(this.myMnemonicWords);\n        const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n        const walletVersion = DEFAULT_WALLET_VERSION;\n        const WalletClass = this.ton.wallet.all[walletVersion];\n        this.walletContract = new WalletClass(this.ton.provider, {\n            publicKey: keyPair.publicKey,\n            wc: 0\n        });\n        this.myAddress = (await this.walletContract.getAddress()).toString(true, true, false, this.isTestnet);\n        this.publicKeyHex = TonWeb.utils.bytesToHex(keyPair.publicKey);\n        await storage.setItem('publicKey', this.publicKeyHex);\n        await storage.setItem('walletVersion', walletVersion);\n        this.sendToView('disableCreated', false);\n    }\n\n    async createPrivateKey() {\n        this.showBackup(this.myMnemonicWords, true);\n    }\n\n    // BACKUP WALLET\n\n    onBackupWalletClick() {\n        this.afterEnterPassword = async mnemonicWords => {\n            this.showBackup(mnemonicWords);\n        };\n        this.sendToView('showPopup', {name: 'enterPassword'});\n    }\n\n    showBackup(words, isFirst) {\n        this.sendToView('showScreen', {name: 'backup', words, isFirst});\n    }\n\n    async onBackupDone() {\n        if (await storage.getItem('words')) {\n            this.sendToView('showScreen', {name: 'main'});\n        } else {\n            this.sendToView('showScreen', {name: 'wordsConfirm', words: this.myMnemonicWords});\n        }\n    }\n\n    onConfirmDone(words) {\n        if (words) {\n            let isValid = true;\n\n            Object.keys(words).forEach(index => {\n                if (this.myMnemonicWords[index] !== words[index]) {\n                    isValid = false;\n                }\n            });\n\n            if (!isValid) {\n                return;\n            }\n\n            this.showCreatePassword();\n        }\n    }\n\n    // IMPORT LEDGER\n\n    async createLedger(transportType) {\n        let transport;\n\n        switch (transportType) {\n            case 'hid':\n                transport = await TonWeb.ledger.TransportWebHID.create();\n                break;\n            case 'ble':\n                transport = await TonWeb.ledger.BluetoothTransport.create();\n                break;\n            default:\n                throw new Error('unknown transportType' + transportType);\n        }\n\n        transport.setDebugMode(true);\n        this.isLedger = true;\n        this.ledgerApp = new TonWeb.ledger.AppTon(transport, this.ton);\n        const ledgerVersion = (await this.ledgerApp.getAppConfiguration()).version;\n        this.debug('ledgerAppConfig=', ledgerVersion);\n        if (!ledgerVersion.startsWith('2')) {\n            alert('Please update your Ledger TON-app to v2.0.1 or upper or use old wallet version https://tonwallet.me/prev/');\n            throw new Error('outdated ledger ton-app version');\n        }\n        const {publicKey} = await this.ledgerApp.getPublicKey(ACCOUNT_NUMBER, false); // todo: можно сохранять publicKey и не запрашивать это\n\n        const WalletClass = this.ton.wallet.all[DEFAULT_LEDGER_WALLET_VERSION];\n        const wallet = new WalletClass(this.ton.provider, {\n            publicKey: publicKey,\n            wc: 0\n        });\n        this.walletContract = wallet;\n\n        const address = await wallet.getAddress();\n        this.myAddress = address.toString(true, true, false, this.isTestnet);\n        this.publicKeyHex = TonWeb.utils.bytesToHex(publicKey);\n    }\n\n    async importLedger(transportType) {\n        await this.createLedger(transportType);\n        await storage.setItem('walletVersion', this.walletContract.getName());\n        await storage.setItem('address', this.myAddress);\n        await storage.setItem('isLedger', 'true');\n        await storage.setItem('ledgerTransportType', transportType);\n        await storage.setItem('words', 'ledger');\n        await storage.setItem('publicKey', this.publicKeyHex);\n        this.sendToView('setIsLedger', this.isLedger);\n        this.sendToView('showScreen', {name: 'readyToGo'});\n    }\n\n    // IMPORT WALLET\n\n    showImport() {\n        this.sendToView('showScreen', {name: 'import'});\n    }\n\n    async import(words) {\n        this.myMnemonicWords = words;\n        if (this.myMnemonicWords) {\n            try {\n                const privateKey = await Controller.wordsToPrivateKey(this.myMnemonicWords);\n                const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n\n                let hasBalance = [];\n\n                for (let WalletClass of this.ton.wallet.list) {\n                    const wallet = new WalletClass(this.ton.provider, {\n                        publicKey: keyPair.publicKey,\n                        wc: 0\n                    });\n                    const walletAddress = (await wallet.getAddress()).toString(true, true, false, this.isTestnet);\n                    const walletBalance = await this.getBalance(walletAddress);\n                    if (walletBalance.gt(new BN(0))) {\n                        hasBalance.push({balance: walletBalance, clazz: WalletClass});\n                    }\n                    this.debug(wallet.getName(), walletAddress, walletBalance.toString());\n                }\n\n                let walletClass = this.ton.wallet.all[DEFAULT_WALLET_VERSION];\n\n                if (hasBalance.length > 0) {\n                    hasBalance.sort((a, b) => {\n                        return a.balance.cmp(b.balance);\n                    });\n                    walletClass = hasBalance[hasBalance.length - 1].clazz;\n                }\n\n                await this.importImpl(keyPair, walletClass);\n\n                this.sendToView('importCompleted', {state: 'success'});\n            } catch (e) {\n                this.debug(e);\n                this.sendToView('importCompleted', {state: 'failure'});\n            }\n        } else {\n            this.sendToView('importCompleted', {state: 'failure'});\n        }\n    }\n\n    async importImpl(keyPair, WalletClass) {\n        this.walletContract = new WalletClass(this.ton.provider, {\n            publicKey: keyPair.publicKey,\n            wc: 0\n        });\n        this.myAddress = (await this.walletContract.getAddress()).toString(true, true, false, this.isTestnet);\n        this.publicKeyHex = TonWeb.utils.bytesToHex(keyPair.publicKey);\n        await storage.setItem('publicKey', this.publicKeyHex);\n        await storage.setItem('walletVersion', this.walletContract.getName());\n        this.showCreatePassword();\n    }\n\n    // PASSWORD\n\n    showCreatePassword() {\n        this.sendToView('showScreen', {name: 'createPassword'});\n    }\n\n    /**\n     * @param password  {string}\n     * @return {Promise<void>}\n     */\n    async savePrivateKey(password) {\n        this.isLedger = false;\n        await storage.setItem('isLedger', 'false');\n        await storage.setItem('address', this.myAddress);\n        await Controller.saveWords(this.myMnemonicWords, password);\n        this.myMnemonicWords = null;\n\n        this.sendToView('setIsLedger', this.isLedger);\n        this.sendToView('showScreen', {name: 'readyToGo'});\n        this.sendToView('privateKeySaved');\n    }\n\n    /**\n     * @param oldPassword   {string}\n     * @param newPassword   {string}\n     * @return {Promise<void>}\n     */\n    async onChangePassword(oldPassword, newPassword) {\n        let words;\n        try {\n            words = await Controller.loadWords(oldPassword);\n        } catch (e) {\n            this.sendToView('showChangePasswordError');\n            return;\n        }\n        await Controller.saveWords(words, newPassword);\n\n        this.sendToView('closePopup');\n        this.sendToView('passwordChanged');\n    }\n\n    /**\n     * @param password  {string}\n     * @return {Promise<void>}\n     */\n    async onEnterPassword(password) {\n        let words;\n        try {\n            words = await Controller.loadWords(password);\n        } catch (e) {\n            this.sendToView('showEnterPasswordError');\n            return;\n        }\n\n        this.afterEnterPassword(words);\n        this.sendToView('passwordEntered');\n    }\n\n    // MAIN\n\n    /**\n     * @return {Promise<void>}\n     */\n    async showMain() {\n        this.sendToView('showScreen', {name: 'main', myAddress: this.myAddress});\n        if (!this.walletContract) {\n            const walletVersion = await storage.getItem('walletVersion');\n            const walletClass = walletVersion ? this.ton.wallet.all[walletVersion] : this.ton.wallet.default;\n\n            this.walletContract = new walletClass(this.ton.provider, {\n                address: this.myAddress,\n                publicKey: this.publicKeyHex ? TonWeb.utils.hexToBytes(this.publicKeyHex) : undefined,\n                wc: 0\n            });\n        }\n        this.updateIntervalId = setInterval(() => this.update(false), 5000);\n        this.update(true);\n        this.sendToDapp('ton_accounts', [this.myAddress]);\n    }\n\n    /**\n     * @return {Promise<void>}\n     */\n    async initDapp() {\n        this.sendToDapp('ton_accounts', this.myAddress ? [this.myAddress] : []);\n        this.doMagic((await storage.getItem('magic')) === 'true');\n        this.doProxy((await storage.getItem('proxy')) === 'true');\n    }\n\n    /**\n     * @return {Promise<void>}\n     */\n    async initView() {\n        if (!this.myAddress || !(await storage.getItem('words'))) {\n            this.sendToView('showScreen', {name: 'start', noAnimation: true});\n        } else {\n            this.sendToView('showScreen', {name: 'main', myAddress: this.myAddress});\n            if (this.balance !== null) {\n                this.sendToView('setBalance', {balance: this.balance.toString(), txs: this.transactions});\n            }\n        }\n        this.sendToView('setIsMagic', (await storage.getItem('magic')) === 'true');\n        this.sendToView('setIsProxy', (await storage.getItem('proxy')) === 'true');\n        this.sendToView('setIsTestnet', this.isTestnet);\n    }\n\n    /**\n     * @return {Promise<boolean>} successfully updated\n     */\n    async updateBalance() {\n        try {\n            this.balance = await this.getBalance(this.myAddress);\n            return true;\n        } catch (e) {\n            console.error(e);\n            return false;\n        }\n    }\n\n    /**\n     * @param force {boolean}\n     * @return {Promise<boolean>} successfully updated\n     */\n    async update(force) {\n        try {\n            // if (!document.hasFocus()) {\n            //     return true;\n            // }\n            const needUpdate = (this.processingVisible && this.sendingData) || (this.balance === null) || force;\n\n            if (!needUpdate) return true;\n\n            if (!(await this.updateBalance())) return false;\n\n            const txs = await this.getTransactions();\n            if (txs.length > 0) {\n                this.transactions = txs;\n\n                if (this.processingVisible && this.sendingData) {\n                    for (let tx of txs) {\n                        if (tx.bodyHashBase64 === this.sendingData.bodyHashBase64) {\n                            this.sendToView('showPopup', {\n                                name: 'done',\n                                message: formatNanograms(this.sendingData.totalAmount) + ' TON have been sent'\n                            });\n                            this.processingVisible = false;\n                            this.sendingData = null;\n                            break;\n                        }\n                    }\n                }\n            }\n\n            this.sendToView('setBalance', {balance: this.balance.toString(), txs: this.transactions});\n            return true;\n\n        } catch (e) {\n            console.error(e);\n            return false;\n        }\n    }\n\n    async showAddressOnDevice() {\n        if (!this.ledgerApp) {\n            await this.createLedger((await storage.getItem('ledgerTransportType')) || 'hid');\n        }\n        const {address} = await this.ledgerApp.getAddress(ACCOUNT_NUMBER, true, this.ledgerApp.ADDRESS_FORMAT_USER_FRIENDLY + this.ledgerApp.ADDRESS_FORMAT_URL_SAFE + this.ledgerApp.ADDRESS_FORMAT_BOUNCEABLE);\n        this.debug(address.toString(true, true, true));\n    }\n\n    // DECRYPT MESSAGE COMMENT\n\n    /**\n     * @param hash  {string}\n     * @param encryptedComment  {string} base64\n     * @param senderAddress {string | Address}\n     */\n    onDecryptComment(hash, encryptedComment, senderAddress) {\n        this.afterEnterPassword = async mnemonicWords => {\n            const keyPair = await TonWeb.mnemonic.mnemonicToKeyPair(mnemonicWords);\n            let decryptedComment = ''\n            try {\n                decryptedComment = await decryptMessageComment(TonWeb.utils.base64ToBytes(encryptedComment), keyPair.publicKey, keyPair.secretKey, senderAddress);\n            } catch (e) {\n                console.error(e);\n            }\n            this.sendToView('decryptedComment', {hash, decryptedComment});\n        };\n        this.sendToView('showPopup', {name: 'enterPassword'});\n    }\n\n    // SEND TONCOIN\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @return {Promise<BN>} total fees in nanotons\n     */\n    async getFees(request) {\n        /** @type {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}} */\n        const tempRequest = {\n            expireAt: request.expireAt,\n            messages: []\n        };\n\n        for (const message of request.messages) {\n            let tempComment = message.comment\n\n            if (message.needEncryptComment) {\n                const tempKeyPair = TonWeb.utils.newKeyPair();  // encrypt with random key just to get estimage fees\n                const tempEncryptedCommentCell = await encryptMessageComment(message.comment, tempKeyPair.publicKey, tempKeyPair.publicKey, tempKeyPair.secretKey, this.myAddress);\n                tempComment = tempEncryptedCommentCell;\n\n            }\n            tempRequest.messages.push({\n                amount: message.amount,\n                toAddress: message.toAddress,\n                comment: tempComment,\n                needEncryptComment: message.needEncryptComment,\n                stateInit: message.stateInit\n            });\n        }\n\n        const query = await this.sign(tempRequest, null);\n        const all_fees = await query.estimateFee();\n        const fees = all_fees.source_fees;\n        const in_fwd_fee = new BN(fees.in_fwd_fee); // External processing fee\n        const storage_fee = new BN(fees.storage_fee);\n        const gas_fee = new BN(fees.gas_fee);\n        const fwd_fee = new BN(fees.fwd_fee);\n\n        return in_fwd_fee.add(storage_fee).add(gas_fee).add(fwd_fee);\n    };\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @param needQueue? {boolean}\n     * @return {Promise<Cell | null>} successfully sent BoC\n     */\n    async showSendConfirm(request, needQueue) {\n        createDappPromise();\n\n        if (!request.messages) throw new Error('no messages');\n        if (!request.messages.length) throw new Error('no messages to send');\n        if (request.messages.length > 4) throw new Error('maximum 4 message at once');\n\n        /** @type {BN} */\n        let totalAmount = new BN(0);\n\n        for (const message of request.messages) {\n\n            // message.address\n\n            if (!message.amount) throw new Error('no amount');\n\n            if (!message.amount.gte(new BN(0))) {\n                this.sendToView('sendCheckFailed', {message: 'Amount must be positive'});\n                return null;\n            }\n\n            if (message.amount.eq(new BN(0)) && !message.comment) {\n                this.sendToView('sendCheckFailed', {message: 'You can send 0 TON only with comment'});\n                return null;\n            }\n\n            totalAmount = totalAmount.add(message.amount);\n\n            // message.toAddress\n\n            if (!message.toAddress) throw new Error('no toAddress');\n\n            if (!Address.isValid(message.toAddress)) {\n                try {\n                    message.toAddress = message.toAddress.toLowerCase();\n                    if (!message.toAddress.endsWith('.ton') && !message.toAddress.endsWith('.t.me')) {\n                        throw new Error();\n                    }\n\n                    message.toAddress = await this.ton.dns.getWalletAddress(message.toAddress);\n                    if (!message.toAddress) {\n                        throw new Error();\n                    }\n                    if (!Address.isValid(message.toAddress)) {\n                        throw new Error();\n                    }\n                    message.toAddress = message.toAddress.toString(true, true, true, this.isTestnet);\n\n                } catch (e) {\n                    this.sendToView('sendCheckFailed', {message: 'Invalid address or domain'});\n                    return null;\n                }\n            }\n\n            // make toAddress non-bounceable if destination contract uninitialized\n            if (!(await this.checkContractInitialized(message.toAddress))) {\n                message.toAddress = (new Address(message.toAddress)).toString(true, true, false);\n            }\n\n            // message.payload\n\n            if (!message.comment) {\n                message.needEncryptComment = false;\n            }\n\n            // serialize long text comment\n            if (!message.needEncryptComment && (typeof message.comment === 'string')) {\n                if (message.comment.length > 0) {\n                    const commentBytes = new TextEncoder().encode(message.comment);\n                    const payloadBytes = new Uint8Array(4 + commentBytes.length);\n                    payloadBytes[0] = 0; // zero uint32 means simple text message\n                    payloadBytes[1] = 0;\n                    payloadBytes[2] = 0;\n                    payloadBytes[3] = 0;\n                    payloadBytes.set(commentBytes, 4);\n                    message.comment = makeSnakeCells(payloadBytes);\n                }\n            }\n\n            // get destination public key for encryption\n\n            if (message.needEncryptComment) {\n                let toPublicKey = null;\n\n                try {\n                    const toPublicKeyBN = await this.ton.provider.call2(message.toAddress, 'get_public_key');\n                    let toPublicKeyHex = toPublicKeyBN.toString(16);\n                    if (toPublicKeyHex.length % 2 !== 0) {\n                        toPublicKeyHex = '0' + toPublicKeyHex;\n                    }\n                    toPublicKey = TonWeb.utils.hexToBytes(toPublicKeyHex);\n                } catch (e) {\n                    console.error(e);\n                }\n\n                if (!toPublicKey) {\n                    this.sendToView('sendCheckCantPublicKey', {});\n                    return null;\n                }\n\n                message.toPublicKey = toPublicKey;\n            }\n        }\n\n        // check balance\n\n        if (!(await this.updateBalance())) {\n            this.sendToView('sendCheckFailed', {message: 'API request error'});\n            return null;\n        }\n\n        if (this.balance.lt(totalAmount)) {\n            this.sendToView('sendCheckFailed', {\n                message: 'Not enough balance'\n            });\n            return null;\n        }\n\n        let fee;\n\n        try {\n            fee = await this.getFees(request);\n        } catch (e) {\n            console.error(e);\n            this.sendToView('sendCheckFailed', {message: 'API request error'});\n            return null;\n        }\n\n        if (this.balance.sub(fee).lt(totalAmount)) {\n            this.sendToView('sendCheckCantPayFee', {fee});\n            return null;\n        }\n\n        // start\n\n        if (this.isLedger) {\n            const message = request.messages[0];\n\n            this.sendToView('showPopup', {\n                name: 'sendConfirm',\n                amount: message.amount.toString(),\n                toAddress: message.toAddress,\n                needEncryptComment: false,\n                fee: fee.toString()\n            }, needQueue);\n\n            const sentBoc = await this.send(request, null, totalAmount);\n\n            if (sentBoc) {\n                dAppPromise.resolve(sentBoc);\n            } else {\n                this.sendToView('sendCheckFailed', {message: 'API request error'});\n                dAppPromise.resolve(null);\n            }\n        } else {\n            this.afterEnterPassword = async words => {\n                this.processingVisible = true;\n                this.sendToView('showPopup', {name: 'processing'});\n\n                const keyPair = await TonWeb.mnemonic.mnemonicToKeyPair(words);\n\n                for (const message of request.messages) {\n                    if (message.needEncryptComment) {\n                        const encryptedCommentCell = await encryptMessageComment(message.comment, keyPair.publicKey, message.toPublicKey, keyPair.secretKey, this.myAddress);\n                        message.comment = encryptedCommentCell;\n                    }\n                }\n\n                const privateKeyBase64 = await Controller.wordsToPrivateKey(words);\n                const sentBoc = await this.send(request, privateKeyBase64, totalAmount);\n\n                this.onCancelAction = null;\n\n                if (sentBoc) {\n                    dAppPromise.resolve(sentBoc);\n                } else {\n                    this.sendToView('sendCheckFailed', {message: 'API request error'});\n                    dAppPromise.resolve(null);\n                }\n            };\n\n            this.onCancelAction = () => {\n                dAppPromise.resolve(null);\n            };\n\n            this.sendToView('showPopup', {\n                name: 'sendConfirm',\n                amount: totalAmount.toString(),\n                toAddress: request.messages.length === 1 ? request.messages[0].toAddress : `${request.messages.length} addresses`,\n                fee: fee.toString(),\n                needEncryptComment: request.messages[0].needEncryptComment // todo\n            }, needQueue);\n        }\n\n        this.sendToView('sendCheckSucceeded');\n\n        return dAppPromise;\n    }\n\n    /**\n     * @param request {{expireAt?: number, messages: [{amount: BN, toAddress: string, comment?: string | Uint8Array | Cell, needEncryptComment: boolean, stateInit?: Cell}]}}\n     * @param privateKeyBase64 {string | null} null if Ledger\n     * @param totalAmount {BN}\n     * @return  {Promise<Cell | null>} successfully sent BoC\n     */\n    async send(request, privateKeyBase64, totalAmount) {\n        try {\n            let query;\n\n            if (this.isLedger) {\n                if (request.messages.length !== 1) {\n                    throw new Error('Ledger support only 1 message at once');\n                }\n\n                const message = request.messages[0];\n\n                if (message.needEncryptComment) {\n                    throw new Error('encrypted comment dont supported by Ledger');\n                }\n\n                if (message.stateInit) {\n                    throw new Error('stateInit dont supported by Ledger');\n                }\n\n                if (!this.ledgerApp) {\n                    await this.createLedger((await storage.getItem('ledgerTransportType')) || 'hid');\n                }\n\n                let addressFormat = 0;\n\n                const toAddress = new Address(message.toAddress);\n                if (toAddress.isUserFriendly) {\n                    addressFormat += this.ledgerApp.ADDRESS_FORMAT_USER_FRIENDLY;\n                    if (toAddress.isUrlSafe) {\n                        addressFormat += this.ledgerApp.ADDRESS_FORMAT_URL_SAFE;\n                    }\n                    if (toAddress.isBounceable) {\n                        addressFormat += this.ledgerApp.ADDRESS_FORMAT_BOUNCEABLE;\n                    }\n                    if (toAddress.isTestOnly) {\n                        addressFormat += this.ledgerApp.ADDRESS_FORMAT_TEST_ONLY;\n                    }\n                }\n\n                const seqno = await this.getMySeqno();\n\n                query = await this.ledgerApp.transfer(ACCOUNT_NUMBER, this.walletContract, message.toAddress, message.amount, seqno, addressFormat);\n                this.sendToView('showPopup', {name: 'processing'});\n                this.processingVisible = true;\n\n            } else {\n\n                const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKeyBase64));\n                query = await this.sign(request, keyPair);\n\n            }\n\n            /** @type {Cell | null} */\n            const sentBoc = await this.sendQuery(query);\n\n            if (!sentBoc) return null;\n\n            /** @type {Cell} */\n            const bodyCell = await query.getBody();\n            /** @type {Uint8Array} */\n            const bodyHash = await bodyCell.hash();\n\n            this.sendingData = {\n                bodyHashBase64: TonWeb.utils.bytesToBase64(bodyHash),\n                totalAmount: totalAmount\n            };\n\n            return sentBoc;\n\n        } catch (e) {\n            this.debug(e);\n            this.sendToView('closePopup');\n            alert('Error sending');\n            return null;\n        }\n    }\n\n    /**\n     * @param hexToSign   {string} hex to sign\n     * @param privateKey    {string}\n     * @returns {Promise<string>} signature in hex\n     */\n    rawSign(hexToSign, privateKey) {\n        const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n        const signature = nacl.sign.detached(TonWeb.utils.hexToBytes(hexToSign), keyPair.secretKey);\n        return TonWeb.utils.bytesToHex(signature);\n    }\n\n    /**\n     * @param query {{send: () => Promise<*>, getQuery: () => Promise<Cell>}}\n     * @return {Promise<Cell | null>} successfully sent BoC\n     */\n    async sendQuery(query) {\n        const sendResponse = await query.send();\n        if (sendResponse[\"@type\"] === \"ok\") { // response from ton-http-api\n            // wait for transaction, then show Done popup\n            return query.getQuery();\n        } else {\n            this.sendToView('closePopup');\n            alert('Send error');\n            return null;\n        }\n    }\n\n    // RAW SIGN\n\n    /**\n     * @param hexToSign  {string} hex data to sign\n     * @param isConnect {boolean}\n     * @param needQueue {boolean}\n     * @returns {Promise<string>} signature in hex\n     */\n    showSignConfirm(hexToSign, isConnect, needQueue) {\n        return new Promise((resolve, reject) => {\n            if (this.isLedger) {\n                alert('sign not supported by Ledger');\n                reject();\n            } else {\n\n                this.onCancelAction = () => {\n                    reject('User cancel');\n                };\n\n                this.afterEnterPassword = async words => {\n                    this.sendToView('closePopup');\n                    const privateKeyBase64 = await Controller.wordsToPrivateKey(words);\n                    const signature = this.rawSign(hexToSign, privateKeyBase64);\n                    resolve(signature);\n                };\n\n                this.sendToView('showPopup', {\n                    name: 'signConfirm',\n                    data: hexToSign,\n                    isConnect: isConnect\n                }, needQueue);\n\n            }\n        });\n    }\n\n    /**\n     * Ask user for password and set `this.publicKeyHex`\n     * @param needQueue {boolean}\n     * @return {Promise<void>}\n     */\n    requestPublicKey(needQueue) {\n        return new Promise(async (resolve, reject) => {\n            await showExtensionWindow();\n\n            this.onCancelAction = () => {\n                reject('User cancel');\n            };\n\n            this.afterEnterPassword = async words => {\n                const privateKey = await Controller.wordsToPrivateKey(words);\n                const keyPair = nacl.sign.keyPair.fromSeed(TonWeb.utils.base64ToBytes(privateKey));\n                this.publicKeyHex = TonWeb.utils.bytesToHex(keyPair.publicKey);\n                await storage.setItem('publicKey', this.publicKeyHex);\n                resolve();\n            };\n\n            this.sendToView('showPopup', {name: 'enterPassword'}, needQueue);\n        });\n    }\n\n    /**\n     * @param needQueue {boolean}\n     * @returns {Promise<void>}\n     */\n    showConnectConfirm(needQueue) {\n        return new Promise((resolve, reject) => {\n            this.onCancelAction = () => {\n                reject({\n                    message: 'Reject request',\n                    code: 300 // USER_REJECTS_ERROR\n                });\n            };\n\n            this.onConnectConfirmed = async () => {\n                this.sendToView('closePopup');\n                resolve();\n            };\n\n            this.sendToView('showPopup', {\n                name: 'connectConfirm',\n            }, needQueue);\n        });\n    }\n\n    // DISCONNECT WALLET\n\n    clearVars() {\n        this.myAddress = null;\n        this.publicKeyHex = null;\n        this.balance = null;\n        this.walletContract = null;\n        this.transactions = [];\n        this.sendingData = null;\n        this.processingVisible = false;\n        this.isLedger = false;\n        this.ledgerApp = null;\n        clearInterval(this.updateIntervalId);\n    }\n\n    async onDisconnectClick() {\n        this.clearVars();\n        await storage.clear();\n        this.sendToView('showScreen', {name: 'start'});\n        this.sendToDapp('ton_accounts', []);\n    }\n\n    // MAGIC\n\n    doMagic(enabled) {\n        try {\n            this.sendToDapp('ton_doMagic', enabled);\n        } catch (e) {\n\n        }\n    }\n\n    // PROXY\n\n    doProxy(enabled) {\n\n    }\n\n    // TRANSPORT WITH VIEW\n\n    /**\n     * @param method    {string}\n     * @param params?   {any}  boolean or object, not array\n     * @param needQueue? {boolean}\n     * @param needResult? {boolean}\n     * @return {void | Promise<{magic: (string|null), proxy: (string|null), address: (string|null), words: (string|null), walletVersion: (string|null)}>}\n     */\n    sendToView(method, params, needQueue, needResult) {\n        if (self.view) {\n            const result = self.view.onMessage(method, params);\n            if (needResult) {\n                return result;\n            }\n        } else {\n            const msg = {method, params};\n            const exec = () => {\n                if (popupPort) {\n                    popupPort.postMessage(msg);\n                } else if (needQueue) {\n                    queueToPopup.push(msg);\n                }\n            };\n\n            if (!needResult) {\n                exec();\n                return;\n            }\n\n            return new Promise((resolve) => {\n                msg.id = this._lastMsgId++;\n                this.pendingMessageResolvers.set(msg.id, resolve);\n                exec();\n            });\n        }\n    }\n\n    /**\n     * @param method    {string}\n     * @param params?   {any}  boolean or object, not array\n     * @return {Promise<void>}\n     */\n    async onViewMessage(method, params) {\n        switch (method) {\n            case 'showScreen':\n                switch (params.name) {\n                    case 'created':\n                        await this.showCreated();\n                        break;\n                    case 'import':\n                        this.showImport();\n                        break;\n                    case 'importLedger':\n                        await this.importLedger(params.transportType);\n                        break;\n                }\n                break;\n            case 'import':\n                await this.import(params.words);\n                break;\n            case 'createPrivateKey':\n                await this.createPrivateKey();\n                break;\n            case 'passwordCreated':\n                await this.savePrivateKey(params.password);\n                break;\n            case 'update':\n                this.update(true);\n                break;\n            case 'showAddressOnDevice':\n                await this.showAddressOnDevice();\n                break;\n            case 'onCancelAction':\n                if (this.onCancelAction) {\n                    await this.onCancelAction();\n                    this.onCancelAction = null;\n                }\n                break;\n            case 'onConnectConfirmed':\n                if (this.onConnectConfirmed) {\n                    this.onConnectConfirmed();\n                    this.onConnectConfirmed = null;\n                }\n                break;\n            case 'onEnterPassword':\n                await this.onEnterPassword(params.password);\n                break;\n            case 'decryptComment':\n                await this.onDecryptComment(params.hash, params.encryptedComment, params.senderAddress);\n                break;\n            case 'onChangePassword':\n                await this.onChangePassword(params.oldPassword, params.newPassword);\n                break;\n            case 'onSend':\n                await this.showSendConfirm({\n                    messages: [\n                        {\n                            amount: new BN(params.amount),\n                            toAddress: params.toAddress,\n                            comment: params.comment,\n                            needEncryptComment: params.needEncryptComment\n                        }\n                    ]\n                }, false);\n                break;\n            case 'onBackupDone':\n                await this.onBackupDone();\n                break;\n            case 'onConfirmBack':\n                this.showBackup(this.myMnemonicWords);\n                break;\n            case 'onImportBack':\n                this.sendToView('showScreen', {name: 'start'});\n                break;\n            case 'onConfirmDone':\n                this.onConfirmDone(params.words);\n                break;\n            case 'showMain':\n                await this.showMain();\n                break;\n            case 'onBackupWalletClick':\n                this.onBackupWalletClick();\n                break;\n            case 'disconnect':\n                await this.onDisconnectClick();\n                break;\n            case 'onClosePopup':\n                this.processingVisible = false;\n                break;\n            case 'onMagicClick':\n                await storage.setItem('magic', params ? 'true' : 'false');\n                this.doMagic(params);\n                break;\n            case 'onProxyClick':\n                await storage.setItem('proxy', params ? 'true' : 'false');\n                this.doProxy(params);\n                break;\n            case 'toggleTestnet':\n                await this.toggleTestnet();\n                break;\n            case 'toggleDebug':\n                await this.toggleDebug();\n                break;\n            case 'onWindowUpdate':\n                await storage.setItem('windowState', {\n                    top: params.top,\n                    left: params.left,\n                    // -2 need for remove frames size\n                    // TODO: check in linux and macos\n                    height: params.height - 2,\n                    width: params.width - 2\n                });\n                break;\n        }\n    }\n\n    // TRANSPORT WITH DAPP\n\n    /**\n     * @param method    {string}\n     * @param params    {any | any[]}\n     */\n    sendToDapp(method, params) {\n        contentScriptPorts.forEach(port => {\n            port.postMessage(JSON.stringify({\n                type: 'gramWalletAPI',\n                message: {jsonrpc: '2.0', method: method, params: params}\n            }));\n        });\n    }\n\n    /**\n     * @param needQueue {boolean}\n     * @return {Promise<{name: 'ton_addr', address: string, network: string, walletStateInit: string, publicKey: string }>}\n     */\n    async createTonAddrItemReply(needQueue) {\n        if (!this.myAddress) {\n            throw {\n                message: 'Missing connection',\n                code: 1 // BAD_REQUEST_ERROR\n            };\n        }\n        if (!this.publicKeyHex) {\n            await this.requestPublicKey(needQueue);\n        }\n        const walletVersion = await storage.getItem('walletVersion');\n\n        const rawAddressString = new TonWeb.utils.Address(this.myAddress).toString(false);\n        const WalletClass = walletVersion ? this.ton.wallet.all[walletVersion] : this.ton.wallet.default;\n        const wallet = new WalletClass(this.ton.provider, {\n            publicKey: TonWeb.utils.hexToBytes(this.publicKeyHex),\n            wc: 0\n        });\n        const {stateInit} = await wallet.createStateInit();\n        const stateInitBase64 = TonWeb.utils.bytesToBase64(await stateInit.toBoc(false));\n\n        return {\n            name: 'ton_addr',\n            address: rawAddressString,\n            network: this.isTestnet ? TONCONNECT_TESTNET : TONCONNECT_MAINNET,\n            walletStateInit: stateInitBase64,\n            publicKey: this.publicKeyHex\n        };\n    }\n\n    /**\n     * @param origin    {string}\n     * @param payload   {string}\n     * @param needQueue {boolean}\n     * @return {any} ton_proof item\n     */\n    async createTonProofItemReply(origin, payload, needQueue) {\n        if (!this.myAddress) {\n            throw {\n                message: 'Missing connection',\n                code: 1 // BAD_REQUEST_ERROR\n            };\n        }\n\n        const timestamp = Math.round(Date.now() / 1000);\n        const timestampBuffer = new BigInt64Array(1);\n        timestampBuffer[0] = BigInt(timestamp);\n\n        const domain = new URL(origin).host;\n        const domainBuffer = new TextEncoder().encode(domain);\n        const domainLengthBuffer = new Int32Array(1);\n        domainLengthBuffer[0] = domainBuffer.byteLength;\n\n        const address = new TonWeb.utils.Address(this.myAddress);\n\n        const addressWorkchainBuffer = new Int32Array(1);\n        addressWorkchainBuffer[0] = address.wc;\n\n        const addressBuffer = new Uint8Array(4 + address.hashPart.length);\n        addressBuffer.set(addressWorkchainBuffer, 0);\n        addressBuffer.set(address.hashPart, 4);\n\n        const prefixBuffer = new TextEncoder().encode('ton-proof-item-v2/');\n        const payloadBuffer = new TextEncoder().encode(payload);\n        const messageBuffer = new Uint8Array(prefixBuffer.byteLength + addressBuffer.byteLength + domainLengthBuffer.byteLength + domainBuffer.byteLength + timestampBuffer.byteLength + payloadBuffer.byteLength);\n\n        let offset = 0;\n        messageBuffer.set(prefixBuffer, offset);\n        offset += prefixBuffer.byteLength;\n        messageBuffer.set(addressBuffer, offset);\n        offset += addressBuffer.byteLength;\n        messageBuffer.set(domainLengthBuffer, offset);\n        offset += domainLengthBuffer.byteLength;\n        messageBuffer.set(domainBuffer, offset);\n        offset += domainBuffer.byteLength;\n        messageBuffer.set(new Uint8Array(timestampBuffer.buffer), offset);\n        offset += 8;\n        messageBuffer.set(payloadBuffer, offset);\n\n        const ffffPrefix = new Uint8Array([0xff, 0xff]);\n        const tonconnectPrefix = new TextEncoder().encode('ton-connect')\n\n        const messageBufferHash = new Uint8Array(await TonWeb.utils.sha256(messageBuffer));\n        const bufferToSign = new Uint8Array(ffffPrefix.byteLength + tonconnectPrefix.byteLength + messageBufferHash.byteLength);\n        offset = 0;\n        bufferToSign.set(ffffPrefix, offset);\n        offset += ffffPrefix.byteLength;\n        bufferToSign.set(tonconnectPrefix, offset);\n        offset += tonconnectPrefix.byteLength;\n        bufferToSign.set(messageBufferHash, offset);\n\n        const hexToSign = TonWeb.utils.bytesToHex(new Uint8Array(await TonWeb.utils.sha256(bufferToSign)));\n        const signatureHex = await this.showSignConfirm(hexToSign, true, needQueue);\n        console.log({signatureHex});\n        const signatureBase64 = TonWeb.utils.bytesToBase64(TonWeb.utils.hexToBytes(signatureHex));\n        console.log({signatureBase64});\n\n        return {\n            name: 'ton_proof',\n            proof: {\n                timestamp: timestamp, // 64-bit unix epoch time of the signing operation (seconds)\n                domain: {\n                    lengthBytes: domainBuffer.byteLength, // AppDomain Length\n                    value: domain, // app domain name (as url part, without encoding)\n                },\n                signature: signatureBase64, // base64-encoded signature\n                payload: payload, // payload from the request\n            },\n        }\n    }\n\n    async onDappMessage(method, params, origin) {\n        // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md\n        // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1102.md\n        await this.whenReady;\n\n        const needQueue = !popupPort;\n\n        switch (method) {\n            case 'tonConnect_connect':\n                await showExtensionWindow();\n                if (!this.myAddress) {\n                    throw {\n                        message: 'Missing connection',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                const data = params[0];\n                const tonProof = data.items.find((item) => item.name === 'ton_proof');\n\n\n                if (!tonProof &&\n                    !(await storage.getItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin))) {\n\n                    await this.showConnectConfirm(needQueue);\n                }\n\n                await storage.setItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin, 'true');\n\n                const connectResult = [\n                    await this.createTonAddrItemReply(needQueue),\n                ];\n                if (tonProof) {\n                    connectResult.push(await this.createTonProofItemReply(origin, tonProof.payload, needQueue))\n                }\n\n                return connectResult;\n\n            case 'tonConnect_reconnect':\n                if (!this.myAddress ||\n                    !(await storage.getItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin))) {\n                    throw {\n                        message: 'Missing connection',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                return [\n                    await this.createTonAddrItemReply(needQueue)\n                ];\n\n            case 'tonConnect_disconnect':\n                await storage.removeItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin);\n                return;\n\n            case 'tonConnect_sendTransaction':\n                await showExtensionWindow();\n\n                const tx = params[0];\n                console.log('tonConnect_sendTransaction', params, origin, tx);\n\n                // check is dapp connected to wallet\n\n                if (!this.myAddress) {\n                    throw {\n                        message: 'Missing connection',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n                if (!(await storage.getItem('tonconnect_' + this.myAddress + '_' + (this.isTestnet ? 'testnet' : 'mainnet') + '_' + origin))) {\n                    throw {\n                        message: 'dApp don\\'t have an access to wallet',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                // check tonConnect_sendTransaction request\n\n                /** @type {number | undefined} */\n                let expireAt = undefined;\n\n                if (tx.valid_until) {\n                    expireAt = Number(tx.valid_until);\n                    if (isNaN(expireAt)) {\n                        throw {\n                            message: 'invalid validUntil',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                    if (expireAt > 9999999999) {\n                        expireAt = expireAt / 1000; // convert millis to seconds, todo: it's not good\n                    }\n                    if (expireAt < Date.now() / 1000) {\n                        throw {\n                            message: 'expired',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                if (tx.from) {\n                    if (!Address.isValid(tx.from)) {\n                        throw {\n                            message: 'Invalid source address',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n\n                    if (new TonWeb.utils.Address(tx.from).toString(false) !== new TonWeb.utils.Address(this.myAddress).toString(false)) {\n                        throw {\n                            message: 'Different source address',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                if (tx.network) {\n                    if (tx.network !== TONCONNECT_TESTNET && tx.network !== TONCONNECT_MAINNET) {\n                        throw {\n                            message: 'Invalid network',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n\n                    if ((tx.network === TONCONNECT_TESTNET) !== !!this.isTestnet) {\n                        throw {\n                            message: 'Different network',\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                if (!tx.messages || !tx.messages.length) {\n                    throw {\n                        message: 'no messages',\n                        code: 1 // BAD_REQUEST_ERROR\n                    }\n                }\n\n                const convertTonconnectMessage = (message) => {\n                    try {\n                        if (!message.address) {\n                            throw new Error('no address')\n                        }\n                        if (!Address.isValid(message.address)) {\n                            throw new Error('invalid address');\n                        }\n                        if (!message.amount) {\n                            throw new Error('no amount')\n                        }\n                        message.amount = new BN(message.amount);\n                        if (message.payload) {\n                            message.payload = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(message.payload));\n                        }\n                        if (message.stateInit) {\n                            message.stateInit = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(message.stateInit));\n                        }\n\n                        return {\n                            amount: message.amount,\n                            toAddress: message.address,\n                            comment: message.payload,\n                            needEncryptComment: false,\n                            stateInit: message.stateInit\n                        }\n                    } catch (e) {\n                        throw {\n                            message: e.message,\n                            code: 1 // BAD_REQUEST_ERROR\n                        }\n                    }\n                }\n\n                const messages = [];\n                for (const message of tx.messages) {\n                    messages.push(convertTonconnectMessage(message));\n                }\n\n                this.sendToView('showPopup', {\n                    name: 'loader',\n                });\n\n                /** @type {Cell | null} */\n                const sentBoc = await this.showSendConfirm(\n                    {\n                        expireAt: expireAt,\n                        messages\n                    },\n                    needQueue\n                );\n\n                if (!sentBoc) {\n                    this.sendToView('closePopup');\n                    throw {\n                        message: 'Reject request',\n                        code: 300 // USER_REJECTS_ERROR\n                    }\n                }\n\n                return TonWeb.utils.bytesToBase64(await sentBoc.toBoc(false));\n\n            case 'ton_requestAccounts':\n                return (this.myAddress ? [this.myAddress] : []);\n            case 'ton_requestWallets':\n                if (!this.myAddress) {\n                    return [];\n                }\n                if (!this.publicKeyHex) {\n                    await this.requestPublicKey(needQueue);\n                }\n                const walletVersion = await storage.getItem('walletVersion');\n                return [{\n                    address: this.myAddress,\n                    publicKey: this.publicKeyHex,\n                    walletVersion: walletVersion\n                }];\n            case 'ton_getBalance':\n                await this.updateBalance();\n                return (this.balance ? this.balance.toString() : '');\n            case 'ton_sendTransaction':\n                const param = params[0];\n                await showExtensionWindow();\n\n                if (param.data) {\n                    if (param.dataType === 'hex') {\n                        param.data = TonWeb.utils.hexToBytes(param.data);\n                    } else if (param.dataType === 'base64') {\n                        param.data = TonWeb.utils.base64ToBytes(param.data);\n                    } else if (param.dataType === 'boc') {\n                        param.data = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(param.data));\n                    }\n                }\n                if (param.stateInit) {\n                    param.stateInit = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(param.stateInit));\n                }\n\n                this.sendToView('showPopup', {\n                    name: 'loader',\n                });\n\n                const result = await this.showSendConfirm(\n                    {\n                        messages: [{\n                            amount: new BN(param.value),\n                            toAddress: param.to,\n                            comment: param.data,\n                            needEncryptComment: false,\n                            stateInit: param.stateInit,\n                        }]\n                    },\n                    needQueue\n                );\n                if (!result) {\n                    this.sendToView('closePopup');\n                }\n                return !!result;\n            case 'ton_rawSign':\n                const signParam = params[0];\n                await showExtensionWindow();\n\n                return this.showSignConfirm(signParam.data, false, needQueue);\n            case 'flushMemoryCache':\n                await chrome.webRequest.handlerBehaviorChanged();\n                return true;\n            default:\n                throw {\n                    message: `Method \"${method}\" not implemented`,\n                    code: 400 // METHOD_NOT_SUPPORTED\n                };\n        }\n    }\n}\n\nconst controller = new Controller();\n\nif (IS_EXTENSION) {\n    chrome.runtime.onConnect.addListener(port => {\n        if (port.name === 'gramWalletContentScript') { // dapp\n            contentScriptPorts.add(port)\n            port.onMessage.addListener(async (msg, port) => {\n                if (msg.type === 'gramWalletAPI_ton_provider_connect') {\n                    controller.whenReady.then(() => {\n                        controller.initDapp();\n                    });\n                }\n\n                if (!msg.message) return;\n\n                const origin = decodeURIComponent(msg.message.origin);\n\n                let result = undefined;\n                let error = undefined;\n                try {\n                    result = await controller.onDappMessage(msg.message.method, msg.message.params, origin);\n                } catch (e) {\n                    console.error(e);\n                    error = {\n                        message: e.message,\n                        code: e.code || 0\n                    };\n                }\n                if (port) {\n                    port.postMessage(JSON.stringify({\n                        type: 'gramWalletAPI',\n                        message: {jsonrpc: '2.0', id: msg.message.id, method: msg.message.method, result, error}\n                    }));\n                }\n            });\n            port.onDisconnect.addListener(port => {\n                contentScriptPorts.delete(port)\n            })\n        } else if (port.name === 'gramWalletPopup') { // view\n            popupPort = port;\n            popupPort.onMessage.addListener(function (msg) {\n                if (msg.method === 'response') {\n                    const resolver = controller.pendingMessageResolvers.get(msg.id);\n                    if (resolver) {\n                        resolver(msg.result);\n                        controller.pendingMessageResolvers.delete(msg.id);\n                    }\n                } else {\n                    controller.onViewMessage(msg.method, msg.params);\n                }\n            });\n            popupPort.onDisconnect.addListener(() => {\n                popupPort = null;\n            });\n\n            const runQueueToPopup = () => {\n                queueToPopup.forEach(msg => popupPort.postMessage(msg));\n                queueToPopup.length = 0;\n            };\n\n            if (!controller.myAddress) { // if controller not initialized yet\n                runQueueToPopup();\n            }\n\n            controller.whenReady.then(async () => {\n                await controller.initView();\n                runQueueToPopup();\n            });\n        }\n    });\n\n    let actionApiName = 'action';\n    if (chrome.runtime.getManifest().manifest_version === 2) actionApiName = 'browserAction';\n\n    chrome[actionApiName].onClicked.addListener(showExtensionWindow);\n\n    chrome.windows.onRemoved.addListener(removedWindowId => {\n        if (dAppPromise) dAppPromise.resolve(false);\n\n        if (removedWindowId !== extensionWindowId) return;\n        extensionWindowId = -1;\n    });\n}\n"
  },
  {
    "path": "src/js/extension/background.js",
    "content": "if(typeof importScripts !== 'function') {\n    const injectScript = path => {\n        return new Promise(resolve => {\n            const scriptTag = document.createElement('script');\n            scriptTag.setAttribute('src', path);\n            scriptTag.addEventListener('load', resolve);\n            document.body.appendChild(scriptTag);\n        });\n    };\n\n    window.importScripts = async (...scripts) => {\n        for (const path of scripts) {\n            await injectScript(path);\n        }\n    };\n}\n\nimportScripts(\n    '/libs/aes-js-3.1.2.js',\n    '/libs/noble-ed25519-1.7.3.js',\n    '/libs/tonweb.min.js',\n    '/libs/tonweb-mnemonic.min.js',\n    '/js/Controller.js',\n);\n"
  },
  {
    "path": "src/js/extension/content.js",
    "content": "const container = document.head || document.documentElement;\nconst scriptTag = document.createElement('script');\nscriptTag.async = false;\nscriptTag.src = chrome.runtime.getURL('/js/extension/provider.js');\ncontainer.insertBefore(scriptTag, container.children[0]);\ncontainer.removeChild(scriptTag);\n\nconst onPortMessage = data => {\n    self.postMessage(data, '*'); // todo: origin\n};\n\nconst onPageMessage = e => {\n    if (!e.data) return;\n    if (e.data.type !== 'gramWalletAPI_ton_provider_write' &&\n        e.data.type !== 'gramWalletAPI_ton_provider_connect') return;\n\n    sendMessageToActivePort(e.data);\n};\n\nconst PORT_NAME = 'gramWalletContentScript'\nlet port = chrome.runtime.connect({ name: PORT_NAME });\nport.onMessage.addListener(onPortMessage);\n\nconst sendMessageToActivePort = (payload, isRepeat = false) => {\n    try {\n        port.postMessage(payload);\n    } catch (err) {\n        const isInvalidated = err.message.toString().includes('Extension context invalidated');\n        if (isInvalidated) {\n            self.removeEventListener('message', onPageMessage);\n            return;\n        }\n\n        const isDisconnected = err.message.toString().includes('disconnected port');\n\n        if (!isRepeat && isDisconnected) {\n            port = chrome.runtime.connect({name: PORT_NAME});\n            port.onMessage.addListener(onPortMessage);\n            sendMessageToActivePort(payload, true);\n        } else {\n            onPortMessage(JSON.stringify({\n                type: 'gramWalletAPI',\n                message: {\n                    id: payload?.message?.id,\n                    method: payload?.message?.method,\n                    error: { message: err.message },\n                    jsonrpc: true,\n                }\n            }));\n        }\n    }\n}\n\nself.addEventListener('message', onPageMessage);\n"
  },
  {
    "path": "src/js/extension/provider.js",
    "content": "// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#sample-class-implementation\n(() => {\n    class TonProvider {\n        constructor() {\n            this.listeners = window.ton ? window.ton.listeners : {};\n\n            this.isTonWallet = true;\n            this.targetOrigin = '*'; // todo\n\n            // Init storage\n            this._nextJsonRpcId = window.ton ? window.ton._nextJsonRpcId : 0;\n            this._promises = window.ton ? window.ton._promises : {};\n            // todo: take `listeners` from previous window.ton ?\n\n            // Fire the connect\n            this._connect();\n\n            if (window.ton) window.ton._destroy();\n\n            // Listen for jsonrpc responses\n            this._onMessage = this._handleJsonRpcMessage.bind(this);\n            window.addEventListener('message', this._onMessage);\n        }\n\n        /* EventEmitter */\n\n        on(method, listener) {\n            let methodListeners = this.listeners[method];\n            if (!methodListeners) {\n                methodListeners = [];\n                this.listeners[method] = methodListeners;\n            }\n            if (methodListeners.indexOf(listener) === -1) {\n                methodListeners.push(listener);\n            }\n            return this;\n        }\n\n        removeListener(method, listener) {\n            const methodListeners = this.listeners[method];\n            if (!methodListeners) return;\n            const index = methodListeners.indexOf(listener);\n            if (index > -1) {\n                methodListeners.splice(index, 1);\n            }\n        }\n\n        emit(method, ...args) {\n            const methodListeners = this.listeners[method];\n            if (!methodListeners || !methodListeners.length) return false;\n            methodListeners.forEach(listener => listener(...args));\n            return true;\n        }\n\n        /* Methods */\n\n        send(method, params = []) {\n            if (!method || typeof method !== 'string') {\n                return new Error('Method is not a valid string.');\n            }\n\n            if (!(params instanceof Array)) {\n                return new Error('Params is not a valid array.');\n            }\n\n            const id = this._nextJsonRpcId++;\n            const jsonrpc = '2.0';\n            const payload = {\n                jsonrpc,\n                id,\n                method,\n                params,\n                origin: window.origin\n            };\n\n            const promise = new Promise((resolve, reject) => {\n                this._promises[payload.id] = {\n                    resolve,\n                    reject,\n                };\n            });\n\n            // Send jsonrpc request to TON Wallet\n            window.postMessage(\n                {\n                    type: 'gramWalletAPI_ton_provider_write',\n                    message: payload,\n                },\n                this.targetOrigin,\n            );\n\n            return promise;\n        }\n\n        /* Internal methods */\n\n        async _handleJsonRpcMessage(event) {\n            // Return if no data to parse\n            if (!event || !event.data) {\n                return;\n            }\n\n            let data;\n            try {\n                data = JSON.parse(event.data);\n            } catch (error) {\n                // Return if we can't parse a valid object\n                return;\n            }\n\n            if (data.type !== 'gramWalletAPI') return;\n\n            // Return if not a jsonrpc response\n            if (!data || !data.message || !data.message.jsonrpc) {\n                return;\n            }\n\n            const message = data.message;\n            const {\n                id,\n                method,\n                error,\n                result,\n            } = message;\n\n            if (typeof id !== 'undefined') {\n                const promise = this._promises[id];\n                if (promise) {\n                    // Handle pending promise\n                    if (data.type === 'error') {\n                        promise.reject(message);\n                    } else if (message.error) {\n                        promise.reject(error);\n                    } else {\n                        promise.resolve(result);\n                    }\n                    delete this._promises[id];\n                }\n            } else {\n                if (method) {\n                    if (method.indexOf('_subscription') > -1) {\n                        // Emit subscription notification\n                        this._emitNotification(message.params);\n                    } else if (method === 'ton_accounts') { // todo\n                        this._emitAccountsChanged(message.params);\n                    } else if (method === 'ton_doMagic') {\n                        const isTurnedOn = message.params;\n\n                        if (!location.href.startsWith('https://web.telegram.org/z/')) {\n                            if (location.href.startsWith('https://web.telegram.org/k/')) {\n                                toggleMagicBadge(isTurnedOn);\n                            }\n\n                            return;\n                        }\n\n                        if (isTurnedOn) {\n                            const scriptEl = document.querySelector('script[src^=\"main.\"]');\n                            const localRevision = scriptEl.getAttribute('src');\n\n                            const filesToInjectResponse = await fetch('https://ton.org/app/magic-sources.json?' + Date.now());\n                            const filesToInject = await filesToInjectResponse.json();\n                            const magicRevision = filesToInject.find(f => f.startsWith('main.') && f.endsWith('.js'));\n\n                            const assetCache = await window.caches.open('tt-assets');\n                            const cachedResponse = await assetCache.match(localRevision);\n                            if (cachedResponse) {\n                                const cachedText = await cachedResponse.text();\n                                // we leverage the fact that the file has its name as part of the sourcemaps appendix\n                                const isMagicInjected = cachedText?.endsWith(magicRevision + '.map');\n                                if (isMagicInjected) {\n                                    return;\n                                }\n                            }\n\n                            addBadge('Loading <strong>TON magic</strong>...');\n\n                            const responses = await Promise.all(filesToInject.map(async (fileName) => {\n                                const res = await fetch('https://ton.org/app/' + fileName);\n\n                                if (res.status !== 200) {\n                                    throw new Error('[TON Wallet] Failed to load magic: ' + res.statusText + '. File: ' + fileName);\n                                }\n\n                                return [\n                                    fileName,\n                                    new Response(await res.blob(), {\n                                        headers: res.headers,\n                                        status: res.status,\n                                        statusText: res.statusText,\n                                    }),\n                                ];\n                            }));\n\n                            await Promise.all(responses.map(async ([fileName, response]) => {\n                                if (fileName.startsWith('main.')) {\n                                    if (fileName.endsWith('.js')) {\n                                        await assetCache.put('https://web.telegram.org/z/' + localRevision, response.clone());\n                                    } else if (fileName.endsWith('.css')) {\n                                        const linkEl = document.querySelector('link[rel=stylesheet]');\n                                        const currentCssRevision = linkEl.getAttribute('href');\n                                        await assetCache.put('https://web.telegram.org/z/' + currentCssRevision, response.clone());\n                                    }\n                                } else {\n                                    await assetCache.put('https://web.telegram.org/z/' + fileName, response.clone());\n                                }\n                            }));\n\n                            localStorage.setItem('ton:magicRevision', magicRevision);\n\n                            await this.send('flushMemoryCache');\n                            window.location.reload();\n                        } else {\n                            const prevMagicRevision = localStorage.getItem('ton:magicRevision');\n                            if (!prevMagicRevision) {\n                                return;\n                            }\n\n                            localStorage.removeItem('ton:magicRevision');\n                            await window.caches.delete('tt-assets');\n\n                            await this.send('flushMemoryCache');\n                            window.location.reload();\n                        }\n                    }\n                }\n            }\n        }\n\n        /* Connection handling */\n\n        _connect() {\n            // Send to TON Wallet\n            window.postMessage(\n                {type: 'gramWalletAPI_ton_provider_connect'},\n                this.targetOrigin,\n            );\n\n            // Reconnect on close\n            // this.once('close', this._connect.bind(this)); todo\n        }\n\n        _destroy() {\n            window.removeEventListener('message', this._onMessage);\n        }\n\n        /* Events */\n\n        _emitNotification(result) {\n            this.emit('notification', result);\n        }\n\n        _emitConnect() {\n            this.emit('connect');\n        }\n\n        _emitClose(code, reason) {\n            this.emit('close', code, reason);\n        }\n\n        _emitChainChanged(chainId) {\n            this.emit('chainChanged', chainId);\n        }\n\n        _emitAccountsChanged(accounts) {\n            this.emit('accountsChanged', accounts);\n        }\n    };\n\n    // TONCONNECT\n\n    function tonConnectEventError(message, code) {\n        return {\n            event: 'connect_error',\n            id: Date.now(),\n            payload: {\n                code: code,\n                message: message\n            }\n        }\n    }\n\n    class TonConnectBridge {\n        constructor(provider, prevBridge) {\n            this.provider = provider;\n\n            provider.on('chainChanged', () => {\n                this.notify({\n                    event: 'disconnect',\n                    id: Date.now(),\n                    payload: {}\n                })\n            });\n\n            this.callbacks = prevBridge?.tonconnect ? prevBridge?.tonconnect.callbacks : [];\n\n            this.deviceInfo = {\n                platform: 'web',\n                appName: 'tonwallet',\n                appVersion: '1.1.50',\n                maxProtocolVersion: 2,\n                features: [\n                    'SendTransaction',\n                    {\n                        name: 'SendTransaction',\n                        maxMessages: 4,\n                    },\n                ],\n            };\n\n            this.walletInfo = {\n                name: 'TON Wallet',\n                image: 'https://wallet.ton.org/assets/ui/qr-logo.png',\n                about_url: 'https://wallet.ton.org',\n            }\n\n            this.protocolVersion = 2;\n            this.isWalletBrowser = false;\n        }\n\n        async connect(protocolVersion, message) {\n            if (protocolVersion > this.protocolVersion) {\n                return this.notify(\n                    tonConnectEventError('Unsupported protocol version', 1)\n                );\n            }\n\n            try {\n                const items = await this.provider.send(\n                    'tonConnect_connect',\n                    [message]\n                );\n\n                return this.notify({\n                    event: 'connect',\n                    id: Date.now(),\n                    payload: {\n                        items: items,\n                        device: this.deviceInfo\n                    }\n                });\n            } catch (e) {\n                return this.notify(\n                    tonConnectEventError(e?.message || 'Unknown error', 0)\n                );\n            }\n        }\n\n        async disconnect() {\n            await this.provider.send('tonConnect_disconnect', []);\n            return this.notify({\n                event: 'disconnect',\n                id: Date.now(),\n                payload: {}\n            })\n        }\n\n        async restoreConnection() {\n            try {\n                const items = await this.provider.send('tonConnect_reconnect', [{name: 'ton_addr'}]);\n\n                return this.notify({\n                    event: 'connect',\n                    id: Date.now(),\n                    payload: {\n                        items: items,\n                        device: this.deviceInfo\n                    }\n                })\n            } catch (e) {\n                return this.notify(\n                    tonConnectEventError(e?.message || 'Unknown error', 0)\n                );\n            }\n        }\n\n        async send(message) {\n            try {\n                const result = await this.provider.send(\n                    'tonConnect_' + message.method,\n                    message.params.map(param => JSON.parse(param))\n                );\n                return {\n                    result,\n                    id: String(message.id)\n                }\n            } catch (e) {\n                return {\n                    error: {\n                        message: e?.message || 'Unknown error',\n                        code: 0 // unknown error\n                    },\n                    id: String(message.id)\n                }\n            }\n        }\n\n        listen(callback) {\n            this.callbacks.push(callback);\n            const callbacks = this.callbacks;\n            return () => {\n                const index = callbacks.indexOf(callback);\n                if (index > -1) {\n                    callbacks.splice(index, 1);\n                }\n            }\n        }\n\n        async notify(event) {\n            this.callbacks.forEach(callback => callback(event));\n            return event;\n        }\n    }\n\n    // START\n\n    const havePrevInstance = !!window.ton;\n    window.tonProtocolVersion = 1;\n    window.ton = new TonProvider();\n    if (!havePrevInstance) window.dispatchEvent(new Event('tonready'));\n\n    window.tonwallet = {\n        provider: window.ton,\n        tonconnect: new TonConnectBridge(window.ton, window.tonwallet)\n    }\n\n    function toggleMagicBadge(isTurnedOn) {\n        if (isTurnedOn) {\n            addBadge('Switch to <strong>Z version</strong> in the menu to take advantage of <strong>TON magic</strong>.');\n\n            // handle shallow screen layout\n            document.getElementById('column-left').style.top = '28px';\n            document.getElementById('column-center').style.top = '28px';\n        } else {\n            const badge = document.getElementById('ton-magic-badge');\n            if (badge) {\n                badge.remove();\n                document.getElementById('column-left').style.top = '';\n                document.getElementById('column-center').style.top = '';\n            }\n        }\n    }\n\n    function addBadge(html) {\n        const badge = document.createElement('div');\n        badge.id = 'ton-magic-badge';\n        badge.style.position = 'fixed';\n        badge.style.zIndex = '999';\n        badge.style.top = '0';\n        badge.style.background = '#0072ab';\n        badge.style.width = '100%';\n        badge.style.height = '28px';\n        badge.style.lineHeight = '28px';\n        badge.style.textAlign = 'center';\n        badge.style.fontSize = '14px';\n        badge.style.color = 'white';\n        badge.innerHTML = html;\n        document.body.prepend(badge);\n    }\n})();\n"
  },
  {
    "path": "src/js/util/encryption.js",
    "content": "// This JS library implements TON message comment encryption and decryption for Web\n// Reference C++ code - SimpleEncryptionV2 - https://github.com/ton-blockchain/ton/blob/cc0eb453cb3bf69f92693160103d33112856c056/tonlib/tonlib/keys/SimpleEncryption.cpp#L110\n// Dependencies:\n// - TonWeb 0.0.60\n// - aes-js - 3.1.2 - https://github.com/ricmoo/aes-js/releases/tag/v3.1.2 - for aes-cbc without padding\n// - noble-ed25519 - 1.7.3 - // https://github.com/paulmillr/noble-ed25519/releases/tag/1.7.3 - for getSharedKey\n\nconst ed25519 = self.nobleEd25519;\n\n/**\n * @param key {Uint8Array}\n * @param data {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst hmac_sha512 = async (key, data) => {\n    const hmacAlgo = {name: \"HMAC\", hash: \"SHA-512\"};\n    /** @type {CryptoKey} */\n    const hmacKey = await self.crypto.subtle.importKey(\"raw\", key, hmacAlgo, false, [\"sign\"]);\n    /** @type {ArrayBuffer} */\n    const signature = await self.crypto.subtle.sign(hmacAlgo, hmacKey, data);\n    const result = new Uint8Array(signature);\n    if (result.length !== 512 / 8) throw new Error();\n    return result;\n}\n\n/**\n * @param hash  {Uint8Array}\n * @return {Promise<any>} aesjs.ModeOfOperation.cbc\n */\nconst getAesCbcState = async (hash) => {\n    if (hash.length < 48) throw new Error();\n    const key = hash.slice(0, 32);\n    const iv = hash.slice(32, 32 + 16);\n\n    // Note that native crypto.subtle AES-CBC not suitable here because\n    // even if the data IS a multiple of 16 bytes, padding will still be added\n    // So we use aes-js\n\n    return new aesjs.ModeOfOperation.cbc(key, iv);\n}\n\n/**\n * @param dataLength    {number}\n * @param minPadding    {number}\n * @return {Uint8Array}\n */\nconst getRandomPrefix = (dataLength, minPadding) => {\n    const prefixLength = ((minPadding + 15 + dataLength) & -16) - dataLength;\n    /** @type {Uint8Array} */\n    const prefix = self.crypto.getRandomValues(new Uint8Array(prefixLength));\n    prefix[0] = prefixLength;\n    if ((prefixLength + dataLength) % 16 !== 0) throw new Error();\n    return prefix;\n}\n\n/**\n * @param a {Uint8Array}\n * @param b {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst combineSecrets = async (a, b) => {\n    return hmac_sha512(a, b);\n}\n\n/**\n * @param data  {Uint8Array}\n * @param sharedSecret {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst encryptDataWithPrefix = async (data, sharedSecret, salt) => {\n    if (data.length % 16 !== 0) throw new Error();\n    /** @type {Uint8Array} */\n    const dataHash = await combineSecrets(salt, data);\n    /** @type {Uint8Array} */\n    const msgKey = dataHash.slice(0, 16);\n\n    const res = new Uint8Array(data.length + 16);\n    res.set(msgKey, 0);\n\n    /** @type {Uint8Array} */\n    const cbcStateSecret = await combineSecrets(sharedSecret, msgKey);\n    /** @type {Uint8Array} */\n    const encrypted = (await getAesCbcState(cbcStateSecret)).encrypt(data);\n    res.set(encrypted, 16);\n\n    return res;\n}\n\n/**\n * @param data  {Uint8Array}\n * @param sharedSecret {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst encryptDataImpl = async (data, sharedSecret, salt) => {\n    /** @type {Uint8Array} */\n    const prefix = await getRandomPrefix(data.length, 16);\n    const combined = new Uint8Array(prefix.length + data.length);\n    combined.set(prefix, 0);\n    combined.set(data, prefix.length);\n    return encryptDataWithPrefix(combined, sharedSecret, salt);\n}\n\n/**\n * @param data  {Uint8Array}\n * @param myPublicKey {Uint8Array}\n * @param theirPublicKey {Uint8Array}\n * @param privateKey    {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nexport const encryptData = async (data, myPublicKey, theirPublicKey, privateKey, salt) => {\n    /** @type {Uint8Array} */\n    const sharedSecret = await ed25519.getSharedSecret(privateKey, theirPublicKey);\n\n    /** @type {Uint8Array} */\n    const encrypted = await encryptDataImpl(data, sharedSecret, salt);\n    const prefixedEncrypted = new Uint8Array(myPublicKey.length + encrypted.length);\n    for (let i = 0; i < myPublicKey.length; i++) {\n        prefixedEncrypted[i] = theirPublicKey[i] ^ myPublicKey[i];\n    }\n    prefixedEncrypted.set(encrypted, myPublicKey.length);\n    return prefixedEncrypted;\n}\n\n/**\n * @param bytes {Uint8Array}\n * @return {Cell}\n */\nexport const makeSnakeCells = (bytes) => {\n    const ROOT_CELL_BYTE_LENGTH = 35 + 4;\n    const CELL_BYTE_LENGTH = 127;\n    /** @type {Cell} */\n    const root = new TonWeb.boc.Cell();\n    root.bits.writeBytes(bytes.slice(0, Math.min(bytes.length, ROOT_CELL_BYTE_LENGTH)));\n\n    const cellCount = Math.ceil((bytes.length - ROOT_CELL_BYTE_LENGTH) / CELL_BYTE_LENGTH);\n    if (cellCount > 16) {\n        throw new Error('Text too long');\n    }\n\n    /** @type {Cell} */\n    let cell = root;\n    for (let i = 0; i < cellCount; i++) {\n        /** @type {Cell} */\n        const prevCell = cell;\n        cell = new TonWeb.boc.Cell();\n        const cursor = ROOT_CELL_BYTE_LENGTH + i * CELL_BYTE_LENGTH;\n        cell.bits.writeBytes(bytes.slice(cursor, Math.min(bytes.length, cursor + CELL_BYTE_LENGTH)));\n        prevCell.refs[0] = cell;\n    }\n\n    return root;\n}\n\n/**\n * @param cell  {Cell}\n * @return {Uint8Array}\n */\nexport const parseSnakeCells = (cell) => {\n    /** @type {Cell} */\n   let c = cell;\n    /** @type {Uint8Array} */\n   let result = new Uint8Array(0);\n   while (c) {\n       /** @type {Uint8Array} */\n       const newResult = new Uint8Array(result.length + c.bits.array.length);\n       newResult.set(result);\n       newResult.set(c.bits.array, result.length);\n\n       result = newResult;\n       c = c.refs[0];\n   }\n   return result;\n}\n\n/**\n * @param comment   {string}\n * @param myPublicKey   {Uint8Array}\n * @param theirPublicKey    {Uint8Array}\n * @param myPrivateKey  {Uint8Array}\n * @param senderAddress   {string | Address}\n * @return {Promise<Cell>} full message binary payload with 0x2167da4b prefix\n */\nexport const encryptMessageComment = async (comment, myPublicKey, theirPublicKey, myPrivateKey, senderAddress) => {\n    if (!comment || !comment.length) throw new Error('empty comment');\n\n    if (myPrivateKey.length === 64) {\n        myPrivateKey = myPrivateKey.slice(0, 32); // convert nacl private key\n    }\n\n    /** @type {Uint8Array} */\n    const commentBytes = new TextEncoder().encode(comment);\n\n    /** @type {Uint8Array} */\n    const salt = new TextEncoder().encode(new TonWeb.utils.Address(senderAddress).toString(true, true, true, false));\n\n    /** @type {Uint8Array} */\n    const encryptedBytes = await encryptData(commentBytes, myPublicKey, theirPublicKey, myPrivateKey, salt);\n\n    const payload = new Uint8Array(encryptedBytes.length + 4);\n    payload[0] = 0x21; // encrypted text prefix\n    payload[1] = 0x67;\n    payload[2] = 0xda;\n    payload[3] = 0x4b;\n    payload.set(encryptedBytes, 4);\n\n    return makeSnakeCells(payload);\n}\n\n/**\n * @param cbcStateSecret {Uint8Array}\n * @param msgKey {Uint8Array}\n * @param encryptedData {Uint8Array}\n * @param salt {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst doDecrypt = async (cbcStateSecret, msgKey, encryptedData, salt) => {\n    /** @type {Uint8Array} */\n    const decryptedData = (await getAesCbcState(cbcStateSecret)).decrypt(encryptedData);\n    /** @type {Uint8Array} */\n    const dataHash = await combineSecrets(salt, decryptedData);\n    /** @type {Uint8Array} */\n    const gotMsgKey = dataHash.slice(0, 16);\n    if (msgKey.join(',') !== gotMsgKey.join(',')) {\n        throw new Error('Failed to decrypt: hash mismatch')\n    }\n    const prefixLength = decryptedData[0];\n    if (prefixLength > decryptedData.length || prefixLength < 16) {\n        throw new Error('Failed to decrypt: invalid prefix size');\n    }\n    return decryptedData.slice(prefixLength);\n}\n\n/**\n * @param encryptedData {Uint8Array}\n * @param sharedSecret {Uint8Array}\n * @param salt {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nconst decryptDataImpl = async (encryptedData, sharedSecret, salt) => {\n    if (encryptedData.length < 16) throw new Error('Failed to decrypt: data is too small');\n    if (encryptedData.length % 16 !== 0) throw new Error('Failed to decrypt: data size is not divisible by 16');\n    /** @type {Uint8Array} */\n    const msgKey = encryptedData.slice(0, 16);\n    /** @type {Uint8Array} */\n    const data = encryptedData.slice(16);\n    /** @type {Uint8Array} */\n    const cbcStateSecret = await combineSecrets(sharedSecret, msgKey);\n    /** @type {Uint8Array} */\n    const res = await doDecrypt(cbcStateSecret, msgKey, data, salt);\n    return res;\n}\n\n/**\n * @param data  {Uint8Array}\n * @param publicKey  {Uint8Array}\n * @param privateKey  {Uint8Array}\n * @param salt  {Uint8Array}\n * @return {Promise<Uint8Array>}\n */\nexport const decryptData = async (data, publicKey, privateKey, salt) => {\n    if (data.length < publicKey.length) {\n        throw new Error('Failed to decrypt: data is too small');\n    }\n    const theirPublicKey = new Uint8Array(publicKey.length);\n    for (let i = 0; i < publicKey.length; i++) {\n        theirPublicKey[i] = data[i] ^ publicKey[i];\n    }\n    /** @type {Uint8Array} */\n    const sharedSecret = await ed25519.getSharedSecret(privateKey, theirPublicKey);\n\n    /** @type {Uint8Array} */\n    const decrypted = await decryptDataImpl(data.slice(publicKey.length), sharedSecret, salt);\n    return decrypted;\n}\n\n/**\n * @param encryptedData {Uint8Array}    encrypted data without 0x2167da4b prefix\n * @param myPublicKey   {Uint8Array}\n * @param myPrivateKey  {Uint8Array}\n * @param senderAddress   {string | Address}\n * @return {Promise<string>}    decrypted text comment\n */\nexport const decryptMessageComment = async (encryptedData, myPublicKey, myPrivateKey, senderAddress) => {\n    if (myPrivateKey.length === 64) {\n        myPrivateKey = myPrivateKey.slice(0, 32); // convert nacl private key\n    }\n\n    /** @type {Uint8Array} */\n    const salt = new TextEncoder().encode(new TonWeb.utils.Address(senderAddress).toString(true, true, true, false));\n\n    /** @type {Uint8Array} */\n    const decryptedBytes = await decryptData(encryptedData, myPublicKey, myPrivateKey, salt);\n    return new TextDecoder().decode(decryptedBytes);\n}"
  },
  {
    "path": "src/js/util/storage.js",
    "content": "/**\n *  `localStorage` polyfill for Chrome Extension environment\n */\n\nexport default self.localStorage || {\n    /**\n     * @param key   {string}\n     * @param value {string}\n     * @return {Promise<void>}\n     */\n    setItem(key, value) {\n        return chrome.storage.local.set({[key]: value});\n    },\n\n    /**\n     * @param key   {string}\n     * @return {Promise<string | null>}\n     */\n    getItem(key) {\n        return chrome.storage.local.get(key)\n            .then(({[key]: value}) => value);\n    },\n\n    /**\n     * @param key   {string}\n     * @return {Promise<void>}\n     */\n    removeItem(key) {\n        return chrome.storage.local.remove(key);\n    },\n\n    /**\n     * @return {Promise<void>}\n     */\n    clear() {\n        return chrome.storage.local.clear();\n    },\n};\n"
  },
  {
    "path": "src/js/view/DropDown.js",
    "content": "import {clearElement, createElement, toggle} from \"./Utils.js\";\n\nexport default class DropDown {\n    /**\n     * @param container {HTMLElement}\n     * @param onEnter   {(input: HTMLInputElement) => void}\n     * @param mnemonicWords {string[]}\n     */\n    constructor(container, onEnter, mnemonicWords) {\n        /** @type {HTMLElement} */\n        this.container = container;\n        /** @type {(input: HTMLInputElement) => void} */\n        this.onEnter = onEnter;\n        /** @type {string[]} */\n        this.mnemonicWords = mnemonicWords;\n        /** @type {number} */\n        this.selectedI = -1;\n    }\n\n    /**\n     * @param input {HTMLInputElement}\n     * @param text  {string}\n     */\n    show(input, text) {\n        clearElement(this.container);\n\n        /**\n         * @param e {MouseEvent}\n         */\n        const onMouseDown = e => {\n            input.value = e.target.innerText;\n            input.classList.remove('error');\n            this.hide();\n            e.preventDefault();\n            this.onEnter(input);\n        };\n\n        this.mnemonicWords\n            .filter(w => w.indexOf(text) === 0)\n            .forEach(w => {\n                const item = createElement({tag: 'div', clazz: 'words-popup-item', text: w});\n                item.addEventListener('mousedown', onMouseDown);\n                this.container.appendChild(item);\n            });\n\n        this.selectedI = -1;\n        if (this.container.children.length > 0) this.select(0);\n\n        this.container.style.left = input.offsetLeft + 'px';\n        this.container.style.top = (input.offsetTop + input.offsetHeight) + 'px';\n        toggle(this.container, true);\n    };\n\n    hide() {\n        toggle(this.container, false);\n        clearElement(this.container);\n        this.selectedI = -1;\n    }\n\n    /**\n     * @param i {number}\n     */\n    select(i) {\n        if (this.selectedI > -1) {\n            this.container.children[this.selectedI].classList.remove('selected');\n        }\n        this.selectedI = i;\n        if (this.selectedI > -1) {\n            this.container.children[this.selectedI].classList.add('selected');\n            const ITEM_HEIGHT = 30;\n            this.container.scrollTo(0, ITEM_HEIGHT * this.selectedI);\n        }\n    }\n\n    /**\n     * @return {null | string}\n     */\n    getSelectedText() {\n        if (this.selectedI === -1) return null;\n        return this.container.children[this.selectedI].innerText;\n    }\n\n    up() {\n        if (this.selectedI === -1) return;\n\n        if (this.selectedI > 0) {\n            this.select(this.selectedI - 1);\n        }\n    }\n\n    down() {\n        if (this.selectedI === -1) return;\n\n        if (this.selectedI < this.container.children.length - 1) {\n            this.select(this.selectedI + 1);\n        }\n    }\n}\n"
  },
  {
    "path": "src/js/view/Lottie.js",
    "content": "import {$$} from \"./Utils.js\";\n\n/**\n * @type {Object<string, any>} lottie name -> lottie element\n */\nconst lotties = {};\n\n/**\n * @param div   {HTMLElement}\n * @return {Promise<void>}\n */\nfunction initLottie(div) {\n    return new Promise((resolve, reject) => {\n        const url = div.getAttribute('src');\n        const name = div.getAttribute('data-name');\n        const w = Number(div.getAttribute('width'));\n        const h = Number(div.getAttribute('height'));\n\n        const xmlHttp = new XMLHttpRequest();\n        xmlHttp.responseType = 'arraybuffer';\n        xmlHttp.onreadystatechange = function () {\n            if (xmlHttp.readyState === 4) {\n                if (xmlHttp.status === 200) {\n                    const canvas = document.createElement('canvas');\n                    canvas.setAttribute('width', w * window.devicePixelRatio);\n                    canvas.setAttribute('height', h * window.devicePixelRatio);\n                    canvas.style.width = w + 'px';\n                    canvas.style.height = h + 'px';\n                    div.appendChild(canvas);\n                    const ctx = canvas.getContext('2d');\n\n                    const animationData = JSON.parse(new TextDecoder('utf-8').decode(pako.inflate(xmlHttp.response)));\n                    lotties[name] = {\n                        ctx: ctx,\n                        player: lottie.loadAnimation({\n                            renderer: 'canvas',\n                            loop: name === 'processing' || name === 'start' || name === 'about' || name === 'symbol',\n                            autoplay: false,\n                            animationData,\n                            rendererSettings: {\n                                context: ctx,\n                                scaleMode: 'noScale',\n                                clearCanvas: true\n                            },\n                        })\n                    };\n                    ctx.clearRect(0, 0, 1000, 1000);\n                    resolve();\n                } else {\n                    reject();\n                }\n            }\n        };\n        xmlHttp.open(\"GET\", url, true);\n        xmlHttp.send(null);\n    });\n}\n\n/**\n * @return {Promise<void>}\n */\nasync function initLotties() {\n    const divs = $$('tgs-player');\n    for (let i = 0; i < divs.length; i++) {\n        try {\n            await initLottie(divs[i]);\n        } catch (e) {\n        }\n    }\n}\n\n/**\n * @param lottie?   {any}\n * @param visible   {boolean}\n * @param params?    {{hideDelay?: number}}\n */\nfunction toggleLottie(lottie, visible, params) {\n    if (!lottie) return;\n\n    params = params || {};\n    clearTimeout(lottie.hideTimeout);\n    if (visible) {\n        lottie.player.play();\n    } else {\n        lottie.player.stop();\n\n        if (params.hideDelay) {\n            lottie.hideTimeout = setTimeout(() => {\n                lottie.ctx.clearRect(0, 0, 1000, 1000);\n            }, params.hideDelay);\n        } else {\n            lottie.ctx.clearRect(0, 0, 1000, 1000);\n        }\n    }\n}\n\nexport {initLotties, toggleLottie, lotties};"
  },
  {
    "path": "src/js/view/Utils.js",
    "content": "// UI Utils\n\n/**\n * @param selector  {string}\n * @return {HTMLElement | null}\n */\nfunction $(selector) {\n    return document.querySelector(selector);\n}\n\n/**\n * @param selector  {string}\n * @return {NodeListOf<HTMLElement>}\n */\nfunction $$(selector) {\n    return document.querySelectorAll(selector);\n}\n\n/**\n * @param div   {HTMLElement}\n * @param visible {boolean | 'none' | 'block' | 'flex' | 'inline-block'}\n */\nfunction toggle(div, visible) {\n    let d = visible;\n    if (visible === true) d = 'block';\n    if (visible === false) d = 'none';\n\n    div.style.display = d;\n}\n\n/**\n * @param div   {HTMLElement}\n * @param isVisible {boolean}\n * @param params?    {{isBack?: boolean}}\n */\nfunction toggleFaded(div, isVisible, params) {\n    params = params || {};\n    if (params.isBack) {\n        div.classList.add('isBack');\n    } else {\n        div.classList.remove('isBack');\n    }\n    if (isVisible) {\n        div.classList.add('faded-show');\n        div.classList.remove('faded-hide');\n    } else {\n        div.classList.remove('faded-show');\n        div.classList.add('faded-hide');\n    }\n}\n\n/**\n * @param div   {HTMLElement}\n * @param className {string}\n * @param duration  {number}\n */\nfunction triggerClass(div, className, duration) {\n    div.classList.add(className);\n\n    setTimeout(() => {\n        div.classList.remove(className);\n    }, duration);\n}\n\n/**\n * @param params    {{tag: string, clazz?: string | (string | undefined)[], text?: string, child?: (HTMLElement | undefined)[], style?: Object<string, string>}}\n * @return {HTMLElement}\n */\nfunction createElement(params) {\n    const item = document.createElement(params.tag);\n    if (params.clazz) {\n        if (Array.isArray(params.clazz)) {\n            for (let c of params.clazz) {\n                if (c) {\n                    item.classList.add(c);\n                }\n            }\n        } else {\n            item.classList.add(params.clazz);\n        }\n    }\n    if (params.text) item.innerText = params.text;\n    if (params.child) {\n        for (let c of params.child) {\n            if (c) {\n                item.appendChild(c);\n            }\n        }\n    }\n    if (params.style) {\n        for (let key in params.style) {\n            item.style[key] = params.style[key];\n        }\n    }\n    return item;\n}\n\n/**\n * @param el {HTMLElement}\n * @param s  {string}\n * @return {HTMLElement}\n */\nfunction setAddr(el, s) {\n    el.innerHTML = '';\n    el.appendChild(document.createTextNode(s.substring(0, s.length / 2)));\n    el.appendChild(document.createElement('wbr'));\n    el.appendChild(document.createTextNode(s.substring(s.length / 2)));\n    return el;\n}\n\n/**\n * @param el    {HTMLElement}\n */\nfunction clearElement(el) {\n    el.innerHTML = '';\n}\n\n/**\n * @param input {HTMLElement}\n * @param handler   {(e: Event) => void}\n */\nfunction onInput(input, handler) {\n    input.addEventListener('change', handler);\n    input.addEventListener('input', handler);\n    input.addEventListener('cut', handler);\n    input.addEventListener('paste', handler);\n}\n\n/**\n * @param n {number}\n * @return {string}\n */\nfunction doubleZero(n) {\n    if (n < 10) return '0' + n;\n    return n.toString();\n}\n\n/**\n * @param date  {Date}\n * @return {string}\n */\nfunction formatTime(date) {\n    return doubleZero(date.getHours()) + ':' + doubleZero(date.getMinutes());\n}\n\nconst MONTH_NAMES = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\n\n/**\n * @param date  {Date}\n * @return {string}\n */\nfunction formatDate(date) {\n    return MONTH_NAMES[date.getMonth()] + ' ' + date.getDate();\n}\n\n/**\n * @param date  {Date}\n * @return {string}\n */\nfunction formatDateFull(date) {\n    return date.toString();\n}\n\n/**\n * @param text  {string}\n * @return {boolean}\n */\nfunction copyToClipboard(text) {\n    /** @type {HTMLTextAreaElement} */\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";  //avoid scrolling to bottom\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n\n    /** @type {boolean} */\n    let result = false;\n    try {\n        result = document.execCommand('copy');\n    } catch (err) {\n    }\n\n    document.body.removeChild(textArea);\n    return result;\n}\n\nconst IMPORT_WORDS_COUNT = 24;\nconst CONFIRM_WORDS_COUNT = 3;\n\nexport {\n    $,\n    $$,\n    toggle,\n    toggleFaded,\n    triggerClass,\n    createElement,\n    clearElement,\n    onInput,\n    setAddr,\n    doubleZero,\n    formatTime,\n    formatDate,\n    formatDateFull,\n    copyToClipboard,\n    IMPORT_WORDS_COUNT,\n    CONFIRM_WORDS_COUNT\n};\n"
  },
  {
    "path": "src/js/view/View.js",
    "content": "import {\n    $,\n    $$,\n    clearElement,\n    CONFIRM_WORDS_COUNT,\n    copyToClipboard,\n    createElement,\n    formatDate,\n    formatDateFull,\n    formatTime,\n    IMPORT_WORDS_COUNT,\n    onInput,\n    setAddr,\n    toggle,\n    toggleFaded,\n    triggerClass\n} from \"./Utils.js\";\n\nimport {initLotties, lotties, toggleLottie} from \"./Lottie.js\";\nimport DropDown from \"./DropDown.js\";\n\nconst toNano = TonWeb.utils.toNano;\nconst fromNano = TonWeb.utils.fromNano;\nconst BN = TonWeb.utils.BN;\n\nconst IS_EXTENSION = !!(self.chrome && chrome.runtime && chrome.runtime.onConnect);\nconst IS_FIREFOX = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\n/**\n * @param text  {string}\n * @param containerSelector {string}\n */\nconst drawQRCode = (text, containerSelector) => {\n    const $container = $(containerSelector);\n\n    clearElement($container);\n\n    new QRCode($container, {\n        text: text,\n        width: 185 * window.devicePixelRatio,\n        height: 185 * window.devicePixelRatio,\n        colorDark: '#303757',\n        logo: \"assets/ui/qr-logo.png\",\n        logoBackgroundTransparent: false,\n        logoWidth: 44 * window.devicePixelRatio,\n        logoHeight: 44 * window.devicePixelRatio,\n        correctLevel: QRCode.CorrectLevel.L\n    });\n\n    const canvas = $container.querySelector('canvas');\n    canvas.style.width = '185px';\n    canvas.style.height = '185px';\n};\n\nclass View {\n    /**\n     * @param mnemonicWords {string[]}\n     */\n    constructor(mnemonicWords) {\n        /** @type   {string[]} */\n        this.mnemonicWords = mnemonicWords;\n        /** @type {Controller | null} */\n        this.controller = null;\n        /** @type {any | null} */\n        this.port = null;\n        /** @type   {string | null} */\n        this.myAddress = null;\n        /** @type   {string | null} */\n        this.address = null;\n        /** @type   {BN | null} */\n        this.balance = null;\n        /** @type   {string | null} */\n        this.currentScreenName = null;\n        /** @type   {boolean} */\n        this.isTestnet = false;\n        /** @type   {string} */\n        this.popup = ''; // current opened popup name\n\n        /** @type   {boolean} */\n        this.isBack = false;\n        /** @type   {number} */\n        this.backupShownTime = 0;\n\n        /** @type {any | null} */\n        this.currentOpenTransaction = null;\n\n        /** @type {string | null} */\n        this.currentTransactionAddr = null;\n\n        this.createWordInputs({\n            count: IMPORT_WORDS_COUNT,\n            dropdownId: '#wordsPopup',\n            inputId: '#importsInput',\n            containerId: '#importWords',\n            multiColumns: true\n        });\n        this.createWordInputs({\n            count: CONFIRM_WORDS_COUNT,\n            dropdownId: '#wordsConfirmPopup',\n            inputId: '#confirmInput',\n            containerId: '#confirmWords',\n            multiColumns: false\n        });\n\n        /** @type {Promise<void>} */\n        this._initLotties = initLotties().then(() => {\n            if (this.currentScreenName) {\n                toggleLottie(lotties[this.currentScreenName], true);\n                toggleLottie(lotties['symbol'], this.currentScreenName === 'main');\n            }\n        });\n\n        /**\n         * @param e {Event}\n         */\n        function resetErrors(e) {\n            const input = e.target;\n            input.classList.remove('error');\n        }\n\n        onInput($('#amountInput'), resetErrors);\n        onInput($('#toWalletInput'), resetErrors);\n        onInput($('#commentInput'), resetErrors);\n        onInput($('#createPassword_repeatInput'), resetErrors);\n        onInput($('#enterPassword_input'), resetErrors);\n        onInput($('#changePassword_oldInput'), resetErrors);\n        onInput($('#changePassword_newInput'), resetErrors);\n        onInput($('#changePassword_repeatInput'), resetErrors);\n\n        /**\n         * @param e {ClipboardEvent}\n         * @return {string}\n         */\n        function getClipboardData(e) {\n            const s = (e.clipboardData || window.clipboardData).getData('text');\n            try {\n                return decodeURI(s).replaceAll(/%23/g, '#');\n            } catch (e) { // URIError\n                return s;\n            }\n        }\n\n        $('#toWalletInput').addEventListener('paste', e => {\n            const urlString = getClipboardData(e);\n\n            if (!urlString.startsWith('ton://')) return;\n\n            /** @type {{address: string, amount?: string, text?: string} | null } */\n            let parsedTransferUrl = null;\n            try {\n                parsedTransferUrl = TonWeb.utils.parseTransferUrl(urlString);\n            } catch (e) {\n                $('#notify').innerText = 'Parse transfer URL error';\n                triggerClass($('#notify'), 'faded-show', 2000);\n                return;\n            }\n\n            $('#toWalletInput').value = parsedTransferUrl.address;\n\n            if (parsedTransferUrl.amount) {\n                $('#amountInput').value = fromNano(new BN(parsedTransferUrl.amount));\n            }\n\n            if (parsedTransferUrl.text) {\n                $('#commentInput').value = parsedTransferUrl.text;\n            }\n\n            e.preventDefault();\n        });\n\n        onInput($('#invoice_amountInput'), () => this.updateInvoiceLink());\n        onInput($('#invoice_commentInput'), () => this.updateInvoiceLink());\n\n        $(\"#start_createBtn\").addEventListener('click', () => this.sendMessage('showScreen', {name: 'created'}));\n        $(\"#start_importBtn\").addEventListener('click', () => this.sendMessage('showScreen', {name: 'import'}));\n\n        /** @type {boolean} */\n        let needShowLedger = false;\n        try {\n            needShowLedger = window.location.href.indexOf('ledgerReview') > -1;\n        } catch (e) {\n\n        }\n        if (needShowLedger) {\n            toggle($(\"#start_importLedgerHidBtn\"), 'inline-block');\n        }\n\n        $(\"#start_importLedgerHidBtn\").addEventListener('click', () => {\n            this.showPopup('connectLedger');\n            this.sendMessage('showScreen', {name: 'importLedger', transportType: 'hid'});\n        });\n        // $(\"#start_importLedgerBleBtn\").addEventListener('click', () => this.sendMessage('showScreen', {name: 'importLedger', transportType: 'ble'}));\n\n        // $('#main_buyBtn').addEventListener('click', () => {\n        //     window.open('https://exchange.mercuryo.io/?currency=TONCOIN&address=' + this.myAddress, '_blank');\n        // });\n\n        $('#import_backBtn').addEventListener('click', () => {\n            this.isBack = true;\n            this.sendMessage('onImportBack');\n        });\n\n        $('#import_alertBtn').addEventListener('click', () => {\n            this.showAlert({\n                title: 'Too Bad',\n                message: 'Without the secret words, you can\\'t restore access to your wallet.',\n                buttons: [\n                    {\n                        label: 'CANCEL',\n                        callback: () => {\n                            this.isBack = true;\n                            this.sendMessage('onImportBack');\n                        }\n                    },\n                    {\n                        label: 'ENTER WORDS',\n                        callback: () => {\n                            this.closePopup();\n                        }\n                    },\n                ]\n            });\n        });\n        $('#import_continueBtn').addEventListener('click', async (e) => {\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('import', {words: await this.getImportWords()});\n        });\n\n        $('#createdContinueButton').addEventListener('click', () => this.sendMessage('createPrivateKey'));\n\n        $('#backup_continueBtn').addEventListener('click', () => {\n            const currentTime = Date.now();\n            if (currentTime - this.backupShownTime < 60000) { // 1 minute\n                this.showAlert({\n                    title: 'Sure done?',\n                    message: 'You didn\\'t have enough time to write these words down.',\n                    buttons: [\n                        {\n                            label: 'I\\'M SURE',\n                            callback: () => {\n                                this.sendMessage('onBackupDone');\n                            }\n                        },\n                        {\n                            label: 'OK, SORRY',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            } else {\n                this.sendMessage('onBackupDone');\n            }\n        });\n\n        $('#wordsConfirm_backBtn').addEventListener('click', () => {\n            this.isBack = true;\n            this.sendMessage('onConfirmBack');\n        });\n\n        $('#wordsConfirm_continueBtn').addEventListener('click', () => {\n            const confirmWords = this.getConfirmWords();\n\n            if (!confirmWords.isWordsFromList) {\n                return;\n            }\n\n            if (!confirmWords.isRightWords) {\n                this.showAlert({\n                    title: 'Incorrect words',\n                    message: 'The secret words you have entered do not match the ones in the list.',\n                    buttons: [\n                        {\n                            label: 'SEE WORDS',\n                            callback: () => {\n                                this.isBack = true;\n                                this.sendMessage('onConfirmBack');\n                            }\n                        },\n                        {\n                            label: 'TRY AGAIN',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            } else {\n                this.sendMessage('onConfirmDone', {words: confirmWords.words});\n            }\n        });\n\n\n        $('#createPassword_continueBtn').addEventListener('click', (e) => {\n            /** @type {string} */\n            const password = $('#createPassword_input').value;\n            /** @type {string} */\n            const passwordRepeat = $('#createPassword_repeatInput').value;\n\n            const isEmpty = password.length === 0 && !this.isTestnet;\n\n            if (isEmpty) {\n                $('#createPassword_input').classList.add('error');\n            } else if (password !== passwordRepeat) {\n                $('#createPassword_repeatInput').classList.add('error');\n            } else {\n                this.toggleButtonLoader(e.currentTarget, true);\n                this.sendMessage('passwordCreated', {password});\n            }\n        });\n\n        $('#readyToGo_continueBtn').addEventListener('click', () => this.sendMessage('showMain'));\n\n        $('#main_refreshBtn').addEventListener('click', () => {\n            this.setUpdating(true);\n            this.sendMessage('update');\n        });\n        $('#main_settingsButton').addEventListener('click', () => this.onSettingsClick());\n\n        $('#main_receiveBtn').addEventListener('click', () => {\n            toggle($('#receive_showAddressOnDeviceBtn'), !!this.isLedger);\n            this.showPopup('receive');\n        });\n        $('#sendButton').addEventListener('click', () => this.onMessage('showPopup', {name: 'send'}));\n\n        $('#modal').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n\n        if (IS_FIREFOX) {\n            toggle($('#menu_magic'), false);\n            toggle($('.about-magic'), false);\n        }\n\n        $('#menu_magic').addEventListener('click', () => {\n            $('#menu_magic .dropdown-toggle').classList.toggle('toggle-on');\n            const isTurnedOn = $('#menu_magic .dropdown-toggle').classList.contains('toggle-on');\n            $('#menu_telegram').classList.toggle('menu_telegram-show', isTurnedOn);\n            this.sendMessage('onMagicClick', isTurnedOn);\n        });\n\n        $('#menu_telegram').addEventListener('click', () => {\n            window.open('https://web.telegram.org/z', '_blank');\n        });\n\n        $('#menu_proxy').addEventListener('click', () => {\n            $('#menu_proxy .dropdown-toggle').classList.toggle('toggle-on');\n            this.sendMessage('onProxyClick', $('#menu_proxy .dropdown-toggle').classList.contains('toggle-on'));\n        });\n\n        $('#menu_extension_chrome').addEventListener('click', () => window.open('https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd', '_blank'));\n        $('#menu_extension_firefox').addEventListener('click', () => window.open('https://addons.mozilla.org/ru/firefox/addon/', '_blank'));\n        $('#menu_about').addEventListener('click', () => this.showPopup('about'));\n        $('#menu_changePassword').addEventListener('click', () => this.onMessage('showPopup', {name: 'changePassword'}));\n        $('#menu_backupWallet').addEventListener('click', () => this.sendMessage('onBackupWalletClick'));\n        $('#menu_delete').addEventListener('click', () => this.showPopup('delete'));\n\n        $('#receive_showAddressOnDeviceBtn').addEventListener('click', () => this.onShowAddressOnDevice());\n        $('#receive_invoiceBtn').addEventListener('click', () => this.onCreateInvoiceClick());\n        $('#receive_shareBtn').addEventListener('click', () => this.onShareAddressClick(false));\n        $('#receive .addr').addEventListener('click', () => this.onShareAddressClick(true));\n        $('#receive_closeBtn').addEventListener('click', () => this.closePopup());\n\n        $('#invoice_qrBtn').addEventListener('click', () => this.onCreateInvoiceQrClick());\n        $('#invoice_shareBtn').addEventListener('click', () => this.onShareInvoiceClick());\n        $('#invoice_closeBtn').addEventListener('click', () => this.showPopup('receive'));\n\n        $('#invoiceQr_shareBtn').addEventListener('click', () => this.onShareInvoiceClick());\n        $('#invoiceQr_closeBtn').addEventListener('click', () => this.showPopup('invoice'));\n\n        $('#transaction_sendBtn').addEventListener('click', () => this.onTransactionButtonClick());\n        $('#transaction_closeBtn').addEventListener('click', () => this.closePopup());\n\n        $('#connectLedger_cancelBtn').addEventListener('click', () => this.closePopup());\n\n        $('#send_btn').addEventListener('click', (e) => {\n            /** @type {string} */\n            const amount = $('#amountInput').value;\n            /** @type {BN} */\n            const amountNano = toNano(amount);\n            if (!amountNano.gt(new BN(0)) || this.balance.lt(amountNano)) {\n                $('#amountInput').classList.add('error');\n                return;\n            }\n\n            /** @type {string} */\n            const toAddressString = $('#toWalletInput').value;\n            /** @type {Address | null} */\n            let toAddress = null;\n            try {\n                toAddress = new TonWeb.utils.Address(toAddressString);\n            } catch (e) {\n            }\n            if (!toAddressString.toLowerCase().endsWith('.ton') && !toAddressString.toLowerCase().endsWith('.t.me') && !toAddress) {\n                $('#toWalletInput').classList.add('error');\n                return;\n            }\n\n            /** @type {string} */\n            const comment = $('#commentInput').value;\n            /** @type {boolean} */\n            const needEncryptComment = $('#encryptCommentCheckbox').checked;\n            if (comment.length > 1024) {\n                $('#commentInput').classList.add('error');\n                $('#notify').innerText = 'Maximum 1024 symbols';\n                triggerClass($('#notify'), 'faded-show', 2000);\n                return;\n            }\n\n            // from https://github.com/tonkeeper/ton-assets/blob/main/accounts.json with \"require_memo\": true\n            const exchangeAddresses = [\n                '0:5f00decb7da51881764dc3959cec60609045f6ca1b89e646bde49d492705d77f', // OKX\n                '0:b31535e934db05bbc220267467903c8108bdabcbc2a06588838b726ddf589ef0', // FTX\n                '0:57eb74407604a19f7e04005315ef70aeb7b675e6551977586756f6baf12125ee', // MEXC\n                '0:7994848c1fcbcbc57a6a5a987b66eb424b8b54e10759b6b514a66b600c2b0eef', // EXMO\n                '0:8d195793baad9a08c46dc353aebe999341dabd07721b9725f19e18abc3d10d92', // EXMO Cold Storage 1\n                '0:26ab8ae763a3a7c3067d882b7b01cd5d37254cb8768f57b6a47c00028effc7b8', // EXMO Cold Storage 2\n                '0:0130c77346e9ed82df677d107ad6a775c11f9c18f6a05c0dd17906b355850dad', // EXMO Deposit\n                '0:342a359e38357c083968129fddddf049ef5c47315bfbef27505a356bf9f02d65', // CoinEx\n                '0:555f3053e257130374bb831ae0e219e5e5f9ec0ca8f8a0d133369d3d690c64c2', // Huobi Deposit\n                '0:85af78e8d035e920117cda654615cdf371d464480b629e110d3c5310d85ab362', // Huobi\n                '0:80d4123841167ca989ac912443cc99a4b9c1a87584536427ff6fd85c92395ae9', // Kucoin\n                '0:a14b1f452385b2bb984ad2c4441e1d23cae071fdfc096dfba53ebba3b6ff1d10', // Lbank.info\n                '0:c3f1da8ecda8f8cd42bace224ea3f1b6971eaa7f54c492d4d190527b4f573f7c', // Bybit\n                '0:008bb088e81e38d583826901093567027cc1575ec744ac354fa4eeec302d166d', // bit.com\n            ]\n\n            const isExchange = toAddress && (exchangeAddresses.indexOf(toAddress.toString(false)) > -1);\n\n            if (isExchange) {\n                if (!comment) {\n                    $('#notify').innerText = 'Exchange require text comment (MEMO) for deposit';\n                    triggerClass($('#notify'), 'faded-show', 2000);\n                    return;\n                }\n\n                if (comment && needEncryptComment) {\n                    $('#notify').innerText = `Can't encrypt comment when depositing on exchange`;\n                    triggerClass($('#notify'), 'faded-show', 2000);\n                    return;\n                }\n            }\n\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('onSend', {\n                amount: amountNano.toString(),\n                toAddress: toAddressString,\n                comment,\n                needEncryptComment\n            });\n        });\n        $('#send_closeBtn').addEventListener('click', () => this.closePopup());\n\n        $('#sendConfirm_closeBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n        $('#sendConfirm_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n        $('#sendConfirm_okBtn').addEventListener('click', () => this.onMessage('showPopup', {name: 'enterPassword'}));\n\n        $('#signConfirm_closeBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#signConfirm_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#signConfirm_okBtn').addEventListener('click', () => this.onMessage('showPopup', {name: 'enterPassword'}));\n\n        $('#connectConfirm_closeBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#connectConfirm_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup()\n        });\n        $('#connectConfirm_okBtn').addEventListener('click', () => {\n            this.sendMessage('onConnectConfirmed', {});\n        });\n\n        $('#processing_closeBtn').addEventListener('click', () => this.closePopup());\n        $('#done_closeBtn').addEventListener('click', () => this.closePopup());\n        $('#about_closeBtn').addEventListener('click', () => this.closePopup());\n        $('#about_version').addEventListener('click', (e) => {\n            if (e.shiftKey) {\n                this.showAlert({\n                    title: 'Are you sure you want to switch between mainnet/testnet?',\n                    message: 'You can switch back the network by clicking on the version with the Shift key pressed',\n                    buttons: [\n                        {\n                            label: 'I\\'M SURE',\n                            callback: () => {\n                                this.sendMessage('toggleTestnet');\n                            }\n                        },\n                        {\n                            label: 'BACK',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            } else if (e.altKey) {\n                this.showAlert({\n                    title: 'Are you sure you want to switch between clear console/debug mode?',\n                    message: 'You can switch back the clear console by clicking on the version with the Alt key pressed',\n                    buttons: [\n                        {\n                            label: 'I\\'M SURE',\n                            callback: () => {\n                                this.sendMessage('toggleDebug');\n                            }\n                        },\n                        {\n                            label: 'BACK',\n                            callback: () => {\n                                this.closePopup();\n                            }\n                        },\n                    ]\n                });\n            }\n        });\n\n        $('#changePassword_cancelBtn').addEventListener('click', () => this.closePopup());\n        $('#changePassword_okBtn').addEventListener('click', async (e) => {\n            /** @type {string} */\n            const oldPassword = $('#changePassword_oldInput').value;\n            /** @type {string} */\n            const newPassword = $('#changePassword_newInput').value;\n            /** @type {string} */\n            const passwordRepeat = $('#changePassword_repeatInput').value;\n\n            const isEmpty = newPassword.length === 0 && !this.isTestnet;\n\n            if (isEmpty) {\n                $('#changePassword_newInput').classList.add('error');\n                return;\n            }\n\n            if (newPassword !== passwordRepeat) {\n                $('#changePassword_repeatInput').classList.add('error');\n                return;\n            }\n\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('onChangePassword', {oldPassword, newPassword});\n        });\n\n        $('#enterPassword_cancelBtn').addEventListener('click', () => {\n            this.sendMessage('onCancelAction');\n            this.closePopup();\n        });\n        $('#enterPassword_okBtn').addEventListener('click', async (e) => {\n            /** @type {string} */\n            const password = $('#enterPassword_input').value;\n\n            this.toggleButtonLoader(e.currentTarget, true);\n            this.sendMessage('onEnterPassword', {password});\n        });\n\n        $('#delete_cancelBtn').addEventListener('click', () => this.closePopup());\n        $('#delete_okBtn').addEventListener('click', () => this.sendMessage('disconnect'));\n\n        $('#transactionDecryptCommentButton').addEventListener('click', () => {\n            if (!this.currentOpenTransaction) return;\n\n            this.sendMessage('decryptComment', {\n                hash: this.currentOpenTransaction.hash,\n                senderAddress: this.currentOpenTransaction.from_addr,\n                encryptedComment: this.currentOpenTransaction.encryptedComment,\n            });\n        });\n    }\n\n    // COMMON\n\n    /**\n     * @param name  {string}\n     */\n    showScreen(name) {\n        this.closePopup();\n\n        const screens = ['start', 'created', 'backup', 'wordsConfirm', 'import', 'createPassword', 'readyToGo', 'main'];\n\n        screens.forEach(screen => {\n            toggleFaded($('#' + screen), name === screen, {\n                isBack: this.isBack,\n            });\n\n            toggleLottie(lotties[screen], name === screen, {hideDelay: 300}); // 300ms, as for screen show/hide animation duration in CSS\n        });\n        toggleLottie(lotties['symbol'], name === 'main', {hideDelay: 300});\n        this.currentScreenName = name;\n\n        this.isBack = false;\n\n        window.scrollTo(0, 0);\n    }\n\n    /**\n     * @param el    {HTMLElement}\n     * @param enable    {boolean}\n     */\n    toggleButtonLoader(el, enable) {\n        el.disabled = enable;\n        enable ? el.classList.add('btn-loader') : el.classList.remove('btn-loader');\n    }\n\n    /**\n     * @param params    {{title: string, message: string, buttons?: {label: string, callback: () => void}[]}}\n     */\n    showAlert(params) {\n        $('#alert .popup-title').innerText = params.title;\n        $('#alert .popup-black-text').innerText = params.message;\n        $('#alert .popup-footer').innerHTML = '';\n\n        if (params.buttons) {\n            params.buttons.forEach(button => {\n                const el = createElement({\n                    tag: 'button',\n                    clazz: 'btn-lite',\n                    text: button.label\n                });\n                $('#alert .popup-footer').appendChild(el);\n                el.addEventListener('click', button.callback);\n            });\n        }\n\n        this.showPopup('alert');\n    }\n\n    /**\n     * @param name  {string}\n     */\n    showPopup(name) {\n        this.popup = name;\n\n        $('#enterPassword_input').value = '';\n\n        //popups switching without animations\n        if (this.popup && name) {\n            triggerClass(document.body, 'disable-animations', 20);\n        }\n\n        toggleFaded($('#modal'), name !== '');\n\n        const popups = ['alert', 'receive', 'invoice', 'invoiceQr', 'send', 'sendConfirm', 'signConfirm', 'connectConfirm', 'processing', 'done', 'menuDropdown', 'about', 'delete', 'changePassword', 'enterPassword', 'transaction', 'connectLedger', 'loader'];\n\n        popups.forEach(popup => {\n            toggleFaded($('#' + popup), name === popup);\n            toggleLottie(lotties[popup], name === popup);\n        });\n    }\n\n    closePopup() {\n        this.currentOpenTransaction = null;\n        this.showPopup('');\n        this.sendMessage('onClosePopup');\n    }\n\n    // BACKUP SCREEN\n\n    /**\n     * @param words {string[]}\n     */\n    setBackupWords(words) {\n        /**\n         * @param n {number}\n         */\n        const createBackupWord = n => {\n            $('#createWords').appendChild(\n                createElement({\n                    tag: 'div',\n                    clazz: 'create-word-item',\n                    child: [\n                        createElement({\n                            tag: 'span',\n                            clazz: 'word-num',\n                            text: (n + 1) + '.'\n                        }),\n                        createElement({\n                            tag: 'span',\n                            style: {\n                                'font-weight': 'bold'\n                            },\n                            text: words[n]\n                        })\n                    ]\n                })\n            );\n        };\n\n        clearElement($('#createWords'));\n        for (let i = 0; i < words.length / 2; i++) {\n            createBackupWord(i);\n            createBackupWord(i + 12);\n        }\n    }\n\n    clearBackupWords() {\n        clearElement($('#createWords'));\n    }\n\n    // IMPORT && CONFIRM SCREENS\n\n    /**\n     * @param params    {{count: number, containerId: string, inputId: string, dropdownId: string, multiColumns: boolean}}\n     */\n    createWordInputs(params) {\n\n        /**\n         * @param input {HTMLInputElement}\n         */\n        const onEnter = input => {\n            const i = Number(input.getAttribute('tabindex'));\n            if (i === params.count) {\n\n            } else {\n                $(params.inputId + i).focus();\n            }\n        };\n\n        const dropdown = new DropDown($(params.dropdownId), onEnter, this.mnemonicWords);\n\n        /** @type {HTMLInputElement | null} */\n        let lastInput = null;\n\n        /**\n         * @param input {HTMLInputElement}\n         */\n        const showWordsPopup = input => {\n            const text = input.value;\n            if (text === null || text.length === 0) {\n                toggle($(params.dropdownId), false);\n                return;\n            }\n\n            dropdown.show(input, text.toLowerCase());\n        };\n\n        /**\n         * @param e {Event}\n         */\n        function onWordInput(e) {\n            /** @type {HTMLInputElement} */\n            const input = e.target;\n            input.classList.remove('error');\n\n            showWordsPopup(input);\n        }\n\n        /**\n         * @param e {Event}\n         */\n        const onFocusIn = (e) => {\n            /** @type {HTMLInputElement} */\n            const input = e.target;\n            lastInput = input;\n            showWordsPopup(input);\n        };\n\n        /**\n         * @param e {Event}\n         */\n        const onFocusOut = (e) => {\n            toggle($(params.dropdownId), false);\n            if (lastInput) {\n                const value = lastInput.value.toLowerCase().trim();\n                if (value.length > 0 && this.mnemonicWords.indexOf(value) === -1) {\n                    lastInput.classList.add('error');\n                } else {\n                    lastInput.classList.remove('error');\n                }\n            }\n        };\n\n        /**\n         * @param e {KeyboardEvent}\n         */\n        const onKeyDown = (e) => {\n            /** @type {HTMLInputElement} */\n            const input = e.target;\n            switch (e.key) {\n                case 'Enter':\n                    const selectedText = dropdown.getSelectedText();\n                    if (selectedText) {\n                        input.value = selectedText;\n                        input.classList.remove('error');\n                        dropdown.hide();\n                    }\n                    onEnter(input);\n                    break;\n                case 'ArrowUp':\n                    dropdown.up();\n                    break;\n                case 'ArrowDown':\n                    dropdown.down();\n                    break;\n            }\n        };\n\n        /**\n         * @param event {ClipboardEvent}\n         */\n        const onPaste = (event) => {\n            const text = (event.clipboardData || window.clipboardData).getData('text');\n            let arr = text.split(' ');\n            if (arr.length !== params.count) {\n                arr = text.split(',');\n            }\n            if (arr.length === params.count) {\n                for (let i = 0; i < params.count; i++) {\n                    /** @type {HTMLInputElement} */\n                    const input = $(params.inputId + i);\n                    const value = arr[i].toLowerCase().trim();\n                    if (!value || this.mnemonicWords.indexOf(value) === -1) {\n                        input.classList.add('error');\n                    } else {\n                        input.classList.remove('error');\n                    }\n                    input.value = value;\n                }\n                event.preventDefault();\n            }\n        };\n\n        /**\n         * @param n {number}\n         */\n        const createInput = (n) => {\n            const inputContainer = createElement({tag: 'div', clazz: 'word-item'});\n            const span = createElement({tag: 'span', clazz: 'word-num', text: (n + 1) + '.'});\n            inputContainer.appendChild(span);\n            /** @type {HTMLInputElement} */\n            const input = createElement({tag: 'input'});\n            input.id = params.inputId.slice(1) + n;\n            input.type = 'text';\n            input.tabIndex = n + 1;\n            input.autocomplete = 'off';\n            inputContainer.appendChild(input);\n\n            input.addEventListener('focusin', onFocusIn);\n            input.addEventListener('focusout', onFocusOut);\n            input.addEventListener('keydown', onKeyDown);\n            input.addEventListener('paste', onPaste);\n            onInput(input, onWordInput);\n\n            $(params.containerId).appendChild(inputContainer);\n        };\n\n        if (params.multiColumns) {\n            for (let i = 0; i < params.count / 2; i++) {\n                createInput(i);\n                createInput(i + params.count / 2);\n            }\n        } else {\n            for (let i = 0; i < params.count; i++) {\n                createInput(i);\n            }\n        }\n    }\n\n    clearImportWords() {\n        toggle($('#wordsPopup'), false);\n        for (let i = 0; i < IMPORT_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#importsInput' + i);\n            input.value = '';\n            input.classList.remove('error');\n        }\n    }\n\n    clearConfirmWords() {\n        toggle($('#wordsConfirmPopup'), false);\n        for (let i = 0; i < CONFIRM_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#confirmInput' + i);\n            input.value = '';\n            input.setAttribute('data-word', '');\n            input.classList.remove('error');\n        }\n    }\n\n    /**\n     * @param words {string[]}\n     */\n    setConfirmWords(words) {\n        /** @type {number[]} */\n        const nums = Array(IMPORT_WORDS_COUNT)\n            .fill(0)\n            .map((_, index) => ({index, rnd: Math.random()}))\n            .sort((a, b) => a.rnd - b.rnd)\n            .map(item => item.index)\n            .slice(0, CONFIRM_WORDS_COUNT)\n            .sort((a, b) => a - b);\n\n        const spans = $$('#confirmWordsNums span');\n        for (let i = 0; i < CONFIRM_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#confirmInput' + i);\n            input.setAttribute('data-index', nums[i].toString());\n            input.setAttribute('data-word', words[nums[i]]);\n            spans[i].innerText = (nums[i] + 1).toString();\n            input.parentNode.children[0].innerText = (nums[i] + 1) + '.';\n        }\n    }\n\n    /**\n     * @return {Promise<string[] | null>}\n     */\n    async getImportWords() {\n        /** @type {boolean} */\n        let isValid = true;\n        /** @type {string[]} */\n        const words = [];\n        for (let i = 0; i < IMPORT_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#importsInput' + i);\n            /** @type {string} */\n            const value = input.value.toLowerCase().trim();\n            if (!value || this.mnemonicWords.indexOf(value) === -1) {\n                input.classList.add('error');\n                isValid = false;\n            }\n            words.push(value);\n        }\n\n        if (isValid) {\n            isValid = await TonWeb.mnemonic.validateMnemonic(words);\n            if (!isValid) {\n                for (let i = 0; i < IMPORT_WORDS_COUNT; i++) {\n                    const input = $('#importsInput' + i);\n                    input.classList.add('error');\n                }\n            }\n        }\n\n        return isValid ? words : null;\n    }\n\n    /**\n     * @return {{isWordsFromList: boolean, isRightWords: boolean, words: null | Object<string, string>}} words - index to word\n     */\n    getConfirmWords() {\n        /** @type {boolean} */\n        let isWordsFromList = true;\n        /** @type {boolean} */\n        let isRightWords = true;\n        /** @type {Object<string, string>} */\n        const words = {};\n\n        for (let i = 0; i < CONFIRM_WORDS_COUNT; i++) {\n            /** @type {HTMLInputElement} */\n            const input = $('#confirmInput' + i);\n            /** @type {string} */\n            const value = input.value.toLowerCase().trim();\n            /** @type {string} */\n            const index = input.getAttribute('data-index');\n            /** @type {string} */\n            const validValue = input.getAttribute('data-word');\n            if (!value || this.mnemonicWords.indexOf(value) === -1) {\n                input.classList.add('error');\n                isWordsFromList = false;\n            }\n            if (value !== validValue) {\n                isRightWords = false;\n            }\n            words[index] = value;\n        }\n\n        return {\n            isWordsFromList,\n            isRightWords,\n            words: isWordsFromList && isRightWords ? words : null\n        };\n    }\n\n    // CREATE PASSWORD SCREEN\n\n    clearCreatePassword() {\n        $('#createPassword_input').value = '';\n        $('#createPassword_repeatInput').value = '';\n    }\n\n    // CHANGE PASSWORD POPUP\n\n    clearChangePassword() {\n        $('#changePassword_oldInput').value = '';\n        $('#changePassword_newInput').value = '';\n        $('#changePassword_repeatInput').value = '';\n    }\n\n    // MAIN SCREEN\n\n    /**\n     * @param updating  {boolean}\n     */\n    setUpdating(updating) {\n        $('#updateLabel').innerText = updating ? 'updating..' : 'updated just now';\n    }\n\n    onSettingsClick() {\n        toggleFaded($('#modal'), true);\n        toggleFaded($('#menuDropdown'), true);\n        toggle($('#menu_changePassword'), !this.isLedger);\n        toggle($('#menu_backupWallet'), !this.isLedger);\n    }\n\n    clearBalance() {\n        clearElement($('#balance'));\n        clearElement($('#transactionsList'));\n        toggle($('#walletCreated'), false);\n    }\n\n    /**\n     * @param balance   {BN}\n     * @param txs   {any[]}\n     */\n    setBalance(balance, txs) {\n        this.balance = balance;\n        /** @type {string} */\n        let s = fromNano(balance);\n        if (s === '0') s = '0.00';\n        const i = s.indexOf('.');\n        const first = s.substring(0, i);\n        const last = s.substring(i);\n\n        clearElement($('#balance'));\n        $('#balance').appendChild(createElement({tag: 'span', text: first}));\n        $('#balance').appendChild(createElement({tag: 'span', style: {'font-size': '24px'}, text: last}));\n\n        $('#sendBalance').innerText = 'Balance: ' + s + ' 💎';\n        toggle($('#sendButton'), balance.gt(new BN(0)) ? 'inline-block' : 'none');\n        this.setTransactions(txs);\n        this.setUpdating(false);\n    }\n\n    /**\n     * @param txs   {any[]}\n     */\n    setTransactions(txs) {\n        clearElement($('#transactionsList'));\n        /** @type {string} */\n        let date = '';\n\n        toggle($('#walletCreated'), txs.length === 0);\n\n        txs.forEach(tx => {\n            tx.amount = new BN(tx.amount);\n            tx.fee = new BN(tx.fee);\n            tx.date = new Date(tx.date);\n\n            /** @type {string} */\n            const txDate = formatDate(tx.date);\n            if (date !== txDate) {\n                this.addDateSeparator(txDate);\n                date = txDate;\n            }\n            this.addTx(tx);\n        });\n    }\n\n    /**\n     * @param dateString    {string}\n     */\n    addDateSeparator(dateString) {\n        $('#transactionsList').appendChild(createElement({tag: 'div', clazz: 'date-separator', text: dateString}));\n    }\n\n    /**\n     * @param tx    {any}\n     */\n    addTx(tx) {\n        /** @type {boolean} */\n        const isReceive = tx.inbound;\n        /** @type {string} */\n        const amountFormatted = fromNano(tx.amount);\n        /** @type {string} */\n        const addr = isReceive ? tx.from_addr : tx.to_addr;\n\n        const item = createElement({\n            tag: 'div',\n            clazz: 'tx-item',\n            child: [\n                createElement({\n                    tag: 'div',\n                    child: isReceive ? [\n                        createElement({\n                            tag: 'span',\n                            clazz: ['tx-amount', 'tx-amount-green'],\n                            text: '+' + amountFormatted\n                        }),\n                        createElement({tag: 'span', text: ' 💎'}),\n                        createElement({tag: 'span', clazz: 'tx-from', text: ' from:'})\n                    ] : [\n                        createElement({tag: 'span', clazz: 'tx-amount', text: amountFormatted}),\n                        createElement({tag: 'span', text: ' 💎'}),\n                        createElement({tag: 'span', clazz: 'tx-from', text: ' to:'})\n                    ]\n                }),\n                setAddr(createElement({tag: 'div', clazz: ['tx-addr', 'addr']}), addr),\n                tx.encryptedComment ? createElement({tag: 'div', clazz: 'tx-item-encrypted-icon'}) : undefined,\n                tx.comment ? createElement({tag: 'div', clazz: 'tx-comment', text: tx.comment}) : undefined,\n                createElement({tag: 'div', clazz: 'tx-fee', text: `blockchain fees: ${fromNano(tx.fee)}`}),\n                createElement({tag: 'div', clazz: 'tx-item-date', text: formatTime(tx.date)})\n            ]\n        });\n\n        item.addEventListener('click', () => this.onTransactionClick(tx));\n\n        $('#transactionsList').appendChild(item);\n    }\n\n    // TRANSACTION POPUP\n\n    /**\n     * @param tx    {any}\n     */\n    onTransactionClick(tx) {\n        this.currentOpenTransaction = tx;\n        this.showPopup('transaction');\n        /** @type {boolean} */\n        const isReceive = tx.inbound;\n        /** @type {string} */\n        const amountFormatted = fromNano(tx.amount);\n        /** @type {string} */\n        const addr = isReceive ? tx.from_addr : tx.to_addr;\n        this.currentTransactionAddr = addr;\n        $('#transactionAmount').innerText = (isReceive ? '+' + amountFormatted : amountFormatted) + ' 💎';\n        $('#transactionFee').innerText = fromNano(tx.fee) + ' transaction fee';\n        $('#transactionSenderLabel').innerText = isReceive ? 'Sender' : 'Recipient';\n        setAddr($('#transactionSender'), addr);\n        toggle($('#transactionCommentLabel'), !!tx.comment || !!tx.encryptedComment);\n        toggle($('#transactionDecryptCommentButton'), !!tx.encryptedComment);\n        toggle($('#transactionComment'), !!tx.comment);\n        $('#transactionComment').innerText = tx.comment;\n        $('#transactionDate').innerText = formatDateFull(tx.date);\n    }\n\n    onTransactionButtonClick() {\n        this.onMessage('showPopup', {name: 'send', toAddr: this.currentTransactionAddr});\n    }\n\n    // SEND POPUP\n\n    clearSend() {\n        $('#toWalletInput').value = '';\n        $('#amountInput').value = '';\n        $('#commentInput').value = '';\n        $('#encryptCommentCheckbox').checked = false;\n    }\n\n    // RECEIVE POPUP\n\n    /**\n     * @param address   {string}\n     */\n    setMyAddress(address) {\n        setAddr($('#receive .addr'), address);\n        drawQRCode(TonWeb.utils.formatTransferUrl(address), '#qr');\n        this.address = address;\n        this.loadDiamond(address);\n    }\n\n    /**\n     * @param address   {string}\n     * @return {Promise<void>}\n     */\n    async loadDiamond(address) {\n        toggle($('.balance-symbol'), true);\n        toggle($('.balance-diamond-container'), false);\n        toggle($('#diamond'), false);\n\n        try {\n            if (this.isTestnet) return;\n            const res = await fetch('https://ton.diamonds/api/wallet/diamond_nfts?address=' + address + '&perPage=1&current=1');\n            if (res.status !== 200) return;\n            const json = await res.json();\n            if (json.ok !== true) return;\n            if (json.result.total < 1) return;\n            const nftNumber = json.result.rows[0].nftNumber;\n            const diamondImageUrl = 'https://nft.ton.diamonds/nft/' + nftNumber + '/' + nftNumber + '_diamond.svg';\n            if (address === this.address) {\n                toggle($('.balance-symbol'), false);\n                $('#diamond').style.backgroundImage = 'url(\"' + diamondImageUrl + '\")';\n                toggle($('.balance-diamond-container'), true);\n                toggle($('#diamond'), true);\n            }\n        } catch (e) {\n            console.error('Diamonds Error', e);\n        }\n    }\n\n    /**\n     * @param onyAddress    {boolean} share address or transfer link\n     */\n    onShareAddressClick(onyAddress) {\n        const data = onyAddress ? this.myAddress : TonWeb.utils.formatTransferUrl(this.myAddress);\n        const text = onyAddress ? 'Wallet address copied to clipboard' : 'Transfer link copied to clipboard';\n        $('#notify').innerText = copyToClipboard(data) ? text : 'Can\\'t copy link';\n        triggerClass($('#notify'), 'faded-show', 2000);\n    }\n\n    onShowAddressOnDevice() {\n        this.sendMessage('showAddressOnDevice');\n        $('#notify').innerText = 'Please check the address on your device';\n        triggerClass($('#notify'), 'faded-show', 2000);\n    }\n\n    // RECEIVE INVOICE POPUP\n\n    onCreateInvoiceClick() {\n        this.onMessage('showPopup', {name: 'invoice'});\n    }\n\n    updateInvoiceLink() {\n        $('#invoice_link').innerText = this.getInvoiceLink();\n    };\n\n    /**\n     * @return {string}\n     */\n    getInvoiceLink() {\n        const amountString = $('#invoice_amountInput').value;\n        /** @type {string | undefined} */\n        const amount = amountString ? toNano(amountString).toString() : undefined;\n        return TonWeb.utils.formatTransferUrl(this.myAddress, amount, $('#invoice_commentInput').value);\n    }\n\n    onShareInvoiceClick() {\n        $('#notify').innerText = copyToClipboard(this.getInvoiceLink()) ? 'Transfer link copied to clipboard' : 'Can\\'t copy link';\n        triggerClass($('#notify'), 'faded-show', 2000);\n    }\n\n    // RECEIVE INVOICE QR POPUP\n\n    onCreateInvoiceQrClick() {\n        this.onMessage('showPopup', {name: 'invoiceQr'});\n    }\n\n    /**\n     * @param link  {string}\n     */\n    drawInvoiceQr(link) {\n        drawQRCode(link, '#invoiceQrImg');\n    }\n\n    // TRANSPORT WITH CONTROLLER\n\n    /**\n     * Send message to Controller.js\n     * @param method    {string}\n     * @param params?    {any}  boolean or object, not array\n     */\n    sendMessage(method, params) {\n        if (this.controller) {\n            this.controller.onViewMessage(method, params);\n        } else {\n            this.port.postMessage({method, params});\n        }\n    }\n\n    /**\n     * Receive message from Controller.js\n     * @param method    {string}\n     * @param params?    {any} boolean or object, not array\n     * @return {undefined | {magic: string | null, proxy: string | null, address: string | null, words: string | null, walletVersion: string | null}}\n     */\n    onMessage(method, params) {\n        switch (method) {\n            case 'disableCreated':\n                $('#createdContinueButton').disabled = params;\n                break;\n\n            case 'setIsTestnet':\n                this.isTestnet = params;\n                $('.your-balance').innerText = params ? 'Your testnet balance' : 'Your mainnet balance';\n                break;\n\n            case 'setBalance':\n                this.setBalance(new BN(params.balance), params.txs);\n                break;\n\n            case 'setIsLedger':\n                this.isLedger = params;\n                break;\n\n            case 'setIsMagic':\n                const isTurnedOn = params;\n                $('#menu_magic .dropdown-toggle').classList.toggle('toggle-on', isTurnedOn && !IS_FIREFOX);\n                $('#menu_telegram').classList.toggle('menu_telegram-show', isTurnedOn && !IS_FIREFOX);\n                break;\n\n            case 'setIsProxy':\n                if (params) {\n                    $('#menu_proxy .dropdown-toggle').classList.add('toggle-on');\n                } else {\n                    $('#menu_proxy .dropdown-toggle').classList.remove('toggle-on');\n                }\n                break;\n\n            case 'privateKeySaved':\n                this.toggleButtonLoader($('#createPassword_continueBtn'), false);\n                break;\n\n            case 'passwordChanged':\n                this.toggleButtonLoader($('#changePassword_okBtn'), false);\n                break;\n\n            case 'showChangePasswordError':\n                this.toggleButtonLoader($('#changePassword_okBtn'), false);\n                $('#changePassword_oldInput').classList.add('error');\n                break;\n\n            case 'passwordEntered':\n                this.toggleButtonLoader($('#enterPassword_okBtn'), false);\n                break;\n\n            case 'showEnterPasswordError':\n                this.toggleButtonLoader($('#enterPassword_okBtn'), false);\n                $('#enterPassword_input').classList.add('error');\n                break;\n\n            case 'importCompleted':\n                this.toggleButtonLoader($('#import_continueBtn'), false);\n                break;\n\n            case 'sendCheckFailed':\n                if (params && params.message) {\n                    $('#notify').innerText = params.message;\n                    triggerClass($('#notify'), 'faded-show', 3000);\n                }\n\n                this.toggleButtonLoader($('#send_btn'), false);\n                break;\n\n            case 'sendCheckSucceeded':\n                this.toggleButtonLoader($('#send_btn'), false);\n                break;\n\n            case 'sendCheckCantPublicKey':\n                this.toggleButtonLoader($('#send_btn'), false);\n                $('#notify').innerText = `To encrypt a message, the destination wallet must have at least one outgoing transfer`;\n                triggerClass($('#notify'), 'faded-show', 3000);\n                break;\n\n            case 'sendCheckCantPayFee':\n                this.toggleButtonLoader($('#send_btn'), false);\n                $('#amountInput').classList.add('error');\n\n                $('#notify').innerText = `Estimated fee is ~${fromNano(params.fee)} TON`;\n                triggerClass($('#notify'), 'faded-show', 3000);\n                break;\n\n            case 'decryptedComment':\n                if (this.currentOpenTransaction && this.currentOpenTransaction.hash === params.hash) {\n                    this.currentOpenTransaction.encryptedComment = null;\n                    this.currentOpenTransaction.comment = params.decryptedComment;\n                    this.onTransactionClick(this.currentOpenTransaction);\n                }\n                break;\n\n            case 'showScreen':\n                if (params.noAnimation) {\n                    triggerClass(document.body, 'disable-animations', 300);\n                }\n\n                this.showScreen(params.name);\n\n                switch (params.name) {\n                    case 'start':\n                        this.clearBalance();\n                        this.clearImportWords();\n                        break;\n                    case 'created':\n                        break;\n                    case 'import':\n                        this.clearImportWords();\n                        $('#importsInput0').focus();\n                        break;\n                    case 'backup':\n                        this.clearConfirmWords();\n                        this.setBackupWords(params.words);\n                        this.backupShownTime = params.isFirst ? (+new Date()) : 0;\n                        break;\n                    case 'wordsConfirm':\n                        this.clearConfirmWords();\n                        this.clearBackupWords();\n                        $('#confirmInput0').focus();\n                        this.setConfirmWords(params.words);\n                        break;\n                    case 'createPassword':\n                        this.clearImportWords();\n                        this.clearConfirmWords();\n                        this.clearCreatePassword();\n                        $('#createPassword_input').focus();\n                        break;\n                    case 'readyToGo':\n                        this.clearCreatePassword();\n                        break;\n                    case 'main':\n                        this.clearBackupWords();\n                        if (params.myAddress) {\n                            this.myAddress = params.myAddress;\n                            this.setMyAddress(params.myAddress);\n                        }\n                        break;\n                }\n                break;\n\n            case 'showPopup':\n                this.showPopup(params.name);\n\n                switch (params.name) {\n                    case 'changePassword':\n                        this.clearChangePassword();\n                        $('#changePassword_oldInput').focus();\n                        break;\n                    case 'enterPassword':\n                        $('#enterPassword_input').focus();\n                        break;\n                    case 'done':\n                        $('#done .popup-grey-text').innerText = params.message;\n                        break;\n                    case 'invoice':\n                        $('#invoice_amountInput').value = '';\n                        $('#invoice_commentInput').value = '';\n                        this.updateInvoiceLink();\n                        $('#invoice_amountInput').focus();\n                        break;\n                    case 'invoiceQr':\n                        this.drawInvoiceQr(this.getInvoiceLink());\n                        $('#invoiceQrAmount').innerText = $('#invoice_amountInput').value;\n                        break;\n                    case 'send':\n                        this.clearSend();\n                        if (params.toAddr) {\n                            $('#toWalletInput').value = params.toAddr;\n                        }\n                        toggle($('#commentInput'), !this.isLedger);\n                        toggle($('#encryptCommentCheckboxContainer'), !this.isLedger ? 'flex' : false);\n                        $('#toWalletInput').focus();\n                        break;\n                    case 'sendConfirm':\n                        $('#sendConfirmAmount').innerText = fromNano(new BN(params.amount)) + ' TON';\n                        setAddr($('#sendConfirmAddr'), params.toAddress);\n                        $('#sendConfirmFee').innerText = params.fee ? 'Fee: ~' + fromNano(new BN(params.fee)) + ' TON' : '';\n\n                        toggle($('#sendConfirmNotEncryptedNote'), !params.needEncryptComment);\n                        toggle($('#sendConfirm .popup-footer'), !this.isLedger);\n                        toggle($('#sendConfirm_closeBtn'), !this.isLedger);\n                        // todo: show label 'Please approve on device'\n                        break;\n                    case 'signConfirm':\n                        $('#signConfirmText').innerText = params.isConnect ? 'Do you want to connect your wallet to this page?' : 'Do you want to sign:';\n                        toggle($('#signConfirmData'), !params.isConnect);\n                        toggle($('#signConfirmAlert'), !params.isConnect);\n\n                        const hex = params.data.length > 48 ? params.data.substring(0, 47) + '…' : params.data;\n                        setAddr($('#signConfirmData'), hex);\n                        break;\n                    case 'connectConfirm':\n                        break;\n                }\n                break;\n\n            case 'closePopup':\n                this.closePopup();\n                break;\n\n            case 'restoreDeprecatedStorage':\n                const address = localStorage.getItem('address');\n                const words = localStorage.getItem('words');\n                const walletVersion = localStorage.getItem('walletVersion');\n                const magic = localStorage.getItem('magic');\n                const proxy = localStorage.getItem('proxy');\n                localStorage.clear();\n\n                return {address, words, walletVersion, magic, proxy};\n\n        }\n    }\n}\n\nwindow.view = new View(TonWeb.mnemonic.wordlists.EN);\n\nif (IS_EXTENSION) {\n\n    // connect to background process\n\n    const connectToBackground = () => {\n        const port = chrome.runtime.connect({name: 'gramWalletPopup'});\n        window.view.port = port;\n\n        port.onMessage.addListener(data => {\n            const result = window.view.onMessage(data.method, data.params);\n            if (result && data.id) {\n                port.postMessage({method: 'response', id: data.id, result});\n            }\n        });\n\n        port.onDisconnect.addListener(() => {\n            connectToBackground();\n        });\n    }\n\n    connectToBackground();\n\n    // remember extension position and size\n\n    const startTrackWindowPositionAndSize = async () => {\n        let prevWindow = await chrome.windows.getCurrent();\n\n        setInterval(async () => {\n            const currentWindow = await chrome.windows.getCurrent();\n\n            if (\n                currentWindow.top !== prevWindow.top ||\n                currentWindow.left !== prevWindow.left ||\n                currentWindow.height !== prevWindow.height ||\n                currentWindow.width !== prevWindow.width\n            ) {\n                prevWindow = currentWindow;\n\n                window.view.sendMessage('onWindowUpdate', {\n                    top: currentWindow.top,\n                    left: currentWindow.left,\n                    height: currentWindow.height,\n                    width: currentWindow.width\n                });\n            }\n        }, 3000);\n    }\n\n    startTrackWindowPositionAndSize();\n}\n\n// show attention message in browser console\n\nif (window.top == window && window.console) {\n    /** @type {Object<string, string[]>} */\n    const selfXssAttentions = {\n        'ru-RU': ['Внимание!', 'Используя эту консоль, вы можете подвергнуться атаке Self-XSS, что позволит злоумышленникам завладеть вашим кошельком.\\nНе вводите и не вставляйте программный код, который не понимаете.'],\n        '*': ['Attention!', 'Using this console, you can be exposed to a Self-XSS attack, allowing attackers to take over your wallet.\\nDo not enter or paste program code that you do not understand.']\n    };\n\n    /** @type {string} */\n    const userLanguage = navigator.language || navigator.userLanguage;\n    /** @type {string[]} */\n    let localizedSelfXssAttention = selfXssAttentions[userLanguage];\n    if (!localizedSelfXssAttention) localizedSelfXssAttention = selfXssAttentions['*'];\n\n    console.log(\n        '%c%s', 'color: red; background: yellow; font-size: 24px;', localizedSelfXssAttention[0]\n    );\n    console.log('%c%s', 'font-size: 18px;', localizedSelfXssAttention[1]);\n}\n"
  },
  {
    "path": "src/libs/aes-js-3.1.2.js",
    "content": "/*! MIT License. Copyright 2015-2018 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */\n(function(root) {\n    \"use strict\";\n\n    function checkInt(value) {\n        return (parseInt(value) === value);\n    }\n\n    function checkInts(arrayish) {\n        if (!checkInt(arrayish.length)) { return false; }\n\n        for (var i = 0; i < arrayish.length; i++) {\n            if (!checkInt(arrayish[i]) || arrayish[i] < 0 || arrayish[i] > 255) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    function coerceArray(arg, copy) {\n\n        // ArrayBuffer view\n        if (arg.buffer && arg.name === 'Uint8Array') {\n\n            if (copy) {\n                if (arg.slice) {\n                    arg = arg.slice();\n                } else {\n                    arg = Array.prototype.slice.call(arg);\n                }\n            }\n\n            return arg;\n        }\n\n        // It's an array; check it is a valid representation of a byte\n        if (Array.isArray(arg)) {\n            if (!checkInts(arg)) {\n                throw new Error('Array contains invalid value: ' + arg);\n            }\n\n            return new Uint8Array(arg);\n        }\n\n        // Something else, but behaves like an array (maybe a Buffer? Arguments?)\n        if (checkInt(arg.length) && checkInts(arg)) {\n            return new Uint8Array(arg);\n        }\n\n        throw new Error('unsupported array-like object');\n    }\n\n    function createArray(length) {\n        return new Uint8Array(length);\n    }\n\n    function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {\n        if (sourceStart != null || sourceEnd != null) {\n            if (sourceArray.slice) {\n                sourceArray = sourceArray.slice(sourceStart, sourceEnd);\n            } else {\n                sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);\n            }\n        }\n        targetArray.set(sourceArray, targetStart);\n    }\n\n\n\n    var convertUtf8 = (function() {\n        function toBytes(text) {\n            var result = [], i = 0;\n            text = encodeURI(text);\n            while (i < text.length) {\n                var c = text.charCodeAt(i++);\n\n                // if it is a % sign, encode the following 2 bytes as a hex value\n                if (c === 37) {\n                    result.push(parseInt(text.substr(i, 2), 16))\n                    i += 2;\n\n                // otherwise, just the actual byte\n                } else {\n                    result.push(c)\n                }\n            }\n\n            return coerceArray(result);\n        }\n\n        function fromBytes(bytes) {\n            var result = [], i = 0;\n\n            while (i < bytes.length) {\n                var c = bytes[i];\n\n                if (c < 128) {\n                    result.push(String.fromCharCode(c));\n                    i++;\n                } else if (c > 191 && c < 224) {\n                    result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f)));\n                    i += 2;\n                } else {\n                    result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f)));\n                    i += 3;\n                }\n            }\n\n            return result.join('');\n        }\n\n        return {\n            toBytes: toBytes,\n            fromBytes: fromBytes,\n        }\n    })();\n\n    var convertHex = (function() {\n        function toBytes(text) {\n            var result = [];\n            for (var i = 0; i < text.length; i += 2) {\n                result.push(parseInt(text.substr(i, 2), 16));\n            }\n\n            return result;\n        }\n\n        // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html\n        var Hex = '0123456789abcdef';\n\n        function fromBytes(bytes) {\n                var result = [];\n                for (var i = 0; i < bytes.length; i++) {\n                    var v = bytes[i];\n                    result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]);\n                }\n                return result.join('');\n        }\n\n        return {\n            toBytes: toBytes,\n            fromBytes: fromBytes,\n        }\n    })();\n\n\n    // Number of rounds by keysize\n    var numberOfRounds = {16: 10, 24: 12, 32: 14}\n\n    // Round constant words\n    var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91];\n\n    // S-box and Inverse S-box (S is for Substitution)\n    var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16];\n    var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d];\n\n    // Transformations for encryption\n    var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a];\n    var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616];\n    var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16];\n    var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c];\n\n    // Transformations for decryption\n    var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742];\n    var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857];\n    var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8];\n    var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0];\n\n    // Transformations for decryption key expansion\n    var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3];\n    var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697];\n    var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46];\n    var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d];\n\n    function convertToInt32(bytes) {\n        var result = [];\n        for (var i = 0; i < bytes.length; i += 4) {\n            result.push(\n                (bytes[i    ] << 24) |\n                (bytes[i + 1] << 16) |\n                (bytes[i + 2] <<  8) |\n                 bytes[i + 3]\n            );\n        }\n        return result;\n    }\n\n    var AES = function(key) {\n        if (!(this instanceof AES)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        Object.defineProperty(this, 'key', {\n            value: coerceArray(key, true)\n        });\n\n        this._prepare();\n    }\n\n\n    AES.prototype._prepare = function() {\n\n        var rounds = numberOfRounds[this.key.length];\n        if (rounds == null) {\n            throw new Error('invalid key size (must be 16, 24 or 32 bytes)');\n        }\n\n        // encryption round keys\n        this._Ke = [];\n\n        // decryption round keys\n        this._Kd = [];\n\n        for (var i = 0; i <= rounds; i++) {\n            this._Ke.push([0, 0, 0, 0]);\n            this._Kd.push([0, 0, 0, 0]);\n        }\n\n        var roundKeyCount = (rounds + 1) * 4;\n        var KC = this.key.length / 4;\n\n        // convert the key into ints\n        var tk = convertToInt32(this.key);\n\n        // copy values into round key arrays\n        var index;\n        for (var i = 0; i < KC; i++) {\n            index = i >> 2;\n            this._Ke[index][i % 4] = tk[i];\n            this._Kd[rounds - index][i % 4] = tk[i];\n        }\n\n        // key expansion (fips-197 section 5.2)\n        var rconpointer = 0;\n        var t = KC, tt;\n        while (t < roundKeyCount) {\n            tt = tk[KC - 1];\n            tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^\n                      (S[(tt >>  8) & 0xFF] << 16) ^\n                      (S[ tt        & 0xFF] <<  8) ^\n                       S[(tt >> 24) & 0xFF]        ^\n                      (rcon[rconpointer] << 24));\n            rconpointer += 1;\n\n            // key expansion (for non-256 bit)\n            if (KC != 8) {\n                for (var i = 1; i < KC; i++) {\n                    tk[i] ^= tk[i - 1];\n                }\n\n            // key expansion for 256-bit keys is \"slightly different\" (fips-197)\n            } else {\n                for (var i = 1; i < (KC / 2); i++) {\n                    tk[i] ^= tk[i - 1];\n                }\n                tt = tk[(KC / 2) - 1];\n\n                tk[KC / 2] ^= (S[ tt        & 0xFF]        ^\n                              (S[(tt >>  8) & 0xFF] <<  8) ^\n                              (S[(tt >> 16) & 0xFF] << 16) ^\n                              (S[(tt >> 24) & 0xFF] << 24));\n\n                for (var i = (KC / 2) + 1; i < KC; i++) {\n                    tk[i] ^= tk[i - 1];\n                }\n            }\n\n            // copy values into round key arrays\n            var i = 0, r, c;\n            while (i < KC && t < roundKeyCount) {\n                r = t >> 2;\n                c = t % 4;\n                this._Ke[r][c] = tk[i];\n                this._Kd[rounds - r][c] = tk[i++];\n                t++;\n            }\n        }\n\n        // inverse-cipher-ify the decryption round key (fips-197 section 5.3)\n        for (var r = 1; r < rounds; r++) {\n            for (var c = 0; c < 4; c++) {\n                tt = this._Kd[r][c];\n                this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^\n                                  U2[(tt >> 16) & 0xFF] ^\n                                  U3[(tt >>  8) & 0xFF] ^\n                                  U4[ tt        & 0xFF]);\n            }\n        }\n    }\n\n    AES.prototype.encrypt = function(plaintext) {\n        if (plaintext.length != 16) {\n            throw new Error('invalid plaintext size (must be 16 bytes)');\n        }\n\n        var rounds = this._Ke.length - 1;\n        var a = [0, 0, 0, 0];\n\n        // convert plaintext to (ints ^ key)\n        var t = convertToInt32(plaintext);\n        for (var i = 0; i < 4; i++) {\n            t[i] ^= this._Ke[0][i];\n        }\n\n        // apply round transforms\n        for (var r = 1; r < rounds; r++) {\n            for (var i = 0; i < 4; i++) {\n                a[i] = (T1[(t[ i         ] >> 24) & 0xff] ^\n                        T2[(t[(i + 1) % 4] >> 16) & 0xff] ^\n                        T3[(t[(i + 2) % 4] >>  8) & 0xff] ^\n                        T4[ t[(i + 3) % 4]        & 0xff] ^\n                        this._Ke[r][i]);\n            }\n            t = a.slice();\n        }\n\n        // the last round is special\n        var result = createArray(16), tt;\n        for (var i = 0; i < 4; i++) {\n            tt = this._Ke[rounds][i];\n            result[4 * i    ] = (S[(t[ i         ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;\n            result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;\n            result[4 * i + 2] = (S[(t[(i + 2) % 4] >>  8) & 0xff] ^ (tt >>  8)) & 0xff;\n            result[4 * i + 3] = (S[ t[(i + 3) % 4]        & 0xff] ^  tt       ) & 0xff;\n        }\n\n        return result;\n    }\n\n    AES.prototype.decrypt = function(ciphertext) {\n        if (ciphertext.length != 16) {\n            throw new Error('invalid ciphertext size (must be 16 bytes)');\n        }\n\n        var rounds = this._Kd.length - 1;\n        var a = [0, 0, 0, 0];\n\n        // convert plaintext to (ints ^ key)\n        var t = convertToInt32(ciphertext);\n        for (var i = 0; i < 4; i++) {\n            t[i] ^= this._Kd[0][i];\n        }\n\n        // apply round transforms\n        for (var r = 1; r < rounds; r++) {\n            for (var i = 0; i < 4; i++) {\n                a[i] = (T5[(t[ i          ] >> 24) & 0xff] ^\n                        T6[(t[(i + 3) % 4] >> 16) & 0xff] ^\n                        T7[(t[(i + 2) % 4] >>  8) & 0xff] ^\n                        T8[ t[(i + 1) % 4]        & 0xff] ^\n                        this._Kd[r][i]);\n            }\n            t = a.slice();\n        }\n\n        // the last round is special\n        var result = createArray(16), tt;\n        for (var i = 0; i < 4; i++) {\n            tt = this._Kd[rounds][i];\n            result[4 * i    ] = (Si[(t[ i         ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff;\n            result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff;\n            result[4 * i + 2] = (Si[(t[(i + 2) % 4] >>  8) & 0xff] ^ (tt >>  8)) & 0xff;\n            result[4 * i + 3] = (Si[ t[(i + 1) % 4]        & 0xff] ^  tt       ) & 0xff;\n        }\n\n        return result;\n    }\n\n\n    /**\n     *  Mode Of Operation - Electonic Codebook (ECB)\n     */\n    var ModeOfOperationECB = function(key) {\n        if (!(this instanceof ModeOfOperationECB)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Electronic Code Block\";\n        this.name = \"ecb\";\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationECB.prototype.encrypt = function(plaintext) {\n        plaintext = coerceArray(plaintext);\n\n        if ((plaintext.length % 16) !== 0) {\n            throw new Error('invalid plaintext size (must be multiple of 16 bytes)');\n        }\n\n        var ciphertext = createArray(plaintext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < plaintext.length; i += 16) {\n            copyArray(plaintext, block, 0, i, i + 16);\n            block = this._aes.encrypt(block);\n            copyArray(block, ciphertext, i);\n        }\n\n        return ciphertext;\n    }\n\n    ModeOfOperationECB.prototype.decrypt = function(ciphertext) {\n        ciphertext = coerceArray(ciphertext);\n\n        if ((ciphertext.length % 16) !== 0) {\n            throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');\n        }\n\n        var plaintext = createArray(ciphertext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < ciphertext.length; i += 16) {\n            copyArray(ciphertext, block, 0, i, i + 16);\n            block = this._aes.decrypt(block);\n            copyArray(block, plaintext, i);\n        }\n\n        return plaintext;\n    }\n\n\n    /**\n     *  Mode Of Operation - Cipher Block Chaining (CBC)\n     */\n    var ModeOfOperationCBC = function(key, iv) {\n        if (!(this instanceof ModeOfOperationCBC)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Cipher Block Chaining\";\n        this.name = \"cbc\";\n\n        if (!iv) {\n            iv = createArray(16);\n\n        } else if (iv.length != 16) {\n            throw new Error('invalid initialation vector size (must be 16 bytes)');\n        }\n\n        this._lastCipherblock = coerceArray(iv, true);\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationCBC.prototype.encrypt = function(plaintext) {\n        plaintext = coerceArray(plaintext);\n\n        if ((plaintext.length % 16) !== 0) {\n            throw new Error('invalid plaintext size (must be multiple of 16 bytes)');\n        }\n\n        var ciphertext = createArray(plaintext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < plaintext.length; i += 16) {\n            copyArray(plaintext, block, 0, i, i + 16);\n\n            for (var j = 0; j < 16; j++) {\n                block[j] ^= this._lastCipherblock[j];\n            }\n\n            this._lastCipherblock = this._aes.encrypt(block);\n            copyArray(this._lastCipherblock, ciphertext, i);\n        }\n\n        return ciphertext;\n    }\n\n    ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {\n        ciphertext = coerceArray(ciphertext);\n\n        if ((ciphertext.length % 16) !== 0) {\n            throw new Error('invalid ciphertext size (must be multiple of 16 bytes)');\n        }\n\n        var plaintext = createArray(ciphertext.length);\n        var block = createArray(16);\n\n        for (var i = 0; i < ciphertext.length; i += 16) {\n            copyArray(ciphertext, block, 0, i, i + 16);\n            block = this._aes.decrypt(block);\n\n            for (var j = 0; j < 16; j++) {\n                plaintext[i + j] = block[j] ^ this._lastCipherblock[j];\n            }\n\n            copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16);\n        }\n\n        return plaintext;\n    }\n\n\n    /**\n     *  Mode Of Operation - Cipher Feedback (CFB)\n     */\n    var ModeOfOperationCFB = function(key, iv, segmentSize) {\n        if (!(this instanceof ModeOfOperationCFB)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Cipher Feedback\";\n        this.name = \"cfb\";\n\n        if (!iv) {\n            iv = createArray(16);\n\n        } else if (iv.length != 16) {\n            throw new Error('invalid initialation vector size (must be 16 size)');\n        }\n\n        if (!segmentSize) { segmentSize = 1; }\n\n        this.segmentSize = segmentSize;\n\n        this._shiftRegister = coerceArray(iv, true);\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationCFB.prototype.encrypt = function(plaintext) {\n        if ((plaintext.length % this.segmentSize) != 0) {\n            throw new Error('invalid plaintext size (must be segmentSize bytes)');\n        }\n\n        var encrypted = coerceArray(plaintext, true);\n\n        var xorSegment;\n        for (var i = 0; i < encrypted.length; i += this.segmentSize) {\n            xorSegment = this._aes.encrypt(this._shiftRegister);\n            for (var j = 0; j < this.segmentSize; j++) {\n                encrypted[i + j] ^= xorSegment[j];\n            }\n\n            // Shift the register\n            copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);\n            copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);\n        }\n\n        return encrypted;\n    }\n\n    ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {\n        if ((ciphertext.length % this.segmentSize) != 0) {\n            throw new Error('invalid ciphertext size (must be segmentSize bytes)');\n        }\n\n        var plaintext = coerceArray(ciphertext, true);\n\n        var xorSegment;\n        for (var i = 0; i < plaintext.length; i += this.segmentSize) {\n            xorSegment = this._aes.encrypt(this._shiftRegister);\n\n            for (var j = 0; j < this.segmentSize; j++) {\n                plaintext[i + j] ^= xorSegment[j];\n            }\n\n            // Shift the register\n            copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);\n            copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize);\n        }\n\n        return plaintext;\n    }\n\n    /**\n     *  Mode Of Operation - Output Feedback (OFB)\n     */\n    var ModeOfOperationOFB = function(key, iv) {\n        if (!(this instanceof ModeOfOperationOFB)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Output Feedback\";\n        this.name = \"ofb\";\n\n        if (!iv) {\n            iv = createArray(16);\n\n        } else if (iv.length != 16) {\n            throw new Error('invalid initialation vector size (must be 16 bytes)');\n        }\n\n        this._lastPrecipher = coerceArray(iv, true);\n        this._lastPrecipherIndex = 16;\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationOFB.prototype.encrypt = function(plaintext) {\n        var encrypted = coerceArray(plaintext, true);\n\n        for (var i = 0; i < encrypted.length; i++) {\n            if (this._lastPrecipherIndex === 16) {\n                this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);\n                this._lastPrecipherIndex = 0;\n            }\n            encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++];\n        }\n\n        return encrypted;\n    }\n\n    // Decryption is symetric\n    ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;\n\n\n    /**\n     *  Counter object for CTR common mode of operation\n     */\n    var Counter = function(initialValue) {\n        if (!(this instanceof Counter)) {\n            throw Error('Counter must be instanitated with `new`');\n        }\n\n        // We allow 0, but anything false-ish uses the default 1\n        if (initialValue !== 0 && !initialValue) { initialValue = 1; }\n\n        if (typeof(initialValue) === 'number') {\n            this._counter = createArray(16);\n            this.setValue(initialValue);\n\n        } else {\n            this.setBytes(initialValue);\n        }\n    }\n\n    Counter.prototype.setValue = function(value) {\n        if (typeof(value) !== 'number' || parseInt(value) != value) {\n            throw new Error('invalid counter value (must be an integer)');\n        }\n\n        // We cannot safely handle numbers beyond the safe range for integers\n        if (value > Number.MAX_SAFE_INTEGER) {\n            throw new Error('integer value out of safe range');\n        }\n\n        for (var index = 15; index >= 0; --index) {\n            this._counter[index] = value % 256;\n            value = parseInt(value / 256);\n        }\n    }\n\n    Counter.prototype.setBytes = function(bytes) {\n        bytes = coerceArray(bytes, true);\n\n        if (bytes.length != 16) {\n            throw new Error('invalid counter bytes size (must be 16 bytes)');\n        }\n\n        this._counter = bytes;\n    };\n\n    Counter.prototype.increment = function() {\n        for (var i = 15; i >= 0; i--) {\n            if (this._counter[i] === 255) {\n                this._counter[i] = 0;\n            } else {\n                this._counter[i]++;\n                break;\n            }\n        }\n    }\n\n\n    /**\n     *  Mode Of Operation - Counter (CTR)\n     */\n    var ModeOfOperationCTR = function(key, counter) {\n        if (!(this instanceof ModeOfOperationCTR)) {\n            throw Error('AES must be instanitated with `new`');\n        }\n\n        this.description = \"Counter\";\n        this.name = \"ctr\";\n\n        if (!(counter instanceof Counter)) {\n            counter = new Counter(counter)\n        }\n\n        this._counter = counter;\n\n        this._remainingCounter = null;\n        this._remainingCounterIndex = 16;\n\n        this._aes = new AES(key);\n    }\n\n    ModeOfOperationCTR.prototype.encrypt = function(plaintext) {\n        var encrypted = coerceArray(plaintext, true);\n\n        for (var i = 0; i < encrypted.length; i++) {\n            if (this._remainingCounterIndex === 16) {\n                this._remainingCounter = this._aes.encrypt(this._counter._counter);\n                this._remainingCounterIndex = 0;\n                this._counter.increment();\n            }\n            encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++];\n        }\n\n        return encrypted;\n    }\n\n    // Decryption is symetric\n    ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;\n\n\n    ///////////////////////\n    // Padding\n\n    // See:https://tools.ietf.org/html/rfc2315\n    function pkcs7pad(data) {\n        data = coerceArray(data, true);\n        var padder = 16 - (data.length % 16);\n        var result = createArray(data.length + padder);\n        copyArray(data, result);\n        for (var i = data.length; i < result.length; i++) {\n            result[i] = padder;\n        }\n        return result;\n    }\n\n    function pkcs7strip(data) {\n        data = coerceArray(data, true);\n        if (data.length < 16) { throw new Error('PKCS#7 invalid length'); }\n\n        var padder = data[data.length - 1];\n        if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); }\n\n        var length = data.length - padder;\n        for (var i = 0; i < padder; i++) {\n            if (data[length + i] !== padder) {\n                throw new Error('PKCS#7 invalid padding byte');\n            }\n        }\n\n        var result = createArray(length);\n        copyArray(data, result, 0, 0, length);\n        return result;\n    }\n\n    ///////////////////////\n    // Exporting\n\n\n    // The block cipher\n    var aesjs = {\n        AES: AES,\n        Counter: Counter,\n\n        ModeOfOperation: {\n            ecb: ModeOfOperationECB,\n            cbc: ModeOfOperationCBC,\n            cfb: ModeOfOperationCFB,\n            ofb: ModeOfOperationOFB,\n            ctr: ModeOfOperationCTR\n        },\n\n        utils: {\n            hex: convertHex,\n            utf8: convertUtf8\n        },\n\n        padding: {\n            pkcs7: {\n                pad: pkcs7pad,\n                strip: pkcs7strip\n            }\n        },\n\n        _arrayTest: {\n            coerceArray: coerceArray,\n            createArray: createArray,\n            copyArray: copyArray,\n        }\n    };\n\n\n    // node.js\n    if (typeof exports !== 'undefined') {\n        module.exports = aesjs\n\n    // RequireJS/AMD\n    // http://www.requirejs.org/docs/api.html\n    // https://github.com/amdjs/amdjs-api/wiki/AMD\n    } else if (typeof(define) === 'function' && define.amd) {\n        define([], function() { return aesjs; });\n\n    // Web Browsers\n    } else {\n\n        // If there was an existing library at \"aesjs\" make sure it's still available\n        if (root.aesjs) {\n            aesjs._aesjs = root.aesjs;\n        }\n\n        root.aesjs = aesjs;\n    }\n\n\n})(this);\n"
  },
  {
    "path": "src/libs/noble-ed25519-1.7.3.js",
    "content": "(function (global, factory) {\n    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n    typeof define === 'function' && define.amd ? define(['exports'], factory) :\n    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.nobleEd25519 = {}));\n})(this, (function (exports) { 'use strict';\n\n    const _nodeResolve_empty = {};\n\n    const nodeCrypto = /*#__PURE__*/Object.freeze({\n        __proto__: null,\n        'default': _nodeResolve_empty\n    });\n\n    /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */\n    const _0n = BigInt(0);\n    const _1n = BigInt(1);\n    const _2n = BigInt(2);\n    const _8n = BigInt(8);\n    const CU_O = BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989');\n    const CURVE = Object.freeze({\n        a: BigInt(-1),\n        d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),\n        P: BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949'),\n        l: CU_O,\n        n: CU_O,\n        h: BigInt(8),\n        Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),\n        Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),\n    });\n    const POW_2_256 = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000');\n    const SQRT_M1 = BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');\n    BigInt('6853475219497561581579357271197624642482790079785650197046958215289687604742');\n    const SQRT_AD_MINUS_ONE = BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235');\n    const INVSQRT_A_MINUS_D = BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578');\n    const ONE_MINUS_D_SQ = BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838');\n    const D_MINUS_ONE_SQ = BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952');\n    class ExtendedPoint {\n        constructor(x, y, z, t) {\n            this.x = x;\n            this.y = y;\n            this.z = z;\n            this.t = t;\n        }\n        static fromAffine(p) {\n            if (!(p instanceof Point)) {\n                throw new TypeError('ExtendedPoint#fromAffine: expected Point');\n            }\n            if (p.equals(Point.ZERO))\n                return ExtendedPoint.ZERO;\n            return new ExtendedPoint(p.x, p.y, _1n, mod(p.x * p.y));\n        }\n        static toAffineBatch(points) {\n            const toInv = invertBatch(points.map((p) => p.z));\n            return points.map((p, i) => p.toAffine(toInv[i]));\n        }\n        static normalizeZ(points) {\n            return this.toAffineBatch(points).map(this.fromAffine);\n        }\n        equals(other) {\n            assertExtPoint(other);\n            const { x: X1, y: Y1, z: Z1 } = this;\n            const { x: X2, y: Y2, z: Z2 } = other;\n            const X1Z2 = mod(X1 * Z2);\n            const X2Z1 = mod(X2 * Z1);\n            const Y1Z2 = mod(Y1 * Z2);\n            const Y2Z1 = mod(Y2 * Z1);\n            return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;\n        }\n        negate() {\n            return new ExtendedPoint(mod(-this.x), this.y, this.z, mod(-this.t));\n        }\n        double() {\n            const { x: X1, y: Y1, z: Z1 } = this;\n            const { a } = CURVE;\n            const A = mod(X1 * X1);\n            const B = mod(Y1 * Y1);\n            const C = mod(_2n * mod(Z1 * Z1));\n            const D = mod(a * A);\n            const x1y1 = X1 + Y1;\n            const E = mod(mod(x1y1 * x1y1) - A - B);\n            const G = D + B;\n            const F = G - C;\n            const H = D - B;\n            const X3 = mod(E * F);\n            const Y3 = mod(G * H);\n            const T3 = mod(E * H);\n            const Z3 = mod(F * G);\n            return new ExtendedPoint(X3, Y3, Z3, T3);\n        }\n        add(other) {\n            assertExtPoint(other);\n            const { x: X1, y: Y1, z: Z1, t: T1 } = this;\n            const { x: X2, y: Y2, z: Z2, t: T2 } = other;\n            const A = mod((Y1 - X1) * (Y2 + X2));\n            const B = mod((Y1 + X1) * (Y2 - X2));\n            const F = mod(B - A);\n            if (F === _0n)\n                return this.double();\n            const C = mod(Z1 * _2n * T2);\n            const D = mod(T1 * _2n * Z2);\n            const E = D + C;\n            const G = B + A;\n            const H = D - C;\n            const X3 = mod(E * F);\n            const Y3 = mod(G * H);\n            const T3 = mod(E * H);\n            const Z3 = mod(F * G);\n            return new ExtendedPoint(X3, Y3, Z3, T3);\n        }\n        subtract(other) {\n            return this.add(other.negate());\n        }\n        precomputeWindow(W) {\n            const windows = 1 + 256 / W;\n            const points = [];\n            let p = this;\n            let base = p;\n            for (let window = 0; window < windows; window++) {\n                base = p;\n                points.push(base);\n                for (let i = 1; i < 2 ** (W - 1); i++) {\n                    base = base.add(p);\n                    points.push(base);\n                }\n                p = base.double();\n            }\n            return points;\n        }\n        wNAF(n, affinePoint) {\n            if (!affinePoint && this.equals(ExtendedPoint.BASE))\n                affinePoint = Point.BASE;\n            const W = (affinePoint && affinePoint._WINDOW_SIZE) || 1;\n            if (256 % W) {\n                throw new Error('Point#wNAF: Invalid precomputation window, must be power of 2');\n            }\n            let precomputes = affinePoint && pointPrecomputes.get(affinePoint);\n            if (!precomputes) {\n                precomputes = this.precomputeWindow(W);\n                if (affinePoint && W !== 1) {\n                    precomputes = ExtendedPoint.normalizeZ(precomputes);\n                    pointPrecomputes.set(affinePoint, precomputes);\n                }\n            }\n            let p = ExtendedPoint.ZERO;\n            let f = ExtendedPoint.BASE;\n            const windows = 1 + 256 / W;\n            const windowSize = 2 ** (W - 1);\n            const mask = BigInt(2 ** W - 1);\n            const maxNumber = 2 ** W;\n            const shiftBy = BigInt(W);\n            for (let window = 0; window < windows; window++) {\n                const offset = window * windowSize;\n                let wbits = Number(n & mask);\n                n >>= shiftBy;\n                if (wbits > windowSize) {\n                    wbits -= maxNumber;\n                    n += _1n;\n                }\n                const offset1 = offset;\n                const offset2 = offset + Math.abs(wbits) - 1;\n                const cond1 = window % 2 !== 0;\n                const cond2 = wbits < 0;\n                if (wbits === 0) {\n                    f = f.add(constTimeNegate(cond1, precomputes[offset1]));\n                }\n                else {\n                    p = p.add(constTimeNegate(cond2, precomputes[offset2]));\n                }\n            }\n            return ExtendedPoint.normalizeZ([p, f])[0];\n        }\n        multiply(scalar, affinePoint) {\n            return this.wNAF(normalizeScalar(scalar, CURVE.l), affinePoint);\n        }\n        multiplyUnsafe(scalar) {\n            let n = normalizeScalar(scalar, CURVE.l, false);\n            const G = ExtendedPoint.BASE;\n            const P0 = ExtendedPoint.ZERO;\n            if (n === _0n)\n                return P0;\n            if (this.equals(P0) || n === _1n)\n                return this;\n            if (this.equals(G))\n                return this.wNAF(n);\n            let p = P0;\n            let d = this;\n            while (n > _0n) {\n                if (n & _1n)\n                    p = p.add(d);\n                d = d.double();\n                n >>= _1n;\n            }\n            return p;\n        }\n        isSmallOrder() {\n            return this.multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n        }\n        isTorsionFree() {\n            let p = this.multiplyUnsafe(CURVE.l / _2n).double();\n            if (CURVE.l % _2n)\n                p = p.add(this);\n            return p.equals(ExtendedPoint.ZERO);\n        }\n        toAffine(invZ) {\n            const { x, y, z } = this;\n            const is0 = this.equals(ExtendedPoint.ZERO);\n            if (invZ == null)\n                invZ = is0 ? _8n : invert(z);\n            const ax = mod(x * invZ);\n            const ay = mod(y * invZ);\n            const zz = mod(z * invZ);\n            if (is0)\n                return Point.ZERO;\n            if (zz !== _1n)\n                throw new Error('invZ was invalid');\n            return new Point(ax, ay);\n        }\n        fromRistrettoBytes() {\n            legacyRist();\n        }\n        toRistrettoBytes() {\n            legacyRist();\n        }\n        fromRistrettoHash() {\n            legacyRist();\n        }\n    }\n    ExtendedPoint.BASE = new ExtendedPoint(CURVE.Gx, CURVE.Gy, _1n, mod(CURVE.Gx * CURVE.Gy));\n    ExtendedPoint.ZERO = new ExtendedPoint(_0n, _1n, _1n, _0n);\n    function constTimeNegate(condition, item) {\n        const neg = item.negate();\n        return condition ? neg : item;\n    }\n    function assertExtPoint(other) {\n        if (!(other instanceof ExtendedPoint))\n            throw new TypeError('ExtendedPoint expected');\n    }\n    function assertRstPoint(other) {\n        if (!(other instanceof RistrettoPoint))\n            throw new TypeError('RistrettoPoint expected');\n    }\n    function legacyRist() {\n        throw new Error('Legacy method: switch to RistrettoPoint');\n    }\n    class RistrettoPoint {\n        constructor(ep) {\n            this.ep = ep;\n        }\n        static calcElligatorRistrettoMap(r0) {\n            const { d } = CURVE;\n            const r = mod(SQRT_M1 * r0 * r0);\n            const Ns = mod((r + _1n) * ONE_MINUS_D_SQ);\n            let c = BigInt(-1);\n            const D = mod((c - d * r) * mod(r + d));\n            let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D);\n            let s_ = mod(s * r0);\n            if (!edIsNegative(s_))\n                s_ = mod(-s_);\n            if (!Ns_D_is_sq)\n                s = s_;\n            if (!Ns_D_is_sq)\n                c = r;\n            const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D);\n            const s2 = s * s;\n            const W0 = mod((s + s) * D);\n            const W1 = mod(Nt * SQRT_AD_MINUS_ONE);\n            const W2 = mod(_1n - s2);\n            const W3 = mod(_1n + s2);\n            return new ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));\n        }\n        static hashToCurve(hex) {\n            hex = ensureBytes(hex, 64);\n            const r1 = bytes255ToNumberLE(hex.slice(0, 32));\n            const R1 = this.calcElligatorRistrettoMap(r1);\n            const r2 = bytes255ToNumberLE(hex.slice(32, 64));\n            const R2 = this.calcElligatorRistrettoMap(r2);\n            return new RistrettoPoint(R1.add(R2));\n        }\n        static fromHex(hex) {\n            hex = ensureBytes(hex, 32);\n            const { a, d } = CURVE;\n            const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';\n            const s = bytes255ToNumberLE(hex);\n            if (!equalBytes(numberTo32BytesLE(s), hex) || edIsNegative(s))\n                throw new Error(emsg);\n            const s2 = mod(s * s);\n            const u1 = mod(_1n + a * s2);\n            const u2 = mod(_1n - a * s2);\n            const u1_2 = mod(u1 * u1);\n            const u2_2 = mod(u2 * u2);\n            const v = mod(a * d * u1_2 - u2_2);\n            const { isValid, value: I } = invertSqrt(mod(v * u2_2));\n            const Dx = mod(I * u2);\n            const Dy = mod(I * Dx * v);\n            let x = mod((s + s) * Dx);\n            if (edIsNegative(x))\n                x = mod(-x);\n            const y = mod(u1 * Dy);\n            const t = mod(x * y);\n            if (!isValid || edIsNegative(t) || y === _0n)\n                throw new Error(emsg);\n            return new RistrettoPoint(new ExtendedPoint(x, y, _1n, t));\n        }\n        toRawBytes() {\n            let { x, y, z, t } = this.ep;\n            const u1 = mod(mod(z + y) * mod(z - y));\n            const u2 = mod(x * y);\n            const u2sq = mod(u2 * u2);\n            const { value: invsqrt } = invertSqrt(mod(u1 * u2sq));\n            const D1 = mod(invsqrt * u1);\n            const D2 = mod(invsqrt * u2);\n            const zInv = mod(D1 * D2 * t);\n            let D;\n            if (edIsNegative(t * zInv)) {\n                let _x = mod(y * SQRT_M1);\n                let _y = mod(x * SQRT_M1);\n                x = _x;\n                y = _y;\n                D = mod(D1 * INVSQRT_A_MINUS_D);\n            }\n            else {\n                D = D2;\n            }\n            if (edIsNegative(x * zInv))\n                y = mod(-y);\n            let s = mod((z - y) * D);\n            if (edIsNegative(s))\n                s = mod(-s);\n            return numberTo32BytesLE(s);\n        }\n        toHex() {\n            return bytesToHex(this.toRawBytes());\n        }\n        toString() {\n            return this.toHex();\n        }\n        equals(other) {\n            assertRstPoint(other);\n            const a = this.ep;\n            const b = other.ep;\n            const one = mod(a.x * b.y) === mod(a.y * b.x);\n            const two = mod(a.y * b.y) === mod(a.x * b.x);\n            return one || two;\n        }\n        add(other) {\n            assertRstPoint(other);\n            return new RistrettoPoint(this.ep.add(other.ep));\n        }\n        subtract(other) {\n            assertRstPoint(other);\n            return new RistrettoPoint(this.ep.subtract(other.ep));\n        }\n        multiply(scalar) {\n            return new RistrettoPoint(this.ep.multiply(scalar));\n        }\n        multiplyUnsafe(scalar) {\n            return new RistrettoPoint(this.ep.multiplyUnsafe(scalar));\n        }\n    }\n    RistrettoPoint.BASE = new RistrettoPoint(ExtendedPoint.BASE);\n    RistrettoPoint.ZERO = new RistrettoPoint(ExtendedPoint.ZERO);\n    const pointPrecomputes = new WeakMap();\n    class Point {\n        constructor(x, y) {\n            this.x = x;\n            this.y = y;\n        }\n        _setWindowSize(windowSize) {\n            this._WINDOW_SIZE = windowSize;\n            pointPrecomputes.delete(this);\n        }\n        static fromHex(hex, strict = true) {\n            const { d, P } = CURVE;\n            hex = ensureBytes(hex, 32);\n            const normed = hex.slice();\n            normed[31] = hex[31] & ~0x80;\n            const y = bytesToNumberLE(normed);\n            if (strict && y >= P)\n                throw new Error('Expected 0 < hex < P');\n            if (!strict && y >= POW_2_256)\n                throw new Error('Expected 0 < hex < 2**256');\n            const y2 = mod(y * y);\n            const u = mod(y2 - _1n);\n            const v = mod(d * y2 + _1n);\n            let { isValid, value: x } = uvRatio(u, v);\n            if (!isValid)\n                throw new Error('Point.fromHex: invalid y coordinate');\n            const isXOdd = (x & _1n) === _1n;\n            const isLastByteOdd = (hex[31] & 0x80) !== 0;\n            if (isLastByteOdd !== isXOdd) {\n                x = mod(-x);\n            }\n            return new Point(x, y);\n        }\n        static async fromPrivateKey(privateKey) {\n            return (await getExtendedPublicKey(privateKey)).point;\n        }\n        toRawBytes() {\n            const bytes = numberTo32BytesLE(this.y);\n            bytes[31] |= this.x & _1n ? 0x80 : 0;\n            return bytes;\n        }\n        toHex() {\n            return bytesToHex(this.toRawBytes());\n        }\n        toX25519() {\n            const { y } = this;\n            const u = mod((_1n + y) * invert(_1n - y));\n            return numberTo32BytesLE(u);\n        }\n        isTorsionFree() {\n            return ExtendedPoint.fromAffine(this).isTorsionFree();\n        }\n        equals(other) {\n            return this.x === other.x && this.y === other.y;\n        }\n        negate() {\n            return new Point(mod(-this.x), this.y);\n        }\n        add(other) {\n            return ExtendedPoint.fromAffine(this).add(ExtendedPoint.fromAffine(other)).toAffine();\n        }\n        subtract(other) {\n            return this.add(other.negate());\n        }\n        multiply(scalar) {\n            return ExtendedPoint.fromAffine(this).multiply(scalar, this).toAffine();\n        }\n    }\n    Point.BASE = new Point(CURVE.Gx, CURVE.Gy);\n    Point.ZERO = new Point(_0n, _1n);\n    class Signature {\n        constructor(r, s) {\n            this.r = r;\n            this.s = s;\n            this.assertValidity();\n        }\n        static fromHex(hex) {\n            const bytes = ensureBytes(hex, 64);\n            const r = Point.fromHex(bytes.slice(0, 32), false);\n            const s = bytesToNumberLE(bytes.slice(32, 64));\n            return new Signature(r, s);\n        }\n        assertValidity() {\n            const { r, s } = this;\n            if (!(r instanceof Point))\n                throw new Error('Expected Point instance');\n            normalizeScalar(s, CURVE.l, false);\n            return this;\n        }\n        toRawBytes() {\n            const u8 = new Uint8Array(64);\n            u8.set(this.r.toRawBytes());\n            u8.set(numberTo32BytesLE(this.s), 32);\n            return u8;\n        }\n        toHex() {\n            return bytesToHex(this.toRawBytes());\n        }\n    }\n    function concatBytes(...arrays) {\n        if (!arrays.every((a) => a instanceof Uint8Array))\n            throw new Error('Expected Uint8Array list');\n        if (arrays.length === 1)\n            return arrays[0];\n        const length = arrays.reduce((a, arr) => a + arr.length, 0);\n        const result = new Uint8Array(length);\n        for (let i = 0, pad = 0; i < arrays.length; i++) {\n            const arr = arrays[i];\n            result.set(arr, pad);\n            pad += arr.length;\n        }\n        return result;\n    }\n    const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));\n    function bytesToHex(uint8a) {\n        if (!(uint8a instanceof Uint8Array))\n            throw new Error('Uint8Array expected');\n        let hex = '';\n        for (let i = 0; i < uint8a.length; i++) {\n            hex += hexes[uint8a[i]];\n        }\n        return hex;\n    }\n    function hexToBytes(hex) {\n        if (typeof hex !== 'string') {\n            throw new TypeError('hexToBytes: expected string, got ' + typeof hex);\n        }\n        if (hex.length % 2)\n            throw new Error('hexToBytes: received invalid unpadded hex');\n        const array = new Uint8Array(hex.length / 2);\n        for (let i = 0; i < array.length; i++) {\n            const j = i * 2;\n            const hexByte = hex.slice(j, j + 2);\n            const byte = Number.parseInt(hexByte, 16);\n            if (Number.isNaN(byte) || byte < 0)\n                throw new Error('Invalid byte sequence');\n            array[i] = byte;\n        }\n        return array;\n    }\n    function numberTo32BytesBE(num) {\n        const length = 32;\n        const hex = num.toString(16).padStart(length * 2, '0');\n        return hexToBytes(hex);\n    }\n    function numberTo32BytesLE(num) {\n        return numberTo32BytesBE(num).reverse();\n    }\n    function edIsNegative(num) {\n        return (mod(num) & _1n) === _1n;\n    }\n    function bytesToNumberLE(uint8a) {\n        if (!(uint8a instanceof Uint8Array))\n            throw new Error('Expected Uint8Array');\n        return BigInt('0x' + bytesToHex(Uint8Array.from(uint8a).reverse()));\n    }\n    const MAX_255B = BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');\n    function bytes255ToNumberLE(bytes) {\n        return mod(bytesToNumberLE(bytes) & MAX_255B);\n    }\n    function mod(a, b = CURVE.P) {\n        const res = a % b;\n        return res >= _0n ? res : b + res;\n    }\n    function invert(number, modulo = CURVE.P) {\n        if (number === _0n || modulo <= _0n) {\n            throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);\n        }\n        let a = mod(number, modulo);\n        let b = modulo;\n        let x = _0n, u = _1n;\n        while (a !== _0n) {\n            const q = b / a;\n            const r = b % a;\n            const m = x - u * q;\n            b = a, a = r, x = u, u = m;\n        }\n        const gcd = b;\n        if (gcd !== _1n)\n            throw new Error('invert: does not exist');\n        return mod(x, modulo);\n    }\n    function invertBatch(nums, p = CURVE.P) {\n        const tmp = new Array(nums.length);\n        const lastMultiplied = nums.reduce((acc, num, i) => {\n            if (num === _0n)\n                return acc;\n            tmp[i] = acc;\n            return mod(acc * num, p);\n        }, _1n);\n        const inverted = invert(lastMultiplied, p);\n        nums.reduceRight((acc, num, i) => {\n            if (num === _0n)\n                return acc;\n            tmp[i] = mod(acc * tmp[i], p);\n            return mod(acc * num, p);\n        }, inverted);\n        return tmp;\n    }\n    function pow2(x, power) {\n        const { P } = CURVE;\n        let res = x;\n        while (power-- > _0n) {\n            res *= res;\n            res %= P;\n        }\n        return res;\n    }\n    function pow_2_252_3(x) {\n        const { P } = CURVE;\n        const _5n = BigInt(5);\n        const _10n = BigInt(10);\n        const _20n = BigInt(20);\n        const _40n = BigInt(40);\n        const _80n = BigInt(80);\n        const x2 = (x * x) % P;\n        const b2 = (x2 * x) % P;\n        const b4 = (pow2(b2, _2n) * b2) % P;\n        const b5 = (pow2(b4, _1n) * x) % P;\n        const b10 = (pow2(b5, _5n) * b5) % P;\n        const b20 = (pow2(b10, _10n) * b10) % P;\n        const b40 = (pow2(b20, _20n) * b20) % P;\n        const b80 = (pow2(b40, _40n) * b40) % P;\n        const b160 = (pow2(b80, _80n) * b80) % P;\n        const b240 = (pow2(b160, _80n) * b80) % P;\n        const b250 = (pow2(b240, _10n) * b10) % P;\n        const pow_p_5_8 = (pow2(b250, _2n) * x) % P;\n        return { pow_p_5_8, b2 };\n    }\n    function uvRatio(u, v) {\n        const v3 = mod(v * v * v);\n        const v7 = mod(v3 * v3 * v);\n        const pow = pow_2_252_3(u * v7).pow_p_5_8;\n        let x = mod(u * v3 * pow);\n        const vx2 = mod(v * x * x);\n        const root1 = x;\n        const root2 = mod(x * SQRT_M1);\n        const useRoot1 = vx2 === u;\n        const useRoot2 = vx2 === mod(-u);\n        const noRoot = vx2 === mod(-u * SQRT_M1);\n        if (useRoot1)\n            x = root1;\n        if (useRoot2 || noRoot)\n            x = root2;\n        if (edIsNegative(x))\n            x = mod(-x);\n        return { isValid: useRoot1 || useRoot2, value: x };\n    }\n    function invertSqrt(number) {\n        return uvRatio(_1n, number);\n    }\n    function modlLE(hash) {\n        return mod(bytesToNumberLE(hash), CURVE.l);\n    }\n    function equalBytes(b1, b2) {\n        if (b1.length !== b2.length) {\n            return false;\n        }\n        for (let i = 0; i < b1.length; i++) {\n            if (b1[i] !== b2[i]) {\n                return false;\n            }\n        }\n        return true;\n    }\n    function ensureBytes(hex, expectedLength) {\n        const bytes = hex instanceof Uint8Array ? Uint8Array.from(hex) : hexToBytes(hex);\n        if (typeof expectedLength === 'number' && bytes.length !== expectedLength)\n            throw new Error(`Expected ${expectedLength} bytes`);\n        return bytes;\n    }\n    function normalizeScalar(num, max, strict = true) {\n        if (!max)\n            throw new TypeError('Specify max value');\n        if (typeof num === 'number' && Number.isSafeInteger(num))\n            num = BigInt(num);\n        if (typeof num === 'bigint' && num < max) {\n            if (strict) {\n                if (_0n < num)\n                    return num;\n            }\n            else {\n                if (_0n <= num)\n                    return num;\n            }\n        }\n        throw new TypeError('Expected valid scalar: 0 < scalar < max');\n    }\n    function adjustBytes25519(bytes) {\n        bytes[0] &= 248;\n        bytes[31] &= 127;\n        bytes[31] |= 64;\n        return bytes;\n    }\n    function decodeScalar25519(n) {\n        return bytesToNumberLE(adjustBytes25519(ensureBytes(n, 32)));\n    }\n    function checkPrivateKey(key) {\n        key =\n            typeof key === 'bigint' || typeof key === 'number'\n                ? numberTo32BytesBE(normalizeScalar(key, POW_2_256))\n                : ensureBytes(key);\n        if (key.length !== 32)\n            throw new Error(`Expected 32 bytes`);\n        return key;\n    }\n    function getKeyFromHash(hashed) {\n        const head = adjustBytes25519(hashed.slice(0, 32));\n        const prefix = hashed.slice(32, 64);\n        const scalar = modlLE(head);\n        const point = Point.BASE.multiply(scalar);\n        const pointBytes = point.toRawBytes();\n        return { head, prefix, scalar, point, pointBytes };\n    }\n    let _sha512Sync;\n    function sha512s(...m) {\n        if (typeof _sha512Sync !== 'function')\n            throw new Error('utils.sha512Sync must be set to use sync methods');\n        return _sha512Sync(...m);\n    }\n    async function getExtendedPublicKey(key) {\n        return getKeyFromHash(await utils.sha512(checkPrivateKey(key)));\n    }\n    function getExtendedPublicKeySync(key) {\n        return getKeyFromHash(sha512s(checkPrivateKey(key)));\n    }\n    async function getPublicKey(privateKey) {\n        return (await getExtendedPublicKey(privateKey)).pointBytes;\n    }\n    function getPublicKeySync(privateKey) {\n        return getExtendedPublicKeySync(privateKey).pointBytes;\n    }\n    async function sign(message, privateKey) {\n        message = ensureBytes(message);\n        const { prefix, scalar, pointBytes } = await getExtendedPublicKey(privateKey);\n        const r = modlLE(await utils.sha512(prefix, message));\n        const R = Point.BASE.multiply(r);\n        const k = modlLE(await utils.sha512(R.toRawBytes(), pointBytes, message));\n        const s = mod(r + k * scalar, CURVE.l);\n        return new Signature(R, s).toRawBytes();\n    }\n    function signSync(message, privateKey) {\n        message = ensureBytes(message);\n        const { prefix, scalar, pointBytes } = getExtendedPublicKeySync(privateKey);\n        const r = modlLE(sha512s(prefix, message));\n        const R = Point.BASE.multiply(r);\n        const k = modlLE(sha512s(R.toRawBytes(), pointBytes, message));\n        const s = mod(r + k * scalar, CURVE.l);\n        return new Signature(R, s).toRawBytes();\n    }\n    function prepareVerification(sig, message, publicKey) {\n        message = ensureBytes(message);\n        if (!(publicKey instanceof Point))\n            publicKey = Point.fromHex(publicKey, false);\n        const { r, s } = sig instanceof Signature ? sig.assertValidity() : Signature.fromHex(sig);\n        const SB = ExtendedPoint.BASE.multiplyUnsafe(s);\n        return { r, s, SB, pub: publicKey, msg: message };\n    }\n    function finishVerification(publicKey, r, SB, hashed) {\n        const k = modlLE(hashed);\n        const kA = ExtendedPoint.fromAffine(publicKey).multiplyUnsafe(k);\n        const RkA = ExtendedPoint.fromAffine(r).add(kA);\n        return RkA.subtract(SB).multiplyUnsafe(CURVE.h).equals(ExtendedPoint.ZERO);\n    }\n    async function verify(sig, message, publicKey) {\n        const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n        const hashed = await utils.sha512(r.toRawBytes(), pub.toRawBytes(), msg);\n        return finishVerification(pub, r, SB, hashed);\n    }\n    function verifySync(sig, message, publicKey) {\n        const { r, SB, msg, pub } = prepareVerification(sig, message, publicKey);\n        const hashed = sha512s(r.toRawBytes(), pub.toRawBytes(), msg);\n        return finishVerification(pub, r, SB, hashed);\n    }\n    const sync = {\n        getExtendedPublicKey: getExtendedPublicKeySync,\n        getPublicKey: getPublicKeySync,\n        sign: signSync,\n        verify: verifySync,\n    };\n    async function getSharedSecret(privateKey, publicKey) {\n        const { head } = await getExtendedPublicKey(privateKey);\n        const u = Point.fromHex(publicKey).toX25519();\n        return curve25519.scalarMult(head, u);\n    }\n    Point.BASE._setWindowSize(8);\n    function cswap(swap, x_2, x_3) {\n        const dummy = mod(swap * (x_2 - x_3));\n        x_2 = mod(x_2 - dummy);\n        x_3 = mod(x_3 + dummy);\n        return [x_2, x_3];\n    }\n    function montgomeryLadder(pointU, scalar) {\n        const { P } = CURVE;\n        const u = normalizeScalar(pointU, P);\n        const k = normalizeScalar(scalar, P);\n        const a24 = BigInt(121665);\n        const x_1 = u;\n        let x_2 = _1n;\n        let z_2 = _0n;\n        let x_3 = u;\n        let z_3 = _1n;\n        let swap = _0n;\n        let sw;\n        for (let t = BigInt(255 - 1); t >= _0n; t--) {\n            const k_t = (k >> t) & _1n;\n            swap ^= k_t;\n            sw = cswap(swap, x_2, x_3);\n            x_2 = sw[0];\n            x_3 = sw[1];\n            sw = cswap(swap, z_2, z_3);\n            z_2 = sw[0];\n            z_3 = sw[1];\n            swap = k_t;\n            const A = x_2 + z_2;\n            const AA = mod(A * A);\n            const B = x_2 - z_2;\n            const BB = mod(B * B);\n            const E = AA - BB;\n            const C = x_3 + z_3;\n            const D = x_3 - z_3;\n            const DA = mod(D * A);\n            const CB = mod(C * B);\n            const dacb = DA + CB;\n            const da_cb = DA - CB;\n            x_3 = mod(dacb * dacb);\n            z_3 = mod(x_1 * mod(da_cb * da_cb));\n            x_2 = mod(AA * BB);\n            z_2 = mod(E * (AA + mod(a24 * E)));\n        }\n        sw = cswap(swap, x_2, x_3);\n        x_2 = sw[0];\n        x_3 = sw[1];\n        sw = cswap(swap, z_2, z_3);\n        z_2 = sw[0];\n        z_3 = sw[1];\n        const { pow_p_5_8, b2 } = pow_2_252_3(z_2);\n        const xp2 = mod(pow2(pow_p_5_8, BigInt(3)) * b2);\n        return mod(x_2 * xp2);\n    }\n    function encodeUCoordinate(u) {\n        return numberTo32BytesLE(mod(u, CURVE.P));\n    }\n    function decodeUCoordinate(uEnc) {\n        const u = ensureBytes(uEnc, 32);\n        u[31] &= 127;\n        return bytesToNumberLE(u);\n    }\n    const curve25519 = {\n        BASE_POINT_U: '0900000000000000000000000000000000000000000000000000000000000000',\n        scalarMult(privateKey, publicKey) {\n            const u = decodeUCoordinate(publicKey);\n            const p = decodeScalar25519(privateKey);\n            const pu = montgomeryLadder(u, p);\n            if (pu === _0n)\n                throw new Error('Invalid private or public key received');\n            return encodeUCoordinate(pu);\n        },\n        scalarMultBase(privateKey) {\n            return curve25519.scalarMult(privateKey, curve25519.BASE_POINT_U);\n        },\n    };\n    const crypto = {\n        node: nodeCrypto,\n        web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,\n    };\n    const utils = {\n        bytesToHex,\n        hexToBytes,\n        concatBytes,\n        getExtendedPublicKey,\n        mod,\n        invert,\n        TORSION_SUBGROUP: [\n            '0100000000000000000000000000000000000000000000000000000000000000',\n            'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a',\n            '0000000000000000000000000000000000000000000000000000000000000080',\n            '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05',\n            'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',\n            '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85',\n            '0000000000000000000000000000000000000000000000000000000000000000',\n            'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',\n        ],\n        hashToPrivateScalar: (hash) => {\n            hash = ensureBytes(hash);\n            if (hash.length < 40 || hash.length > 1024)\n                throw new Error('Expected 40-1024 bytes of private key as per FIPS 186');\n            return mod(bytesToNumberLE(hash), CURVE.l - _1n) + _1n;\n        },\n        randomBytes: (bytesLength = 32) => {\n            if (crypto.web) {\n                return crypto.web.getRandomValues(new Uint8Array(bytesLength));\n            }\n            else if (crypto.node) {\n                const { randomBytes } = crypto.node;\n                return new Uint8Array(randomBytes(bytesLength).buffer);\n            }\n            else {\n                throw new Error(\"The environment doesn't have randomBytes function\");\n            }\n        },\n        randomPrivateKey: () => {\n            return utils.randomBytes(32);\n        },\n        sha512: async (...messages) => {\n            const message = concatBytes(...messages);\n            if (crypto.web) {\n                const buffer = await crypto.web.subtle.digest('SHA-512', message.buffer);\n                return new Uint8Array(buffer);\n            }\n            else if (crypto.node) {\n                return Uint8Array.from(crypto.node.createHash('sha512').update(message).digest());\n            }\n            else {\n                throw new Error(\"The environment doesn't have sha512 function\");\n            }\n        },\n        precompute(windowSize = 8, point = Point.BASE) {\n            const cached = point.equals(Point.BASE) ? point : new Point(point.x, point.y);\n            cached._setWindowSize(windowSize);\n            cached.multiply(_2n);\n            return cached;\n        },\n        sha512Sync: undefined,\n    };\n    Object.defineProperties(utils, {\n        sha512Sync: {\n            configurable: false,\n            get() {\n                return _sha512Sync;\n            },\n            set(val) {\n                if (!_sha512Sync)\n                    _sha512Sync = val;\n            },\n        },\n    });\n\n    exports.CURVE = CURVE;\n    exports.ExtendedPoint = ExtendedPoint;\n    exports.Point = Point;\n    exports.RistrettoPoint = RistrettoPoint;\n    exports.Signature = Signature;\n    exports.curve25519 = curve25519;\n    exports.getPublicKey = getPublicKey;\n    exports.getSharedSecret = getSharedSecret;\n    exports.sign = sign;\n    exports.sync = sync;\n    exports.utils = utils;\n    exports.verify = verify;\n\n    Object.defineProperty(exports, '__esModule', { value: true });\n\n}));\n"
  }
]