# 1.0.0 - 2016-01-07

- Removed: unused speed test
- Added: Automatic routing between previously unsupported conversions
([#27](https://github.com/Qix-/color-convert/pull/27))
- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
([#27](https://github.com/Qix-/color-convert/pull/27))
- Removed: `convert()` class
([#27](https://github.com/Qix-/color-convert/pull/27))
- Changed: all functions to lookup dictionary
([#27](https://github.com/Qix-/color-convert/pull/27))
- Changed: `ansi` to `ansi256`
([#27](https://github.com/Qix-/color-convert/pull/27))
- Fixed: argument grouping for functions requiring only one argument
([#27](https://github.com/Qix-/color-convert/pull/27))

# 0.6.0 - 2015-07-23

- Added: methods to handle
[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
  - rgb2ansi16
  - rgb2ansi
  - hsl2ansi16
  - hsl2ansi
  - hsv2ansi16
  - hsv2ansi
  - hwb2ansi16
  - hwb2ansi
  - cmyk2ansi16
  - cmyk2ansi
  - keyword2ansi16
  - keyword2ansi
  - ansi162rgb
  - ansi162hsl
  - ansi162hsv
  - ansi162hwb
  - ansi162cmyk
  - ansi162keyword
  - ansi2rgb
  - ansi2hsl
  - ansi2hsv
  - ansi2hwb
  - ansi2cmyk
  - ansi2keyword
([#18](https://github.com/harthur/color-convert/pull/18))

# 0.5.3 - 2015-06-02

- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
([#15](https://github.com/harthur/color-convert/issues/15))

---

Check out commit logs for older releases
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       const SemVer = require('../classes/semver')
const parse = require('./parse')
const {re, t} = require('../internal/re')

const coerce = (version, options) => {
  if (version instanceof SemVer) {
    return version
  }

  if (typeof version === 'number') {
    version = String(version)
  }

  if (typeof version !== 'string') {
    return null
  }

  options = options || {}

  let match = null
  if (!options.rtl) {
    match = version.match(re[t.COERCE])
  } else {
    // Find the right-most coercible string that does not share
    // a terminus with a more left-ward coercible string.
    // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
    //
    // Walk through the string checking with a /g regexp
    // Manually set the index so as to pick up overlapping matches.
    // Stop when we get a match that ends at the string end, since no
    // coercible string can be more right-ward without the same terminus.
    let next
    while ((next = re[t.COERCERTL].exec(version)) &&
        (!match || match.index + match[0].length !== version.length)
    ) {
      if (!match ||
            next.index + next[0].length !== match.index + match[0].length) {
        match = next
      }
      re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
    }
    // leave it in a clean state
    re[t.COERCERTL].lastIndex = -1
  }

  if (match === null)
    return null

  return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
}
module.exports = coerce
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       INDX( 	                 (      è                                 ` P         Ùä-kxŰUmîaxŰéä-kxŰUmîaxŰ       Ü               w a l k . j s                   ` P         Ùä-kxŰUmîaxŰéä-kxŰUmîaxŰ       Ü               w a l k . j s                   ` P         Ùä-kxŰUmîaxŰéä-kxŰUmîaxŰ       Ü               w a l k . j s               ` P         Ùä-kxŰUmîaxŰéä-kxŰUmîaxŰ       Ü               w a l k . j s               ` P        Ùä-kxŰUmîaxŰéä-kxŰUmîaxŰ       Ü               w a l k . j s               ` P         Ùä-kxŰUmîaxŰéä-kxŰUmîaxŰ       Ü               w a l k . j s                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
  "name": "depd",
  "description": "Deprecate all the things",
  "version": "2.0.0",
  "author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
  "license": "MIT",
  "keywords": [
    "deprecate",
    "deprecated"
  ],
  "repository": "dougwilson/nodejs-depd",
  "browser": "lib/browser/index.js",
  "devDependencies": {
    "benchmark": "2.1.4",
    "beautify-benchmark": "0.2.4",
    "eslint": "5.7.0",
    "eslint-config-standard": "12.0.0",
    "eslint-plugin-import": "2.14.0",
    "eslint-plugin-markdown": "1.0.0-beta.7",
    "eslint-plugin-node": "7.0.1",
    "eslint-plugin-promise": "4.0.1",
    "eslint-plugin-standard": "4.0.0",
    "istanbul": "0.4.5",
    "mocha": "5.2.0",
    "safe-buffer": "5.1.2",
    "uid-safe": "2.1.5"
  },
  "files": [
    "lib/",
    "History.md",
    "LICENSE",
    "index.js",
    "Readme.md"
  ],
  "engines": {
    "node": ">= 0.8"
  },
  "scripts": {
    "bench": "node benchmark/index.js",
    "lint": "eslint --plugin markdown --ext js,md .",
    "test": "mocha --reporter spec --bail test/",
    "test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
    "test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
  }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         # <img src="./logo.png" alt="bn.js" width="160" height="160" />

> BigNum in pure javascript

[![Build Status](https://secure.travis-ci.org/indutny/bn.js.png)](http://travis-ci.org/indutny/bn.js)

## Install
`npm install --save bn.js`

## Usage

```js
const BN = require('bn.js');

var a = new BN('dead', 16);
var b = new BN('101010', 2);

var res = a.add(b);
console.log(res.toString(10));  // 57047
```

**Note**: decimals are not supported in this library.

## Notation

### Prefixes

There are several prefixes to instructions that affect the way the work. Here
is the list of them in the order of appearance in the function name:

* `i` - perform operation in-place, storing the result in the host object (on
  which the method was invoked). Might be used to avoid number allocation costs
* `u` - unsigned, ignore the sign of operands when performing operation, or
  always return positive value. Second case applies to reduction operations
  like `mod()`. In such cases if the result will be negative - modulo will be
  added to the result to make it positive

### Postfixes

The only available postfix at the moment is:

* `n` - which means that the argument of the function must be a plain JavaScript
  Number. Decimals are not supported.

### Examples

* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
* `a.iushln(13)` - shift bits of `a` left by 13

## Instructions

Prefixes/postfixes are put in parens at the of the line. `endian` - could be
either `le` (little-endian) or `be` (big-endian).

### Utilities

* `a.clone()` - clone number
* `a.toString(base, length)` - convert to base-string and pad with zeroes
* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
  pad to length, throwing if already exceeding
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
  which must behave like an `Array`
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
  compatibility with browserify and similar tools, use this instead:
  `a.toArrayLike(Buffer, endian, length)`
* `a.bitLength()` - get number of bits occupied
* `a.zeroBits()` - return number of less-significant consequent zero bits
  (example: `1010000` has 4 zero bits)
* `a.byteLength()` - return number of bytes occupied
* `a.isNeg()` - true if the number is negative
* `a.isEven()` - no comments
* `a.isOdd()` - no comments
* `a.isZero()` - no comments
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
  depending on the comparison result (`ucmp`, `cmpn`)
* `a.lt(b)` - `a` less than `b` (`n`)
* `a.lte(b)` - `a` less than or equals `b` (`n`)
* `a.gt(b)` - `a` greater than `b` (`n`)
* `a.gte(b)` - `a` greater than or equals `b` (`n`)
* `a.eq(b)` - `a` equals `b` (`n`)
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance

### Arithmetics

* `a.neg()` - negate sign (`i`)
* `a.abs()` - absolute value (`i`)
* `a.add(b)` - addition (`i`, `n`, `in`)
* `a.sub(b)` - subtraction (`i`, `n`, `in`)
* `a.mul(b)` - multiply (`i`, `n`, `in`)
* `a.sqr()` - square (`i`)
* `a.pow(b)` - raise `a` to the power of `b`
* `a.div(b)` - divide (`divn`, `idivn`)
* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
* `a.divRound(b)` - rounded division

### Bit operations

* `a.or(b)` - or (`i`, `u`, `iu`)
* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
  with `andn` in future)
* `a.xor(b)` - xor (`i`, `u`, `iu`)
* `a.setn(b)` - set specified bit to `1`
* `a.shln(b)` - shift left (`i`, `u`, `iu`)
* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
* `a.testn(b)` - test if specified bit is set
* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
* `a.bincn(b)` - add `1 << b` to the number
* `a.notn(w)` - not (for the width specified by `w`) (`i`)

### Reduction

* `a.gcd(b)` - GCD
* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
* `a.invm(b)` - inverse `a` modulo `b`

## Fast reduction

When doing lots of reductions using the same modulo, it might be beneficial to
use some tricks: like [Montgomery multiplication][0], or using special algorithm
for [Mersenne Prime][1].

### Reduction context

To enable this tricks one should create a reduction context:

```js
var red = BN.red(num);
```
where `num` is just a BN instance.

Or:

```js
var red = BN.red(primeName);
```

Where `primeName` is either of these [Mersenne Primes][1]:

* `'k256'`
* `'p224'`
* `'p192'`
* `'p25519'`

Or:

```js
var red = BN.mont(num);
```

To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
`.red(num)`, but slower than `BN.red(primeName)`.

### Converting numbers

Before performing anything in reduction context - numbers should be converted
to it. Usually, this means that one should:

* Convert inputs to reducted ones
* Operate on them in reduction context
* Convert outputs back from the reduction context

Here is how one may convert numbers to `red`:

```js
var redA = a.toRed(red);
```
Where `red` is a reduction context created using instructions above

Here is how to convert them back:

```js
var a = redA.fromRed();
```

### Red instructions

Most of the instructions from the very start of this readme have their
counterparts in red context:

* `a.redAdd(b)`, `a.redIAdd(b)`
* `a.redSub(b)`, `a.redISub(b)`
* `a.redShl(num)`
* `a.redMul(b)`, `a.redIMul(b)`
* `a.redSqr()`, `a.redISqr()`
* `a.redSqrt()` - square root modulo reduction context's prime
* `a.redInvm()` - modular inverse of the number
* `a.redNeg()`
* `a.redPow(b)` - modular exponentiation

## LICENSE

This software is licensed under the MIT License.

[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
[1]: https://en.wikipedia.org/wiki/Mersenne_prime
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           'use strict';
const {signalsByName} = require('human-signals');

const getErrorPrefix = ({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled}) => {
	if (timedOut) {
		return `timed out after ${timeout} milliseconds`;
	}

	if (isCanceled) {
		return 'was canceled';
	}

	if (errorCode !== undefined) {
		return `failed with ${errorCode}`;
	}

	if (signal !== undefined) {
		return `was killed with ${signal} (${signalDescription})`;
	}

	if (exitCode !== undefined) {
		return `failed with exit code ${exitCode}`;
	}

	return 'failed';
};

const makeError = ({
	stdout,
	stderr,
	all,
	error,
	signal,
	exitCode,
	command,
	escapedCommand,
	timedOut,
	isCanceled,
	killed,
	parsed: {options: {timeout}}
}) => {
	// `signal` and `exitCode` emitted on `spawned.on('exit')` event can be `null`.
	// We normalize them to `undefined`
	exitCode = exitCode === null ? undefined : exitCode;
	signal = signal === null ? undefined : signal;
	const signalDescription = signal === undefined ? undefined : signalsByName[signal].description;

	const errorCode = error && error.code;

	const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
	const execaMessage = `Command ${prefix}: ${command}`;
	const isError = Object.prototype.toString.call(error) === '[object Error]';
	const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
	const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');

	if (isError) {
		error.originalMessage = error.message;
		error.message = message;
	} else {
		error = new Error(message);
	}

	error.shortMessage = shortMessage;
	error.command = command;
	error.escapedCommand = escapedCommand;
	error.exitCode = exitCode;
	error.signal = signal;
	error.signalDescription = signalDescription;
	error.stdout = stdout;
	error.stderr = stderr;

	if (all !== undefined) {
		error.all = all;
	}

	if ('bufferedData' in error) {
		delete error.bufferedData;
	}

	error.failed = true;
	error.timedOut = Boolean(timedOut);
	error.isCanceled = isCanceled;
	error.killed = killed && !timedOut;

	return error;
};

module.exports = makeError;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           // Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// A bit simpler than readable streams.
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
// the drain event emission and buffering.
'use strict';

module.exports = Writable;
/* <replacement> */

function WriteReq(chunk, encoding, cb) {
  this.chunk = chunk;
  this.encoding = encoding;
  this.callback = cb;
  this.next = null;
} // It seems a linked list but it is not
// there will be only 2 of these for each stream


function CorkedRequest(state) {
  var _this = this;

  this.next = null;
  this.entry = null;

  this.finish = function () {
    onCorkedFinish(_this, state);
  };
}
/* </replacement> */

/*<replacement>*/


var Duplex;
/*</replacement>*/

Writable.WritableState = WritableState;
/*<replacement>*/

var internalUtil = {
  deprecate: require('util-deprecate')
};
/*</replacement>*/

/*<replacement>*/

var Stream = require('./internal/streams/stream');
/*</replacement>*/


var Buffer = require('buffer').Buffer;

var OurUint8Array = global.Uint8Array || function () {};

function _uint8ArrayToBuffer(chunk) {
  return Buffer.from(chunk);
}

function _isUint8Array(obj) {
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}

var destroyImpl = require('./internal/streams/destroy');

var _require = require('./internal/streams/state'),
    getHighWaterMark = _require.getHighWaterMark;

var _require$codes = require('../errors').codes,
    ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
    ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
    ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
    ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
    ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
    ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
    ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
    ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;

var errorOrDestroy = destroyImpl.errorOrDestroy;

require('inherits')(Writable, Stream);

function nop() {}

function WritableState(options, stream, isDuplex) {
  Duplex = Duplex || require('./_stream_duplex');
  options = options || {}; // Duplex streams are both readable and writable, but share
  // the same options object.
  // However, some cases require setting options to different
  // values for the readable and the writable sides of the duplex stream,
  // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.

  if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream
  // contains buffers or objects.

  this.objectMode = !!options.objectMode;
  if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false
  // Note: 0 is a valid value, means that we always return false if
  // the entire buffer is not flushed immediately on write()

  this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called

  this.finalCalled = false; // drain event flag.

  this.needDrain = false; // at the start of calling end()

  this.ending = false; // when end() has been called, and returned

  this.ended = false; // when 'finish' is emitted

  this.finished = false; // has it been destroyed

  this.destroyed = false; // should we decode strings into buffers before passing to _write?
  // this is here so that some node-core streams can optimize string
  // handling at a lower level.

  var noDecode = options.decodeStrings === false;
  this.decodeStrings = !noDecode; // Crypto is kind of old and crusty.  Historically, its default string
  // encoding is 'binary' so we have to make this configurable.
  // Everything else in the universe uses 'utf8', though.

  this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement
  // of how much we're waiting to get pushed to some underlying
  // socket or file.

  this.length = 0; // a flag to see when we're in the middle of a write.

  this.writing = false; // when true all writes will be buffered until .uncork() call

  this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately,
  // or on a later tick.  We set this to true at first, because any
  // actions that shouldn't happen until "later" should generally also
  // not happen before the first write call.

  this.sync = true; // a flag to know if we're processing previously buffered items, which
  // may call the _write() callback in the same tick, so that we don't
  // end up in an overlapped onwrite situation.

  this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb)

  this.onwrite = function (er) {
    onwrite(stream, er);
  }; // the callback that the user supplies to write(chunk,encoding,cb)


  this.writecb = null; // the amount that is being written when _write is called.

  this.writelen = 0;
  this.bufferedRequest = null;
  this.lastBufferedRequest = null; // number of pending user-supplied write callbacks
  // this must be 0 before 'finish' can be emitted

  this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs
  // This is relevant for synchronous Transform streams

  this.prefinished = false; // True if the error was already emitted and should not be thrown again

  this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true.

  this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')

  this.autoDestroy = !!options.autoDestroy; // count buffered requests

  this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always
  // one allocated and free to use, and we maintain at most two

  this.corkedRequestsFree = new CorkedRequest(this);
}

WritableState.prototype.getBuffer = function getBuffer() {
  var current = this.bufferedRequest;
  var out = [];

  while (current) {
    out.push(current);
    current = current.next;
  }

  return out;
};

(function () {
  try {
    Object.defineProperty(WritableState.prototype, 'buffer', {
      get: internalUtil.deprecate(function writableStateBufferGetter() {
        return this.getBuffer();
      }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
    });
  } catch (_) {}
})(); // Test _writableState for inheritance to account for Duplex streams,
// whose prototype chain only points to Readable.


var realHasInstance;

if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  realHasInstance = Function.prototype[Symbol.hasInstance];
  Object.defineProperty(Writable, Symbol.hasInstance, {
    value: function value(object) {
      if (realHasInstance.call(this, object)) return true;
      if (this !== Writable) return false;
      return object && object._writableState instanceof WritableState;
    }
  });
} else {
  realHasInstance = function realHasInstance(object) {
    return object instanceof this;
  };
}

function Writable(options) {
  Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too.
  // `realHasInstance` is necessary because using plain `instanceof`
  // would return false, as no `_writableState` property is attached.
  // Trying to use the custom `instanceof` for Writable here will also break the
  // Node.js LazyTransform implementation, which has a non-trivial getter for
  // `_writableState` that would lead to infinite recursion.
  // Checking for a Stream.Duplex instance is faster here instead of inside
  // the WritableState constructor, at least with V8 6.5

  var isDuplex = this instanceof Duplex;
  if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
  this._writableState = new WritableState(options, this, isDuplex); // legacy.

  this.writable = true;

  if (options) {
    if (typeof options.write === 'function') this._write = options.write;
    if (typeof options.writev === 'function') this._writev = options.writev;
    if (typeof options.destroy === 'function') this._destroy = options.destroy;
    if (typeof options.final === 'function') this._final = options.final;
  }

  Stream.call(this);
} // Otherwise people can pipe Writable streams, which is just wrong.


Writable.prototype.pipe = function () {
  errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
};

function writeAfterEnd(stream, cb) {
  var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb

  errorOrDestroy(stream, er);
  process.nextTick(cb, er);
} // Checks that a user-supplied chunk is valid, especially for the particular
// mode the stream is in. Currently this means that `null` is never accepted
// and undefined/non-string values are only allowed in object mode.


function validChunk(stream, state, chunk, cb) {
  var er;

  if (chunk === null) {
    er = new ERR_STREAM_NULL_VALUES();
  } else if (typeof chunk !== 'string' && !state.objectMode) {
    er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
  }

  if (er) {
    errorOrDestroy(stream, er);
    process.nextTick(cb, er);
    return false;
  }

  return true;
}

Writable.prototype.write = function (chunk, encoding, cb) {
  var state = this._writableState;
  var ret = false;

  var isBuf = !state.objectMode && _isUint8Array(chunk);

  if (isBuf && !Buffer.isBuffer(chunk)) {
    chunk = _uint8ArrayToBuffer(chunk);
  }

  if (typeof encoding === 'function') {
    cb = encoding;
    encoding = null;
  }

  if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  if (typeof cb !== 'function') cb = nop;
  if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
    state.pendingcb++;
    ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  }
  return ret;
};

Writable.prototype.cork = function () {
  this._writableState.corked++;
};

Writable.prototype.uncork = function () {
  var state = this._writableState;

  if (state.corked) {
    state.corked--;
    if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  }
};

Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  // node::ParseEncoding() requires lower case.
  if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
  this._writableState.defaultEncoding = encoding;
  return this;
};

Object.defineProperty(Writable.prototype, 'writableBuffer', {
  // making it explicit this property is not enumerable
  // because otherwise some prototype manipulation in
  // userland will fail
  enumerable: false,
  get: function get() {
    return this._writableState && this._writableState.getBuffer();
  }
});

function decodeChunk(state, chunk, encoding) {
  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
    chunk = Buffer.from(chunk, encoding);
  }

  return chunk;
}

Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  // making it explicit this property is not enumerable
  // because otherwise some prototype manipulation in
  // userland will fail
  enumerable: false,
  get: function get() {
    return this._writableState.highWaterMark;
  }
}); // if we're already writing something, then just put this
// in the queue, and wait our turn.  Otherwise, call _write
// If we return false, then we need a drain event, so set that flag.

function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  if (!isBuf) {
    var newChunk = decodeChunk(state, chunk, encoding);

    if (chunk !== newChunk) {
      isBuf = true;
      encoding = 'buffer';
      chunk = newChunk;
    }
  }

  var len = state.objectMode ? 1 : chunk.length;
  state.length += len;
  var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false.

  if (!ret) state.needDrain = true;

  if (state.writing || state.corked) {
    var last = state.lastBufferedRequest;
    state.lastBufferedRequest = {
      chunk: chunk,
      encoding: encoding,
      isBuf: isBuf,
      callback: cb,
      next: null
    };

    if (last) {
      last.next = state.lastBufferedRequest;
    } else {
      state.bufferedRequest = state.lastBufferedRequest;
    }

    state.bufferedRequestCount += 1;
  } else {
    doWrite(stream, state, false, len, chunk, encoding, cb);
  }

  return ret;
}

function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  state.writelen = len;
  state.writecb = cb;
  state.writing = true;
  state.sync = true;
  if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  state.sync = false;
}

function onwriteError(stream, state, sync, er, cb) {
  --state.pendingcb;

  if (sync) {
    // defer the callback if we are being called synchronously
    // to avoid piling up things on the stack
    process.nextTick(cb, er); // this can emit finish, and it will always happen
    // after error

    process.nextTick(finishMaybe, stream, state);
    stream._writableState.errorEmitted = true;
    errorOrDestroy(stream, er);
  } else {
    // the caller expect this to happen before if
    // it is async
    cb(er);
    stream._writableState.errorEmitted = true;
    errorOrDestroy(stream, er); // this can emit finish, but finish must
    // always follow error

    finishMaybe(stream, state);
  }
}

function onwriteStateUpdate(state) {
  state.writing = false;
  state.writecb = null;
  state.length -= state.writelen;
  state.writelen = 0;
}

function onwrite(stream, er) {
  var state = stream._writableState;
  var sync = state.sync;
  var cb = state.writecb;
  if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
  onwriteStateUpdate(state);
  if (er) onwriteError(stream, state, sync, er, cb);else {
    // Check if we're actually ready to finish, but don't emit yet
    var finished = needFinish(state) || stream.destroyed;

    if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
      clearBuffer(stream, state);
    }

    if (sync) {
      process.nextTick(afterWrite, stream, state, finished, cb);
    } else {
      afterWrite(stream, state, finished, cb);
    }
  }
}

function afterWrite(stream, state, finished, cb) {
  if (!finished) onwriteDrain(stream, state);
  state.pendingcb--;
  cb();
  finishMaybe(stream, state);
} // Must force callback to be called on nextTick, so that we don't
// emit 'drain' before the write() consumer gets the 'false' return
// value, and has a chance to attach a 'drain' listener.


function onwriteDrain(stream, state) {
  if (state.length === 0 && state.needDrain) {
    state.needDrain = false;
    stream.emit('drain');
  }
} // if there's something in the buffer waiting, then process it


function clearBuffer(stream, state) {
  state.bufferProcessing = true;
  var entry = state.bufferedRequest;

  if (stream._writev && entry && entry.next) {
    // Fast case, write everything using _writev()
    var l = state.bufferedRequestCount;
    var buffer = new Array(l);
    var holder = state.corkedRequestsFree;
    holder.entry = entry;
    var count = 0;
    var allBuffers = true;

    while (entry) {
      buffer[count] = entry;
      if (!entry.isBuf) allBuffers = false;
      entry = entry.next;
      count += 1;
    }

    buffer.allBuffers = allBuffers;
    doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time
    // as the hot path ends with doWrite

    state.pendingcb++;
    state.lastBufferedRequest = null;

    if (holder.next) {
      state.corkedRequestsFree = holder.next;
      holder.next = null;
    } else {
      state.corkedRequestsFree = new CorkedRequest(state);
    }

    state.bufferedRequestCount = 0;
  } else {
    // Slow case, write chunks one-by-one
    while (entry) {
      var chunk = entry.chunk;
      var encoding = entry.encoding;
      var cb = entry.callback;
      var len = state.objectMode ? 1 : chunk.length;
      doWrite(stream, state, false, len, chunk, encoding, cb);
      entry = entry.next;
      state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then
      // it means that we need to wait until it does.
      // also, that means that the chunk and cb are currently
      // being processed, so move the buffer counter past them.

      if (state.writing) {
        break;
      }
    }

    if (entry === null) state.lastBufferedRequest = null;
  }

  state.bufferedRequest = entry;
  state.bufferProcessing = false;
}

Writable.prototype._write = function (chunk, encoding, cb) {
  cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
};

Writable.prototype._writev = null;

Writable.prototype.end = function (chunk, encoding, cb) {
  var state = this._writableState;

  if (typeof chunk === 'function') {
    cb = chunk;
    chunk = null;
    encoding = null;
  } else if (typeof encoding === 'function') {
    cb = encoding;
    encoding = null;
  }

  if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks

  if (state.corked) {
    state.corked = 1;
    this.uncork();
  } // ignore unnecessary end() calls.


  if (!state.ending) endWritable(this, state, cb);
  return this;
};

Object.defineProperty(Writable.prototype, 'writableLength', {
  // making it explicit this property is not enumerable
  // because otherwise some prototype manipulation in
  // userland will fail
  enumerable: false,
  get: function get() {
    return this._writableState.length;
  }
});

function needFinish(state) {
  return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
}

function callFinal(stream, state) {
  stream._final(function (err) {
    state.pendingcb--;

    if (err) {
      errorOrDestroy(stream, err);
    }

    state.prefinished = true;
    stream.emit('prefinish');
    finishMaybe(stream, state);
  });
}

function prefinish(stream, state) {
  if (!state.prefinished && !state.finalCalled) {
    if (typeof stream._final === 'function' && !state.destroyed) {
      state.pendingcb++;
      state.finalCalled = true;
      process.nextTick(callFinal, stream, state);
    } else {
      state.prefinished = true;
      stream.emit('prefinish');
    }
  }
}

function finishMaybe(stream, state) {
  var need = needFinish(state);

  if (need) {
    prefinish(stream, state);

    if (state.pendingcb === 0) {
      state.finished = true;
      stream.emit('finish');

      if (state.autoDestroy) {
        // In case of duplex streams we need a way to detect
        // if the readable side is ready for autoDestroy as well
        var rState = stream._readableState;

        if (!rState || rState.autoDestroy && rState.endEmitted) {
          stream.destroy();
        }
      }
    }
  }

  return need;
}

function endWritable(stream, state, cb) {
  state.ending = true;
  finishMaybe(stream, state);

  if (cb) {
    if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
  }

  state.ended = true;
  stream.writable = false;
}

function onCorkedFinish(corkReq, state, err) {
  var entry = corkReq.entry;
  corkReq.entry = null;

  while (entry) {
    var cb = entry.callback;
    state.pendingcb--;
    cb(err);
    entry = entry.next;
  } // reuse the free corkReq.


  state.corkedRequestsFree.next = corkReq;
}

Object.defineProperty(Writable.prototype, 'destroyed', {
  // making it explicit this property is not enumerable
  // because otherwise some prototype manipulation in
  // userland will fail
  enumerable: false,
  get: function get() {
    if (this._writableState === undefined) {
      return false;
    }

    return this._writableState.destroyed;
  },
  set: function set(value) {
    // we ignore the value if the stream
    // has not been initialized yet
    if (!this._writableState) {
      return;
    } // backward compatibility, the user is explicitly
    // managing destroyed


    this._writableState.destroyed = value;
  }
});
Writable.prototype.destroy = destroyImpl.destroy;
Writable.prototype._undestroy = destroyImpl.undestroy;

Writable.prototype._destroy = function (err, cb) {
  cb(err);
};                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   UglifyJS is released under the BSD license:

Copyright 2012-2018 (c) Mihai Bazon <mihai.bazon@gmail.com>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

    * Redistributions of source code must retain the above
      copyright notice, this list of conditions and the following
      disclaimer.

    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials
      provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER âAS ISâ AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            /**
 * This file provides type definitions for use with the Flow type checker.
 *
 * An important caveat when using these definitions is that the types for
 * `Collection.Keyed`, `Collection.Indexed`, `Seq.Keyed`, and so on are stubs.
 * When referring to those types, you can get the proper definitions by
 * importing the types `KeyedCollection`, `IndexedCollection`, `KeyedSeq`, etc.
 * For example,
 *
 *     import { Seq } from 'immutable'
 *     import type { IndexedCollection, IndexedSeq } from 'immutable'
 *
 *     const someSeq: IndexedSeq<number> = Seq.Indexed.of(1, 2, 3)
 *
 *     function takesASeq<T, TS: IndexedCollection<T>>(iter: TS): TS {
 *       return iter.butLast()
 *     }
 *
 *     takesASeq(someSeq)
 *
 * @flow strict
 */

// Helper type that represents plain objects allowed as arguments to
// some constructors and functions.
type PlainObjInput<K, V> = { +[key: K]: V, __proto__: null };

type K<T> = $Keys<T>;

// Helper types to extract the "keys" and "values" use by the *In() methods.
type $KeyOf<C> = $Call<
  (<K>(?_Collection<K, mixed>) => K) &
    (<T>(?$ReadOnlyArray<T>) => number) &
    (<T>(?RecordInstance<T> | T) => $Keys<T>) &
    (<T: Object>(T) => $Keys<T>),
  C
>;

type $ValOf<C, K = $KeyOf<C>> = $Call<
  (<V>(?_Collection<any, V>) => V) &
    (<T>(?$ReadOnlyArray<T>) => T) &
    (<T, K: $Keys<T>>(?RecordInstance<T> | T, K) => $ElementType<T, K>) &
    (<T: Object>(T) => $Values<T>),
  C,
  K
>;

type $IterableOf<C> = $Call<
  (<V: Array<any> | IndexedCollection<any> | SetCollection<any>>(
    V
  ) => Iterable<$ValOf<V>>) &
    (<
      V:
        | KeyedCollection<any, any>
        | RecordInstance<any>
        | PlainObjInput<any, any>
    >(
      V
    ) => Iterable<[$KeyOf<V>, $ValOf<V>]>),
  C
>;

declare class _Collection<K, +V> implements ValueObject {
  equals(other: mixed): boolean;
  hashCode(): number;
  get(key: K, ..._: []): V | void;
  get<NSV>(key: K, notSetValue: NSV): V | NSV;
  has(key: K): boolean;
  includes(value: V): boolean;
  contains(value: V): boolean;
  first<NSV>(notSetValue?: NSV): V | NSV;
  last<NSV>(notSetValue?: NSV): V | NSV;

  hasIn(keyPath: Iterable<mixed>): boolean;

  getIn(keyPath: [], notSetValue?: mixed): this;
  getIn<NSV>(keyPath: [K], notSetValue: NSV): V | NSV;
  getIn<NSV, K2: $KeyOf<V>>(
    keyPath: [K, K2],
    notSetValue: NSV
  ): $ValOf<V, K2> | NSV;
  getIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>(
    keyPath: [K, K2, K3],
    notSetValue: NSV
  ): $ValOf<$ValOf<V, K2>, K3> | NSV;
  getIn<
    NSV,
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>
  >(
    keyPath: [K, K2, K3, K4],
    notSetValue: NSV
  ): $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> | NSV;
  getIn<
    NSV,
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>
  >(
    keyPath: [K, K2, K3, K4, K5],
    notSetValue: NSV
  ): $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> | NSV;

  update<U>(updater: (value: this) => U): U;

  toJS(): Array<any> | { [key: string]: mixed };
  toJSON(): Array<V> | { [key: string]: V };
  toArray(): Array<V> | Array<[K, V]>;
  toObject(): { [key: string]: V };
  toMap(): Map<K, V>;
  toOrderedMap(): OrderedMap<K, V>;
  toSet(): Set<V>;
  toOrderedSet(): OrderedSet<V>;
  toList(): List<V>;
  toStack(): Stack<V>;
  toSeq(): Seq<K, V>;
  toKeyedSeq(): KeyedSeq<K, V>;
  toIndexedSeq(): IndexedSeq<V>;
  toSetSeq(): SetSeq<V>;

  keys(): Iterator<K>;
  values(): Iterator<V>;
  entries(): Iterator<[K, V]>;

  keySeq(): IndexedSeq<K>;
  valueSeq(): IndexedSeq<V>;
  entrySeq(): IndexedSeq<[K, V]>;

  reverse(): this;
  sort(comparator?: (valueA: V, valueB: V) => number): this;

  sortBy<C>(
    comparatorValueMapper: (value: V, key: K, iter: this) => C,
    comparator?: (valueA: C, valueB: C) => number
  ): this;

  groupBy<G>(
    grouper: (value: V, key: K, iter: this) => G,
    context?: mixed
  ): KeyedSeq<G, this>;

  forEach(
    sideEffect: (value: V, key: K, iter: this) => any,
    context?: mixed
  ): number;

  slice(begin?: number, end?: number): this;
  rest(): this;
  butLast(): this;
  skip(amount: number): this;
  skipLast(amount: number): this;
  skipWhile(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): this;
  skipUntil(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): this;
  take(amount: number): this;
  takeLast(amount: number): this;
  takeWhile(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): this;
  takeUntil(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): this;

  filterNot(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): this;

  reduce<R>(
    reducer: (reduction: R, value: V, key: K, iter: this) => R,
    initialReduction: R,
    context?: mixed
  ): R;
  reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;

  reduceRight<R>(
    reducer: (reduction: R, value: V, key: K, iter: this) => R,
    initialReduction: R,
    context?: mixed
  ): R;
  reduceRight<R>(
    reducer: (reduction: V | R, value: V, key: K, iter: this) => R
  ): R;

  every(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): boolean;
  some(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): boolean;
  join(separator?: string): string;
  isEmpty(): boolean;
  count(
    predicate?: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): number;
  countBy<G>(
    grouper: (value: V, key: K, iter: this) => G,
    context?: mixed
  ): Map<G, number>;

  find<NSV>(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed,
    notSetValue?: NSV
  ): V | NSV;
  findLast<NSV>(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed,
    notSetValue?: NSV
  ): V | NSV;

  findEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void;
  findLastEntry(
    predicate: (value: V, key: K, iter: this) => mixed
  ): [K, V] | void;

  findKey(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): K | void;
  findLastKey(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): K | void;

  keyOf(searchValue: V): K | void;
  lastKeyOf(searchValue: V): K | void;

  max(comparator?: (valueA: V, valueB: V) => number): V;
  maxBy<C>(
    comparatorValueMapper: (value: V, key: K, iter: this) => C,
    comparator?: (valueA: C, valueB: C) => number
  ): V;
  min(comparator?: (valueA: V, valueB: V) => number): V;
  minBy<C>(
    comparatorValueMapper: (value: V, key: K, iter: this) => C,
    comparator?: (valueA: C, valueB: C) => number
  ): V;

  isSubset(iter: Iterable<V>): boolean;
  isSuperset(iter: Iterable<V>): boolean;
}

declare function isImmutable(
  maybeImmutable: mixed
): boolean %checks(maybeImmutable instanceof Collection);
declare function isCollection(
  maybeCollection: mixed
): boolean %checks(maybeCollection instanceof Collection);
declare function isKeyed(
  maybeKeyed: mixed
): boolean %checks(maybeKeyed instanceof KeyedCollection);
declare function isIndexed(
  maybeIndexed: mixed
): boolean %checks(maybeIndexed instanceof IndexedCollection);
declare function isAssociative(
  maybeAssociative: mixed
): boolean %checks(maybeAssociative instanceof KeyedCollection ||
  maybeAssociative instanceof IndexedCollection);
declare function isOrdered(
  maybeOrdered: mixed
): boolean %checks(maybeOrdered instanceof IndexedCollection ||
  maybeOrdered instanceof OrderedMap ||
  maybeOrdered instanceof OrderedSet);
declare function isValueObject(maybeValue: mixed): boolean;

declare function isSeq(maybeSeq: any): boolean %checks(maybeSeq instanceof Seq);
declare function isList(maybeList: any): boolean %checks(maybeList instanceof
  List);
declare function isMap(maybeMap: any): boolean %checks(maybeMap instanceof Map);
declare function isOrderedMap(
  maybeOrderedMap: any
): boolean %checks(maybeOrderedMap instanceof OrderedMap);
declare function isStack(maybeStack: any): boolean %checks(maybeStack instanceof
  Stack);
declare function isSet(maybeSet: any): boolean %checks(maybeSet instanceof Set);
declare function isOrderedSet(
  maybeOrderedSet: any
): boolean %checks(maybeOrderedSet instanceof OrderedSet);
declare function isRecord(
  maybeRecord: any
): boolean %checks(maybeRecord instanceof Record);

declare interface ValueObject {
  equals(other: mixed): boolean;
  hashCode(): number;
}

declare class Collection<K, +V> extends _Collection<K, V> {
  static Keyed: typeof KeyedCollection;
  static Indexed: typeof IndexedCollection;
  static Set: typeof SetCollection;

  static isCollection: typeof isCollection;
  static isKeyed: typeof isKeyed;
  static isIndexed: typeof isIndexed;
  static isAssociative: typeof isAssociative;
  static isOrdered: typeof isOrdered;
}

declare class KeyedCollection<K, +V> extends Collection<K, V> {
  static <K, V>(
    values?: Iterable<[K, V]> | PlainObjInput<K, V>
  ): KeyedCollection<K, V>;

  toJS(): { [key: string]: mixed };
  toJSON(): { [key: string]: V };
  toArray(): Array<[K, V]>;
  @@iterator(): Iterator<[K, V]>;
  toSeq(): KeyedSeq<K, V>;
  flip(): KeyedCollection<V, K>;

  concat<KC, VC>(
    ...iters: Array<Iterable<[KC, VC]> | PlainObjInput<KC, VC>>
  ): KeyedCollection<K | KC, V | VC>;

  filter(predicate: typeof Boolean): KeyedCollection<K, $NonMaybeType<V>>;
  filter(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): KeyedCollection<K, V>;

  map<M>(
    mapper: (value: V, key: K, iter: this) => M,
    context?: mixed
  ): KeyedCollection<K, M>;

  mapKeys<M>(
    mapper: (key: K, value: V, iter: this) => M,
    context?: mixed
  ): KeyedCollection<M, V>;

  mapEntries<KM, VM>(
    mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
    context?: mixed
  ): KeyedCollection<KM, VM>;

  flatMap<KM, VM>(
    mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
    context?: mixed
  ): KeyedCollection<KM, VM>;

  flatten(depth?: number): KeyedCollection<any, any>;
  flatten(shallow?: boolean): KeyedCollection<any, any>;
}

Collection.Keyed = KeyedCollection;

declare class IndexedCollection<+T> extends Collection<number, T> {
  static <T>(iter?: Iterable<T>): IndexedCollection<T>;

  toJS(): Array<mixed>;
  toJSON(): Array<T>;
  toArray(): Array<T>;
  @@iterator(): Iterator<T>;
  toSeq(): IndexedSeq<T>;
  fromEntrySeq<K, V>(): KeyedSeq<K, V>;
  interpose(separator: T): this;
  interleave(...collections: Iterable<T>[]): this;
  splice(index: number, removeNum: number, ...values: T[]): this;

  zip<A>(a: Iterable<A>, ..._: []): IndexedCollection<[T, A]>;
  zip<A, B>(
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): IndexedCollection<[T, A, B]>;
  zip<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): IndexedCollection<[T, A, B, C]>;
  zip<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): IndexedCollection<[T, A, B, C, D]>;
  zip<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): IndexedCollection<[T, A, B, C, D, E]>;

  zipAll<A>(a: Iterable<A>, ..._: []): IndexedCollection<[T | void, A | void]>;
  zipAll<A, B>(
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): IndexedCollection<[T | void, A | void, B | void]>;
  zipAll<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): IndexedCollection<[T | void, A | void, B | void, C | void]>;
  zipAll<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): IndexedCollection<[T | void, A | void, B | void, C | void, D | void]>;
  zipAll<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): IndexedCollection<
    [T | void, A | void, B | void, C | void, D | void, E | void]
  >;

  zipWith<A, R>(
    zipper: (value: T, a: A) => R,
    a: Iterable<A>,
    ..._: []
  ): IndexedCollection<R>;
  zipWith<A, B, R>(
    zipper: (value: T, a: A, b: B) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): IndexedCollection<R>;
  zipWith<A, B, C, R>(
    zipper: (value: T, a: A, b: B, c: C) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): IndexedCollection<R>;
  zipWith<A, B, C, D, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): IndexedCollection<R>;
  zipWith<A, B, C, D, E, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): IndexedCollection<R>;

  indexOf(searchValue: T): number;
  lastIndexOf(searchValue: T): number;
  findIndex(
    predicate: (value: T, index: number, iter: this) => mixed,
    context?: mixed
  ): number;
  findLastIndex(
    predicate: (value: T, index: number, iter: this) => mixed,
    context?: mixed
  ): number;

  concat<C>(...iters: Array<Iterable<C> | C>): IndexedCollection<T | C>;

  filter(predicate: typeof Boolean): IndexedCollection<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, index: number, iter: this) => mixed,
    context?: mixed
  ): IndexedCollection<T>;

  map<M>(
    mapper: (value: T, index: number, iter: this) => M,
    context?: mixed
  ): IndexedCollection<M>;

  flatMap<M>(
    mapper: (value: T, index: number, iter: this) => Iterable<M>,
    context?: mixed
  ): IndexedCollection<M>;

  flatten(depth?: number): IndexedCollection<any>;
  flatten(shallow?: boolean): IndexedCollection<any>;
}

declare class SetCollection<+T> extends Collection<T, T> {
  static <T>(iter?: Iterable<T>): SetCollection<T>;

  toJS(): Array<mixed>;
  toJSON(): Array<T>;
  toArray(): Array<T>;
  @@iterator(): Iterator<T>;
  toSeq(): SetSeq<T>;

  concat<U>(...collections: Iterable<U>[]): SetCollection<T | U>;

  // `filter`, `map` and `flatMap` cannot be defined further up the hierarchy,
  // because the implementation for `KeyedCollection` allows the value type to
  // change without constraining the key type. That does not work for
  // `SetCollection` - the value and key types *must* match.
  filter(predicate: typeof Boolean): SetCollection<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, value: T, iter: this) => mixed,
    context?: mixed
  ): SetCollection<T>;

  map<M>(
    mapper: (value: T, value: T, iter: this) => M,
    context?: mixed
  ): SetCollection<M>;

  flatMap<M>(
    mapper: (value: T, value: T, iter: this) => Iterable<M>,
    context?: mixed
  ): SetCollection<M>;

  flatten(depth?: number): SetCollection<any>;
  flatten(shallow?: boolean): SetCollection<any>;
}

