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