formiojs-eorion 0.1.55 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,7 +81,7 @@ eval("\n\n__webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js
81
81
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
82
82
 
83
83
  "use strict";
84
- eval("\n\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.array.slice.js */ \"./node_modules/core-js/modules/es.array.slice.js\");\n__webpack_require__(/*! core-js/modules/es.function.name.js */ \"./node_modules/core-js/modules/es.function.name.js\");\n__webpack_require__(/*! core-js/modules/es.array.from.js */ \"./node_modules/core-js/modules/es.array.from.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = exports.GlobalFormio = void 0;\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.match.js */ \"./node_modules/core-js/modules/es.string.match.js\");\n__webpack_require__(/*! core-js/modules/es.string.search.js */ \"./node_modules/core-js/modules/es.string.search.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.constructor.js */ \"./node_modules/core-js/modules/es.regexp.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ \"./node_modules/core-js/modules/es.regexp.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.array.join.js */ \"./node_modules/core-js/modules/es.array.join.js\");\n__webpack_require__(/*! core-js/modules/es.array.includes.js */ \"./node_modules/core-js/modules/es.array.includes.js\");\n__webpack_require__(/*! core-js/modules/es.string.includes.js */ \"./node_modules/core-js/modules/es.string.includes.js\");\n__webpack_require__(/*! core-js/modules/es.object.assign.js */ \"./node_modules/core-js/modules/es.object.assign.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.array.filter.js */ \"./node_modules/core-js/modules/es.array.filter.js\");\n__webpack_require__(/*! core-js/modules/es.array.sort.js */ \"./node_modules/core-js/modules/es.array.sort.js\");\n__webpack_require__(/*! core-js/modules/es.array.map.js */ \"./node_modules/core-js/modules/es.array.map.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nvar _nativePromiseOnly = _interopRequireDefault(__webpack_require__(/*! native-promise-only */ \"./node_modules/native-promise-only/lib/npo.src.js\"));\nvar _fetchPonyfill2 = _interopRequireDefault(__webpack_require__(/*! fetch-ponyfill */ \"./node_modules/fetch-ponyfill/build/fetch-browser.js\"));\nvar _EventEmitter = _interopRequireDefault(__webpack_require__(/*! ./EventEmitter */ \"./lib/EventEmitter.js\"));\nvar _browserCookies = _interopRequireDefault(__webpack_require__(/*! browser-cookies */ \"./node_modules/browser-cookies/src/browser-cookies.js\"));\nvar _providers = _interopRequireDefault(__webpack_require__(/*! ./providers */ \"./lib/providers/index.js\"));\nvar _intersection2 = _interopRequireDefault(__webpack_require__(/*! lodash/intersection */ \"./node_modules/lodash/intersection.js\"));\nvar _get2 = _interopRequireDefault(__webpack_require__(/*! lodash/get */ \"./node_modules/lodash/get.js\"));\nvar _cloneDeep2 = _interopRequireDefault(__webpack_require__(/*! lodash/cloneDeep */ \"./node_modules/lodash/cloneDeep.js\"));\nvar _defaults2 = _interopRequireDefault(__webpack_require__(/*! lodash/defaults */ \"./node_modules/lodash/defaults.js\"));\nvar _utils = __webpack_require__(/*! ./utils/utils */ \"./lib/utils/utils.js\");\nvar _jwtDecode = _interopRequireDefault(__webpack_require__(/*! jwt-decode */ \"./node_modules/jwt-decode/build/jwt-decode.esm.js\"));\n__webpack_require__(/*! ./polyfills */ \"./lib/polyfills/index.js\");\nvar _CDN = _interopRequireDefault(__webpack_require__(/*! ./CDN */ \"./lib/CDN.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nvar _fetchPonyfill = (0, _fetchPonyfill2.default)({\n Promise: _nativePromiseOnly.default\n }),\n fetch = _fetchPonyfill.fetch,\n Headers = _fetchPonyfill.Headers;\nvar isBoolean = function isBoolean(val) {\n return _typeof(val) === _typeof(true);\n};\nvar isNil = function isNil(val) {\n return val === null || val === undefined;\n};\nvar isObject = function isObject(val) {\n return val && _typeof(val) === 'object';\n};\nfunction cloneResponse(response) {\n var copy = (0, _cloneDeep2.default)(response);\n if (Array.isArray(response)) {\n copy.skip = response.skip;\n copy.limit = response.limit;\n copy.serverCount = response.serverCount;\n }\n return copy;\n}\n\n/**\n * The Formio interface class.\n *\n * let formio = new Formio('https://examples.form.io/example');\n */\nvar Formio = /*#__PURE__*/function () {\n /* eslint-disable max-statements */\n function Formio(path) {\n var _this = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck(this, Formio);\n // Ensure we have an instance of Formio.\n if (!(this instanceof Formio)) {\n return new Formio(path);\n }\n\n // Initialize our variables.\n this.base = '';\n this.projectsUrl = '';\n this.projectUrl = '';\n this.projectId = '';\n this.roleUrl = '';\n this.rolesUrl = '';\n this.roleId = '';\n this.formUrl = '';\n this.formsUrl = '';\n this.formId = '';\n this.submissionsUrl = '';\n this.submissionUrl = '';\n this.submissionId = '';\n this.actionsUrl = '';\n this.actionId = '';\n this.actionUrl = '';\n this.vsUrl = '';\n this.vId = '';\n this.vUrl = '';\n this.query = '';\n\n // Store the original path and options.\n this.path = path;\n this.options = options;\n if (options.useSessionToken) {\n Formio.useSessionToken(options);\n }\n if (options.hasOwnProperty('base')) {\n this.base = options.base;\n } else if (Formio.baseUrl) {\n this.base = Formio.baseUrl;\n } else if (typeof window !== 'undefined') {\n this.base = window.location.href.match(/http[s]?:\\/\\/api./)[0];\n }\n if (!path) {\n // Allow user to create new projects if this was instantiated without\n // a url\n this.projectUrl = Formio.projectUrl || \"\".concat(this.base, \"/project\");\n this.projectsUrl = \"\".concat(this.base, \"/project\");\n this.projectId = false;\n this.query = '';\n return;\n }\n if (options.hasOwnProperty('project')) {\n this.projectUrl = options.project;\n }\n var project = this.projectUrl || Formio.projectUrl;\n var projectRegEx = /(^|\\/)(project)($|\\/[^/]+)/;\n var isProjectUrl = path.search(projectRegEx) !== -1;\n\n // The baseURL is the same as the projectUrl, and does not contain \"/project/MONGO_ID\" in\n // its domain. This is almost certainly against the Open Source server.\n if (project && this.base === project && !isProjectUrl) {\n this.noProject = true;\n this.projectUrl = this.base;\n }\n\n // Normalize to an absolute path.\n if (path.indexOf('http') !== 0 && path.indexOf('//') !== 0) {\n path = this.base + path;\n }\n var hostparts = this.getUrlParts(path);\n var parts = [];\n var hostName = hostparts[1] + hostparts[2];\n path = hostparts.length > 3 ? hostparts[3] : '';\n var queryparts = path.split('?');\n if (queryparts.length > 1) {\n path = queryparts[0];\n this.query = \"?\".concat(queryparts[1]);\n }\n\n // Register a specific path.\n var registerPath = function registerPath(name, base) {\n _this[\"\".concat(name, \"sUrl\")] = \"\".concat(base, \"/\").concat(name);\n var regex = new RegExp(\"/\".concat(name, \"/([^/]+)\"));\n if (path.search(regex) !== -1) {\n parts = path.match(regex);\n _this[\"\".concat(name, \"Url\")] = parts ? base + parts[0] : '';\n _this[\"\".concat(name, \"Id\")] = parts.length > 1 ? parts[1] : '';\n base += parts[0];\n }\n return base;\n };\n\n // Register an array of items.\n var registerItems = function registerItems(items, base, staticBase) {\n for (var i in items) {\n if (items.hasOwnProperty(i)) {\n var item = items[i];\n if (Array.isArray(item)) {\n registerItems(item, base, true);\n } else {\n var newBase = registerPath(item, base);\n base = staticBase ? base : newBase;\n }\n }\n }\n };\n if (!this.projectUrl || this.projectUrl === this.base) {\n // If a project uses Subdirectories path type, we need to specify a projectUrl\n if (!this.projectUrl && !isProjectUrl && Formio.pathType === 'Subdirectories') {\n var regex = \"^\".concat(hostName.replace(/\\//g, '\\\\/'), \".[^/]+\");\n var match = project.match(new RegExp(regex));\n this.projectUrl = match ? match[0] : hostName;\n } else {\n this.projectUrl = hostName;\n }\n }\n // Check if we have a specified path type.\n var isNotSubdomainType = false;\n if (Formio.pathType) {\n isNotSubdomainType = Formio.pathType !== 'Subdomains';\n }\n if (!this.noProject) {\n // Determine the projectUrl and projectId\n if (isProjectUrl) {\n // Get project id as project/:projectId.\n registerItems(['project'], hostName);\n path = path.replace(projectRegEx, '');\n } else if (hostName === this.base) {\n // Get project id as first part of path (subdirectory).\n if (hostparts.length > 3 && path.split('/').length > 1) {\n var isFile = path.match(/.json/);\n var pathParts = path.split('/');\n if (isFile) {\n this.projectUrl = hostName;\n } else {\n pathParts.shift(); // Throw away the first /.\n this.projectId = pathParts.shift();\n path = \"/\".concat(pathParts.join('/'));\n this.projectUrl = \"\".concat(hostName, \"/\").concat(this.projectId);\n }\n }\n } else {\n // Get project id from subdomain.\n if (hostparts.length > 2 && (hostparts[2].split('.').length > 2 || hostName.includes('localhost')) && !isNotSubdomainType) {\n this.projectUrl = hostName;\n this.projectId = hostparts[2].split('.')[0];\n }\n }\n this.projectsUrl = this.projectsUrl || \"\".concat(this.base, \"/project\");\n }\n\n // Configure Role urls and role ids.\n registerItems(['role'], this.projectUrl);\n\n // Configure Form urls and form ids.\n if (/(^|\\/)(form)($|\\/)/.test(path)) {\n registerItems(['form', ['submission', 'action', 'v']], this.projectUrl);\n } else {\n var subRegEx = new RegExp('/(submission|action|v)($|/.*)');\n var subs = path.match(subRegEx);\n this.pathType = subs && subs.length > 1 ? subs[1] : '';\n path = path.replace(subRegEx, '');\n path = path.replace(/\\/$/, '');\n this.formsUrl = \"\".concat(this.projectUrl, \"/form\");\n this.formUrl = path ? this.projectUrl + path : '';\n this.formId = path.replace(/^\\/+|\\/+$/g, '');\n var items = ['submission', 'action', 'v'];\n for (var i in items) {\n if (items.hasOwnProperty(i)) {\n var item = items[i];\n this[\"\".concat(item, \"sUrl\")] = \"\".concat(this.projectUrl + path, \"/\").concat(item);\n if (this.pathType === item && subs.length > 2 && subs[2]) {\n this[\"\".concat(item, \"Id\")] = subs[2].replace(/^\\/+|\\/+$/g, '');\n this[\"\".concat(item, \"Url\")] = this.projectUrl + path + subs[0];\n }\n }\n }\n }\n\n // Set the app url if it is not set.\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = this.projectUrl;\n }\n }\n /* eslint-enable max-statements */\n _createClass(Formio, [{\n key: \"delete\",\n value: function _delete(type, opts) {\n var _id = \"\".concat(type, \"Id\");\n var _url = \"\".concat(type, \"Url\");\n if (!this[_id]) {\n return _nativePromiseOnly.default.reject('Nothing to delete');\n }\n Formio.cache = {};\n return this.makeRequest(type, this[_url], 'delete', null, opts);\n }\n }, {\n key: \"index\",\n value: function index(type, query, opts) {\n var _url = \"\".concat(type, \"Url\");\n query = query || '';\n if (query && isObject(query)) {\n query = \"?\".concat(Formio.serialize(query.params));\n }\n return this.makeRequest(type, this[_url] + query, 'get', null, opts);\n }\n }, {\n key: \"save\",\n value: function save(type, data, opts) {\n var _id = \"\".concat(type, \"Id\");\n var _url = \"\".concat(type, \"Url\");\n var method = this[_id] || data._id ? 'put' : 'post';\n var reqUrl = this[_id] ? this[_url] : this[\"\".concat(type, \"sUrl\")];\n if (!this[_id] && data._id && method === 'put' && !reqUrl.includes(data._id)) {\n reqUrl += \"/\".concat(data._id);\n }\n Formio.cache = {};\n return this.makeRequest(type, reqUrl + this.query, method, data, opts);\n }\n }, {\n key: \"load\",\n value: function load(type, query, opts) {\n var _id = \"\".concat(type, \"Id\");\n var _url = \"\".concat(type, \"Url\");\n if (query && isObject(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = this.query ? \"\".concat(this.query, \"&\").concat(query) : \"?\".concat(query);\n } else {\n query = this.query;\n }\n if (!this[_id]) {\n return _nativePromiseOnly.default.reject(\"Missing \".concat(_id));\n }\n var url = this[_url] + query;\n if (type === 'form' && !isNaN(parseInt(this.vId)) && parseInt(this.vId) !== 0) {\n url += url.match(/\\?/) ? '&' : '?';\n url += \"formRevision=\".concat(this.vId);\n }\n return this.makeRequest(type, url, 'get', null, opts);\n }\n }, {\n key: \"makeRequest\",\n value: function makeRequest() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return Formio.makeRequest.apply(Formio, [this].concat(args));\n }\n }, {\n key: \"loadProject\",\n value: function loadProject(query, opts) {\n return this.load('project', query, opts);\n }\n }, {\n key: \"saveProject\",\n value: function saveProject(data, opts) {\n return this.save('project', data, opts);\n }\n }, {\n key: \"deleteProject\",\n value: function deleteProject(opts) {\n return this.delete('project', opts);\n }\n }, {\n key: \"loadRole\",\n value: function loadRole(opts) {\n return this.load('role', null, opts);\n }\n }, {\n key: \"saveRole\",\n value: function saveRole(data, opts) {\n return this.save('role', data, opts);\n }\n }, {\n key: \"deleteRole\",\n value: function deleteRole(opts) {\n return this.delete('role', opts);\n }\n }, {\n key: \"loadRoles\",\n value: function loadRoles(opts) {\n return this.index('roles', null, opts);\n }\n }, {\n key: \"loadForm\",\n value: function loadForm(query, opts) {\n var _this2 = this;\n return this.load('form', query, opts).then(function (currentForm) {\n // Check to see if there isn't a number in vId.\n if (!currentForm.revisions || isNaN(parseInt(_this2.vId))) {\n return currentForm;\n }\n // If a submission already exists but form is marked to load current version of form.\n if (currentForm.revisions === 'current' && _this2.submissionId) {\n return currentForm;\n }\n // eslint-disable-next-line eqeqeq\n if (currentForm._vid == _this2.vId || currentForm.revisionId === _this2.vId) {\n return currentForm;\n }\n // If they specified a revision form, load the revised form components.\n if (query && isObject(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = _this2.query ? \"\".concat(_this2.query, \"&\").concat(query) : \"?\".concat(query);\n } else {\n query = _this2.query;\n }\n return _this2.makeRequest('form', _this2.vUrl + query, 'get', null, opts).then(function (revisionForm) {\n currentForm._vid = revisionForm._vid;\n currentForm.components = revisionForm.components;\n currentForm.settings = revisionForm.settings;\n currentForm.revisionId = revisionForm.revisionId;\n // Using object.assign so we don't cross polinate multiple form loads.\n return Object.assign({}, currentForm);\n })\n // If we couldn't load the revision, just return the original form.\n .catch(function () {\n return Object.assign({}, currentForm);\n });\n });\n }\n }, {\n key: \"saveForm\",\n value: function saveForm(data, opts) {\n return this.save('form', data, opts);\n }\n }, {\n key: \"deleteForm\",\n value: function deleteForm(opts) {\n return this.delete('form', opts);\n }\n }, {\n key: \"loadForms\",\n value: function loadForms(query, opts) {\n return this.index('forms', query, opts);\n }\n }, {\n key: \"loadSubmission\",\n value: function loadSubmission(query, opts) {\n var _this3 = this;\n return this.load('submission', query, opts).then(function (submission) {\n _this3.vId = submission._frid || submission._fvid;\n _this3.vUrl = \"\".concat(_this3.formUrl, \"/v/\").concat(_this3.vId);\n return submission;\n });\n }\n }, {\n key: \"saveSubmission\",\n value: function saveSubmission(data, opts) {\n if (!isNaN(parseInt(this.vId))) {\n data._fvid = this.vId;\n }\n return this.save('submission', data, opts);\n }\n }, {\n key: \"deleteSubmission\",\n value: function deleteSubmission(opts) {\n return this.delete('submission', opts);\n }\n }, {\n key: \"loadSubmissions\",\n value: function loadSubmissions(query, opts) {\n return this.index('submissions', query, opts);\n }\n }, {\n key: \"loadAction\",\n value: function loadAction(query, opts) {\n return this.load('action', query, opts);\n }\n }, {\n key: \"saveAction\",\n value: function saveAction(data, opts) {\n return this.save('action', data, opts);\n }\n }, {\n key: \"deleteAction\",\n value: function deleteAction(opts) {\n return this.delete('action', opts);\n }\n }, {\n key: \"loadActions\",\n value: function loadActions(query, opts) {\n return this.index('actions', query, opts);\n }\n }, {\n key: \"availableActions\",\n value: function availableActions() {\n return this.makeRequest('availableActions', \"\".concat(this.formUrl, \"/actions\"));\n }\n }, {\n key: \"actionInfo\",\n value: function actionInfo(name) {\n return this.makeRequest('actionInfo', \"\".concat(this.formUrl, \"/actions/\").concat(name));\n }\n }, {\n key: \"isObjectId\",\n value: function isObjectId(id) {\n var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');\n return checkForHexRegExp.test(id);\n }\n }, {\n key: \"getProjectId\",\n value: function getProjectId() {\n if (!this.projectId) {\n return _nativePromiseOnly.default.resolve('');\n }\n if (this.isObjectId(this.projectId)) {\n return _nativePromiseOnly.default.resolve(this.projectId);\n } else {\n return this.loadProject().then(function (project) {\n return project._id;\n });\n }\n }\n }, {\n key: \"getFormId\",\n value: function getFormId() {\n if (!this.formId) {\n return _nativePromiseOnly.default.resolve('');\n }\n if (this.isObjectId(this.formId)) {\n return _nativePromiseOnly.default.resolve(this.formId);\n } else {\n return this.loadForm().then(function (form) {\n return form._id;\n });\n }\n }\n }, {\n key: \"currentUser\",\n value: function currentUser(options) {\n return Formio.currentUser(this, options);\n }\n }, {\n key: \"accessInfo\",\n value: function accessInfo() {\n return Formio.accessInfo(this);\n }\n\n /**\n * Returns the JWT token for this instance.\n *\n * @return {*}\n */\n }, {\n key: \"getToken\",\n value: function getToken(options) {\n return Formio.getToken(Object.assign({\n formio: this\n }, this.options, options));\n }\n\n /**\n * Sets the JWT token for this instance.\n *\n * @return {*}\n */\n }, {\n key: \"setToken\",\n value: function setToken(token, options) {\n return Formio.setToken(token, Object.assign({\n formio: this\n }, this.options, options));\n }\n\n /**\n * Returns a temporary authentication token for single purpose token generation.\n */\n }, {\n key: \"getTempToken\",\n value: function getTempToken(expire, allowed, options) {\n var token = Formio.getToken(options);\n if (!token) {\n return _nativePromiseOnly.default.reject('You must be authenticated to generate a temporary auth token.');\n }\n var authUrl = Formio.authUrl || this.projectUrl;\n return this.makeRequest('tempToken', \"\".concat(authUrl, \"/token\"), 'GET', null, {\n ignoreCache: true,\n header: new Headers({\n 'x-expire': expire,\n 'x-allow': allowed\n })\n });\n }\n\n /**\n * Get a download url for a submission PDF of this submission.\n *\n * @return {*}\n */\n }, {\n key: \"getDownloadUrl\",\n value: function getDownloadUrl(form) {\n var _this4 = this;\n if (!this.submissionId) {\n return _nativePromiseOnly.default.resolve('');\n }\n if (!form) {\n // Make sure to load the form first.\n return this.loadForm().then(function (_form) {\n if (!_form) {\n return '';\n }\n return _this4.getDownloadUrl(_form);\n });\n }\n var apiUrl = \"/project/\".concat(form.project);\n apiUrl += \"/form/\".concat(form._id);\n apiUrl += \"/submission/\".concat(this.submissionId);\n var postfix = form.submissionRevisions && form.settings.changeLog ? '/download/changelog' : '/download';\n apiUrl += postfix;\n var download = this.base + apiUrl;\n return new _nativePromiseOnly.default(function (resolve, reject) {\n _this4.getTempToken(3600, \"GET:\".concat(apiUrl)).then(function (tempToken) {\n download += \"?token=\".concat(tempToken.key);\n resolve(download);\n }, function () {\n resolve(download);\n }).catch(reject);\n });\n }\n }, {\n key: \"uploadFile\",\n value: function uploadFile(storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback) {\n var _this5 = this;\n var requestArgs = {\n provider: storage,\n method: 'upload',\n file: file,\n fileName: fileName,\n dir: dir\n };\n fileKey = fileKey || 'file';\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('fileRequest', requestArgs).then(function (result) {\n if (storage && isNil(result)) {\n var Provider = _providers.default.getProvider('storage', storage);\n if (Provider) {\n var provider = new Provider(_this5);\n if (uploadStartCallback) {\n uploadStartCallback();\n }\n return provider.uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback);\n } else {\n throw 'Storage provider not found';\n }\n }\n return result || {\n url: ''\n };\n });\n });\n return Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n }\n }, {\n key: \"downloadFile\",\n value: function downloadFile(file, options) {\n var _this6 = this;\n var requestArgs = {\n method: 'download',\n file: file\n };\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('fileRequest', requestArgs).then(function (result) {\n if (file.storage && isNil(result)) {\n var Provider = _providers.default.getProvider('storage', file.storage);\n if (Provider) {\n var provider = new Provider(_this6);\n return provider.downloadFile(file, options);\n } else {\n throw 'Storage provider not found';\n }\n }\n return result || {\n url: ''\n };\n });\n });\n return Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n }\n }, {\n key: \"deleteFile\",\n value: function deleteFile(file, options) {\n var _this7 = this;\n var requestArgs = {\n method: 'delete',\n file: file\n };\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('fileRequest', requestArgs).then(function (result) {\n if (file.storage && isNil(result)) {\n var Provider = _providers.default.getProvider('storage', file.storage);\n if (Provider) {\n var provider = new Provider(_this7);\n return provider.deleteFile(file, options);\n } else {\n throw 'Storage provider not found';\n }\n }\n return result || {\n url: ''\n };\n });\n });\n return Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n }\n\n /**\n * Returns the user permissions to a form and submission.\n *\n * @param user - The user or current user if undefined. For anonymous, use \"null\"\n * @param form - The form or current form if undefined. For no form check, use \"null\"\n * @param submission - The submisison or \"index\" if undefined.\n *\n * @return {create: boolean, read: boolean, edit: boolean, delete: boolean}\n */\n }, {\n key: \"userPermissions\",\n value: function userPermissions(user, form, submission) {\n return _nativePromiseOnly.default.all([form !== undefined ? _nativePromiseOnly.default.resolve(form) : this.loadForm(), user !== undefined ? _nativePromiseOnly.default.resolve(user) : this.currentUser(), submission !== undefined || !this.submissionId ? _nativePromiseOnly.default.resolve(submission) : this.loadSubmission(), this.accessInfo()]).then(function (results) {\n var form = results.shift();\n var user = results.shift() || {\n _id: false,\n roles: []\n };\n var submission = results.shift();\n var access = results.shift();\n var permMap = {\n create: 'create',\n read: 'read',\n update: 'edit',\n delete: 'delete'\n };\n var perms = {\n user: user,\n form: form,\n access: access,\n create: false,\n read: false,\n edit: false,\n delete: false\n };\n for (var roleName in access.roles) {\n if (access.roles.hasOwnProperty(roleName)) {\n var role = access.roles[roleName];\n if (role.default && user._id === false) {\n // User is anonymous. Add the anonymous role.\n user.roles.push(role._id);\n } else if (role.admin && user.roles.indexOf(role._id) !== -1) {\n perms.create = true;\n perms.read = true;\n perms.delete = true;\n perms.edit = true;\n return perms;\n }\n }\n }\n if (form && form.submissionAccess) {\n for (var i = 0; i < form.submissionAccess.length; i++) {\n var permission = form.submissionAccess[i];\n var _permission$type$spli = permission.type.split('_'),\n _permission$type$spli2 = _slicedToArray(_permission$type$spli, 2),\n perm = _permission$type$spli2[0],\n scope = _permission$type$spli2[1];\n if (['create', 'read', 'update', 'delete'].includes(perm)) {\n if ((0, _intersection2.default)(permission.roles, user.roles).length) {\n perms[permMap[perm]] = scope === 'all' || !submission || user._id === submission.owner;\n }\n }\n }\n }\n // check for Group Permissions\n if (submission) {\n // we would anyway need to loop through components for create permission, so we'll do that for all of them\n (0, _utils.eachComponent)(form.components, function (component, path) {\n if (component && component.defaultPermission) {\n var value = (0, _get2.default)(submission.data, path);\n // make it work for single-select Group and multi-select Group\n var groups = Array.isArray(value) ? value : [value];\n groups.forEach(function (group) {\n if (group && group._id &&\n // group id is present\n user.roles.indexOf(group._id) > -1 // user has group id in his roles\n ) {\n if (component.defaultPermission === 'read') {\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'create') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'write') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n }\n if (component.defaultPermission === 'admin') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n perms[permMap.delete] = true;\n }\n }\n });\n }\n });\n }\n return perms;\n });\n }\n\n /**\n * Determine if the current user can submit a form.\n * @return {*}\n */\n }, {\n key: \"canSubmit\",\n value: function canSubmit() {\n var _this8 = this;\n return this.userPermissions().then(function (perms) {\n // If there is user and they cannot create, then check anonymous user permissions.\n if (!perms.create && Formio.getUser()) {\n return _this8.userPermissions(null).then(function (anonPerms) {\n if (anonPerms.create) {\n Formio.setUser(null);\n return true;\n }\n return false;\n });\n }\n return perms.create;\n });\n }\n }, {\n key: \"getUrlParts\",\n value: function getUrlParts(url) {\n return Formio.getUrlParts(url, this);\n }\n }], [{\n key: \"useSessionToken\",\n value: function useSessionToken(options) {\n var tokenName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"Token\");\n var token = localStorage.getItem(tokenName);\n if (token) {\n localStorage.removeItem(tokenName);\n sessionStorage.setItem(tokenName, token);\n }\n var userName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"User\");\n var user = localStorage.getItem(userName);\n if (user) {\n localStorage.removeItem(userName);\n sessionStorage.setItem(userName, user);\n }\n localStorage.setItem('useSessionToken', true);\n }\n }, {\n key: \"loadProjects\",\n value: function loadProjects(query, opts) {\n query = query || '';\n if (isObject(query)) {\n query = \"?\".concat(Formio.serialize(query.params));\n }\n return Formio.makeStaticRequest(\"\".concat(Formio.baseUrl, \"/project\").concat(query), 'GET', null, opts);\n }\n }, {\n key: \"getUrlParts\",\n value: function getUrlParts(url, formio) {\n var base = formio && formio.base ? formio.base : Formio.baseUrl;\n var regex = '^(http[s]?:\\\\/\\\\/)';\n if (base && url.indexOf(base) === 0) {\n regex += \"(\".concat(base.replace(/^http[s]?:\\/\\//, ''), \")\");\n } else {\n regex += '([^/]+)';\n }\n regex += '($|\\\\/.*)';\n return url.match(new RegExp(regex));\n }\n }, {\n key: \"serialize\",\n value: function serialize(obj, _interpolate) {\n var str = [];\n var interpolate = function interpolate(item) {\n return _interpolate ? _interpolate(item) : item;\n };\n for (var p in obj) {\n if (obj.hasOwnProperty(p)) {\n str.push(\"\".concat(encodeURIComponent(p), \"=\").concat(encodeURIComponent(interpolate(obj[p]))));\n }\n }\n return str.join('&');\n }\n }, {\n key: \"getRequestArgs\",\n value: function getRequestArgs(formio, type, url, method, data, opts) {\n method = (method || 'GET').toUpperCase();\n if (!opts || !isObject(opts)) {\n opts = {};\n }\n var requestArgs = {\n url: url,\n method: method,\n data: data || null,\n opts: opts\n };\n if (type) {\n requestArgs.type = type;\n }\n if (formio) {\n requestArgs.formio = formio;\n }\n return requestArgs;\n }\n }, {\n key: \"makeStaticRequest\",\n value: function makeStaticRequest(url, method, data, opts) {\n var requestArgs = Formio.getRequestArgs(null, '', url, method, data, opts);\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('staticRequest', requestArgs).then(function (result) {\n if (isNil(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n });\n });\n return Formio.pluginAlter('wrapStaticRequestPromise', request, requestArgs);\n }\n }, {\n key: \"makeRequest\",\n value: function makeRequest(formio, type, url, method, data, opts) {\n if (!formio) {\n return Formio.makeStaticRequest(url, method, data, opts);\n }\n var requestArgs = Formio.getRequestArgs(formio, type, url, method, data, opts);\n requestArgs.opts = requestArgs.opts || {};\n requestArgs.opts.formio = formio;\n\n //for Formio requests default Accept and Content-type headers\n if (!requestArgs.opts.headers) {\n requestArgs.opts.headers = {};\n }\n requestArgs.opts.headers = (0, _defaults2.default)(requestArgs.opts.headers, {\n 'Accept': 'application/json',\n 'Content-type': 'application/json'\n });\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('request', requestArgs).then(function (result) {\n if (isNil(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n });\n });\n return Formio.pluginAlter('wrapRequestPromise', request, requestArgs);\n }\n }, {\n key: \"request\",\n value: function request(url, method, data, header, opts) {\n if (!url) {\n return _nativePromiseOnly.default.reject('No url provided');\n }\n var _Formio = Formio;\n method = (method || 'GET').toUpperCase();\n\n // For reverse compatibility, if they provided the ignoreCache parameter,\n // then change it back to the options format where that is a parameter.\n if (isBoolean(opts)) {\n opts = {\n ignoreCache: opts\n };\n }\n if (!opts || !isObject(opts)) {\n opts = {};\n }\n\n // Generate a cachekey.\n var cacheKey = btoa(encodeURI(url));\n\n // Get the cached promise to save multiple loads.\n if (!opts.ignoreCache && method === 'GET' && _Formio.cache.hasOwnProperty(cacheKey)) {\n return _nativePromiseOnly.default.resolve(cloneResponse(_Formio.cache[cacheKey]));\n }\n\n // Set up and fetch request\n var headers = header || new Headers(opts.headers || {\n 'Accept': 'application/json',\n 'Content-type': 'application/json'\n });\n var token = _Formio.getToken(opts);\n if (token && !opts.noToken) {\n headers.append('x-jwt-token', token);\n }\n\n // The fetch-ponyfill can't handle a proper Headers class anymore. Change it back to an object.\n var headerObj = {};\n headers.forEach(function (value, name) {\n headerObj[name] = value;\n });\n var options = {\n method: method,\n headers: headerObj,\n mode: 'cors'\n };\n if (data) {\n options.body = JSON.stringify(data);\n if (method === \"POST\") {\n options.body = data;\n }\n }\n\n // Allow plugins to alter the options.\n options = _Formio.pluginAlter('requestOptions', options, url);\n if (options.namespace || _Formio.namespace) {\n opts.namespace = options.namespace || _Formio.namespace;\n }\n var requestToken = options.headers['x-jwt-token'];\n var result = _Formio.pluginAlter('wrapFetchRequestPromise', _Formio.fetch(url, options), {\n url: url,\n method: method,\n data: data,\n opts: opts\n }).then(function (response) {\n // Allow plugins to respond.\n response = _Formio.pluginAlter('requestResponse', response, _Formio, data);\n if (!response.ok) {\n if (response.status === 440) {\n _Formio.setToken(null, opts);\n _Formio.events.emit('formio.sessionExpired', response.body);\n } else if (response.status === 401) {\n _Formio.events.emit('formio.unauthorized', response.body);\n } else if (response.status === 416) {\n _Formio.events.emit('formio.rangeIsNotSatisfiable', response.body);\n } else if (response.status === 504) {\n return _nativePromiseOnly.default.reject(new Error('Network request failed'));\n }\n\n // Parse and return the error as a rejected promise to reject this promise\n return (response.headers.get('content-type').includes('application/json') ? response.json() : response.text()).then(function (error) {\n return _nativePromiseOnly.default.reject(error);\n });\n }\n\n // Handle fetch results\n var token = response.headers.get('x-jwt-token');\n\n // In some strange cases, the fetch library will return an x-jwt-token without sending\n // one to the server. This has even been debugged on the server to verify that no token\n // was introduced with the request, but the response contains a token. This is an Invalid\n // case where we do not send an x-jwt-token and get one in return for any GET request.\n var tokenIntroduced = false;\n if (method === 'GET' && !requestToken && token && !opts.external && !url.includes('token=') && !url.includes('x-jwt-token=')) {\n console.warn('Token was introduced in request.');\n tokenIntroduced = true;\n }\n if (response.status >= 200 && response.status < 300 && token && token !== '' && !tokenIntroduced) {\n _Formio.setToken(token, opts);\n }\n // 204 is no content. Don't try to .json() it.\n if (response.status === 204) {\n return {};\n }\n var getResult = response.headers.get('content-type').includes('application/json') ? response.json() : response.text();\n return getResult.then(function (result) {\n // Add some content-range metadata to the result here\n var range = response.headers.get('content-range');\n if (range && isObject(result)) {\n range = range.split('/');\n if (range[0] !== '*') {\n var skipLimit = range[0].split('-');\n result.skip = Number(skipLimit[0]);\n result.limit = skipLimit[1] - skipLimit[0] + 1;\n }\n result.serverCount = range[1] === '*' ? range[1] : Number(range[1]);\n }\n if (!opts.getHeaders) {\n return result;\n }\n var headers = {};\n response.headers.forEach(function (item, key) {\n headers[key] = item;\n });\n\n // Return the result with the headers.\n return {\n result: result,\n headers: headers\n };\n });\n }).then(function (result) {\n if (opts.getHeaders) {\n return result;\n }\n\n // Cache the response.\n if (method === 'GET') {\n _Formio.cache[cacheKey] = result;\n }\n return cloneResponse(result);\n }).catch(function (err) {\n if (err === 'Bad Token') {\n _Formio.setToken(null, opts);\n _Formio.events.emit('formio.badToken', err);\n }\n if (err.message) {\n err = new Error(\"Could not connect to API server (\".concat(err.message, \"): \").concat(url));\n err.networkError = true;\n }\n if (method === 'GET') {\n delete _Formio.cache[cacheKey];\n }\n return _nativePromiseOnly.default.reject(err);\n });\n return result;\n }\n\n // Needed to maintain reverse compatability...\n }, {\n key: \"token\",\n get: function get() {\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n return Formio.tokens.formioToken || '';\n }\n\n // Needed to maintain reverse compatability...\n ,\n set: function set(token) {\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n Formio.tokens.formioToken = token || '';\n }\n }, {\n key: \"setToken\",\n value: function setToken() {\n var token = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n var opts = arguments.length > 1 ? arguments[1] : undefined;\n token = token || '';\n opts = typeof opts === 'string' ? {\n namespace: opts\n } : opts || {};\n var tokenName = \"\".concat(opts.namespace || Formio.namespace || 'formio', \"Token\");\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n var storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!token) {\n if (!opts.fromUser) {\n opts.fromToken = true;\n Formio.setUser(null, opts);\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.removeItem(tokenName);\n } catch (err) {\n _browserCookies.default.erase(tokenName, {\n path: '/'\n });\n }\n Formio.tokens[tokenName] = token;\n return _nativePromiseOnly.default.resolve(null);\n }\n if (Formio.tokens[tokenName] !== token) {\n Formio.tokens[tokenName] = token;\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(tokenName, token);\n } catch (err) {\n _browserCookies.default.set(tokenName, token, {\n path: '/'\n });\n }\n }\n // Return or updates the current user\n return this.currentUserResolved ? Formio.currentUser(opts.formio, opts) : _nativePromiseOnly.default.resolve(null);\n }\n }, {\n key: \"getToken\",\n value: function getToken(options) {\n options = typeof options === 'string' ? {\n namespace: options\n } : options || {};\n var tokenName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"Token\");\n var decodedTokenName = options.decode ? \"\".concat(tokenName, \"Decoded\") : tokenName;\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n if (Formio.tokens[decodedTokenName]) {\n return Formio.tokens[decodedTokenName];\n }\n try {\n var token = localStorage.getItem('useSessionToken') ? sessionStorage.getItem(tokenName) : localStorage.getItem(tokenName);\n Formio.tokens[tokenName] = token || '';\n if (options.decode) {\n Formio.tokens[decodedTokenName] = Formio.tokens[tokenName] ? (0, _jwtDecode.default)(Formio.tokens[tokenName]) : {};\n return Formio.tokens[decodedTokenName];\n }\n return Formio.tokens[tokenName];\n } catch (e) {\n Formio.tokens[tokenName] = _browserCookies.default.get(tokenName);\n return Formio.tokens[tokenName];\n }\n }\n }, {\n key: \"setUser\",\n value: function setUser(user) {\n var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var userName = \"\".concat(opts.namespace || Formio.namespace || 'formio', \"User\");\n var storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!user) {\n if (!opts.fromToken) {\n opts.fromUser = true;\n Formio.setToken(null, opts);\n }\n\n // Emit an event on the cleared user.\n Formio.events.emit('formio.user', null);\n\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n return storage.removeItem(userName);\n } catch (err) {\n return _browserCookies.default.erase(userName, {\n path: '/'\n });\n }\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(userName, JSON.stringify(user));\n } catch (err) {\n _browserCookies.default.set(userName, JSON.stringify(user), {\n path: '/'\n });\n }\n\n // Emit an event on the authenticated user.\n Formio.events.emit('formio.user', user);\n }\n }, {\n key: \"getUser\",\n value: function getUser(options) {\n options = options || {};\n var userName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"User\");\n try {\n return JSON.parse((localStorage.getItem('useSessionToken') ? sessionStorage : localStorage).getItem(userName) || null);\n } catch (e) {\n return JSON.parse(_browserCookies.default.get(userName));\n }\n }\n }, {\n key: \"setBaseUrl\",\n value: function setBaseUrl(url) {\n Formio.baseUrl = url;\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = url;\n }\n }\n }, {\n key: \"getBaseUrl\",\n value: function getBaseUrl() {\n return Formio.baseUrl;\n }\n }, {\n key: \"setApiUrl\",\n value: function setApiUrl(url) {\n return Formio.setBaseUrl(url);\n }\n }, {\n key: \"getApiUrl\",\n value: function getApiUrl() {\n return Formio.getBaseUrl();\n }\n }, {\n key: \"setAppUrl\",\n value: function setAppUrl(url) {\n console.warn('Formio.setAppUrl() is deprecated. Use Formio.setProjectUrl instead.');\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n }, {\n key: \"setProjectUrl\",\n value: function setProjectUrl(url) {\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n }, {\n key: \"setAuthUrl\",\n value: function setAuthUrl(url) {\n Formio.authUrl = url;\n }\n }, {\n key: \"getAppUrl\",\n value: function getAppUrl() {\n console.warn('Formio.getAppUrl() is deprecated. Use Formio.getProjectUrl instead.');\n return Formio.projectUrl;\n }\n }, {\n key: \"getProjectUrl\",\n value: function getProjectUrl() {\n return Formio.projectUrl;\n }\n }, {\n key: \"clearCache\",\n value: function clearCache() {\n Formio.cache = {};\n }\n }, {\n key: \"noop\",\n value: function noop() {}\n }, {\n key: \"identity\",\n value: function identity(value) {\n return value;\n }\n }, {\n key: \"deregisterPlugin\",\n value: function deregisterPlugin(plugin) {\n var beforeLength = Formio.plugins.length;\n Formio.plugins = Formio.plugins.filter(function (p) {\n if (p !== plugin && p.__name !== plugin) {\n return true;\n }\n (p.deregister || Formio.noop).call(plugin, Formio);\n return false;\n });\n return beforeLength !== Formio.plugins.length;\n }\n }, {\n key: \"registerPlugin\",\n value: function registerPlugin(plugin, name) {\n var __Formio = Formio;\n __Formio.plugins.push(plugin);\n __Formio.plugins.sort(function (a, b) {\n return (b.priority || 0) - (a.priority || 0);\n });\n plugin.__name = name;\n (plugin.init || __Formio.noop).call(plugin, __Formio);\n }\n }, {\n key: \"getPlugin\",\n value: function getPlugin(name) {\n var _iterator = _createForOfIteratorHelper(Formio.plugins),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var plugin = _step.value;\n if (plugin.__name === name) {\n return plugin;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n return null;\n }\n }, {\n key: \"pluginWait\",\n value: function pluginWait(pluginFn) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n return _nativePromiseOnly.default.all(Formio.plugins.map(function (plugin) {\n var _ref;\n return (_ref = plugin[pluginFn] || Formio.noop).call.apply(_ref, [plugin].concat(args));\n }));\n }\n }, {\n key: \"pluginGet\",\n value: function pluginGet(pluginFn) {\n for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n args[_key3 - 1] = arguments[_key3];\n }\n var callPlugin = function callPlugin(index) {\n var _ref2;\n var plugin = Formio.plugins[index];\n if (!plugin) {\n return _nativePromiseOnly.default.resolve(null);\n }\n return _nativePromiseOnly.default.resolve((_ref2 = plugin[pluginFn] || Formio.noop).call.apply(_ref2, [plugin].concat(args))).then(function (result) {\n if (!isNil(result)) {\n return result;\n }\n return callPlugin(index + 1);\n });\n };\n return callPlugin(0);\n }\n }, {\n key: \"pluginAlter\",\n value: function pluginAlter(pluginFn, value) {\n for (var _len4 = arguments.length, args = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {\n args[_key4 - 2] = arguments[_key4];\n }\n return Formio.plugins.reduce(function (value, plugin) {\n return (plugin[pluginFn] || Formio.identity).apply(void 0, [value].concat(args));\n }, value);\n }\n }, {\n key: \"accessInfo\",\n value: function accessInfo(formio) {\n var projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'accessInfo', \"\".concat(projectUrl, \"/access\"));\n }\n }, {\n key: \"projectRoles\",\n value: function projectRoles(formio) {\n var projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'projectRoles', \"\".concat(projectUrl, \"/role\"));\n }\n }, {\n key: \"currentUser\",\n value: function currentUser(formio, options) {\n var _this9 = this;\n var authUrl = Formio.authUrl;\n if (!authUrl) {\n authUrl = formio ? formio.projectUrl : Formio.projectUrl || Formio.baseUrl;\n }\n authUrl += '/current';\n var user = Formio.getUser(options);\n if (user) {\n return Formio.pluginAlter('wrapStaticRequestPromise', _nativePromiseOnly.default.resolve(user), {\n url: authUrl,\n method: 'GET',\n options: options\n });\n }\n var token = Formio.getToken(options);\n if ((!options || !options.external) && !token) {\n return Formio.pluginAlter('wrapStaticRequestPromise', _nativePromiseOnly.default.resolve(null), {\n url: authUrl,\n method: 'GET',\n options: options\n });\n }\n authUrl = \"\".concat(Formio.baseUrl, \"/current\");\n this.currentUserResolved = false;\n return Formio.makeRequest(formio, 'currentUser', authUrl, 'GET', null, options).then(function (response) {\n _this9.currentUserResolved = true;\n Formio.setUser(response, options);\n return response;\n });\n }\n }, {\n key: \"logout\",\n value: function logout(formio, options) {\n options = options || {};\n options.formio = formio;\n var projectUrl = Formio.authUrl ? Formio.authUrl : formio ? formio.projectUrl : Formio.baseUrl;\n var logout = function logout() {\n Formio.setToken(null, options);\n Formio.setUser(null, options);\n Formio.clearCache();\n localStorage.removeItem('useSessionToken');\n };\n return Formio.makeRequest(formio, 'logout', \"\".concat(projectUrl, \"/logout\")).then(function (result) {\n logout();\n return result;\n }).catch(function (err) {\n logout();\n throw err;\n });\n }\n }, {\n key: \"pageQuery\",\n value: function pageQuery() {\n var pageQuery = {};\n pageQuery.paths = [];\n var hashes = location.hash.substr(1).replace(/\\?/g, '&').split('&');\n var parts = [];\n location.search.substr(1).split('&').forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n }\n });\n hashes.forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n } else if (item.indexOf('/') === 0) {\n pageQuery.paths = item.substr(1).split('/');\n }\n });\n return pageQuery;\n }\n }, {\n key: \"oAuthCurrentUser\",\n value: function oAuthCurrentUser(formio, token) {\n return Formio.currentUser(formio, {\n external: true,\n headers: {\n Authorization: \"Bearer \".concat(token)\n }\n });\n }\n }, {\n key: \"samlInit\",\n value: function samlInit(options) {\n options = options || {};\n var query = Formio.pageQuery();\n if (query.saml) {\n Formio.setUser(null);\n var retVal = Formio.setToken(query.saml);\n var uri = window.location.toString();\n uri = uri.substring(0, uri.indexOf('?'));\n if (window.location.hash) {\n uri += window.location.hash;\n }\n window.history.replaceState({}, document.title, uri);\n return retVal;\n }\n\n // Set the relay if not provided.\n if (!options.relay) {\n options.relay = window.location.href;\n }\n\n // go to the saml sso endpoint for this project.\n var authUrl = Formio.authUrl || Formio.projectUrl;\n window.location.href = \"\".concat(authUrl, \"/saml/sso?relay=\").concat(encodeURI(options.relay));\n return false;\n }\n }, {\n key: \"oktaInit\",\n value: function oktaInit(options) {\n options = options || {};\n if ((typeof OktaAuth === \"undefined\" ? \"undefined\" : _typeof(OktaAuth)) !== undefined) {\n options.OktaAuth = OktaAuth;\n }\n if (_typeof(options.OktaAuth) === undefined) {\n var errorMessage = 'Cannot find OktaAuth. Please include the Okta JavaScript SDK within your application. See https://developer.okta.com/code/javascript/okta_auth_sdk for an example.';\n console.warn(errorMessage);\n return _nativePromiseOnly.default.reject(errorMessage);\n }\n return new _nativePromiseOnly.default(function (resolve, reject) {\n var Okta = options.OktaAuth;\n delete options.OktaAuth;\n var authClient = new Okta(options);\n authClient.tokenManager.get('accessToken').then(function (accessToken) {\n if (accessToken) {\n resolve(Formio.oAuthCurrentUser(options.formio, accessToken.accessToken));\n } else if (location.hash) {\n authClient.token.parseFromUrl().then(function (token) {\n authClient.tokenManager.add('accessToken', token);\n resolve(Formio.oAuthCurrentUser(options.formio, token.accessToken));\n }).catch(function (err) {\n console.warn(err);\n reject(err);\n });\n } else {\n authClient.token.getWithRedirect({\n responseType: 'token',\n scopes: options.scopes\n });\n resolve(false);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n }\n }, {\n key: \"ssoInit\",\n value: function ssoInit(type, options) {\n switch (type) {\n case 'saml':\n return Formio.samlInit(options);\n case 'okta':\n return Formio.oktaInit(options);\n default:\n console.warn('Unknown SSO type');\n return _nativePromiseOnly.default.reject('Unknown SSO type');\n }\n }\n }, {\n key: \"requireLibrary\",\n value: function requireLibrary(name, property, src, polling, onload) {\n if (!Formio.libraries.hasOwnProperty(name)) {\n Formio.libraries[name] = {};\n Formio.libraries[name].ready = new _nativePromiseOnly.default(function (resolve, reject) {\n Formio.libraries[name].resolve = resolve;\n Formio.libraries[name].reject = reject;\n });\n var callbackName = \"\".concat(name, \"Callback\");\n if (!polling && !window[callbackName]) {\n window[callbackName] = function () {\n return Formio.libraries[name].resolve();\n };\n }\n\n // See if the plugin already exists.\n var plugin = (0, _get2.default)(window, property);\n if (plugin) {\n Formio.libraries[name].resolve(plugin);\n } else {\n src = Array.isArray(src) ? src : [src];\n src.forEach(function (lib) {\n var attrs = {};\n var elementType = '';\n if (typeof lib === 'string') {\n lib = {\n type: 'script',\n src: lib\n };\n }\n switch (lib.type) {\n case 'script':\n elementType = 'script';\n attrs = {\n src: lib.src,\n type: 'text/javascript',\n defer: true,\n async: true,\n referrerpolicy: 'origin'\n };\n break;\n case 'styles':\n elementType = 'link';\n attrs = {\n href: lib.src,\n rel: 'stylesheet'\n };\n break;\n }\n\n // Add the script to the top of the page.\n var element = document.createElement(elementType);\n if (element.setAttribute) {\n for (var attr in attrs) {\n element.setAttribute(attr, attrs[attr]);\n }\n }\n if (onload) {\n element.addEventListener('load', function () {\n Formio.libraries[name].loaded = true;\n onload(Formio.libraries[name].ready);\n });\n }\n var _document = document,\n head = _document.head;\n if (head) {\n head.appendChild(element);\n }\n });\n\n // if no callback is provided, then check periodically for the script.\n if (polling) {\n var interval = setInterval(function () {\n var plugin = (0, _get2.default)(window, property);\n if (plugin) {\n clearInterval(interval);\n Formio.libraries[name].resolve(plugin);\n }\n }, 200);\n }\n }\n }\n var lib = Formio.libraries[name];\n return onload && lib.loaded ? onload(lib.ready) : lib.ready;\n }\n }, {\n key: \"libraryReady\",\n value: function libraryReady(name) {\n if (Formio.libraries.hasOwnProperty(name) && Formio.libraries[name].ready) {\n return Formio.libraries[name].ready;\n }\n return _nativePromiseOnly.default.reject(\"\".concat(name, \" library was not required.\"));\n }\n }, {\n key: \"addToGlobal\",\n value: function addToGlobal(global) {\n if (_typeof(global) === 'object' && !global.Formio) {\n global.Formio = Formio;\n }\n }\n }, {\n key: \"setPathType\",\n value: function setPathType(type) {\n if (typeof type === 'string') {\n Formio.pathType = type;\n }\n }\n }, {\n key: \"getPathType\",\n value: function getPathType() {\n return Formio.pathType;\n }\n }, {\n key: \"rulesEntities\",\n get: function get() {\n return {\n ValueSources: Formio.ValueSources,\n Conjunctions: Formio.Conjunctions,\n Operators: Formio.Operators,\n Transformers: Formio.Transformers,\n QuickRules: Formio.QuickRules,\n Rules: Formio.Rules\n };\n }\n }, {\n key: \"GlobalFormio\",\n get: function get() {\n if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.Formio) {\n return __webpack_require__.g.Formio;\n } else if (typeof window !== 'undefined' && window.Formio) {\n return window.Formio;\n }\n return Formio;\n }\n }]);\n return Formio;\n}(); // Define all the static properties.\n_defineProperty(Formio, \"currentUserResolved\", true);\nFormio.libraries = {};\nFormio.Promise = _nativePromiseOnly.default;\nFormio.fetch = fetch;\nFormio.Headers = Headers;\nFormio.baseUrl = 'https://api.form.io';\nFormio.projectUrl = Formio.baseUrl;\nFormio.authUrl = '';\nFormio.projectUrlSet = false;\nFormio.plugins = [];\nFormio.cache = {};\nFormio.Providers = _providers.default;\nFormio.version = '0.1.55';\nFormio.pathType = '';\nFormio.events = new _EventEmitter.default();\nFormio.cdn = new _CDN.default();\nif ((Formio.version || '').includes('rc')) {\n Formio.cdn.setBaseUrl('https://cdn.test-form.io');\n}\nif (typeof __webpack_require__.g !== 'undefined') {\n Formio.addToGlobal(__webpack_require__.g);\n}\nif (typeof window !== 'undefined') {\n Formio.addToGlobal(window);\n}\nvar GlobalFormio = Formio.GlobalFormio;\nexports.GlobalFormio = GlobalFormio;\nvar _default = Formio;\nexports[\"default\"] = _default;\n\n//# sourceURL=webpack://Formio/./lib/Formio.js?");
84
+ eval("\n\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.array.slice.js */ \"./node_modules/core-js/modules/es.array.slice.js\");\n__webpack_require__(/*! core-js/modules/es.function.name.js */ \"./node_modules/core-js/modules/es.function.name.js\");\n__webpack_require__(/*! core-js/modules/es.array.from.js */ \"./node_modules/core-js/modules/es.array.from.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = exports.GlobalFormio = void 0;\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.match.js */ \"./node_modules/core-js/modules/es.string.match.js\");\n__webpack_require__(/*! core-js/modules/es.string.search.js */ \"./node_modules/core-js/modules/es.string.search.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.constructor.js */ \"./node_modules/core-js/modules/es.regexp.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ \"./node_modules/core-js/modules/es.regexp.to-string.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.array.join.js */ \"./node_modules/core-js/modules/es.array.join.js\");\n__webpack_require__(/*! core-js/modules/es.array.includes.js */ \"./node_modules/core-js/modules/es.array.includes.js\");\n__webpack_require__(/*! core-js/modules/es.string.includes.js */ \"./node_modules/core-js/modules/es.string.includes.js\");\n__webpack_require__(/*! core-js/modules/es.object.assign.js */ \"./node_modules/core-js/modules/es.object.assign.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.array.filter.js */ \"./node_modules/core-js/modules/es.array.filter.js\");\n__webpack_require__(/*! core-js/modules/es.array.sort.js */ \"./node_modules/core-js/modules/es.array.sort.js\");\n__webpack_require__(/*! core-js/modules/es.array.map.js */ \"./node_modules/core-js/modules/es.array.map.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nvar _nativePromiseOnly = _interopRequireDefault(__webpack_require__(/*! native-promise-only */ \"./node_modules/native-promise-only/lib/npo.src.js\"));\nvar _fetchPonyfill2 = _interopRequireDefault(__webpack_require__(/*! fetch-ponyfill */ \"./node_modules/fetch-ponyfill/build/fetch-browser.js\"));\nvar _EventEmitter = _interopRequireDefault(__webpack_require__(/*! ./EventEmitter */ \"./lib/EventEmitter.js\"));\nvar _browserCookies = _interopRequireDefault(__webpack_require__(/*! browser-cookies */ \"./node_modules/browser-cookies/src/browser-cookies.js\"));\nvar _providers = _interopRequireDefault(__webpack_require__(/*! ./providers */ \"./lib/providers/index.js\"));\nvar _intersection2 = _interopRequireDefault(__webpack_require__(/*! lodash/intersection */ \"./node_modules/lodash/intersection.js\"));\nvar _get2 = _interopRequireDefault(__webpack_require__(/*! lodash/get */ \"./node_modules/lodash/get.js\"));\nvar _cloneDeep2 = _interopRequireDefault(__webpack_require__(/*! lodash/cloneDeep */ \"./node_modules/lodash/cloneDeep.js\"));\nvar _defaults2 = _interopRequireDefault(__webpack_require__(/*! lodash/defaults */ \"./node_modules/lodash/defaults.js\"));\nvar _utils = __webpack_require__(/*! ./utils/utils */ \"./lib/utils/utils.js\");\nvar _jwtDecode = _interopRequireDefault(__webpack_require__(/*! jwt-decode */ \"./node_modules/jwt-decode/build/jwt-decode.esm.js\"));\n__webpack_require__(/*! ./polyfills */ \"./lib/polyfills/index.js\");\nvar _CDN = _interopRequireDefault(__webpack_require__(/*! ./CDN */ \"./lib/CDN.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nvar _fetchPonyfill = (0, _fetchPonyfill2.default)({\n Promise: _nativePromiseOnly.default\n }),\n fetch = _fetchPonyfill.fetch,\n Headers = _fetchPonyfill.Headers;\nvar isBoolean = function isBoolean(val) {\n return _typeof(val) === _typeof(true);\n};\nvar isNil = function isNil(val) {\n return val === null || val === undefined;\n};\nvar isObject = function isObject(val) {\n return val && _typeof(val) === 'object';\n};\nfunction cloneResponse(response) {\n var copy = (0, _cloneDeep2.default)(response);\n if (Array.isArray(response)) {\n copy.skip = response.skip;\n copy.limit = response.limit;\n copy.serverCount = response.serverCount;\n }\n return copy;\n}\n\n/**\n * The Formio interface class.\n *\n * let formio = new Formio('https://examples.form.io/example');\n */\nvar Formio = /*#__PURE__*/function () {\n /* eslint-disable max-statements */\n function Formio(path) {\n var _this = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck(this, Formio);\n // Ensure we have an instance of Formio.\n if (!(this instanceof Formio)) {\n return new Formio(path);\n }\n\n // Initialize our variables.\n this.base = '';\n this.projectsUrl = '';\n this.projectUrl = '';\n this.projectId = '';\n this.roleUrl = '';\n this.rolesUrl = '';\n this.roleId = '';\n this.formUrl = '';\n this.formsUrl = '';\n this.formId = '';\n this.submissionsUrl = '';\n this.submissionUrl = '';\n this.submissionId = '';\n this.actionsUrl = '';\n this.actionId = '';\n this.actionUrl = '';\n this.vsUrl = '';\n this.vId = '';\n this.vUrl = '';\n this.query = '';\n\n // Store the original path and options.\n this.path = path;\n this.options = options;\n if (options.useSessionToken) {\n Formio.useSessionToken(options);\n }\n if (options.hasOwnProperty('base')) {\n this.base = options.base;\n } else if (Formio.baseUrl) {\n this.base = Formio.baseUrl;\n } else if (typeof window !== 'undefined') {\n this.base = window.location.href.match(/http[s]?:\\/\\/api./)[0];\n }\n if (!path) {\n // Allow user to create new projects if this was instantiated without\n // a url\n this.projectUrl = Formio.projectUrl || \"\".concat(this.base, \"/project\");\n this.projectsUrl = \"\".concat(this.base, \"/project\");\n this.projectId = false;\n this.query = '';\n return;\n }\n if (options.hasOwnProperty('project')) {\n this.projectUrl = options.project;\n }\n var project = this.projectUrl || Formio.projectUrl;\n var projectRegEx = /(^|\\/)(project)($|\\/[^/]+)/;\n var isProjectUrl = path.search(projectRegEx) !== -1;\n\n // The baseURL is the same as the projectUrl, and does not contain \"/project/MONGO_ID\" in\n // its domain. This is almost certainly against the Open Source server.\n if (project && this.base === project && !isProjectUrl) {\n this.noProject = true;\n this.projectUrl = this.base;\n }\n\n // Normalize to an absolute path.\n if (path.indexOf('http') !== 0 && path.indexOf('//') !== 0) {\n path = this.base + path;\n }\n var hostparts = this.getUrlParts(path);\n var parts = [];\n var hostName = hostparts[1] + hostparts[2];\n path = hostparts.length > 3 ? hostparts[3] : '';\n var queryparts = path.split('?');\n if (queryparts.length > 1) {\n path = queryparts[0];\n this.query = \"?\".concat(queryparts[1]);\n }\n\n // Register a specific path.\n var registerPath = function registerPath(name, base) {\n _this[\"\".concat(name, \"sUrl\")] = \"\".concat(base, \"/\").concat(name);\n var regex = new RegExp(\"/\".concat(name, \"/([^/]+)\"));\n if (path.search(regex) !== -1) {\n parts = path.match(regex);\n _this[\"\".concat(name, \"Url\")] = parts ? base + parts[0] : '';\n _this[\"\".concat(name, \"Id\")] = parts.length > 1 ? parts[1] : '';\n base += parts[0];\n }\n return base;\n };\n\n // Register an array of items.\n var registerItems = function registerItems(items, base, staticBase) {\n for (var i in items) {\n if (items.hasOwnProperty(i)) {\n var item = items[i];\n if (Array.isArray(item)) {\n registerItems(item, base, true);\n } else {\n var newBase = registerPath(item, base);\n base = staticBase ? base : newBase;\n }\n }\n }\n };\n if (!this.projectUrl || this.projectUrl === this.base) {\n // If a project uses Subdirectories path type, we need to specify a projectUrl\n if (!this.projectUrl && !isProjectUrl && Formio.pathType === 'Subdirectories') {\n var regex = \"^\".concat(hostName.replace(/\\//g, '\\\\/'), \".[^/]+\");\n var match = project.match(new RegExp(regex));\n this.projectUrl = match ? match[0] : hostName;\n } else {\n this.projectUrl = hostName;\n }\n }\n // Check if we have a specified path type.\n var isNotSubdomainType = false;\n if (Formio.pathType) {\n isNotSubdomainType = Formio.pathType !== 'Subdomains';\n }\n if (!this.noProject) {\n // Determine the projectUrl and projectId\n if (isProjectUrl) {\n // Get project id as project/:projectId.\n registerItems(['project'], hostName);\n path = path.replace(projectRegEx, '');\n } else if (hostName === this.base) {\n // Get project id as first part of path (subdirectory).\n if (hostparts.length > 3 && path.split('/').length > 1) {\n var isFile = path.match(/.json/);\n var pathParts = path.split('/');\n if (isFile) {\n this.projectUrl = hostName;\n } else {\n pathParts.shift(); // Throw away the first /.\n this.projectId = pathParts.shift();\n path = \"/\".concat(pathParts.join('/'));\n this.projectUrl = \"\".concat(hostName, \"/\").concat(this.projectId);\n }\n }\n } else {\n // Get project id from subdomain.\n if (hostparts.length > 2 && (hostparts[2].split('.').length > 2 || hostName.includes('localhost')) && !isNotSubdomainType) {\n this.projectUrl = hostName;\n this.projectId = hostparts[2].split('.')[0];\n }\n }\n this.projectsUrl = this.projectsUrl || \"\".concat(this.base, \"/project\");\n }\n\n // Configure Role urls and role ids.\n registerItems(['role'], this.projectUrl);\n\n // Configure Form urls and form ids.\n if (/(^|\\/)(form)($|\\/)/.test(path)) {\n registerItems(['form', ['submission', 'action', 'v']], this.projectUrl);\n } else {\n var subRegEx = new RegExp('/(submission|action|v)($|/.*)');\n var subs = path.match(subRegEx);\n this.pathType = subs && subs.length > 1 ? subs[1] : '';\n path = path.replace(subRegEx, '');\n path = path.replace(/\\/$/, '');\n this.formsUrl = \"\".concat(this.projectUrl, \"/form\");\n this.formUrl = path ? this.projectUrl + path : '';\n this.formId = path.replace(/^\\/+|\\/+$/g, '');\n var items = ['submission', 'action', 'v'];\n for (var i in items) {\n if (items.hasOwnProperty(i)) {\n var item = items[i];\n this[\"\".concat(item, \"sUrl\")] = \"\".concat(this.projectUrl + path, \"/\").concat(item);\n if (this.pathType === item && subs.length > 2 && subs[2]) {\n this[\"\".concat(item, \"Id\")] = subs[2].replace(/^\\/+|\\/+$/g, '');\n this[\"\".concat(item, \"Url\")] = this.projectUrl + path + subs[0];\n }\n }\n }\n }\n\n // Set the app url if it is not set.\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = this.projectUrl;\n }\n }\n /* eslint-enable max-statements */\n _createClass(Formio, [{\n key: \"delete\",\n value: function _delete(type, opts) {\n var _id = \"\".concat(type, \"Id\");\n var _url = \"\".concat(type, \"Url\");\n if (!this[_id]) {\n return _nativePromiseOnly.default.reject('Nothing to delete');\n }\n Formio.cache = {};\n return this.makeRequest(type, this[_url], 'delete', null, opts);\n }\n }, {\n key: \"index\",\n value: function index(type, query, opts) {\n var _url = \"\".concat(type, \"Url\");\n query = query || '';\n if (query && isObject(query)) {\n query = \"?\".concat(Formio.serialize(query.params));\n }\n return this.makeRequest(type, this[_url] + query, 'get', null, opts);\n }\n }, {\n key: \"save\",\n value: function save(type, data, opts) {\n var _id = \"\".concat(type, \"Id\");\n var _url = \"\".concat(type, \"Url\");\n var method = this[_id] || data._id ? 'put' : 'post';\n var reqUrl = this[_id] ? this[_url] : this[\"\".concat(type, \"sUrl\")];\n if (!this[_id] && data._id && method === 'put' && !reqUrl.includes(data._id)) {\n reqUrl += \"/\".concat(data._id);\n }\n Formio.cache = {};\n return this.makeRequest(type, reqUrl + this.query, method, data, opts);\n }\n }, {\n key: \"load\",\n value: function load(type, query, opts) {\n var _id = \"\".concat(type, \"Id\");\n var _url = \"\".concat(type, \"Url\");\n if (query && isObject(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = this.query ? \"\".concat(this.query, \"&\").concat(query) : \"?\".concat(query);\n } else {\n query = this.query;\n }\n if (!this[_id]) {\n return _nativePromiseOnly.default.reject(\"Missing \".concat(_id));\n }\n var url = this[_url] + query;\n if (type === 'form' && !isNaN(parseInt(this.vId)) && parseInt(this.vId) !== 0) {\n url += url.match(/\\?/) ? '&' : '?';\n url += \"formRevision=\".concat(this.vId);\n }\n return this.makeRequest(type, url, 'get', null, opts);\n }\n }, {\n key: \"makeRequest\",\n value: function makeRequest() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return Formio.makeRequest.apply(Formio, [this].concat(args));\n }\n }, {\n key: \"loadProject\",\n value: function loadProject(query, opts) {\n return this.load('project', query, opts);\n }\n }, {\n key: \"saveProject\",\n value: function saveProject(data, opts) {\n return this.save('project', data, opts);\n }\n }, {\n key: \"deleteProject\",\n value: function deleteProject(opts) {\n return this.delete('project', opts);\n }\n }, {\n key: \"loadRole\",\n value: function loadRole(opts) {\n return this.load('role', null, opts);\n }\n }, {\n key: \"saveRole\",\n value: function saveRole(data, opts) {\n return this.save('role', data, opts);\n }\n }, {\n key: \"deleteRole\",\n value: function deleteRole(opts) {\n return this.delete('role', opts);\n }\n }, {\n key: \"loadRoles\",\n value: function loadRoles(opts) {\n return this.index('roles', null, opts);\n }\n }, {\n key: \"loadForm\",\n value: function loadForm(query, opts) {\n var _this2 = this;\n return this.load('form', query, opts).then(function (currentForm) {\n // Check to see if there isn't a number in vId.\n if (!currentForm.revisions || isNaN(parseInt(_this2.vId))) {\n return currentForm;\n }\n // If a submission already exists but form is marked to load current version of form.\n if (currentForm.revisions === 'current' && _this2.submissionId) {\n return currentForm;\n }\n // eslint-disable-next-line eqeqeq\n if (currentForm._vid == _this2.vId || currentForm.revisionId === _this2.vId) {\n return currentForm;\n }\n // If they specified a revision form, load the revised form components.\n if (query && isObject(query)) {\n query = Formio.serialize(query.params);\n }\n if (query) {\n query = _this2.query ? \"\".concat(_this2.query, \"&\").concat(query) : \"?\".concat(query);\n } else {\n query = _this2.query;\n }\n return _this2.makeRequest('form', _this2.vUrl + query, 'get', null, opts).then(function (revisionForm) {\n currentForm._vid = revisionForm._vid;\n currentForm.components = revisionForm.components;\n currentForm.settings = revisionForm.settings;\n currentForm.revisionId = revisionForm.revisionId;\n // Using object.assign so we don't cross polinate multiple form loads.\n return Object.assign({}, currentForm);\n })\n // If we couldn't load the revision, just return the original form.\n .catch(function () {\n return Object.assign({}, currentForm);\n });\n });\n }\n }, {\n key: \"saveForm\",\n value: function saveForm(data, opts) {\n return this.save('form', data, opts);\n }\n }, {\n key: \"deleteForm\",\n value: function deleteForm(opts) {\n return this.delete('form', opts);\n }\n }, {\n key: \"loadForms\",\n value: function loadForms(query, opts) {\n return this.index('forms', query, opts);\n }\n }, {\n key: \"loadSubmission\",\n value: function loadSubmission(query, opts) {\n var _this3 = this;\n return this.load('submission', query, opts).then(function (submission) {\n _this3.vId = submission._frid || submission._fvid;\n _this3.vUrl = \"\".concat(_this3.formUrl, \"/v/\").concat(_this3.vId);\n return submission;\n });\n }\n }, {\n key: \"saveSubmission\",\n value: function saveSubmission(data, opts) {\n if (!isNaN(parseInt(this.vId))) {\n data._fvid = this.vId;\n }\n return this.save('submission', data, opts);\n }\n }, {\n key: \"deleteSubmission\",\n value: function deleteSubmission(opts) {\n return this.delete('submission', opts);\n }\n }, {\n key: \"loadSubmissions\",\n value: function loadSubmissions(query, opts) {\n return this.index('submissions', query, opts);\n }\n }, {\n key: \"loadAction\",\n value: function loadAction(query, opts) {\n return this.load('action', query, opts);\n }\n }, {\n key: \"saveAction\",\n value: function saveAction(data, opts) {\n return this.save('action', data, opts);\n }\n }, {\n key: \"deleteAction\",\n value: function deleteAction(opts) {\n return this.delete('action', opts);\n }\n }, {\n key: \"loadActions\",\n value: function loadActions(query, opts) {\n return this.index('actions', query, opts);\n }\n }, {\n key: \"availableActions\",\n value: function availableActions() {\n return this.makeRequest('availableActions', \"\".concat(this.formUrl, \"/actions\"));\n }\n }, {\n key: \"actionInfo\",\n value: function actionInfo(name) {\n return this.makeRequest('actionInfo', \"\".concat(this.formUrl, \"/actions/\").concat(name));\n }\n }, {\n key: \"isObjectId\",\n value: function isObjectId(id) {\n var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');\n return checkForHexRegExp.test(id);\n }\n }, {\n key: \"getProjectId\",\n value: function getProjectId() {\n if (!this.projectId) {\n return _nativePromiseOnly.default.resolve('');\n }\n if (this.isObjectId(this.projectId)) {\n return _nativePromiseOnly.default.resolve(this.projectId);\n } else {\n return this.loadProject().then(function (project) {\n return project._id;\n });\n }\n }\n }, {\n key: \"getFormId\",\n value: function getFormId() {\n if (!this.formId) {\n return _nativePromiseOnly.default.resolve('');\n }\n if (this.isObjectId(this.formId)) {\n return _nativePromiseOnly.default.resolve(this.formId);\n } else {\n return this.loadForm().then(function (form) {\n return form._id;\n });\n }\n }\n }, {\n key: \"currentUser\",\n value: function currentUser(options) {\n return Formio.currentUser(this, options);\n }\n }, {\n key: \"accessInfo\",\n value: function accessInfo() {\n return Formio.accessInfo(this);\n }\n\n /**\n * Returns the JWT token for this instance.\n *\n * @return {*}\n */\n }, {\n key: \"getToken\",\n value: function getToken(options) {\n return Formio.getToken(Object.assign({\n formio: this\n }, this.options, options));\n }\n\n /**\n * Sets the JWT token for this instance.\n *\n * @return {*}\n */\n }, {\n key: \"setToken\",\n value: function setToken(token, options) {\n return Formio.setToken(token, Object.assign({\n formio: this\n }, this.options, options));\n }\n\n /**\n * Returns a temporary authentication token for single purpose token generation.\n */\n }, {\n key: \"getTempToken\",\n value: function getTempToken(expire, allowed, options) {\n var token = Formio.getToken(options);\n if (!token) {\n return _nativePromiseOnly.default.reject('You must be authenticated to generate a temporary auth token.');\n }\n var authUrl = Formio.authUrl || this.projectUrl;\n return this.makeRequest('tempToken', \"\".concat(authUrl, \"/token\"), 'GET', null, {\n ignoreCache: true,\n header: new Headers({\n 'x-expire': expire,\n 'x-allow': allowed\n })\n });\n }\n\n /**\n * Get a download url for a submission PDF of this submission.\n *\n * @return {*}\n */\n }, {\n key: \"getDownloadUrl\",\n value: function getDownloadUrl(form) {\n var _this4 = this;\n if (!this.submissionId) {\n return _nativePromiseOnly.default.resolve('');\n }\n if (!form) {\n // Make sure to load the form first.\n return this.loadForm().then(function (_form) {\n if (!_form) {\n return '';\n }\n return _this4.getDownloadUrl(_form);\n });\n }\n var apiUrl = \"/project/\".concat(form.project);\n apiUrl += \"/form/\".concat(form._id);\n apiUrl += \"/submission/\".concat(this.submissionId);\n var postfix = form.submissionRevisions && form.settings.changeLog ? '/download/changelog' : '/download';\n apiUrl += postfix;\n var download = this.base + apiUrl;\n return new _nativePromiseOnly.default(function (resolve, reject) {\n _this4.getTempToken(3600, \"GET:\".concat(apiUrl)).then(function (tempToken) {\n download += \"?token=\".concat(tempToken.key);\n resolve(download);\n }, function () {\n resolve(download);\n }).catch(reject);\n });\n }\n }, {\n key: \"uploadFile\",\n value: function uploadFile(storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback) {\n var _this5 = this;\n var requestArgs = {\n provider: storage,\n method: 'upload',\n file: file,\n fileName: fileName,\n dir: dir\n };\n fileKey = fileKey || 'file';\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('fileRequest', requestArgs).then(function (result) {\n if (storage && isNil(result)) {\n var Provider = _providers.default.getProvider('storage', storage);\n if (Provider) {\n var provider = new Provider(_this5);\n if (uploadStartCallback) {\n uploadStartCallback();\n }\n return provider.uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback);\n } else {\n throw 'Storage provider not found';\n }\n }\n return result || {\n url: ''\n };\n });\n });\n return Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n }\n }, {\n key: \"downloadFile\",\n value: function downloadFile(file, options) {\n var _this6 = this;\n var requestArgs = {\n method: 'download',\n file: file\n };\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('fileRequest', requestArgs).then(function (result) {\n if (file.storage && isNil(result)) {\n var Provider = _providers.default.getProvider('storage', file.storage);\n if (Provider) {\n var provider = new Provider(_this6);\n return provider.downloadFile(file, options);\n } else {\n throw 'Storage provider not found';\n }\n }\n return result || {\n url: ''\n };\n });\n });\n return Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n }\n }, {\n key: \"deleteFile\",\n value: function deleteFile(file, options) {\n var _this7 = this;\n var requestArgs = {\n method: 'delete',\n file: file\n };\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('fileRequest', requestArgs).then(function (result) {\n if (file.storage && isNil(result)) {\n var Provider = _providers.default.getProvider('storage', file.storage);\n if (Provider) {\n var provider = new Provider(_this7);\n return provider.deleteFile(file, options);\n } else {\n throw 'Storage provider not found';\n }\n }\n return result || {\n url: ''\n };\n });\n });\n return Formio.pluginAlter('wrapFileRequestPromise', request, requestArgs);\n }\n\n /**\n * Returns the user permissions to a form and submission.\n *\n * @param user - The user or current user if undefined. For anonymous, use \"null\"\n * @param form - The form or current form if undefined. For no form check, use \"null\"\n * @param submission - The submisison or \"index\" if undefined.\n *\n * @return {create: boolean, read: boolean, edit: boolean, delete: boolean}\n */\n }, {\n key: \"userPermissions\",\n value: function userPermissions(user, form, submission) {\n return _nativePromiseOnly.default.all([form !== undefined ? _nativePromiseOnly.default.resolve(form) : this.loadForm(), user !== undefined ? _nativePromiseOnly.default.resolve(user) : this.currentUser(), submission !== undefined || !this.submissionId ? _nativePromiseOnly.default.resolve(submission) : this.loadSubmission(), this.accessInfo()]).then(function (results) {\n var form = results.shift();\n var user = results.shift() || {\n _id: false,\n roles: []\n };\n var submission = results.shift();\n var access = results.shift();\n var permMap = {\n create: 'create',\n read: 'read',\n update: 'edit',\n delete: 'delete'\n };\n var perms = {\n user: user,\n form: form,\n access: access,\n create: false,\n read: false,\n edit: false,\n delete: false\n };\n for (var roleName in access.roles) {\n if (access.roles.hasOwnProperty(roleName)) {\n var role = access.roles[roleName];\n if (role.default && user._id === false) {\n // User is anonymous. Add the anonymous role.\n user.roles.push(role._id);\n } else if (role.admin && user.roles.indexOf(role._id) !== -1) {\n perms.create = true;\n perms.read = true;\n perms.delete = true;\n perms.edit = true;\n return perms;\n }\n }\n }\n if (form && form.submissionAccess) {\n for (var i = 0; i < form.submissionAccess.length; i++) {\n var permission = form.submissionAccess[i];\n var _permission$type$spli = permission.type.split('_'),\n _permission$type$spli2 = _slicedToArray(_permission$type$spli, 2),\n perm = _permission$type$spli2[0],\n scope = _permission$type$spli2[1];\n if (['create', 'read', 'update', 'delete'].includes(perm)) {\n if ((0, _intersection2.default)(permission.roles, user.roles).length) {\n perms[permMap[perm]] = scope === 'all' || !submission || user._id === submission.owner;\n }\n }\n }\n }\n // check for Group Permissions\n if (submission) {\n // we would anyway need to loop through components for create permission, so we'll do that for all of them\n (0, _utils.eachComponent)(form.components, function (component, path) {\n if (component && component.defaultPermission) {\n var value = (0, _get2.default)(submission.data, path);\n // make it work for single-select Group and multi-select Group\n var groups = Array.isArray(value) ? value : [value];\n groups.forEach(function (group) {\n if (group && group._id &&\n // group id is present\n user.roles.indexOf(group._id) > -1 // user has group id in his roles\n ) {\n if (component.defaultPermission === 'read') {\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'create') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n }\n if (component.defaultPermission === 'write') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n }\n if (component.defaultPermission === 'admin') {\n perms[permMap.create] = true;\n perms[permMap.read] = true;\n perms[permMap.update] = true;\n perms[permMap.delete] = true;\n }\n }\n });\n }\n });\n }\n return perms;\n });\n }\n\n /**\n * Determine if the current user can submit a form.\n * @return {*}\n */\n }, {\n key: \"canSubmit\",\n value: function canSubmit() {\n var _this8 = this;\n return this.userPermissions().then(function (perms) {\n // If there is user and they cannot create, then check anonymous user permissions.\n if (!perms.create && Formio.getUser()) {\n return _this8.userPermissions(null).then(function (anonPerms) {\n if (anonPerms.create) {\n Formio.setUser(null);\n return true;\n }\n return false;\n });\n }\n return perms.create;\n });\n }\n }, {\n key: \"getUrlParts\",\n value: function getUrlParts(url) {\n return Formio.getUrlParts(url, this);\n }\n }], [{\n key: \"useSessionToken\",\n value: function useSessionToken(options) {\n var tokenName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"Token\");\n var token = localStorage.getItem(tokenName);\n if (token) {\n localStorage.removeItem(tokenName);\n sessionStorage.setItem(tokenName, token);\n }\n var userName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"User\");\n var user = localStorage.getItem(userName);\n if (user) {\n localStorage.removeItem(userName);\n sessionStorage.setItem(userName, user);\n }\n localStorage.setItem('useSessionToken', true);\n }\n }, {\n key: \"loadProjects\",\n value: function loadProjects(query, opts) {\n query = query || '';\n if (isObject(query)) {\n query = \"?\".concat(Formio.serialize(query.params));\n }\n return Formio.makeStaticRequest(\"\".concat(Formio.baseUrl, \"/project\").concat(query), 'GET', null, opts);\n }\n }, {\n key: \"getUrlParts\",\n value: function getUrlParts(url, formio) {\n var base = formio && formio.base ? formio.base : Formio.baseUrl;\n var regex = '^(http[s]?:\\\\/\\\\/)';\n if (base && url.indexOf(base) === 0) {\n regex += \"(\".concat(base.replace(/^http[s]?:\\/\\//, ''), \")\");\n } else {\n regex += '([^/]+)';\n }\n regex += '($|\\\\/.*)';\n return url.match(new RegExp(regex));\n }\n }, {\n key: \"serialize\",\n value: function serialize(obj, _interpolate) {\n var str = [];\n var interpolate = function interpolate(item) {\n return _interpolate ? _interpolate(item) : item;\n };\n for (var p in obj) {\n if (obj.hasOwnProperty(p)) {\n str.push(\"\".concat(encodeURIComponent(p), \"=\").concat(encodeURIComponent(interpolate(obj[p]))));\n }\n }\n return str.join('&');\n }\n }, {\n key: \"getRequestArgs\",\n value: function getRequestArgs(formio, type, url, method, data, opts) {\n method = (method || 'GET').toUpperCase();\n if (!opts || !isObject(opts)) {\n opts = {};\n }\n var requestArgs = {\n url: url,\n method: method,\n data: data || null,\n opts: opts\n };\n if (type) {\n requestArgs.type = type;\n }\n if (formio) {\n requestArgs.formio = formio;\n }\n return requestArgs;\n }\n }, {\n key: \"makeStaticRequest\",\n value: function makeStaticRequest(url, method, data, opts) {\n var requestArgs = Formio.getRequestArgs(null, '', url, method, data, opts);\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('staticRequest', requestArgs).then(function (result) {\n if (isNil(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n });\n });\n return Formio.pluginAlter('wrapStaticRequestPromise', request, requestArgs);\n }\n }, {\n key: \"makeRequest\",\n value: function makeRequest(formio, type, url, method, data, opts) {\n if (!formio) {\n return Formio.makeStaticRequest(url, method, data, opts);\n }\n var requestArgs = Formio.getRequestArgs(formio, type, url, method, data, opts);\n requestArgs.opts = requestArgs.opts || {};\n requestArgs.opts.formio = formio;\n\n //for Formio requests default Accept and Content-type headers\n if (!requestArgs.opts.headers) {\n requestArgs.opts.headers = {};\n }\n requestArgs.opts.headers = (0, _defaults2.default)(requestArgs.opts.headers, {\n 'Accept': 'application/json',\n 'Content-type': 'application/json'\n });\n var request = Formio.pluginWait('preRequest', requestArgs).then(function () {\n return Formio.pluginGet('request', requestArgs).then(function (result) {\n if (isNil(result)) {\n return Formio.request(requestArgs.url, requestArgs.method, requestArgs.data, requestArgs.opts.header, requestArgs.opts);\n }\n return result;\n });\n });\n return Formio.pluginAlter('wrapRequestPromise', request, requestArgs);\n }\n }, {\n key: \"request\",\n value: function request(url, method, data, header, opts) {\n if (!url) {\n return _nativePromiseOnly.default.reject('No url provided');\n }\n var _Formio = Formio;\n method = (method || 'GET').toUpperCase();\n\n // For reverse compatibility, if they provided the ignoreCache parameter,\n // then change it back to the options format where that is a parameter.\n if (isBoolean(opts)) {\n opts = {\n ignoreCache: opts\n };\n }\n if (!opts || !isObject(opts)) {\n opts = {};\n }\n\n // Generate a cachekey.\n var cacheKey = btoa(encodeURI(url));\n\n // Get the cached promise to save multiple loads.\n if (!opts.ignoreCache && method === 'GET' && _Formio.cache.hasOwnProperty(cacheKey)) {\n return _nativePromiseOnly.default.resolve(cloneResponse(_Formio.cache[cacheKey]));\n }\n\n // Set up and fetch request\n var headers = header || new Headers(opts.headers || {\n 'Accept': 'application/json',\n 'Content-type': 'application/json'\n });\n var token = _Formio.getToken(opts);\n if (token && !opts.noToken) {\n headers.append('x-jwt-token', token);\n }\n\n // The fetch-ponyfill can't handle a proper Headers class anymore. Change it back to an object.\n var headerObj = {};\n headers.forEach(function (value, name) {\n headerObj[name] = value;\n });\n var options = {\n method: method,\n headers: headerObj,\n mode: 'cors'\n };\n if (data) {\n options.body = JSON.stringify(data);\n if (method === \"POST\") {\n options.body = data;\n }\n }\n\n // Allow plugins to alter the options.\n options = _Formio.pluginAlter('requestOptions', options, url);\n if (options.namespace || _Formio.namespace) {\n opts.namespace = options.namespace || _Formio.namespace;\n }\n var requestToken = options.headers['x-jwt-token'];\n var result = _Formio.pluginAlter('wrapFetchRequestPromise', _Formio.fetch(url, options), {\n url: url,\n method: method,\n data: data,\n opts: opts\n }).then(function (response) {\n // Allow plugins to respond.\n response = _Formio.pluginAlter('requestResponse', response, _Formio, data);\n if (!response.ok) {\n if (response.status === 440) {\n _Formio.setToken(null, opts);\n _Formio.events.emit('formio.sessionExpired', response.body);\n } else if (response.status === 401) {\n _Formio.events.emit('formio.unauthorized', response.body);\n } else if (response.status === 416) {\n _Formio.events.emit('formio.rangeIsNotSatisfiable', response.body);\n } else if (response.status === 504) {\n return _nativePromiseOnly.default.reject(new Error('Network request failed'));\n }\n\n // Parse and return the error as a rejected promise to reject this promise\n return (response.headers.get('content-type').includes('application/json') ? response.json() : response.text()).then(function (error) {\n return _nativePromiseOnly.default.reject(error);\n });\n }\n\n // Handle fetch results\n var token = response.headers.get('x-jwt-token');\n\n // In some strange cases, the fetch library will return an x-jwt-token without sending\n // one to the server. This has even been debugged on the server to verify that no token\n // was introduced with the request, but the response contains a token. This is an Invalid\n // case where we do not send an x-jwt-token and get one in return for any GET request.\n var tokenIntroduced = false;\n if (method === 'GET' && !requestToken && token && !opts.external && !url.includes('token=') && !url.includes('x-jwt-token=')) {\n console.warn('Token was introduced in request.');\n tokenIntroduced = true;\n }\n if (response.status >= 200 && response.status < 300 && token && token !== '' && !tokenIntroduced) {\n _Formio.setToken(token, opts);\n }\n // 204 is no content. Don't try to .json() it.\n if (response.status === 204) {\n return {};\n }\n var getResult = response.headers.get('content-type').includes('application/json') ? response.json() : response.text();\n return getResult.then(function (result) {\n // Add some content-range metadata to the result here\n var range = response.headers.get('content-range');\n if (range && isObject(result)) {\n range = range.split('/');\n if (range[0] !== '*') {\n var skipLimit = range[0].split('-');\n result.skip = Number(skipLimit[0]);\n result.limit = skipLimit[1] - skipLimit[0] + 1;\n }\n result.serverCount = range[1] === '*' ? range[1] : Number(range[1]);\n }\n if (!opts.getHeaders) {\n return result;\n }\n var headers = {};\n response.headers.forEach(function (item, key) {\n headers[key] = item;\n });\n\n // Return the result with the headers.\n return {\n result: result,\n headers: headers\n };\n });\n }).then(function (result) {\n if (opts.getHeaders) {\n return result;\n }\n\n // Cache the response.\n if (method === 'GET') {\n _Formio.cache[cacheKey] = result;\n }\n return cloneResponse(result);\n }).catch(function (err) {\n if (err === 'Bad Token') {\n _Formio.setToken(null, opts);\n _Formio.events.emit('formio.badToken', err);\n }\n if (err.message) {\n err = new Error(\"Could not connect to API server (\".concat(err.message, \"): \").concat(url));\n err.networkError = true;\n }\n if (method === 'GET') {\n delete _Formio.cache[cacheKey];\n }\n return _nativePromiseOnly.default.reject(err);\n });\n return result;\n }\n\n // Needed to maintain reverse compatability...\n }, {\n key: \"token\",\n get: function get() {\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n return Formio.tokens.formioToken || '';\n }\n\n // Needed to maintain reverse compatability...\n ,\n set: function set(token) {\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n Formio.tokens.formioToken = token || '';\n }\n }, {\n key: \"setToken\",\n value: function setToken() {\n var token = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n var opts = arguments.length > 1 ? arguments[1] : undefined;\n token = token || '';\n opts = typeof opts === 'string' ? {\n namespace: opts\n } : opts || {};\n var tokenName = \"\".concat(opts.namespace || Formio.namespace || 'formio', \"Token\");\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n var storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!token) {\n if (!opts.fromUser) {\n opts.fromToken = true;\n Formio.setUser(null, opts);\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.removeItem(tokenName);\n } catch (err) {\n _browserCookies.default.erase(tokenName, {\n path: '/'\n });\n }\n Formio.tokens[tokenName] = token;\n return _nativePromiseOnly.default.resolve(null);\n }\n if (Formio.tokens[tokenName] !== token) {\n Formio.tokens[tokenName] = token;\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(tokenName, token);\n } catch (err) {\n _browserCookies.default.set(tokenName, token, {\n path: '/'\n });\n }\n }\n // Return or updates the current user\n return this.currentUserResolved ? Formio.currentUser(opts.formio, opts) : _nativePromiseOnly.default.resolve(null);\n }\n }, {\n key: \"getToken\",\n value: function getToken(options) {\n options = typeof options === 'string' ? {\n namespace: options\n } : options || {};\n var tokenName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"Token\");\n var decodedTokenName = options.decode ? \"\".concat(tokenName, \"Decoded\") : tokenName;\n if (!Formio.tokens) {\n Formio.tokens = {};\n }\n if (Formio.tokens[decodedTokenName]) {\n return Formio.tokens[decodedTokenName];\n }\n try {\n var token = localStorage.getItem('useSessionToken') ? sessionStorage.getItem(tokenName) : localStorage.getItem(tokenName);\n Formio.tokens[tokenName] = token || '';\n if (options.decode) {\n Formio.tokens[decodedTokenName] = Formio.tokens[tokenName] ? (0, _jwtDecode.default)(Formio.tokens[tokenName]) : {};\n return Formio.tokens[decodedTokenName];\n }\n return Formio.tokens[tokenName];\n } catch (e) {\n Formio.tokens[tokenName] = _browserCookies.default.get(tokenName);\n return Formio.tokens[tokenName];\n }\n }\n }, {\n key: \"setUser\",\n value: function setUser(user) {\n var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var userName = \"\".concat(opts.namespace || Formio.namespace || 'formio', \"User\");\n var storage = localStorage.getItem('useSessionToken') ? sessionStorage : localStorage;\n if (!user) {\n if (!opts.fromToken) {\n opts.fromUser = true;\n Formio.setToken(null, opts);\n }\n\n // Emit an event on the cleared user.\n Formio.events.emit('formio.user', null);\n\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n return storage.removeItem(userName);\n } catch (err) {\n return _browserCookies.default.erase(userName, {\n path: '/'\n });\n }\n }\n // iOS in private browse mode will throw an error but we can't detect ahead of time that we are in private mode.\n try {\n storage.setItem(userName, JSON.stringify(user));\n } catch (err) {\n _browserCookies.default.set(userName, JSON.stringify(user), {\n path: '/'\n });\n }\n\n // Emit an event on the authenticated user.\n Formio.events.emit('formio.user', user);\n }\n }, {\n key: \"getUser\",\n value: function getUser(options) {\n options = options || {};\n var userName = \"\".concat(options.namespace || Formio.namespace || 'formio', \"User\");\n try {\n return JSON.parse((localStorage.getItem('useSessionToken') ? sessionStorage : localStorage).getItem(userName) || null);\n } catch (e) {\n return JSON.parse(_browserCookies.default.get(userName));\n }\n }\n }, {\n key: \"setBaseUrl\",\n value: function setBaseUrl(url) {\n Formio.baseUrl = url;\n if (!Formio.projectUrlSet) {\n Formio.projectUrl = url;\n }\n }\n }, {\n key: \"getBaseUrl\",\n value: function getBaseUrl() {\n return Formio.baseUrl;\n }\n }, {\n key: \"setApiUrl\",\n value: function setApiUrl(url) {\n return Formio.setBaseUrl(url);\n }\n }, {\n key: \"getApiUrl\",\n value: function getApiUrl() {\n return Formio.getBaseUrl();\n }\n }, {\n key: \"setAppUrl\",\n value: function setAppUrl(url) {\n console.warn('Formio.setAppUrl() is deprecated. Use Formio.setProjectUrl instead.');\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n }, {\n key: \"setProjectUrl\",\n value: function setProjectUrl(url) {\n Formio.projectUrl = url;\n Formio.projectUrlSet = true;\n }\n }, {\n key: \"setAuthUrl\",\n value: function setAuthUrl(url) {\n Formio.authUrl = url;\n }\n }, {\n key: \"getAppUrl\",\n value: function getAppUrl() {\n console.warn('Formio.getAppUrl() is deprecated. Use Formio.getProjectUrl instead.');\n return Formio.projectUrl;\n }\n }, {\n key: \"getProjectUrl\",\n value: function getProjectUrl() {\n return Formio.projectUrl;\n }\n }, {\n key: \"clearCache\",\n value: function clearCache() {\n Formio.cache = {};\n }\n }, {\n key: \"noop\",\n value: function noop() {}\n }, {\n key: \"identity\",\n value: function identity(value) {\n return value;\n }\n }, {\n key: \"deregisterPlugin\",\n value: function deregisterPlugin(plugin) {\n var beforeLength = Formio.plugins.length;\n Formio.plugins = Formio.plugins.filter(function (p) {\n if (p !== plugin && p.__name !== plugin) {\n return true;\n }\n (p.deregister || Formio.noop).call(plugin, Formio);\n return false;\n });\n return beforeLength !== Formio.plugins.length;\n }\n }, {\n key: \"registerPlugin\",\n value: function registerPlugin(plugin, name) {\n var __Formio = Formio;\n __Formio.plugins.push(plugin);\n __Formio.plugins.sort(function (a, b) {\n return (b.priority || 0) - (a.priority || 0);\n });\n plugin.__name = name;\n (plugin.init || __Formio.noop).call(plugin, __Formio);\n }\n }, {\n key: \"getPlugin\",\n value: function getPlugin(name) {\n var _iterator = _createForOfIteratorHelper(Formio.plugins),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var plugin = _step.value;\n if (plugin.__name === name) {\n return plugin;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n return null;\n }\n }, {\n key: \"pluginWait\",\n value: function pluginWait(pluginFn) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n return _nativePromiseOnly.default.all(Formio.plugins.map(function (plugin) {\n var _ref;\n return (_ref = plugin[pluginFn] || Formio.noop).call.apply(_ref, [plugin].concat(args));\n }));\n }\n }, {\n key: \"pluginGet\",\n value: function pluginGet(pluginFn) {\n for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n args[_key3 - 1] = arguments[_key3];\n }\n var callPlugin = function callPlugin(index) {\n var _ref2;\n var plugin = Formio.plugins[index];\n if (!plugin) {\n return _nativePromiseOnly.default.resolve(null);\n }\n return _nativePromiseOnly.default.resolve((_ref2 = plugin[pluginFn] || Formio.noop).call.apply(_ref2, [plugin].concat(args))).then(function (result) {\n if (!isNil(result)) {\n return result;\n }\n return callPlugin(index + 1);\n });\n };\n return callPlugin(0);\n }\n }, {\n key: \"pluginAlter\",\n value: function pluginAlter(pluginFn, value) {\n for (var _len4 = arguments.length, args = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {\n args[_key4 - 2] = arguments[_key4];\n }\n return Formio.plugins.reduce(function (value, plugin) {\n return (plugin[pluginFn] || Formio.identity).apply(void 0, [value].concat(args));\n }, value);\n }\n }, {\n key: \"accessInfo\",\n value: function accessInfo(formio) {\n var projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'accessInfo', \"\".concat(projectUrl, \"/access\"));\n }\n }, {\n key: \"projectRoles\",\n value: function projectRoles(formio) {\n var projectUrl = formio ? formio.projectUrl : Formio.projectUrl;\n return Formio.makeRequest(formio, 'projectRoles', \"\".concat(projectUrl, \"/role\"));\n }\n }, {\n key: \"currentUser\",\n value: function currentUser(formio, options) {\n var _this9 = this;\n var authUrl = Formio.authUrl;\n if (!authUrl) {\n authUrl = formio ? formio.projectUrl : Formio.projectUrl || Formio.baseUrl;\n }\n authUrl += '/current';\n var user = Formio.getUser(options);\n if (user) {\n return Formio.pluginAlter('wrapStaticRequestPromise', _nativePromiseOnly.default.resolve(user), {\n url: authUrl,\n method: 'GET',\n options: options\n });\n }\n var token = Formio.getToken(options);\n if ((!options || !options.external) && !token) {\n return Formio.pluginAlter('wrapStaticRequestPromise', _nativePromiseOnly.default.resolve(null), {\n url: authUrl,\n method: 'GET',\n options: options\n });\n }\n authUrl = \"\".concat(Formio.baseUrl, \"/current\");\n this.currentUserResolved = false;\n return Formio.makeRequest(formio, 'currentUser', authUrl, 'GET', null, options).then(function (response) {\n _this9.currentUserResolved = true;\n Formio.setUser(response, options);\n return response;\n });\n }\n }, {\n key: \"logout\",\n value: function logout(formio, options) {\n options = options || {};\n options.formio = formio;\n var projectUrl = Formio.authUrl ? Formio.authUrl : formio ? formio.projectUrl : Formio.baseUrl;\n var logout = function logout() {\n Formio.setToken(null, options);\n Formio.setUser(null, options);\n Formio.clearCache();\n localStorage.removeItem('useSessionToken');\n };\n return Formio.makeRequest(formio, 'logout', \"\".concat(projectUrl, \"/logout\")).then(function (result) {\n logout();\n return result;\n }).catch(function (err) {\n logout();\n throw err;\n });\n }\n }, {\n key: \"pageQuery\",\n value: function pageQuery() {\n var pageQuery = {};\n pageQuery.paths = [];\n var hashes = location.hash.substr(1).replace(/\\?/g, '&').split('&');\n var parts = [];\n location.search.substr(1).split('&').forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n }\n });\n hashes.forEach(function (item) {\n parts = item.split('=');\n if (parts.length > 1) {\n pageQuery[parts[0]] = parts[1] && decodeURIComponent(parts[1]);\n } else if (item.indexOf('/') === 0) {\n pageQuery.paths = item.substr(1).split('/');\n }\n });\n return pageQuery;\n }\n }, {\n key: \"oAuthCurrentUser\",\n value: function oAuthCurrentUser(formio, token) {\n return Formio.currentUser(formio, {\n external: true,\n headers: {\n Authorization: \"Bearer \".concat(token)\n }\n });\n }\n }, {\n key: \"samlInit\",\n value: function samlInit(options) {\n options = options || {};\n var query = Formio.pageQuery();\n if (query.saml) {\n Formio.setUser(null);\n var retVal = Formio.setToken(query.saml);\n var uri = window.location.toString();\n uri = uri.substring(0, uri.indexOf('?'));\n if (window.location.hash) {\n uri += window.location.hash;\n }\n window.history.replaceState({}, document.title, uri);\n return retVal;\n }\n\n // Set the relay if not provided.\n if (!options.relay) {\n options.relay = window.location.href;\n }\n\n // go to the saml sso endpoint for this project.\n var authUrl = Formio.authUrl || Formio.projectUrl;\n window.location.href = \"\".concat(authUrl, \"/saml/sso?relay=\").concat(encodeURI(options.relay));\n return false;\n }\n }, {\n key: \"oktaInit\",\n value: function oktaInit(options) {\n options = options || {};\n if ((typeof OktaAuth === \"undefined\" ? \"undefined\" : _typeof(OktaAuth)) !== undefined) {\n options.OktaAuth = OktaAuth;\n }\n if (_typeof(options.OktaAuth) === undefined) {\n var errorMessage = 'Cannot find OktaAuth. Please include the Okta JavaScript SDK within your application. See https://developer.okta.com/code/javascript/okta_auth_sdk for an example.';\n console.warn(errorMessage);\n return _nativePromiseOnly.default.reject(errorMessage);\n }\n return new _nativePromiseOnly.default(function (resolve, reject) {\n var Okta = options.OktaAuth;\n delete options.OktaAuth;\n var authClient = new Okta(options);\n authClient.tokenManager.get('accessToken').then(function (accessToken) {\n if (accessToken) {\n resolve(Formio.oAuthCurrentUser(options.formio, accessToken.accessToken));\n } else if (location.hash) {\n authClient.token.parseFromUrl().then(function (token) {\n authClient.tokenManager.add('accessToken', token);\n resolve(Formio.oAuthCurrentUser(options.formio, token.accessToken));\n }).catch(function (err) {\n console.warn(err);\n reject(err);\n });\n } else {\n authClient.token.getWithRedirect({\n responseType: 'token',\n scopes: options.scopes\n });\n resolve(false);\n }\n }).catch(function (error) {\n reject(error);\n });\n });\n }\n }, {\n key: \"ssoInit\",\n value: function ssoInit(type, options) {\n switch (type) {\n case 'saml':\n return Formio.samlInit(options);\n case 'okta':\n return Formio.oktaInit(options);\n default:\n console.warn('Unknown SSO type');\n return _nativePromiseOnly.default.reject('Unknown SSO type');\n }\n }\n }, {\n key: \"requireLibrary\",\n value: function requireLibrary(name, property, src, polling, onload) {\n if (!Formio.libraries.hasOwnProperty(name)) {\n Formio.libraries[name] = {};\n Formio.libraries[name].ready = new _nativePromiseOnly.default(function (resolve, reject) {\n Formio.libraries[name].resolve = resolve;\n Formio.libraries[name].reject = reject;\n });\n var callbackName = \"\".concat(name, \"Callback\");\n if (!polling && !window[callbackName]) {\n window[callbackName] = function () {\n return Formio.libraries[name].resolve();\n };\n }\n\n // See if the plugin already exists.\n var plugin = (0, _get2.default)(window, property);\n if (plugin) {\n Formio.libraries[name].resolve(plugin);\n } else {\n src = Array.isArray(src) ? src : [src];\n src.forEach(function (lib) {\n var attrs = {};\n var elementType = '';\n if (typeof lib === 'string') {\n lib = {\n type: 'script',\n src: lib\n };\n }\n switch (lib.type) {\n case 'script':\n elementType = 'script';\n attrs = {\n src: lib.src,\n type: 'text/javascript',\n defer: true,\n async: true,\n referrerpolicy: 'origin'\n };\n break;\n case 'styles':\n elementType = 'link';\n attrs = {\n href: lib.src,\n rel: 'stylesheet'\n };\n break;\n }\n\n // Add the script to the top of the page.\n var element = document.createElement(elementType);\n if (element.setAttribute) {\n for (var attr in attrs) {\n element.setAttribute(attr, attrs[attr]);\n }\n }\n if (onload) {\n element.addEventListener('load', function () {\n Formio.libraries[name].loaded = true;\n onload(Formio.libraries[name].ready);\n });\n }\n var _document = document,\n head = _document.head;\n if (head) {\n head.appendChild(element);\n }\n });\n\n // if no callback is provided, then check periodically for the script.\n if (polling) {\n var interval = setInterval(function () {\n var plugin = (0, _get2.default)(window, property);\n if (plugin) {\n clearInterval(interval);\n Formio.libraries[name].resolve(plugin);\n }\n }, 200);\n }\n }\n }\n var lib = Formio.libraries[name];\n return onload && lib.loaded ? onload(lib.ready) : lib.ready;\n }\n }, {\n key: \"libraryReady\",\n value: function libraryReady(name) {\n if (Formio.libraries.hasOwnProperty(name) && Formio.libraries[name].ready) {\n return Formio.libraries[name].ready;\n }\n return _nativePromiseOnly.default.reject(\"\".concat(name, \" library was not required.\"));\n }\n }, {\n key: \"addToGlobal\",\n value: function addToGlobal(global) {\n if (_typeof(global) === 'object' && !global.Formio) {\n global.Formio = Formio;\n }\n }\n }, {\n key: \"setPathType\",\n value: function setPathType(type) {\n if (typeof type === 'string') {\n Formio.pathType = type;\n }\n }\n }, {\n key: \"getPathType\",\n value: function getPathType() {\n return Formio.pathType;\n }\n }, {\n key: \"rulesEntities\",\n get: function get() {\n return {\n ValueSources: Formio.ValueSources,\n Conjunctions: Formio.Conjunctions,\n Operators: Formio.Operators,\n Transformers: Formio.Transformers,\n QuickRules: Formio.QuickRules,\n Rules: Formio.Rules\n };\n }\n }, {\n key: \"GlobalFormio\",\n get: function get() {\n if (typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g.Formio) {\n return __webpack_require__.g.Formio;\n } else if (typeof window !== 'undefined' && window.Formio) {\n return window.Formio;\n }\n return Formio;\n }\n }]);\n return Formio;\n}(); // Define all the static properties.\n_defineProperty(Formio, \"currentUserResolved\", true);\nFormio.libraries = {};\nFormio.Promise = _nativePromiseOnly.default;\nFormio.fetch = fetch;\nFormio.Headers = Headers;\nFormio.baseUrl = 'https://api.form.io';\nFormio.projectUrl = Formio.baseUrl;\nFormio.authUrl = '';\nFormio.projectUrlSet = false;\nFormio.plugins = [];\nFormio.cache = {};\nFormio.Providers = _providers.default;\nFormio.version = '0.1.57';\nFormio.pathType = '';\nFormio.events = new _EventEmitter.default();\nFormio.cdn = new _CDN.default();\nif ((Formio.version || '').includes('rc')) {\n Formio.cdn.setBaseUrl('https://cdn.test-form.io');\n}\nif (typeof __webpack_require__.g !== 'undefined') {\n Formio.addToGlobal(__webpack_require__.g);\n}\nif (typeof window !== 'undefined') {\n Formio.addToGlobal(window);\n}\nvar GlobalFormio = Formio.GlobalFormio;\nexports.GlobalFormio = GlobalFormio;\nvar _default = Formio;\nexports[\"default\"] = _default;\n\n//# sourceURL=webpack://Formio/./lib/Formio.js?");
85
85
 
86
86
  /***/ }),