declare function isSeq(maybeSeq: mixed): boolean %checks(maybeSeq instanceof
  Seq);
declare class Seq<K, +V> extends _Collection<K, V> {
  static Keyed: typeof KeyedSeq;
  static Indexed: typeof IndexedSeq;
  static Set: typeof SetSeq;

  static <K, V>(values: KeyedSeq<K, V>): KeyedSeq<K, V>;
  static <T>(values: SetSeq<T>): SetSeq<K, V>;
  static <T>(values: Iterable<T>): IndexedSeq<T>;
  static <K, V>(values?: PlainObjInput<K, V>): KeyedSeq<K, V>;

  static isSeq: typeof isSeq;

  size: number | void;
  cacheResult(): this;
  toSeq(): this;
}

declare class KeyedSeq<K, +V> extends Seq<K, V> mixins KeyedCollection<K, V> {
  static <K, V>(
    values?: Iterable<[K, V]> | PlainObjInput<K, V>
  ): KeyedSeq<K, V>;

  // Override specialized return types
  flip(): KeyedSeq<V, K>;

  concat<KC, VC>(
    ...iters: Array<Iterable<[KC, VC]> | PlainObjInput<KC, VC>>
  ): KeyedSeq<K | KC, V | VC>;

  filter(predicate: typeof Boolean): KeyedSeq<K, $NonMaybeType<V>>;
  filter(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): KeyedSeq<K, V>;

  map<M>(
    mapper: (value: V, key: K, iter: this) => M,
    context?: mixed
  ): KeyedSeq<K, M>;

  mapKeys<M>(
    mapper: (key: K, value: V, iter: this) => M,
    context?: mixed
  ): KeyedSeq<M, V>;

  mapEntries<KM, VM>(
    mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
    context?: mixed
  ): KeyedSeq<KM, VM>;

