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.

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