You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9279 lines
266 KiB

  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./resources/js/components/field-error.riot":
  4. /*!**************************************************!*\
  5. !*** ./resources/js/components/field-error.riot ***!
  6. \**************************************************/
  7. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  8. "use strict";
  9. __webpack_require__.r(__webpack_exports__);
  10. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  11. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  12. /* harmony export */ });
  13. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  14. 'css': null,
  15. 'exports': {
  16. state: {
  17. errors: [
  18. ],
  19. },
  20. /**
  21. *
  22. *
  23. * @param {Object} props [description]
  24. * @param {Object} state [description]
  25. *
  26. */
  27. onMounted(props, state)
  28. {
  29. // getting parent element for entire field
  30. const parent = this.root.closest('.field-group')
  31. // getting current element by name
  32. const element = document.querySelector('[name="' + props.name + '"]')
  33. // getting form
  34. const form = element.closest('form')
  35. // element, form are exists and nofieldupdate is not set
  36. // each change of the element dispatch a event to form validation
  37. if (element && form && !props.nofieldupdate) {
  38. element.addEventListener('input', (event) => {
  39. this.dispatchCustomEvent(event, form, props.name)
  40. })
  41. }
  42. // add custom event to listen to form-validation
  43. this.root.addEventListener('form-validation', (event) => {
  44. this.onFormValidation(event, parent)
  45. })
  46. },
  47. /**
  48. * process form validation triggered by form
  49. *
  50. * @param {Event} event
  51. * @param {Element} parent
  52. *
  53. */
  54. onFormValidation(event, parent)
  55. {
  56. // if detail is a value, set to errors
  57. if (event.detail) {
  58. this.state.errors = event.detail
  59. parent.classList.add('field--error')
  60. parent.classList.remove('field--valid')
  61. } else {
  62. this.state.errors = []
  63. parent.classList.remove('field--error')
  64. parent.classList.add('field--valid')
  65. }
  66. this.update()
  67. },
  68. /**
  69. * create event to send to form validation
  70. *
  71. * @param {Event} event
  72. * @param {Element} form
  73. * @param {string} name
  74. *
  75. */
  76. dispatchCustomEvent(event, form, name)
  77. {
  78. const fieldUpdateEvent = new CustomEvent('field-update', {
  79. 'detail': {
  80. 'name': name,
  81. 'value': event.target.value
  82. }
  83. })
  84. form.dispatchEvent(fieldUpdateEvent)
  85. }
  86. },
  87. 'template': function(
  88. template,
  89. expressionTypes,
  90. bindingTypes,
  91. getComponent
  92. ) {
  93. return template(
  94. '<div expr14="expr14" class="field-error"></div>',
  95. [
  96. {
  97. 'type': bindingTypes.IF,
  98. 'evaluate': function(
  99. _scope
  100. ) {
  101. return _scope.state.errors.length > 0;
  102. },
  103. 'redundantAttribute': 'expr14',
  104. 'selector': '[expr14]',
  105. 'template': template(
  106. '<ul><li expr15="expr15"></li></ul>',
  107. [
  108. {
  109. 'type': bindingTypes.EACH,
  110. 'getKey': null,
  111. 'condition': null,
  112. 'template': template(
  113. ' ',
  114. [
  115. {
  116. 'expressions': [
  117. {
  118. 'type': expressionTypes.TEXT,
  119. 'childNodeIndex': 0,
  120. 'evaluate': function(
  121. _scope
  122. ) {
  123. return [
  124. _scope.error
  125. ].join(
  126. ''
  127. );
  128. }
  129. }
  130. ]
  131. }
  132. ]
  133. ),
  134. 'redundantAttribute': 'expr15',
  135. 'selector': '[expr15]',
  136. 'itemName': 'error',
  137. 'indexName': null,
  138. 'evaluate': function(
  139. _scope
  140. ) {
  141. return _scope.state.errors;
  142. }
  143. }
  144. ]
  145. )
  146. }
  147. ]
  148. );
  149. },
  150. 'name': 'field-error'
  151. });
  152. /***/ }),
  153. /***/ "./resources/js/components/users.riot":
  154. /*!********************************************!*\
  155. !*** ./resources/js/components/users.riot ***!
  156. \********************************************/
  157. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  158. "use strict";
  159. __webpack_require__.r(__webpack_exports__);
  160. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  161. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  162. /* harmony export */ });
  163. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  164. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
  165. /* harmony import */ var lodash_remove__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.remove */ "./node_modules/lodash.remove/index.js");
  166. /* harmony import */ var lodash_remove__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_remove__WEBPACK_IMPORTED_MODULE_1__);
  167. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  168. 'css': null,
  169. 'exports': {
  170. state: {
  171. users: [],
  172. maxLength: 0
  173. },
  174. onBeforeMount() {
  175. this.fetch()
  176. },
  177. handleClick() {
  178. },
  179. handleDelete(event, bucket) {
  180. event.preventDefault()
  181. axios__WEBPACK_IMPORTED_MODULE_0___default().delete('/api/bucket/' + bucket._id)
  182. .then((response) => {
  183. // removing from buckets
  184. lodash_remove__WEBPACK_IMPORTED_MODULE_1___default()(this.state.buckets, function(b) {
  185. return b._id === bucket._id
  186. })
  187. this.update()
  188. })
  189. },
  190. /**
  191. * getting all buckets
  192. *
  193. *
  194. */
  195. fetch() {
  196. axios__WEBPACK_IMPORTED_MODULE_0___default().get('/api/users').then((response) => {
  197. this.state.users = response.data.data
  198. this.update()
  199. })
  200. }
  201. },
  202. 'template': function(
  203. template,
  204. expressionTypes,
  205. bindingTypes,
  206. getComponent
  207. ) {
  208. return template(
  209. '<div class="buckets"><table class="table"><div expr3="expr3" class="table__row"></div></table><div expr6="expr6" class="grid"></div></div>',
  210. [
  211. {
  212. 'type': bindingTypes.EACH,
  213. 'getKey': null,
  214. 'condition': null,
  215. 'template': template(
  216. '<div expr4="expr4" class="table__column"> </div><div expr5="expr5" class="table__column"> </div><div class="table__column"></div>',
  217. [
  218. {
  219. 'redundantAttribute': 'expr4',
  220. 'selector': '[expr4]',
  221. 'expressions': [
  222. {
  223. 'type': expressionTypes.TEXT,
  224. 'childNodeIndex': 0,
  225. 'evaluate': function(
  226. _scope
  227. ) {
  228. return [
  229. _scope.user.username
  230. ].join(
  231. ''
  232. );
  233. }
  234. }
  235. ]
  236. },
  237. {
  238. 'redundantAttribute': 'expr5',
  239. 'selector': '[expr5]',
  240. 'expressions': [
  241. {
  242. 'type': expressionTypes.TEXT,
  243. 'childNodeIndex': 0,
  244. 'evaluate': function(
  245. _scope
  246. ) {
  247. return [
  248. _scope.user.email
  249. ].join(
  250. ''
  251. );
  252. }
  253. }
  254. ]
  255. }
  256. ]
  257. ),
  258. 'redundantAttribute': 'expr3',
  259. 'selector': '[expr3]',
  260. 'itemName': 'user',
  261. 'indexName': null,
  262. 'evaluate': function(
  263. _scope
  264. ) {
  265. return _scope.state.users;
  266. }
  267. },
  268. {
  269. 'type': bindingTypes.IF,
  270. 'evaluate': function(
  271. _scope
  272. ) {
  273. return _scope.state.maxLength > _scope.state.users.length;
  274. },
  275. 'redundantAttribute': 'expr6',
  276. 'selector': '[expr6]',
  277. 'template': template(
  278. '<div class="col-12"><div class="buckets__more"><button expr7="expr7" type="button" class="button">\n More\n <svg class="icon" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-down"/></svg></button></div></div>',
  279. [
  280. {
  281. 'redundantAttribute': 'expr7',
  282. 'selector': '[expr7]',
  283. 'expressions': [
  284. {
  285. 'type': expressionTypes.EVENT,
  286. 'name': 'onclick',
  287. 'evaluate': function(
  288. _scope
  289. ) {
  290. return _scope.handleClick;
  291. }
  292. }
  293. ]
  294. }
  295. ]
  296. )
  297. }
  298. ]
  299. );
  300. },
  301. 'name': 'app-users'
  302. });
  303. /***/ }),
  304. /***/ "./resources/js/components/users/form.riot":
  305. /*!*************************************************!*\
  306. !*** ./resources/js/components/users/form.riot ***!
  307. \*************************************************/
  308. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  309. "use strict";
  310. __webpack_require__.r(__webpack_exports__);
  311. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  312. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  313. /* harmony export */ });
  314. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  315. /* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
  316. /* harmony import */ var riot__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js");
  317. /* harmony import */ var _FormValidator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../FormValidator */ "./resources/js/FormValidator.js");
  318. /* harmony import */ var _field_error_riot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../field-error.riot */ "./resources/js/components/field-error.riot");
  319. riot__WEBPACK_IMPORTED_MODULE_3__.register('field-error', _field_error_riot__WEBPACK_IMPORTED_MODULE_2__.default)
  320. riot__WEBPACK_IMPORTED_MODULE_3__.mount('field-error')
  321. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
  322. 'css': null,
  323. 'exports': {
  324. state: {
  325. user: { }
  326. },
  327. /**
  328. *
  329. *
  330. */
  331. onMounted(props, state) {
  332. // create form validation
  333. const formValidation = new _FormValidator__WEBPACK_IMPORTED_MODULE_1__.default('app-users-form', {
  334. 'email': {
  335. 'length': {
  336. 'maximum': 255
  337. },
  338. 'email': true,
  339. 'presence': true
  340. },
  341. 'password': {
  342. 'length': {
  343. 'maximum': 64
  344. },
  345. 'presence': true
  346. }
  347. }, (event, data) => {
  348. this.handleSubmit(event, data)
  349. })
  350. },
  351. handleClose(event)
  352. {
  353. event.preventDefault()
  354. this.$('.sidebar').classList.remove('sidebar--open')
  355. },
  356. /**
  357. *
  358. *
  359. */
  360. handleSubmit(event, data) {
  361. let method = 'post'
  362. if (this.state.user && this.state.user._id) {
  363. method = 'put'
  364. }
  365. axios__WEBPACK_IMPORTED_MODULE_0___default()({
  366. method: method,
  367. url: '/api/users',
  368. data: data
  369. }).then((response) => {
  370. this.state.user = response.data.data
  371. this.update()
  372. })
  373. }
  374. },
  375. 'template': function(
  376. template,
  377. expressionTypes,
  378. bindingTypes,
  379. getComponent
  380. ) {
  381. return template(
  382. '<div class="sidebar sidebar--open"><div class="sidebar__inner"><div class="bar"><div class="bar__main">\n Create User\n </div><div class="bar__end"><button expr16="expr16" class="button button--transparent" type="button"><svg class="icon fill-text-contrast" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-close"/></svg></button></div></div><div class="sidebar__body"><form id="app-users-form"><div class="field-group"><label class="field-label">\n E-Mail\n <input name="email" type="text" class="field-text"/></label><field-error expr17="expr17" name="email"></field-error></div><div class="field-group"><label class="field-label">\n Password\n <input name="password" type="password" class="field-text"/></label><field-error expr18="expr18" name="password"></field-error></div></form></div><div class="sidebar__footer"><button class="button m-bottom-0" type="submit" form="app-users-form">\n Save\n <svg class="icon fill-success p-left-3" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-check"/></svg></button><button class="button m-bottom-0" type="submit" form="app-users-form">\n Save and Close\n <svg class="icon fill-success p-left-3" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-arrow-right"/></svg></button></div></div></div>',
  383. [
  384. {
  385. 'redundantAttribute': 'expr16',
  386. 'selector': '[expr16]',
  387. 'expressions': [
  388. {
  389. 'type': expressionTypes.EVENT,
  390. 'name': 'onclick',
  391. 'evaluate': function(
  392. _scope
  393. ) {
  394. return (event) => { _scope.handleClose(event) };
  395. }
  396. }
  397. ]
  398. },
  399. {
  400. 'type': bindingTypes.TAG,
  401. 'getComponent': getComponent,
  402. 'evaluate': function(
  403. _scope
  404. ) {
  405. return 'field-error';
  406. },
  407. 'slots': [],
  408. 'attributes': [],
  409. 'redundantAttribute': 'expr17',
  410. 'selector': '[expr17]'
  411. },
  412. {
  413. 'type': bindingTypes.TAG,
  414. 'getComponent': getComponent,
  415. 'evaluate': function(
  416. _scope
  417. ) {
  418. return 'field-error';
  419. },
  420. 'slots': [],
  421. 'attributes': [],
  422. 'redundantAttribute': 'expr18',
  423. 'selector': '[expr18]'
  424. }
  425. ]
  426. );
  427. },
  428. 'name': 'app-users-form'
  429. });
  430. /***/ }),
  431. /***/ "./node_modules/axios/index.js":
  432. /*!*************************************!*\
  433. !*** ./node_modules/axios/index.js ***!
  434. \*************************************/
  435. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  436. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  437. /***/ }),
  438. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  439. /*!************************************************!*\
  440. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  441. \************************************************/
  442. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  443. "use strict";
  444. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  445. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  446. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  447. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  448. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  449. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  450. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  451. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  452. module.exports = function xhrAdapter(config) {
  453. return new Promise(function dispatchXhrRequest(resolve, reject) {
  454. var requestData = config.data;
  455. var requestHeaders = config.headers;
  456. if (utils.isFormData(requestData)) {
  457. delete requestHeaders['Content-Type']; // Let the browser set it
  458. }
  459. var request = new XMLHttpRequest();
  460. // HTTP basic authentication
  461. if (config.auth) {
  462. var username = config.auth.username || '';
  463. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  464. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  465. }
  466. var fullPath = buildFullPath(config.baseURL, config.url);
  467. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  468. // Set the request timeout in MS
  469. request.timeout = config.timeout;
  470. // Listen for ready state
  471. request.onreadystatechange = function handleLoad() {
  472. if (!request || request.readyState !== 4) {
  473. return;
  474. }
  475. // The request errored out and we didn't get a response, this will be
  476. // handled by onerror instead
  477. // With one exception: request that using file: protocol, most browsers
  478. // will return status as 0 even though it's a successful request
  479. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  480. return;
  481. }
  482. // Prepare the response
  483. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  484. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  485. var response = {
  486. data: responseData,
  487. status: request.status,
  488. statusText: request.statusText,
  489. headers: responseHeaders,
  490. config: config,
  491. request: request
  492. };
  493. settle(resolve, reject, response);
  494. // Clean up request
  495. request = null;
  496. };
  497. // Handle browser request cancellation (as opposed to a manual cancellation)
  498. request.onabort = function handleAbort() {
  499. if (!request) {
  500. return;
  501. }
  502. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  503. // Clean up request
  504. request = null;
  505. };
  506. // Handle low level network errors
  507. request.onerror = function handleError() {
  508. // Real errors are hidden from us by the browser
  509. // onerror should only fire if it's a network error
  510. reject(createError('Network Error', config, null, request));
  511. // Clean up request
  512. request = null;
  513. };
  514. // Handle timeout
  515. request.ontimeout = function handleTimeout() {
  516. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  517. if (config.timeoutErrorMessage) {
  518. timeoutErrorMessage = config.timeoutErrorMessage;
  519. }
  520. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  521. request));
  522. // Clean up request
  523. request = null;
  524. };
  525. // Add xsrf header
  526. // This is only done if running in a standard browser environment.
  527. // Specifically not if we're in a web worker, or react-native.
  528. if (utils.isStandardBrowserEnv()) {
  529. // Add xsrf header
  530. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  531. cookies.read(config.xsrfCookieName) :
  532. undefined;
  533. if (xsrfValue) {
  534. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  535. }
  536. }
  537. // Add headers to the request
  538. if ('setRequestHeader' in request) {
  539. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  540. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  541. // Remove Content-Type if data is undefined
  542. delete requestHeaders[key];
  543. } else {
  544. // Otherwise add header to the request
  545. request.setRequestHeader(key, val);
  546. }
  547. });
  548. }
  549. // Add withCredentials to request if needed
  550. if (!utils.isUndefined(config.withCredentials)) {
  551. request.withCredentials = !!config.withCredentials;
  552. }
  553. // Add responseType to request if needed
  554. if (config.responseType) {
  555. try {
  556. request.responseType = config.responseType;
  557. } catch (e) {
  558. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  559. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  560. if (config.responseType !== 'json') {
  561. throw e;
  562. }
  563. }
  564. }
  565. // Handle progress if needed
  566. if (typeof config.onDownloadProgress === 'function') {
  567. request.addEventListener('progress', config.onDownloadProgress);
  568. }
  569. // Not all browsers support upload events
  570. if (typeof config.onUploadProgress === 'function' && request.upload) {
  571. request.upload.addEventListener('progress', config.onUploadProgress);
  572. }
  573. if (config.cancelToken) {
  574. // Handle cancellation
  575. config.cancelToken.promise.then(function onCanceled(cancel) {
  576. if (!request) {
  577. return;
  578. }
  579. request.abort();
  580. reject(cancel);
  581. // Clean up request
  582. request = null;
  583. });
  584. }
  585. if (!requestData) {
  586. requestData = null;
  587. }
  588. // Send the request
  589. request.send(requestData);
  590. });
  591. };
  592. /***/ }),
  593. /***/ "./node_modules/axios/lib/axios.js":
  594. /*!*****************************************!*\
  595. !*** ./node_modules/axios/lib/axios.js ***!
  596. \*****************************************/
  597. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  598. "use strict";
  599. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  600. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  601. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  602. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  603. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  604. /**
  605. * Create an instance of Axios
  606. *
  607. * @param {Object} defaultConfig The default config for the instance
  608. * @return {Axios} A new instance of Axios
  609. */
  610. function createInstance(defaultConfig) {
  611. var context = new Axios(defaultConfig);
  612. var instance = bind(Axios.prototype.request, context);
  613. // Copy axios.prototype to instance
  614. utils.extend(instance, Axios.prototype, context);
  615. // Copy context to instance
  616. utils.extend(instance, context);
  617. return instance;
  618. }
  619. // Create the default instance to be exported
  620. var axios = createInstance(defaults);
  621. // Expose Axios class to allow class inheritance
  622. axios.Axios = Axios;
  623. // Factory for creating new instances
  624. axios.create = function create(instanceConfig) {
  625. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  626. };
  627. // Expose Cancel & CancelToken
  628. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  629. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  630. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  631. // Expose all/spread
  632. axios.all = function all(promises) {
  633. return Promise.all(promises);
  634. };
  635. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  636. // Expose isAxiosError
  637. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  638. module.exports = axios;
  639. // Allow use of default import syntax in TypeScript
  640. module.exports.default = axios;
  641. /***/ }),
  642. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  643. /*!*************************************************!*\
  644. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  645. \*************************************************/
  646. /***/ ((module) => {
  647. "use strict";
  648. /**
  649. * A `Cancel` is an object that is thrown when an operation is canceled.
  650. *
  651. * @class
  652. * @param {string=} message The message.
  653. */
  654. function Cancel(message) {
  655. this.message = message;
  656. }
  657. Cancel.prototype.toString = function toString() {
  658. return 'Cancel' + (this.message ? ': ' + this.message : '');
  659. };
  660. Cancel.prototype.__CANCEL__ = true;
  661. module.exports = Cancel;
  662. /***/ }),
  663. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  664. /*!******************************************************!*\
  665. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  666. \******************************************************/
  667. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  668. "use strict";
  669. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  670. /**
  671. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  672. *
  673. * @class
  674. * @param {Function} executor The executor function.
  675. */
  676. function CancelToken(executor) {
  677. if (typeof executor !== 'function') {
  678. throw new TypeError('executor must be a function.');
  679. }
  680. var resolvePromise;
  681. this.promise = new Promise(function promiseExecutor(resolve) {
  682. resolvePromise = resolve;
  683. });
  684. var token = this;
  685. executor(function cancel(message) {
  686. if (token.reason) {
  687. // Cancellation has already been requested
  688. return;
  689. }
  690. token.reason = new Cancel(message);
  691. resolvePromise(token.reason);
  692. });
  693. }
  694. /**
  695. * Throws a `Cancel` if cancellation has been requested.
  696. */
  697. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  698. if (this.reason) {
  699. throw this.reason;
  700. }
  701. };
  702. /**
  703. * Returns an object that contains a new `CancelToken` and a function that, when called,
  704. * cancels the `CancelToken`.
  705. */
  706. CancelToken.source = function source() {
  707. var cancel;
  708. var token = new CancelToken(function executor(c) {
  709. cancel = c;
  710. });
  711. return {
  712. token: token,
  713. cancel: cancel
  714. };
  715. };
  716. module.exports = CancelToken;
  717. /***/ }),
  718. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  719. /*!***************************************************!*\
  720. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  721. \***************************************************/
  722. /***/ ((module) => {
  723. "use strict";
  724. module.exports = function isCancel(value) {
  725. return !!(value && value.__CANCEL__);
  726. };
  727. /***/ }),
  728. /***/ "./node_modules/axios/lib/core/Axios.js":
  729. /*!**********************************************!*\
  730. !*** ./node_modules/axios/lib/core/Axios.js ***!
  731. \**********************************************/
  732. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  733. "use strict";
  734. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  735. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  736. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  737. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  738. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  739. /**
  740. * Create a new instance of Axios
  741. *
  742. * @param {Object} instanceConfig The default config for the instance
  743. */
  744. function Axios(instanceConfig) {
  745. this.defaults = instanceConfig;
  746. this.interceptors = {
  747. request: new InterceptorManager(),
  748. response: new InterceptorManager()
  749. };
  750. }
  751. /**
  752. * Dispatch a request
  753. *
  754. * @param {Object} config The config specific for this request (merged with this.defaults)
  755. */
  756. Axios.prototype.request = function request(config) {
  757. /*eslint no-param-reassign:0*/
  758. // Allow for axios('example/url'[, config]) a la fetch API
  759. if (typeof config === 'string') {
  760. config = arguments[1] || {};
  761. config.url = arguments[0];
  762. } else {
  763. config = config || {};
  764. }
  765. config = mergeConfig(this.defaults, config);
  766. // Set config.method
  767. if (config.method) {
  768. config.method = config.method.toLowerCase();
  769. } else if (this.defaults.method) {
  770. config.method = this.defaults.method.toLowerCase();
  771. } else {
  772. config.method = 'get';
  773. }
  774. // Hook up interceptors middleware
  775. var chain = [dispatchRequest, undefined];
  776. var promise = Promise.resolve(config);
  777. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  778. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  779. });
  780. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  781. chain.push(interceptor.fulfilled, interceptor.rejected);
  782. });
  783. while (chain.length) {
  784. promise = promise.then(chain.shift(), chain.shift());
  785. }
  786. return promise;
  787. };
  788. Axios.prototype.getUri = function getUri(config) {
  789. config = mergeConfig(this.defaults, config);
  790. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  791. };
  792. // Provide aliases for supported request methods
  793. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  794. /*eslint func-names:0*/
  795. Axios.prototype[method] = function(url, config) {
  796. return this.request(mergeConfig(config || {}, {
  797. method: method,
  798. url: url,
  799. data: (config || {}).data
  800. }));
  801. };
  802. });
  803. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  804. /*eslint func-names:0*/
  805. Axios.prototype[method] = function(url, data, config) {
  806. return this.request(mergeConfig(config || {}, {
  807. method: method,
  808. url: url,
  809. data: data
  810. }));
  811. };
  812. });
  813. module.exports = Axios;
  814. /***/ }),
  815. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  816. /*!***********************************************************!*\
  817. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  818. \***********************************************************/
  819. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  820. "use strict";
  821. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  822. function InterceptorManager() {
  823. this.handlers = [];
  824. }
  825. /**
  826. * Add a new interceptor to the stack
  827. *
  828. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  829. * @param {Function} rejected The function to handle `reject` for a `Promise`
  830. *
  831. * @return {Number} An ID used to remove interceptor later
  832. */
  833. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  834. this.handlers.push({
  835. fulfilled: fulfilled,
  836. rejected: rejected
  837. });
  838. return this.handlers.length - 1;
  839. };
  840. /**
  841. * Remove an interceptor from the stack
  842. *
  843. * @param {Number} id The ID that was returned by `use`
  844. */
  845. InterceptorManager.prototype.eject = function eject(id) {
  846. if (this.handlers[id]) {
  847. this.handlers[id] = null;
  848. }
  849. };
  850. /**
  851. * Iterate over all the registered interceptors
  852. *
  853. * This method is particularly useful for skipping over any
  854. * interceptors that may have become `null` calling `eject`.
  855. *
  856. * @param {Function} fn The function to call for each interceptor
  857. */
  858. InterceptorManager.prototype.forEach = function forEach(fn) {
  859. utils.forEach(this.handlers, function forEachHandler(h) {
  860. if (h !== null) {
  861. fn(h);
  862. }
  863. });
  864. };
  865. module.exports = InterceptorManager;
  866. /***/ }),
  867. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  868. /*!******************************************************!*\
  869. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  870. \******************************************************/
  871. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  872. "use strict";
  873. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  874. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  875. /**
  876. * Creates a new URL by combining the baseURL with the requestedURL,
  877. * only when the requestedURL is not already an absolute URL.
  878. * If the requestURL is absolute, this function returns the requestedURL untouched.
  879. *
  880. * @param {string} baseURL The base URL
  881. * @param {string} requestedURL Absolute or relative URL to combine
  882. * @returns {string} The combined full path
  883. */
  884. module.exports = function buildFullPath(baseURL, requestedURL) {
  885. if (baseURL && !isAbsoluteURL(requestedURL)) {
  886. return combineURLs(baseURL, requestedURL);
  887. }
  888. return requestedURL;
  889. };
  890. /***/ }),
  891. /***/ "./node_modules/axios/lib/core/createError.js":
  892. /*!****************************************************!*\
  893. !*** ./node_modules/axios/lib/core/createError.js ***!
  894. \****************************************************/
  895. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  896. "use strict";
  897. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  898. /**
  899. * Create an Error with the specified message, config, error code, request and response.
  900. *
  901. * @param {string} message The error message.
  902. * @param {Object} config The config.
  903. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  904. * @param {Object} [request] The request.
  905. * @param {Object} [response] The response.
  906. * @returns {Error} The created error.
  907. */
  908. module.exports = function createError(message, config, code, request, response) {
  909. var error = new Error(message);
  910. return enhanceError(error, config, code, request, response);
  911. };
  912. /***/ }),
  913. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  914. /*!********************************************************!*\
  915. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  916. \********************************************************/
  917. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  918. "use strict";
  919. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  920. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  921. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  922. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  923. /**
  924. * Throws a `Cancel` if cancellation has been requested.
  925. */
  926. function throwIfCancellationRequested(config) {
  927. if (config.cancelToken) {
  928. config.cancelToken.throwIfRequested();
  929. }
  930. }
  931. /**
  932. * Dispatch a request to the server using the configured adapter.
  933. *
  934. * @param {object} config The config that is to be used for the request
  935. * @returns {Promise} The Promise to be fulfilled
  936. */
  937. module.exports = function dispatchRequest(config) {
  938. throwIfCancellationRequested(config);
  939. // Ensure headers exist
  940. config.headers = config.headers || {};
  941. // Transform request data
  942. config.data = transformData(
  943. config.data,
  944. config.headers,
  945. config.transformRequest
  946. );
  947. // Flatten headers
  948. config.headers = utils.merge(
  949. config.headers.common || {},
  950. config.headers[config.method] || {},
  951. config.headers
  952. );
  953. utils.forEach(
  954. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  955. function cleanHeaderConfig(method) {
  956. delete config.headers[method];
  957. }
  958. );
  959. var adapter = config.adapter || defaults.adapter;
  960. return adapter(config).then(function onAdapterResolution(response) {
  961. throwIfCancellationRequested(config);
  962. // Transform response data
  963. response.data = transformData(
  964. response.data,
  965. response.headers,
  966. config.transformResponse
  967. );
  968. return response;
  969. }, function onAdapterRejection(reason) {
  970. if (!isCancel(reason)) {
  971. throwIfCancellationRequested(config);
  972. // Transform response data
  973. if (reason && reason.response) {
  974. reason.response.data = transformData(
  975. reason.response.data,
  976. reason.response.headers,
  977. config.transformResponse
  978. );
  979. }
  980. }
  981. return Promise.reject(reason);
  982. });
  983. };
  984. /***/ }),
  985. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  986. /*!*****************************************************!*\
  987. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  988. \*****************************************************/
  989. /***/ ((module) => {
  990. "use strict";
  991. /**
  992. * Update an Error with the specified config, error code, and response.
  993. *
  994. * @param {Error} error The error to update.
  995. * @param {Object} config The config.
  996. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  997. * @param {Object} [request] The request.
  998. * @param {Object} [response] The response.
  999. * @returns {Error} The error.
  1000. */
  1001. module.exports = function enhanceError(error, config, code, request, response) {
  1002. error.config = config;
  1003. if (code) {
  1004. error.code = code;
  1005. }
  1006. error.request = request;
  1007. error.response = response;
  1008. error.isAxiosError = true;
  1009. error.toJSON = function toJSON() {
  1010. return {
  1011. // Standard
  1012. message: this.message,
  1013. name: this.name,
  1014. // Microsoft
  1015. description: this.description,
  1016. number: this.number,
  1017. // Mozilla
  1018. fileName: this.fileName,
  1019. lineNumber: this.lineNumber,
  1020. columnNumber: this.columnNumber,
  1021. stack: this.stack,
  1022. // Axios
  1023. config: this.config,
  1024. code: this.code
  1025. };
  1026. };
  1027. return error;
  1028. };
  1029. /***/ }),
  1030. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  1031. /*!****************************************************!*\
  1032. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  1033. \****************************************************/
  1034. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1035. "use strict";
  1036. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1037. /**
  1038. * Config-specific merge-function which creates a new config-object
  1039. * by merging two configuration objects together.
  1040. *
  1041. * @param {Object} config1
  1042. * @param {Object} config2
  1043. * @returns {Object} New object resulting from merging config2 to config1
  1044. */
  1045. module.exports = function mergeConfig(config1, config2) {
  1046. // eslint-disable-next-line no-param-reassign
  1047. config2 = config2 || {};
  1048. var config = {};
  1049. var valueFromConfig2Keys = ['url', 'method', 'data'];
  1050. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  1051. var defaultToConfig2Keys = [
  1052. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  1053. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  1054. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  1055. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  1056. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  1057. ];
  1058. var directMergeKeys = ['validateStatus'];
  1059. function getMergedValue(target, source) {
  1060. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  1061. return utils.merge(target, source);
  1062. } else if (utils.isPlainObject(source)) {
  1063. return utils.merge({}, source);
  1064. } else if (utils.isArray(source)) {
  1065. return source.slice();
  1066. }
  1067. return source;
  1068. }
  1069. function mergeDeepProperties(prop) {
  1070. if (!utils.isUndefined(config2[prop])) {
  1071. config[prop] = getMergedValue(config1[prop], config2[prop]);
  1072. } else if (!utils.isUndefined(config1[prop])) {
  1073. config[prop] = getMergedValue(undefined, config1[prop]);
  1074. }
  1075. }
  1076. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  1077. if (!utils.isUndefined(config2[prop])) {
  1078. config[prop] = getMergedValue(undefined, config2[prop]);
  1079. }
  1080. });
  1081. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  1082. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  1083. if (!utils.isUndefined(config2[prop])) {
  1084. config[prop] = getMergedValue(undefined, config2[prop]);
  1085. } else if (!utils.isUndefined(config1[prop])) {
  1086. config[prop] = getMergedValue(undefined, config1[prop]);
  1087. }
  1088. });
  1089. utils.forEach(directMergeKeys, function merge(prop) {
  1090. if (prop in config2) {
  1091. config[prop] = getMergedValue(config1[prop], config2[prop]);
  1092. } else if (prop in config1) {
  1093. config[prop] = getMergedValue(undefined, config1[prop]);
  1094. }
  1095. });
  1096. var axiosKeys = valueFromConfig2Keys
  1097. .concat(mergeDeepPropertiesKeys)
  1098. .concat(defaultToConfig2Keys)
  1099. .concat(directMergeKeys);
  1100. var otherKeys = Object
  1101. .keys(config1)
  1102. .concat(Object.keys(config2))
  1103. .filter(function filterAxiosKeys(key) {
  1104. return axiosKeys.indexOf(key) === -1;
  1105. });
  1106. utils.forEach(otherKeys, mergeDeepProperties);
  1107. return config;
  1108. };
  1109. /***/ }),
  1110. /***/ "./node_modules/axios/lib/core/settle.js":
  1111. /*!***********************************************!*\
  1112. !*** ./node_modules/axios/lib/core/settle.js ***!
  1113. \***********************************************/
  1114. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1115. "use strict";
  1116. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  1117. /**
  1118. * Resolve or reject a Promise based on response status.
  1119. *
  1120. * @param {Function} resolve A function that resolves the promise.
  1121. * @param {Function} reject A function that rejects the promise.
  1122. * @param {object} response The response.
  1123. */
  1124. module.exports = function settle(resolve, reject, response) {
  1125. var validateStatus = response.config.validateStatus;
  1126. if (!response.status || !validateStatus || validateStatus(response.status)) {
  1127. resolve(response);
  1128. } else {
  1129. reject(createError(
  1130. 'Request failed with status code ' + response.status,
  1131. response.config,
  1132. null,
  1133. response.request,
  1134. response
  1135. ));
  1136. }
  1137. };
  1138. /***/ }),
  1139. /***/ "./node_modules/axios/lib/core/transformData.js":
  1140. /*!******************************************************!*\
  1141. !*** ./node_modules/axios/lib/core/transformData.js ***!
  1142. \******************************************************/
  1143. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1144. "use strict";
  1145. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1146. /**
  1147. * Transform the data for a request or a response
  1148. *
  1149. * @param {Object|String} data The data to be transformed
  1150. * @param {Array} headers The headers for the request or response
  1151. * @param {Array|Function} fns A single function or Array of functions
  1152. * @returns {*} The resulting transformed data
  1153. */
  1154. module.exports = function transformData(data, headers, fns) {
  1155. /*eslint no-param-reassign:0*/
  1156. utils.forEach(fns, function transform(fn) {
  1157. data = fn(data, headers);
  1158. });
  1159. return data;
  1160. };
  1161. /***/ }),
  1162. /***/ "./node_modules/axios/lib/defaults.js":
  1163. /*!********************************************!*\
  1164. !*** ./node_modules/axios/lib/defaults.js ***!
  1165. \********************************************/
  1166. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1167. "use strict";
  1168. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
  1169. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  1170. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  1171. var DEFAULT_CONTENT_TYPE = {
  1172. 'Content-Type': 'application/x-www-form-urlencoded'
  1173. };
  1174. function setContentTypeIfUnset(headers, value) {
  1175. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  1176. headers['Content-Type'] = value;
  1177. }
  1178. }
  1179. function getDefaultAdapter() {
  1180. var adapter;
  1181. if (typeof XMLHttpRequest !== 'undefined') {
  1182. // For browsers use XHR adapter
  1183. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  1184. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  1185. // For node use HTTP adapter
  1186. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  1187. }
  1188. return adapter;
  1189. }
  1190. var defaults = {
  1191. adapter: getDefaultAdapter(),
  1192. transformRequest: [function transformRequest(data, headers) {
  1193. normalizeHeaderName(headers, 'Accept');
  1194. normalizeHeaderName(headers, 'Content-Type');
  1195. if (utils.isFormData(data) ||
  1196. utils.isArrayBuffer(data) ||
  1197. utils.isBuffer(data) ||
  1198. utils.isStream(data) ||
  1199. utils.isFile(data) ||
  1200. utils.isBlob(data)
  1201. ) {
  1202. return data;
  1203. }
  1204. if (utils.isArrayBufferView(data)) {
  1205. return data.buffer;
  1206. }
  1207. if (utils.isURLSearchParams(data)) {
  1208. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  1209. return data.toString();
  1210. }
  1211. if (utils.isObject(data)) {
  1212. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  1213. return JSON.stringify(data);
  1214. }
  1215. return data;
  1216. }],
  1217. transformResponse: [function transformResponse(data) {
  1218. /*eslint no-param-reassign:0*/
  1219. if (typeof data === 'string') {
  1220. try {
  1221. data = JSON.parse(data);
  1222. } catch (e) { /* Ignore */ }
  1223. }
  1224. return data;
  1225. }],
  1226. /**
  1227. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1228. * timeout is not created.
  1229. */
  1230. timeout: 0,
  1231. xsrfCookieName: 'XSRF-TOKEN',
  1232. xsrfHeaderName: 'X-XSRF-TOKEN',
  1233. maxContentLength: -1,
  1234. maxBodyLength: -1,
  1235. validateStatus: function validateStatus(status) {
  1236. return status >= 200 && status < 300;
  1237. }
  1238. };
  1239. defaults.headers = {
  1240. common: {
  1241. 'Accept': 'application/json, text/plain, */*'
  1242. }
  1243. };
  1244. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1245. defaults.headers[method] = {};
  1246. });
  1247. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1248. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1249. });
  1250. module.exports = defaults;
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/helpers/bind.js":
  1253. /*!************************************************!*\
  1254. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  1255. \************************************************/
  1256. /***/ ((module) => {
  1257. "use strict";
  1258. module.exports = function bind(fn, thisArg) {
  1259. return function wrap() {
  1260. var args = new Array(arguments.length);
  1261. for (var i = 0; i < args.length; i++) {
  1262. args[i] = arguments[i];
  1263. }
  1264. return fn.apply(thisArg, args);
  1265. };
  1266. };
  1267. /***/ }),
  1268. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  1269. /*!****************************************************!*\
  1270. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  1271. \****************************************************/
  1272. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1273. "use strict";
  1274. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1275. function encode(val) {
  1276. return encodeURIComponent(val).
  1277. replace(/%3A/gi, ':').
  1278. replace(/%24/g, '$').
  1279. replace(/%2C/gi, ',').
  1280. replace(/%20/g, '+').
  1281. replace(/%5B/gi, '[').
  1282. replace(/%5D/gi, ']');
  1283. }
  1284. /**
  1285. * Build a URL by appending params to the end
  1286. *
  1287. * @param {string} url The base of the url (e.g., http://www.google.com)
  1288. * @param {object} [params] The params to be appended
  1289. * @returns {string} The formatted url
  1290. */
  1291. module.exports = function buildURL(url, params, paramsSerializer) {
  1292. /*eslint no-param-reassign:0*/
  1293. if (!params) {
  1294. return url;
  1295. }
  1296. var serializedParams;
  1297. if (paramsSerializer) {
  1298. serializedParams = paramsSerializer(params);
  1299. } else if (utils.isURLSearchParams(params)) {
  1300. serializedParams = params.toString();
  1301. } else {
  1302. var parts = [];
  1303. utils.forEach(params, function serialize(val, key) {
  1304. if (val === null || typeof val === 'undefined') {
  1305. return;
  1306. }
  1307. if (utils.isArray(val)) {
  1308. key = key + '[]';
  1309. } else {
  1310. val = [val];
  1311. }
  1312. utils.forEach(val, function parseValue(v) {
  1313. if (utils.isDate(v)) {
  1314. v = v.toISOString();
  1315. } else if (utils.isObject(v)) {
  1316. v = JSON.stringify(v);
  1317. }
  1318. parts.push(encode(key) + '=' + encode(v));
  1319. });
  1320. });
  1321. serializedParams = parts.join('&');
  1322. }
  1323. if (serializedParams) {
  1324. var hashmarkIndex = url.indexOf('#');
  1325. if (hashmarkIndex !== -1) {
  1326. url = url.slice(0, hashmarkIndex);
  1327. }
  1328. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1329. }
  1330. return url;
  1331. };
  1332. /***/ }),
  1333. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  1334. /*!*******************************************************!*\
  1335. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  1336. \*******************************************************/
  1337. /***/ ((module) => {
  1338. "use strict";
  1339. /**
  1340. * Creates a new URL by combining the specified URLs
  1341. *
  1342. * @param {string} baseURL The base URL
  1343. * @param {string} relativeURL The relative URL
  1344. * @returns {string} The combined URL
  1345. */
  1346. module.exports = function combineURLs(baseURL, relativeURL) {
  1347. return relativeURL
  1348. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1349. : baseURL;
  1350. };
  1351. /***/ }),
  1352. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1353. /*!***************************************************!*\
  1354. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1355. \***************************************************/
  1356. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1357. "use strict";
  1358. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1359. module.exports = (
  1360. utils.isStandardBrowserEnv() ?
  1361. // Standard browser envs support document.cookie
  1362. (function standardBrowserEnv() {
  1363. return {
  1364. write: function write(name, value, expires, path, domain, secure) {
  1365. var cookie = [];
  1366. cookie.push(name + '=' + encodeURIComponent(value));
  1367. if (utils.isNumber(expires)) {
  1368. cookie.push('expires=' + new Date(expires).toGMTString());
  1369. }
  1370. if (utils.isString(path)) {
  1371. cookie.push('path=' + path);
  1372. }
  1373. if (utils.isString(domain)) {
  1374. cookie.push('domain=' + domain);
  1375. }
  1376. if (secure === true) {
  1377. cookie.push('secure');
  1378. }
  1379. document.cookie = cookie.join('; ');
  1380. },
  1381. read: function read(name) {
  1382. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1383. return (match ? decodeURIComponent(match[3]) : null);
  1384. },
  1385. remove: function remove(name) {
  1386. this.write(name, '', Date.now() - 86400000);
  1387. }
  1388. };
  1389. })() :
  1390. // Non standard browser env (web workers, react-native) lack needed support.
  1391. (function nonStandardBrowserEnv() {
  1392. return {
  1393. write: function write() {},
  1394. read: function read() { return null; },
  1395. remove: function remove() {}
  1396. };
  1397. })()
  1398. );
  1399. /***/ }),
  1400. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1401. /*!*********************************************************!*\
  1402. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1403. \*********************************************************/
  1404. /***/ ((module) => {
  1405. "use strict";
  1406. /**
  1407. * Determines whether the specified URL is absolute
  1408. *
  1409. * @param {string} url The URL to test
  1410. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1411. */
  1412. module.exports = function isAbsoluteURL(url) {
  1413. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1414. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1415. // by any combination of letters, digits, plus, period, or hyphen.
  1416. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1417. };
  1418. /***/ }),
  1419. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  1420. /*!********************************************************!*\
  1421. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  1422. \********************************************************/
  1423. /***/ ((module) => {
  1424. "use strict";
  1425. /**
  1426. * Determines whether the payload is an error thrown by Axios
  1427. *
  1428. * @param {*} payload The value to test
  1429. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1430. */
  1431. module.exports = function isAxiosError(payload) {
  1432. return (typeof payload === 'object') && (payload.isAxiosError === true);
  1433. };
  1434. /***/ }),
  1435. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1436. /*!***********************************************************!*\
  1437. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1438. \***********************************************************/
  1439. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1440. "use strict";
  1441. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1442. module.exports = (
  1443. utils.isStandardBrowserEnv() ?
  1444. // Standard browser envs have full support of the APIs needed to test
  1445. // whether the request URL is of the same origin as current location.
  1446. (function standardBrowserEnv() {
  1447. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1448. var urlParsingNode = document.createElement('a');
  1449. var originURL;
  1450. /**
  1451. * Parse a URL to discover it's components
  1452. *
  1453. * @param {String} url The URL to be parsed
  1454. * @returns {Object}
  1455. */
  1456. function resolveURL(url) {
  1457. var href = url;
  1458. if (msie) {
  1459. // IE needs attribute set twice to normalize properties
  1460. urlParsingNode.setAttribute('href', href);
  1461. href = urlParsingNode.href;
  1462. }
  1463. urlParsingNode.setAttribute('href', href);
  1464. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1465. return {
  1466. href: urlParsingNode.href,
  1467. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1468. host: urlParsingNode.host,
  1469. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1470. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1471. hostname: urlParsingNode.hostname,
  1472. port: urlParsingNode.port,
  1473. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1474. urlParsingNode.pathname :
  1475. '/' + urlParsingNode.pathname
  1476. };
  1477. }
  1478. originURL = resolveURL(window.location.href);
  1479. /**
  1480. * Determine if a URL shares the same origin as the current location
  1481. *
  1482. * @param {String} requestURL The URL to test
  1483. * @returns {boolean} True if URL shares the same origin, otherwise false
  1484. */
  1485. return function isURLSameOrigin(requestURL) {
  1486. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1487. return (parsed.protocol === originURL.protocol &&
  1488. parsed.host === originURL.host);
  1489. };
  1490. })() :
  1491. // Non standard browser envs (web workers, react-native) lack needed support.
  1492. (function nonStandardBrowserEnv() {
  1493. return function isURLSameOrigin() {
  1494. return true;
  1495. };
  1496. })()
  1497. );
  1498. /***/ }),
  1499. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1500. /*!***************************************************************!*\
  1501. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1502. \***************************************************************/
  1503. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1504. "use strict";
  1505. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1506. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1507. utils.forEach(headers, function processHeader(value, name) {
  1508. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1509. headers[normalizedName] = value;
  1510. delete headers[name];
  1511. }
  1512. });
  1513. };
  1514. /***/ }),
  1515. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1516. /*!********************************************************!*\
  1517. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1518. \********************************************************/
  1519. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1520. "use strict";
  1521. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1522. // Headers whose duplicates are ignored by node
  1523. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1524. var ignoreDuplicateOf = [
  1525. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1526. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1527. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1528. 'referer', 'retry-after', 'user-agent'
  1529. ];
  1530. /**
  1531. * Parse headers into an object
  1532. *
  1533. * ```
  1534. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1535. * Content-Type: application/json
  1536. * Connection: keep-alive
  1537. * Transfer-Encoding: chunked
  1538. * ```
  1539. *
  1540. * @param {String} headers Headers needing to be parsed
  1541. * @returns {Object} Headers parsed into an object
  1542. */
  1543. module.exports = function parseHeaders(headers) {
  1544. var parsed = {};
  1545. var key;
  1546. var val;
  1547. var i;
  1548. if (!headers) { return parsed; }
  1549. utils.forEach(headers.split('\n'), function parser(line) {
  1550. i = line.indexOf(':');
  1551. key = utils.trim(line.substr(0, i)).toLowerCase();
  1552. val = utils.trim(line.substr(i + 1));
  1553. if (key) {
  1554. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1555. return;
  1556. }
  1557. if (key === 'set-cookie') {
  1558. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1559. } else {
  1560. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1561. }
  1562. }
  1563. });
  1564. return parsed;
  1565. };
  1566. /***/ }),
  1567. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1568. /*!**************************************************!*\
  1569. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1570. \**************************************************/
  1571. /***/ ((module) => {
  1572. "use strict";
  1573. /**
  1574. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1575. *
  1576. * Common use case would be to use `Function.prototype.apply`.
  1577. *
  1578. * ```js
  1579. * function f(x, y, z) {}
  1580. * var args = [1, 2, 3];
  1581. * f.apply(null, args);
  1582. * ```
  1583. *
  1584. * With `spread` this example can be re-written.
  1585. *
  1586. * ```js
  1587. * spread(function(x, y, z) {})([1, 2, 3]);
  1588. * ```
  1589. *
  1590. * @param {Function} callback
  1591. * @returns {Function}
  1592. */
  1593. module.exports = function spread(callback) {
  1594. return function wrap(arr) {
  1595. return callback.apply(null, arr);
  1596. };
  1597. };
  1598. /***/ }),
  1599. /***/ "./node_modules/axios/lib/utils.js":
  1600. /*!*****************************************!*\
  1601. !*** ./node_modules/axios/lib/utils.js ***!
  1602. \*****************************************/
  1603. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1604. "use strict";
  1605. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1606. /*global toString:true*/
  1607. // utils is a library of generic helper functions non-specific to axios
  1608. var toString = Object.prototype.toString;
  1609. /**
  1610. * Determine if a value is an Array
  1611. *
  1612. * @param {Object} val The value to test
  1613. * @returns {boolean} True if value is an Array, otherwise false
  1614. */
  1615. function isArray(val) {
  1616. return toString.call(val) === '[object Array]';
  1617. }
  1618. /**
  1619. * Determine if a value is undefined
  1620. *
  1621. * @param {Object} val The value to test
  1622. * @returns {boolean} True if the value is undefined, otherwise false
  1623. */
  1624. function isUndefined(val) {
  1625. return typeof val === 'undefined';
  1626. }
  1627. /**
  1628. * Determine if a value is a Buffer
  1629. *
  1630. * @param {Object} val The value to test
  1631. * @returns {boolean} True if value is a Buffer, otherwise false
  1632. */
  1633. function isBuffer(val) {
  1634. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1635. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1636. }
  1637. /**
  1638. * Determine if a value is an ArrayBuffer
  1639. *
  1640. * @param {Object} val The value to test
  1641. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1642. */
  1643. function isArrayBuffer(val) {
  1644. return toString.call(val) === '[object ArrayBuffer]';
  1645. }
  1646. /**
  1647. * Determine if a value is a FormData
  1648. *
  1649. * @param {Object} val The value to test
  1650. * @returns {boolean} True if value is an FormData, otherwise false
  1651. */
  1652. function isFormData(val) {
  1653. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1654. }
  1655. /**
  1656. * Determine if a value is a view on an ArrayBuffer
  1657. *
  1658. * @param {Object} val The value to test
  1659. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1660. */
  1661. function isArrayBufferView(val) {
  1662. var result;
  1663. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1664. result = ArrayBuffer.isView(val);
  1665. } else {
  1666. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1667. }
  1668. return result;
  1669. }
  1670. /**
  1671. * Determine if a value is a String
  1672. *
  1673. * @param {Object} val The value to test
  1674. * @returns {boolean} True if value is a String, otherwise false
  1675. */
  1676. function isString(val) {
  1677. return typeof val === 'string';
  1678. }
  1679. /**
  1680. * Determine if a value is a Number
  1681. *
  1682. * @param {Object} val The value to test
  1683. * @returns {boolean} True if value is a Number, otherwise false
  1684. */
  1685. function isNumber(val) {
  1686. return typeof val === 'number';
  1687. }
  1688. /**
  1689. * Determine if a value is an Object
  1690. *
  1691. * @param {Object} val The value to test
  1692. * @returns {boolean} True if value is an Object, otherwise false
  1693. */
  1694. function isObject(val) {
  1695. return val !== null && typeof val === 'object';
  1696. }
  1697. /**
  1698. * Determine if a value is a plain Object
  1699. *
  1700. * @param {Object} val The value to test
  1701. * @return {boolean} True if value is a plain Object, otherwise false
  1702. */
  1703. function isPlainObject(val) {
  1704. if (toString.call(val) !== '[object Object]') {
  1705. return false;
  1706. }
  1707. var prototype = Object.getPrototypeOf(val);
  1708. return prototype === null || prototype === Object.prototype;
  1709. }
  1710. /**
  1711. * Determine if a value is a Date
  1712. *
  1713. * @param {Object} val The value to test
  1714. * @returns {boolean} True if value is a Date, otherwise false
  1715. */
  1716. function isDate(val) {
  1717. return toString.call(val) === '[object Date]';
  1718. }
  1719. /**
  1720. * Determine if a value is a File
  1721. *
  1722. * @param {Object} val The value to test
  1723. * @returns {boolean} True if value is a File, otherwise false
  1724. */
  1725. function isFile(val) {
  1726. return toString.call(val) === '[object File]';
  1727. }
  1728. /**
  1729. * Determine if a value is a Blob
  1730. *
  1731. * @param {Object} val The value to test
  1732. * @returns {boolean} True if value is a Blob, otherwise false
  1733. */
  1734. function isBlob(val) {
  1735. return toString.call(val) === '[object Blob]';
  1736. }
  1737. /**
  1738. * Determine if a value is a Function
  1739. *
  1740. * @param {Object} val The value to test
  1741. * @returns {boolean} True if value is a Function, otherwise false
  1742. */
  1743. function isFunction(val) {
  1744. return toString.call(val) === '[object Function]';
  1745. }
  1746. /**
  1747. * Determine if a value is a Stream
  1748. *
  1749. * @param {Object} val The value to test
  1750. * @returns {boolean} True if value is a Stream, otherwise false
  1751. */
  1752. function isStream(val) {
  1753. return isObject(val) && isFunction(val.pipe);
  1754. }
  1755. /**
  1756. * Determine if a value is a URLSearchParams object
  1757. *
  1758. * @param {Object} val The value to test
  1759. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1760. */
  1761. function isURLSearchParams(val) {
  1762. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1763. }
  1764. /**
  1765. * Trim excess whitespace off the beginning and end of a string
  1766. *
  1767. * @param {String} str The String to trim
  1768. * @returns {String} The String freed of excess whitespace
  1769. */
  1770. function trim(str) {
  1771. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1772. }
  1773. /**
  1774. * Determine if we're running in a standard browser environment
  1775. *
  1776. * This allows axios to run in a web worker, and react-native.
  1777. * Both environments support XMLHttpRequest, but not fully standard globals.
  1778. *
  1779. * web workers:
  1780. * typeof window -> undefined
  1781. * typeof document -> undefined
  1782. *
  1783. * react-native:
  1784. * navigator.product -> 'ReactNative'
  1785. * nativescript
  1786. * navigator.product -> 'NativeScript' or 'NS'
  1787. */
  1788. function isStandardBrowserEnv() {
  1789. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1790. navigator.product === 'NativeScript' ||
  1791. navigator.product === 'NS')) {
  1792. return false;
  1793. }
  1794. return (
  1795. typeof window !== 'undefined' &&
  1796. typeof document !== 'undefined'
  1797. );
  1798. }
  1799. /**
  1800. * Iterate over an Array or an Object invoking a function for each item.
  1801. *
  1802. * If `obj` is an Array callback will be called passing
  1803. * the value, index, and complete array for each item.
  1804. *
  1805. * If 'obj' is an Object callback will be called passing
  1806. * the value, key, and complete object for each property.
  1807. *
  1808. * @param {Object|Array} obj The object to iterate
  1809. * @param {Function} fn The callback to invoke for each item
  1810. */
  1811. function forEach(obj, fn) {
  1812. // Don't bother if no value provided
  1813. if (obj === null || typeof obj === 'undefined') {
  1814. return;
  1815. }
  1816. // Force an array if not already something iterable
  1817. if (typeof obj !== 'object') {
  1818. /*eslint no-param-reassign:0*/
  1819. obj = [obj];
  1820. }
  1821. if (isArray(obj)) {
  1822. // Iterate over array values
  1823. for (var i = 0, l = obj.length; i < l; i++) {
  1824. fn.call(null, obj[i], i, obj);
  1825. }
  1826. } else {
  1827. // Iterate over object keys
  1828. for (var key in obj) {
  1829. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1830. fn.call(null, obj[key], key, obj);
  1831. }
  1832. }
  1833. }
  1834. }
  1835. /**
  1836. * Accepts varargs expecting each argument to be an object, then
  1837. * immutably merges the properties of each object and returns result.
  1838. *
  1839. * When multiple objects contain the same key the later object in
  1840. * the arguments list will take precedence.
  1841. *
  1842. * Example:
  1843. *
  1844. * ```js
  1845. * var result = merge({foo: 123}, {foo: 456});
  1846. * console.log(result.foo); // outputs 456
  1847. * ```
  1848. *
  1849. * @param {Object} obj1 Object to merge
  1850. * @returns {Object} Result of all merge properties
  1851. */
  1852. function merge(/* obj1, obj2, obj3, ... */) {
  1853. var result = {};
  1854. function assignValue(val, key) {
  1855. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1856. result[key] = merge(result[key], val);
  1857. } else if (isPlainObject(val)) {
  1858. result[key] = merge({}, val);
  1859. } else if (isArray(val)) {
  1860. result[key] = val.slice();
  1861. } else {
  1862. result[key] = val;
  1863. }
  1864. }
  1865. for (var i = 0, l = arguments.length; i < l; i++) {
  1866. forEach(arguments[i], assignValue);
  1867. }
  1868. return result;
  1869. }
  1870. /**
  1871. * Extends object a by mutably adding to it the properties of object b.
  1872. *
  1873. * @param {Object} a The object to be extended
  1874. * @param {Object} b The object to copy properties from
  1875. * @param {Object} thisArg The object to bind function to
  1876. * @return {Object} The resulting value of object a
  1877. */
  1878. function extend(a, b, thisArg) {
  1879. forEach(b, function assignValue(val, key) {
  1880. if (thisArg && typeof val === 'function') {
  1881. a[key] = bind(val, thisArg);
  1882. } else {
  1883. a[key] = val;
  1884. }
  1885. });
  1886. return a;
  1887. }
  1888. /**
  1889. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1890. *
  1891. * @param {string} content with BOM
  1892. * @return {string} content value without BOM
  1893. */
  1894. function stripBOM(content) {
  1895. if (content.charCodeAt(0) === 0xFEFF) {
  1896. content = content.slice(1);
  1897. }
  1898. return content;
  1899. }
  1900. module.exports = {
  1901. isArray: isArray,
  1902. isArrayBuffer: isArrayBuffer,
  1903. isBuffer: isBuffer,
  1904. isFormData: isFormData,
  1905. isArrayBufferView: isArrayBufferView,
  1906. isString: isString,
  1907. isNumber: isNumber,
  1908. isObject: isObject,
  1909. isPlainObject: isPlainObject,
  1910. isUndefined: isUndefined,
  1911. isDate: isDate,
  1912. isFile: isFile,
  1913. isBlob: isBlob,
  1914. isFunction: isFunction,
  1915. isStream: isStream,
  1916. isURLSearchParams: isURLSearchParams,
  1917. isStandardBrowserEnv: isStandardBrowserEnv,
  1918. forEach: forEach,
  1919. merge: merge,
  1920. extend: extend,
  1921. trim: trim,
  1922. stripBOM: stripBOM
  1923. };
  1924. /***/ }),
  1925. /***/ "./resources/js/FormValidator.js":
  1926. /*!***************************************!*\
  1927. !*** ./resources/js/FormValidator.js ***!
  1928. \***************************************/
  1929. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1930. "use strict";
  1931. __webpack_require__.r(__webpack_exports__);
  1932. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1933. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1934. /* harmony export */ });
  1935. /* harmony import */ var validate_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! validate.js */ "./node_modules/validate.js/validate.js");
  1936. /* harmony import */ var validate_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(validate_js__WEBPACK_IMPORTED_MODULE_0__);
  1937. /* harmony import */ var form_serialize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! form-serialize */ "./node_modules/form-serialize/index.js");
  1938. /* harmony import */ var form_serialize__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(form_serialize__WEBPACK_IMPORTED_MODULE_1__);
  1939. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1940. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1941. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1942. /**
  1943. * Form Validator with RiotJS Components
  1944. *
  1945. *
  1946. *
  1947. *
  1948. */
  1949. var FormValidator = /*#__PURE__*/function () {
  1950. /**
  1951. *
  1952. * @param {[type]} formSelector [description]
  1953. * @param {[type]} constraits [description]
  1954. */
  1955. function FormValidator(formSelector, constraits, onSuccess) {
  1956. var _this = this;
  1957. _classCallCheck(this, FormValidator);
  1958. // getting selector to find form-element
  1959. this.formSelector = formSelector; // constraits for validate.js
  1960. this.constraits = constraits; // get form and elements
  1961. this.form = document.querySelector(this.formSelector);
  1962. this.elements = this.form.querySelectorAll('field-error'); // adding submit event
  1963. this.form.addEventListener('submit', function (event) {
  1964. _this.onSubmit(event);
  1965. }); // adding event if a element is updated
  1966. this.form.addEventListener('field-update', function (event) {
  1967. _this.onFieldUpdate(event);
  1968. });
  1969. this.onSuccess = onSuccess;
  1970. }
  1971. /**
  1972. *
  1973. * @param {[type]} event [description]
  1974. * @return {[type]} [description]
  1975. */
  1976. _createClass(FormValidator, [{
  1977. key: "onSubmit",
  1978. value: function onSubmit(event) {
  1979. var _this2 = this;
  1980. event.preventDefault();
  1981. var errors = validate_js__WEBPACK_IMPORTED_MODULE_0___default()(form_serialize__WEBPACK_IMPORTED_MODULE_1___default()(event.target, {
  1982. hash: true
  1983. }), this.constraits, {
  1984. fullMessages: false
  1985. });
  1986. if (errors) {
  1987. // send each element a event
  1988. this.elements.forEach(function (element) {
  1989. var elementErrors = false; // check for errors by name
  1990. if (errors[element.attributes.name.nodeValue]) {
  1991. elementErrors = errors[element.attributes.name.nodeValue];
  1992. }
  1993. _this2.dispatchCustomEvent(elementErrors, element);
  1994. });
  1995. } else {
  1996. this.onSuccess(event, form_serialize__WEBPACK_IMPORTED_MODULE_1___default()(event.target, {
  1997. hash: true
  1998. }));
  1999. }
  2000. }
  2001. /**
  2002. *
  2003. *
  2004. * @param {Event} event
  2005. *
  2006. */
  2007. }, {
  2008. key: "onFieldUpdate",
  2009. value: function onFieldUpdate(event) {
  2010. var _this3 = this;
  2011. // workaround, make sure that value for single is undefined if it is empty
  2012. if (event.detail.value == '') {
  2013. event.detail.value = undefined;
  2014. }
  2015. var errors = validate_js__WEBPACK_IMPORTED_MODULE_0___default().single(event.detail.value, this.constraits[event.detail.name]); // search for element by name and dispatch event
  2016. this.elements.forEach(function (element) {
  2017. if (element.attributes.name.nodeValue == event.detail.name) {
  2018. _this3.dispatchCustomEvent(errors, element);
  2019. }
  2020. });
  2021. }
  2022. /**
  2023. * dispatch event to single element
  2024. *
  2025. * @param {Array} errors
  2026. * @param {Element} element
  2027. *
  2028. */
  2029. }, {
  2030. key: "dispatchCustomEvent",
  2031. value: function dispatchCustomEvent(errors, element) {
  2032. var detail = false;
  2033. if (errors) {
  2034. detail = errors;
  2035. }
  2036. var formValidationEvent = new CustomEvent('form-validation', {
  2037. 'detail': detail
  2038. });
  2039. element.dispatchEvent(formValidationEvent);
  2040. }
  2041. }]);
  2042. return FormValidator;
  2043. }();
  2044. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (FormValidator);
  2045. /***/ }),
  2046. /***/ "./node_modules/form-serialize/index.js":
  2047. /*!**********************************************!*\
  2048. !*** ./node_modules/form-serialize/index.js ***!
  2049. \**********************************************/
  2050. /***/ ((module) => {
  2051. // get successful control from form and assemble into object
  2052. // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2
  2053. // types which indicate a submit action and are not successful controls
  2054. // these will be ignored
  2055. var k_r_submitter = /^(?:submit|button|image|reset|file)$/i;
  2056. // node names which could be successful controls
  2057. var k_r_success_contrls = /^(?:input|select|textarea|keygen)/i;
  2058. // Matches bracket notation.
  2059. var brackets = /(\[[^\[\]]*\])/g;
  2060. // serializes form fields
  2061. // @param form MUST be an HTMLForm element
  2062. // @param options is an optional argument to configure the serialization. Default output
  2063. // with no options specified is a url encoded string
  2064. // - hash: [true | false] Configure the output type. If true, the output will
  2065. // be a js object.
  2066. // - serializer: [function] Optional serializer function to override the default one.
  2067. // The function takes 3 arguments (result, key, value) and should return new result
  2068. // hash and url encoded str serializers are provided with this module
  2069. // - disabled: [true | false]. If true serialize disabled fields.
  2070. // - empty: [true | false]. If true serialize empty fields
  2071. function serialize(form, options) {
  2072. if (typeof options != 'object') {
  2073. options = { hash: !!options };
  2074. }
  2075. else if (options.hash === undefined) {
  2076. options.hash = true;
  2077. }
  2078. var result = (options.hash) ? {} : '';
  2079. var serializer = options.serializer || ((options.hash) ? hash_serializer : str_serialize);
  2080. var elements = form && form.elements ? form.elements : [];
  2081. //Object store each radio and set if it's empty or not
  2082. var radio_store = Object.create(null);
  2083. for (var i=0 ; i<elements.length ; ++i) {
  2084. var element = elements[i];
  2085. // ingore disabled fields
  2086. if ((!options.disabled && element.disabled) || !element.name) {
  2087. continue;
  2088. }
  2089. // ignore anyhting that is not considered a success field
  2090. if (!k_r_success_contrls.test(element.nodeName) ||
  2091. k_r_submitter.test(element.type)) {
  2092. continue;
  2093. }
  2094. var key = element.name;
  2095. var val = element.value;
  2096. // we can't just use element.value for checkboxes cause some browsers lie to us
  2097. // they say "on" for value when the box isn't checked
  2098. if ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) {
  2099. val = undefined;
  2100. }
  2101. // If we want empty elements
  2102. if (options.empty) {
  2103. // for checkbox
  2104. if (element.type === 'checkbox' && !element.checked) {
  2105. val = '';
  2106. }
  2107. // for radio
  2108. if (element.type === 'radio') {
  2109. if (!radio_store[element.name] && !element.checked) {
  2110. radio_store[element.name] = false;
  2111. }
  2112. else if (element.checked) {
  2113. radio_store[element.name] = true;
  2114. }
  2115. }
  2116. // if options empty is true, continue only if its radio
  2117. if (val == undefined && element.type == 'radio') {
  2118. continue;
  2119. }
  2120. }
  2121. else {
  2122. // value-less fields are ignored unless options.empty is true
  2123. if (!val) {
  2124. continue;
  2125. }
  2126. }
  2127. // multi select boxes
  2128. if (element.type === 'select-multiple') {
  2129. val = [];
  2130. var selectOptions = element.options;
  2131. var isSelectedOptions = false;
  2132. for (var j=0 ; j<selectOptions.length ; ++j) {
  2133. var option = selectOptions[j];
  2134. var allowedEmpty = options.empty && !option.value;
  2135. var hasValue = (option.value || allowedEmpty);
  2136. if (option.selected && hasValue) {
  2137. isSelectedOptions = true;
  2138. // If using a hash serializer be sure to add the
  2139. // correct notation for an array in the multi-select
  2140. // context. Here the name attribute on the select element
  2141. // might be missing the trailing bracket pair. Both names
  2142. // "foo" and "foo[]" should be arrays.
  2143. if (options.hash && key.slice(key.length - 2) !== '[]') {
  2144. result = serializer(result, key + '[]', option.value);
  2145. }
  2146. else {
  2147. result = serializer(result, key, option.value);
  2148. }
  2149. }
  2150. }
  2151. // Serialize if no selected options and options.empty is true
  2152. if (!isSelectedOptions && options.empty) {
  2153. result = serializer(result, key, '');
  2154. }
  2155. continue;
  2156. }
  2157. result = serializer(result, key, val);
  2158. }
  2159. // Check for all empty radio buttons and serialize them with key=""
  2160. if (options.empty) {
  2161. for (var key in radio_store) {
  2162. if (!radio_store[key]) {
  2163. result = serializer(result, key, '');
  2164. }
  2165. }
  2166. }
  2167. return result;
  2168. }
  2169. function parse_keys(string) {
  2170. var keys = [];
  2171. var prefix = /^([^\[\]]*)/;
  2172. var children = new RegExp(brackets);
  2173. var match = prefix.exec(string);
  2174. if (match[1]) {
  2175. keys.push(match[1]);
  2176. }
  2177. while ((match = children.exec(string)) !== null) {
  2178. keys.push(match[1]);
  2179. }
  2180. return keys;
  2181. }
  2182. function hash_assign(result, keys, value) {
  2183. if (keys.length === 0) {
  2184. result = value;
  2185. return result;
  2186. }
  2187. var key = keys.shift();
  2188. var between = key.match(/^\[(.+?)\]$/);
  2189. if (key === '[]') {
  2190. result = result || [];
  2191. if (Array.isArray(result)) {
  2192. result.push(hash_assign(null, keys, value));
  2193. }
  2194. else {
  2195. // This might be the result of bad name attributes like "[][foo]",
  2196. // in this case the original `result` object will already be
  2197. // assigned to an object literal. Rather than coerce the object to
  2198. // an array, or cause an exception the attribute "_values" is
  2199. // assigned as an array.
  2200. result._values = result._values || [];
  2201. result._values.push(hash_assign(null, keys, value));
  2202. }
  2203. return result;
  2204. }
  2205. // Key is an attribute name and can be assigned directly.
  2206. if (!between) {
  2207. result[key] = hash_assign(result[key], keys, value);
  2208. }
  2209. else {
  2210. var string = between[1];
  2211. // +var converts the variable into a number
  2212. // better than parseInt because it doesn't truncate away trailing
  2213. // letters and actually fails if whole thing is not a number
  2214. var index = +string;
  2215. // If the characters between the brackets is not a number it is an
  2216. // attribute name and can be assigned directly.
  2217. if (isNaN(index)) {
  2218. result = result || {};
  2219. result[string] = hash_assign(result[string], keys, value);
  2220. }
  2221. else {
  2222. result = result || [];
  2223. result[index] = hash_assign(result[index], keys, value);
  2224. }
  2225. }
  2226. return result;
  2227. }
  2228. // Object/hash encoding serializer.
  2229. function hash_serializer(result, key, value) {
  2230. var matches = key.match(brackets);
  2231. // Has brackets? Use the recursive assignment function to walk the keys,
  2232. // construct any missing objects in the result tree and make the assignment
  2233. // at the end of the chain.
  2234. if (matches) {
  2235. var keys = parse_keys(key);
  2236. hash_assign(result, keys, value);
  2237. }
  2238. else {
  2239. // Non bracket notation can make assignments directly.
  2240. var existing = result[key];
  2241. // If the value has been assigned already (for instance when a radio and
  2242. // a checkbox have the same name attribute) convert the previous value
  2243. // into an array before pushing into it.
  2244. //
  2245. // NOTE: If this requirement were removed all hash creation and
  2246. // assignment could go through `hash_assign`.
  2247. if (existing) {
  2248. if (!Array.isArray(existing)) {
  2249. result[key] = [ existing ];
  2250. }
  2251. result[key].push(value);
  2252. }
  2253. else {
  2254. result[key] = value;
  2255. }
  2256. }
  2257. return result;
  2258. }
  2259. // urlform encoding serializer
  2260. function str_serialize(result, key, value) {
  2261. // encode newlines as \r\n cause the html spec says so
  2262. value = value.replace(/(\r)?\n/g, '\r\n');
  2263. value = encodeURIComponent(value);
  2264. // spaces should be '+' rather than '%20'.
  2265. value = value.replace(/%20/g, '+');
  2266. return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value;
  2267. }
  2268. module.exports = serialize;
  2269. /***/ }),
  2270. /***/ "./node_modules/lodash.remove/index.js":
  2271. /*!*********************************************!*\
  2272. !*** ./node_modules/lodash.remove/index.js ***!
  2273. \*********************************************/
  2274. /***/ ((module, exports, __webpack_require__) => {
  2275. /* module decorator */ module = __webpack_require__.nmd(module);
  2276. /**
  2277. * lodash (Custom Build) <https://lodash.com/>
  2278. * Build: `lodash modularize exports="npm" -o ./`
  2279. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  2280. * Released under MIT license <https://lodash.com/license>
  2281. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  2282. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  2283. */
  2284. /** Used as the size to enable large array optimizations. */
  2285. var LARGE_ARRAY_SIZE = 200;
  2286. /** Used as the `TypeError` message for "Functions" methods. */
  2287. var FUNC_ERROR_TEXT = 'Expected a function';
  2288. /** Used to stand-in for `undefined` hash values. */
  2289. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  2290. /** Used to compose bitmasks for comparison styles. */
  2291. var UNORDERED_COMPARE_FLAG = 1,
  2292. PARTIAL_COMPARE_FLAG = 2;
  2293. /** Used as references for various `Number` constants. */
  2294. var INFINITY = 1 / 0,
  2295. MAX_SAFE_INTEGER = 9007199254740991;
  2296. /** `Object#toString` result references. */
  2297. var argsTag = '[object Arguments]',
  2298. arrayTag = '[object Array]',
  2299. boolTag = '[object Boolean]',
  2300. dateTag = '[object Date]',
  2301. errorTag = '[object Error]',
  2302. funcTag = '[object Function]',
  2303. genTag = '[object GeneratorFunction]',
  2304. mapTag = '[object Map]',
  2305. numberTag = '[object Number]',
  2306. objectTag = '[object Object]',
  2307. promiseTag = '[object Promise]',
  2308. regexpTag = '[object RegExp]',
  2309. setTag = '[object Set]',
  2310. stringTag = '[object String]',
  2311. symbolTag = '[object Symbol]',
  2312. weakMapTag = '[object WeakMap]';
  2313. var arrayBufferTag = '[object ArrayBuffer]',
  2314. dataViewTag = '[object DataView]',
  2315. float32Tag = '[object Float32Array]',
  2316. float64Tag = '[object Float64Array]',
  2317. int8Tag = '[object Int8Array]',
  2318. int16Tag = '[object Int16Array]',
  2319. int32Tag = '[object Int32Array]',
  2320. uint8Tag = '[object Uint8Array]',
  2321. uint8ClampedTag = '[object Uint8ClampedArray]',
  2322. uint16Tag = '[object Uint16Array]',
  2323. uint32Tag = '[object Uint32Array]';
  2324. /** Used to match property names within property paths. */
  2325. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  2326. reIsPlainProp = /^\w*$/,
  2327. reLeadingDot = /^\./,
  2328. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  2329. /**
  2330. * Used to match `RegExp`
  2331. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  2332. */
  2333. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  2334. /** Used to match backslashes in property paths. */
  2335. var reEscapeChar = /\\(\\)?/g;
  2336. /** Used to detect host constructors (Safari). */
  2337. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  2338. /** Used to detect unsigned integer values. */
  2339. var reIsUint = /^(?:0|[1-9]\d*)$/;
  2340. /** Used to identify `toStringTag` values of typed arrays. */
  2341. var typedArrayTags = {};
  2342. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  2343. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  2344. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  2345. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  2346. typedArrayTags[uint32Tag] = true;
  2347. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  2348. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  2349. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  2350. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  2351. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  2352. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  2353. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  2354. typedArrayTags[weakMapTag] = false;
  2355. /** Detect free variable `global` from Node.js. */
  2356. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  2357. /** Detect free variable `self`. */
  2358. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  2359. /** Used as a reference to the global object. */
  2360. var root = freeGlobal || freeSelf || Function('return this')();
  2361. /** Detect free variable `exports`. */
  2362. var freeExports = true && exports && !exports.nodeType && exports;
  2363. /** Detect free variable `module`. */
  2364. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  2365. /** Detect the popular CommonJS extension `module.exports`. */
  2366. var moduleExports = freeModule && freeModule.exports === freeExports;
  2367. /** Detect free variable `process` from Node.js. */
  2368. var freeProcess = moduleExports && freeGlobal.process;
  2369. /** Used to access faster Node.js helpers. */
  2370. var nodeUtil = (function() {
  2371. try {
  2372. return freeProcess && freeProcess.binding('util');
  2373. } catch (e) {}
  2374. }());
  2375. /* Node.js helper references. */
  2376. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  2377. /**
  2378. * A specialized version of `_.some` for arrays without support for iteratee
  2379. * shorthands.
  2380. *
  2381. * @private
  2382. * @param {Array} [array] The array to iterate over.
  2383. * @param {Function} predicate The function invoked per iteration.
  2384. * @returns {boolean} Returns `true` if any element passes the predicate check,
  2385. * else `false`.
  2386. */
  2387. function arraySome(array, predicate) {
  2388. var index = -1,
  2389. length = array ? array.length : 0;
  2390. while (++index < length) {
  2391. if (predicate(array[index], index, array)) {
  2392. return true;
  2393. }
  2394. }
  2395. return false;
  2396. }
  2397. /**
  2398. * The base implementation of `_.property` without support for deep paths.
  2399. *
  2400. * @private
  2401. * @param {string} key The key of the property to get.
  2402. * @returns {Function} Returns the new accessor function.
  2403. */
  2404. function baseProperty(key) {
  2405. return function(object) {
  2406. return object == null ? undefined : object[key];
  2407. };
  2408. }
  2409. /**
  2410. * The base implementation of `_.times` without support for iteratee shorthands
  2411. * or max array length checks.
  2412. *
  2413. * @private
  2414. * @param {number} n The number of times to invoke `iteratee`.
  2415. * @param {Function} iteratee The function invoked per iteration.
  2416. * @returns {Array} Returns the array of results.
  2417. */
  2418. function baseTimes(n, iteratee) {
  2419. var index = -1,
  2420. result = Array(n);
  2421. while (++index < n) {
  2422. result[index] = iteratee(index);
  2423. }
  2424. return result;
  2425. }
  2426. /**
  2427. * The base implementation of `_.unary` without support for storing metadata.
  2428. *
  2429. * @private
  2430. * @param {Function} func The function to cap arguments for.
  2431. * @returns {Function} Returns the new capped function.
  2432. */
  2433. function baseUnary(func) {
  2434. return function(value) {
  2435. return func(value);
  2436. };
  2437. }
  2438. /**
  2439. * Gets the value at `key` of `object`.
  2440. *
  2441. * @private
  2442. * @param {Object} [object] The object to query.
  2443. * @param {string} key The key of the property to get.
  2444. * @returns {*} Returns the property value.
  2445. */
  2446. function getValue(object, key) {
  2447. return object == null ? undefined : object[key];
  2448. }
  2449. /**
  2450. * Checks if `value` is a host object in IE < 9.
  2451. *
  2452. * @private
  2453. * @param {*} value The value to check.
  2454. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  2455. */
  2456. function isHostObject(value) {
  2457. // Many host objects are `Object` objects that can coerce to strings
  2458. // despite having improperly defined `toString` methods.
  2459. var result = false;
  2460. if (value != null && typeof value.toString != 'function') {
  2461. try {
  2462. result = !!(value + '');
  2463. } catch (e) {}
  2464. }
  2465. return result;
  2466. }
  2467. /**
  2468. * Converts `map` to its key-value pairs.
  2469. *
  2470. * @private
  2471. * @param {Object} map The map to convert.
  2472. * @returns {Array} Returns the key-value pairs.
  2473. */
  2474. function mapToArray(map) {
  2475. var index = -1,
  2476. result = Array(map.size);
  2477. map.forEach(function(value, key) {
  2478. result[++index] = [key, value];
  2479. });
  2480. return result;
  2481. }
  2482. /**
  2483. * Creates a unary function that invokes `func` with its argument transformed.
  2484. *
  2485. * @private
  2486. * @param {Function} func The function to wrap.
  2487. * @param {Function} transform The argument transform.
  2488. * @returns {Function} Returns the new function.
  2489. */
  2490. function overArg(func, transform) {
  2491. return function(arg) {
  2492. return func(transform(arg));
  2493. };
  2494. }
  2495. /**
  2496. * Converts `set` to an array of its values.
  2497. *
  2498. * @private
  2499. * @param {Object} set The set to convert.
  2500. * @returns {Array} Returns the values.
  2501. */
  2502. function setToArray(set) {
  2503. var index = -1,
  2504. result = Array(set.size);
  2505. set.forEach(function(value) {
  2506. result[++index] = value;
  2507. });
  2508. return result;
  2509. }
  2510. /** Used for built-in method references. */
  2511. var arrayProto = Array.prototype,
  2512. funcProto = Function.prototype,
  2513. objectProto = Object.prototype;
  2514. /** Used to detect overreaching core-js shims. */
  2515. var coreJsData = root['__core-js_shared__'];
  2516. /** Used to detect methods masquerading as native. */
  2517. var maskSrcKey = (function() {
  2518. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2519. return uid ? ('Symbol(src)_1.' + uid) : '';
  2520. }());
  2521. /** Used to resolve the decompiled source of functions. */
  2522. var funcToString = funcProto.toString;
  2523. /** Used to check objects for own properties. */
  2524. var hasOwnProperty = objectProto.hasOwnProperty;
  2525. /**
  2526. * Used to resolve the
  2527. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2528. * of values.
  2529. */
  2530. var objectToString = objectProto.toString;
  2531. /** Used to detect if a method is native. */
  2532. var reIsNative = RegExp('^' +
  2533. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2534. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2535. );
  2536. /** Built-in value references. */
  2537. var Symbol = root.Symbol,
  2538. Uint8Array = root.Uint8Array,
  2539. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2540. splice = arrayProto.splice;
  2541. /* Built-in method references for those with the same name as other `lodash` methods. */
  2542. var nativeKeys = overArg(Object.keys, Object);
  2543. /* Built-in method references that are verified to be native. */
  2544. var DataView = getNative(root, 'DataView'),
  2545. Map = getNative(root, 'Map'),
  2546. Promise = getNative(root, 'Promise'),
  2547. Set = getNative(root, 'Set'),
  2548. WeakMap = getNative(root, 'WeakMap'),
  2549. nativeCreate = getNative(Object, 'create');
  2550. /** Used to detect maps, sets, and weakmaps. */
  2551. var dataViewCtorString = toSource(DataView),
  2552. mapCtorString = toSource(Map),
  2553. promiseCtorString = toSource(Promise),
  2554. setCtorString = toSource(Set),
  2555. weakMapCtorString = toSource(WeakMap);
  2556. /** Used to convert symbols to primitives and strings. */
  2557. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2558. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2559. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2560. /**
  2561. * Creates a hash object.
  2562. *
  2563. * @private
  2564. * @constructor
  2565. * @param {Array} [entries] The key-value pairs to cache.
  2566. */
  2567. function Hash(entries) {
  2568. var index = -1,
  2569. length = entries ? entries.length : 0;
  2570. this.clear();
  2571. while (++index < length) {
  2572. var entry = entries[index];
  2573. this.set(entry[0], entry[1]);
  2574. }
  2575. }
  2576. /**
  2577. * Removes all key-value entries from the hash.
  2578. *
  2579. * @private
  2580. * @name clear
  2581. * @memberOf Hash
  2582. */
  2583. function hashClear() {
  2584. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2585. }
  2586. /**
  2587. * Removes `key` and its value from the hash.
  2588. *
  2589. * @private
  2590. * @name delete
  2591. * @memberOf Hash
  2592. * @param {Object} hash The hash to modify.
  2593. * @param {string} key The key of the value to remove.
  2594. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2595. */
  2596. function hashDelete(key) {
  2597. return this.has(key) && delete this.__data__[key];
  2598. }
  2599. /**
  2600. * Gets the hash value for `key`.
  2601. *
  2602. * @private
  2603. * @name get
  2604. * @memberOf Hash
  2605. * @param {string} key The key of the value to get.
  2606. * @returns {*} Returns the entry value.
  2607. */
  2608. function hashGet(key) {
  2609. var data = this.__data__;
  2610. if (nativeCreate) {
  2611. var result = data[key];
  2612. return result === HASH_UNDEFINED ? undefined : result;
  2613. }
  2614. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2615. }
  2616. /**
  2617. * Checks if a hash value for `key` exists.
  2618. *
  2619. * @private
  2620. * @name has
  2621. * @memberOf Hash
  2622. * @param {string} key The key of the entry to check.
  2623. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2624. */
  2625. function hashHas(key) {
  2626. var data = this.__data__;
  2627. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  2628. }
  2629. /**
  2630. * Sets the hash `key` to `value`.
  2631. *
  2632. * @private
  2633. * @name set
  2634. * @memberOf Hash
  2635. * @param {string} key The key of the value to set.
  2636. * @param {*} value The value to set.
  2637. * @returns {Object} Returns the hash instance.
  2638. */
  2639. function hashSet(key, value) {
  2640. var data = this.__data__;
  2641. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2642. return this;
  2643. }
  2644. // Add methods to `Hash`.
  2645. Hash.prototype.clear = hashClear;
  2646. Hash.prototype['delete'] = hashDelete;
  2647. Hash.prototype.get = hashGet;
  2648. Hash.prototype.has = hashHas;
  2649. Hash.prototype.set = hashSet;
  2650. /**
  2651. * Creates an list cache object.
  2652. *
  2653. * @private
  2654. * @constructor
  2655. * @param {Array} [entries] The key-value pairs to cache.
  2656. */
  2657. function ListCache(entries) {
  2658. var index = -1,
  2659. length = entries ? entries.length : 0;
  2660. this.clear();
  2661. while (++index < length) {
  2662. var entry = entries[index];
  2663. this.set(entry[0], entry[1]);
  2664. }
  2665. }
  2666. /**
  2667. * Removes all key-value entries from the list cache.
  2668. *
  2669. * @private
  2670. * @name clear
  2671. * @memberOf ListCache
  2672. */
  2673. function listCacheClear() {
  2674. this.__data__ = [];
  2675. }
  2676. /**
  2677. * Removes `key` and its value from the list cache.
  2678. *
  2679. * @private
  2680. * @name delete
  2681. * @memberOf ListCache
  2682. * @param {string} key The key of the value to remove.
  2683. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2684. */
  2685. function listCacheDelete(key) {
  2686. var data = this.__data__,
  2687. index = assocIndexOf(data, key);
  2688. if (index < 0) {
  2689. return false;
  2690. }
  2691. var lastIndex = data.length - 1;
  2692. if (index == lastIndex) {
  2693. data.pop();
  2694. } else {
  2695. splice.call(data, index, 1);
  2696. }
  2697. return true;
  2698. }
  2699. /**
  2700. * Gets the list cache value for `key`.
  2701. *
  2702. * @private
  2703. * @name get
  2704. * @memberOf ListCache
  2705. * @param {string} key The key of the value to get.
  2706. * @returns {*} Returns the entry value.
  2707. */
  2708. function listCacheGet(key) {
  2709. var data = this.__data__,
  2710. index = assocIndexOf(data, key);
  2711. return index < 0 ? undefined : data[index][1];
  2712. }
  2713. /**
  2714. * Checks if a list cache value for `key` exists.
  2715. *
  2716. * @private
  2717. * @name has
  2718. * @memberOf ListCache
  2719. * @param {string} key The key of the entry to check.
  2720. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2721. */
  2722. function listCacheHas(key) {
  2723. return assocIndexOf(this.__data__, key) > -1;
  2724. }
  2725. /**
  2726. * Sets the list cache `key` to `value`.
  2727. *
  2728. * @private
  2729. * @name set
  2730. * @memberOf ListCache
  2731. * @param {string} key The key of the value to set.
  2732. * @param {*} value The value to set.
  2733. * @returns {Object} Returns the list cache instance.
  2734. */
  2735. function listCacheSet(key, value) {
  2736. var data = this.__data__,
  2737. index = assocIndexOf(data, key);
  2738. if (index < 0) {
  2739. data.push([key, value]);
  2740. } else {
  2741. data[index][1] = value;
  2742. }
  2743. return this;
  2744. }
  2745. // Add methods to `ListCache`.
  2746. ListCache.prototype.clear = listCacheClear;
  2747. ListCache.prototype['delete'] = listCacheDelete;
  2748. ListCache.prototype.get = listCacheGet;
  2749. ListCache.prototype.has = listCacheHas;
  2750. ListCache.prototype.set = listCacheSet;
  2751. /**
  2752. * Creates a map cache object to store key-value pairs.
  2753. *
  2754. * @private
  2755. * @constructor
  2756. * @param {Array} [entries] The key-value pairs to cache.
  2757. */
  2758. function MapCache(entries) {
  2759. var index = -1,
  2760. length = entries ? entries.length : 0;
  2761. this.clear();
  2762. while (++index < length) {
  2763. var entry = entries[index];
  2764. this.set(entry[0], entry[1]);
  2765. }
  2766. }
  2767. /**
  2768. * Removes all key-value entries from the map.
  2769. *
  2770. * @private
  2771. * @name clear
  2772. * @memberOf MapCache
  2773. */
  2774. function mapCacheClear() {
  2775. this.__data__ = {
  2776. 'hash': new Hash,
  2777. 'map': new (Map || ListCache),
  2778. 'string': new Hash
  2779. };
  2780. }
  2781. /**
  2782. * Removes `key` and its value from the map.
  2783. *
  2784. * @private
  2785. * @name delete
  2786. * @memberOf MapCache
  2787. * @param {string} key The key of the value to remove.
  2788. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2789. */
  2790. function mapCacheDelete(key) {
  2791. return getMapData(this, key)['delete'](key);
  2792. }
  2793. /**
  2794. * Gets the map value for `key`.
  2795. *
  2796. * @private
  2797. * @name get
  2798. * @memberOf MapCache
  2799. * @param {string} key The key of the value to get.
  2800. * @returns {*} Returns the entry value.
  2801. */
  2802. function mapCacheGet(key) {
  2803. return getMapData(this, key).get(key);
  2804. }
  2805. /**
  2806. * Checks if a map value for `key` exists.
  2807. *
  2808. * @private
  2809. * @name has
  2810. * @memberOf MapCache
  2811. * @param {string} key The key of the entry to check.
  2812. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2813. */
  2814. function mapCacheHas(key) {
  2815. return getMapData(this, key).has(key);
  2816. }
  2817. /**
  2818. * Sets the map `key` to `value`.
  2819. *
  2820. * @private
  2821. * @name set
  2822. * @memberOf MapCache
  2823. * @param {string} key The key of the value to set.
  2824. * @param {*} value The value to set.
  2825. * @returns {Object} Returns the map cache instance.
  2826. */
  2827. function mapCacheSet(key, value) {
  2828. getMapData(this, key).set(key, value);
  2829. return this;
  2830. }
  2831. // Add methods to `MapCache`.
  2832. MapCache.prototype.clear = mapCacheClear;
  2833. MapCache.prototype['delete'] = mapCacheDelete;
  2834. MapCache.prototype.get = mapCacheGet;
  2835. MapCache.prototype.has = mapCacheHas;
  2836. MapCache.prototype.set = mapCacheSet;
  2837. /**
  2838. *
  2839. * Creates an array cache object to store unique values.
  2840. *
  2841. * @private
  2842. * @constructor
  2843. * @param {Array} [values] The values to cache.
  2844. */
  2845. function SetCache(values) {
  2846. var index = -1,
  2847. length = values ? values.length : 0;
  2848. this.__data__ = new MapCache;
  2849. while (++index < length) {
  2850. this.add(values[index]);
  2851. }
  2852. }
  2853. /**
  2854. * Adds `value` to the array cache.
  2855. *
  2856. * @private
  2857. * @name add
  2858. * @memberOf SetCache
  2859. * @alias push
  2860. * @param {*} value The value to cache.
  2861. * @returns {Object} Returns the cache instance.
  2862. */
  2863. function setCacheAdd(value) {
  2864. this.__data__.set(value, HASH_UNDEFINED);
  2865. return this;
  2866. }
  2867. /**
  2868. * Checks if `value` is in the array cache.
  2869. *
  2870. * @private
  2871. * @name has
  2872. * @memberOf SetCache
  2873. * @param {*} value The value to search for.
  2874. * @returns {number} Returns `true` if `value` is found, else `false`.
  2875. */
  2876. function setCacheHas(value) {
  2877. return this.__data__.has(value);
  2878. }
  2879. // Add methods to `SetCache`.
  2880. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  2881. SetCache.prototype.has = setCacheHas;
  2882. /**
  2883. * Creates a stack cache object to store key-value pairs.
  2884. *
  2885. * @private
  2886. * @constructor
  2887. * @param {Array} [entries] The key-value pairs to cache.
  2888. */
  2889. function Stack(entries) {
  2890. this.__data__ = new ListCache(entries);
  2891. }
  2892. /**
  2893. * Removes all key-value entries from the stack.
  2894. *
  2895. * @private
  2896. * @name clear
  2897. * @memberOf Stack
  2898. */
  2899. function stackClear() {
  2900. this.__data__ = new ListCache;
  2901. }
  2902. /**
  2903. * Removes `key` and its value from the stack.
  2904. *
  2905. * @private
  2906. * @name delete
  2907. * @memberOf Stack
  2908. * @param {string} key The key of the value to remove.
  2909. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2910. */
  2911. function stackDelete(key) {
  2912. return this.__data__['delete'](key);
  2913. }
  2914. /**
  2915. * Gets the stack value for `key`.
  2916. *
  2917. * @private
  2918. * @name get
  2919. * @memberOf Stack
  2920. * @param {string} key The key of the value to get.
  2921. * @returns {*} Returns the entry value.
  2922. */
  2923. function stackGet(key) {
  2924. return this.__data__.get(key);
  2925. }
  2926. /**
  2927. * Checks if a stack value for `key` exists.
  2928. *
  2929. * @private
  2930. * @name has
  2931. * @memberOf Stack
  2932. * @param {string} key The key of the entry to check.
  2933. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2934. */
  2935. function stackHas(key) {
  2936. return this.__data__.has(key);
  2937. }
  2938. /**
  2939. * Sets the stack `key` to `value`.
  2940. *
  2941. * @private
  2942. * @name set
  2943. * @memberOf Stack
  2944. * @param {string} key The key of the value to set.
  2945. * @param {*} value The value to set.
  2946. * @returns {Object} Returns the stack cache instance.
  2947. */
  2948. function stackSet(key, value) {
  2949. var cache = this.__data__;
  2950. if (cache instanceof ListCache) {
  2951. var pairs = cache.__data__;
  2952. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  2953. pairs.push([key, value]);
  2954. return this;
  2955. }
  2956. cache = this.__data__ = new MapCache(pairs);
  2957. }
  2958. cache.set(key, value);
  2959. return this;
  2960. }
  2961. // Add methods to `Stack`.
  2962. Stack.prototype.clear = stackClear;
  2963. Stack.prototype['delete'] = stackDelete;
  2964. Stack.prototype.get = stackGet;
  2965. Stack.prototype.has = stackHas;
  2966. Stack.prototype.set = stackSet;
  2967. /**
  2968. * Creates an array of the enumerable property names of the array-like `value`.
  2969. *
  2970. * @private
  2971. * @param {*} value The value to query.
  2972. * @param {boolean} inherited Specify returning inherited property names.
  2973. * @returns {Array} Returns the array of property names.
  2974. */
  2975. function arrayLikeKeys(value, inherited) {
  2976. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  2977. // Safari 9 makes `arguments.length` enumerable in strict mode.
  2978. var result = (isArray(value) || isArguments(value))
  2979. ? baseTimes(value.length, String)
  2980. : [];
  2981. var length = result.length,
  2982. skipIndexes = !!length;
  2983. for (var key in value) {
  2984. if ((inherited || hasOwnProperty.call(value, key)) &&
  2985. !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  2986. result.push(key);
  2987. }
  2988. }
  2989. return result;
  2990. }
  2991. /**
  2992. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2993. *
  2994. * @private
  2995. * @param {Array} array The array to inspect.
  2996. * @param {*} key The key to search for.
  2997. * @returns {number} Returns the index of the matched value, else `-1`.
  2998. */
  2999. function assocIndexOf(array, key) {
  3000. var length = array.length;
  3001. while (length--) {
  3002. if (eq(array[length][0], key)) {
  3003. return length;
  3004. }
  3005. }
  3006. return -1;
  3007. }
  3008. /**
  3009. * The base implementation of `_.get` without support for default values.
  3010. *
  3011. * @private
  3012. * @param {Object} object The object to query.
  3013. * @param {Array|string} path The path of the property to get.
  3014. * @returns {*} Returns the resolved value.
  3015. */
  3016. function baseGet(object, path) {
  3017. path = isKey(path, object) ? [path] : castPath(path);
  3018. var index = 0,
  3019. length = path.length;
  3020. while (object != null && index < length) {
  3021. object = object[toKey(path[index++])];
  3022. }
  3023. return (index && index == length) ? object : undefined;
  3024. }
  3025. /**
  3026. * The base implementation of `getTag`.
  3027. *
  3028. * @private
  3029. * @param {*} value The value to query.
  3030. * @returns {string} Returns the `toStringTag`.
  3031. */
  3032. function baseGetTag(value) {
  3033. return objectToString.call(value);
  3034. }
  3035. /**
  3036. * The base implementation of `_.hasIn` without support for deep paths.
  3037. *
  3038. * @private
  3039. * @param {Object} [object] The object to query.
  3040. * @param {Array|string} key The key to check.
  3041. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3042. */
  3043. function baseHasIn(object, key) {
  3044. return object != null && key in Object(object);
  3045. }
  3046. /**
  3047. * The base implementation of `_.isEqual` which supports partial comparisons
  3048. * and tracks traversed objects.
  3049. *
  3050. * @private
  3051. * @param {*} value The value to compare.
  3052. * @param {*} other The other value to compare.
  3053. * @param {Function} [customizer] The function to customize comparisons.
  3054. * @param {boolean} [bitmask] The bitmask of comparison flags.
  3055. * The bitmask may be composed of the following flags:
  3056. * 1 - Unordered comparison
  3057. * 2 - Partial comparison
  3058. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  3059. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3060. */
  3061. function baseIsEqual(value, other, customizer, bitmask, stack) {
  3062. if (value === other) {
  3063. return true;
  3064. }
  3065. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  3066. return value !== value && other !== other;
  3067. }
  3068. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  3069. }
  3070. /**
  3071. * A specialized version of `baseIsEqual` for arrays and objects which performs
  3072. * deep comparisons and tracks traversed objects enabling objects with circular
  3073. * references to be compared.
  3074. *
  3075. * @private
  3076. * @param {Object} object The object to compare.
  3077. * @param {Object} other The other object to compare.
  3078. * @param {Function} equalFunc The function to determine equivalents of values.
  3079. * @param {Function} [customizer] The function to customize comparisons.
  3080. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  3081. * for more details.
  3082. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  3083. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3084. */
  3085. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  3086. var objIsArr = isArray(object),
  3087. othIsArr = isArray(other),
  3088. objTag = arrayTag,
  3089. othTag = arrayTag;
  3090. if (!objIsArr) {
  3091. objTag = getTag(object);
  3092. objTag = objTag == argsTag ? objectTag : objTag;
  3093. }
  3094. if (!othIsArr) {
  3095. othTag = getTag(other);
  3096. othTag = othTag == argsTag ? objectTag : othTag;
  3097. }
  3098. var objIsObj = objTag == objectTag && !isHostObject(object),
  3099. othIsObj = othTag == objectTag && !isHostObject(other),
  3100. isSameTag = objTag == othTag;
  3101. if (isSameTag && !objIsObj) {
  3102. stack || (stack = new Stack);
  3103. return (objIsArr || isTypedArray(object))
  3104. ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
  3105. : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  3106. }
  3107. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  3108. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  3109. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  3110. if (objIsWrapped || othIsWrapped) {
  3111. var objUnwrapped = objIsWrapped ? object.value() : object,
  3112. othUnwrapped = othIsWrapped ? other.value() : other;
  3113. stack || (stack = new Stack);
  3114. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  3115. }
  3116. }
  3117. if (!isSameTag) {
  3118. return false;
  3119. }
  3120. stack || (stack = new Stack);
  3121. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  3122. }
  3123. /**
  3124. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  3125. *
  3126. * @private
  3127. * @param {Object} object The object to inspect.
  3128. * @param {Object} source The object of property values to match.
  3129. * @param {Array} matchData The property names, values, and compare flags to match.
  3130. * @param {Function} [customizer] The function to customize comparisons.
  3131. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  3132. */
  3133. function baseIsMatch(object, source, matchData, customizer) {
  3134. var index = matchData.length,
  3135. length = index,
  3136. noCustomizer = !customizer;
  3137. if (object == null) {
  3138. return !length;
  3139. }
  3140. object = Object(object);
  3141. while (index--) {
  3142. var data = matchData[index];
  3143. if ((noCustomizer && data[2])
  3144. ? data[1] !== object[data[0]]
  3145. : !(data[0] in object)
  3146. ) {
  3147. return false;
  3148. }
  3149. }
  3150. while (++index < length) {
  3151. data = matchData[index];
  3152. var key = data[0],
  3153. objValue = object[key],
  3154. srcValue = data[1];
  3155. if (noCustomizer && data[2]) {
  3156. if (objValue === undefined && !(key in object)) {
  3157. return false;
  3158. }
  3159. } else {
  3160. var stack = new Stack;
  3161. if (customizer) {
  3162. var result = customizer(objValue, srcValue, key, object, source, stack);
  3163. }
  3164. if (!(result === undefined
  3165. ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
  3166. : result
  3167. )) {
  3168. return false;
  3169. }
  3170. }
  3171. }
  3172. return true;
  3173. }
  3174. /**
  3175. * The base implementation of `_.isNative` without bad shim checks.
  3176. *
  3177. * @private
  3178. * @param {*} value The value to check.
  3179. * @returns {boolean} Returns `true` if `value` is a native function,
  3180. * else `false`.
  3181. */
  3182. function baseIsNative(value) {
  3183. if (!isObject(value) || isMasked(value)) {
  3184. return false;
  3185. }
  3186. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  3187. return pattern.test(toSource(value));
  3188. }
  3189. /**
  3190. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  3191. *
  3192. * @private
  3193. * @param {*} value The value to check.
  3194. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3195. */
  3196. function baseIsTypedArray(value) {
  3197. return isObjectLike(value) &&
  3198. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  3199. }
  3200. /**
  3201. * The base implementation of `_.iteratee`.
  3202. *
  3203. * @private
  3204. * @param {*} [value=_.identity] The value to convert to an iteratee.
  3205. * @returns {Function} Returns the iteratee.
  3206. */
  3207. function baseIteratee(value) {
  3208. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  3209. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  3210. if (typeof value == 'function') {
  3211. return value;
  3212. }
  3213. if (value == null) {
  3214. return identity;
  3215. }
  3216. if (typeof value == 'object') {
  3217. return isArray(value)
  3218. ? baseMatchesProperty(value[0], value[1])
  3219. : baseMatches(value);
  3220. }
  3221. return property(value);
  3222. }
  3223. /**
  3224. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  3225. *
  3226. * @private
  3227. * @param {Object} object The object to query.
  3228. * @returns {Array} Returns the array of property names.
  3229. */
  3230. function baseKeys(object) {
  3231. if (!isPrototype(object)) {
  3232. return nativeKeys(object);
  3233. }
  3234. var result = [];
  3235. for (var key in Object(object)) {
  3236. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  3237. result.push(key);
  3238. }
  3239. }
  3240. return result;
  3241. }
  3242. /**
  3243. * The base implementation of `_.matches` which doesn't clone `source`.
  3244. *
  3245. * @private
  3246. * @param {Object} source The object of property values to match.
  3247. * @returns {Function} Returns the new spec function.
  3248. */
  3249. function baseMatches(source) {
  3250. var matchData = getMatchData(source);
  3251. if (matchData.length == 1 && matchData[0][2]) {
  3252. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  3253. }
  3254. return function(object) {
  3255. return object === source || baseIsMatch(object, source, matchData);
  3256. };
  3257. }
  3258. /**
  3259. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  3260. *
  3261. * @private
  3262. * @param {string} path The path of the property to get.
  3263. * @param {*} srcValue The value to match.
  3264. * @returns {Function} Returns the new spec function.
  3265. */
  3266. function baseMatchesProperty(path, srcValue) {
  3267. if (isKey(path) && isStrictComparable(srcValue)) {
  3268. return matchesStrictComparable(toKey(path), srcValue);
  3269. }
  3270. return function(object) {
  3271. var objValue = get(object, path);
  3272. return (objValue === undefined && objValue === srcValue)
  3273. ? hasIn(object, path)
  3274. : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  3275. };
  3276. }
  3277. /**
  3278. * A specialized version of `baseProperty` which supports deep paths.
  3279. *
  3280. * @private
  3281. * @param {Array|string} path The path of the property to get.
  3282. * @returns {Function} Returns the new accessor function.
  3283. */
  3284. function basePropertyDeep(path) {
  3285. return function(object) {
  3286. return baseGet(object, path);
  3287. };
  3288. }
  3289. /**
  3290. * The base implementation of `_.pullAt` without support for individual
  3291. * indexes or capturing the removed elements.
  3292. *
  3293. * @private
  3294. * @param {Array} array The array to modify.
  3295. * @param {number[]} indexes The indexes of elements to remove.
  3296. * @returns {Array} Returns `array`.
  3297. */
  3298. function basePullAt(array, indexes) {
  3299. var length = array ? indexes.length : 0,
  3300. lastIndex = length - 1;
  3301. while (length--) {
  3302. var index = indexes[length];
  3303. if (length == lastIndex || index !== previous) {
  3304. var previous = index;
  3305. if (isIndex(index)) {
  3306. splice.call(array, index, 1);
  3307. }
  3308. else if (!isKey(index, array)) {
  3309. var path = castPath(index),
  3310. object = parent(array, path);
  3311. if (object != null) {
  3312. delete object[toKey(last(path))];
  3313. }
  3314. }
  3315. else {
  3316. delete array[toKey(index)];
  3317. }
  3318. }
  3319. }
  3320. return array;
  3321. }
  3322. /**
  3323. * The base implementation of `_.slice` without an iteratee call guard.
  3324. *
  3325. * @private
  3326. * @param {Array} array The array to slice.
  3327. * @param {number} [start=0] The start position.
  3328. * @param {number} [end=array.length] The end position.
  3329. * @returns {Array} Returns the slice of `array`.
  3330. */
  3331. function baseSlice(array, start, end) {
  3332. var index = -1,
  3333. length = array.length;
  3334. if (start < 0) {
  3335. start = -start > length ? 0 : (length + start);
  3336. }
  3337. end = end > length ? length : end;
  3338. if (end < 0) {
  3339. end += length;
  3340. }
  3341. length = start > end ? 0 : ((end - start) >>> 0);
  3342. start >>>= 0;
  3343. var result = Array(length);
  3344. while (++index < length) {
  3345. result[index] = array[index + start];
  3346. }
  3347. return result;
  3348. }
  3349. /**
  3350. * The base implementation of `_.toString` which doesn't convert nullish
  3351. * values to empty strings.
  3352. *
  3353. * @private
  3354. * @param {*} value The value to process.
  3355. * @returns {string} Returns the string.
  3356. */
  3357. function baseToString(value) {
  3358. // Exit early for strings to avoid a performance hit in some environments.
  3359. if (typeof value == 'string') {
  3360. return value;
  3361. }
  3362. if (isSymbol(value)) {
  3363. return symbolToString ? symbolToString.call(value) : '';
  3364. }
  3365. var result = (value + '');
  3366. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  3367. }
  3368. /**
  3369. * Casts `value` to a path array if it's not one.
  3370. *
  3371. * @private
  3372. * @param {*} value The value to inspect.
  3373. * @returns {Array} Returns the cast property path array.
  3374. */
  3375. function castPath(value) {
  3376. return isArray(value) ? value : stringToPath(value);
  3377. }
  3378. /**
  3379. * A specialized version of `baseIsEqualDeep` for arrays with support for
  3380. * partial deep comparisons.
  3381. *
  3382. * @private
  3383. * @param {Array} array The array to compare.
  3384. * @param {Array} other The other array to compare.
  3385. * @param {Function} equalFunc The function to determine equivalents of values.
  3386. * @param {Function} customizer The function to customize comparisons.
  3387. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3388. * for more details.
  3389. * @param {Object} stack Tracks traversed `array` and `other` objects.
  3390. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  3391. */
  3392. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  3393. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  3394. arrLength = array.length,
  3395. othLength = other.length;
  3396. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  3397. return false;
  3398. }
  3399. // Assume cyclic values are equal.
  3400. var stacked = stack.get(array);
  3401. if (stacked && stack.get(other)) {
  3402. return stacked == other;
  3403. }
  3404. var index = -1,
  3405. result = true,
  3406. seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
  3407. stack.set(array, other);
  3408. stack.set(other, array);
  3409. // Ignore non-index properties.
  3410. while (++index < arrLength) {
  3411. var arrValue = array[index],
  3412. othValue = other[index];
  3413. if (customizer) {
  3414. var compared = isPartial
  3415. ? customizer(othValue, arrValue, index, other, array, stack)
  3416. : customizer(arrValue, othValue, index, array, other, stack);
  3417. }
  3418. if (compared !== undefined) {
  3419. if (compared) {
  3420. continue;
  3421. }
  3422. result = false;
  3423. break;
  3424. }
  3425. // Recursively compare arrays (susceptible to call stack limits).
  3426. if (seen) {
  3427. if (!arraySome(other, function(othValue, othIndex) {
  3428. if (!seen.has(othIndex) &&
  3429. (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  3430. return seen.add(othIndex);
  3431. }
  3432. })) {
  3433. result = false;
  3434. break;
  3435. }
  3436. } else if (!(
  3437. arrValue === othValue ||
  3438. equalFunc(arrValue, othValue, customizer, bitmask, stack)
  3439. )) {
  3440. result = false;
  3441. break;
  3442. }
  3443. }
  3444. stack['delete'](array);
  3445. stack['delete'](other);
  3446. return result;
  3447. }
  3448. /**
  3449. * A specialized version of `baseIsEqualDeep` for comparing objects of
  3450. * the same `toStringTag`.
  3451. *
  3452. * **Note:** This function only supports comparing values with tags of
  3453. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  3454. *
  3455. * @private
  3456. * @param {Object} object The object to compare.
  3457. * @param {Object} other The other object to compare.
  3458. * @param {string} tag The `toStringTag` of the objects to compare.
  3459. * @param {Function} equalFunc The function to determine equivalents of values.
  3460. * @param {Function} customizer The function to customize comparisons.
  3461. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3462. * for more details.
  3463. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3464. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3465. */
  3466. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  3467. switch (tag) {
  3468. case dataViewTag:
  3469. if ((object.byteLength != other.byteLength) ||
  3470. (object.byteOffset != other.byteOffset)) {
  3471. return false;
  3472. }
  3473. object = object.buffer;
  3474. other = other.buffer;
  3475. case arrayBufferTag:
  3476. if ((object.byteLength != other.byteLength) ||
  3477. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  3478. return false;
  3479. }
  3480. return true;
  3481. case boolTag:
  3482. case dateTag:
  3483. case numberTag:
  3484. // Coerce booleans to `1` or `0` and dates to milliseconds.
  3485. // Invalid dates are coerced to `NaN`.
  3486. return eq(+object, +other);
  3487. case errorTag:
  3488. return object.name == other.name && object.message == other.message;
  3489. case regexpTag:
  3490. case stringTag:
  3491. // Coerce regexes to strings and treat strings, primitives and objects,
  3492. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  3493. // for more details.
  3494. return object == (other + '');
  3495. case mapTag:
  3496. var convert = mapToArray;
  3497. case setTag:
  3498. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  3499. convert || (convert = setToArray);
  3500. if (object.size != other.size && !isPartial) {
  3501. return false;
  3502. }
  3503. // Assume cyclic values are equal.
  3504. var stacked = stack.get(object);
  3505. if (stacked) {
  3506. return stacked == other;
  3507. }
  3508. bitmask |= UNORDERED_COMPARE_FLAG;
  3509. // Recursively compare objects (susceptible to call stack limits).
  3510. stack.set(object, other);
  3511. var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  3512. stack['delete'](object);
  3513. return result;
  3514. case symbolTag:
  3515. if (symbolValueOf) {
  3516. return symbolValueOf.call(object) == symbolValueOf.call(other);
  3517. }
  3518. }
  3519. return false;
  3520. }
  3521. /**
  3522. * A specialized version of `baseIsEqualDeep` for objects with support for
  3523. * partial deep comparisons.
  3524. *
  3525. * @private
  3526. * @param {Object} object The object to compare.
  3527. * @param {Object} other The other object to compare.
  3528. * @param {Function} equalFunc The function to determine equivalents of values.
  3529. * @param {Function} customizer The function to customize comparisons.
  3530. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3531. * for more details.
  3532. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3533. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3534. */
  3535. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  3536. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  3537. objProps = keys(object),
  3538. objLength = objProps.length,
  3539. othProps = keys(other),
  3540. othLength = othProps.length;
  3541. if (objLength != othLength && !isPartial) {
  3542. return false;
  3543. }
  3544. var index = objLength;
  3545. while (index--) {
  3546. var key = objProps[index];
  3547. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  3548. return false;
  3549. }
  3550. }
  3551. // Assume cyclic values are equal.
  3552. var stacked = stack.get(object);
  3553. if (stacked && stack.get(other)) {
  3554. return stacked == other;
  3555. }
  3556. var result = true;
  3557. stack.set(object, other);
  3558. stack.set(other, object);
  3559. var skipCtor = isPartial;
  3560. while (++index < objLength) {
  3561. key = objProps[index];
  3562. var objValue = object[key],
  3563. othValue = other[key];
  3564. if (customizer) {
  3565. var compared = isPartial
  3566. ? customizer(othValue, objValue, key, other, object, stack)
  3567. : customizer(objValue, othValue, key, object, other, stack);
  3568. }
  3569. // Recursively compare objects (susceptible to call stack limits).
  3570. if (!(compared === undefined
  3571. ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
  3572. : compared
  3573. )) {
  3574. result = false;
  3575. break;
  3576. }
  3577. skipCtor || (skipCtor = key == 'constructor');
  3578. }
  3579. if (result && !skipCtor) {
  3580. var objCtor = object.constructor,
  3581. othCtor = other.constructor;
  3582. // Non `Object` object instances with different constructors are not equal.
  3583. if (objCtor != othCtor &&
  3584. ('constructor' in object && 'constructor' in other) &&
  3585. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  3586. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  3587. result = false;
  3588. }
  3589. }
  3590. stack['delete'](object);
  3591. stack['delete'](other);
  3592. return result;
  3593. }
  3594. /**
  3595. * Gets the data for `map`.
  3596. *
  3597. * @private
  3598. * @param {Object} map The map to query.
  3599. * @param {string} key The reference key.
  3600. * @returns {*} Returns the map data.
  3601. */
  3602. function getMapData(map, key) {
  3603. var data = map.__data__;
  3604. return isKeyable(key)
  3605. ? data[typeof key == 'string' ? 'string' : 'hash']
  3606. : data.map;
  3607. }
  3608. /**
  3609. * Gets the property names, values, and compare flags of `object`.
  3610. *
  3611. * @private
  3612. * @param {Object} object The object to query.
  3613. * @returns {Array} Returns the match data of `object`.
  3614. */
  3615. function getMatchData(object) {
  3616. var result = keys(object),
  3617. length = result.length;
  3618. while (length--) {
  3619. var key = result[length],
  3620. value = object[key];
  3621. result[length] = [key, value, isStrictComparable(value)];
  3622. }
  3623. return result;
  3624. }
  3625. /**
  3626. * Gets the native function at `key` of `object`.
  3627. *
  3628. * @private
  3629. * @param {Object} object The object to query.
  3630. * @param {string} key The key of the method to get.
  3631. * @returns {*} Returns the function if it's native, else `undefined`.
  3632. */
  3633. function getNative(object, key) {
  3634. var value = getValue(object, key);
  3635. return baseIsNative(value) ? value : undefined;
  3636. }
  3637. /**
  3638. * Gets the `toStringTag` of `value`.
  3639. *
  3640. * @private
  3641. * @param {*} value The value to query.
  3642. * @returns {string} Returns the `toStringTag`.
  3643. */
  3644. var getTag = baseGetTag;
  3645. // Fallback for data views, maps, sets, and weak maps in IE 11,
  3646. // for data views in Edge < 14, and promises in Node.js.
  3647. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  3648. (Map && getTag(new Map) != mapTag) ||
  3649. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  3650. (Set && getTag(new Set) != setTag) ||
  3651. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  3652. getTag = function(value) {
  3653. var result = objectToString.call(value),
  3654. Ctor = result == objectTag ? value.constructor : undefined,
  3655. ctorString = Ctor ? toSource(Ctor) : undefined;
  3656. if (ctorString) {
  3657. switch (ctorString) {
  3658. case dataViewCtorString: return dataViewTag;
  3659. case mapCtorString: return mapTag;
  3660. case promiseCtorString: return promiseTag;
  3661. case setCtorString: return setTag;
  3662. case weakMapCtorString: return weakMapTag;
  3663. }
  3664. }
  3665. return result;
  3666. };
  3667. }
  3668. /**
  3669. * Checks if `path` exists on `object`.
  3670. *
  3671. * @private
  3672. * @param {Object} object The object to query.
  3673. * @param {Array|string} path The path to check.
  3674. * @param {Function} hasFunc The function to check properties.
  3675. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  3676. */
  3677. function hasPath(object, path, hasFunc) {
  3678. path = isKey(path, object) ? [path] : castPath(path);
  3679. var result,
  3680. index = -1,
  3681. length = path.length;
  3682. while (++index < length) {
  3683. var key = toKey(path[index]);
  3684. if (!(result = object != null && hasFunc(object, key))) {
  3685. break;
  3686. }
  3687. object = object[key];
  3688. }
  3689. if (result) {
  3690. return result;
  3691. }
  3692. var length = object ? object.length : 0;
  3693. return !!length && isLength(length) && isIndex(key, length) &&
  3694. (isArray(object) || isArguments(object));
  3695. }
  3696. /**
  3697. * Checks if `value` is a valid array-like index.
  3698. *
  3699. * @private
  3700. * @param {*} value The value to check.
  3701. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  3702. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  3703. */
  3704. function isIndex(value, length) {
  3705. length = length == null ? MAX_SAFE_INTEGER : length;
  3706. return !!length &&
  3707. (typeof value == 'number' || reIsUint.test(value)) &&
  3708. (value > -1 && value % 1 == 0 && value < length);
  3709. }
  3710. /**
  3711. * Checks if `value` is a property name and not a property path.
  3712. *
  3713. * @private
  3714. * @param {*} value The value to check.
  3715. * @param {Object} [object] The object to query keys on.
  3716. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  3717. */
  3718. function isKey(value, object) {
  3719. if (isArray(value)) {
  3720. return false;
  3721. }
  3722. var type = typeof value;
  3723. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  3724. value == null || isSymbol(value)) {
  3725. return true;
  3726. }
  3727. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  3728. (object != null && value in Object(object));
  3729. }
  3730. /**
  3731. * Checks if `value` is suitable for use as unique object key.
  3732. *
  3733. * @private
  3734. * @param {*} value The value to check.
  3735. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  3736. */
  3737. function isKeyable(value) {
  3738. var type = typeof value;
  3739. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  3740. ? (value !== '__proto__')
  3741. : (value === null);
  3742. }
  3743. /**
  3744. * Checks if `func` has its source masked.
  3745. *
  3746. * @private
  3747. * @param {Function} func The function to check.
  3748. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  3749. */
  3750. function isMasked(func) {
  3751. return !!maskSrcKey && (maskSrcKey in func);
  3752. }
  3753. /**
  3754. * Checks if `value` is likely a prototype object.
  3755. *
  3756. * @private
  3757. * @param {*} value The value to check.
  3758. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  3759. */
  3760. function isPrototype(value) {
  3761. var Ctor = value && value.constructor,
  3762. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  3763. return value === proto;
  3764. }
  3765. /**
  3766. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  3767. *
  3768. * @private
  3769. * @param {*} value The value to check.
  3770. * @returns {boolean} Returns `true` if `value` if suitable for strict
  3771. * equality comparisons, else `false`.
  3772. */
  3773. function isStrictComparable(value) {
  3774. return value === value && !isObject(value);
  3775. }
  3776. /**
  3777. * A specialized version of `matchesProperty` for source values suitable
  3778. * for strict equality comparisons, i.e. `===`.
  3779. *
  3780. * @private
  3781. * @param {string} key The key of the property to get.
  3782. * @param {*} srcValue The value to match.
  3783. * @returns {Function} Returns the new spec function.
  3784. */
  3785. function matchesStrictComparable(key, srcValue) {
  3786. return function(object) {
  3787. if (object == null) {
  3788. return false;
  3789. }
  3790. return object[key] === srcValue &&
  3791. (srcValue !== undefined || (key in Object(object)));
  3792. };
  3793. }
  3794. /**
  3795. * Gets the parent value at `path` of `object`.
  3796. *
  3797. * @private
  3798. * @param {Object} object The object to query.
  3799. * @param {Array} path The path to get the parent value of.
  3800. * @returns {*} Returns the parent value.
  3801. */
  3802. function parent(object, path) {
  3803. return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  3804. }
  3805. /**
  3806. * Converts `string` to a property path array.
  3807. *
  3808. * @private
  3809. * @param {string} string The string to convert.
  3810. * @returns {Array} Returns the property path array.
  3811. */
  3812. var stringToPath = memoize(function(string) {
  3813. string = toString(string);
  3814. var result = [];
  3815. if (reLeadingDot.test(string)) {
  3816. result.push('');
  3817. }
  3818. string.replace(rePropName, function(match, number, quote, string) {
  3819. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  3820. });
  3821. return result;
  3822. });
  3823. /**
  3824. * Converts `value` to a string key if it's not a string or symbol.
  3825. *
  3826. * @private
  3827. * @param {*} value The value to inspect.
  3828. * @returns {string|symbol} Returns the key.
  3829. */
  3830. function toKey(value) {
  3831. if (typeof value == 'string' || isSymbol(value)) {
  3832. return value;
  3833. }
  3834. var result = (value + '');
  3835. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  3836. }
  3837. /**
  3838. * Converts `func` to its source code.
  3839. *
  3840. * @private
  3841. * @param {Function} func The function to process.
  3842. * @returns {string} Returns the source code.
  3843. */
  3844. function toSource(func) {
  3845. if (func != null) {
  3846. try {
  3847. return funcToString.call(func);
  3848. } catch (e) {}
  3849. try {
  3850. return (func + '');
  3851. } catch (e) {}
  3852. }
  3853. return '';
  3854. }
  3855. /**
  3856. * Gets the last element of `array`.
  3857. *
  3858. * @static
  3859. * @memberOf _
  3860. * @since 0.1.0
  3861. * @category Array
  3862. * @param {Array} array The array to query.
  3863. * @returns {*} Returns the last element of `array`.
  3864. * @example
  3865. *
  3866. * _.last([1, 2, 3]);
  3867. * // => 3
  3868. */
  3869. function last(array) {
  3870. var length = array ? array.length : 0;
  3871. return length ? array[length - 1] : undefined;
  3872. }
  3873. /**
  3874. * Removes all elements from `array` that `predicate` returns truthy for
  3875. * and returns an array of the removed elements. The predicate is invoked
  3876. * with three arguments: (value, index, array).
  3877. *
  3878. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  3879. * to pull elements from an array by value.
  3880. *
  3881. * @static
  3882. * @memberOf _
  3883. * @since 2.0.0
  3884. * @category Array
  3885. * @param {Array} array The array to modify.
  3886. * @param {Function} [predicate=_.identity]
  3887. * The function invoked per iteration.
  3888. * @returns {Array} Returns the new array of removed elements.
  3889. * @example
  3890. *
  3891. * var array = [1, 2, 3, 4];
  3892. * var evens = _.remove(array, function(n) {
  3893. * return n % 2 == 0;
  3894. * });
  3895. *
  3896. * console.log(array);
  3897. * // => [1, 3]
  3898. *
  3899. * console.log(evens);
  3900. * // => [2, 4]
  3901. */
  3902. function remove(array, predicate) {
  3903. var result = [];
  3904. if (!(array && array.length)) {
  3905. return result;
  3906. }
  3907. var index = -1,
  3908. indexes = [],
  3909. length = array.length;
  3910. predicate = baseIteratee(predicate, 3);
  3911. while (++index < length) {
  3912. var value = array[index];
  3913. if (predicate(value, index, array)) {
  3914. result.push(value);
  3915. indexes.push(index);
  3916. }
  3917. }
  3918. basePullAt(array, indexes);
  3919. return result;
  3920. }
  3921. /**
  3922. * Creates a function that memoizes the result of `func`. If `resolver` is
  3923. * provided, it determines the cache key for storing the result based on the
  3924. * arguments provided to the memoized function. By default, the first argument
  3925. * provided to the memoized function is used as the map cache key. The `func`
  3926. * is invoked with the `this` binding of the memoized function.
  3927. *
  3928. * **Note:** The cache is exposed as the `cache` property on the memoized
  3929. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  3930. * constructor with one whose instances implement the
  3931. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  3932. * method interface of `delete`, `get`, `has`, and `set`.
  3933. *
  3934. * @static
  3935. * @memberOf _
  3936. * @since 0.1.0
  3937. * @category Function
  3938. * @param {Function} func The function to have its output memoized.
  3939. * @param {Function} [resolver] The function to resolve the cache key.
  3940. * @returns {Function} Returns the new memoized function.
  3941. * @example
  3942. *
  3943. * var object = { 'a': 1, 'b': 2 };
  3944. * var other = { 'c': 3, 'd': 4 };
  3945. *
  3946. * var values = _.memoize(_.values);
  3947. * values(object);
  3948. * // => [1, 2]
  3949. *
  3950. * values(other);
  3951. * // => [3, 4]
  3952. *
  3953. * object.a = 2;
  3954. * values(object);
  3955. * // => [1, 2]
  3956. *
  3957. * // Modify the result cache.
  3958. * values.cache.set(object, ['a', 'b']);
  3959. * values(object);
  3960. * // => ['a', 'b']
  3961. *
  3962. * // Replace `_.memoize.Cache`.
  3963. * _.memoize.Cache = WeakMap;
  3964. */
  3965. function memoize(func, resolver) {
  3966. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  3967. throw new TypeError(FUNC_ERROR_TEXT);
  3968. }
  3969. var memoized = function() {
  3970. var args = arguments,
  3971. key = resolver ? resolver.apply(this, args) : args[0],
  3972. cache = memoized.cache;
  3973. if (cache.has(key)) {
  3974. return cache.get(key);
  3975. }
  3976. var result = func.apply(this, args);
  3977. memoized.cache = cache.set(key, result);
  3978. return result;
  3979. };
  3980. memoized.cache = new (memoize.Cache || MapCache);
  3981. return memoized;
  3982. }
  3983. // Assign cache to `_.memoize`.
  3984. memoize.Cache = MapCache;
  3985. /**
  3986. * Performs a
  3987. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3988. * comparison between two values to determine if they are equivalent.
  3989. *
  3990. * @static
  3991. * @memberOf _
  3992. * @since 4.0.0
  3993. * @category Lang
  3994. * @param {*} value The value to compare.
  3995. * @param {*} other The other value to compare.
  3996. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3997. * @example
  3998. *
  3999. * var object = { 'a': 1 };
  4000. * var other = { 'a': 1 };
  4001. *
  4002. * _.eq(object, object);
  4003. * // => true
  4004. *
  4005. * _.eq(object, other);
  4006. * // => false
  4007. *
  4008. * _.eq('a', 'a');
  4009. * // => true
  4010. *
  4011. * _.eq('a', Object('a'));
  4012. * // => false
  4013. *
  4014. * _.eq(NaN, NaN);
  4015. * // => true
  4016. */
  4017. function eq(value, other) {
  4018. return value === other || (value !== value && other !== other);
  4019. }
  4020. /**
  4021. * Checks if `value` is likely an `arguments` object.
  4022. *
  4023. * @static
  4024. * @memberOf _
  4025. * @since 0.1.0
  4026. * @category Lang
  4027. * @param {*} value The value to check.
  4028. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  4029. * else `false`.
  4030. * @example
  4031. *
  4032. * _.isArguments(function() { return arguments; }());
  4033. * // => true
  4034. *
  4035. * _.isArguments([1, 2, 3]);
  4036. * // => false
  4037. */
  4038. function isArguments(value) {
  4039. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  4040. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  4041. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  4042. }
  4043. /**
  4044. * Checks if `value` is classified as an `Array` object.
  4045. *
  4046. * @static
  4047. * @memberOf _
  4048. * @since 0.1.0
  4049. * @category Lang
  4050. * @param {*} value The value to check.
  4051. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  4052. * @example
  4053. *
  4054. * _.isArray([1, 2, 3]);
  4055. * // => true
  4056. *
  4057. * _.isArray(document.body.children);
  4058. * // => false
  4059. *
  4060. * _.isArray('abc');
  4061. * // => false
  4062. *
  4063. * _.isArray(_.noop);
  4064. * // => false
  4065. */
  4066. var isArray = Array.isArray;
  4067. /**
  4068. * Checks if `value` is array-like. A value is considered array-like if it's
  4069. * not a function and has a `value.length` that's an integer greater than or
  4070. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  4071. *
  4072. * @static
  4073. * @memberOf _
  4074. * @since 4.0.0
  4075. * @category Lang
  4076. * @param {*} value The value to check.
  4077. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  4078. * @example
  4079. *
  4080. * _.isArrayLike([1, 2, 3]);
  4081. * // => true
  4082. *
  4083. * _.isArrayLike(document.body.children);
  4084. * // => true
  4085. *
  4086. * _.isArrayLike('abc');
  4087. * // => true
  4088. *
  4089. * _.isArrayLike(_.noop);
  4090. * // => false
  4091. */
  4092. function isArrayLike(value) {
  4093. return value != null && isLength(value.length) && !isFunction(value);
  4094. }
  4095. /**
  4096. * This method is like `_.isArrayLike` except that it also checks if `value`
  4097. * is an object.
  4098. *
  4099. * @static
  4100. * @memberOf _
  4101. * @since 4.0.0
  4102. * @category Lang
  4103. * @param {*} value The value to check.
  4104. * @returns {boolean} Returns `true` if `value` is an array-like object,
  4105. * else `false`.
  4106. * @example
  4107. *
  4108. * _.isArrayLikeObject([1, 2, 3]);
  4109. * // => true
  4110. *
  4111. * _.isArrayLikeObject(document.body.children);
  4112. * // => true
  4113. *
  4114. * _.isArrayLikeObject('abc');
  4115. * // => false
  4116. *
  4117. * _.isArrayLikeObject(_.noop);
  4118. * // => false
  4119. */
  4120. function isArrayLikeObject(value) {
  4121. return isObjectLike(value) && isArrayLike(value);
  4122. }
  4123. /**
  4124. * Checks if `value` is classified as a `Function` object.
  4125. *
  4126. * @static
  4127. * @memberOf _
  4128. * @since 0.1.0
  4129. * @category Lang
  4130. * @param {*} value The value to check.
  4131. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  4132. * @example
  4133. *
  4134. * _.isFunction(_);
  4135. * // => true
  4136. *
  4137. * _.isFunction(/abc/);
  4138. * // => false
  4139. */
  4140. function isFunction(value) {
  4141. // The use of `Object#toString` avoids issues with the `typeof` operator
  4142. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  4143. var tag = isObject(value) ? objectToString.call(value) : '';
  4144. return tag == funcTag || tag == genTag;
  4145. }
  4146. /**
  4147. * Checks if `value` is a valid array-like length.
  4148. *
  4149. * **Note:** This method is loosely based on
  4150. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  4151. *
  4152. * @static
  4153. * @memberOf _
  4154. * @since 4.0.0
  4155. * @category Lang
  4156. * @param {*} value The value to check.
  4157. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  4158. * @example
  4159. *
  4160. * _.isLength(3);
  4161. * // => true
  4162. *
  4163. * _.isLength(Number.MIN_VALUE);
  4164. * // => false
  4165. *
  4166. * _.isLength(Infinity);
  4167. * // => false
  4168. *
  4169. * _.isLength('3');
  4170. * // => false
  4171. */
  4172. function isLength(value) {
  4173. return typeof value == 'number' &&
  4174. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  4175. }
  4176. /**
  4177. * Checks if `value` is the
  4178. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  4179. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4180. *
  4181. * @static
  4182. * @memberOf _
  4183. * @since 0.1.0
  4184. * @category Lang
  4185. * @param {*} value The value to check.
  4186. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4187. * @example
  4188. *
  4189. * _.isObject({});
  4190. * // => true
  4191. *
  4192. * _.isObject([1, 2, 3]);
  4193. * // => true
  4194. *
  4195. * _.isObject(_.noop);
  4196. * // => true
  4197. *
  4198. * _.isObject(null);
  4199. * // => false
  4200. */
  4201. function isObject(value) {
  4202. var type = typeof value;
  4203. return !!value && (type == 'object' || type == 'function');
  4204. }
  4205. /**
  4206. * Checks if `value` is object-like. A value is object-like if it's not `null`
  4207. * and has a `typeof` result of "object".
  4208. *
  4209. * @static
  4210. * @memberOf _
  4211. * @since 4.0.0
  4212. * @category Lang
  4213. * @param {*} value The value to check.
  4214. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  4215. * @example
  4216. *
  4217. * _.isObjectLike({});
  4218. * // => true
  4219. *
  4220. * _.isObjectLike([1, 2, 3]);
  4221. * // => true
  4222. *
  4223. * _.isObjectLike(_.noop);
  4224. * // => false
  4225. *
  4226. * _.isObjectLike(null);
  4227. * // => false
  4228. */
  4229. function isObjectLike(value) {
  4230. return !!value && typeof value == 'object';
  4231. }
  4232. /**
  4233. * Checks if `value` is classified as a `Symbol` primitive or object.
  4234. *
  4235. * @static
  4236. * @memberOf _
  4237. * @since 4.0.0
  4238. * @category Lang
  4239. * @param {*} value The value to check.
  4240. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  4241. * @example
  4242. *
  4243. * _.isSymbol(Symbol.iterator);
  4244. * // => true
  4245. *
  4246. * _.isSymbol('abc');
  4247. * // => false
  4248. */
  4249. function isSymbol(value) {
  4250. return typeof value == 'symbol' ||
  4251. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  4252. }
  4253. /**
  4254. * Checks if `value` is classified as a typed array.
  4255. *
  4256. * @static
  4257. * @memberOf _
  4258. * @since 3.0.0
  4259. * @category Lang
  4260. * @param {*} value The value to check.
  4261. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  4262. * @example
  4263. *
  4264. * _.isTypedArray(new Uint8Array);
  4265. * // => true
  4266. *
  4267. * _.isTypedArray([]);
  4268. * // => false
  4269. */
  4270. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  4271. /**
  4272. * Converts `value` to a string. An empty string is returned for `null`
  4273. * and `undefined` values. The sign of `-0` is preserved.
  4274. *
  4275. * @static
  4276. * @memberOf _
  4277. * @since 4.0.0
  4278. * @category Lang
  4279. * @param {*} value The value to process.
  4280. * @returns {string} Returns the string.
  4281. * @example
  4282. *
  4283. * _.toString(null);
  4284. * // => ''
  4285. *
  4286. * _.toString(-0);
  4287. * // => '-0'
  4288. *
  4289. * _.toString([1, 2, 3]);
  4290. * // => '1,2,3'
  4291. */
  4292. function toString(value) {
  4293. return value == null ? '' : baseToString(value);
  4294. }
  4295. /**
  4296. * Gets the value at `path` of `object`. If the resolved value is
  4297. * `undefined`, the `defaultValue` is returned in its place.
  4298. *
  4299. * @static
  4300. * @memberOf _
  4301. * @since 3.7.0
  4302. * @category Object
  4303. * @param {Object} object The object to query.
  4304. * @param {Array|string} path The path of the property to get.
  4305. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  4306. * @returns {*} Returns the resolved value.
  4307. * @example
  4308. *
  4309. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  4310. *
  4311. * _.get(object, 'a[0].b.c');
  4312. * // => 3
  4313. *
  4314. * _.get(object, ['a', '0', 'b', 'c']);
  4315. * // => 3
  4316. *
  4317. * _.get(object, 'a.b.c', 'default');
  4318. * // => 'default'
  4319. */
  4320. function get(object, path, defaultValue) {
  4321. var result = object == null ? undefined : baseGet(object, path);
  4322. return result === undefined ? defaultValue : result;
  4323. }
  4324. /**
  4325. * Checks if `path` is a direct or inherited property of `object`.
  4326. *
  4327. * @static
  4328. * @memberOf _
  4329. * @since 4.0.0
  4330. * @category Object
  4331. * @param {Object} object The object to query.
  4332. * @param {Array|string} path The path to check.
  4333. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  4334. * @example
  4335. *
  4336. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  4337. *
  4338. * _.hasIn(object, 'a');
  4339. * // => true
  4340. *
  4341. * _.hasIn(object, 'a.b');
  4342. * // => true
  4343. *
  4344. * _.hasIn(object, ['a', 'b']);
  4345. * // => true
  4346. *
  4347. * _.hasIn(object, 'b');
  4348. * // => false
  4349. */
  4350. function hasIn(object, path) {
  4351. return object != null && hasPath(object, path, baseHasIn);
  4352. }
  4353. /**
  4354. * Creates an array of the own enumerable property names of `object`.
  4355. *
  4356. * **Note:** Non-object values are coerced to objects. See the
  4357. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  4358. * for more details.
  4359. *
  4360. * @static
  4361. * @since 0.1.0
  4362. * @memberOf _
  4363. * @category Object
  4364. * @param {Object} object The object to query.
  4365. * @returns {Array} Returns the array of property names.
  4366. * @example
  4367. *
  4368. * function Foo() {
  4369. * this.a = 1;
  4370. * this.b = 2;
  4371. * }
  4372. *
  4373. * Foo.prototype.c = 3;
  4374. *
  4375. * _.keys(new Foo);
  4376. * // => ['a', 'b'] (iteration order is not guaranteed)
  4377. *
  4378. * _.keys('hi');
  4379. * // => ['0', '1']
  4380. */
  4381. function keys(object) {
  4382. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  4383. }
  4384. /**
  4385. * This method returns the first argument it receives.
  4386. *
  4387. * @static
  4388. * @since 0.1.0
  4389. * @memberOf _
  4390. * @category Util
  4391. * @param {*} value Any value.
  4392. * @returns {*} Returns `value`.
  4393. * @example
  4394. *
  4395. * var object = { 'a': 1 };
  4396. *
  4397. * console.log(_.identity(object) === object);
  4398. * // => true
  4399. */
  4400. function identity(value) {
  4401. return value;
  4402. }
  4403. /**
  4404. * Creates a function that returns the value at `path` of a given object.
  4405. *
  4406. * @static
  4407. * @memberOf _
  4408. * @since 2.4.0
  4409. * @category Util
  4410. * @param {Array|string} path The path of the property to get.
  4411. * @returns {Function} Returns the new accessor function.
  4412. * @example
  4413. *
  4414. * var objects = [
  4415. * { 'a': { 'b': 2 } },
  4416. * { 'a': { 'b': 1 } }
  4417. * ];
  4418. *
  4419. * _.map(objects, _.property('a.b'));
  4420. * // => [2, 1]
  4421. *
  4422. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  4423. * // => [1, 2]
  4424. */
  4425. function property(path) {
  4426. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  4427. }
  4428. module.exports = remove;
  4429. /***/ }),
  4430. /***/ "./node_modules/process/browser.js":
  4431. /*!*****************************************!*\
  4432. !*** ./node_modules/process/browser.js ***!
  4433. \*****************************************/
  4434. /***/ ((module) => {
  4435. // shim for using process in browser
  4436. var process = module.exports = {};
  4437. // cached from whatever global is present so that test runners that stub it
  4438. // don't break things. But we need to wrap it in a try catch in case it is
  4439. // wrapped in strict mode code which doesn't define any globals. It's inside a
  4440. // function because try/catches deoptimize in certain engines.
  4441. var cachedSetTimeout;
  4442. var cachedClearTimeout;
  4443. function defaultSetTimout() {
  4444. throw new Error('setTimeout has not been defined');
  4445. }
  4446. function defaultClearTimeout () {
  4447. throw new Error('clearTimeout has not been defined');
  4448. }
  4449. (function () {
  4450. try {
  4451. if (typeof setTimeout === 'function') {
  4452. cachedSetTimeout = setTimeout;
  4453. } else {
  4454. cachedSetTimeout = defaultSetTimout;
  4455. }
  4456. } catch (e) {
  4457. cachedSetTimeout = defaultSetTimout;
  4458. }
  4459. try {
  4460. if (typeof clearTimeout === 'function') {
  4461. cachedClearTimeout = clearTimeout;
  4462. } else {
  4463. cachedClearTimeout = defaultClearTimeout;
  4464. }
  4465. } catch (e) {
  4466. cachedClearTimeout = defaultClearTimeout;
  4467. }
  4468. } ())
  4469. function runTimeout(fun) {
  4470. if (cachedSetTimeout === setTimeout) {
  4471. //normal enviroments in sane situations
  4472. return setTimeout(fun, 0);
  4473. }
  4474. // if setTimeout wasn't available but was latter defined
  4475. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  4476. cachedSetTimeout = setTimeout;
  4477. return setTimeout(fun, 0);
  4478. }
  4479. try {
  4480. // when when somebody has screwed with setTimeout but no I.E. maddness
  4481. return cachedSetTimeout(fun, 0);
  4482. } catch(e){
  4483. try {
  4484. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4485. return cachedSetTimeout.call(null, fun, 0);
  4486. } catch(e){
  4487. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  4488. return cachedSetTimeout.call(this, fun, 0);
  4489. }
  4490. }
  4491. }
  4492. function runClearTimeout(marker) {
  4493. if (cachedClearTimeout === clearTimeout) {
  4494. //normal enviroments in sane situations
  4495. return clearTimeout(marker);
  4496. }
  4497. // if clearTimeout wasn't available but was latter defined
  4498. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  4499. cachedClearTimeout = clearTimeout;
  4500. return clearTimeout(marker);
  4501. }
  4502. try {
  4503. // when when somebody has screwed with setTimeout but no I.E. maddness
  4504. return cachedClearTimeout(marker);
  4505. } catch (e){
  4506. try {
  4507. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  4508. return cachedClearTimeout.call(null, marker);
  4509. } catch (e){
  4510. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  4511. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  4512. return cachedClearTimeout.call(this, marker);
  4513. }
  4514. }
  4515. }
  4516. var queue = [];
  4517. var draining = false;
  4518. var currentQueue;
  4519. var queueIndex = -1;
  4520. function cleanUpNextTick() {
  4521. if (!draining || !currentQueue) {
  4522. return;
  4523. }
  4524. draining = false;
  4525. if (currentQueue.length) {
  4526. queue = currentQueue.concat(queue);
  4527. } else {
  4528. queueIndex = -1;
  4529. }
  4530. if (queue.length) {
  4531. drainQueue();
  4532. }
  4533. }
  4534. function drainQueue() {
  4535. if (draining) {
  4536. return;
  4537. }
  4538. var timeout = runTimeout(cleanUpNextTick);
  4539. draining = true;
  4540. var len = queue.length;
  4541. while(len) {
  4542. currentQueue = queue;
  4543. queue = [];
  4544. while (++queueIndex < len) {
  4545. if (currentQueue) {
  4546. currentQueue[queueIndex].run();
  4547. }
  4548. }
  4549. queueIndex = -1;
  4550. len = queue.length;
  4551. }
  4552. currentQueue = null;
  4553. draining = false;
  4554. runClearTimeout(timeout);
  4555. }
  4556. process.nextTick = function (fun) {
  4557. var args = new Array(arguments.length - 1);
  4558. if (arguments.length > 1) {
  4559. for (var i = 1; i < arguments.length; i++) {
  4560. args[i - 1] = arguments[i];
  4561. }
  4562. }
  4563. queue.push(new Item(fun, args));
  4564. if (queue.length === 1 && !draining) {
  4565. runTimeout(drainQueue);
  4566. }
  4567. };
  4568. // v8 likes predictible objects
  4569. function Item(fun, array) {
  4570. this.fun = fun;
  4571. this.array = array;
  4572. }
  4573. Item.prototype.run = function () {
  4574. this.fun.apply(null, this.array);
  4575. };
  4576. process.title = 'browser';
  4577. process.browser = true;
  4578. process.env = {};
  4579. process.argv = [];
  4580. process.version = ''; // empty string to avoid regexp issues
  4581. process.versions = {};
  4582. function noop() {}
  4583. process.on = noop;
  4584. process.addListener = noop;
  4585. process.once = noop;
  4586. process.off = noop;
  4587. process.removeListener = noop;
  4588. process.removeAllListeners = noop;
  4589. process.emit = noop;
  4590. process.prependListener = noop;
  4591. process.prependOnceListener = noop;
  4592. process.listeners = function (name) { return [] }
  4593. process.binding = function (name) {
  4594. throw new Error('process.binding is not supported');
  4595. };
  4596. process.cwd = function () { return '/' };
  4597. process.chdir = function (dir) {
  4598. throw new Error('process.chdir is not supported');
  4599. };
  4600. process.umask = function() { return 0; };
  4601. /***/ }),
  4602. /***/ "./node_modules/riot/riot.esm.js":
  4603. /*!***************************************!*\
  4604. !*** ./node_modules/riot/riot.esm.js ***!
  4605. \***************************************/
  4606. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4607. "use strict";
  4608. __webpack_require__.r(__webpack_exports__);
  4609. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4610. /* harmony export */ "__": () => (/* binding */ __),
  4611. /* harmony export */ "component": () => (/* binding */ component),
  4612. /* harmony export */ "install": () => (/* binding */ install),
  4613. /* harmony export */ "mount": () => (/* binding */ mount),
  4614. /* harmony export */ "pure": () => (/* binding */ pure),
  4615. /* harmony export */ "register": () => (/* binding */ register),
  4616. /* harmony export */ "uninstall": () => (/* binding */ uninstall),
  4617. /* harmony export */ "unmount": () => (/* binding */ unmount),
  4618. /* harmony export */ "unregister": () => (/* binding */ unregister),
  4619. /* harmony export */ "version": () => (/* binding */ version),
  4620. /* harmony export */ "withTypes": () => (/* binding */ withTypes)
  4621. /* harmony export */ });
  4622. /* Riot v6.0.1, @license MIT */
  4623. /**
  4624. * Convert a string from camel case to dash-case
  4625. * @param {string} string - probably a component tag name
  4626. * @returns {string} component name normalized
  4627. */
  4628. function camelToDashCase(string) {
  4629. return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
  4630. }
  4631. /**
  4632. * Convert a string containing dashes to camel case
  4633. * @param {string} string - input string
  4634. * @returns {string} my-string -> myString
  4635. */
  4636. function dashToCamelCase(string) {
  4637. return string.replace(/-(\w)/g, (_, c) => c.toUpperCase());
  4638. }
  4639. /**
  4640. * Get all the element attributes as object
  4641. * @param {HTMLElement} element - DOM node we want to parse
  4642. * @returns {Object} all the attributes found as a key value pairs
  4643. */
  4644. function DOMattributesToObject(element) {
  4645. return Array.from(element.attributes).reduce((acc, attribute) => {
  4646. acc[dashToCamelCase(attribute.name)] = attribute.value;
  4647. return acc;
  4648. }, {});
  4649. }
  4650. /**
  4651. * Move all the child nodes from a source tag to another
  4652. * @param {HTMLElement} source - source node
  4653. * @param {HTMLElement} target - target node
  4654. * @returns {undefined} it's a void method ¯\_()_/¯
  4655. */
  4656. // Ignore this helper because it's needed only for svg tags
  4657. function moveChildren(source, target) {
  4658. if (source.firstChild) {
  4659. target.appendChild(source.firstChild);
  4660. moveChildren(source, target);
  4661. }
  4662. }
  4663. /**
  4664. * Remove the child nodes from any DOM node
  4665. * @param {HTMLElement} node - target node
  4666. * @returns {undefined}
  4667. */
  4668. function cleanNode(node) {
  4669. clearChildren(node.childNodes);
  4670. }
  4671. /**
  4672. * Clear multiple children in a node
  4673. * @param {HTMLElement[]} children - direct children nodes
  4674. * @returns {undefined}
  4675. */
  4676. function clearChildren(children) {
  4677. Array.from(children).forEach(removeChild);
  4678. }
  4679. /**
  4680. * Remove a node
  4681. * @param {HTMLElement}node - node to remove
  4682. * @returns {undefined}
  4683. */
  4684. const removeChild = node => node && node.parentNode && node.parentNode.removeChild(node);
  4685. /**
  4686. * Insert before a node
  4687. * @param {HTMLElement} newNode - node to insert
  4688. * @param {HTMLElement} refNode - ref child
  4689. * @returns {undefined}
  4690. */
  4691. const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode);
  4692. /**
  4693. * Replace a node
  4694. * @param {HTMLElement} newNode - new node to add to the DOM
  4695. * @param {HTMLElement} replaced - node to replace
  4696. * @returns {undefined}
  4697. */
  4698. const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced);
  4699. // Riot.js constants that can be used accross more modules
  4700. const COMPONENTS_IMPLEMENTATION_MAP$1 = new Map(),
  4701. DOM_COMPONENT_INSTANCE_PROPERTY$1 = Symbol('riot-component'),
  4702. PLUGINS_SET$1 = new Set(),
  4703. IS_DIRECTIVE = 'is',
  4704. VALUE_ATTRIBUTE = 'value',
  4705. MOUNT_METHOD_KEY = 'mount',
  4706. UPDATE_METHOD_KEY = 'update',
  4707. UNMOUNT_METHOD_KEY = 'unmount',
  4708. SHOULD_UPDATE_KEY = 'shouldUpdate',
  4709. ON_BEFORE_MOUNT_KEY = 'onBeforeMount',
  4710. ON_MOUNTED_KEY = 'onMounted',
  4711. ON_BEFORE_UPDATE_KEY = 'onBeforeUpdate',
  4712. ON_UPDATED_KEY = 'onUpdated',
  4713. ON_BEFORE_UNMOUNT_KEY = 'onBeforeUnmount',
  4714. ON_UNMOUNTED_KEY = 'onUnmounted',
  4715. PROPS_KEY = 'props',
  4716. STATE_KEY = 'state',
  4717. SLOTS_KEY = 'slots',
  4718. ROOT_KEY = 'root',
  4719. IS_PURE_SYMBOL = Symbol('pure'),
  4720. IS_COMPONENT_UPDATING = Symbol('is_updating'),
  4721. PARENT_KEY_SYMBOL = Symbol('parent'),
  4722. ATTRIBUTES_KEY_SYMBOL = Symbol('attributes'),
  4723. TEMPLATE_KEY_SYMBOL = Symbol('template');
  4724. var globals = /*#__PURE__*/Object.freeze({
  4725. __proto__: null,
  4726. COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP$1,
  4727. DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY$1,
  4728. PLUGINS_SET: PLUGINS_SET$1,
  4729. IS_DIRECTIVE: IS_DIRECTIVE,
  4730. VALUE_ATTRIBUTE: VALUE_ATTRIBUTE,
  4731. MOUNT_METHOD_KEY: MOUNT_METHOD_KEY,
  4732. UPDATE_METHOD_KEY: UPDATE_METHOD_KEY,
  4733. UNMOUNT_METHOD_KEY: UNMOUNT_METHOD_KEY,
  4734. SHOULD_UPDATE_KEY: SHOULD_UPDATE_KEY,
  4735. ON_BEFORE_MOUNT_KEY: ON_BEFORE_MOUNT_KEY,
  4736. ON_MOUNTED_KEY: ON_MOUNTED_KEY,
  4737. ON_BEFORE_UPDATE_KEY: ON_BEFORE_UPDATE_KEY,
  4738. ON_UPDATED_KEY: ON_UPDATED_KEY,
  4739. ON_BEFORE_UNMOUNT_KEY: ON_BEFORE_UNMOUNT_KEY,
  4740. ON_UNMOUNTED_KEY: ON_UNMOUNTED_KEY,
  4741. PROPS_KEY: PROPS_KEY,
  4742. STATE_KEY: STATE_KEY,
  4743. SLOTS_KEY: SLOTS_KEY,
  4744. ROOT_KEY: ROOT_KEY,
  4745. IS_PURE_SYMBOL: IS_PURE_SYMBOL,
  4746. IS_COMPONENT_UPDATING: IS_COMPONENT_UPDATING,
  4747. PARENT_KEY_SYMBOL: PARENT_KEY_SYMBOL,
  4748. ATTRIBUTES_KEY_SYMBOL: ATTRIBUTES_KEY_SYMBOL,
  4749. TEMPLATE_KEY_SYMBOL: TEMPLATE_KEY_SYMBOL
  4750. });
  4751. const EACH = 0;
  4752. const IF = 1;
  4753. const SIMPLE = 2;
  4754. const TAG = 3;
  4755. const SLOT = 4;
  4756. var bindingTypes = {
  4757. EACH,
  4758. IF,
  4759. SIMPLE,
  4760. TAG,
  4761. SLOT
  4762. };
  4763. const ATTRIBUTE = 0;
  4764. const EVENT = 1;
  4765. const TEXT = 2;
  4766. const VALUE = 3;
  4767. var expressionTypes = {
  4768. ATTRIBUTE,
  4769. EVENT,
  4770. TEXT,
  4771. VALUE
  4772. };
  4773. const HEAD_SYMBOL = Symbol('head');
  4774. const TAIL_SYMBOL = Symbol('tail');
  4775. /**
  4776. * Create the <template> fragments text nodes
  4777. * @return {Object} {{head: Text, tail: Text}}
  4778. */
  4779. function createHeadTailPlaceholders() {
  4780. const head = document.createTextNode('');
  4781. const tail = document.createTextNode('');
  4782. head[HEAD_SYMBOL] = true;
  4783. tail[TAIL_SYMBOL] = true;
  4784. return {
  4785. head,
  4786. tail
  4787. };
  4788. }
  4789. /**
  4790. * Create the template meta object in case of <template> fragments
  4791. * @param {TemplateChunk} componentTemplate - template chunk object
  4792. * @returns {Object} the meta property that will be passed to the mount function of the TemplateChunk
  4793. */
  4794. function createTemplateMeta(componentTemplate) {
  4795. const fragment = componentTemplate.dom.cloneNode(true);
  4796. const {
  4797. head,
  4798. tail
  4799. } = createHeadTailPlaceholders();
  4800. return {
  4801. avoidDOMInjection: true,
  4802. fragment,
  4803. head,
  4804. tail,
  4805. children: [head, ...Array.from(fragment.childNodes), tail]
  4806. };
  4807. }
  4808. /**
  4809. * Helper function to set an immutable property
  4810. * @param {Object} source - object where the new property will be set
  4811. * @param {string} key - object key where the new property will be stored
  4812. * @param {*} value - value of the new property
  4813. * @param {Object} options - set the propery overriding the default options
  4814. * @returns {Object} - the original object modified
  4815. */
  4816. function defineProperty(source, key, value, options) {
  4817. if (options === void 0) {
  4818. options = {};
  4819. }
  4820. /* eslint-disable fp/no-mutating-methods */
  4821. Object.defineProperty(source, key, Object.assign({
  4822. value,
  4823. enumerable: false,
  4824. writable: false,
  4825. configurable: true
  4826. }, options));
  4827. /* eslint-enable fp/no-mutating-methods */
  4828. return source;
  4829. }
  4830. /**
  4831. * Define multiple properties on a target object
  4832. * @param {Object} source - object where the new properties will be set
  4833. * @param {Object} properties - object containing as key pair the key + value properties
  4834. * @param {Object} options - set the propery overriding the default options
  4835. * @returns {Object} the original object modified
  4836. */
  4837. function defineProperties(source, properties, options) {
  4838. Object.entries(properties).forEach(_ref => {
  4839. let [key, value] = _ref;
  4840. defineProperty(source, key, value, options);
  4841. });
  4842. return source;
  4843. }
  4844. /**
  4845. * Define default properties if they don't exist on the source object
  4846. * @param {Object} source - object that will receive the default properties
  4847. * @param {Object} defaults - object containing additional optional keys
  4848. * @returns {Object} the original object received enhanced
  4849. */
  4850. function defineDefaults(source, defaults) {
  4851. Object.entries(defaults).forEach(_ref2 => {
  4852. let [key, value] = _ref2;
  4853. if (!source[key]) source[key] = value;
  4854. });
  4855. return source;
  4856. }
  4857. /**
  4858. * Get the current <template> fragment children located in between the head and tail comments
  4859. * @param {Comment} head - head comment node
  4860. * @param {Comment} tail - tail comment node
  4861. * @return {Array[]} children list of the nodes found in this template fragment
  4862. */
  4863. function getFragmentChildren(_ref) {
  4864. let {
  4865. head,
  4866. tail
  4867. } = _ref;
  4868. const nodes = walkNodes([head], head.nextSibling, n => n === tail, false);
  4869. nodes.push(tail);
  4870. return nodes;
  4871. }
  4872. /**
  4873. * Recursive function to walk all the <template> children nodes
  4874. * @param {Array[]} children - children nodes collection
  4875. * @param {ChildNode} node - current node
  4876. * @param {Function} check - exit function check
  4877. * @param {boolean} isFilterActive - filter flag to skip nodes managed by other bindings
  4878. * @returns {Array[]} children list of the nodes found in this template fragment
  4879. */
  4880. function walkNodes(children, node, check, isFilterActive) {
  4881. const {
  4882. nextSibling
  4883. } = node; // filter tail and head nodes together with all the nodes in between
  4884. // this is needed only to fix a really ugly edge case https://github.com/riot/riot/issues/2892
  4885. if (!isFilterActive && !node[HEAD_SYMBOL] && !node[TAIL_SYMBOL]) {
  4886. children.push(node);
  4887. }
  4888. if (!nextSibling || check(node)) return children;
  4889. return walkNodes(children, nextSibling, check, // activate the filters to skip nodes between <template> fragments that will be managed by other bindings
  4890. isFilterActive && !node[TAIL_SYMBOL] || nextSibling[HEAD_SYMBOL]);
  4891. }
  4892. /**
  4893. * Quick type checking
  4894. * @param {*} element - anything
  4895. * @param {string} type - type definition
  4896. * @returns {boolean} true if the type corresponds
  4897. */
  4898. function checkType(element, type) {
  4899. return typeof element === type;
  4900. }
  4901. /**
  4902. * Check if an element is part of an svg
  4903. * @param {HTMLElement} el - element to check
  4904. * @returns {boolean} true if we are in an svg context
  4905. */
  4906. function isSvg(el) {
  4907. const owner = el.ownerSVGElement;
  4908. return !!owner || owner === null;
  4909. }
  4910. /**
  4911. * Check if an element is a template tag
  4912. * @param {HTMLElement} el - element to check
  4913. * @returns {boolean} true if it's a <template>
  4914. */
  4915. function isTemplate(el) {
  4916. return el.tagName.toLowerCase() === 'template';
  4917. }
  4918. /**
  4919. * Check that will be passed if its argument is a function
  4920. * @param {*} value - value to check
  4921. * @returns {boolean} - true if the value is a function
  4922. */
  4923. function isFunction(value) {
  4924. return checkType(value, 'function');
  4925. }
  4926. /**
  4927. * Check if a value is a Boolean
  4928. * @param {*} value - anything
  4929. * @returns {boolean} true only for the value is a boolean
  4930. */
  4931. function isBoolean(value) {
  4932. return checkType(value, 'boolean');
  4933. }
  4934. /**
  4935. * Check if a value is an Object
  4936. * @param {*} value - anything
  4937. * @returns {boolean} true only for the value is an object
  4938. */
  4939. function isObject(value) {
  4940. return !isNil(value) && value.constructor === Object;
  4941. }
  4942. /**
  4943. * Check if a value is null or undefined
  4944. * @param {*} value - anything
  4945. * @returns {boolean} true only for the 'undefined' and 'null' types
  4946. */
  4947. function isNil(value) {
  4948. return value === null || value === undefined;
  4949. }
  4950. /**
  4951. * ISC License
  4952. *
  4953. * Copyright (c) 2020, Andrea Giammarchi, @WebReflection
  4954. *
  4955. * Permission to use, copy, modify, and/or distribute this software for any
  4956. * purpose with or without fee is hereby granted, provided that the above
  4957. * copyright notice and this permission notice appear in all copies.
  4958. *
  4959. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  4960. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  4961. * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  4962. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  4963. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  4964. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  4965. * PERFORMANCE OF THIS SOFTWARE.
  4966. */
  4967. // fork of https://github.com/WebReflection/udomdiff version 1.1.0
  4968. // due to https://github.com/WebReflection/udomdiff/pull/2
  4969. /* eslint-disable */
  4970. /**
  4971. * @param {Node[]} a The list of current/live children
  4972. * @param {Node[]} b The list of future children
  4973. * @param {(entry: Node, action: number) => Node} get
  4974. * The callback invoked per each entry related DOM operation.
  4975. * @param {Node} [before] The optional node used as anchor to insert before.
  4976. * @returns {Node[]} The same list of future children.
  4977. */
  4978. var udomdiff = ((a, b, get, before) => {
  4979. const bLength = b.length;
  4980. let aEnd = a.length;
  4981. let bEnd = bLength;
  4982. let aStart = 0;
  4983. let bStart = 0;
  4984. let map = null;
  4985. while (aStart < aEnd || bStart < bEnd) {
  4986. // append head, tail, or nodes in between: fast path
  4987. if (aEnd === aStart) {
  4988. // we could be in a situation where the rest of nodes that
  4989. // need to be added are not at the end, and in such case
  4990. // the node to `insertBefore`, if the index is more than 0
  4991. // must be retrieved, otherwise it's gonna be the first item.
  4992. const node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd - bStart], 0) : before;
  4993. while (bStart < bEnd) insertBefore(get(b[bStart++], 1), node);
  4994. } // remove head or tail: fast path
  4995. else if (bEnd === bStart) {
  4996. while (aStart < aEnd) {
  4997. // remove the node only if it's unknown or not live
  4998. if (!map || !map.has(a[aStart])) removeChild(get(a[aStart], -1));
  4999. aStart++;
  5000. }
  5001. } // same node: fast path
  5002. else if (a[aStart] === b[bStart]) {
  5003. aStart++;
  5004. bStart++;
  5005. } // same tail: fast path
  5006. else if (a[aEnd - 1] === b[bEnd - 1]) {
  5007. aEnd--;
  5008. bEnd--;
  5009. } // The once here single last swap "fast path" has been removed in v1.1.0
  5010. // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85
  5011. // reverse swap: also fast path
  5012. else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
  5013. // this is a "shrink" operation that could happen in these cases:
  5014. // [1, 2, 3, 4, 5]
  5015. // [1, 4, 3, 2, 5]
  5016. // or asymmetric too
  5017. // [1, 2, 3, 4, 5]
  5018. // [1, 2, 3, 5, 6, 4]
  5019. const node = get(a[--aEnd], -1).nextSibling;
  5020. insertBefore(get(b[bStart++], 1), get(a[aStart++], -1).nextSibling);
  5021. insertBefore(get(b[--bEnd], 1), node); // mark the future index as identical (yeah, it's dirty, but cheap 👍)
  5022. // The main reason to do this, is that when a[aEnd] will be reached,
  5023. // the loop will likely be on the fast path, as identical to b[bEnd].
  5024. // In the best case scenario, the next loop will skip the tail,
  5025. // but in the worst one, this node will be considered as already
  5026. // processed, bailing out pretty quickly from the map index check
  5027. a[aEnd] = b[bEnd];
  5028. } // map based fallback, "slow" path
  5029. else {
  5030. // the map requires an O(bEnd - bStart) operation once
  5031. // to store all future nodes indexes for later purposes.
  5032. // In the worst case scenario, this is a full O(N) cost,
  5033. // and such scenario happens at least when all nodes are different,
  5034. // but also if both first and last items of the lists are different
  5035. if (!map) {
  5036. map = new Map();
  5037. let i = bStart;
  5038. while (i < bEnd) map.set(b[i], i++);
  5039. } // if it's a future node, hence it needs some handling
  5040. if (map.has(a[aStart])) {
  5041. // grab the index of such node, 'cause it might have been processed
  5042. const index = map.get(a[aStart]); // if it's not already processed, look on demand for the next LCS
  5043. if (bStart < index && index < bEnd) {
  5044. let i = aStart; // counts the amount of nodes that are the same in the future
  5045. let sequence = 1;
  5046. while (++i < aEnd && i < bEnd && map.get(a[i]) === index + sequence) sequence++; // effort decision here: if the sequence is longer than replaces
  5047. // needed to reach such sequence, which would brings again this loop
  5048. // to the fast path, prepend the difference before a sequence,
  5049. // and move only the future list index forward, so that aStart
  5050. // and bStart will be aligned again, hence on the fast path.
  5051. // An example considering aStart and bStart are both 0:
  5052. // a: [1, 2, 3, 4]
  5053. // b: [7, 1, 2, 3, 6]
  5054. // this would place 7 before 1 and, from that time on, 1, 2, and 3
  5055. // will be processed at zero cost
  5056. if (sequence > index - bStart) {
  5057. const node = get(a[aStart], 0);
  5058. while (bStart < index) insertBefore(get(b[bStart++], 1), node);
  5059. } // if the effort wasn't good enough, fallback to a replace,
  5060. // moving both source and target indexes forward, hoping that some
  5061. // similar node will be found later on, to go back to the fast path
  5062. else {
  5063. replaceChild(get(b[bStart++], 1), get(a[aStart++], -1));
  5064. }
  5065. } // otherwise move the source forward, 'cause there's nothing to do
  5066. else aStart++;
  5067. } // this node has no meaning in the future list, so it's more than safe
  5068. // to remove it, and check the next live node out instead, meaning
  5069. // that only the live list index should be forwarded
  5070. else removeChild(get(a[aStart++], -1));
  5071. }
  5072. }
  5073. return b;
  5074. });
  5075. const UNMOUNT_SCOPE = Symbol('unmount');
  5076. const EachBinding = {
  5077. // dynamic binding properties
  5078. // childrenMap: null,
  5079. // node: null,
  5080. // root: null,
  5081. // condition: null,
  5082. // evaluate: null,
  5083. // template: null,
  5084. // isTemplateTag: false,
  5085. nodes: [],
  5086. // getKey: null,
  5087. // indexName: null,
  5088. // itemName: null,
  5089. // afterPlaceholder: null,
  5090. // placeholder: null,
  5091. // API methods
  5092. mount(scope, parentScope) {
  5093. return this.update(scope, parentScope);
  5094. },
  5095. update(scope, parentScope) {
  5096. const {
  5097. placeholder,
  5098. nodes,
  5099. childrenMap
  5100. } = this;
  5101. const collection = scope === UNMOUNT_SCOPE ? null : this.evaluate(scope);
  5102. const items = collection ? Array.from(collection) : []; // prepare the diffing
  5103. const {
  5104. newChildrenMap,
  5105. batches,
  5106. futureNodes
  5107. } = createPatch(items, scope, parentScope, this); // patch the DOM only if there are new nodes
  5108. udomdiff(nodes, futureNodes, patch(Array.from(childrenMap.values()), parentScope), placeholder); // trigger the mounts and the updates
  5109. batches.forEach(fn => fn()); // update the children map
  5110. this.childrenMap = newChildrenMap;
  5111. this.nodes = futureNodes; // make sure that the loop edge nodes are marked
  5112. markEdgeNodes(this.nodes);
  5113. return this;
  5114. },
  5115. unmount(scope, parentScope) {
  5116. this.update(UNMOUNT_SCOPE, parentScope);
  5117. return this;
  5118. }
  5119. };
  5120. /**
  5121. * Patch the DOM while diffing
  5122. * @param {any[]} redundant - list of all the children (template, nodes, context) added via each
  5123. * @param {*} parentScope - scope of the parent template
  5124. * @returns {Function} patch function used by domdiff
  5125. */
  5126. function patch(redundant, parentScope) {
  5127. return (item, info) => {
  5128. if (info < 0) {
  5129. // get the last element added to the childrenMap saved previously
  5130. const element = redundant[redundant.length - 1];
  5131. if (element) {
  5132. // get the nodes and the template in stored in the last child of the childrenMap
  5133. const {
  5134. template,
  5135. nodes,
  5136. context
  5137. } = element; // remove the last node (notice <template> tags might have more children nodes)
  5138. nodes.pop(); // notice that we pass null as last argument because
  5139. // the root node and its children will be removed by domdiff
  5140. if (!nodes.length) {
  5141. // we have cleared all the children nodes and we can unmount this template
  5142. redundant.pop();
  5143. template.unmount(context, parentScope, null);
  5144. }
  5145. }
  5146. }
  5147. return item;
  5148. };
  5149. }
  5150. /**
  5151. * Check whether a template must be filtered from a loop
  5152. * @param {Function} condition - filter function
  5153. * @param {Object} context - argument passed to the filter function
  5154. * @returns {boolean} true if this item should be skipped
  5155. */
  5156. function mustFilterItem(condition, context) {
  5157. return condition ? !condition(context) : false;
  5158. }
  5159. /**
  5160. * Extend the scope of the looped template
  5161. * @param {Object} scope - current template scope
  5162. * @param {Object} options - options
  5163. * @param {string} options.itemName - key to identify the looped item in the new context
  5164. * @param {string} options.indexName - key to identify the index of the looped item
  5165. * @param {number} options.index - current index
  5166. * @param {*} options.item - collection item looped
  5167. * @returns {Object} enhanced scope object
  5168. */
  5169. function extendScope(scope, _ref) {
  5170. let {
  5171. itemName,
  5172. indexName,
  5173. index,
  5174. item
  5175. } = _ref;
  5176. defineProperty(scope, itemName, item);
  5177. if (indexName) defineProperty(scope, indexName, index);
  5178. return scope;
  5179. }
  5180. /**
  5181. * Mark the first and last nodes in order to ignore them in case we need to retrieve the <template> fragment nodes
  5182. * @param {Array[]} nodes - each binding nodes list
  5183. * @returns {undefined} void function
  5184. */
  5185. function markEdgeNodes(nodes) {
  5186. const first = nodes[0];
  5187. const last = nodes[nodes.length - 1];
  5188. if (first) first[HEAD_SYMBOL] = true;
  5189. if (last) last[TAIL_SYMBOL] = true;
  5190. }
  5191. /**
  5192. * Loop the current template items
  5193. * @param {Array} items - expression collection value
  5194. * @param {*} scope - template scope
  5195. * @param {*} parentScope - scope of the parent template
  5196. * @param {EachBinding} binding - each binding object instance
  5197. * @returns {Object} data
  5198. * @returns {Map} data.newChildrenMap - a Map containing the new children template structure
  5199. * @returns {Array} data.batches - array containing the template lifecycle functions to trigger
  5200. * @returns {Array} data.futureNodes - array containing the nodes we need to diff
  5201. */
  5202. function createPatch(items, scope, parentScope, binding) {
  5203. const {
  5204. condition,
  5205. template,
  5206. childrenMap,
  5207. itemName,
  5208. getKey,
  5209. indexName,
  5210. root,
  5211. isTemplateTag
  5212. } = binding;
  5213. const newChildrenMap = new Map();
  5214. const batches = [];
  5215. const futureNodes = [];
  5216. items.forEach((item, index) => {
  5217. const context = extendScope(Object.create(scope), {
  5218. itemName,
  5219. indexName,
  5220. index,
  5221. item
  5222. });
  5223. const key = getKey ? getKey(context) : index;
  5224. const oldItem = childrenMap.get(key);
  5225. const nodes = [];
  5226. if (mustFilterItem(condition, context)) {
  5227. return;
  5228. }
  5229. const mustMount = !oldItem;
  5230. const componentTemplate = oldItem ? oldItem.template : template.clone();
  5231. const el = componentTemplate.el || root.cloneNode();
  5232. const meta = isTemplateTag && mustMount ? createTemplateMeta(componentTemplate) : componentTemplate.meta;
  5233. if (mustMount) {
  5234. batches.push(() => componentTemplate.mount(el, context, parentScope, meta));
  5235. } else {
  5236. batches.push(() => componentTemplate.update(context, parentScope));
  5237. } // create the collection of nodes to update or to add
  5238. // in case of template tags we need to add all its children nodes
  5239. if (isTemplateTag) {
  5240. nodes.push(...(mustMount ? meta.children : getFragmentChildren(meta)));
  5241. } else {
  5242. nodes.push(el);
  5243. } // delete the old item from the children map
  5244. childrenMap.delete(key);
  5245. futureNodes.push(...nodes); // update the children map
  5246. newChildrenMap.set(key, {
  5247. nodes,
  5248. template: componentTemplate,
  5249. context,
  5250. index
  5251. });
  5252. });
  5253. return {
  5254. newChildrenMap,
  5255. batches,
  5256. futureNodes
  5257. };
  5258. }
  5259. function create$6(node, _ref2) {
  5260. let {
  5261. evaluate,
  5262. condition,
  5263. itemName,
  5264. indexName,
  5265. getKey,
  5266. template
  5267. } = _ref2;
  5268. const placeholder = document.createTextNode('');
  5269. const root = node.cloneNode();
  5270. insertBefore(placeholder, node);
  5271. removeChild(node);
  5272. return Object.assign({}, EachBinding, {
  5273. childrenMap: new Map(),
  5274. node,
  5275. root,
  5276. condition,
  5277. evaluate,
  5278. isTemplateTag: isTemplate(root),
  5279. template: template.createDOM(node),
  5280. getKey,
  5281. indexName,
  5282. itemName,
  5283. placeholder
  5284. });
  5285. }
  5286. /**
  5287. * Binding responsible for the `if` directive
  5288. */
  5289. const IfBinding = {
  5290. // dynamic binding properties
  5291. // node: null,
  5292. // evaluate: null,
  5293. // isTemplateTag: false,
  5294. // placeholder: null,
  5295. // template: null,
  5296. // API methods
  5297. mount(scope, parentScope) {
  5298. return this.update(scope, parentScope);
  5299. },
  5300. update(scope, parentScope) {
  5301. const value = !!this.evaluate(scope);
  5302. const mustMount = !this.value && value;
  5303. const mustUnmount = this.value && !value;
  5304. const mount = () => {
  5305. const pristine = this.node.cloneNode();
  5306. insertBefore(pristine, this.placeholder);
  5307. this.template = this.template.clone();
  5308. this.template.mount(pristine, scope, parentScope);
  5309. };
  5310. switch (true) {
  5311. case mustMount:
  5312. mount();
  5313. break;
  5314. case mustUnmount:
  5315. this.unmount(scope);
  5316. break;
  5317. default:
  5318. if (value) this.template.update(scope, parentScope);
  5319. }
  5320. this.value = value;
  5321. return this;
  5322. },
  5323. unmount(scope, parentScope) {
  5324. this.template.unmount(scope, parentScope, true);
  5325. return this;
  5326. }
  5327. };
  5328. function create$5(node, _ref) {
  5329. let {
  5330. evaluate,
  5331. template
  5332. } = _ref;
  5333. const placeholder = document.createTextNode('');
  5334. insertBefore(placeholder, node);
  5335. removeChild(node);
  5336. return Object.assign({}, IfBinding, {
  5337. node,
  5338. evaluate,
  5339. placeholder,
  5340. template: template.createDOM(node)
  5341. });
  5342. }
  5343. /**
  5344. * Throw an error with a descriptive message
  5345. * @param { string } message - error message
  5346. * @returns { undefined } hoppla.. at this point the program should stop working
  5347. */
  5348. function panic(message) {
  5349. throw new Error(message);
  5350. }
  5351. /**
  5352. * Returns the memoized (cached) function.
  5353. * // borrowed from https://www.30secondsofcode.org/js/s/memoize
  5354. * @param {Function} fn - function to memoize
  5355. * @returns {Function} memoize function
  5356. */
  5357. function memoize(fn) {
  5358. const cache = new Map();
  5359. const cached = val => {
  5360. return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
  5361. };
  5362. cached.cache = cache;
  5363. return cached;
  5364. }
  5365. /**
  5366. * Evaluate a list of attribute expressions
  5367. * @param {Array} attributes - attribute expressions generated by the riot compiler
  5368. * @returns {Object} key value pairs with the result of the computation
  5369. */
  5370. function evaluateAttributeExpressions(attributes) {
  5371. return attributes.reduce((acc, attribute) => {
  5372. const {
  5373. value,
  5374. type
  5375. } = attribute;
  5376. switch (true) {
  5377. // spread attribute
  5378. case !attribute.name && type === ATTRIBUTE:
  5379. return Object.assign({}, acc, value);
  5380. // value attribute
  5381. case type === VALUE:
  5382. acc.value = attribute.value;
  5383. break;
  5384. // normal attributes
  5385. default:
  5386. acc[dashToCamelCase(attribute.name)] = attribute.value;
  5387. }
  5388. return acc;
  5389. }, {});
  5390. }
  5391. const ElementProto = typeof Element === 'undefined' ? {} : Element.prototype;
  5392. const isNativeHtmlProperty = memoize(name => ElementProto.hasOwnProperty(name)); // eslint-disable-line
  5393. /**
  5394. * Add all the attributes provided
  5395. * @param {HTMLElement} node - target node
  5396. * @param {Object} attributes - object containing the attributes names and values
  5397. * @returns {undefined} sorry it's a void function :(
  5398. */
  5399. function setAllAttributes(node, attributes) {
  5400. Object.entries(attributes).forEach(_ref => {
  5401. let [name, value] = _ref;
  5402. return attributeExpression(node, {
  5403. name
  5404. }, value);
  5405. });
  5406. }
  5407. /**
  5408. * Remove all the attributes provided
  5409. * @param {HTMLElement} node - target node
  5410. * @param {Object} newAttributes - object containing all the new attribute names
  5411. * @param {Object} oldAttributes - object containing all the old attribute names
  5412. * @returns {undefined} sorry it's a void function :(
  5413. */
  5414. function removeAllAttributes(node, newAttributes, oldAttributes) {
  5415. const newKeys = newAttributes ? Object.keys(newAttributes) : [];
  5416. Object.keys(oldAttributes).filter(name => !newKeys.includes(name)).forEach(attribute => node.removeAttribute(attribute));
  5417. }
  5418. /**
  5419. * Check whether the attribute value can be rendered
  5420. * @param {*} value - expression value
  5421. * @returns {boolean} true if we can render this attribute value
  5422. */
  5423. function canRenderAttribute(value) {
  5424. return value === true || ['string', 'number'].includes(typeof value);
  5425. }
  5426. /**
  5427. * Check whether the attribute should be removed
  5428. * @param {*} value - expression value
  5429. * @returns {boolean} boolean - true if the attribute can be removed}
  5430. */
  5431. function shouldRemoveAttribute(value) {
  5432. return !value && value !== 0;
  5433. }
  5434. /**
  5435. * This methods handles the DOM attributes updates
  5436. * @param {HTMLElement} node - target node
  5437. * @param {Object} expression - expression object
  5438. * @param {string} expression.name - attribute name
  5439. * @param {*} value - new expression value
  5440. * @param {*} oldValue - the old expression cached value
  5441. * @returns {undefined}
  5442. */
  5443. function attributeExpression(node, _ref2, value, oldValue) {
  5444. let {
  5445. name
  5446. } = _ref2;
  5447. // is it a spread operator? {...attributes}
  5448. if (!name) {
  5449. if (oldValue) {
  5450. // remove all the old attributes
  5451. removeAllAttributes(node, value, oldValue);
  5452. } // is the value still truthy?
  5453. if (value) {
  5454. setAllAttributes(node, value);
  5455. }
  5456. return;
  5457. } // handle boolean attributes
  5458. if (!isNativeHtmlProperty(name) && (isBoolean(value) || isObject(value) || isFunction(value))) {
  5459. node[name] = value;
  5460. }
  5461. if (shouldRemoveAttribute(value)) {
  5462. node.removeAttribute(name);
  5463. } else if (canRenderAttribute(value)) {
  5464. node.setAttribute(name, normalizeValue(name, value));
  5465. }
  5466. }
  5467. /**
  5468. * Get the value as string
  5469. * @param {string} name - attribute name
  5470. * @param {*} value - user input value
  5471. * @returns {string} input value as string
  5472. */
  5473. function normalizeValue(name, value) {
  5474. // be sure that expressions like selected={ true } will be always rendered as selected='selected'
  5475. return value === true ? name : value;
  5476. }
  5477. const RE_EVENTS_PREFIX = /^on/;
  5478. const getCallbackAndOptions = value => Array.isArray(value) ? value : [value, false]; // see also https://medium.com/@WebReflection/dom-handleevent-a-cross-platform-standard-since-year-2000-5bf17287fd38
  5479. const EventListener = {
  5480. handleEvent(event) {
  5481. this[event.type](event);
  5482. }
  5483. };
  5484. const ListenersWeakMap = new WeakMap();
  5485. const createListener = node => {
  5486. const listener = Object.create(EventListener);
  5487. ListenersWeakMap.set(node, listener);
  5488. return listener;
  5489. };
  5490. /**
  5491. * Set a new event listener
  5492. * @param {HTMLElement} node - target node
  5493. * @param {Object} expression - expression object
  5494. * @param {string} expression.name - event name
  5495. * @param {*} value - new expression value
  5496. * @returns {value} the callback just received
  5497. */
  5498. function eventExpression(node, _ref, value) {
  5499. let {
  5500. name
  5501. } = _ref;
  5502. const normalizedEventName = name.replace(RE_EVENTS_PREFIX, '');
  5503. const eventListener = ListenersWeakMap.get(node) || createListener(node);
  5504. const [callback, options] = getCallbackAndOptions(value);
  5505. const handler = eventListener[normalizedEventName];
  5506. const mustRemoveEvent = handler && !callback;
  5507. const mustAddEvent = callback && !handler;
  5508. if (mustRemoveEvent) {
  5509. node.removeEventListener(normalizedEventName, eventListener);
  5510. }
  5511. if (mustAddEvent) {
  5512. node.addEventListener(normalizedEventName, eventListener, options);
  5513. }
  5514. eventListener[normalizedEventName] = callback;
  5515. }
  5516. /**
  5517. * Normalize the user value in order to render a empty string in case of falsy values
  5518. * @param {*} value - user input value
  5519. * @returns {string} hopefully a string
  5520. */
  5521. function normalizeStringValue(value) {
  5522. return isNil(value) ? '' : value;
  5523. }
  5524. /**
  5525. * Get the the target text node to update or create one from of a comment node
  5526. * @param {HTMLElement} node - any html element containing childNodes
  5527. * @param {number} childNodeIndex - index of the text node in the childNodes list
  5528. * @returns {Text} the text node to update
  5529. */
  5530. const getTextNode = (node, childNodeIndex) => {
  5531. const target = node.childNodes[childNodeIndex];
  5532. if (target.nodeType === Node.COMMENT_NODE) {
  5533. const textNode = document.createTextNode('');
  5534. node.replaceChild(textNode, target);
  5535. return textNode;
  5536. }
  5537. return target;
  5538. };
  5539. /**
  5540. * This methods handles a simple text expression update
  5541. * @param {HTMLElement} node - target node
  5542. * @param {Object} data - expression object
  5543. * @param {*} value - new expression value
  5544. * @returns {undefined}
  5545. */
  5546. function textExpression(node, data, value) {
  5547. node.data = normalizeStringValue(value);
  5548. }
  5549. /**
  5550. * This methods handles the input fileds value updates
  5551. * @param {HTMLElement} node - target node
  5552. * @param {Object} expression - expression object
  5553. * @param {*} value - new expression value
  5554. * @returns {undefined}
  5555. */
  5556. function valueExpression(node, expression, value) {
  5557. node.value = normalizeStringValue(value);
  5558. }
  5559. var expressions = {
  5560. [ATTRIBUTE]: attributeExpression,
  5561. [EVENT]: eventExpression,
  5562. [TEXT]: textExpression,
  5563. [VALUE]: valueExpression
  5564. };
  5565. const Expression = {
  5566. // Static props
  5567. // node: null,
  5568. // value: null,
  5569. // API methods
  5570. /**
  5571. * Mount the expression evaluating its initial value
  5572. * @param {*} scope - argument passed to the expression to evaluate its current values
  5573. * @returns {Expression} self
  5574. */
  5575. mount(scope) {
  5576. // hopefully a pure function
  5577. this.value = this.evaluate(scope); // IO() DOM updates
  5578. apply(this, this.value);
  5579. return this;
  5580. },
  5581. /**
  5582. * Update the expression if its value changed
  5583. * @param {*} scope - argument passed to the expression to evaluate its current values
  5584. * @returns {Expression} self
  5585. */
  5586. update(scope) {
  5587. // pure function
  5588. const value = this.evaluate(scope);
  5589. if (this.value !== value) {
  5590. // IO() DOM updates
  5591. apply(this, value);
  5592. this.value = value;
  5593. }
  5594. return this;
  5595. },
  5596. /**
  5597. * Expression teardown method
  5598. * @returns {Expression} self
  5599. */
  5600. unmount() {
  5601. // unmount only the event handling expressions
  5602. if (this.type === EVENT) apply(this, null);
  5603. return this;
  5604. }
  5605. };
  5606. /**
  5607. * IO() function to handle the DOM updates
  5608. * @param {Expression} expression - expression object
  5609. * @param {*} value - current expression value
  5610. * @returns {undefined}
  5611. */
  5612. function apply(expression, value) {
  5613. return expressions[expression.type](expression.node, expression, value, expression.value);
  5614. }
  5615. function create$4(node, data) {
  5616. return Object.assign({}, Expression, data, {
  5617. node: data.type === TEXT ? getTextNode(node, data.childNodeIndex) : node
  5618. });
  5619. }
  5620. /**
  5621. * Create a flat object having as keys a list of methods that if dispatched will propagate
  5622. * on the whole collection
  5623. * @param {Array} collection - collection to iterate
  5624. * @param {Array<string>} methods - methods to execute on each item of the collection
  5625. * @param {*} context - context returned by the new methods created
  5626. * @returns {Object} a new object to simplify the the nested methods dispatching
  5627. */
  5628. function flattenCollectionMethods(collection, methods, context) {
  5629. return methods.reduce((acc, method) => {
  5630. return Object.assign({}, acc, {
  5631. [method]: scope => {
  5632. return collection.map(item => item[method](scope)) && context;
  5633. }
  5634. });
  5635. }, {});
  5636. }
  5637. function create$3(node, _ref) {
  5638. let {
  5639. expressions
  5640. } = _ref;
  5641. return Object.assign({}, flattenCollectionMethods(expressions.map(expression => create$4(node, expression)), ['mount', 'update', 'unmount']));
  5642. }
  5643. function extendParentScope(attributes, scope, parentScope) {
  5644. if (!attributes || !attributes.length) return parentScope;
  5645. const expressions = attributes.map(attr => Object.assign({}, attr, {
  5646. value: attr.evaluate(scope)
  5647. }));
  5648. return Object.assign(Object.create(parentScope || null), evaluateAttributeExpressions(expressions));
  5649. } // this function is only meant to fix an edge case
  5650. // https://github.com/riot/riot/issues/2842
  5651. const getRealParent = (scope, parentScope) => scope[PARENT_KEY_SYMBOL] || parentScope;
  5652. const SlotBinding = {
  5653. // dynamic binding properties
  5654. // node: null,
  5655. // name: null,
  5656. attributes: [],
  5657. // template: null,
  5658. getTemplateScope(scope, parentScope) {
  5659. return extendParentScope(this.attributes, scope, parentScope);
  5660. },
  5661. // API methods
  5662. mount(scope, parentScope) {
  5663. const templateData = scope.slots ? scope.slots.find(_ref => {
  5664. let {
  5665. id
  5666. } = _ref;
  5667. return id === this.name;
  5668. }) : false;
  5669. const {
  5670. parentNode
  5671. } = this.node;
  5672. const realParent = getRealParent(scope, parentScope);
  5673. this.template = templateData && create(templateData.html, templateData.bindings).createDOM(parentNode);
  5674. if (this.template) {
  5675. cleanNode(this.node);
  5676. this.template.mount(this.node, this.getTemplateScope(scope, realParent), realParent);
  5677. this.template.children = Array.from(this.node.childNodes);
  5678. }
  5679. moveSlotInnerContent(this.node);
  5680. removeChild(this.node);
  5681. return this;
  5682. },
  5683. update(scope, parentScope) {
  5684. if (this.template) {
  5685. const realParent = getRealParent(scope, parentScope);
  5686. this.template.update(this.getTemplateScope(scope, realParent), realParent);
  5687. }
  5688. return this;
  5689. },
  5690. unmount(scope, parentScope, mustRemoveRoot) {
  5691. if (this.template) {
  5692. this.template.unmount(this.getTemplateScope(scope, parentScope), null, mustRemoveRoot);
  5693. }
  5694. return this;
  5695. }
  5696. };
  5697. /**
  5698. * Move the inner content of the slots outside of them
  5699. * @param {HTMLElement} slot - slot node
  5700. * @returns {undefined} it's a void method ¯\_()_/¯
  5701. */
  5702. function moveSlotInnerContent(slot) {
  5703. const child = slot && slot.firstChild;
  5704. if (!child) return;
  5705. insertBefore(child, slot);
  5706. moveSlotInnerContent(slot);
  5707. }
  5708. /**
  5709. * Create a single slot binding
  5710. * @param {HTMLElement} node - slot node
  5711. * @param {string} name - slot id
  5712. * @param {AttributeExpressionData[]} attributes - slot attributes
  5713. * @returns {Object} Slot binding object
  5714. */
  5715. function createSlot(node, _ref2) {
  5716. let {
  5717. name,
  5718. attributes
  5719. } = _ref2;
  5720. return Object.assign({}, SlotBinding, {
  5721. attributes,
  5722. node,
  5723. name
  5724. });
  5725. }
  5726. /**
  5727. * Create a new tag object if it was registered before, otherwise fallback to the simple
  5728. * template chunk
  5729. * @param {Function} component - component factory function
  5730. * @param {Array<Object>} slots - array containing the slots markup
  5731. * @param {Array} attributes - dynamic attributes that will be received by the tag element
  5732. * @returns {TagImplementation|TemplateChunk} a tag implementation or a template chunk as fallback
  5733. */
  5734. function getTag(component, slots, attributes) {
  5735. if (slots === void 0) {
  5736. slots = [];
  5737. }
  5738. if (attributes === void 0) {
  5739. attributes = [];
  5740. }
  5741. // if this tag was registered before we will return its implementation
  5742. if (component) {
  5743. return component({
  5744. slots,
  5745. attributes
  5746. });
  5747. } // otherwise we return a template chunk
  5748. return create(slotsToMarkup(slots), [...slotBindings(slots), {
  5749. // the attributes should be registered as binding
  5750. // if we fallback to a normal template chunk
  5751. expressions: attributes.map(attr => {
  5752. return Object.assign({
  5753. type: ATTRIBUTE
  5754. }, attr);
  5755. })
  5756. }]);
  5757. }
  5758. /**
  5759. * Merge all the slots bindings into a single array
  5760. * @param {Array<Object>} slots - slots collection
  5761. * @returns {Array<Bindings>} flatten bindings array
  5762. */
  5763. function slotBindings(slots) {
  5764. return slots.reduce((acc, _ref) => {
  5765. let {
  5766. bindings
  5767. } = _ref;
  5768. return acc.concat(bindings);
  5769. }, []);
  5770. }
  5771. /**
  5772. * Merge all the slots together in a single markup string
  5773. * @param {Array<Object>} slots - slots collection
  5774. * @returns {string} markup of all the slots in a single string
  5775. */
  5776. function slotsToMarkup(slots) {
  5777. return slots.reduce((acc, slot) => {
  5778. return acc + slot.html;
  5779. }, '');
  5780. }
  5781. const TagBinding = {
  5782. // dynamic binding properties
  5783. // node: null,
  5784. // evaluate: null,
  5785. // name: null,
  5786. // slots: null,
  5787. // tag: null,
  5788. // attributes: null,
  5789. // getComponent: null,
  5790. mount(scope) {
  5791. return this.update(scope);
  5792. },
  5793. update(scope, parentScope) {
  5794. const name = this.evaluate(scope); // simple update
  5795. if (name && name === this.name) {
  5796. this.tag.update(scope);
  5797. } else {
  5798. // unmount the old tag if it exists
  5799. this.unmount(scope, parentScope, true); // mount the new tag
  5800. this.name = name;
  5801. this.tag = getTag(this.getComponent(name), this.slots, this.attributes);
  5802. this.tag.mount(this.node, scope);
  5803. }
  5804. return this;
  5805. },
  5806. unmount(scope, parentScope, keepRootTag) {
  5807. if (this.tag) {
  5808. // keep the root tag
  5809. this.tag.unmount(keepRootTag);
  5810. }
  5811. return this;
  5812. }
  5813. };
  5814. function create$2(node, _ref2) {
  5815. let {
  5816. evaluate,
  5817. getComponent,
  5818. slots,
  5819. attributes
  5820. } = _ref2;
  5821. return Object.assign({}, TagBinding, {
  5822. node,
  5823. evaluate,
  5824. slots,
  5825. attributes,
  5826. getComponent
  5827. });
  5828. }
  5829. var bindings = {
  5830. [IF]: create$5,
  5831. [SIMPLE]: create$3,
  5832. [EACH]: create$6,
  5833. [TAG]: create$2,
  5834. [SLOT]: createSlot
  5835. };
  5836. /**
  5837. * Text expressions in a template tag will get childNodeIndex value normalized
  5838. * depending on the position of the <template> tag offset
  5839. * @param {Expression[]} expressions - riot expressions array
  5840. * @param {number} textExpressionsOffset - offset of the <template> tag
  5841. * @returns {Expression[]} expressions containing the text expressions normalized
  5842. */
  5843. function fixTextExpressionsOffset(expressions, textExpressionsOffset) {
  5844. return expressions.map(e => e.type === TEXT ? Object.assign({}, e, {
  5845. childNodeIndex: e.childNodeIndex + textExpressionsOffset
  5846. }) : e);
  5847. }
  5848. /**
  5849. * Bind a new expression object to a DOM node
  5850. * @param {HTMLElement} root - DOM node where to bind the expression
  5851. * @param {TagBindingData} binding - binding data
  5852. * @param {number|null} templateTagOffset - if it's defined we need to fix the text expressions childNodeIndex offset
  5853. * @returns {Binding} Binding object
  5854. */
  5855. function create$1(root, binding, templateTagOffset) {
  5856. const {
  5857. selector,
  5858. type,
  5859. redundantAttribute,
  5860. expressions
  5861. } = binding; // find the node to apply the bindings
  5862. const node = selector ? root.querySelector(selector) : root; // remove eventually additional attributes created only to select this node
  5863. if (redundantAttribute) node.removeAttribute(redundantAttribute);
  5864. const bindingExpressions = expressions || []; // init the binding
  5865. return (bindings[type] || bindings[SIMPLE])(node, Object.assign({}, binding, {
  5866. expressions: templateTagOffset && !selector ? fixTextExpressionsOffset(bindingExpressions, templateTagOffset) : bindingExpressions
  5867. }));
  5868. }
  5869. function createHTMLTree(html, root) {
  5870. const template = isTemplate(root) ? root : document.createElement('template');
  5871. template.innerHTML = html;
  5872. return template.content;
  5873. } // for svg nodes we need a bit more work
  5874. function createSVGTree(html, container) {
  5875. // create the SVGNode
  5876. const svgNode = container.ownerDocument.importNode(new window.DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${html}</svg>`, 'application/xml').documentElement, true);
  5877. return svgNode;
  5878. }
  5879. /**
  5880. * Create the DOM that will be injected
  5881. * @param {Object} root - DOM node to find out the context where the fragment will be created
  5882. * @param {string} html - DOM to create as string
  5883. * @returns {HTMLDocumentFragment|HTMLElement} a new html fragment
  5884. */
  5885. function createDOMTree(root, html) {
  5886. if (isSvg(root)) return createSVGTree(html, root);
  5887. return createHTMLTree(html, root);
  5888. }
  5889. /**
  5890. * Inject the DOM tree into a target node
  5891. * @param {HTMLElement} el - target element
  5892. * @param {DocumentFragment|SVGElement} dom - dom tree to inject
  5893. * @returns {undefined}
  5894. */
  5895. function injectDOM(el, dom) {
  5896. switch (true) {
  5897. case isSvg(el):
  5898. moveChildren(dom, el);
  5899. break;
  5900. case isTemplate(el):
  5901. el.parentNode.replaceChild(dom, el);
  5902. break;
  5903. default:
  5904. el.appendChild(dom);
  5905. }
  5906. }
  5907. /**
  5908. * Create the Template DOM skeleton
  5909. * @param {HTMLElement} el - root node where the DOM will be injected
  5910. * @param {string|HTMLElement} html - HTML markup or HTMLElement that will be injected into the root node
  5911. * @returns {?DocumentFragment} fragment that will be injected into the root node
  5912. */
  5913. function createTemplateDOM(el, html) {
  5914. return html && (typeof html === 'string' ? createDOMTree(el, html) : html);
  5915. }
  5916. /**
  5917. * Get the offset of the <template> tag
  5918. * @param {HTMLElement} parentNode - template tag parent node
  5919. * @param {HTMLElement} el - the template tag we want to render
  5920. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  5921. * @returns {number} offset of the <template> tag calculated from its siblings DOM nodes
  5922. */
  5923. function getTemplateTagOffset(parentNode, el, meta) {
  5924. const siblings = Array.from(parentNode.childNodes);
  5925. return Math.max(siblings.indexOf(el), siblings.indexOf(meta.head) + 1, 0);
  5926. }
  5927. /**
  5928. * Template Chunk model
  5929. * @type {Object}
  5930. */
  5931. const TemplateChunk = Object.freeze({
  5932. // Static props
  5933. // bindings: null,
  5934. // bindingsData: null,
  5935. // html: null,
  5936. // isTemplateTag: false,
  5937. // fragment: null,
  5938. // children: null,
  5939. // dom: null,
  5940. // el: null,
  5941. /**
  5942. * Create the template DOM structure that will be cloned on each mount
  5943. * @param {HTMLElement} el - the root node
  5944. * @returns {TemplateChunk} self
  5945. */
  5946. createDOM(el) {
  5947. // make sure that the DOM gets created before cloning the template
  5948. this.dom = this.dom || createTemplateDOM(el, this.html) || document.createDocumentFragment();
  5949. return this;
  5950. },
  5951. // API methods
  5952. /**
  5953. * Attach the template to a DOM node
  5954. * @param {HTMLElement} el - target DOM node
  5955. * @param {*} scope - template data
  5956. * @param {*} parentScope - scope of the parent template tag
  5957. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  5958. * @returns {TemplateChunk} self
  5959. */
  5960. mount(el, scope, parentScope, meta) {
  5961. if (meta === void 0) {
  5962. meta = {};
  5963. }
  5964. if (!el) throw new Error('Please provide DOM node to mount properly your template');
  5965. if (this.el) this.unmount(scope); // <template> tags require a bit more work
  5966. // the template fragment might be already created via meta outside of this call
  5967. const {
  5968. fragment,
  5969. children,
  5970. avoidDOMInjection
  5971. } = meta; // <template> bindings of course can not have a root element
  5972. // so we check the parent node to set the query selector bindings
  5973. const {
  5974. parentNode
  5975. } = children ? children[0] : el;
  5976. const isTemplateTag = isTemplate(el);
  5977. const templateTagOffset = isTemplateTag ? getTemplateTagOffset(parentNode, el, meta) : null; // create the DOM if it wasn't created before
  5978. this.createDOM(el); // create the DOM of this template cloning the original DOM structure stored in this instance
  5979. // notice that if a documentFragment was passed (via meta) we will use it instead
  5980. const cloneNode = fragment || this.dom.cloneNode(true); // store root node
  5981. // notice that for template tags the root note will be the parent tag
  5982. this.el = isTemplateTag ? parentNode : el; // create the children array only for the <template> fragments
  5983. this.children = isTemplateTag ? children || Array.from(cloneNode.childNodes) : null; // inject the DOM into the el only if a fragment is available
  5984. if (!avoidDOMInjection && cloneNode) injectDOM(el, cloneNode); // create the bindings
  5985. this.bindings = this.bindingsData.map(binding => create$1(this.el, binding, templateTagOffset));
  5986. this.bindings.forEach(b => b.mount(scope, parentScope)); // store the template meta properties
  5987. this.meta = meta;
  5988. return this;
  5989. },
  5990. /**
  5991. * Update the template with fresh data
  5992. * @param {*} scope - template data
  5993. * @param {*} parentScope - scope of the parent template tag
  5994. * @returns {TemplateChunk} self
  5995. */
  5996. update(scope, parentScope) {
  5997. this.bindings.forEach(b => b.update(scope, parentScope));
  5998. return this;
  5999. },
  6000. /**
  6001. * Remove the template from the node where it was initially mounted
  6002. * @param {*} scope - template data
  6003. * @param {*} parentScope - scope of the parent template tag
  6004. * @param {boolean|null} mustRemoveRoot - if true remove the root element,
  6005. * if false or undefined clean the root tag content, if null don't touch the DOM
  6006. * @returns {TemplateChunk} self
  6007. */
  6008. unmount(scope, parentScope, mustRemoveRoot) {
  6009. if (mustRemoveRoot === void 0) {
  6010. mustRemoveRoot = false;
  6011. }
  6012. const el = this.el;
  6013. if (!el) {
  6014. return this;
  6015. }
  6016. this.bindings.forEach(b => b.unmount(scope, parentScope, mustRemoveRoot));
  6017. switch (true) {
  6018. // pure components should handle the DOM unmount updates by themselves
  6019. // for mustRemoveRoot === null don't touch the DOM
  6020. case el[IS_PURE_SYMBOL] || mustRemoveRoot === null:
  6021. break;
  6022. // if children are declared, clear them
  6023. // applicable for <template> and <slot/> bindings
  6024. case Array.isArray(this.children):
  6025. clearChildren(this.children);
  6026. break;
  6027. // clean the node children only
  6028. case !mustRemoveRoot:
  6029. cleanNode(el);
  6030. break;
  6031. // remove the root node only if the mustRemoveRoot is truly
  6032. case !!mustRemoveRoot:
  6033. removeChild(el);
  6034. break;
  6035. }
  6036. this.el = null;
  6037. return this;
  6038. },
  6039. /**
  6040. * Clone the template chunk
  6041. * @returns {TemplateChunk} a clone of this object resetting the this.el property
  6042. */
  6043. clone() {
  6044. return Object.assign({}, this, {
  6045. meta: {},
  6046. el: null
  6047. });
  6048. }
  6049. });
  6050. /**
  6051. * Create a template chunk wiring also the bindings
  6052. * @param {string|HTMLElement} html - template string
  6053. * @param {BindingData[]} bindings - bindings collection
  6054. * @returns {TemplateChunk} a new TemplateChunk copy
  6055. */
  6056. function create(html, bindings) {
  6057. if (bindings === void 0) {
  6058. bindings = [];
  6059. }
  6060. return Object.assign({}, TemplateChunk, {
  6061. html,
  6062. bindingsData: bindings
  6063. });
  6064. }
  6065. /**
  6066. * Method used to bind expressions to a DOM node
  6067. * @param {string|HTMLElement} html - your static template html structure
  6068. * @param {Array} bindings - list of the expressions to bind to update the markup
  6069. * @returns {TemplateChunk} a new TemplateChunk object having the `update`,`mount`, `unmount` and `clone` methods
  6070. *
  6071. * @example
  6072. *
  6073. * riotDOMBindings
  6074. * .template(
  6075. * `<div expr0><!----></div><div><p expr1><!----><section expr2></section></p>`,
  6076. * [
  6077. * {
  6078. * selector: '[expr0]',
  6079. * redundantAttribute: 'expr0',
  6080. * expressions: [
  6081. * {
  6082. * type: expressionTypes.TEXT,
  6083. * childNodeIndex: 0,
  6084. * evaluate(scope) {
  6085. * return scope.time;
  6086. * },
  6087. * },
  6088. * ],
  6089. * },
  6090. * {
  6091. * selector: '[expr1]',
  6092. * redundantAttribute: 'expr1',
  6093. * expressions: [
  6094. * {
  6095. * type: expressionTypes.TEXT,
  6096. * childNodeIndex: 0,
  6097. * evaluate(scope) {
  6098. * return scope.name;
  6099. * },
  6100. * },
  6101. * {
  6102. * type: 'attribute',
  6103. * name: 'style',
  6104. * evaluate(scope) {
  6105. * return scope.style;
  6106. * },
  6107. * },
  6108. * ],
  6109. * },
  6110. * {
  6111. * selector: '[expr2]',
  6112. * redundantAttribute: 'expr2',
  6113. * type: bindingTypes.IF,
  6114. * evaluate(scope) {
  6115. * return scope.isVisible;
  6116. * },
  6117. * template: riotDOMBindings.template('hello there'),
  6118. * },
  6119. * ]
  6120. * )
  6121. */
  6122. var DOMBindings = /*#__PURE__*/Object.freeze({
  6123. __proto__: null,
  6124. template: create,
  6125. createBinding: create$1,
  6126. createExpression: create$4,
  6127. bindingTypes: bindingTypes,
  6128. expressionTypes: expressionTypes
  6129. });
  6130. function noop() {
  6131. return this;
  6132. }
  6133. /**
  6134. * Autobind the methods of a source object to itself
  6135. * @param {Object} source - probably a riot tag instance
  6136. * @param {Array<string>} methods - list of the methods to autobind
  6137. * @returns {Object} the original object received
  6138. */
  6139. function autobindMethods(source, methods) {
  6140. methods.forEach(method => {
  6141. source[method] = source[method].bind(source);
  6142. });
  6143. return source;
  6144. }
  6145. /**
  6146. * Call the first argument received only if it's a function otherwise return it as it is
  6147. * @param {*} source - anything
  6148. * @returns {*} anything
  6149. */
  6150. function callOrAssign(source) {
  6151. return isFunction(source) ? source.prototype && source.prototype.constructor ? new source() : source() : source;
  6152. }
  6153. /**
  6154. * Converts any DOM node/s to a loopable array
  6155. * @param { HTMLElement|NodeList } els - single html element or a node list
  6156. * @returns { Array } always a loopable object
  6157. */
  6158. function domToArray(els) {
  6159. // can this object be already looped?
  6160. if (!Array.isArray(els)) {
  6161. // is it a node list?
  6162. if (/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(els)) && typeof els.length === 'number') return Array.from(els);else // if it's a single node
  6163. // it will be returned as "array" with one single entry
  6164. return [els];
  6165. } // this object could be looped out of the box
  6166. return els;
  6167. }
  6168. /**
  6169. * Simple helper to find DOM nodes returning them as array like loopable object
  6170. * @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
  6171. * @param { HTMLElement } ctx - context defining where the query will search for the DOM nodes
  6172. * @returns { Array } DOM nodes found as array
  6173. */
  6174. function $(selector, ctx) {
  6175. return domToArray(typeof selector === 'string' ? (ctx || document).querySelectorAll(selector) : selector);
  6176. }
  6177. /**
  6178. * Normalize the return values, in case of a single value we avoid to return an array
  6179. * @param { Array } values - list of values we want to return
  6180. * @returns { Array|string|boolean } either the whole list of values or the single one found
  6181. * @private
  6182. */
  6183. const normalize = values => values.length === 1 ? values[0] : values;
  6184. /**
  6185. * Parse all the nodes received to get/remove/check their attributes
  6186. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  6187. * @param { string|Array } name - name or list of attributes
  6188. * @param { string } method - method that will be used to parse the attributes
  6189. * @returns { Array|string } result of the parsing in a list or a single value
  6190. * @private
  6191. */
  6192. function parseNodes(els, name, method) {
  6193. const names = typeof name === 'string' ? [name] : name;
  6194. return normalize(domToArray(els).map(el => {
  6195. return normalize(names.map(n => el[method](n)));
  6196. }));
  6197. }
  6198. /**
  6199. * Set any attribute on a single or a list of DOM nodes
  6200. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  6201. * @param { string|Object } name - either the name of the attribute to set
  6202. * or a list of properties as object key - value
  6203. * @param { string } value - the new value of the attribute (optional)
  6204. * @returns { HTMLElement|NodeList|Array } the original array of elements passed to this function
  6205. *
  6206. * @example
  6207. *
  6208. * import { set } from 'bianco.attr'
  6209. *
  6210. * const img = document.createElement('img')
  6211. *
  6212. * set(img, 'width', 100)
  6213. *
  6214. * // or also
  6215. * set(img, {
  6216. * width: 300,
  6217. * height: 300
  6218. * })
  6219. *
  6220. */
  6221. function set(els, name, value) {
  6222. const attrs = typeof name === 'object' ? name : {
  6223. [name]: value
  6224. };
  6225. const props = Object.keys(attrs);
  6226. domToArray(els).forEach(el => {
  6227. props.forEach(prop => el.setAttribute(prop, attrs[prop]));
  6228. });
  6229. return els;
  6230. }
  6231. /**
  6232. * Get any attribute from a single or a list of DOM nodes
  6233. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  6234. * @param { string|Array } name - name or list of attributes to get
  6235. * @returns { Array|string } list of the attributes found
  6236. *
  6237. * @example
  6238. *
  6239. * import { get } from 'bianco.attr'
  6240. *
  6241. * const img = document.createElement('img')
  6242. *
  6243. * get(img, 'width') // => '200'
  6244. *
  6245. * // or also
  6246. * get(img, ['width', 'height']) // => ['200', '300']
  6247. *
  6248. * // or also
  6249. * get([img1, img2], ['width', 'height']) // => [['200', '300'], ['500', '200']]
  6250. */
  6251. function get(els, name) {
  6252. return parseNodes(els, name, 'getAttribute');
  6253. }
  6254. const CSS_BY_NAME = new Map();
  6255. const STYLE_NODE_SELECTOR = 'style[riot]'; // memoized curried function
  6256. const getStyleNode = (style => {
  6257. return () => {
  6258. // lazy evaluation:
  6259. // if this function was already called before
  6260. // we return its cached result
  6261. if (style) return style; // create a new style element or use an existing one
  6262. // and cache it internally
  6263. style = $(STYLE_NODE_SELECTOR)[0] || document.createElement('style');
  6264. set(style, 'type', 'text/css');
  6265. /* istanbul ignore next */
  6266. if (!style.parentNode) document.head.appendChild(style);
  6267. return style;
  6268. };
  6269. })();
  6270. /**
  6271. * Object that will be used to inject and manage the css of every tag instance
  6272. */
  6273. var cssManager = {
  6274. CSS_BY_NAME,
  6275. /**
  6276. * Save a tag style to be later injected into DOM
  6277. * @param { string } name - if it's passed we will map the css to a tagname
  6278. * @param { string } css - css string
  6279. * @returns {Object} self
  6280. */
  6281. add(name, css) {
  6282. if (!CSS_BY_NAME.has(name)) {
  6283. CSS_BY_NAME.set(name, css);
  6284. this.inject();
  6285. }
  6286. return this;
  6287. },
  6288. /**
  6289. * Inject all previously saved tag styles into DOM
  6290. * innerHTML seems slow: http://jsperf.com/riot-insert-style
  6291. * @returns {Object} self
  6292. */
  6293. inject() {
  6294. getStyleNode().innerHTML = [...CSS_BY_NAME.values()].join('\n');
  6295. return this;
  6296. },
  6297. /**
  6298. * Remove a tag style from the DOM
  6299. * @param {string} name a registered tagname
  6300. * @returns {Object} self
  6301. */
  6302. remove(name) {
  6303. if (CSS_BY_NAME.has(name)) {
  6304. CSS_BY_NAME.delete(name);
  6305. this.inject();
  6306. }
  6307. return this;
  6308. }
  6309. };
  6310. /**
  6311. * Function to curry any javascript method
  6312. * @param {Function} fn - the target function we want to curry
  6313. * @param {...[args]} acc - initial arguments
  6314. * @returns {Function|*} it will return a function until the target function
  6315. * will receive all of its arguments
  6316. */
  6317. function curry(fn) {
  6318. for (var _len = arguments.length, acc = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6319. acc[_key - 1] = arguments[_key];
  6320. }
  6321. return function () {
  6322. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6323. args[_key2] = arguments[_key2];
  6324. }
  6325. args = [...acc, ...args];
  6326. return args.length < fn.length ? curry(fn, ...args) : fn(...args);
  6327. };
  6328. }
  6329. /**
  6330. * Get the tag name of any DOM node
  6331. * @param {HTMLElement} element - DOM node we want to inspect
  6332. * @returns {string} name to identify this dom node in riot
  6333. */
  6334. function getName(element) {
  6335. return get(element, IS_DIRECTIVE) || element.tagName.toLowerCase();
  6336. }
  6337. const COMPONENT_CORE_HELPERS = Object.freeze({
  6338. // component helpers
  6339. $(selector) {
  6340. return $(selector, this.root)[0];
  6341. },
  6342. $$(selector) {
  6343. return $(selector, this.root);
  6344. }
  6345. });
  6346. const PURE_COMPONENT_API = Object.freeze({
  6347. [MOUNT_METHOD_KEY]: noop,
  6348. [UPDATE_METHOD_KEY]: noop,
  6349. [UNMOUNT_METHOD_KEY]: noop
  6350. });
  6351. const COMPONENT_LIFECYCLE_METHODS = Object.freeze({
  6352. [SHOULD_UPDATE_KEY]: noop,
  6353. [ON_BEFORE_MOUNT_KEY]: noop,
  6354. [ON_MOUNTED_KEY]: noop,
  6355. [ON_BEFORE_UPDATE_KEY]: noop,
  6356. [ON_UPDATED_KEY]: noop,
  6357. [ON_BEFORE_UNMOUNT_KEY]: noop,
  6358. [ON_UNMOUNTED_KEY]: noop
  6359. });
  6360. const MOCKED_TEMPLATE_INTERFACE = Object.assign({}, PURE_COMPONENT_API, {
  6361. clone: noop,
  6362. createDOM: noop
  6363. });
  6364. /**
  6365. * Performance optimization for the recursive components
  6366. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  6367. * @returns {Object} component like interface
  6368. */
  6369. const memoizedCreateComponent = memoize(createComponent);
  6370. /**
  6371. * Evaluate the component properties either from its real attributes or from its initial user properties
  6372. * @param {HTMLElement} element - component root
  6373. * @param {Object} initialProps - initial props
  6374. * @returns {Object} component props key value pairs
  6375. */
  6376. function evaluateInitialProps(element, initialProps) {
  6377. if (initialProps === void 0) {
  6378. initialProps = {};
  6379. }
  6380. return Object.assign({}, DOMattributesToObject(element), callOrAssign(initialProps));
  6381. }
  6382. /**
  6383. * Bind a DOM node to its component object
  6384. * @param {HTMLElement} node - html node mounted
  6385. * @param {Object} component - Riot.js component object
  6386. * @returns {Object} the component object received as second argument
  6387. */
  6388. const bindDOMNodeToComponentObject = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY$1] = component;
  6389. /**
  6390. * Wrap the Riot.js core API methods using a mapping function
  6391. * @param {Function} mapFunction - lifting function
  6392. * @returns {Object} an object having the { mount, update, unmount } functions
  6393. */
  6394. function createCoreAPIMethods(mapFunction) {
  6395. return [MOUNT_METHOD_KEY, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY].reduce((acc, method) => {
  6396. acc[method] = mapFunction(method);
  6397. return acc;
  6398. }, {});
  6399. }
  6400. /**
  6401. * Factory function to create the component templates only once
  6402. * @param {Function} template - component template creation function
  6403. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  6404. * @returns {TemplateChunk} template chunk object
  6405. */
  6406. function componentTemplateFactory(template, componentWrapper) {
  6407. const components = createSubcomponents(componentWrapper.exports ? componentWrapper.exports.components : {});
  6408. return template(create, expressionTypes, bindingTypes, name => {
  6409. // improve support for recursive components
  6410. if (name === componentWrapper.name) return memoizedCreateComponent(componentWrapper); // return the registered components
  6411. return components[name] || COMPONENTS_IMPLEMENTATION_MAP$1.get(name);
  6412. });
  6413. }
  6414. /**
  6415. * Create a pure component
  6416. * @param {Function} pureFactoryFunction - pure component factory function
  6417. * @param {Array} options.slots - component slots
  6418. * @param {Array} options.attributes - component attributes
  6419. * @param {Array} options.template - template factory function
  6420. * @param {Array} options.template - template factory function
  6421. * @param {any} options.props - initial component properties
  6422. * @returns {Object} pure component object
  6423. */
  6424. function createPureComponent(pureFactoryFunction, _ref) {
  6425. let {
  6426. slots,
  6427. attributes,
  6428. props,
  6429. css,
  6430. template
  6431. } = _ref;
  6432. if (template) panic('Pure components can not have html');
  6433. if (css) panic('Pure components do not have css');
  6434. const component = defineDefaults(pureFactoryFunction({
  6435. slots,
  6436. attributes,
  6437. props
  6438. }), PURE_COMPONENT_API);
  6439. return createCoreAPIMethods(method => function () {
  6440. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6441. args[_key] = arguments[_key];
  6442. }
  6443. // intercept the mount calls to bind the DOM node to the pure object created
  6444. // see also https://github.com/riot/riot/issues/2806
  6445. if (method === MOUNT_METHOD_KEY) {
  6446. const [el] = args; // mark this node as pure element
  6447. el[IS_PURE_SYMBOL] = true;
  6448. bindDOMNodeToComponentObject(el, component);
  6449. }
  6450. component[method](...args);
  6451. return component;
  6452. });
  6453. }
  6454. /**
  6455. * Create the component interface needed for the @riotjs/dom-bindings tag bindings
  6456. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  6457. * @param {string} componentWrapper.css - component css
  6458. * @param {Function} componentWrapper.template - function that will return the dom-bindings template function
  6459. * @param {Object} componentWrapper.exports - component interface
  6460. * @param {string} componentWrapper.name - component name
  6461. * @returns {Object} component like interface
  6462. */
  6463. function createComponent(componentWrapper) {
  6464. const {
  6465. css,
  6466. template,
  6467. exports,
  6468. name
  6469. } = componentWrapper;
  6470. const templateFn = template ? componentTemplateFactory(template, componentWrapper) : MOCKED_TEMPLATE_INTERFACE;
  6471. return _ref2 => {
  6472. let {
  6473. slots,
  6474. attributes,
  6475. props
  6476. } = _ref2;
  6477. // pure components rendering will be managed by the end user
  6478. if (exports && exports[IS_PURE_SYMBOL]) return createPureComponent(exports, {
  6479. slots,
  6480. attributes,
  6481. props,
  6482. css,
  6483. template
  6484. });
  6485. const componentAPI = callOrAssign(exports) || {};
  6486. const component = defineComponent({
  6487. css,
  6488. template: templateFn,
  6489. componentAPI,
  6490. name
  6491. })({
  6492. slots,
  6493. attributes,
  6494. props
  6495. }); // notice that for the components create via tag binding
  6496. // we need to invert the mount (state/parentScope) arguments
  6497. // the template bindings will only forward the parentScope updates
  6498. // and never deal with the component state
  6499. return {
  6500. mount(element, parentScope, state) {
  6501. return component.mount(element, state, parentScope);
  6502. },
  6503. update(parentScope, state) {
  6504. return component.update(state, parentScope);
  6505. },
  6506. unmount(preserveRoot) {
  6507. return component.unmount(preserveRoot);
  6508. }
  6509. };
  6510. };
  6511. }
  6512. /**
  6513. * Component definition function
  6514. * @param {Object} implementation - the componen implementation will be generated via compiler
  6515. * @param {Object} component - the component initial properties
  6516. * @returns {Object} a new component implementation object
  6517. */
  6518. function defineComponent(_ref3) {
  6519. let {
  6520. css,
  6521. template,
  6522. componentAPI,
  6523. name
  6524. } = _ref3;
  6525. // add the component css into the DOM
  6526. if (css && name) cssManager.add(name, css);
  6527. return curry(enhanceComponentAPI)(defineProperties( // set the component defaults without overriding the original component API
  6528. defineDefaults(componentAPI, Object.assign({}, COMPONENT_LIFECYCLE_METHODS, {
  6529. [PROPS_KEY]: {},
  6530. [STATE_KEY]: {}
  6531. })), Object.assign({
  6532. // defined during the component creation
  6533. [SLOTS_KEY]: null,
  6534. [ROOT_KEY]: null
  6535. }, COMPONENT_CORE_HELPERS, {
  6536. name,
  6537. css,
  6538. template
  6539. })));
  6540. }
  6541. /**
  6542. * Create the bindings to update the component attributes
  6543. * @param {HTMLElement} node - node where we will bind the expressions
  6544. * @param {Array} attributes - list of attribute bindings
  6545. * @returns {TemplateChunk} - template bindings object
  6546. */
  6547. function createAttributeBindings(node, attributes) {
  6548. if (attributes === void 0) {
  6549. attributes = [];
  6550. }
  6551. const expressions = attributes.map(a => create$4(node, a));
  6552. const binding = {};
  6553. return Object.assign(binding, Object.assign({
  6554. expressions
  6555. }, createCoreAPIMethods(method => scope => {
  6556. expressions.forEach(e => e[method](scope));
  6557. return binding;
  6558. })));
  6559. }
  6560. /**
  6561. * Create the subcomponents that can be included inside a tag in runtime
  6562. * @param {Object} components - components imported in runtime
  6563. * @returns {Object} all the components transformed into Riot.Component factory functions
  6564. */
  6565. function createSubcomponents(components) {
  6566. if (components === void 0) {
  6567. components = {};
  6568. }
  6569. return Object.entries(callOrAssign(components)).reduce((acc, _ref4) => {
  6570. let [key, value] = _ref4;
  6571. acc[camelToDashCase(key)] = createComponent(value);
  6572. return acc;
  6573. }, {});
  6574. }
  6575. /**
  6576. * Run the component instance through all the plugins set by the user
  6577. * @param {Object} component - component instance
  6578. * @returns {Object} the component enhanced by the plugins
  6579. */
  6580. function runPlugins(component) {
  6581. return [...PLUGINS_SET$1].reduce((c, fn) => fn(c) || c, component);
  6582. }
  6583. /**
  6584. * Compute the component current state merging it with its previous state
  6585. * @param {Object} oldState - previous state object
  6586. * @param {Object} newState - new state givent to the `update` call
  6587. * @returns {Object} new object state
  6588. */
  6589. function computeState(oldState, newState) {
  6590. return Object.assign({}, oldState, callOrAssign(newState));
  6591. }
  6592. /**
  6593. * Add eventually the "is" attribute to link this DOM node to its css
  6594. * @param {HTMLElement} element - target root node
  6595. * @param {string} name - name of the component mounted
  6596. * @returns {undefined} it's a void function
  6597. */
  6598. function addCssHook(element, name) {
  6599. if (getName(element) !== name) {
  6600. set(element, IS_DIRECTIVE, name);
  6601. }
  6602. }
  6603. /**
  6604. * Component creation factory function that will enhance the user provided API
  6605. * @param {Object} component - a component implementation previously defined
  6606. * @param {Array} options.slots - component slots generated via riot compiler
  6607. * @param {Array} options.attributes - attribute expressions generated via riot compiler
  6608. * @returns {Riot.Component} a riot component instance
  6609. */
  6610. function enhanceComponentAPI(component, _ref5) {
  6611. let {
  6612. slots,
  6613. attributes,
  6614. props
  6615. } = _ref5;
  6616. return autobindMethods(runPlugins(defineProperties(isObject(component) ? Object.create(component) : component, {
  6617. mount(element, state, parentScope) {
  6618. if (state === void 0) {
  6619. state = {};
  6620. }
  6621. this[PARENT_KEY_SYMBOL] = parentScope;
  6622. this[ATTRIBUTES_KEY_SYMBOL] = createAttributeBindings(element, attributes).mount(parentScope);
  6623. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, evaluateInitialProps(element, props), evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions))));
  6624. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  6625. this[TEMPLATE_KEY_SYMBOL] = this.template.createDOM(element).clone(); // link this object to the DOM node
  6626. bindDOMNodeToComponentObject(element, this); // add eventually the 'is' attribute
  6627. component.name && addCssHook(element, component.name); // define the root element
  6628. defineProperty(this, ROOT_KEY, element); // define the slots array
  6629. defineProperty(this, SLOTS_KEY, slots); // before mount lifecycle event
  6630. this[ON_BEFORE_MOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]); // mount the template
  6631. this[TEMPLATE_KEY_SYMBOL].mount(element, this, parentScope);
  6632. this[ON_MOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6633. return this;
  6634. },
  6635. update(state, parentScope) {
  6636. if (state === void 0) {
  6637. state = {};
  6638. }
  6639. if (parentScope) {
  6640. this[PARENT_KEY_SYMBOL] = parentScope;
  6641. this[ATTRIBUTES_KEY_SYMBOL].update(parentScope);
  6642. }
  6643. const newProps = evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions);
  6644. if (this[SHOULD_UPDATE_KEY](newProps, this[PROPS_KEY]) === false) return;
  6645. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, this[PROPS_KEY], newProps)));
  6646. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  6647. this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]); // avoiding recursive updates
  6648. // see also https://github.com/riot/riot/issues/2895
  6649. if (!this[IS_COMPONENT_UPDATING]) {
  6650. this[IS_COMPONENT_UPDATING] = true;
  6651. this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
  6652. }
  6653. this[ON_UPDATED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6654. this[IS_COMPONENT_UPDATING] = false;
  6655. return this;
  6656. },
  6657. unmount(preserveRoot) {
  6658. this[ON_BEFORE_UNMOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6659. this[ATTRIBUTES_KEY_SYMBOL].unmount(); // if the preserveRoot is null the template html will be left untouched
  6660. // in that case the DOM cleanup will happen differently from a parent node
  6661. this[TEMPLATE_KEY_SYMBOL].unmount(this, this[PARENT_KEY_SYMBOL], preserveRoot === null ? null : !preserveRoot);
  6662. this[ON_UNMOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  6663. return this;
  6664. }
  6665. })), Object.keys(component).filter(prop => isFunction(component[prop])));
  6666. }
  6667. /**
  6668. * Component initialization function starting from a DOM node
  6669. * @param {HTMLElement} element - element to upgrade
  6670. * @param {Object} initialProps - initial component properties
  6671. * @param {string} componentName - component id
  6672. * @returns {Object} a new component instance bound to a DOM node
  6673. */
  6674. function mountComponent(element, initialProps, componentName) {
  6675. const name = componentName || getName(element);
  6676. if (!COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component named "${name}" was never registered`);
  6677. const component = COMPONENTS_IMPLEMENTATION_MAP$1.get(name)({
  6678. props: initialProps
  6679. });
  6680. return component.mount(element);
  6681. }
  6682. /**
  6683. * Similar to compose but performs from left-to-right function composition.<br/>
  6684. * {@link https://30secondsofcode.org/function#composeright see also}
  6685. * @param {...[function]} fns) - list of unary function
  6686. * @returns {*} result of the computation
  6687. */
  6688. /**
  6689. * Performs right-to-left function composition.<br/>
  6690. * Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
  6691. * The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
  6692. * {@link https://30secondsofcode.org/function#compose original source code}
  6693. * @param {...[function]} fns) - list of unary function
  6694. * @returns {*} result of the computation
  6695. */
  6696. function compose() {
  6697. for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  6698. fns[_key2] = arguments[_key2];
  6699. }
  6700. return fns.reduce((f, g) => function () {
  6701. return f(g(...arguments));
  6702. });
  6703. }
  6704. const {
  6705. DOM_COMPONENT_INSTANCE_PROPERTY,
  6706. COMPONENTS_IMPLEMENTATION_MAP,
  6707. PLUGINS_SET
  6708. } = globals;
  6709. /**
  6710. * Riot public api
  6711. */
  6712. /**
  6713. * Register a custom tag by name
  6714. * @param {string} name - component name
  6715. * @param {Object} implementation - tag implementation
  6716. * @returns {Map} map containing all the components implementations
  6717. */
  6718. function register(name, _ref) {
  6719. let {
  6720. css,
  6721. template,
  6722. exports
  6723. } = _ref;
  6724. if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`);
  6725. COMPONENTS_IMPLEMENTATION_MAP.set(name, createComponent({
  6726. name,
  6727. css,
  6728. template,
  6729. exports
  6730. }));
  6731. return COMPONENTS_IMPLEMENTATION_MAP;
  6732. }
  6733. /**
  6734. * Unregister a riot web component
  6735. * @param {string} name - component name
  6736. * @returns {Map} map containing all the components implementations
  6737. */
  6738. function unregister(name) {
  6739. if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was never registered`);
  6740. COMPONENTS_IMPLEMENTATION_MAP.delete(name);
  6741. cssManager.remove(name);
  6742. return COMPONENTS_IMPLEMENTATION_MAP;
  6743. }
  6744. /**
  6745. * Mounting function that will work only for the components that were globally registered
  6746. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  6747. * @param {Object} initialProps - the initial component properties
  6748. * @param {string} name - optional component name
  6749. * @returns {Array} list of riot components
  6750. */
  6751. function mount(selector, initialProps, name) {
  6752. return $(selector).map(element => mountComponent(element, initialProps, name));
  6753. }
  6754. /**
  6755. * Sweet unmounting helper function for the DOM node mounted manually by the user
  6756. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  6757. * @param {boolean|null} keepRootElement - if true keep the root element
  6758. * @returns {Array} list of nodes unmounted
  6759. */
  6760. function unmount(selector, keepRootElement) {
  6761. return $(selector).map(element => {
  6762. if (element[DOM_COMPONENT_INSTANCE_PROPERTY]) {
  6763. element[DOM_COMPONENT_INSTANCE_PROPERTY].unmount(keepRootElement);
  6764. }
  6765. return element;
  6766. });
  6767. }
  6768. /**
  6769. * Define a riot plugin
  6770. * @param {Function} plugin - function that will receive all the components created
  6771. * @returns {Set} the set containing all the plugins installed
  6772. */
  6773. function install(plugin) {
  6774. if (!isFunction(plugin)) panic('Plugins must be of type function');
  6775. if (PLUGINS_SET.has(plugin)) panic('This plugin was already installed');
  6776. PLUGINS_SET.add(plugin);
  6777. return PLUGINS_SET;
  6778. }
  6779. /**
  6780. * Uninstall a riot plugin
  6781. * @param {Function} plugin - plugin previously installed
  6782. * @returns {Set} the set containing all the plugins installed
  6783. */
  6784. function uninstall(plugin) {
  6785. if (!PLUGINS_SET.has(plugin)) panic('This plugin was never installed');
  6786. PLUGINS_SET.delete(plugin);
  6787. return PLUGINS_SET;
  6788. }
  6789. /**
  6790. * Helper method to create component without relying on the registered ones
  6791. * @param {Object} implementation - component implementation
  6792. * @returns {Function} function that will allow you to mount a riot component on a DOM node
  6793. */
  6794. function component(implementation) {
  6795. return function (el, props, _temp) {
  6796. let {
  6797. slots,
  6798. attributes,
  6799. parentScope
  6800. } = _temp === void 0 ? {} : _temp;
  6801. return compose(c => c.mount(el, parentScope), c => c({
  6802. props,
  6803. slots,
  6804. attributes
  6805. }), createComponent)(implementation);
  6806. };
  6807. }
  6808. /**
  6809. * Lift a riot component Interface into a pure riot object
  6810. * @param {Function} func - RiotPureComponent factory function
  6811. * @returns {Function} the lifted original function received as argument
  6812. */
  6813. function pure(func) {
  6814. if (!isFunction(func)) panic('riot.pure accepts only arguments of type "function"');
  6815. func[IS_PURE_SYMBOL] = true;
  6816. return func;
  6817. }
  6818. /**
  6819. * no-op function needed to add the proper types to your component via typescript
  6820. * @param {Function|Object} component - component default export
  6821. * @returns {Function|Object} returns exactly what it has received
  6822. */
  6823. const withTypes = component => component;
  6824. /** @type {string} current riot version */
  6825. const version = 'v6.0.1'; // expose some internal stuff that might be used from external tools
  6826. const __ = {
  6827. cssManager,
  6828. DOMBindings,
  6829. createComponent,
  6830. defineComponent,
  6831. globals
  6832. };
  6833. /***/ }),
  6834. /***/ "./node_modules/validate.js/validate.js":
  6835. /*!**********************************************!*\
  6836. !*** ./node_modules/validate.js/validate.js ***!
  6837. \**********************************************/
  6838. /***/ (function(module, exports, __webpack_require__) {
  6839. /* module decorator */ module = __webpack_require__.nmd(module);
  6840. /*!
  6841. * validate.js 0.13.1
  6842. *
  6843. * (c) 2013-2019 Nicklas Ansman, 2013 Wrapp
  6844. * Validate.js may be freely distributed under the MIT license.
  6845. * For all details and documentation:
  6846. * http://validatejs.org/
  6847. */
  6848. (function(exports, module, define) {
  6849. "use strict";
  6850. // The main function that calls the validators specified by the constraints.
  6851. // The options are the following:
  6852. // - format (string) - An option that controls how the returned value is formatted
  6853. // * flat - Returns a flat array of just the error messages
  6854. // * grouped - Returns the messages grouped by attribute (default)
  6855. // * detailed - Returns an array of the raw validation data
  6856. // - fullMessages (boolean) - If `true` (default) the attribute name is prepended to the error.
  6857. //
  6858. // Please note that the options are also passed to each validator.
  6859. var validate = function(attributes, constraints, options) {
  6860. options = v.extend({}, v.options, options);
  6861. var results = v.runValidations(attributes, constraints, options)
  6862. , attr
  6863. , validator;
  6864. if (results.some(function(r) { return v.isPromise(r.error); })) {
  6865. throw new Error("Use validate.async if you want support for promises");
  6866. }
  6867. return validate.processValidationResults(results, options);
  6868. };
  6869. var v = validate;
  6870. // Copies over attributes from one or more sources to a single destination.
  6871. // Very much similar to underscore's extend.
  6872. // The first argument is the target object and the remaining arguments will be
  6873. // used as sources.
  6874. v.extend = function(obj) {
  6875. [].slice.call(arguments, 1).forEach(function(source) {
  6876. for (var attr in source) {
  6877. obj[attr] = source[attr];
  6878. }
  6879. });
  6880. return obj;
  6881. };
  6882. v.extend(validate, {
  6883. // This is the version of the library as a semver.
  6884. // The toString function will allow it to be coerced into a string
  6885. version: {
  6886. major: 0,
  6887. minor: 13,
  6888. patch: 1,
  6889. metadata: null,
  6890. toString: function() {
  6891. var version = v.format("%{major}.%{minor}.%{patch}", v.version);
  6892. if (!v.isEmpty(v.version.metadata)) {
  6893. version += "+" + v.version.metadata;
  6894. }
  6895. return version;
  6896. }
  6897. },
  6898. // Below is the dependencies that are used in validate.js
  6899. // The constructor of the Promise implementation.
  6900. // If you are using Q.js, RSVP or any other A+ compatible implementation
  6901. // override this attribute to be the constructor of that promise.
  6902. // Since jQuery promises aren't A+ compatible they won't work.
  6903. Promise: typeof Promise !== "undefined" ? Promise : /* istanbul ignore next */ null,
  6904. EMPTY_STRING_REGEXP: /^\s*$/,
  6905. // Runs the validators specified by the constraints object.
  6906. // Will return an array of the format:
  6907. // [{attribute: "<attribute name>", error: "<validation result>"}, ...]
  6908. runValidations: function(attributes, constraints, options) {
  6909. var results = []
  6910. , attr
  6911. , validatorName
  6912. , value
  6913. , validators
  6914. , validator
  6915. , validatorOptions
  6916. , error;
  6917. if (v.isDomElement(attributes) || v.isJqueryElement(attributes)) {
  6918. attributes = v.collectFormValues(attributes);
  6919. }
  6920. // Loops through each constraints, finds the correct validator and run it.
  6921. for (attr in constraints) {
  6922. value = v.getDeepObjectValue(attributes, attr);
  6923. // This allows the constraints for an attribute to be a function.
  6924. // The function will be called with the value, attribute name, the complete dict of
  6925. // attributes as well as the options and constraints passed in.
  6926. // This is useful when you want to have different
  6927. // validations depending on the attribute value.
  6928. validators = v.result(constraints[attr], value, attributes, attr, options, constraints);
  6929. for (validatorName in validators) {
  6930. validator = v.validators[validatorName];
  6931. if (!validator) {
  6932. error = v.format("Unknown validator %{name}", {name: validatorName});
  6933. throw new Error(error);
  6934. }
  6935. validatorOptions = validators[validatorName];
  6936. // This allows the options to be a function. The function will be
  6937. // called with the value, attribute name, the complete dict of
  6938. // attributes as well as the options and constraints passed in.
  6939. // This is useful when you want to have different
  6940. // validations depending on the attribute value.
  6941. validatorOptions = v.result(validatorOptions, value, attributes, attr, options, constraints);
  6942. if (!validatorOptions) {
  6943. continue;
  6944. }
  6945. results.push({
  6946. attribute: attr,
  6947. value: value,
  6948. validator: validatorName,
  6949. globalOptions: options,
  6950. attributes: attributes,
  6951. options: validatorOptions,
  6952. error: validator.call(validator,
  6953. value,
  6954. validatorOptions,
  6955. attr,
  6956. attributes,
  6957. options)
  6958. });
  6959. }
  6960. }
  6961. return results;
  6962. },
  6963. // Takes the output from runValidations and converts it to the correct
  6964. // output format.
  6965. processValidationResults: function(errors, options) {
  6966. errors = v.pruneEmptyErrors(errors, options);
  6967. errors = v.expandMultipleErrors(errors, options);
  6968. errors = v.convertErrorMessages(errors, options);
  6969. var format = options.format || "grouped";
  6970. if (typeof v.formatters[format] === 'function') {
  6971. errors = v.formatters[format](errors);
  6972. } else {
  6973. throw new Error(v.format("Unknown format %{format}", options));
  6974. }
  6975. return v.isEmpty(errors) ? undefined : errors;
  6976. },
  6977. // Runs the validations with support for promises.
  6978. // This function will return a promise that is settled when all the
  6979. // validation promises have been completed.
  6980. // It can be called even if no validations returned a promise.
  6981. async: function(attributes, constraints, options) {
  6982. options = v.extend({}, v.async.options, options);
  6983. var WrapErrors = options.wrapErrors || function(errors) {
  6984. return errors;
  6985. };
  6986. // Removes unknown attributes
  6987. if (options.cleanAttributes !== false) {
  6988. attributes = v.cleanAttributes(attributes, constraints);
  6989. }
  6990. var results = v.runValidations(attributes, constraints, options);
  6991. return new v.Promise(function(resolve, reject) {
  6992. v.waitForResults(results).then(function() {
  6993. var errors = v.processValidationResults(results, options);
  6994. if (errors) {
  6995. reject(new WrapErrors(errors, options, attributes, constraints));
  6996. } else {
  6997. resolve(attributes);
  6998. }
  6999. }, function(err) {
  7000. reject(err);
  7001. });
  7002. });
  7003. },
  7004. single: function(value, constraints, options) {
  7005. options = v.extend({}, v.single.options, options, {
  7006. format: "flat",
  7007. fullMessages: false
  7008. });
  7009. return v({single: value}, {single: constraints}, options);
  7010. },
  7011. // Returns a promise that is resolved when all promises in the results array
  7012. // are settled. The promise returned from this function is always resolved,
  7013. // never rejected.
  7014. // This function modifies the input argument, it replaces the promises
  7015. // with the value returned from the promise.
  7016. waitForResults: function(results) {
  7017. // Create a sequence of all the results starting with a resolved promise.
  7018. return results.reduce(function(memo, result) {
  7019. // If this result isn't a promise skip it in the sequence.
  7020. if (!v.isPromise(result.error)) {
  7021. return memo;
  7022. }
  7023. return memo.then(function() {
  7024. return result.error.then(function(error) {
  7025. result.error = error || null;
  7026. });
  7027. });
  7028. }, new v.Promise(function(r) { r(); })); // A resolved promise
  7029. },
  7030. // If the given argument is a call: function the and: function return the value
  7031. // otherwise just return the value. Additional arguments will be passed as
  7032. // arguments to the function.
  7033. // Example:
  7034. // ```
  7035. // result('foo') // 'foo'
  7036. // result(Math.max, 1, 2) // 2
  7037. // ```
  7038. result: function(value) {
  7039. var args = [].slice.call(arguments, 1);
  7040. if (typeof value === 'function') {
  7041. value = value.apply(null, args);
  7042. }
  7043. return value;
  7044. },
  7045. // Checks if the value is a number. This function does not consider NaN a
  7046. // number like many other `isNumber` functions do.
  7047. isNumber: function(value) {
  7048. return typeof value === 'number' && !isNaN(value);
  7049. },
  7050. // Returns false if the object is not a function
  7051. isFunction: function(value) {
  7052. return typeof value === 'function';
  7053. },
  7054. // A simple check to verify that the value is an integer. Uses `isNumber`
  7055. // and a simple modulo check.
  7056. isInteger: function(value) {
  7057. return v.isNumber(value) && value % 1 === 0;
  7058. },
  7059. // Checks if the value is a boolean
  7060. isBoolean: function(value) {
  7061. return typeof value === 'boolean';
  7062. },
  7063. // Uses the `Object` function to check if the given argument is an object.
  7064. isObject: function(obj) {
  7065. return obj === Object(obj);
  7066. },
  7067. // Simply checks if the object is an instance of a date
  7068. isDate: function(obj) {
  7069. return obj instanceof Date;
  7070. },
  7071. // Returns false if the object is `null` of `undefined`
  7072. isDefined: function(obj) {
  7073. return obj !== null && obj !== undefined;
  7074. },
  7075. // Checks if the given argument is a promise. Anything with a `then`
  7076. // function is considered a promise.
  7077. isPromise: function(p) {
  7078. return !!p && v.isFunction(p.then);
  7079. },
  7080. isJqueryElement: function(o) {
  7081. return o && v.isString(o.jquery);
  7082. },
  7083. isDomElement: function(o) {
  7084. if (!o) {
  7085. return false;
  7086. }
  7087. if (!o.querySelectorAll || !o.querySelector) {
  7088. return false;
  7089. }
  7090. if (v.isObject(document) && o === document) {
  7091. return true;
  7092. }
  7093. // http://stackoverflow.com/a/384380/699304
  7094. /* istanbul ignore else */
  7095. if (typeof HTMLElement === "object") {
  7096. return o instanceof HTMLElement;
  7097. } else {
  7098. return o &&
  7099. typeof o === "object" &&
  7100. o !== null &&
  7101. o.nodeType === 1 &&
  7102. typeof o.nodeName === "string";
  7103. }
  7104. },
  7105. isEmpty: function(value) {
  7106. var attr;
  7107. // Null and undefined are empty
  7108. if (!v.isDefined(value)) {
  7109. return true;
  7110. }
  7111. // functions are non empty
  7112. if (v.isFunction(value)) {
  7113. return false;
  7114. }
  7115. // Whitespace only strings are empty
  7116. if (v.isString(value)) {
  7117. return v.EMPTY_STRING_REGEXP.test(value);
  7118. }
  7119. // For arrays we use the length property
  7120. if (v.isArray(value)) {
  7121. return value.length === 0;
  7122. }
  7123. // Dates have no attributes but aren't empty
  7124. if (v.isDate(value)) {
  7125. return false;
  7126. }
  7127. // If we find at least one property we consider it non empty
  7128. if (v.isObject(value)) {
  7129. for (attr in value) {
  7130. return false;
  7131. }
  7132. return true;
  7133. }
  7134. return false;
  7135. },
  7136. // Formats the specified strings with the given values like so:
  7137. // ```
  7138. // format("Foo: %{foo}", {foo: "bar"}) // "Foo bar"
  7139. // ```
  7140. // If you want to write %{...} without having it replaced simply
  7141. // prefix it with % like this `Foo: %%{foo}` and it will be returned
  7142. // as `"Foo: %{foo}"`
  7143. format: v.extend(function(str, vals) {
  7144. if (!v.isString(str)) {
  7145. return str;
  7146. }
  7147. return str.replace(v.format.FORMAT_REGEXP, function(m0, m1, m2) {
  7148. if (m1 === '%') {
  7149. return "%{" + m2 + "}";
  7150. } else {
  7151. return String(vals[m2]);
  7152. }
  7153. });
  7154. }, {
  7155. // Finds %{key} style patterns in the given string
  7156. FORMAT_REGEXP: /(%?)%\{([^\}]+)\}/g
  7157. }),
  7158. // "Prettifies" the given string.
  7159. // Prettifying means replacing [.\_-] with spaces as well as splitting
  7160. // camel case words.
  7161. prettify: function(str) {
  7162. if (v.isNumber(str)) {
  7163. // If there are more than 2 decimals round it to two
  7164. if ((str * 100) % 1 === 0) {
  7165. return "" + str;
  7166. } else {
  7167. return parseFloat(Math.round(str * 100) / 100).toFixed(2);
  7168. }
  7169. }
  7170. if (v.isArray(str)) {
  7171. return str.map(function(s) { return v.prettify(s); }).join(", ");
  7172. }
  7173. if (v.isObject(str)) {
  7174. if (!v.isDefined(str.toString)) {
  7175. return JSON.stringify(str);
  7176. }
  7177. return str.toString();
  7178. }
  7179. // Ensure the string is actually a string
  7180. str = "" + str;
  7181. return str
  7182. // Splits keys separated by periods
  7183. .replace(/([^\s])\.([^\s])/g, '$1 $2')
  7184. // Removes backslashes
  7185. .replace(/\\+/g, '')
  7186. // Replaces - and - with space
  7187. .replace(/[_-]/g, ' ')
  7188. // Splits camel cased words
  7189. .replace(/([a-z])([A-Z])/g, function(m0, m1, m2) {
  7190. return "" + m1 + " " + m2.toLowerCase();
  7191. })
  7192. .toLowerCase();
  7193. },
  7194. stringifyValue: function(value, options) {
  7195. var prettify = options && options.prettify || v.prettify;
  7196. return prettify(value);
  7197. },
  7198. isString: function(value) {
  7199. return typeof value === 'string';
  7200. },
  7201. isArray: function(value) {
  7202. return {}.toString.call(value) === '[object Array]';
  7203. },
  7204. // Checks if the object is a hash, which is equivalent to an object that
  7205. // is neither an array nor a function.
  7206. isHash: function(value) {
  7207. return v.isObject(value) && !v.isArray(value) && !v.isFunction(value);
  7208. },
  7209. contains: function(obj, value) {
  7210. if (!v.isDefined(obj)) {
  7211. return false;
  7212. }
  7213. if (v.isArray(obj)) {
  7214. return obj.indexOf(value) !== -1;
  7215. }
  7216. return value in obj;
  7217. },
  7218. unique: function(array) {
  7219. if (!v.isArray(array)) {
  7220. return array;
  7221. }
  7222. return array.filter(function(el, index, array) {
  7223. return array.indexOf(el) == index;
  7224. });
  7225. },
  7226. forEachKeyInKeypath: function(object, keypath, callback) {
  7227. if (!v.isString(keypath)) {
  7228. return undefined;
  7229. }
  7230. var key = ""
  7231. , i
  7232. , escape = false;
  7233. for (i = 0; i < keypath.length; ++i) {
  7234. switch (keypath[i]) {
  7235. case '.':
  7236. if (escape) {
  7237. escape = false;
  7238. key += '.';
  7239. } else {
  7240. object = callback(object, key, false);
  7241. key = "";
  7242. }
  7243. break;
  7244. case '\\':
  7245. if (escape) {
  7246. escape = false;
  7247. key += '\\';
  7248. } else {
  7249. escape = true;
  7250. }
  7251. break;
  7252. default:
  7253. escape = false;
  7254. key += keypath[i];
  7255. break;
  7256. }
  7257. }
  7258. return callback(object, key, true);
  7259. },
  7260. getDeepObjectValue: function(obj, keypath) {
  7261. if (!v.isObject(obj)) {
  7262. return undefined;
  7263. }
  7264. return v.forEachKeyInKeypath(obj, keypath, function(obj, key) {
  7265. if (v.isObject(obj)) {
  7266. return obj[key];
  7267. }
  7268. });
  7269. },
  7270. // This returns an object with all the values of the form.
  7271. // It uses the input name as key and the value as value
  7272. // So for example this:
  7273. // <input type="text" name="email" value="foo@bar.com" />
  7274. // would return:
  7275. // {email: "foo@bar.com"}
  7276. collectFormValues: function(form, options) {
  7277. var values = {}
  7278. , i
  7279. , j
  7280. , input
  7281. , inputs
  7282. , option
  7283. , value;
  7284. if (v.isJqueryElement(form)) {
  7285. form = form[0];
  7286. }
  7287. if (!form) {
  7288. return values;
  7289. }
  7290. options = options || {};
  7291. inputs = form.querySelectorAll("input[name], textarea[name]");
  7292. for (i = 0; i < inputs.length; ++i) {
  7293. input = inputs.item(i);
  7294. if (v.isDefined(input.getAttribute("data-ignored"))) {
  7295. continue;
  7296. }
  7297. var name = input.name.replace(/\./g, "\\\\.");
  7298. value = v.sanitizeFormValue(input.value, options);
  7299. if (input.type === "number") {
  7300. value = value ? +value : null;
  7301. } else if (input.type === "checkbox") {
  7302. if (input.attributes.value) {
  7303. if (!input.checked) {
  7304. value = values[name] || null;
  7305. }
  7306. } else {
  7307. value = input.checked;
  7308. }
  7309. } else if (input.type === "radio") {
  7310. if (!input.checked) {
  7311. value = values[name] || null;
  7312. }
  7313. }
  7314. values[name] = value;
  7315. }
  7316. inputs = form.querySelectorAll("select[name]");
  7317. for (i = 0; i < inputs.length; ++i) {
  7318. input = inputs.item(i);
  7319. if (v.isDefined(input.getAttribute("data-ignored"))) {
  7320. continue;
  7321. }
  7322. if (input.multiple) {
  7323. value = [];
  7324. for (j in input.options) {
  7325. option = input.options[j];
  7326. if (option && option.selected) {
  7327. value.push(v.sanitizeFormValue(option.value, options));
  7328. }
  7329. }
  7330. } else {
  7331. var _val = typeof input.options[input.selectedIndex] !== 'undefined' ? input.options[input.selectedIndex].value : /* istanbul ignore next */ '';
  7332. value = v.sanitizeFormValue(_val, options);
  7333. }
  7334. values[input.name] = value;
  7335. }
  7336. return values;
  7337. },
  7338. sanitizeFormValue: function(value, options) {
  7339. if (options.trim && v.isString(value)) {
  7340. value = value.trim();
  7341. }
  7342. if (options.nullify !== false && value === "") {
  7343. return null;
  7344. }
  7345. return value;
  7346. },
  7347. capitalize: function(str) {
  7348. if (!v.isString(str)) {
  7349. return str;
  7350. }
  7351. return str[0].toUpperCase() + str.slice(1);
  7352. },
  7353. // Remove all errors who's error attribute is empty (null or undefined)
  7354. pruneEmptyErrors: function(errors) {
  7355. return errors.filter(function(error) {
  7356. return !v.isEmpty(error.error);
  7357. });
  7358. },
  7359. // In
  7360. // [{error: ["err1", "err2"], ...}]
  7361. // Out
  7362. // [{error: "err1", ...}, {error: "err2", ...}]
  7363. //
  7364. // All attributes in an error with multiple messages are duplicated
  7365. // when expanding the errors.
  7366. expandMultipleErrors: function(errors) {
  7367. var ret = [];
  7368. errors.forEach(function(error) {
  7369. // Removes errors without a message
  7370. if (v.isArray(error.error)) {
  7371. error.error.forEach(function(msg) {
  7372. ret.push(v.extend({}, error, {error: msg}));
  7373. });
  7374. } else {
  7375. ret.push(error);
  7376. }
  7377. });
  7378. return ret;
  7379. },
  7380. // Converts the error mesages by prepending the attribute name unless the
  7381. // message is prefixed by ^
  7382. convertErrorMessages: function(errors, options) {
  7383. options = options || {};
  7384. var ret = []
  7385. , prettify = options.prettify || v.prettify;
  7386. errors.forEach(function(errorInfo) {
  7387. var error = v.result(errorInfo.error,
  7388. errorInfo.value,
  7389. errorInfo.attribute,
  7390. errorInfo.options,
  7391. errorInfo.attributes,
  7392. errorInfo.globalOptions);
  7393. if (!v.isString(error)) {
  7394. ret.push(errorInfo);
  7395. return;
  7396. }
  7397. if (error[0] === '^') {
  7398. error = error.slice(1);
  7399. } else if (options.fullMessages !== false) {
  7400. error = v.capitalize(prettify(errorInfo.attribute)) + " " + error;
  7401. }
  7402. error = error.replace(/\\\^/g, "^");
  7403. error = v.format(error, {
  7404. value: v.stringifyValue(errorInfo.value, options)
  7405. });
  7406. ret.push(v.extend({}, errorInfo, {error: error}));
  7407. });
  7408. return ret;
  7409. },
  7410. // In:
  7411. // [{attribute: "<attributeName>", ...}]
  7412. // Out:
  7413. // {"<attributeName>": [{attribute: "<attributeName>", ...}]}
  7414. groupErrorsByAttribute: function(errors) {
  7415. var ret = {};
  7416. errors.forEach(function(error) {
  7417. var list = ret[error.attribute];
  7418. if (list) {
  7419. list.push(error);
  7420. } else {
  7421. ret[error.attribute] = [error];
  7422. }
  7423. });
  7424. return ret;
  7425. },
  7426. // In:
  7427. // [{error: "<message 1>", ...}, {error: "<message 2>", ...}]
  7428. // Out:
  7429. // ["<message 1>", "<message 2>"]
  7430. flattenErrorsToArray: function(errors) {
  7431. return errors
  7432. .map(function(error) { return error.error; })
  7433. .filter(function(value, index, self) {
  7434. return self.indexOf(value) === index;
  7435. });
  7436. },
  7437. cleanAttributes: function(attributes, whitelist) {
  7438. function whitelistCreator(obj, key, last) {
  7439. if (v.isObject(obj[key])) {
  7440. return obj[key];
  7441. }
  7442. return (obj[key] = last ? true : {});
  7443. }
  7444. function buildObjectWhitelist(whitelist) {
  7445. var ow = {}
  7446. , lastObject
  7447. , attr;
  7448. for (attr in whitelist) {
  7449. if (!whitelist[attr]) {
  7450. continue;
  7451. }
  7452. v.forEachKeyInKeypath(ow, attr, whitelistCreator);
  7453. }
  7454. return ow;
  7455. }
  7456. function cleanRecursive(attributes, whitelist) {
  7457. if (!v.isObject(attributes)) {
  7458. return attributes;
  7459. }
  7460. var ret = v.extend({}, attributes)
  7461. , w
  7462. , attribute;
  7463. for (attribute in attributes) {
  7464. w = whitelist[attribute];
  7465. if (v.isObject(w)) {
  7466. ret[attribute] = cleanRecursive(ret[attribute], w);
  7467. } else if (!w) {
  7468. delete ret[attribute];
  7469. }
  7470. }
  7471. return ret;
  7472. }
  7473. if (!v.isObject(whitelist) || !v.isObject(attributes)) {
  7474. return {};
  7475. }
  7476. whitelist = buildObjectWhitelist(whitelist);
  7477. return cleanRecursive(attributes, whitelist);
  7478. },
  7479. exposeModule: function(validate, root, exports, module, define) {
  7480. if (exports) {
  7481. if (module && module.exports) {
  7482. exports = module.exports = validate;
  7483. }
  7484. exports.validate = validate;
  7485. } else {
  7486. root.validate = validate;
  7487. if (validate.isFunction(define) && define.amd) {
  7488. define([], function () { return validate; });
  7489. }
  7490. }
  7491. },
  7492. warn: function(msg) {
  7493. if (typeof console !== "undefined" && console.warn) {
  7494. console.warn("[validate.js] " + msg);
  7495. }
  7496. },
  7497. error: function(msg) {
  7498. if (typeof console !== "undefined" && console.error) {
  7499. console.error("[validate.js] " + msg);
  7500. }
  7501. }
  7502. });
  7503. validate.validators = {
  7504. // Presence validates that the value isn't empty
  7505. presence: function(value, options) {
  7506. options = v.extend({}, this.options, options);
  7507. if (options.allowEmpty !== false ? !v.isDefined(value) : v.isEmpty(value)) {
  7508. return options.message || this.message || "can't be blank";
  7509. }
  7510. },
  7511. length: function(value, options, attribute) {
  7512. // Empty values are allowed
  7513. if (!v.isDefined(value)) {
  7514. return;
  7515. }
  7516. options = v.extend({}, this.options, options);
  7517. var is = options.is
  7518. , maximum = options.maximum
  7519. , minimum = options.minimum
  7520. , tokenizer = options.tokenizer || function(val) { return val; }
  7521. , err
  7522. , errors = [];
  7523. value = tokenizer(value);
  7524. var length = value.length;
  7525. if(!v.isNumber(length)) {
  7526. return options.message || this.notValid || "has an incorrect length";
  7527. }
  7528. // Is checks
  7529. if (v.isNumber(is) && length !== is) {
  7530. err = options.wrongLength ||
  7531. this.wrongLength ||
  7532. "is the wrong length (should be %{count} characters)";
  7533. errors.push(v.format(err, {count: is}));
  7534. }
  7535. if (v.isNumber(minimum) && length < minimum) {
  7536. err = options.tooShort ||
  7537. this.tooShort ||
  7538. "is too short (minimum is %{count} characters)";
  7539. errors.push(v.format(err, {count: minimum}));
  7540. }
  7541. if (v.isNumber(maximum) && length > maximum) {
  7542. err = options.tooLong ||
  7543. this.tooLong ||
  7544. "is too long (maximum is %{count} characters)";
  7545. errors.push(v.format(err, {count: maximum}));
  7546. }
  7547. if (errors.length > 0) {
  7548. return options.message || errors;
  7549. }
  7550. },
  7551. numericality: function(value, options, attribute, attributes, globalOptions) {
  7552. // Empty values are fine
  7553. if (!v.isDefined(value)) {
  7554. return;
  7555. }
  7556. options = v.extend({}, this.options, options);
  7557. var errors = []
  7558. , name
  7559. , count
  7560. , checks = {
  7561. greaterThan: function(v, c) { return v > c; },
  7562. greaterThanOrEqualTo: function(v, c) { return v >= c; },
  7563. equalTo: function(v, c) { return v === c; },
  7564. lessThan: function(v, c) { return v < c; },
  7565. lessThanOrEqualTo: function(v, c) { return v <= c; },
  7566. divisibleBy: function(v, c) { return v % c === 0; }
  7567. }
  7568. , prettify = options.prettify ||
  7569. (globalOptions && globalOptions.prettify) ||
  7570. v.prettify;
  7571. // Strict will check that it is a valid looking number
  7572. if (v.isString(value) && options.strict) {
  7573. var pattern = "^-?(0|[1-9]\\d*)";
  7574. if (!options.onlyInteger) {
  7575. pattern += "(\\.\\d+)?";
  7576. }
  7577. pattern += "$";
  7578. if (!(new RegExp(pattern).test(value))) {
  7579. return options.message ||
  7580. options.notValid ||
  7581. this.notValid ||
  7582. this.message ||
  7583. "must be a valid number";
  7584. }
  7585. }
  7586. // Coerce the value to a number unless we're being strict.
  7587. if (options.noStrings !== true && v.isString(value) && !v.isEmpty(value)) {
  7588. value = +value;
  7589. }
  7590. // If it's not a number we shouldn't continue since it will compare it.
  7591. if (!v.isNumber(value)) {
  7592. return options.message ||
  7593. options.notValid ||
  7594. this.notValid ||
  7595. this.message ||
  7596. "is not a number";
  7597. }
  7598. // Same logic as above, sort of. Don't bother with comparisons if this
  7599. // doesn't pass.
  7600. if (options.onlyInteger && !v.isInteger(value)) {
  7601. return options.message ||
  7602. options.notInteger ||
  7603. this.notInteger ||
  7604. this.message ||
  7605. "must be an integer";
  7606. }
  7607. for (name in checks) {
  7608. count = options[name];
  7609. if (v.isNumber(count) && !checks[name](value, count)) {
  7610. // This picks the default message if specified
  7611. // For example the greaterThan check uses the message from
  7612. // this.notGreaterThan so we capitalize the name and prepend "not"
  7613. var key = "not" + v.capitalize(name);
  7614. var msg = options[key] ||
  7615. this[key] ||
  7616. this.message ||
  7617. "must be %{type} %{count}";
  7618. errors.push(v.format(msg, {
  7619. count: count,
  7620. type: prettify(name)
  7621. }));
  7622. }
  7623. }
  7624. if (options.odd && value % 2 !== 1) {
  7625. errors.push(options.notOdd ||
  7626. this.notOdd ||
  7627. this.message ||
  7628. "must be odd");
  7629. }
  7630. if (options.even && value % 2 !== 0) {
  7631. errors.push(options.notEven ||
  7632. this.notEven ||
  7633. this.message ||
  7634. "must be even");
  7635. }
  7636. if (errors.length) {
  7637. return options.message || errors;
  7638. }
  7639. },
  7640. datetime: v.extend(function(value, options) {
  7641. if (!v.isFunction(this.parse) || !v.isFunction(this.format)) {
  7642. throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");
  7643. }
  7644. // Empty values are fine
  7645. if (!v.isDefined(value)) {
  7646. return;
  7647. }
  7648. options = v.extend({}, this.options, options);
  7649. var err
  7650. , errors = []
  7651. , earliest = options.earliest ? this.parse(options.earliest, options) : NaN
  7652. , latest = options.latest ? this.parse(options.latest, options) : NaN;
  7653. value = this.parse(value, options);
  7654. // 86400000 is the number of milliseconds in a day, this is used to remove
  7655. // the time from the date
  7656. if (isNaN(value) || options.dateOnly && value % 86400000 !== 0) {
  7657. err = options.notValid ||
  7658. options.message ||
  7659. this.notValid ||
  7660. "must be a valid date";
  7661. return v.format(err, {value: arguments[0]});
  7662. }
  7663. if (!isNaN(earliest) && value < earliest) {
  7664. err = options.tooEarly ||
  7665. options.message ||
  7666. this.tooEarly ||
  7667. "must be no earlier than %{date}";
  7668. err = v.format(err, {
  7669. value: this.format(value, options),
  7670. date: this.format(earliest, options)
  7671. });
  7672. errors.push(err);
  7673. }
  7674. if (!isNaN(latest) && value > latest) {
  7675. err = options.tooLate ||
  7676. options.message ||
  7677. this.tooLate ||
  7678. "must be no later than %{date}";
  7679. err = v.format(err, {
  7680. date: this.format(latest, options),
  7681. value: this.format(value, options)
  7682. });
  7683. errors.push(err);
  7684. }
  7685. if (errors.length) {
  7686. return v.unique(errors);
  7687. }
  7688. }, {
  7689. parse: null,
  7690. format: null
  7691. }),
  7692. date: function(value, options) {
  7693. options = v.extend({}, options, {dateOnly: true});
  7694. return v.validators.datetime.call(v.validators.datetime, value, options);
  7695. },
  7696. format: function(value, options) {
  7697. if (v.isString(options) || (options instanceof RegExp)) {
  7698. options = {pattern: options};
  7699. }
  7700. options = v.extend({}, this.options, options);
  7701. var message = options.message || this.message || "is invalid"
  7702. , pattern = options.pattern
  7703. , match;
  7704. // Empty values are allowed
  7705. if (!v.isDefined(value)) {
  7706. return;
  7707. }
  7708. if (!v.isString(value)) {
  7709. return message;
  7710. }
  7711. if (v.isString(pattern)) {
  7712. pattern = new RegExp(options.pattern, options.flags);
  7713. }
  7714. match = pattern.exec(value);
  7715. if (!match || match[0].length != value.length) {
  7716. return message;
  7717. }
  7718. },
  7719. inclusion: function(value, options) {
  7720. // Empty values are fine
  7721. if (!v.isDefined(value)) {
  7722. return;
  7723. }
  7724. if (v.isArray(options)) {
  7725. options = {within: options};
  7726. }
  7727. options = v.extend({}, this.options, options);
  7728. if (v.contains(options.within, value)) {
  7729. return;
  7730. }
  7731. var message = options.message ||
  7732. this.message ||
  7733. "^%{value} is not included in the list";
  7734. return v.format(message, {value: value});
  7735. },
  7736. exclusion: function(value, options) {
  7737. // Empty values are fine
  7738. if (!v.isDefined(value)) {
  7739. return;
  7740. }
  7741. if (v.isArray(options)) {
  7742. options = {within: options};
  7743. }
  7744. options = v.extend({}, this.options, options);
  7745. if (!v.contains(options.within, value)) {
  7746. return;
  7747. }
  7748. var message = options.message || this.message || "^%{value} is restricted";
  7749. if (v.isString(options.within[value])) {
  7750. value = options.within[value];
  7751. }
  7752. return v.format(message, {value: value});
  7753. },
  7754. email: v.extend(function(value, options) {
  7755. options = v.extend({}, this.options, options);
  7756. var message = options.message || this.message || "is not a valid email";
  7757. // Empty values are fine
  7758. if (!v.isDefined(value)) {
  7759. return;
  7760. }
  7761. if (!v.isString(value)) {
  7762. return message;
  7763. }
  7764. if (!this.PATTERN.exec(value)) {
  7765. return message;
  7766. }
  7767. }, {
  7768. PATTERN: /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i
  7769. }),
  7770. equality: function(value, options, attribute, attributes, globalOptions) {
  7771. if (!v.isDefined(value)) {
  7772. return;
  7773. }
  7774. if (v.isString(options)) {
  7775. options = {attribute: options};
  7776. }
  7777. options = v.extend({}, this.options, options);
  7778. var message = options.message ||
  7779. this.message ||
  7780. "is not equal to %{attribute}";
  7781. if (v.isEmpty(options.attribute) || !v.isString(options.attribute)) {
  7782. throw new Error("The attribute must be a non empty string");
  7783. }
  7784. var otherValue = v.getDeepObjectValue(attributes, options.attribute)
  7785. , comparator = options.comparator || function(v1, v2) {
  7786. return v1 === v2;
  7787. }
  7788. , prettify = options.prettify ||
  7789. (globalOptions && globalOptions.prettify) ||
  7790. v.prettify;
  7791. if (!comparator(value, otherValue, options, attribute, attributes)) {
  7792. return v.format(message, {attribute: prettify(options.attribute)});
  7793. }
  7794. },
  7795. // A URL validator that is used to validate URLs with the ability to
  7796. // restrict schemes and some domains.
  7797. url: function(value, options) {
  7798. if (!v.isDefined(value)) {
  7799. return;
  7800. }
  7801. options = v.extend({}, this.options, options);
  7802. var message = options.message || this.message || "is not a valid url"
  7803. , schemes = options.schemes || this.schemes || ['http', 'https']
  7804. , allowLocal = options.allowLocal || this.allowLocal || false
  7805. , allowDataUrl = options.allowDataUrl || this.allowDataUrl || false;
  7806. if (!v.isString(value)) {
  7807. return message;
  7808. }
  7809. // https://gist.github.com/dperini/729294
  7810. var regex =
  7811. "^" +
  7812. // protocol identifier
  7813. "(?:(?:" + schemes.join("|") + ")://)" +
  7814. // user:pass authentication
  7815. "(?:\\S+(?::\\S*)?@)?" +
  7816. "(?:";
  7817. var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
  7818. if (allowLocal) {
  7819. tld += "?";
  7820. } else {
  7821. regex +=
  7822. // IP address exclusion
  7823. // private & local networks
  7824. "(?!(?:10|127)(?:\\.\\d{1,3}){3})" +
  7825. "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" +
  7826. "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})";
  7827. }
  7828. regex +=
  7829. // IP address dotted notation octets
  7830. // excludes loopback network 0.0.0.0
  7831. // excludes reserved space >= 224.0.0.0
  7832. // excludes network & broacast addresses
  7833. // (first & last IP address of each class)
  7834. "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
  7835. "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
  7836. "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
  7837. "|" +
  7838. // host name
  7839. "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)" +
  7840. // domain name
  7841. "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*" +
  7842. tld +
  7843. ")" +
  7844. // port number
  7845. "(?::\\d{2,5})?" +
  7846. // resource path
  7847. "(?:[/?#]\\S*)?" +
  7848. "$";
  7849. if (allowDataUrl) {
  7850. // RFC 2397
  7851. var mediaType = "\\w+\\/[-+.\\w]+(?:;[\\w=]+)*";
  7852. var urlchar = "[A-Za-z0-9-_.!~\\*'();\\/?:@&=+$,%]*";
  7853. var dataurl = "data:(?:"+mediaType+")?(?:;base64)?,"+urlchar;
  7854. regex = "(?:"+regex+")|(?:^"+dataurl+"$)";
  7855. }
  7856. var PATTERN = new RegExp(regex, 'i');
  7857. if (!PATTERN.exec(value)) {
  7858. return message;
  7859. }
  7860. },
  7861. type: v.extend(function(value, originalOptions, attribute, attributes, globalOptions) {
  7862. if (v.isString(originalOptions)) {
  7863. originalOptions = {type: originalOptions};
  7864. }
  7865. if (!v.isDefined(value)) {
  7866. return;
  7867. }
  7868. var options = v.extend({}, this.options, originalOptions);
  7869. var type = options.type;
  7870. if (!v.isDefined(type)) {
  7871. throw new Error("No type was specified");
  7872. }
  7873. var check;
  7874. if (v.isFunction(type)) {
  7875. check = type;
  7876. } else {
  7877. check = this.types[type];
  7878. }
  7879. if (!v.isFunction(check)) {
  7880. throw new Error("validate.validators.type.types." + type + " must be a function.");
  7881. }
  7882. if (!check(value, options, attribute, attributes, globalOptions)) {
  7883. var message = originalOptions.message ||
  7884. this.messages[type] ||
  7885. this.message ||
  7886. options.message ||
  7887. (v.isFunction(type) ? "must be of the correct type" : "must be of type %{type}");
  7888. if (v.isFunction(message)) {
  7889. message = message(value, originalOptions, attribute, attributes, globalOptions);
  7890. }
  7891. return v.format(message, {attribute: v.prettify(attribute), type: type});
  7892. }
  7893. }, {
  7894. types: {
  7895. object: function(value) {
  7896. return v.isObject(value) && !v.isArray(value);
  7897. },
  7898. array: v.isArray,
  7899. integer: v.isInteger,
  7900. number: v.isNumber,
  7901. string: v.isString,
  7902. date: v.isDate,
  7903. boolean: v.isBoolean
  7904. },
  7905. messages: {}
  7906. })
  7907. };
  7908. validate.formatters = {
  7909. detailed: function(errors) {return errors;},
  7910. flat: v.flattenErrorsToArray,
  7911. grouped: function(errors) {
  7912. var attr;
  7913. errors = v.groupErrorsByAttribute(errors);
  7914. for (attr in errors) {
  7915. errors[attr] = v.flattenErrorsToArray(errors[attr]);
  7916. }
  7917. return errors;
  7918. },
  7919. constraint: function(errors) {
  7920. var attr;
  7921. errors = v.groupErrorsByAttribute(errors);
  7922. for (attr in errors) {
  7923. errors[attr] = errors[attr].map(function(result) {
  7924. return result.validator;
  7925. }).sort();
  7926. }
  7927. return errors;
  7928. }
  7929. };
  7930. validate.exposeModule(validate, this, exports, module, __webpack_require__.amdD);
  7931. }).call(this,
  7932. true ? /* istanbul ignore next */ exports : 0,
  7933. true ? /* istanbul ignore next */ module : 0,
  7934. __webpack_require__.amdD);
  7935. /***/ })
  7936. /******/ });
  7937. /************************************************************************/
  7938. /******/ // The module cache
  7939. /******/ var __webpack_module_cache__ = {};
  7940. /******/
  7941. /******/ // The require function
  7942. /******/ function __webpack_require__(moduleId) {
  7943. /******/ // Check if module is in cache
  7944. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  7945. /******/ if (cachedModule !== undefined) {
  7946. /******/ return cachedModule.exports;
  7947. /******/ }
  7948. /******/ // Create a new module (and put it into the cache)
  7949. /******/ var module = __webpack_module_cache__[moduleId] = {
  7950. /******/ id: moduleId,
  7951. /******/ loaded: false,
  7952. /******/ exports: {}
  7953. /******/ };
  7954. /******/
  7955. /******/ // Execute the module function
  7956. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  7957. /******/
  7958. /******/ // Flag the module as loaded
  7959. /******/ module.loaded = true;
  7960. /******/
  7961. /******/ // Return the exports of the module
  7962. /******/ return module.exports;
  7963. /******/ }
  7964. /******/
  7965. /************************************************************************/
  7966. /******/ /* webpack/runtime/amd define */
  7967. /******/ (() => {
  7968. /******/ __webpack_require__.amdD = function () {
  7969. /******/ throw new Error('define cannot be used indirect');
  7970. /******/ };
  7971. /******/ })();
  7972. /******/
  7973. /******/ /* webpack/runtime/compat get default export */
  7974. /******/ (() => {
  7975. /******/ // getDefaultExport function for compatibility with non-harmony modules
  7976. /******/ __webpack_require__.n = (module) => {
  7977. /******/ var getter = module && module.__esModule ?
  7978. /******/ () => (module['default']) :
  7979. /******/ () => (module);
  7980. /******/ __webpack_require__.d(getter, { a: getter });
  7981. /******/ return getter;
  7982. /******/ };
  7983. /******/ })();
  7984. /******/
  7985. /******/ /* webpack/runtime/define property getters */
  7986. /******/ (() => {
  7987. /******/ // define getter functions for harmony exports
  7988. /******/ __webpack_require__.d = (exports, definition) => {
  7989. /******/ for(var key in definition) {
  7990. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  7991. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  7992. /******/ }
  7993. /******/ }
  7994. /******/ };
  7995. /******/ })();
  7996. /******/
  7997. /******/ /* webpack/runtime/global */
  7998. /******/ (() => {
  7999. /******/ __webpack_require__.g = (function() {
  8000. /******/ if (typeof globalThis === 'object') return globalThis;
  8001. /******/ try {
  8002. /******/ return this || new Function('return this')();
  8003. /******/ } catch (e) {
  8004. /******/ if (typeof window === 'object') return window;
  8005. /******/ }
  8006. /******/ })();
  8007. /******/ })();
  8008. /******/
  8009. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  8010. /******/ (() => {
  8011. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  8012. /******/ })();
  8013. /******/
  8014. /******/ /* webpack/runtime/make namespace object */
  8015. /******/ (() => {
  8016. /******/ // define __esModule on exports
  8017. /******/ __webpack_require__.r = (exports) => {
  8018. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  8019. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  8020. /******/ }
  8021. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  8022. /******/ };
  8023. /******/ })();
  8024. /******/
  8025. /******/ /* webpack/runtime/node module decorator */
  8026. /******/ (() => {
  8027. /******/ __webpack_require__.nmd = (module) => {
  8028. /******/ module.paths = [];
  8029. /******/ if (!module.children) module.children = [];
  8030. /******/ return module;
  8031. /******/ };
  8032. /******/ })();
  8033. /******/
  8034. /************************************************************************/
  8035. var __webpack_exports__ = {};
  8036. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  8037. (() => {
  8038. "use strict";
  8039. /*!*******************************!*\
  8040. !*** ./resources/js/users.js ***!
  8041. \*******************************/
  8042. __webpack_require__.r(__webpack_exports__);
  8043. /* harmony import */ var riot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js");
  8044. /* harmony import */ var _components_users_riot__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/users.riot */ "./resources/js/components/users.riot");
  8045. /* harmony import */ var _components_users_form_riot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/users/form.riot */ "./resources/js/components/users/form.riot");
  8046. // register components for buckets
  8047. riot__WEBPACK_IMPORTED_MODULE_2__.register('app-users', _components_users_riot__WEBPACK_IMPORTED_MODULE_0__.default);
  8048. riot__WEBPACK_IMPORTED_MODULE_2__.mount('app-users');
  8049. riot__WEBPACK_IMPORTED_MODULE_2__.register('app-users-form', _components_users_form_riot__WEBPACK_IMPORTED_MODULE_1__.default);
  8050. riot__WEBPACK_IMPORTED_MODULE_2__.mount('app-users-form');
  8051. })();
  8052. /******/ })()
  8053. ;