  flatMap<KM, VM>(
    mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
    context?: mixed
  ): KeyedSeq<KM, VM>;

  flatten(depth?: number): KeyedSeq<any, any>;
  flatten(shallow?: boolean): KeyedSeq<any, any>;
}

declare class IndexedSeq<+T>
  extends Seq<number, T>
  mixins IndexedCollection<T>
{
  static <T>(values?: Iterable<T>): IndexedSeq<T>;

  static of<T>(...values: T[]): IndexedSeq<T>;

  // Override specialized return types

  concat<C>(...iters: Array<Iterable<C> | C>): IndexedSeq<T | C>;

  filter(predicate: typeof Boolean): IndexedSeq<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, index: number, iter: this) => mixed,
    context?: mixed
  ): IndexedSeq<T>;

  map<M>(
    mapper: (value: T, index: number, iter: this) => M,
    context?: mixed
  ): IndexedSeq<M>;

  flatMap<M>(
    mapper: (value: T, index: number, iter: this) => Iterable<M>,
    context?: mixed
  ): IndexedSeq<M>;

  flatten(depth?: number): IndexedSeq<any>;
  flatten(shallow?: boolean): IndexedSeq<any>;

  zip<A>(a: Iterable<A>, ..._: []): IndexedSeq<[T, A]>;
  zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): IndexedSeq<[T, A, B]>;
  zip<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): IndexedSeq<[T, A, B, C]>;
  zip<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): IndexedSeq<[T, A, B, C, D]>;
  zip<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): IndexedSeq<[T, A, B, C, D, E]>;

  zipAll<A>(a: Iterable<A>, ..._: []): IndexedSeq<[T | void, A | void]>;
  zipAll<A, B>(
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): IndexedSeq<[T | void, A | void, B | void]>;
  zipAll<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): IndexedSeq<[T | void, A | void, B | void, C | void]>;
  zipAll<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): IndexedSeq<[T | void, A | void, B | void, C | void, D | void]>;
  zipAll<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): IndexedSeq<[T | void, A | void, B | void, C | void, D | void, E | void]>;

  zipWith<A, R>(
    zipper: (value: T, a: A) => R,
    a: Iterable<A>,
    ..._: []
  ): IndexedSeq<R>;
  zipWith<A, B, R>(
    zipper: (value: T, a: A, b: B) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): IndexedSeq<R>;
  zipWith<A, B, C, R>(
    zipper: (value: T, a: A, b: B, c: C) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): IndexedSeq<R>;
  zipWith<A, B, C, D, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): IndexedSeq<R>;
  zipWith<A, B, C, D, E, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): IndexedSeq<R>;
}

declare class SetSeq<+T> extends Seq<T, T> mixins SetCollection<T> {
  static <T>(values?: Iterable<T>): SetSeq<T>;

  static of<T>(...values: T[]): SetSeq<T>;

  // Override specialized return types

  concat<U>(...collections: Iterable<U>[]): SetSeq<T | U>;

  filter(predicate: typeof Boolean): SetSeq<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, value: T, iter: this) => mixed,
    context?: mixed
  ): SetSeq<T>;

  map<M>(
    mapper: (value: T, value: T, iter: this) => M,
    context?: mixed
  ): SetSeq<M>;

  flatMap<M>(
    mapper: (value: T, value: T, iter: this) => Iterable<M>,
    context?: mixed
  ): SetSeq<M>;

  flatten(depth?: number): SetSeq<any>;
  flatten(shallow?: boolean): SetSeq<any>;
}

declare class UpdatableInCollection<K, +V> {
  setIn<S>(keyPath: [], value: S): S;
  setIn(keyPath: [K], value: V): this;
  setIn<K2: $KeyOf<V>, S: $ValOf<V, K2>>(keyPath: [K, K2], value: S): this;
  setIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, S: $ValOf<$ValOf<V, K2>, K3>>(
    keyPath: [K, K2, K3],
    value: S
  ): this;
  setIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>
  >(
    keyPath: [K, K2, K3, K4],
    value: S
  ): this;
  setIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>
  >(
    keyPath: [K, K2, K3, K4, K5],
    value: S
  ): this;

  deleteIn(keyPath: []): void;
  deleteIn(keyPath: [K]): this;
  deleteIn<K2: $KeyOf<V>>(keyPath: [K, K2]): this;
  deleteIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>(
    keyPath: [K, K2, K3]
  ): this;
  deleteIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>
  >(
    keyPath: [K, K2, K3, K4]
  ): this;
  deleteIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>
  >(
    keyPath: [K, K2, K3, K4, K5]
  ): this;

  removeIn(keyPath: []): void;
  removeIn(keyPath: [K]): this;
  removeIn<K2: $KeyOf<V>>(keyPath: [K, K2]): this;
  removeIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>(
    keyPath: [K, K2, K3]
  ): this;
  removeIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>
  >(
    keyPath: [K, K2, K3, K4]
  ): this;
  removeIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>
  >(
    keyPath: [K, K2, K3, K4, K5]
  ): this;

  updateIn<U>(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U;
  updateIn<U>(keyPath: [], updater: (value: this) => U): U;
  updateIn<NSV>(keyPath: [K], notSetValue: NSV, updater: (value: V) => V): this;
  updateIn(keyPath: [K], updater: (value: V) => V): this;
  updateIn<NSV, K2: $KeyOf<V>, S: $ValOf<V, K2>>(
    keyPath: [K, K2],
    notSetValue: NSV,
    updater: (value: $ValOf<V, K2> | NSV) => S
  ): this;
  updateIn<K2: $KeyOf<V>, S: $ValOf<V, K2>>(
    keyPath: [K, K2],
    updater: (value: $ValOf<V, K2>) => S
  ): this;
  updateIn<
    NSV,
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    S: $ValOf<$ValOf<V, K2>, K3>
  >(
    keyPath: [K, K2, K3],
    notSetValue: NSV,
    updater: (value: $ValOf<$ValOf<V, K2>, K3> | NSV) => S
  ): this;
  updateIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    S: $ValOf<$ValOf<V, K2>, K3>
  >(
    keyPath: [K, K2, K3],
    updater: (value: $ValOf<$ValOf<V, K2>, K3>) => S
  ): this;
  updateIn<
    NSV,
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>
  >(
    keyPath: [K, K2, K3, K4],
    notSetValue: NSV,
    updater: (value: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> | NSV) => S
  ): this;
  updateIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>
  >(
    keyPath: [K, K2, K3, K4],
    updater: (value: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>) => S
  ): this;
  updateIn<
    NSV,
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>
  >(
    keyPath: [K, K2, K3, K4, K5],
    notSetValue: NSV,
    updater: (
      value: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> | NSV
    ) => S
  ): this;
  updateIn<
    K2: $KeyOf<V>,
    K3: $KeyOf<$ValOf<V, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>
  >(
    keyPath: [K, K2, K3, K4, K5],
    updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>) => S
  ): this;
}

declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof
  List);
declare class List<+T>
  extends IndexedCollection<T>
  mixins UpdatableInCollection<number, T>
{
  static (collection?: Iterable<T>): List<T>;

  static of<T>(...values: T[]): List<T>;

  static isList: typeof isList;

  size: number;

  set<U>(index: number, value: U): List<T | U>;
  delete(index: number): this;
  remove(index: number): this;
  insert<U>(index: number, value: U): List<T | U>;
  clear(): this;
  push<U>(...values: U[]): List<T | U>;
  pop(): this;
  unshift<U>(...values: U[]): List<T | U>;
  shift(): this;

  update<U>(updater: (value: this) => U): U;
  update<U>(index: number, updater: (value: T) => U): List<T | U>;
  update<U>(
    index: number,
    notSetValue: U,
    updater: (value: T) => U
  ): List<T | U>;

  merge<U>(...collections: Iterable<U>[]): List<T | U>;

  setSize(size: number): this;

  mergeIn(keyPath: Iterable<mixed>, ...collections: Iterable<mixed>[]): this;
  mergeDeepIn(
    keyPath: Iterable<mixed>,
    ...collections: Iterable<mixed>[]
  ): this;

  withMutations(mutator: (mutable: this) => mixed): this;
  asMutable(): this;
  wasAltered(): boolean;
  asImmutable(): this;

  // Override specialized return types

  concat<C>(...iters: Array<Iterable<C> | C>): List<T | C>;

  filter(predicate: typeof Boolean): List<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, index: number, iter: this) => mixed,
    context?: mixed
  ): List<T>;

  map<M>(
    mapper: (value: T, index: number, iter: this) => M,
    context?: mixed
  ): List<M>;

  flatMap<M>(
    mapper: (value: T, index: number, iter: this) => Iterable<M>,
    context?: mixed
  ): List<M>;

  flatten(depth?: number): List<any>;
  flatten(shallow?: boolean): List<any>;

  zip<A>(a: Iterable<A>, ..._: []): List<[T, A]>;
  zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): List<[T, A, B]>;
  zip<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): List<[T, A, B, C]>;
  zip<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): List<[T, A, B, C, D]>;
  zip<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): List<[T, A, B, C, D, E]>;

  zipAll<A>(a: Iterable<A>, ..._: []): List<[T | void, A | void]>;
  zipAll<A, B>(
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): List<[T | void, A | void, B | void]>;
  zipAll<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): List<[T | void, A | void, B | void, C | void]>;
  zipAll<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): List<[T | void, A | void, B | void, C | void, D | void]>;
  zipAll<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): List<[T | void, A | void, B | void, C | void, D | void, E | void]>;

  zipWith<A, R>(
    zipper: (value: T, a: A) => R,
    a: Iterable<A>,
    ..._: []
  ): List<R>;
  zipWith<A, B, R>(
    zipper: (value: T, a: A, b: B) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): List<R>;
  zipWith<A, B, C, R>(
    zipper: (value: T, a: A, b: B, c: C) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): List<R>;
  zipWith<A, B, C, D, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): List<R>;
  zipWith<A, B, C, D, E, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): List<R>;
}

declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof
  Map);
declare class Map<K, +V>
  extends KeyedCollection<K, V>
  mixins UpdatableInCollection<K, V>
{
  static <K, V>(values?: Iterable<[K, V]> | PlainObjInput<K, V>): Map<K, V>;

  static isMap: typeof isMap;

  size: number;

  set<K_, V_>(key: K_, value: V_): Map<K | K_, V | V_>;
  delete(key: K): this;
  remove(key: K): this;
  clear(): this;

  deleteAll(keys: Iterable<K>): Map<K, V>;
  removeAll(keys: Iterable<K>): Map<K, V>;

  update<U>(updater: (value: this) => U): U;
  update<V_>(key: K, updater: (value: V) => V_): Map<K, V | V_>;
  update<V_>(
    key: K,
    notSetValue: V_,
    updater: (value: V) => V_
  ): Map<K, V | V_>;

  merge<K_, V_>(
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): Map<K | K_, V | V_>;
  concat<K_, V_>(
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): Map<K | K_, V | V_>;

  mergeWith<K_, W, X>(
    merger: (oldVal: V, newVal: W, key: K) => X,
    ...collections: (Iterable<[K_, W]> | PlainObjInput<K_, W>)[]
  ): Map<K | K_, V | W | X>;

  mergeDeep<K_, V_>(
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): Map<K | K_, V | V_>;

  mergeDeepWith<K_, V_>(
    merger: (oldVal: any, newVal: any, key: any) => mixed,
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): Map<K | K_, V | V_>;

  mergeIn(
    keyPath: Iterable<mixed>,
    ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
  ): this;
  mergeDeepIn(
    keyPath: Iterable<mixed>,
    ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
  ): this;

  withMutations(mutator: (mutable: this) => mixed): this;
  asMutable(): this;
  wasAltered(): boolean;
  asImmutable(): this;

  // Override specialized return types

  flip(): Map<V, K>;

  filter(predicate: typeof Boolean): Map<K, $NonMaybeType<V>>;
  filter(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): Map<K, V>;

  map<M>(
    mapper: (value: V, key: K, iter: this) => M,
    context?: mixed
  ): Map<K, M>;

  mapKeys<M>(
    mapper: (key: K, value: V, iter: this) => M,
    context?: mixed
  ): Map<M, V>;

  mapEntries<KM, VM>(
    mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
    context?: mixed
  ): Map<KM, VM>;

  flatMap<KM, VM>(
    mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
    context?: mixed
  ): Map<KM, VM>;

  flatten(depth?: number): Map<any, any>;
  flatten(shallow?: boolean): Map<any, any>;
}

declare function isOrderedMap(
  maybeOrderedMap: mixed
): boolean %checks(maybeOrderedMap instanceof OrderedMap);
declare class OrderedMap<K, +V>
  extends Map<K, V>
  mixins UpdatableInCollection<K, V>
{
  static <K, V>(
    values?: Iterable<[K, V]> | PlainObjInput<K, V>
  ): OrderedMap<K, V>;

  static isOrderedMap: typeof isOrderedMap;

  size: number;

  set<K_, V_>(key: K_, value: V_): OrderedMap<K | K_, V | V_>;
  delete(key: K): this;
  remove(key: K): this;
  clear(): this;

  update<U>(updater: (value: this) => U): U;
  update<V_>(key: K, updater: (value: V) => V_): OrderedMap<K, V | V_>;
  update<V_>(
    key: K,
    notSetValue: V_,
    updater: (value: V) => V_
  ): OrderedMap<K, V | V_>;

  merge<K_, V_>(
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): OrderedMap<K | K_, V | V_>;
  concat<K_, V_>(
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): OrderedMap<K | K_, V | V_>;

  mergeWith<K_, W, X>(
    merger: (oldVal: V, newVal: W, key: K) => X,
    ...collections: (Iterable<[K_, W]> | PlainObjInput<K_, W>)[]
  ): OrderedMap<K | K_, V | W | X>;

  mergeDeep<K_, V_>(
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): OrderedMap<K | K_, V | V_>;

  mergeDeepWith<K_, V_>(
    merger: (oldVal: any, newVal: any, key: any) => mixed,
    ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
  ): OrderedMap<K | K_, V | V_>;

  mergeIn(
    keyPath: Iterable<mixed>,
    ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
  ): this;
  mergeDeepIn(
    keyPath: Iterable<mixed>,
    ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
  ): this;

  withMutations(mutator: (mutable: this) => mixed): this;
  asMutable(): this;
  wasAltered(): boolean;
  asImmutable(): this;

  // Override specialized return types

  flip(): OrderedMap<V, K>;

  filter(predicate: typeof Boolean): OrderedMap<K, $NonMaybeType<V>>;
  filter(
    predicate: (value: V, key: K, iter: this) => mixed,
    context?: mixed
  ): OrderedMap<K, V>;

  map<M>(
    mapper: (value: V, key: K, iter: this) => M,
    context?: mixed
  ): OrderedMap<K, M>;

  mapKeys<M>(
    mapper: (key: K, value: V, iter: this) => M,
    context?: mixed
  ): OrderedMap<M, V>;

  mapEntries<KM, VM>(
    mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
    context?: mixed
  ): OrderedMap<KM, VM>;

  flatMap<KM, VM>(
    mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
    context?: mixed
  ): OrderedMap<KM, VM>;

  flatten(depth?: number): OrderedMap<any, any>;
  flatten(shallow?: boolean): OrderedMap<any, any>;
}

declare function isSet(maybeSet: mixed): boolean %checks(maybeSet instanceof
  Set);
declare class Set<+T> extends SetCollection<T> {
  static <T>(values?: Iterable<T>): Set<T>;

  static of<T>(...values: T[]): Set<T>;
  static fromKeys<T>(
    values: Iterable<[T, mixed]> | PlainObjInput<T, mixed>
  ): Set<T>;

  static intersect(sets: Iterable<Iterable<T>>): Set<T>;
  static union(sets: Iterable<Iterable<T>>): Set<T>;

  static isSet: typeof isSet;

  size: number;

  add<U>(value: U): Set<T | U>;
  delete(value: T): this;
  remove(value: T): this;
  clear(): this;
  union<U>(...collections: Iterable<U>[]): Set<T | U>;
  merge<U>(...collections: Iterable<U>[]): Set<T | U>;
  concat<U>(...collections: Iterable<U>[]): Set<T | U>;
  intersect<U>(...collections: Iterable<U>[]): Set<T & U>;
  subtract(...collections: Iterable<mixed>[]): this;

  withMutations(mutator: (mutable: this) => mixed): this;
  asMutable(): this;
  wasAltered(): boolean;
  asImmutable(): this;

  // Override specialized return types

  filter(predicate: typeof Boolean): Set<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, value: T, iter: this) => mixed,
    context?: mixed
  ): Set<T>;

  map<M>(
    mapper: (value: T, value: T, iter: this) => M,
    context?: mixed
  ): Set<M>;

  flatMap<M>(
    mapper: (value: T, value: T, iter: this) => Iterable<M>,
    context?: mixed
  ): Set<M>;

  flatten(depth?: number): Set<any>;
  flatten(shallow?: boolean): Set<any>;
}

// Overrides except for `isOrderedSet` are for specialized return types
declare function isOrderedSet(
  maybeOrderedSet: mixed
): boolean %checks(maybeOrderedSet instanceof OrderedSet);
declare class OrderedSet<+T> extends Set<T> {
  static <T>(values?: Iterable<T>): OrderedSet<T>;

  static of<T>(...values: T[]): OrderedSet<T>;
  static fromKeys<T>(
    values: Iterable<[T, mixed]> | PlainObjInput<T, mixed>
  ): OrderedSet<T>;

  static isOrderedSet: typeof isOrderedSet;

  size: number;

  add<U>(value: U): OrderedSet<T | U>;
  union<U>(...collections: Iterable<U>[]): OrderedSet<T | U>;
  merge<U>(...collections: Iterable<U>[]): OrderedSet<T | U>;
  concat<U>(...collections: Iterable<U>[]): OrderedSet<T | U>;
  intersect<U>(...collections: Iterable<U>[]): OrderedSet<T & U>;

  filter(predicate: typeof Boolean): OrderedSet<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, value: T, iter: this) => mixed,
    context?: mixed
  ): OrderedSet<T>;

  map<M>(
    mapper: (value: T, value: T, iter: this) => M,
    context?: mixed
  ): OrderedSet<M>;

  flatMap<M>(
    mapper: (value: T, value: T, iter: this) => Iterable<M>,
    context?: mixed
  ): OrderedSet<M>;

  flatten(depth?: number): OrderedSet<any>;
  flatten(shallow?: boolean): OrderedSet<any>;

  zip<A>(a: Iterable<A>, ..._: []): OrderedSet<[T, A]>;
  zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): OrderedSet<[T, A, B]>;
  zip<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): OrderedSet<[T, A, B, C]>;
  zip<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): OrderedSet<[T, A, B, C, D]>;
  zip<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): OrderedSet<[T, A, B, C, D, E]>;

  zipAll<A>(a: Iterable<A>, ..._: []): OrderedSet<[T | void, A | void]>;
  zipAll<A, B>(
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): OrderedSet<[T | void, A | void, B | void]>;
  zipAll<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): OrderedSet<[T | void, A | void, B | void, C | void]>;
  zipAll<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): OrderedSet<[T | void, A | void, B | void, C | void, D | void]>;
  zipAll<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): OrderedSet<[T | void, A | void, B | void, C | void, D | void, E | void]>;

  zipWith<A, R>(
    zipper: (value: T, a: A) => R,
    a: Iterable<A>,
    ..._: []
  ): OrderedSet<R>;
  zipWith<A, B, R>(
    zipper: (value: T, a: A, b: B) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): OrderedSet<R>;
  zipWith<A, B, C, R>(
    zipper: (value: T, a: A, b: B, c: C) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): OrderedSet<R>;
  zipWith<A, B, C, D, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): OrderedSet<R>;
  zipWith<A, B, C, D, E, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): OrderedSet<R>;
}

declare function isStack(
  maybeStack: mixed
): boolean %checks(maybeStack instanceof Stack);
declare class Stack<+T> extends IndexedCollection<T> {
  static <T>(collection?: Iterable<T>): Stack<T>;

  static isStack(maybeStack: mixed): boolean;
  static of<T>(...values: T[]): Stack<T>;

  static isStack: typeof isStack;

  size: number;

  peek(): T;
  clear(): this;
  unshift<U>(...values: U[]): Stack<T | U>;
  unshiftAll<U>(iter: Iterable<U>): Stack<T | U>;
  shift(): this;
  push<U>(...values: U[]): Stack<T | U>;
  pushAll<U>(iter: Iterable<U>): Stack<T | U>;
  pop(): this;

  withMutations(mutator: (mutable: this) => mixed): this;
  asMutable(): this;
  wasAltered(): boolean;
  asImmutable(): this;

  // Override specialized return types

  concat<C>(...iters: Array<Iterable<C> | C>): Stack<T | C>;

  filter(predicate: typeof Boolean): Stack<$NonMaybeType<T>>;
  filter(
    predicate: (value: T, index: number, iter: this) => mixed,
    context?: mixed
  ): Stack<T>;

  map<M>(
    mapper: (value: T, index: number, iter: this) => M,
    context?: mixed
  ): Stack<M>;

  flatMap<M>(
    mapper: (value: T, index: number, iter: this) => Iterable<M>,
    context?: mixed
  ): Stack<M>;

  flatten(depth?: number): Stack<any>;
  flatten(shallow?: boolean): Stack<any>;

  zip<A>(a: Iterable<A>, ..._: []): Stack<[T, A]>;
  zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): Stack<[T, A, B]>;
  zip<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): Stack<[T, A, B, C]>;
  zip<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): Stack<[T, A, B, C, D]>;
  zip<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): Stack<[T, A, B, C, D, E]>;

  zipAll<A>(a: Iterable<A>, ..._: []): Stack<[T | void, A | void]>;
  zipAll<A, B>(
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): Stack<[T | void, A | void, B | void]>;
  zipAll<A, B, C>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): Stack<[T | void, A | void, B | void, C | void]>;
  zipAll<A, B, C, D>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): Stack<[T | void, A | void, B | void, C | void, D | void]>;
  zipAll<A, B, C, D, E>(
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): Stack<[T | void, A | void, B | void, C | void, D | void, E | void]>;

  zipWith<A, R>(
    zipper: (value: T, a: A) => R,
    a: Iterable<A>,
    ..._: []
  ): Stack<R>;
  zipWith<A, B, R>(
    zipper: (value: T, a: A, b: B) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    ..._: []
  ): Stack<R>;
  zipWith<A, B, C, R>(
    zipper: (value: T, a: A, b: B, c: C) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    ..._: []
  ): Stack<R>;
  zipWith<A, B, C, D, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    ..._: []
  ): Stack<R>;
  zipWith<A, B, C, D, E, R>(
    zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
    a: Iterable<A>,
    b: Iterable<B>,
    c: Iterable<C>,
    d: Iterable<D>,
    e: Iterable<E>,
    ..._: []
  ): Stack<R>;
}