87
87
 
@@ -587,7 +587,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
587
587
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
588
588
 
589
589
  "use strict";
590
- eval("\n\n__webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ \"./node_modules/core-js/modules/es.object.get-prototype-of.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.construct.js */ \"./node_modules/core-js/modules/es.reflect.construct.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.get.js */ \"./node_modules/core-js/modules/es.reflect.get.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ \"./node_modules/core-js/modules/es.object.get-own-property-descriptor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.object.keys.js */ \"./node_modules/core-js/modules/es.object.keys.js\");\n__webpack_require__(/*! core-js/modules/es.string.trim.js */ \"./node_modules/core-js/modules/es.string.trim.js\");\n__webpack_require__(/*! core-js/modules/es.array.join.js */ \"./node_modules/core-js/modules/es.array.join.js\");\n__webpack_require__(/*! core-js/modules/es.array.map.js */ \"./node_modules/core-js/modules/es.array.map.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.string.ends-with.js */ \"./node_modules/core-js/modules/es.string.ends-with.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.array.find.js */ \"./node_modules/core-js/modules/es.array.find.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ../_classes/field/Field */ \"./lib/components/_classes/field/Field.js\"));\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n__webpack_require__(/*! peity */ \"./node_modules/peity/jquery.peity.js\");\nvar _lodash = _interopRequireDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\n/**\n * Here we will derive from the base component which all Form.io form components derive from.\n *\n * @param component\n * @param options\n * @param data\n * @constructor\n */\nvar Data = /*#__PURE__*/function (_Component) {\n _inherits(Data, _Component);\n var _super = _createSuper(Data);\n function Data(component, options, data) {\n var _this;\n _classCallCheck(this, Data);\n _this = _super.call(this, component, options, data);\n _defineProperty(_assertThisInitialized(_this), \"getField\", function (url, path, callback, headers, arrayKey) {\n var xhr = new XMLHttpRequest();\n xhr.open('GET', url, true);\n xhr.responseType = 'json';\n if (headers) {\n Object.keys(headers).forEach(function (key) {\n xhr.setRequestHeader(key, headers[\"\".concat(key)]);\n });\n }\n xhr.onload = function () {\n var status = xhr.status;\n var result = xhr.response;\n result = _lodash.default.get(result, path);\n if (arrayKey && arrayKey.trim().length > 0) {\n // result是数组,需要组合数组\n result = result.map(function (item) {\n return _lodash.default.get(item, arrayKey);\n }).join(',');\n }\n var value = \"\".concat(result);\n try {\n if (!isNaN(Number(value))) {\n value = Number(value).toLocaleString();\n } else {\n value = result;\n }\n } catch (e) {\n console.log(e);\n }\n if (status === 200) {\n callback(value);\n } else {\n callback(value, status);\n }\n };\n xhr.send();\n });\n _this.isLoadingSparkLine = false;\n return _this;\n }\n _createClass(Data, [{\n key: \"render\",\n value: function render() {\n return _get(_getPrototypeOf(Data.prototype), \"render\", this).call(this, this.renderTemplate('data'));\n }\n\n /**\n * After the html string has been mounted into the dom, the dom element is returned here. Use refs to find specific\n * elements to attach functionality to.\n *\n * @param element\n * @returns {Promise}\n */\n }, {\n key: \"attach\",\n value: function attach(element) {\n var _this2 = this;\n var self = this;\n var refs = {\n dataContainer: 'single',\n refHeader: 'single',\n refSubHeader: 'single',\n refValue: 'single',\n refSubValue: 'single',\n refHeaderContent: 'single',\n refSparkLineTitle: 'single',\n refIcon: 'single'\n };\n this.loadRefs(element, refs);\n var dataContainer = this.refs.dataContainer;\n if (dataContainer) {\n var rect = dataContainer.getBoundingClientRect();\n this.refs.dataContainer.style['background-size'] = \"\".concat(rect.width, \"px \").concat(rect.height, \"px\");\n var clickEventType = this.component['click-event-type'];\n if (clickEventType) {\n var clickEventUrl;\n var url = window.location.href;\n url = url.split('/index.html')[0];\n if (url.endsWith('/design')) {\n url = url.substring(0, url.length - '/design'.length);\n } else if (url.endsWith('/task')) {\n url = url.substring(0, url.length - '/task'.length);\n } else if (url.endsWith('/admin')) {\n url = url.substring(0, url.length - '/admin'.length);\n } else if (url.endsWith('/automation')) {\n url = url.substring(0, url.length - '/automation'.length);\n }\n switch (clickEventType) {\n case 'url':\n clickEventUrl = this.component['click-event-url'];\n break;\n case 'processDefList':\n clickEventUrl = \"\".concat(url, \"/task/index.html#/application/list?defaultSearchProcessDefinitionKeyIn=\").concat(this.component['click-event-process-def-keys']);\n break;\n case 'taskList':\n clickEventUrl = \"\".concat(url, \"/task/index.html#/task/list?defaultSearchProcessDefinitionKeyIn=\").concat(this.component['click-event-task-keys']);\n break;\n }\n this.addEventListener(dataContainer, 'click', function (event) {\n var params = self.component['click-event-params'];\n try {\n params = JSON.parse(self.parseTpl(params, {\n data: self.rootValue\n }, '{}'));\n } catch (e) {\n params = {};\n }\n // 点击事件\n switch (clickEventType) {\n case 'newProcessInstance':\n window.startProcessByDrawer({\n processKey: self.component['click-event-process-def-key'],\n label: '启动',\n field: self.component['key'],\n lockDrawer: self.component['click-event-lock-drawer'],\n preData: params\n });\n break;\n case 'taskListPanel':\n window.openTaskListByDrawer({\n processKey: self.component['click-event-process-def-keys'],\n label: '',\n field: self.component['key']\n });\n break;\n case 'newTab':\n window.openNewTab({\n formId: self.component['click-event-form-id'],\n label: '',\n field: self.component['key'],\n preData: params\n });\n break;\n default:\n window.open(clickEventUrl, '_blank');\n break;\n }\n });\n }\n }\n var customStyleStr = this.component['custom-style-bg'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.dataContainer.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-title'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refHeader.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-sub-title'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refSubHeader.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-value'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refValue.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-sub-value'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refSubValue.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n setTimeout(function () {\n _this2.setValue('');\n }, 100);\n return _get(_getPrototypeOf(Data.prototype), \"attach\", this).call(this, element);\n }\n }, {\n key: \"parseTpl\",\n value: function parseTpl(template, map, defaultVal) {\n if (template && template.length > 0) {\n try {\n return template.replace(/\\$\\{.+?}/g, function (match) {\n var _$get;\n var path = match.substr(2, match.length - 3).trim();\n return (_$get = _lodash.default.get(map, path)) !== null && _$get !== void 0 ? _$get : '--';\n });\n } catch (e) {\n console.log(e);\n }\n }\n return defaultVal !== null && defaultVal !== void 0 ? defaultVal : '';\n }\n }, {\n key: \"getValue\",\n value:\n /**\n * Get the value of the component from the dom elements.\n *\n * @returns {Array}\n */\n function getValue() {\n return this.component.field;\n }\n\n /**\n * Set the value of the component into the dom elements.\n *\n * @param value\n * @returns {boolean}\n */\n }, {\n key: \"setValue\",\n value: function setValue(value) {\n var _this3 = this;\n var self = this;\n try {\n var _this$component$icon, _this$component$icon2, _this$component$value, _this$component$value2;\n var container = this.element.querySelector('.data-container');\n this.component['icon-field'] = (_this$component$icon = this.component['icon-field']) !== null && _this$component$icon !== void 0 ? _this$component$icon : this.component.icon;\n this.component['icon-color'] = (_this$component$icon2 = this.component['icon-color']) !== null && _this$component$icon2 !== void 0 ? _this$component$icon2 : this.component.color;\n this.component['value-field'] = (_this$component$value = this.component['value-field']) !== null && _this$component$value !== void 0 ? _this$component$value : this.component.field;\n this.component['value-url'] = (_this$component$value2 = this.component['value-url']) !== null && _this$component$value2 !== void 0 ? _this$component$value2 : this.component.url;\n\n // icon\n if (this.component['icon-field']) {\n var icon = this.parseTpl(this.component['icon-field'], {\n data: this.rootValue\n });\n this.refs.refIcon.className = \"fa-fw \".concat(icon);\n var iconColor = this.parseTpl(this.component['icon-color'], {\n data: this.rootValue\n });\n this.refs.refIcon.style.color = iconColor;\n } else {\n this.refs.refIcon.style.display = 'none';\n }\n // header\n this.refs.refHeaderContent.innerHTML = self.interpolate(self.parseTpl(self.component['header'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n this.refs.refSubHeader.innerHTML = self.interpolate(self.parseTpl(self.component['sub-header'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n this.refs.refSparkLineTitle.innerHTML = self.interpolate(self.parseTpl(self.component['sparkLine-title'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n var sparkLineType = this.component['sparkLine-type'] || 'line';\n var fillColor;\n if (self.component['sparkLine-fill-color']) {\n switch (sparkLineType) {\n case 'line':\n fillColor = self.component['sparkLine-fill-color'].split(',')[0];\n break;\n case 'pie':\n case 'donut':\n case 'bar':\n fillColor = self.component['sparkLine-fill-color'].split(',');\n break;\n }\n }\n var element = container.querySelector('h2');\n if (this.component['value-url']) {\n var url = this.parseTpl(this.component['value-url'], {\n data: this.rootValue\n });\n var headers = {};\n try {\n headers = this.parseTpl(this.component['value-headers'], {\n data: this.rootValue\n }, '{}');\n if (typeof headers === 'string') {\n headers = JSON.parse(headers);\n }\n } catch (e) {\n headers = {};\n console.log(e);\n }\n if (this.component['new-value-headers']) {\n var newValueHeaders = this.component['new-value-headers'];\n newValueHeaders.forEach(function (header) {\n if (header.key && header.key.length > 0 && header.value && header.value.length > 0) {\n headers[\"\".concat(header.key)] = _this3.parseTpl(header.value, {\n data: _this3.rootValue\n });\n }\n });\n }\n this.getField(url, this.component['value-field'], function (field) {\n container.querySelector('h2').textContent = field;\n }, headers);\n } else {\n element.innerHTML = self.interpolate(self.parseTpl(self.component['value-field'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n ;\n }\n element = container.querySelector('.unit-container');\n if (this.component['subValue-url']) {\n var _url = this.parseTpl(this.component['subValue-url'], {\n data: this.rootValue\n });\n this.getField(_url, this.component['subValue-field'], function (field) {\n container.querySelector('.unit-container').textContent = field;\n }, {});\n } else {\n element.innerHTML = self.interpolate(self.parseTpl(self.component['subValue-field'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n ;\n }\n if (self.isLoadingSparkLine) {\n return true;\n }\n self.isLoadingSparkLine = true;\n if (self.component['sparkLine-dataSrc'] === 'values' && self.component['sparkLine-const-field'] && self.component['sparkLine-const-field'].length > 0) {\n // values\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(self.component['sparkLine-const-field'], \"</span>\");\n // @ts-ignore\n (0, _jquery.default)(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n self.isLoadingSparkLine = false;\n } else if (self.component['sparkLine-dataSrc'] === 'url' && self.component['sparkLine-url'] && self.component['sparkLine-url'].length > 0) {\n // url\n var _url2 = this.parseTpl(this.component['sparkLine-url'], {\n data: this.rootValue\n });\n var _headers = {};\n try {\n _headers = self.parseTpl(self.component['sparkLine-headers'], {\n data: self.rootValue\n }, '{}');\n if (typeof _headers === 'string') {\n _headers = JSON.parse(_headers);\n }\n } catch (e) {\n _headers = {};\n console.log(e);\n }\n if (this.component['new-sparkLine-headers']) {\n var _newValueHeaders = this.component['new-sparkLine-headers'];\n _newValueHeaders.forEach(function (header) {\n if (header.key && header.key.length > 0 && header.value && header.value.length > 0) {\n _headers[\"\".concat(header.key)] = _this3.parseTpl(header.value, {\n data: _this3.rootValue\n });\n }\n });\n }\n self.getField(_url2, self.component['sparkLine-field'], function (field) {\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(field, \"</span>\");\n\n // @ts-ignore\n (0, _jquery.default)(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n self.isLoadingSparkLine = false;\n }, _headers, self.component['sparkLine-array-field']);\n }\n } catch (e) {\n console.log(e);\n }\n return true;\n }\n }], [{\n key: \"schema\",\n value: function schema() {\n for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {\n extend[_key] = arguments[_key];\n }\n return _Field.default.schema.apply(_Field.default, [{\n type: 'data',\n icon: '',\n color: '#ff7754',\n header: '',\n url: '',\n field: ''\n }].concat(extend));\n }\n }, {\n key: \"builderInfo\",\n get: function get() {\n return {\n title: 'Info Block',\n group: 'advanced',\n icon: 'square-info',\n weight: 70,\n schema: Data.schema()\n };\n }\n }]);\n return Data;\n}(_Field.default);\nexports[\"default\"] = Data;\n\n//# sourceURL=webpack://Formio/./lib/components/Data/Data.js?");
590
+ eval("\n\n__webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ \"./node_modules/core-js/modules/es.object.get-prototype-of.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.construct.js */ \"./node_modules/core-js/modules/es.reflect.construct.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.get.js */ \"./node_modules/core-js/modules/es.reflect.get.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ \"./node_modules/core-js/modules/es.object.get-own-property-descriptor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.object.keys.js */ \"./node_modules/core-js/modules/es.object.keys.js\");\n__webpack_require__(/*! core-js/modules/es.string.trim.js */ \"./node_modules/core-js/modules/es.string.trim.js\");\n__webpack_require__(/*! core-js/modules/es.array.join.js */ \"./node_modules/core-js/modules/es.array.join.js\");\n__webpack_require__(/*! core-js/modules/es.array.map.js */ \"./node_modules/core-js/modules/es.array.map.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.string.ends-with.js */ \"./node_modules/core-js/modules/es.string.ends-with.js\");\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.array.find.js */ \"./node_modules/core-js/modules/es.array.find.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ../_classes/field/Field */ \"./lib/components/_classes/field/Field.js\"));\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n__webpack_require__(/*! peity */ \"./node_modules/peity/jquery.peity.js\");\nvar _lodash = _interopRequireDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\n/**\n * Here we will derive from the base component which all Form.io form components derive from.\n *\n * @param component\n * @param options\n * @param data\n * @constructor\n */\nvar Data = /*#__PURE__*/function (_Component) {\n _inherits(Data, _Component);\n var _super = _createSuper(Data);\n function Data(component, options, data) {\n var _this;\n _classCallCheck(this, Data);\n _this = _super.call(this, component, options, data);\n _defineProperty(_assertThisInitialized(_this), \"getField\", function (url, path, callback, headers, arrayKey) {\n var xhr = new XMLHttpRequest();\n xhr.open('GET', url, true);\n xhr.responseType = 'json';\n if (headers) {\n Object.keys(headers).forEach(function (key) {\n xhr.setRequestHeader(key, headers[\"\".concat(key)]);\n });\n }\n xhr.onload = function () {\n var status = xhr.status;\n var result = xhr.response;\n result = _lodash.default.get(result, path);\n if (arrayKey && arrayKey.trim().length > 0) {\n // result是数组,需要组合数组\n result = result.map(function (item) {\n return _lodash.default.get(item, arrayKey);\n }).join(',');\n }\n var value = \"\".concat(result);\n try {\n if (!isNaN(Number(value))) {\n value = Number(value).toLocaleString();\n } else {\n value = result;\n }\n } catch (e) {\n console.log(e);\n }\n if (status === 200) {\n callback(value);\n } else {\n callback(value, status);\n }\n };\n xhr.send();\n });\n _this.isLoadingSparkLine = false;\n return _this;\n }\n _createClass(Data, [{\n key: \"render\",\n value: function render() {\n return _get(_getPrototypeOf(Data.prototype), \"render\", this).call(this, this.renderTemplate('data'));\n }\n\n /**\n * After the html string has been mounted into the dom, the dom element is returned here. Use refs to find specific\n * elements to attach functionality to.\n *\n * @param element\n * @returns {Promise}\n */\n }, {\n key: \"attach\",\n value: function attach(element) {\n var _this2 = this;\n var self = this;\n var refs = {\n dataContainer: 'single',\n refHeader: 'single',\n refSubHeader: 'single',\n refValue: 'single',\n refSubValue: 'single',\n refHeaderContent: 'single',\n refSparkLineTitle: 'single',\n refIcon: 'single'\n };\n this.loadRefs(element, refs);\n var dataContainer = this.refs.dataContainer;\n if (dataContainer) {\n var rect = dataContainer.getBoundingClientRect();\n this.refs.dataContainer.style['background-size'] = \"\".concat(rect.width, \"px \").concat(rect.height, \"px\");\n var clickEventType = self.component['click-event-type'];\n if (clickEventType) {\n var clickEventUrl;\n var url = window.location.href;\n url = url.split('/index.html')[0];\n if (url.endsWith('/design')) {\n url = url.substring(0, url.length - '/design'.length);\n } else if (url.endsWith('/task')) {\n url = url.substring(0, url.length - '/task'.length);\n } else if (url.endsWith('/admin')) {\n url = url.substring(0, url.length - '/admin'.length);\n } else if (url.endsWith('/automation')) {\n url = url.substring(0, url.length - '/automation'.length);\n }\n switch (clickEventType) {\n case 'url':\n clickEventUrl = self.parseTpl(self.component['click-event-url'], {\n data: self.rootValue\n });\n break;\n case 'processDefList':\n clickEventUrl = \"\".concat(url, \"/task/index.html#/application/list?defaultSearchProcessDefinitionKeyIn=\").concat(self.parseTpl(self.component['click-event-process-def-keys'], {\n data: self.rootValue\n }));\n break;\n case 'taskList':\n clickEventUrl = \"\".concat(url, \"/task/index.html#/task/list?defaultSearchProcessDefinitionKeyIn=\").concat(self.parseTpl(self.component['click-event-task-keys'], {\n data: self.rootValue\n }));\n break;\n }\n this.addEventListener(dataContainer, 'click', function (event) {\n var params = self.component['click-event-params'];\n try {\n params = JSON.parse(self.parseTpl(params, {\n data: self.rootValue\n }, '{}'));\n } catch (e) {\n params = {};\n }\n // 点击事件\n switch (clickEventType) {\n case 'newProcessInstance':\n window.startProcessByDrawer({\n processKey: self.parseTpl(self.component['click-event-process-def-key'], {\n data: self.rootValue\n }),\n label: '启动',\n field: self.component['key'],\n lockDrawer: self.component['click-event-lock-drawer'],\n preData: params\n });\n break;\n case 'taskListPanel':\n window.openTaskListByDrawer({\n processKey: self.parseTpl(self.component['click-event-process-def-keys'], {\n data: self.rootValue\n }),\n label: '',\n field: self.component['key']\n });\n break;\n case 'newTab':\n window.openNewTab({\n formId: self.parseTpl(self.component['click-event-form-id'], {\n data: self.rootValue\n }),\n label: '',\n field: self.component['key'],\n preData: params\n });\n break;\n default:\n window.open(clickEventUrl, '_blank');\n break;\n }\n });\n }\n }\n var customStyleStr = this.component['custom-style-bg'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.dataContainer.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-title'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refHeader.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-sub-title'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refSubHeader.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-value'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refValue.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n customStyleStr = this.component['custom-style-sub-value'];\n if (customStyleStr && customStyleStr.length > 0) {\n try {\n customStyleStr = this.parseTpl(customStyleStr, {\n data: this.rootValue\n }, '{}');\n _lodash.default.forEach(JSON.parse(customStyleStr), function (value, key) {\n _this2.refs.refSubValue.style[key] = value;\n });\n } catch (e) {\n console.warn(e);\n }\n }\n setTimeout(function () {\n _this2.setValue('');\n }, 100);\n return _get(_getPrototypeOf(Data.prototype), \"attach\", this).call(this, element);\n }\n }, {\n key: \"parseTpl\",\n value: function parseTpl(template, map, defaultVal) {\n if (template && template.length > 0) {\n try {\n return template.replace(/\\$\\{.+?}/g, function (match) {\n var _$get;\n var path = match.substr(2, match.length - 3).trim();\n return (_$get = _lodash.default.get(map, path)) !== null && _$get !== void 0 ? _$get : '--';\n });\n } catch (e) {\n console.log(e);\n }\n }\n return defaultVal !== null && defaultVal !== void 0 ? defaultVal : '';\n }\n }, {\n key: \"getValue\",\n value:\n /**\n * Get the value of the component from the dom elements.\n *\n * @returns {Array}\n */\n function getValue() {\n return this.component.field;\n }\n\n /**\n * Set the value of the component into the dom elements.\n *\n * @param value\n * @returns {boolean}\n */\n }, {\n key: \"setValue\",\n value: function setValue(value) {\n var _this3 = this;\n var self = this;\n try {\n var _this$component$icon, _this$component$icon2, _this$component$value, _this$component$value2;\n var container = this.element.querySelector('.data-container');\n this.component['icon-field'] = (_this$component$icon = this.component['icon-field']) !== null && _this$component$icon !== void 0 ? _this$component$icon : this.component.icon;\n this.component['icon-color'] = (_this$component$icon2 = this.component['icon-color']) !== null && _this$component$icon2 !== void 0 ? _this$component$icon2 : this.component.color;\n this.component['value-field'] = (_this$component$value = this.component['value-field']) !== null && _this$component$value !== void 0 ? _this$component$value : this.component.field;\n this.component['value-url'] = (_this$component$value2 = this.component['value-url']) !== null && _this$component$value2 !== void 0 ? _this$component$value2 : this.component.url;\n\n // icon\n if (this.component['icon-field']) {\n var icon = this.parseTpl(this.component['icon-field'], {\n data: this.rootValue\n });\n this.refs.refIcon.className = \"fa-fw \".concat(icon);\n var iconColor = this.parseTpl(this.component['icon-color'], {\n data: this.rootValue\n });\n this.refs.refIcon.style.color = iconColor;\n } else {\n this.refs.refIcon.style.display = 'none';\n }\n // header\n this.refs.refHeaderContent.innerHTML = self.interpolate(self.parseTpl(self.component['header'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n this.refs.refSubHeader.innerHTML = self.interpolate(self.parseTpl(self.component['sub-header'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n this.refs.refSparkLineTitle.innerHTML = self.interpolate(self.parseTpl(self.component['sparkLine-title'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n var sparkLineType = this.component['sparkLine-type'] || 'line';\n var fillColor;\n if (self.component['sparkLine-fill-color']) {\n switch (sparkLineType) {\n case 'line':\n fillColor = self.component['sparkLine-fill-color'].split(',')[0];\n break;\n case 'pie':\n case 'donut':\n case 'bar':\n fillColor = self.component['sparkLine-fill-color'].split(',');\n break;\n }\n }\n var element = container.querySelector('h2');\n if (this.component['value-url']) {\n var url = this.parseTpl(this.component['value-url'], {\n data: this.rootValue\n });\n var headers = {};\n try {\n headers = this.parseTpl(this.component['value-headers'], {\n data: this.rootValue\n }, '{}');\n if (typeof headers === 'string') {\n headers = JSON.parse(headers);\n }\n } catch (e) {\n headers = {};\n console.log(e);\n }\n if (this.component['new-value-headers']) {\n var newValueHeaders = this.component['new-value-headers'];\n newValueHeaders.forEach(function (header) {\n if (header.key && header.key.length > 0 && header.value && header.value.length > 0) {\n headers[\"\".concat(header.key)] = _this3.parseTpl(header.value, {\n data: _this3.rootValue\n });\n }\n });\n }\n this.getField(url, this.component['value-field'], function (field) {\n container.querySelector('h2').textContent = field;\n }, headers);\n } else {\n element.innerHTML = self.interpolate(self.parseTpl(self.component['value-field'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n ;\n }\n element = container.querySelector('.unit-container');\n if (this.component['subValue-url']) {\n var _url = this.parseTpl(this.component['subValue-url'], {\n data: this.rootValue\n });\n this.getField(_url, this.component['subValue-field'], function (field) {\n container.querySelector('.unit-container').textContent = field;\n }, {});\n } else {\n element.innerHTML = self.interpolate(self.parseTpl(self.component['subValue-field'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n ;\n }\n if (self.isLoadingSparkLine) {\n return true;\n }\n self.isLoadingSparkLine = true;\n if (self.component['sparkLine-dataSrc'] === 'values' && self.component['sparkLine-const-field'] && self.component['sparkLine-const-field'].length > 0) {\n // values\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(self.component['sparkLine-const-field'], \"</span>\");\n // @ts-ignore\n (0, _jquery.default)(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n self.isLoadingSparkLine = false;\n } else if (self.component['sparkLine-dataSrc'] === 'url' && self.component['sparkLine-url'] && self.component['sparkLine-url'].length > 0) {\n // url\n var _url2 = this.parseTpl(this.component['sparkLine-url'], {\n data: this.rootValue\n });\n var _headers = {};\n try {\n _headers = self.parseTpl(self.component['sparkLine-headers'], {\n data: self.rootValue\n }, '{}');\n if (typeof _headers === 'string') {\n _headers = JSON.parse(_headers);\n }\n } catch (e) {\n _headers = {};\n console.log(e);\n }\n if (this.component['new-sparkLine-headers']) {\n var _newValueHeaders = this.component['new-sparkLine-headers'];\n _newValueHeaders.forEach(function (header) {\n if (header.key && header.key.length > 0 && header.value && header.value.length > 0) {\n _headers[\"\".concat(header.key)] = _this3.parseTpl(header.value, {\n data: _this3.rootValue\n });\n }\n });\n }\n self.getField(_url2, self.component['sparkLine-field'], function (field) {\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(field, \"</span>\");\n\n // @ts-ignore\n (0, _jquery.default)(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n self.isLoadingSparkLine = false;\n }, _headers, self.component['sparkLine-array-field']);\n }\n } catch (e) {\n console.log(e);\n }\n return true;\n }\n }], [{\n key: \"schema\",\n value: function schema() {\n for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {\n extend[_key] = arguments[_key];\n }\n return _Field.default.schema.apply(_Field.default, [{\n type: 'data',\n icon: '',\n color: '#ff7754',\n header: '',\n url: '',\n field: ''\n }].concat(extend));\n }\n }, {\n key: \"builderInfo\",\n get: function get() {\n return {\n title: 'Info Block',\n group: 'advanced',\n icon: 'square-info',\n weight: 70,\n schema: Data.schema()\n };\n }\n }]);\n return Data;\n}(_Field.default);\nexports[\"default\"] = Data;\n\n//# sourceURL=webpack://Formio/./lib/components/Data/Data.js?");
591
591
 
