Bug 1753131 - use MediaManager device list change coalescing for MediaDevices r=jib
[gecko.git] / testing / modules / ajv-6.12.6.js
blob161935b06ca0dc50a1cebc847cd91de03dc1696d
1 "use strict";
2 const global = this;
4 var EXPORTED_SYMBOLS = ["Ajv"];
6 /*
7  * ajv 6.12.6: Another JSON Schema Validator
8  *
9  * https://github.com/epoberezkin/ajv
10  *
11  * The MIT License (MIT)
12  *
13  * Copyright (c) 2015 Evgeny Poberezkin
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining a copy
16  * of this software and associated documentation files (the "Software"), to deal
17  * in the Software without restriction, including without limitation the rights
18  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19  * copies of the Software, and to permit persons to whom the Software is
20  * furnished to do so, subject to the following conditions:
22  * The above copyright notice and this permission notice shall be included in all
23  * copies or substantial portions of the Software.
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  */
34 // Everything below this comment was taken from the `dist/ajv.bundle.js` in the
35 // ajv node module. (You can get this by running `npm install ajv` in an empty
36 // directory and copying `node_modules/ajv/dist/ajv.bundle.js`).
38 (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Ajv = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
39 'use strict';
42 var Cache = module.exports = function Cache() {
43   this._cache = {};
47 Cache.prototype.put = function Cache_put(key, value) {
48   this._cache[key] = value;
52 Cache.prototype.get = function Cache_get(key) {
53   return this._cache[key];
57 Cache.prototype.del = function Cache_del(key) {
58   delete this._cache[key];
62 Cache.prototype.clear = function Cache_clear() {
63   this._cache = {};
66 },{}],2:[function(require,module,exports){
67 'use strict';
69 var MissingRefError = require('./error_classes').MissingRef;
71 module.exports = compileAsync;
74 /**
75  * Creates validating function for passed schema with asynchronous loading of missing schemas.
76  * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
77  * @this  Ajv
78  * @param {Object}   schema schema object
79  * @param {Boolean}  meta optional true to compile meta-schema; this parameter can be skipped
80  * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
81  * @return {Promise} promise that resolves with a validating function.
82  */
83 function compileAsync(schema, meta, callback) {
84   /* eslint no-shadow: 0 */
85   /* global Promise */
86   /* jshint validthis: true */
87   var self = this;
88   if (typeof this._opts.loadSchema != 'function')
89     throw new Error('options.loadSchema should be a function');
91   if (typeof meta == 'function') {
92     callback = meta;
93     meta = undefined;
94   }
96   var p = loadMetaSchemaOf(schema).then(function () {
97     var schemaObj = self._addSchema(schema, undefined, meta);
98     return schemaObj.validate || _compileAsync(schemaObj);
99   });
101   if (callback) {
102     p.then(
103       function(v) { callback(null, v); },
104       callback
105     );
106   }
108   return p;
111   function loadMetaSchemaOf(sch) {
112     var $schema = sch.$schema;
113     return $schema && !self.getSchema($schema)
114             ? compileAsync.call(self, { $ref: $schema }, true)
115             : Promise.resolve();
116   }
119   function _compileAsync(schemaObj) {
120     try { return self._compile(schemaObj); }
121     catch(e) {
122       if (e instanceof MissingRefError) return loadMissingSchema(e);
123       throw e;
124     }
127     function loadMissingSchema(e) {
128       var ref = e.missingSchema;
129       if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
131       var schemaPromise = self._loadingSchemas[ref];
132       if (!schemaPromise) {
133         schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
134         schemaPromise.then(removePromise, removePromise);
135       }
137       return schemaPromise.then(function (sch) {
138         if (!added(ref)) {
139           return loadMetaSchemaOf(sch).then(function () {
140             if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
141           });
142         }
143       }).then(function() {
144         return _compileAsync(schemaObj);
145       });
147       function removePromise() {
148         delete self._loadingSchemas[ref];
149       }
151       function added(ref) {
152         return self._refs[ref] || self._schemas[ref];
153       }
154     }
155   }
158 },{"./error_classes":3}],3:[function(require,module,exports){
159 'use strict';
161 var resolve = require('./resolve');
163 module.exports = {
164   Validation: errorSubclass(ValidationError),
165   MissingRef: errorSubclass(MissingRefError)
169 function ValidationError(errors) {
170   this.message = 'validation failed';
171   this.errors = errors;
172   this.ajv = this.validation = true;
176 MissingRefError.message = function (baseId, ref) {
177   return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
181 function MissingRefError(baseId, ref, message) {
182   this.message = message || MissingRefError.message(baseId, ref);
183   this.missingRef = resolve.url(baseId, ref);
184   this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
188 function errorSubclass(Subclass) {
189   Subclass.prototype = Object.create(Error.prototype);
190   Subclass.prototype.constructor = Subclass;
191   return Subclass;
194 },{"./resolve":6}],4:[function(require,module,exports){
195 'use strict';
197 var util = require('./util');
199 var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
200 var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
201 var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
202 var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
203 var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
204 var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
205 // uri-template: https://tools.ietf.org/html/rfc6570
206 var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
207 // For the source: https://gist.github.com/dperini/729294
208 // For test cases: https://mathiasbynens.be/demo/url-regex
209 // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
210 // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
211 var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
212 var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
213 var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
214 var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
215 var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
218 module.exports = formats;
220 function formats(mode) {
221   mode = mode == 'full' ? 'full' : 'fast';
222   return util.copy(formats[mode]);
226 formats.fast = {
227   // date: http://tools.ietf.org/html/rfc3339#section-5.6
228   date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
229   // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
230   time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
231   'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
232   // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
233   uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
234   'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
235   'uri-template': URITEMPLATE,
236   url: URL,
237   // email (sources from jsen validator):
238   // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
239   // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
240   email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
241   hostname: HOSTNAME,
242   // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
243   ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
244   // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
245   ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
246   regex: regex,
247   // uuid: http://tools.ietf.org/html/rfc4122
248   uuid: UUID,
249   // JSON-pointer: https://tools.ietf.org/html/rfc6901
250   // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
251   'json-pointer': JSON_POINTER,
252   'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
253   // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
254   'relative-json-pointer': RELATIVE_JSON_POINTER
258 formats.full = {
259   date: date,
260   time: time,
261   'date-time': date_time,
262   uri: uri,
263   'uri-reference': URIREF,
264   'uri-template': URITEMPLATE,
265   url: URL,
266   email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
267   hostname: HOSTNAME,
268   ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
269   ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
270   regex: regex,
271   uuid: UUID,
272   'json-pointer': JSON_POINTER,
273   'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
274   'relative-json-pointer': RELATIVE_JSON_POINTER
278 function isLeapYear(year) {
279   // https://tools.ietf.org/html/rfc3339#appendix-C
280   return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
284 function date(str) {
285   // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
286   var matches = str.match(DATE);
287   if (!matches) return false;
289   var year = +matches[1];
290   var month = +matches[2];
291   var day = +matches[3];
293   return month >= 1 && month <= 12 && day >= 1 &&
294           day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
298 function time(str, full) {
299   var matches = str.match(TIME);
300   if (!matches) return false;
302   var hour = matches[1];
303   var minute = matches[2];
304   var second = matches[3];
305   var timeZone = matches[5];
306   return ((hour <= 23 && minute <= 59 && second <= 59) ||
307           (hour == 23 && minute == 59 && second == 60)) &&
308          (!full || timeZone);
312 var DATE_TIME_SEPARATOR = /t|\s/i;
313 function date_time(str) {
314   // http://tools.ietf.org/html/rfc3339#section-5.6
315   var dateTime = str.split(DATE_TIME_SEPARATOR);
316   return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
320 var NOT_URI_FRAGMENT = /\/|:/;
321 function uri(str) {
322   // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
323   return NOT_URI_FRAGMENT.test(str) && URI.test(str);
327 var Z_ANCHOR = /[^\\]\\Z/;
328 function regex(str) {
329   if (Z_ANCHOR.test(str)) return false;
330   try {
331     new RegExp(str);
332     return true;
333   } catch(e) {
334     return false;
335   }
338 },{"./util":10}],5:[function(require,module,exports){
339 'use strict';
341 var resolve = require('./resolve')
342   , util = require('./util')
343   , errorClasses = require('./error_classes')
344   , stableStringify = require('fast-json-stable-stringify');
346 var validateGenerator = require('../dotjs/validate');
349  * Functions below are used inside compiled validations function
350  */
352 var ucs2length = util.ucs2length;
353 var equal = require('fast-deep-equal');
355 // this error is thrown by async schemas to return validation errors via exception
356 var ValidationError = errorClasses.Validation;
358 module.exports = compile;
362  * Compiles schema to validation function
363  * @this   Ajv
364  * @param  {Object} schema schema object
365  * @param  {Object} root object with information about the root schema for this schema
366  * @param  {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
367  * @param  {String} baseId base ID for IDs in the schema
368  * @return {Function} validation function
369  */
370 function compile(schema, root, localRefs, baseId) {
371   /* jshint validthis: true, evil: true */
372   /* eslint no-shadow: 0 */
373   var self = this
374     , opts = this._opts
375     , refVal = [ undefined ]
376     , refs = {}
377     , patterns = []
378     , patternsHash = {}
379     , defaults = []
380     , defaultsHash = {}
381     , customRules = [];
383   root = root || { schema: schema, refVal: refVal, refs: refs };
385   var c = checkCompiling.call(this, schema, root, baseId);
386   var compilation = this._compilations[c.index];
387   if (c.compiling) return (compilation.callValidate = callValidate);
389   var formats = this._formats;
390   var RULES = this.RULES;
392   try {
393     var v = localCompile(schema, root, localRefs, baseId);
394     compilation.validate = v;
395     var cv = compilation.callValidate;
396     if (cv) {
397       cv.schema = v.schema;
398       cv.errors = null;
399       cv.refs = v.refs;
400       cv.refVal = v.refVal;
401       cv.root = v.root;
402       cv.$async = v.$async;
403       if (opts.sourceCode) cv.source = v.source;
404     }
405     return v;
406   } finally {
407     endCompiling.call(this, schema, root, baseId);
408   }
410   /* @this   {*} - custom context, see passContext option */
411   function callValidate() {
412     /* jshint validthis: true */
413     var validate = compilation.validate;
414     var result = validate.apply(this, arguments);
415     callValidate.errors = validate.errors;
416     return result;
417   }
419   function localCompile(_schema, _root, localRefs, baseId) {
420     var isRoot = !_root || (_root && _root.schema == _schema);
421     if (_root.schema != root.schema)
422       return compile.call(self, _schema, _root, localRefs, baseId);
424     var $async = _schema.$async === true;
426     var sourceCode = validateGenerator({
427       isTop: true,
428       schema: _schema,
429       isRoot: isRoot,
430       baseId: baseId,
431       root: _root,
432       schemaPath: '',
433       errSchemaPath: '#',
434       errorPath: '""',
435       MissingRefError: errorClasses.MissingRef,
436       RULES: RULES,
437       validate: validateGenerator,
438       util: util,
439       resolve: resolve,
440       resolveRef: resolveRef,
441       usePattern: usePattern,
442       useDefault: useDefault,
443       useCustomRule: useCustomRule,
444       opts: opts,
445       formats: formats,
446       logger: self.logger,
447       self: self
448     });
450     sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
451                    + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
452                    + sourceCode;
454     if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
455     // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
456     var validate;
457     try {
458       var makeValidate = new Function(
459         'self',
460         'RULES',
461         'formats',
462         'root',
463         'refVal',
464         'defaults',
465         'customRules',
466         'equal',
467         'ucs2length',
468         'ValidationError',
469         sourceCode
470       );
472       validate = makeValidate(
473         self,
474         RULES,
475         formats,
476         root,
477         refVal,
478         defaults,
479         customRules,
480         equal,
481         ucs2length,
482         ValidationError
483       );
485       refVal[0] = validate;
486     } catch(e) {
487       self.logger.error('Error compiling schema, function code:', sourceCode);
488       throw e;
489     }
491     validate.schema = _schema;
492     validate.errors = null;
493     validate.refs = refs;
494     validate.refVal = refVal;
495     validate.root = isRoot ? validate : _root;
496     if ($async) validate.$async = true;
497     if (opts.sourceCode === true) {
498       validate.source = {
499         code: sourceCode,
500         patterns: patterns,
501         defaults: defaults
502       };
503     }
505     return validate;
506   }
508   function resolveRef(baseId, ref, isRoot) {
509     ref = resolve.url(baseId, ref);
510     var refIndex = refs[ref];
511     var _refVal, refCode;
512     if (refIndex !== undefined) {
513       _refVal = refVal[refIndex];
514       refCode = 'refVal[' + refIndex + ']';
515       return resolvedRef(_refVal, refCode);
516     }
517     if (!isRoot && root.refs) {
518       var rootRefId = root.refs[ref];
519       if (rootRefId !== undefined) {
520         _refVal = root.refVal[rootRefId];
521         refCode = addLocalRef(ref, _refVal);
522         return resolvedRef(_refVal, refCode);
523       }
524     }
526     refCode = addLocalRef(ref);
527     var v = resolve.call(self, localCompile, root, ref);
528     if (v === undefined) {
529       var localSchema = localRefs && localRefs[ref];
530       if (localSchema) {
531         v = resolve.inlineRef(localSchema, opts.inlineRefs)
532             ? localSchema
533             : compile.call(self, localSchema, root, localRefs, baseId);
534       }
535     }
537     if (v === undefined) {
538       removeLocalRef(ref);
539     } else {
540       replaceLocalRef(ref, v);
541       return resolvedRef(v, refCode);
542     }
543   }
545   function addLocalRef(ref, v) {
546     var refId = refVal.length;
547     refVal[refId] = v;
548     refs[ref] = refId;
549     return 'refVal' + refId;
550   }
552   function removeLocalRef(ref) {
553     delete refs[ref];
554   }
556   function replaceLocalRef(ref, v) {
557     var refId = refs[ref];
558     refVal[refId] = v;
559   }
561   function resolvedRef(refVal, code) {
562     return typeof refVal == 'object' || typeof refVal == 'boolean'
563             ? { code: code, schema: refVal, inline: true }
564             : { code: code, $async: refVal && !!refVal.$async };
565   }
567   function usePattern(regexStr) {
568     var index = patternsHash[regexStr];
569     if (index === undefined) {
570       index = patternsHash[regexStr] = patterns.length;
571       patterns[index] = regexStr;
572     }
573     return 'pattern' + index;
574   }
576   function useDefault(value) {
577     switch (typeof value) {
578       case 'boolean':
579       case 'number':
580         return '' + value;
581       case 'string':
582         return util.toQuotedString(value);
583       case 'object':
584         if (value === null) return 'null';
585         var valueStr = stableStringify(value);
586         var index = defaultsHash[valueStr];
587         if (index === undefined) {
588           index = defaultsHash[valueStr] = defaults.length;
589           defaults[index] = value;
590         }
591         return 'default' + index;
592     }
593   }
595   function useCustomRule(rule, schema, parentSchema, it) {
596     if (self._opts.validateSchema !== false) {
597       var deps = rule.definition.dependencies;
598       if (deps && !deps.every(function(keyword) {
599         return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
600       }))
601         throw new Error('parent schema must have all required keywords: ' + deps.join(','));
603       var validateSchema = rule.definition.validateSchema;
604       if (validateSchema) {
605         var valid = validateSchema(schema);
606         if (!valid) {
607           var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
608           if (self._opts.validateSchema == 'log') self.logger.error(message);
609           else throw new Error(message);
610         }
611       }
612     }
614     var compile = rule.definition.compile
615       , inline = rule.definition.inline
616       , macro = rule.definition.macro;
618     var validate;
619     if (compile) {
620       validate = compile.call(self, schema, parentSchema, it);
621     } else if (macro) {
622       validate = macro.call(self, schema, parentSchema, it);
623       if (opts.validateSchema !== false) self.validateSchema(validate, true);
624     } else if (inline) {
625       validate = inline.call(self, it, rule.keyword, schema, parentSchema);
626     } else {
627       validate = rule.definition.validate;
628       if (!validate) return;
629     }
631     if (validate === undefined)
632       throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
634     var index = customRules.length;
635     customRules[index] = validate;
637     return {
638       code: 'customRule' + index,
639       validate: validate
640     };
641   }
646  * Checks if the schema is currently compiled
647  * @this   Ajv
648  * @param  {Object} schema schema to compile
649  * @param  {Object} root root object
650  * @param  {String} baseId base schema ID
651  * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
652  */
653 function checkCompiling(schema, root, baseId) {
654   /* jshint validthis: true */
655   var index = compIndex.call(this, schema, root, baseId);
656   if (index >= 0) return { index: index, compiling: true };
657   index = this._compilations.length;
658   this._compilations[index] = {
659     schema: schema,
660     root: root,
661     baseId: baseId
662   };
663   return { index: index, compiling: false };
668  * Removes the schema from the currently compiled list
669  * @this   Ajv
670  * @param  {Object} schema schema to compile
671  * @param  {Object} root root object
672  * @param  {String} baseId base schema ID
673  */
674 function endCompiling(schema, root, baseId) {
675   /* jshint validthis: true */
676   var i = compIndex.call(this, schema, root, baseId);
677   if (i >= 0) this._compilations.splice(i, 1);
682  * Index of schema compilation in the currently compiled list
683  * @this   Ajv
684  * @param  {Object} schema schema to compile
685  * @param  {Object} root root object
686  * @param  {String} baseId base schema ID
687  * @return {Integer} compilation index
688  */
689 function compIndex(schema, root, baseId) {
690   /* jshint validthis: true */
691   for (var i=0; i<this._compilations.length; i++) {
692     var c = this._compilations[i];
693     if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
694   }
695   return -1;
699 function patternCode(i, patterns) {
700   return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
704 function defaultCode(i) {
705   return 'var default' + i + ' = defaults[' + i + '];';
709 function refValCode(i, refVal) {
710   return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
714 function customRuleCode(i) {
715   return 'var customRule' + i + ' = customRules[' + i + '];';
719 function vars(arr, statement) {
720   if (!arr.length) return '';
721   var code = '';
722   for (var i=0; i<arr.length; i++)
723     code += statement(i, arr);
724   return code;
727 },{"../dotjs/validate":38,"./error_classes":3,"./resolve":6,"./util":10,"fast-deep-equal":42,"fast-json-stable-stringify":43}],6:[function(require,module,exports){
728 'use strict';
730 var URI = require('uri-js')
731   , equal = require('fast-deep-equal')
732   , util = require('./util')
733   , SchemaObject = require('./schema_obj')
734   , traverse = require('json-schema-traverse');
736 module.exports = resolve;
738 resolve.normalizeId = normalizeId;
739 resolve.fullPath = getFullPath;
740 resolve.url = resolveUrl;
741 resolve.ids = resolveIds;
742 resolve.inlineRef = inlineRef;
743 resolve.schema = resolveSchema;
746  * [resolve and compile the references ($ref)]
747  * @this   Ajv
748  * @param  {Function} compile reference to schema compilation funciton (localCompile)
749  * @param  {Object} root object with information about the root schema for the current schema
750  * @param  {String} ref reference to resolve
751  * @return {Object|Function} schema object (if the schema can be inlined) or validation function
752  */
753 function resolve(compile, root, ref) {
754   /* jshint validthis: true */
755   var refVal = this._refs[ref];
756   if (typeof refVal == 'string') {
757     if (this._refs[refVal]) refVal = this._refs[refVal];
758     else return resolve.call(this, compile, root, refVal);
759   }
761   refVal = refVal || this._schemas[ref];
762   if (refVal instanceof SchemaObject) {
763     return inlineRef(refVal.schema, this._opts.inlineRefs)
764             ? refVal.schema
765             : refVal.validate || this._compile(refVal);
766   }
768   var res = resolveSchema.call(this, root, ref);
769   var schema, v, baseId;
770   if (res) {
771     schema = res.schema;
772     root = res.root;
773     baseId = res.baseId;
774   }
776   if (schema instanceof SchemaObject) {
777     v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
778   } else if (schema !== undefined) {
779     v = inlineRef(schema, this._opts.inlineRefs)
780         ? schema
781         : compile.call(this, schema, root, undefined, baseId);
782   }
784   return v;
789  * Resolve schema, its root and baseId
790  * @this Ajv
791  * @param  {Object} root root object with properties schema, refVal, refs
792  * @param  {String} ref  reference to resolve
793  * @return {Object} object with properties schema, root, baseId
794  */
795 function resolveSchema(root, ref) {
796   /* jshint validthis: true */
797   var p = URI.parse(ref)
798     , refPath = _getFullPath(p)
799     , baseId = getFullPath(this._getId(root.schema));
800   if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
801     var id = normalizeId(refPath);
802     var refVal = this._refs[id];
803     if (typeof refVal == 'string') {
804       return resolveRecursive.call(this, root, refVal, p);
805     } else if (refVal instanceof SchemaObject) {
806       if (!refVal.validate) this._compile(refVal);
807       root = refVal;
808     } else {
809       refVal = this._schemas[id];
810       if (refVal instanceof SchemaObject) {
811         if (!refVal.validate) this._compile(refVal);
812         if (id == normalizeId(ref))
813           return { schema: refVal, root: root, baseId: baseId };
814         root = refVal;
815       } else {
816         return;
817       }
818     }
819     if (!root.schema) return;
820     baseId = getFullPath(this._getId(root.schema));
821   }
822   return getJsonPointer.call(this, p, baseId, root.schema, root);
826 /* @this Ajv */
827 function resolveRecursive(root, ref, parsedRef) {
828   /* jshint validthis: true */
829   var res = resolveSchema.call(this, root, ref);
830   if (res) {
831     var schema = res.schema;
832     var baseId = res.baseId;
833     root = res.root;
834     var id = this._getId(schema);
835     if (id) baseId = resolveUrl(baseId, id);
836     return getJsonPointer.call(this, parsedRef, baseId, schema, root);
837   }
841 var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
842 /* @this Ajv */
843 function getJsonPointer(parsedRef, baseId, schema, root) {
844   /* jshint validthis: true */
845   parsedRef.fragment = parsedRef.fragment || '';
846   if (parsedRef.fragment.slice(0,1) != '/') return;
847   var parts = parsedRef.fragment.split('/');
849   for (var i = 1; i < parts.length; i++) {
850     var part = parts[i];
851     if (part) {
852       part = util.unescapeFragment(part);
853       schema = schema[part];
854       if (schema === undefined) break;
855       var id;
856       if (!PREVENT_SCOPE_CHANGE[part]) {
857         id = this._getId(schema);
858         if (id) baseId = resolveUrl(baseId, id);
859         if (schema.$ref) {
860           var $ref = resolveUrl(baseId, schema.$ref);
861           var res = resolveSchema.call(this, root, $ref);
862           if (res) {
863             schema = res.schema;
864             root = res.root;
865             baseId = res.baseId;
866           }
867         }
868       }
869     }
870   }
871   if (schema !== undefined && schema !== root.schema)
872     return { schema: schema, root: root, baseId: baseId };
876 var SIMPLE_INLINED = util.toHash([
877   'type', 'format', 'pattern',
878   'maxLength', 'minLength',
879   'maxProperties', 'minProperties',
880   'maxItems', 'minItems',
881   'maximum', 'minimum',
882   'uniqueItems', 'multipleOf',
883   'required', 'enum'
885 function inlineRef(schema, limit) {
886   if (limit === false) return false;
887   if (limit === undefined || limit === true) return checkNoRef(schema);
888   else if (limit) return countKeys(schema) <= limit;
892 function checkNoRef(schema) {
893   var item;
894   if (Array.isArray(schema)) {
895     for (var i=0; i<schema.length; i++) {
896       item = schema[i];
897       if (typeof item == 'object' && !checkNoRef(item)) return false;
898     }
899   } else {
900     for (var key in schema) {
901       if (key == '$ref') return false;
902       item = schema[key];
903       if (typeof item == 'object' && !checkNoRef(item)) return false;
904     }
905   }
906   return true;
910 function countKeys(schema) {
911   var count = 0, item;
912   if (Array.isArray(schema)) {
913     for (var i=0; i<schema.length; i++) {
914       item = schema[i];
915       if (typeof item == 'object') count += countKeys(item);
916       if (count == Infinity) return Infinity;
917     }
918   } else {
919     for (var key in schema) {
920       if (key == '$ref') return Infinity;
921       if (SIMPLE_INLINED[key]) {
922         count++;
923       } else {
924         item = schema[key];
925         if (typeof item == 'object') count += countKeys(item) + 1;
926         if (count == Infinity) return Infinity;
927       }
928     }
929   }
930   return count;
934 function getFullPath(id, normalize) {
935   if (normalize !== false) id = normalizeId(id);
936   var p = URI.parse(id);
937   return _getFullPath(p);
941 function _getFullPath(p) {
942   return URI.serialize(p).split('#')[0] + '#';
946 var TRAILING_SLASH_HASH = /#\/?$/;
947 function normalizeId(id) {
948   return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
952 function resolveUrl(baseId, id) {
953   id = normalizeId(id);
954   return URI.resolve(baseId, id);
958 /* @this Ajv */
959 function resolveIds(schema) {
960   var schemaId = normalizeId(this._getId(schema));
961   var baseIds = {'': schemaId};
962   var fullPaths = {'': getFullPath(schemaId, false)};
963   var localRefs = {};
964   var self = this;
966   traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
967     if (jsonPtr === '') return;
968     var id = self._getId(sch);
969     var baseId = baseIds[parentJsonPtr];
970     var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
971     if (keyIndex !== undefined)
972       fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
974     if (typeof id == 'string') {
975       id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
977       var refVal = self._refs[id];
978       if (typeof refVal == 'string') refVal = self._refs[refVal];
979       if (refVal && refVal.schema) {
980         if (!equal(sch, refVal.schema))
981           throw new Error('id "' + id + '" resolves to more than one schema');
982       } else if (id != normalizeId(fullPath)) {
983         if (id[0] == '#') {
984           if (localRefs[id] && !equal(sch, localRefs[id]))
985             throw new Error('id "' + id + '" resolves to more than one schema');
986           localRefs[id] = sch;
987         } else {
988           self._refs[id] = fullPath;
989         }
990       }
991     }
992     baseIds[jsonPtr] = baseId;
993     fullPaths[jsonPtr] = fullPath;
994   });
996   return localRefs;
999 },{"./schema_obj":8,"./util":10,"fast-deep-equal":42,"json-schema-traverse":44,"uri-js":45}],7:[function(require,module,exports){
1000 'use strict';
1002 var ruleModules = require('../dotjs')
1003   , toHash = require('./util').toHash;
1005 module.exports = function rules() {
1006   var RULES = [
1007     { type: 'number',
1008       rules: [ { 'maximum': ['exclusiveMaximum'] },
1009                { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
1010     { type: 'string',
1011       rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
1012     { type: 'array',
1013       rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
1014     { type: 'object',
1015       rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
1016                { 'properties': ['additionalProperties', 'patternProperties'] } ] },
1017     { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
1018   ];
1020   var ALL = [ 'type', '$comment' ];
1021   var KEYWORDS = [
1022     '$schema', '$id', 'id', '$data', '$async', 'title',
1023     'description', 'default', 'definitions',
1024     'examples', 'readOnly', 'writeOnly',
1025     'contentMediaType', 'contentEncoding',
1026     'additionalItems', 'then', 'else'
1027   ];
1028   var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
1029   RULES.all = toHash(ALL);
1030   RULES.types = toHash(TYPES);
1032   RULES.forEach(function (group) {
1033     group.rules = group.rules.map(function (keyword) {
1034       var implKeywords;
1035       if (typeof keyword == 'object') {
1036         var key = Object.keys(keyword)[0];
1037         implKeywords = keyword[key];
1038         keyword = key;
1039         implKeywords.forEach(function (k) {
1040           ALL.push(k);
1041           RULES.all[k] = true;
1042         });
1043       }
1044       ALL.push(keyword);
1045       var rule = RULES.all[keyword] = {
1046         keyword: keyword,
1047         code: ruleModules[keyword],
1048         implements: implKeywords
1049       };
1050       return rule;
1051     });
1053     RULES.all.$comment = {
1054       keyword: '$comment',
1055       code: ruleModules.$comment
1056     };
1058     if (group.type) RULES.types[group.type] = group;
1059   });
1061   RULES.keywords = toHash(ALL.concat(KEYWORDS));
1062   RULES.custom = {};
1064   return RULES;
1067 },{"../dotjs":27,"./util":10}],8:[function(require,module,exports){
1068 'use strict';
1070 var util = require('./util');
1072 module.exports = SchemaObject;
1074 function SchemaObject(obj) {
1075   util.copy(obj, this);
1078 },{"./util":10}],9:[function(require,module,exports){
1079 'use strict';
1081 // https://mathiasbynens.be/notes/javascript-encoding
1082 // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
1083 module.exports = function ucs2length(str) {
1084   var length = 0
1085     , len = str.length
1086     , pos = 0
1087     , value;
1088   while (pos < len) {
1089     length++;
1090     value = str.charCodeAt(pos++);
1091     if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
1092       // high surrogate, and there is a next character
1093       value = str.charCodeAt(pos);
1094       if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
1095     }
1096   }
1097   return length;
1100 },{}],10:[function(require,module,exports){
1101 'use strict';
1104 module.exports = {
1105   copy: copy,
1106   checkDataType: checkDataType,
1107   checkDataTypes: checkDataTypes,
1108   coerceToTypes: coerceToTypes,
1109   toHash: toHash,
1110   getProperty: getProperty,
1111   escapeQuotes: escapeQuotes,
1112   equal: require('fast-deep-equal'),
1113   ucs2length: require('./ucs2length'),
1114   varOccurences: varOccurences,
1115   varReplace: varReplace,
1116   schemaHasRules: schemaHasRules,
1117   schemaHasRulesExcept: schemaHasRulesExcept,
1118   schemaUnknownRules: schemaUnknownRules,
1119   toQuotedString: toQuotedString,
1120   getPathExpr: getPathExpr,
1121   getPath: getPath,
1122   getData: getData,
1123   unescapeFragment: unescapeFragment,
1124   unescapeJsonPointer: unescapeJsonPointer,
1125   escapeFragment: escapeFragment,
1126   escapeJsonPointer: escapeJsonPointer
1130 function copy(o, to) {
1131   to = to || {};
1132   for (var key in o) to[key] = o[key];
1133   return to;
1137 function checkDataType(dataType, data, strictNumbers, negate) {
1138   var EQUAL = negate ? ' !== ' : ' === '
1139     , AND = negate ? ' || ' : ' && '
1140     , OK = negate ? '!' : ''
1141     , NOT = negate ? '' : '!';
1142   switch (dataType) {
1143     case 'null': return data + EQUAL + 'null';
1144     case 'array': return OK + 'Array.isArray(' + data + ')';
1145     case 'object': return '(' + OK + data + AND +
1146                           'typeof ' + data + EQUAL + '"object"' + AND +
1147                           NOT + 'Array.isArray(' + data + '))';
1148     case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
1149                            NOT + '(' + data + ' % 1)' +
1150                            AND + data + EQUAL + data +
1151                            (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
1152     case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
1153                           (strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
1154     default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
1155   }
1159 function checkDataTypes(dataTypes, data, strictNumbers) {
1160   switch (dataTypes.length) {
1161     case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
1162     default:
1163       var code = '';
1164       var types = toHash(dataTypes);
1165       if (types.array && types.object) {
1166         code = types.null ? '(': '(!' + data + ' || ';
1167         code += 'typeof ' + data + ' !== "object")';
1168         delete types.null;
1169         delete types.array;
1170         delete types.object;
1171       }
1172       if (types.number) delete types.integer;
1173       for (var t in types)
1174         code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
1176       return code;
1177   }
1181 var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
1182 function coerceToTypes(optionCoerceTypes, dataTypes) {
1183   if (Array.isArray(dataTypes)) {
1184     var types = [];
1185     for (var i=0; i<dataTypes.length; i++) {
1186       var t = dataTypes[i];
1187       if (COERCE_TO_TYPES[t]) types[types.length] = t;
1188       else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
1189     }
1190     if (types.length) return types;
1191   } else if (COERCE_TO_TYPES[dataTypes]) {
1192     return [dataTypes];
1193   } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
1194     return ['array'];
1195   }
1199 function toHash(arr) {
1200   var hash = {};
1201   for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
1202   return hash;
1206 var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
1207 var SINGLE_QUOTE = /'|\\/g;
1208 function getProperty(key) {
1209   return typeof key == 'number'
1210           ? '[' + key + ']'
1211           : IDENTIFIER.test(key)
1212             ? '.' + key
1213             : "['" + escapeQuotes(key) + "']";
1217 function escapeQuotes(str) {
1218   return str.replace(SINGLE_QUOTE, '\\$&')
1219             .replace(/\n/g, '\\n')
1220             .replace(/\r/g, '\\r')
1221             .replace(/\f/g, '\\f')
1222             .replace(/\t/g, '\\t');
1226 function varOccurences(str, dataVar) {
1227   dataVar += '[^0-9]';
1228   var matches = str.match(new RegExp(dataVar, 'g'));
1229   return matches ? matches.length : 0;
1233 function varReplace(str, dataVar, expr) {
1234   dataVar += '([^0-9])';
1235   expr = expr.replace(/\$/g, '$$$$');
1236   return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
1240 function schemaHasRules(schema, rules) {
1241   if (typeof schema == 'boolean') return !schema;
1242   for (var key in schema) if (rules[key]) return true;
1246 function schemaHasRulesExcept(schema, rules, exceptKeyword) {
1247   if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
1248   for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
1252 function schemaUnknownRules(schema, rules) {
1253   if (typeof schema == 'boolean') return;
1254   for (var key in schema) if (!rules[key]) return key;
1258 function toQuotedString(str) {
1259   return '\'' + escapeQuotes(str) + '\'';
1263 function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
1264   var path = jsonPointers // false by default
1265               ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
1266               : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
1267   return joinPaths(currentPath, path);
1271 function getPath(currentPath, prop, jsonPointers) {
1272   var path = jsonPointers // false by default
1273               ? toQuotedString('/' + escapeJsonPointer(prop))
1274               : toQuotedString(getProperty(prop));
1275   return joinPaths(currentPath, path);
1279 var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
1280 var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
1281 function getData($data, lvl, paths) {
1282   var up, jsonPointer, data, matches;
1283   if ($data === '') return 'rootData';
1284   if ($data[0] == '/') {
1285     if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
1286     jsonPointer = $data;
1287     data = 'rootData';
1288   } else {
1289     matches = $data.match(RELATIVE_JSON_POINTER);
1290     if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
1291     up = +matches[1];
1292     jsonPointer = matches[2];
1293     if (jsonPointer == '#') {
1294       if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
1295       return paths[lvl - up];
1296     }
1298     if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
1299     data = 'data' + ((lvl - up) || '');
1300     if (!jsonPointer) return data;
1301   }
1303   var expr = data;
1304   var segments = jsonPointer.split('/');
1305   for (var i=0; i<segments.length; i++) {
1306     var segment = segments[i];
1307     if (segment) {
1308       data += getProperty(unescapeJsonPointer(segment));
1309       expr += ' && ' + data;
1310     }
1311   }
1312   return expr;
1316 function joinPaths (a, b) {
1317   if (a == '""') return b;
1318   return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
1322 function unescapeFragment(str) {
1323   return unescapeJsonPointer(decodeURIComponent(str));
1327 function escapeFragment(str) {
1328   return encodeURIComponent(escapeJsonPointer(str));
1332 function escapeJsonPointer(str) {
1333   return str.replace(/~/g, '~0').replace(/\//g, '~1');
1337 function unescapeJsonPointer(str) {
1338   return str.replace(/~1/g, '/').replace(/~0/g, '~');
1341 },{"./ucs2length":9,"fast-deep-equal":42}],11:[function(require,module,exports){
1342 'use strict';
1344 var KEYWORDS = [
1345   'multipleOf',
1346   'maximum',
1347   'exclusiveMaximum',
1348   'minimum',
1349   'exclusiveMinimum',
1350   'maxLength',
1351   'minLength',
1352   'pattern',
1353   'additionalItems',
1354   'maxItems',
1355   'minItems',
1356   'uniqueItems',
1357   'maxProperties',
1358   'minProperties',
1359   'required',
1360   'additionalProperties',
1361   'enum',
1362   'format',
1363   'const'
1366 module.exports = function (metaSchema, keywordsJsonPointers) {
1367   for (var i=0; i<keywordsJsonPointers.length; i++) {
1368     metaSchema = JSON.parse(JSON.stringify(metaSchema));
1369     var segments = keywordsJsonPointers[i].split('/');
1370     var keywords = metaSchema;
1371     var j;
1372     for (j=1; j<segments.length; j++)
1373       keywords = keywords[segments[j]];
1375     for (j=0; j<KEYWORDS.length; j++) {
1376       var key = KEYWORDS[j];
1377       var schema = keywords[key];
1378       if (schema) {
1379         keywords[key] = {
1380           anyOf: [
1381             schema,
1382             { $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
1383           ]
1384         };
1385       }
1386     }
1387   }
1389   return metaSchema;
1392 },{}],12:[function(require,module,exports){
1393 'use strict';
1395 var metaSchema = require('./refs/json-schema-draft-07.json');
1397 module.exports = {
1398   $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
1399   definitions: {
1400     simpleTypes: metaSchema.definitions.simpleTypes
1401   },
1402   type: 'object',
1403   dependencies: {
1404     schema: ['validate'],
1405     $data: ['validate'],
1406     statements: ['inline'],
1407     valid: {not: {required: ['macro']}}
1408   },
1409   properties: {
1410     type: metaSchema.properties.type,
1411     schema: {type: 'boolean'},
1412     statements: {type: 'boolean'},
1413     dependencies: {
1414       type: 'array',
1415       items: {type: 'string'}
1416     },
1417     metaSchema: {type: 'object'},
1418     modifying: {type: 'boolean'},
1419     valid: {type: 'boolean'},
1420     $data: {type: 'boolean'},
1421     async: {type: 'boolean'},
1422     errors: {
1423       anyOf: [
1424         {type: 'boolean'},
1425         {const: 'full'}
1426       ]
1427     }
1428   }
1431 },{"./refs/json-schema-draft-07.json":41}],13:[function(require,module,exports){
1432 'use strict';
1433 module.exports = function generate__limit(it, $keyword, $ruleType) {
1434   var out = ' ';
1435   var $lvl = it.level;
1436   var $dataLvl = it.dataLevel;
1437   var $schema = it.schema[$keyword];
1438   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1439   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1440   var $breakOnError = !it.opts.allErrors;
1441   var $errorKeyword;
1442   var $data = 'data' + ($dataLvl || '');
1443   var $isData = it.opts.$data && $schema && $schema.$data,
1444     $schemaValue;
1445   if ($isData) {
1446     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1447     $schemaValue = 'schema' + $lvl;
1448   } else {
1449     $schemaValue = $schema;
1450   }
1451   var $isMax = $keyword == 'maximum',
1452     $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
1453     $schemaExcl = it.schema[$exclusiveKeyword],
1454     $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
1455     $op = $isMax ? '<' : '>',
1456     $notOp = $isMax ? '>' : '<',
1457     $errorKeyword = undefined;
1458   if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
1459     throw new Error($keyword + ' must be number');
1460   }
1461   if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
1462     throw new Error($exclusiveKeyword + ' must be number or boolean');
1463   }
1464   if ($isDataExcl) {
1465     var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
1466       $exclusive = 'exclusive' + $lvl,
1467       $exclType = 'exclType' + $lvl,
1468       $exclIsNumber = 'exclIsNumber' + $lvl,
1469       $opExpr = 'op' + $lvl,
1470       $opStr = '\' + ' + $opExpr + ' + \'';
1471     out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
1472     $schemaValueExcl = 'schemaExcl' + $lvl;
1473     out += ' var ' + ($exclusive) + '; var ' + ($exclType) + ' = typeof ' + ($schemaValueExcl) + '; if (' + ($exclType) + ' != \'boolean\' && ' + ($exclType) + ' != \'undefined\' && ' + ($exclType) + ' != \'number\') { ';
1474     var $errorKeyword = $exclusiveKeyword;
1475     var $$outStack = $$outStack || [];
1476     $$outStack.push(out);
1477     out = ''; /* istanbul ignore else */
1478     if (it.createErrors !== false) {
1479       out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
1480       if (it.opts.messages !== false) {
1481         out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
1482       }
1483       if (it.opts.verbose) {
1484         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1485       }
1486       out += ' } ';
1487     } else {
1488       out += ' {} ';
1489     }
1490     var __err = out;
1491     out = $$outStack.pop();
1492     if (!it.compositeRule && $breakOnError) {
1493       /* istanbul ignore if */
1494       if (it.async) {
1495         out += ' throw new ValidationError([' + (__err) + ']); ';
1496       } else {
1497         out += ' validate.errors = [' + (__err) + ']; return false; ';
1498       }
1499     } else {
1500       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1501     }
1502     out += ' } else if ( ';
1503     if ($isData) {
1504       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1505     }
1506     out += ' ' + ($exclType) + ' == \'number\' ? ( (' + ($exclusive) + ' = ' + ($schemaValue) + ' === undefined || ' + ($schemaValueExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ') ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValueExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) : ( (' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\'; ';
1507     if ($schema === undefined) {
1508       $errorKeyword = $exclusiveKeyword;
1509       $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
1510       $schemaValue = $schemaValueExcl;
1511       $isData = $isDataExcl;
1512     }
1513   } else {
1514     var $exclIsNumber = typeof $schemaExcl == 'number',
1515       $opStr = $op;
1516     if ($exclIsNumber && $isData) {
1517       var $opExpr = '\'' + $opStr + '\'';
1518       out += ' if ( ';
1519       if ($isData) {
1520         out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1521       }
1522       out += ' ( ' + ($schemaValue) + ' === undefined || ' + ($schemaExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ' ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { ';
1523     } else {
1524       if ($exclIsNumber && $schema === undefined) {
1525         $exclusive = true;
1526         $errorKeyword = $exclusiveKeyword;
1527         $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
1528         $schemaValue = $schemaExcl;
1529         $notOp += '=';
1530       } else {
1531         if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
1532         if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
1533           $exclusive = true;
1534           $errorKeyword = $exclusiveKeyword;
1535           $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
1536           $notOp += '=';
1537         } else {
1538           $exclusive = false;
1539           $opStr += '=';
1540         }
1541       }
1542       var $opExpr = '\'' + $opStr + '\'';
1543       out += ' if ( ';
1544       if ($isData) {
1545         out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1546       }
1547       out += ' ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') { ';
1548     }
1549   }
1550   $errorKeyword = $errorKeyword || $keyword;
1551   var $$outStack = $$outStack || [];
1552   $$outStack.push(out);
1553   out = ''; /* istanbul ignore else */
1554   if (it.createErrors !== false) {
1555     out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ' + ($schemaValue) + ', exclusive: ' + ($exclusive) + ' } ';
1556     if (it.opts.messages !== false) {
1557       out += ' , message: \'should be ' + ($opStr) + ' ';
1558       if ($isData) {
1559         out += '\' + ' + ($schemaValue);
1560       } else {
1561         out += '' + ($schemaValue) + '\'';
1562       }
1563     }
1564     if (it.opts.verbose) {
1565       out += ' , schema:  ';
1566       if ($isData) {
1567         out += 'validate.schema' + ($schemaPath);
1568       } else {
1569         out += '' + ($schema);
1570       }
1571       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1572     }
1573     out += ' } ';
1574   } else {
1575     out += ' {} ';
1576   }
1577   var __err = out;
1578   out = $$outStack.pop();
1579   if (!it.compositeRule && $breakOnError) {
1580     /* istanbul ignore if */
1581     if (it.async) {
1582       out += ' throw new ValidationError([' + (__err) + ']); ';
1583     } else {
1584       out += ' validate.errors = [' + (__err) + ']; return false; ';
1585     }
1586   } else {
1587     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1588   }
1589   out += ' } ';
1590   if ($breakOnError) {
1591     out += ' else { ';
1592   }
1593   return out;
1596 },{}],14:[function(require,module,exports){
1597 'use strict';
1598 module.exports = function generate__limitItems(it, $keyword, $ruleType) {
1599   var out = ' ';
1600   var $lvl = it.level;
1601   var $dataLvl = it.dataLevel;
1602   var $schema = it.schema[$keyword];
1603   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1604   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1605   var $breakOnError = !it.opts.allErrors;
1606   var $errorKeyword;
1607   var $data = 'data' + ($dataLvl || '');
1608   var $isData = it.opts.$data && $schema && $schema.$data,
1609     $schemaValue;
1610   if ($isData) {
1611     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1612     $schemaValue = 'schema' + $lvl;
1613   } else {
1614     $schemaValue = $schema;
1615   }
1616   if (!($isData || typeof $schema == 'number')) {
1617     throw new Error($keyword + ' must be number');
1618   }
1619   var $op = $keyword == 'maxItems' ? '>' : '<';
1620   out += 'if ( ';
1621   if ($isData) {
1622     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1623   }
1624   out += ' ' + ($data) + '.length ' + ($op) + ' ' + ($schemaValue) + ') { ';
1625   var $errorKeyword = $keyword;
1626   var $$outStack = $$outStack || [];
1627   $$outStack.push(out);
1628   out = ''; /* istanbul ignore else */
1629   if (it.createErrors !== false) {
1630     out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
1631     if (it.opts.messages !== false) {
1632       out += ' , message: \'should NOT have ';
1633       if ($keyword == 'maxItems') {
1634         out += 'more';
1635       } else {
1636         out += 'fewer';
1637       }
1638       out += ' than ';
1639       if ($isData) {
1640         out += '\' + ' + ($schemaValue) + ' + \'';
1641       } else {
1642         out += '' + ($schema);
1643       }
1644       out += ' items\' ';
1645     }
1646     if (it.opts.verbose) {
1647       out += ' , schema:  ';
1648       if ($isData) {
1649         out += 'validate.schema' + ($schemaPath);
1650       } else {
1651         out += '' + ($schema);
1652       }
1653       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1654     }
1655     out += ' } ';
1656   } else {
1657     out += ' {} ';
1658   }
1659   var __err = out;
1660   out = $$outStack.pop();
1661   if (!it.compositeRule && $breakOnError) {
1662     /* istanbul ignore if */
1663     if (it.async) {
1664       out += ' throw new ValidationError([' + (__err) + ']); ';
1665     } else {
1666       out += ' validate.errors = [' + (__err) + ']; return false; ';
1667     }
1668   } else {
1669     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1670   }
1671   out += '} ';
1672   if ($breakOnError) {
1673     out += ' else { ';
1674   }
1675   return out;
1678 },{}],15:[function(require,module,exports){
1679 'use strict';
1680 module.exports = function generate__limitLength(it, $keyword, $ruleType) {
1681   var out = ' ';
1682   var $lvl = it.level;
1683   var $dataLvl = it.dataLevel;
1684   var $schema = it.schema[$keyword];
1685   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1686   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1687   var $breakOnError = !it.opts.allErrors;
1688   var $errorKeyword;
1689   var $data = 'data' + ($dataLvl || '');
1690   var $isData = it.opts.$data && $schema && $schema.$data,
1691     $schemaValue;
1692   if ($isData) {
1693     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1694     $schemaValue = 'schema' + $lvl;
1695   } else {
1696     $schemaValue = $schema;
1697   }
1698   if (!($isData || typeof $schema == 'number')) {
1699     throw new Error($keyword + ' must be number');
1700   }
1701   var $op = $keyword == 'maxLength' ? '>' : '<';
1702   out += 'if ( ';
1703   if ($isData) {
1704     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1705   }
1706   if (it.opts.unicode === false) {
1707     out += ' ' + ($data) + '.length ';
1708   } else {
1709     out += ' ucs2length(' + ($data) + ') ';
1710   }
1711   out += ' ' + ($op) + ' ' + ($schemaValue) + ') { ';
1712   var $errorKeyword = $keyword;
1713   var $$outStack = $$outStack || [];
1714   $$outStack.push(out);
1715   out = ''; /* istanbul ignore else */
1716   if (it.createErrors !== false) {
1717     out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
1718     if (it.opts.messages !== false) {
1719       out += ' , message: \'should NOT be ';
1720       if ($keyword == 'maxLength') {
1721         out += 'longer';
1722       } else {
1723         out += 'shorter';
1724       }
1725       out += ' than ';
1726       if ($isData) {
1727         out += '\' + ' + ($schemaValue) + ' + \'';
1728       } else {
1729         out += '' + ($schema);
1730       }
1731       out += ' characters\' ';
1732     }
1733     if (it.opts.verbose) {
1734       out += ' , schema:  ';
1735       if ($isData) {
1736         out += 'validate.schema' + ($schemaPath);
1737       } else {
1738         out += '' + ($schema);
1739       }
1740       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1741     }
1742     out += ' } ';
1743   } else {
1744     out += ' {} ';
1745   }
1746   var __err = out;
1747   out = $$outStack.pop();
1748   if (!it.compositeRule && $breakOnError) {
1749     /* istanbul ignore if */
1750     if (it.async) {
1751       out += ' throw new ValidationError([' + (__err) + ']); ';
1752     } else {
1753       out += ' validate.errors = [' + (__err) + ']; return false; ';
1754     }
1755   } else {
1756     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1757   }
1758   out += '} ';
1759   if ($breakOnError) {
1760     out += ' else { ';
1761   }
1762   return out;
1765 },{}],16:[function(require,module,exports){
1766 'use strict';
1767 module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
1768   var out = ' ';
1769   var $lvl = it.level;
1770   var $dataLvl = it.dataLevel;
1771   var $schema = it.schema[$keyword];
1772   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1773   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1774   var $breakOnError = !it.opts.allErrors;
1775   var $errorKeyword;
1776   var $data = 'data' + ($dataLvl || '');
1777   var $isData = it.opts.$data && $schema && $schema.$data,
1778     $schemaValue;
1779   if ($isData) {
1780     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1781     $schemaValue = 'schema' + $lvl;
1782   } else {
1783     $schemaValue = $schema;
1784   }
1785   if (!($isData || typeof $schema == 'number')) {
1786     throw new Error($keyword + ' must be number');
1787   }
1788   var $op = $keyword == 'maxProperties' ? '>' : '<';
1789   out += 'if ( ';
1790   if ($isData) {
1791     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
1792   }
1793   out += ' Object.keys(' + ($data) + ').length ' + ($op) + ' ' + ($schemaValue) + ') { ';
1794   var $errorKeyword = $keyword;
1795   var $$outStack = $$outStack || [];
1796   $$outStack.push(out);
1797   out = ''; /* istanbul ignore else */
1798   if (it.createErrors !== false) {
1799     out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schemaValue) + ' } ';
1800     if (it.opts.messages !== false) {
1801       out += ' , message: \'should NOT have ';
1802       if ($keyword == 'maxProperties') {
1803         out += 'more';
1804       } else {
1805         out += 'fewer';
1806       }
1807       out += ' than ';
1808       if ($isData) {
1809         out += '\' + ' + ($schemaValue) + ' + \'';
1810       } else {
1811         out += '' + ($schema);
1812       }
1813       out += ' properties\' ';
1814     }
1815     if (it.opts.verbose) {
1816       out += ' , schema:  ';
1817       if ($isData) {
1818         out += 'validate.schema' + ($schemaPath);
1819       } else {
1820         out += '' + ($schema);
1821       }
1822       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1823     }
1824     out += ' } ';
1825   } else {
1826     out += ' {} ';
1827   }
1828   var __err = out;
1829   out = $$outStack.pop();
1830   if (!it.compositeRule && $breakOnError) {
1831     /* istanbul ignore if */
1832     if (it.async) {
1833       out += ' throw new ValidationError([' + (__err) + ']); ';
1834     } else {
1835       out += ' validate.errors = [' + (__err) + ']; return false; ';
1836     }
1837   } else {
1838     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1839   }
1840   out += '} ';
1841   if ($breakOnError) {
1842     out += ' else { ';
1843   }
1844   return out;
1847 },{}],17:[function(require,module,exports){
1848 'use strict';
1849 module.exports = function generate_allOf(it, $keyword, $ruleType) {
1850   var out = ' ';
1851   var $schema = it.schema[$keyword];
1852   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1853   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1854   var $breakOnError = !it.opts.allErrors;
1855   var $it = it.util.copy(it);
1856   var $closingBraces = '';
1857   $it.level++;
1858   var $nextValid = 'valid' + $it.level;
1859   var $currentBaseId = $it.baseId,
1860     $allSchemasEmpty = true;
1861   var arr1 = $schema;
1862   if (arr1) {
1863     var $sch, $i = -1,
1864       l1 = arr1.length - 1;
1865     while ($i < l1) {
1866       $sch = arr1[$i += 1];
1867       if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
1868         $allSchemasEmpty = false;
1869         $it.schema = $sch;
1870         $it.schemaPath = $schemaPath + '[' + $i + ']';
1871         $it.errSchemaPath = $errSchemaPath + '/' + $i;
1872         out += '  ' + (it.validate($it)) + ' ';
1873         $it.baseId = $currentBaseId;
1874         if ($breakOnError) {
1875           out += ' if (' + ($nextValid) + ') { ';
1876           $closingBraces += '}';
1877         }
1878       }
1879     }
1880   }
1881   if ($breakOnError) {
1882     if ($allSchemasEmpty) {
1883       out += ' if (true) { ';
1884     } else {
1885       out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
1886     }
1887   }
1888   return out;
1891 },{}],18:[function(require,module,exports){
1892 'use strict';
1893 module.exports = function generate_anyOf(it, $keyword, $ruleType) {
1894   var out = ' ';
1895   var $lvl = it.level;
1896   var $dataLvl = it.dataLevel;
1897   var $schema = it.schema[$keyword];
1898   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1899   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1900   var $breakOnError = !it.opts.allErrors;
1901   var $data = 'data' + ($dataLvl || '');
1902   var $valid = 'valid' + $lvl;
1903   var $errs = 'errs__' + $lvl;
1904   var $it = it.util.copy(it);
1905   var $closingBraces = '';
1906   $it.level++;
1907   var $nextValid = 'valid' + $it.level;
1908   var $noEmptySchema = $schema.every(function($sch) {
1909     return (it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all));
1910   });
1911   if ($noEmptySchema) {
1912     var $currentBaseId = $it.baseId;
1913     out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = false;  ';
1914     var $wasComposite = it.compositeRule;
1915     it.compositeRule = $it.compositeRule = true;
1916     var arr1 = $schema;
1917     if (arr1) {
1918       var $sch, $i = -1,
1919         l1 = arr1.length - 1;
1920       while ($i < l1) {
1921         $sch = arr1[$i += 1];
1922         $it.schema = $sch;
1923         $it.schemaPath = $schemaPath + '[' + $i + ']';
1924         $it.errSchemaPath = $errSchemaPath + '/' + $i;
1925         out += '  ' + (it.validate($it)) + ' ';
1926         $it.baseId = $currentBaseId;
1927         out += ' ' + ($valid) + ' = ' + ($valid) + ' || ' + ($nextValid) + '; if (!' + ($valid) + ') { ';
1928         $closingBraces += '}';
1929       }
1930     }
1931     it.compositeRule = $it.compositeRule = $wasComposite;
1932     out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */
1933     if (it.createErrors !== false) {
1934       out += ' { keyword: \'' + ('anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
1935       if (it.opts.messages !== false) {
1936         out += ' , message: \'should match some schema in anyOf\' ';
1937       }
1938       if (it.opts.verbose) {
1939         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
1940       }
1941       out += ' } ';
1942     } else {
1943       out += ' {} ';
1944     }
1945     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
1946     if (!it.compositeRule && $breakOnError) {
1947       /* istanbul ignore if */
1948       if (it.async) {
1949         out += ' throw new ValidationError(vErrors); ';
1950       } else {
1951         out += ' validate.errors = vErrors; return false; ';
1952       }
1953     }
1954     out += ' } else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
1955     if (it.opts.allErrors) {
1956       out += ' } ';
1957     }
1958   } else {
1959     if ($breakOnError) {
1960       out += ' if (true) { ';
1961     }
1962   }
1963   return out;
1966 },{}],19:[function(require,module,exports){
1967 'use strict';
1968 module.exports = function generate_comment(it, $keyword, $ruleType) {
1969   var out = ' ';
1970   var $schema = it.schema[$keyword];
1971   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1972   var $breakOnError = !it.opts.allErrors;
1973   var $comment = it.util.toQuotedString($schema);
1974   if (it.opts.$comment === true) {
1975     out += ' console.log(' + ($comment) + ');';
1976   } else if (typeof it.opts.$comment == 'function') {
1977     out += ' self._opts.$comment(' + ($comment) + ', ' + (it.util.toQuotedString($errSchemaPath)) + ', validate.root.schema);';
1978   }
1979   return out;
1982 },{}],20:[function(require,module,exports){
1983 'use strict';
1984 module.exports = function generate_const(it, $keyword, $ruleType) {
1985   var out = ' ';
1986   var $lvl = it.level;
1987   var $dataLvl = it.dataLevel;
1988   var $schema = it.schema[$keyword];
1989   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
1990   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
1991   var $breakOnError = !it.opts.allErrors;
1992   var $data = 'data' + ($dataLvl || '');
1993   var $valid = 'valid' + $lvl;
1994   var $isData = it.opts.$data && $schema && $schema.$data,
1995     $schemaValue;
1996   if ($isData) {
1997     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
1998     $schemaValue = 'schema' + $lvl;
1999   } else {
2000     $schemaValue = $schema;
2001   }
2002   if (!$isData) {
2003     out += ' var schema' + ($lvl) + ' = validate.schema' + ($schemaPath) + ';';
2004   }
2005   out += 'var ' + ($valid) + ' = equal(' + ($data) + ', schema' + ($lvl) + '); if (!' + ($valid) + ') {   ';
2006   var $$outStack = $$outStack || [];
2007   $$outStack.push(out);
2008   out = ''; /* istanbul ignore else */
2009   if (it.createErrors !== false) {
2010     out += ' { keyword: \'' + ('const') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValue: schema' + ($lvl) + ' } ';
2011     if (it.opts.messages !== false) {
2012       out += ' , message: \'should be equal to constant\' ';
2013     }
2014     if (it.opts.verbose) {
2015       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2016     }
2017     out += ' } ';
2018   } else {
2019     out += ' {} ';
2020   }
2021   var __err = out;
2022   out = $$outStack.pop();
2023   if (!it.compositeRule && $breakOnError) {
2024     /* istanbul ignore if */
2025     if (it.async) {
2026       out += ' throw new ValidationError([' + (__err) + ']); ';
2027     } else {
2028       out += ' validate.errors = [' + (__err) + ']; return false; ';
2029     }
2030   } else {
2031     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2032   }
2033   out += ' }';
2034   if ($breakOnError) {
2035     out += ' else { ';
2036   }
2037   return out;
2040 },{}],21:[function(require,module,exports){
2041 'use strict';
2042 module.exports = function generate_contains(it, $keyword, $ruleType) {
2043   var out = ' ';
2044   var $lvl = it.level;
2045   var $dataLvl = it.dataLevel;
2046   var $schema = it.schema[$keyword];
2047   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2048   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2049   var $breakOnError = !it.opts.allErrors;
2050   var $data = 'data' + ($dataLvl || '');
2051   var $valid = 'valid' + $lvl;
2052   var $errs = 'errs__' + $lvl;
2053   var $it = it.util.copy(it);
2054   var $closingBraces = '';
2055   $it.level++;
2056   var $nextValid = 'valid' + $it.level;
2057   var $idx = 'i' + $lvl,
2058     $dataNxt = $it.dataLevel = it.dataLevel + 1,
2059     $nextData = 'data' + $dataNxt,
2060     $currentBaseId = it.baseId,
2061     $nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all));
2062   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
2063   if ($nonEmptySchema) {
2064     var $wasComposite = it.compositeRule;
2065     it.compositeRule = $it.compositeRule = true;
2066     $it.schema = $schema;
2067     $it.schemaPath = $schemaPath;
2068     $it.errSchemaPath = $errSchemaPath;
2069     out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
2070     $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
2071     var $passData = $data + '[' + $idx + ']';
2072     $it.dataPathArr[$dataNxt] = $idx;
2073     var $code = it.validate($it);
2074     $it.baseId = $currentBaseId;
2075     if (it.util.varOccurences($code, $nextData) < 2) {
2076       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
2077     } else {
2078       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
2079     }
2080     out += ' if (' + ($nextValid) + ') break; }  ';
2081     it.compositeRule = $it.compositeRule = $wasComposite;
2082     out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {';
2083   } else {
2084     out += ' if (' + ($data) + '.length == 0) {';
2085   }
2086   var $$outStack = $$outStack || [];
2087   $$outStack.push(out);
2088   out = ''; /* istanbul ignore else */
2089   if (it.createErrors !== false) {
2090     out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
2091     if (it.opts.messages !== false) {
2092       out += ' , message: \'should contain a valid item\' ';
2093     }
2094     if (it.opts.verbose) {
2095       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2096     }
2097     out += ' } ';
2098   } else {
2099     out += ' {} ';
2100   }
2101   var __err = out;
2102   out = $$outStack.pop();
2103   if (!it.compositeRule && $breakOnError) {
2104     /* istanbul ignore if */
2105     if (it.async) {
2106       out += ' throw new ValidationError([' + (__err) + ']); ';
2107     } else {
2108       out += ' validate.errors = [' + (__err) + ']; return false; ';
2109     }
2110   } else {
2111     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2112   }
2113   out += ' } else { ';
2114   if ($nonEmptySchema) {
2115     out += '  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
2116   }
2117   if (it.opts.allErrors) {
2118     out += ' } ';
2119   }
2120   return out;
2123 },{}],22:[function(require,module,exports){
2124 'use strict';
2125 module.exports = function generate_custom(it, $keyword, $ruleType) {
2126   var out = ' ';
2127   var $lvl = it.level;
2128   var $dataLvl = it.dataLevel;
2129   var $schema = it.schema[$keyword];
2130   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2131   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2132   var $breakOnError = !it.opts.allErrors;
2133   var $errorKeyword;
2134   var $data = 'data' + ($dataLvl || '');
2135   var $valid = 'valid' + $lvl;
2136   var $errs = 'errs__' + $lvl;
2137   var $isData = it.opts.$data && $schema && $schema.$data,
2138     $schemaValue;
2139   if ($isData) {
2140     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
2141     $schemaValue = 'schema' + $lvl;
2142   } else {
2143     $schemaValue = $schema;
2144   }
2145   var $rule = this,
2146     $definition = 'definition' + $lvl,
2147     $rDef = $rule.definition,
2148     $closingBraces = '';
2149   var $compile, $inline, $macro, $ruleValidate, $validateCode;
2150   if ($isData && $rDef.$data) {
2151     $validateCode = 'keywordValidate' + $lvl;
2152     var $validateSchema = $rDef.validateSchema;
2153     out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;';
2154   } else {
2155     $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
2156     if (!$ruleValidate) return;
2157     $schemaValue = 'validate.schema' + $schemaPath;
2158     $validateCode = $ruleValidate.code;
2159     $compile = $rDef.compile;
2160     $inline = $rDef.inline;
2161     $macro = $rDef.macro;
2162   }
2163   var $ruleErrs = $validateCode + '.errors',
2164     $i = 'i' + $lvl,
2165     $ruleErr = 'ruleErr' + $lvl,
2166     $asyncKeyword = $rDef.async;
2167   if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
2168   if (!($inline || $macro)) {
2169     out += '' + ($ruleErrs) + ' = null;';
2170   }
2171   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
2172   if ($isData && $rDef.$data) {
2173     $closingBraces += '}';
2174     out += ' if (' + ($schemaValue) + ' === undefined) { ' + ($valid) + ' = true; } else { ';
2175     if ($validateSchema) {
2176       $closingBraces += '}';
2177       out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') { ';
2178     }
2179   }
2180   if ($inline) {
2181     if ($rDef.statements) {
2182       out += ' ' + ($ruleValidate.validate) + ' ';
2183     } else {
2184       out += ' ' + ($valid) + ' = ' + ($ruleValidate.validate) + '; ';
2185     }
2186   } else if ($macro) {
2187     var $it = it.util.copy(it);
2188     var $closingBraces = '';
2189     $it.level++;
2190     var $nextValid = 'valid' + $it.level;
2191     $it.schema = $ruleValidate.validate;
2192     $it.schemaPath = '';
2193     var $wasComposite = it.compositeRule;
2194     it.compositeRule = $it.compositeRule = true;
2195     var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
2196     it.compositeRule = $it.compositeRule = $wasComposite;
2197     out += ' ' + ($code);
2198   } else {
2199     var $$outStack = $$outStack || [];
2200     $$outStack.push(out);
2201     out = '';
2202     out += '  ' + ($validateCode) + '.call( ';
2203     if (it.opts.passContext) {
2204       out += 'this';
2205     } else {
2206       out += 'self';
2207     }
2208     if ($compile || $rDef.schema === false) {
2209       out += ' , ' + ($data) + ' ';
2210     } else {
2211       out += ' , ' + ($schemaValue) + ' , ' + ($data) + ' , validate.schema' + (it.schemaPath) + ' ';
2212     }
2213     out += ' , (dataPath || \'\')';
2214     if (it.errorPath != '""') {
2215       out += ' + ' + (it.errorPath);
2216     }
2217     var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
2218       $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
2219     out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ' , rootData )  ';
2220     var def_callRuleValidate = out;
2221     out = $$outStack.pop();
2222     if ($rDef.errors === false) {
2223       out += ' ' + ($valid) + ' = ';
2224       if ($asyncKeyword) {
2225         out += 'await ';
2226       }
2227       out += '' + (def_callRuleValidate) + '; ';
2228     } else {
2229       if ($asyncKeyword) {
2230         $ruleErrs = 'customErrors' + $lvl;
2231         out += ' var ' + ($ruleErrs) + ' = null; try { ' + ($valid) + ' = await ' + (def_callRuleValidate) + '; } catch (e) { ' + ($valid) + ' = false; if (e instanceof ValidationError) ' + ($ruleErrs) + ' = e.errors; else throw e; } ';
2232       } else {
2233         out += ' ' + ($ruleErrs) + ' = null; ' + ($valid) + ' = ' + (def_callRuleValidate) + '; ';
2234       }
2235     }
2236   }
2237   if ($rDef.modifying) {
2238     out += ' if (' + ($parentData) + ') ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
2239   }
2240   out += '' + ($closingBraces);
2241   if ($rDef.valid) {
2242     if ($breakOnError) {
2243       out += ' if (true) { ';
2244     }
2245   } else {
2246     out += ' if ( ';
2247     if ($rDef.valid === undefined) {
2248       out += ' !';
2249       if ($macro) {
2250         out += '' + ($nextValid);
2251       } else {
2252         out += '' + ($valid);
2253       }
2254     } else {
2255       out += ' ' + (!$rDef.valid) + ' ';
2256     }
2257     out += ') { ';
2258     $errorKeyword = $rule.keyword;
2259     var $$outStack = $$outStack || [];
2260     $$outStack.push(out);
2261     out = '';
2262     var $$outStack = $$outStack || [];
2263     $$outStack.push(out);
2264     out = ''; /* istanbul ignore else */
2265     if (it.createErrors !== false) {
2266       out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
2267       if (it.opts.messages !== false) {
2268         out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
2269       }
2270       if (it.opts.verbose) {
2271         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2272       }
2273       out += ' } ';
2274     } else {
2275       out += ' {} ';
2276     }
2277     var __err = out;
2278     out = $$outStack.pop();
2279     if (!it.compositeRule && $breakOnError) {
2280       /* istanbul ignore if */
2281       if (it.async) {
2282         out += ' throw new ValidationError([' + (__err) + ']); ';
2283       } else {
2284         out += ' validate.errors = [' + (__err) + ']; return false; ';
2285       }
2286     } else {
2287       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2288     }
2289     var def_customError = out;
2290     out = $$outStack.pop();
2291     if ($inline) {
2292       if ($rDef.errors) {
2293         if ($rDef.errors != 'full') {
2294           out += '  for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } ';
2295           if (it.opts.verbose) {
2296             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
2297           }
2298           out += ' } ';
2299         }
2300       } else {
2301         if ($rDef.errors === false) {
2302           out += ' ' + (def_customError) + ' ';
2303         } else {
2304           out += ' if (' + ($errs) + ' == errors) { ' + (def_customError) + ' } else {  for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + '; if (' + ($ruleErr) + '.schemaPath === undefined) { ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '"; } ';
2305           if (it.opts.verbose) {
2306             out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
2307           }
2308           out += ' } } ';
2309         }
2310       }
2311     } else if ($macro) {
2312       out += '   var err =   '; /* istanbul ignore else */
2313       if (it.createErrors !== false) {
2314         out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { keyword: \'' + ($rule.keyword) + '\' } ';
2315         if (it.opts.messages !== false) {
2316           out += ' , message: \'should pass "' + ($rule.keyword) + '" keyword validation\' ';
2317         }
2318         if (it.opts.verbose) {
2319           out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2320         }
2321         out += ' } ';
2322       } else {
2323         out += ' {} ';
2324       }
2325       out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2326       if (!it.compositeRule && $breakOnError) {
2327         /* istanbul ignore if */
2328         if (it.async) {
2329           out += ' throw new ValidationError(vErrors); ';
2330         } else {
2331           out += ' validate.errors = vErrors; return false; ';
2332         }
2333       }
2334     } else {
2335       if ($rDef.errors === false) {
2336         out += ' ' + (def_customError) + ' ';
2337       } else {
2338         out += ' if (Array.isArray(' + ($ruleErrs) + ')) { if (vErrors === null) vErrors = ' + ($ruleErrs) + '; else vErrors = vErrors.concat(' + ($ruleErrs) + '); errors = vErrors.length;  for (var ' + ($i) + '=' + ($errs) + '; ' + ($i) + '<errors; ' + ($i) + '++) { var ' + ($ruleErr) + ' = vErrors[' + ($i) + ']; if (' + ($ruleErr) + '.dataPath === undefined) ' + ($ruleErr) + '.dataPath = (dataPath || \'\') + ' + (it.errorPath) + ';  ' + ($ruleErr) + '.schemaPath = "' + ($errSchemaPath) + '";  ';
2339         if (it.opts.verbose) {
2340           out += ' ' + ($ruleErr) + '.schema = ' + ($schemaValue) + '; ' + ($ruleErr) + '.data = ' + ($data) + '; ';
2341         }
2342         out += ' } } else { ' + (def_customError) + ' } ';
2343       }
2344     }
2345     out += ' } ';
2346     if ($breakOnError) {
2347       out += ' else { ';
2348     }
2349   }
2350   return out;
2353 },{}],23:[function(require,module,exports){
2354 'use strict';
2355 module.exports = function generate_dependencies(it, $keyword, $ruleType) {
2356   var out = ' ';
2357   var $lvl = it.level;
2358   var $dataLvl = it.dataLevel;
2359   var $schema = it.schema[$keyword];
2360   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2361   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2362   var $breakOnError = !it.opts.allErrors;
2363   var $data = 'data' + ($dataLvl || '');
2364   var $errs = 'errs__' + $lvl;
2365   var $it = it.util.copy(it);
2366   var $closingBraces = '';
2367   $it.level++;
2368   var $nextValid = 'valid' + $it.level;
2369   var $schemaDeps = {},
2370     $propertyDeps = {},
2371     $ownProperties = it.opts.ownProperties;
2372   for ($property in $schema) {
2373     if ($property == '__proto__') continue;
2374     var $sch = $schema[$property];
2375     var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
2376     $deps[$property] = $sch;
2377   }
2378   out += 'var ' + ($errs) + ' = errors;';
2379   var $currentErrorPath = it.errorPath;
2380   out += 'var missing' + ($lvl) + ';';
2381   for (var $property in $propertyDeps) {
2382     $deps = $propertyDeps[$property];
2383     if ($deps.length) {
2384       out += ' if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
2385       if ($ownProperties) {
2386         out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
2387       }
2388       if ($breakOnError) {
2389         out += ' && ( ';
2390         var arr1 = $deps;
2391         if (arr1) {
2392           var $propertyKey, $i = -1,
2393             l1 = arr1.length - 1;
2394           while ($i < l1) {
2395             $propertyKey = arr1[$i += 1];
2396             if ($i) {
2397               out += ' || ';
2398             }
2399             var $prop = it.util.getProperty($propertyKey),
2400               $useData = $data + $prop;
2401             out += ' ( ( ' + ($useData) + ' === undefined ';
2402             if ($ownProperties) {
2403               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
2404             }
2405             out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
2406           }
2407         }
2408         out += ')) {  ';
2409         var $propertyPath = 'missing' + $lvl,
2410           $missingProperty = '\' + ' + $propertyPath + ' + \'';
2411         if (it.opts._errorDataPathProperty) {
2412           it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
2413         }
2414         var $$outStack = $$outStack || [];
2415         $$outStack.push(out);
2416         out = ''; /* istanbul ignore else */
2417         if (it.createErrors !== false) {
2418           out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
2419           if (it.opts.messages !== false) {
2420             out += ' , message: \'should have ';
2421             if ($deps.length == 1) {
2422               out += 'property ' + (it.util.escapeQuotes($deps[0]));
2423             } else {
2424               out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
2425             }
2426             out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
2427           }
2428           if (it.opts.verbose) {
2429             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2430           }
2431           out += ' } ';
2432         } else {
2433           out += ' {} ';
2434         }
2435         var __err = out;
2436         out = $$outStack.pop();
2437         if (!it.compositeRule && $breakOnError) {
2438           /* istanbul ignore if */
2439           if (it.async) {
2440             out += ' throw new ValidationError([' + (__err) + ']); ';
2441           } else {
2442             out += ' validate.errors = [' + (__err) + ']; return false; ';
2443           }
2444         } else {
2445           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2446         }
2447       } else {
2448         out += ' ) { ';
2449         var arr2 = $deps;
2450         if (arr2) {
2451           var $propertyKey, i2 = -1,
2452             l2 = arr2.length - 1;
2453           while (i2 < l2) {
2454             $propertyKey = arr2[i2 += 1];
2455             var $prop = it.util.getProperty($propertyKey),
2456               $missingProperty = it.util.escapeQuotes($propertyKey),
2457               $useData = $data + $prop;
2458             if (it.opts._errorDataPathProperty) {
2459               it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
2460             }
2461             out += ' if ( ' + ($useData) + ' === undefined ';
2462             if ($ownProperties) {
2463               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
2464             }
2465             out += ') {  var err =   '; /* istanbul ignore else */
2466             if (it.createErrors !== false) {
2467               out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
2468               if (it.opts.messages !== false) {
2469                 out += ' , message: \'should have ';
2470                 if ($deps.length == 1) {
2471                   out += 'property ' + (it.util.escapeQuotes($deps[0]));
2472                 } else {
2473                   out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
2474                 }
2475                 out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
2476               }
2477               if (it.opts.verbose) {
2478                 out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2479               }
2480               out += ' } ';
2481             } else {
2482               out += ' {} ';
2483             }
2484             out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
2485           }
2486         }
2487       }
2488       out += ' }   ';
2489       if ($breakOnError) {
2490         $closingBraces += '}';
2491         out += ' else { ';
2492       }
2493     }
2494   }
2495   it.errorPath = $currentErrorPath;
2496   var $currentBaseId = $it.baseId;
2497   for (var $property in $schemaDeps) {
2498     var $sch = $schemaDeps[$property];
2499     if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
2500       out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
2501       if ($ownProperties) {
2502         out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
2503       }
2504       out += ') { ';
2505       $it.schema = $sch;
2506       $it.schemaPath = $schemaPath + it.util.getProperty($property);
2507       $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
2508       out += '  ' + (it.validate($it)) + ' ';
2509       $it.baseId = $currentBaseId;
2510       out += ' }  ';
2511       if ($breakOnError) {
2512         out += ' if (' + ($nextValid) + ') { ';
2513         $closingBraces += '}';
2514       }
2515     }
2516   }
2517   if ($breakOnError) {
2518     out += '   ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
2519   }
2520   return out;
2523 },{}],24:[function(require,module,exports){
2524 'use strict';
2525 module.exports = function generate_enum(it, $keyword, $ruleType) {
2526   var out = ' ';
2527   var $lvl = it.level;
2528   var $dataLvl = it.dataLevel;
2529   var $schema = it.schema[$keyword];
2530   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2531   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2532   var $breakOnError = !it.opts.allErrors;
2533   var $data = 'data' + ($dataLvl || '');
2534   var $valid = 'valid' + $lvl;
2535   var $isData = it.opts.$data && $schema && $schema.$data,
2536     $schemaValue;
2537   if ($isData) {
2538     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
2539     $schemaValue = 'schema' + $lvl;
2540   } else {
2541     $schemaValue = $schema;
2542   }
2543   var $i = 'i' + $lvl,
2544     $vSchema = 'schema' + $lvl;
2545   if (!$isData) {
2546     out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + ';';
2547   }
2548   out += 'var ' + ($valid) + ';';
2549   if ($isData) {
2550     out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
2551   }
2552   out += '' + ($valid) + ' = false;for (var ' + ($i) + '=0; ' + ($i) + '<' + ($vSchema) + '.length; ' + ($i) + '++) if (equal(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + '])) { ' + ($valid) + ' = true; break; }';
2553   if ($isData) {
2554     out += '  }  ';
2555   }
2556   out += ' if (!' + ($valid) + ') {   ';
2557   var $$outStack = $$outStack || [];
2558   $$outStack.push(out);
2559   out = ''; /* istanbul ignore else */
2560   if (it.createErrors !== false) {
2561     out += ' { keyword: \'' + ('enum') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { allowedValues: schema' + ($lvl) + ' } ';
2562     if (it.opts.messages !== false) {
2563       out += ' , message: \'should be equal to one of the allowed values\' ';
2564     }
2565     if (it.opts.verbose) {
2566       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2567     }
2568     out += ' } ';
2569   } else {
2570     out += ' {} ';
2571   }
2572   var __err = out;
2573   out = $$outStack.pop();
2574   if (!it.compositeRule && $breakOnError) {
2575     /* istanbul ignore if */
2576     if (it.async) {
2577       out += ' throw new ValidationError([' + (__err) + ']); ';
2578     } else {
2579       out += ' validate.errors = [' + (__err) + ']; return false; ';
2580     }
2581   } else {
2582     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2583   }
2584   out += ' }';
2585   if ($breakOnError) {
2586     out += ' else { ';
2587   }
2588   return out;
2591 },{}],25:[function(require,module,exports){
2592 'use strict';
2593 module.exports = function generate_format(it, $keyword, $ruleType) {
2594   var out = ' ';
2595   var $lvl = it.level;
2596   var $dataLvl = it.dataLevel;
2597   var $schema = it.schema[$keyword];
2598   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2599   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2600   var $breakOnError = !it.opts.allErrors;
2601   var $data = 'data' + ($dataLvl || '');
2602   if (it.opts.format === false) {
2603     if ($breakOnError) {
2604       out += ' if (true) { ';
2605     }
2606     return out;
2607   }
2608   var $isData = it.opts.$data && $schema && $schema.$data,
2609     $schemaValue;
2610   if ($isData) {
2611     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
2612     $schemaValue = 'schema' + $lvl;
2613   } else {
2614     $schemaValue = $schema;
2615   }
2616   var $unknownFormats = it.opts.unknownFormats,
2617     $allowUnknown = Array.isArray($unknownFormats);
2618   if ($isData) {
2619     var $format = 'format' + $lvl,
2620       $isObject = 'isObject' + $lvl,
2621       $formatType = 'formatType' + $lvl;
2622     out += ' var ' + ($format) + ' = formats[' + ($schemaValue) + ']; var ' + ($isObject) + ' = typeof ' + ($format) + ' == \'object\' && !(' + ($format) + ' instanceof RegExp) && ' + ($format) + '.validate; var ' + ($formatType) + ' = ' + ($isObject) + ' && ' + ($format) + '.type || \'string\'; if (' + ($isObject) + ') { ';
2623     if (it.async) {
2624       out += ' var async' + ($lvl) + ' = ' + ($format) + '.async; ';
2625     }
2626     out += ' ' + ($format) + ' = ' + ($format) + '.validate; } if (  ';
2627     if ($isData) {
2628       out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
2629     }
2630     out += ' (';
2631     if ($unknownFormats != 'ignore') {
2632       out += ' (' + ($schemaValue) + ' && !' + ($format) + ' ';
2633       if ($allowUnknown) {
2634         out += ' && self._opts.unknownFormats.indexOf(' + ($schemaValue) + ') == -1 ';
2635       }
2636       out += ') || ';
2637     }
2638     out += ' (' + ($format) + ' && ' + ($formatType) + ' == \'' + ($ruleType) + '\' && !(typeof ' + ($format) + ' == \'function\' ? ';
2639     if (it.async) {
2640       out += ' (async' + ($lvl) + ' ? await ' + ($format) + '(' + ($data) + ') : ' + ($format) + '(' + ($data) + ')) ';
2641     } else {
2642       out += ' ' + ($format) + '(' + ($data) + ') ';
2643     }
2644     out += ' : ' + ($format) + '.test(' + ($data) + '))))) {';
2645   } else {
2646     var $format = it.formats[$schema];
2647     if (!$format) {
2648       if ($unknownFormats == 'ignore') {
2649         it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
2650         if ($breakOnError) {
2651           out += ' if (true) { ';
2652         }
2653         return out;
2654       } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
2655         if ($breakOnError) {
2656           out += ' if (true) { ';
2657         }
2658         return out;
2659       } else {
2660         throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
2661       }
2662     }
2663     var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate;
2664     var $formatType = $isObject && $format.type || 'string';
2665     if ($isObject) {
2666       var $async = $format.async === true;
2667       $format = $format.validate;
2668     }
2669     if ($formatType != $ruleType) {
2670       if ($breakOnError) {
2671         out += ' if (true) { ';
2672       }
2673       return out;
2674     }
2675     if ($async) {
2676       if (!it.async) throw new Error('async format in sync schema');
2677       var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
2678       out += ' if (!(await ' + ($formatRef) + '(' + ($data) + '))) { ';
2679     } else {
2680       out += ' if (! ';
2681       var $formatRef = 'formats' + it.util.getProperty($schema);
2682       if ($isObject) $formatRef += '.validate';
2683       if (typeof $format == 'function') {
2684         out += ' ' + ($formatRef) + '(' + ($data) + ') ';
2685       } else {
2686         out += ' ' + ($formatRef) + '.test(' + ($data) + ') ';
2687       }
2688       out += ') { ';
2689     }
2690   }
2691   var $$outStack = $$outStack || [];
2692   $$outStack.push(out);
2693   out = ''; /* istanbul ignore else */
2694   if (it.createErrors !== false) {
2695     out += ' { keyword: \'' + ('format') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { format:  ';
2696     if ($isData) {
2697       out += '' + ($schemaValue);
2698     } else {
2699       out += '' + (it.util.toQuotedString($schema));
2700     }
2701     out += '  } ';
2702     if (it.opts.messages !== false) {
2703       out += ' , message: \'should match format "';
2704       if ($isData) {
2705         out += '\' + ' + ($schemaValue) + ' + \'';
2706       } else {
2707         out += '' + (it.util.escapeQuotes($schema));
2708       }
2709       out += '"\' ';
2710     }
2711     if (it.opts.verbose) {
2712       out += ' , schema:  ';
2713       if ($isData) {
2714         out += 'validate.schema' + ($schemaPath);
2715       } else {
2716         out += '' + (it.util.toQuotedString($schema));
2717       }
2718       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2719     }
2720     out += ' } ';
2721   } else {
2722     out += ' {} ';
2723   }
2724   var __err = out;
2725   out = $$outStack.pop();
2726   if (!it.compositeRule && $breakOnError) {
2727     /* istanbul ignore if */
2728     if (it.async) {
2729       out += ' throw new ValidationError([' + (__err) + ']); ';
2730     } else {
2731       out += ' validate.errors = [' + (__err) + ']; return false; ';
2732     }
2733   } else {
2734     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2735   }
2736   out += ' } ';
2737   if ($breakOnError) {
2738     out += ' else { ';
2739   }
2740   return out;
2743 },{}],26:[function(require,module,exports){
2744 'use strict';
2745 module.exports = function generate_if(it, $keyword, $ruleType) {
2746   var out = ' ';
2747   var $lvl = it.level;
2748   var $dataLvl = it.dataLevel;
2749   var $schema = it.schema[$keyword];
2750   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2751   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2752   var $breakOnError = !it.opts.allErrors;
2753   var $data = 'data' + ($dataLvl || '');
2754   var $valid = 'valid' + $lvl;
2755   var $errs = 'errs__' + $lvl;
2756   var $it = it.util.copy(it);
2757   $it.level++;
2758   var $nextValid = 'valid' + $it.level;
2759   var $thenSch = it.schema['then'],
2760     $elseSch = it.schema['else'],
2761     $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? (typeof $thenSch == 'object' && Object.keys($thenSch).length > 0) || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)),
2762     $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? (typeof $elseSch == 'object' && Object.keys($elseSch).length > 0) || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)),
2763     $currentBaseId = $it.baseId;
2764   if ($thenPresent || $elsePresent) {
2765     var $ifClause;
2766     $it.createErrors = false;
2767     $it.schema = $schema;
2768     $it.schemaPath = $schemaPath;
2769     $it.errSchemaPath = $errSchemaPath;
2770     out += ' var ' + ($errs) + ' = errors; var ' + ($valid) + ' = true;  ';
2771     var $wasComposite = it.compositeRule;
2772     it.compositeRule = $it.compositeRule = true;
2773     out += '  ' + (it.validate($it)) + ' ';
2774     $it.baseId = $currentBaseId;
2775     $it.createErrors = true;
2776     out += '  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }  ';
2777     it.compositeRule = $it.compositeRule = $wasComposite;
2778     if ($thenPresent) {
2779       out += ' if (' + ($nextValid) + ') {  ';
2780       $it.schema = it.schema['then'];
2781       $it.schemaPath = it.schemaPath + '.then';
2782       $it.errSchemaPath = it.errSchemaPath + '/then';
2783       out += '  ' + (it.validate($it)) + ' ';
2784       $it.baseId = $currentBaseId;
2785       out += ' ' + ($valid) + ' = ' + ($nextValid) + '; ';
2786       if ($thenPresent && $elsePresent) {
2787         $ifClause = 'ifClause' + $lvl;
2788         out += ' var ' + ($ifClause) + ' = \'then\'; ';
2789       } else {
2790         $ifClause = '\'then\'';
2791       }
2792       out += ' } ';
2793       if ($elsePresent) {
2794         out += ' else { ';
2795       }
2796     } else {
2797       out += ' if (!' + ($nextValid) + ') { ';
2798     }
2799     if ($elsePresent) {
2800       $it.schema = it.schema['else'];
2801       $it.schemaPath = it.schemaPath + '.else';
2802       $it.errSchemaPath = it.errSchemaPath + '/else';
2803       out += '  ' + (it.validate($it)) + ' ';
2804       $it.baseId = $currentBaseId;
2805       out += ' ' + ($valid) + ' = ' + ($nextValid) + '; ';
2806       if ($thenPresent && $elsePresent) {
2807         $ifClause = 'ifClause' + $lvl;
2808         out += ' var ' + ($ifClause) + ' = \'else\'; ';
2809       } else {
2810         $ifClause = '\'else\'';
2811       }
2812       out += ' } ';
2813     }
2814     out += ' if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */
2815     if (it.createErrors !== false) {
2816       out += ' { keyword: \'' + ('if') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { failingKeyword: ' + ($ifClause) + ' } ';
2817       if (it.opts.messages !== false) {
2818         out += ' , message: \'should match "\' + ' + ($ifClause) + ' + \'" schema\' ';
2819       }
2820       if (it.opts.verbose) {
2821         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2822       }
2823       out += ' } ';
2824     } else {
2825       out += ' {} ';
2826     }
2827     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2828     if (!it.compositeRule && $breakOnError) {
2829       /* istanbul ignore if */
2830       if (it.async) {
2831         out += ' throw new ValidationError(vErrors); ';
2832       } else {
2833         out += ' validate.errors = vErrors; return false; ';
2834       }
2835     }
2836     out += ' }   ';
2837     if ($breakOnError) {
2838       out += ' else { ';
2839     }
2840   } else {
2841     if ($breakOnError) {
2842       out += ' if (true) { ';
2843     }
2844   }
2845   return out;
2848 },{}],27:[function(require,module,exports){
2849 'use strict';
2851 //all requires must be explicit because browserify won't work with dynamic requires
2852 module.exports = {
2853   '$ref': require('./ref'),
2854   allOf: require('./allOf'),
2855   anyOf: require('./anyOf'),
2856   '$comment': require('./comment'),
2857   const: require('./const'),
2858   contains: require('./contains'),
2859   dependencies: require('./dependencies'),
2860   'enum': require('./enum'),
2861   format: require('./format'),
2862   'if': require('./if'),
2863   items: require('./items'),
2864   maximum: require('./_limit'),
2865   minimum: require('./_limit'),
2866   maxItems: require('./_limitItems'),
2867   minItems: require('./_limitItems'),
2868   maxLength: require('./_limitLength'),
2869   minLength: require('./_limitLength'),
2870   maxProperties: require('./_limitProperties'),
2871   minProperties: require('./_limitProperties'),
2872   multipleOf: require('./multipleOf'),
2873   not: require('./not'),
2874   oneOf: require('./oneOf'),
2875   pattern: require('./pattern'),
2876   properties: require('./properties'),
2877   propertyNames: require('./propertyNames'),
2878   required: require('./required'),
2879   uniqueItems: require('./uniqueItems'),
2880   validate: require('./validate')
2883 },{"./_limit":13,"./_limitItems":14,"./_limitLength":15,"./_limitProperties":16,"./allOf":17,"./anyOf":18,"./comment":19,"./const":20,"./contains":21,"./dependencies":23,"./enum":24,"./format":25,"./if":26,"./items":28,"./multipleOf":29,"./not":30,"./oneOf":31,"./pattern":32,"./properties":33,"./propertyNames":34,"./ref":35,"./required":36,"./uniqueItems":37,"./validate":38}],28:[function(require,module,exports){
2884 'use strict';
2885 module.exports = function generate_items(it, $keyword, $ruleType) {
2886   var out = ' ';
2887   var $lvl = it.level;
2888   var $dataLvl = it.dataLevel;
2889   var $schema = it.schema[$keyword];
2890   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
2891   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
2892   var $breakOnError = !it.opts.allErrors;
2893   var $data = 'data' + ($dataLvl || '');
2894   var $valid = 'valid' + $lvl;
2895   var $errs = 'errs__' + $lvl;
2896   var $it = it.util.copy(it);
2897   var $closingBraces = '';
2898   $it.level++;
2899   var $nextValid = 'valid' + $it.level;
2900   var $idx = 'i' + $lvl,
2901     $dataNxt = $it.dataLevel = it.dataLevel + 1,
2902     $nextData = 'data' + $dataNxt,
2903     $currentBaseId = it.baseId;
2904   out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
2905   if (Array.isArray($schema)) {
2906     var $additionalItems = it.schema.additionalItems;
2907     if ($additionalItems === false) {
2908       out += ' ' + ($valid) + ' = ' + ($data) + '.length <= ' + ($schema.length) + '; ';
2909       var $currErrSchemaPath = $errSchemaPath;
2910       $errSchemaPath = it.errSchemaPath + '/additionalItems';
2911       out += '  if (!' + ($valid) + ') {   ';
2912       var $$outStack = $$outStack || [];
2913       $$outStack.push(out);
2914       out = ''; /* istanbul ignore else */
2915       if (it.createErrors !== false) {
2916         out += ' { keyword: \'' + ('additionalItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { limit: ' + ($schema.length) + ' } ';
2917         if (it.opts.messages !== false) {
2918           out += ' , message: \'should NOT have more than ' + ($schema.length) + ' items\' ';
2919         }
2920         if (it.opts.verbose) {
2921           out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
2922         }
2923         out += ' } ';
2924       } else {
2925         out += ' {} ';
2926       }
2927       var __err = out;
2928       out = $$outStack.pop();
2929       if (!it.compositeRule && $breakOnError) {
2930         /* istanbul ignore if */
2931         if (it.async) {
2932           out += ' throw new ValidationError([' + (__err) + ']); ';
2933         } else {
2934           out += ' validate.errors = [' + (__err) + ']; return false; ';
2935         }
2936       } else {
2937         out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
2938       }
2939       out += ' } ';
2940       $errSchemaPath = $currErrSchemaPath;
2941       if ($breakOnError) {
2942         $closingBraces += '}';
2943         out += ' else { ';
2944       }
2945     }
2946     var arr1 = $schema;
2947     if (arr1) {
2948       var $sch, $i = -1,
2949         l1 = arr1.length - 1;
2950       while ($i < l1) {
2951         $sch = arr1[$i += 1];
2952         if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
2953           out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { ';
2954           var $passData = $data + '[' + $i + ']';
2955           $it.schema = $sch;
2956           $it.schemaPath = $schemaPath + '[' + $i + ']';
2957           $it.errSchemaPath = $errSchemaPath + '/' + $i;
2958           $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
2959           $it.dataPathArr[$dataNxt] = $i;
2960           var $code = it.validate($it);
2961           $it.baseId = $currentBaseId;
2962           if (it.util.varOccurences($code, $nextData) < 2) {
2963             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
2964           } else {
2965             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
2966           }
2967           out += ' }  ';
2968           if ($breakOnError) {
2969             out += ' if (' + ($nextValid) + ') { ';
2970             $closingBraces += '}';
2971           }
2972         }
2973       }
2974     }
2975     if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? (typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0) || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
2976       $it.schema = $additionalItems;
2977       $it.schemaPath = it.schemaPath + '.additionalItems';
2978       $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
2979       out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($schema.length) + ') {  for (var ' + ($idx) + ' = ' + ($schema.length) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
2980       $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
2981       var $passData = $data + '[' + $idx + ']';
2982       $it.dataPathArr[$dataNxt] = $idx;
2983       var $code = it.validate($it);
2984       $it.baseId = $currentBaseId;
2985       if (it.util.varOccurences($code, $nextData) < 2) {
2986         out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
2987       } else {
2988         out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
2989       }
2990       if ($breakOnError) {
2991         out += ' if (!' + ($nextValid) + ') break; ';
2992       }
2993       out += ' } }  ';
2994       if ($breakOnError) {
2995         out += ' if (' + ($nextValid) + ') { ';
2996         $closingBraces += '}';
2997       }
2998     }
2999   } else if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
3000     $it.schema = $schema;
3001     $it.schemaPath = $schemaPath;
3002     $it.errSchemaPath = $errSchemaPath;
3003     out += '  for (var ' + ($idx) + ' = ' + (0) + '; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
3004     $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
3005     var $passData = $data + '[' + $idx + ']';
3006     $it.dataPathArr[$dataNxt] = $idx;
3007     var $code = it.validate($it);
3008     $it.baseId = $currentBaseId;
3009     if (it.util.varOccurences($code, $nextData) < 2) {
3010       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3011     } else {
3012       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3013     }
3014     if ($breakOnError) {
3015       out += ' if (!' + ($nextValid) + ') break; ';
3016     }
3017     out += ' }';
3018   }
3019   if ($breakOnError) {
3020     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
3021   }
3022   return out;
3025 },{}],29:[function(require,module,exports){
3026 'use strict';
3027 module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
3028   var out = ' ';
3029   var $lvl = it.level;
3030   var $dataLvl = it.dataLevel;
3031   var $schema = it.schema[$keyword];
3032   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3033   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3034   var $breakOnError = !it.opts.allErrors;
3035   var $data = 'data' + ($dataLvl || '');
3036   var $isData = it.opts.$data && $schema && $schema.$data,
3037     $schemaValue;
3038   if ($isData) {
3039     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
3040     $schemaValue = 'schema' + $lvl;
3041   } else {
3042     $schemaValue = $schema;
3043   }
3044   if (!($isData || typeof $schema == 'number')) {
3045     throw new Error($keyword + ' must be number');
3046   }
3047   out += 'var division' + ($lvl) + ';if (';
3048   if ($isData) {
3049     out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
3050   }
3051   out += ' (division' + ($lvl) + ' = ' + ($data) + ' / ' + ($schemaValue) + ', ';
3052   if (it.opts.multipleOfPrecision) {
3053     out += ' Math.abs(Math.round(division' + ($lvl) + ') - division' + ($lvl) + ') > 1e-' + (it.opts.multipleOfPrecision) + ' ';
3054   } else {
3055     out += ' division' + ($lvl) + ' !== parseInt(division' + ($lvl) + ') ';
3056   }
3057   out += ' ) ';
3058   if ($isData) {
3059     out += '  )  ';
3060   }
3061   out += ' ) {   ';
3062   var $$outStack = $$outStack || [];
3063   $$outStack.push(out);
3064   out = ''; /* istanbul ignore else */
3065   if (it.createErrors !== false) {
3066     out += ' { keyword: \'' + ('multipleOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { multipleOf: ' + ($schemaValue) + ' } ';
3067     if (it.opts.messages !== false) {
3068       out += ' , message: \'should be multiple of ';
3069       if ($isData) {
3070         out += '\' + ' + ($schemaValue);
3071       } else {
3072         out += '' + ($schemaValue) + '\'';
3073       }
3074     }
3075     if (it.opts.verbose) {
3076       out += ' , schema:  ';
3077       if ($isData) {
3078         out += 'validate.schema' + ($schemaPath);
3079       } else {
3080         out += '' + ($schema);
3081       }
3082       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3083     }
3084     out += ' } ';
3085   } else {
3086     out += ' {} ';
3087   }
3088   var __err = out;
3089   out = $$outStack.pop();
3090   if (!it.compositeRule && $breakOnError) {
3091     /* istanbul ignore if */
3092     if (it.async) {
3093       out += ' throw new ValidationError([' + (__err) + ']); ';
3094     } else {
3095       out += ' validate.errors = [' + (__err) + ']; return false; ';
3096     }
3097   } else {
3098     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3099   }
3100   out += '} ';
3101   if ($breakOnError) {
3102     out += ' else { ';
3103   }
3104   return out;
3107 },{}],30:[function(require,module,exports){
3108 'use strict';
3109 module.exports = function generate_not(it, $keyword, $ruleType) {
3110   var out = ' ';
3111   var $lvl = it.level;
3112   var $dataLvl = it.dataLevel;
3113   var $schema = it.schema[$keyword];
3114   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3115   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3116   var $breakOnError = !it.opts.allErrors;
3117   var $data = 'data' + ($dataLvl || '');
3118   var $errs = 'errs__' + $lvl;
3119   var $it = it.util.copy(it);
3120   $it.level++;
3121   var $nextValid = 'valid' + $it.level;
3122   if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
3123     $it.schema = $schema;
3124     $it.schemaPath = $schemaPath;
3125     $it.errSchemaPath = $errSchemaPath;
3126     out += ' var ' + ($errs) + ' = errors;  ';
3127     var $wasComposite = it.compositeRule;
3128     it.compositeRule = $it.compositeRule = true;
3129     $it.createErrors = false;
3130     var $allErrorsOption;
3131     if ($it.opts.allErrors) {
3132       $allErrorsOption = $it.opts.allErrors;
3133       $it.opts.allErrors = false;
3134     }
3135     out += ' ' + (it.validate($it)) + ' ';
3136     $it.createErrors = true;
3137     if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
3138     it.compositeRule = $it.compositeRule = $wasComposite;
3139     out += ' if (' + ($nextValid) + ') {   ';
3140     var $$outStack = $$outStack || [];
3141     $$outStack.push(out);
3142     out = ''; /* istanbul ignore else */
3143     if (it.createErrors !== false) {
3144       out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
3145       if (it.opts.messages !== false) {
3146         out += ' , message: \'should NOT be valid\' ';
3147       }
3148       if (it.opts.verbose) {
3149         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3150       }
3151       out += ' } ';
3152     } else {
3153       out += ' {} ';
3154     }
3155     var __err = out;
3156     out = $$outStack.pop();
3157     if (!it.compositeRule && $breakOnError) {
3158       /* istanbul ignore if */
3159       if (it.async) {
3160         out += ' throw new ValidationError([' + (__err) + ']); ';
3161       } else {
3162         out += ' validate.errors = [' + (__err) + ']; return false; ';
3163       }
3164     } else {
3165       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3166     }
3167     out += ' } else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
3168     if (it.opts.allErrors) {
3169       out += ' } ';
3170     }
3171   } else {
3172     out += '  var err =   '; /* istanbul ignore else */
3173     if (it.createErrors !== false) {
3174       out += ' { keyword: \'' + ('not') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
3175       if (it.opts.messages !== false) {
3176         out += ' , message: \'should NOT be valid\' ';
3177       }
3178       if (it.opts.verbose) {
3179         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3180       }
3181       out += ' } ';
3182     } else {
3183       out += ' {} ';
3184     }
3185     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3186     if ($breakOnError) {
3187       out += ' if (false) { ';
3188     }
3189   }
3190   return out;
3193 },{}],31:[function(require,module,exports){
3194 'use strict';
3195 module.exports = function generate_oneOf(it, $keyword, $ruleType) {
3196   var out = ' ';
3197   var $lvl = it.level;
3198   var $dataLvl = it.dataLevel;
3199   var $schema = it.schema[$keyword];
3200   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3201   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3202   var $breakOnError = !it.opts.allErrors;
3203   var $data = 'data' + ($dataLvl || '');
3204   var $valid = 'valid' + $lvl;
3205   var $errs = 'errs__' + $lvl;
3206   var $it = it.util.copy(it);
3207   var $closingBraces = '';
3208   $it.level++;
3209   var $nextValid = 'valid' + $it.level;
3210   var $currentBaseId = $it.baseId,
3211     $prevValid = 'prevValid' + $lvl,
3212     $passingSchemas = 'passingSchemas' + $lvl;
3213   out += 'var ' + ($errs) + ' = errors , ' + ($prevValid) + ' = false , ' + ($valid) + ' = false , ' + ($passingSchemas) + ' = null; ';
3214   var $wasComposite = it.compositeRule;
3215   it.compositeRule = $it.compositeRule = true;
3216   var arr1 = $schema;
3217   if (arr1) {
3218     var $sch, $i = -1,
3219       l1 = arr1.length - 1;
3220     while ($i < l1) {
3221       $sch = arr1[$i += 1];
3222       if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
3223         $it.schema = $sch;
3224         $it.schemaPath = $schemaPath + '[' + $i + ']';
3225         $it.errSchemaPath = $errSchemaPath + '/' + $i;
3226         out += '  ' + (it.validate($it)) + ' ';
3227         $it.baseId = $currentBaseId;
3228       } else {
3229         out += ' var ' + ($nextValid) + ' = true; ';
3230       }
3231       if ($i) {
3232         out += ' if (' + ($nextValid) + ' && ' + ($prevValid) + ') { ' + ($valid) + ' = false; ' + ($passingSchemas) + ' = [' + ($passingSchemas) + ', ' + ($i) + ']; } else { ';
3233         $closingBraces += '}';
3234       }
3235       out += ' if (' + ($nextValid) + ') { ' + ($valid) + ' = ' + ($prevValid) + ' = true; ' + ($passingSchemas) + ' = ' + ($i) + '; }';
3236     }
3237   }
3238   it.compositeRule = $it.compositeRule = $wasComposite;
3239   out += '' + ($closingBraces) + 'if (!' + ($valid) + ') {   var err =   '; /* istanbul ignore else */
3240   if (it.createErrors !== false) {
3241     out += ' { keyword: \'' + ('oneOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { passingSchemas: ' + ($passingSchemas) + ' } ';
3242     if (it.opts.messages !== false) {
3243       out += ' , message: \'should match exactly one schema in oneOf\' ';
3244     }
3245     if (it.opts.verbose) {
3246       out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3247     }
3248     out += ' } ';
3249   } else {
3250     out += ' {} ';
3251   }
3252   out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3253   if (!it.compositeRule && $breakOnError) {
3254     /* istanbul ignore if */
3255     if (it.async) {
3256       out += ' throw new ValidationError(vErrors); ';
3257     } else {
3258       out += ' validate.errors = vErrors; return false; ';
3259     }
3260   }
3261   out += '} else {  errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }';
3262   if (it.opts.allErrors) {
3263     out += ' } ';
3264   }
3265   return out;
3268 },{}],32:[function(require,module,exports){
3269 'use strict';
3270 module.exports = function generate_pattern(it, $keyword, $ruleType) {
3271   var out = ' ';
3272   var $lvl = it.level;
3273   var $dataLvl = it.dataLevel;
3274   var $schema = it.schema[$keyword];
3275   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3276   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3277   var $breakOnError = !it.opts.allErrors;
3278   var $data = 'data' + ($dataLvl || '');
3279   var $isData = it.opts.$data && $schema && $schema.$data,
3280     $schemaValue;
3281   if ($isData) {
3282     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
3283     $schemaValue = 'schema' + $lvl;
3284   } else {
3285     $schemaValue = $schema;
3286   }
3287   var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
3288   out += 'if ( ';
3289   if ($isData) {
3290     out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
3291   }
3292   out += ' !' + ($regexp) + '.test(' + ($data) + ') ) {   ';
3293   var $$outStack = $$outStack || [];
3294   $$outStack.push(out);
3295   out = ''; /* istanbul ignore else */
3296   if (it.createErrors !== false) {
3297     out += ' { keyword: \'' + ('pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern:  ';
3298     if ($isData) {
3299       out += '' + ($schemaValue);
3300     } else {
3301       out += '' + (it.util.toQuotedString($schema));
3302     }
3303     out += '  } ';
3304     if (it.opts.messages !== false) {
3305       out += ' , message: \'should match pattern "';
3306       if ($isData) {
3307         out += '\' + ' + ($schemaValue) + ' + \'';
3308       } else {
3309         out += '' + (it.util.escapeQuotes($schema));
3310       }
3311       out += '"\' ';
3312     }
3313     if (it.opts.verbose) {
3314       out += ' , schema:  ';
3315       if ($isData) {
3316         out += 'validate.schema' + ($schemaPath);
3317       } else {
3318         out += '' + (it.util.toQuotedString($schema));
3319       }
3320       out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3321     }
3322     out += ' } ';
3323   } else {
3324     out += ' {} ';
3325   }
3326   var __err = out;
3327   out = $$outStack.pop();
3328   if (!it.compositeRule && $breakOnError) {
3329     /* istanbul ignore if */
3330     if (it.async) {
3331       out += ' throw new ValidationError([' + (__err) + ']); ';
3332     } else {
3333       out += ' validate.errors = [' + (__err) + ']; return false; ';
3334     }
3335   } else {
3336     out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3337   }
3338   out += '} ';
3339   if ($breakOnError) {
3340     out += ' else { ';
3341   }
3342   return out;
3345 },{}],33:[function(require,module,exports){
3346 'use strict';
3347 module.exports = function generate_properties(it, $keyword, $ruleType) {
3348   var out = ' ';
3349   var $lvl = it.level;
3350   var $dataLvl = it.dataLevel;
3351   var $schema = it.schema[$keyword];
3352   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3353   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3354   var $breakOnError = !it.opts.allErrors;
3355   var $data = 'data' + ($dataLvl || '');
3356   var $errs = 'errs__' + $lvl;
3357   var $it = it.util.copy(it);
3358   var $closingBraces = '';
3359   $it.level++;
3360   var $nextValid = 'valid' + $it.level;
3361   var $key = 'key' + $lvl,
3362     $idx = 'idx' + $lvl,
3363     $dataNxt = $it.dataLevel = it.dataLevel + 1,
3364     $nextData = 'data' + $dataNxt,
3365     $dataProperties = 'dataProperties' + $lvl;
3366   var $schemaKeys = Object.keys($schema || {}).filter(notProto),
3367     $pProperties = it.schema.patternProperties || {},
3368     $pPropertyKeys = Object.keys($pProperties).filter(notProto),
3369     $aProperties = it.schema.additionalProperties,
3370     $someProperties = $schemaKeys.length || $pPropertyKeys.length,
3371     $noAdditional = $aProperties === false,
3372     $additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length,
3373     $removeAdditional = it.opts.removeAdditional,
3374     $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
3375     $ownProperties = it.opts.ownProperties,
3376     $currentBaseId = it.baseId;
3377   var $required = it.schema.required;
3378   if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
3379     var $requiredHash = it.util.toHash($required);
3380   }
3382   function notProto(p) {
3383     return p !== '__proto__';
3384   }
3385   out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
3386   if ($ownProperties) {
3387     out += ' var ' + ($dataProperties) + ' = undefined;';
3388   }
3389   if ($checkAdditional) {
3390     if ($ownProperties) {
3391       out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
3392     } else {
3393       out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
3394     }
3395     if ($someProperties) {
3396       out += ' var isAdditional' + ($lvl) + ' = !(false ';
3397       if ($schemaKeys.length) {
3398         if ($schemaKeys.length > 8) {
3399           out += ' || validate.schema' + ($schemaPath) + '.hasOwnProperty(' + ($key) + ') ';
3400         } else {
3401           var arr1 = $schemaKeys;
3402           if (arr1) {
3403             var $propertyKey, i1 = -1,
3404               l1 = arr1.length - 1;
3405             while (i1 < l1) {
3406               $propertyKey = arr1[i1 += 1];
3407               out += ' || ' + ($key) + ' == ' + (it.util.toQuotedString($propertyKey)) + ' ';
3408             }
3409           }
3410         }
3411       }
3412       if ($pPropertyKeys.length) {
3413         var arr2 = $pPropertyKeys;
3414         if (arr2) {
3415           var $pProperty, $i = -1,
3416             l2 = arr2.length - 1;
3417           while ($i < l2) {
3418             $pProperty = arr2[$i += 1];
3419             out += ' || ' + (it.usePattern($pProperty)) + '.test(' + ($key) + ') ';
3420           }
3421         }
3422       }
3423       out += ' ); if (isAdditional' + ($lvl) + ') { ';
3424     }
3425     if ($removeAdditional == 'all') {
3426       out += ' delete ' + ($data) + '[' + ($key) + ']; ';
3427     } else {
3428       var $currentErrorPath = it.errorPath;
3429       var $additionalProperty = '\' + ' + $key + ' + \'';
3430       if (it.opts._errorDataPathProperty) {
3431         it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3432       }
3433       if ($noAdditional) {
3434         if ($removeAdditional) {
3435           out += ' delete ' + ($data) + '[' + ($key) + ']; ';
3436         } else {
3437           out += ' ' + ($nextValid) + ' = false; ';
3438           var $currErrSchemaPath = $errSchemaPath;
3439           $errSchemaPath = it.errSchemaPath + '/additionalProperties';
3440           var $$outStack = $$outStack || [];
3441           $$outStack.push(out);
3442           out = ''; /* istanbul ignore else */
3443           if (it.createErrors !== false) {
3444             out += ' { keyword: \'' + ('additionalProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { additionalProperty: \'' + ($additionalProperty) + '\' } ';
3445             if (it.opts.messages !== false) {
3446               out += ' , message: \'';
3447               if (it.opts._errorDataPathProperty) {
3448                 out += 'is an invalid additional property';
3449               } else {
3450                 out += 'should NOT have additional properties';
3451               }
3452               out += '\' ';
3453             }
3454             if (it.opts.verbose) {
3455               out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3456             }
3457             out += ' } ';
3458           } else {
3459             out += ' {} ';
3460           }
3461           var __err = out;
3462           out = $$outStack.pop();
3463           if (!it.compositeRule && $breakOnError) {
3464             /* istanbul ignore if */
3465             if (it.async) {
3466               out += ' throw new ValidationError([' + (__err) + ']); ';
3467             } else {
3468               out += ' validate.errors = [' + (__err) + ']; return false; ';
3469             }
3470           } else {
3471             out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3472           }
3473           $errSchemaPath = $currErrSchemaPath;
3474           if ($breakOnError) {
3475             out += ' break; ';
3476           }
3477         }
3478       } else if ($additionalIsSchema) {
3479         if ($removeAdditional == 'failing') {
3480           out += ' var ' + ($errs) + ' = errors;  ';
3481           var $wasComposite = it.compositeRule;
3482           it.compositeRule = $it.compositeRule = true;
3483           $it.schema = $aProperties;
3484           $it.schemaPath = it.schemaPath + '.additionalProperties';
3485           $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
3486           $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3487           var $passData = $data + '[' + $key + ']';
3488           $it.dataPathArr[$dataNxt] = $key;
3489           var $code = it.validate($it);
3490           $it.baseId = $currentBaseId;
3491           if (it.util.varOccurences($code, $nextData) < 2) {
3492             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3493           } else {
3494             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3495           }
3496           out += ' if (!' + ($nextValid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + ($data) + '[' + ($key) + ']; }  ';
3497           it.compositeRule = $it.compositeRule = $wasComposite;
3498         } else {
3499           $it.schema = $aProperties;
3500           $it.schemaPath = it.schemaPath + '.additionalProperties';
3501           $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
3502           $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3503           var $passData = $data + '[' + $key + ']';
3504           $it.dataPathArr[$dataNxt] = $key;
3505           var $code = it.validate($it);
3506           $it.baseId = $currentBaseId;
3507           if (it.util.varOccurences($code, $nextData) < 2) {
3508             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3509           } else {
3510             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3511           }
3512           if ($breakOnError) {
3513             out += ' if (!' + ($nextValid) + ') break; ';
3514           }
3515         }
3516       }
3517       it.errorPath = $currentErrorPath;
3518     }
3519     if ($someProperties) {
3520       out += ' } ';
3521     }
3522     out += ' }  ';
3523     if ($breakOnError) {
3524       out += ' if (' + ($nextValid) + ') { ';
3525       $closingBraces += '}';
3526     }
3527   }
3528   var $useDefaults = it.opts.useDefaults && !it.compositeRule;
3529   if ($schemaKeys.length) {
3530     var arr3 = $schemaKeys;
3531     if (arr3) {
3532       var $propertyKey, i3 = -1,
3533         l3 = arr3.length - 1;
3534       while (i3 < l3) {
3535         $propertyKey = arr3[i3 += 1];
3536         var $sch = $schema[$propertyKey];
3537         if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
3538           var $prop = it.util.getProperty($propertyKey),
3539             $passData = $data + $prop,
3540             $hasDefault = $useDefaults && $sch.default !== undefined;
3541           $it.schema = $sch;
3542           $it.schemaPath = $schemaPath + $prop;
3543           $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
3544           $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
3545           $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
3546           var $code = it.validate($it);
3547           $it.baseId = $currentBaseId;
3548           if (it.util.varOccurences($code, $nextData) < 2) {
3549             $code = it.util.varReplace($code, $nextData, $passData);
3550             var $useData = $passData;
3551           } else {
3552             var $useData = $nextData;
3553             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ';
3554           }
3555           if ($hasDefault) {
3556             out += ' ' + ($code) + ' ';
3557           } else {
3558             if ($requiredHash && $requiredHash[$propertyKey]) {
3559               out += ' if ( ' + ($useData) + ' === undefined ';
3560               if ($ownProperties) {
3561                 out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
3562               }
3563               out += ') { ' + ($nextValid) + ' = false; ';
3564               var $currentErrorPath = it.errorPath,
3565                 $currErrSchemaPath = $errSchemaPath,
3566                 $missingProperty = it.util.escapeQuotes($propertyKey);
3567               if (it.opts._errorDataPathProperty) {
3568                 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
3569               }
3570               $errSchemaPath = it.errSchemaPath + '/required';
3571               var $$outStack = $$outStack || [];
3572               $$outStack.push(out);
3573               out = ''; /* istanbul ignore else */
3574               if (it.createErrors !== false) {
3575                 out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
3576                 if (it.opts.messages !== false) {
3577                   out += ' , message: \'';
3578                   if (it.opts._errorDataPathProperty) {
3579                     out += 'is a required property';
3580                   } else {
3581                     out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
3582                   }
3583                   out += '\' ';
3584                 }
3585                 if (it.opts.verbose) {
3586                   out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3587                 }
3588                 out += ' } ';
3589               } else {
3590                 out += ' {} ';
3591               }
3592               var __err = out;
3593               out = $$outStack.pop();
3594               if (!it.compositeRule && $breakOnError) {
3595                 /* istanbul ignore if */
3596                 if (it.async) {
3597                   out += ' throw new ValidationError([' + (__err) + ']); ';
3598                 } else {
3599                   out += ' validate.errors = [' + (__err) + ']; return false; ';
3600                 }
3601               } else {
3602                 out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3603               }
3604               $errSchemaPath = $currErrSchemaPath;
3605               it.errorPath = $currentErrorPath;
3606               out += ' } else { ';
3607             } else {
3608               if ($breakOnError) {
3609                 out += ' if ( ' + ($useData) + ' === undefined ';
3610                 if ($ownProperties) {
3611                   out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
3612                 }
3613                 out += ') { ' + ($nextValid) + ' = true; } else { ';
3614               } else {
3615                 out += ' if (' + ($useData) + ' !== undefined ';
3616                 if ($ownProperties) {
3617                   out += ' &&   Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
3618                 }
3619                 out += ' ) { ';
3620               }
3621             }
3622             out += ' ' + ($code) + ' } ';
3623           }
3624         }
3625         if ($breakOnError) {
3626           out += ' if (' + ($nextValid) + ') { ';
3627           $closingBraces += '}';
3628         }
3629       }
3630     }
3631   }
3632   if ($pPropertyKeys.length) {
3633     var arr4 = $pPropertyKeys;
3634     if (arr4) {
3635       var $pProperty, i4 = -1,
3636         l4 = arr4.length - 1;
3637       while (i4 < l4) {
3638         $pProperty = arr4[i4 += 1];
3639         var $sch = $pProperties[$pProperty];
3640         if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
3641           $it.schema = $sch;
3642           $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
3643           $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
3644           if ($ownProperties) {
3645             out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
3646           } else {
3647             out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
3648           }
3649           out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { ';
3650           $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
3651           var $passData = $data + '[' + $key + ']';
3652           $it.dataPathArr[$dataNxt] = $key;
3653           var $code = it.validate($it);
3654           $it.baseId = $currentBaseId;
3655           if (it.util.varOccurences($code, $nextData) < 2) {
3656             out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3657           } else {
3658             out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3659           }
3660           if ($breakOnError) {
3661             out += ' if (!' + ($nextValid) + ') break; ';
3662           }
3663           out += ' } ';
3664           if ($breakOnError) {
3665             out += ' else ' + ($nextValid) + ' = true; ';
3666           }
3667           out += ' }  ';
3668           if ($breakOnError) {
3669             out += ' if (' + ($nextValid) + ') { ';
3670             $closingBraces += '}';
3671           }
3672         }
3673       }
3674     }
3675   }
3676   if ($breakOnError) {
3677     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
3678   }
3679   return out;
3682 },{}],34:[function(require,module,exports){
3683 'use strict';
3684 module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
3685   var out = ' ';
3686   var $lvl = it.level;
3687   var $dataLvl = it.dataLevel;
3688   var $schema = it.schema[$keyword];
3689   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3690   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3691   var $breakOnError = !it.opts.allErrors;
3692   var $data = 'data' + ($dataLvl || '');
3693   var $errs = 'errs__' + $lvl;
3694   var $it = it.util.copy(it);
3695   var $closingBraces = '';
3696   $it.level++;
3697   var $nextValid = 'valid' + $it.level;
3698   out += 'var ' + ($errs) + ' = errors;';
3699   if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) {
3700     $it.schema = $schema;
3701     $it.schemaPath = $schemaPath;
3702     $it.errSchemaPath = $errSchemaPath;
3703     var $key = 'key' + $lvl,
3704       $idx = 'idx' + $lvl,
3705       $i = 'i' + $lvl,
3706       $invalidName = '\' + ' + $key + ' + \'',
3707       $dataNxt = $it.dataLevel = it.dataLevel + 1,
3708       $nextData = 'data' + $dataNxt,
3709       $dataProperties = 'dataProperties' + $lvl,
3710       $ownProperties = it.opts.ownProperties,
3711       $currentBaseId = it.baseId;
3712     if ($ownProperties) {
3713       out += ' var ' + ($dataProperties) + ' = undefined; ';
3714     }
3715     if ($ownProperties) {
3716       out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
3717     } else {
3718       out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
3719     }
3720     out += ' var startErrs' + ($lvl) + ' = errors; ';
3721     var $passData = $key;
3722     var $wasComposite = it.compositeRule;
3723     it.compositeRule = $it.compositeRule = true;
3724     var $code = it.validate($it);
3725     $it.baseId = $currentBaseId;
3726     if (it.util.varOccurences($code, $nextData) < 2) {
3727       out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
3728     } else {
3729       out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
3730     }
3731     it.compositeRule = $it.compositeRule = $wasComposite;
3732     out += ' if (!' + ($nextValid) + ') { for (var ' + ($i) + '=startErrs' + ($lvl) + '; ' + ($i) + '<errors; ' + ($i) + '++) { vErrors[' + ($i) + '].propertyName = ' + ($key) + '; }   var err =   '; /* istanbul ignore else */
3733     if (it.createErrors !== false) {
3734       out += ' { keyword: \'' + ('propertyNames') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { propertyName: \'' + ($invalidName) + '\' } ';
3735       if (it.opts.messages !== false) {
3736         out += ' , message: \'property name \\\'' + ($invalidName) + '\\\' is invalid\' ';
3737       }
3738       if (it.opts.verbose) {
3739         out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3740       }
3741       out += ' } ';
3742     } else {
3743       out += ' {} ';
3744     }
3745     out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3746     if (!it.compositeRule && $breakOnError) {
3747       /* istanbul ignore if */
3748       if (it.async) {
3749         out += ' throw new ValidationError(vErrors); ';
3750       } else {
3751         out += ' validate.errors = vErrors; return false; ';
3752       }
3753     }
3754     if ($breakOnError) {
3755       out += ' break; ';
3756     }
3757     out += ' } }';
3758   }
3759   if ($breakOnError) {
3760     out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
3761   }
3762   return out;
3765 },{}],35:[function(require,module,exports){
3766 'use strict';
3767 module.exports = function generate_ref(it, $keyword, $ruleType) {
3768   var out = ' ';
3769   var $lvl = it.level;
3770   var $dataLvl = it.dataLevel;
3771   var $schema = it.schema[$keyword];
3772   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3773   var $breakOnError = !it.opts.allErrors;
3774   var $data = 'data' + ($dataLvl || '');
3775   var $valid = 'valid' + $lvl;
3776   var $async, $refCode;
3777   if ($schema == '#' || $schema == '#/') {
3778     if (it.isRoot) {
3779       $async = it.async;
3780       $refCode = 'validate';
3781     } else {
3782       $async = it.root.schema.$async === true;
3783       $refCode = 'root.refVal[0]';
3784     }
3785   } else {
3786     var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot);
3787     if ($refVal === undefined) {
3788       var $message = it.MissingRefError.message(it.baseId, $schema);
3789       if (it.opts.missingRefs == 'fail') {
3790         it.logger.error($message);
3791         var $$outStack = $$outStack || [];
3792         $$outStack.push(out);
3793         out = ''; /* istanbul ignore else */
3794         if (it.createErrors !== false) {
3795           out += ' { keyword: \'' + ('$ref') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { ref: \'' + (it.util.escapeQuotes($schema)) + '\' } ';
3796           if (it.opts.messages !== false) {
3797             out += ' , message: \'can\\\'t resolve reference ' + (it.util.escapeQuotes($schema)) + '\' ';
3798           }
3799           if (it.opts.verbose) {
3800             out += ' , schema: ' + (it.util.toQuotedString($schema)) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3801           }
3802           out += ' } ';
3803         } else {
3804           out += ' {} ';
3805         }
3806         var __err = out;
3807         out = $$outStack.pop();
3808         if (!it.compositeRule && $breakOnError) {
3809           /* istanbul ignore if */
3810           if (it.async) {
3811             out += ' throw new ValidationError([' + (__err) + ']); ';
3812           } else {
3813             out += ' validate.errors = [' + (__err) + ']; return false; ';
3814           }
3815         } else {
3816           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3817         }
3818         if ($breakOnError) {
3819           out += ' if (false) { ';
3820         }
3821       } else if (it.opts.missingRefs == 'ignore') {
3822         it.logger.warn($message);
3823         if ($breakOnError) {
3824           out += ' if (true) { ';
3825         }
3826       } else {
3827         throw new it.MissingRefError(it.baseId, $schema, $message);
3828       }
3829     } else if ($refVal.inline) {
3830       var $it = it.util.copy(it);
3831       $it.level++;
3832       var $nextValid = 'valid' + $it.level;
3833       $it.schema = $refVal.schema;
3834       $it.schemaPath = '';
3835       $it.errSchemaPath = $schema;
3836       var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code);
3837       out += ' ' + ($code) + ' ';
3838       if ($breakOnError) {
3839         out += ' if (' + ($nextValid) + ') { ';
3840       }
3841     } else {
3842       $async = $refVal.$async === true || (it.async && $refVal.$async !== false);
3843       $refCode = $refVal.code;
3844     }
3845   }
3846   if ($refCode) {
3847     var $$outStack = $$outStack || [];
3848     $$outStack.push(out);
3849     out = '';
3850     if (it.opts.passContext) {
3851       out += ' ' + ($refCode) + '.call(this, ';
3852     } else {
3853       out += ' ' + ($refCode) + '( ';
3854     }
3855     out += ' ' + ($data) + ', (dataPath || \'\')';
3856     if (it.errorPath != '""') {
3857       out += ' + ' + (it.errorPath);
3858     }
3859     var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
3860       $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
3861     out += ' , ' + ($parentData) + ' , ' + ($parentDataProperty) + ', rootData)  ';
3862     var __callValidate = out;
3863     out = $$outStack.pop();
3864     if ($async) {
3865       if (!it.async) throw new Error('async schema referenced by sync schema');
3866       if ($breakOnError) {
3867         out += ' var ' + ($valid) + '; ';
3868       }
3869       out += ' try { await ' + (__callValidate) + '; ';
3870       if ($breakOnError) {
3871         out += ' ' + ($valid) + ' = true; ';
3872       }
3873       out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ';
3874       if ($breakOnError) {
3875         out += ' ' + ($valid) + ' = false; ';
3876       }
3877       out += ' } ';
3878       if ($breakOnError) {
3879         out += ' if (' + ($valid) + ') { ';
3880       }
3881     } else {
3882       out += ' if (!' + (__callValidate) + ') { if (vErrors === null) vErrors = ' + ($refCode) + '.errors; else vErrors = vErrors.concat(' + ($refCode) + '.errors); errors = vErrors.length; } ';
3883       if ($breakOnError) {
3884         out += ' else { ';
3885       }
3886     }
3887   }
3888   return out;
3891 },{}],36:[function(require,module,exports){
3892 'use strict';
3893 module.exports = function generate_required(it, $keyword, $ruleType) {
3894   var out = ' ';
3895   var $lvl = it.level;
3896   var $dataLvl = it.dataLevel;
3897   var $schema = it.schema[$keyword];
3898   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
3899   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
3900   var $breakOnError = !it.opts.allErrors;
3901   var $data = 'data' + ($dataLvl || '');
3902   var $valid = 'valid' + $lvl;
3903   var $isData = it.opts.$data && $schema && $schema.$data,
3904     $schemaValue;
3905   if ($isData) {
3906     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
3907     $schemaValue = 'schema' + $lvl;
3908   } else {
3909     $schemaValue = $schema;
3910   }
3911   var $vSchema = 'schema' + $lvl;
3912   if (!$isData) {
3913     if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) {
3914       var $required = [];
3915       var arr1 = $schema;
3916       if (arr1) {
3917         var $property, i1 = -1,
3918           l1 = arr1.length - 1;
3919         while (i1 < l1) {
3920           $property = arr1[i1 += 1];
3921           var $propertySch = it.schema.properties[$property];
3922           if (!($propertySch && (it.opts.strictKeywords ? (typeof $propertySch == 'object' && Object.keys($propertySch).length > 0) || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
3923             $required[$required.length] = $property;
3924           }
3925         }
3926       }
3927     } else {
3928       var $required = $schema;
3929     }
3930   }
3931   if ($isData || $required.length) {
3932     var $currentErrorPath = it.errorPath,
3933       $loopRequired = $isData || $required.length >= it.opts.loopRequired,
3934       $ownProperties = it.opts.ownProperties;
3935     if ($breakOnError) {
3936       out += ' var missing' + ($lvl) + '; ';
3937       if ($loopRequired) {
3938         if (!$isData) {
3939           out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; ';
3940         }
3941         var $i = 'i' + $lvl,
3942           $propertyPath = 'schema' + $lvl + '[' + $i + ']',
3943           $missingProperty = '\' + ' + $propertyPath + ' + \'';
3944         if (it.opts._errorDataPathProperty) {
3945           it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
3946         }
3947         out += ' var ' + ($valid) + ' = true; ';
3948         if ($isData) {
3949           out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
3950         }
3951         out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { ' + ($valid) + ' = ' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] !== undefined ';
3952         if ($ownProperties) {
3953           out += ' &&   Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
3954         }
3955         out += '; if (!' + ($valid) + ') break; } ';
3956         if ($isData) {
3957           out += '  }  ';
3958         }
3959         out += '  if (!' + ($valid) + ') {   ';
3960         var $$outStack = $$outStack || [];
3961         $$outStack.push(out);
3962         out = ''; /* istanbul ignore else */
3963         if (it.createErrors !== false) {
3964           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
3965           if (it.opts.messages !== false) {
3966             out += ' , message: \'';
3967             if (it.opts._errorDataPathProperty) {
3968               out += 'is a required property';
3969             } else {
3970               out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
3971             }
3972             out += '\' ';
3973           }
3974           if (it.opts.verbose) {
3975             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
3976           }
3977           out += ' } ';
3978         } else {
3979           out += ' {} ';
3980         }
3981         var __err = out;
3982         out = $$outStack.pop();
3983         if (!it.compositeRule && $breakOnError) {
3984           /* istanbul ignore if */
3985           if (it.async) {
3986             out += ' throw new ValidationError([' + (__err) + ']); ';
3987           } else {
3988             out += ' validate.errors = [' + (__err) + ']; return false; ';
3989           }
3990         } else {
3991           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
3992         }
3993         out += ' } else { ';
3994       } else {
3995         out += ' if ( ';
3996         var arr2 = $required;
3997         if (arr2) {
3998           var $propertyKey, $i = -1,
3999             l2 = arr2.length - 1;
4000           while ($i < l2) {
4001             $propertyKey = arr2[$i += 1];
4002             if ($i) {
4003               out += ' || ';
4004             }
4005             var $prop = it.util.getProperty($propertyKey),
4006               $useData = $data + $prop;
4007             out += ' ( ( ' + ($useData) + ' === undefined ';
4008             if ($ownProperties) {
4009               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
4010             }
4011             out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
4012           }
4013         }
4014         out += ') {  ';
4015         var $propertyPath = 'missing' + $lvl,
4016           $missingProperty = '\' + ' + $propertyPath + ' + \'';
4017         if (it.opts._errorDataPathProperty) {
4018           it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
4019         }
4020         var $$outStack = $$outStack || [];
4021         $$outStack.push(out);
4022         out = ''; /* istanbul ignore else */
4023         if (it.createErrors !== false) {
4024           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
4025           if (it.opts.messages !== false) {
4026             out += ' , message: \'';
4027             if (it.opts._errorDataPathProperty) {
4028               out += 'is a required property';
4029             } else {
4030               out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
4031             }
4032             out += '\' ';
4033           }
4034           if (it.opts.verbose) {
4035             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4036           }
4037           out += ' } ';
4038         } else {
4039           out += ' {} ';
4040         }
4041         var __err = out;
4042         out = $$outStack.pop();
4043         if (!it.compositeRule && $breakOnError) {
4044           /* istanbul ignore if */
4045           if (it.async) {
4046             out += ' throw new ValidationError([' + (__err) + ']); ';
4047           } else {
4048             out += ' validate.errors = [' + (__err) + ']; return false; ';
4049           }
4050         } else {
4051           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4052         }
4053         out += ' } else { ';
4054       }
4055     } else {
4056       if ($loopRequired) {
4057         if (!$isData) {
4058           out += ' var ' + ($vSchema) + ' = validate.schema' + ($schemaPath) + '; ';
4059         }
4060         var $i = 'i' + $lvl,
4061           $propertyPath = 'schema' + $lvl + '[' + $i + ']',
4062           $missingProperty = '\' + ' + $propertyPath + ' + \'';
4063         if (it.opts._errorDataPathProperty) {
4064           it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
4065         }
4066         if ($isData) {
4067           out += ' if (' + ($vSchema) + ' && !Array.isArray(' + ($vSchema) + ')) {  var err =   '; /* istanbul ignore else */
4068           if (it.createErrors !== false) {
4069             out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
4070             if (it.opts.messages !== false) {
4071               out += ' , message: \'';
4072               if (it.opts._errorDataPathProperty) {
4073                 out += 'is a required property';
4074               } else {
4075                 out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
4076               }
4077               out += '\' ';
4078             }
4079             if (it.opts.verbose) {
4080               out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4081             }
4082             out += ' } ';
4083           } else {
4084             out += ' {} ';
4085           }
4086           out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + ($vSchema) + ' !== undefined) { ';
4087         }
4088         out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { if (' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] === undefined ';
4089         if ($ownProperties) {
4090           out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
4091         }
4092         out += ') {  var err =   '; /* istanbul ignore else */
4093         if (it.createErrors !== false) {
4094           out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
4095           if (it.opts.messages !== false) {
4096             out += ' , message: \'';
4097             if (it.opts._errorDataPathProperty) {
4098               out += 'is a required property';
4099             } else {
4100               out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
4101             }
4102             out += '\' ';
4103           }
4104           if (it.opts.verbose) {
4105             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4106           }
4107           out += ' } ';
4108         } else {
4109           out += ' {} ';
4110         }
4111         out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ';
4112         if ($isData) {
4113           out += '  }  ';
4114         }
4115       } else {
4116         var arr3 = $required;
4117         if (arr3) {
4118           var $propertyKey, i3 = -1,
4119             l3 = arr3.length - 1;
4120           while (i3 < l3) {
4121             $propertyKey = arr3[i3 += 1];
4122             var $prop = it.util.getProperty($propertyKey),
4123               $missingProperty = it.util.escapeQuotes($propertyKey),
4124               $useData = $data + $prop;
4125             if (it.opts._errorDataPathProperty) {
4126               it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
4127             }
4128             out += ' if ( ' + ($useData) + ' === undefined ';
4129             if ($ownProperties) {
4130               out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
4131             }
4132             out += ') {  var err =   '; /* istanbul ignore else */
4133             if (it.createErrors !== false) {
4134               out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
4135               if (it.opts.messages !== false) {
4136                 out += ' , message: \'';
4137                 if (it.opts._errorDataPathProperty) {
4138                   out += 'is a required property';
4139                 } else {
4140                   out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
4141                 }
4142                 out += '\' ';
4143               }
4144               if (it.opts.verbose) {
4145                 out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4146               }
4147               out += ' } ';
4148             } else {
4149               out += ' {} ';
4150             }
4151             out += ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
4152           }
4153         }
4154       }
4155     }
4156     it.errorPath = $currentErrorPath;
4157   } else if ($breakOnError) {
4158     out += ' if (true) {';
4159   }
4160   return out;
4163 },{}],37:[function(require,module,exports){
4164 'use strict';
4165 module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
4166   var out = ' ';
4167   var $lvl = it.level;
4168   var $dataLvl = it.dataLevel;
4169   var $schema = it.schema[$keyword];
4170   var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
4171   var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
4172   var $breakOnError = !it.opts.allErrors;
4173   var $data = 'data' + ($dataLvl || '');
4174   var $valid = 'valid' + $lvl;
4175   var $isData = it.opts.$data && $schema && $schema.$data,
4176     $schemaValue;
4177   if ($isData) {
4178     out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
4179     $schemaValue = 'schema' + $lvl;
4180   } else {
4181     $schemaValue = $schema;
4182   }
4183   if (($schema || $isData) && it.opts.uniqueItems !== false) {
4184     if ($isData) {
4185       out += ' var ' + ($valid) + '; if (' + ($schemaValue) + ' === false || ' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'boolean\') ' + ($valid) + ' = false; else { ';
4186     }
4187     out += ' var i = ' + ($data) + '.length , ' + ($valid) + ' = true , j; if (i > 1) { ';
4188     var $itemType = it.schema.items && it.schema.items.type,
4189       $typeIsArray = Array.isArray($itemType);
4190     if (!$itemType || $itemType == 'object' || $itemType == 'array' || ($typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0))) {
4191       out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + ($data) + '[i], ' + ($data) + '[j])) { ' + ($valid) + ' = false; break outer; } } } ';
4192     } else {
4193       out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; ';
4194       var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
4195       out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; ';
4196       if ($typeIsArray) {
4197         out += ' if (typeof item == \'string\') item = \'"\' + item; ';
4198       }
4199       out += ' if (typeof itemIndices[item] == \'number\') { ' + ($valid) + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ';
4200     }
4201     out += ' } ';
4202     if ($isData) {
4203       out += '  }  ';
4204     }
4205     out += ' if (!' + ($valid) + ') {   ';
4206     var $$outStack = $$outStack || [];
4207     $$outStack.push(out);
4208     out = ''; /* istanbul ignore else */
4209     if (it.createErrors !== false) {
4210       out += ' { keyword: \'' + ('uniqueItems') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { i: i, j: j } ';
4211       if (it.opts.messages !== false) {
4212         out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' ';
4213       }
4214       if (it.opts.verbose) {
4215         out += ' , schema:  ';
4216         if ($isData) {
4217           out += 'validate.schema' + ($schemaPath);
4218         } else {
4219           out += '' + ($schema);
4220         }
4221         out += '         , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4222       }
4223       out += ' } ';
4224     } else {
4225       out += ' {} ';
4226     }
4227     var __err = out;
4228     out = $$outStack.pop();
4229     if (!it.compositeRule && $breakOnError) {
4230       /* istanbul ignore if */
4231       if (it.async) {
4232         out += ' throw new ValidationError([' + (__err) + ']); ';
4233       } else {
4234         out += ' validate.errors = [' + (__err) + ']; return false; ';
4235       }
4236     } else {
4237       out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4238     }
4239     out += ' } ';
4240     if ($breakOnError) {
4241       out += ' else { ';
4242     }
4243   } else {
4244     if ($breakOnError) {
4245       out += ' if (true) { ';
4246     }
4247   }
4248   return out;
4251 },{}],38:[function(require,module,exports){
4252 'use strict';
4253 module.exports = function generate_validate(it, $keyword, $ruleType) {
4254   var out = '';
4255   var $async = it.schema.$async === true,
4256     $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
4257     $id = it.self._getId(it.schema);
4258   if (it.opts.strictKeywords) {
4259     var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
4260     if ($unknownKwd) {
4261       var $keywordsMsg = 'unknown keyword: ' + $unknownKwd;
4262       if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg);
4263       else throw new Error($keywordsMsg);
4264     }
4265   }
4266   if (it.isTop) {
4267     out += ' var validate = ';
4268     if ($async) {
4269       it.async = true;
4270       out += 'async ';
4271     }
4272     out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
4273     if ($id && (it.opts.sourceCode || it.opts.processCode)) {
4274       out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
4275     }
4276   }
4277   if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) {
4278     var $keyword = 'false schema';
4279     var $lvl = it.level;
4280     var $dataLvl = it.dataLevel;
4281     var $schema = it.schema[$keyword];
4282     var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
4283     var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
4284     var $breakOnError = !it.opts.allErrors;
4285     var $errorKeyword;
4286     var $data = 'data' + ($dataLvl || '');
4287     var $valid = 'valid' + $lvl;
4288     if (it.schema === false) {
4289       if (it.isTop) {
4290         $breakOnError = true;
4291       } else {
4292         out += ' var ' + ($valid) + ' = false; ';
4293       }
4294       var $$outStack = $$outStack || [];
4295       $$outStack.push(out);
4296       out = ''; /* istanbul ignore else */
4297       if (it.createErrors !== false) {
4298         out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
4299         if (it.opts.messages !== false) {
4300           out += ' , message: \'boolean schema is false\' ';
4301         }
4302         if (it.opts.verbose) {
4303           out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4304         }
4305         out += ' } ';
4306       } else {
4307         out += ' {} ';
4308       }
4309       var __err = out;
4310       out = $$outStack.pop();
4311       if (!it.compositeRule && $breakOnError) {
4312         /* istanbul ignore if */
4313         if (it.async) {
4314           out += ' throw new ValidationError([' + (__err) + ']); ';
4315         } else {
4316           out += ' validate.errors = [' + (__err) + ']; return false; ';
4317         }
4318       } else {
4319         out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4320       }
4321     } else {
4322       if (it.isTop) {
4323         if ($async) {
4324           out += ' return data; ';
4325         } else {
4326           out += ' validate.errors = null; return true; ';
4327         }
4328       } else {
4329         out += ' var ' + ($valid) + ' = true; ';
4330       }
4331     }
4332     if (it.isTop) {
4333       out += ' }; return validate; ';
4334     }
4335     return out;
4336   }
4337   if (it.isTop) {
4338     var $top = it.isTop,
4339       $lvl = it.level = 0,
4340       $dataLvl = it.dataLevel = 0,
4341       $data = 'data';
4342     it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
4343     it.baseId = it.baseId || it.rootId;
4344     delete it.isTop;
4345     it.dataPathArr = [""];
4346     if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
4347       var $defaultMsg = 'default is ignored in the schema root';
4348       if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
4349       else throw new Error($defaultMsg);
4350     }
4351     out += ' var vErrors = null; ';
4352     out += ' var errors = 0;     ';
4353     out += ' if (rootData === undefined) rootData = data; ';
4354   } else {
4355     var $lvl = it.level,
4356       $dataLvl = it.dataLevel,
4357       $data = 'data' + ($dataLvl || '');
4358     if ($id) it.baseId = it.resolve.url(it.baseId, $id);
4359     if ($async && !it.async) throw new Error('async schema in sync schema');
4360     out += ' var errs_' + ($lvl) + ' = errors;';
4361   }
4362   var $valid = 'valid' + $lvl,
4363     $breakOnError = !it.opts.allErrors,
4364     $closingBraces1 = '',
4365     $closingBraces2 = '';
4366   var $errorKeyword;
4367   var $typeSchema = it.schema.type,
4368     $typeIsArray = Array.isArray($typeSchema);
4369   if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
4370     if ($typeIsArray) {
4371       if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null');
4372     } else if ($typeSchema != 'null') {
4373       $typeSchema = [$typeSchema, 'null'];
4374       $typeIsArray = true;
4375     }
4376   }
4377   if ($typeIsArray && $typeSchema.length == 1) {
4378     $typeSchema = $typeSchema[0];
4379     $typeIsArray = false;
4380   }
4381   if (it.schema.$ref && $refKeywords) {
4382     if (it.opts.extendRefs == 'fail') {
4383       throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
4384     } else if (it.opts.extendRefs !== true) {
4385       $refKeywords = false;
4386       it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
4387     }
4388   }
4389   if (it.schema.$comment && it.opts.$comment) {
4390     out += ' ' + (it.RULES.all.$comment.code(it, '$comment'));
4391   }
4392   if ($typeSchema) {
4393     if (it.opts.coerceTypes) {
4394       var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
4395     }
4396     var $rulesGroup = it.RULES.types[$typeSchema];
4397     if ($coerceToTypes || $typeIsArray || $rulesGroup === true || ($rulesGroup && !$shouldUseGroup($rulesGroup))) {
4398       var $schemaPath = it.schemaPath + '.type',
4399         $errSchemaPath = it.errSchemaPath + '/type';
4400       var $schemaPath = it.schemaPath + '.type',
4401         $errSchemaPath = it.errSchemaPath + '/type',
4402         $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
4403       out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { ';
4404       if ($coerceToTypes) {
4405         var $dataType = 'dataType' + $lvl,
4406           $coerced = 'coerced' + $lvl;
4407         out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; var ' + ($coerced) + ' = undefined; ';
4408         if (it.opts.coerceTypes == 'array') {
4409           out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ') && ' + ($data) + '.length == 1) { ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; if (' + (it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)) + ') ' + ($coerced) + ' = ' + ($data) + '; } ';
4410         }
4411         out += ' if (' + ($coerced) + ' !== undefined) ; ';
4412         var arr1 = $coerceToTypes;
4413         if (arr1) {
4414           var $type, $i = -1,
4415             l1 = arr1.length - 1;
4416           while ($i < l1) {
4417             $type = arr1[$i += 1];
4418             if ($type == 'string') {
4419               out += ' else if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
4420             } else if ($type == 'number' || $type == 'integer') {
4421               out += ' else if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
4422               if ($type == 'integer') {
4423                 out += ' && !(' + ($data) + ' % 1)';
4424               }
4425               out += ')) ' + ($coerced) + ' = +' + ($data) + '; ';
4426             } else if ($type == 'boolean') {
4427               out += ' else if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
4428             } else if ($type == 'null') {
4429               out += ' else if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
4430             } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
4431               out += ' else if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
4432             }
4433           }
4434         }
4435         out += ' else {   ';
4436         var $$outStack = $$outStack || [];
4437         $$outStack.push(out);
4438         out = ''; /* istanbul ignore else */
4439         if (it.createErrors !== false) {
4440           out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
4441           if ($typeIsArray) {
4442             out += '' + ($typeSchema.join(","));
4443           } else {
4444             out += '' + ($typeSchema);
4445           }
4446           out += '\' } ';
4447           if (it.opts.messages !== false) {
4448             out += ' , message: \'should be ';
4449             if ($typeIsArray) {
4450               out += '' + ($typeSchema.join(","));
4451             } else {
4452               out += '' + ($typeSchema);
4453             }
4454             out += '\' ';
4455           }
4456           if (it.opts.verbose) {
4457             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4458           }
4459           out += ' } ';
4460         } else {
4461           out += ' {} ';
4462         }
4463         var __err = out;
4464         out = $$outStack.pop();
4465         if (!it.compositeRule && $breakOnError) {
4466           /* istanbul ignore if */
4467           if (it.async) {
4468             out += ' throw new ValidationError([' + (__err) + ']); ';
4469           } else {
4470             out += ' validate.errors = [' + (__err) + ']; return false; ';
4471           }
4472         } else {
4473           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4474         }
4475         out += ' } if (' + ($coerced) + ' !== undefined) {  ';
4476         var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
4477           $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
4478         out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
4479         if (!$dataLvl) {
4480           out += 'if (' + ($parentData) + ' !== undefined)';
4481         }
4482         out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } ';
4483       } else {
4484         var $$outStack = $$outStack || [];
4485         $$outStack.push(out);
4486         out = ''; /* istanbul ignore else */
4487         if (it.createErrors !== false) {
4488           out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
4489           if ($typeIsArray) {
4490             out += '' + ($typeSchema.join(","));
4491           } else {
4492             out += '' + ($typeSchema);
4493           }
4494           out += '\' } ';
4495           if (it.opts.messages !== false) {
4496             out += ' , message: \'should be ';
4497             if ($typeIsArray) {
4498               out += '' + ($typeSchema.join(","));
4499             } else {
4500               out += '' + ($typeSchema);
4501             }
4502             out += '\' ';
4503           }
4504           if (it.opts.verbose) {
4505             out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4506           }
4507           out += ' } ';
4508         } else {
4509           out += ' {} ';
4510         }
4511         var __err = out;
4512         out = $$outStack.pop();
4513         if (!it.compositeRule && $breakOnError) {
4514           /* istanbul ignore if */
4515           if (it.async) {
4516             out += ' throw new ValidationError([' + (__err) + ']); ';
4517           } else {
4518             out += ' validate.errors = [' + (__err) + ']; return false; ';
4519           }
4520         } else {
4521           out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4522         }
4523       }
4524       out += ' } ';
4525     }
4526   }
4527   if (it.schema.$ref && !$refKeywords) {
4528     out += ' ' + (it.RULES.all.$ref.code(it, '$ref')) + ' ';
4529     if ($breakOnError) {
4530       out += ' } if (errors === ';
4531       if ($top) {
4532         out += '0';
4533       } else {
4534         out += 'errs_' + ($lvl);
4535       }
4536       out += ') { ';
4537       $closingBraces2 += '}';
4538     }
4539   } else {
4540     var arr2 = it.RULES;
4541     if (arr2) {
4542       var $rulesGroup, i2 = -1,
4543         l2 = arr2.length - 1;
4544       while (i2 < l2) {
4545         $rulesGroup = arr2[i2 += 1];
4546         if ($shouldUseGroup($rulesGroup)) {
4547           if ($rulesGroup.type) {
4548             out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { ';
4549           }
4550           if (it.opts.useDefaults) {
4551             if ($rulesGroup.type == 'object' && it.schema.properties) {
4552               var $schema = it.schema.properties,
4553                 $schemaKeys = Object.keys($schema);
4554               var arr3 = $schemaKeys;
4555               if (arr3) {
4556                 var $propertyKey, i3 = -1,
4557                   l3 = arr3.length - 1;
4558                 while (i3 < l3) {
4559                   $propertyKey = arr3[i3 += 1];
4560                   var $sch = $schema[$propertyKey];
4561                   if ($sch.default !== undefined) {
4562                     var $passData = $data + it.util.getProperty($propertyKey);
4563                     if (it.compositeRule) {
4564                       if (it.opts.strictDefaults) {
4565                         var $defaultMsg = 'default is ignored for: ' + $passData;
4566                         if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
4567                         else throw new Error($defaultMsg);
4568                       }
4569                     } else {
4570                       out += ' if (' + ($passData) + ' === undefined ';
4571                       if (it.opts.useDefaults == 'empty') {
4572                         out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
4573                       }
4574                       out += ' ) ' + ($passData) + ' = ';
4575                       if (it.opts.useDefaults == 'shared') {
4576                         out += ' ' + (it.useDefault($sch.default)) + ' ';
4577                       } else {
4578                         out += ' ' + (JSON.stringify($sch.default)) + ' ';
4579                       }
4580                       out += '; ';
4581                     }
4582                   }
4583                 }
4584               }
4585             } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) {
4586               var arr4 = it.schema.items;
4587               if (arr4) {
4588                 var $sch, $i = -1,
4589                   l4 = arr4.length - 1;
4590                 while ($i < l4) {
4591                   $sch = arr4[$i += 1];
4592                   if ($sch.default !== undefined) {
4593                     var $passData = $data + '[' + $i + ']';
4594                     if (it.compositeRule) {
4595                       if (it.opts.strictDefaults) {
4596                         var $defaultMsg = 'default is ignored for: ' + $passData;
4597                         if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);
4598                         else throw new Error($defaultMsg);
4599                       }
4600                     } else {
4601                       out += ' if (' + ($passData) + ' === undefined ';
4602                       if (it.opts.useDefaults == 'empty') {
4603                         out += ' || ' + ($passData) + ' === null || ' + ($passData) + ' === \'\' ';
4604                       }
4605                       out += ' ) ' + ($passData) + ' = ';
4606                       if (it.opts.useDefaults == 'shared') {
4607                         out += ' ' + (it.useDefault($sch.default)) + ' ';
4608                       } else {
4609                         out += ' ' + (JSON.stringify($sch.default)) + ' ';
4610                       }
4611                       out += '; ';
4612                     }
4613                   }
4614                 }
4615               }
4616             }
4617           }
4618           var arr5 = $rulesGroup.rules;
4619           if (arr5) {
4620             var $rule, i5 = -1,
4621               l5 = arr5.length - 1;
4622             while (i5 < l5) {
4623               $rule = arr5[i5 += 1];
4624               if ($shouldUseRule($rule)) {
4625                 var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
4626                 if ($code) {
4627                   out += ' ' + ($code) + ' ';
4628                   if ($breakOnError) {
4629                     $closingBraces1 += '}';
4630                   }
4631                 }
4632               }
4633             }
4634           }
4635           if ($breakOnError) {
4636             out += ' ' + ($closingBraces1) + ' ';
4637             $closingBraces1 = '';
4638           }
4639           if ($rulesGroup.type) {
4640             out += ' } ';
4641             if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
4642               out += ' else { ';
4643               var $schemaPath = it.schemaPath + '.type',
4644                 $errSchemaPath = it.errSchemaPath + '/type';
4645               var $$outStack = $$outStack || [];
4646               $$outStack.push(out);
4647               out = ''; /* istanbul ignore else */
4648               if (it.createErrors !== false) {
4649                 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
4650                 if ($typeIsArray) {
4651                   out += '' + ($typeSchema.join(","));
4652                 } else {
4653                   out += '' + ($typeSchema);
4654                 }
4655                 out += '\' } ';
4656                 if (it.opts.messages !== false) {
4657                   out += ' , message: \'should be ';
4658                   if ($typeIsArray) {
4659                     out += '' + ($typeSchema.join(","));
4660                   } else {
4661                     out += '' + ($typeSchema);
4662                   }
4663                   out += '\' ';
4664                 }
4665                 if (it.opts.verbose) {
4666                   out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
4667                 }
4668                 out += ' } ';
4669               } else {
4670                 out += ' {} ';
4671               }
4672               var __err = out;
4673               out = $$outStack.pop();
4674               if (!it.compositeRule && $breakOnError) {
4675                 /* istanbul ignore if */
4676                 if (it.async) {
4677                   out += ' throw new ValidationError([' + (__err) + ']); ';
4678                 } else {
4679                   out += ' validate.errors = [' + (__err) + ']; return false; ';
4680                 }
4681               } else {
4682                 out += ' var err = ' + (__err) + ';  if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
4683               }
4684               out += ' } ';
4685             }
4686           }
4687           if ($breakOnError) {
4688             out += ' if (errors === ';
4689             if ($top) {
4690               out += '0';
4691             } else {
4692               out += 'errs_' + ($lvl);
4693             }
4694             out += ') { ';
4695             $closingBraces2 += '}';
4696           }
4697         }
4698       }
4699     }
4700   }
4701   if ($breakOnError) {
4702     out += ' ' + ($closingBraces2) + ' ';
4703   }
4704   if ($top) {
4705     if ($async) {
4706       out += ' if (errors === 0) return data;           ';
4707       out += ' else throw new ValidationError(vErrors); ';
4708     } else {
4709       out += ' validate.errors = vErrors; ';
4710       out += ' return errors === 0;       ';
4711     }
4712     out += ' }; return validate;';
4713   } else {
4714     out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
4715   }
4717   function $shouldUseGroup($rulesGroup) {
4718     var rules = $rulesGroup.rules;
4719     for (var i = 0; i < rules.length; i++)
4720       if ($shouldUseRule(rules[i])) return true;
4721   }
4723   function $shouldUseRule($rule) {
4724     return it.schema[$rule.keyword] !== undefined || ($rule.implements && $ruleImplementsSomeKeyword($rule));
4725   }
4727   function $ruleImplementsSomeKeyword($rule) {
4728     var impl = $rule.implements;
4729     for (var i = 0; i < impl.length; i++)
4730       if (it.schema[impl[i]] !== undefined) return true;
4731   }
4732   return out;
4735 },{}],39:[function(require,module,exports){
4736 'use strict';
4738 var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
4739 var customRuleCode = require('./dotjs/custom');
4740 var definitionSchema = require('./definition_schema');
4742 module.exports = {
4743   add: addKeyword,
4744   get: getKeyword,
4745   remove: removeKeyword,
4746   validate: validateKeyword
4751  * Define custom keyword
4752  * @this  Ajv
4753  * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords).
4754  * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
4755  * @return {Ajv} this for method chaining
4756  */
4757 function addKeyword(keyword, definition) {
4758   /* jshint validthis: true */
4759   /* eslint no-shadow: 0 */
4760   var RULES = this.RULES;
4761   if (RULES.keywords[keyword])
4762     throw new Error('Keyword ' + keyword + ' is already defined');
4764   if (!IDENTIFIER.test(keyword))
4765     throw new Error('Keyword ' + keyword + ' is not a valid identifier');
4767   if (definition) {
4768     this.validateKeyword(definition, true);
4770     var dataType = definition.type;
4771     if (Array.isArray(dataType)) {
4772       for (var i=0; i<dataType.length; i++)
4773         _addRule(keyword, dataType[i], definition);
4774     } else {
4775       _addRule(keyword, dataType, definition);
4776     }
4778     var metaSchema = definition.metaSchema;
4779     if (metaSchema) {
4780       if (definition.$data && this._opts.$data) {
4781         metaSchema = {
4782           anyOf: [
4783             metaSchema,
4784             { '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
4785           ]
4786         };
4787       }
4788       definition.validateSchema = this.compile(metaSchema, true);
4789     }
4790   }
4792   RULES.keywords[keyword] = RULES.all[keyword] = true;
4795   function _addRule(keyword, dataType, definition) {
4796     var ruleGroup;
4797     for (var i=0; i<RULES.length; i++) {
4798       var rg = RULES[i];
4799       if (rg.type == dataType) {
4800         ruleGroup = rg;
4801         break;
4802       }
4803     }
4805     if (!ruleGroup) {
4806       ruleGroup = { type: dataType, rules: [] };
4807       RULES.push(ruleGroup);
4808     }
4810     var rule = {
4811       keyword: keyword,
4812       definition: definition,
4813       custom: true,
4814       code: customRuleCode,
4815       implements: definition.implements
4816     };
4817     ruleGroup.rules.push(rule);
4818     RULES.custom[keyword] = rule;
4819   }
4821   return this;
4826  * Get keyword
4827  * @this  Ajv
4828  * @param {String} keyword pre-defined or custom keyword.
4829  * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
4830  */
4831 function getKeyword(keyword) {
4832   /* jshint validthis: true */
4833   var rule = this.RULES.custom[keyword];
4834   return rule ? rule.definition : this.RULES.keywords[keyword] || false;
4839  * Remove keyword
4840  * @this  Ajv
4841  * @param {String} keyword pre-defined or custom keyword.
4842  * @return {Ajv} this for method chaining
4843  */
4844 function removeKeyword(keyword) {
4845   /* jshint validthis: true */
4846   var RULES = this.RULES;
4847   delete RULES.keywords[keyword];
4848   delete RULES.all[keyword];
4849   delete RULES.custom[keyword];
4850   for (var i=0; i<RULES.length; i++) {
4851     var rules = RULES[i].rules;
4852     for (var j=0; j<rules.length; j++) {
4853       if (rules[j].keyword == keyword) {
4854         rules.splice(j, 1);
4855         break;
4856       }
4857     }
4858   }
4859   return this;
4864  * Validate keyword definition
4865  * @this  Ajv
4866  * @param {Object} definition keyword definition object.
4867  * @param {Boolean} throwError true to throw exception if definition is invalid
4868  * @return {boolean} validation result
4869  */
4870 function validateKeyword(definition, throwError) {
4871   validateKeyword.errors = null;
4872   var v = this._validateKeyword = this._validateKeyword
4873                                   || this.compile(definitionSchema, true);
4875   if (v(definition)) return true;
4876   validateKeyword.errors = v.errors;
4877   if (throwError)
4878     throw new Error('custom keyword definition is invalid: '  + this.errorsText(v.errors));
4879   else
4880     return false;
4883 },{"./definition_schema":12,"./dotjs/custom":22}],40:[function(require,module,exports){
4884 module.exports={
4885     "$schema": "http://json-schema.org/draft-07/schema#",
4886     "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
4887     "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
4888     "type": "object",
4889     "required": [ "$data" ],
4890     "properties": {
4891         "$data": {
4892             "type": "string",
4893             "anyOf": [
4894                 { "format": "relative-json-pointer" }, 
4895                 { "format": "json-pointer" }
4896             ]
4897         }
4898     },
4899     "additionalProperties": false
4902 },{}],41:[function(require,module,exports){
4903 module.exports={
4904     "$schema": "http://json-schema.org/draft-07/schema#",
4905     "$id": "http://json-schema.org/draft-07/schema#",
4906     "title": "Core schema meta-schema",
4907     "definitions": {
4908         "schemaArray": {
4909             "type": "array",
4910             "minItems": 1,
4911             "items": { "$ref": "#" }
4912         },
4913         "nonNegativeInteger": {
4914             "type": "integer",
4915             "minimum": 0
4916         },
4917         "nonNegativeIntegerDefault0": {
4918             "allOf": [
4919                 { "$ref": "#/definitions/nonNegativeInteger" },
4920                 { "default": 0 }
4921             ]
4922         },
4923         "simpleTypes": {
4924             "enum": [
4925                 "array",
4926                 "boolean",
4927                 "integer",
4928                 "null",
4929                 "number",
4930                 "object",
4931                 "string"
4932             ]
4933         },
4934         "stringArray": {
4935             "type": "array",
4936             "items": { "type": "string" },
4937             "uniqueItems": true,
4938             "default": []
4939         }
4940     },
4941     "type": ["object", "boolean"],
4942     "properties": {
4943         "$id": {
4944             "type": "string",
4945             "format": "uri-reference"
4946         },
4947         "$schema": {
4948             "type": "string",
4949             "format": "uri"
4950         },
4951         "$ref": {
4952             "type": "string",
4953             "format": "uri-reference"
4954         },
4955         "$comment": {
4956             "type": "string"
4957         },
4958         "title": {
4959             "type": "string"
4960         },
4961         "description": {
4962             "type": "string"
4963         },
4964         "default": true,
4965         "readOnly": {
4966             "type": "boolean",
4967             "default": false
4968         },
4969         "examples": {
4970             "type": "array",
4971             "items": true
4972         },
4973         "multipleOf": {
4974             "type": "number",
4975             "exclusiveMinimum": 0
4976         },
4977         "maximum": {
4978             "type": "number"
4979         },
4980         "exclusiveMaximum": {
4981             "type": "number"
4982         },
4983         "minimum": {
4984             "type": "number"
4985         },
4986         "exclusiveMinimum": {
4987             "type": "number"
4988         },
4989         "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
4990         "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
4991         "pattern": {
4992             "type": "string",
4993             "format": "regex"
4994         },
4995         "additionalItems": { "$ref": "#" },
4996         "items": {
4997             "anyOf": [
4998                 { "$ref": "#" },
4999                 { "$ref": "#/definitions/schemaArray" }
5000             ],
5001             "default": true
5002         },
5003         "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
5004         "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
5005         "uniqueItems": {
5006             "type": "boolean",
5007             "default": false
5008         },
5009         "contains": { "$ref": "#" },
5010         "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
5011         "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
5012         "required": { "$ref": "#/definitions/stringArray" },
5013         "additionalProperties": { "$ref": "#" },
5014         "definitions": {
5015             "type": "object",
5016             "additionalProperties": { "$ref": "#" },
5017             "default": {}
5018         },
5019         "properties": {
5020             "type": "object",
5021             "additionalProperties": { "$ref": "#" },
5022             "default": {}
5023         },
5024         "patternProperties": {
5025             "type": "object",
5026             "additionalProperties": { "$ref": "#" },
5027             "propertyNames": { "format": "regex" },
5028             "default": {}
5029         },
5030         "dependencies": {
5031             "type": "object",
5032             "additionalProperties": {
5033                 "anyOf": [
5034                     { "$ref": "#" },
5035                     { "$ref": "#/definitions/stringArray" }
5036                 ]
5037             }
5038         },
5039         "propertyNames": { "$ref": "#" },
5040         "const": true,
5041         "enum": {
5042             "type": "array",
5043             "items": true,
5044             "minItems": 1,
5045             "uniqueItems": true
5046         },
5047         "type": {
5048             "anyOf": [
5049                 { "$ref": "#/definitions/simpleTypes" },
5050                 {
5051                     "type": "array",
5052                     "items": { "$ref": "#/definitions/simpleTypes" },
5053                     "minItems": 1,
5054                     "uniqueItems": true
5055                 }
5056             ]
5057         },
5058         "format": { "type": "string" },
5059         "contentMediaType": { "type": "string" },
5060         "contentEncoding": { "type": "string" },
5061         "if": {"$ref": "#"},
5062         "then": {"$ref": "#"},
5063         "else": {"$ref": "#"},
5064         "allOf": { "$ref": "#/definitions/schemaArray" },
5065         "anyOf": { "$ref": "#/definitions/schemaArray" },
5066         "oneOf": { "$ref": "#/definitions/schemaArray" },
5067         "not": { "$ref": "#" }
5068     },
5069     "default": true
5072 },{}],42:[function(require,module,exports){
5073 'use strict';
5075 // do not edit .js files directly - edit src/index.jst
5079 module.exports = function equal(a, b) {
5080   if (a === b) return true;
5082   if (a && b && typeof a == 'object' && typeof b == 'object') {
5083     if (a.constructor !== b.constructor) return false;
5085     var length, i, keys;
5086     if (Array.isArray(a)) {
5087       length = a.length;
5088       if (length != b.length) return false;
5089       for (i = length; i-- !== 0;)
5090         if (!equal(a[i], b[i])) return false;
5091       return true;
5092     }
5096     if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
5097     if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
5098     if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
5100     keys = Object.keys(a);
5101     length = keys.length;
5102     if (length !== Object.keys(b).length) return false;
5104     for (i = length; i-- !== 0;)
5105       if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
5107     for (i = length; i-- !== 0;) {
5108       var key = keys[i];
5110       if (!equal(a[key], b[key])) return false;
5111     }
5113     return true;
5114   }
5116   // true if both NaN, false otherwise
5117   return a!==a && b!==b;
5120 },{}],43:[function(require,module,exports){
5121 'use strict';
5123 module.exports = function (data, opts) {
5124     if (!opts) opts = {};
5125     if (typeof opts === 'function') opts = { cmp: opts };
5126     var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
5128     var cmp = opts.cmp && (function (f) {
5129         return function (node) {
5130             return function (a, b) {
5131                 var aobj = { key: a, value: node[a] };
5132                 var bobj = { key: b, value: node[b] };
5133                 return f(aobj, bobj);
5134             };
5135         };
5136     })(opts.cmp);
5138     var seen = [];
5139     return (function stringify (node) {
5140         if (node && node.toJSON && typeof node.toJSON === 'function') {
5141             node = node.toJSON();
5142         }
5144         if (node === undefined) return;
5145         if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
5146         if (typeof node !== 'object') return JSON.stringify(node);
5148         var i, out;
5149         if (Array.isArray(node)) {
5150             out = '[';
5151             for (i = 0; i < node.length; i++) {
5152                 if (i) out += ',';
5153                 out += stringify(node[i]) || 'null';
5154             }
5155             return out + ']';
5156         }
5158         if (node === null) return 'null';
5160         if (seen.indexOf(node) !== -1) {
5161             if (cycles) return JSON.stringify('__cycle__');
5162             throw new TypeError('Converting circular structure to JSON');
5163         }
5165         var seenIndex = seen.push(node) - 1;
5166         var keys = Object.keys(node).sort(cmp && cmp(node));
5167         out = '';
5168         for (i = 0; i < keys.length; i++) {
5169             var key = keys[i];
5170             var value = stringify(node[key]);
5172             if (!value) continue;
5173             if (out) out += ',';
5174             out += JSON.stringify(key) + ':' + value;
5175         }
5176         seen.splice(seenIndex, 1);
5177         return '{' + out + '}';
5178     })(data);
5181 },{}],44:[function(require,module,exports){
5182 'use strict';
5184 var traverse = module.exports = function (schema, opts, cb) {
5185   // Legacy support for v0.3.1 and earlier.
5186   if (typeof opts == 'function') {
5187     cb = opts;
5188     opts = {};
5189   }
5191   cb = opts.cb || cb;
5192   var pre = (typeof cb == 'function') ? cb : cb.pre || function() {};
5193   var post = cb.post || function() {};
5195   _traverse(opts, pre, post, schema, '', schema);
5199 traverse.keywords = {
5200   additionalItems: true,
5201   items: true,
5202   contains: true,
5203   additionalProperties: true,
5204   propertyNames: true,
5205   not: true
5208 traverse.arrayKeywords = {
5209   items: true,
5210   allOf: true,
5211   anyOf: true,
5212   oneOf: true
5215 traverse.propsKeywords = {
5216   definitions: true,
5217   properties: true,
5218   patternProperties: true,
5219   dependencies: true
5222 traverse.skipKeywords = {
5223   default: true,
5224   enum: true,
5225   const: true,
5226   required: true,
5227   maximum: true,
5228   minimum: true,
5229   exclusiveMaximum: true,
5230   exclusiveMinimum: true,
5231   multipleOf: true,
5232   maxLength: true,
5233   minLength: true,
5234   pattern: true,
5235   format: true,
5236   maxItems: true,
5237   minItems: true,
5238   uniqueItems: true,
5239   maxProperties: true,
5240   minProperties: true
5244 function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
5245   if (schema && typeof schema == 'object' && !Array.isArray(schema)) {
5246     pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
5247     for (var key in schema) {
5248       var sch = schema[key];
5249       if (Array.isArray(sch)) {
5250         if (key in traverse.arrayKeywords) {
5251           for (var i=0; i<sch.length; i++)
5252             _traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i);
5253         }
5254       } else if (key in traverse.propsKeywords) {
5255         if (sch && typeof sch == 'object') {
5256           for (var prop in sch)
5257             _traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
5258         }
5259       } else if (key in traverse.keywords || (opts.allKeys && !(key in traverse.skipKeywords))) {
5260         _traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema);
5261       }
5262     }
5263     post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
5264   }
5268 function escapeJsonPtr(str) {
5269   return str.replace(/~/g, '~0').replace(/\//g, '~1');
5272 },{}],45:[function(require,module,exports){
5273 /** @license URI.js v4.4.0 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
5274 (function (global, factory) {
5275         typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
5276         typeof define === 'function' && define.amd ? define(['exports'], factory) :
5277         (factory((global.URI = global.URI || {})));
5278 }(this, (function (exports) { 'use strict';
5280 function merge() {
5281     for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
5282         sets[_key] = arguments[_key];
5283     }
5285     if (sets.length > 1) {
5286         sets[0] = sets[0].slice(0, -1);
5287         var xl = sets.length - 1;
5288         for (var x = 1; x < xl; ++x) {
5289             sets[x] = sets[x].slice(1, -1);
5290         }
5291         sets[xl] = sets[xl].slice(1);
5292         return sets.join('');
5293     } else {
5294         return sets[0];
5295     }
5297 function subexp(str) {
5298     return "(?:" + str + ")";
5300 function typeOf(o) {
5301     return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
5303 function toUpperCase(str) {
5304     return str.toUpperCase();
5306 function toArray(obj) {
5307     return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
5309 function assign(target, source) {
5310     var obj = target;
5311     if (source) {
5312         for (var key in source) {
5313             obj[key] = source[key];
5314         }
5315     }
5316     return obj;
5319 function buildExps(isIRI) {
5320     var ALPHA$$ = "[A-Za-z]",
5321         CR$ = "[\\x0D]",
5322         DIGIT$$ = "[0-9]",
5323         DQUOTE$$ = "[\\x22]",
5324         HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
5325         //case-insensitive
5326     LF$$ = "[\\x0A]",
5327         SP$$ = "[\\x20]",
5328         PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
5329         //expanded
5330     GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
5331         SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
5332         RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
5333         UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]",
5334         //subset, excludes bidi control characters
5335     IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
5336         //subset
5337     UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$),
5338         SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
5339         USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
5340         DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
5341         DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
5342         //relaxed parsing rules
5343     IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
5344         H16$ = subexp(HEXDIG$$ + "{1,4}"),
5345         LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
5346         IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
5347         //                           6( h16 ":" ) ls32
5348     IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
5349         //                      "::" 5( h16 ":" ) ls32
5350     IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
5351         //[               h16 ] "::" 4( h16 ":" ) ls32
5352     IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
5353         //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
5354     IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
5355         //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
5356     IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
5357         //[ *3( h16 ":" ) h16 ] "::"    h16 ":"   ls32
5358     IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
5359         //[ *4( h16 ":" ) h16 ] "::"              ls32
5360     IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
5361         //[ *5( h16 ":" ) h16 ] "::"              h16
5362     IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
5363         //[ *6( h16 ":" ) h16 ] "::"
5364     IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
5365         ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
5366         //RFC 6874
5367     IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
5368         //RFC 6874
5369     IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
5370         //RFC 6874, with relaxed parsing rules
5371     IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
5372         IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
5373         //RFC 6874
5374     REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
5375         HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),
5376         PORT$ = subexp(DIGIT$$ + "*"),
5377         AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
5378         PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
5379         SEGMENT$ = subexp(PCHAR$ + "*"),
5380         SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
5381         SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
5382         PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
5383         PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"),
5384         //simplified
5385     PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$),
5386         //simplified
5387     PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$),
5388         //simplified
5389     PATH_EMPTY$ = "(?!" + PCHAR$ + ")",
5390         PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
5391         QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"),
5392         FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
5393         HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
5394         URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
5395         RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
5396         RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
5397         URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$),
5398         ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
5399         GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
5400         RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
5401         ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$",
5402         SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
5403         AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
5404     return {
5405         NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
5406         NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5407         NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5408         NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5409         NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5410         NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
5411         NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
5412         ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
5413         UNRESERVED: new RegExp(UNRESERVED$$, "g"),
5414         OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
5415         PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
5416         IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
5417         IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
5418     };
5420 var URI_PROTOCOL = buildExps(false);
5422 var IRI_PROTOCOL = buildExps(true);
5424 var slicedToArray = function () {
5425   function sliceIterator(arr, i) {
5426     var _arr = [];
5427     var _n = true;
5428     var _d = false;
5429     var _e = undefined;
5431     try {
5432       for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
5433         _arr.push(_s.value);
5435         if (i && _arr.length === i) break;
5436       }
5437     } catch (err) {
5438       _d = true;
5439       _e = err;
5440     } finally {
5441       try {
5442         if (!_n && _i["return"]) _i["return"]();
5443       } finally {
5444         if (_d) throw _e;
5445       }
5446     }
5448     return _arr;
5449   }
5451   return function (arr, i) {
5452     if (Array.isArray(arr)) {
5453       return arr;
5454     } else if (Symbol.iterator in Object(arr)) {
5455       return sliceIterator(arr, i);
5456     } else {
5457       throw new TypeError("Invalid attempt to destructure non-iterable instance");
5458     }
5459   };
5460 }();
5474 var toConsumableArray = function (arr) {
5475   if (Array.isArray(arr)) {
5476     for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
5478     return arr2;
5479   } else {
5480     return Array.from(arr);
5481   }
5484 /** Highest positive signed 32-bit float value */
5486 var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
5488 /** Bootstring parameters */
5489 var base = 36;
5490 var tMin = 1;
5491 var tMax = 26;
5492 var skew = 38;
5493 var damp = 700;
5494 var initialBias = 72;
5495 var initialN = 128; // 0x80
5496 var delimiter = '-'; // '\x2D'
5498 /** Regular expressions */
5499 var regexPunycode = /^xn--/;
5500 var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
5501 var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
5503 /** Error messages */
5504 var errors = {
5505         'overflow': 'Overflow: input needs wider integers to process',
5506         'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
5507         'invalid-input': 'Invalid input'
5510 /** Convenience shortcuts */
5511 var baseMinusTMin = base - tMin;
5512 var floor = Math.floor;
5513 var stringFromCharCode = String.fromCharCode;
5515 /*--------------------------------------------------------------------------*/
5518  * A generic error utility function.
5519  * @private
5520  * @param {String} type The error type.
5521  * @returns {Error} Throws a `RangeError` with the applicable error message.
5522  */
5523 function error$1(type) {
5524         throw new RangeError(errors[type]);
5528  * A generic `Array#map` utility function.
5529  * @private
5530  * @param {Array} array The array to iterate over.
5531  * @param {Function} callback The function that gets called for every array
5532  * item.
5533  * @returns {Array} A new array of values returned by the callback function.
5534  */
5535 function map(array, fn) {
5536         var result = [];
5537         var length = array.length;
5538         while (length--) {
5539                 result[length] = fn(array[length]);
5540         }
5541         return result;
5545  * A simple `Array#map`-like wrapper to work with domain name strings or email
5546  * addresses.
5547  * @private
5548  * @param {String} domain The domain name or email address.
5549  * @param {Function} callback The function that gets called for every
5550  * character.
5551  * @returns {Array} A new string of characters returned by the callback
5552  * function.
5553  */
5554 function mapDomain(string, fn) {
5555         var parts = string.split('@');
5556         var result = '';
5557         if (parts.length > 1) {
5558                 // In email addresses, only the domain name should be punycoded. Leave
5559                 // the local part (i.e. everything up to `@`) intact.
5560                 result = parts[0] + '@';
5561                 string = parts[1];
5562         }
5563         // Avoid `split(regex)` for IE8 compatibility. See #17.
5564         string = string.replace(regexSeparators, '\x2E');
5565         var labels = string.split('.');
5566         var encoded = map(labels, fn).join('.');
5567         return result + encoded;
5571  * Creates an array containing the numeric code points of each Unicode
5572  * character in the string. While JavaScript uses UCS-2 internally,
5573  * this function will convert a pair of surrogate halves (each of which
5574  * UCS-2 exposes as separate characters) into a single code point,
5575  * matching UTF-16.
5576  * @see `punycode.ucs2.encode`
5577  * @see <https://mathiasbynens.be/notes/javascript-encoding>
5578  * @memberOf punycode.ucs2
5579  * @name decode
5580  * @param {String} string The Unicode input string (UCS-2).
5581  * @returns {Array} The new array of code points.
5582  */
5583 function ucs2decode(string) {
5584         var output = [];
5585         var counter = 0;
5586         var length = string.length;
5587         while (counter < length) {
5588                 var value = string.charCodeAt(counter++);
5589                 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
5590                         // It's a high surrogate, and there is a next character.
5591                         var extra = string.charCodeAt(counter++);
5592                         if ((extra & 0xFC00) == 0xDC00) {
5593                                 // Low surrogate.
5594                                 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
5595                         } else {
5596                                 // It's an unmatched surrogate; only append this code unit, in case the
5597                                 // next code unit is the high surrogate of a surrogate pair.
5598                                 output.push(value);
5599                                 counter--;
5600                         }
5601                 } else {
5602                         output.push(value);
5603                 }
5604         }
5605         return output;
5609  * Creates a string based on an array of numeric code points.
5610  * @see `punycode.ucs2.decode`
5611  * @memberOf punycode.ucs2
5612  * @name encode
5613  * @param {Array} codePoints The array of numeric code points.
5614  * @returns {String} The new Unicode string (UCS-2).
5615  */
5616 var ucs2encode = function ucs2encode(array) {
5617         return String.fromCodePoint.apply(String, toConsumableArray(array));
5621  * Converts a basic code point into a digit/integer.
5622  * @see `digitToBasic()`
5623  * @private
5624  * @param {Number} codePoint The basic numeric code point value.
5625  * @returns {Number} The numeric value of a basic code point (for use in
5626  * representing integers) in the range `0` to `base - 1`, or `base` if
5627  * the code point does not represent a value.
5628  */
5629 var basicToDigit = function basicToDigit(codePoint) {
5630         if (codePoint - 0x30 < 0x0A) {
5631                 return codePoint - 0x16;
5632         }
5633         if (codePoint - 0x41 < 0x1A) {
5634                 return codePoint - 0x41;
5635         }
5636         if (codePoint - 0x61 < 0x1A) {
5637                 return codePoint - 0x61;
5638         }
5639         return base;
5643  * Converts a digit/integer into a basic code point.
5644  * @see `basicToDigit()`
5645  * @private
5646  * @param {Number} digit The numeric value of a basic code point.
5647  * @returns {Number} The basic code point whose value (when used for
5648  * representing integers) is `digit`, which needs to be in the range
5649  * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
5650  * used; else, the lowercase form is used. The behavior is undefined
5651  * if `flag` is non-zero and `digit` has no uppercase form.
5652  */
5653 var digitToBasic = function digitToBasic(digit, flag) {
5654         //  0..25 map to ASCII a..z or A..Z
5655         // 26..35 map to ASCII 0..9
5656         return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
5660  * Bias adaptation function as per section 3.4 of RFC 3492.
5661  * https://tools.ietf.org/html/rfc3492#section-3.4
5662  * @private
5663  */
5664 var adapt = function adapt(delta, numPoints, firstTime) {
5665         var k = 0;
5666         delta = firstTime ? floor(delta / damp) : delta >> 1;
5667         delta += floor(delta / numPoints);
5668         for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) {
5669                 delta = floor(delta / baseMinusTMin);
5670         }
5671         return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
5675  * Converts a Punycode string of ASCII-only symbols to a string of Unicode
5676  * symbols.
5677  * @memberOf punycode
5678  * @param {String} input The Punycode string of ASCII-only symbols.
5679  * @returns {String} The resulting string of Unicode symbols.
5680  */
5681 var decode = function decode(input) {
5682         // Don't use UCS-2.
5683         var output = [];
5684         var inputLength = input.length;
5685         var i = 0;
5686         var n = initialN;
5687         var bias = initialBias;
5689         // Handle the basic code points: let `basic` be the number of input code
5690         // points before the last delimiter, or `0` if there is none, then copy
5691         // the first basic code points to the output.
5693         var basic = input.lastIndexOf(delimiter);
5694         if (basic < 0) {
5695                 basic = 0;
5696         }
5698         for (var j = 0; j < basic; ++j) {
5699                 // if it's not a basic code point
5700                 if (input.charCodeAt(j) >= 0x80) {
5701                         error$1('not-basic');
5702                 }
5703                 output.push(input.charCodeAt(j));
5704         }
5706         // Main decoding loop: start just after the last delimiter if any basic code
5707         // points were copied; start at the beginning otherwise.
5709         for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{
5711                 // `index` is the index of the next character to be consumed.
5712                 // Decode a generalized variable-length integer into `delta`,
5713                 // which gets added to `i`. The overflow checking is easier
5714                 // if we increase `i` as we go, then subtract off its starting
5715                 // value at the end to obtain `delta`.
5716                 var oldi = i;
5717                 for (var w = 1, k = base;; /* no condition */k += base) {
5719                         if (index >= inputLength) {
5720                                 error$1('invalid-input');
5721                         }
5723                         var digit = basicToDigit(input.charCodeAt(index++));
5725                         if (digit >= base || digit > floor((maxInt - i) / w)) {
5726                                 error$1('overflow');
5727                         }
5729                         i += digit * w;
5730                         var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
5732                         if (digit < t) {
5733                                 break;
5734                         }
5736                         var baseMinusT = base - t;
5737                         if (w > floor(maxInt / baseMinusT)) {
5738                                 error$1('overflow');
5739                         }
5741                         w *= baseMinusT;
5742                 }
5744                 var out = output.length + 1;
5745                 bias = adapt(i - oldi, out, oldi == 0);
5747                 // `i` was supposed to wrap around from `out` to `0`,
5748                 // incrementing `n` each time, so we'll fix that now:
5749                 if (floor(i / out) > maxInt - n) {
5750                         error$1('overflow');
5751                 }
5753                 n += floor(i / out);
5754                 i %= out;
5756                 // Insert `n` at position `i` of the output.
5757                 output.splice(i++, 0, n);
5758         }
5760         return String.fromCodePoint.apply(String, output);
5764  * Converts a string of Unicode symbols (e.g. a domain name label) to a
5765  * Punycode string of ASCII-only symbols.
5766  * @memberOf punycode
5767  * @param {String} input The string of Unicode symbols.
5768  * @returns {String} The resulting Punycode string of ASCII-only symbols.
5769  */
5770 var encode = function encode(input) {
5771         var output = [];
5773         // Convert the input in UCS-2 to an array of Unicode code points.
5774         input = ucs2decode(input);
5776         // Cache the length.
5777         var inputLength = input.length;
5779         // Initialize the state.
5780         var n = initialN;
5781         var delta = 0;
5782         var bias = initialBias;
5784         // Handle the basic code points.
5785         var _iteratorNormalCompletion = true;
5786         var _didIteratorError = false;
5787         var _iteratorError = undefined;
5789         try {
5790                 for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
5791                         var _currentValue2 = _step.value;
5793                         if (_currentValue2 < 0x80) {
5794                                 output.push(stringFromCharCode(_currentValue2));
5795                         }
5796                 }
5797         } catch (err) {
5798                 _didIteratorError = true;
5799                 _iteratorError = err;
5800         } finally {
5801                 try {
5802                         if (!_iteratorNormalCompletion && _iterator.return) {
5803                                 _iterator.return();
5804                         }
5805                 } finally {
5806                         if (_didIteratorError) {
5807                                 throw _iteratorError;
5808                         }
5809                 }
5810         }
5812         var basicLength = output.length;
5813         var handledCPCount = basicLength;
5815         // `handledCPCount` is the number of code points that have been handled;
5816         // `basicLength` is the number of basic code points.
5818         // Finish the basic string with a delimiter unless it's empty.
5819         if (basicLength) {
5820                 output.push(delimiter);
5821         }
5823         // Main encoding loop:
5824         while (handledCPCount < inputLength) {
5826                 // All non-basic code points < n have been handled already. Find the next
5827                 // larger one:
5828                 var m = maxInt;
5829                 var _iteratorNormalCompletion2 = true;
5830                 var _didIteratorError2 = false;
5831                 var _iteratorError2 = undefined;
5833                 try {
5834                         for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
5835                                 var currentValue = _step2.value;
5837                                 if (currentValue >= n && currentValue < m) {
5838                                         m = currentValue;
5839                                 }
5840                         }
5842                         // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
5843                         // but guard against overflow.
5844                 } catch (err) {
5845                         _didIteratorError2 = true;
5846                         _iteratorError2 = err;
5847                 } finally {
5848                         try {
5849                                 if (!_iteratorNormalCompletion2 && _iterator2.return) {
5850                                         _iterator2.return();
5851                                 }
5852                         } finally {
5853                                 if (_didIteratorError2) {
5854                                         throw _iteratorError2;
5855                                 }
5856                         }
5857                 }
5859                 var handledCPCountPlusOne = handledCPCount + 1;
5860                 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
5861                         error$1('overflow');
5862                 }
5864                 delta += (m - n) * handledCPCountPlusOne;
5865                 n = m;
5867                 var _iteratorNormalCompletion3 = true;
5868                 var _didIteratorError3 = false;
5869                 var _iteratorError3 = undefined;
5871                 try {
5872                         for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
5873                                 var _currentValue = _step3.value;
5875                                 if (_currentValue < n && ++delta > maxInt) {
5876                                         error$1('overflow');
5877                                 }
5878                                 if (_currentValue == n) {
5879                                         // Represent delta as a generalized variable-length integer.
5880                                         var q = delta;
5881                                         for (var k = base;; /* no condition */k += base) {
5882                                                 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
5883                                                 if (q < t) {
5884                                                         break;
5885                                                 }
5886                                                 var qMinusT = q - t;
5887                                                 var baseMinusT = base - t;
5888                                                 output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
5889                                                 q = floor(qMinusT / baseMinusT);
5890                                         }
5892                                         output.push(stringFromCharCode(digitToBasic(q, 0)));
5893                                         bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
5894                                         delta = 0;
5895                                         ++handledCPCount;
5896                                 }
5897                         }
5898                 } catch (err) {
5899                         _didIteratorError3 = true;
5900                         _iteratorError3 = err;
5901                 } finally {
5902                         try {
5903                                 if (!_iteratorNormalCompletion3 && _iterator3.return) {
5904                                         _iterator3.return();
5905                                 }
5906                         } finally {
5907                                 if (_didIteratorError3) {
5908                                         throw _iteratorError3;
5909                                 }
5910                         }
5911                 }
5913                 ++delta;
5914                 ++n;
5915         }
5916         return output.join('');
5920  * Converts a Punycode string representing a domain name or an email address
5921  * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
5922  * it doesn't matter if you call it on a string that has already been
5923  * converted to Unicode.
5924  * @memberOf punycode
5925  * @param {String} input The Punycoded domain name or email address to
5926  * convert to Unicode.
5927  * @returns {String} The Unicode representation of the given Punycode
5928  * string.
5929  */
5930 var toUnicode = function toUnicode(input) {
5931         return mapDomain(input, function (string) {
5932                 return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
5933         });
5937  * Converts a Unicode string representing a domain name or an email address to
5938  * Punycode. Only the non-ASCII parts of the domain name will be converted,
5939  * i.e. it doesn't matter if you call it with a domain that's already in
5940  * ASCII.
5941  * @memberOf punycode
5942  * @param {String} input The domain name or email address to convert, as a
5943  * Unicode string.
5944  * @returns {String} The Punycode representation of the given domain name or
5945  * email address.
5946  */
5947 var toASCII = function toASCII(input) {
5948         return mapDomain(input, function (string) {
5949                 return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
5950         });
5953 /*--------------------------------------------------------------------------*/
5955 /** Define the public API */
5956 var punycode = {
5957         /**
5958   * A string representing the current Punycode.js version number.
5959   * @memberOf punycode
5960   * @type String
5961   */
5962         'version': '2.1.0',
5963         /**
5964   * An object of methods to convert from JavaScript's internal character
5965   * representation (UCS-2) to Unicode code points, and back.
5966   * @see <https://mathiasbynens.be/notes/javascript-encoding>
5967   * @memberOf punycode
5968   * @type Object
5969   */
5970         'ucs2': {
5971                 'decode': ucs2decode,
5972                 'encode': ucs2encode
5973         },
5974         'decode': decode,
5975         'encode': encode,
5976         'toASCII': toASCII,
5977         'toUnicode': toUnicode
5981  * URI.js
5983  * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
5984  * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
5985  * @see http://github.com/garycourt/uri-js
5986  */
5988  * Copyright 2011 Gary Court. All rights reserved.
5990  * Redistribution and use in source and binary forms, with or without modification, are
5991  * permitted provided that the following conditions are met:
5993  *    1. Redistributions of source code must retain the above copyright notice, this list of
5994  *       conditions and the following disclaimer.
5996  *    2. Redistributions in binary form must reproduce the above copyright notice, this list
5997  *       of conditions and the following disclaimer in the documentation and/or other materials
5998  *       provided with the distribution.
6000  * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
6001  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
6002  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
6003  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
6004  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
6005  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
6006  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
6007  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
6008  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6010  * The views and conclusions contained in the software and documentation are those of the
6011  * authors and should not be interpreted as representing official policies, either expressed
6012  * or implied, of Gary Court.
6013  */
6014 var SCHEMES = {};
6015 function pctEncChar(chr) {
6016     var c = chr.charCodeAt(0);
6017     var e = void 0;
6018     if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
6019     return e;
6021 function pctDecChars(str) {
6022     var newStr = "";
6023     var i = 0;
6024     var il = str.length;
6025     while (i < il) {
6026         var c = parseInt(str.substr(i + 1, 2), 16);
6027         if (c < 128) {
6028             newStr += String.fromCharCode(c);
6029             i += 3;
6030         } else if (c >= 194 && c < 224) {
6031             if (il - i >= 6) {
6032                 var c2 = parseInt(str.substr(i + 4, 2), 16);
6033                 newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
6034             } else {
6035                 newStr += str.substr(i, 6);
6036             }
6037             i += 6;
6038         } else if (c >= 224) {
6039             if (il - i >= 9) {
6040                 var _c = parseInt(str.substr(i + 4, 2), 16);
6041                 var c3 = parseInt(str.substr(i + 7, 2), 16);
6042                 newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
6043             } else {
6044                 newStr += str.substr(i, 9);
6045             }
6046             i += 9;
6047         } else {
6048             newStr += str.substr(i, 3);
6049             i += 3;
6050         }
6051     }
6052     return newStr;
6054 function _normalizeComponentEncoding(components, protocol) {
6055     function decodeUnreserved(str) {
6056         var decStr = pctDecChars(str);
6057         return !decStr.match(protocol.UNRESERVED) ? str : decStr;
6058     }
6059     if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
6060     if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6061     if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6062     if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6063     if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6064     if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
6065     return components;
6068 function _stripLeadingZeros(str) {
6069     return str.replace(/^0*(.*)/, "$1") || "0";
6071 function _normalizeIPv4(host, protocol) {
6072     var matches = host.match(protocol.IPV4ADDRESS) || [];
6074     var _matches = slicedToArray(matches, 2),
6075         address = _matches[1];
6077     if (address) {
6078         return address.split(".").map(_stripLeadingZeros).join(".");
6079     } else {
6080         return host;
6081     }
6083 function _normalizeIPv6(host, protocol) {
6084     var matches = host.match(protocol.IPV6ADDRESS) || [];
6086     var _matches2 = slicedToArray(matches, 3),
6087         address = _matches2[1],
6088         zone = _matches2[2];
6090     if (address) {
6091         var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
6092             _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
6093             last = _address$toLowerCase$2[0],
6094             first = _address$toLowerCase$2[1];
6096         var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
6097         var lastFields = last.split(":").map(_stripLeadingZeros);
6098         var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
6099         var fieldCount = isLastFieldIPv4Address ? 7 : 8;
6100         var lastFieldsStart = lastFields.length - fieldCount;
6101         var fields = Array(fieldCount);
6102         for (var x = 0; x < fieldCount; ++x) {
6103             fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
6104         }
6105         if (isLastFieldIPv4Address) {
6106             fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
6107         }
6108         var allZeroFields = fields.reduce(function (acc, field, index) {
6109             if (!field || field === "0") {
6110                 var lastLongest = acc[acc.length - 1];
6111                 if (lastLongest && lastLongest.index + lastLongest.length === index) {
6112                     lastLongest.length++;
6113                 } else {
6114                     acc.push({ index: index, length: 1 });
6115                 }
6116             }
6117             return acc;
6118         }, []);
6119         var longestZeroFields = allZeroFields.sort(function (a, b) {
6120             return b.length - a.length;
6121         })[0];
6122         var newHost = void 0;
6123         if (longestZeroFields && longestZeroFields.length > 1) {
6124             var newFirst = fields.slice(0, longestZeroFields.index);
6125             var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
6126             newHost = newFirst.join(":") + "::" + newLast.join(":");
6127         } else {
6128             newHost = fields.join(":");
6129         }
6130         if (zone) {
6131             newHost += "%" + zone;
6132         }
6133         return newHost;
6134     } else {
6135         return host;
6136     }
6138 var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
6139 var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
6140 function parse(uriString) {
6141     var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6143     var components = {};
6144     var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
6145     if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
6146     var matches = uriString.match(URI_PARSE);
6147     if (matches) {
6148         if (NO_MATCH_IS_UNDEFINED) {
6149             //store each component
6150             components.scheme = matches[1];
6151             components.userinfo = matches[3];
6152             components.host = matches[4];
6153             components.port = parseInt(matches[5], 10);
6154             components.path = matches[6] || "";
6155             components.query = matches[7];
6156             components.fragment = matches[8];
6157             //fix port number
6158             if (isNaN(components.port)) {
6159                 components.port = matches[5];
6160             }
6161         } else {
6162             //IE FIX for improper RegExp matching
6163             //store each component
6164             components.scheme = matches[1] || undefined;
6165             components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
6166             components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
6167             components.port = parseInt(matches[5], 10);
6168             components.path = matches[6] || "";
6169             components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
6170             components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined;
6171             //fix port number
6172             if (isNaN(components.port)) {
6173                 components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
6174             }
6175         }
6176         if (components.host) {
6177             //normalize IP hosts
6178             components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
6179         }
6180         //determine reference type
6181         if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
6182             components.reference = "same-document";
6183         } else if (components.scheme === undefined) {
6184             components.reference = "relative";
6185         } else if (components.fragment === undefined) {
6186             components.reference = "absolute";
6187         } else {
6188             components.reference = "uri";
6189         }
6190         //check for reference errors
6191         if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
6192             components.error = components.error || "URI is not a " + options.reference + " reference.";
6193         }
6194         //find scheme handler
6195         var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
6196         //check if scheme can't handle IRIs
6197         if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
6198             //if host component is a domain name
6199             if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
6200                 //convert Unicode IDN -> ASCII IDN
6201                 try {
6202                     components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
6203                 } catch (e) {
6204                     components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
6205                 }
6206             }
6207             //convert IRI -> URI
6208             _normalizeComponentEncoding(components, URI_PROTOCOL);
6209         } else {
6210             //normalize encodings
6211             _normalizeComponentEncoding(components, protocol);
6212         }
6213         //perform scheme specific parsing
6214         if (schemeHandler && schemeHandler.parse) {
6215             schemeHandler.parse(components, options);
6216         }
6217     } else {
6218         components.error = components.error || "URI can not be parsed.";
6219     }
6220     return components;
6223 function _recomposeAuthority(components, options) {
6224     var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
6225     var uriTokens = [];
6226     if (components.userinfo !== undefined) {
6227         uriTokens.push(components.userinfo);
6228         uriTokens.push("@");
6229     }
6230     if (components.host !== undefined) {
6231         //normalize IP hosts, add brackets and escape zone separator for IPv6
6232         uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
6233             return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
6234         }));
6235     }
6236     if (typeof components.port === "number" || typeof components.port === "string") {
6237         uriTokens.push(":");
6238         uriTokens.push(String(components.port));
6239     }
6240     return uriTokens.length ? uriTokens.join("") : undefined;
6243 var RDS1 = /^\.\.?\//;
6244 var RDS2 = /^\/\.(\/|$)/;
6245 var RDS3 = /^\/\.\.(\/|$)/;
6246 var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
6247 function removeDotSegments(input) {
6248     var output = [];
6249     while (input.length) {
6250         if (input.match(RDS1)) {
6251             input = input.replace(RDS1, "");
6252         } else if (input.match(RDS2)) {
6253             input = input.replace(RDS2, "/");
6254         } else if (input.match(RDS3)) {
6255             input = input.replace(RDS3, "/");
6256             output.pop();
6257         } else if (input === "." || input === "..") {
6258             input = "";
6259         } else {
6260             var im = input.match(RDS5);
6261             if (im) {
6262                 var s = im[0];
6263                 input = input.slice(s.length);
6264                 output.push(s);
6265             } else {
6266                 throw new Error("Unexpected dot segment condition");
6267             }
6268         }
6269     }
6270     return output.join("");
6273 function serialize(components) {
6274     var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6276     var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
6277     var uriTokens = [];
6278     //find scheme handler
6279     var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
6280     //perform scheme specific serialization
6281     if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
6282     if (components.host) {
6283         //if host component is an IPv6 address
6284         if (protocol.IPV6ADDRESS.test(components.host)) {}
6285         //TODO: normalize IPv6 address as per RFC 5952
6287         //if host component is a domain name
6288         else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
6289                 //convert IDN via punycode
6290                 try {
6291                     components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
6292                 } catch (e) {
6293                     components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
6294                 }
6295             }
6296     }
6297     //normalize encoding
6298     _normalizeComponentEncoding(components, protocol);
6299     if (options.reference !== "suffix" && components.scheme) {
6300         uriTokens.push(components.scheme);
6301         uriTokens.push(":");
6302     }
6303     var authority = _recomposeAuthority(components, options);
6304     if (authority !== undefined) {
6305         if (options.reference !== "suffix") {
6306             uriTokens.push("//");
6307         }
6308         uriTokens.push(authority);
6309         if (components.path && components.path.charAt(0) !== "/") {
6310             uriTokens.push("/");
6311         }
6312     }
6313     if (components.path !== undefined) {
6314         var s = components.path;
6315         if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
6316             s = removeDotSegments(s);
6317         }
6318         if (authority === undefined) {
6319             s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
6320         }
6321         uriTokens.push(s);
6322     }
6323     if (components.query !== undefined) {
6324         uriTokens.push("?");
6325         uriTokens.push(components.query);
6326     }
6327     if (components.fragment !== undefined) {
6328         uriTokens.push("#");
6329         uriTokens.push(components.fragment);
6330     }
6331     return uriTokens.join(""); //merge tokens into a string
6334 function resolveComponents(base, relative) {
6335     var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6336     var skipNormalization = arguments[3];
6338     var target = {};
6339     if (!skipNormalization) {
6340         base = parse(serialize(base, options), options); //normalize base components
6341         relative = parse(serialize(relative, options), options); //normalize relative components
6342     }
6343     options = options || {};
6344     if (!options.tolerant && relative.scheme) {
6345         target.scheme = relative.scheme;
6346         //target.authority = relative.authority;
6347         target.userinfo = relative.userinfo;
6348         target.host = relative.host;
6349         target.port = relative.port;
6350         target.path = removeDotSegments(relative.path || "");
6351         target.query = relative.query;
6352     } else {
6353         if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
6354             //target.authority = relative.authority;
6355             target.userinfo = relative.userinfo;
6356             target.host = relative.host;
6357             target.port = relative.port;
6358             target.path = removeDotSegments(relative.path || "");
6359             target.query = relative.query;
6360         } else {
6361             if (!relative.path) {
6362                 target.path = base.path;
6363                 if (relative.query !== undefined) {
6364                     target.query = relative.query;
6365                 } else {
6366                     target.query = base.query;
6367                 }
6368             } else {
6369                 if (relative.path.charAt(0) === "/") {
6370                     target.path = removeDotSegments(relative.path);
6371                 } else {
6372                     if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
6373                         target.path = "/" + relative.path;
6374                     } else if (!base.path) {
6375                         target.path = relative.path;
6376                     } else {
6377                         target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
6378                     }
6379                     target.path = removeDotSegments(target.path);
6380                 }
6381                 target.query = relative.query;
6382             }
6383             //target.authority = base.authority;
6384             target.userinfo = base.userinfo;
6385             target.host = base.host;
6386             target.port = base.port;
6387         }
6388         target.scheme = base.scheme;
6389     }
6390     target.fragment = relative.fragment;
6391     return target;
6394 function resolve(baseURI, relativeURI, options) {
6395     var schemelessOptions = assign({ scheme: 'null' }, options);
6396     return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
6399 function normalize(uri, options) {
6400     if (typeof uri === "string") {
6401         uri = serialize(parse(uri, options), options);
6402     } else if (typeOf(uri) === "object") {
6403         uri = parse(serialize(uri, options), options);
6404     }
6405     return uri;
6408 function equal(uriA, uriB, options) {
6409     if (typeof uriA === "string") {
6410         uriA = serialize(parse(uriA, options), options);
6411     } else if (typeOf(uriA) === "object") {
6412         uriA = serialize(uriA, options);
6413     }
6414     if (typeof uriB === "string") {
6415         uriB = serialize(parse(uriB, options), options);
6416     } else if (typeOf(uriB) === "object") {
6417         uriB = serialize(uriB, options);
6418     }
6419     return uriA === uriB;
6422 function escapeComponent(str, options) {
6423     return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
6426 function unescapeComponent(str, options) {
6427     return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
6430 var handler = {
6431     scheme: "http",
6432     domainHost: true,
6433     parse: function parse(components, options) {
6434         //report missing host
6435         if (!components.host) {
6436             components.error = components.error || "HTTP URIs must have a host.";
6437         }
6438         return components;
6439     },
6440     serialize: function serialize(components, options) {
6441         var secure = String(components.scheme).toLowerCase() === "https";
6442         //normalize the default port
6443         if (components.port === (secure ? 443 : 80) || components.port === "") {
6444             components.port = undefined;
6445         }
6446         //normalize the empty path
6447         if (!components.path) {
6448             components.path = "/";
6449         }
6450         //NOTE: We do not parse query strings for HTTP URIs
6451         //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
6452         //and not the HTTP spec.
6453         return components;
6454     }
6457 var handler$1 = {
6458     scheme: "https",
6459     domainHost: handler.domainHost,
6460     parse: handler.parse,
6461     serialize: handler.serialize
6464 function isSecure(wsComponents) {
6465     return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
6467 //RFC 6455
6468 var handler$2 = {
6469     scheme: "ws",
6470     domainHost: true,
6471     parse: function parse(components, options) {
6472         var wsComponents = components;
6473         //indicate if the secure flag is set
6474         wsComponents.secure = isSecure(wsComponents);
6475         //construct resouce name
6476         wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : '');
6477         wsComponents.path = undefined;
6478         wsComponents.query = undefined;
6479         return wsComponents;
6480     },
6481     serialize: function serialize(wsComponents, options) {
6482         //normalize the default port
6483         if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
6484             wsComponents.port = undefined;
6485         }
6486         //ensure scheme matches secure flag
6487         if (typeof wsComponents.secure === 'boolean') {
6488             wsComponents.scheme = wsComponents.secure ? 'wss' : 'ws';
6489             wsComponents.secure = undefined;
6490         }
6491         //reconstruct path from resource name
6492         if (wsComponents.resourceName) {
6493             var _wsComponents$resourc = wsComponents.resourceName.split('?'),
6494                 _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2),
6495                 path = _wsComponents$resourc2[0],
6496                 query = _wsComponents$resourc2[1];
6498             wsComponents.path = path && path !== '/' ? path : undefined;
6499             wsComponents.query = query;
6500             wsComponents.resourceName = undefined;
6501         }
6502         //forbid fragment component
6503         wsComponents.fragment = undefined;
6504         return wsComponents;
6505     }
6508 var handler$3 = {
6509     scheme: "wss",
6510     domainHost: handler$2.domainHost,
6511     parse: handler$2.parse,
6512     serialize: handler$2.serialize
6515 var O = {};
6516 var isIRI = true;
6517 //RFC 3986
6518 var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]";
6519 var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
6520 var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
6521 //RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
6522 //const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
6523 //const WSP$$ = "[\\x20\\x09]";
6524 //const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]";  //(%d1-8 / %d11-12 / %d14-31 / %d127)
6525 //const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$);  //%d33 / %d35-91 / %d93-126 / obs-qtext
6526 //const VCHAR$$ = "[\\x21-\\x7E]";
6527 //const WSP$$ = "[\\x20\\x09]";
6528 //const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$));  //%d0 / CR / LF / obs-qtext
6529 //const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
6530 //const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
6531 //const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
6532 var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
6533 var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
6534 var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
6535 var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
6536 var UNRESERVED = new RegExp(UNRESERVED$$, "g");
6537 var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
6538 var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
6539 var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
6540 var NOT_HFVALUE = NOT_HFNAME;
6541 function decodeUnreserved(str) {
6542     var decStr = pctDecChars(str);
6543     return !decStr.match(UNRESERVED) ? str : decStr;
6545 var handler$4 = {
6546     scheme: "mailto",
6547     parse: function parse$$1(components, options) {
6548         var mailtoComponents = components;
6549         var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
6550         mailtoComponents.path = undefined;
6551         if (mailtoComponents.query) {
6552             var unknownHeaders = false;
6553             var headers = {};
6554             var hfields = mailtoComponents.query.split("&");
6555             for (var x = 0, xl = hfields.length; x < xl; ++x) {
6556                 var hfield = hfields[x].split("=");
6557                 switch (hfield[0]) {
6558                     case "to":
6559                         var toAddrs = hfield[1].split(",");
6560                         for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
6561                             to.push(toAddrs[_x]);
6562                         }
6563                         break;
6564                     case "subject":
6565                         mailtoComponents.subject = unescapeComponent(hfield[1], options);
6566                         break;
6567                     case "body":
6568                         mailtoComponents.body = unescapeComponent(hfield[1], options);
6569                         break;
6570                     default:
6571                         unknownHeaders = true;
6572                         headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
6573                         break;
6574                 }
6575             }
6576             if (unknownHeaders) mailtoComponents.headers = headers;
6577         }
6578         mailtoComponents.query = undefined;
6579         for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
6580             var addr = to[_x2].split("@");
6581             addr[0] = unescapeComponent(addr[0]);
6582             if (!options.unicodeSupport) {
6583                 //convert Unicode IDN -> ASCII IDN
6584                 try {
6585                     addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
6586                 } catch (e) {
6587                     mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
6588                 }
6589             } else {
6590                 addr[1] = unescapeComponent(addr[1], options).toLowerCase();
6591             }
6592             to[_x2] = addr.join("@");
6593         }
6594         return mailtoComponents;
6595     },
6596     serialize: function serialize$$1(mailtoComponents, options) {
6597         var components = mailtoComponents;
6598         var to = toArray(mailtoComponents.to);
6599         if (to) {
6600             for (var x = 0, xl = to.length; x < xl; ++x) {
6601                 var toAddr = String(to[x]);
6602                 var atIdx = toAddr.lastIndexOf("@");
6603                 var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
6604                 var domain = toAddr.slice(atIdx + 1);
6605                 //convert IDN via punycode
6606                 try {
6607                     domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
6608                 } catch (e) {
6609                     components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
6610                 }
6611                 to[x] = localPart + "@" + domain;
6612             }
6613             components.path = to.join(",");
6614         }
6615         var headers = mailtoComponents.headers = mailtoComponents.headers || {};
6616         if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
6617         if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
6618         var fields = [];
6619         for (var name in headers) {
6620             if (headers[name] !== O[name]) {
6621                 fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
6622             }
6623         }
6624         if (fields.length) {
6625             components.query = fields.join("&");
6626         }
6627         return components;
6628     }
6631 var URN_PARSE = /^([^\:]+)\:(.*)/;
6632 //RFC 2141
6633 var handler$5 = {
6634     scheme: "urn",
6635     parse: function parse$$1(components, options) {
6636         var matches = components.path && components.path.match(URN_PARSE);
6637         var urnComponents = components;
6638         if (matches) {
6639             var scheme = options.scheme || urnComponents.scheme || "urn";
6640             var nid = matches[1].toLowerCase();
6641             var nss = matches[2];
6642             var urnScheme = scheme + ":" + (options.nid || nid);
6643             var schemeHandler = SCHEMES[urnScheme];
6644             urnComponents.nid = nid;
6645             urnComponents.nss = nss;
6646             urnComponents.path = undefined;
6647             if (schemeHandler) {
6648                 urnComponents = schemeHandler.parse(urnComponents, options);
6649             }
6650         } else {
6651             urnComponents.error = urnComponents.error || "URN can not be parsed.";
6652         }
6653         return urnComponents;
6654     },
6655     serialize: function serialize$$1(urnComponents, options) {
6656         var scheme = options.scheme || urnComponents.scheme || "urn";
6657         var nid = urnComponents.nid;
6658         var urnScheme = scheme + ":" + (options.nid || nid);
6659         var schemeHandler = SCHEMES[urnScheme];
6660         if (schemeHandler) {
6661             urnComponents = schemeHandler.serialize(urnComponents, options);
6662         }
6663         var uriComponents = urnComponents;
6664         var nss = urnComponents.nss;
6665         uriComponents.path = (nid || options.nid) + ":" + nss;
6666         return uriComponents;
6667     }
6670 var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
6671 //RFC 4122
6672 var handler$6 = {
6673     scheme: "urn:uuid",
6674     parse: function parse(urnComponents, options) {
6675         var uuidComponents = urnComponents;
6676         uuidComponents.uuid = uuidComponents.nss;
6677         uuidComponents.nss = undefined;
6678         if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
6679             uuidComponents.error = uuidComponents.error || "UUID is not valid.";
6680         }
6681         return uuidComponents;
6682     },
6683     serialize: function serialize(uuidComponents, options) {
6684         var urnComponents = uuidComponents;
6685         //normalize UUID
6686         urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
6687         return urnComponents;
6688     }
6691 SCHEMES[handler.scheme] = handler;
6692 SCHEMES[handler$1.scheme] = handler$1;
6693 SCHEMES[handler$2.scheme] = handler$2;
6694 SCHEMES[handler$3.scheme] = handler$3;
6695 SCHEMES[handler$4.scheme] = handler$4;
6696 SCHEMES[handler$5.scheme] = handler$5;
6697 SCHEMES[handler$6.scheme] = handler$6;
6699 exports.SCHEMES = SCHEMES;
6700 exports.pctEncChar = pctEncChar;
6701 exports.pctDecChars = pctDecChars;
6702 exports.parse = parse;
6703 exports.removeDotSegments = removeDotSegments;
6704 exports.serialize = serialize;
6705 exports.resolveComponents = resolveComponents;
6706 exports.resolve = resolve;
6707 exports.normalize = normalize;
6708 exports.equal = equal;
6709 exports.escapeComponent = escapeComponent;
6710 exports.unescapeComponent = unescapeComponent;
6712 Object.defineProperty(exports, '__esModule', { value: true });
6714 })));
6717 },{}],"ajv":[function(require,module,exports){
6718 'use strict';
6720 var compileSchema = require('./compile')
6721   , resolve = require('./compile/resolve')
6722   , Cache = require('./cache')
6723   , SchemaObject = require('./compile/schema_obj')
6724   , stableStringify = require('fast-json-stable-stringify')
6725   , formats = require('./compile/formats')
6726   , rules = require('./compile/rules')
6727   , $dataMetaSchema = require('./data')
6728   , util = require('./compile/util');
6730 module.exports = Ajv;
6732 Ajv.prototype.validate = validate;
6733 Ajv.prototype.compile = compile;
6734 Ajv.prototype.addSchema = addSchema;
6735 Ajv.prototype.addMetaSchema = addMetaSchema;
6736 Ajv.prototype.validateSchema = validateSchema;
6737 Ajv.prototype.getSchema = getSchema;
6738 Ajv.prototype.removeSchema = removeSchema;
6739 Ajv.prototype.addFormat = addFormat;
6740 Ajv.prototype.errorsText = errorsText;
6742 Ajv.prototype._addSchema = _addSchema;
6743 Ajv.prototype._compile = _compile;
6745 Ajv.prototype.compileAsync = require('./compile/async');
6746 var customKeyword = require('./keyword');
6747 Ajv.prototype.addKeyword = customKeyword.add;
6748 Ajv.prototype.getKeyword = customKeyword.get;
6749 Ajv.prototype.removeKeyword = customKeyword.remove;
6750 Ajv.prototype.validateKeyword = customKeyword.validate;
6752 var errorClasses = require('./compile/error_classes');
6753 Ajv.ValidationError = errorClasses.Validation;
6754 Ajv.MissingRefError = errorClasses.MissingRef;
6755 Ajv.$dataMetaSchema = $dataMetaSchema;
6757 var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
6759 var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults' ];
6760 var META_SUPPORT_DATA = ['/properties'];
6763  * Creates validator instance.
6764  * Usage: `Ajv(opts)`
6765  * @param {Object} opts optional options
6766  * @return {Object} ajv instance
6767  */
6768 function Ajv(opts) {
6769   if (!(this instanceof Ajv)) return new Ajv(opts);
6770   opts = this._opts = util.copy(opts) || {};
6771   setLogger(this);
6772   this._schemas = {};
6773   this._refs = {};
6774   this._fragments = {};
6775   this._formats = formats(opts.format);
6777   this._cache = opts.cache || new Cache;
6778   this._loadingSchemas = {};
6779   this._compilations = [];
6780   this.RULES = rules();
6781   this._getId = chooseGetId(opts);
6783   opts.loopRequired = opts.loopRequired || Infinity;
6784   if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
6785   if (opts.serialize === undefined) opts.serialize = stableStringify;
6786   this._metaOpts = getMetaSchemaOptions(this);
6788   if (opts.formats) addInitialFormats(this);
6789   if (opts.keywords) addInitialKeywords(this);
6790   addDefaultMetaSchema(this);
6791   if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
6792   if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
6793   addInitialSchemas(this);
6799  * Validate data using schema
6800  * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
6801  * @this   Ajv
6802  * @param  {String|Object} schemaKeyRef key, ref or schema object
6803  * @param  {Any} data to be validated
6804  * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
6805  */
6806 function validate(schemaKeyRef, data) {
6807   var v;
6808   if (typeof schemaKeyRef == 'string') {
6809     v = this.getSchema(schemaKeyRef);
6810     if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
6811   } else {
6812     var schemaObj = this._addSchema(schemaKeyRef);
6813     v = schemaObj.validate || this._compile(schemaObj);
6814   }
6816   var valid = v(data);
6817   if (v.$async !== true) this.errors = v.errors;
6818   return valid;
6823  * Create validating function for passed schema.
6824  * @this   Ajv
6825  * @param  {Object} schema schema object
6826  * @param  {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
6827  * @return {Function} validating function
6828  */
6829 function compile(schema, _meta) {
6830   var schemaObj = this._addSchema(schema, undefined, _meta);
6831   return schemaObj.validate || this._compile(schemaObj);
6836  * Adds schema to the instance.
6837  * @this   Ajv
6838  * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
6839  * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
6840  * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
6841  * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
6842  * @return {Ajv} this for method chaining
6843  */
6844 function addSchema(schema, key, _skipValidation, _meta) {
6845   if (Array.isArray(schema)){
6846     for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
6847     return this;
6848   }
6849   var id = this._getId(schema);
6850   if (id !== undefined && typeof id != 'string')
6851     throw new Error('schema id must be string');
6852   key = resolve.normalizeId(key || id);
6853   checkUnique(this, key);
6854   this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
6855   return this;
6860  * Add schema that will be used to validate other schemas
6861  * options in META_IGNORE_OPTIONS are alway set to false
6862  * @this   Ajv
6863  * @param {Object} schema schema object
6864  * @param {String} key optional schema key
6865  * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
6866  * @return {Ajv} this for method chaining
6867  */
6868 function addMetaSchema(schema, key, skipValidation) {
6869   this.addSchema(schema, key, skipValidation, true);
6870   return this;
6875  * Validate schema
6876  * @this   Ajv
6877  * @param {Object} schema schema to validate
6878  * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
6879  * @return {Boolean} true if schema is valid
6880  */
6881 function validateSchema(schema, throwOrLogError) {
6882   var $schema = schema.$schema;
6883   if ($schema !== undefined && typeof $schema != 'string')
6884     throw new Error('$schema must be a string');
6885   $schema = $schema || this._opts.defaultMeta || defaultMeta(this);
6886   if (!$schema) {
6887     this.logger.warn('meta-schema not available');
6888     this.errors = null;
6889     return true;
6890   }
6891   var valid = this.validate($schema, schema);
6892   if (!valid && throwOrLogError) {
6893     var message = 'schema is invalid: ' + this.errorsText();
6894     if (this._opts.validateSchema == 'log') this.logger.error(message);
6895     else throw new Error(message);
6896   }
6897   return valid;
6901 function defaultMeta(self) {
6902   var meta = self._opts.meta;
6903   self._opts.defaultMeta = typeof meta == 'object'
6904                             ? self._getId(meta) || meta
6905                             : self.getSchema(META_SCHEMA_ID)
6906                               ? META_SCHEMA_ID
6907                               : undefined;
6908   return self._opts.defaultMeta;
6913  * Get compiled schema from the instance by `key` or `ref`.
6914  * @this   Ajv
6915  * @param  {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
6916  * @return {Function} schema validating function (with property `schema`).
6917  */
6918 function getSchema(keyRef) {
6919   var schemaObj = _getSchemaObj(this, keyRef);
6920   switch (typeof schemaObj) {
6921     case 'object': return schemaObj.validate || this._compile(schemaObj);
6922     case 'string': return this.getSchema(schemaObj);
6923     case 'undefined': return _getSchemaFragment(this, keyRef);
6924   }
6928 function _getSchemaFragment(self, ref) {
6929   var res = resolve.schema.call(self, { schema: {} }, ref);
6930   if (res) {
6931     var schema = res.schema
6932       , root = res.root
6933       , baseId = res.baseId;
6934     var v = compileSchema.call(self, schema, root, undefined, baseId);
6935     self._fragments[ref] = new SchemaObject({
6936       ref: ref,
6937       fragment: true,
6938       schema: schema,
6939       root: root,
6940       baseId: baseId,
6941       validate: v
6942     });
6943     return v;
6944   }
6948 function _getSchemaObj(self, keyRef) {
6949   keyRef = resolve.normalizeId(keyRef);
6950   return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
6955  * Remove cached schema(s).
6956  * If no parameter is passed all schemas but meta-schemas are removed.
6957  * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
6958  * Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
6959  * @this   Ajv
6960  * @param  {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
6961  * @return {Ajv} this for method chaining
6962  */
6963 function removeSchema(schemaKeyRef) {
6964   if (schemaKeyRef instanceof RegExp) {
6965     _removeAllSchemas(this, this._schemas, schemaKeyRef);
6966     _removeAllSchemas(this, this._refs, schemaKeyRef);
6967     return this;
6968   }
6969   switch (typeof schemaKeyRef) {
6970     case 'undefined':
6971       _removeAllSchemas(this, this._schemas);
6972       _removeAllSchemas(this, this._refs);
6973       this._cache.clear();
6974       return this;
6975     case 'string':
6976       var schemaObj = _getSchemaObj(this, schemaKeyRef);
6977       if (schemaObj) this._cache.del(schemaObj.cacheKey);
6978       delete this._schemas[schemaKeyRef];
6979       delete this._refs[schemaKeyRef];
6980       return this;
6981     case 'object':
6982       var serialize = this._opts.serialize;
6983       var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
6984       this._cache.del(cacheKey);
6985       var id = this._getId(schemaKeyRef);
6986       if (id) {
6987         id = resolve.normalizeId(id);
6988         delete this._schemas[id];
6989         delete this._refs[id];
6990       }
6991   }
6992   return this;
6996 function _removeAllSchemas(self, schemas, regex) {
6997   for (var keyRef in schemas) {
6998     var schemaObj = schemas[keyRef];
6999     if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
7000       self._cache.del(schemaObj.cacheKey);
7001       delete schemas[keyRef];
7002     }
7003   }
7007 /* @this   Ajv */
7008 function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
7009   if (typeof schema != 'object' && typeof schema != 'boolean')
7010     throw new Error('schema should be object or boolean');
7011   var serialize = this._opts.serialize;
7012   var cacheKey = serialize ? serialize(schema) : schema;
7013   var cached = this._cache.get(cacheKey);
7014   if (cached) return cached;
7016   shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
7018   var id = resolve.normalizeId(this._getId(schema));
7019   if (id && shouldAddSchema) checkUnique(this, id);
7021   var willValidate = this._opts.validateSchema !== false && !skipValidation;
7022   var recursiveMeta;
7023   if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)))
7024     this.validateSchema(schema, true);
7026   var localRefs = resolve.ids.call(this, schema);
7028   var schemaObj = new SchemaObject({
7029     id: id,
7030     schema: schema,
7031     localRefs: localRefs,
7032     cacheKey: cacheKey,
7033     meta: meta
7034   });
7036   if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
7037   this._cache.put(cacheKey, schemaObj);
7039   if (willValidate && recursiveMeta) this.validateSchema(schema, true);
7041   return schemaObj;
7045 /* @this   Ajv */
7046 function _compile(schemaObj, root) {
7047   if (schemaObj.compiling) {
7048     schemaObj.validate = callValidate;
7049     callValidate.schema = schemaObj.schema;
7050     callValidate.errors = null;
7051     callValidate.root = root ? root : callValidate;
7052     if (schemaObj.schema.$async === true)
7053       callValidate.$async = true;
7054     return callValidate;
7055   }
7056   schemaObj.compiling = true;
7058   var currentOpts;
7059   if (schemaObj.meta) {
7060     currentOpts = this._opts;
7061     this._opts = this._metaOpts;
7062   }
7064   var v;
7065   try { v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs); }
7066   catch(e) {
7067     delete schemaObj.validate;
7068     throw e;
7069   }
7070   finally {
7071     schemaObj.compiling = false;
7072     if (schemaObj.meta) this._opts = currentOpts;
7073   }
7075   schemaObj.validate = v;
7076   schemaObj.refs = v.refs;
7077   schemaObj.refVal = v.refVal;
7078   schemaObj.root = v.root;
7079   return v;
7082   /* @this   {*} - custom context, see passContext option */
7083   function callValidate() {
7084     /* jshint validthis: true */
7085     var _validate = schemaObj.validate;
7086     var result = _validate.apply(this, arguments);
7087     callValidate.errors = _validate.errors;
7088     return result;
7089   }
7093 function chooseGetId(opts) {
7094   switch (opts.schemaId) {
7095     case 'auto': return _get$IdOrId;
7096     case 'id': return _getId;
7097     default: return _get$Id;
7098   }
7101 /* @this   Ajv */
7102 function _getId(schema) {
7103   if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
7104   return schema.id;
7107 /* @this   Ajv */
7108 function _get$Id(schema) {
7109   if (schema.id) this.logger.warn('schema id ignored', schema.id);
7110   return schema.$id;
7114 function _get$IdOrId(schema) {
7115   if (schema.$id && schema.id && schema.$id != schema.id)
7116     throw new Error('schema $id is different from id');
7117   return schema.$id || schema.id;
7122  * Convert array of error message objects to string
7123  * @this   Ajv
7124  * @param  {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
7125  * @param  {Object} options optional options with properties `separator` and `dataVar`.
7126  * @return {String} human readable string with all errors descriptions
7127  */
7128 function errorsText(errors, options) {
7129   errors = errors || this.errors;
7130   if (!errors) return 'No errors';
7131   options = options || {};
7132   var separator = options.separator === undefined ? ', ' : options.separator;
7133   var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
7135   var text = '';
7136   for (var i=0; i<errors.length; i++) {
7137     var e = errors[i];
7138     if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
7139   }
7140   return text.slice(0, -separator.length);
7145  * Add custom format
7146  * @this   Ajv
7147  * @param {String} name format name
7148  * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
7149  * @return {Ajv} this for method chaining
7150  */
7151 function addFormat(name, format) {
7152   if (typeof format == 'string') format = new RegExp(format);
7153   this._formats[name] = format;
7154   return this;
7158 function addDefaultMetaSchema(self) {
7159   var $dataSchema;
7160   if (self._opts.$data) {
7161     $dataSchema = require('./refs/data.json');
7162     self.addMetaSchema($dataSchema, $dataSchema.$id, true);
7163   }
7164   if (self._opts.meta === false) return;
7165   var metaSchema = require('./refs/json-schema-draft-07.json');
7166   if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
7167   self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
7168   self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
7172 function addInitialSchemas(self) {
7173   var optsSchemas = self._opts.schemas;
7174   if (!optsSchemas) return;
7175   if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);
7176   else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key);
7180 function addInitialFormats(self) {
7181   for (var name in self._opts.formats) {
7182     var format = self._opts.formats[name];
7183     self.addFormat(name, format);
7184   }
7188 function addInitialKeywords(self) {
7189   for (var name in self._opts.keywords) {
7190     var keyword = self._opts.keywords[name];
7191     self.addKeyword(name, keyword);
7192   }
7196 function checkUnique(self, id) {
7197   if (self._schemas[id] || self._refs[id])
7198     throw new Error('schema with key or id "' + id + '" already exists');
7202 function getMetaSchemaOptions(self) {
7203   var metaOpts = util.copy(self._opts);
7204   for (var i=0; i<META_IGNORE_OPTIONS.length; i++)
7205     delete metaOpts[META_IGNORE_OPTIONS[i]];
7206   return metaOpts;
7210 function setLogger(self) {
7211   var logger = self._opts.logger;
7212   if (logger === false) {
7213     self.logger = {log: noop, warn: noop, error: noop};
7214   } else {
7215     if (logger === undefined) logger = console;
7216     if (!(typeof logger == 'object' && logger.log && logger.warn && logger.error))
7217       throw new Error('logger must implement log, warn and error methods');
7218     self.logger = logger;
7219   }
7223 function noop() {}
7225 },{"./cache":1,"./compile":5,"./compile/async":2,"./compile/error_classes":3,"./compile/formats":4,"./compile/resolve":6,"./compile/rules":7,"./compile/schema_obj":8,"./compile/util":10,"./data":11,"./keyword":39,"./refs/data.json":40,"./refs/json-schema-draft-07.json":41,"fast-json-stable-stringify":43}]},{},[])("ajv")