/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@pratico/json-schema@0.1.15/dist/pratico-json-schema.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.PraticoJsonSchema={})}(this,(function(e){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of the
    License at http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
    WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
    MERCHANTABLITY OR NON-INFRINGEMENT.

    See the Apache Version 2.0 License for specific language governing permissions
    and limitations under the License.
    ***************************************************************************** */var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};var n=function(){function e(){this.eventListeners=new Map}return e.prototype.on=function(e,t){if(this.eventListeners.has(e)){var n=this.eventListeners.get(e);void 0!==n&&n.push(t)}else this.eventListeners.set(e,[t]);return new r(this,e,t)},e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(){if(0===arguments.length)this.eventListeners.clear();else if(1===arguments.length&&"object"==typeof arguments[0]){var e=arguments[0];this.removeListener(e.event,e.listener)}else if(arguments.length>=1){var t=arguments[0],n=arguments[1];if(this.eventListeners.has(t)){var r=this.eventListeners.get(t),o=r.indexOf(n);if(void 0!==r)for(;!n||-1!==o;)void 0!==o&&r.splice(o,1)}}},e.prototype.registerEvent=function(){var e=this,t=function(n){return e.addListener(t,n)};return t},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(this.eventListeners.has(e))for(var r=0,o=this.eventListeners.get(e);r<o.length;r++){o[r].apply(void 0,t)}},e}(),r=function(){function e(e,t,n){this.owner=e,this.event=t,this.listener=n}return e.prototype.unbind=function(){this.owner.removeListener(this)},e}(),o={allErrors:!0,coerceTypes:!0},i=function(e){function n(t,n){var r=e.call(this)||this;return r.onValidated=r.registerEvent(),r.onError=r.registerEvent(),r.executionId=0,r.config=Object.assign(t,o),r.ajvInstance=new n({allErrors:t.allErrors,coerceTypes:t.coerceTypes}),r.loadSchemasKeywordsAndFormats(t),r}return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,e),n.prototype.updateSchema=function(e,t){if(!this.ajvInstance.validateSchema(t))throw new Error("Could not validate the schema");this.ajvInstance.removeSchema(e),this.ajvInstance.addSchema(t,e),t.$id=e;var n=this.config.schemas.findIndex((function(t){return t.$id===e||t.$ref===e}));this.config.schemas[n]=t},n.prototype.addSchema=function(e,t){t.$id=e,this.config.schemas.push(t),this.ajvInstance.addSchema(t,e)},n.prototype.getSchema=function(e){return this.config.schemas.find((function(t){return t.$id===e||t.$ref===e}))},n.prototype.removeSchema=function(e){this.ajvInstance.removeSchema(e);var t=this.config.schemas.findIndex((function(t){return t.$id===e||t.$ref===e}));t>=0&&this.config.schemas.splice(t,1)},n.prototype.validate=function(e,t,n){var r=this;this.executionId+=1;var o=this.executionId;return setTimeout((function(){var i;try{if("boolean"==typeof(i=r.ajvInstance.validate(e,t))){var s=void 0;s=i?{executionId:o,schemaId:e,data:t,valid:i}:{executionId:o,schemaId:e,data:t,valid:i,errors:r.ajvInstance.errors},r.emit(r.onValidated,s),n&&n(s)}else i.then((function(i){var s={executionId:o,schemaId:e,data:t,valid:i};r.emit(r.onValidated,s),n&&n(s)}),(function(i){var s={executionId:o,schemaId:e,data:t,valid:!1,errors:i};r.emit(r.onValidated,s),n&&n(s)}))}catch(n){n.schemaId=e,n.data=t,n.executionId=o,r.emit(r.onError,n)}}),0),o},n.prototype.addFormat=function(e,t){this.ajvInstance.addFormat(e,t)},n.prototype.loadSchemasKeywordsAndFormats=function(e){var t=this;e&&void 0!==e.schemas&&e.schemas.forEach((function(e){t.ajvInstance.addSchema(e,e.$id)})),e&&e.formats&&Object.keys(e.formats).forEach((function(n){void 0!==e.formats&&t.ajvInstance.addFormat(n,e.formats[n])})),e&&e.keywords&&Object.keys(e.keywords).forEach((function(n){void 0!==e.keywords&&void 0!==e.keywords[n]&&t.ajvInstance.addKeyword(n,e.keywords[n])}))},n}(n);function s(e){return null!==e&&("function"==typeof e||"object"==typeof e)}var a=function(e,t){return e&&"object"==typeof e?"string"==typeof t&&""!==t?t.split(".").reduce((function(e,t){return e&&e[t]}),e):"number"==typeof t?e[t]:e:e};var c=Object.freeze({filterOutEmptyStringProperty:function e(t){if(Array.isArray(t)){var n=[];return t.forEach((function(t,r){n[r]=e(t)})),n}if(s(t)){var r={};return Object.keys(t).forEach((function(n){s(t[n])||Array.isArray(t[n])?r[n]=e(t[n]):"".endsWith(t[n])||(r[n]=t[n])})),r}return t}
/**
    * @license nested-property https://github.com/cosmosio/nested-property
    *
    * The MIT License (MIT)
    *
    * Copyright (c) 2014-2015 Olivier Scherrer <pode.fr@gmail.com>
    */,getValueByPath:function(e,t){return a(e,t)},isObject:s,isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}});e.utils=c,e.Validator=i,e.EventEmitter=n,e.Listener=r,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=/sm/d43bc1df5ef24ec1976977bab25397cf5571a59575d427d3cc7fc67802a6a636.map