declare function Range(
  start?: number,
  end?: number,
  step?: number
): IndexedSeq<number>;
declare function Repeat<T>(value: T, times?: number): IndexedSeq<T>;

// The type of a Record factory function.
type RecordFactory<Values: Object> = Class<RecordInstance<Values>>;

// The type of runtime Record instances.
type RecordOf<Values: Object> = RecordInstance<Values> & $ReadOnly<Values>;

// The values of a Record instance.
type _RecordValues<T, R: RecordInstance<T> | T> = R;
type RecordValues<R> = _RecordValues<*, R>;

declare function isRecord(
  maybeRecord: any
): boolean %checks(maybeRecord instanceof RecordInstance);
declare class Record {
  static <Values: Object>(spec: Values, name?: string): typeof RecordInstance;
  constructor<Values: Object>(
    spec: Values,
    name?: string
  ): typeof RecordInstance;

  static isRecord: typeof isRecord;

  static getDescriptiveName(record: RecordInstance<any>): string;
}

declare class RecordInstance<T: Object = Object> {
  static (values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>): RecordOf<T>;
  // Note: a constructor can only create an instance of RecordInstance<T>,
  // it's encouraged to not use `new` when creating Records.
  constructor(values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>): void;

  size: number;

  has(key: string): boolean;

  get<K: $Keys<T>>(key: K, ..._: []): $ElementType<T, K>;
  get<K: $Keys<T>, NSV>(key: K, notSetValue: NSV): $ElementType<T, K> | NSV;

  hasIn(keyPath: Iterable<mixed>): boolean;

  getIn(keyPath: [], notSetValue?: mixed): this & $ReadOnly<T>;
  getIn<K: $Keys<T>>(keyPath: [K], notSetValue?: mixed): $ElementType<T, K>;
  getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(
    keyPath: [K, K2],
    notSetValue: NSV
  ): $ValOf<$ValOf<T, K>, K2> | NSV;
  getIn<
    NSV,
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>
  >(
    keyPath: [K, K2, K3],
    notSetValue: NSV
  ): $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV;
  getIn<
    NSV,
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>
  >(
    keyPath: [K, K2, K3, K4],
    notSetValue: NSV
  ): $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV;
  getIn<
    NSV,
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>
  >(
    keyPath: [K, K2, K3, K4, K5],
    notSetValue: NSV
  ): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV;

  equals(other: any): boolean;
  hashCode(): number;

  set<K: $Keys<T>>(key: K, value: $ElementType<T, K>): this & $ReadOnly<T>;
  update<K: $Keys<T>>(
    key: K,
    updater: (value: $ElementType<T, K>) => $ElementType<T, K>
  ): this & $ReadOnly<T>;
  merge(
    ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
  ): this & $ReadOnly<T>;
  mergeDeep(
    ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
  ): this & $ReadOnly<T>;

  mergeWith(
    merger: (oldVal: $ValOf<T>, newVal: $ValOf<T>, key: $Keys<T>) => $ValOf<T>,
    ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
  ): this & $ReadOnly<T>;
  mergeDeepWith(
    merger: (oldVal: any, newVal: any, key: any) => any,
    ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
  ): this & $ReadOnly<T>;

  delete<K: $Keys<T>>(key: K): this & $ReadOnly<T>;
  remove<K: $Keys<T>>(key: K): this & $ReadOnly<T>;
  clear(): this & $ReadOnly<T>;

  setIn<S>(keyPath: [], value: S): S;
  setIn<K: $Keys<T>, S: $ValOf<T, K>>(
    keyPath: [K],
    value: S
  ): this & $ReadOnly<T>;
  setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(
    keyPath: [K, K2],
    value: S
  ): this & $ReadOnly<T>;
  setIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>
  >(
    keyPath: [K, K2, K3],
    value: S
  ): this & $ReadOnly<T>;
  setIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>
  >(
    keyPath: [K, K2, K3, K4],
    value: S
  ): this & $ReadOnly<T>;
  setIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>
  >(
    keyPath: [K, K2, K3, K4, K5],
    value: S
  ): this & $ReadOnly<T>;

  deleteIn(keyPath: []): void;
  deleteIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>;
  deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(
    keyPath: [K, K2]
  ): this & $ReadOnly<T>;
  deleteIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>
  >(
    keyPath: [K, K2, K3]
  ): this & $ReadOnly<T>;
  deleteIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>
  >(
    keyPath: [K, K2, K3, K4]
  ): this & $ReadOnly<T>;
  deleteIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>
  >(
    keyPath: [K, K2, K3, K4, K5]
  ): this & $ReadOnly<T>;

  removeIn(keyPath: []): void;
  removeIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>;
  removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(
    keyPath: [K, K2]
  ): this & $ReadOnly<T>;
  removeIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>
  >(
    keyPath: [K, K2, K3]
  ): this & $ReadOnly<T>;
  removeIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>
  >(
    keyPath: [K, K2, K3, K4]
  ): this & $ReadOnly<T>;
  removeIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>
  >(
    keyPath: [K, K2, K3, K4, K5]
  ): this & $ReadOnly<T>;

  updateIn<U>(
    keyPath: [],
    notSetValue: mixed,
    updater: (value: this & T) => U
  ): U;
  updateIn<U>(keyPath: [], updater: (value: this & T) => U): U;
  updateIn<NSV, K: $Keys<T>, S: $ValOf<T, K>>(
    keyPath: [K],
    notSetValue: NSV,
    updater: (value: $ValOf<T, K>) => S
  ): this & $ReadOnly<T>;
  updateIn<K: $Keys<T>, S: $ValOf<T, K>>(
    keyPath: [K],
    updater: (value: $ValOf<T, K>) => S
  ): this & $ReadOnly<T>;
  updateIn<
    NSV,
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    S: $ValOf<$ValOf<T, K>, K2>
  >(
    keyPath: [K, K2],
    notSetValue: NSV,
    updater: (value: $ValOf<$ValOf<T, K>, K2> | NSV) => S
  ): this & $ReadOnly<T>;
  updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(
    keyPath: [K, K2],
    updater: (value: $ValOf<$ValOf<T, K>, K2>) => S
  ): this & $ReadOnly<T>;
  updateIn<
    NSV,
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>
  >(
    keyPath: [K, K2, K3],
    notSetValue: NSV,
    updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV) => S
  ): this & $ReadOnly<T>;
  updateIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>
  >(
    keyPath: [K, K2, K3],
    updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>) => S
  ): this & $ReadOnly<T>;
  updateIn<
    NSV,
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>
  >(
    keyPath: [K, K2, K3, K4],
    notSetValue: NSV,
    updater: (
      value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV
    ) => S
  ): this & $ReadOnly<T>;
  updateIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>
  >(
    keyPath: [K, K2, K3, K4],
    updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>) => S
  ): this & $ReadOnly<T>;
  updateIn<
    NSV,
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>
  >(
    keyPath: [K, K2, K3, K4, K5],
    notSetValue: NSV,
    updater: (
      value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV
    ) => S
  ): this & $ReadOnly<T>;
  updateIn<
    K: $Keys<T>,
    K2: $KeyOf<$ValOf<T, K>>,
    K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>,
    K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>,
    K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>,
    S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>
  >(
    keyPath: [K, K2, K3, K4, K5],
    updater: (
      value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>
    ) => S
  ): this & $ReadOnly<T>;

  mergeIn(
    keyPath: Iterable<mixed>,
    ...collections: Array<any>
  ): this & $ReadOnly<T>;
  mergeDeepIn(
    keyPath: Iterable<mixed>,
    ...collections: Array<any>
  ): this & $ReadOnly<T>;

  toSeq(): KeyedSeq<$Keys<T>, any>;

  toJS(): { [key: $Keys<T>]: mixed };
  toJSON(): T;
  toObject(): T;

  withMutations(mutator: (mutable: this & T) => mixed): this & $ReadOnly<T>;
  asMutable(): this & $ReadOnly<T>;
  wasAltered(): boolean;
  asImmutable(): this & $ReadOnly<T>;

  @@iterator(): Iterator<[$Keys<T>, $ValOf<T>]>;
}

declare function fromJS(
  jsValue: mixed,
  reviver?: (
    key: string | number,
    sequence: KeyedCollection<string, mixed> | IndexedCollection<mixed>,
    path?: Array<string | number>
  ) => mixed
): Collection<mixed, mixed>;

declare function is(first: mixed, second: mixed): boolean;
declare function hash(value: mixed): number;

declare function get<C: Object, K: $Keys<C>>(
  collection: C,
  key: K,
  notSetValue: mixed
): $ValOf<C, K>;
declare function get<C, K: $KeyOf<C>, NSV>(
  collection: C,
  key: K,
  notSetValue: NSV
): $ValOf<C, K> | NSV;

declare function has(collection: Object, key: mixed): boolean;
declare function remove<C>(collection: C, key: $KeyOf<C>): C;
declare function set<C, K: $KeyOf<C>, V: $ValOf<C, K>>(
  collection: C,
  key: K,
  value: V
): C;
declare function update<C, K: $KeyOf<C>, V: $ValOf<C, K>, NSV>(
  collection: C,
  key: K,
  notSetValue: NSV,
  updater: ($ValOf<C, K> | NSV) => V
): C;
declare function update<C, K: $KeyOf<C>, V: $ValOf<C, K>>(
  collection: C,
  key: K,
  updater: ($ValOf<C, K>) => V
): C;

declare function getIn<C>(collection: C, keyPath: [], notSetValue?: mixed): C;
declare function getIn<C, K: $KeyOf<C>, NSV>(
  collection: C,
  keyPath: [K],
  notSetValue: NSV
): $ValOf<C, K> | NSV;
declare function getIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, NSV>(
  collection: C,
  keyPath: [K, K2],
  notSetValue: NSV
): $ValOf<$ValOf<C, K>, K2> | NSV;
declare function getIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  NSV
>(
  collection: C,
  keyPath: [K, K2, K3],
  notSetValue: NSV
): $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> | NSV;
declare function getIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  NSV
>(
  collection: C,
  keyPath: [K, K2, K3, K4],
  notSetValue: NSV
): $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> | NSV;
declare function getIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>,
  NSV
>(
  collection: C,
  keyPath: [K, K2, K3, K4, K5],
  notSetValue: NSV
): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> | NSV;

declare function hasIn(collection: Object, keyPath: Iterable<mixed>): boolean;

declare function removeIn<C>(collection: C, keyPath: []): void;
declare function removeIn<C, K: $KeyOf<C>>(collection: C, keyPath: [K]): C;
declare function removeIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C>>>(
  collection: C,
  keyPath: [K, K2]
): C;
declare function removeIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C>>,
  K3: $KeyOf<$ValOf<$ValOf<C>, K2>>
>(
  collection: C,
  keyPath: [K, K2, K3]
): C;
declare function removeIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C>>,
  K3: $KeyOf<$ValOf<$ValOf<C>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C>, K2>, K3>>
>(
  collection: C,
  keyPath: [K, K2, K3, K4]
): C;
declare function removeIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C>>,
  K3: $KeyOf<$ValOf<$ValOf<C>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C>, K2>, K3>>,
  K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C>, K2>, K3>, K4>>
>(
  collection: C,
  keyPath: [K, K2, K3, K4, K5]
): C;

declare function setIn<S>(collection: Object, keyPath: [], value: S): S;
declare function setIn<C, K: $KeyOf<C>, S: $ValOf<C, K>>(
  collection: C,
  keyPath: [K],
  value: S
): C;
declare function setIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  S: $ValOf<$ValOf<C, K>, K2>
>(
  collection: C,
  keyPath: [K, K2],
  value: S
): C;
declare function setIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>
>(
  collection: C,
  keyPath: [K, K2, K3],
  value: S
): C;
declare function setIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>
>(
  collection: C,
  keyPath: [K, K2, K3, K4],
  value: S
): C;
declare function setIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>,
  S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>
>(
  collection: C,
  keyPath: [K, K2, K3, K4, K5],
  value: S
): C;