592
592
  /***/ }),
593
593
 
@@ -620,7 +620,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
620
620
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
621
621
 
622
622
  "use strict";
623
- eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n__webpack_require__(/*! core-js/modules/es.reflect.construct.js */ \"./node_modules/core-js/modules/es.reflect.construct.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.get.js */ \"./node_modules/core-js/modules/es.reflect.get.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ \"./node_modules/core-js/modules/es.object.get-own-property-descriptor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.string.trim.js */ \"./node_modules/core-js/modules/es.string.trim.js\");\n__webpack_require__(/*! core-js/modules/es.array.find.js */ \"./node_modules/core-js/modules/es.array.find.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ \"./node_modules/core-js/modules/es.object.get-prototype-of.js\");\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ../_classes/field/Field */ \"./lib/components/_classes/field/Field.js\"));\n__webpack_require__(/*! peity */ \"./node_modules/peity/jquery.peity.js\");\nvar _lodash = _interopRequireDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n/**\n * Here we will derive from the base component which all Form.io form components derive from.\n *\n * @param component\n * @param options\n * @param data\n * @constructor\n */\nvar DataChinaGrid = /*#__PURE__*/function (_Component) {\n _inherits(DataChinaGrid, _Component);\n var _super = _createSuper(DataChinaGrid);\n function DataChinaGrid(component, options, data) {\n var _this;\n _classCallCheck(this, DataChinaGrid);\n _this = _super.call(this, component, options, data);\n _this.isLoadingSparkLine = false;\n return _this;\n }\n _createClass(DataChinaGrid, [{\n key: \"render\",\n value: function render() {\n return _get(_getPrototypeOf(DataChinaGrid.prototype), \"render\", this).call(this, this.renderTemplate('dataChinaGrid'));\n }\n\n /**\n * After the html string has been mounted into the dom, the dom element is returned here. Use refs to find specific\n * elements to attach functionality to.\n *\n * @param element\n * @returns {Promise}\n */\n }, {\n key: \"attach\",\n value: function attach(element) {\n var _this2 = this;\n var self = this;\n var refs = {\n dataContainer: 'single'\n };\n this.loadRefs(element, refs);\n var dataContainer = this.refs.dataContainer;\n if (dataContainer) {\n var clickEventType = this.component['click-event-type'];\n if (clickEventType) {\n this.addEventListener(dataContainer, 'click', function (event) {\n // 点击事件\n var params;\n switch (clickEventType) {\n case 'newPage':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openNewPage(_this2.component['click-event-form-id'], params);\n break;\n case 'bottomSheet':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openBottomSheet(_this2.component['click-event-form-id'], params);\n break;\n case 'setTab':\n // 切换tab\n Formio.forms[_this2.currentForm.id].getComponent(_this2.component['click-event-tab-id']).setTabByKey(_this2.component['click-event-tab-key']);\n break;\n case 'openUrl':\n if (window.openNewUrlByQmx) {\n window.openNewUrlByQmx(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n } else {\n window.open(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n }\n break;\n }\n });\n }\n }\n setTimeout(function () {\n _this2.setValue('');\n }, 100);\n return _get(_getPrototypeOf(DataChinaGrid.prototype), \"attach\", this).call(this, element);\n }\n }, {\n key: \"parseTpl\",\n value: function parseTpl(template, map) {\n if (template && template.length > 0) {\n try {\n return template.replace(/\\$\\{.+?}/g, function (match) {\n var _$get;\n var path = match.substr(2, match.length - 3).trim();\n return (_$get = _lodash.default.get(map, path)) !== null && _$get !== void 0 ? _$get : '--';\n });\n } catch (e) {\n console.log(e);\n }\n }\n return '{}';\n }\n\n /**\n * Get the value of the component from the dom elements.\n *\n * @returns {Array}\n */\n }, {\n key: \"getValue\",\n value: function getValue() {\n return this.component.field;\n }\n }, {\n key: \"resetSparkLine\",\n value: function resetSparkLine() {\n var self = this;\n var container = this.element.querySelector('.data-container');\n if (self.component['enable-sparkline']) {\n if (self.isLoadingSparkLine) {\n return true;\n }\n self.isLoadingSparkLine = true;\n var sparkLineType = this.component['sparkLine-type'] || 'line';\n var fillColor;\n if (self.component['sparkLine-fill-color']) {\n switch (sparkLineType) {\n case 'line':\n fillColor = self.component['sparkLine-fill-color'].split(',')[0];\n break;\n case 'pie':\n case 'donut':\n case 'bar':\n fillColor = self.component['sparkLine-fill-color'].split(',');\n break;\n }\n }\n // values\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(self.parseTpl(self.component['sparkLine-value'], {\n data: self.rootValue\n }), \"</span>\");\n try {\n // @ts-ignore\n $(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n self.isLoadingSparkLine = false;\n } catch (e) {\n container.querySelectorAll(\".line\").forEach(function (e) {\n return peity(e, sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n });\n self.isLoadingSparkLine = false;\n }\n }\n }\n\n /**\n * Set the value of the component into the dom elements.\n *\n * @param value\n * @returns {boolean}\n */\n }, {\n key: \"setValue\",\n value: function setValue(value) {\n var _this3 = this;\n var self = this;\n try {\n var container = this.element.querySelector('.data-container');\n try {\n var customStyle = JSON.parse(this.component[\"custom-style\"] || {});\n _lodash.default.forEach(customStyle, function (value, key) {\n _this3.refs.dataContainer.style[key] = value;\n });\n } catch (e) {}\n // 标题设置\n var element = container.querySelector('.title-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['title-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.value-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['value-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.footer-container-value1');\n var footerContentStr = self.component['footer-content1'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value2');\n footerContentStr = self.component['footer-content2'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value3');\n if (element) {\n footerContentStr = self.component['footer-content3'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n }\n // 图标\n self.resetSparkLine();\n } catch (e) {\n console.log(e);\n }\n return true;\n }\n }], [{\n key: \"schema\",\n value: function schema() {\n for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {\n extend[_key] = arguments[_key];\n }\n return _Field.default.schema.apply(_Field.default, [{\n type: 'data_china_grid',\n \"title-content\": \"低压问题综合治理率 <i class=\\\"fa fa-info-circle\\\" aria-hidden=\\\"true\\\"></i>\",\n \"value-content\": \"160 <i style='font-size: 10px;color: #0a6ebd'>%</i>\",\n \"footer-content1\": \"name\",\n \"footer-content2\": \"<div style='color:red'>up</div>\",\n \"footer-content3\": \"info\",\n \"footer-content\": \"开始时间\"\n }].concat(extend));\n }\n }, {\n key: \"builderInfo\",\n get: function get() {\n return {\n title: 'Info Block ChinaFrid',\n group: 'advanced',\n icon: 'square-info',\n weight: 70,\n schema: DataChinaGrid.schema()\n };\n }\n }]);\n return DataChinaGrid;\n}(_Field.default);\nexports[\"default\"] = DataChinaGrid;\n\n//# sourceURL=webpack://Formio/./lib/components/DataChinaGrid/Data.js?");
623
+ eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n__webpack_require__(/*! core-js/modules/es.reflect.construct.js */ \"./node_modules/core-js/modules/es.reflect.construct.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.get.js */ \"./node_modules/core-js/modules/es.reflect.get.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ \"./node_modules/core-js/modules/es.object.get-own-property-descriptor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.string.trim.js */ \"./node_modules/core-js/modules/es.string.trim.js\");\n__webpack_require__(/*! core-js/modules/es.array.find.js */ \"./node_modules/core-js/modules/es.array.find.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ \"./node_modules/core-js/modules/es.object.get-prototype-of.js\");\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ../_classes/field/Field */ \"./lib/components/_classes/field/Field.js\"));\n__webpack_require__(/*! peity */ \"./node_modules/peity/jquery.peity.js\");\nvar _lodash = _interopRequireDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n/**\n * Here we will derive from the base component which all Form.io form components derive from.\n *\n * @param component\n * @param options\n * @param data\n * @constructor\n */\nvar DataChinaGrid = /*#__PURE__*/function (_Component) {\n _inherits(DataChinaGrid, _Component);\n var _super = _createSuper(DataChinaGrid);\n function DataChinaGrid(component, options, data) {\n var _this;\n _classCallCheck(this, DataChinaGrid);\n _this = _super.call(this, component, options, data);\n _this.isLoadingSparkLine = false;\n return _this;\n }\n _createClass(DataChinaGrid, [{\n key: \"render\",\n value: function render() {\n return _get(_getPrototypeOf(DataChinaGrid.prototype), \"render\", this).call(this, this.renderTemplate('dataChinaGrid'));\n }\n\n /**\n * After the html string has been mounted into the dom, the dom element is returned here. Use refs to find specific\n * elements to attach functionality to.\n *\n * @param element\n * @returns {Promise}\n */\n }, {\n key: \"attach\",\n value: function attach(element) {\n var _this2 = this;\n var self = this;\n var refs = {\n dataContainer: 'single'\n };\n this.loadRefs(element, refs);\n var dataContainer = this.refs.dataContainer;\n if (dataContainer) {\n var clickEventType = this.component['click-event-type'];\n if (clickEventType) {\n this.addEventListener(dataContainer, 'click', function (event) {\n // 点击事件\n var params;\n switch (clickEventType) {\n case 'newPage':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openNewPage(self.parseTpl(self.component['click-event-form-id'], {\n data: self.rootValue\n }), params);\n break;\n case 'bottomSheet':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openBottomSheet(self.parseTpl(self.component['click-event-form-id'], {\n data: self.rootValue\n }), params);\n break;\n case 'setTab':\n // 切换tab\n Formio.forms[_this2.currentForm.id].getComponent(self.parseTpl(self.component['click-event-tab-id'], {\n data: self.rootValue\n })).setTabByKey(self.parseTpl(self.component['click-event-tab-key'], {\n data: self.rootValue\n }));\n break;\n case 'openUrl':\n if (window.openNewUrlByQmx) {\n window.openNewUrlByQmx(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n } else {\n window.open(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n }\n break;\n }\n });\n }\n }\n setTimeout(function () {\n _this2.setValue('');\n }, 100);\n return _get(_getPrototypeOf(DataChinaGrid.prototype), \"attach\", this).call(this, element);\n }\n }, {\n key: \"parseTpl\",\n value: function parseTpl(template, map) {\n if (template && template.length > 0) {\n try {\n return template.replace(/\\$\\{.+?}/g, function (match) {\n var _$get;\n var path = match.substr(2, match.length - 3).trim();\n return (_$get = _lodash.default.get(map, path)) !== null && _$get !== void 0 ? _$get : '--';\n });\n } catch (e) {\n console.log(e);\n }\n }\n return '{}';\n }\n\n /**\n * Get the value of the component from the dom elements.\n *\n * @returns {Array}\n */\n }, {\n key: \"getValue\",\n value: function getValue() {\n return this.component.field;\n }\n }, {\n key: \"resetSparkLine\",\n value: function resetSparkLine() {\n var self = this;\n var container = this.element.querySelector('.data-container');\n if (self.component['enable-sparkline']) {\n if (self.isLoadingSparkLine) {\n return true;\n }\n self.isLoadingSparkLine = true;\n var sparkLineType = this.component['sparkLine-type'] || 'line';\n var fillColor;\n if (self.component['sparkLine-fill-color']) {\n switch (sparkLineType) {\n case 'line':\n fillColor = self.component['sparkLine-fill-color'].split(',')[0];\n break;\n case 'pie':\n case 'donut':\n case 'bar':\n fillColor = self.component['sparkLine-fill-color'].split(',');\n break;\n }\n }\n // values\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(self.parseTpl(self.component['sparkLine-value'], {\n data: self.rootValue\n }), \"</span>\");\n try {\n // @ts-ignore\n $(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n self.isLoadingSparkLine = false;\n } catch (e) {\n container.querySelectorAll(\".line\").forEach(function (e) {\n return peity(e, sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: self.component['sparkLine-width']\n });\n });\n self.isLoadingSparkLine = false;\n }\n }\n }\n\n /**\n * Set the value of the component into the dom elements.\n *\n * @param value\n * @returns {boolean}\n */\n }, {\n key: \"setValue\",\n value: function setValue(value) {\n var _this3 = this;\n var self = this;\n try {\n var container = this.element.querySelector('.data-container');\n try {\n var customStyle = JSON.parse(this.component[\"custom-style\"] || {});\n _lodash.default.forEach(customStyle, function (value, key) {\n _this3.refs.dataContainer.style[key] = value;\n });\n } catch (e) {}\n // 标题设置\n var element = container.querySelector('.title-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['title-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.value-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['value-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.footer-container-value1');\n var footerContentStr = self.component['footer-content1'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value2');\n footerContentStr = self.component['footer-content2'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value3');\n if (element) {\n footerContentStr = self.component['footer-content3'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n }\n // 图标\n self.resetSparkLine();\n } catch (e) {\n console.log(e);\n }\n return true;\n }\n }], [{\n key: \"schema\",\n value: function schema() {\n for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {\n extend[_key] = arguments[_key];\n }\n return _Field.default.schema.apply(_Field.default, [{\n type: 'data_china_grid',\n \"title-content\": \"低压问题综合治理率 <i class=\\\"fa fa-info-circle\\\" aria-hidden=\\\"true\\\"></i>\",\n \"value-content\": \"160 <i style='font-size: 10px;color: #0a6ebd'>%</i>\",\n \"footer-content1\": \"name\",\n \"footer-content2\": \"<div style='color:red'>up</div>\",\n \"footer-content3\": \"info\",\n \"footer-content\": \"开始时间\"\n }].concat(extend));\n }\n }, {\n key: \"builderInfo\",\n get: function get() {\n return {\n title: 'Info Block ChinaFrid',\n group: 'advanced',\n icon: 'square-info',\n weight: 70,\n schema: DataChinaGrid.schema()\n };\n }\n }]);\n return DataChinaGrid;\n}(_Field.default);\nexports[\"default\"] = DataChinaGrid;\n\n//# sourceURL=webpack://Formio/./lib/components/DataChinaGrid/Data.js?");
624
624
 
