[
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n  extends: 'eslint:recommended',\n  env: {\n    es6: true,\n    node: true,\n    browser: false,\n  },\n  parserOptions: {\n    ecmaVersion: 2020,\n    sourceType: 'module',\n  },\n  rules: {\n    'arrow-parens': ['error', 'as-needed'],\n    'array-bracket-spacing': ['error', 'never'],\n    'brace-style': ['error', '1tbs'],\n    'camelcase': 'error',\n    'comma-dangle': ['error', 'always-multiline'],\n    'comma-spacing': ['error', { before: false, after: true }],\n    'comma-style': ['error', 'last'],\n    'computed-property-spacing': ['error', 'never'],\n    'consistent-return': 'error',\n    'consistent-this': ['error', 'self'],\n    'curly': ['error', 'multi-line'],\n    'dot-notation': 'error',\n    'eol-last': 'error',\n    'eqeqeq': ['error', 'smart'],\n    'guard-for-in': 'error',\n    'indent': ['error', 2, { SwitchCase: 1, VariableDeclarator: { var: 2, let: 2, const: 3 } }],\n    'key-spacing': ['error', { beforeColon: false, afterColon: true }],\n    'keyword-spacing': 'error',\n    // 'max-len': ['warn', 120],\n    'no-alert': 'error',\n    'no-caller': 'error',\n    'no-catch-shadow': 'error',\n    'no-console': 'warn',\n    'no-else-return': 'error',\n    'no-empty': ['error', { allowEmptyCatch: true }],\n    'no-eval': 'error',\n    'no-extend-native': 'error',\n    'no-extra-bind': 'error',\n    'no-extra-parens': 'warn',\n    'no-fallthrough': 'error',\n    'no-floating-decimal': 'error',\n    'no-implied-eval': 'error',\n    'no-inner-declarations': ['error', 'both'],\n    'no-lonely-if': 'error',\n    'no-loop-func': 'error',\n    'no-mixed-spaces-and-tabs': 'error',\n    'no-multi-spaces': 'error',\n    'no-multiple-empty-lines': ['error', { max: 2 }],\n    'no-negated-condition': 'error',\n    'no-param-reassign': 'warn',\n    'no-redeclare': 'error',\n    'no-return-assign': 'error',\n    'no-self-compare': 'error',\n    'no-sequences': 'error',\n    'no-shadow': ['error', { builtinGlobals: true }],\n    'no-shadow-restricted-names': 'error',\n    'no-spaced-func': 'error',\n    'no-trailing-spaces': 'error',\n    'no-undef': 'error',\n    'no-undefined': 'error',\n    'no-underscore-dangle': 'off',\n    'no-unused-vars': ['error', { vars: 'all', args: 'after-used' }],\n    'no-use-before-define': ['error', 'nofunc'],\n    'no-useless-call': 'error',\n    'no-useless-escape': 'error',\n    'no-var': 'error',\n    'no-warning-comments': 'off',\n    'no-with': 'error',\n    'object-curly-spacing': ['error', 'always'],\n    'object-shorthand': ['error', 'always'],\n    'prefer-arrow-callback': ['error'],\n    'quotes': ['error', 'single'],\n    'semi': ['error', 'always'],\n    'semi-spacing': ['error', { before: false, after: true }],\n    'space-before-blocks': 'error',\n    'space-before-function-paren': ['error', { anonymous: 'always', named: 'never' }],\n    'space-in-parens': 'error',\n    'space-infix-ops': 'error',\n    'space-unary-ops': 'error',\n    'spaced-comment': ['warn', 'always', { block: { markers: ['!'], exceptions: ['*'] } }],\n    'strict': 'off',\n    'valid-jsdoc': 'warn',\n    'wrap-iife': ['error', 'outside'],\n    'yoda': ['error', 'never'],\n  },\n};\n\n"
  },
  {
    "path": ".github/workflows/check.yml",
    "content": "name: check\n\non:\n  push:\n    branches:\n      - main\n  pull_request:\n\njobs:\n  pre:\n    name: Prerequisites\n    if: github.event_name == 'pull_request'\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n        with:\n          fetch-depth: 0\n\n      - name: Enforce CLA signature\n        env:\n          COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}\n        run: curl https://raw.githubusercontent.com/shapesecurity/CLA/HEAD/cla-check.sh | bash\n\n  check:\n    needs: pre\n    if: |\n      !cancelled() && !failure()\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        node: [18]\n\n    name: Check - node ${{ matrix.node }}\n\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n\n      - name: Setup node\n        uses: actions/setup-node@v2\n        with:\n          node-version: ${{ matrix.node }}\n\n      - name: Install dependencies\n        run: npm ci\n\n      - name: Lint\n        run: npm run lint -- --quiet\n\n      - name: Test\n        run: npm test\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n"
  },
  {
    "path": "LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "Unminify\n========\n\nA little project to undo several of the horrible things JavaScript build tools will do to JavaScript. In addition to undoing most minification, it reverses some of the stupider but surprisingly common \"obfuscation\" techniques used in the wild.\n\nIt may amuse you to try it on, say, [this random bit of JavaScript I found](https://secure2.homedepot.com/_bm/async.js).\n\n## Installation\n\n```\nnpm install -g unminify\n```\n\nor use it without installing via `npx` (available since `npm` 5.2.0)\n\n```\nnpx unminify [...args]\n```\n\n## CLI Usage\n\n```\nunminify /path/to/file.js\n```\n\n* `--safety` may be given to enable/disable transformations based on the user's required safety guarantees. Refer to the [safety levels](#safety-levels) documentation for more details. The value of `--safety` may be one of\n  * `useless`\n  * `safe` (default)\n  * `mostly-safe`\n  * `unsafe`\n  * `wildly-unsafe`\n* `--additional-transform` may be given zero or more times, each followed by a path to a module providing an AST transform; the function signals that the transformation was not applied by returning its input\n\n## API Usage\n\n```js\nlet { unminifySource } = require('unminify');\nlet sourceText = '/* a minified/\"obfuscated\" JavaScript program */';\nconsole.log(unminify(sourceText));\n\n// or, with options\nconsole.log(unminifySource(sourceText, {\n  safety: unminify.safetyLevels.UNSAFE,\n  additionalTransforms: [function(ast) { /* ... */ }],\n}));\n```\n\nIf you already have a Shift tree then you can use `unminifyTree` to avoid the codegen & reparse cost.\n\n```js\nlet { parseScript } = require('shift-parser');\nlet { unminifyTree } = require('unminify');\n\nlet sourceText = '/* a minified/\"obfuscated\" JavaScript program */';\n\nlet tree = parseScript(sourceText);\nlet unminifiedTree = unminifyTree(tree);\n```\n\n## Safety Levels\n\n* \"safe to the point of uselessness\":\n  * safe for ALL programs (\"programs\" don't have early errors)\n* \"safe\": \"safe to the point of uselessness\" except\n  * Function.prototype.toString\n  * function name/arity\n  * Annex B\n  * direct eval\n* \"mostly safe\": \"safe\" except\n  * side effecting getters/setters on the global object\n  * sealed global object\n  * non-writable/non-configurable properties on the global object\n  * top-level var decls make global properties\n* \"unsafe\": \"mostly safe\" except\n  * non-spec built-in global properties or native proto properties\n* \"wildly unsafe\":\n  * no guarantees but it'll probably work most of the time\n\n## License\n\n    Copyright 2017 Shape Security, Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n"
  },
  {
    "path": "bin/cli.js",
    "content": "#!/usr/bin/env node\nrequire('../src/cli');\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"unminify\",\n  \"version\": \"2.0.0\",\n  \"author\": \"Kevin Gibbons <kevin@shapesecurity.com>\",\n  \"description\": \"reverse many of the transformations applied by minifiers and naïve obfuscators\",\n  \"license\": \"Apache-2.0\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/shapesecurity/unminify\"\n  },\n  \"main\": \"src/index.js\",\n  \"files\": [\n    \"src\",\n    \"bin\"\n  ],\n  \"bin\": \"bin/cli.js\",\n  \"scripts\": {\n    \"test\": \"ava --fail-fast --verbose\",\n    \"update-snapshots\": \"ava --update-snapshots\",\n    \"lint\": \"eslint src bin\",\n    \"build\": \"exit 0\"\n  },\n  \"ava\": {\n    \"files\": [\n      \"test/**/*.js\",\n      \"!test/snapshots-*/**/*.js\"\n    ],\n    \"snapshotDir\": \"test/snapshots-out\",\n    \"failFast\": true,\n    \"failWithoutAssertions\": false\n  },\n  \"dependencies\": {\n    \"command-line-args\": \"5.2.1\",\n    \"esutils\": \"2.0.3\",\n    \"prettier\": \"2.6.2\",\n    \"shift-ast\": \"7.0.0\",\n    \"shift-codegen\": \"8.0.0\",\n    \"shift-parser\": \"8.0.0\",\n    \"shift-reducer\": \"7.0.0\",\n    \"shift-scope\": \"6.0.0\",\n    \"shift-spec\": \"2019.0.0\"\n  },\n  \"devDependencies\": {\n    \"ava\": \"4.2.0\",\n    \"eslint\": \"8.15.0\"\n  }\n}\n"
  },
  {
    "path": "src/cli.js",
    "content": "'use strict';\n/* eslint-disable no-console */\n\nconst fs = require('fs');\nconst args = require('command-line-args')([\n  { name: 'file', type: String, defaultOption: true },\n  { name: 'safety', type: String, defaultValue: 'safe' },\n  { name: 'additional-transform', type: String, multiple: true, defaultValue: [] },\n]);\nconst prettier = require('prettier');\nconst deobfuscate = require('../');\nconst safetyLevels = require('./safety-levels');\nconst safetyLevelMap = {\n  __proto__: null,\n  useless: safetyLevels.USELESS,\n  safe: safetyLevels.SAFE,\n  'mostly-safe': safetyLevels.MOSTLY_SAFE,\n  unsafe: safetyLevels.UNSAFE,\n  'wildly-unsafe': safetyLevels.WILDLY_UNSAFE,\n};\n\nfunction format(src) {\n  return prettier.format(src, { parser: 'babel', singleQuote: true, trailingComma: 'es5' });\n}\n\nif (!args.file) {\n  throw new Error('Missing required input file parameter');\n}\nif (!(args.safety in safetyLevelMap)) {\n  throw new Error(`Safety level must be one of ${JSON.stringify(Object.keys(safetyLevelMap))}`);\n}\n\nconst src = fs.readFileSync(args.file, 'utf-8');\nconst safety = safetyLevelMap[args.safety];\nconst additionalTransforms = args['additional-transform'].map(a => require(a));\n\nconsole.log(format(deobfuscate(src, { additionalTransforms, safety })).trim());\n"
  },
  {
    "path": "src/helpers/codegen.js",
    "content": "'use strict';\n\nconst codegen = require('shift-codegen');\n\nclass FormattedCodeGenWithStrs extends codegen.FormattedCodeGen {\n  reduceLiteralStringExpression(node) {\n    const s = super.reduceLiteralStringExpression(node);\n    let out = '';\n    for (let i = 0; i < s.token.length; ++i) {\n      const code = s.token.codePointAt(i);\n      if (code >= 0x20 && code <= 0x7E) {\n        out += s.token.charAt(i);\n      } else if (code > 0xFFFF) {\n        ++i;\n        out += '\\\\u{' + code.toString(16).toUpperCase() + '}';\n      } else if (code > 0xFF) {\n        let hex = code.toString(16).toUpperCase();\n        out += '\\\\u' + '0000'.slice(hex.length) + hex;\n      } else if (code === 0) {\n        out += '\\\\0';\n      } else {\n        let hex = code.toString(16).toUpperCase();\n        out += '\\\\x' + '00'.slice(hex.length) + hex;\n      }\n    }\n    s.token = out;\n    return s;\n  }\n}\n\nmodule.exports = function (tree) {\n  return codegen.default(tree, new FormattedCodeGenWithStrs);\n};\n"
  },
  {
    "path": "src/helpers/fn-contains-weirdness.js",
    "content": "'use strict';\n\n// TODO short-curcuiting, memoization\n\nconst reducer = require('shift-reducer');\n\nclass ContainsWeirdness extends reducer.MonoidalReducer {\n  constructor() {\n    super({ empty: () => false, concat(b) {\n      return this || b;\n    } });\n  }\n\n  reduceThisExpression() {\n    return true;\n  }\n\n  reduceFunctionExpression() {\n    return false;\n  }\n\n  reduceFunctionDeclaration() {\n    return false;\n  }\n\n  reduceIdentifierExpression(node) {\n    return node.name === 'arguments';\n  }\n\n  // TODO many other cases\n}\nContainsWeirdness.INSTANCE = new ContainsWeirdness;\n\nmodule.exports.functionContainsWeirdness = function (fn) {\n  return reducer.default(ContainsWeirdness.INSTANCE, fn.params) || reducer.default(ContainsWeirdness.INSTANCE, fn.body);\n};\n\nmodule.exports.expressionContainsWeirdness = function (expr) {\n  return reducer.default(ContainsWeirdness.INSTANCE, expr);\n};\n"
  },
  {
    "path": "src/helpers/inlinable.js",
    "content": "module.exports = [\n  'LiteralNumericExpression',\n  'LiteralStringExpression',\n  'LiteralNullExpression',\n  'LiteralBooleanExpression',\n];\n"
  },
  {
    "path": "src/helpers/parents.js",
    "content": "'use strict';\n\n// Give a map from a node to its parents.\n\nconst reducer = require('shift-reducer');\nconst spec = require('shift-spec');\n\n\nclass ParentFinder {\n  constructor() {\n    this.parents = new WeakMap;\n  }\n}\n\n// eslint-disable-next-line guard-for-in\nfor (const typeName in spec) {\n  const type = spec[typeName];\n  const fields = type.fields.filter(f => f.name !== 'type');\n  ParentFinder.prototype['reduce' + typeName] = function (node) {\n    for (const field of fields) {\n      if (node[field.name] === null || typeof node[field.name] !== 'object') continue;\n      if (Array.isArray(node[field.name])) {\n        node[field.name].filter(c => c !== null).forEach(c => {\n          this.parents.set(c, node);\n        });\n      } else {\n        this.parents.set(node[field.name], node);\n      }\n    }\n  };\n}\n\nParentFinder.prototype.originalReduceScript = ParentFinder.prototype.reduceScript;\nParentFinder.prototype.originalReduceModule = ParentFinder.prototype.reduceModule;\nParentFinder.prototype.reduceScript = function (node) {\n  this.originalReduceScript(node);\n  this.parents.set(node, null);\n  return this.parents;\n};\nParentFinder.prototype.reduceModule = function (node) {\n  this.originalReduceModule(node);\n  this.parents.set(node, null);\n  return this.parents;\n};\n\nmodule.exports = ast => reducer.default(new ParentFinder, ast);\n"
  },
  {
    "path": "src/index.js",
    "content": "'use strict';\n\nconst parser = require('shift-parser');\nconst codegen = require('./helpers/codegen');\nconst safetyLevels = require('./safety-levels');\n\nconst TRANSFORMATIONS = {\n  [safetyLevels.USELESS]: [],\n  [safetyLevels.SAFE]: [\n    require('./transforms/safe/cleanup'),\n    require('./transforms/safe/cleanup-with-state'),\n  ],\n  [safetyLevels.MOSTLY_SAFE]: [],\n  [safetyLevels.UNSAFE]: [\n    require('./transforms/unsafe/remove-unused'),\n  ],\n  [safetyLevels.WILDLY_UNSAFE]: [\n    require('./transforms/wildly-unsafe/inline'),\n    require('./transforms/wildly-unsafe/partial-evaluate'),\n  ],\n};\n\nfunction unminifySource(src, options) {\n  let tree = parser.parseScript(src);\n  return codegen(unminifyTree(tree, options));\n}\n\nfunction unminifyTree(tree, { safety = safetyLevels.SAFE, additionalTransforms = [] } = {}) {\n  let transformations = [];\n  for (let i = 0; i <= safety; ++i) {\n    transformations.push(...TRANSFORMATIONS[i]);\n  }\n  transformations.push(...additionalTransforms);\n\n  let lastTree = tree;\n  // cap at 100 on general principles, but theoretically `while (true)` should be ok\n  for (let i = 0; i < 100; ++i) {\n    let newTree = lastTree;\n    for (let transformation of transformations) {\n      newTree = transformation(newTree);\n    }\n    if (newTree === lastTree) break;\n    lastTree = newTree;\n  }\n\n  return lastTree;\n}\n\nmodule.exports = unminifySource;\nmodule.exports.unminifySource = unminifySource;\nmodule.exports.unminifyTree = unminifyTree;\nmodule.exports.safetyLevels = safetyLevels;\n"
  },
  {
    "path": "src/safety-levels.js",
    "content": "module.exports = {\n  __proto__: null,\n  USELESS: 0,\n  SAFE: 1,\n  MOSTLY_SAFE: 2,\n  UNSAFE: 3,\n  WILDLY_UNSAFE: 4,\n};\n"
  },
  {
    "path": "src/transforms/safe/cleanup-with-state.js",
    "content": "'use strict';\n\nconst reducer = require('shift-reducer');\nconst shiftScope = require('shift-scope');\nconst Shift = require('shift-ast/checked');\n\nconst getParents = require('../../helpers/parents');\nconst { functionContainsWeirdness, expressionContainsWeirdness } = require('../../helpers/fn-contains-weirdness');\n\n// TODO rename this to something better expressing \"transform for simpler static analysis\"\nmodule.exports = function cleanupWithState(ast) {\n  const parents = getParents(ast);\n  const globalScope = shiftScope.default(ast);\n  const lookup = new shiftScope.ScopeLookup(globalScope);\n\n  function findScopeForNode(node, scope = globalScope) {\n    // TODO this should live elsewhere\n    if (scope.astNode === node) return scope;\n    for (let child of scope.children) {\n      const r = findScopeForNode(node, child);\n      if (r !== null) return r;\n    }\n    return null;\n  }\n\n  function unhoistVarDeclarations(statements) {\n    const out = [];\n    const toRemove = new WeakSet;\n    const toBecomeDecl = new WeakMap; // ExpressionStatement -> list of other expression statements to remove from this set\n    let touched = false;\n    for (let statement of statements) {\n      if (statement.type === 'VariableDeclarationStatement' && statement.declaration.kind === 'var' && statement.declaration.declarators.length === 1 && statement.declaration.declarators[0].init === null) {\n        const vs = lookup.lookup(statement.declaration.declarators[0].binding);\n        if (vs != null && vs.length === 1) {\n          const v = vs[0];\n          const simpleWrites = v.references\n            .filter(r => r.accessibility.isWrite && !r.accessibility.isRead)\n            .map(r => parents.get(r.node))\n            .filter(n => n.type === 'AssignmentExpression')\n            .map(n => [n, parents.get(n)])\n            .filter(([n, p]) => p.type === 'ExpressionStatement' || p.type === 'ForStatement' && p.init === n)\n            .map(([, p]) => p);\n          const declParent = parents.get(statement);\n          const isSameParent = n => {\n            const parent = parents.get(n);\n            if (parent === declParent) {\n              return true;\n            }\n            const gp = parents.get(parent);\n            if (gp != null && gp.type === 'ForStatement' && gp.init === parent) {\n              return true;\n            }\n            return false;\n          };\n          if (simpleWrites.length > 0 && simpleWrites.every(isSameParent)) {\n            touched = true;\n            toRemove.add(statement);\n            simpleWrites.forEach(s => toBecomeDecl.set(s, simpleWrites));\n          }\n        }\n      }\n    }\n\n    if (!touched) {\n      return statements;\n    }\n\n    for (let statement of statements) {\n      if (toRemove.has(statement)) continue;\n      if (toBecomeDecl.has(statement)) {\n        if (statement.type === 'ExpressionStatement') {\n          const declaration = new Shift.VariableDeclaration({ kind: 'var', declarators: [new Shift.VariableDeclarator({\n            binding: new Shift.BindingIdentifier({ name: statement.expression.binding.name }),\n            init: statement.expression.expression,\n          })] });\n          out.push(new Shift.VariableDeclarationStatement({ declaration }));\n        } else if (statement.type === 'ForStatement') {\n          const declaration = new Shift.VariableDeclaration({ kind: 'var', declarators: [new Shift.VariableDeclarator({\n            binding: new Shift.BindingIdentifier({ name: statement.init.binding.name }),\n            init: statement.init.expression,\n          })] });\n          out.push(new Shift.ForStatement({ init: declaration, test: statement.test, update: statement.update, body: statement.body }));\n        } else {\n          throw new Error('unreachable');\n        }\n        toBecomeDecl.get(statement).forEach(s => toBecomeDecl.delete(s));\n        continue;\n      }\n      out.push(statement);\n    }\n\n    return out;\n  }\n\n  class CleanupWithState extends reducer.LazyCloneReducer {\n    reduceFunctionBody(node, { directives, statements }) {\n      // move declarations to first initialization, as long as all writes are in the same statement list as the declaration\n      return super.reduceFunctionBody(node, { directives, statements: unhoistVarDeclarations(statements) });\n    }\n\n    reduceCallExpression(node, { callee, arguments: _arguments }) {\n      // Turn (function(a){ ... })(b) into (function(){ var a = b; ... })()\n      // Note: not safe if the function contains a direct `eval` which references `arguments` or an argument contains a direct `eval` which references `arguments` or `this`.\n      if (callee.type === 'FunctionExpression' && !callee.isGenerator && !functionContainsWeirdness(callee)) {\n        if (_arguments.length > 0 && _arguments.every(a => a.type !== 'SpreadElement' && !expressionContainsWeirdness(a)) && callee.params.rest === null && callee.params.items.every(p => p.type === 'BindingIdentifier')) {\n          const names = [].concat(...node.arguments.map(collectNames)); // TODO avoid\n          const fnScope = findScopeForNode(node.callee);\n          if (fnScope && !names.some(n => fnScope.variables.has(n))) {\n            // the scope check is to avoid shadowing something in the arguments\n            const newInit = [];\n            let i = 0;\n            for (; i < callee.params.items.length; ++i) {\n              newInit.push(new Shift.VariableDeclarationStatement({ declaration: new Shift.VariableDeclaration({\n                kind: 'var',\n                declarators: [\n                  new Shift.VariableDeclarator({ binding: callee.params.items[i], init: _arguments[i] || null }),\n                ],\n              }) }));\n            }\n            for (; i < _arguments.length; ++i) {\n              newInit.push(new Shift.ExpressionStatement({ expression: _arguments[i] }));\n            }\n            const fn = new Shift.FunctionExpression({ name: callee.name, isGenerator: false, isAsync: false, params: new Shift.FormalParameters({ items: [], rest: null }), body: new Shift.FunctionBody({\n              directives: [],\n              statements: newInit.concat(callee.body.statements),\n            }) });\n            return new Shift.CallExpression({ callee: fn, arguments: [] });\n          }\n        }\n      }\n      return super.reduceCallExpression(node, { callee, arguments: _arguments });\n    }\n  }\n\n\n  class NameCollector extends reducer.MonoidalReducer {\n    constructor() {\n      super({ empty: () => [], concat: (a, b) => a.concat(b) });\n    }\n\n    reduceIdentifierExpression(node) {\n      return [node.name];\n    }\n\n    reduceAssignmentTargetIdentifier(node) {\n      return [node.name];\n    }\n\n    reduceBindingIdentifier(node) {\n      return [node.name];\n    }\n\n    reduceFunctionExpression(node, state) { // TODO it would be nice for this to be thunked\n      const scope = findScopeForNode(node);\n      if (scope !== null) {\n        return [...scope.through.keys()];\n      }\n      return super.reduceFunctionExpression(node, state); // better than nothing\n    }\n\n    /*\n      Maybe this is a thing which should be exposed by the scope analyzer? through references for individual nodes, not just scopes?\n    */\n  }\n\n  function collectNames(node) {\n    return reducer.default(new NameCollector, node);\n  }\n\n\n  return reducer.default(new CleanupWithState, ast);\n};\n"
  },
  {
    "path": "src/transforms/safe/cleanup.js",
    "content": "'use strict';\n\n/* eslint-disable no-param-reassign */\n// Basically de-uglify-js\n\nconst reducer = require('shift-reducer');\nconst Shift = require('shift-ast/checked');\n\nconst inlinable = require('../../helpers/inlinable');\nconst { functionContainsWeirdness } = require('../../helpers/fn-contains-weirdness');\n\nconst esutils = require('esutils');\n\n\n// TODO convert switches to if/else\n\nfunction makeBlock(statement) {\n  return new Shift.BlockStatement({ block: new Shift.Block({ statements: [statement] }) });\n}\n\nfunction negate(expr, isBooleanContext, requireResult = true) {\n  if (expr.type === 'LiteralBooleanExpression') {\n    return new Shift.LiteralBooleanExpression({ value: !expr.value });\n  } else if (expr.type === 'LiteralNumericExpression') {\n    return new Shift.LiteralBooleanExpression({ value: !expr.value });\n  } else if (expr.type === 'ArrayExpression' && expr.elements.length === 0) {\n    return new Shift.LiteralBooleanExpression({ value: false });\n  } else if (expr.type === 'ObjectExpression' && expr.properties.length === 0) {\n    return new Shift.LiteralBooleanExpression({ value: false });\n  } else if (expr.type === 'BinaryExpression') {\n    if (expr.operator === '&&') {\n      return new Shift.BinaryExpression({ left: negate(expr.left, isBooleanContext), operator: '||', right: negate(expr.right, isBooleanContext) });\n    } else if (expr.operator === '||') {\n      return new Shift.BinaryExpression({ left: negate(expr.left, isBooleanContext), operator: '&&', right: negate(expr.right, isBooleanContext) });\n    } else if (expr.operator === '==') {\n      return new Shift.BinaryExpression({ left: expr.left, operator: '!=', right: expr.right });\n    } else if (expr.operator === '===') {\n      return new Shift.BinaryExpression({ left: expr.left, operator: '!==', right: expr.right });\n    } else if (expr.operator === '!=') {\n      return new Shift.BinaryExpression({ left: expr.left, operator: '==', right: expr.right });\n    } else if (expr.operator === '!==') {\n      return new Shift.BinaryExpression({ left: expr.left, operator: '===', right: expr.right });\n    }\n  } else if (expr.type === 'UnaryExpression' && expr.operator === '!' && isBooleanContext) {\n    return { ...expr.operand };\n  }\n  if (!requireResult) {\n    return null;\n  }\n  return new Shift.UnaryExpression({ operator: '!', operand: expr });\n}\n\nfunction isConstant(node) {\n  return inlinable.includes(node.type)\n    || node.type === 'UnaryExpression' && inlinable.includes(node.operand.type);\n}\n\nfunction isSequence(expr) {\n  return expr != null && expr.type === 'BinaryExpression' && expr.operator === ',';\n}\n\n// NB: only for use with associative operators\nfunction binExprToExprs(expr) {\n  const operator = expr.operator;\n  return [...binExprToExprsHelper(expr.left, operator), ...binExprToExprsHelper(expr.right, operator)];\n}\n\nfunction binExprToExprsHelper(expr, operator) {\n  if (expr.type === 'BinaryExpression' && expr.operator === operator) {\n    return [...binExprToExprsHelper(expr.left, operator), ...binExprToExprsHelper(expr.right, operator)];\n  }\n  return [expr];\n}\n\nfunction declaratorsToDeclarationStatements(kind, declarators) {\n  return declarators.map(d => new Shift.VariableDeclarationStatement({ declaration: new Shift.VariableDeclaration({ kind, declarators: [d] }) }));\n}\n\n\nclass OnlyReturnUndefined extends reducer.LazyCloneReducer { // TODO this would be better thunked.\n  reduceFunctionBody(node) {\n    return node;\n  }\n\n  reduceReturnStatement(node, { expression }) {\n    if (expression === null || expression.type === 'UnaryExpression' && expression.operator === 'void') {\n      return node;\n    }\n    if (expression.type === 'UnaryExpression' && expression.operator === 'void') {\n      return node;\n    }\n    const undef = new Shift.UnaryExpression({ operator: 'void', operand: expression });\n    return new Shift.ReturnStatement({ expression: undef });\n  }\n}\nconst onlyReturnUndefined = new OnlyReturnUndefined;\n\nfunction makeReturnsUndefined(fnBody) {\n  const fixed = fnBody.statements.map(s => reducer.default(onlyReturnUndefined, s));\n  if (arrayEquals(fixed, fnBody.statements)) {\n    return fnBody;\n  }\n  return new Shift.FunctionBody({ directives: fnBody.directives, statements: fixed });\n}\n\nlet booleanBinOps = ['==', '!=', '===', '!==', '<', '<=', '>', '>=', 'in', 'instanceof'];\nfunction returnsBoolean(expr) {\n  return expr.type === 'LiteralBooleanExpression'\n    || expr.type === 'UnaryExpression' && expr.operator === '!'\n    || expr.type === 'BinaryExpression' && booleanBinOps.includes(expr.operator)\n    || expr.type === 'BinaryExpression' && (expr.operator === '&&' || expr.operator === '||') && returnsBoolean(expr.left) && returnsBoolean(expr.right)\n    || expr.type === 'BinaryExpression' && expr.operator === ',' && returnsBoolean(expr.right)\n    || expr.type === 'ConditionalExpression' && returnsBoolean(expr.consequent) && returnsBoolean(expr.alternate);\n}\n\n/*\nThis function takes an expression like\n\n  a && (b, c, d) && e\n\nand returns an object with three properties:\n\n- prefix, a conjunction of all the clauses before the sequence expression, or `null` if there are none\n- seqs, a list of all expressions in the sequence expression save the last\n- suffix, a conjuction of the last item in the sequence expression with all the clauses after the sequence expression\n\nIf the expression is not a conjunction of clauses at least one of which is a sequence, returns `null`.\n\nIf `isBooleanContext` is true, it will additionally require that each clause in the prefix returns a boolean.\n\nIn this example, assuming `isBooleanContext` is false, it would return\n{\n  prefix: a\n  seqs: [b, c]\n  suffix: d && e\n}\n*/\nfunction extractSequenceFromConjunction(expr, isBooleanContext) {\n  if (expr.type !== 'BinaryExpression' || expr.operator !== '&&') {\n    return null;\n  }\n  const clauses = binExprToExprs(expr);\n  for (let i = 0; i < clauses.length; ++i) {\n    if (isSequence(clauses[i])) {\n      const seqs = binExprToExprs(clauses[i]);\n      const last = seqs.pop();\n      return {\n        prefix: i === 0 ? null : clauses.slice(0, i).reduce((acc, e) => new Shift.BinaryExpression({ left: acc, operator: '&&', right: e })),\n        seqs,\n        suffix: clauses.slice(i + 1).reduce((acc, e) => new Shift.BinaryExpression({ left: acc, operator: '&&', right: e }), last),\n      };\n    }\n    if (!isBooleanContext && !returnsBoolean(clauses[i])) {\n      break;\n    }\n  }\n  return null;\n}\n\nfunction fixStatementList(statements) {\n  // strip empty statements\n  // turn sequence expressions in statement position into multiple statements\n  // turn variable declarations with multiple declarators into multiple statements\n  // for (var a, b, c;;); -> var a; var b; for (var c;;);\n  const o = [];\n  for (const s of statements) {\n    switch (s.type) {\n      case 'EmptyStatement':\n        break;\n      case 'TryCatchStatement':\n        if (s.body.statements.length === 0) {\n          o.push(new Shift.IfStatement({ test: new Shift.LiteralBooleanExpression({ value: false }), consequent: new Shift.BlockStatement({ block: s.catchClause.body }), alternate: null }));\n        } else {\n          o.push(s);\n        }\n        break;\n      case 'ExpressionStatement':\n        if (isSequence(s.expression)) {\n          o.push(...binExprToExprs(s.expression).map(e => new Shift.ExpressionStatement({ expression: e })));\n        } else if (inlinable.includes(s.expression.type) || s.expression.type === 'ThisExpression' || s.expression.type === 'FunctionExpression') { // TODO local IdentifierExpressions\n          continue;\n        } else if (s.expression.type === 'UnaryExpression' && s.expression.operator === 'void') {\n          if (inlinable.includes(s.expression.operand.type)) {\n            continue;\n          }\n          o.push(new Shift.ExpressionStatement({ expression: s.expression.operand }));\n        } else {\n          o.push(s);\n        }\n        break;\n      case 'ThrowStatement':\n        if (isSequence(s.expression)) {\n          const exprs = binExprToExprs(s.expression);\n          const last = exprs.pop();\n          o.push(...exprs.map(e => new Shift.ExpressionStatement({ expression: e })));\n          o.push(new Shift.ThrowStatement({ expression: last }));\n        } else {\n          o.push(s);\n        }\n        break;\n      case 'ReturnStatement':\n        if (s.expression === null) {\n          o.push(s);\n        } else if (isSequence(s.expression)) {\n          const exprs = binExprToExprs(s.expression);\n          const last = exprs.pop();\n          o.push(...exprs.map(e => new Shift.ExpressionStatement({ expression: e })));\n          o.push(new Shift.ReturnStatement({ expression: last }));\n        } else if (s.expression.type === 'ConditionalExpression') {\n          const consequent = new Shift.ReturnStatement({ expression: s.expression.consequent });\n          const alternate = new Shift.ReturnStatement({ expression: s.expression.alternate });\n          o.push(new Shift.IfStatement({ test: s.expression.test, consequent, alternate }));\n        } else if (s.expression.type === 'BinaryExpression' && s.expression.operator === '&&') {\n          const extracted = extractSequenceFromConjunction(s.expression, false);\n          if (extracted === null) {\n            o.push(s);\n          } else {\n            const { prefix, seqs, suffix } = extracted;\n            if (prefix !== null) {\n              o.push(new Shift.IfStatement({\n                test: negate(prefix, true),\n                consequent: new Shift.BlockStatement({ block: new Shift.Block({ statements: [new Shift.ReturnStatement({ expression: new Shift.LiteralBooleanExpression({ value: false }) })] }) }),\n                alternate: null,\n              }));\n            }\n            o.push(...seqs.map(e => new Shift.ExpressionStatement({ expression: e })));\n            o.push(new Shift.ReturnStatement({ expression: suffix }));\n          }\n        } else if (s.expression.type === 'UnaryExpression' && s.expression.operator === 'void') {\n          o.push(new Shift.ExpressionStatement({ expression: s.expression.operand }));\n          o.push(new Shift.ReturnStatement({ expression: null }));\n        } else {\n          o.push(s);\n        }\n        // TODO: elsewhere, remove statements after returns (while preserving hoisted declarations)\n        break;\n      case 'BlockStatement':\n        if (s.block.statements.every(x => x.type !== 'FunctionDeclaration' && (x.type !== 'VariableDeclarationStatement' || x.declaration.kind === 'var'))) {\n          o.push(...s.block.statements);\n        } else {\n          o.push(s);\n        }\n        break;\n      case 'IfStatement':\n        if (isSequence(s.test)) {\n          const exprs = binExprToExprs(s.test);\n          const last = exprs.pop();\n          o.push(...exprs.map(e => new Shift.ExpressionStatement({ expression: e })));\n          o.push(new Shift.IfStatement({ test: last, consequent: s.consequent, alternate: s.alternate }));\n        } else if (s.test.type === 'BinaryExpression' && s.test.operator === '&&' && s.alternate == null) {\n          const extracted = extractSequenceFromConjunction(s.test, true);\n          if (extracted === null) {\n            o.push(s);\n          } else {\n            const { prefix, seqs, suffix } = extracted;\n            let newStatements = seqs.map(e => new Shift.ExpressionStatement({ expression: e }));\n            newStatements.push(new Shift.IfStatement({\n              test: suffix,\n              consequent: s.consequent,\n              alternate: null,\n            }));\n            if (prefix === null) {\n              o.push(...newStatements);\n            } else {\n              o.push(new Shift.IfStatement({\n                test: prefix,\n                consequent: new Shift.BlockStatement({ block: new Shift.Block({ statements: newStatements }) }),\n                alternate: null,\n              }));\n            }\n          }\n        } else {\n          o.push(s);\n        }\n        break;\n      case 'VariableDeclarationStatement':\n        if (s.declaration.declarators.length > 1) {\n          o.push(...declaratorsToDeclarationStatements(s.declaration.kind, s.declaration.declarators));\n        } else if (isSequence(s.declaration.declarators[0].init)) {\n          let originalDeclarator = s.declaration.declarators[0];\n          // Yes, these steps could be combined, but /shrug\n          const exprs = binExprToExprs(originalDeclarator.init);\n          const last = exprs.pop();\n          o.push(...exprs.map(e => new Shift.ExpressionStatement({ expression: e })));\n          const declarator = new Shift.VariableDeclarator({ binding: originalDeclarator.binding, init: last });\n          const declaration = new Shift.VariableDeclaration({ kind: s.declaration.kind, declarators: [declarator] });\n          o.push(new Shift.VariableDeclarationStatement({ declaration }));\n        } else {\n          o.push(s);\n        }\n        break;\n      case 'ForStatement':\n        if (s.init != null) {\n          if (s.init.type === 'VariableDeclaration' && s.init.declarators.length > 1) {\n            const declarators = [...s.init.declarators];\n            const finalDeclarator = declarators.pop();\n            const newDeclaration = new Shift.VariableDeclaration({ kind: s.init.kind, declarators: [finalDeclarator] });\n            o.push(...declaratorsToDeclarationStatements(s.init.kind, declarators));\n            o.push(new Shift.ForStatement({ init: newDeclaration, test: s.test, update: s.update, body: s.body }));\n          } else if (isSequence(s.init)) {\n            const exprs = binExprToExprs(s.init);\n            const last = exprs.pop();\n            o.push(...exprs.map(e => new Shift.ExpressionStatement({ expression: e })));\n            o.push(new Shift.ForStatement({ init: last, test: s.test, update: s.update, body: s.body }));\n          } else {\n            o.push(s);\n          }\n        }\n        break;\n      default:\n        o.push(s);\n    }\n  }\n\n  if (arrayEquals(o, statements)) {\n    return statements;\n  }\n  return o;\n}\n\n\nfunction arrayEquals(a, b) {\n  return a.length === b.length && a.every((v, i) => v === b[i]);\n}\n\nfunction hoistFunctionDeclarations(statements) {\n  const decls = [];\n  const nonDecls = [];\n  for (const statement of statements) {\n    if (statement.type === 'FunctionDeclaration') {\n      decls.push(statement);\n    } else {\n      nonDecls.push(statement);\n    }\n  }\n  const o = decls.concat(nonDecls);\n  if (arrayEquals(o, statements)) {\n    return statements;\n  }\n  return o;\n}\n\nclass Cleanup extends reducer.LazyCloneReducer {\n  reduceBlock(node, { statements }) {\n    return super.reduceBlock(node, { statements: fixStatementList(statements) });\n  }\n\n  reduceSwitchCase(node, { test, consequent }) {\n    return super.reduceSwitchCase(node, { test, consequent: fixStatementList(consequent) });\n  }\n\n  reduceSwitchDefault(node, { consequent }) {\n    return super.reduceSwitchDefault(node, { consequent: fixStatementList(consequent) });\n  }\n\n  reduceFunctionBody(node, { directives, statements }) {\n    statements = hoistFunctionDeclarations(fixStatementList(statements));\n    if (directives.length === 0 && statements.length === 1 && (statements[0].type === 'ExpressionStatement' || statements[0].type === 'ReturnStatement') && statements[0].expression != null && statements[0].expression.type === 'CallExpression' && statements[0].expression.arguments.length === 0) {\n      const callee = statements[0].expression.callee;\n      if (callee.type === 'FunctionExpression' && callee.name === null && callee.params.items.length === 0 && callee.params.rest === null && !functionContainsWeirdness(callee)) {\n        return statements[0].type === 'ExpressionStatement' ? makeReturnsUndefined(callee.body) : callee.body;\n      }\n    }\n    if (statements.length > 0 && statements[statements.length - 1].type === 'ReturnStatement' && statements[statements.length - 1].expression == null) {\n      statements = statements.slice(0, -1);\n    }\n    return super.reduceFunctionBody(node, { directives, statements });\n  }\n\n  reduceScript(node, { directives, statements }) {\n    return super.reduceScript(node, { directives, statements: fixStatementList(statements) });\n  }\n\n  reduceUnaryExpression(node, { operand }) {\n    if (node.operator === '!') {\n      const negated = negate(operand, false, false);\n      if (negated) {\n        return negated;\n      }\n    }\n    return super.reduceUnaryExpression(node, { operand });\n  }\n\n  reduceBinaryExpression(node, { left, right }) {\n    // 1 == a -> a == 1\n    if (['==', '===', '!=', '!=='].includes(node.operator) && isConstant(left) && !isConstant(right)) {\n      return new Shift.BinaryExpression({ left: right, operator: node.operator, right: left });\n    }\n    if (node.operator === ',' && inlinable.includes(left.type)) {\n      return right;\n    }\n    return super.reduceBinaryExpression(node, { left, right });\n  }\n\n  reduceExpressionStatement(node, { expression }) {\n    if (expression.type === 'ConditionalExpression') {\n      return new Shift.IfStatement({ test: expression.test, consequent: new Shift.ExpressionStatement({ expression: expression.consequent }), alternate: new Shift.ExpressionStatement({ expression: expression.alternate }) });\n    } else if (expression.type === 'BinaryExpression' && expression.operator === '&&') {\n      return new Shift.IfStatement({ test: expression.left, consequent: new Shift.ExpressionStatement({ expression: expression.right }), alternate: null });\n    } else if (expression.type === 'BinaryExpression' && expression.operator === '||') {\n      return new Shift.IfStatement({ test: new Shift.UnaryExpression({ operator: '!', operand: expression.left }), consequent: new Shift.ExpressionStatement({ expression: expression.right }), alternate: null });\n    } else if (expression.type === 'UnaryExpression' && expression.operator === '!') {\n      return new Shift.ExpressionStatement({ expression: expression.operand });\n    }\n    return super.reduceExpressionStatement(node, { expression });\n  }\n\n  reduceIfStatement(node, { test, consequent, alternate }) {\n    if (test.type === 'UnaryExpression' && test.operator === '!') {\n      test = negate(test.operand, true, false) || test;\n    }\n    if (test.type === 'BinaryExpression' && (test.operator === '!=' || test.operator === '!==') && alternate != null) {\n      test = negate(test, true);\n      [consequent, alternate] = [alternate, consequent];\n    }\n    if (consequent.type !== 'BlockStatement') {\n      consequent = makeBlock(consequent);\n    }\n    if (alternate != null) {\n      if (alternate.type !== 'BlockStatement' && alternate.type !== 'IfStatement') {\n        alternate = makeBlock(alternate);\n      } else if (alternate.type === 'BlockStatement' && alternate.block.statements.length === 1 && alternate.block.statements[0].type === 'IfStatement') {\n        alternate = alternate.block.statements[0];\n      }\n      if (alternate.type === 'BlockStatement' && alternate.block.statements.length === 0) {\n        alternate = null;\n      }\n    }\n    return super.reduceIfStatement(node, { test, consequent, alternate });\n  }\n\n  reduceConditionalExpression(node, { test, consequent, alternate }) {\n    if (test.type === 'UnaryExpression' && test.operator === '!') {\n      test = negate(test.operand, true, false) || test;\n    }\n    return super.reduceConditionalExpression(node, { test, consequent, alternate });\n  }\n\n  reduceForStatement(node, { init, test, update, body }) {\n    if (body.type !== 'BlockStatement') {\n      body = makeBlock(body);\n    }\n    if (init == null && test != null && update == null) {\n      return new Shift.WhileStatement({ test, body });\n    }\n    return super.reduceForStatement(node, { init, test, update, body });\n  }\n\n  reduceForInStatement(node, { left, right, body }) {\n    if (body.type !== 'BlockStatement') {\n      body = makeBlock(body);\n    }\n    return super.reduceForInStatement(node, { left, right, body });\n  }\n\n  reduceForOfStatement(node, { left, right, body }) {\n    if (body.type !== 'BlockStatement') {\n      body = makeBlock(body);\n    }\n    return super.reduceForOfStatement(node, { left, right, body });\n  }\n\n  reduceWhileStatement(node, { test, body }) {\n    if (body.type !== 'BlockStatement') {\n      body = makeBlock(body);\n    }\n    return super.reduceWhileStatement(node, { test, body });\n  }\n\n  reduceDoWhileStatement(node, { body, test }) {\n    if (body.type !== 'BlockStatement') {\n      body = makeBlock(body);\n    }\n    return super.reduceDoWhileStatement(node, { body, test });\n  }\n\n  reduceComputedMemberAssignmentTarget(node, { object, expression }) {\n    if (expression.type === 'LiteralStringExpression' && esutils.keyword.isIdentifierNameES6(expression.value)) {\n      return new Shift.StaticMemberAssignmentTarget({ object, property: expression.value });\n    }\n    return super.reduceComputedMemberAssignmentTarget(node, { object, expression });\n  }\n\n  reduceComputedMemberExpression(node, { object, expression }) {\n    if (expression.type === 'LiteralStringExpression' && esutils.keyword.isIdentifierNameES6(expression.value)) {\n      return new Shift.StaticMemberExpression({ object, property: expression.value });\n    }\n    return super.reduceComputedMemberExpression(node, { object, expression });\n  }\n\n  reduceCallExpression(node, { callee, arguments: _arguments }) {\n    if (callee.type === 'FunctionExpression' && !callee.isGenerator && !functionContainsWeirdness(callee)) {\n      if (_arguments.length === 0 && callee.params.rest === null && callee.params.items.length === 0 && callee.body.directives.length === 0 && callee.body.statements.length <= 1) {\n        // turn iifes with very simple bodies into expressions with no calls\n        if (callee.body.statements.length === 0) {\n          return new Shift.UnaryExpression({ operator: 'void', operand: new Shift.LiteralNullExpression });\n        }\n        const statement = callee.body.statements[0];\n        if (statement.type === 'ReturnStatement') {\n          return statement.expression;\n        }\n        if (statement.type === 'ExpressionStatement') {\n          return new Shift.BinaryExpression({ left: statement.expression, operator: ',', right: new Shift.UnaryExpression({ operator: 'void', operand: new Shift.LiteralNullExpression }) }); // `(expr, void 0)`\n        }\n      }\n    }\n    return super.reduceCallExpression(node, { callee, arguments: _arguments });\n  }\n}\n\n\nconst cleaner = new Cleanup;\n\nmodule.exports = function cleanup(ast) {\n  return reducer.default(cleaner, ast);\n};\n"
  },
  {
    "path": "src/transforms/unsafe/remove-unused.js",
    "content": "'use strict';\n\n// Remove unused variables and object properties which are initialized to constants.\n\nconst scope = require('shift-scope');\nconst reducer = require('shift-reducer');\nconst Shift = require('shift-ast/checked');\n\nconst getParents = require('../../helpers/parents');\nconst inlinable = require('../../helpers/inlinable');\n\n\nfunction isOnlyWritten(node, parents, lookup) {\n  if (node.type !== 'AssignmentTargetIdentifier') {\n    return false;\n  }\n  const vs = lookup.lookup(node);\n  if (vs.length === 1 && lookup.scope.variableList.indexOf(vs[0]) === -1) {\n    const reads = vs[0].references.filter(r => r.accessibility.isRead);\n\n    return reads.length === 0 || reads.every(r => {\n      if (!r.accessibility.isWrite) {\n        return false;\n      }\n      const parent = parents.get(r.node);\n      if (parent == null || !(parent.type === 'CompoundAssignmentExpression' || parent.type === 'UpdateExpression')) {\n        return false;\n      }\n\n      const gp = parents.get(parent);\n      return gp.type === 'ExpressionStatement';\n    });\n  }\n  return false;\n}\n\nmodule.exports = function removeUnused(ast) {\n  const globalScope = scope.default(ast);\n  const lookup = new scope.ScopeLookup(globalScope);\n  const parents = getParents(ast);\n\n  class RemoveUnused extends reducer.LazyCloneReducer {\n    reduceVariableDeclarationStatement(node, { declaration }) {\n      // This strips declarations of variables initialized to constants if those variables are never referred to.\n      const declarators = declaration.declarators.filter((d, i) => {\n        const oldD = node.declaration.declarators[i];\n        if (d.binding.type !== 'BindingIdentifier' || d.init == null || !(\n          inlinable.includes(d.init.type)\n          || d.init.type === 'FunctionExpression'\n          || d.init.type === 'ObjectExpression' && d.init.properties.length === 0\n          || d.init.type === 'ArrayExpression' && d.init.elements.every(e => inlinable.includes(e.type))\n        )) return true;\n        const v = lookup.lookup(oldD.binding)[0];\n        if (v.declarations.length !== 1 || lookup.scope.variableList.includes(v)) return true;\n        return v.references.length !== 1;\n      });\n      if (declarators.length === 0) {\n        return new Shift.EmptyStatement;\n      } else if (declarators.length === 1) {\n        const binding = declarators[0].binding;\n        if (binding.type === 'BindingIdentifier') {\n          const v = lookup.lookup(binding)[0];\n          if (v.references.every(ref => ref.node === binding) && !lookup.scope.variableList.includes(v)) {\n            if (declarators[0].init === null) {\n              return new Shift.EmptyStatement;\n            }\n            return new Shift.ExpressionStatement({ expression: declarators[0].init });\n          }\n        }\n      }\n\n      if (declarators.length === declaration.declarators.length) {\n        return super.reduceVariableDeclarationStatement(node, { declaration });\n      }\n\n      return new Shift.VariableDeclarationStatement({ declaration: new Shift.VariableDeclaration({ kind: declaration.kind, declarators }) });\n    }\n\n    reduceVariableDeclarator(node, { binding, init }) {\n      // This strips properties from object literals used to initialize variables provided that\n      // a.) no one ever refers to that variable except to read a static property of it,\n      // b.) no one ever tries to read that property, and\n      // c.) the object contains only data properties.\n      // TODO make this safe by asserting that all properties ever referred to are present on the object (so they never go up to Object.prototype)\n      if (init !== null && init.type === 'ObjectExpression' && init.properties.every(p => p.type === 'DataProperty')) {\n        const v = lookup.lookup(node.binding)[0];\n        const referencedNames = new Set;\n        if (v.references.every(r => {\n          if (r.node === node.binding) return true; // We don't care about the declaration itself.\n          const parent = parents.get(r.node);\n          if (parent.type !== 'StaticMemberExpression') return false;\n          referencedNames.add(parent.property);\n          return true;\n        })) {\n          const properties = init.properties.filter(p => {\n            return !(inlinable.includes(p.expression.type) || p.expression.type === 'FunctionExpression') || p.name.type !== 'StaticPropertyName' || referencedNames.has(p.name.value);\n          });\n          if (properties.length === init.properties.length) {\n            return super.reduceVariableDeclarator(node, { binding, init });\n          }\n          const obj = new Shift.ObjectExpression({ properties });\n          return new Shift.VariableDeclarator({ binding, init: obj });\n        }\n      }\n      return super.reduceVariableDeclarator(node, { binding, init });\n    }\n\n    reduceAssignmentExpression(node, { binding, expression }) {\n      if (isOnlyWritten(node.binding, parents, lookup)) {\n        return expression;\n      }\n      return super.reduceAssignmentExpression(node, { binding, expression });\n    }\n\n    reduceCompoundAssignmentExpression(node, { binding, expression }) {\n      if (isOnlyWritten(node.binding, parents, lookup)) {\n        return expression;\n      }\n      return super.reduceCompoundAssignmentExpression(node, { binding, expression });\n    }\n  }\n\n  return reducer.default(new RemoveUnused, ast);\n};\n"
  },
  {
    "path": "src/transforms/wildly-unsafe/inline.js",
    "content": "'use strict';\n\n// Inline constant primitive variables, constant primitive object properties, and constant object properties which are particularly trivial functions.\n\nconst shiftScope = require('shift-scope');\nconst reducer = require('shift-reducer');\nconst Shift = require('shift-ast/checked');\n\nconst getParents = require('../../helpers/parents');\nconst inlinable = require('../../helpers/inlinable');\n\n\nmodule.exports = function inline(ast) {\n\n  const globalScope = shiftScope.default(ast);\n  const lookup = new shiftScope.ScopeLookup(globalScope);\n  const parents = getParents(ast);\n\n  function findScopeForNode(node, scope = globalScope) {\n    // TODO this should live elsewhere\n    if (scope.astNode === node) return scope;\n    for (let child of scope.children) {\n      const r = findScopeForNode(node, child);\n      if (r !== null) return r;\n    }\n    return null;\n  }\n\n  function isConstantInitializedVariable(v) {\n    if (!isConstantVariable(v)) {\n      return false;\n    }\n    const parent = parents.get(v.declarations[0].node);\n    if (parent.type !== 'VariableDeclarator') {\n      return false;\n    }\n    return parent.init !== null;\n  }\n\n  function isConstantVariable(v) {\n    // TODO this also needs to check that use-before-def is impossible\n    if (v.declarations.length !== 1) return false;\n    const binding = v.declarations[0].node;\n    const parent = parents.get(binding);\n    if (parent.type !== 'VariableDeclarator' && parent.type !== 'FormalParameters') return false;\n    if (v.references.some(r => r.accessibility.isWrite && r.node !== binding)) return false;\n    return true;\n  }\n\n  function getConstantObjectVariableObject(_var) {\n    // TODO for this to be actually correct we'd also need to check that none of the properties of the object are functions binding 'this'\n    if (!isConstantInitializedVariable(_var)) return null;\n    const binding = _var.declarations[0].node;\n    const parent = parents.get(binding);\n    if (parent.init == null) return null;\n    if (parent.init.type === 'ObjectExpression' || parent.init.type === 'ArrayExpression') {\n      if (_var.references.some(r => {\n        const rparent = parents.get(r.node);\n        return rparent.type === 'StaticMemberAssignmentTarget' || rparent.type === 'ComputedMemberAssignmentTarget' && rparent.object === r.node;\n      })) return null;\n      const obj = parent.init;\n\n      if (obj.type === 'ObjectExpression') {\n        return new Map(obj.properties.filter(p => p.type === 'DataProperty' && p.name.type === 'StaticPropertyName').map(p => [p.name.value, p.expression])); // TODO could include methods, in principle\n      } else if (obj.type === 'ArrayExpression') {\n        return new Map(obj.elements.map((v, i) => [i, v]));\n      }\n      throw 'not reached;';\n\n    } else {\n      return null;\n    }\n  }\n\n  function findStatementParent(node) {\n    while (!/Statement/.test(node.type) && node.type !== 'FunctionDeclaration') {\n      // eslint-disable-next-line no-param-reassign\n      node = parents.get(node);\n    }\n    return node;\n  }\n\n\n  function getInlining(node) {\n    const vars = lookup.lookup(node);\n    if (vars.length !== 1) return null;\n    const v = vars[0];\n    if (!isConstantInitializedVariable(v)) return null;\n    const init = parents.get(v.declarations[0].node).init;\n    if (init.type === 'IdentifierExpression') {\n      const indirectVars = lookup.lookup(init);\n      if (indirectVars.length === 1 && isConstantVariable(indirectVars[0])) {\n        return new Shift.IdentifierExpression(init);\n      }\n    }\n    if (!inlinable.includes(init.type)) return null;\n\n    return { ...init };\n  }\n\n\n  function getTriviallyInlineableFunction(f, arglen) {\n    if (f.type !== 'FunctionExpression') return null;\n    if (f.params.items.length !== arglen) return null;\n    if (f.body.directives.length > 0) return null;\n    if (f.body.statements.length !== 1) return null;\n    if (f.body.statements[0].type !== 'ReturnStatement') return null;\n    if (f.body.statements[0].expression.type !== 'BinaryExpression') return null;\n    const expr = f.body.statements[0].expression;\n\n    if (arglen === 2) {\n      if (expr.left.type !== 'IdentifierExpression' || lookup.lookup(expr.left)[0] !== lookup.lookup(f.params.items[0])[0]) return null;\n      if (expr.right.type !== 'IdentifierExpression' || lookup.lookup(expr.right)[0] !== lookup.lookup(f.params.items[1])[0]) return null;\n      return (left, right) => new Shift.BinaryExpression({ left, operator: expr.operator, right });\n    } else if (arglen === 3) {\n      if (expr.left.type !== 'BinaryExpression') return null;\n      const expr2 = expr.left;\n      if (expr2.left.type !== 'IdentifierExpression' || lookup.lookup(expr2.left)[0] !== lookup.lookup(f.params.items[0])[0]) return null;\n      if (expr2.right.type !== 'IdentifierExpression' || lookup.lookup(expr2.right)[0] !== lookup.lookup(f.params.items[1])[0]) return null;\n      if (expr.right.type !== 'IdentifierExpression' || lookup.lookup(expr.right)[0] !== lookup.lookup(f.params.items[2])[0]) return null;\n\n      return (a, b, right) => new Shift.BinaryExpression({ left: new Shift.BinaryExpression({ left: a, operator: expr2.operator, right: b }), operator: expr.operator, right });\n    }\n    return null;\n  }\n\n  class InliningReducer extends reducer.LazyCloneReducer {\n    reduceExpressionStatement(node, { expression }) {\n      if (expression.type === 'IdentifierExpression') {\n        return new Shift.EmptyStatement;\n      }\n      return super.reduceExpressionStatement(node, { expression });\n    }\n\n    reduceCallExpression(node, { callee, arguments: _arguments }) {\n      if (callee.type === 'StaticMemberExpression' && callee.object.type === 'IdentifierExpression' && (_arguments.length === 2 || _arguments.length === 3)) {\n        const vs = lookup.lookup(node.callee.object);\n        if (vs.length === 1) {\n          const obj = getConstantObjectVariableObject(vs[0]);\n          if (obj !== null && obj.has(callee.property)) {\n            const val = obj.get(callee.property);\n            const replacer = getTriviallyInlineableFunction(val, _arguments.length);\n            if (replacer !== null) {\n              return replacer(..._arguments);\n            }\n          }\n        }\n      } else if (callee.type === 'IdentifierExpression') {\n        const vs = lookup.lookup(node.callee);\n        if (vs.length === 1 && isConstantInitializedVariable(vs[0]) && lookup.scope.variableList.indexOf(vs[0]) === -1) {\n          const v = vs[0];\n          const decl = parents.get(v.declarations[0].node);\n          if (decl.init.type === 'FunctionExpression') {\n            const f = decl.init;\n            let scope = findScopeForNode(f);\n            if (scope !== null && scope.through.size === 0) {\n\n              // This is to handle specifically `var x = function (foo) { if (foo == 'bar') { return a; } else { return b; } }; y = x('bar'); z = x('baz'); w = x();`\n              if (f.params.items.length === 1 && _arguments.length <= 1) {\n                const pv = lookup.lookup(f.params.items[0])[0];\n                if (pv.references.length === 1 && f.body.statements.length === 1 && f.body.statements[0].type === 'IfStatement') {\n                  const consequent = f.body.statements[0].consequent;\n                  const alternate = f.body.statements[0].alternate;\n                  if (consequent.type === 'BlockStatement' && consequent.block.statements.length === 1 && consequent.block.statements[0].type === 'ReturnStatement' && alternate.type === 'BlockStatement' && alternate.block.statements.length === 1 && alternate.block.statements[0].type === 'ReturnStatement') {\n                    const test = f.body.statements[0].test;\n                    if (test.type === 'BinaryExpression' && test.operator.slice(0, 2) === '==' && test.left.type === 'IdentifierExpression' && lookup.lookup(test.left)[0] === pv && inlinable.includes(test.right.type)) {\n                      const conditional = new Shift.ConditionalExpression({ test: { ...test }, consequent: consequent.block.statements[0].expression, alternate: alternate.block.statements[0].expression });\n                      if (_arguments.length === 1) {\n                        conditional.test.left = _arguments[0];\n                      } else {\n                        conditional.test.left = new Shift.UnaryExpression({ operator: 'void', operand: new Shift.LiteralNumericExpression({ value: 0 }) });\n                      }\n                      return conditional;\n                    }\n                  }\n                }\n              }\n            }\n\n            if (v.references.length === 2) {\n              // inline functions which are only called once\n              const p1 = findStatementParent(v.references[0].node);\n              const p2 = findStatementParent(v.references[0].node);\n              if (scope.through.size === 0 || parents.get(p1) === parents.get(p2)) {\n                // This ensures any through references get resolved the same after inlining\n                return new Shift.CallExpression({ callee: reducer.default(new reducer.CloneReducer, f), arguments: _arguments });\n              }\n            }\n          }\n        }\n      }\n      return super.reduceCallExpression(node, { callee, arguments: _arguments });\n    }\n\n    reduceIdentifierExpression(node) {\n      const inlining = getInlining(node);\n      if (inlining !== null) return inlining;\n      return super.reduceIdentifierExpression(node);\n    }\n\n    reduceComputedMemberExpression(node, { object, expression }) {\n      if (node.object.type === 'IdentifierExpression' && expression.type === 'LiteralNumericExpression') {\n        const vs = lookup.lookup(node.object);\n        if (vs.length === 1) {\n          const obj = getConstantObjectVariableObject(vs[0]);\n          if (obj !== null && obj.has(expression.value)) {\n            const val = obj.get(expression.value);\n            if (inlinable.includes(val.type)) {\n              return new Shift[val.type](val);\n            }\n          }\n        }\n      }\n      return super.reduceComputedMemberExpression(node, { object, expression });// new Shift.ComputedMemberExpression({object, expression});\n    }\n\n    reduceStaticMemberExpression(node, { object }) {\n      if (node.object.type === 'IdentifierExpression') {\n        const vs = lookup.lookup(node.object);\n        if (vs.length === 1) {\n          const obj = getConstantObjectVariableObject(vs[0]);\n          if (obj !== null && obj.has(node.property)) {\n            const val = obj.get(node.property);\n            if (inlinable.includes(val.type)) {\n              return { ...val };\n            }\n          }\n        }\n      }\n      return super.reduceStaticMemberExpression(node, { object });\n    }\n  }\n\n  return reducer.default(new InliningReducer, ast);\n};\n"
  },
  {
    "path": "src/transforms/wildly-unsafe/partial-evaluate.js",
    "content": "'use strict';\n\nconst reducer = require('shift-reducer');\nconst Shift = require('shift-ast/checked');\nconst shiftScope = require('shift-scope');\n\nconst getParents = require('../../helpers/parents');\n\nconst none = {};\n\nfunction constantToNode(c) {\n  switch (typeof c) {\n    case 'undefined':\n      return new Shift.UnaryExpression({ operator: 'void', operand: new Shift.LiteralNumericExpression({ value: 0 }) });\n    case 'number':\n      return new Shift.LiteralNumericExpression({ value: c });\n    case 'string':\n      return new Shift.LiteralStringExpression({ value: c });\n    case 'boolean':\n      return new Shift.LiteralBooleanExpression({ value: c });\n    case 'object':\n      if (Array.isArray(c)) {\n        const elements = c.map(constantToNode);\n        return new Shift.ArrayExpression({ elements });\n      }\n      // falls through\n    default:\n      throw new Error('cannot handle ' + typeof c);\n  }\n}\n\nconst globalFunctions = {\n  decodeURI,\n  decodeURIComponent,\n  unescape,\n  parseInt,\n  parseFloat,\n};\n\nconst isNonMutatingArrayMethod = p => ['slice', 'forEach', 'map', 'filter', 'reduce', 'indexOf'].includes(p);\n\nmodule.exports = function partialEvaluate(ast) {\n\n  const parents = getParents(ast);\n  const globalScope = shiftScope.default(ast);\n  const lookup = new shiftScope.ScopeLookup(globalScope);\n\n  function getStaticInit(node) {\n    // This is unsafe in that it assumes no use-before-def\n    const vs = lookup.lookup(node);\n    if (vs && vs.length === 1) {\n      const v = vs[0];\n      if (v.declarations.length === 1) {\n        const binding = v.declarations[0].node;\n        const parent = parents.get(binding);\n        if (parent.type === 'VariableDeclarator' && parent.init !== null && v.references.every(r => !(r.accessibility.isWrite && r.node !== binding))) {\n          return { initNode: parent.init, variable: v };\n        }\n      }\n    }\n    return { initNode: null };\n  }\n\n  function evaluateToNode(node) {\n    const value = evaluate(node);\n    if (value !== none && (typeof value !== 'object' || value === null) && typeof value !== 'function') {\n      const rv = constantToNode(value);\n      if (rv.type === 'UnaryExpression' && rv.type === node.type && rv.operator === 'void' && rv.operator === node.operator && rv.operand.type === 'LiteralNumericExpression' && rv.operand.type === node.operand.type && rv.operand.value === node.operand.value) {\n        return node;\n      }\n      return rv;\n    }\n    return node;\n  }\n\n\n  const seen = new WeakMap;\n  function evaluate(node) {\n    if (seen.has(node)) {\n      return seen.get(node);\n    }\n    seen.set(node, none);\n    const out = evaluateCore(node);\n    if (out !== none) {\n      seen.set(node, out);\n    }\n    return out;\n  }\n  function evaluateCore(node) {\n    switch (node.type) {\n      case 'ArrayExpression': {\n        const evaluated = node.elements.map(e => e === null ? void 0 : evaluate(e));\n        if (evaluated.every(v => v !== none)) {\n          return evaluated;\n        }\n        break;\n      }\n      case 'LiteralNumericExpression':\n      case 'LiteralStringExpression':\n      case 'LiteralBooleanExpression':\n        return node.value;\n      case 'LiteralRegExpExpression':\n        // Not actually safe, since regexps have identity\n        if (!node.global && !node.ignoreCase && !node.multiLine && !node.sticky && !node.unicode) {\n          return new RegExp(node.pattern);\n        }\n        break;\n      case 'UnaryExpression': {\n        const operand = evaluate(node.operand);\n        if (operand !== none) {\n          switch (node.operator) {\n            case '+':\n              return +operand;\n            case 'void':\n              return void 0;\n            case '-':\n              return -operand;\n            case '!':\n              return !operand;\n            case '~':\n              return ~operand;\n            case 'typeof':\n              return typeof operand;\n            default:\n              throw new Error('useful unary operator: ' + node.operator + ' ' + operand);\n          }\n        }\n        break;\n      }\n      case 'BinaryExpression': {\n        const left = evaluate(node.left);\n        const right = evaluate(node.right);\n        if (left !== none && right !== none) {\n          switch (node.operator) {\n            case '===':\n              return left === right;\n            case '!==':\n              return left !== right;\n            case '==':\n              // eslint-disable-next-line eqeqeq\n              return left == right;\n            case '!=':\n              // eslint-disable-next-line eqeqeq\n              return left != right;\n            case '>':\n              return left > right;\n            case '<':\n              return left < right;\n            case '>=':\n              return left >= right;\n            case '<=':\n              return left <= right;\n            case '+':\n              return left + right;\n            case '-':\n              return left - right;\n            case '*':\n              return left * right;\n            case '/':\n              return left / right;\n            case '%':\n              return left % right;\n            case '||':\n              return left || right;\n            case '&&':\n              return left && right;\n            case '<<':\n              return left << right;\n            case '>>':\n              return left >> right;\n            case '>>>':\n              return left >>> right;\n            case '|':\n              return left | right;\n            case '&':\n              return left & right;\n            case '^':\n              return left ^ right;\n            case 'in':\n              // If this happens, something may have gone wrong.\n              break;\n            default:\n              throw new Error('useful binary operator: ' + node.operator + ' ' + left + ' ' + right);\n          }\n        }\n        break;\n      }\n      case 'IdentifierExpression': {\n        if (node.name in globalFunctions) {\n          const vs = lookup.lookup(node);\n          if (vs.length === 1) {\n            const refs = vs[0].references;\n            if (vs[0].declarations.length === 0 && !refs.some(r => r.accessibility.isWrite)) {\n              return globalFunctions[node.name];\n            }\n          }\n        }\n\n        // TODO this isn't actually safe, for several reasons\n        const { initNode, variable } = getStaticInit(node);\n        if (initNode !== null) {\n          const val = evaluate(initNode);\n          if (val !== none) {\n            if (Array.isArray(val)) {\n              for (let r of variable.references) {\n                let p = parents.get(r.node);\n                if (p.type === 'StaticMemberExpression') {\n                  if (!(isNonMutatingArrayMethod(p.property) || p.property === 'length')) {\n                    return none;\n                  }\n                } else if (p.type === 'StaticMemberAssignmentTarget' || p.type === 'ComputedMemberAssignmentTarget') {\n                  return none;\n                } else if (p.type === 'ComputedMemberExpression') {\n                  const gp = parents.get(p);\n                  if (gp.type === 'CallExpression' && gp.callee === p) {\n                    return none;\n                  }\n                }\n              }\n            }\n            return val;\n          }\n        }\n        break;\n      }\n      case 'CallExpression': {\n        // TODO factor these cases better\n        const argVals = node.arguments.map(evaluate);\n        if (argVals.every(v => v !== none)) {\n          if (node.callee.type === 'StaticMemberExpression') {\n\n            // TODO factor this and similar cases out to something else\n            if (node.callee.object.type === 'IdentifierExpression' && node.callee.object.name === 'String' && node.callee.property === 'fromCharCode' && node.arguments.length === 1 && node.arguments[0].type === 'LiteralNumericExpression') {\n              return String.fromCharCode(node.arguments[0].value);\n            }\n\n\n            const objVal = evaluate(node.callee.object);\n            if (objVal !== none) {\n              if (typeof objVal !== 'object') {\n                if (typeof objVal !== 'function') {\n                  return objVal[node.callee.property](...argVals);\n                }\n              } else if (Array.isArray(objVal) && isNonMutatingArrayMethod(node.callee.property)) {\n                return objVal[node.callee.property](...argVals);\n              }\n            }\n          }\n\n          const calleeVal = evaluate(node.callee);\n          if (typeof calleeVal === 'function') {\n            let c = calleeVal(...argVals);\n            return c;\n          }\n        }\n        break;\n      }\n      case 'StaticMemberExpression': {\n        if (node.property === 'length' && node.object.type === 'ArrayExpression') {\n          return node.object.elements.length;\n        }\n        return evaluateStaticProperty(node.object, node.property);\n      }\n    }\n    return none;\n  }\n\n  function evaluateStaticProperty(object, property) {\n    // TODO this has a lot of overlap with inline.js\n    // this interacts poorly with getters\n    const objVal = evaluate(object);\n    if (objVal !== none && typeof objVal !== 'object' && typeof objVal !== 'function') {\n      if (property in Object(objVal)) {\n        return objVal[property];\n      }\n      return none;\n    }\n    if (object.type === 'IdentifierExpression') {\n      const { initNode, variable } = getStaticInit(object); // TODO this is not sufficient; we also need to check it doesn't leak\n      if (initNode !== null) {\n        const leaks = variable.references.some(r => {\n          if (r.accessibility.isRead) {\n            const parent = parents.get(r.node);\n            return parent.type !== 'StaticMemberExpression' && parent.type !== 'ComputedMemberAssignmentTarget' && parent.type !== 'StaticMemberAssignmentTarget' && parent.type !== 'ComputedMemberAssignmentTarget';\n          }\n          return false;\n        });\n        if (!leaks && (initNode.type === 'FunctionExpression' || initNode.type === 'ObjectExpression' && initNode.properties.every(p => p.type === 'DataProperty' && p.name.type === 'StaticPropertyName'))) {\n          const hasComputedWrite = variable.references.some(r => {\n            const parent = parents.get(r.node);\n            return parent.type === 'ComputedMemberAssignmentTarget' && parent.object === r.node;\n          });\n          if (!hasComputedWrite) {\n            const hasProperty = initNode.type === 'ObjectExpression' && initNode.properties.filter(p => p.name.value === property).length === 1;\n            const propertyWrites = variable.references.filter(r => {\n              const parent = parents.get(r.node);\n              return parent.type === 'StaticMemberAssignmentTarget' && parent.property === property;\n            });\n            if (!hasProperty && propertyWrites.length === 1) {\n              const gp = parents.get(parents.get(propertyWrites[0].node));\n              if (gp.type === 'AssignmentExpression') {\n                return evaluate(gp.expression);\n              }\n            } else if (hasProperty && propertyWrites.length === 0) {\n              for (let p of initNode.properties) {\n                if (p.name.value === property) {\n                  return evaluate(p.expression);\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n    return none;\n  }\n\n  class Evaluate extends reducer.LazyCloneReducer {\n    reduceUnaryExpression(node, { operand }) {\n      return evaluateToNode(super.reduceUnaryExpression(node, { operand }));\n    }\n\n    reduceBinaryExpression(node, { left, right }) {\n      return evaluateToNode(super.reduceBinaryExpression(node, { left, right }));\n    }\n\n    reduceCallExpression(node, { callee, arguments: _arguments }) {\n      return evaluateToNode(super.reduceCallExpression(node, { callee, arguments: _arguments }));\n    }\n\n    reduceStaticMemberExpression(node, { object }) {\n      return evaluateToNode(super.reduceStaticMemberExpression(node, { object }));\n    }\n\n    reduceIdentifierExpression(node) {\n      return evaluateToNode(node);\n    }\n\n    reduceComputedMemberExpression(node, { object, expression }) {\n      const clone = super.reduceComputedMemberExpression(node, { object, expression });\n      const parent = parents.get(node);\n      if (parent.type !== 'CallExpression' || parent.callee !== node) {\n        if (object.type === 'ArrayExpression' || object.type === 'LiteralStringExpression') {\n          const isArray = object.type === 'ArrayExpression';\n          const index = evaluate(expression);\n          if (index !== none) {\n            if (index === 'length') {\n              return constantToNode((isArray ? object.elements : object.value).length);\n            }\n            const coerced = +('' + index);\n            if (!Number.isNaN(coerced) && Math.floor(coerced) === coerced && coerced.toString() === '' + index) {\n              if (coerced >= (isArray ? object.elements : object.value).length) {\n                return constantToNode(void 0);\n              }\n              return isArray ? object.elements[index] : constantToNode(object.value[index]);\n            }\n          }\n        }\n      }\n      return clone;\n    }\n\n    reduceConditionalExpression(node, { test, consequent, alternate }) {\n      const clone = super.reduceConditionalExpression(node, { test, consequent, alternate });\n      const testValue = evaluate(clone.test);\n      if (testValue !== none) {\n        return testValue ? consequent : alternate;\n      }\n      return clone;\n    }\n\n    reduceIfStatement(node, { test, consequent, alternate }) {\n      // Note: this needs to pull var declarations out of the untaken branch\n      const clone = super.reduceIfStatement(node, { test, consequent, alternate });\n      const testValue = evaluate(clone.test);\n      if (testValue !== none) {\n        if (testValue) {\n          return consequent;\n        }\n        if (alternate === null) {\n          return new Shift.EmptyStatement;\n        }\n        return alternate;\n\n\n      }\n      return clone;\n    }\n  }\n\n  return reducer.default(new Evaluate, ast);\n};\n"
  },
  {
    "path": "test/snapshots-in/computed-member-to-static.js",
    "content": "a['b'];\na['b'] = 0;\na[0];\na['0'];"
  },
  {
    "path": "test/snapshots-in/expand-expression-statement.js",
    "content": "foo(), this, void bar(), void 0, new baz;"
  },
  {
    "path": "test/snapshots-in/expand-multiple-decl.js",
    "content": "function f(){\n  var a = foo(), b = bar();\n  for (var c = foo(), d = bar(); false;);\n  return a + b + c + d;\n}"
  },
  {
    "path": "test/snapshots-in/expand-sequence.js",
    "content": "if(a(), b()) {\n  c();\n}\nfunction f(){\n  var a = (b(), c);\n  return d(), a;\n}\nthrow f(), g;\nfor((a(), b()); false;);"
  },
  {
    "path": "test/snapshots-in/hoist-fns.js",
    "content": "function f(){\n  foo();\n  function bar(){}\n  return bar;\n}"
  },
  {
    "path": "test/snapshots-in/if-and-seq.js",
    "content": "if (a && (b, c) && d) {\n  foo();\n}\n\nif ((b, c) && d) {\n  foo();\n}\n\nif (a && (b, c)) {\n  foo();\n}\n"
  },
  {
    "path": "test/snapshots-in/if-not.js",
    "content": "if (a !== b) {\n  foo();\n} else {\n  bar();\n}"
  },
  {
    "path": "test/snapshots-in/indexing.js",
    "content": "[0][0]();\nf([0, 1, 2][1]);\nf('abcd'[2]);\nf('' + [][0]);\nf('abcd'[5]);\nf([0, 1, 2].length);\nf('abcd'.length);\nf([].map);\n"
  },
  {
    "path": "test/snapshots-in/inline-arguments.js",
    "content": "(function(a, b){ return a + b; })(foo(), bar(), baz());\n(function(a, b, c){ return a + b + c; })(foo(), bar());"
  },
  {
    "path": "test/snapshots-in/inline-called-once.js",
    "content": "function f() {\n  var x = function(a){ return a + foo(); }\n  return x(a);\n}"
  },
  {
    "path": "test/snapshots-in/inline-constant-object-property.js",
    "content": "var x = {\n  a: 0,\n};\ny = x.a;\n"
  },
  {
    "path": "test/snapshots-in/inline-function-as-conditional.js",
    "content": "function f(){\n\n  var x = function (foo) { if (foo == 'bar') return 'a'; else return 'b'; };\n  var y = x(a);\n  var z = x(b);\n  var w = x();\n  return y + z + w;\n}\n"
  },
  {
    "path": "test/snapshots-in/inline-iife.js",
    "content": "function f () {\n  (function() {\n    foo();\n  })();\n\n  x = function(){ return 0; }();\n  x = function(){ foo(); }();\n}\n"
  },
  {
    "path": "test/snapshots-in/inline-trivial-function.js",
    "content": "function f(){\n  var x = {\n    p: function (a, b, c) {\n      return a + b + c;\n    },\n  };\n\n  console.log(x.p(foo(), bar(), baz()));  \n}\n"
  },
  {
    "path": "test/snapshots-in/make-blocks.js",
    "content": "if (foo()) bar();\nfor(;;) bar();\nwhile (0) bar();\nfor (a in b) bar();\ndo bar(); while (0);\nfor (a of b) bar();"
  },
  {
    "path": "test/snapshots-in/negate.js",
    "content": "f(!false);\nf(!0);\nf(![]);\nf(!(a && b));\nf(!(a == b));\nif (!!a) foo();\n"
  },
  {
    "path": "test/snapshots-in/no-trailing-return-void.js",
    "content": "function f(){\n  foo();\n  return;\n}"
  },
  {
    "path": "test/snapshots-in/partial-evaluate.js",
    "content": "function f(){\n  var a = 1;\n  return a + 2 + ['d', 'e'];\n}"
  },
  {
    "path": "test/snapshots-in/remove-empty-statements.js",
    "content": ";;\n"
  },
  {
    "path": "test/snapshots-in/remove-empty-try.js",
    "content": "try{}catch(e){var x;}"
  },
  {
    "path": "test/snapshots-in/remove-unused-vars.js",
    "content": "var x = 0;\nfunction f(){\n  var x = foo();\n}"
  },
  {
    "path": "test/snapshots-in/return-and.js",
    "content": "function f(){\n  return (a = 0, b, c) && d && e;\n}\n\nfunction g(){\n  return !a && b === 0 && (c = 0, d, e) && f && g;\n}\n\nfunction h(){\n  return !a && b === 0 && (c = 0, d, e);\n}\n\nfunction i(){\n  return a && (b, c);\n}\n"
  },
  {
    "path": "test/snapshots-in/return-conditional.js",
    "content": "function f(){\n  return foo() ? 0 : 1;\n}"
  },
  {
    "path": "test/snapshots-in/return-void.js",
    "content": "function f(){\n  if (foo()) {\n    return void bar();\n  }\n}"
  },
  {
    "path": "test/snapshots-in/shorthand-if.js",
    "content": "a ? b() : c();\na && b();\na || c();\n"
  },
  {
    "path": "test/snapshots-in/spread-block.js",
    "content": "{\n  foo();\n  {\n    bar();\n    baz();\n  }\n  quux();\n}\n"
  },
  {
    "path": "test/snapshots-in/statement-position-negation.js",
    "content": "!d();"
  },
  {
    "path": "test/snapshots-in/un-yoda.js",
    "content": "0 === b;\n"
  },
  {
    "path": "test/snapshots-in/unhoist-var-decls.js",
    "content": "function f(){\n  var a;\n  b();\n  a = b();\n  return a;\n}"
  },
  {
    "path": "test/snapshots-out/test/snapshots.js.md",
    "content": "# Snapshot report for `test/snapshots.js`\n\nThe actual snapshot is saved in `snapshots.js.snap`.\n\nGenerated by [AVA](https://avajs.dev).\n\n## USELESS snapshot: computed-member-to-static.js\n\n> Snapshot 1\n\n    `a['b'];␊\n    a['b'] = 0;␊\n    a[0];␊\n    a['0'];␊\n    `\n\n## SAFE snapshot: computed-member-to-static.js\n\n> Snapshot 1\n\n    `a.b;␊\n    a.b = 0;␊\n    a[0];␊\n    a['0'];␊\n    `\n\n## MOSTLY_SAFE snapshot: computed-member-to-static.js\n\n> Snapshot 1\n\n    `a.b;␊\n    a.b = 0;␊\n    a[0];␊\n    a['0'];␊\n    `\n\n## UNSAFE snapshot: computed-member-to-static.js\n\n> Snapshot 1\n\n    `a.b;␊\n    a.b = 0;␊\n    a[0];␊\n    a['0'];␊\n    `\n\n## WILDLY_UNSAFE snapshot: computed-member-to-static.js\n\n> Snapshot 1\n\n    `a.b;␊\n    a.b = 0;␊\n    a[0];␊\n    a['0'];␊\n    `\n\n## USELESS snapshot: expand-expression-statement.js\n\n> Snapshot 1\n\n    `foo(), this, void bar(), void 0, new baz();␊\n    `\n\n## SAFE snapshot: expand-expression-statement.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    new baz();␊\n    `\n\n## MOSTLY_SAFE snapshot: expand-expression-statement.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    new baz();␊\n    `\n\n## UNSAFE snapshot: expand-expression-statement.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    new baz();␊\n    `\n\n## WILDLY_UNSAFE snapshot: expand-expression-statement.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    new baz();␊\n    `\n\n## USELESS snapshot: expand-multiple-decl.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = foo(),␊\n        b = bar();␊\n      for (var c = foo(), d = bar(); false; );␊\n      return a + b + c + d;␊\n    }␊\n    `\n\n## SAFE snapshot: expand-multiple-decl.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c = foo();␊\n      for (var d = bar(); false; ) {}␊\n      return a + b + c + d;␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: expand-multiple-decl.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c = foo();␊\n      for (var d = bar(); false; ) {}␊\n      return a + b + c + d;␊\n    }␊\n    `\n\n## UNSAFE snapshot: expand-multiple-decl.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c = foo();␊\n      for (var d = bar(); false; ) {}␊\n      return a + b + c + d;␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: expand-multiple-decl.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c = foo();␊\n      for (var d = bar(); false; ) {}␊\n      return a + b + c + d;␊\n    }␊\n    `\n\n## USELESS snapshot: expand-sequence.js\n\n> Snapshot 1\n\n    `if ((a(), b())) {␊\n      c();␊\n    }␊\n    function f() {␊\n      var a = (b(), c);␊\n      return d(), a;␊\n    }␊\n    throw (f(), g);␊\n    for (a(), b(); false; );␊\n    `\n\n## SAFE snapshot: expand-sequence.js\n\n> Snapshot 1\n\n    `a();␊\n    if (b()) {␊\n      c();␊\n    }␊\n    function f() {␊\n      b();␊\n      var a = c;␊\n      d();␊\n      return a;␊\n    }␊\n    f();␊\n    throw g;␊\n    a();␊\n    for (b(); false; ) {}␊\n    `\n\n## MOSTLY_SAFE snapshot: expand-sequence.js\n\n> Snapshot 1\n\n    `a();␊\n    if (b()) {␊\n      c();␊\n    }␊\n    function f() {␊\n      b();␊\n      var a = c;␊\n      d();␊\n      return a;␊\n    }␊\n    f();␊\n    throw g;␊\n    a();␊\n    for (b(); false; ) {}␊\n    `\n\n## UNSAFE snapshot: expand-sequence.js\n\n> Snapshot 1\n\n    `a();␊\n    if (b()) {␊\n      c();␊\n    }␊\n    function f() {␊\n      b();␊\n      var a = c;␊\n      d();␊\n      return a;␊\n    }␊\n    f();␊\n    throw g;␊\n    a();␊\n    for (b(); false; ) {}␊\n    `\n\n## WILDLY_UNSAFE snapshot: expand-sequence.js\n\n> Snapshot 1\n\n    `a();␊\n    if (b()) {␊\n      c();␊\n    }␊\n    function f() {␊\n      b();␊\n      var a = c;␊\n      d();␊\n      return a;␊\n    }␊\n    f();␊\n    throw g;␊\n    a();␊\n    for (b(); false; ) {}␊\n    `\n\n## USELESS snapshot: hoist-fns.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n      function bar() {}␊\n      return bar;␊\n    }␊\n    `\n\n## SAFE snapshot: hoist-fns.js\n\n> Snapshot 1\n\n    `function f() {␊\n      function bar() {}␊\n      foo();␊\n      return bar;␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: hoist-fns.js\n\n> Snapshot 1\n\n    `function f() {␊\n      function bar() {}␊\n      foo();␊\n      return bar;␊\n    }␊\n    `\n\n## UNSAFE snapshot: hoist-fns.js\n\n> Snapshot 1\n\n    `function f() {␊\n      function bar() {}␊\n      foo();␊\n      return bar;␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: hoist-fns.js\n\n> Snapshot 1\n\n    `function f() {␊\n      function bar() {}␊\n      foo();␊\n      return bar;␊\n    }␊\n    `\n\n## USELESS snapshot: if-and-seq.js\n\n> Snapshot 1\n\n    `if (a && (b, c) && d) {␊\n      foo();␊\n    }␊\n    if ((b, c) && d) {␊\n      foo();␊\n    }␊\n    if (a && (b, c)) {␊\n      foo();␊\n    }␊\n    `\n\n## SAFE snapshot: if-and-seq.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      b;␊\n      if (c && d) {␊\n        foo();␊\n      }␊\n    }␊\n    b;␊\n    if (c && d) {␊\n      foo();␊\n    }␊\n    if (a) {␊\n      b;␊\n      if (c) {␊\n        foo();␊\n      }␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: if-and-seq.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      b;␊\n      if (c && d) {␊\n        foo();␊\n      }␊\n    }␊\n    b;␊\n    if (c && d) {␊\n      foo();␊\n    }␊\n    if (a) {␊\n      b;␊\n      if (c) {␊\n        foo();␊\n      }␊\n    }␊\n    `\n\n## UNSAFE snapshot: if-and-seq.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      b;␊\n      if (c && d) {␊\n        foo();␊\n      }␊\n    }␊\n    b;␊\n    if (c && d) {␊\n      foo();␊\n    }␊\n    if (a) {␊\n      b;␊\n      if (c) {␊\n        foo();␊\n      }␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: if-and-seq.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      if (c && d) {␊\n        foo();␊\n      }␊\n    }␊\n    if (c && d) {␊\n      foo();␊\n    }␊\n    if (a) {␊\n      if (c) {␊\n        foo();␊\n      }␊\n    }␊\n    `\n\n## USELESS snapshot: if-not.js\n\n> Snapshot 1\n\n    `if (a !== b) {␊\n      foo();␊\n    } else {␊\n      bar();␊\n    }␊\n    `\n\n## SAFE snapshot: if-not.js\n\n> Snapshot 1\n\n    `if (a === b) {␊\n      bar();␊\n    } else {␊\n      foo();␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: if-not.js\n\n> Snapshot 1\n\n    `if (a === b) {␊\n      bar();␊\n    } else {␊\n      foo();␊\n    }␊\n    `\n\n## UNSAFE snapshot: if-not.js\n\n> Snapshot 1\n\n    `if (a === b) {␊\n      bar();␊\n    } else {␊\n      foo();␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: if-not.js\n\n> Snapshot 1\n\n    `if (a === b) {␊\n      bar();␊\n    } else {␊\n      foo();␊\n    }␊\n    `\n\n## USELESS snapshot: indexing.js\n\n> Snapshot 1\n\n    `[0][0]();␊\n    f([0, 1, 2][1]);␊\n    f('abcd'[2]);␊\n    f('' + [][0]);␊\n    f('abcd'[5]);␊\n    f([0, 1, 2].length);␊\n    f('abcd'.length);␊\n    f([].map);␊\n    `\n\n## SAFE snapshot: indexing.js\n\n> Snapshot 1\n\n    `[0][0]();␊\n    f([0, 1, 2][1]);␊\n    f('abcd'[2]);␊\n    f('' + [][0]);␊\n    f('abcd'[5]);␊\n    f([0, 1, 2].length);␊\n    f('abcd'.length);␊\n    f([].map);␊\n    `\n\n## MOSTLY_SAFE snapshot: indexing.js\n\n> Snapshot 1\n\n    `[0][0]();␊\n    f([0, 1, 2][1]);␊\n    f('abcd'[2]);␊\n    f('' + [][0]);␊\n    f('abcd'[5]);␊\n    f([0, 1, 2].length);␊\n    f('abcd'.length);␊\n    f([].map);␊\n    `\n\n## UNSAFE snapshot: indexing.js\n\n> Snapshot 1\n\n    `[0][0]();␊\n    f([0, 1, 2][1]);␊\n    f('abcd'[2]);␊\n    f('' + [][0]);␊\n    f('abcd'[5]);␊\n    f([0, 1, 2].length);␊\n    f('abcd'.length);␊\n    f([].map);␊\n    `\n\n## WILDLY_UNSAFE snapshot: indexing.js\n\n> Snapshot 1\n\n    `[0][0]();␊\n    f(1);␊\n    f('c');␊\n    f('undefined');␊\n    f(void 0);␊\n    f(3);␊\n    f(4);␊\n    f([].map);␊\n    `\n\n## USELESS snapshot: inline-arguments.js\n\n> Snapshot 1\n\n    `(function (a, b) {␊\n      return a + b;␊\n    })(foo(), bar(), baz());␊\n    (function (a, b, c) {␊\n      return a + b + c;␊\n    })(foo(), bar());␊\n    `\n\n## SAFE snapshot: inline-arguments.js\n\n> Snapshot 1\n\n    `(function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      baz();␊\n      return a + b;␊\n    })();␊\n    (function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c;␊\n      return a + b + c;␊\n    })();␊\n    `\n\n## MOSTLY_SAFE snapshot: inline-arguments.js\n\n> Snapshot 1\n\n    `(function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      baz();␊\n      return a + b;␊\n    })();␊\n    (function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c;␊\n      return a + b + c;␊\n    })();␊\n    `\n\n## UNSAFE snapshot: inline-arguments.js\n\n> Snapshot 1\n\n    `(function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      baz();␊\n      return a + b;␊\n    })();␊\n    (function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c;␊\n      return a + b + c;␊\n    })();␊\n    `\n\n## WILDLY_UNSAFE snapshot: inline-arguments.js\n\n> Snapshot 1\n\n    `(function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      baz();␊\n      return a + b;␊\n    })();␊\n    (function () {␊\n      var a = foo();␊\n      var b = bar();␊\n      var c;␊\n      return a + b + c;␊\n    })();␊\n    `\n\n## USELESS snapshot: inline-called-once.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (a) {␊\n        return a + foo();␊\n      };␊\n      return x(a);␊\n    }␊\n    `\n\n## SAFE snapshot: inline-called-once.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (a) {␊\n        return a + foo();␊\n      };␊\n      return x(a);␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: inline-called-once.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (a) {␊\n        return a + foo();␊\n      };␊\n      return x(a);␊\n    }␊\n    `\n\n## UNSAFE snapshot: inline-called-once.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (a) {␊\n        return a + foo();␊\n      };␊\n      return x(a);␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: inline-called-once.js\n\n> Snapshot 1\n\n    `function f() {␊\n      return (function (a) {␊\n        return a + foo();␊\n      })(a);␊\n    }␊\n    `\n\n## USELESS snapshot: inline-constant-object-property.js\n\n> Snapshot 1\n\n    `var x = { a: 0 };␊\n    y = x.a;␊\n    `\n\n## SAFE snapshot: inline-constant-object-property.js\n\n> Snapshot 1\n\n    `var x = { a: 0 };␊\n    y = x.a;␊\n    `\n\n## MOSTLY_SAFE snapshot: inline-constant-object-property.js\n\n> Snapshot 1\n\n    `var x = { a: 0 };␊\n    y = x.a;␊\n    `\n\n## UNSAFE snapshot: inline-constant-object-property.js\n\n> Snapshot 1\n\n    `var x = { a: 0 };␊\n    y = x.a;␊\n    `\n\n## WILDLY_UNSAFE snapshot: inline-constant-object-property.js\n\n> Snapshot 1\n\n    `var x = {};␊\n    y = 0;␊\n    `\n\n## USELESS snapshot: inline-function-as-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (foo) {␊\n        if (foo == 'bar') return 'a';␊\n        else return 'b';␊\n      };␊\n      var y = x(a);␊\n      var z = x(b);␊\n      var w = x();␊\n      return y + z + w;␊\n    }␊\n    `\n\n## SAFE snapshot: inline-function-as-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (foo) {␊\n        if (foo == 'bar') {␊\n          return 'a';␊\n        } else {␊\n          return 'b';␊\n        }␊\n      };␊\n      var y = x(a);␊\n      var z = x(b);␊\n      var w = x();␊\n      return y + z + w;␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: inline-function-as-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (foo) {␊\n        if (foo == 'bar') {␊\n          return 'a';␊\n        } else {␊\n          return 'b';␊\n        }␊\n      };␊\n      var y = x(a);␊\n      var z = x(b);␊\n      var w = x();␊\n      return y + z + w;␊\n    }␊\n    `\n\n## UNSAFE snapshot: inline-function-as-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = function (foo) {␊\n        if (foo == 'bar') {␊\n          return 'a';␊\n        } else {␊\n          return 'b';␊\n        }␊\n      };␊\n      var y = x(a);␊\n      var z = x(b);␊\n      var w = x();␊\n      return y + z + w;␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: inline-function-as-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var y = a == 'bar' ? 'a' : 'b';␊\n      var z = b == 'bar' ? 'a' : 'b';␊\n      return y + z + 'b';␊\n    }␊\n    `\n\n## USELESS snapshot: inline-iife.js\n\n> Snapshot 1\n\n    `function f() {␊\n      (function () {␊\n        foo();␊\n      })();␊\n      x = (function () {␊\n        return 0;␊\n      })();␊\n      x = (function () {␊\n        foo();␊\n      })();␊\n    }␊\n    `\n\n## SAFE snapshot: inline-iife.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n      x = 0;␊\n      x = (foo(), void null);␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: inline-iife.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n      x = 0;␊\n      x = (foo(), void null);␊\n    }␊\n    `\n\n## UNSAFE snapshot: inline-iife.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n      x = 0;␊\n      x = (foo(), void null);␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: inline-iife.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n      x = 0;␊\n      x = (foo(), void null);␊\n    }␊\n    `\n\n## USELESS snapshot: inline-trivial-function.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = {␊\n        p: function (a, b, c) {␊\n          return a + b + c;␊\n        },␊\n      };␊\n      console.log(x.p(foo(), bar(), baz()));␊\n    }␊\n    `\n\n## SAFE snapshot: inline-trivial-function.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = {␊\n        p: function (a, b, c) {␊\n          return a + b + c;␊\n        },␊\n      };␊\n      console.log(x.p(foo(), bar(), baz()));␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: inline-trivial-function.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = {␊\n        p: function (a, b, c) {␊\n          return a + b + c;␊\n        },␊\n      };␊\n      console.log(x.p(foo(), bar(), baz()));␊\n    }␊\n    `\n\n## UNSAFE snapshot: inline-trivial-function.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var x = {␊\n        p: function (a, b, c) {␊\n          return a + b + c;␊\n        },␊\n      };␊\n      console.log(x.p(foo(), bar(), baz()));␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: inline-trivial-function.js\n\n> Snapshot 1\n\n    `function f() {␊\n      console.log(foo() + bar() + baz());␊\n    }␊\n    `\n\n## USELESS snapshot: make-blocks.js\n\n> Snapshot 1\n\n    `if (foo()) bar();␊\n    for (;;) bar();␊\n    while (0) bar();␊\n    for (a in b) bar();␊\n    do bar();␊\n    while (0);␊\n    for (a of b) bar();␊\n    `\n\n## SAFE snapshot: make-blocks.js\n\n> Snapshot 1\n\n    `if (foo()) {␊\n      bar();␊\n    }␊\n    while (0) {␊\n      bar();␊\n    }␊\n    for (a in b) {␊\n      bar();␊\n    }␊\n    do {␊\n      bar();␊\n    } while (0);␊\n    for (a of b) {␊\n      bar();␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: make-blocks.js\n\n> Snapshot 1\n\n    `if (foo()) {␊\n      bar();␊\n    }␊\n    while (0) {␊\n      bar();␊\n    }␊\n    for (a in b) {␊\n      bar();␊\n    }␊\n    do {␊\n      bar();␊\n    } while (0);␊\n    for (a of b) {␊\n      bar();␊\n    }␊\n    `\n\n## UNSAFE snapshot: make-blocks.js\n\n> Snapshot 1\n\n    `if (foo()) {␊\n      bar();␊\n    }␊\n    while (0) {␊\n      bar();␊\n    }␊\n    for (a in b) {␊\n      bar();␊\n    }␊\n    do {␊\n      bar();␊\n    } while (0);␊\n    for (a of b) {␊\n      bar();␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: make-blocks.js\n\n> Snapshot 1\n\n    `if (foo()) {␊\n      bar();␊\n    }␊\n    while (0) {␊\n      bar();␊\n    }␊\n    for (a in b) {␊\n      bar();␊\n    }␊\n    do {␊\n      bar();␊\n    } while (0);␊\n    for (a of b) {␊\n      bar();␊\n    }␊\n    `\n\n## USELESS snapshot: negate.js\n\n> Snapshot 1\n\n    `f(!false);␊\n    f(!0);␊\n    f(![]);␊\n    f(!(a && b));␊\n    f(!(a == b));␊\n    if (!!a) foo();␊\n    `\n\n## SAFE snapshot: negate.js\n\n> Snapshot 1\n\n    `f(true);␊\n    f(true);␊\n    f(false);␊\n    f(!a || !b);␊\n    f(a != b);␊\n    if (a) {␊\n      foo();␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: negate.js\n\n> Snapshot 1\n\n    `f(true);␊\n    f(true);␊\n    f(false);␊\n    f(!a || !b);␊\n    f(a != b);␊\n    if (a) {␊\n      foo();␊\n    }␊\n    `\n\n## UNSAFE snapshot: negate.js\n\n> Snapshot 1\n\n    `f(true);␊\n    f(true);␊\n    f(false);␊\n    f(!a || !b);␊\n    f(a != b);␊\n    if (a) {␊\n      foo();␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: negate.js\n\n> Snapshot 1\n\n    `f(true);␊\n    f(true);␊\n    f(false);␊\n    f(!a || !b);␊\n    f(a != b);␊\n    if (a) {␊\n      foo();␊\n    }␊\n    `\n\n## USELESS snapshot: no-trailing-return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n      return;␊\n    }␊\n    `\n\n## SAFE snapshot: no-trailing-return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: no-trailing-return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n    }␊\n    `\n\n## UNSAFE snapshot: no-trailing-return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: no-trailing-return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      foo();␊\n    }␊\n    `\n\n## USELESS snapshot: partial-evaluate.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = 1;␊\n      return a + 2 + ['d', 'e'];␊\n    }␊\n    `\n\n## SAFE snapshot: partial-evaluate.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = 1;␊\n      return a + 2 + ['d', 'e'];␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: partial-evaluate.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = 1;␊\n      return a + 2 + ['d', 'e'];␊\n    }␊\n    `\n\n## UNSAFE snapshot: partial-evaluate.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a = 1;␊\n      return a + 2 + ['d', 'e'];␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: partial-evaluate.js\n\n> Snapshot 1\n\n    `function f() {␊\n      return '3d,e';␊\n    }␊\n    `\n\n## USELESS snapshot: remove-empty-statements.js\n\n> Snapshot 1\n\n    ''\n\n## SAFE snapshot: remove-empty-statements.js\n\n> Snapshot 1\n\n    ''\n\n## MOSTLY_SAFE snapshot: remove-empty-statements.js\n\n> Snapshot 1\n\n    ''\n\n## UNSAFE snapshot: remove-empty-statements.js\n\n> Snapshot 1\n\n    ''\n\n## WILDLY_UNSAFE snapshot: remove-empty-statements.js\n\n> Snapshot 1\n\n    ''\n\n## USELESS snapshot: remove-empty-try.js\n\n> Snapshot 1\n\n    `try {␊\n    } catch (e) {␊\n      var x;␊\n    }␊\n    `\n\n## SAFE snapshot: remove-empty-try.js\n\n> Snapshot 1\n\n    `if (false) {␊\n      var x;␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: remove-empty-try.js\n\n> Snapshot 1\n\n    `if (false) {␊\n      var x;␊\n    }␊\n    `\n\n## UNSAFE snapshot: remove-empty-try.js\n\n> Snapshot 1\n\n    `if (false) {␊\n      var x;␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: remove-empty-try.js\n\n> Snapshot 1\n\n    ''\n\n## USELESS snapshot: remove-unused-vars.js\n\n> Snapshot 1\n\n    `var x = 0;␊\n    function f() {␊\n      var x = foo();␊\n    }␊\n    `\n\n## SAFE snapshot: remove-unused-vars.js\n\n> Snapshot 1\n\n    `var x = 0;␊\n    function f() {␊\n      var x = foo();␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: remove-unused-vars.js\n\n> Snapshot 1\n\n    `var x = 0;␊\n    function f() {␊\n      var x = foo();␊\n    }␊\n    `\n\n## UNSAFE snapshot: remove-unused-vars.js\n\n> Snapshot 1\n\n    `var x = 0;␊\n    function f() {␊\n      foo();␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: remove-unused-vars.js\n\n> Snapshot 1\n\n    `var x = 0;␊\n    function f() {␊\n      foo();␊\n    }␊\n    `\n\n## USELESS snapshot: return-and.js\n\n> Snapshot 1\n\n    `function f() {␊\n      return ((a = 0), b, c) && d && e;␊\n    }␊\n    function g() {␊\n      return !a && b === 0 && ((c = 0), d, e) && f && g;␊\n    }␊\n    function h() {␊\n      return !a && b === 0 && ((c = 0), d, e);␊\n    }␊\n    function i() {␊\n      return a && (b, c);␊\n    }␊\n    `\n\n## SAFE snapshot: return-and.js\n\n> Snapshot 1\n\n    `function f() {␊\n      a = 0;␊\n      b;␊\n      return c && d && e;␊\n    }␊\n    function g() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      d;␊\n      return e && f && g;␊\n    }␊\n    function h() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      d;␊\n      return e;␊\n    }␊\n    function i() {␊\n      return a && (b, c);␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: return-and.js\n\n> Snapshot 1\n\n    `function f() {␊\n      a = 0;␊\n      b;␊\n      return c && d && e;␊\n    }␊\n    function g() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      d;␊\n      return e && f && g;␊\n    }␊\n    function h() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      d;␊\n      return e;␊\n    }␊\n    function i() {␊\n      return a && (b, c);␊\n    }␊\n    `\n\n## UNSAFE snapshot: return-and.js\n\n> Snapshot 1\n\n    `function f() {␊\n      a = 0;␊\n      b;␊\n      return c && d && e;␊\n    }␊\n    function g() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      d;␊\n      return e && f && g;␊\n    }␊\n    function h() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      d;␊\n      return e;␊\n    }␊\n    function i() {␊\n      return a && (b, c);␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: return-and.js\n\n> Snapshot 1\n\n    `function f() {␊\n      a = 0;␊\n      return c && d && e;␊\n    }␊\n    function g() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      return e && f && g;␊\n    }␊\n    function h() {␊\n      if (a || b !== 0) {␊\n        return false;␊\n      }␊\n      c = 0;␊\n      return e;␊\n    }␊\n    function i() {␊\n      return a && (b, c);␊\n    }␊\n    `\n\n## USELESS snapshot: return-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      return foo() ? 0 : 1;␊\n    }␊\n    `\n\n## SAFE snapshot: return-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        return 0;␊\n      } else {␊\n        return 1;␊\n      }␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: return-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        return 0;␊\n      } else {␊\n        return 1;␊\n      }␊\n    }␊\n    `\n\n## UNSAFE snapshot: return-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        return 0;␊\n      } else {␊\n        return 1;␊\n      }␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: return-conditional.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        return 0;␊\n      } else {␊\n        return 1;␊\n      }␊\n    }␊\n    `\n\n## USELESS snapshot: return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        return void bar();␊\n      }␊\n    }␊\n    `\n\n## SAFE snapshot: return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        bar();␊\n        return;␊\n      }␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        bar();␊\n        return;␊\n      }␊\n    }␊\n    `\n\n## UNSAFE snapshot: return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        bar();␊\n        return;␊\n      }␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: return-void.js\n\n> Snapshot 1\n\n    `function f() {␊\n      if (foo()) {␊\n        bar();␊\n        return;␊\n      }␊\n    }␊\n    `\n\n## USELESS snapshot: shorthand-if.js\n\n> Snapshot 1\n\n    `a ? b() : c();␊\n    a && b();␊\n    a || c();␊\n    `\n\n## SAFE snapshot: shorthand-if.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      b();␊\n    } else {␊\n      c();␊\n    }␊\n    if (a) {␊\n      b();␊\n    }␊\n    if (!a) {␊\n      c();␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: shorthand-if.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      b();␊\n    } else {␊\n      c();␊\n    }␊\n    if (a) {␊\n      b();␊\n    }␊\n    if (!a) {␊\n      c();␊\n    }␊\n    `\n\n## UNSAFE snapshot: shorthand-if.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      b();␊\n    } else {␊\n      c();␊\n    }␊\n    if (a) {␊\n      b();␊\n    }␊\n    if (!a) {␊\n      c();␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: shorthand-if.js\n\n> Snapshot 1\n\n    `if (a) {␊\n      b();␊\n    } else {␊\n      c();␊\n    }␊\n    if (a) {␊\n      b();␊\n    }␊\n    if (!a) {␊\n      c();␊\n    }␊\n    `\n\n## USELESS snapshot: spread-block.js\n\n> Snapshot 1\n\n    `{␊\n      foo();␊\n      {␊\n        bar();␊\n        baz();␊\n      }␊\n      quux();␊\n    }␊\n    `\n\n## SAFE snapshot: spread-block.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    baz();␊\n    quux();␊\n    `\n\n## MOSTLY_SAFE snapshot: spread-block.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    baz();␊\n    quux();␊\n    `\n\n## UNSAFE snapshot: spread-block.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    baz();␊\n    quux();␊\n    `\n\n## WILDLY_UNSAFE snapshot: spread-block.js\n\n> Snapshot 1\n\n    `foo();␊\n    bar();␊\n    baz();␊\n    quux();␊\n    `\n\n## USELESS snapshot: statement-position-negation.js\n\n> Snapshot 1\n\n    `!d();␊\n    `\n\n## SAFE snapshot: statement-position-negation.js\n\n> Snapshot 1\n\n    `d();␊\n    `\n\n## MOSTLY_SAFE snapshot: statement-position-negation.js\n\n> Snapshot 1\n\n    `d();␊\n    `\n\n## UNSAFE snapshot: statement-position-negation.js\n\n> Snapshot 1\n\n    `d();␊\n    `\n\n## WILDLY_UNSAFE snapshot: statement-position-negation.js\n\n> Snapshot 1\n\n    `d();␊\n    `\n\n## USELESS snapshot: un-yoda.js\n\n> Snapshot 1\n\n    `0 === b;␊\n    `\n\n## SAFE snapshot: un-yoda.js\n\n> Snapshot 1\n\n    `b === 0;␊\n    `\n\n## MOSTLY_SAFE snapshot: un-yoda.js\n\n> Snapshot 1\n\n    `b === 0;␊\n    `\n\n## UNSAFE snapshot: un-yoda.js\n\n> Snapshot 1\n\n    `b === 0;␊\n    `\n\n## WILDLY_UNSAFE snapshot: un-yoda.js\n\n> Snapshot 1\n\n    `b === 0;␊\n    `\n\n## USELESS snapshot: unhoist-var-decls.js\n\n> Snapshot 1\n\n    `function f() {␊\n      var a;␊\n      b();␊\n      a = b();␊\n      return a;␊\n    }␊\n    `\n\n## SAFE snapshot: unhoist-var-decls.js\n\n> Snapshot 1\n\n    `function f() {␊\n      b();␊\n      var a = b();␊\n      return a;␊\n    }␊\n    `\n\n## MOSTLY_SAFE snapshot: unhoist-var-decls.js\n\n> Snapshot 1\n\n    `function f() {␊\n      b();␊\n      var a = b();␊\n      return a;␊\n    }␊\n    `\n\n## UNSAFE snapshot: unhoist-var-decls.js\n\n> Snapshot 1\n\n    `function f() {␊\n      b();␊\n      var a = b();␊\n      return a;␊\n    }␊\n    `\n\n## WILDLY_UNSAFE snapshot: unhoist-var-decls.js\n\n> Snapshot 1\n\n    `function f() {␊\n      b();␊\n      var a = b();␊\n      return a;␊\n    }␊\n    `\n"
  },
  {
    "path": "test/snapshots.js",
    "content": "const fs = require('fs');\nconst test = require('ava');\nconst prettier = require('prettier');\nconst unminify = require('../');\n\nconst SNAPSHOTS_DIR = `${__dirname}/snapshots-in`;\nconst files = fs.readdirSync(SNAPSHOTS_DIR)\n\nfunction format(src) {\n  return prettier.format(src, { parser: 'babel', singleQuote: true, trailingComma: 'all' });\n}\n\nfiles.forEach(file => {\n  let sourceText = fs.readFileSync(`${SNAPSHOTS_DIR}/${file}`, 'utf-8');\n\n  Object.keys(unminify.safetyLevels).forEach(safetyLevel => {\n    test(`${safetyLevel} snapshot: ${file}`, async t => {\n      t.snapshot(format(unminify(sourceText, { safety: unminify.safetyLevels[safetyLevel] })));\n    });\n  });\n});\n"
  }
]