declare function updateIn<C, S>(
  collection: C,
  keyPath: [],
  notSetValue: mixed,
  updater: (value: C) => S
): S;
declare function updateIn<C, S>(
  collection: C,
  keyPath: [],
  updater: (value: C) => S
): S;
declare function updateIn<C, K: $KeyOf<C>, S: $ValOf<C, K>, NSV>(
  collection: C,
  keyPath: [K],
  notSetValue: NSV,
  updater: (value: $ValOf<C, K> | NSV) => S
): C;
declare function updateIn<C, K: $KeyOf<C>, S: $ValOf<C, K>>(
  collection: C,
  keyPath: [K],
  updater: (value: $ValOf<C, K>) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  S: $ValOf<$ValOf<C, K>, K2>,
  NSV
>(
  collection: C,
  keyPath: [K, K2],
  notSetValue: NSV,
  updater: (value: $ValOf<$ValOf<C, K>, K2> | NSV) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  S: $ValOf<$ValOf<C, K>, K2>
>(
  collection: C,
  keyPath: [K, K2],
  updater: (value: $ValOf<$ValOf<C, K>, K2>) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>,
  NSV
>(
  collection: C,
  keyPath: [K, K2, K3],
  notSetValue: NSV,
  updater: (value: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> | NSV) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>
>(
  collection: C,
  keyPath: [K, K2, K3],
  updater: (value: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>,
  NSV
>(
  collection: C,
  keyPath: [K, K2, K3, K4],
  notSetValue: NSV,
  updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> | NSV) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>
>(
  collection: C,
  keyPath: [K, K2, K3, K4],
  updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>,
  S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>,
  NSV
>(
  collection: C,
  keyPath: [K, K2, K3, K4, K5],
  notSetValue: NSV,
  updater: (
    value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> | NSV
  ) => S
): C;
declare function updateIn<
  C,
  K: $KeyOf<C>,
  K2: $KeyOf<$ValOf<C, K>>,
  K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>,
  K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>,
  K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>,
  S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>
>(
  collection: C,
  keyPath: [K, K2, K3, K4, K5],
  updater: (
    value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>
  ) => S
): C;

declare function merge<C>(
  collection: C,
  ...collections: Array<
    | $IterableOf<C>
    | $Shape<RecordValues<C>>
    | PlainObjInput<$KeyOf<C>, $ValOf<C>>
  >
): C;
declare function mergeWith<C>(
  merger: (oldVal: $ValOf<C>, newVal: $ValOf<C>, key: $KeyOf<C>) => $ValOf<C>,
  collection: C,
  ...collections: Array<
    | $IterableOf<C>
    | $Shape<RecordValues<C>>
    | PlainObjInput<$KeyOf<C>, $ValOf<C>>
  >
): C;
declare function mergeDeep<C>(
  collection: C,
  ...collections: Array<
    | $IterableOf<C>
    | $Shape<RecordValues<C>>
    | PlainObjInput<$KeyOf<C>, $ValOf<C>>
  >
): C;
declare function mergeDeepWith<C>(
  merger: (oldVal: any, newVal: any, key: any) => mixed,
  collection: C,
  ...collections: Array<
    | $IterableOf<C>
    | $Shape<RecordValues<C>>
    | PlainObjInput<$KeyOf<C>, $ValOf<C>>
  >
): C;

export {
  Collection,
  Seq,
  List,
  Map,
  OrderedMap,
  OrderedSet,
  Range,
  Repeat,
  Record,
  Set,
  Stack,
  fromJS,
  is,
  hash,
  isImmutable,
  isCollection,
  isKeyed,
  isIndexed,
  isAssociative,
  isOrdered,
  isRecord,
  isValueObject,
  get,
  has,
  remove,
  set,
  update,
  getIn,
  hasIn,
  removeIn,
  setIn,
  updateIn,
  merge,
  mergeWith,
  mergeDeep,
  mergeDeepWith,
};

export default {
  Collection,
  Seq,

  List,
  Map,
  OrderedMap,
  OrderedSet,
  Range,
  Repeat,
  Record,
  Set,
  Stack,

  fromJS,
  is,
  hash,

  isImmutable,
  isCollection,
  isKeyed,
  isIndexed,
  isAssociative,
  isOrdered,
  isRecord,
  isValueObject,

  get,
  has,
  remove,
  set,
  update,
  getIn,
  hasIn,
  removeIn,
  setIn,
  updateIn,
  merge,
  mergeWith,
  mergeDeep,
  mergeDeepWith,
};

export type {
  KeyedCollection,
  IndexedCollection,
  SetCollection,
  KeyedSeq,
  IndexedSeq,
  SetSeq,
  RecordFactory,
  RecordOf,
  RecordInstance,
  ValueObject,
  $KeyOf,
  $ValOf,
};
                                    INDX( 	                 (       è       Ű                    á'    h T     Ö'    AęLkxŰŃžîaxŰ3eęLkxŰŃžîaxŰ p      5k              	 R E A D M E . m d                   h T     Ö'    AęLkxŰŃžîaxŰ3eęLkxŰŃžîaxŰ p      5k              	 R E A D M E . m d                   AęLkxŰŃžîaxŰ3eęLkxŰŃžîaxŰ p      5k              	 R E A D M E . m d                   ŃžîaxŰ3eęLkxŰŃžîaxŰ p      5k              	 R E A D M E . m d                   Ö'    AęLkxŰŃžîaxŰ3eęLkx ŃžîaxŰ p      5k              	 R E A D M E . m d                   h T     Ö'    AęLkxŰŃžîaxŰ3eęLkxŰŃžîaxŰ p      5k              	 R E A D M E . m d                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    "use strict";

const selectorParser = require("postcss-selector-parser");
const valueParser = require("postcss-value-parser");
const { extractICSS } = require("icss-utils");

const isSpacing = (node) => node.type === "combinator" && node.value === " ";

function normalizeNodeArray(nodes) {
  const array = [];

  nodes.forEach((x) => {
    if (Array.isArray(x)) {
      normalizeNodeArray(x).forEach((item) => {
        array.push(item);
      });
    } else if (x) {
      array.push(x);
    }
  });

  if (array.length > 0 && isSpacing(array[array.length - 1])) {
    array.pop();
  }
  return array;
}

function localizeNode(rule, mode, localAliasMap) {
  const transform = (node, context) => {
    if (context.ignoreNextSpacing && !isSpacing(node)) {
      throw new Error("Missing whitespace after " + context.ignoreNextSpacing);
    }

    if (context.enforceNoSpacing && isSpacing(node)) {
      throw new Error("Missing whitespace before " + context.enforceNoSpacing);
    }

    let newNodes;

    switch (node.type) {
      case "root": {
        let resultingGlobal;

        context.hasPureGlobals = false;

        newNodes = node.nodes.map((n) => {
          const nContext = {
            global: context.global,
            lastWasSpacing: true,
            hasLocals: false,
            explicit: false,
          };

          n = transform(n, nContext);

          if (typeof resultingGlobal === "undefined") {
            resultingGlobal = nContext.global;
          } else if (resultingGlobal !== nContext.global) {
            throw new Error(
              'Inconsistent rule global/local result in rule "' +
                node +
                '" (multiple selectors must result in the same mode for the rule)'
            );
          }

          if (!nContext.hasLocals) {
            context.hasPureGlobals = true;
          }

          return n;
        });

        context.global = resultingGlobal;

        node.nodes = normalizeNodeArray(newNodes);
        break;
      }
      case "selector": {
        newNodes = node.map((childNode) => transform(childNode, context));

        node = node.clone();
        node.nodes = normalizeNodeArray(newNodes);
        break;
      }
      case "combinator": {
        if (isSpacing(node)) {
          if (context.ignoreNextSpacing) {
            context.ignoreNextSpacing = false;
            context.lastWasSpacing = false;
            context.enforceNoSpacing = false;
            return null;
          }
          context.lastWasSpacing = true;
          return node;
        }
        break;
      }
      case "pseudo": {
        let childContext;
        const isNested = !!node.length;
        const isScoped = node.value === ":local" || node.value === ":global";
        const isImportExport =
          node.value === ":import" || node.value === ":export";

        if (isImportExport) {
          context.hasLocals = true;
          // :local(.foo)
        } else if (isNested) {
          if (isScoped) {
            if (node.nodes.length === 0) {
              throw new Error(`${node.value}() can't be empty`);
            }

            if (context.inside) {
              throw new Error(
                `A ${node.value} is not allowed inside of a ${context.inside}(...)`
              );
            }

            childContext = {
              global: node.value === ":global",
              inside: node.value,
              hasLocals: false,
              explicit: true,
            };

            newNodes = node
              .map((childNode) => transform(childNode, childContext))
              .reduce((acc, next) => acc.concat(next.nodes), []);

            if (newNodes.length) {
              const { before, after } = node.spaces;

              const first = newNodes[0];
              const last = newNodes[newNodes.length - 1];

              first.spaces = { before, after: first.spaces.after };
              last.spaces = { before: last.spaces.before, after };
            }

            node = newNodes;

            break;
          } else {
            childContext = {
              global: context.global,
              inside: context.inside,
              lastWasSpacing: true,
              hasLocals: false,
              explicit: context.explicit,
            };
            newNodes = node.map((childNode) =>
              transform(childNode, childContext)
            );

            node = node.clone();
            node.nodes = normalizeNodeArray(newNodes);

            if (childContext.hasLocals) {
              context.hasLocals = true;
            }
          }
          break;

          //:local .foo .bar
        } else if (isScoped) {
          if (context.inside) {
            throw new Error(
              `A ${node.value} is not allowed inside of a ${context.inside}(...)`
            );
          }

          const addBackSpacing = !!node.spaces.before;

          context.ignoreNextSpacing = context.lastWasSpacing
            ? node.value
            : false;

          context.enforceNoSpacing = context.lastWasSpacing
            ? false
            : node.value;

          context.global = node.value === ":global";
          context.explicit = true;

          // because this node has spacing that is lost when we remove it
          // we make up for it by adding an extra combinator in since adding
          // spacing on the parent selector doesn't work
          return addBackSpacing
            ? selectorParser.combinator({ value: " " })
            : null;
        }
        break;
      }
      case "id":
      case "class": {
        if (!node.value) {
          throw new Error("Invalid class or id selector syntax");
        }

        if (context.global) {
          break;
        }

        const isImportedValue = localAliasMap.has(node.value);
        const isImportedWithExplicitScope = isImportedValue && context.explicit;

        if (!isImportedValue || isImportedWithExplicitScope) {
          const innerNode = node.clone();
          innerNode.spaces = { before: "", after: "" };

          node = selectorParser.pseudo({
            value: ":local",
            nodes: [innerNode],
            spaces: node.spaces,
          });

          context.hasLocals = true;
        }

        break;
      }
    }

    context.lastWasSpacing = false;
    context.ignoreNextSpacing = false;
    context.enforceNoSpacing = false;

    return node;
  };

  const rootContext = {
    global: mode === "global",
    hasPureGlobals: false,
  };

  rootContext.selector = selectorParser((root) => {
    transform(root, rootContext);
  }).processSync(rule, { updateSelector: false, lossless: true });

  return rootContext;
}

function localizeDeclNode(node, context) {
  switch (node.type) {
    case "word":
      if (context.localizeNextItem) {
        if (!context.localAliasMap.has(node.value)) {
          node.value = ":local(" + node.value + ")";
          context.localizeNextItem = false;
        }
      }
      break;

    case "function":
      if (
        context.options &&
        context.options.rewriteUrl &&
        node.value.toLowerCase() === "url"
      ) {
        node.nodes.map((nestedNode) => {
          if (nestedNode.type !== "string" && nestedNode.type !== "word") {
            return;
          }

          let newUrl = context.options.rewriteUrl(
            context.global,
            nestedNode.value
          );

          switch (nestedNode.type) {
            case "string":
              if (nestedNode.quote === "'") {
                newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/'/g, "\\'");
              }

              if (nestedNode.quote === '"') {
                newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/"/g, '\\"');
              }

              break;
            case "word":
              newUrl = newUrl.replace(/("|'|\)|\\)/g, "\\$1");
              break;
          }

          nestedNode.value = newUrl;
        });
      }
      break;
  }
  return node;
}

function isWordAFunctionArgument(wordNode, functionNode) {
  return functionNode
    ? functionNode.nodes.some(
        (functionNodeChild) =>
          functionNodeChild.sourceIndex === wordNode.sourceIndex
      )
    : false;
}

function localizeDeclarationValues(localize, declaration, context) {
  const valueNodes = valueParser(declaration.value);

  valueNodes.walk((node, index, nodes) => {
    const subContext = {
      options: context.options,
      global: context.global,
      localizeNextItem: localize && !context.global,
      localAliasMap: context.localAliasMap,
    };
    nodes[index] = localizeDeclNode(node, subContext);
  });

  declaration.value = valueNodes.toString();
}

function localizeDeclaration(declaration, context) {
  const isAnimation = /animation$/i.test(declaration.prop);

  if (isAnimation) {
    const validIdent = /^-?[_a-z][_a-z0-9-]*$/i;

    /*
    The spec defines some keywords that you can use to describe properties such as the timing
    function. These are still valid animation names, so as long as there is a property that accepts
    a keyword, it is given priority. Only when all the properties that can take a keyword are
    exhausted can the animation name be set to the keyword. I.e.
  
    animation: infinite infinite;
  
    The animation will repeat an infinite number of times from the first argument, and will have an
    animation name of infinite from the second.
    */
    const animationKeywords = {
      $alternate: 1,
      "$alternate-reverse": 1,
      $backwards: 1,
      $both: 1,
      $ease: 1,
      "$ease-in": 1,
      "$ease-in-out": 1,
      "$ease-out": 1,
      $forwards: 1,
      $infinite: 1,
      $linear: 1,
      $none: Infinity, // No matter how many times you write none, it will never be an animation name
      $normal: 1,
      $paused: 1,
      $reverse: 1,
      $running: 1,
      "$step-end": 1,
      "$step-start": 1,
      $initial: Infinity,
      $inherit: Infinity,
      $unset: Infinity,
    };

    const didParseAnimationName = false;
    let parsedAnimationKeywords = {};
    let stepsFunctionNode = null;
    const valueNodes = valueParser(declaration.value).walk((node) => {
      /* If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. */
      if (node.type === "div") {
        parsedAnimationKeywords = {};
      }
      if (node.type === "function" && node.value.toLowerCase() === "steps") {
        stepsFunctionNode = node;
      }
      const value =
        node.type === "word" &&
        !isWordAFunctionArgument(node, stepsFunctionNode)
          ? node.value.toLowerCase()
          : null;

      let shouldParseAnimationName = false;

      if (!didParseAnimationName && value && validIdent.test(value)) {
        if ("$" + value in animationKeywords) {
          parsedAnimationKeywords["$" + value] =
            "$" + value in parsedAnimationKeywords
              ? parsedAnimationKeywords["$" + value] + 1
              : 0;

          shouldParseAnimationName =
            parsedAnimationKeywords["$" + value] >=
            animationKeywords["$" + value];
        } else {
          shouldParseAnimationName = true;
        }
      }

      const subContext = {
        options: context.options,
        global: context.global,
        localizeNextItem: shouldParseAnimationName && !context.global,
        localAliasMap: context.localAliasMap,
      };
      return localizeDeclNode(node, subContext);
    });

    declaration.value = valueNodes.toString();

    return;
  }

  const isAnimationName = /animation(-name)?$/i.test(declaration.prop);

  if (isAnimationName) {
    return localizeDeclarationValues(true, declaration, context);
  }

  const hasUrl = /url\(/i.test(declaration.value);

  if (hasUrl) {
    return localizeDeclarationValues(false, declaration, context);
  }
}

module.exports = (options = {}) => {
  if (
    options &&
    options.mode &&
    options.mode !== "global" &&
    options.mode !== "local" &&
    options.mode !== "pure"
  ) {
    throw new Error(
      'options.mode must be either "global", "local" or "pure" (default "local")'
    );
  }

  const pureMode = options && options.mode === "pure";
  const globalMode = options && options.mode === "global";

  return {
    postcssPlugin: "postcss-modules-local-by-default",
    prepare() {
      const localAliasMap = new Map();

      return {
        Once(root) {
          const { icssImports } = extractICSS(root, false);

          Object.keys(icssImports).forEach((key) => {
            Object.keys(icssImports[key]).forEach((prop) => {
              localAliasMap.set(prop, icssImports[key][prop]);
            });
          });

          root.walkAtRules((atRule) => {
            if (/keyframes$/i.test(atRule.name)) {
              const globalMatch = /^\s*:global\s*\((.+)\)\s*$/.exec(
                atRule.params
              );
              const localMatch = /^\s*:local\s*\((.+)\)\s*$/.exec(
                atRule.params
              );

              let globalKeyframes = globalMode;

              if (globalMatch) {
                if (pureMode) {
                  throw atRule.error(
                    "@keyframes :global(...) is not allowed in pure mode"
                  );
                }
                atRule.params = globalMatch[1];
                globalKeyframes = true;
              } else if (localMatch) {
                atRule.params = localMatch[0];
                globalKeyframes = false;
              } else if (!globalMode) {
                if (atRule.params && !localAliasMap.has(atRule.params)) {
                  atRule.params = ":local(" + atRule.params + ")";
                }
              }

              atRule.walkDecls((declaration) => {
                localizeDeclaration(declaration, {
                  localAliasMap,
                  options: options,
                  global: globalKeyframes,
                });
              });
            } else if (atRule.nodes) {
              atRule.nodes.forEach((declaration) => {
                if (declaration.type === "decl") {
                  localizeDeclaration(declaration, {
                    localAliasMap,
                    options: options,
                    global: globalMode,
                  });
                }
              });
            }
          });

          root.walkRules((rule) => {
            if (
              rule.parent &&
              rule.parent.type === "atrule" &&
              /keyframes$/i.test(rule.parent.name)
            ) {
              // ignore keyframe rules
              return;
            }

            const context = localizeNode(rule, options.mode, localAliasMap);

            context.options = options;
            context.localAliasMap = localAliasMap;

            if (pureMode && context.hasPureGlobals) {
              throw rule.error(
                'Selector "' +
                  rule.selector +
                  '" is not pure ' +
                  "(pure selectors must contain at least one local class or id)"
              );
            }

            rule.selector = context.selector;

            // Less-syntax mixins parse as rules with no nodes
            if (rule.nodes) {
              rule.nodes.forEach((declaration) =>
                localizeDeclaration(declaration, context)
              );
            }
          });
        },
      };
    },
  };
};
module.exports.postcss = true;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       import {RawSourceMap} from 'source-map-js';

import {Options, StringOptions} from './options';

/**
 * The result of compiling Sass to CSS. Returned by [[compile]],
 * [[compileAsync]], [[compileString]], and [[compileStringAsync]].
 *
 * @category Compile
 */
export interface CompileResult {
  /**
   * The generated CSS.
   *
   * Note that this *never* includes a `sourceMapUrl` commentâit's up to the
   * caller to determine where to save the source map and how to link to it from
   * the stylesheet.
   */
  css: string;

  /**
   * The canonical URLs of all the stylesheets that were loaded during the
   * Sass compilation. The order of these URLs is not guaranteed.
   */
  loadedUrls: URL[];

  /**
   * The object representation of the source map that maps locations in the
   * generated CSS back to locations in the Sass source code.
   *
   * This typically uses absolute `file:` URLs to refer to Sass files, although
   * this can be controlled by having a custom [[Importer]] return
   * [[ImporterResult.sourceMapUrl]].
   *
   * This is set if and only if [[Options.sourceMap]] is `true`.
   */
  sourceMap?: RawSourceMap;
}

/**
 * Synchronously compiles the Sass file at `path` to CSS. If it succeeds it
 * returns a [[CompileResult]], and if it fails it throws an [[Exception]].
 *
 * This only allows synchronous [[Importer]]s and [[CustomFunction]]s.
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = sass.compile("style.scss");
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compile(path: string, options?: Options<'sync'>): CompileResult;

/**
 * Asynchronously compiles the Sass file at `path` to CSS. Returns a promise
 * that resolves with a [[CompileResult]] if it succeeds and rejects with an
 * [[Exception]] if it fails.
 *
 * This only allows synchronous or asynchronous [[Importer]]s and
 * [[CustomFunction]]s.
 *
 * **Heads up!** When using Dart Sass, **[[compile]] is almost twice as fast as
 * [[compileAsync]]**, due to the overhead of making the entire evaluation
 * process asynchronous.
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = await sass.compileAsync("style.scss");
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compileAsync(
  path: string,
  options?: Options<'async'>
): Promise<CompileResult>;

/**
 * Synchronously compiles a stylesheet whose contents is `source` to CSS. If it
 * succeeds it returns a [[CompileResult]], and if it fails it throws an
 * [[Exception]].
 *
 * This only allows synchronous [[Importer]]s and [[CustomFunction]]s.
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = sass.compileString(`
 * h1 {
 *   font-size: 40px;
 *   code {
 *     font-face: Roboto Mono;
 *   }
 * }`);
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compileString(
  source: string,
  options?: StringOptions<'sync'>
): CompileResult;

/**
 * Asynchronously compiles a stylesheet whose contents is `source` to CSS.
 * Returns a promise that resolves with a [[CompileResult]] if it succeeds and
 * rejects with an [[Exception]] if it fails.
 *
 * This only allows synchronous or asynchronous [[Importer]]s and
 * [[CustomFunction]]s.
 *
 * **Heads up!** When using Dart Sass, **[[compile]] is almost twice as fast as
 * [[compileAsync]]**, due to the overhead of making the entire evaluation
 * process asynchronous.
 *
 * @example
 *
 * ```js
 * const sass = require('sass');
 *
 * const result = await sass.compileStringAsync(`
 * h1 {
 *   font-size: 40px;
 *   code {
 *     font-face: Roboto Mono;
 *   }
 * }`);
 * console.log(result.css);
 * ```
 *
 * @category Compile
 * @compatibility dart: "1.45.0", node: false
 */
export function compileStringAsync(
  source: string,
  options?: StringOptions<'async'>
): Promise<CompileResult>;
                                                                  PNG

   IHDR         óÿa   gAMA  ŻÈ7é   tEXtSoftware Adobe ImageReadyqÉe<  PIDAT8ËoHqÇôï8	-·ĄŁ7FDhB€ÈJ0 ȚeŃ\zFQŻ"ŰÂV
œ°^Á ÂLbcąs ćÎMçĘîvw»»íŸĘ]íOmîĆïù~îîčçŃĐ©(IĄQÁöj*òč"Ac:Š$IÊf2C9ÇăyT,)ŰÔp*ËČyÉ$HD,Ó$AÀëőæ%čđU đ<AŽ»
Ă0 (
ńx\pő!>ï·$'ŽȚ =kneTßM,nÇĐëÉOÒzą
ăÚDôÀ\dČ	ÒÒV»»±\oÄ|œgÜŁxÖȚ$îœĆ°SęĄ6YT?¶@țŸ	€s7êv"n©FÄZcŚühèa$đDą èęxîgÏű%șĘĘzEL@țRȘËÂČDÍ6,ï3ęüaî{OŻŠé gÌčzŸÿßìxxKÒ`/a20êAÔUAxźGfĐ5æ@Ëè.­y}űłóț4NĘA	c„V0mïÛ
Ì+mú¶/{ĐđÊĄÚ<üŐÄ»!WÇ >Ű0T șœÿ	äf`J)ÖáćŚ.Đ]*Pă??	òà^°~żV ńçZ!ÏZ03Ó	^`!ąF 7HÿąLgYÖÈkíAČyÁÉ~eúXő`=a„Ń¶·H`V%ëXçêêż©łČy    IENDźB`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  INDX( 	                 (   š   è      	                       l0    p \     g0    _Ę^XkxŰÖÒ:ïaxŰTí^XkxŰÖÒ:ïaxŰ       \               s t a b l e . m i n . j s                   _Ę^XkxŰÖÒ:ïaxŰTí^XkxŰÖÒ:ïaxŰ       \               s t a b l e . m i n . j s                   _Ę^XkxŰÖÒ:ïaxŰTí^XkxŰÖÒ:ïaxŰ       \               s t a b l e . m i n . j s                   g0    _Ę^XkxŰÖÒ:ïaxŰTí^XkxŰÖÒ:ïaxŰ       \               s t a b l e . m i n . j s                 	 _Ę^XkxŰÖÒ:ïaxŰTí^XkxŰÖÒ:ïaxŰ       \               s t a b l e . m i n . j s                                                                                                                                                                                                                                                                                                                                                                                                                                         	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	 'use strict';

exports.type = 'visitor';
exports.name = 'removeUnusedNS';
exports.active = true;
exports.description = 'removes unused namespaces declaration';

/**
 * Remove unused namespaces declaration from svg element
 * which are not used in elements or attributes
 *
 * @author Kir Belevich
 *
 * @type {import('../lib/types').Plugin<void>}
 */
exports.fn = () => {
  /**
   * @type {Set<string>}
   */
  const unusedNamespaces = new Set();
  return {
    element: {
      enter: (node, parentNode) => {
        // collect all namespaces from svg element
        // (such as xmlns:xlink="http://www.w3.org/1999/xlink")
        if (node.name === 'svg' && parentNode.type === 'root') {
          for (const name of Object.keys(node.attributes)) {
            if (name.startsWith('xmlns:')) {
              const local = name.slice('xmlns:'.length);
              unusedNamespaces.add(local);
            }
          }
        }
        if (unusedNamespaces.size !== 0) {
          // preserve namespace used in nested elements names
          if (node.name.includes(':')) {
            const [ns] = node.name.split(':');
            if (unusedNamespaces.has(ns)) {
              unusedNamespaces.delete(ns);
            }
          }
          // preserve namespace used in nested elements attributes
          for (const name of Object.keys(node.attributes)) {
            if (name.includes(':')) {
              const [ns] = name.split(':');
              unusedNamespaces.delete(ns);
            }
          }
        }
      },
      exit: (node, parentNode) => {
        // remove unused namespace attributes from svg element
        if (node.name === 'svg' && parentNode.type === 'root') {
          for (const name of unusedNamespaces) {
            delete node.attributes[`xmlns:${name}`];
          }
        }
      },
    },
  };
};
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Copyright Mathias Bynens <https://mathiasbynens.be/>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           /*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*globals __resourceQuery */
if (module.hot) {
	var log = require("./log");
	var checkForUpdate = function checkForUpdate(fromUpdate) {
		module.hot
			.check()
			.then(function (updatedModules) {
				if (!updatedModules) {
					if (fromUpdate) log("info", "[HMR] Update applied.");
					else log("warning", "[HMR] Cannot find update.");
					return;
				}

				return module.hot
					.apply({
						ignoreUnaccepted: true,
						onUnaccepted: function (data) {
							log(
								"warning",
								"Ignored an update to unaccepted module " +
									data.chain.join(" -> ")
							);
						}
					})
					.then(function (renewedModules) {
						require("./log-apply-result")(updatedModules, renewedModules);

						checkForUpdate(true);
						return null;
					});
			})
			.catch(function (err) {
				var status = module.hot.status();
				if (["abort", "fail"].indexOf(status) >= 0) {
					log("warning", "[HMR] Cannot apply update.");
					log("warning", "[HMR] " + log.formatError(err));
					log("warning", "[HMR] You need to restart the application!");
				} else {
					log("warning", "[HMR] Update failed: " + (err.stack || err.message));
				}
			});
	};

	process.on(__resourceQuery.slice(1) || "SIGUSR2", function () {
		if (module.hot.status() !== "idle") {
			log(
				"warning",
				"[HMR] Got signal but currently in " + module.hot.status() + " state."
			);
			log("warning", "[HMR] Need to be in idle state to start hot update.");
			return;
		}

		checkForUpdate();
	});
} else {
	throw new Error("[HMR] Hot Module Replacement is disabled.");
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             /*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Naoyuki Kanezawa @nkzawa
*/

"use strict";

const EntryOptionPlugin = require("./EntryOptionPlugin");
const EntryPlugin = require("./EntryPlugin");
const EntryDependency = require("./dependencies/EntryDependency");

/** @typedef {import("../declarations/WebpackOptions").EntryDynamicNormalized} EntryDynamic */
/** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */
/** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStatic */
/** @typedef {import("./Compiler")} Compiler */

class DynamicEntryPlugin {
	/**
	 * @param {string} context the context path
	 * @param {EntryDynamic} entry the entry value
	 */
	constructor(context, entry) {
		this.context = context;
		this.entry = entry;
	}

	/**
	 * Apply the plugin
	 * @param {Compiler} compiler the compiler instance
	 * @returns {void}
	 */
	apply(compiler) {
		compiler.hooks.compilation.tap(
			"DynamicEntryPlugin",
			(compilation, { normalModuleFactory }) => {
				compilation.dependencyFactories.set(
					EntryDependency,
					normalModuleFactory
				);
			}
		);

		compiler.hooks.make.tapPromise(
			"DynamicEntryPlugin",
			(compilation, callback) =>
				Promise.resolve(this.entry())
					.then(entry => {
						const promises = [];
						for (const name of Object.keys(entry)) {
							const desc = entry[name];
							const options = EntryOptionPlugin.entryDescriptionToOptions(
								compiler,
								name,
								desc
							);
							for (const entry of desc.import) {
								promises.push(
									new Promise((resolve, reject) => {
										compilation.addEntry(
											this.context,
											EntryPlugin.createDependency(entry, options),
											options,
											err => {
												if (err) return reject(err);
												resolve();
											}
										);
									})
								);
							}
						}
						return Promise.all(promises);
					})
					.then(x => {})
		);
	}
}

module.exports = DynamicEntryPlugin;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             /*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/

"use strict";

const { RawSource } = require("webpack-sources");
const OriginalSource = require("webpack-sources").OriginalSource;
const Module = require("./Module");

/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
/** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
/** @typedef {import("./RequestShortener")} RequestShortener */
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
/** @typedef {import("./WebpackError")} WebpackError */
/** @typedef {import("./util/Hash")} Hash */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */

const TYPES = new Set(["runtime"]);

class RuntimeModule extends Module {
	/**
	 * @param {string} name a readable name
	 * @param {number=} stage an optional stage
	 */
	constructor(name, stage = 0) {
		super("runtime");
		this.name = name;
		this.stage = stage;
		this.buildMeta = {};
		this.buildInfo = {};
		/** @type {Compilation} */
		this.compilation = undefined;
		/** @type {Chunk} */
		this.chunk = undefined;
		/** @type {ChunkGraph} */
		this.chunkGraph = undefined;
		this.fullHash = false;
		this.dependentHash = false;
		/** @type {string} */
		this._cachedGeneratedCode = undefined;
	}

	/**
	 * @param {Compilation} compilation the compilation
	 * @param {Chunk} chunk the chunk
	 * @param {ChunkGraph} chunkGraph the chunk graph
	 * @returns {void}
	 */
	attach(compilation, chunk, chunkGraph = compilation.chunkGraph) {
		this.compilation = compilation;
		this.chunk = chunk;
		this.chunkGraph = chunkGraph;
	}

	/**
	 * @returns {string} a unique identifier of the module
	 */
	identifier() {
		return `webpack/runtime/${this.name}`;
	}

	/**
	 * @param {RequestShortener} requestShortener the request shortener
	 * @returns {string} a user readable identifier of the module
	 */
	readableIdentifier(requestShortener) {
		return `webpack/runtime/${this.name}`;
	}

	/**
	 * @param {NeedBuildContext} context context info
	 * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
	 * @returns {void}
	 */
	needBuild(context, callback) {
		return callback(null, false);
	}

	/**
	 * @param {WebpackOptions} options webpack options
	 * @param {Compilation} compilation the compilation
	 * @param {ResolverWithOptions} resolver the resolver
	 * @param {InputFileSystem} fs the file system
	 * @param {function(WebpackError=): void} callback callback function
	 * @returns {void}
	 */
	build(options, compilation, resolver, fs, callback) {
		// do nothing
		// should not be called as runtime modules are added later to the compilation
		callback();
	}

	/**
	 * @param {Hash} hash the hash used to track dependencies
	 * @param {UpdateHashContext} context context
	 * @returns {void}
	 */
	updateHash(hash, context) {
		hash.update(this.name);
		hash.update(`${this.stage}`);
		try {
			if (this.fullHash || this.dependentHash) {
				// Do not use getGeneratedCode here, because i. e. compilation hash might be not
				// ready at this point. We will cache it later instead.
				hash.update(this.generate());
			} else {
				hash.update(this.getGeneratedCode());
			}
		} catch (err) {
			hash.update(err.message);
		}
		super.updateHash(hash, context);
	}

	/**
	 * @returns {Set<string>} types available (do not mutate)
	 */
	getSourceTypes() {
		return TYPES;
	}

	/**
	 * @param {CodeGenerationContext} context context for code generation
	 * @returns {CodeGenerationResult} result
	 */
	codeGeneration(context) {
		const sources = new Map();
		const generatedCode = this.getGeneratedCode();
		if (generatedCode) {
			sources.set(
				"runtime",
				this.useSourceMap || this.useSimpleSourceMap
					? new OriginalSource(generatedCode, this.identifier())
					: new RawSource(generatedCode)
			);
		}
		return {
			sources,
			runtimeRequirements: null
		};
	}

	/**
	 * @param {string=} type the source type for which the size should be estimated
	 * @returns {number} the estimated size of the module (must be non-zero)
	 */
	size(type) {
		try {
			const source = this.getGeneratedCode();
			return source ? source.length : 0;
		} catch (e) {
			return 0;
		}
	}

	/* istanbul ignore next */
	/**
	 * @abstract
	 * @returns {string} runtime code
	 */
	generate() {
		const AbstractMethodError = require("./AbstractMethodError");
		throw new AbstractMethodError();
	}

	/**
	 * @returns {string} runtime code
	 */
	getGeneratedCode() {
		if (this._cachedGeneratedCode) {
			return this._cachedGeneratedCode;
		}
		return (this._cachedGeneratedCode = this.generate());
	}

	/**
	 * @returns {boolean} true, if the runtime module should get it's own scope
	 */
	shouldIsolate() {
		return true;
	}
}

/**
 * Runtime modules without any dependencies to other runtime modules
 */
RuntimeModule.STAGE_NORMAL = 0;

/**
 * Runtime modules with simple dependencies on other runtime modules
 */
RuntimeModule.STAGE_BASIC = 5;

/**
 * Runtime modules which attach to handlers of other runtime modules
 */
RuntimeModule.STAGE_ATTACH = 10;

/**
 * Runtime modules which trigger actions on bootstrap
 */
RuntimeModule.STAGE_TRIGGER = 20;

module.exports = RuntimeModule;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                /*
 * This file was automatically generated.
 * DO NOT MODIFY BY HAND.
 * Run `yarn special-lint-fix` to update
 */
const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=n,module.exports.default=n;const t=new RegExp("^https?://","u");function e(n,{instancePath:o="",parentData:s,parentDataProperty:a,rootData:l=n}={}){let i=null,p=0;if(0===p){if(!n||"object"!=typeof n||Array.isArray(n))return e.errors=[{params:{type:"object"}}],!1;{let o;if(void 0===n.allowedUris&&(o="allowedUris"))return e.errors=[{params:{missingProperty:o}}],!1;{const o=p;for(const r in n)if("allowedUris"!==r&&"cacheLocation"!==r&&"frozen"!==r&&"lockfileLocation"!==r&&"proxy"!==r&&"upgrade"!==r)return e.errors=[{params:{additionalProperty:r}}],!1;if(o===p){if(void 0!==n.allowedUris){let r=n.allowedUris;const o=p;if(p==p){if(!Array.isArray(r))return e.errors=[{params:{type:"array"}}],!1;{const n=r.length;for(let o=0;o<n;o++){let n=r[o];const s=p,a=p;let l=!1;const c=p;if(!(n instanceof RegExp)){const r={params:{}};null===i?i=[r]:i.push(r),p++}var f=c===p;if(l=l||f,!l){const r=p;if(p===r)if("string"==typeof n){if(!t.test(n)){const r={params:{pattern:"^https?://"}};null===i?i=[r]:i.push(r),p++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}if(f=r===p,l=l||f,!l){const r=p;if(!(n instanceof Function)){const r={params:{}};null===i?i=[r]:i.push(r),p++}f=r===p,l=l||f}}if(!l){const r={params:{}};return null===i?i=[r]:i.push(r),p++,e.errors=i,!1}if(p=a,null!==i&&(a?i.length=a:i=null),s!==p)break}}}var c=o===p}else c=!0;if(c){if(void 0!==n.cacheLocation){let t=n.cacheLocation;const o=p,s=p;let a=!1;const l=p;if(!1!==t){const r={params:{}};null===i?i=[r]:i.push(r),p++}var u=l===p;if(a=a||u,!a){const e=p;if(p===e)if("string"==typeof t){if(t.includes("!")||!0!==r.test(t)){const r={params:{}};null===i?i=[r]:i.push(r),p++}}else{const r={params:{type:"string"}};null===i?i=[r]:i.push(r),p++}u=e===p,a=a||u}if(!a){const r={params:{}};return null===i?i=[r]:i.push(r),p++,e.errors=i,!1}p=s,null!==i&&(s?i.length=s:i=null),c=o===p}else c=!0;if(c){if(void 0!==n.frozen){const r=p;if("boolean"!=typeof n.frozen)return e.errors=[{params:{type:"boolean"}}],!1;c=r===p}else c=!0;if(c){if(void 0!==n.lockfileLocation){let t=n.lockfileLocation;const o=p;if(p===o){if("string"!=typeof t)return e.errors=[{params:{type:"string"}}],!1;if(t.includes("!")||!0!==r.test(t))return e.errors=[{params:{}}],!1}c=o===p}else c=!0;if(c){if(void 0!==n.proxy){const r=p;if("string"!=typeof n.proxy)return e.errors=[{params:{type:"string"}}],!1;c=r===p}else c=!0;if(c)if(void 0!==n.upgrade){const r=p;if("boolean"!=typeof n.upgrade)return e.errors=[{params:{type:"boolean"}}],!1;c=r===p}else c=!0}}}}}}}}return e.errors=i,0===p}function n(r,{instancePath:t="",parentData:o,parentDataProperty:s,rootData:a=r}={}){let l=null,i=0;const p=i;let f=!1,c=null;const u=i;if(e(r,{instancePath:t,parentData:o,parentDataProperty:s,rootData:a})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),u===i&&(f=!0,c=0),!f){const r={params:{passingSchemas:c}};return null===l?l=[r]:l.push(r),i++,n.errors=l,!1}return i=p,null!==l&&(p?l.length=p:l=null),n.errors=l,0===i}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       {"version":3,"file":"discriminator.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/discriminator.ts"],"names":[],"mappings":";;AAEA,mDAA+D;AAC/D,yCAAwC;AACxC,yCAA8C;AAC9C,mCAAwE;AACxE,kDAAgE;AAOhE,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;QACf,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,GAAG,CAAA;QAC5B,OAAO,MAAM,CAAC,UAAU;YACtB,CAAC,CAAC,MAAM,CAAC,UAAU,KAAK,kBAAU,CAAC,GAAG;gBACpC,CAAC,CAAC,QAAQ,MAAM,kBAAkB;gBAClC,CAAC,CAAC,iBAAiB,MAAM,sBAAsB;YACjD,CAAC,CAAC,IAAA,wBAAgB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IACrC,CAAC;IACD,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;QACd,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,GAAG,CAAA;QAC5B,OAAO,MAAM,CAAC,UAAU;YACtB,CAAC,CAAC,IAAA,WAAC,EAAA,WAAW,MAAM,CAAC,UAAU,UAAU,MAAM,eAAe,MAAM,CAAC,GAAG,GAAG;YAC3E,CAAC,CAAC,IAAA,uBAAe,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IACpC,CAAC;CACF,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,eAAe;IACxB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,CAAC,SAAS,CAAC;IACvB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAA;QAClB,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAC,GAAG,GAAG,CAAA;QAC7C,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,IAAA,8BAAmB,EAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAEpD,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;QACZ,qBAAqB,EAAE,CAAA;QACvB,GAAG,CAAC,MAAM,CAAC,IAAA,aAAG,EAAC,KAAK,CAAC,CAAC,CAAA;QACtB,GAAG,CAAC,KAAK,EAAE,CAAA;QACX,GAAG,CAAC,KAAK,EAAE,CAAA;QACX,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;QAEb,SAAS,qBAAqB;YAC5B,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,IAAA,WAAC,EAAA,GAAG,IAAI,GAAG,IAAA,qBAAW,EAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC9D,GAAG,CAAC,EAAE,CAAC,IAAA,WAAC,EAAA,GAAG,GAAG,gBAAgB,CAAC,CAAA;YAC/B,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,EAAC,UAAU,EAAE,kBAAU,CAAC,GAAG,EAAE,GAAG,EAAC,CAAC,CAAA;YACnD,GAAG,CAAC,MAAM,CAAC,IAAA,WAAC,EAAA,UAAU,GAAG,cAAc,CAAC,CAAA;YACxC,eAAe,CAAC,GAAG,CAAC,CAAA;YACpB,GAAG,CAAC,IAAI,EAAE,CAAA;YACV,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,EAAC,UAAU,EAAE,kBAAU,CAAC,GAAG,EAAE,GAAG,EAAC,EAAE,EAAC,YAAY,EAAE,MAAM,EAAC,CAAC,CAAA;YAC3E,GAAG,CAAC,KAAK,EAAE,CAAA;QACb,CAAC;QAED,SAAS,eAAe,CAAC,GAAS;YAChC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;YACb,KAAK,MAAM,QAAQ,IAAI,YAAY,CAAC,OAAO,EAAE;gBAC3C,GAAG,CAAC,MAAM,CAAC,IAAA,WAAC,EAAA,GAAG,GAAG,QAAQ,QAAQ,EAAE,CAAC,CAAA;gBACrC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAA;aAC5C;YACD,GAAG,CAAC,IAAI,EAAE,CAAA;YACV,GAAG,CAAC,KAAK,CACP,KAAK,EACL,EAAC,UAAU,EAAE,kBAAU,CAAC,OAAO,EAAE,GAAG,EAAC,EACrC,EAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAC,CAClE,CAAA;YACD,GAAG,CAAC,KAAK,EAAE,CAAA;QACb,CAAC;QAED,SAAS,cAAc,CAAC,UAAkB;YACxC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAChC,GAAG,CAAC,SAAS,CACX;gBACE,OAAO,EAAE,SAAS;gBAClB,UAAU;gBACV,gBAAgB,EAAE,MAAM;aACzB,EACD,MAAM,CACP,CAAA;YACD,OAAO,MAAM,CAAA;QACf,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             import type {CodeKeywordDefinition, KeywordCxt} from "ajv"
import {_, or, and, getProperty, Code} from "ajv/dist/compile/codegen"

export default function getDef(): CodeKeywordDefinition {
  return {
    keyword: "deepRequired",
    type: "object",
    schemaType: "array",
    code(ctx: KeywordCxt) {
      const {schema, data} = ctx
      const props = (schema as string[]).map((jp: string) => _`(${getData(jp)}) === undefined`)
      ctx.fail(or(...props))

      function getData(jsonPointer: string): Code {
        if (jsonPointer === "") throw new Error("empty JSON pointer not allowed")
        const segments = jsonPointer.split("/")
        let x: Code = data
        const xs = segments.map((s, i) =>
          i ? (x = _`${x}${getProperty(unescapeJPSegment(s))}`) : x
        )
        return and(...xs)
      }
    },
    metaSchema: {
      type: "array",
      items: {type: "string", format: "json-pointer"},
    },
  }
}

function unescapeJPSegment(s: string): string {
  return s.replace(/~1/g, "/").replace(/~0/g, "~")
}

module.exports = getDef
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const code_1 = require("../code");
const codegen_1 = require("../../compile/codegen");
const util_1 = require("../../compile/util");
const util_2 = require("../../compile/util");
const def = {
    keyword: "patternProperties",
    type: "object",
    schemaType: "object",
    code(cxt) {
        const { gen, schema, data, parentSchema, it } = cxt;
        const { opts } = it;
        const patterns = (0, code_1.allSchemaProperties)(schema);
        const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
        if (patterns.length === 0 ||
            (alwaysValidPatterns.length === patterns.length &&
                (!it.opts.unevaluated || it.props === true))) {
            return;
        }
        const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;
        const valid = gen.name("valid");
        if (it.props !== true && !(it.props instanceof codegen_1.Name)) {
            it.props = (0, util_2.evaluatedPropsToName)(gen, it.props);
        }
        const { props } = it;
        validatePatternProperties();
        function validatePatternProperties() {
            for (const pat of patterns) {
                if (checkProperties)
                    checkMatchingProperties(pat);
                if (it.allErrors) {
                    validateProperties(pat);
                }
                else {
                    gen.var(valid, true); // TODO var
                    validateProperties(pat);
                    gen.if(valid);
                }
            }
        }
        function checkMatchingProperties(pat) {
            for (const prop in checkProperties) {
                if (new RegExp(pat).test(prop)) {
                    (0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
                }
            }
        }
        function validateProperties(pat) {
            gen.forIn("key", data, (key) => {
                gen.if((0, codegen_1._) `${(0, code_1.usePattern)(cxt, pat)}.test(${key})`, () => {
                    const alwaysValid = alwaysValidPatterns.includes(pat);
                    if (!alwaysValid) {
                        cxt.subschema({
                            keyword: "patternProperties",
                            schemaProp: pat,
                            dataProp: key,
                            dataPropType: util_2.Type.Str,
                        }, valid);
                    }
                    if (it.opts.unevaluated && props !== true) {
                        gen.assign((0, codegen_1._) `${props}[${key}]`, true);
                    }
                    else if (!alwaysValid && !it.allErrors) {
                        // can short-circuit if `unevaluatedProperties` is not supported (opts.next === false)
                        // or if all properties were evaluated (props === true)
                        gen.if((0, codegen_1.not)(valid), () => gen.break());
                    }
                });
            });
        }
    },
};
exports.default = def;
//# sourceMappingURL=patternProperties.js.map                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/definitions/transform.ts"],"names":[],"mappings":";;AACA,sDAAkE;AAkBlE,MAAM,SAAS,GAAwC;IACrD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE;IAC/B,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE;IAC3B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE;IAC9B,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE;IAC7B,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE;IACrB,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE;IACnC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE;IACnC,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAI,CAAC;CACrD,CAAA;AAED,MAAM,MAAM,GAER,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAC,SAAS,EAAC,CAAC,CAAA;AAEvC,SAAS,OAAO;IACd,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,UAAU,EAAE,OAAO;QACnB,MAAM,EAAE,MAAM;QACd,IAAI,CAAC,GAAe;YAClB,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;YACjD,MAAM,EAAC,UAAU,EAAE,kBAAkB,EAAC,GAAG,EAAE,CAAA;YAC3C,MAAM,MAAM,GAAa,MAAM,CAAA;YAC/B,IAAI,CAAC,MAAM,CAAC,MAAM;gBAAE,OAAM;YAC1B,IAAI,GAAqB,CAAA;YACzB,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;gBACjC,MAAM,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAAA;gBAC3C,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,EAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAA,mBAAS,EAAC,MAAM,CAAC,EAAC,CAAC,CAAA;aACpE;YACD,GAAG,CAAC,EAAE,CAAC,IAAA,WAAC,EAAA,UAAU,IAAI,mBAAmB,UAAU,gBAAgB,EAAE,GAAG,EAAE;gBACxE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;gBAC/C,GAAG,CAAC,MAAM,CAAC,IAAA,WAAC,EAAA,GAAG,UAAU,IAAI,kBAAkB,GAAG,EAAE,IAAI,CAAC,CAAA;YAC3D,CAAC,CAAC,CAAA;YAEF,SAAS,aAAa,CAAC,EAAY;gBACjC,IAAI,CAAC,EAAE,CAAC,MAAM;oBAAE,OAAO,IAAI,CAAA;gBAC3B,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAY,CAAA;gBAC5B,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;oBAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,EAAE,CAAC,CAAA;gBAChF,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE;oBAClC,GAAG,EAAE,SAAS,CAAC,CAAkB,CAAC;oBAClC,IAAI,EAAE,IAAA,WAAC,EAAA,+DAA+D,IAAA,qBAAW,EAAC,CAAC,CAAC,EAAE;iBACvF,CAAC,CAAA;gBACF,MAAM,GAAG,GAAG,aAAa,CAAC,EAAE,CAAC,CAAA;gBAC7B,OAAO,GAAG,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,IAAA,WAAC,EAAA,GAAG,IAAI,IAAI,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,IAAA,WAAC,EAAA,GAAG,IAAI,IAAI,GAAG,GAAG,CAAA;YACpF,CAAC;QACH,CAAC;QACD,UAAU,EAAE;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC;SACtD;KACF,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,YAA6B;IACnD,kCAAkC;IAClC,MAAM,GAAG,GAAoB,EAAC,IAAI,EAAE,EAAE,EAAC,CAAA;IAEvC,kDAAkD;IAClD,IAAI,CAAC,YAAY,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAClF,KAAK,MAAM,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE;QACjC,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,SAAQ;QACnC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QACtB,8CAA8C;QAC9C,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAA;SAC9F;QACD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;KAChB;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,WAAW,EAAE,CAAA;AACxB,CAAC;AAED,kBAAe,MAAM,CAAA;AACrB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAA"}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           import { _ as _createForOfIteratorHelper, h as _slicedToArray, a as _typeof, b as _createClass, e as _defineProperty, c as _classCallCheck, d as defaultTagPrefix, n as defaultTags } from './PlainValue-b8036b75.js';
import { d as YAMLMap, g as resolveMap, Y as YAMLSeq, h as resolveSeq, j as resolveString, c as stringifyString, s as strOptions, S as Scalar, n as nullOptions, a as boolOptions, i as intOptions, k as stringifyNumber, N as Node, A as Alias, P as Pair } from './resolveSeq-492ab440.js';
import { b as binary, o as omap, p as pairs, s as set, i as intTime, f as floatTime, t as timestamp, a as warnOptionDeprecation } from './warnings-df54cb69.js';

function createMap(schema, obj, ctx) {
  var map = new YAMLMap(schema);

  if (obj instanceof Map) {
    var _iterator = _createForOfIteratorHelper(obj),
        _step;

    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var _step$value = _slicedToArray(_step.value, 2),
            key = _step$value[0],
            value = _step$value[1];

        map.items.push(schema.createPair(key, value, ctx));
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
  } else if (obj && _typeof(obj) === 'object') {
    for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
      var _key = _Object$keys[_i];
      map.items.push(schema.createPair(_key, obj[_key], ctx));
    }
  }

  if (typeof schema.sortMapEntries === 'function') {
    map.items.sort(schema.sortMapEntries);
  }

  return map;
}

var map = {
  createNode: createMap,
  default: true,
  nodeClass: YAMLMap,
  tag: 'tag:yaml.org,2002:map',
  resolve: resolveMap
};

function createSeq(schema, obj, ctx) {
  var seq = new YAMLSeq(schema);

  if (obj && obj[Symbol.iterator]) {
    var _iterator = _createForOfIteratorHelper(obj),
        _step;

    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var it = _step.value;
        var v = schema.createNode(it, ctx.wrapScalars, null, ctx);
        seq.items.push(v);
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
  }

  return seq;
}

var seq = {
  createNode: createSeq,
  default: true,
  nodeClass: YAMLSeq,
  tag: 'tag:yaml.org,2002:seq',
  resolve: resolveSeq
};

var string = {
  identify: function identify(value) {
    return typeof value === 'string';
  },
  default: true,
  tag: 'tag:yaml.org,2002:str',
  resolve: resolveString,
  stringify: function stringify(item, ctx, onComment, onChompKeep) {
    ctx = Object.assign({
      actualString: true
    }, ctx);
    return stringifyString(item, ctx, onComment, onChompKeep);
  },
  options: strOptions
};

var failsafe = [map, seq, string];

/* global BigInt */

var intIdentify$2 = function intIdentify(value) {
  return typeof value === 'bigint' || Number.isInteger(value);
};

var intResolve$1 = function intResolve(src, part, radix) {
  return intOptions.asBigInt ? BigInt(src) : parseInt(part, radix);
};

function intStringify$1(node, radix, prefix) {
  var value = node.value;
  if (intIdentify$2(value) && value >= 0) return prefix + value.toString(radix);
  return stringifyNumber(node);
}

var nullObj = {
  identify: function identify(value) {
    return value == null;
  },
  createNode: function createNode(schema, value, ctx) {
    return ctx.wrapScalars ? new Scalar(null) : null;
  },
  default: true,
  tag: 'tag:yaml.org,2002:null',
  test: /^(?:~|[Nn]ull|NULL)?$/,
  resolve: function resolve() {
    return null;
  },
  options: nullOptions,
  stringify: function stringify() {
    return nullOptions.nullStr;
  }
};
var boolObj = {
  identify: function identify(value) {
    return typeof value === 'boolean';
  },
  default: true,
  tag: 'tag:yaml.org,2002:bool',
  test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
  resolve: function resolve(str) {
    return str[0] === 't' || str[0] === 'T';
  },
  options: boolOptions,
  stringify: function stringify(_ref) {
    var value = _ref.value;
    return value ? boolOptions.trueStr : boolOptions.falseStr;
  }
};
var octObj = {
  identify: function identify(value) {
    return intIdentify$2(value) && value >= 0;
  },
  default: true,
  tag: 'tag:yaml.org,2002:int',
  format: 'OCT',
  test: /^0o([0-7]+)$/,
  resolve: function resolve(str, oct) {
    return intResolve$1(str, oct, 8);
  },
  options: intOptions,
  stringify: function stringify(node) {
    return intStringify$1(node, 8, '0o');
  }
};
var intObj = {
  identify: intIdentify$2,
  default: true,
  tag: 'tag:yaml.org,2002:int',
  test: /^[-+]?[0-9]+$/,
  resolve: function resolve(str) {
    return intResolve$1(str, str, 10);
  },
  options: intOptions,
  stringify: stringifyNumber
};
var hexObj = {
  identify: function identify(value) {
    return intIdentify$2(value) && value >= 0;
  },
  default: true,
  tag: 'tag:yaml.org,2002:int',
  format: 'HEX',
  test: /^0x([0-9a-fA-F]+)$/,
  resolve: function resolve(str, hex) {
    return intResolve$1(str, hex, 16);
  },
  options: intOptions,
  stringify: function stringify(node) {
    return intStringify$1(node, 16, '0x');
  }
};
var nanObj = {
  identify: function identify(value) {
    return typeof value === 'number';
  },
  default: true,
  tag: 'tag:yaml.org,2002:float',
  test: /^(?:[-+]?\.inf|(\.nan))$/i,
  resolve: function resolve(str, nan) {
    return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
  },
  stringify: stringifyNumber
};
var expObj = {
  identify: function identify(value) {
    return typeof value === 'number';
  },
  default: true,
  tag: 'tag:yaml.org,2002:float',
  format: 'EXP',
  test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
  resolve: function resolve(str) {
    return parseFloat(str);
  },
  stringify: function stringify(_ref2) {
    var value = _ref2.value;
    return Number(value).toExponential();
  }
};
var floatObj = {
  identify: function identify(value) {
    return typeof value === 'number';
  },
  default: true,
  tag: 'tag:yaml.org,2002:float',
  test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,
  resolve: function resolve(str, frac1, frac2) {
    var frac = frac1 || frac2;
    var node = new Scalar(parseFloat(str));
    if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
    return node;
  },
  stringify: stringifyNumber
};
var core = failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);

/* global BigInt */

var intIdentify$1 = function intIdentify(value) {
  return typeof value === 'bigint' || Number.isInteger(value);
};

var stringifyJSON = function stringifyJSON(_ref) {
  var value = _ref.value;
  return JSON.stringify(value);
};

var json = [map, seq, {
  identify: function identify(value) {
    return typeof value === 'string';
  },
  default: true,
  tag: 'tag:yaml.org,2002:str',
  resolve: resolveString,
  stringify: stringifyJSON
}, {
  identify: function identify(value) {
    return value == null;
  },
  createNode: function createNode(schema, value, ctx) {
    return ctx.wrapScalars ? new Scalar(null) : null;
  },
  default: true,
  tag: 'tag:yaml.org,2002:null',
  test: /^null$/,
  resolve: function resolve() {
    return null;
  },
  stringify: stringifyJSON
}, {
  identify: function identify(value) {
    return typeof value === 'boolean';
  },
  default: true,
  tag: 'tag:yaml.org,2002:bool',
  test: /^true|false$/,
  resolve: function resolve(str) {
    return str === 'true';
  },
  stringify: stringifyJSON
}, {
  identify: intIdentify$1,
  default: true,
  tag: 'tag:yaml.org,2002:int',
  test: /^-?(?:0|[1-9][0-9]*)$/,
  resolve: function resolve(str) {
    return intOptions.asBigInt ? BigInt(str) : parseInt(str, 10);
  },
  stringify: function stringify(_ref2) {
    var value = _ref2.value;
    return intIdentify$1(value) ? value.toString() : JSON.stringify(value);
  }
}, {
  identify: function identify(value) {
    return typeof value === 'number';
  },
  default: true,
  tag: 'tag:yaml.org,2002:float',
  test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
  resolve: function resolve(str) {
    return parseFloat(str);
  },
  stringify: stringifyJSON
}];

json.scalarFallback = function (str) {
  throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str)));
};

/* global BigInt */

var boolStringify = function boolStringify(_ref) {
  var value = _ref.value;
  return value ? boolOptions.trueStr : boolOptions.falseStr;
};

var intIdentify = function intIdentify(value) {
  return typeof value === 'bigint' || Number.isInteger(value);
};

function intResolve(sign, src, radix) {
  var str = src.replace(/_/g, '');

  if (intOptions.asBigInt) {
    switch (radix) {
      case 2:
        str = "0b".concat(str);
        break;

      case 8:
        str = "0o".concat(str);
        break;

      case 16:
        str = "0x".concat(str);
        break;
    }

    var _n = BigInt(str);

    return sign === '-' ? BigInt(-1) * _n : _n;
  }

  var n = parseInt(str, radix);
  return sign === '-' ? -1 * n : n;
}

function intStringify(node, radix, prefix) {
  var value = node.value;

  if (intIdentify(value)) {
    var str = value.toString(radix);
    return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
  }

  return stringifyNumber(node);
}

var yaml11 = failsafe.concat([{
  identify: function identify(value) {
    return value == null;
  },
  createNode: function createNode(schema, value, ctx) {
    return ctx.wrapScalars ? new Scalar(null) : null;
  },
  default: true,
  tag: 'tag:yaml.org,2002:null',
  test: /^(?:~|[Nn]ull|NULL)?$/,
  resolve: function resolve() {
    return null;
  },
  options: nullOptions,
  stringify: function stringify() {
    return nullOptions.nullStr;
  }
}, {
  identify: function identify(value) {
    return typeof value === 'boolean';
  },
  default: true,
  tag: 'tag:yaml.org,2002:bool',
  test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
  resolve: function resolve() {
    return true;
  },
  options: boolOptions,
  stringify: boolStringify
}, {
  identify: function identify(value) {
    return typeof value === 'boolean';
  },
  default: true,
  tag: 'tag:yaml.org,2002:bool',
  test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
  resolve: function resolve() {
    return false;
  },
  options: boolOptions,
  stringify: boolStringify
}, {
  identify: intIdentify,
  default: true,
  tag: 'tag:yaml.org,2002:int',
  format: 'BIN',
  test: /^([-+]?)0b([0-1_]+)$/,
  resolve: function resolve(str, sign, bin) {
    return intResolve(sign, bin, 2);
  },
  stringify: function stringify(node) {
    return intStringify(node, 2, '0b');
  }
}, {
  identify: intIdentify,
  default: true,
  tag: 'tag:yaml.org,2002:int',
  format: 'OCT',
  test: /^([-+]?)0([0-7_]+)$/,
  resolve: function resolve(str, sign, oct) {
    return intResolve(sign, oct, 8);
  },
  stringify: function stringify(node) {
    return intStringify(node, 8, '0');
  }
}, {
  identify: intIdentify,
  default: true,
  tag: 'tag:yaml.org,2002:int',
  test: /^([-+]?)([0-9][0-9_]*)$/,
  resolve: function resolve(str, sign, abs) {
    return intResolve(sign, abs, 10);
  },
  stringify: stringifyNumber
}, {
  identify: intIdentify,
  default: true,
  tag: 'tag:yaml.org,2002:int',
  format: 'HEX',
  test: /^([-+]?)0x([0-9a-fA-F_]+)$/,
  resolve: function resolve(str, sign, hex) {
    return intResolve(sign, hex, 16);
  },
  stringify: function stringify(node) {
    return intStringify(node, 16, '0x');
  }
}, {
  identify: function identify(value) {
    return typeof value === 'number';
  },
  default: true,
  tag: 'tag:yaml.org,2002:float',
  test: /^(?:[-+]?\.inf|(\.nan))$/i,
  resolve: function resolve(str, nan) {
    return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
  },
  stringify: stringifyNumber
}, {
  identify: function identify(value) {
    return typeof value === 'number';
  },
  default: true,
  tag: 'tag:yaml.org,2002:float',
  format: 'EXP',
  test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
  resolve: function resolve(str) {
    return parseFloat(str.replace(/_/g, ''));
  },
  stringify: function stringify(_ref2) {
    var value = _ref2.value;
    return Number(value).toExponential();
  }
}, {
  identify: function identify(value) {
    return typeof value === 'number';
  },
  default: true,
  tag: 'tag:yaml.org,2002:float',
  test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
  resolve: function resolve(str, frac) {
    var node = new Scalar(parseFloat(str.replace(/_/g, '')));

    if (frac) {
      var f = frac.replace(/_/g, '');
      if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
    }

    return node;
  },
  stringify: stringifyNumber
}], binary, omap, pairs, set, intTime, floatTime, timestamp);

var schemas = {
  core: core,
  failsafe: failsafe,
  json: json,
  yaml11: yaml11
};
var tags = {
  binary: binary,
  bool: boolObj,
  float: floatObj,
  floatExp: expObj,
  floatNaN: nanObj,
  floatTime: floatTime,
  int: intObj,
  intHex: hexObj,
  intOct: octObj,
  intTime: intTime,
  map: map,
  null: nullObj,
  omap: omap,
  pairs: pairs,
  seq: seq,
  set: set,
  timestamp: timestamp
};

function findTagObject(value, tagName, tags) {
  if (tagName) {
    var match = tags.filter(function (t) {
      return t.tag === tagName;
    });
    var tagObj = match.find(function (t) {
      return !t.format;
    }) || match[0];
    if (!tagObj) throw new Error("Tag ".concat(tagName, " not found"));
    return tagObj;
  } // TODO: deprecate/remove class check


  return tags.find(function (t) {
    return (t.identify && t.identify(value) || t.class && value instanceof t.class) && !t.format;
  });
}

function createNode(value, tagName, ctx) {
  if (value instanceof Node) return value;
  var defaultPrefix = ctx.defaultPrefix,
      onTagObj = ctx.onTagObj,
      prevObjects = ctx.prevObjects,
      schema = ctx.schema,
      wrapScalars = ctx.wrapScalars;
  if (tagName && tagName.startsWith('!!')) tagName = defaultPrefix + tagName.slice(2);
  var tagObj = findTagObject(value, tagName, schema.tags);

  if (!tagObj) {
    if (typeof value.toJSON === 'function') value = value.toJSON();
    if (!value || _typeof(value) !== 'object') return wrapScalars ? new Scalar(value) : value;
    tagObj = value instanceof Map ? map : value[Symbol.iterator] ? seq : map;
  }

  if (onTagObj) {
    onTagObj(tagObj);
    delete ctx.onTagObj;
  } // Detect duplicate references to the same object & use Alias nodes for all
  // after first. The `obj` wrapper allows for circular references to resolve.


  var obj = {
    value: undefined,
    node: undefined
  };

  if (value && _typeof(value) === 'object' && prevObjects) {
    var prev = prevObjects.get(value);

    if (prev) {
      var alias = new Alias(prev); // leaves source dirty; must be cleaned by caller

      ctx.aliasNodes.push(alias); // defined along with prevObjects

      return alias;
    }

    obj.value = value;
    prevObjects.set(value, obj);
  }

  obj.node = tagObj.createNode ? tagObj.createNode(ctx.schema, value, ctx) : wrapScalars ? new Scalar(value) : value;
  if (tagName && obj.node instanceof Node) obj.node.tag = tagName;
  return obj.node;
}

function getSchemaTags(schemas, knownTags, customTags, schemaId) {
  var tags = schemas[schemaId.replace(/\W/g, '')]; // 'yaml-1.1' -> 'yaml11'

  if (!tags) {
    var keys = Object.keys(schemas).map(function (key) {
      return JSON.stringify(key);
    }).join(', ');
    throw new Error("Unknown schema \"".concat(schemaId, "\"; use one of ").concat(keys));
  }

  if (Array.isArray(customTags)) {
    var _iterator = _createForOfIteratorHelper(customTags),
        _step;

    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var tag = _step.value;
        tags = tags.concat(tag);
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
  } else if (typeof customTags === 'function') {
    tags = customTags(tags.slice());
  }

  for (var i = 0; i < tags.length; ++i) {
    var _tag = tags[i];

    if (typeof _tag === 'string') {
      var tagObj = knownTags[_tag];

      if (!tagObj) {
        var _keys = Object.keys(knownTags).map(function (key) {
          return JSON.stringify(key);
        }).join(', ');

        throw new Error("Unknown custom tag \"".concat(_tag, "\"; use one of ").concat(_keys));
      }

      tags[i] = tagObj;
    }
  }

  return tags;
}

var sortMapEntriesByKey = function sortMapEntriesByKey(a, b) {
  return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
};

var Schema = /*#__PURE__*/function () {
  // TODO: remove in v2
  // TODO: remove in v2
  function Schema(_ref) {
    var customTags = _ref.customTags,
        merge = _ref.merge,
        schema = _ref.schema,
        sortMapEntries = _ref.sortMapEntries,
        deprecatedCustomTags = _ref.tags;

    _classCallCheck(this, Schema);

    this.merge = !!merge;
    this.name = schema;
    this.sortMapEntries = sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null;
    if (!customTags && deprecatedCustomTags) warnOptionDeprecation('tags', 'customTags');
    this.tags = getSchemaTags(schemas, tags, customTags || deprecatedCustomTags, schema);
  }

  _createClass(Schema, [{
    key: "createNode",
    value: function createNode$1(value, wrapScalars, tagName, ctx) {
      var baseCtx = {
        defaultPrefix: Schema.defaultPrefix,
        schema: this,
        wrapScalars: wrapScalars
      };
      var createCtx = ctx ? Object.assign(ctx, baseCtx) : baseCtx;
      return createNode(value, tagName, createCtx);
    }
  }, {
    key: "createPair",
    value: function createPair(key, value, ctx) {
      if (!ctx) ctx = {
        wrapScalars: true
      };
      var k = this.createNode(key, ctx.wrapScalars, null, ctx);
      var v = this.createNode(value, ctx.wrapScalars, null, ctx);
      return new Pair(k, v);
    }
  }]);

  return Schema;
}();

_defineProperty(Schema, "defaultPrefix", defaultTagPrefix);

_defineProperty(Schema, "defaultTags", defaultTags);

export { Schema as S };
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      <?php

namespace Egulias\EmailValidator\Validation;

use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Exception\InvalidEmail;
use Egulias\EmailValidator\Warning\Warning;

interface EmailValidation
{
    /**
     * Returns true if the given email is valid.
     *
     * @param string     $email      The email you want to validate.
     * @param EmailLexer $emailLexer The email lexer.
     *
     * @return bool
     */
    public function isValid($email, EmailLexer $emailLexer);

    /**
     * Returns the validation error.
     *
     * @return InvalidEmail|null
     */
    public function getError();

    /**
     * Returns the validation warnings.
     *
     * @return Warning[]
     */
    public function getWarnings();
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 <?php

namespace Faker\ORM\Propel;

/**
 * Service class for populating a database using the Propel ORM.
 * A Populator can populate several tables using ActiveRecord classes.
 */
class Populator
{
    protected $generator;
    protected $entities = [];
    protected $quantities = [];

    public function __construct(\Faker\Generator $generator)
    {
        $this->generator = $generator;
    }

    /**
     * Add an order for the generation of $number records for $entity.
     *
     * @param mixed $entity A Propel ActiveRecord classname, or a \Faker\ORM\Propel\EntityPopulator instance
     * @param int   $number The number of entities to populate
     */
    public function addEntity($entity, $number, $customColumnFormatters = [], $customModifiers = [])
    {
        if (!$entity instanceof \Faker\ORM\Propel\EntityPopulator) {
            $entity = new \Faker\ORM\Propel\EntityPopulator($entity);
        }
        $entity->setColumnFormatters($entity->guessColumnFormatters($this->generator));

        if ($customColumnFormatters) {
            $entity->mergeColumnFormattersWith($customColumnFormatters);
        }
        $entity->setModifiers($entity->guessModifiers($this->generator));

        if ($customModifiers) {
            $entity->mergeModifiersWith($customModifiers);
        }
        $class = $entity->getClass();
        $this->entities[$class] = $entity;
        $this->quantities[$class] = $number;
    }

    /**
     * Populate the database using all the Entity classes previously added.
     *
     * @param PropelPDO $con A Propel connection object
     *
     * @return array A list of the inserted PKs
     */
    public function execute($con = null)
    {
        if (null === $con) {
            $con = $this->getConnection();
        }
        $isInstancePoolingEnabled = \Propel::isInstancePoolingEnabled();
        \Propel::disableInstancePooling();
        $insertedEntities = [];
        $con->beginTransaction();

        foreach ($this->quantities as $class => $number) {
            for ($i = 0; $i < $number; ++$i) {
                $insertedEntities[$class][] = $this->entities[$class]->execute($con, $insertedEntities);
            }
        }
        $con->commit();

        if ($isInstancePoolingEnabled) {
            \Propel::enableInstancePooling();
        }

        return $insertedEntities;
    }

    protected function getConnection()
    {
        // use the first connection available
        $class = key($this->entities);

        if (!$class) {
            throw new \RuntimeException('No class found from entities. Did you add entities to the Populator ?');
        }

        $peer = $class::PEER;

        return \Propel::getConnection($peer::DATABASE_NAME, \Propel::CONNECTION_WRITE);
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               <?php

namespace Faker\Provider\hu_HU;

class Person extends \Faker\Provider\Person
{
    protected static $maleNameFormats = [
        '{{lastName}} {{firstNameMale}}',
        '{{title}} {{lastName}} {{firstNameMale}}',
        '{{lastName}} {{firstNameMale}} {{suffix}}',
        '{{title}} {{lastName}} {{firstNameMale}} {{suffix}}',
    ];

    protected static $femaleNameFormats = [
        '{{lastName}} {{firstNameFemale}}',
        '{{title}} {{lastName}} {{firstNameFemale}}',
        '{{lastName}} {{firstNameFemale}} {{suffix}}',
        '{{title}} {{lastName}} {{firstNameFemale}} {{suffix}}',
        // ..nĂ©
        '{{lastName}} {{firstNameMaleNe}}',
        '{{title}} {{lastName}} {{firstNameMaleNe}}',
    ];

    protected static $firstNameMale = [
        'Albert', 'Attila', 'BalĂĄzs', 'Bence', 'Botond', 'DoriĂĄn', 'Endre', 'ErnĆ', 'GĂĄbor', 'GĂ©za', 'Imre', 'IstvĂĄn',
        'Kevin', 'KornĂ©l', 'KristĂłf', 'LĂĄszlĂł', 'MilĂĄn', 'Noel', 'OlivĂ©r', 'OttĂł', 'Patrik', 'PĂ©ter', 'RichĂĄrd', 'Rudolf',
        'SĂĄndor', 'Vilmos', 'Vince', 'ZoltĂĄn', 'Zsolt', 'ĂdĂĄm', 'Ărmin', 'Ăron', 'Antal', 'Barna', 'BarnabĂĄs', 'BendegĂșz',
        'Benedek', 'Hunor', 'JenĆ', 'JĂĄnos', 'MihĂĄly', 'MĂĄtyĂĄs', 'SzervĂĄc', 'Zsombor', 'ZĂ©tĂ©ny', 'ĂrpĂĄd',
    ];

    protected static $firstNameMaleNe = [
        'AlbertnĂ©', 'AttilĂĄnĂ©', 'BalĂĄzsnĂ©', 'BencĂ©nĂ©', 'BotondnĂ©', 'DoriĂĄnnĂ©', 'EndrenĂ©', 'ErnĆnĂ©', 'GĂĄbornĂ©', 'GĂ©zanĂ©', 'ImrĂ©nĂ©', 'IstvĂĄnnĂ©',
        'KevinnĂ©', 'KornĂ©lnĂ©', 'KristĂłfnĂ©', 'LĂĄszlĂłnĂ©', 'MilĂĄnnĂ©', 'NoelnĂ©', 'OlivĂ©rnĂ©', 'OttĂłnĂ©', 'PatriknĂ©', 'PĂ©ternĂ©', 'RichĂĄrdnĂ©', 'RudolfnĂ©',
        'SĂĄndornĂ©', 'VilmosnĂ©', 'VincĂ©nĂ©', 'ZoltĂĄnnĂ©', 'ZsoltnĂ©', 'ĂdĂĄmnĂ©', 'ĂrminnĂ©', 'ĂronnĂ©', 'AntalnĂ©', 'BarnĂĄnĂ©', 'BarnabĂĄsnĂ©', 'BendegĂșz',
        'BenedeknĂ©', 'HunornĂ©', 'JenĆnĂ©', 'JĂĄnosnĂ©', 'MihĂĄlynĂ©', 'MĂĄtyĂĄsnĂ©', 'SzervĂĄcnĂ©', 'ZsombornĂ©', 'ZĂ©tĂ©nynĂ©', 'ĂrpĂĄdnĂ©',
    ];

    protected static $firstNameFemale = [
        'AdĂ©l', 'Alexa', 'Andrea', 'AngĂ©la', 'AnikĂł', 'Beatrix', 'Bettina', 'Dalma', 'Dorina', 'Dorottya', 'Evelin', 'Fanni', 'FlĂłra', 'Gabriella',
        'Georgina', 'Gitta', 'Gizella', 'GrĂ©ta', 'Henrietta', 'Izabella', 'Johanna', 'Judit', 'Julianna', 'JĂĄzmin', 'Kata', 'Katalin',
        'Katinka', 'Klaudia', 'KĂ­ra', 'LiliĂĄna', 'Linda', 'Liza', 'LĂ©na', 'LĂ­via', 'Maja', 'Marianna', 'Marietta', 'Martina',
        'Mia', 'Milla', 'Mirella', 'MĂĄria', 'MĂĄrton', 'MĂ­ra', 'Nikoletta', 'OlĂ­via', 'PatrĂ­cia', 'RamĂłna', 'Rebeka', 'Soma',
        'Szandra', 'SĂĄra', 'ValĂ©ria', 'Zita', 'Aranka', 'BorĂłka', 'BoglĂĄrka', 'Csenge', 'EmĆke', 'ErzsĂ©bet', 'Hanga', 'Henriett',
        'KincsĆ', 'Panna', 'Szabina', 'Szonja', 'VirĂĄg', 'ZsĂłka',
    ];

    protected static $lastName = [
        'Antal', 'Bakos', 'Balla', 'Balog', 'Balogh', 'BalĂĄzs', 'Barna', 'Barta', 'BirĂł', 'BodnĂĄr', 'BogdĂĄn', 'BognĂĄr', 'BorbĂ©ly', 'Boros', 'Budai', 'BĂĄlint', 'Csonka', 'DeĂĄk', 'Dobos', 'DudĂĄs', 'FaragĂł', 'Farkas', 'Fazekas', 'FehĂ©r', 'Fekete', 'Fodor', 'FĂĄbiĂĄn', 'FĂŒlĂ¶p', 'GulyĂĄs', 'GĂĄl', 'GĂĄspĂĄr', 'Hajdu', 'HalĂĄsz', 'HegedĂŒs', 'HegedĆ±s', 'HorvĂĄth', 'IllĂ©s', 'Jakab', 'JuhĂĄsz', 'JĂłnĂĄs', 'Katona', 'Kelemen', 'Kerekes', 'KirĂĄly', 'Kis', 'Kiss', 'Kocsis', 'KovĂĄcs', 'Kozma', 'Lakatos', 'Lengyel', 'LukĂĄcs', 'LĂĄszlĂł', 'Magyar', 'Major', 'MolnĂĄr', 'MĂĄtĂ©', 'MĂ©szĂĄros', 'Nagy', 'Nemes', 'NovĂĄk', 'NĂ©meth', 'OlĂĄh', 'OrbĂĄn', 'Orosz', 'OrsĂłs', 'Pap', 'Papp', 'Pataki', 'PintĂ©r', 'PĂĄl', 'PĂĄsztor', 'PĂ©ter', 'RĂĄcz', 'Simon', 'Sipos', 'Somogyi', 'SoĂłs', 'SzabĂł', 'Szalai', 'Szekeres', 'SzilĂĄgyi', 'SzĂ©kely', 'SzĂŒcs', 'SzĆke', 'SzĆ±cs', 'SĂĄndor', 'TakĂĄcs', 'TamĂĄs', 'TĂłth', 'TĂ¶rĂ¶k', 'Varga', 'Vass', 'Veres', 'Vincze', 'VirĂĄg', 'VĂĄradi', 'VĂ©gh', 'VĂ¶rĂ¶s',
    ];

    protected static $title = ['Dr.', 'Prof.', 'id.', 'ifj.'];

    private static $suffix = ['PhD'];

    public function title($gender = null)
    {
        return static::titleMale();
    }

    /**
     * replaced by specific unisex hungarian title
     */
    public static function titleMale()
    {
        return static::randomElement(static::$title);
    }

    /**
     * specific Hungarian name format for females after marriage
     */
    public static function firstNameMaleNe()
    {
        return static::randomElement(static::$firstNameMaleNe);
    }

    /**
     * replaced by specific unisex hungarian title
     */
    public static function titleFemale()
    {
        return static::titleMale();
    }

    /**
     * @example 'PhD'
     */
    public static function suffix()
    {
        return static::randomElement(static::$suffix);
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 <?php

namespace Faker\Provider\zh_TW;

class DateTime extends \Faker\Provider\DateTime
{
    public static function amPm($max = 'now')
    {
        return static::dateTime($max)->format('a') === 'am' ? 'äžć' : 'äžć';
    }

    public static function dayOfWeek($max = 'now')
    {
        $map = [
            'Sunday' => 'æææ„',
            'Monday' => 'ææäž',
            'Tuesday' => 'ææäș',
            'Wednesday' => 'ææäž',
            'Thursday' => 'ææć',
            'Friday' => 'ææäș',
            'Saturday' => 'ææć­',
        ];
        $week = static::dateTime($max)->format('l');

        return $map[$week] ?? $week;
    }

    public static function monthName($max = 'now')
    {
        $map = [
            'January' => 'äžæ',
            'February' => 'äșæ',
            'March' => 'äžæ',
            'April' => 'ćæ',
            'May' => 'äșæ',
            'June' => 'ć­æ',
            'July' => 'äžæ',
            'August' => 'ć«æ',
            'September' => 'äčæ',
            'October' => 'ćæ',
            'November' => 'ćäžæ',
            'December' => 'ćäșæ',
        ];
        $month = static::dateTime($max)->format('F');

        return $map[$month] ?? $month;
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           <?php
namespace Hamcrest\Core;

/*
 Copyright (c) 2010 hamcrest.org
 */
use Hamcrest\BaseMatcher;
use Hamcrest\Description;

/**
 * Tests if a value (class, object, or array) has a named property.
 *
 * For example:
 * <pre>
 * assertThat(array('a', 'b'), set('b'));
 * assertThat($foo, set('bar'));
 * assertThat('Server', notSet('defaultPort'));
 * </pre>
 *
 * @todo Replace $property with a matcher and iterate all property names.
 */
class Set extends BaseMatcher
{

    private $_property;
    private $_not;

    public function __construct($property, $not = false)
    {
        $this->_property = $property;
        $this->_not = $not;
    }

    public function matches($item)
    {
        if ($item === null) {
            return false;
        }
        $property = $this->_property;
        if (is_array($item)) {
            $result = isset($item[$property]);
        } elseif (is_object($item)) {
            $result = isset($item->$property);
        } elseif (is_string($item)) {
            $result = isset($item::$$property);
        } else {
            throw new \InvalidArgumentException('Must pass an object, array, or class name');
        }

        return $this->_not ? !$result : $result;
    }

    public function describeTo(Description $description)
    {
        $description->appendText($this->_not ? 'unset property ' : 'set property ')->appendText($this->_property);
    }

    public function describeMismatch($item, Description $description)
    {
        $value = '';
        if (!$this->_not) {
            $description->appendText('was not set');
        } else {
            $property = $this->_property;
            if (is_array($item)) {
                $value = $item[$property];
            } elseif (is_object($item)) {
                $value = $item->$property;
            } elseif (is_string($item)) {
                $value = $item::$$property;
            }
            parent::describeMismatch($value, $description);
        }
    }

    /**
     * Matches if value (class, object, or array) has named $property.
     *
     * @factory
     */
    public static function set($property)
    {
        return new self($property);
    }

    /**
     * Matches if value (class, object, or array) does not have named $property.
     *
     * @factory
     */
    public static function notSet($property)
    {
        return new self($property, true);
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <?php

namespace Illuminate\Cache;

use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Support\InteractsWithTime;
use Memcached;
use ReflectionMethod;

class MemcachedStore extends TaggableStore implements LockProvider
{
    use InteractsWithTime;

    /**
     * The Memcached instance.
     *
     * @var \Memcached
     */
    protected $memcached;

    /**
     * A string that should be prepended to keys.
     *
     * @var string
     */
    protected $prefix;

    /**
     * Indicates whether we are using Memcached version >= 3.0.0.
     *
     * @var bool
     */
    protected $onVersionThree;

    /**
     * Create a new Memcached store.
     *
     * @param  \Memcached  $memcached
     * @param  string  $prefix
     * @return void
     */
    public function __construct($memcached, $prefix = '')
    {
        $this->setPrefix($prefix);
        $this->memcached = $memcached;

        $this->onVersionThree = (new ReflectionMethod('Memcached', 'getMulti'))
                            ->getNumberOfParameters() == 2;
    }

    /**
     * Retrieve an item from the cache by key.
     *
     * @param  string  $key
     * @return mixed
     */
    public function get($key)
    {
        $value = $this->memcached->get($this->prefix.$key);

        if ($this->memcached->getResultCode() == 0) {
            return $value;
        }
    }

    /**
     * Retrieve multiple items from the cache by key.
     *
     * Items not found in the cache will have a null value.
     *
     * @param  array  $keys
     * @return array
     */
    public function many(array $keys)
    {
        $prefixedKeys = array_map(function ($key) {
            return $this->prefix.$key;
        }, $keys);

        if ($this->onVersionThree) {
            $values = $this->memcached->getMulti($prefixedKeys, Memcached::GET_PRESERVE_ORDER);
        } else {
            $null = null;

            $values = $this->memcached->getMulti($prefixedKeys, $null, Memcached::GET_PRESERVE_ORDER);
        }

        if ($this->memcached->getResultCode() != 0) {
            return array_fill_keys($keys, null);
        }

        return array_combine($keys, $values);
    }

    /**
     * Store an item in the cache for a given number of seconds.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @param  int  $seconds
     * @return bool
     */
    public function put($key, $value, $seconds)
    {
        return $this->memcached->set(
            $this->prefix.$key, $value, $this->calculateExpiration($seconds)
        );
    }

    /**
     * Store multiple items in the cache for a given number of seconds.
     *
     * @param  array  $values
     * @param  int  $seconds
     * @return bool
     */
    public function putMany(array $values, $seconds)
    {
        $prefixedValues = [];

        foreach ($values as $key => $value) {
            $prefixedValues[$this->prefix.$key] = $value;
        }

        return $this->memcached->setMulti(
            $prefixedValues, $this->calculateExpiration($seconds)
        );
    }

    /**
     * Store an item in the cache if the key doesn't exist.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @param  int  $seconds
     * @return bool
     */
    public function add($key, $value, $seconds)
    {
        return $this->memcached->add(
            $this->prefix.$key, $value, $this->calculateExpiration($seconds)
        );
    }

    /**
     * Increment the value of an item in the cache.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @return int|bool
     */
    public function increment($key, $value = 1)
    {
        return $this->memcached->increment($this->prefix.$key, $value);
    }

    /**
     * Decrement the value of an item in the cache.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @return int|bool
     */
    public function decrement($key, $value = 1)
    {
        return $this->memcached->decrement($this->prefix.$key, $value);
    }

    /**
     * Store an item in the cache indefinitely.
     *
     * @param  string  $key
     * @param  mixed  $value
     * @return bool
     */
    public function forever($key, $value)
    {
        return $this->put($key, $value, 0);
    }

    /**
     * Get a lock instance.
     *
     * @param  string  $name
     * @param  int  $seconds
     * @param  string|null  $owner
     * @return \Illuminate\Contracts\Cache\Lock
     */
    public function lock($name, $seconds = 0, $owner = null)
    {
        return new MemcachedLock($this->memcached, $this->prefix.$name, $seconds, $owner);
    }

    /**
     * Restore a lock instance using the owner identifier.
     *
     * @param  string  $name
     * @param  string  $owner
     * @return \Illuminate\Contracts\Cache\Lock
     */
    public function restoreLock($name, $owner)
    {
        return $this->lock($name, 0, $owner);
    }

    /**
     * Remove an item from the cache.
     *
     * @param  string  $key
     * @return bool
     */
    public function forget($key)
    {
        return $this->memcached->delete($this->prefix.$key);
    }

    /**
     * Remove all items from the cache.
     *
     * @return bool
     */
    public function flush()
    {
        return $this->memcached->flush();
    }

    /**
     * Get the expiration time of the key.
     *
     * @param  int  $seconds
     * @return int
     */
    protected function calculateExpiration($seconds)
    {
        return $this->toTimestamp($seconds);
    }

    /**
     * Get the UNIX timestamp for the given number of seconds.
     *
     * @param  int  $seconds
     * @return int
     */
    protected function toTimestamp($seconds)
    {
        return $seconds > 0 ? $this->availableAt($seconds) : 0;
    }

    /**
     * Get the underlying Memcached connection.
     *
     * @return \Memcached
     */
    public function getMemcached()
    {
        return $this->memcached;
    }

    /**
     * Get the cache key prefix.
     *
     * @return string
     */
    public function getPrefix()
    {
        return $this->prefix;
    }

    /**
     * Set the cache key prefix.
     *
     * @param  string  $prefix
     * @return void
     */
    public function setPrefix($prefix)
    {
        $this->prefix = ! empty($prefix) ? $prefix.':' : '';
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          <?php

namespace Illuminate\Database\Eloquent\Casts;

class Attribute
{
    /**
     * The attribute accessor.
     *
     * @var callable
     */
    public $get;

    /**
     * The attribute mutator.
     *
     * @var callable
     */
    public $set;

    /**
     * Indicates if caching of objects is enabled for this attribute.
     *
     * @var bool
     */
    public $withObjectCaching = true;

    /**
     * Create a new attribute accessor / mutator.
     *
     * @param  callable|null  $get
     * @param  callable|null  $set
     * @return void
     */
    public function __construct(callable $get = null, callable $set = null)
    {
        $this->get = $get;
        $this->set = $set;
    }

    /**
     * Create a new attribute accessor.
     *
     * @param  callable  $get
     * @return static
     */
    public static function get(callable $get)
    {
        return new static($get);
    }

    /**
     * Create a new attribute mutator.
     *
     * @param  callable  $set
     * @return static
     */
    public static function set(callable $set)
    {
        return new static(null, $set);
    }

    /**
     * Disable object caching for the attribute.
     *
     * @return static
     */
    public function withoutObjectCaching()
    {
        $this->withObjectCaching = false;

        return $this;
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             <?php

namespace Illuminate\Foundation\Console;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Events\VendorTagPublished;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem as Flysystem;
use League\Flysystem\MountManager;

class VendorPublishCommand extends Command
{
    /**
     * The filesystem instance.
     *
     * @var \Illuminate\Filesystem\Filesystem
     */
    protected $files;

    /**
     * The provider to publish.
     *
     * @var string
     */
    protected $provider = null;

    /**
     * The tags to publish.
     *
     * @var array
     */
    protected $tags = [];

    /**
     * The console command signature.
     *
     * @var string
     */
    protected $signature = 'vendor:publish {--force : Overwrite any existing files}
                    {--all : Publish assets for all service providers without prompt}
                    {--provider= : The service provider that has assets you want to publish}
                    {--tag=* : One or many tags that have assets you want to publish}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Publish any publishable assets from vendor packages';

    /**
     * Create a new command instance.
     *
     * @param  \Illuminate\Filesystem\Filesystem  $files
     * @return void
     */
    public function __construct(Filesystem $files)
    {
        parent::__construct();

        $this->files = $files;
    }

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle()
    {
        $this->determineWhatShouldBePublished();

        foreach ($this->tags ?: [null] as $tag) {
            $this->publishTag($tag);
        }

        $this->info('Publishing complete.');
    }

    /**
     * Determine the provider or tag(s) to publish.
     *
     * @return void
     */
    protected function determineWhatShouldBePublished()
    {
        if ($this->option('all')) {
            return;
        }

        [$this->provider, $this->tags] = [
            $this->option('provider'), (array) $this->option('tag'),
        ];

        if (! $this->provider && ! $this->tags) {
            $this->promptForProviderOrTag();
        }
    }

    /**
     * Prompt for which provider or tag to publish.
     *
     * @return void
     */
    protected function promptForProviderOrTag()
    {
        $choice = $this->choice(
            "Which provider or tag's files would you like to publish?",
            $choices = $this->publishableChoices()
        );

        if ($choice == $choices[0] || is_null($choice)) {
            return;
        }

        $this->parseChoice($choice);
    }

    /**
     * The choices available via the prompt.
     *
     * @return array
     */
    protected function publishableChoices()
    {
        return array_merge(
            ['<comment>Publish files from all providers and tags listed below</comment>'],
            preg_filter('/^/', '<comment>Provider: </comment>', Arr::sort(ServiceProvider::publishableProviders())),
            preg_filter('/^/', '<comment>Tag: </comment>', Arr::sort(ServiceProvider::publishableGroups()))
        );
    }

    /**
     * Parse the answer that was given via the prompt.
     *
     * @param  string  $choice
     * @return void
     */
    protected function parseChoice($choice)
    {
        [$type, $value] = explode(': ', strip_tags($choice));

        if ($type === 'Provider') {
            $this->provider = $value;
        } elseif ($type === 'Tag') {
            $this->tags = [$value];
        }
    }

    /**
     * Publishes the assets for a tag.
     *
     * @param  string  $tag
     * @return mixed
     */
    protected function publishTag($tag)
    {
        $published = false;

        $pathsToPublish = $this->pathsToPublish($tag);

        foreach ($pathsToPublish as $from => $to) {
            $this->publishItem($from, $to);

            $published = true;
        }

        if ($published === false) {
            $this->comment('No publishable resources for tag ['.$tag.'].');
        } else {
            $this->laravel['events']->dispatch(new VendorTagPublished($tag, $pathsToPublish));
        }
    }

    /**
     * Get all of the paths to publish.
     *
     * @param  string  $tag
     * @return array
     */
    protected function pathsToPublish($tag)
    {
        return ServiceProvider::pathsToPublish(
            $this->provider, $tag
        );
    }

    /**
     * Publish the given item from and to the given location.
     *
     * @param  string  $from
     * @param  string  $to
     * @return void
     */
    protected function publishItem($from, $to)
    {
        if ($this->files->isFile($from)) {
            return $this->publishFile($from, $to);
        } elseif ($this->files->isDirectory($from)) {
            return $this->publishDirectory($from, $to);
        }

        $this->error("Can't locate path: <{$from}>");
    }

    /**
     * Publish the file to the given path.
     *
     * @param  string  $from
     * @param  string  $to
     * @return void
     */
    protected function publishFile($from, $to)
    {
        if (! $this->files->exists($to) || $this->option('force')) {
            $this->createParentDirectory(dirname($to));

            $this->files->copy($from, $to);

            $this->status($from, $to, 'File');
        }
    }

    /**
     * Publish the directory to the given directory.
     *
     * @param  string  $from
     * @param  string  $to
     * @return void
     */
    protected function publishDirectory($from, $to)
    {
        $this->moveManagedFiles(new MountManager([
            'from' => new Flysystem(new LocalAdapter($from)),
            'to' => new Flysystem(new LocalAdapter($to)),
        ]));

        $this->status($from, $to, 'Directory');
    }

    /**
     * Move all the files in the given MountManager.
     *
     * @param  \League\Flysystem\MountManager  $manager
     * @return void
     */
    protected function moveManagedFiles($manager)
    {
        foreach ($manager->listContents('from://', true) as $file) {
            if ($file['type'] === 'file' && (! $manager->has('to://'.$file['path']) || $this->option('force'))) {
                $manager->put('to://'.$file['path'], $manager->read('from://'.$file['path']));
            }
        }
    }

    /**
     * Create the directory to house the published files if needed.
     *
     * @param  string  $directory
     * @return void
     */
    protected function createParentDirectory($directory)
    {
        if (! $this->files->isDirectory($directory)) {
            $this->files->makeDirectory($directory, 0755, true);
        }
    }

    /**
     * Write a status message to the console.
     *
     * @param  string  $from
     * @param  string  $to
     * @param  string  $type
     * @return void
     */
    protected function status($from, $to, $type)
    {
        $from = str_replace(base_path(), '', realpath($from));

        $to = str_replace(base_path(), '', realpath($to));

        $this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>');
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <?php

namespace Illuminate\Queue\Capsule;

use Illuminate\Container\Container;
use Illuminate\Queue\QueueManager;
use Illuminate\Queue\QueueServiceProvider;
use Illuminate\Support\Traits\CapsuleManagerTrait;

/**
 * @mixin \Illuminate\Queue\QueueManager
 * @mixin \Illuminate\Contracts\Queue\Queue
 */
class Manager
{
    use CapsuleManagerTrait;

    /**
     * The queue manager instance.
     *
     * @var \Illuminate\Queue\QueueManager
     */
    protected $manager;

    /**
     * Create a new queue capsule manager.
     *
     * @param  \Illuminate\Container\Container|null  $container
     * @return void
     */
    public function __construct(Container $container = null)
    {
        $this->setupContainer($container ?: new Container);

        // Once we have the container setup, we will setup the default configuration
        // options in the container "config" bindings. This just makes this queue
        // manager behave correctly since all the correct binding are in place.
        $this->setupDefaultConfiguration();

        $this->setupManager();

        $this->registerConnectors();
    }

    /**
     * Setup the default queue configuration options.
     *
     * @return void
     */
    protected function setupDefaultConfiguration()
    {
        $this->container['config']['queue.default'] = 'default';
    }

    /**
     * Build the queue manager instance.
     *
     * @return void
     */
    protected function setupManager()
    {
        $this->manager = new QueueManager($this->container);
    }

    /**
     * Register the default connectors that the component ships with.
     *
     * @return void
     */
    protected function registerConnectors()
    {
        $provider = new QueueServiceProvider($this->container);

        $provider->registerConnectors($this->manager);
    }

    /**
     * Get a connection instance from the global manager.
     *
     * @param  string|null  $connection
     * @return \Illuminate\Contracts\Queue\Queue
     */
    public static function connection($connection = null)
    {
        return static::$instance->getConnection($connection);
    }

    /**
     * Push a new job onto the queue.
     *
     * @param  string  $job
     * @param  mixed  $data
     * @param  string|null  $queue
     * @param  string|null  $connection
     * @return mixed
     */
    public static function push($job, $data = '', $queue = null, $connection = null)
    {
        return static::$instance->connection($connection)->push($job, $data, $queue);
    }

    /**
     * Push a new an array of jobs onto the queue.
     *
     * @param  array  $jobs
     * @param  mixed  $data
     * @param  string|null  $queue
     * @param  string|null  $connection
     * @return mixed
     */
    public static function bulk($jobs, $data = '', $queue = null, $connection = null)
    {
        return static::$instance->connection($connection)->bulk($jobs, $data, $queue);
    }

    /**
     * Push a new job onto the queue after a delay.
     *
     * @param  \DateTimeInterface|\DateInterval|int  $delay
     * @param  string  $job
     * @param  mixed  $data
     * @param  string|null  $queue
     * @param  string|null  $connection
     * @return mixed
     */
    public static function later($delay, $job, $data = '', $queue = null, $connection = null)
    {
        return static::$instance->connection($connection)->later($delay, $job, $data, $queue);
    }

    /**
     * Get a registered connection instance.
     *
     * @param  string|null  $name
     * @return \Illuminate\Contracts\Queue\Queue
     */
    public function getConnection($name = null)
    {
        return $this->manager->connection($name);
    }

    /**
     * Register a connection with the manager.
     *
     * @param  array  $config
     * @param  string  $name
     * @return void
     */
    public function addConnection(array $config, $name = 'default')
    {
        $this->container['config']["queue.connections.{$name}"] = $config;
    }

    /**
     * Get the queue manager instance.
     *
     * @return \Illuminate\Queue\QueueManager
     */
    public function getQueueManager()
    {
        return $this->manager;
    }

    /**
     * Pass dynamic instance methods to the manager.
     *
     * @param  string  $method
     * @param  array  $parameters
     * @return mixed
     */
    public function __call($method, $parameters)
    {
        return $this->manager->$method(...$parameters);
    }

    /**
     * Dynamically pass methods to the default connection.
     *
     * @param  string  $method
     * @param  array  $parameters
     * @return mixed
     */
    public static function __callStatic($method, $parameters)
    {
        return static::connection()->$method(...$parameters);
    }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              