625
625
  /***/ }),
626
626
 
@@ -653,7 +653,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
653
653
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
654
654
 
655
655
  "use strict";
656
- eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n__webpack_require__(/*! core-js/modules/es.reflect.construct.js */ \"./node_modules/core-js/modules/es.reflect.construct.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.get.js */ \"./node_modules/core-js/modules/es.reflect.get.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ \"./node_modules/core-js/modules/es.object.get-own-property-descriptor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.string.trim.js */ \"./node_modules/core-js/modules/es.string.trim.js\");\n__webpack_require__(/*! core-js/modules/es.array.find.js */ \"./node_modules/core-js/modules/es.array.find.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ \"./node_modules/core-js/modules/es.object.get-prototype-of.js\");\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ../_classes/field/Field */ \"./lib/components/_classes/field/Field.js\"));\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n__webpack_require__(/*! peity */ \"./node_modules/peity/jquery.peity.js\");\nvar _lodash = _interopRequireDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n/**\n * Here we will derive from the base component which all Form.io form components derive from.\n *\n * @param component\n * @param options\n * @param data\n * @constructor\n */\nvar DataChinaGridRow = /*#__PURE__*/function (_Component) {\n _inherits(DataChinaGridRow, _Component);\n var _super = _createSuper(DataChinaGridRow);\n function DataChinaGridRow(component, options, data) {\n var _this;\n _classCallCheck(this, DataChinaGridRow);\n _this = _super.call(this, component, options, data);\n _this.isLoadingSparkLine = false;\n return _this;\n }\n _createClass(DataChinaGridRow, [{\n key: \"render\",\n value: function render() {\n return _get(_getPrototypeOf(DataChinaGridRow.prototype), \"render\", this).call(this, this.renderTemplate('dataChinaGridRow'));\n }\n\n /**\n * After the html string has been mounted into the dom, the dom element is returned here. Use refs to find specific\n * elements to attach functionality to.\n *\n * @param element\n * @returns {Promise}\n */\n }, {\n key: \"attach\",\n value: function attach(element) {\n var _this2 = this;\n var self = this;\n var refs = {\n dataContainer: 'single'\n };\n this.loadRefs(element, refs);\n var dataContainer = this.refs.dataContainer;\n if (dataContainer) {\n var clickEventType = this.component['click-event-type'];\n if (clickEventType) {\n this.addEventListener(dataContainer, 'click', function (event) {\n // 点击事件\n var params;\n switch (clickEventType) {\n case 'newPage':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openNewPage(_this2.component['click-event-form-id'], params);\n break;\n case 'bottomSheet':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openBottomSheet(_this2.component['click-event-form-id'], params);\n break;\n case 'setTab':\n // 切换tab\n Formio.forms[_this2.currentForm.id].getComponent(_this2.component['click-event-tab-id']).setTabByKey(_this2.component['click-event-tab-key']);\n break;\n case 'openUrl':\n if (window.openNewUrlByQmx) {\n window.openNewUrlByQmx(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n } else {\n window.open(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n }\n break;\n }\n });\n }\n }\n setTimeout(function () {\n _this2.setValue('');\n }, 100);\n return _get(_getPrototypeOf(DataChinaGridRow.prototype), \"attach\", this).call(this, element);\n }\n }, {\n key: \"parseTpl\",\n value: function parseTpl(template, map) {\n if (template && template.length > 0) {\n try {\n return template.replace(/\\$\\{.+?}/g, function (match) {\n var _$get;\n var path = match.substr(2, match.length - 3).trim();\n return (_$get = _lodash.default.get(map, path)) !== null && _$get !== void 0 ? _$get : '--';\n });\n } catch (e) {\n console.log(e);\n }\n }\n return '{}';\n }\n\n /**\n * Get the value of the component from the dom elements.\n *\n * @returns {Array}\n */\n }, {\n key: \"getValue\",\n value: function getValue() {\n return this.component.field;\n }\n }, {\n key: \"resetSparkLine\",\n value: function resetSparkLine() {\n var self = this;\n var container = this.element.querySelector('.data-container');\n if (self.component['enable-sparkline']) {\n if (self.isLoadingSparkLine) {\n return true;\n }\n self.isLoadingSparkLine = true;\n var sparkLineType = this.component['sparkLine-type'] || 'line';\n var fillColor;\n if (self.component['sparkLine-fill-color']) {\n switch (sparkLineType) {\n case 'line':\n fillColor = self.component['sparkLine-fill-color'].split(',')[0];\n break;\n case 'pie':\n case 'donut':\n case 'bar':\n fillColor = self.component['sparkLine-fill-color'].split(',');\n break;\n }\n }\n // values\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(self.parseTpl(self.component['sparkLine-value'], {\n data: self.rootValue\n }), \"</span>\");\n // 宽度计算\n var parentWidth = container.querySelector('#sparkline-container-parent').offsetWidth;\n parentWidth = parentWidth * self.component['sparkLine-width'];\n try {\n // @ts-ignore\n (0, _jquery.default)(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: parentWidth\n });\n self.isLoadingSparkLine = false;\n } catch (e) {\n container.querySelectorAll(\".line\").forEach(function (e) {\n return peity(e, sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: parentWidth\n });\n });\n self.isLoadingSparkLine = false;\n }\n }\n }\n\n /**\n * Set the value of the component into the dom elements.\n *\n * @param value\n * @returns {boolean}\n */\n }, {\n key: \"setValue\",\n value: function setValue(value) {\n var _this3 = this;\n var self = this;\n try {\n var container = this.element.querySelector('.data-container');\n try {\n var customStyle = JSON.parse(this.component[\"custom-style\"] || {});\n _lodash.default.forEach(customStyle, function (value, key) {\n _this3.refs.dataContainer.style[key] = value;\n });\n } catch (e) {}\n // 标题设置\n var element = container.querySelector('.title-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['title-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.value-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['value-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.footer-container-value1');\n var footerContentStr = self.component['footer-content1'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value2');\n footerContentStr = self.component['footer-content2'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value3');\n if (element) {\n footerContentStr = self.component['footer-content3'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n }\n // 图标\n self.resetSparkLine();\n } catch (e) {\n console.log(e);\n }\n return true;\n }\n }], [{\n key: \"schema\",\n value: function schema() {\n for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {\n extend[_key] = arguments[_key];\n }\n return _Field.default.schema.apply(_Field.default, [{\n type: 'data_china_grid_row',\n color: '#ff7754',\n \"title-content\": \"低压问题综合治理率 <i class=\\\"fa fa-info-circle\\\" aria-hidden=\\\"true\\\"></i>\",\n \"value-content\": \"160 <i style='font-size: 10px;color: #0a6ebd'>%</i>\",\n \"footer-content1\": \"name\",\n \"footer-content2\": \"<div style='color:red'>up</div>\",\n \"footer-content3\": \"info\",\n \"footer-content\": \"开始时间\"\n }].concat(extend));\n }\n }, {\n key: \"builderInfo\",\n get: function get() {\n return {\n title: 'Info Block ChinaFrid Row',\n group: 'advanced',\n icon: 'square-info',\n weight: 70,\n schema: DataChinaGridRow.schema()\n };\n }\n }]);\n return DataChinaGridRow;\n}(_Field.default);\nexports[\"default\"] = DataChinaGridRow;\n\n//# sourceURL=webpack://Formio/./lib/components/DataChinaGridRow/Data.js?");
656
+ eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n__webpack_require__(/*! core-js/modules/es.reflect.construct.js */ \"./node_modules/core-js/modules/es.reflect.construct.js\");\n__webpack_require__(/*! core-js/modules/es.reflect.get.js */ \"./node_modules/core-js/modules/es.reflect.get.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ \"./node_modules/core-js/modules/es.object.get-own-property-descriptor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.to-primitive.js */ \"./node_modules/core-js/modules/es.symbol.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.date.to-primitive.js */ \"./node_modules/core-js/modules/es.date.to-primitive.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.js */ \"./node_modules/core-js/modules/es.symbol.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.description.js */ \"./node_modules/core-js/modules/es.symbol.description.js\");\n__webpack_require__(/*! core-js/modules/es.number.constructor.js */ \"./node_modules/core-js/modules/es.number.constructor.js\");\n__webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ \"./node_modules/core-js/modules/es.symbol.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.array.iterator.js */ \"./node_modules/core-js/modules/es.array.iterator.js\");\n__webpack_require__(/*! core-js/modules/es.string.iterator.js */ \"./node_modules/core-js/modules/es.string.iterator.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ \"./node_modules/core-js/modules/web.dom-collections.iterator.js\");\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports[\"default\"] = void 0;\n__webpack_require__(/*! core-js/modules/es.regexp.exec.js */ \"./node_modules/core-js/modules/es.regexp.exec.js\");\n__webpack_require__(/*! core-js/modules/es.string.replace.js */ \"./node_modules/core-js/modules/es.string.replace.js\");\n__webpack_require__(/*! core-js/modules/es.string.trim.js */ \"./node_modules/core-js/modules/es.string.trim.js\");\n__webpack_require__(/*! core-js/modules/es.array.find.js */ \"./node_modules/core-js/modules/es.array.find.js\");\n__webpack_require__(/*! core-js/modules/es.object.to-string.js */ \"./node_modules/core-js/modules/es.object.to-string.js\");\n__webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ \"./node_modules/core-js/modules/web.dom-collections.for-each.js\");\n__webpack_require__(/*! core-js/modules/es.array.concat.js */ \"./node_modules/core-js/modules/es.array.concat.js\");\n__webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ \"./node_modules/core-js/modules/es.object.get-prototype-of.js\");\nvar _Field = _interopRequireDefault(__webpack_require__(/*! ../_classes/field/Field */ \"./lib/components/_classes/field/Field.js\"));\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n__webpack_require__(/*! peity */ \"./node_modules/peity/jquery.peity.js\");\nvar _lodash = _interopRequireDefault(__webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\"));\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _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, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n/**\n * Here we will derive from the base component which all Form.io form components derive from.\n *\n * @param component\n * @param options\n * @param data\n * @constructor\n */\nvar DataChinaGridRow = /*#__PURE__*/function (_Component) {\n _inherits(DataChinaGridRow, _Component);\n var _super = _createSuper(DataChinaGridRow);\n function DataChinaGridRow(component, options, data) {\n var _this;\n _classCallCheck(this, DataChinaGridRow);\n _this = _super.call(this, component, options, data);\n _this.isLoadingSparkLine = false;\n return _this;\n }\n _createClass(DataChinaGridRow, [{\n key: \"render\",\n value: function render() {\n return _get(_getPrototypeOf(DataChinaGridRow.prototype), \"render\", this).call(this, this.renderTemplate('dataChinaGridRow'));\n }\n\n /**\n * After the html string has been mounted into the dom, the dom element is returned here. Use refs to find specific\n * elements to attach functionality to.\n *\n * @param element\n * @returns {Promise}\n */\n }, {\n key: \"attach\",\n value: function attach(element) {\n var _this2 = this;\n var self = this;\n var refs = {\n dataContainer: 'single'\n };\n this.loadRefs(element, refs);\n var dataContainer = this.refs.dataContainer;\n if (dataContainer) {\n var clickEventType = this.component['click-event-type'];\n if (clickEventType) {\n this.addEventListener(dataContainer, 'click', function (event) {\n // 点击事件\n var params;\n switch (clickEventType) {\n case 'newPage':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openNewPage(self.parseTpl(self.component['click-event-form-id'], {\n data: self.rootValue\n }), params);\n break;\n case 'bottomSheet':\n try {\n params = JSON.parse(_this2.parseTpl(_this2.component['page_params'], {\n data: _this2.rootValue\n }));\n } catch (e) {\n console.log(\"json\\u8F6C\\u6362\\u5931\\u8D25:\".concat(e));\n }\n window.openBottomSheet(self.parseTpl(self.component['click-event-form-id'], {\n data: self.rootValue\n }), params);\n break;\n case 'setTab':\n // 切换tab\n Formio.forms[_this2.currentForm.id].getComponent(self.parseTpl(self.component['click-event-tab-id'], {\n data: self.rootValue\n })).setTabByKey(self.parseTpl(self.component['click-event-tab-key'], {\n data: self.rootValue\n }));\n break;\n case 'openUrl':\n if (window.openNewUrlByQmx) {\n window.openNewUrlByQmx(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n } else {\n window.open(_this2.parseTpl(_this2.component['click-event-url'], {\n data: _this2.rootValue\n }));\n }\n break;\n }\n });\n }\n }\n setTimeout(function () {\n _this2.setValue('');\n }, 100);\n return _get(_getPrototypeOf(DataChinaGridRow.prototype), \"attach\", this).call(this, element);\n }\n }, {\n key: \"parseTpl\",\n value: function parseTpl(template, map) {\n if (template && template.length > 0) {\n try {\n return template.replace(/\\$\\{.+?}/g, function (match) {\n var _$get;\n var path = match.substr(2, match.length - 3).trim();\n return (_$get = _lodash.default.get(map, path)) !== null && _$get !== void 0 ? _$get : '--';\n });\n } catch (e) {\n console.log(e);\n }\n }\n return '{}';\n }\n\n /**\n * Get the value of the component from the dom elements.\n *\n * @returns {Array}\n */\n }, {\n key: \"getValue\",\n value: function getValue() {\n return this.component.field;\n }\n }, {\n key: \"resetSparkLine\",\n value: function resetSparkLine() {\n var self = this;\n var container = this.element.querySelector('.data-container');\n if (self.component['enable-sparkline']) {\n if (self.isLoadingSparkLine) {\n return true;\n }\n self.isLoadingSparkLine = true;\n var sparkLineType = this.component['sparkLine-type'] || 'line';\n var fillColor;\n if (self.component['sparkLine-fill-color']) {\n switch (sparkLineType) {\n case 'line':\n fillColor = self.component['sparkLine-fill-color'].split(',')[0];\n break;\n case 'pie':\n case 'donut':\n case 'bar':\n fillColor = self.component['sparkLine-fill-color'].split(',');\n break;\n }\n }\n // values\n container.querySelector('.sparkline-container').innerHTML = \"<span class=\\\"line\\\">\".concat(self.parseTpl(self.component['sparkLine-value'], {\n data: self.rootValue\n }), \"</span>\");\n // 宽度计算\n var parentWidth = container.querySelector('#sparkline-container-parent').offsetWidth;\n parentWidth = parentWidth * self.component['sparkLine-width'];\n try {\n // @ts-ignore\n (0, _jquery.default)(container).find('.line').peity(sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: parentWidth\n });\n self.isLoadingSparkLine = false;\n } catch (e) {\n container.querySelectorAll(\".line\").forEach(function (e) {\n return peity(e, sparkLineType, {\n fill: fillColor,\n height: self.component['sparkLine-height'],\n max: _lodash.default.toNumber(self.parseTpl(\"\".concat(self.component['sparkLine-max-value-count']), {\n data: self.rootValue\n })),\n min: 0,\n stroke: self.component['sparkLine-stroke-color'],\n strokeWidth: 2,\n width: parentWidth\n });\n });\n self.isLoadingSparkLine = false;\n }\n }\n }\n\n /**\n * Set the value of the component into the dom elements.\n *\n * @param value\n * @returns {boolean}\n */\n }, {\n key: \"setValue\",\n value: function setValue(value) {\n var _this3 = this;\n var self = this;\n try {\n var container = this.element.querySelector('.data-container');\n try {\n var customStyle = JSON.parse(this.component[\"custom-style\"] || {});\n _lodash.default.forEach(customStyle, function (value, key) {\n _this3.refs.dataContainer.style[key] = value;\n });\n } catch (e) {}\n // 标题设置\n var element = container.querySelector('.title-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['title-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.value-container');\n element.innerHTML = self.interpolate(self.parseTpl(self.component['value-content'], {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n element = container.querySelector('.footer-container-value1');\n var footerContentStr = self.component['footer-content1'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value2');\n footerContentStr = self.component['footer-content2'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n element = container.querySelector('.footer-container-value3');\n if (element) {\n footerContentStr = self.component['footer-content3'];\n if (footerContentStr && footerContentStr.length > 0) {\n element.innerHTML = self.interpolate(self.parseTpl(footerContentStr, {\n data: self.rootValue\n }), {\n data: self.rootValue\n });\n } else {\n element.style.display = 'none';\n }\n }\n // 图标\n self.resetSparkLine();\n } catch (e) {\n console.log(e);\n }\n return true;\n }\n }], [{\n key: \"schema\",\n value: function schema() {\n for (var _len = arguments.length, extend = new Array(_len), _key = 0; _key < _len; _key++) {\n extend[_key] = arguments[_key];\n }\n return _Field.default.schema.apply(_Field.default, [{\n type: 'data_china_grid_row',\n color: '#ff7754',\n \"title-content\": \"低压问题综合治理率 <i class=\\\"fa fa-info-circle\\\" aria-hidden=\\\"true\\\"></i>\",\n \"value-content\": \"160 <i style='font-size: 10px;color: #0a6ebd'>%</i>\",\n \"footer-content1\": \"name\",\n \"footer-content2\": \"<div style='color:red'>up</div>\",\n \"footer-content3\": \"info\",\n \"footer-content\": \"开始时间\"\n }].concat(extend));\n }\n }, {\n key: \"builderInfo\",\n get: function get() {\n return {\n title: 'Info Block ChinaFrid Row',\n group: 'advanced',\n icon: 'square-info',\n weight: 70,\n schema: DataChinaGridRow.schema()\n };\n }\n }]);\n return DataChinaGridRow;\n}(_Field.default);\nexports[\"default\"] = DataChinaGridRow;\n\n//# sourceURL=webpack://Formio/./lib/components/DataChinaGridRow/Data.js?");
657
657
 
658
658
  /***/ }),
659
659