/*! * jsoneditor.js * * @brief * JSONEditor is a web-based tool to view, edit, format, and validate JSON. * It has various modes such as a tree editor, a code editor, and a plain text * editor. * * Supported browsers: Chrome, Firefox, Safari, Opera, Internet Explorer 8+ * * @license * 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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * Copyright (c) 2011-2021 Jos de Jong, http://jsoneditoronline.org * * @author Jos de Jong, * @version 9.1.8 * @date 2021-01-16 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["JSONEditor"] = factory(); else root["JSONEditor"] = factory(); })(self, function() { return /******/ (function() { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 6835: /***/ (function(module) { "use strict"; module.exports = JSON.parse("{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"$id\":\"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#\",\"description\":\"Meta-schema for $data reference (JSON Schema extension proposal)\",\"type\":\"object\",\"required\":[\"$data\"],\"properties\":{\"$data\":{\"type\":\"string\",\"anyOf\":[{\"format\":\"relative-json-pointer\"},{\"format\":\"json-pointer\"}]}},\"additionalProperties\":false}"); /***/ }), /***/ 2689: /***/ (function(module) { "use strict"; module.exports = JSON.parse("{\"id\":\"http://json-schema.org/draft-04/schema#\",\"$schema\":\"http://json-schema.org/draft-04/schema#\",\"description\":\"Core schema meta-schema\",\"definitions\":{\"schemaArray\":{\"type\":\"array\",\"minItems\":1,\"items\":{\"$ref\":\"#\"}},\"positiveInteger\":{\"type\":\"integer\",\"minimum\":0},\"positiveIntegerDefault0\":{\"allOf\":[{\"$ref\":\"#/definitions/positiveInteger\"},{\"default\":0}]},\"simpleTypes\":{\"enum\":[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},\"stringArray\":{\"type\":\"array\",\"items\":{\"type\":\"string\"},\"minItems\":1,\"uniqueItems\":true}},\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"string\"},\"$schema\":{\"type\":\"string\"},\"title\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"default\":{},\"multipleOf\":{\"type\":\"number\",\"minimum\":0,\"exclusiveMinimum\":true},\"maximum\":{\"type\":\"number\"},\"exclusiveMaximum\":{\"type\":\"boolean\",\"default\":false},\"minimum\":{\"type\":\"number\"},\"exclusiveMinimum\":{\"type\":\"boolean\",\"default\":false},\"maxLength\":{\"$ref\":\"#/definitions/positiveInteger\"},\"minLength\":{\"$ref\":\"#/definitions/positiveIntegerDefault0\"},\"pattern\":{\"type\":\"string\",\"format\":\"regex\"},\"additionalItems\":{\"anyOf\":[{\"type\":\"boolean\"},{\"$ref\":\"#\"}],\"default\":{}},\"items\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/schemaArray\"}],\"default\":{}},\"maxItems\":{\"$ref\":\"#/definitions/positiveInteger\"},\"minItems\":{\"$ref\":\"#/definitions/positiveIntegerDefault0\"},\"uniqueItems\":{\"type\":\"boolean\",\"default\":false},\"maxProperties\":{\"$ref\":\"#/definitions/positiveInteger\"},\"minProperties\":{\"$ref\":\"#/definitions/positiveIntegerDefault0\"},\"required\":{\"$ref\":\"#/definitions/stringArray\"},\"additionalProperties\":{\"anyOf\":[{\"type\":\"boolean\"},{\"$ref\":\"#\"}],\"default\":{}},\"definitions\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"properties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"patternProperties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"dependencies\":{\"type\":\"object\",\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/stringArray\"}]}},\"enum\":{\"type\":\"array\",\"minItems\":1,\"uniqueItems\":true},\"type\":{\"anyOf\":[{\"$ref\":\"#/definitions/simpleTypes\"},{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/simpleTypes\"},\"minItems\":1,\"uniqueItems\":true}]},\"format\":{\"type\":\"string\"},\"allOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"anyOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"oneOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"not\":{\"$ref\":\"#\"}},\"dependencies\":{\"exclusiveMaximum\":[\"maximum\"],\"exclusiveMinimum\":[\"minimum\"]},\"default\":{}}"); /***/ }), /***/ 1030: /***/ (function(module) { "use strict"; module.exports = JSON.parse("{\"$schema\":\"http://json-schema.org/draft-06/schema#\",\"$id\":\"http://json-schema.org/draft-06/schema#\",\"title\":\"Core schema meta-schema\",\"definitions\":{\"schemaArray\":{\"type\":\"array\",\"minItems\":1,\"items\":{\"$ref\":\"#\"}},\"nonNegativeInteger\":{\"type\":\"integer\",\"minimum\":0},\"nonNegativeIntegerDefault0\":{\"allOf\":[{\"$ref\":\"#/definitions/nonNegativeInteger\"},{\"default\":0}]},\"simpleTypes\":{\"enum\":[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},\"stringArray\":{\"type\":\"array\",\"items\":{\"type\":\"string\"},\"uniqueItems\":true,\"default\":[]}},\"type\":[\"object\",\"boolean\"],\"properties\":{\"$id\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"$schema\":{\"type\":\"string\",\"format\":\"uri\"},\"$ref\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"title\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"default\":{},\"examples\":{\"type\":\"array\",\"items\":{}},\"multipleOf\":{\"type\":\"number\",\"exclusiveMinimum\":0},\"maximum\":{\"type\":\"number\"},\"exclusiveMaximum\":{\"type\":\"number\"},\"minimum\":{\"type\":\"number\"},\"exclusiveMinimum\":{\"type\":\"number\"},\"maxLength\":{\"$ref\":\"#/definitions/nonNegativeInteger\"},\"minLength\":{\"$ref\":\"#/definitions/nonNegativeIntegerDefault0\"},\"pattern\":{\"type\":\"string\",\"format\":\"regex\"},\"additionalItems\":{\"$ref\":\"#\"},\"items\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/schemaArray\"}],\"default\":{}},\"maxItems\":{\"$ref\":\"#/definitions/nonNegativeInteger\"},\"minItems\":{\"$ref\":\"#/definitions/nonNegativeIntegerDefault0\"},\"uniqueItems\":{\"type\":\"boolean\",\"default\":false},\"contains\":{\"$ref\":\"#\"},\"maxProperties\":{\"$ref\":\"#/definitions/nonNegativeInteger\"},\"minProperties\":{\"$ref\":\"#/definitions/nonNegativeIntegerDefault0\"},\"required\":{\"$ref\":\"#/definitions/stringArray\"},\"additionalProperties\":{\"$ref\":\"#\"},\"definitions\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"properties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"patternProperties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"dependencies\":{\"type\":\"object\",\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/stringArray\"}]}},\"propertyNames\":{\"$ref\":\"#\"},\"const\":{},\"enum\":{\"type\":\"array\",\"minItems\":1,\"uniqueItems\":true},\"type\":{\"anyOf\":[{\"$ref\":\"#/definitions/simpleTypes\"},{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/simpleTypes\"},\"minItems\":1,\"uniqueItems\":true}]},\"format\":{\"type\":\"string\"},\"allOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"anyOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"oneOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"not\":{\"$ref\":\"#\"}},\"default\":{}}"); /***/ }), /***/ 38: /***/ (function(module) { "use strict"; module.exports = JSON.parse("{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"$id\":\"http://json-schema.org/draft-07/schema#\",\"title\":\"Core schema meta-schema\",\"definitions\":{\"schemaArray\":{\"type\":\"array\",\"minItems\":1,\"items\":{\"$ref\":\"#\"}},\"nonNegativeInteger\":{\"type\":\"integer\",\"minimum\":0},\"nonNegativeIntegerDefault0\":{\"allOf\":[{\"$ref\":\"#/definitions/nonNegativeInteger\"},{\"default\":0}]},\"simpleTypes\":{\"enum\":[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},\"stringArray\":{\"type\":\"array\",\"items\":{\"type\":\"string\"},\"uniqueItems\":true,\"default\":[]}},\"type\":[\"object\",\"boolean\"],\"properties\":{\"$id\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"$schema\":{\"type\":\"string\",\"format\":\"uri\"},\"$ref\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"$comment\":{\"type\":\"string\"},\"title\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"default\":true,\"readOnly\":{\"type\":\"boolean\",\"default\":false},\"examples\":{\"type\":\"array\",\"items\":true},\"multipleOf\":{\"type\":\"number\",\"exclusiveMinimum\":0},\"maximum\":{\"type\":\"number\"},\"exclusiveMaximum\":{\"type\":\"number\"},\"minimum\":{\"type\":\"number\"},\"exclusiveMinimum\":{\"type\":\"number\"},\"maxLength\":{\"$ref\":\"#/definitions/nonNegativeInteger\"},\"minLength\":{\"$ref\":\"#/definitions/nonNegativeIntegerDefault0\"},\"pattern\":{\"type\":\"string\",\"format\":\"regex\"},\"additionalItems\":{\"$ref\":\"#\"},\"items\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/schemaArray\"}],\"default\":true},\"maxItems\":{\"$ref\":\"#/definitions/nonNegativeInteger\"},\"minItems\":{\"$ref\":\"#/definitions/nonNegativeIntegerDefault0\"},\"uniqueItems\":{\"type\":\"boolean\",\"default\":false},\"contains\":{\"$ref\":\"#\"},\"maxProperties\":{\"$ref\":\"#/definitions/nonNegativeInteger\"},\"minProperties\":{\"$ref\":\"#/definitions/nonNegativeIntegerDefault0\"},\"required\":{\"$ref\":\"#/definitions/stringArray\"},\"additionalProperties\":{\"$ref\":\"#\"},\"definitions\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"properties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"default\":{}},\"patternProperties\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#\"},\"propertyNames\":{\"format\":\"regex\"},\"default\":{}},\"dependencies\":{\"type\":\"object\",\"additionalProperties\":{\"anyOf\":[{\"$ref\":\"#\"},{\"$ref\":\"#/definitions/stringArray\"}]}},\"propertyNames\":{\"$ref\":\"#\"},\"const\":true,\"enum\":{\"type\":\"array\",\"items\":true,\"minItems\":1,\"uniqueItems\":true},\"type\":{\"anyOf\":[{\"$ref\":\"#/definitions/simpleTypes\"},{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/simpleTypes\"},\"minItems\":1,\"uniqueItems\":true}]},\"format\":{\"type\":\"string\"},\"contentMediaType\":{\"type\":\"string\"},\"contentEncoding\":{\"type\":\"string\"},\"if\":{\"$ref\":\"#\"},\"then\":{\"$ref\":\"#\"},\"else\":{\"$ref\":\"#\"},\"allOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"anyOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"oneOf\":{\"$ref\":\"#/definitions/schemaArray\"},\"not\":{\"$ref\":\"#\"}},\"default\":true}"); /***/ }), /***/ 897: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "x": function() { return /* binding */ ContextMenu; } /* harmony export */ }); /* harmony import */ var _createAbsoluteAnchor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2602); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9791); /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7907); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * A context menu * @param {Object[]} items Array containing the menu structure * TODO: describe structure * @param {Object} [options] Object with options. Available options: * {function} close Callback called when the * context menu is being closed. * {boolean} limitHeight Whether ContextMenu height should be * limited or not. * @constructor */ var ContextMenu = /*#__PURE__*/function () { function ContextMenu(items, options) { _classCallCheck(this, ContextMenu); this.dom = {}; var me = this; var dom = this.dom; this.anchor = undefined; this.items = items; this.eventListeners = {}; this.selection = undefined; // holds the selection before the menu was opened this.onClose = options ? options.close : undefined; this.limitHeight = options ? options.limitHeight : false; // create root element var root = document.createElement('div'); root.className = 'jsoneditor-contextmenu-root'; dom.root = root; // create a container element var menu = document.createElement('div'); menu.className = 'jsoneditor-contextmenu'; dom.menu = menu; root.appendChild(menu); // create a list to hold the menu items var list = document.createElement('ul'); list.className = 'jsoneditor-menu'; menu.appendChild(list); dom.list = list; dom.items = []; // list with all buttons // create a (non-visible) button to set the focus to the menu var focusButton = document.createElement('button'); focusButton.type = 'button'; dom.focusButton = focusButton; var li = document.createElement('li'); li.style.overflow = 'hidden'; li.style.height = '0'; li.appendChild(focusButton); list.appendChild(li); function createMenuItems(list, domItems, items) { items.forEach(function (item) { if (item.type === 'separator') { // create a separator var separator = document.createElement('div'); separator.className = 'jsoneditor-separator'; var _li = document.createElement('li'); _li.appendChild(separator); list.appendChild(_li); } else { var domItem = {}; // create a menu item var _li2 = document.createElement('li'); list.appendChild(_li2); // create a button in the menu item var button = document.createElement('button'); button.type = 'button'; button.className = item.className; domItem.button = button; if (item.title) { button.title = item.title; } if (item.click) { button.onclick = function (event) { event.preventDefault(); me.hide(); item.click(); }; } _li2.appendChild(button); // create the contents of the button if (item.submenu) { // add the icon to the button var divIcon = document.createElement('div'); divIcon.className = 'jsoneditor-icon'; button.appendChild(divIcon); var divText = document.createElement('div'); divText.className = 'jsoneditor-text' + (item.click ? '' : ' jsoneditor-right-margin'); divText.appendChild(document.createTextNode(item.text)); button.appendChild(divText); var buttonSubmenu; if (item.click) { // submenu and a button with a click handler button.className += ' jsoneditor-default'; var buttonExpand = document.createElement('button'); buttonExpand.type = 'button'; domItem.buttonExpand = buttonExpand; buttonExpand.className = 'jsoneditor-expand'; var buttonExpandInner = document.createElement('div'); buttonExpandInner.className = 'jsoneditor-expand'; buttonExpand.appendChild(buttonExpandInner); _li2.appendChild(buttonExpand); if (item.submenuTitle) { buttonExpand.title = item.submenuTitle; } buttonSubmenu = buttonExpand; } else { // submenu and a button without a click handler var divExpand = document.createElement('div'); divExpand.className = 'jsoneditor-expand'; button.appendChild(divExpand); buttonSubmenu = button; } // attach a handler to expand/collapse the submenu buttonSubmenu.onclick = function (event) { event.preventDefault(); me._onExpandItem(domItem); buttonSubmenu.focus(); }; // create the submenu var domSubItems = []; domItem.subItems = domSubItems; var ul = document.createElement('ul'); domItem.ul = ul; ul.className = 'jsoneditor-menu'; ul.style.height = '0'; _li2.appendChild(ul); createMenuItems(ul, domSubItems, item.submenu); } else { // no submenu, just a button with clickhandler var icon = document.createElement('div'); icon.className = 'jsoneditor-icon'; button.appendChild(icon); var text = document.createElement('div'); text.className = 'jsoneditor-text'; text.appendChild(document.createTextNode((0,_i18n__WEBPACK_IMPORTED_MODULE_2__/* .translate */ .Iu)(item.text))); button.appendChild(text); } domItems.push(domItem); } }); } createMenuItems(list, this.dom.items, items); // TODO: when the editor is small, show the submenu on the right instead of inline? // calculate the max height of the menu with one submenu expanded this.maxHeight = 0; // height in pixels items.forEach(function (item) { var height = (items.length + (item.submenu ? item.submenu.length : 0)) * 24; me.maxHeight = Math.max(me.maxHeight, height); }); } /** * Get the currently visible buttons * @return {Array.} buttons * @private */ _createClass(ContextMenu, [{ key: "_getVisibleButtons", value: function _getVisibleButtons() { var buttons = []; var me = this; this.dom.items.forEach(function (item) { buttons.push(item.button); if (item.buttonExpand) { buttons.push(item.buttonExpand); } if (item.subItems && item === me.expandedItem) { item.subItems.forEach(function (subItem) { buttons.push(subItem.button); if (subItem.buttonExpand) { buttons.push(subItem.buttonExpand); } // TODO: change to fully recursive method }); } }); return buttons; } /** * Attach the menu to an anchor * @param {HTMLElement} anchor Anchor where the menu will be attached as sibling. * @param {HTMLElement} frame The root of the JSONEditor window * @param {Boolean=} ignoreParent ignore anchor parent in regard to the calculation of the position, needed when the parent position is absolute */ }, { key: "show", value: function show(anchor, frame, ignoreParent) { this.hide(); // determine whether to display the menu below or above the anchor var showBelow = true; var parent = anchor.parentNode; var anchorRect = anchor.getBoundingClientRect(); var parentRect = parent.getBoundingClientRect(); var frameRect = frame.getBoundingClientRect(); var me = this; this.dom.absoluteAnchor = (0,_createAbsoluteAnchor__WEBPACK_IMPORTED_MODULE_0__/* .createAbsoluteAnchor */ .w)(anchor, frame, function () { me.hide(); }); if (anchorRect.bottom + this.maxHeight < frameRect.bottom) {// fits below -> show below } else if (anchorRect.top - this.maxHeight > frameRect.top) { // fits above -> show above showBelow = false; } else {// doesn't fit above nor below -> show below } var topGap = ignoreParent ? 0 : anchorRect.top - parentRect.top; // position the menu if (showBelow) { // display the menu below the anchor var anchorHeight = anchor.offsetHeight; this.dom.menu.style.left = '0'; this.dom.menu.style.top = topGap + anchorHeight + 'px'; this.dom.menu.style.bottom = ''; } else { // display the menu above the anchor this.dom.menu.style.left = '0'; this.dom.menu.style.top = ''; this.dom.menu.style.bottom = '0px'; } if (this.limitHeight) { var margin = 10; // make sure there is a little margin left var maxPossibleMenuHeight = showBelow ? frameRect.bottom - anchorRect.bottom - margin : anchorRect.top - frameRect.top - margin; this.dom.list.style.maxHeight = maxPossibleMenuHeight + 'px'; this.dom.list.style.overflowY = 'auto'; } // attach the menu to the temporary, absolute anchor // parent.insertBefore(this.dom.root, anchor); this.dom.absoluteAnchor.appendChild(this.dom.root); // move focus to the first button in the context menu this.selection = (0,_util__WEBPACK_IMPORTED_MODULE_1__.getSelection)(); this.anchor = anchor; setTimeout(function () { me.dom.focusButton.focus(); }, 0); if (ContextMenu.visibleMenu) { ContextMenu.visibleMenu.hide(); } ContextMenu.visibleMenu = this; } /** * Hide the context menu if visible */ }, { key: "hide", value: function hide() { // remove temporary absolutely positioned anchor if (this.dom.absoluteAnchor) { this.dom.absoluteAnchor.destroy(); delete this.dom.absoluteAnchor; } // remove the menu from the DOM if (this.dom.root.parentNode) { this.dom.root.parentNode.removeChild(this.dom.root); if (this.onClose) { this.onClose(); } } if (ContextMenu.visibleMenu === this) { ContextMenu.visibleMenu = undefined; } } /** * Expand a submenu * Any currently expanded submenu will be hided. * @param {Object} domItem * @private */ }, { key: "_onExpandItem", value: function _onExpandItem(domItem) { var me = this; var alreadyVisible = domItem === this.expandedItem; // hide the currently visible submenu var expandedItem = this.expandedItem; if (expandedItem) { // var ul = expandedItem.ul; expandedItem.ul.style.height = '0'; expandedItem.ul.style.padding = ''; setTimeout(function () { if (me.expandedItem !== expandedItem) { expandedItem.ul.style.display = ''; (0,_util__WEBPACK_IMPORTED_MODULE_1__.removeClassName)(expandedItem.ul.parentNode, 'jsoneditor-selected'); } }, 300); // timeout duration must match the css transition duration this.expandedItem = undefined; } if (!alreadyVisible) { var ul = domItem.ul; ul.style.display = 'block'; // eslint-disable-next-line no-unused-expressions ul.clientHeight; // force a reflow in Firefox setTimeout(function () { if (me.expandedItem === domItem) { var childsHeight = 0; for (var i = 0; i < ul.childNodes.length; i++) { childsHeight += ul.childNodes[i].clientHeight; } ul.style.height = childsHeight + 'px'; ul.style.padding = '5px 10px'; } }, 0); (0,_util__WEBPACK_IMPORTED_MODULE_1__.addClassName)(ul.parentNode, 'jsoneditor-selected'); this.expandedItem = domItem; } } /** * Handle onkeydown event * @param {Event} event * @private */ }, { key: "_onKeyDown", value: function _onKeyDown(event) { var target = event.target; var keynum = event.which; var handled = false; var buttons, targetIndex, prevButton, nextButton; if (keynum === 27) { // ESC // hide the menu on ESC key // restore previous selection and focus if (this.selection) { (0,_util__WEBPACK_IMPORTED_MODULE_1__.setSelection)(this.selection); } if (this.anchor) { this.anchor.focus(); } this.hide(); handled = true; } else if (keynum === 9) { // Tab if (!event.shiftKey) { // Tab buttons = this._getVisibleButtons(); targetIndex = buttons.indexOf(target); if (targetIndex === buttons.length - 1) { // move to first button buttons[0].focus(); handled = true; } } else { // Shift+Tab buttons = this._getVisibleButtons(); targetIndex = buttons.indexOf(target); if (targetIndex === 0) { // move to last button buttons[buttons.length - 1].focus(); handled = true; } } } else if (keynum === 37) { // Arrow Left if (target.className === 'jsoneditor-expand') { buttons = this._getVisibleButtons(); targetIndex = buttons.indexOf(target); prevButton = buttons[targetIndex - 1]; if (prevButton) { prevButton.focus(); } } handled = true; } else if (keynum === 38) { // Arrow Up buttons = this._getVisibleButtons(); targetIndex = buttons.indexOf(target); prevButton = buttons[targetIndex - 1]; if (prevButton && prevButton.className === 'jsoneditor-expand') { // skip expand button prevButton = buttons[targetIndex - 2]; } if (!prevButton) { // move to last button prevButton = buttons[buttons.length - 1]; } if (prevButton) { prevButton.focus(); } handled = true; } else if (keynum === 39) { // Arrow Right buttons = this._getVisibleButtons(); targetIndex = buttons.indexOf(target); nextButton = buttons[targetIndex + 1]; if (nextButton && nextButton.className === 'jsoneditor-expand') { nextButton.focus(); } handled = true; } else if (keynum === 40) { // Arrow Down buttons = this._getVisibleButtons(); targetIndex = buttons.indexOf(target); nextButton = buttons[targetIndex + 1]; if (nextButton && nextButton.className === 'jsoneditor-expand') { // skip expand button nextButton = buttons[targetIndex + 2]; } if (!nextButton) { // move to first button nextButton = buttons[0]; } if (nextButton) { nextButton.focus(); handled = true; } handled = true; } // TODO: arrow left and right if (handled) { event.stopPropagation(); event.preventDefault(); } } }]); return ContextMenu; }(); // currently displayed context menu, a singleton. We may only have one visible context menu ContextMenu.visibleMenu = undefined; /***/ }), /***/ 6436: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Q": function() { return /* binding */ ErrorTable; } /* harmony export */ }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * Show errors and schema warnings in a clickable table view * @param {Object} config * @property {boolean} errorTableVisible * @property {function (boolean) : void} onToggleVisibility * @property {function (number)} [onFocusLine] * @property {function (number)} onChangeHeight * @constructor */ var ErrorTable = /*#__PURE__*/function () { function ErrorTable(config) { _classCallCheck(this, ErrorTable); this.errorTableVisible = config.errorTableVisible; this.onToggleVisibility = config.onToggleVisibility; this.onFocusLine = config.onFocusLine || function () {}; this.onChangeHeight = config.onChangeHeight; this.dom = {}; var validationErrorsContainer = document.createElement('div'); validationErrorsContainer.className = 'jsoneditor-validation-errors-container'; this.dom.validationErrorsContainer = validationErrorsContainer; var additionalErrorsIndication = document.createElement('div'); additionalErrorsIndication.style.display = 'none'; additionalErrorsIndication.className = 'jsoneditor-additional-errors fadein'; additionalErrorsIndication.textContent = "Scroll for more \u25BF"; this.dom.additionalErrorsIndication = additionalErrorsIndication; validationErrorsContainer.appendChild(additionalErrorsIndication); var validationErrorIcon = document.createElement('span'); validationErrorIcon.className = 'jsoneditor-validation-error-icon'; validationErrorIcon.style.display = 'none'; this.dom.validationErrorIcon = validationErrorIcon; var validationErrorCount = document.createElement('span'); validationErrorCount.className = 'jsoneditor-validation-error-count'; validationErrorCount.style.display = 'none'; this.dom.validationErrorCount = validationErrorCount; this.dom.parseErrorIndication = document.createElement('span'); this.dom.parseErrorIndication.className = 'jsoneditor-parse-error-icon'; this.dom.parseErrorIndication.style.display = 'none'; } _createClass(ErrorTable, [{ key: "getErrorTable", value: function getErrorTable() { return this.dom.validationErrorsContainer; } }, { key: "getErrorCounter", value: function getErrorCounter() { return this.dom.validationErrorCount; } }, { key: "getWarningIcon", value: function getWarningIcon() { return this.dom.validationErrorIcon; } }, { key: "getErrorIcon", value: function getErrorIcon() { return this.dom.parseErrorIndication; } }, { key: "toggleTableVisibility", value: function toggleTableVisibility() { this.errorTableVisible = !this.errorTableVisible; this.onToggleVisibility(this.errorTableVisible); } }, { key: "setErrors", value: function setErrors(errors, errorLocations) { var _this = this; // clear any previous errors if (this.dom.validationErrors) { this.dom.validationErrors.parentNode.removeChild(this.dom.validationErrors); this.dom.validationErrors = null; this.dom.additionalErrorsIndication.style.display = 'none'; } // create the table with errors // keep default behavior for parse errors if (this.errorTableVisible && errors.length > 0) { var validationErrors = document.createElement('div'); validationErrors.className = 'jsoneditor-validation-errors'; var table = document.createElement('table'); table.className = 'jsoneditor-text-errors'; validationErrors.appendChild(table); var tbody = document.createElement('tbody'); table.appendChild(tbody); errors.forEach(function (error) { var line; if (!isNaN(error.line)) { line = error.line; } else if (error.dataPath) { var errLoc = errorLocations.find(function (loc) { return loc.path === error.dataPath; }); if (errLoc) { line = errLoc.line + 1; } } var trEl = document.createElement('tr'); trEl.className = !isNaN(line) ? 'jump-to-line' : ''; if (error.type === 'error') { trEl.className += ' parse-error'; } else { trEl.className += ' validation-error'; } var td1 = document.createElement('td'); var button = document.createElement('button'); button.className = 'jsoneditor-schema-error'; td1.appendChild(button); trEl.appendChild(td1); var td2 = document.createElement('td'); td2.style = 'white-space: nowrap;'; td2.textContent = !isNaN(line) ? 'Ln ' + line : ''; trEl.appendChild(td2); if (typeof error === 'string') { var td34 = document.createElement('td'); td34.colSpan = 2; var pre = document.createElement('pre'); pre.appendChild(document.createTextNode(error)); td34.appendChild(pre); trEl.appendChild(td34); } else { var td3 = document.createElement('td'); td3.appendChild(document.createTextNode(error.dataPath || '')); trEl.appendChild(td3); var td4 = document.createElement('td'); var _pre = document.createElement('pre'); _pre.appendChild(document.createTextNode(error.message)); td4.appendChild(_pre); trEl.appendChild(td4); } trEl.onclick = function () { _this.onFocusLine(line); }; tbody.appendChild(trEl); }); this.dom.validationErrors = validationErrors; this.dom.validationErrorsContainer.appendChild(validationErrors); this.dom.additionalErrorsIndication.title = errors.length + ' errors total'; if (this.dom.validationErrorsContainer.clientHeight < this.dom.validationErrorsContainer.scrollHeight) { this.dom.additionalErrorsIndication.style.display = 'block'; this.dom.validationErrorsContainer.onscroll = function () { _this.dom.additionalErrorsIndication.style.display = _this.dom.validationErrorsContainer.clientHeight > 0 && _this.dom.validationErrorsContainer.scrollTop === 0 ? 'block' : 'none'; }; } else { this.dom.validationErrorsContainer.onscroll = undefined; } var height = this.dom.validationErrorsContainer.clientHeight + (this.dom.statusBar ? this.dom.statusBar.clientHeight : 0); // this.content.style.marginBottom = (-height) + 'px'; // this.content.style.paddingBottom = height + 'px'; this.onChangeHeight(height); } else { this.onChangeHeight(0); } // update the status bar var validationErrorsCount = errors.filter(function (error) { return error.type !== 'error'; }).length; if (validationErrorsCount > 0) { this.dom.validationErrorCount.style.display = 'inline'; this.dom.validationErrorCount.innerText = validationErrorsCount; this.dom.validationErrorCount.onclick = this.toggleTableVisibility.bind(this); this.dom.validationErrorIcon.style.display = 'inline'; this.dom.validationErrorIcon.title = validationErrorsCount + ' schema validation error(s) found'; this.dom.validationErrorIcon.onclick = this.toggleTableVisibility.bind(this); } else { this.dom.validationErrorCount.style.display = 'none'; this.dom.validationErrorIcon.style.display = 'none'; } // update the parse error icon var hasParseErrors = errors.some(function (error) { return error.type === 'error'; }); if (hasParseErrors) { var line = errors[0].line; this.dom.parseErrorIndication.style.display = 'block'; this.dom.parseErrorIndication.title = !isNaN(line) ? 'parse error on line ' + line : 'parse error - check that the json is valid'; this.dom.parseErrorIndication.onclick = this.toggleTableVisibility.bind(this); } else { this.dom.parseErrorIndication.style.display = 'none'; } } }]); return ErrorTable; }(); /***/ }), /***/ 2474: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "R": function() { return /* binding */ FocusTracker; } /* harmony export */ }); /** * @constructor FocusTracker * A custom focus tracker for a DOM element with complex internal DOM structure * @param {[Object]} config A set of configurations for the FocusTracker * {DOM Object} target * The DOM object to track (required) * {Function} onFocus onFocus callback * {Function} onBlur onBlur callback * * @return */ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var FocusTracker = /*#__PURE__*/function () { function FocusTracker(config) { _classCallCheck(this, FocusTracker); this.target = config.target || null; if (!this.target) { throw new Error('FocusTracker constructor called without a "target" to track.'); } this.onFocus = typeof config.onFocus === 'function' ? config.onFocus : null; this.onBlur = typeof config.onBlur === 'function' ? config.onBlur : null; this._onClick = this._onEvent.bind(this); this._onKeyUp = function (event) { if (event.which === 9 || event.keyCode === 9) { this._onEvent(event); } }.bind(this); this.focusFlag = false; this.firstEventFlag = true; /* Adds required (click and keyup) event listeners to the 'document' object to track the focus of the given 'target' */ if (this.onFocus || this.onBlur) { document.addEventListener('click', this._onClick); document.addEventListener('keyup', this._onKeyUp); } } /** * Removes the event listeners on the 'document' object * that were added to track the focus of the given 'target' */ _createClass(FocusTracker, [{ key: "destroy", value: function destroy() { document.removeEventListener('click', this._onClick); document.removeEventListener('keyup', this._onKeyUp); this._onEvent({ target: document.body }); // calling _onEvent with body element in the hope that the FocusTracker is added to an element inside the body tag } /** * Tracks the focus of the target and calls the onFocus and onBlur * event callbacks if available. * @param {Event} [event] The 'click' or 'keyup' event object, * from the respective events set on * document object * @private */ }, { key: "_onEvent", value: function _onEvent(event) { var target = event.target; var focusFlag; if (target === this.target) { focusFlag = true; } else if (this.target.contains(target) || this.target.contains(document.activeElement)) { focusFlag = true; } else { focusFlag = false; } if (focusFlag) { if (!this.focusFlag) { // trigger the onFocus callback if (this.onFocus) { this.onFocus({ type: 'focus', target: this.target }); } this.focusFlag = true; } } else { if (this.focusFlag || this.firstEventFlag) { // trigger the onBlur callback if (this.onBlur) { this.onBlur({ type: 'blur', target: this.target }); } this.focusFlag = false; /* When switching from one mode to another in the editor, the FocusTracker gets recreated. At that time, this.focusFlag will be init to 'false' and will fail the above if condition, when blur occurs this.firstEventFlag is added to overcome that issue */ if (this.firstEventFlag) { this.firstEventFlag = false; } } } } }]); return FocusTracker; }(); /***/ }), /***/ 3161: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { "use strict"; var ace = __webpack_require__(8170); // may be undefined in case of minimalist bundle var VanillaPicker = __webpack_require__(8037); // may be undefined in case of minimalist bundle var _require = __webpack_require__(8038), treeModeMixins = _require.treeModeMixins; var _require2 = __webpack_require__(5956), textModeMixins = _require2.textModeMixins; var _require3 = __webpack_require__(341), previewModeMixins = _require3.previewModeMixins; var _require4 = __webpack_require__(9791), clear = _require4.clear, extend = _require4.extend, getInnerText = _require4.getInnerText, getInternetExplorerVersion = _require4.getInternetExplorerVersion, parse = _require4.parse; var _require5 = __webpack_require__(2744), tryRequireAjv = _require5.tryRequireAjv; var _require6 = __webpack_require__(2558), showTransformModal = _require6.showTransformModal; var _require7 = __webpack_require__(6210), showSortModal = _require7.showSortModal; var Ajv = tryRequireAjv(); if (typeof Promise === 'undefined') { console.error('Promise undefined. Please load a Promise polyfill in the browser in order to use JSONEditor'); } /** * @constructor JSONEditor * @param {Element} container Container element * @param {Object} [options] Object with options. available options: * {String} mode Editor mode. Available values: * 'tree' (default), 'view', * 'form', 'text', and 'code'. * {function} onChange Callback method, triggered * on change of contents. * Does not pass the contents itself. * See also `onChangeJSON` and * `onChangeText`. * {function} onChangeJSON Callback method, triggered * in modes on change of contents, * passing the changed contents * as JSON. * Only applicable for modes * 'tree', 'view', and 'form'. * {function} onChangeText Callback method, triggered * in modes on change of contents, * passing the changed contents * as stringified JSON. * {function} onError Callback method, triggered * when an error occurs * {Boolean} search Enable search box. * True by default * Only applicable for modes * 'tree', 'view', and 'form' * {Boolean} history Enable history (undo/redo). * True by default * Only applicable for modes * 'tree', 'view', and 'form' * {String} name Field name for the root node. * Only applicable for modes * 'tree', 'view', and 'form' * {Number} indentation Number of indentation * spaces. 4 by default. * Only applicable for * modes 'text' and 'code' * {boolean} escapeUnicode If true, unicode * characters are escaped. * false by default. * {boolean} sortObjectKeys If true, object keys are * sorted before display. * false by default. * {function} onSelectionChange Callback method, * triggered on node selection change * Only applicable for modes * 'tree', 'view', and 'form' * {function} onTextSelectionChange Callback method, * triggered on text selection change * Only applicable for modes * {HTMLElement} modalAnchor The anchor element to apply an * overlay and display the modals in a * centered location. * Defaults to document.body * 'text' and 'code' * {function} onEvent Callback method, triggered * when an event occurs in * a JSON field or value. * Only applicable for * modes 'form', 'tree' and * 'view' * {function} onFocus Callback method, triggered * when the editor comes into focus, * passing an object {type, target}, * Applicable for all modes * {function} onBlur Callback method, triggered * when the editor goes out of focus, * passing an object {type, target}, * Applicable for all modes * {function} onClassName Callback method, triggered * when a Node DOM is rendered. Function returns * a css class name to be set on a node. * Only applicable for * modes 'form', 'tree' and * 'view' * {Number} maxVisibleChilds Number of children allowed for a node * in 'tree', 'view', or 'form' mode before * the "show more/show all" buttons appear. * 100 by default. * * @param {Object | undefined} json JSON object */ function JSONEditor(container, options, json) { if (!(this instanceof JSONEditor)) { throw new Error('JSONEditor constructor called without "new".'); } // check for unsupported browser (IE8 and older) var ieVersion = getInternetExplorerVersion(); if (ieVersion !== -1 && ieVersion < 9) { throw new Error('Unsupported browser, IE9 or newer required. ' + 'Please install the newest version of your browser.'); } if (options) { // check for deprecated options if (options.error) { console.warn('Option "error" has been renamed to "onError"'); options.onError = options.error; delete options.error; } if (options.change) { console.warn('Option "change" has been renamed to "onChange"'); options.onChange = options.change; delete options.change; } if (options.editable) { console.warn('Option "editable" has been renamed to "onEditable"'); options.onEditable = options.editable; delete options.editable; } // warn if onChangeJSON is used when mode can be `text` or `code` if (options.onChangeJSON) { if (options.mode === 'text' || options.mode === 'code' || options.modes && (options.modes.indexOf('text') !== -1 || options.modes.indexOf('code') !== -1)) { console.warn('Option "onChangeJSON" is not applicable to modes "text" and "code". ' + 'Use "onChangeText" or "onChange" instead.'); } } // validate options if (options) { Object.keys(options).forEach(function (option) { if (JSONEditor.VALID_OPTIONS.indexOf(option) === -1) { console.warn('Unknown option "' + option + '". This option will be ignored'); } }); } } if (arguments.length) { this._create(container, options, json); } } /** * Configuration for all registered modes. Example: * { * tree: { * mixin: TreeEditor, * data: 'json' * }, * text: { * mixin: TextEditor, * data: 'text' * } * } * * @type { Object. } */ JSONEditor.modes = {}; // debounce interval for JSON schema validation in milliseconds JSONEditor.prototype.DEBOUNCE_INTERVAL = 150; JSONEditor.VALID_OPTIONS = ['ajv', 'schema', 'schemaRefs', 'templates', 'ace', 'theme', 'autocomplete', 'onChange', 'onChangeJSON', 'onChangeText', 'onEditable', 'onError', 'onEvent', 'onModeChange', 'onNodeName', 'onValidate', 'onCreateMenu', 'onSelectionChange', 'onTextSelectionChange', 'onClassName', 'onFocus', 'onBlur', 'colorPicker', 'onColorPicker', 'timestampTag', 'timestampFormat', 'escapeUnicode', 'history', 'search', 'mode', 'modes', 'name', 'indentation', 'sortObjectKeys', 'navigationBar', 'statusBar', 'mainMenuBar', 'languages', 'language', 'enableSort', 'enableTransform', 'limitDragging', 'maxVisibleChilds', 'onValidationError', 'modalAnchor', 'popupAnchor', 'createQuery', 'executeQuery', 'queryDescription']; /** * Create the JSONEditor * @param {Element} container Container element * @param {Object} [options] See description in constructor * @param {Object | undefined} json JSON object * @private */ JSONEditor.prototype._create = function (container, options, json) { this.container = container; this.options = options || {}; this.json = json || {}; var mode = this.options.mode || this.options.modes && this.options.modes[0] || 'tree'; this.setMode(mode); }; /** * Destroy the editor. Clean up DOM, event listeners, and web workers. */ JSONEditor.prototype.destroy = function () {}; /** * Set JSON object in editor * @param {Object | undefined} json JSON data */ JSONEditor.prototype.set = function (json) { this.json = json; }; /** * Get JSON from the editor * @returns {Object} json */ JSONEditor.prototype.get = function () { return this.json; }; /** * Set string containing JSON for the editor * @param {String | undefined} jsonText */ JSONEditor.prototype.setText = function (jsonText) { this.json = parse(jsonText); }; /** * Get stringified JSON contents from the editor * @returns {String} jsonText */ JSONEditor.prototype.getText = function () { return JSON.stringify(this.json); }; /** * Set a field name for the root node. * @param {String | undefined} name */ JSONEditor.prototype.setName = function (name) { if (!this.options) { this.options = {}; } this.options.name = name; }; /** * Get the field name for the root node. * @return {String | undefined} name */ JSONEditor.prototype.getName = function () { return this.options && this.options.name; }; /** * Change the mode of the editor. * JSONEditor will be extended with all methods needed for the chosen mode. * @param {String} mode Available modes: 'tree' (default), 'view', 'form', * 'text', and 'code'. */ JSONEditor.prototype.setMode = function (mode) { // if the mode is the same as current mode (and it's not the first time), do nothing. if (mode === this.options.mode && this.create) { return; } var container = this.container; var options = extend({}, this.options); var oldMode = options.mode; var data; var name; options.mode = mode; var config = JSONEditor.modes[mode]; if (config) { try { var asText = config.data === 'text'; name = this.getName(); data = this[asText ? 'getText' : 'get'](); // get text or json this.destroy(); clear(this); extend(this, config.mixin); this.create(container, options); this.setName(name); this[asText ? 'setText' : 'set'](data); // set text or json if (typeof config.load === 'function') { try { config.load.call(this); } catch (err) { console.error(err); } } if (typeof options.onModeChange === 'function' && mode !== oldMode) { try { options.onModeChange(mode, oldMode); } catch (err) { console.error(err); } } } catch (err) { this._onError(err); } } else { throw new Error('Unknown mode "' + options.mode + '"'); } }; /** * Get the current mode * @return {string} */ JSONEditor.prototype.getMode = function () { return this.options.mode; }; /** * Throw an error. If an error callback is configured in options.error, this * callback will be invoked. Else, a regular error is thrown. * @param {Error} err * @private */ JSONEditor.prototype._onError = function (err) { if (this.options && typeof this.options.onError === 'function') { this.options.onError(err); } else { throw err; } }; /** * Set a JSON schema for validation of the JSON object. * To remove the schema, call JSONEditor.setSchema(null) * @param {Object | null} schema * @param {Object.=} schemaRefs Schemas that are referenced using the `$ref` property from the JSON schema that are set in the `schema` option, + the object structure in the form of `{reference_key: schemaObject}` */ JSONEditor.prototype.setSchema = function (schema, schemaRefs) { // compile a JSON schema validator if a JSON schema is provided if (schema) { var ajv; try { // grab ajv from options if provided, else create a new instance if (this.options.ajv) { ajv = this.options.ajv; } else { ajv = Ajv({ allErrors: true, verbose: true, schemaId: 'auto', $data: true }); // support both draft-04 and draft-06 alongside the latest draft-07 ajv.addMetaSchema(__webpack_require__(2689)); ajv.addMetaSchema(__webpack_require__(1030)); } } catch (err) { console.warn('Failed to create an instance of Ajv, JSON Schema validation is not available. Please use a JSONEditor bundle including Ajv, or pass an instance of Ajv as via the configuration option `ajv`.'); } if (ajv) { if (schemaRefs) { for (var ref in schemaRefs) { ajv.removeSchema(ref); // When updating a schema - old refs has to be removed first if (schemaRefs[ref]) { ajv.addSchema(schemaRefs[ref], ref); } } this.options.schemaRefs = schemaRefs; } this.validateSchema = ajv.compile(schema); // add schema to the options, so that when switching to an other mode, // the set schema is not lost this.options.schema = schema; // validate now this.validate(); } this.refresh(); // update DOM } else { // remove current schema this.validateSchema = null; this.options.schema = null; this.options.schemaRefs = null; this.validate(); // to clear current error messages this.refresh(); // update DOM } }; /** * Validate current JSON object against the configured JSON schema * Throws an exception when no JSON schema is configured */ JSONEditor.prototype.validate = function () {// must be implemented by treemode and textmode }; /** * Refresh the rendered contents */ JSONEditor.prototype.refresh = function () {// can be implemented by treemode and textmode }; /** * Register a plugin with one ore multiple modes for the JSON Editor. * * A mode is described as an object with properties: * * - `mode: String` The name of the mode. * - `mixin: Object` An object containing the mixin functions which * will be added to the JSONEditor. Must contain functions * create, get, getText, set, and setText. May have * additional functions. * When the JSONEditor switches to a mixin, all mixin * functions are added to the JSONEditor, and then * the function `create(container, options)` is executed. * - `data: 'text' | 'json'` The type of data that will be used to load the mixin. * - `[load: function]` An optional function called after the mixin * has been loaded. * * @param {Object | Array} mode A mode object or an array with multiple mode objects. */ JSONEditor.registerMode = function (mode) { var i, prop; if (Array.isArray(mode)) { // multiple modes for (i = 0; i < mode.length; i++) { JSONEditor.registerMode(mode[i]); } } else { // validate the new mode if (!('mode' in mode)) throw new Error('Property "mode" missing'); if (!('mixin' in mode)) throw new Error('Property "mixin" missing'); if (!('data' in mode)) throw new Error('Property "data" missing'); var name = mode.mode; if (name in JSONEditor.modes) { throw new Error('Mode "' + name + '" already registered'); } // validate the mixin if (typeof mode.mixin.create !== 'function') { throw new Error('Required function "create" missing on mixin'); } var reserved = ['setMode', 'registerMode', 'modes']; for (i = 0; i < reserved.length; i++) { prop = reserved[i]; if (prop in mode.mixin) { throw new Error('Reserved property "' + prop + '" not allowed in mixin'); } } JSONEditor.modes[name] = mode; } }; // register tree, text, and preview modes JSONEditor.registerMode(treeModeMixins); JSONEditor.registerMode(textModeMixins); JSONEditor.registerMode(previewModeMixins); // expose some of the libraries that can be used customized JSONEditor.ace = ace; JSONEditor.Ajv = Ajv; JSONEditor.VanillaPicker = VanillaPicker; // expose some utils (this is undocumented, unofficial) JSONEditor.showTransformModal = showTransformModal; JSONEditor.showSortModal = showSortModal; JSONEditor.getInnerText = getInnerText; // default export for TypeScript ES6 projects JSONEditor["default"] = JSONEditor; module.exports = JSONEditor; /***/ }), /***/ 6617: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "x": function() { return /* binding */ ModeSwitcher; } /* harmony export */ }); /* harmony import */ var _ContextMenu__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(897); /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7907); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * Create a select box to be used in the editor menu's, which allows to switch mode * @param {HTMLElement} container * @param {String[]} modes Available modes: 'code', 'form', 'text', 'tree', 'view', 'preview' * @param {String} current Available modes: 'code', 'form', 'text', 'tree', 'view', 'preview' * @param {function(mode: string)} onSwitch Callback invoked on switch * @constructor */ var ModeSwitcher = /*#__PURE__*/function () { function ModeSwitcher(container, modes, current, onSwitch) { _classCallCheck(this, ModeSwitcher); // available modes var availableModes = { code: { text: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeCodeText'), title: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeCodeTitle'), click: function click() { onSwitch('code'); } }, form: { text: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeFormText'), title: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeFormTitle'), click: function click() { onSwitch('form'); } }, text: { text: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeTextText'), title: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeTextTitle'), click: function click() { onSwitch('text'); } }, tree: { text: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeTreeText'), title: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeTreeTitle'), click: function click() { onSwitch('tree'); } }, view: { text: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeViewText'), title: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeViewTitle'), click: function click() { onSwitch('view'); } }, preview: { text: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modePreviewText'), title: (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modePreviewTitle'), click: function click() { onSwitch('preview'); } } }; // list the selected modes var items = []; for (var i = 0; i < modes.length; i++) { var mode = modes[i]; var item = availableModes[mode]; if (!item) { throw new Error('Unknown mode "' + mode + '"'); } item.className = 'jsoneditor-type-modes' + (current === mode ? ' jsoneditor-selected' : ''); items.push(item); } // retrieve the title of current mode var currentMode = availableModes[current]; if (!currentMode) { throw new Error('Unknown mode "' + current + '"'); } var currentTitle = currentMode.text; // create the html element var box = document.createElement('button'); box.type = 'button'; box.className = 'jsoneditor-modes jsoneditor-separator'; box.textContent = currentTitle + " \u25BE"; box.title = (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('modeEditorTitle'); box.onclick = function () { var menu = new _ContextMenu__WEBPACK_IMPORTED_MODULE_0__/* .ContextMenu */ .x(items); menu.show(box, container); }; var frame = document.createElement('div'); frame.className = 'jsoneditor-modes'; frame.style.position = 'relative'; frame.appendChild(box); container.appendChild(frame); this.dom = { container: container, box: box, frame: frame }; } /** * Set focus to switcher */ _createClass(ModeSwitcher, [{ key: "focus", value: function focus() { this.dom.box.focus(); } /** * Destroy the ModeSwitcher, remove from DOM */ }, { key: "destroy", value: function destroy() { if (this.dom && this.dom.frame && this.dom.frame.parentNode) { this.dom.frame.parentNode.removeChild(this.dom.frame); } this.dom = null; } }]); return ModeSwitcher; }(); /***/ }), /***/ 8170: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var ace; if (window.ace) { // use the already loaded instance of Ace ace = window.ace; } else { try { // load Ace editor ace = __webpack_require__(6225); // load required Ace plugins __webpack_require__(4091); __webpack_require__(3330); // embed Ace json worker // https://github.com/ajaxorg/ace/issues/3913 var jsonWorkerDataUrl = __webpack_require__(7923); ace.config.setModuleUrl('ace/mode/json_worker', jsonWorkerDataUrl); } catch (err) {// failed to load Ace (can be minimalist bundle). // No worries, the editor will fall back to plain text if needed. } } module.exports = ace; /***/ }), /***/ 4864: /***/ (function() { /* ***** BEGIN LICENSE BLOCK ***** * Distributed under the BSD license: * * Copyright (c) 2010, Ajax.org B.V. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ***** END LICENSE BLOCK ***** */ window.ace.define('ace/theme/jsoneditor', ['require', 'exports', 'module', 'ace/lib/dom'], function (acequire, exports, module) { exports.isDark = false; exports.cssClass = 'ace-jsoneditor'; exports.cssText = ".ace-jsoneditor .ace_gutter {\nbackground: #ebebeb;\ncolor: #333\n}\n\n.ace-jsoneditor.ace_editor {\nfont-family: \"dejavu sans mono\", \"droid sans mono\", consolas, monaco, \"lucida console\", \"courier new\", courier, monospace, sans-serif;\nline-height: 1.3;\nbackground-color: #fff;\n}\n.ace-jsoneditor .ace_print-margin {\nwidth: 1px;\nbackground: #e8e8e8\n}\n.ace-jsoneditor .ace_scroller {\nbackground-color: #FFFFFF\n}\n.ace-jsoneditor .ace_text-layer {\ncolor: gray\n}\n.ace-jsoneditor .ace_variable {\ncolor: #1a1a1a\n}\n.ace-jsoneditor .ace_cursor {\nborder-left: 2px solid #000000\n}\n.ace-jsoneditor .ace_overwrite-cursors .ace_cursor {\nborder-left: 0px;\nborder-bottom: 1px solid #000000\n}\n.ace-jsoneditor .ace_marker-layer .ace_selection {\nbackground: lightgray\n}\n.ace-jsoneditor.ace_multiselect .ace_selection.ace_start {\nbox-shadow: 0 0 3px 0px #FFFFFF;\nborder-radius: 2px\n}\n.ace-jsoneditor .ace_marker-layer .ace_step {\nbackground: rgb(255, 255, 0)\n}\n.ace-jsoneditor .ace_marker-layer .ace_bracket {\nmargin: -1px 0 0 -1px;\nborder: 1px solid #BFBFBF\n}\n.ace-jsoneditor .ace_marker-layer .ace_active-line {\nbackground: #FFFBD1\n}\n.ace-jsoneditor .ace_gutter-active-line {\nbackground-color : #dcdcdc\n}\n.ace-jsoneditor .ace_marker-layer .ace_selected-word {\nborder: 1px solid lightgray\n}\n.ace-jsoneditor .ace_invisible {\ncolor: #BFBFBF\n}\n.ace-jsoneditor .ace_keyword,\n.ace-jsoneditor .ace_meta,\n.ace-jsoneditor .ace_support.ace_constant.ace_property-value {\ncolor: #AF956F\n}\n.ace-jsoneditor .ace_keyword.ace_operator {\ncolor: #484848\n}\n.ace-jsoneditor .ace_keyword.ace_other.ace_unit {\ncolor: #96DC5F\n}\n.ace-jsoneditor .ace_constant.ace_language {\ncolor: darkorange\n}\n.ace-jsoneditor .ace_constant.ace_numeric {\ncolor: red\n}\n.ace-jsoneditor .ace_constant.ace_character.ace_entity {\ncolor: #BF78CC\n}\n.ace-jsoneditor .ace_invalid {\ncolor: #FFFFFF;\nbackground-color: #FF002A;\n}\n.ace-jsoneditor .ace_fold {\nbackground-color: #AF956F;\nborder-color: #000000\n}\n.ace-jsoneditor .ace_storage,\n.ace-jsoneditor .ace_support.ace_class,\n.ace-jsoneditor .ace_support.ace_function,\n.ace-jsoneditor .ace_support.ace_other,\n.ace-jsoneditor .ace_support.ace_type {\ncolor: #C52727\n}\n.ace-jsoneditor .ace_string {\ncolor: green\n}\n.ace-jsoneditor .ace_comment {\ncolor: #BCC8BA\n}\n.ace-jsoneditor .ace_entity.ace_name.ace_tag,\n.ace-jsoneditor .ace_entity.ace_other.ace_attribute-name {\ncolor: #606060\n}\n.ace-jsoneditor .ace_markup.ace_underline {\ntext-decoration: underline\n}\n.ace-jsoneditor .ace_indent-guide {\nbackground: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y\n}"; var dom = acequire('../lib/dom'); dom.importCssString(exports.cssText, exports.cssClass); }); /***/ }), /***/ 6589: /***/ (function(__unused_webpack_module, exports) { /* Jison generated parser */ var jsonlint = function () { var parser = { trace: function trace() {}, yy: {}, symbols_: { "error": 2, "JSONString": 3, "STRING": 4, "JSONNumber": 5, "NUMBER": 6, "JSONNullLiteral": 7, "NULL": 8, "JSONBooleanLiteral": 9, "TRUE": 10, "FALSE": 11, "JSONText": 12, "JSONValue": 13, "EOF": 14, "JSONObject": 15, "JSONArray": 16, "{": 17, "}": 18, "JSONMemberList": 19, "JSONMember": 20, ":": 21, ",": 22, "[": 23, "]": 24, "JSONElementList": 25, "$accept": 0, "$end": 1 }, terminals_: { 2: "error", 4: "STRING", 6: "NUMBER", 8: "NULL", 10: "TRUE", 11: "FALSE", 14: "EOF", 17: "{", 18: "}", 21: ":", 22: ",", 23: "[", 24: "]" }, productions_: [0, [3, 1], [5, 1], [7, 1], [9, 1], [9, 1], [12, 2], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [15, 2], [15, 3], [20, 3], [19, 1], [19, 3], [16, 2], [16, 3], [25, 1], [25, 3]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { var $0 = $$.length - 1; switch (yystate) { case 1: // replace escaped characters with actual character this.$ = yytext.replace(/\\(\\|")/g, "$" + "1").replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\v/g, '\v').replace(/\\f/g, '\f').replace(/\\b/g, '\b'); break; case 2: this.$ = Number(yytext); break; case 3: this.$ = null; break; case 4: this.$ = true; break; case 5: this.$ = false; break; case 6: return this.$ = $$[$0 - 1]; break; case 13: this.$ = {}; break; case 14: this.$ = $$[$0 - 1]; break; case 15: this.$ = [$$[$0 - 2], $$[$0]]; break; case 16: this.$ = {}; this.$[$$[$0][0]] = $$[$0][1]; break; case 17: this.$ = $$[$0 - 2]; $$[$0 - 2][$$[$0][0]] = $$[$0][1]; break; case 18: this.$ = []; break; case 19: this.$ = $$[$0 - 1]; break; case 20: this.$ = [$$[$0]]; break; case 21: this.$ = $$[$0 - 2]; $$[$0 - 2].push($$[$0]); break; } }, table: [{ 3: 5, 4: [1, 12], 5: 6, 6: [1, 13], 7: 3, 8: [1, 9], 9: 4, 10: [1, 10], 11: [1, 11], 12: 1, 13: 2, 15: 7, 16: 8, 17: [1, 14], 23: [1, 15] }, { 1: [3] }, { 14: [1, 16] }, { 14: [2, 7], 18: [2, 7], 22: [2, 7], 24: [2, 7] }, { 14: [2, 8], 18: [2, 8], 22: [2, 8], 24: [2, 8] }, { 14: [2, 9], 18: [2, 9], 22: [2, 9], 24: [2, 9] }, { 14: [2, 10], 18: [2, 10], 22: [2, 10], 24: [2, 10] }, { 14: [2, 11], 18: [2, 11], 22: [2, 11], 24: [2, 11] }, { 14: [2, 12], 18: [2, 12], 22: [2, 12], 24: [2, 12] }, { 14: [2, 3], 18: [2, 3], 22: [2, 3], 24: [2, 3] }, { 14: [2, 4], 18: [2, 4], 22: [2, 4], 24: [2, 4] }, { 14: [2, 5], 18: [2, 5], 22: [2, 5], 24: [2, 5] }, { 14: [2, 1], 18: [2, 1], 21: [2, 1], 22: [2, 1], 24: [2, 1] }, { 14: [2, 2], 18: [2, 2], 22: [2, 2], 24: [2, 2] }, { 3: 20, 4: [1, 12], 18: [1, 17], 19: 18, 20: 19 }, { 3: 5, 4: [1, 12], 5: 6, 6: [1, 13], 7: 3, 8: [1, 9], 9: 4, 10: [1, 10], 11: [1, 11], 13: 23, 15: 7, 16: 8, 17: [1, 14], 23: [1, 15], 24: [1, 21], 25: 22 }, { 1: [2, 6] }, { 14: [2, 13], 18: [2, 13], 22: [2, 13], 24: [2, 13] }, { 18: [1, 24], 22: [1, 25] }, { 18: [2, 16], 22: [2, 16] }, { 21: [1, 26] }, { 14: [2, 18], 18: [2, 18], 22: [2, 18], 24: [2, 18] }, { 22: [1, 28], 24: [1, 27] }, { 22: [2, 20], 24: [2, 20] }, { 14: [2, 14], 18: [2, 14], 22: [2, 14], 24: [2, 14] }, { 3: 20, 4: [1, 12], 20: 29 }, { 3: 5, 4: [1, 12], 5: 6, 6: [1, 13], 7: 3, 8: [1, 9], 9: 4, 10: [1, 10], 11: [1, 11], 13: 30, 15: 7, 16: 8, 17: [1, 14], 23: [1, 15] }, { 14: [2, 19], 18: [2, 19], 22: [2, 19], 24: [2, 19] }, { 3: 5, 4: [1, 12], 5: 6, 6: [1, 13], 7: 3, 8: [1, 9], 9: 4, 10: [1, 10], 11: [1, 11], 13: 31, 15: 7, 16: 8, 17: [1, 14], 23: [1, 15] }, { 18: [2, 17], 22: [2, 17] }, { 18: [2, 15], 22: [2, 15] }, { 22: [2, 21], 24: [2, 21] }], defaultActions: { 16: [2, 6] }, parseError: function parseError(str, hash) { throw new Error(str); }, parse: function parse(input) { var self = this, stack = [0], vstack = [null], // semantic value stack lstack = [], // location stack table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; //this.reductionCount = this.shiftCount = 0; this.lexer.setInput(input); this.lexer.yy = this.yy; this.yy.lexer = this.lexer; if (typeof this.lexer.yylloc == 'undefined') this.lexer.yylloc = {}; var yyloc = this.lexer.yylloc; lstack.push(yyloc); if (typeof this.yy.parseError === 'function') this.parseError = this.yy.parseError; function popStack(n) { stack.length = stack.length - 2 * n; vstack.length = vstack.length - n; lstack.length = lstack.length - n; } function lex() { var token; token = self.lexer.lex() || 1; // $end = 1 // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } return token; } var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; while (true) { // retreive state number from top of stack state = stack[stack.length - 1]; // use default actions if available if (this.defaultActions[state]) { action = this.defaultActions[state]; } else { if (symbol == null) symbol = lex(); // read action for current state and first input action = table[state] && table[state][symbol]; } // handle parse error _handle_error: if (typeof action === 'undefined' || !action.length || !action[0]) { if (!recovering) { // Report error expected = []; for (p in table[state]) { if (this.terminals_[p] && p > 2) { expected.push("'" + this.terminals_[p] + "'"); } } var errStr = ''; if (this.lexer.showPosition) { errStr = 'Parse error on line ' + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(', ') + ", got '" + this.terminals_[symbol] + "'"; } else { errStr = 'Parse error on line ' + (yylineno + 1) + ": Unexpected " + (symbol == 1 /*EOF*/ ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); } this.parseError(errStr, { text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected }); } // just recovered from another error if (recovering == 3) { if (symbol == EOF) { throw new Error(errStr || 'Parsing halted.'); } // discard current lookahead and grab another yyleng = this.lexer.yyleng; yytext = this.lexer.yytext; yylineno = this.lexer.yylineno; yyloc = this.lexer.yylloc; symbol = lex(); } // try to recover from error while (1) { // check for error recovery rule in this state if (TERROR.toString() in table[state]) { break; } if (state == 0) { throw new Error(errStr || 'Parsing halted.'); } popStack(1); state = stack[stack.length - 1]; } preErrorSymbol = symbol; // save the lookahead token symbol = TERROR; // insert generic error symbol as new lookahead state = stack[stack.length - 1]; action = table[state] && table[state][TERROR]; recovering = 3; // allow 3 real symbols to be shifted before reporting a new error } // this shouldn't happen, unless resolve defaults are off if (action[0] instanceof Array && action.length > 1) { throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); } switch (action[0]) { case 1: // shift //this.shiftCount++; stack.push(symbol); vstack.push(this.lexer.yytext); lstack.push(this.lexer.yylloc); stack.push(action[1]); // push state symbol = null; if (!preErrorSymbol) { // normal execution/no error yyleng = this.lexer.yyleng; yytext = this.lexer.yytext; yylineno = this.lexer.yylineno; yyloc = this.lexer.yylloc; if (recovering > 0) recovering--; } else { // error just occurred, resume old lookahead f/ before error symbol = preErrorSymbol; preErrorSymbol = null; } break; case 2: // reduce //this.reductionCount++; len = this.productions_[action[1]][1]; // perform semantic action yyval.$ = vstack[vstack.length - len]; // default to $$ = $1 // default location, uses first token for firsts, last for lasts yyval._$ = { first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column }; r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); if (typeof r !== 'undefined') { return r; } // pop off stack if (len) { stack = stack.slice(0, -1 * len * 2); vstack = vstack.slice(0, -1 * len); lstack = lstack.slice(0, -1 * len); } stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce) vstack.push(yyval.$); lstack.push(yyval._$); // goto new state = table[STATE][NONTERMINAL] newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; stack.push(newState); break; case 3: // accept return true; } } return true; } }; /* Jison generated lexer */ var lexer = function () { var lexer = { EOF: 1, parseError: function parseError(str, hash) { if (this.yy.parseError) { this.yy.parseError(str, hash); } else { throw new Error(str); } }, setInput: function setInput(input) { this._input = input; this._more = this._less = this.done = false; this.yylineno = this.yyleng = 0; this.yytext = this.matched = this.match = ''; this.conditionStack = ['INITIAL']; this.yylloc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0 }; return this; }, input: function input() { var ch = this._input[0]; this.yytext += ch; this.yyleng++; this.match += ch; this.matched += ch; var lines = ch.match(/\n/); if (lines) this.yylineno++; this._input = this._input.slice(1); return ch; }, unput: function unput(ch) { this._input = ch + this._input; return this; }, more: function more() { this._more = true; return this; }, less: function less(n) { this._input = this.match.slice(n) + this._input; }, pastInput: function pastInput() { var past = this.matched.substr(0, this.matched.length - this.match.length); return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, ""); }, upcomingInput: function upcomingInput() { var next = this.match; if (next.length < 20) { next += this._input.substr(0, 20 - next.length); } return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); }, showPosition: function showPosition() { var pre = this.pastInput(); var c = new Array(pre.length + 1).join("-"); return pre + this.upcomingInput() + "\n" + c + "^"; }, next: function next() { if (this.done) { return this.EOF; } if (!this._input) this.done = true; var token, match, tempMatch, index, col, lines; if (!this._more) { this.yytext = ''; this.match = ''; } var rules = this._currentRules(); for (var i = 0; i < rules.length; i++) { tempMatch = this._input.match(this.rules[rules[i]]); if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { match = tempMatch; index = i; if (!this.options.flex) break; } } if (match) { lines = match[0].match(/\n.*/g); if (lines) this.yylineno += lines.length; this.yylloc = { first_line: this.yylloc.last_line, last_line: this.yylineno + 1, first_column: this.yylloc.last_column, last_column: lines ? lines[lines.length - 1].length - 1 : this.yylloc.last_column + match[0].length }; this.yytext += match[0]; this.match += match[0]; this.yyleng = this.yytext.length; this._more = false; this._input = this._input.slice(match[0].length); this.matched += match[0]; token = this.performAction.call(this, this.yy, this, rules[index], this.conditionStack[this.conditionStack.length - 1]); if (this.done && this._input) this.done = false; if (token) return token;else return; } if (this._input === "") { return this.EOF; } else { this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { text: "", token: null, line: this.yylineno }); } }, lex: function lex() { var r = this.next(); if (typeof r !== 'undefined') { return r; } else { return this.lex(); } }, begin: function begin(condition) { this.conditionStack.push(condition); }, popState: function popState() { return this.conditionStack.pop(); }, _currentRules: function _currentRules() { return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; }, topState: function topState() { return this.conditionStack[this.conditionStack.length - 2]; }, pushState: function begin(condition) { this.begin(condition); } }; lexer.options = {}; lexer.performAction = function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { var YYSTATE = YY_START; switch ($avoiding_name_collisions) { case 0: /* skip whitespace */ break; case 1: return 6; break; case 2: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 2); return 4; break; case 3: return 17; break; case 4: return 18; break; case 5: return 23; break; case 6: return 24; break; case 7: return 22; break; case 8: return 21; break; case 9: return 10; break; case 10: return 11; break; case 11: return 8; break; case 12: return 14; break; case 13: return 'INVALID'; break; } }; lexer.rules = [/^(?:\s+)/, /^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/, /^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/, /^(?:\{)/, /^(?:\})/, /^(?:\[)/, /^(?:\])/, /^(?:,)/, /^(?::)/, /^(?:true\b)/, /^(?:false\b)/, /^(?:null\b)/, /^(?:$)/, /^(?:.)/]; lexer.conditions = { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], "inclusive": true } }; ; return lexer; }(); parser.lexer = lexer; return parser; }(); if (true) { exports.parser = jsonlint; exports.parse = jsonlint.parse.bind(jsonlint); } /***/ }), /***/ 3879: /***/ (function(module) { "use strict"; /*! * Selectr 2.4.0 * https://github.com/Mobius1/Selectr * * Released under the MIT license */ /** * Default configuration options * @type {Object} */ var defaultConfig = { /** * Emulates browser behaviour by selecting the first option by default * @type {Boolean} */ defaultSelected: true, /** * Sets the width of the container * @type {String} */ width: "auto", /** * Enables/ disables the container * @type {Boolean} */ disabled: false, /** * Enables / disables the search function * @type {Boolean} */ searchable: true, /** * Enable disable the clear button * @type {Boolean} */ clearable: false, /** * Sort the tags / multiselect options * @type {Boolean} */ sortSelected: false, /** * Allow deselecting of select-one options * @type {Boolean} */ allowDeselect: false, /** * Close the dropdown when scrolling (@AlexanderReiswich, #11) * @type {Boolean} */ closeOnScroll: false, /** * Allow the use of the native dropdown (@jonnyscholes, #14) * @type {Boolean} */ nativeDropdown: false, /** * Set the main placeholder * @type {String} */ placeholder: "Select an option...", /** * Allow the tagging feature * @type {Boolean} */ taggable: false, /** * Set the tag input placeholder (@labikmartin, #21, #22) * @type {String} */ tagPlaceholder: "Enter a tag..." }; /** * Event Emitter */ var Events = function Events() {}; /** * Event Prototype * @type {Object} */ Events.prototype = { /** * Add custom event listener * @param {String} event Event type * @param {Function} func Callback * @return {Void} */ on: function on(event, func) { this._events = this._events || {}; this._events[event] = this._events[event] || []; this._events[event].push(func); }, /** * Remove custom event listener * @param {String} event Event type * @param {Function} func Callback * @return {Void} */ off: function off(event, func) { this._events = this._events || {}; if (event in this._events === false) return; this._events[event].splice(this._events[event].indexOf(func), 1); }, /** * Fire a custom event * @param {String} event Event type * @return {Void} */ emit: function emit(event /* , args... */ ) { this._events = this._events || {}; if (event in this._events === false) return; for (var i = 0; i < this._events[event].length; i++) { this._events[event][i].apply(this, Array.prototype.slice.call(arguments, 1)); } } }; /** * Event mixin * @param {Object} obj * @return {Object} */ Events.mixin = function (obj) { var props = ['on', 'off', 'emit']; for (var i = 0; i < props.length; i++) { if (typeof obj === 'function') { obj.prototype[props[i]] = Events.prototype[props[i]]; } else { obj[props[i]] = Events.prototype[props[i]]; } } return obj; }; /** * Helpers * @type {Object} */ var util = { extend: function extend(src, props) { props = props || {}; var p; for (p in src) { if (src.hasOwnProperty(p)) { if (!props.hasOwnProperty(p)) { props[p] = src[p]; } } } return props; }, each: function each(a, b, c) { if ("[object Object]" === Object.prototype.toString.call(a)) { for (var d in a) { if (Object.prototype.hasOwnProperty.call(a, d)) { b.call(c, d, a[d], a); } } } else { for (var e = 0, f = a.length; e < f; e++) { b.call(c, e, a[e], a); } } }, createElement: function createElement(e, a) { var d = document, el = d.createElement(e); if (a && "[object Object]" === Object.prototype.toString.call(a)) { var i; for (i in a) { if (i in el) el[i] = a[i];else if ("html" === i) el.textContent = a[i];else if ("text" === i) { var t = d.createTextNode(a[i]); el.appendChild(t); } else el.setAttribute(i, a[i]); } } return el; }, hasClass: function hasClass(a, b) { if (a) return a.classList ? a.classList.contains(b) : !!a.className && !!a.className.match(new RegExp("(\\s|^)" + b + "(\\s|$)")); }, addClass: function addClass(a, b) { if (!util.hasClass(a, b)) { if (a.classList) { a.classList.add(b); } else { a.className = a.className.trim() + " " + b; } } }, removeClass: function removeClass(a, b) { if (util.hasClass(a, b)) { if (a.classList) { a.classList.remove(b); } else { a.className = a.className.replace(new RegExp("(^|\\s)" + b.split(" ").join("|") + "(\\s|$)", "gi"), " "); } } }, closest: function closest(el, fn) { return el && el !== document.body && (fn(el) ? el : util.closest(el.parentNode, fn)); }, isInt: function isInt(val) { return typeof val === 'number' && isFinite(val) && Math.floor(val) === val; }, debounce: function debounce(a, b, c) { var d; return function () { var e = this, f = arguments, g = function g() { d = null; if (!c) a.apply(e, f); }, h = c && !d; clearTimeout(d); d = setTimeout(g, b); if (h) { a.apply(e, f); } }; }, rect: function rect(el, abs) { var w = window; var r = el.getBoundingClientRect(); var x = abs ? w.pageXOffset : 0; var y = abs ? w.pageYOffset : 0; return { bottom: r.bottom + y, height: r.height, left: r.left + x, right: r.right + x, top: r.top + y, width: r.width }; }, includes: function includes(a, b) { return a.indexOf(b) > -1; }, truncate: function truncate(el) { while (el.firstChild) { el.removeChild(el.firstChild); } } }; function isset(obj, prop) { return obj.hasOwnProperty(prop) && (obj[prop] === true || obj[prop].length); } /** * Append an item to the list * @param {Object} item * @param {Object} custom * @return {Void} */ function appendItem(item, parent, custom) { if (item.parentNode) { if (!item.parentNode.parentNode) { parent.appendChild(item.parentNode); } } else { parent.appendChild(item); } util.removeClass(item, "excluded"); if (!custom) { item.textContent = item.textContent + ''; // clear highlighting } } /** * Render the item list * @return {Void} */ var render = function render() { if (this.items.length) { var f = document.createDocumentFragment(); if (this.config.pagination) { var pages = this.pages.slice(0, this.pageIndex); util.each(pages, function (i, items) { util.each(items, function (j, item) { appendItem(item, f, this.customOption); }, this); }, this); } else { util.each(this.items, function (i, item) { appendItem(item, f, this.customOption); }, this); } if (f.childElementCount) { util.removeClass(this.items[this.navIndex], "active"); this.navIndex = f.querySelector(".selectr-option").idx; util.addClass(this.items[this.navIndex], "active"); } this.tree.appendChild(f); } }; /** * Dismiss / close the dropdown * @param {obj} e * @return {void} */ var dismiss = function dismiss(e) { var target = e.target; if (!this.container.contains(target) && (this.opened || util.hasClass(this.container, "notice"))) { this.close(); } }; /** * Build a list item from the HTMLOptionElement * @param {int} i HTMLOptionElement index * @param {HTMLOptionElement} option * @param {bool} group Has parent optgroup * @return {void} */ var createItem = function createItem(option, data) { data = data || option; var content = this.customOption ? this.config.renderOption(data) : option.textContent; var opt = util.createElement("li", { "class": "selectr-option", html: content, role: "treeitem", "aria-selected": false }); opt.idx = option.idx; this.items.push(opt); if (option.defaultSelected) { this.defaultSelected.push(option.idx); } if (option.disabled) { opt.disabled = true; util.addClass(opt, "disabled"); } return opt; }; /** * Build the container * @return {Void} */ var build = function build() { this.requiresPagination = this.config.pagination && this.config.pagination > 0; // Set width if (isset(this.config, "width")) { if (util.isInt(this.config.width)) { this.width = this.config.width + "px"; } else { if (this.config.width === "auto") { this.width = "100%"; } else if (util.includes(this.config.width, "%")) { this.width = this.config.width; } } } this.container = util.createElement("div", { "class": "selectr-container" }); // Custom className if (this.config.customClass) { util.addClass(this.container, this.config.customClass); } // Mobile device if (this.mobileDevice) { util.addClass(this.container, "selectr-mobile"); } else { util.addClass(this.container, "selectr-desktop"); } // Hide the HTMLSelectElement and prevent focus this.el.tabIndex = -1; // Native dropdown if (this.config.nativeDropdown || this.mobileDevice) { util.addClass(this.el, "selectr-visible"); } else { util.addClass(this.el, "selectr-hidden"); } this.selected = util.createElement("div", { "class": "selectr-selected", disabled: this.disabled, tabIndex: 1, // enable tabIndex (#9) "aria-expanded": false }); this.label = util.createElement(this.el.multiple ? "ul" : "span", { "class": "selectr-label" }); var dropdown = util.createElement("div", { "class": "selectr-options-container" }); this.tree = util.createElement("ul", { "class": "selectr-options", role: "tree", "aria-hidden": true, "aria-expanded": false }); this.notice = util.createElement("div", { "class": "selectr-notice" }); this.el.setAttribute("aria-hidden", true); if (this.disabled) { this.el.disabled = true; } if (this.el.multiple) { util.addClass(this.label, "selectr-tags"); util.addClass(this.container, "multiple"); // Collection of tags this.tags = []; // Collection of selected values this.selectedValues = this.getSelectedProperties('value'); // Collection of selected indexes this.selectedIndexes = this.getSelectedProperties('idx'); } this.selected.appendChild(this.label); if (this.config.clearable) { this.selectClear = util.createElement("button", { "class": "selectr-clear", type: "button" }); this.container.appendChild(this.selectClear); util.addClass(this.container, "clearable"); } if (this.config.taggable) { var li = util.createElement('li', { "class": 'input-tag' }); this.input = util.createElement("input", { "class": "selectr-tag-input", placeholder: this.config.tagPlaceholder, tagIndex: 0, autocomplete: "off", autocorrect: "off", autocapitalize: "off", spellcheck: "false", role: "textbox", type: "search" }); li.appendChild(this.input); this.label.appendChild(li); util.addClass(this.container, "taggable"); this.tagSeperators = [","]; if (this.config.tagSeperators) { this.tagSeperators = this.tagSeperators.concat(this.config.tagSeperators); } } if (this.config.searchable) { this.input = util.createElement("input", { "class": "selectr-input", tagIndex: -1, autocomplete: "off", autocorrect: "off", autocapitalize: "off", spellcheck: "false", role: "textbox", type: "search" }); this.inputClear = util.createElement("button", { "class": "selectr-input-clear", type: "button" }); this.inputContainer = util.createElement("div", { "class": "selectr-input-container" }); this.inputContainer.appendChild(this.input); this.inputContainer.appendChild(this.inputClear); dropdown.appendChild(this.inputContainer); } dropdown.appendChild(this.notice); dropdown.appendChild(this.tree); // List of items for the dropdown this.items = []; // Establish options this.options = []; // Check for options in the element if (this.el.options.length) { this.options = [].slice.call(this.el.options); } // Element may have optgroups so // iterate element.children instead of element.options var group = false, j = 0; if (this.el.children.length) { util.each(this.el.children, function (i, element) { if (element.nodeName === "OPTGROUP") { group = util.createElement("ul", { "class": "selectr-optgroup", role: "group", html: "
  • " + element.label + "
  • " }); util.each(element.children, function (x, el) { el.idx = j; group.appendChild(createItem.call(this, el, group)); j++; }, this); } else { element.idx = j; createItem.call(this, element); j++; } }, this); } // Options defined by the data option if (this.config.data && Array.isArray(this.config.data)) { this.data = []; var optgroup = false, option; group = false; j = 0; util.each(this.config.data, function (i, opt) { // Check for group options if (isset(opt, "children")) { optgroup = util.createElement("optgroup", { label: opt.text }); group = util.createElement("ul", { "class": "selectr-optgroup", role: "group", html: "
  • " + opt.text + "
  • " }); util.each(opt.children, function (x, data) { option = new Option(data.text, data.value, false, data.hasOwnProperty("selected") && data.selected === true); option.disabled = isset(data, "disabled"); this.options.push(option); optgroup.appendChild(option); option.idx = j; group.appendChild(createItem.call(this, option, data)); this.data[j] = data; j++; }, this); } else { option = new Option(opt.text, opt.value, false, opt.hasOwnProperty("selected") && opt.selected === true); option.disabled = isset(opt, "disabled"); this.options.push(option); option.idx = j; createItem.call(this, option, opt); this.data[j] = opt; j++; } }, this); } this.setSelected(true); var first; this.navIndex = 0; for (var i = 0; i < this.items.length; i++) { first = this.items[i]; if (!util.hasClass(first, "disabled")) { util.addClass(first, "active"); this.navIndex = i; break; } } // Check for pagination / infinite scroll if (this.requiresPagination) { this.pageIndex = 1; // Create the pages this.paginate(); } this.container.appendChild(this.selected); this.container.appendChild(dropdown); this.placeEl = util.createElement("div", { "class": "selectr-placeholder" }); // Set the placeholder this.setPlaceholder(); this.selected.appendChild(this.placeEl); // Disable if required if (this.disabled) { this.disable(); } this.el.parentNode.insertBefore(this.container, this.el); this.container.appendChild(this.el); }; /** * Navigate through the dropdown * @param {obj} e * @return {void} */ var navigate = function navigate(e) { e = e || window.event; // Filter out the keys we don"t want if (!this.items.length || !this.opened || !util.includes([13, 38, 40], e.which)) { this.navigating = false; return; } e.preventDefault(); if (e.which === 13) { if (this.config.taggable && this.input.value.length > 0) { return false; } return this.change(this.navIndex); } var direction, prevEl = this.items[this.navIndex]; switch (e.which) { case 38: direction = 0; if (this.navIndex > 0) { this.navIndex--; } break; case 40: direction = 1; if (this.navIndex < this.items.length - 1) { this.navIndex++; } } this.navigating = true; // Instead of wasting memory holding a copy of this.items // with disabled / excluded options omitted, skip them instead while (util.hasClass(this.items[this.navIndex], "disabled") || util.hasClass(this.items[this.navIndex], "excluded")) { if (direction) { this.navIndex++; } else { this.navIndex--; } if (this.searching) { if (this.navIndex > this.tree.lastElementChild.idx) { this.navIndex = this.tree.lastElementChild.idx; break; } else if (this.navIndex < this.tree.firstElementChild.idx) { this.navIndex = this.tree.firstElementChild.idx; break; } } } // Autoscroll the dropdown during navigation var r = util.rect(this.items[this.navIndex]); if (!direction) { if (this.navIndex === 0) { this.tree.scrollTop = 0; } else if (r.top - this.optsRect.top < 0) { this.tree.scrollTop = this.tree.scrollTop + (r.top - this.optsRect.top); } } else { if (this.navIndex === 0) { this.tree.scrollTop = 0; } else if (r.top + r.height > this.optsRect.top + this.optsRect.height) { this.tree.scrollTop = this.tree.scrollTop + (r.top + r.height - (this.optsRect.top + this.optsRect.height)); } // Load another page if needed if (this.navIndex === this.tree.childElementCount - 1 && this.requiresPagination) { load.call(this); } } if (prevEl) { util.removeClass(prevEl, "active"); } util.addClass(this.items[this.navIndex], "active"); }; /** * Add a tag * @param {HTMLElement} item */ var addTag = function addTag(item) { var that = this, r; var docFrag = document.createDocumentFragment(); var option = this.options[item.idx]; var data = this.data ? this.data[item.idx] : option; var content = this.customSelected ? this.config.renderSelection(data) : option.textContent; var tag = util.createElement("li", { "class": "selectr-tag", html: content }); var btn = util.createElement("button", { "class": "selectr-tag-remove", type: "button" }); tag.appendChild(btn); // Set property to check against later tag.idx = item.idx; tag.tag = option.value; this.tags.push(tag); if (this.config.sortSelected) { var tags = this.tags.slice(); // Deal with values that contain numbers r = function r(val, arr) { val.replace(/(\d+)|(\D+)/g, function (that, $1, $2) { arr.push([$1 || Infinity, $2 || ""]); }); }; tags.sort(function (a, b) { var x = [], y = [], ac, bc; if (that.config.sortSelected === true) { ac = a.tag; bc = b.tag; } else if (that.config.sortSelected === 'text') { ac = a.textContent; bc = b.textContent; } r(ac, x); r(bc, y); while (x.length && y.length) { var ax = x.shift(); var by = y.shift(); var nn = ax[0] - by[0] || ax[1].localeCompare(by[1]); if (nn) return nn; } return x.length - y.length; }); util.each(tags, function (i, tg) { docFrag.appendChild(tg); }); this.label.textContent = ""; } else { docFrag.appendChild(tag); } if (this.config.taggable) { this.label.insertBefore(docFrag, this.input.parentNode); } else { this.label.appendChild(docFrag); } }; /** * Remove a tag * @param {HTMLElement} item * @return {void} */ var removeTag = function removeTag(item) { var tag = false; util.each(this.tags, function (i, t) { if (t.idx === item.idx) { tag = t; } }, this); if (tag) { this.label.removeChild(tag); this.tags.splice(this.tags.indexOf(tag), 1); } }; /** * Load the next page of items * @return {void} */ var load = function load() { var tree = this.tree; var scrollTop = tree.scrollTop; var scrollHeight = tree.scrollHeight; var offsetHeight = tree.offsetHeight; var atBottom = scrollTop >= scrollHeight - offsetHeight; if (atBottom && this.pageIndex < this.pages.length) { var f = document.createDocumentFragment(); util.each(this.pages[this.pageIndex], function (i, item) { appendItem(item, f, this.customOption); }, this); tree.appendChild(f); this.pageIndex++; this.emit("selectr.paginate", { items: this.items.length, total: this.data.length, page: this.pageIndex, pages: this.pages.length }); } }; /** * Clear a search * @return {void} */ var clearSearch = function clearSearch() { if (this.config.searchable || this.config.taggable) { this.input.value = null; this.searching = false; if (this.config.searchable) { util.removeClass(this.inputContainer, "active"); } if (util.hasClass(this.container, "notice")) { util.removeClass(this.container, "notice"); util.addClass(this.container, "open"); this.input.focus(); } util.each(this.items, function (i, item) { // Items that didn't match need the class // removing to make them visible again util.removeClass(item, "excluded"); // Remove the span element for underlining matched items if (!this.customOption) { item.textContent = item.textContent + ''; // clear highlighting } }, this); } }; /** * Query matching for searches * @param {string} query * @param {string} text */ var match = function match(query, text) { var result = new RegExp(query, "i").exec(text); if (result) { var start = result.index; var end = result.index + result[0].length; return { before: text.substring(0, start), match: text.substring(start, end), after: text.substring(end) }; } return null; }; // Main Lib var Selectr = function Selectr(el, config) { config = config || {}; if (!el) { throw new Error("You must supply either a HTMLSelectElement or a CSS3 selector string."); } this.el = el; // CSS3 selector string if (typeof el === "string") { this.el = document.querySelector(el); } if (this.el === null) { throw new Error("The element you passed to Selectr can not be found."); } if (this.el.nodeName.toLowerCase() !== "select") { throw new Error("The element you passed to Selectr is not a HTMLSelectElement."); } this.render(config); }; /** * Render the instance * @param {object} config * @return {void} */ Selectr.prototype.render = function (config) { if (this.rendered) return; // Merge defaults with user set config this.config = util.extend(defaultConfig, config); // Store type this.originalType = this.el.type; // Store tabIndex this.originalIndex = this.el.tabIndex; // Store defaultSelected options for form reset this.defaultSelected = []; // Store the original option count this.originalOptionCount = this.el.options.length; if (this.config.multiple || this.config.taggable) { this.el.multiple = true; } // Disabled? this.disabled = isset(this.config, "disabled"); this.opened = false; if (this.config.taggable) { this.config.searchable = false; } this.navigating = false; this.mobileDevice = false; if (/Android|webOS|iPhone|iPad|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(navigator.userAgent)) { this.mobileDevice = true; } this.customOption = this.config.hasOwnProperty("renderOption") && typeof this.config.renderOption === "function"; this.customSelected = this.config.hasOwnProperty("renderSelection") && typeof this.config.renderSelection === "function"; // Enable event emitter Events.mixin(this); build.call(this); this.bindEvents(); this.update(); this.optsRect = util.rect(this.tree); this.rendered = true; // Fixes macOS Safari bug #28 if (!this.el.multiple) { this.el.selectedIndex = this.selectedIndex; } var that = this; setTimeout(function () { that.emit("selectr.init"); }, 20); }; Selectr.prototype.getSelected = function () { var selected = this.el.querySelectorAll('option:checked'); return selected; }; Selectr.prototype.getSelectedProperties = function (prop) { var selected = this.getSelected(); var values = [].slice.call(selected).map(function (option) { return option[prop]; }).filter(function (i) { return i !== null && i !== undefined; }); return values; }; /** * Attach the required event listeners */ Selectr.prototype.bindEvents = function () { var that = this; this.events = {}; this.events.dismiss = dismiss.bind(this); this.events.navigate = navigate.bind(this); this.events.reset = this.reset.bind(this); if (this.config.nativeDropdown || this.mobileDevice) { this.container.addEventListener("touchstart", function (e) { if (e.changedTouches[0].target === that.el) { that.toggle(); } }); if (this.config.nativeDropdown || this.mobileDevice) { this.container.addEventListener("click", function (e) { e.preventDefault(); // Jos: Added to prevent emitting clear directly after select e.stopPropagation(); // Jos: Added to prevent emitting clear directly after select if (e.target === that.el) { that.toggle(); } }); } var getChangedOptions = function getChangedOptions(last, current) { var added = [], removed = last.slice(0); var idx; for (var i = 0; i < current.length; i++) { idx = removed.indexOf(current[i]); if (idx > -1) removed.splice(idx, 1);else added.push(current[i]); } return [added, removed]; }; // Listen for the change on the native select // and update accordingly this.el.addEventListener("change", function (e) { if (that.el.multiple) { var indexes = that.getSelectedProperties('idx'); var changes = getChangedOptions(that.selectedIndexes, indexes); util.each(changes[0], function (i, idx) { that.select(idx); }, that); util.each(changes[1], function (i, idx) { that.deselect(idx); }, that); } else { if (that.el.selectedIndex > -1) { that.select(that.el.selectedIndex); } } }); } // Open the dropdown with Enter key if focused if (this.config.nativeDropdown) { this.container.addEventListener("keydown", function (e) { if (e.key === "Enter" && that.selected === document.activeElement) { // Show the native that.toggle(); // Focus on the native multiselect setTimeout(function () { that.el.focus(); }, 200); } }); } // Non-native dropdown this.selected.addEventListener("click", function (e) { if (!that.disabled) { that.toggle(); } e.preventDefault(); e.stopPropagation(); // Jos: Added to prevent emitting clear directly after select }); // Remove tag this.label.addEventListener("click", function (e) { if (util.hasClass(e.target, "selectr-tag-remove")) { that.deselect(e.target.parentNode.idx); } }); // Clear input if (this.selectClear) { this.selectClear.addEventListener("click", this.clear.bind(this)); } // Prevent text selection this.tree.addEventListener("mousedown", function (e) { e.preventDefault(); }); // Select / deselect items this.tree.addEventListener("click", function (e) { e.preventDefault(); // Jos: Added to prevent emitting clear directly after select e.stopPropagation(); // Jos: Added to prevent emitting clear directly after select var item = util.closest(e.target, function (el) { return el && util.hasClass(el, "selectr-option"); }); if (item) { if (!util.hasClass(item, "disabled")) { if (util.hasClass(item, "selected")) { if (that.el.multiple || !that.el.multiple && that.config.allowDeselect) { that.deselect(item.idx); } } else { that.select(item.idx); } if (that.opened && !that.el.multiple) { that.close(); } } } }); // Mouseover list items this.tree.addEventListener("mouseover", function (e) { if (util.hasClass(e.target, "selectr-option")) { if (!util.hasClass(e.target, "disabled")) { util.removeClass(that.items[that.navIndex], "active"); util.addClass(e.target, "active"); that.navIndex = [].slice.call(that.items).indexOf(e.target); } } }); // Searchable if (this.config.searchable) { // Show / hide the search input clear button this.input.addEventListener("focus", function (e) { that.searching = true; }); this.input.addEventListener("blur", function (e) { that.searching = false; }); this.input.addEventListener("keyup", function (e) { that.search(); if (!that.config.taggable) { // Show / hide the search input clear button if (this.value.length) { util.addClass(this.parentNode, "active"); } else { util.removeClass(this.parentNode, "active"); } } }); // Clear the search input this.inputClear.addEventListener("click", function (e) { that.input.value = null; clearSearch.call(that); if (!that.tree.childElementCount) { render.call(that); } }); } if (this.config.taggable) { this.input.addEventListener("keyup", function (e) { that.search(); if (that.config.taggable && this.value.length) { var val = this.value.trim(); if (e.which === 13 || util.includes(that.tagSeperators, e.key)) { util.each(that.tagSeperators, function (i, k) { val = val.replace(k, ''); }); var option = that.add({ value: val, text: val, selected: true }, true); if (!option) { this.value = ''; that.setMessage('That tag is already in use.'); } else { that.close(); clearSearch.call(that); } } } }); } this.update = util.debounce(function () { // Optionally close dropdown on scroll / resize (#11) if (that.opened && that.config.closeOnScroll) { that.close(); } if (that.width) { that.container.style.width = that.width; } that.invert(); }, 50); if (this.requiresPagination) { this.paginateItems = util.debounce(function () { load.call(this); }, 50); this.tree.addEventListener("scroll", this.paginateItems.bind(this)); } // Dismiss when clicking outside the container document.addEventListener("click", this.events.dismiss); window.addEventListener("keydown", this.events.navigate); window.addEventListener("resize", this.update); window.addEventListener("scroll", this.update); // Listen for form.reset() (@ambrooks, #13) if (this.el.form) { this.el.form.addEventListener("reset", this.events.reset); } }; /** * Check for selected options * @param {bool} reset */ Selectr.prototype.setSelected = function (reset) { // Select first option as with a native select-one element - #21, #24 if (!this.config.data && !this.el.multiple && this.el.options.length) { // Browser has selected the first option by default if (this.el.selectedIndex === 0) { if (!this.el.options[0].defaultSelected && !this.config.defaultSelected) { this.el.selectedIndex = -1; } } this.selectedIndex = this.el.selectedIndex; if (this.selectedIndex > -1) { this.select(this.selectedIndex); } } // If we're changing a select-one to select-multiple via the config // and there are no selected options, the first option will be selected by the browser // Let's prevent that here. if (this.config.multiple && this.originalType === "select-one" && !this.config.data) { if (this.el.options[0].selected && !this.el.options[0].defaultSelected) { this.el.options[0].selected = false; } } util.each(this.options, function (i, option) { if (option.selected && option.defaultSelected) { this.select(option.idx); } }, this); if (this.config.selectedValue) { this.setValue(this.config.selectedValue); } if (this.config.data) { if (!this.el.multiple && this.config.defaultSelected && this.el.selectedIndex < 0) { this.select(0); } var j = 0; util.each(this.config.data, function (i, opt) { // Check for group options if (isset(opt, "children")) { util.each(opt.children, function (x, item) { if (item.hasOwnProperty("selected") && item.selected === true) { this.select(j); } j++; }, this); } else { if (opt.hasOwnProperty("selected") && opt.selected === true) { this.select(j); } j++; } }, this); } }; /** * Destroy the instance * @return {void} */ Selectr.prototype.destroy = function () { if (!this.rendered) return; this.emit("selectr.destroy"); // Revert to select-single if programtically set to multiple if (this.originalType === 'select-one') { this.el.multiple = false; } if (this.config.data) { this.el.textContent = ""; } // Remove the className from select element util.removeClass(this.el, 'selectr-hidden'); // Remove reset listener from parent form if (this.el.form) { util.off(this.el.form, "reset", this.events.reset); } // Remove event listeners attached to doc and win util.off(document, "click", this.events.dismiss); util.off(document, "keydown", this.events.navigate); util.off(window, "resize", this.update); util.off(window, "scroll", this.update); // Replace the container with the original select element this.container.parentNode.replaceChild(this.el, this.container); this.rendered = false; }; /** * Change an options state * @param {Number} index * @return {void} */ Selectr.prototype.change = function (index) { var item = this.items[index], option = this.options[index]; if (option.disabled) { return; } if (option.selected && util.hasClass(item, "selected")) { this.deselect(index); } else { this.select(index); } if (this.opened && !this.el.multiple) { this.close(); } }; /** * Select an option * @param {Number} index * @return {void} */ Selectr.prototype.select = function (index) { var item = this.items[index], options = [].slice.call(this.el.options), option = this.options[index]; if (this.el.multiple) { if (util.includes(this.selectedIndexes, index)) { return false; } if (this.config.maxSelections && this.tags.length === this.config.maxSelections) { this.setMessage("A maximum of " + this.config.maxSelections + " items can be selected.", true); return false; } this.selectedValues.push(option.value); this.selectedIndexes.push(index); addTag.call(this, item); } else { var data = this.data ? this.data[index] : option; this.label.textContent = this.customSelected ? this.config.renderSelection(data) : option.textContent; this.selectedValue = option.value; this.selectedIndex = index; util.each(this.options, function (i, o) { var opt = this.items[i]; if (i !== index) { if (opt) { util.removeClass(opt, "selected"); } o.selected = false; o.removeAttribute("selected"); } }, this); } if (!util.includes(options, option)) { this.el.add(option); } item.setAttribute("aria-selected", true); util.addClass(item, "selected"); util.addClass(this.container, "has-selected"); option.selected = true; option.setAttribute("selected", ""); this.emit("selectr.change", option); this.emit("selectr.select", option); }; /** * Deselect an option * @param {Number} index * @return {void} */ Selectr.prototype.deselect = function (index, force) { var item = this.items[index], option = this.options[index]; if (this.el.multiple) { var selIndex = this.selectedIndexes.indexOf(index); this.selectedIndexes.splice(selIndex, 1); var valIndex = this.selectedValues.indexOf(option.value); this.selectedValues.splice(valIndex, 1); removeTag.call(this, item); if (!this.tags.length) { util.removeClass(this.container, "has-selected"); } } else { if (!force && !this.config.clearable && !this.config.allowDeselect) { return false; } this.label.textContent = ""; this.selectedValue = null; this.el.selectedIndex = this.selectedIndex = -1; util.removeClass(this.container, "has-selected"); } this.items[index].setAttribute("aria-selected", false); util.removeClass(this.items[index], "selected"); option.selected = false; option.removeAttribute("selected"); this.emit("selectr.change", null); this.emit("selectr.deselect", option); }; /** * Programmatically set selected values * @param {String|Array} value - A string or an array of strings */ Selectr.prototype.setValue = function (value) { var isArray = Array.isArray(value); if (!isArray) { value = value.toString().trim(); } // Can't pass array to select-one if (!this.el.multiple && isArray) { return false; } util.each(this.options, function (i, option) { if (isArray && util.includes(value.toString(), option.value) || option.value === value) { this.change(option.idx); } }, this); }; /** * Set the selected value(s) * @param {bool} toObject Return only the raw values or an object * @param {bool} toJson Return the object as a JSON string * @return {mixed} Array or String */ Selectr.prototype.getValue = function (toObject, toJson) { var value; if (this.el.multiple) { if (toObject) { if (this.selectedIndexes.length) { value = {}; value.values = []; util.each(this.selectedIndexes, function (i, index) { var option = this.options[index]; value.values[i] = { value: option.value, text: option.textContent }; }, this); } } else { value = this.selectedValues.slice(); } } else { if (toObject) { var option = this.options[this.selectedIndex]; value = { value: option.value, text: option.textContent }; } else { value = this.selectedValue; } } if (toObject && toJson) { value = JSON.stringify(value); } return value; }; /** * Add a new option or options * @param {object} data */ Selectr.prototype.add = function (data, checkDuplicate) { if (data) { this.data = this.data || []; this.items = this.items || []; this.options = this.options || []; if (Array.isArray(data)) { // We have an array on items util.each(data, function (i, obj) { this.add(obj, checkDuplicate); }, this); } // User passed a single object to the method // or Selectr passed an object from an array else if ("[object Object]" === Object.prototype.toString.call(data)) { if (checkDuplicate) { var dupe = false; util.each(this.options, function (i, option) { if (option.value.toLowerCase() === data.value.toLowerCase()) { dupe = true; } }); if (dupe) { return false; } } var option = util.createElement('option', data); this.data.push(data); // Add the new option to the list this.options.push(option); // Add the index for later use option.idx = this.options.length > 0 ? this.options.length - 1 : 0; // Create a new item createItem.call(this, option); // Select the item if required if (data.selected) { this.select(option.idx); } return option; } // We may have had an empty select so update // the placeholder to reflect the changes. this.setPlaceholder(); // Recount the pages if (this.config.pagination) { this.paginate(); } return true; } }; /** * Remove an option or options * @param {Mixed} o Array, integer (index) or string (value) * @return {Void} */ Selectr.prototype.remove = function (o) { var options = []; if (Array.isArray(o)) { util.each(o, function (i, opt) { if (util.isInt(opt)) { options.push(this.getOptionByIndex(opt)); } else if (typeof o === "string") { options.push(this.getOptionByValue(opt)); } }, this); } else if (util.isInt(o)) { options.push(this.getOptionByIndex(o)); } else if (typeof o === "string") { options.push(this.getOptionByValue(o)); } if (options.length) { var index; util.each(options, function (i, option) { index = option.idx; // Remove the HTMLOptionElement this.el.remove(option); // Remove the reference from the option array this.options.splice(index, 1); // If the item has a parentNode (group element) it needs to be removed // otherwise the render function will still append it to the dropdown var parentNode = this.items[index].parentNode; if (parentNode) { parentNode.removeChild(this.items[index]); } // Remove reference from the items array this.items.splice(index, 1); // Reset the indexes util.each(this.options, function (i, opt) { opt.idx = i; this.items[i].idx = i; }, this); }, this); // We may have had an empty select now so update // the placeholder to reflect the changes. this.setPlaceholder(); // Recount the pages if (this.config.pagination) { this.paginate(); } } }; /** * Remove all options */ Selectr.prototype.removeAll = function () { // Clear any selected options this.clear(true); // Remove the HTMLOptionElements util.each(this.el.options, function (i, option) { this.el.remove(option); }, this); // Empty the dropdown util.truncate(this.tree); // Reset variables this.items = []; this.options = []; this.data = []; this.navIndex = 0; if (this.requiresPagination) { this.requiresPagination = false; this.pageIndex = 1; this.pages = []; } // Update the placeholder this.setPlaceholder(); }; /** * Perform a search * @param {string} query The query string */ Selectr.prototype.search = function (string) { if (this.navigating) return; string = string || this.input.value; var f = document.createDocumentFragment(); // Remove message this.removeMessage(); // Clear the dropdown util.truncate(this.tree); if (string.length > 1) { // Check the options for the matching string util.each(this.options, function (i, option) { var item = this.items[option.idx]; var includes = util.includes(option.textContent.toLowerCase(), string.toLowerCase()); if (includes && !option.disabled) { appendItem(item, f, this.customOption); util.removeClass(item, "excluded"); // Underline the matching results if (!this.customOption) { item.textContent = ''; var result = match(string, option.textContent); if (result) { item.appendChild(document.createTextNode(result.before)); var highlight = document.createElement('span'); highlight.className = 'selectr-match'; highlight.appendChild(document.createTextNode(result.match)); item.appendChild(highlight); item.appendChild(document.createTextNode(result.after)); } } } else { util.addClass(item, "excluded"); } }, this); if (!f.childElementCount) { if (!this.config.taggable) { this.setMessage("no results."); } } else { // Highlight top result (@binary-koan #26) var prevEl = this.items[this.navIndex]; var firstEl = f.firstElementChild; util.removeClass(prevEl, "active"); this.navIndex = firstEl.idx; util.addClass(firstEl, "active"); } } else { render.call(this); } this.tree.appendChild(f); }; /** * Toggle the dropdown * @return {void} */ Selectr.prototype.toggle = function () { if (!this.disabled) { if (this.opened) { this.close(); } else { this.open(); } } }; /** * Open the dropdown * @return {void} */ Selectr.prototype.open = function () { var that = this; if (!this.options.length) { return false; } if (!this.opened) { this.emit("selectr.open"); } this.opened = true; if (this.mobileDevice || this.config.nativeDropdown) { util.addClass(this.container, "native-open"); if (this.config.data) { // Dump the options into the select // otherwise the native dropdown will be empty util.each(this.options, function (i, option) { this.el.add(option); }, this); } return; } util.addClass(this.container, "open"); render.call(this); this.invert(); this.tree.scrollTop = 0; util.removeClass(this.container, "notice"); this.selected.setAttribute("aria-expanded", true); this.tree.setAttribute("aria-hidden", false); this.tree.setAttribute("aria-expanded", true); if (this.config.searchable && !this.config.taggable) { setTimeout(function () { that.input.focus(); // Allow tab focus that.input.tabIndex = 0; }, 10); } }; /** * Close the dropdown * @return {void} */ Selectr.prototype.close = function () { if (this.opened) { this.emit("selectr.close"); } this.opened = false; if (this.mobileDevice || this.config.nativeDropdown) { util.removeClass(this.container, "native-open"); return; } var notice = util.hasClass(this.container, "notice"); if (this.config.searchable && !notice) { this.input.blur(); // Disable tab focus this.input.tabIndex = -1; this.searching = false; } if (notice) { util.removeClass(this.container, "notice"); this.notice.textContent = ""; } util.removeClass(this.container, "open"); util.removeClass(this.container, "native-open"); this.selected.setAttribute("aria-expanded", false); this.tree.setAttribute("aria-hidden", true); this.tree.setAttribute("aria-expanded", false); util.truncate(this.tree); clearSearch.call(this); }; /** * Enable the element * @return {void} */ Selectr.prototype.enable = function () { this.disabled = false; this.el.disabled = false; this.selected.tabIndex = this.originalIndex; if (this.el.multiple) { util.each(this.tags, function (i, t) { t.lastElementChild.tabIndex = 0; }); } util.removeClass(this.container, "selectr-disabled"); }; /** * Disable the element * @param {boolean} container Disable the container only (allow value submit with form) * @return {void} */ Selectr.prototype.disable = function (container) { if (!container) { this.el.disabled = true; } this.selected.tabIndex = -1; if (this.el.multiple) { util.each(this.tags, function (i, t) { t.lastElementChild.tabIndex = -1; }); } this.disabled = true; util.addClass(this.container, "selectr-disabled"); }; /** * Reset to initial state * @return {void} */ Selectr.prototype.reset = function () { if (!this.disabled) { this.clear(); this.setSelected(true); util.each(this.defaultSelected, function (i, idx) { this.select(idx); }, this); this.emit("selectr.reset"); } }; /** * Clear all selections * @return {void} */ Selectr.prototype.clear = function (force) { if (this.el.multiple) { // Loop over the selectedIndexes so we don't have to loop over all the options // which can be costly if there are a lot of them if (this.selectedIndexes.length) { // Copy the array or we'll get an error var indexes = this.selectedIndexes.slice(); util.each(indexes, function (i, idx) { this.deselect(idx); }, this); } } else { if (this.selectedIndex > -1) { this.deselect(this.selectedIndex, force); } } this.emit("selectr.clear"); }; /** * Return serialised data * @param {boolean} toJson * @return {mixed} Returns either an object or JSON string */ Selectr.prototype.serialise = function (toJson) { var data = []; util.each(this.options, function (i, option) { var obj = { value: option.value, text: option.textContent }; if (option.selected) { obj.selected = true; } if (option.disabled) { obj.disabled = true; } data[i] = obj; }); return toJson ? JSON.stringify(data) : data; }; /** * Localised version of serialise() method */ Selectr.prototype.serialize = function (toJson) { return this.serialise(toJson); }; /** * Sets the placeholder * @param {String} placeholder */ Selectr.prototype.setPlaceholder = function (placeholder) { // Set the placeholder placeholder = placeholder || this.config.placeholder || this.el.getAttribute("placeholder"); if (!this.options.length) { placeholder = "No options available"; } this.placeEl.textContent = placeholder; }; /** * Paginate the option list * @return {Array} */ Selectr.prototype.paginate = function () { if (this.items.length) { var that = this; this.pages = this.items.map(function (v, i) { return i % that.config.pagination === 0 ? that.items.slice(i, i + that.config.pagination) : null; }).filter(function (pages) { return pages; }); return this.pages; } }; /** * Display a message * @param {String} message The message */ Selectr.prototype.setMessage = function (message, close) { if (close) { this.close(); } util.addClass(this.container, "notice"); this.notice.textContent = message; }; /** * Dismiss the current message */ Selectr.prototype.removeMessage = function () { util.removeClass(this.container, "notice"); this.notice.textContent = ""; }; /** * Keep the dropdown within the window * @return {void} */ Selectr.prototype.invert = function () { var rt = util.rect(this.selected), oh = this.tree.parentNode.offsetHeight, wh = window.innerHeight, doInvert = rt.top + rt.height + oh > wh; if (doInvert) { util.addClass(this.container, "inverted"); this.isInverted = true; } else { util.removeClass(this.container, "inverted"); this.isInverted = false; } this.optsRect = util.rect(this.tree); }; /** * Get an option via it's index * @param {Integer} index The index of the HTMLOptionElement required * @return {HTMLOptionElement} */ Selectr.prototype.getOptionByIndex = function (index) { return this.options[index]; }; /** * Get an option via it's value * @param {String} value The value of the HTMLOptionElement required * @return {HTMLOptionElement} */ Selectr.prototype.getOptionByValue = function (value) { var option = false; for (var i = 0, l = this.options.length; i < l; i++) { if (this.options[i].value.trim() === value.toString().trim()) { option = this.options[i]; break; } } return option; }; module.exports = Selectr; /***/ }), /***/ 4188: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "qD": function() { return /* binding */ DEFAULT_MODAL_ANCHOR; }, /* harmony export */ "EX": function() { return /* binding */ SIZE_LARGE; }, /* harmony export */ "WF": function() { return /* binding */ MAX_PREVIEW_CHARACTERS; }, /* harmony export */ "oW": function() { return /* binding */ PREVIEW_HISTORY_LIMIT; } /* harmony export */ }); var DEFAULT_MODAL_ANCHOR = document.body; var SIZE_LARGE = 10 * 1024 * 1024; // 10 MB var MAX_PREVIEW_CHARACTERS = 20000; var PREVIEW_HISTORY_LIMIT = 2 * 1024 * 1024 * 1024; // 2 GB /***/ }), /***/ 2602: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "w": function() { return /* binding */ createAbsoluteAnchor; } /* harmony export */ }); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9791); /** * Create an anchor element absolutely positioned in the `parent` * element. * @param {HTMLElement} anchor * @param {HTMLElement} parent * @param {function(HTMLElement)} [onDestroy] Callback when the anchor is destroyed * @param {boolean} [destroyOnMouseOut=false] If true, anchor will be removed on mouse out * @returns {HTMLElement} */ function createAbsoluteAnchor(anchor, parent, onDestroy) { var destroyOnMouseOut = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; var root = getRootNode(anchor); var eventListeners = {}; var anchorRect = anchor.getBoundingClientRect(); var parentRect = parent.getBoundingClientRect(); var absoluteAnchor = document.createElement('div'); absoluteAnchor.className = 'jsoneditor-anchor'; absoluteAnchor.style.position = 'absolute'; absoluteAnchor.style.left = anchorRect.left - parentRect.left + 'px'; absoluteAnchor.style.top = anchorRect.top - parentRect.top + 'px'; absoluteAnchor.style.width = anchorRect.width - 2 + 'px'; absoluteAnchor.style.height = anchorRect.height - 2 + 'px'; absoluteAnchor.style.boxSizing = 'border-box'; parent.appendChild(absoluteAnchor); function destroy() { // remove temporary absolutely positioned anchor if (absoluteAnchor && absoluteAnchor.parentNode) { absoluteAnchor.parentNode.removeChild(absoluteAnchor); // remove all event listeners // all event listeners are supposed to be attached to document. for (var name in eventListeners) { if (hasOwnProperty(eventListeners, name)) { var fn = eventListeners[name]; if (fn) { (0,_util__WEBPACK_IMPORTED_MODULE_0__.removeEventListener)(root, name, fn); } delete eventListeners[name]; } } if (typeof onDestroy === 'function') { onDestroy(anchor); } } } function isOutside(target) { return target !== absoluteAnchor && !(0,_util__WEBPACK_IMPORTED_MODULE_0__.isChildOf)(target, absoluteAnchor); } // create and attach event listeners function destroyIfOutside(event) { if (isOutside(event.target)) { destroy(); } } eventListeners.mousedown = (0,_util__WEBPACK_IMPORTED_MODULE_0__.addEventListener)(root, 'mousedown', destroyIfOutside); eventListeners.mousewheel = (0,_util__WEBPACK_IMPORTED_MODULE_0__.addEventListener)(root, 'mousewheel', destroyIfOutside); if (destroyOnMouseOut) { var destroyTimer = null; absoluteAnchor.onmouseover = function () { clearTimeout(destroyTimer); destroyTimer = null; }; absoluteAnchor.onmouseout = function () { if (!destroyTimer) { destroyTimer = setTimeout(destroy, 200); } }; } absoluteAnchor.destroy = destroy; return absoluteAnchor; } /** * Node.getRootNode shim * @param {HTMLElement} node node to check * @return {HTMLElement} node's rootNode or `window` if there is ShadowDOM is not supported. */ function getRootNode(node) { return typeof node.getRootNode === 'function' ? node.getRootNode() : window; } function hasOwnProperty(object, key) { return Object.prototype.hasOwnProperty.call(object, key); } /***/ }), /***/ 7923: /***/ (function(module) { module.exports = 'data:application/javascript;base64,Im5vIHVzZSBzdHJpY3QiOwohKGZ1bmN0aW9uKHdpbmRvdykgewppZiAodHlwZW9mIHdpbmRvdy53aW5kb3cgIT0gInVuZGVmaW5lZCIgJiYgd2luZG93LmRvY3VtZW50KQogICAgcmV0dXJuOwppZiAod2luZG93LnJlcXVpcmUgJiYgd2luZG93LmRlZmluZSkKICAgIHJldHVybjsKCmlmICghd2luZG93LmNvbnNvbG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XRpb24ucmVwbGFjZSgvXC8qJC8sICIvIikgKyAodGFpbCB8fCBhbGlhcy5tYWluIHx8IGFsaWFzLm5hbWUpOwogICAgICAgIH0gZWxzZSBpZiAoYWxpYXMgPT09IGZhbHNlKSB7CiAgICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CiAgICAgICAgdmFyIGkgPSB0ZXN0UGF0aC5sYXN0SW5kZXhPZigiLyIpOwogICAgICAgIGlmIChpID09PSAtMSkgYnJlYWs7CiAgICAgICAgdGFpbCA9IHRlc3RQYXRoLnN1YnN0cihpKSArIHRhaWw7CiAgICAgICAgdGVzdFBhdGggPSB0ZXN0UGF0aC5zbGljZSgwLCBpKTsKICAgIH0KICAgIHJldHVybiBpZDsKfQp3aW5kb3cucmVxdWlyZS5tb2R1bGVzID0ge307CndpbmRvdy5yZXF1aXJlLnRsbnMgPSB7fTsKCndpbmRvdy5kZWZpbmUgPSBmdW5jdGlvbihpZCwgZGVwcywgZmFjdG9yeSkgewogICAgaWYgKGFyZ3VtZW50cy5sZW5ndGggPT0gMikgewogICAgICAgIGZhY3RvcnkgPSBkZXBzOwogICAgICAgIGlmICh0eXBlb2YgaWQgIT0gInN0cmluZyIpIHsKICAgICAgICAgICAgZGVwcyA9IGlkOwogICAgICAgICAgICBpZCA9IHdpbmRvdy5yZXF1aXJlLmlkOwogICAgICAgIH0KICAgIH0gZWxzZSBpZiAoYXJndW1lbnRzLmxlbmd0aCA9PSAxKSB7CiAgICAgICAgZmFjdG9yeSA9IGlkOwogICAgICAgIGRlcHMgPSBbXTsKICAgICAgICBpZCA9IHdpbmRvdy5yZXF1aXJlLmlkOwogICAgfQogICAgCiAgICBpZiAodHlwZW9mIGZhY3RvcnkgIT0gImZ1bmN0aW9uIikgewogICAgICAgIHdpbmRvdy5yZXF1aXJlLm1vZHVsZXNbaWRdID0gewogICAgICAgICAgICBleHBvcnRzOiBmYWN0b3J5LAogICAgICAgICAgICBpbml0aWFsaXplZDogdHJ1ZQogICAgICAgIH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gICAgICAgICAgICBjYXNlICJtb2R1bGUiOiAgcmV0dXJuIG1vZHVsZTsKICAgICAgICAgICAgICAgICAgICAvLyBCdXQgZm9yIGFsbCBvdGhlciBkZXBlbmRlbmNpZXMsIHdlIGNhbiBqdXN0IGdvIGFoZWFkIGFuZAogICAgICAgICAgICAgICAgICAgIC8vIHJlcXVpcmUgdGhlbS4KICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OiAgICAgICAgcmV0dXJuIHJlcShkZXApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIGlmIChyZXR1cm5FeHBvcnRzKQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSByZXR1cm5FeHBvcnRzOwogICAgICAgICAgICByZXR1cm4gbW9kdWxlOwogICAgICAgIH0KICAgIH07Cn07CndpbmRvdy5kZWZpbmUuYW1kID0ge307CnJlcXVpcmUudGxucyA9IHt9Owp3aW5kb3cuaW5pdEJhc2VVcmxzICA9IGZ1bmN0aW9uIGluaXRCYXNlVXJscyh0b3BMZXZlbE5hbWVzcGFjZXMpIHsKICAgIGZvciAodmFyIGkgaW4gdG9wTGV2ZWxOYW1lc3BhY2VzKQogICAgICAgIHJlcXVpcmUudGxuc1tpXSA9IHRvcExldmVsTmFtZXNwYWNlc1tpXTsKfTsKCndpbmRvdy5pbml0U2VuZGVyID0gZnVuY3Rpb24gaW5pdFNlbmRlcigpIHsKCiAgICB2YXIgRXZlbnRFbWl0dGVyID0gd2luZG93LnJlcXVpcmUoImFjZS9saWIvZXZlbnRfZW1pdHRlciIpLkV2ZW50RW1pdHRlcjsKICAgIHZhciBvb3AgPSB3aW5kb3cucmVxdWlyZSgiYWNlL2xpYi9vb3AiKTsKICAgIAogICAgdmFyIFNlbmRlciA9IGZ1bmN0aW9uKCkge307CiAgICAKICAgIChmdW5jdGlvbigpIHsKICAgICAgICAKICAgICAgICBvb3AuaW1wbGVtZW50KHRoaXMsIEV2ZW50RW1pdHRlcik7CiAgICAgICAgICAgICAgICAKICAgICAgICB0aGlzLmNhbGxiYWNrID0gZnVuY3Rpb24oZGF0YSwgY2FsbGJhY2tJZCkgewogICAgICAgICAgICBwb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICB0eXBlOiAiY2FsbCIsCiAgICAgICAgICAgICAgICBpZDogY2FsbGJhY2tJZCwKICAgICAgICAgICAgICAgIGRhdGE6IGRhdGEKICAgICAgICAgICAgfSk7CiAgICAgICAgfTsKICAgIAogICAgICAgIHRoaXMuZW1pdCA9IGZ1bmN0aW9uKG5hbWUsIGRhdGEpIHsKICAgICAgICAgICAgcG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgdHlwZTogImV2ZW50IiwKICAgICAgICAgICAgICAgIG5hbWU6IG5hbWUsCiAgICAgICAgICAgICAgICBkYXRhOiBkYXRhCiAgICAgICAgICAgIH0pOwogICAgICAgIH07CiAgICAgICAgCiAgICB9KS5jYWxsKFNlbmRlci5wcm90b3R5cGUpOwogICAgCiAgICByZXR1cm4gbmV3IFNlbmRlcigpOwp9OwoKdmFyIG1haW4gPSB3aW5kb3cubWFpbiA9IG51bGw7CnZhciBzZW5kZXIgPSB3aW5kb3cuc2VuZGVyID0gbnVsbDsKCndpbmRvdy5vbm1lc3NhZ2UgPSBmdW5jdGlvbihlKSB7CiAgICB2YXIgbXNnID0gZS5kYXRhOwogICAgaWYgKG1zZy5ldmVudCAmJiBzZW5kZXIpIHsKICAgICAgICBzZW5kZXIuX3NpZ25hbChtc2cuZXZlbnQsIG1zZy5kYXRhKTsKICAgIH0KICAgIGVsc2UgaWYgKG1zZy5jb21tYW5kKSB7CiAgICAgICAgaWYgKG1haW5bbXNnLmNvbW1hbmRdKQogICAgICAgICAgICBtYWluW21zZy5jb21tYW5kXS5hcHBseShtYWluLCBtc2cuYXJncyk7CiAgICAgICAgZWxzZSBpZiAod2luZG93W21zZy5jb21tYW5kXSkKICAgICAgICAgICAgd2luZG93W21zZy5jb21tYW5kXS5hcH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8iICsgdGhpcy5zdGFydC5jb2x1bW4gKwogICAgICAgICAgICAiXSAtPiBbIiArIHRoaXMuZW5kLnJvdyArICIvIiArIHRoaXMuZW5kLmNvbHVtbiArICJdIik7CiAgICB9OwoKICAgIHRoaXMuY29udGFpbnMgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIHJldHVybiB0aGlzLmNvbXBhcmUocm93LCBjb2x1bW4pID09IDA7CiAgICB9OwogICAgdGhpcy5jb21wYXJlUmFuZ2UgPSBmdW5jdGlvbihyYW5nZSkgewogICAgICAgIHZhciBjbXAsCiAgICAgICAgICAgIGVuZCA9IHJhbmdlLmVuZCwKICAgICAgICAgICAgc3RhcnQgPSByYW5nZS5zdGFydDsKCiAgICAgICAgY21wID0gdGhpcy5jb21wYXJlKGVuZC5yb3csIGVuZC5jb2x1bW4pOwogICAgICAgIGlmIChjbXAgPT0gMSkgewogICAgICAgICAgICBjbXAgPSB0aGlzLmNvbXBhcmUoc3RhcnQucm93LCBzdGFydC5jb2x1bW4pOwogICAgICAgICAgICBpZiAoY21wID09IDEpIHsKICAgICAgICAgICAgICAgIHJldHVybiAyOwogICAgICAgICAgICB9IGVsc2UgaWYgKGNtcCA9PSAwKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChjbXAgPT0gLTEpIHsKICAgICAgICAgICAgcmV0dXJuIC0yOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGNtcCA9IHRoaXMuY29tcGFyZShzdGFydC5yb3csIHN0YXJ0LmNvbHVtbik7CiAgICAgICAgICAgIGlmIChjbXAgPT0gLTEpIHsKICAgICAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgICAgfSBlbHNlIGlmIChjbXAgPT0gMSkgewogICAgICAgICAgICAgICAgcmV0dXJuIDQyOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9OwogICAgdGhpcy5jb21wYXJlUG9pbnQgPSBmdW5jdGlvbihwKSB7CiAgICAgICAgcmV0dXJuIHRoaXMuY29tcGFyZShwLnJvdywgcC5jb2x1bW4pOwogICAgfTsKICAgIHRoaXMuY29udGFpbnNSYW5nZSA9IGZ1bmN0aW9uKHJhbmdlKSB7CiAgICAgICAgcmV0dXJuIHRoaXMuY29tcGFyZVBvaW50KHJhbmdlLnN0YXJ0KSA9PSAwICYmIHRoaXMuY29tcGFyZVBvaW50KHJhbmdlLmVuZCkgPT0gMDsKICAgIH07CiAgICB0aGlzLmludGVyc2VjdHMgPSBmdW5jdGlvbihyYW5nZSkgewogICAgICAgIHZhciBjbXAgPSB0aGlzLmNvbXBhcmVSYW5nZShyYW5nZSk7CiAgICAgICAgcmV0dXJuIChjbXAgPT0gLTEgfHwgY21wID09IDAgfHwgY21wID09IDEpOwogICAgfTsKICAgIHRoaXMuaXNFbmQgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIHJldHVybiB0aGlzLmVuZC5yb3cgPT0gcm93ICYmIHRoaXMuZW5kLmNvbHVtbiA9PSBjb2x1bW47CiAgICB9OwogICAgdGhpcy5pc1N0YXJ0ID0gZnVuY3Rpb24ocm93LCBjb2x1bW4pIHsKICAgICAgICByZXR1cm4gdGhpcy5zdGFydC5yb3cgPT0gcm93ICYmIHRoaXMuc3RhcnQuY29sdW1uID09IGNvbHVtbjsKICAgIH07CiAgICB0aGlzLnNldFN0YXJ0ID0gZnVuY3Rpb24ocm93LCBjb2x1bW4pIHsKICAgICAgICBpZiAodHlwZW9mIHJvdyA9PSAib2JqZWN0IikgewogICAgICAgICAgICB0aGlzLnN0YXJ0LmNvbHVtbiA9IHJvdy5jb2x1bW47CiAgICAgICAgICAgIHRoaXMuc3RhcnQucm93ID0gcm93LnJvdzsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICB0aGlzLnN0YXJ0LnJvdyA9IHJvdzsKICAgICAgICAgICAgdGhpcy5zdGFydC5jb2x1bW4gPSBjb2x1bW47CiAgICAgICAgfQogICAgfTsKICAgIHRoaXMuc2V0RW5kID0gZnVuY3Rpb24ocm93LCBjb2x1bW4pIHsKICAgICAgICBpZiAodHlwZW9mIHJvdyA9PSAib2JqZWN0IikgewogICAgICAgICAgICB0aGlzLmVuZC5jb2x1bW4gPSByb3cuY29sdW1uOwogICAgICAgICAgICB0aGlzLmVuZC5yb3cgPSByb3cucm93OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRoaXMuZW5kLnJvdyA9IHJvdzsKICAgICAgICAgICAgdGhpcy5lbmQuY29sdW1uID0gY29sdW1uOwogICAgICAgIH0KICAgIH07CiAgICB0aGlzLmluc2lkZSA9IGZ1bmN0aW9uKHJvdywgY29sdW1uKSB7CiAgICAgICAgaWYgKHRoaXMuY29tcGFyZShyb3csIGNvbHVtbikgPT0gMCkgewogICAgICAgICAgICBpZiAodGhpcy5pc0VuZChyb3csIGNvbHVtbikgfHwgdGhpcy5pc1N0YXJ0KHJvdywgY29sdW1uKSkgewogICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgfTsKICAgIHRoaXMuaW5zaWRlU3RhcnQgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIGlmICh0aGlzLmNvbXBhcmUocm93LCBjb2x1bW4pID09IDApIHsKICAgICAgICAgICAgaWYgKHRoaXMuaXNFbmQocm93LCBjb2x1bW4pKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9OwogICAgdGhpcy5pbnNpZGVFbmQgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIGlmICh0aGlzLmNvbXBhcmUocm93LCBjb2x1bW4pID09IDApIHsKICAgICAgICAgICAgaWYgKHRoaXMuaXNTdGFydChyb3csIGNvbHVtbikpIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiBmYWxzZTsKICAgIH07CiAgICB0aGlzLmNvbXBhcmUgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIGlmICghdGhpcy5pc011bHRpTGluZSgpKSB7CiAgICAgICAgICAgIGlmIChyb3cgPT09IHRoaXMuc3RhcnQucm93KSB7CiAgICAgICAgICAgICAgICByZXR1cm4gY29sdW1uIDwgdGhpcy5zdGFydC5jb2x1bW4gPyAtMSA6IChjb2x1bW4gPiB0aGlzLmVuZC5jb2x1bW4gPyAxIDogMCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGlmIChyb3cgPCB0aGlzLnN0YXJ0LnJvdykKICAgICAgICAgICAgcmV0dXJuIC0xOwoKICAgICAgICBpZiAocm93ID4gdGhpcy5lbmQucm93KQogICAgICAgICAgICByZXR1cm4gMTsKCiAgICAgICAgaWYgKHRoaXMuc3RhcnQucm93ID09PSByb3cpCiAgICAgICAgICAgIHJldHVybiBjb2x1bW4gPj0gdGhpcy5zdGFydC5jb2x1bW4gPyAwIDogLTE7CgogICAgICAgIGlmICh0aGlzLmVuZC5yb3cgPT09IHJvdykKICAgICAgICAgICAgcmV0dXJuIGNvbHVtbiA8PSB0aGlzLmVuZC5jb2x1bW4gPyAwIDogMTsKCiAgICAgICAgcmV0dXJuIDA7CiAgICB9OwogICAgdGhpcy5jb21wYXJlU3RhcnQgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIGlmICh0aGlzLnN0YXJ0LnJvdyA9PSByb3cgJiYgdGhpcy5zdGFydC5jb2x1bW4gPT0gY29sdW1uKSB7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByZXR1cm4gdGhpcy5jb21wYXJlKHJvdywgY29sdW1uKTsKICAgICAgICB9CiAgICB9OwogICAgdGhpcy5jb21wYXJlRW5kID0gZnVuY3Rpb24ocm93LCBjb2x1bW4pIHsKICAgICAgICBpZiAodGhpcy5lbmQucm93ID09IHJvdyAmJiB0aGlzLmVuZC5jb2x1bW4gPT0gY29sdW1uKSB7CiAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbXBhcmUocm93LCBjb2x1bW4pOwogICAgICAgIH0KICAgIH07CiAgICB0aGlzLmNvbXBhcmVJbnNpZGUgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIGlmICh0aGlzLmVuZC5yb3cgPT0gcm93ICYmIHRoaXMuZW5kLmNvbHVtbiA9PSBjb2x1bW4pIHsKICAgICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgfSBlbHNlIGlmICh0aGlzLnN0YXJ0LnJvdyA9PSByb3cgJiYgdGhpcy5zdGFydC5jb2x1bW4gPT0gY29sdW1uKSB7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICByZXR1cm4gdGhpcy5jb21wYXJlKHJvdywgY29sdW1uKTsKICAgICAgICB9CiAgICB9OwogICAgdGhpcy5jbGlwUm93cyA9IGZ1bmN0aW9uKGZpcnN0Um93LCBsYXN0Um93KSB7CiAgICAgICAgaWYgKHRoaXMuZW5kLnJvdyA+IGxhc3RSb3cpCiAgICAgICAgICAgIHZhciBlbmQgPSB7cm93OiBsYXN0Um93ICsgMSwgY29sdW1uOiAwfTsKICAgICAgICBlbHNlIGlmICh0aGlzLmVuZC5yb3cgPCBmaXJzdFJvdykKICAgICAgICAgICAgdmFyIGVuZCA9IHtyb3c6IGZpcnN0Um93LCBjb2x1bW46IDB9OwoKICAgICAgICBpZiAodGhpcy5zdGFydC5yb3cgPiBsYXN0Um93KQogICAgICAgICAgICB2YXIgc3RhcnQgPSB7cm93OiBsYXN0Um93ICsgMSwgY29sdW1uOiAwfTsKICAgICAgICBlbHNlIGlmICh0aGlzLnN0YXJ0LnJvdyA8IGZpcnN0Um93KQogICAgICAgICAgICB2YXIgc3RhcnQgPSB7cm93OiBmaXJzdFJvdywgY29sdW1uOiAwfTsKCiAgICAgICAgcmV0dXJuIFJhbmdlLmZyb21Qb2ludHMoc3RhcnQgfHwgdGhpcy5zdGFydCwgZW5kIHx8IHRoaXMuZW5kKTsKICAgIH07CiAgICB0aGlzLmV4dGVuZCA9IGZ1bmN0aW9uKHJvdywgY29sdW1uKSB7CiAgICAgICAgdmFyIGNtcCA9IHRoaXMuY29tcGFyZShyb3csIGNvbHVtbik7CgogICAgICAgIGlmIChjbXAgPT0gMCkKICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgZWxzZSBpZiAoY21wID09IC0xKQogICAgICAgICAgICB2YXIgc3RhcnQgPSB7cm93OiByb3csIGNvbHVtbjogY29sdW1ufTsKICAgICAgICBlbHNlCiAgICAgICAgICAgIHZhciBlbmQgPSB7cm93OiByb3csIGNvbHVtbjogY29sdW1ufTsKCiAgICAgICAgcmV0dXJuIFJhbmdlLmZyb21Qb2ludHMoc3RhcnQgfHwgdGhpcy5zdGFydCwgZW5kIHx8IHRoaXMuZW5kKTsKICAgIH07CgogICAgdGhpcy5pc0VtcHR5ID0gZnVuY3Rpb24oKSB7CiAgICAgICAgcmV0dXJuICh0aGlzLnN0YXJ0LnJvdyA9PT0gdGhpcy5lbmQucm93ICYmIHRoaXMuc3RhcnQuY29sdW1uID09PSB0a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5hcHBseShkb2NMaW5lcywgYXJncyk7CiAgICAgICAgICAgICAgICBkb2NMaW5lc1tyb3ddID0gbGluZS5zdWJzdHJpbmcoMCwgc3RhcnRDb2x1bW4pICsgZG9jTGluZXNbcm93XTsKICAgICAgICAgICAgICAgIGRvY0xpbmVzW3JvdyArIGRlbHRhLmxpbmVzLmxlbmd0aCAtIDFdICs9IGxpbmUuc3Vic3RyaW5nKHN0YXJ0Q29sdW1uKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyZW1vdmUiOgogICAgICAgICAgICB2YXIgZW5kQ29sdW1uID0gZGVsdGEuZW5kLmNvbHVtbjsKICAgICAgICAgICAgdmFyIGVuZFJvdyA9IGRlbHRhLmVuZC5yb3c7CiAgICAgICAgICAgIGlmIChyb3cgPT09IGVuZFJvdykgewogICAgICAgICAgICAgICAgZG9jTGluZXNbcm93XSA9IGxpbmUuc3Vic3RyaW5nKDAsIHN0YXJ0Q29sdW1uKSArIGxpbmUuc3Vic3RyaW5nKGVuZENvbHVtbik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBkb2NMaW5lcy5zcGxpY2UoCiAgICAgICAgICAgICAgICAgICAgcm93LCBlbmRSb3cgLSByb3cgKyAxLAogICAgICAgICAgICAgICAgICAgIGxpbmUuc3Vic3RyaW5nKDAsIHN0YXJ0Q29sdW1uKSArIGRvY0xpbmVzW2VuZFJvd10uc3Vic3RyaW5nKGVuZENvbHVtbikKICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICB9Cn07Cn0pOwoKYWNlLmRlZmluZSgiYWNlL2xpYi9ldmVudF9lbWl0dGVyIixbXSwgZnVuY3Rpb24ocmVxdWlyZSwgZXhwb3J0cywgbW9kdWxlKSB7CiJ1c2Ugc3RyaWN0IjsKCnZhciBFdmVudEVtaXR0ZXIgPSB7fTsKdmFyIHN0b3BQcm9wYWdhdGlvbi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RzSW5PcmRlcihkZWx0YUVuZCwgcG9pbnQsICFtb3ZlSWZFcXVhbCkpIHsKICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIHJvdzogcG9pbnQucm93ICsgZGVsdGFSb3dTaGlmdCwKICAgICAgICAgICAgICAgIGNvbHVtbjogcG9pbnQuY29sdW1uICsgKHBvaW50LnJvdyA9PSBkZWx0YUVuZC5yb3cgPyBkZWx0YUNvbFNoaWZ0IDogMCkKICAgICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgcm93OiBkZWx0YVN0YXJ0LnJvdywKICAgICAgICAgICAgY29sdW1uOiBkZWx0YVN0YXJ0LmNvbHVtbgogICAgICAgIH07CiAgICB9CiAgICB0aGlzLnNldFBvc2l0aW9uID0gZnVuY3Rpb24ocm93LCBjb2x1bW4sIG5vQ2xpcCkgewogICAgICAgIHZhciBwb3M7CiAgICAgICAgaWYgKG5vQ2xpcCkgewogICAgICAgICAgICBwb3MgPSB7CiAgICAgICAgICAgICAgICByb3c6IHJvdywKICAgICAgICAgICAgICAgIGNvbHVtbjogY29sdW1uCiAgICAgICAgICAgIH07CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcG9zID0gdGhpcy4kY2xpcFBvc2l0aW9uVG9Eb2N1bWVudChyb3csIGNvbHVtbik7CiAgICAgICAgfQoKICAgICAgICBpZiAodGhpcy5yb3cgPT0gcG9zLnJvdyAmJiB0aGlzLmNvbHVtbiA9PSBwb3MuY29sdW1uKQogICAgICAgICAgICByZXR1cm47CgogICAgICAgIHZhciBvbGQgPSB7CiAgICAgICAgICAgIHJvdzogdGhpcy5yb3csCiAgICAgICAgICAgIGNvbHVtbjogdGhpcy5jb2x1bW4KICAgICAgICB9OwoKICAgICAgICB0aGlzLnJvdyA9IHBvcy5yb3c7CiAgICAgICAgdGhpcy5jb2x1bW4gPSBwb3MuY29sdW1uOwogICAgICAgIHRoaXMuX3N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wgdGV4dCkgewogICAgICAgIGlmICh0aGlzLmdldExlbmd0aCgpIDw9IDEpCiAgICAgICAgICAgIHRoaXMuJGRldGVjdE5ld0xpbmUodGV4dCk7CiAgICAgICAgCiAgICAgICAgcmV0dXJuIHRoaXMuaW5zZXJ0TWVyZ2VkTGluZXMocG9zaXRpb24sIHRoaXMuJHNwbGl0KHRleHQpKTsKICAgIH07CiAgICB0aGlzLmluc2VydEluTGluZSA9IGZ1bmN0aW9uKHBvc2l0aW9uLCB0ZXh0KSB7CiAgICAgICAgdmFyIHN0YXJ0ID0gdGhpcy5jbGlwcGVkUG9zKHBvc2l0aW9uLnJvdywgcG9zaXRpb24uY29sdW1uKTsKICAgICAgICB2YXIgZW5kID0gdGhpcy5wb3MocG9zaXRpb24ucm93LCBwb3NpdGlvbi5jb2x1bW4gKyB0ZXh0Lmxlbmd0aCk7CiAgICAgICAgCiAgICAgICAgdGhpcy5hcHBseURlbHRhKHsKICAgICAgICAgICAgc3RhcnQ6IHN0YXJ0LAogICAgICAgICAgICBlbmQ6IGVuZCwKICAgICAgICAgICAgYWN0aW9uOiAiaW5zZXJ0IiwKICAgICAgICAgICAgbGluZXM6IFt0ZXh0XQogICAgICAgIH0sIHRydWUpOwogICAgICAgIAogICAgICAgIHJldHVybiB0aGlzLmNsb25lUG9zKGVuZCk7CiAgICB9OwogICAgCiAgICB0aGlzLmNsaXBwZWRQb3MgPSBmdW5jdGlvbihyb3csIGNvbHVtbikgewogICAgICAgIHZhciBsZW5ndGggPSB0aGlzLmdldExlbmd0aCgpOwogICAgICAgIGlmIChyb3cgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICByb3cgPSBsZW5ndGg7CiAgICAgICAgfSBlbHNlIGlmIChyb3cgPCAwKSB7CiAgICAgICAgICAgIHJvdyA9IDA7CiAgICAgICAgfSBlbHNlIGlmIChyb3cgPj0gbGVuZ3RoKSB7CiAgICAgICAgICAgIHJvdyA9IGxlbmd0aCAtIDE7CiAgICAgICAgICAgIGNvbHVtbiA9IHVuZGVmaW5lZDsKICAgICAgICB9CiAgICAgICAgdmFyIGxpbmUgPSB0aGlzLmdldExpbmUocm93KTsKICAgICAgICBpZiAoY29sdW1uID09IHVuZGVmaW5lZCkKICAgICAgICAgICAgY29sdW1uID0gbGluZS5sZW5ndGg7CiAgICAgICAgY29sdW1uID0gTWF0aC5taW4oTWF0aC5tYXgoY29sdW1uLCAwKSwgbGluZS5sZW5ndGgpOwogICAgICAgIHJldHVybiB7cm93OiByb3csIGNvbHVtbjogY29sdW1ufTsKICAgIH07CiAgICAKICAgIHRoaXMuY2xvbmVQb3MgPSBmdW5jdGlvbihwb3MpIHsKICAgICAgICByZXR1cm4ge3JvdzogcG9zLnJvdywgY29sdW1uOiBwb3MuY29sdW1ufTsKICAgIH07CiAgICAKICAgIHRoaXMucG9zID0gZnVuY3Rpb24ocm93LCBjb2x1bW4pIHsKICAgICAgICByZXR1cm4ge3Jvdzogcm93LCBjb2x1bW46IGNvbHVtbn07CiAgICB9OwogICAgCiAgICB0aGlzLiRjbGlwUG9zaXRpb24gPSBmdW5jdGlvbihwb3NpdGlvbikgewogICAgICAgIHZhciBsZW5ndGggPSB0aGlzLmdldExlbmd0aCgpOwogICAgICAgIGlmIChwb3NpdGlvbi5yb3cgPj0gbGVuZ3RoKSB7CiAgICAgICAgICAgIHBvc2l0aW9uLnJvdyA9IE1hdGgubWF4KDAsIGxlbmd0aCAtIDEpOwogICAgICAgICAgICBwb3NpdGlvbi5jb2x1bW4gPSB0aGlzLmdldExpbmUobGVuZ3RoIC0gMSkubGVuZ3RoOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBvc2l0aW9uLnJvdyA9IE1hdGgubWF4KDAsIHBvc2l0aW9uLnJvdyk7CiAgICAgICAgICAgIHBvc2l0aW9uLmNvbHVtbiA9IE1hdGgubWluKE1hdGgubWF4KHBvc2l0aW9uLmNvbHVtbiwgMCksIHRoaXMuZ2V0TGluZShwb3NpdGlvbi5yb3cpLmxlbmd0aCk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBwb3NpdGlvbjsKICAgIH07CiAgICB0aGlzLmluc2VydEZ1bGxMaW5lcyA9IGZ1bmN0aW9uKHJvdywgbGluZXMpIHsKICAgICAgICByb3cgPSBNYXRoLm1pbihNYXRoLm1heChyb3csIDApLCB0aGlzLmdldExlbmd0aCgpKTsKICAgICAgICB2YXIgY29sdW1uID0gMDsKICAgICAgICBpZiAocm93IDwgdGhpcy5nZXRMZW5ndGgoKSkgewogICAgICAgICAgICBsaW5lcyA9IGxpbmVzLmNvbmNhdChbIiJdKTsKICAgICAgICAgICAgY29sdW1uID0gMDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBsaW5lcyA9IFsiIl0uY29uY2F0KGxpbmVzKTsKICAgICAgICAgICAgcm93LS07CiAgICAgICAgICAgIGNvbHVtbiA9IHRoaXMuJGxpbmVzW3Jvd10ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICB0aGlzLmluc2VydE1lcmdlZExpbmVzKHtyb3c6IHJvdywgY29sdW1uOiBjb2x1bW59LCBsaW5lcyk7CiAgICB9OyAgICAKICAgIHRoaXMuaW5zZXJ0TWVyZ2VkTGluZXMgPSBmdW5jdGlvbihwb3NpdGlvbiwgbGluZXMpIHsKICAgICAgICB2YXIgc3RhcnQgPSB0aGlzLmNsaXBwZWRQb3MocG9zaXRpb24ucm93LCBwb3NpdGlvbi5jb2x1bW4pOwogICAgICAgIHZhciBlbmQgPSB7CiAgICAgICAgICAgIHJvdzogc3RhcnQucm93ICsgbGluZXMubGVuZ3RoIC0gMSwKICAgICAgICAgICAgY29sdW1uOiAobGluZXMubGVuZ3RoID09IDEgPyBzdGFydC5jb2x1bW4gOiAwKSArIGxpbmVzW2xpbmVzLmxlbmd0aCAtIDFdLmxlbmd0aAogICAgICAgIH07CiAgICAgICAgCiAgICAgICAgdGhpcy5hcHBseURlbHRhKHsKICAgICAgICAgICAgc3RhcnQ6IHN0YXJ0LAogICAgICAgICAgIC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AgICAgICAgICAgICAgICAgICAgICAgICAgICA6IHRoaXMuZ2V0TGluZShlbmRSb3cpLmxlbmd0aCApOyAKICAgICAgICB2YXIgcmFuZ2UgPSBuZXcgUmFuZ2Uoc3RhcnRSb3csIHN0YXJ0Q29sLCBlbmRSb3csIGVuZENvbCk7CiAgICAgICAgdmFyIGRlbGV0ZWRMaW5lcyA9IHRoaXMuJGxpbmVzLnNsaWNlKGZpcnN0Um93LCBsYXN0Um93ICsgMSk7CiAgICAgICAgCiAgICAgICAgdGhpcy5hcHBseURlbHRhKHsKICAgICAgICAgICAgc3RhcnQ6IHJhbmdlLnN0YXJ0LAogICAgICAgICAgICBlbmQ6IHJhbmdlLmVuZCwKICAgICAgICAgICAgYWN0aW9uOiAicmVtb3ZlIiwKICAgICAgICAgICAgbGluZXM6IHRoaXMuZ2V0TGluZXNGb3JSYW5nZShyYW5nZSkKICAgICAgICB9KTsKICAgICAgICByZXR1cm4gZGVsZXRlZExpbmVzOwogICAgfTsKICAgIHRoaXMucmVtb3ZlTmV3TGluZSA9IGZ1bmN0aW9uKHJvdykgewogICAgICAgIGlmIChyb3cgPCB0aGlzLmdldExlbmd0aCgpIC0gMSAmJiByb3cgPj0gMCkgewogICAgICAgICAgICB0aGlzLmFwcGx5RGVsdGEoewogICAgICAgICAgICAgICAgc3RhcnQ6IHRoaXMucG9zKHJvdywgdGhpcy5nZXRMaW5lKHJvdykubGVuZ3RoKSwKICAgICAgICAgICAgICAgIGVuZDogdGhpcy5wb3Mocm93ICsgMSwgMCksCiAgICAgICAgICAgICAgICBhY3Rpb246ICJyZW1vdmUiLAogICAgICAgICAgICAgICAgbGluZXM6IFsiIiwgIiJdCiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH07CiAgICB0aGlzLnJlcGxhY2UgPSBmdW5jdGlvbihyYW5nZSwgdGV4dCkgewogICAgICAgIGlmICghKHJhbmdlIGluc3RhbmNlb2YgUmFuZ2UpKQogICAgICAgICAgICByYW5nZSA9IFJhbm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7CiAgICAgICAgdmFyIGwgPSBsaW5lcy5sZW5ndGggLSBNQVggKyAxOwogICAgICAgIHZhciByb3cgPSBkZWx0YS5zdGFydC5yb3c7IAogICAgICAgIHZhciBjb2x1bW4gPSBkZWx0YS5zdGFydC5jb2x1bW47CiAgICAgICAgZm9yICh2YXIgZnJvbSA9IDAsIHRvID0gMDsgZnJvbSA8IGw7IGZyb20gPSB0bykgewogICAgICAgICAgICB0byArPSBNQVggLSAxOwogICAgICAgICAgICB2YXIgY2h1bmsgPSBsaW5lcy5zbGljZShmcm9tLCB0byk7CiAgICAgICAgICAgIGNodW5rLnB1c2goIiIpOwogICAgICAgICAgICB0aGlzLmFwcGx5RGVsdGEoewogICAgICAgICAgICAgICAgc3RhcnQ6IHRoaXMucG9zKHJvdyArIGZyb20sIGNvbHVtbiksCiAgICAgICAgICAgICAgICBlbmQ6IHRoaXMucG9zKHJvdyArIHRvLCBjb2x1bW4gPSAwKSwKICAgICAgICAgICAgICAgIGFjdGlvbjogZGVsdGEuYWN0aW9uLAogICAgICAgICAgICAgICAgbGluZXM6IGNodW5rCiAgICAgICAgICAgIH0sIHRydWUpOwogICAgICAgIH0KICAgICAgICBkZWx0YS5saW5lcyA9IGxpbmVzLnNsaWNlKGZyb20pOwogICAgICAgIGRlbHRhLnN0YXJ0LnJvdyA9IHJvdyArIGZyb207CiAgICAgICAgZGVsdGEuc3RhcnQuY29sdW1uID0gY29sdW1uOwogICAgICAgIHRoaXMuYXBwbHlEZWx0YShkZWx0YSwgdHJ1ZSk7CiAgICB9OwogICAgdGhpcy5yZXZlcnREZWx0YSA9IGZ1bmN0aW9uKGRlbHRhKSB7CiAgICAgICAgdGhpcy4kc2FmZUFwcGx5RGVsdGEoewogICAgICAgICAgICBzdGFydDogdGhpcy5jbG9uZVBvcyhkZWx0YS5zdGFydCksCiAgICAgICAgICAgIGVuZDogdGhpcy5jbG9uZVBvcyhkZWx0YS5lbmQpLAogICAgICAgICAgICBhY3Rpb246IChkZWx0YS5h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ZSh0cmltQmVnaW5SZWdleHAsICcnKTsKfTsKCmV4cG9ydHMuc3RyaW5nVHJpbVJpZ2h0ID0gZnVuY3Rpb24gKHN0cmluZykgewogICAgcmV0dXJuIHN0cmluZy5yZXBsYWNlKHRyaW1FbmRSZWdleHAsICcnKTsKfTsKCmV4cG9ydHMuY29weU9iamVjdCA9IGZ1bmN0aW9uKG9iaikgewogICAgdmFyIGNvcHkgPSB7fTsKICAgIGZvciAodmFyIGtleSBpbiBvYmopIHsKICAgICAgICBjb3B5W2tleV0gPSBvYmpba2V5XTsKICAgIH0KICAgIHJldHVybiBjb3B5Owp9OwoKZXhwb3J0cy5jb3B5QXJyYXkgPSBmdW5jdGlvbihhcnJheSl7CiAgICB2YXIgY29weSA9IFtdOwogICAgZm9yICh2YXIgaT0wLCBsPWFycmF5Lmxlbmd0aDsgaTxsOyBpKyspIHsKICAgICAgICBpZiAoYXJyYXlbaV0gJiYgdHlwZW9mIGFycmF5W2ldID09ICJvYmplY3QiKQogICAgICAgICAgICBjb3B5W2ldID0gdGhpcy5jb3B5T2JqZWN0KGFycmF5W2ldKTsKICAgICAgICBlbHNlIAogICAgICAgICAgICBjb3B5W2ldID0gYXJyYXlbaV07CiAgICB9CiAgICByZXR1cm4gY29weTsKfTsKCmV4cG9ydHMuZGVlcENvcHkgPSBmdW5jdGlvbiBkZWVwQ29weShvYmopIHsKICAgIGlmICh0eXBlb2Ygb2JqICE9PSAib2JqZWN0IiB8fCAhb2JqKQogICAgICAgIHJldHVybiBvYmo7CiAgICB2YXIgY29weTsKICAgIGlmIChBcnJheS5pc0FycmF5KG9iaikpIHsKICAgICAgICBjb3B5ID0gW107CiAgICAgICAgZm9yICh2YXIga2V5ID0gMDsga2V5IDwgb2JqLmxlbmd0aDsga2V5KyspIHsKICAgICAgICAgICAgY29weVtrZXldID0gZGVlcENvcHkob2JqW2tleV0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gY29weTsKICAgIH0KICAgIGlmIChPYmplY3QucHJvd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LnJlcGxhY2UoLycvZywgIiYjMzk7IikucmVwbGFjZSgvPC9nLCAiJiM2MDsiKTsKfTsKCmV4cG9ydHMuZ2V0TWF0Y2hPZmZzZXRzID0gZnVuY3Rpb24oc3RyaW5nLCByZWdFeHApIHsKICAgIHZhciBtYXRjaGVzID0gW107CgogICAgc3RyaW5nLnJlcGxhY2UocmVnRXhwLCBmdW5jdGlvbihzdHIpIHsKICAgICAgICBtYXRjaGVzLnB1c2goewogICAgICAgICAgICBvZmZzZXQ6IGFyZ3VtZW50c1thcmd1bWVudHMubGVuZ3RoLTJdLAogICAgICAgICAgICBsZW5ndGg6IHN0ci5sZW5ndGgKICAgICAgICB9KTsKICAgIH0pOwoKICAgIHJldHVybiBtYXRjaGVzOwp9OwpleHBvcnRzLmRlZmVycmVkQ2FsbCA9IGZ1bmN0aW9uKGZjbikgewogICAgdmFyIHRpbWVyID0gbnVsbDsKICAgIHZhciBjYWxsYmFjayA9IGZ1bmN0aW9uKCkgewogICAgICAgIHRpbWVyID0gbnVsbDsKICAgICAgICBmY24oKTsKICAgIH07CgogICAgdmFyIGRlZmVycmVkID0gZnVuY3Rpb24odGltZW91dCkgewogICAgICAgIGRlZmVycmVkLmNhbmNlbCgpOwogICAgICAgIHRpbWVyID0gc2V0VGltZW91dChjYWxsYmFjaywgdGltZW91dCB8fCAwKTsKICAgICAgICByZXR1cm4gZGVmZXJyZWQ7CiAgICB9OwoKICAgIGRlZmVycmVkLnNjaGVkdWxlID0gZGVmZXJyZWQ7CgogICAgZGVmZXJyZWQuY2FsbCA9IGZ1bmN0aW9uKCkgewogICAgICAgIHRoaXMuY2FuY2VsKCk7CiAgICAgICAgZmNuKCk7CiAgICAgICAgcmV0dXJuIGRlZmVycmVkOwogICAgfTsKCiAgICBkZWZlcnJlZC5jYW5jZWwgPSBmdW5jdGlvbigpIHsKICAgICAgICBjbGVhclRpbWVvdXQodGltZXIpOwogICAgICAgIHRpbWVyID0gbnVsbDsKICAgICAgICByZXR1cm4gZGVmZXJyZWQ7CiAgICB9OwogICAgCiAgICBkZWZlcnJlZC5pc1BlbmRpbmcgPSBmdW5jdGlvbigpIHsKICAgICAgICByZXR1cm4gdGltZXI7CiAgICB9OwoKICAgIHJldHVybiBkZWZlcnJlZDsKfTsKCgpleHBvcnRzLmRlbGF5ZWRDYWxsID0gZnVuY3Rpb24oZmNuLCBkZWZhdWx0VGltZW91dCkgewogICAgdmFyIHRpbWVyID0gbnVsbDsKICAgIHZhciBjYWxsYmFjayA9IGZ1bmN0aW9uKCkgewogICAgICAgIHRpbWVyID0gbnVsbDsKICAgICAgICBmY24oKTsKICAgIH07CgogICAgdmFyIF9zZWxmID0gZnVuY3Rpb24odGltZW91dCkgewogICAgICAgIGlmICh0aW1lciA9PSBudWxsKQogICAgICAgICAgICB0aW1lciA9IHNldFRpbWVvdXQoY2FsbGJhY2ssIHRpbWVvdXQgfHwgZGVmYXVsdFRpbWVvdXQpOwogICAgfTsKCiAgICBfc2VsZi5kZWxheSA9IGZ1bmN0aW9uKHRpbWVvdXQpIHsKICAgICAgICB0aW1lciAmJiBjbGVhclRpbWVvdXQodGltZXIpOwogICAgICAgIHRpbWVyID0gc2V0VGltZW91dChjYWxsYmFjaywgdGltZW91dCB8fCBkZWZhdWx0VGltZW91dCk7CiAgICB9OwogICAgX3NlbGYuc2NoZWR1bGUgPSBfc2VsZjsKCiAgICBfc2VsZi5jYWxsID0gZnVuY3Rpb24oKSB7CiAgICAgICAgdGhpcy5jYW5jZWwoKTsKICAgICAgICBmY24oKTsKICAgIH07CgogICAgX3NlbGYuY2FuY2VsID0gZnVuY3Rpb24oKSB7CiAgICAgICAgdGltZXIgJiYgY2xlYXJUaW1lb3V0KHRpbWVyKTsKICAgICAgICB0aW1lciA9IG51bGw7CiAgICB9OwoKICAgIF9zZWxmLmlzUGVuZGluZyA9IGZ1bmN0aW9uKCkgewogICAgICAgIHJldHVybiB0aW1lcjsKICAgIH07CgogICAgcmV0dXJuIF9zZWxmOwp9Owp9KTsKCm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JhY2UvbW9kZS9qc29uL2pzb25fcGFyc2UiLFtdLCBmdW5jdGlvbihyZXF1aXJlLCBleHBvcnRzLCBtb2R1bGUpIHsKInVzZSBzdHJpY3QiOwoKICAgIHZhciBhdCwgICAgIC8vIFRoZSBpbmRleCBvZiB0aGUgY3VycmVudCBjaGFyYWN0ZXIKICAgICAgICBjaCwgICAgIC8vIFRoZSBjdXJyZW50IGNoYXJhY3RlcgogICAgICAgIGVzY2FwZWUgPSB7CiAgICAgICAgICAgICciJzogICciJywKICAgICAgICAgICAgJ1xcJzogJ1xcJywKICAgICAgICAgICAgJy8nOiAgJy8nLAogICAgICAgICAgICBiOiAgICAnXGInLAogICAgICAgICAgICBmOiAgICAnXGYnLAogICAgICAgICAgICBuOiAgICAnXG4nLAogICAgICAgICAgICByOiAgICAnXHInLAogICAgICAgICAgICB0OiAgICAnXHQnCiAgICAgICAgfSwKICAgICAgICB0ZXh0LAoKICAgICAgICBlcnJvciA9IGZ1bmN0aW9uIChtKSB7CgogICAgICAgICAgICB0aHJvdyB7CiAgICAgICAgICAgICAgICBuYW1lOiAgICAnU3ludGF4RXJyb3InLAogICAgICAgICAgICAgICAgbWVzc2FnZTogbSwKICAgICAgICAgICAgICAgIGF0OiAgICAgIGF0LAogICAgICAgICAgICAgICAgdGV4dDogICAgdGV4dAogICAgICAgICAgICB9OwogICAgICAgIH0sCgogICAgICAgIG5leHQgPSBmdW5jdGlvbiAoYykgewoKICAgICAgICAgICAgaWYgKGMgJiYgYyAhPT0gY2gpIHsKICAgICAgICAgICAgICAgIGVycm9yKCJFeHBlY3RlZCAnIiArIGMgKyAiJyBpbnN0ZWFkIG9mICciICsgY2ggKyAiJyIpOwogICAgICAgICAgICB9CgogICAgICAgICAgICBjaCA9IHRleHQuY2hhckF0KGF0KTsKICAgICAgICAgICAgYXQgKz0gMTsKICAgICAgICAgICAgcmV0dXJuIGNoOwogICAgICAgIH0sCgogICAgICAgIG51bWJlciA9IGZ1bmN0aW9uICgpIHsKCiAgICAgICAgICAgIHZhciBudW1iZXIsCiAgICAgICAgICAgICAgICBzdHJpbmcgPSAnJzsKCiAgICAgICAgICAgIGlmIChjaCA9PT0gJy0nKSB7CiAgICAgICAgICAgICAgICBzdHJpbmcgPSAnLSc7CiAgICAgICAgICAgICAgICBuZXh0KCctJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKGNoID49ICcwJyAmJiBjaCA8PSAnOScpIHsKICAgICAgICAgICAgICAgIHN0cmluZyArPSBjaDsKICAgICAgICAgICAgICAgIG5leHQoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY2ggPT09ICcuJykgewogICAgICAgICAgICAgICAgc3RyaW5nICs9ICcuJzsKICAgICAgICAgICAgICAgIHdoaWxlIChuZXh0KCkgJiYgY2ggPj0gJzAnICYmIGNoIDw9ICc5JykgewogICAgICAgICAgICAgICAgICAgIHN0cmluZyArPSBjaDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY2ggPT09ICdlJyB8fCBjaCA9PT0gJ0UnKSB7CiAgICAgICAgICAgICAgICBzdHJpbmcgKz0gY2g7CiAgICAgICAgICAgICAgICBuZXh0KCk7CiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICctJyB8fCBjaCA9PT0gJysnKSB7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nICs9IGNoOwogICAgICAgICAgICAgICAgICAgIG5leHQoKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChjaCA+PSAnMCcgJiYgY2ggPD0gJzknKSB7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nICs9IGNoOwogICAgICAgICAgICAgICAgICAgIG5leHQoKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBudW1iZXIgPSArc3RyaW5nOwogICAgICAgICAgICBpZiAoaXNOYU4obnVtYmVyKSkgewogICAgICAgICAgICAgICAgZXJyb3IoIkJhZCBudW1iZXIiKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHVybiBudW1iZXI7CiAgICAgICAgICAgIH0KICAgICAgICB9LAoKICAgICAgICBzdHJpbmcgPSBmdW5jdGlvbiAoKSB7CgogICAgICAgICAgICB2YXIgaGV4LAogICAgICAgICAgICAgICAgaSwKICAgICAgICAgICAgICAgIHN0cmluZyA9ICcnLAogICAgICAgICAgICAgICAgdWZmZmY7CgogICAgICAgICAgICBpZiAoY2ggPT09ICciJykgewogICAgICAgICAgICAgICAgd2hpbGUgKG5leHQoKSkgewogICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJyInKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5leHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0cmluZzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoID09PSAnXFwnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5leHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoID09PSAndScpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVmZmZmID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCA0OyBpICs9IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZXggPSBwYXJzZUludChuZXh0KCksIDE2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzRmluaXRlKGhleCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVmZmZmID0gdWZmZmYgKiAxNiArIGhleDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHVmZmZmKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgZXNjYXBlZVtjaF0gPT09ICdzdHJpbmcnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgKz0gZXNjYXBlZVtjaF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2ggPT0gIlxuIiB8fCBjaCA9PSAiXHIiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyArPSBjaDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IoIkJhZCBzdHJpbmciKTsKICAgICAgICB9LAoKICAgICAgICB3aGl0ZSA9IGZ1bmN0aW9uICgpIHsKCiAgICAgICAgICAgIHdoaWxlIChjaCAmJiBjaCA8PSAnICcpIHsKICAgICAgICAgICAgICAgIG5leHQoKTsKICAgICAgICAgICAgfQogICAgICAgIH0sCgogICAgICAgIHdvcmQgPSBmdW5jdGlvbiAoKSB7CgogICAgICAgICAgICBzd2l0Y2ggKGNoKSB7CiAgICAgICAgICAgIGNhc2UgJ3QnOgogICAgICAgICAgICAgICAgbmV4dCgndCcpOwogICAgICAgICAgICAgICAgbmV4dCgncicpOwogICAgICAgICAgICAgICAgbmV4dCgndScpOwogICAgICAgICAgICAgICAgbmV4dCgnZScpOwogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIGNhc2UgJ2YnOgogICAgICAgICAgICAgICAgbmV4dCgnZicpOwogICAgICAgICAgICAgICAgbmV4dCgnYScpOwogICAgICAgICAgICAgICAgbmV4dCgnbCcpOwogICAgICAgICAgICAgICAgbmV4dCgncycpOwogICAgICAgICAgICAgICAgbmV4dCgnZScpOwogICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICBjYXNlICduJzoKICAgICAgICAgICAgICAgIG5leHQoJ24nKTsKICAgICAgICAgICAgICAgIG5leHQoJ3UnKTsKICAgICAgICAgICAgICAgIG5leHQoJ2wnKTsKICAgICAgICAgICAgICAgIG5leHQoJ2wnKTsKICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yKCJVbmV4cGVjdGVkICciICsgY2ggKyAiJyIpOwogICAgICAgIH0sCgogICAgICAgIHZhbHVlLCAgLy8gUGxhY2UgaG9sZGVyIGZvciB0aGUgdmFsdWUgZnVuY3Rpb24uCgogICAgICAgIGFycmF5ID0gZnVuY3Rpb24gKCkgewoKICAgICAgICAgICAgdmFyIGFycmF5ID0gW107CgogICAgICAgICAgICBpZiAoY2ggPT09ICdbJykgewogICAgICAgICAgICAgICAgbmV4dCgnWycpOwogICAgICAgICAgICAgICAgd2hpdGUoKTsKICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJ10nKSB7CiAgICAgICAgICAgICAgICAgICAgbmV4dCgnXScpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnJheTsgICAvLyBlbXB0eSBhcnJheQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKGNoKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXkucHVzaCh2YWx1ZSgpKTsKICAgICAgICAgICAgICAgICAgICB3aGl0ZSgpOwogICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJ10nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5leHQoJ10nKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFycmF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0KCcsJyk7CiAgICAgICAgICAgICAgICAgICAgd2hpdGUoKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBlcnJvcigiQmFkIGFycmF5Iik7CiAgICAgICAgfSwKCiAgICAgICAgb2JqZWN0ID0gZnVuY3Rpb24gKCkgewoKICAgICAgICAgICAgdmFyIGtleSwKICAgICAgICAgICAgICAgIG9iamVjdCA9IHt9OwoKICAgICAgICAgICAgaWYgKGNoID09PSAneycpIHsKICAgICAgICAgICAgICAgIG5leHQoJ3snKTsKICAgICAgICAgICAgICAgIHdoaXRlKCk7CiAgICAgICAgICAgICAgICBpZiAoY2ggPT09ICd9JykgewogICAgICAgICAgICAgICAgICAgIG5leHQoJ30nKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqZWN0OyAgIC8vIGVtcHR5IG9iamVjdAogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKGNoKSB7CiAgICAgICAgICAgICAgICAgICAga2V5ID0gc3RyaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgd2hpdGUoKTsKICAgICAgICAgICAgICAgICAgICBuZXh0KCc6Jyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5oYXNPd25Qcm9wZXJ0eS5jYWxsKG9iamVjdCwga2V5KSkgewogICAgICAgICAgICAgICAgICAgICAgICBlcnJvcignRHVwbGljYXRlIGtleSAiJyArIGtleSArICciJyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9iamVjdFtrZXldID0gdmFsdWUoKTsKICAgICAgICAgICAgICAgICAgICB3aGl0ZSgpOwogICAgICAgICAgICAgICAgICAgIGlmIChjaCA9PT0gJ30nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5leHQoJ30nKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iamVjdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbmV4dCgnLCcpOwogICAgICAgICAgICAgICAgICAgIHdoaXRlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IoIkJhZCBvYmplY3QiKTsKICAgICAgICB9OwoKICAgIHZhbHVlID0gZnVuY3Rpb24gKCkgewoKICAgICAgICB3aGl0ZSgpOwogICAgICAgIHN3aXRjaCAoY2gpIHsKICAgICAgICBjYXNlICd7JzoKICAgICAgICAgICAgcmV0dXJuIG9iamVjdCgpOwogICAgICAgIGNhc2UgJ1snOgogICAgICAgICAgICByZXR1cm4gYXJyYXkoKTsKICAgICAgICBjYXNlICciJzoKICAgICAgICAgICAgcmV0dXJuIHN0cmluZygpOwogICAgICAgIGNhc2UgJy0nOgogICAgICAgICAgICByZXR1cm4gbnVtYmVyKCk7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgcmV0dXJuIGNoID49ICcwJyAmJiBjaCA8PSAnOScgPyBudW1iZXIoKSA6IHdvcmQoKTsKICAgICAgICB9CiAgICB9OwoKICAgIHJldHVybiBmdW5jdGlvbiAoc291cmNlLCByZXZpdmVyKSB7CiAgICAgICAgdmFyIHJlc3VsdDsKCiAgICAgICAgdGV4dCA9IHNvdXJjZTsKICAgICAgICBhdCA9IDA7CiAgICAgICAgY2ggPSAnICc7CiAgICAgICAgcmVzdWx0ID0gdmFsdWUoKTsKICAgICAgICB3aGl0ZSgpOwogICAgICAgIGlmIChjaCkgewogICAgICAgICAgICBlcnJvcigiU3ludGF4IGVycm9yIik7CiAgICAgICAgfQoKICAgICAgICByZXR1cm4gdHlwZW9mIHJldml2ZXIgPT09ICdmdW5jdGlvbicgPyBmdW5jdGlvbiB3YWxrKGhvbGRlciwga2V5KSB7CiAgICAgICAgICAgIHZhciBrLCB2LCB2YWx1ZSA9IGhvbGRlcltrZXldOwogICAgICAgICAgICBpZiAodmFsdWUgJiYgdHlwZW9mIHZhbHVlID09PSAnb2JqZWN0JykgewogICAgICAgICAgICAgICAgZm9yIChrIGluIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5oYXNPd25Qcm9wZXJ0eS5jYWxsKHZhbHVlLCBrKSkgewogICAgICAgICAgICAgICAgICAgICAgICB2ID0gd2Fsayh2YWx1ZSwgayk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlW2tdID0gdjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB2YWx1ZVtrXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gcmV2aXZlci5jYWxsKGhvbGRlciwga2V5LCB2YWx1ZSk7CiAgICAgICAgfSh7Jyc6IHJlc3VsdH0sICcnKSA6IHJlc3VsdDsKICAgIH07Cn0pOwoKYWNlLmRlZmluZSgiYWNlL21vZGUvanNvbl93b3JrZXIiLFtdLCBmdW5jdGlvbihyZXF1aXJlLCBleHBvcnRzLCBtb2R1bGUpIHsKInVzZSBzdHJpY3QiOwoKdmFyIG9vcCA9IHJlcXVpcmUoIi4uL2xpYi9vb3AiKTsKdmFyIE1pcnJvciA9IHJlcXVpcmUoIi4uL3dvcmtlci9taXJyb3IiKS5NaXJyb3I7CnZhciBwYXJzZSA9IHJlcXVpcmUoIi4vanNvbi9qc29uX3BhcnNlIik7Cgp2YXIgSnNvbldvcmtlciA9IGV4cG9ydHMuSnNvbldvcmtlciA9IGZ1bmN0aW9uKHNlbmRlcikgewogICAgTWlycm9yLmNhbGwodGhpcywgc2VuZGVyKTsKICAgIHRoaXMuc2V0VGltZW91dCgyMDApOwp9OwoKb29wLmluaGVyaXRzKEpzb25Xb3JrZXIsIE1pcnJvcik7CgooZnVuY3Rpb24oKSB7CgogICAgdGhpcy5vblVwZGF0ZSA9IGZ1bmN0aW9uKCkgewogICAgICAgIHZhciB2YWx1ZSA9IHRoaXMuZG9jLmdldFZhbHVlKCk7CiAgICAgICAgdmFyIGVycm9ycyA9IFtdOwogICAgICAgIHRyeSB7CiAgICAgICAgICAgIGlmICh2YWx1ZSkKICAgICAgICAgICAgICAgIHBhcnNlKHZhbHVlKTsKICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgIHZhciBwb3MgPSB0aGlzLmRvYy5pbmRleFRvUG9zaXRpb24oZS5hdC0xKTsKICAgICAgICAgICAgZXJyb3JzLnB1c2goewogICAgICAgICAgICAgICAgcm93OiBwb3Mucm93LAogICAgICAgICAgICAgICAgY29sdW1uOiBwb3MuY29sdW1uLAogICAgICAgICAgICAgICAgdGV4dDogZS5tZXNzYWdlLAogICAgICAgICAgICAgICAgdHlwZTogImVycm9yIgogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgdGhpcy5zZW5kZXIuZW1pdCgiYW5ub3RhdGUiLCBlcnJvcnMpOwogICAgfTsKCn0pLmNhbGwoSnNvbldvcmtlci5wcm90b3R5cGUpOwoKfSk7Cg=='; /***/ }), /***/ 7907: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "m0": function() { return /* binding */ setLanguage; }, /* harmony export */ "cC": function() { return /* binding */ setLanguages; }, /* harmony export */ "Iu": function() { return /* binding */ translate; } /* harmony export */ }); /* harmony import */ var _polyfills__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4987); /* harmony import */ var _polyfills__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_polyfills__WEBPACK_IMPORTED_MODULE_0__); /* eslint-disable no-template-curly-in-string */ var _locales = ['en', 'pt-BR', 'zh-CN', 'tr', 'ja', 'fr-FR', 'de']; var _defs = { en: { array: 'Array', auto: 'Auto', appendText: 'Append', appendTitle: 'Append a new field with type \'auto\' after this field (Ctrl+Shift+Ins)', appendSubmenuTitle: 'Select the type of the field to be appended', appendTitleAuto: 'Append a new field with type \'auto\' (Ctrl+Shift+Ins)', ascending: 'Ascending', ascendingTitle: 'Sort the childs of this ${type} in ascending order', actionsMenu: 'Click to open the actions menu (Ctrl+M)', cannotParseFieldError: 'Cannot parse field into JSON', cannotParseValueError: 'Cannot parse value into JSON', collapseAll: 'Collapse all fields', compactTitle: 'Compact JSON data, remove all whitespaces (Ctrl+Shift+\\)', descending: 'Descending', descendingTitle: 'Sort the childs of this ${type} in descending order', drag: 'Drag to move this field (Alt+Shift+Arrows)', duplicateKey: 'duplicate key', duplicateText: 'Duplicate', duplicateTitle: 'Duplicate selected fields (Ctrl+D)', duplicateField: 'Duplicate this field (Ctrl+D)', duplicateFieldError: 'Duplicate field name', empty: 'empty', expandAll: 'Expand all fields', expandTitle: 'Click to expand/collapse this field (Ctrl+E). \n' + 'Ctrl+Click to expand/collapse including all childs.', formatTitle: 'Format JSON data, with proper indentation and line feeds (Ctrl+\\)', insert: 'Insert', insertTitle: 'Insert a new field with type \'auto\' before this field (Ctrl+Ins)', insertSub: 'Select the type of the field to be inserted', object: 'Object', ok: 'Ok', redo: 'Redo (Ctrl+Shift+Z)', removeText: 'Remove', removeTitle: 'Remove selected fields (Ctrl+Del)', removeField: 'Remove this field (Ctrl+Del)', repairTitle: 'Repair JSON: fix quotes and escape characters, remove comments and JSONP notation, turn JavaScript objects into JSON.', searchTitle: 'Search fields and values', searchNextResultTitle: 'Next result (Enter)', searchPreviousResultTitle: 'Previous result (Shift + Enter)', selectNode: 'Select a node...', showAll: 'show all', showMore: 'show more', showMoreStatus: 'displaying ${visibleChilds} of ${totalChilds} items.', sort: 'Sort', sortTitle: 'Sort the childs of this ${type}', sortTitleShort: 'Sort contents', sortFieldLabel: 'Field:', sortDirectionLabel: 'Direction:', sortFieldTitle: 'Select the nested field by which to sort the array or object', sortAscending: 'Ascending', sortAscendingTitle: 'Sort the selected field in ascending order', sortDescending: 'Descending', sortDescendingTitle: 'Sort the selected field in descending order', string: 'String', transform: 'Transform', transformTitle: 'Filter, sort, or transform the childs of this ${type}', transformTitleShort: 'Filter, sort, or transform contents', extract: 'Extract', extractTitle: 'Extract this ${type}', transformQueryTitle: 'Enter a JMESPath query', transformWizardLabel: 'Wizard', transformWizardFilter: 'Filter', transformWizardSortBy: 'Sort by', transformWizardSelectFields: 'Select fields', transformQueryLabel: 'Query', transformPreviewLabel: 'Preview', type: 'Type', typeTitle: 'Change the type of this field', openUrl: 'Ctrl+Click or Ctrl+Enter to open url in new window', undo: 'Undo last action (Ctrl+Z)', validationCannotMove: 'Cannot move a field into a child of itself', autoType: 'Field type "auto". ' + 'The field type is automatically determined from the value ' + 'and can be a string, number, boolean, or null.', objectType: 'Field type "object". ' + 'An object contains an unordered set of key/value pairs.', arrayType: 'Field type "array". ' + 'An array contains an ordered collection of values.', stringType: 'Field type "string". ' + 'Field type is not determined from the value, ' + 'but always returned as string.', modeEditorTitle: 'Switch Editor Mode', modeCodeText: 'Code', modeCodeTitle: 'Switch to code highlighter', modeFormText: 'Form', modeFormTitle: 'Switch to form editor', modeTextText: 'Text', modeTextTitle: 'Switch to plain text editor', modeTreeText: 'Tree', modeTreeTitle: 'Switch to tree editor', modeViewText: 'View', modeViewTitle: 'Switch to tree view', modePreviewText: 'Preview', modePreviewTitle: 'Switch to preview mode', examples: 'Examples', "default": 'Default', containsInvalidProperties: 'Contains invalid properties', containsInvalidItems: 'Contains invalid items' }, 'zh-CN': { array: '数组', auto: '自动', appendText: '追加', appendTitle: '在此字段后追加一个类型为“auto”的新字段 (Ctrl+Shift+Ins)', appendSubmenuTitle: '选择要追加的字段类型', appendTitleAuto: '追加类型为“auto”的新字段 (Ctrl+Shift+Ins)', ascending: '升序', ascendingTitle: '升序排列${type}的子节点', actionsMenu: '点击打开动作菜单(Ctrl+M)', cannotParseFieldError: '无法将字段解析为JSON', cannotParseValueError: '无法将值解析为JSON', collapseAll: '缩进所有字段', compactTitle: '压缩JSON数据,删除所有空格 (Ctrl+Shift+\\)', descending: '降序', descendingTitle: '降序排列${type}的子节点', drag: '拖拽移动该节点(Alt+Shift+Arrows)', duplicateKey: '重复键', duplicateText: '复制', duplicateTitle: '复制选中字段(Ctrl+D)', duplicateField: '复制该字段(Ctrl+D)', duplicateFieldError: '重复的字段名称', empty: '清空', expandAll: '展开所有字段', expandTitle: '点击 展开/收缩 该字段(Ctrl+E). \n' + 'Ctrl+Click 展开/收缩 包含所有子节点.', formatTitle: '使用适当的缩进和换行符格式化JSON数据 (Ctrl+\\)', insert: '插入', insertTitle: '在此字段前插入类型为“auto”的新字段 (Ctrl+Ins)', insertSub: '选择要插入的字段类型', object: '对象', ok: 'Ok', redo: '重做 (Ctrl+Shift+Z)', removeText: '移除', removeTitle: '移除选中字段 (Ctrl+Del)', removeField: '移除该字段 (Ctrl+Del)', repairTitle: '修复JSON:修复引号和转义符,删除注释和JSONP表示法,将JavaScript对象转换为JSON。', selectNode: '选择一个节点...', showAll: '展示全部', showMore: '展示更多', showMoreStatus: '显示${totalChilds}的${visibleChilds}项目.', sort: '排序', sortTitle: '排序${type}的子节点', sortTitleShort: '内容排序', sortFieldLabel: '字段:', sortDirectionLabel: '方向:', sortFieldTitle: '选择用于对数组或对象排序的嵌套字段', sortAscending: '升序排序', sortAscendingTitle: '按照该字段升序排序', sortDescending: '降序排序', sortDescendingTitle: '按照该字段降序排序', string: '字符串', transform: '变换', transformTitle: '筛选,排序,或者转换${type}的子节点', transformTitleShort: '筛选,排序,或者转换内容', extract: '提取', extractTitle: '提取这个 ${type}', transformQueryTitle: '输入JMESPath查询', transformWizardLabel: '向导', transformWizardFilter: '筛选', transformWizardSortBy: '排序', transformWizardSelectFields: '选择字段', transformQueryLabel: '查询', transformPreviewLabel: '预览', type: '类型', typeTitle: '更改字段类型', openUrl: 'Ctrl+Click 或者 Ctrl+Enter 在新窗口打开链接', undo: '撤销上次动作 (Ctrl+Z)', validationCannotMove: '无法将字段移入其子节点', autoType: '字段类型 "auto". ' + '字段类型由值自动确定 ' + '可以为 string,number,boolean,或者 null.', objectType: '字段类型 "object". ' + '对象包含一组无序的键/值对.', arrayType: '字段类型 "array". ' + '数组包含值的有序集合.', stringType: '字段类型 "string". ' + '字段类型由值自动确定,' + '但始终作为字符串返回.', modeCodeText: '代码', modeCodeTitle: '切换至代码高亮', modeFormText: '表单', modeFormTitle: '切换至表单编辑', modeTextText: '文本', modeTextTitle: '切换至文本编辑', modeTreeText: '树', modeTreeTitle: '切换至树编辑', modeViewText: '视图', modeViewTitle: '切换至树视图', modePreviewText: '预览', modePreviewTitle: '切换至预览模式', examples: '例子', "default": '缺省', containsInvalidProperties: '包含无效的属性', containsInvalidItems: '包含无效项目' }, 'pt-BR': { array: 'Lista', auto: 'Automatico', appendText: 'Adicionar', appendTitle: 'Adicionar novo campo com tipo \'auto\' depois deste campo (Ctrl+Shift+Ins)', appendSubmenuTitle: 'Selecione o tipo do campo a ser adicionado', appendTitleAuto: 'Adicionar novo campo com tipo \'auto\' (Ctrl+Shift+Ins)', ascending: 'Ascendente', ascendingTitle: 'Organizar filhor do tipo ${type} em crescente', actionsMenu: 'Clique para abrir o menu de ações (Ctrl+M)', cannotParseFieldError: 'Não é possível analisar o campo no JSON', cannotParseValueError: 'Não é possível analisar o valor em JSON', collapseAll: 'Fechar todos campos', compactTitle: 'Dados JSON compactos, remova todos os espaços em branco (Ctrl+Shift+\\)', descending: 'Descendente', descendingTitle: 'Organizar o filhos do tipo ${type} em decrescente', duplicateKey: 'chave duplicada', drag: 'Arraste para mover este campo (Alt+Shift+Arrows)', duplicateText: 'Duplicar', duplicateTitle: 'Duplicar campos selecionados (Ctrl+D)', duplicateField: 'Duplicar este campo (Ctrl+D)', duplicateFieldError: 'Nome do campo duplicado', empty: 'vazio', expandAll: 'Expandir todos campos', expandTitle: 'Clique para expandir/encolher este campo (Ctrl+E). \n' + 'Ctrl+Click para expandir/encolher incluindo todos os filhos.', formatTitle: 'Formate dados JSON, com recuo e feeds de linha adequados (Ctrl+\\)', insert: 'Inserir', insertTitle: 'Inserir um novo campo do tipo \'auto\' antes deste campo (Ctrl+Ins)', insertSub: 'Selecionar o tipo de campo a ser inserido', object: 'Objeto', ok: 'Ok', redo: 'Refazer (Ctrl+Shift+Z)', removeText: 'Remover', removeTitle: 'Remover campos selecionados (Ctrl+Del)', removeField: 'Remover este campo (Ctrl+Del)', repairTitle: 'Repare JSON: corrija aspas e caracteres de escape, remova comentários e notação JSONP, transforme objetos JavaScript em JSON.', selectNode: 'Selecione um nódulo...', showAll: 'mostrar todos', showMore: 'mostrar mais', showMoreStatus: 'exibindo ${visibleChilds} de ${totalChilds} itens.', sort: 'Organizar', sortTitle: 'Organizar os filhos deste ${type}', sortTitleShort: 'Organizar os filhos', sortFieldLabel: 'Campo:', sortDirectionLabel: 'Direção:', sortFieldTitle: 'Selecione um campo filho pelo qual ordenar o array ou objeto', sortAscending: 'Ascendente', sortAscendingTitle: 'Ordenar o campo selecionado por ordem ascendente', sortDescending: 'Descendente', sortDescendingTitle: 'Ordenar o campo selecionado por ordem descendente', string: 'Texto', transform: 'Transformar', transformTitle: 'Filtrar, ordenar ou transformar os filhos deste ${type}', transformTitleShort: 'Filtrar, ordenar ou transformar conteúdos', transformQueryTitle: 'Insira uma expressão JMESPath', transformWizardLabel: 'Assistente', transformWizardFilter: 'Filtro', transformWizardSortBy: 'Ordenar por', transformWizardSelectFields: 'Selecionar campos', transformQueryLabel: 'Expressão', transformPreviewLabel: 'Visualizar', type: 'Tipo', typeTitle: 'Mudar o tipo deste campo', openUrl: 'Ctrl+Click ou Ctrl+Enter para abrir link em nova janela', undo: 'Desfazer último ação (Ctrl+Z)', validationCannotMove: 'Não pode mover um campo como filho dele mesmo', autoType: 'Campo do tipo "auto". ' + 'O tipo do campo é determinao automaticamente a partir do seu valor ' + 'e pode ser texto, número, verdade/falso ou nulo.', objectType: 'Campo do tipo "objeto". ' + 'Um objeto contém uma lista de pares com chave e valor.', arrayType: 'Campo do tipo "lista". ' + 'Uma lista contem uma coleção de valores ordenados.', stringType: 'Campo do tipo "string". ' + 'Campo do tipo nao é determinado através do seu valor, ' + 'mas sempre retornara um texto.', examples: 'Exemplos', "default": 'Revelia', containsInvalidProperties: 'Contém propriedades inválidas', containsInvalidItems: 'Contém itens inválidos' }, tr: { array: 'Dizin', auto: 'Otomatik', appendText: 'Ekle', appendTitle: 'Bu alanın altına \'otomatik\' tipinde yeni bir alan ekle (Ctrl+Shift+Ins)', appendSubmenuTitle: 'Eklenecek alanın tipini seç', appendTitleAuto: '\'Otomatik\' tipinde yeni bir alan ekle (Ctrl+Shift+Ins)', ascending: 'Artan', ascendingTitle: '${type}\'ın alt tiplerini artan düzende sırala', actionsMenu: 'Aksiyon menüsünü açmak için tıklayın (Ctrl+M)', collapseAll: 'Tüm alanları kapat', descending: 'Azalan', descendingTitle: '${type}\'ın alt tiplerini azalan düzende sırala', drag: 'Bu alanı taşımak için sürükleyin (Alt+Shift+Arrows)', duplicateKey: 'Var olan anahtar', duplicateText: 'Aşağıya kopyala', duplicateTitle: 'Seçili alanlardan bir daha oluştur (Ctrl+D)', duplicateField: 'Bu alandan bir daha oluştur (Ctrl+D)', duplicateFieldError: 'Duplicate field name', cannotParseFieldError: 'Alan JSON\'a ayrıştırılamıyor', cannotParseValueError: 'JSON\'a değer ayrıştırılamıyor', empty: 'boş', expandAll: 'Tüm alanları aç', expandTitle: 'Bu alanı açmak/kapatmak için tıkla (Ctrl+E). \n' + 'Alt alanlarda dahil tüm alanları açmak için Ctrl+Click ', insert: 'Ekle', insertTitle: 'Bu alanın üstüne \'otomatik\' tipinde yeni bir alan ekle (Ctrl+Ins)', insertSub: 'Araya eklenecek alanın tipini seç', object: 'Nesne', ok: 'Tamam', redo: 'Yeniden yap (Ctrl+Shift+Z)', removeText: 'Kaldır', removeTitle: 'Seçilen alanları kaldır (Ctrl+Del)', removeField: 'Bu alanı kaldır (Ctrl+Del)', selectNode: 'Bir nesne seç...', showAll: 'tümünü göster', showMore: 'daha fazla göster', showMoreStatus: '${totalChilds} alanın ${visibleChilds} alt alanları gösteriliyor', sort: 'Sırala', sortTitle: '${type}\'ın alt alanlarını sırala', sortTitleShort: 'İçerikleri sırala', sortFieldLabel: 'Alan:', sortDirectionLabel: 'Yön:', sortFieldTitle: 'Diziyi veya nesneyi sıralamak için iç içe geçmiş alanı seçin', sortAscending: 'Artan', sortAscendingTitle: 'Seçili alanı artan düzende sırala', sortDescending: 'Azalan', sortDescendingTitle: 'Seçili alanı azalan düzende sırala', string: 'Karakter Dizisi', transform: 'Dönüştür', transformTitle: '${type}\'ın alt alanlarını filtrele, sırala veya dönüştür', transformTitleShort: 'İçerikleri filterele, sırala veya dönüştür', transformQueryTitle: 'JMESPath sorgusu gir', transformWizardLabel: 'Sihirbaz', transformWizardFilter: 'Filtre', transformWizardSortBy: 'Sırala', transformWizardSelectFields: 'Alanları seç', transformQueryLabel: 'Sorgu', transformPreviewLabel: 'Önizleme', type: 'Tip', typeTitle: 'Bu alanın tipini değiştir', openUrl: 'URL\'i yeni bir pencerede açmak için Ctrl+Click veya Ctrl+Enter', undo: 'Son değişikliği geri al (Ctrl+Z)', validationCannotMove: 'Alt alan olarak taşınamıyor', autoType: 'Alan tipi "otomatik". ' + 'Alan türü otomatik olarak değerden belirlenir' + 've bir dize, sayı, boolean veya null olabilir.', objectType: 'Alan tipi "nesne". ' + 'Bir nesne, sıralanmamış bir anahtar / değer çifti kümesi içerir.', arrayType: 'Alan tipi "dizi". ' + 'Bir dizi, düzenli değerler koleksiyonu içerir.', stringType: 'Alan tipi "karakter dizisi". ' + 'Alan türü değerden belirlenmez,' + 'ancak her zaman karakter dizisi olarak döndürülür.', modeCodeText: 'Kod', modeCodeTitle: 'Kod vurgulayıcıya geç', modeFormText: 'Form', modeFormTitle: 'Form düzenleyiciye geç', modeTextText: 'Metin', modeTextTitle: 'Düz metin düzenleyiciye geç', modeTreeText: 'Ağaç', modeTreeTitle: 'Ağaç düzenleyiciye geç', modeViewText: 'Görünüm', modeViewTitle: 'Ağaç görünümüne geç', examples: 'Örnekler', "default": 'Varsayılan', containsInvalidProperties: 'Geçersiz özellikler içeriyor', containsInvalidItems: 'Geçersiz öğeler içeriyor' }, ja: { array: '配列', auto: 'オート', appendText: '追加', appendTitle: '次のフィールドに"オート"のフィールドを追加 (Ctrl+Shift+Ins)', appendSubmenuTitle: '追加するフィールドの型を選択してください', appendTitleAuto: '"オート"のフィールドを追加 (Ctrl+Shift+Ins)', ascending: '昇順', ascendingTitle: '${type}の子要素を昇順に並べ替え', actionsMenu: 'クリックしてアクションメニューを開く (Ctrl+M)', collapseAll: 'すべてを折りたたむ', descending: '降順', descendingTitle: '${type}の子要素を降順に並べ替え', drag: 'ドラッグして選択中のフィールドを移動 (Alt+Shift+Arrows)', duplicateKey: '複製キー', duplicateText: '複製', duplicateTitle: '選択中のフィールドを複製 (Ctrl+D)', duplicateField: '選択中のフィールドを複製 (Ctrl+D)', duplicateFieldError: 'フィールド名が重複しています', cannotParseFieldError: 'JSONのフィールドを解析できません', cannotParseValueError: 'JSONの値を解析できません', empty: '空', expandAll: 'すべてを展開', expandTitle: 'クリックしてフィールドを展開/折りたたむ (Ctrl+E). \n' + 'Ctrl+Click ですべての子要素を展開/折りたたむ', insert: '挿入', insertTitle: '選択中のフィールドの前に新しいフィールドを挿入 (Ctrl+Ins)', insertSub: '挿入するフィールドの型を選択', object: 'オブジェクト', ok: '実行', redo: 'やり直す (Ctrl+Shift+Z)', removeText: '削除', removeTitle: '選択中のフィールドを削除 (Ctrl+Del)', removeField: '選択中のフィールドを削除 (Ctrl+Del)', selectNode: 'ノードを選択...', showAll: 'すべてを表示', showMore: 'もっと見る', showMoreStatus: '${totalChilds}個のアイテムのうち ${visibleChilds}個を表示しています。', sort: '並べ替え', sortTitle: '${type}の子要素を並べ替え', sortTitleShort: '並べ替え', sortFieldLabel: 'フィールド:', sortDirectionLabel: '順序:', sortFieldTitle: '配列またはオブジェクトを並び替えるためのフィールドを選択', sortAscending: '昇順', sortAscendingTitle: '選択中のフィールドを昇順に並び替え', sortDescending: '降順', sortDescendingTitle: '選択中のフィールドを降順に並び替え', string: '文字列', transform: '変換', transformTitle: '${type}の子要素をフィルター・並び替え・変換する', transformTitleShort: '内容をフィルター・並び替え・変換する', extract: '抽出', extractTitle: '${type}を抽出', transformQueryTitle: 'JMESPathクエリを入力', transformWizardLabel: 'ウィザード', transformWizardFilter: 'フィルター', transformWizardSortBy: '並び替え', transformWizardSelectFields: 'フィールドを選択', transformQueryLabel: 'クエリ', transformPreviewLabel: 'プレビュー', type: '型', typeTitle: '選択中のフィールドの型を変更', openUrl: 'Ctrl+Click または Ctrl+Enter で 新規ウィンドウでURLを開く', undo: '元に戻す (Ctrl+Z)', validationCannotMove: '子要素に移動できません ', autoType: 'オート: ' + 'フィールドの型は値から自動的に決定されます。 ' + '(文字列・数値・ブール・null)', objectType: 'オブジェクト: ' + 'オブジェクトは順序が決まっていないキーと値のペア組み合わせです。', arrayType: '配列: ' + '配列は順序が決まっている値の集合体です。', stringType: '文字列: ' + 'フィールド型は値から決定されませんが、' + '常に文字列として返されます。', modeCodeText: 'コードモード', modeCodeTitle: 'ハイライトモードに切り替え', modeFormText: 'フォームモード', modeFormTitle: 'フォームモードに切り替え', modeTextText: 'テキストモード', modeTextTitle: 'テキストモードに切り替え', modeTreeText: 'ツリーモード', modeTreeTitle: 'ツリーモードに切り替え', modeViewText: 'ビューモード', modeViewTitle: 'ビューモードに切り替え', modePreviewText: 'プレビュー', modePreviewTitle: 'プレビューに切り替え', examples: '例', "default": 'デフォルト', containsInvalidProperties: '無効なプロパティが含まれています', containsInvalidItems: '無効なアイテムが含まれています' }, 'fr-FR': { array: 'Liste', auto: 'Auto', appendText: 'Ajouter', appendTitle: 'Ajouter un champ de type \'auto\' après ce champ (Ctrl+Shift+Ins)', appendSubmenuTitle: 'Sélectionner le type du champ à ajouter', appendTitleAuto: 'Ajouter un champ de type \'auto\' (Ctrl+Shift+Ins)', ascending: 'Ascendant', ascendingTitle: 'Trier les enfants de ce ${type} par ordre ascendant', actionsMenu: 'Ouvrir le menu des actions (Ctrl+M)', collapseAll: 'Regrouper', descending: 'Descendant', descendingTitle: 'Trier les enfants de ce ${type} par ordre descendant', drag: 'Déplacer (Alt+Shift+Arrows)', duplicateKey: 'Dupliquer la clé', duplicateText: 'Dupliquer', duplicateTitle: 'Dupliquer les champs sélectionnés (Ctrl+D)', duplicateField: 'Dupliquer ce champ (Ctrl+D)', duplicateFieldError: 'Dupliquer le nom de champ', cannotParseFieldError: 'Champ impossible à parser en JSON', cannotParseValueError: 'Valeur impossible à parser en JSON', empty: 'vide', expandAll: 'Étendre', expandTitle: 'Étendre/regrouper ce champ (Ctrl+E). \n' + 'Ctrl+Click pour étendre/regrouper avec tous les champs.', insert: 'Insérer', insertTitle: 'Insérer un champ de type \'auto\' avant ce champ (Ctrl+Ins)', insertSub: 'Sélectionner le type de champ à insérer', object: 'Objet', ok: 'Ok', redo: 'Rejouer (Ctrl+Shift+Z)', removeText: 'Supprimer', removeTitle: 'Supprimer les champs sélectionnés (Ctrl+Del)', removeField: 'Supprimer ce champ (Ctrl+Del)', searchTitle: 'Rechercher champs et valeurs', searchNextResultTitle: 'Résultat suivant (Enter)', searchPreviousResultTitle: 'Résultat précédent (Shift + Enter)', selectNode: 'Sélectionner un nœud...', showAll: 'voir tout', showMore: 'voir plus', showMoreStatus: '${visibleChilds} éléments affichés de ${totalChilds}.', sort: 'Trier', sortTitle: 'Trier les champs de ce ${type}', sortTitleShort: 'Trier', sortFieldLabel: 'Champ:', sortDirectionLabel: 'Direction:', sortFieldTitle: 'Sélectionner les champs permettant de trier les listes et objet', sortAscending: 'Ascendant', sortAscendingTitle: 'Trier les champs sélectionnés par ordre ascendant', sortDescending: 'Descendant', sortDescendingTitle: 'Trier les champs sélectionnés par ordre descendant', string: 'Chaîne', transform: 'Transformer', transformTitle: 'Filtrer, trier, or transformer les enfants de ce ${type}', transformTitleShort: 'Filtrer, trier ou transformer le contenu', extract: 'Extraire', extractTitle: 'Extraire ce ${type}', transformQueryTitle: 'Saisir une requête JMESPath', transformWizardLabel: 'Assistant', transformWizardFilter: 'Filtrer', transformWizardSortBy: 'Trier par', transformWizardSelectFields: 'Sélectionner les champs', transformQueryLabel: 'Requête', transformPreviewLabel: 'Prévisualisation', type: 'Type', typeTitle: 'Changer le type de ce champ', openUrl: 'Ctrl+Click ou Ctrl+Enter pour ouvrir l\'url dans une autre fenêtre', undo: 'Annuler la dernière action (Ctrl+Z)', validationCannotMove: 'Cannot move a field into a child of itself', autoType: 'Champe de type "auto". ' + 'Ce type de champ est automatiquement déterminé en fonction de la valeur ' + 'et peut être de type "chaîne", "nombre", "booléen" ou null.', objectType: 'Champ de type "objet". ' + 'Un objet contient un ensemble non ordonné de paires clé/valeur.', arrayType: 'Champ de type "liste". ' + 'Une liste contient une collection ordonnée de valeurs.', stringType: 'Champ de type "chaîne". ' + 'Ce type de champ n\'est pas déterminé en fonction de la valeur, ' + 'mais retourne systématiquement une chaîne de caractères.', modeEditorTitle: 'Changer mode d\'édition', modeCodeText: 'Code', modeCodeTitle: 'Activer surlignage code', modeFormText: 'Formulaire', modeFormTitle: 'Activer formulaire', modeTextText: 'Texte', modeTextTitle: 'Activer éditeur texte', modeTreeText: 'Arbre', modeTreeTitle: 'Activer éditeur arbre', modeViewText: 'Lecture seule', modeViewTitle: 'Activer vue arbre', modePreviewText: 'Prévisualisation', modePreviewTitle: 'Activer mode prévisualiser', examples: 'Exemples', "default": 'Défaut', containsInvalidProperties: 'Contient des propriétés non valides', containsInvalidItems: 'Contient des éléments invalides' }, de: { array: 'Auflistung', auto: 'Auto', appendText: 'anhängen', appendTitle: 'Fügen Sie nach diesem Feld ein neues Feld mit dem Typ \'auto\' ein (Strg+Umschalt+Ein)', appendSubmenuTitle: 'Wählen Sie den Typ des neuen Feldes', appendTitleAuto: 'Ein neues Feld vom Typ \'auto\' hinzufügen (Strg+Umschalt+Ein)', ascending: 'Aufsteigend', ascendingTitle: 'Sortieren Sie die Elemente dieses ${type} in aufsteigender Reihenfolge', actionsMenu: 'Klicken Sie zum Öffnen des Aktionsmenüs (Strg+M)', cannotParseFieldError: 'Feld kann nicht in JSON geparst werden', cannotParseValueError: 'Wert kann nicht in JSON geparst werden', collapseAll: 'Alle Felder zuklappen', compactTitle: 'JSON-Daten verdichten, alle Leerzeichen entfernen (Strg+Umschalt+\\)', descending: 'Absteigend', descendingTitle: 'Sortieren Sie die Elemente dieses ${type} in absteigender Reihenfolge', drag: 'Ziehen, um dieses Feld zu verschieben (Alt+Umschalt+Pfeile)', duplicateKey: 'Doppelter Schlüssel', duplicateText: 'Duplikat', duplicateTitle: 'Ausgewählte Felder duplizieren (Strg+D)', duplicateField: 'Dieses Feld duplizieren (Strg+D)', duplicateFieldError: 'Doppelter Feldname', empty: 'leer', expandAll: 'Alle Felder anzeigen', expandTitle: 'Klicken Sie, um dieses Feld zu erweitern/zu kollabieren (Strg+E). \nStrg+Klicken Sie, um dieses Feld einschließlich aller Elemente zu erweitern/zu kollabieren.', formatTitle: 'JSON-Daten mit korrekter Einrückung und Zeilenvorschüben formatieren (Strg+\\)', insert: 'einfügen', insertTitle: 'Fügen Sie vor diesem Feld ein neues Feld mit dem Typ \'auto\' ein (Strg+Einfg)', insertSub: 'Wählen Sie den Typ des neuen Feldes', object: 'Objekt', ok: 'Ok', redo: 'Wiederholen (Strg+Umschalt+Z)', removeText: 'entfernen', removeTitle: 'Ausgewählte Felder entfernen (Strg+Entf)', removeField: 'Dieses Feld entfernen (Strg+Entf)', repairTitle: 'JSON reparieren: Anführungszeichen und Escape-Zeichen korrigieren, Kommentare und JSONP-Notation entfernen, JavaScript-Objekte in JSON umwandeln.', searchTitle: 'Suchfelder und Werte', searchNextResultTitle: 'Nächstes Ergebnis (Enter)', searchPreviousResultTitle: 'Vorheriges Ergebnis (Umschalt + Eingabe)', selectNode: 'Wählen Sie einen Knoten aus...', showAll: 'alle anzeigen', showMore: 'mehr anzeigen', showMoreStatus: 'Anzeige von ${visibleChilds} von ${totalChilds}-Elementen.', sort: 'Sortieren', sortTitle: 'Sortieren Sie die Elemente dieses ${type}', sortTitleShort: 'Inhalt sortieren', sortFieldLabel: 'Feld:', sortDirectionLabel: 'Richtung:', sortFieldTitle: 'Wählen Sie das verschachtelte Feld, nach dem das Array oder Objekt sortiert werden soll.', sortAscending: 'Aufsteigend', sortAscendingTitle: 'Sortieren Sie das ausgewählte Feld in aufsteigender Reihenfolge', sortDescending: 'Absteigend', sortDescendingTitle: 'Sortieren Sie das ausgewählte Feld in absteigender Reihenfolge', string: 'Zeichenfolge', transform: 'Verwandeln', transformTitle: 'Die Elemente dieses ${type} filtern, sortieren oder transformieren', transformTitleShort: 'Inhalte filtern, sortieren oder transformieren', extract: 'Auszug', extractTitle: 'Extrahieren Sie diesen ${type}', transformQueryTitle: 'Eine JMESPath-Abfrage eingeben', transformWizardLabel: 'Zauberer', transformWizardFilter: 'Filter', transformWizardSortBy: 'Sortieren nach', transformWizardSelectFields: 'Felder auswählen', transformQueryLabel: 'Anfrage', transformPreviewLabel: 'Vorschau', type: 'Geben Sie ein.', typeTitle: 'Ändern Sie den Typ dieses Feldes', openUrl: 'Strg+Klicken oder Strg+Eingabe, um die URL in einem neuen Fenster zu öffnen', undo: 'Letzte Aktion rückgängig machen (Strg+Z)', validationCannotMove: 'Kann ein Feld nicht in ein Kind seiner selbst verschieben', autoType: 'Feldtyp "auto". Der Feldtyp wird automatisch aus dem Wert bestimmt und kann ein String, eine Zahl, boolesch oder null sein.', objectType: 'Feldtyp "Objekt". Ein Objekt enthält eine ungeordnete Menge von Schlüssel/Wert-Paaren.', arrayType: 'Feldtyp "Array". Ein Array enthält eine geordnete Sammlung von Werten.', stringType: 'Feldtyp "Zeichenfolge". Der Feldtyp wird nicht aus dem Wert bestimmt, sondern immer als Zeichenfolge zurückgegeben.', modeEditorTitle: 'Editor-Modus umschalten', modeCodeText: 'Code', modeCodeTitle: 'Umschalten auf Code-Highlighter', modeFormText: 'Formular', modeFormTitle: 'Zum Formular-Editor wechseln', modeTextText: 'Text', modeTextTitle: 'Zum Editor für einfachen Text wechseln', modeTreeText: 'Baum', modeTreeTitle: 'Zum Baum-Editor wechseln', modeViewText: 'Siehe', modeViewTitle: 'Zur Baumansicht wechseln', modePreviewText: 'Vorschau', modePreviewTitle: 'In den Vorschau-Modus wechseln', examples: 'Beispiele', "default": 'Standardmäßig', containsInvalidProperties: 'Enthält ungültige Eigenschaften', containsInvalidItems: 'Enthält ungültige Elemente' } }; var _defaultLang = 'en'; var userLang = typeof navigator !== 'undefined' ? navigator.language || navigator.userLanguage : undefined; var _lang = _locales.find(function (l) { return l === userLang; }) || _defaultLang; function setLanguage(lang) { if (!lang) { return; } var langFound = _locales.find(function (l) { return l === lang; }); if (langFound) { _lang = langFound; } else { console.error('Language not found'); } } function setLanguages(languages) { if (!languages) { return; } var _loop = function _loop(language) { var langFound = _locales.find(function (l) { return l === language; }); if (!langFound) { _locales.push(language); } _defs[language] = Object.assign({}, _defs[_defaultLang], _defs[language], languages[language]); }; for (var language in languages) { _loop(language); } } function translate(key, data, lang) { if (!lang) { lang = _lang; } var text = _defs[lang][key] || _defs[_defaultLang][key] || key; if (data) { for (var dataKey in data) { text = text.replace('${' + dataKey + '}', data[dataKey]); } } return text; } /***/ }), /***/ 6056: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "r": function() { return /* binding */ createQuery; }, /* harmony export */ "J": function() { return /* binding */ executeQuery; } /* harmony export */ }); /* harmony import */ var jmespath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5156); /* harmony import */ var jmespath__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jmespath__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9791); /** * Build a JMESPath query based on query options coming from the wizard * @param {JSON} json The JSON document for which to build the query. * Used for context information like determining * the type of values (string or number) * @param {QueryOptions} queryOptions * @return {string} Returns a query (as string) */ function createQuery(json, queryOptions) { var sort = queryOptions.sort, filter = queryOptions.filter, projection = queryOptions.projection; var query = ''; if (filter) { var examplePath = filter.field !== '@' ? ['0'].concat((0,_util__WEBPACK_IMPORTED_MODULE_1__.parsePath)('.' + filter.field)) : ['0']; var exampleValue = (0,_util__WEBPACK_IMPORTED_MODULE_1__.get)(json, examplePath); var value1 = typeof exampleValue === 'string' ? filter.value : (0,_util__WEBPACK_IMPORTED_MODULE_1__.parseString)(filter.value); query += '[? ' + filter.field + ' ' + filter.relation + ' ' + '`' + JSON.stringify(value1) + '`' + ']'; } else { query += Array.isArray(json) ? '[*]' : '@'; } if (sort) { if (sort.direction === 'desc') { query += ' | reverse(sort_by(@, &' + sort.field + '))'; } else { query += ' | sort_by(@, &' + sort.field + ')'; } } if (projection) { if (query[query.length - 1] !== ']') { query += ' | [*]'; } if (projection.fields.length === 1) { query += '.' + projection.fields[0]; } else if (projection.fields.length > 1) { query += '.{' + projection.fields.map(function (value) { var parts = value.split('.'); var last = parts[parts.length - 1]; return last + ': ' + value; }).join(', ') + '}'; } else {// values.length === 0 // ignore } } return query; } /** * Execute a JMESPath query * @param {JSON} json * @param {string} query * @return {JSON} Returns the transformed JSON */ function executeQuery(json, query) { return jmespath__WEBPACK_IMPORTED_MODULE_0___default().search(json, query); } /***/ }), /***/ 4987: /***/ (function() { if (typeof Element !== 'undefined') { // Polyfill for array remove (function () { function polyfill(item) { if ('remove' in item) { return; } Object.defineProperty(item, 'remove', { configurable: true, enumerable: true, writable: true, value: function remove() { if (this.parentNode !== undefined) { this.parentNode.removeChild(this); } } }); } if (typeof window.Element !== 'undefined') { polyfill(window.Element.prototype); } if (typeof window.CharacterData !== 'undefined') { polyfill(window.CharacterData.prototype); } if (typeof window.DocumentType !== 'undefined') { polyfill(window.DocumentType.prototype); } })(); } // simple polyfill for Array.findIndex if (!Array.prototype.findIndex) { // eslint-disable-next-line no-extend-native Object.defineProperty(Array.prototype, 'findIndex', { value: function value(predicate) { for (var i = 0; i < this.length; i++) { var element = this[i]; if (predicate.call(this, element, i, this)) { return i; } } return -1; }, configurable: true, writable: true }); } // Polyfill for Array.find if (!Array.prototype.find) { // eslint-disable-next-line no-extend-native Object.defineProperty(Array.prototype, 'find', { value: function value(predicate) { var i = this.findIndex(predicate); return this[i]; }, configurable: true, writable: true }); } // Polyfill for String.trim if (!String.prototype.trim) { // eslint-disable-next-line no-extend-native String.prototype.trim = function () { return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }; } /***/ }), /***/ 341: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "previewModeMixins": function() { return /* binding */ previewModeMixins; } }); // EXTERNAL MODULE: ./node_modules/jsonrepair/lib/cjs/index-commonjs.js var index_commonjs = __webpack_require__(8909); var index_commonjs_default = /*#__PURE__*/__webpack_require__.n(index_commonjs); // EXTERNAL MODULE: ./src/js/constants.js var constants = __webpack_require__(4188); // EXTERNAL MODULE: ./src/js/ErrorTable.js var ErrorTable = __webpack_require__(6436); // EXTERNAL MODULE: ./src/js/FocusTracker.js var FocusTracker = __webpack_require__(2474); ;// CONCATENATED MODULE: ./src/js/History.js function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * Keep track on any history, be able * @param {function} onChange * @param {function} calculateItemSize * @param {number} limit Maximum size of all items in history * @constructor */ var History = /*#__PURE__*/function () { function History(onChange, calculateItemSize, limit) { _classCallCheck(this, History); this.onChange = onChange; this.calculateItemSize = calculateItemSize || function () { return 1; }; this.limit = limit; this.items = []; this.index = -1; } _createClass(History, [{ key: "add", value: function add(item) { // limit number of items in history so that the total size doesn't // always keep at least one item in memory while (this._calculateHistorySize() > this.limit && this.items.length > 1) { this.items.shift(); this.index--; } // cleanup any redo action that are not valid anymore this.items = this.items.slice(0, this.index + 1); this.items.push(item); this.index++; this.onChange(); } }, { key: "_calculateHistorySize", value: function _calculateHistorySize() { var calculateItemSize = this.calculateItemSize; var totalSize = 0; this.items.forEach(function (item) { totalSize += calculateItemSize(item); }); return totalSize; } }, { key: "undo", value: function undo() { if (!this.canUndo()) { return; } this.index--; this.onChange(); return this.items[this.index]; } }, { key: "redo", value: function redo() { if (!this.canRedo()) { return; } this.index++; this.onChange(); return this.items[this.index]; } }, { key: "canUndo", value: function canUndo() { return this.index > 0; } }, { key: "canRedo", value: function canRedo() { return this.index < this.items.length - 1; } }, { key: "clear", value: function clear() { this.items = []; this.index = -1; this.onChange(); } }]); return History; }(); // EXTERNAL MODULE: ./src/js/i18n.js var i18n = __webpack_require__(7907); // EXTERNAL MODULE: ./src/js/jmespathQuery.js var jmespathQuery = __webpack_require__(6056); // EXTERNAL MODULE: ./src/js/ModeSwitcher.js var ModeSwitcher = __webpack_require__(6617); // EXTERNAL MODULE: ./src/js/showSortModal.js var showSortModal = __webpack_require__(6210); // EXTERNAL MODULE: ./src/js/showTransformModal.js + 1 modules var showTransformModal = __webpack_require__(2558); // EXTERNAL MODULE: ./src/js/textmode.js + 1 modules var textmode = __webpack_require__(5956); // EXTERNAL MODULE: ./src/js/util.js var util = __webpack_require__(9791); ;// CONCATENATED MODULE: ./src/js/previewmode.js var previewmode_textmode = textmode.textModeMixins[0].mixin; // create a mixin with the functions for text mode var previewmode = {}; /** * Create a JSON document preview, suitable for processing of large documents * @param {Element} container * @param {Object} [options] Object with options. See docs for details. * @private */ previewmode.create = function (container) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (typeof options.statusBar === 'undefined') { options.statusBar = true; } // setting default for previewmode options.mainMenuBar = options.mainMenuBar !== false; options.enableSort = options.enableSort !== false; options.enableTransform = options.enableTransform !== false; options.createQuery = options.createQuery || jmespathQuery/* createQuery */.r; options.executeQuery = options.executeQuery || jmespathQuery/* executeQuery */.J; this.options = options; // indentation if (typeof options.indentation === 'number') { this.indentation = Number(options.indentation); } else { this.indentation = 2; // number of spaces } // language (0,i18n/* setLanguages */.cC)(this.options.languages); (0,i18n/* setLanguage */.m0)(this.options.language); // determine mode this.mode = 'preview'; var me = this; this.container = container; this.dom = {}; this.json = undefined; this.text = ''; // TODO: JSON Schema support // create a debounced validate function this._debouncedValidate = (0,util.debounce)(this.validate.bind(this), this.DEBOUNCE_INTERVAL); this.width = container.clientWidth; this.height = container.clientHeight; this.frame = document.createElement('div'); this.frame.className = 'jsoneditor jsoneditor-mode-preview'; this.frame.onclick = function (event) { // prevent default submit action when the editor is located inside a form event.preventDefault(); }; // setting the FocusTracker on 'this.frame' to track the editor's focus event var focusTrackerConfig = { target: this.frame, onFocus: this.options.onFocus || null, onBlur: this.options.onBlur || null }; this.frameFocusTracker = new FocusTracker/* FocusTracker */.R(focusTrackerConfig); this.content = document.createElement('div'); this.content.className = 'jsoneditor-outer'; this.dom.busy = document.createElement('div'); this.dom.busy.className = 'jsoneditor-busy'; this.dom.busyContent = document.createElement('span'); this.dom.busyContent.textContent = 'busy...'; this.dom.busy.appendChild(this.dom.busyContent); this.content.appendChild(this.dom.busy); this.dom.previewContent = document.createElement('pre'); this.dom.previewContent.className = 'jsoneditor-preview'; this.dom.previewText = document.createTextNode(''); this.dom.previewContent.appendChild(this.dom.previewText); this.content.appendChild(this.dom.previewContent); if (this.options.mainMenuBar) { (0,util.addClassName)(this.content, 'has-main-menu-bar'); // create menu this.menu = document.createElement('div'); this.menu.className = 'jsoneditor-menu'; this.frame.appendChild(this.menu); // create format button var buttonFormat = document.createElement('button'); buttonFormat.type = 'button'; buttonFormat.className = 'jsoneditor-format'; buttonFormat.title = (0,i18n/* translate */.Iu)('formatTitle'); this.menu.appendChild(buttonFormat); buttonFormat.onclick = function handleFormat() { me.executeWithBusyMessage(function () { try { me.format(); } catch (err) { me._onError(err); } }, 'formatting...'); }; // create compact button var buttonCompact = document.createElement('button'); buttonCompact.type = 'button'; buttonCompact.className = 'jsoneditor-compact'; buttonCompact.title = (0,i18n/* translate */.Iu)('compactTitle'); this.menu.appendChild(buttonCompact); buttonCompact.onclick = function handleCompact() { me.executeWithBusyMessage(function () { try { me.compact(); } catch (err) { me._onError(err); } }, 'compacting...'); }; // create sort button if (this.options.enableSort) { var _sort = document.createElement('button'); _sort.type = 'button'; _sort.className = 'jsoneditor-sort'; _sort.title = (0,i18n/* translate */.Iu)('sortTitleShort'); _sort.onclick = function () { me._showSortModal(); }; this.menu.appendChild(_sort); } // create transform button if (this.options.enableTransform) { var transform = document.createElement('button'); transform.type = 'button'; transform.title = (0,i18n/* translate */.Iu)('transformTitleShort'); transform.className = 'jsoneditor-transform'; transform.onclick = function () { me._showTransformModal(); }; this.dom.transform = transform; this.menu.appendChild(transform); } // create repair button var buttonRepair = document.createElement('button'); buttonRepair.type = 'button'; buttonRepair.className = 'jsoneditor-repair'; buttonRepair.title = (0,i18n/* translate */.Iu)('repairTitle'); this.menu.appendChild(buttonRepair); buttonRepair.onclick = function () { if (me.json === undefined) { // only repair if we don't have valid JSON me.executeWithBusyMessage(function () { try { me.repair(); } catch (err) { me._onError(err); } }, 'repairing...'); } }; // create history and undo/redo buttons if (this.options.history !== false) { // default option value is true var onHistoryChange = function onHistoryChange() { me.dom.undo.disabled = !me.history.canUndo(); me.dom.redo.disabled = !me.history.canRedo(); }; var calculateItemSize = function calculateItemSize(item) { return (// times two to account for the json object item.text.length * 2 ); }; this.history = new History(onHistoryChange, calculateItemSize, constants/* PREVIEW_HISTORY_LIMIT */.oW); // create undo button var undo = document.createElement('button'); undo.type = 'button'; undo.className = 'jsoneditor-undo jsoneditor-separator'; undo.title = (0,i18n/* translate */.Iu)('undo'); undo.onclick = function () { var action = me.history.undo(); if (action) { me._applyHistory(action); } }; this.menu.appendChild(undo); this.dom.undo = undo; // create redo button var redo = document.createElement('button'); redo.type = 'button'; redo.className = 'jsoneditor-redo'; redo.title = (0,i18n/* translate */.Iu)('redo'); redo.onclick = function () { var action = me.history.redo(); if (action) { me._applyHistory(action); } }; this.menu.appendChild(redo); this.dom.redo = redo; // force enabling/disabling the undo/redo button this.history.onChange(); } // create mode box if (this.options && this.options.modes && this.options.modes.length) { this.modeSwitcher = new ModeSwitcher/* ModeSwitcher */.x(this.menu, this.options.modes, this.options.mode, function onSwitch(mode) { // switch mode and restore focus me.setMode(mode); me.modeSwitcher.focus(); }); } } this.errorTable = new ErrorTable/* ErrorTable */.Q({ errorTableVisible: true, onToggleVisibility: function onToggleVisibility() { me.validate(); }, onFocusLine: null, onChangeHeight: function onChangeHeight(height) { // TODO: change CSS to using flex box, remove setting height using JavaScript var statusBarHeight = me.dom.statusBar ? me.dom.statusBar.clientHeight : 0; var totalHeight = height + statusBarHeight + 1; me.content.style.marginBottom = -totalHeight + 'px'; me.content.style.paddingBottom = totalHeight + 'px'; } }); this.frame.appendChild(this.content); this.frame.appendChild(this.errorTable.getErrorTable()); this.container.appendChild(this.frame); if (options.statusBar) { (0,util.addClassName)(this.content, 'has-status-bar'); var statusBar = document.createElement('div'); this.dom.statusBar = statusBar; statusBar.className = 'jsoneditor-statusbar'; this.frame.appendChild(statusBar); this.dom.fileSizeInfo = document.createElement('span'); this.dom.fileSizeInfo.className = 'jsoneditor-size-info'; this.dom.fileSizeInfo.innerText = ''; statusBar.appendChild(this.dom.fileSizeInfo); this.dom.arrayInfo = document.createElement('span'); this.dom.arrayInfo.className = 'jsoneditor-size-info'; this.dom.arrayInfo.innerText = ''; statusBar.appendChild(this.dom.arrayInfo); statusBar.appendChild(this.errorTable.getErrorCounter()); statusBar.appendChild(this.errorTable.getWarningIcon()); statusBar.appendChild(this.errorTable.getErrorIcon()); } this._renderPreview(); this.setSchema(this.options.schema, this.options.schemaRefs); }; previewmode._renderPreview = function () { var text = this.getText(); this.dom.previewText.nodeValue = (0,util.limitCharacters)(text, constants/* MAX_PREVIEW_CHARACTERS */.WF); if (this.dom.fileSizeInfo) { this.dom.fileSizeInfo.innerText = 'Size: ' + (0,util.formatSize)(text.length); } if (this.dom.arrayInfo) { if (Array.isArray(this.json)) { this.dom.arrayInfo.innerText = 'Array: ' + this.json.length + ' items'; } else { this.dom.arrayInfo.innerText = ''; } } }; /** * Handle a change: * - Validate JSON schema * - Send a callback to the onChange listener if provided * @private */ previewmode._onChange = function () { // validate JSON schema (if configured) this._debouncedValidate(); // trigger the onChange callback if (this.options.onChange) { try { this.options.onChange(); } catch (err) { console.error('Error in onChange callback: ', err); } } // trigger the onChangeJSON callback if (this.options.onChangeJSON) { try { this.options.onChangeJSON(this.get()); } catch (err) { console.error('Error in onChangeJSON callback: ', err); } } // trigger the onChangeText callback if (this.options.onChangeText) { try { this.options.onChangeText(this.getText()); } catch (err) { console.error('Error in onChangeText callback: ', err); } } }; /** * Open a sort modal * @private */ previewmode._showSortModal = function () { var me = this; function onSort(json, sortedBy) { if (Array.isArray(json)) { var sortedArray = (0,util.sort)(json, sortedBy.path, sortedBy.direction); me.sortedBy = sortedBy; me._setAndFireOnChange(sortedArray); } if ((0,util.isObject)(json)) { var sortedObject = (0,util.sortObjectKeys)(json, sortedBy.direction); me.sortedBy = sortedBy; me._setAndFireOnChange(sortedObject); } } this.executeWithBusyMessage(function () { var container = me.options.modalAnchor || constants/* DEFAULT_MODAL_ANCHOR */.qD; var json = me.get(); me._renderPreview(); // update array count (0,showSortModal.showSortModal)(container, json, function (sortedBy) { me.executeWithBusyMessage(function () { onSort(json, sortedBy); }, 'sorting...'); }, me.sortedBy); }, 'parsing...'); }; /** * Open a transform modal * @private */ previewmode._showTransformModal = function () { var _this = this; this.executeWithBusyMessage(function () { var _this$options = _this.options, createQuery = _this$options.createQuery, executeQuery = _this$options.executeQuery, modalAnchor = _this$options.modalAnchor, queryDescription = _this$options.queryDescription; var json = _this.get(); _this._renderPreview(); // update array count (0,showTransformModal.showTransformModal)({ container: modalAnchor || constants/* DEFAULT_MODAL_ANCHOR */.qD, json: json, queryDescription: queryDescription, // can be undefined createQuery: createQuery, executeQuery: executeQuery, onTransform: function onTransform(query) { _this.executeWithBusyMessage(function () { var updatedJson = executeQuery(json, query); _this._setAndFireOnChange(updatedJson); }, 'transforming...'); } }); }, 'parsing...'); }; /** * Destroy the editor. Clean up DOM, event listeners, and web workers. */ previewmode.destroy = function () { if (this.frame && this.container && this.frame.parentNode === this.container) { this.container.removeChild(this.frame); } if (this.modeSwitcher) { this.modeSwitcher.destroy(); this.modeSwitcher = null; } this._debouncedValidate = null; if (this.history) { this.history.clear(); this.history = null; } // Removing the FocusTracker set to track the editor's focus event this.frameFocusTracker.destroy(); }; /** * Compact the code in the text editor */ previewmode.compact = function () { var json = this.get(); var text = JSON.stringify(json); // we know that in this case the json is still the same, so we pass json too this._setTextAndFireOnChange(text, json); }; /** * Format the code in the text editor */ previewmode.format = function () { var json = this.get(); var text = JSON.stringify(json, null, this.indentation); // we know that in this case the json is still the same, so we pass json too this._setTextAndFireOnChange(text, json); }; /** * Repair the code in the text editor */ previewmode.repair = function () { var text = this.getText(); try { var repairedText = index_commonjs_default()(text); this._setTextAndFireOnChange(repairedText); } catch (err) {// repair was not successful, do nothing } }; /** * Set focus to the editor */ previewmode.focus = function () { // we don't really have a place to focus, // let's focus on the transform button this.dom.transform.focus(); }; /** * Set json data in the editor * @param {*} json */ previewmode.set = function (json) { if (this.history) { this.history.clear(); } this._set(json); }; /** * Update data. Same as calling `set` in text/code mode. * @param {*} json */ previewmode.update = function (json) { this._set(json); }; /** * Set json data * @param {*} json */ previewmode._set = function (json) { this.text = undefined; this.json = json; this._renderPreview(); this._pushHistory(); // validate JSON schema this._debouncedValidate(); }; previewmode._setAndFireOnChange = function (json) { this._set(json); this._onChange(); }; /** * Get json data * @return {*} json */ previewmode.get = function () { if (this.json === undefined) { var text = this.getText(); this.json = (0,util.parse)(text); // this can throw an error } return this.json; }; /** * Get the text contents of the editor * @return {String} jsonText */ previewmode.getText = function () { if (this.text === undefined) { this.text = JSON.stringify(this.json, null, this.indentation); if (this.options.escapeUnicode === true) { this.text = (0,util.escapeUnicodeChars)(this.text); } } return this.text; }; /** * Set the text contents of the editor * @param {String} jsonText */ previewmode.setText = function (jsonText) { if (this.history) { this.history.clear(); } this._setText(jsonText); }; /** * Update the text contents * @param {string} jsonText */ previewmode.updateText = function (jsonText) { // don't update if there are no changes if (this.getText() === jsonText) { return; } this._setText(jsonText); }; /** * Set the text contents of the editor * @param {string} jsonText * @param {*} [json] Optional JSON instance of the text * @private */ previewmode._setText = function (jsonText, json) { if (this.options.escapeUnicode === true) { this.text = (0,util.escapeUnicodeChars)(jsonText); } else { this.text = jsonText; } this.json = json; this._renderPreview(); if (this.json === undefined) { var me = this; this.executeWithBusyMessage(function () { try { // force parsing the json now, else it will be done in validate without feedback me.json = me.get(); me._renderPreview(); me._pushHistory(); } catch (err) {// no need to throw an error, validation will show an error } }, 'parsing...'); } else { this._pushHistory(); } this._debouncedValidate(); }; /** * Set text and fire onChange callback * @param {string} jsonText * @param {*} [json] Optional JSON instance of the text * @private */ previewmode._setTextAndFireOnChange = function (jsonText, json) { this._setText(jsonText, json); this._onChange(); }; /** * Apply history to the current state * @param {{json?: JSON, text?: string}} action * @private */ previewmode._applyHistory = function (action) { this.json = action.json; this.text = action.text; this._renderPreview(); this._debouncedValidate(); }; /** * Push the current state to history * @private */ previewmode._pushHistory = function () { if (!this.history) { return; } var action = { text: this.text, json: this.json }; this.history.add(action); }; /** * Execute a heavy, blocking action. * Before starting the action, show a message on screen like "parsing..." * @param {function} fn * @param {string} message */ previewmode.executeWithBusyMessage = function (fn, message) { var size = this.getText().length; if (size > constants/* SIZE_LARGE */.EX) { var me = this; (0,util.addClassName)(me.frame, 'busy'); me.dom.busyContent.innerText = message; setTimeout(function () { fn(); (0,util.removeClassName)(me.frame, 'busy'); me.dom.busyContent.innerText = ''; }, 100); } else { fn(); } }; // TODO: refactor into composable functions instead of this shaky mixin-like structure previewmode.validate = previewmode_textmode.validate; previewmode._renderErrors = previewmode_textmode._renderErrors; // define modes var previewModeMixins = [{ mode: 'preview', mixin: previewmode, data: 'json' }]; /***/ }), /***/ 6210: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "showSortModal": function() { return /* binding */ showSortModal; } /* harmony export */ }); /* harmony import */ var picomodal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(483); /* harmony import */ var picomodal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(picomodal__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7907); /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9791); /** * Show advanced sorting modal * @param {HTMLElement} container The container where to center * the modal and create an overlay * @param {JSON} json The JSON data to be sorted. * @param {function} onSort Callback function, invoked with * an object containing the selected * path and direction * @param {Object} options * Available options: * - {string} path The selected path * - {'asc' | 'desc'} direction The selected direction */ function showSortModal(container, json, onSort, options) { var paths = Array.isArray(json) ? (0,_util__WEBPACK_IMPORTED_MODULE_2__.getChildPaths)(json) : ['']; var selectedPath = options && options.path && (0,_util__WEBPACK_IMPORTED_MODULE_2__.contains)(paths, options.path) ? options.path : paths[0]; var selectedDirection = options && options.direction || 'asc'; var content = '
    ' + '
    ' + (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('sort') + '
    ' + '
    ' + '' + '' + '' + ' ' + ' ' + '' + '' + ' ' + ' ' + '' + '' + '' + '' + '' + '
    ' + (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('sortFieldLabel') + ' ' + '
    ' + ' ' + '
    ' + '
    ' + (0,_i18n__WEBPACK_IMPORTED_MODULE_1__/* .translate */ .Iu)('sortDirectionLabel') + ' ' + '
    ' + '' + '' + '
    ' + '
    ' + ' ' + '
    ' + '
    ' + '
    '; picomodal__WEBPACK_IMPORTED_MODULE_0___default()({ parent: container, content: content, overlayClass: 'jsoneditor-modal-overlay', overlayStyles: { backgroundColor: 'rgb(1,1,1)', opacity: 0.3 }, modalClass: 'jsoneditor-modal jsoneditor-modal-sort' }).afterCreate(function (modal) { var form = modal.modalElem().querySelector('form'); var ok = modal.modalElem().querySelector('#ok'); var field = modal.modalElem().querySelector('#field'); var direction = modal.modalElem().querySelector('#direction'); function preprocessPath(path) { return path === '' ? '@' : path[0] === '.' ? path.slice(1) : path; } paths.forEach(function (path) { var option = document.createElement('option'); option.text = preprocessPath(path); option.value = path; field.appendChild(option); }); function setDirection(value) { direction.value = value; direction.className = 'jsoneditor-button-group jsoneditor-button-group-value-' + direction.value; } field.value = selectedPath || paths[0]; setDirection(selectedDirection || 'asc'); direction.onclick = function (event) { setDirection(event.target.getAttribute('data-value')); }; ok.onclick = function (event) { event.preventDefault(); event.stopPropagation(); modal.close(); onSort({ path: field.value, direction: direction.value }); }; if (form) { // form is not available when JSONEditor is created inside a form form.onsubmit = ok.onclick; } }).afterClose(function (modal) { modal.destroy(); }).show(); } /***/ }), /***/ 2558: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "showTransformModal": function() { return /* binding */ showTransformModal; } }); // EXTERNAL MODULE: ./node_modules/picomodal/src/picoModal.js var picoModal = __webpack_require__(483); var picoModal_default = /*#__PURE__*/__webpack_require__.n(picoModal); // EXTERNAL MODULE: ./src/js/assets/selectr/selectr.js var selectr = __webpack_require__(3879); var selectr_default = /*#__PURE__*/__webpack_require__.n(selectr); // EXTERNAL MODULE: ./src/js/i18n.js var i18n = __webpack_require__(7907); ;// CONCATENATED MODULE: ./src/js/jsonUtils.js /** * Convert part of a JSON object to a JSON string. * Use case is to stringify a small part of a large JSON object so you can see * a preview. * * @param {*} value * The value to convert to a JSON string. * * @param {number | string | null} [space] * A String or Number object that's used to insert white space into the output * JSON string for readability purposes. If this is a Number, it indicates the * number of space characters to use as white space; this number is capped at 10 * if it's larger than that. Values less than 1 indicate that no space should be * used. If this is a String, the string (or the first 10 characters of the string, * if it's longer than that) is used as white space. If this parameter is not * provided (or is null), no white space is used. * * @param {number} [limit] Maximum size of the string output. * * @returns {string | undefined} Returns the string representation of the JSON object. */ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function stringifyPartial(value, space, limit) { var _space; // undefined by default if (typeof space === 'number') { if (space > 10) { _space = repeat(' ', 10); } else if (space >= 1) { _space = repeat(' ', space); } // else ignore } else if (typeof space === 'string' && space !== '') { _space = space; } var output = stringifyValue(value, _space, '', limit); return output.length > limit ? slice(output, limit) + '...' : output; } /** * Stringify a value * @param {*} value * @param {string} space * @param {string} indent * @param {number} limit * @return {string | undefined} */ function stringifyValue(value, space, indent, limit) { // boolean, null, number, string, or date if (typeof value === 'boolean' || value instanceof Boolean || value === null || typeof value === 'number' || value instanceof Number || typeof value === 'string' || value instanceof String || value instanceof Date) { return JSON.stringify(value); } // array if (Array.isArray(value)) { return stringifyArray(value, space, indent, limit); } // object (test lastly!) if (value && _typeof(value) === 'object') { return stringifyObject(value, space, indent, limit); } return undefined; } /** * Stringify an array * @param {Array} array * @param {string} space * @param {string} indent * @param {number} limit * @return {string} */ function stringifyArray(array, space, indent, limit) { var childIndent = space ? indent + space : undefined; var str = space ? '[\n' : '['; for (var i = 0; i < array.length; i++) { var item = array[i]; if (space) { str += childIndent; } if (typeof item !== 'undefined' && typeof item !== 'function') { str += stringifyValue(item, space, childIndent, limit); } else { str += 'null'; } if (i < array.length - 1) { str += space ? ',\n' : ','; } // stop as soon as we're exceeding the limit if (str.length > limit) { return str + '...'; } } str += space ? '\n' + indent + ']' : ']'; return str; } /** * Stringify an object * @param {Object} object * @param {string} space * @param {string} indent * @param {number} limit * @return {string} */ function stringifyObject(object, space, indent, limit) { var childIndent = space ? indent + space : undefined; var first = true; var str = space ? '{\n' : '{'; if (typeof object.toJSON === 'function') { return stringifyValue(object.toJSON(), space, indent, limit); } for (var key in object) { if (jsonUtils_hasOwnProperty(object, key)) { var value = object[key]; if (first) { first = false; } else { str += space ? ',\n' : ','; } str += space ? childIndent + '"' + key + '": ' : '"' + key + '":'; str += stringifyValue(value, space, childIndent, limit); // stop as soon as we're exceeding the limit if (str.length > limit) { return str + '...'; } } } str += space ? '\n' + indent + '}' : '}'; return str; } /** * Repeat a string a number of times. * Simple linear solution, we only need up to 10 iterations in practice * @param {string} text * @param {number} times * @return {string} */ function repeat(text, times) { var res = ''; while (times-- > 0) { res += text; } return res; } /** * Limit the length of text * @param {string} text * @param {number} [limit] * @return {string} */ function slice(text, limit) { return typeof limit === 'number' ? text.slice(0, limit) : text; } /** * Test whether some text contains a JSON array, i.e. the first * non-white space character is a [ * @param {string} jsonText * @return {boolean} */ function containsArray(jsonText) { return /^\s*\[/.test(jsonText); } function jsonUtils_hasOwnProperty(object, key) { return Object.prototype.hasOwnProperty.call(object, key); } // EXTERNAL MODULE: ./src/js/util.js var util = __webpack_require__(9791); // EXTERNAL MODULE: ./src/js/constants.js var constants = __webpack_require__(4188); ;// CONCATENATED MODULE: ./src/js/showTransformModal.js var DEFAULT_DESCRIPTION = 'Enter a JMESPath query to filter, sort, or transform the JSON data.
    ' + 'To learn JMESPath, go to the interactive tutorial.'; /** * Show advanced filter and transform modal using JMESPath * @param {Object} params * @property {HTMLElement} container The container where to center * the modal and create an overlay * @property {JSON} json The json data to be transformed * @property {string} [queryDescription] Optional custom description explaining * the transform functionality * @property {function} createQuery Function called to create a query * from the wizard form * @property {function} executeQuery Execute a query for the preview pane * @property {function} onTransform Callback invoked with the created * query as callback */ function showTransformModal(_ref) { var container = _ref.container, json = _ref.json, _ref$queryDescription = _ref.queryDescription, queryDescription = _ref$queryDescription === void 0 ? DEFAULT_DESCRIPTION : _ref$queryDescription, createQuery = _ref.createQuery, executeQuery = _ref.executeQuery, onTransform = _ref.onTransform; var value = json; var content = '