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.

4788 lines
141 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./node_modules/axios/index.js":
  4. /*!*************************************!*\
  5. !*** ./node_modules/axios/index.js ***!
  6. \*************************************/
  7. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  9. /***/ }),
  10. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  11. /*!************************************************!*\
  12. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  13. \************************************************/
  14. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  15. "use strict";
  16. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  17. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  18. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  19. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  20. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  21. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  22. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  23. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  24. module.exports = function xhrAdapter(config) {
  25. return new Promise(function dispatchXhrRequest(resolve, reject) {
  26. var requestData = config.data;
  27. var requestHeaders = config.headers;
  28. if (utils.isFormData(requestData)) {
  29. delete requestHeaders['Content-Type']; // Let the browser set it
  30. }
  31. var request = new XMLHttpRequest();
  32. // HTTP basic authentication
  33. if (config.auth) {
  34. var username = config.auth.username || '';
  35. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  36. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  37. }
  38. var fullPath = buildFullPath(config.baseURL, config.url);
  39. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  40. // Set the request timeout in MS
  41. request.timeout = config.timeout;
  42. // Listen for ready state
  43. request.onreadystatechange = function handleLoad() {
  44. if (!request || request.readyState !== 4) {
  45. return;
  46. }
  47. // The request errored out and we didn't get a response, this will be
  48. // handled by onerror instead
  49. // With one exception: request that using file: protocol, most browsers
  50. // will return status as 0 even though it's a successful request
  51. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  52. return;
  53. }
  54. // Prepare the response
  55. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  56. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  57. var response = {
  58. data: responseData,
  59. status: request.status,
  60. statusText: request.statusText,
  61. headers: responseHeaders,
  62. config: config,
  63. request: request
  64. };
  65. settle(resolve, reject, response);
  66. // Clean up request
  67. request = null;
  68. };
  69. // Handle browser request cancellation (as opposed to a manual cancellation)
  70. request.onabort = function handleAbort() {
  71. if (!request) {
  72. return;
  73. }
  74. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  75. // Clean up request
  76. request = null;
  77. };
  78. // Handle low level network errors
  79. request.onerror = function handleError() {
  80. // Real errors are hidden from us by the browser
  81. // onerror should only fire if it's a network error
  82. reject(createError('Network Error', config, null, request));
  83. // Clean up request
  84. request = null;
  85. };
  86. // Handle timeout
  87. request.ontimeout = function handleTimeout() {
  88. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  89. if (config.timeoutErrorMessage) {
  90. timeoutErrorMessage = config.timeoutErrorMessage;
  91. }
  92. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  93. request));
  94. // Clean up request
  95. request = null;
  96. };
  97. // Add xsrf header
  98. // This is only done if running in a standard browser environment.
  99. // Specifically not if we're in a web worker, or react-native.
  100. if (utils.isStandardBrowserEnv()) {
  101. // Add xsrf header
  102. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  103. cookies.read(config.xsrfCookieName) :
  104. undefined;
  105. if (xsrfValue) {
  106. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  107. }
  108. }
  109. // Add headers to the request
  110. if ('setRequestHeader' in request) {
  111. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  112. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  113. // Remove Content-Type if data is undefined
  114. delete requestHeaders[key];
  115. } else {
  116. // Otherwise add header to the request
  117. request.setRequestHeader(key, val);
  118. }
  119. });
  120. }
  121. // Add withCredentials to request if needed
  122. if (!utils.isUndefined(config.withCredentials)) {
  123. request.withCredentials = !!config.withCredentials;
  124. }
  125. // Add responseType to request if needed
  126. if (config.responseType) {
  127. try {
  128. request.responseType = config.responseType;
  129. } catch (e) {
  130. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  131. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  132. if (config.responseType !== 'json') {
  133. throw e;
  134. }
  135. }
  136. }
  137. // Handle progress if needed
  138. if (typeof config.onDownloadProgress === 'function') {
  139. request.addEventListener('progress', config.onDownloadProgress);
  140. }
  141. // Not all browsers support upload events
  142. if (typeof config.onUploadProgress === 'function' && request.upload) {
  143. request.upload.addEventListener('progress', config.onUploadProgress);
  144. }
  145. if (config.cancelToken) {
  146. // Handle cancellation
  147. config.cancelToken.promise.then(function onCanceled(cancel) {
  148. if (!request) {
  149. return;
  150. }
  151. request.abort();
  152. reject(cancel);
  153. // Clean up request
  154. request = null;
  155. });
  156. }
  157. if (!requestData) {
  158. requestData = null;
  159. }
  160. // Send the request
  161. request.send(requestData);
  162. });
  163. };
  164. /***/ }),
  165. /***/ "./node_modules/axios/lib/axios.js":
  166. /*!*****************************************!*\
  167. !*** ./node_modules/axios/lib/axios.js ***!
  168. \*****************************************/
  169. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  170. "use strict";
  171. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  172. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  173. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  174. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  175. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  176. /**
  177. * Create an instance of Axios
  178. *
  179. * @param {Object} defaultConfig The default config for the instance
  180. * @return {Axios} A new instance of Axios
  181. */
  182. function createInstance(defaultConfig) {
  183. var context = new Axios(defaultConfig);
  184. var instance = bind(Axios.prototype.request, context);
  185. // Copy axios.prototype to instance
  186. utils.extend(instance, Axios.prototype, context);
  187. // Copy context to instance
  188. utils.extend(instance, context);
  189. return instance;
  190. }
  191. // Create the default instance to be exported
  192. var axios = createInstance(defaults);
  193. // Expose Axios class to allow class inheritance
  194. axios.Axios = Axios;
  195. // Factory for creating new instances
  196. axios.create = function create(instanceConfig) {
  197. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  198. };
  199. // Expose Cancel & CancelToken
  200. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  201. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  202. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  203. // Expose all/spread
  204. axios.all = function all(promises) {
  205. return Promise.all(promises);
  206. };
  207. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  208. // Expose isAxiosError
  209. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  210. module.exports = axios;
  211. // Allow use of default import syntax in TypeScript
  212. module.exports.default = axios;
  213. /***/ }),
  214. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  215. /*!*************************************************!*\
  216. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  217. \*************************************************/
  218. /***/ ((module) => {
  219. "use strict";
  220. /**
  221. * A `Cancel` is an object that is thrown when an operation is canceled.
  222. *
  223. * @class
  224. * @param {string=} message The message.
  225. */
  226. function Cancel(message) {
  227. this.message = message;
  228. }
  229. Cancel.prototype.toString = function toString() {
  230. return 'Cancel' + (this.message ? ': ' + this.message : '');
  231. };
  232. Cancel.prototype.__CANCEL__ = true;
  233. module.exports = Cancel;
  234. /***/ }),
  235. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  236. /*!******************************************************!*\
  237. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  238. \******************************************************/
  239. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  240. "use strict";
  241. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  242. /**
  243. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  244. *
  245. * @class
  246. * @param {Function} executor The executor function.
  247. */
  248. function CancelToken(executor) {
  249. if (typeof executor !== 'function') {
  250. throw new TypeError('executor must be a function.');
  251. }
  252. var resolvePromise;
  253. this.promise = new Promise(function promiseExecutor(resolve) {
  254. resolvePromise = resolve;
  255. });
  256. var token = this;
  257. executor(function cancel(message) {
  258. if (token.reason) {
  259. // Cancellation has already been requested
  260. return;
  261. }
  262. token.reason = new Cancel(message);
  263. resolvePromise(token.reason);
  264. });
  265. }
  266. /**
  267. * Throws a `Cancel` if cancellation has been requested.
  268. */
  269. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  270. if (this.reason) {
  271. throw this.reason;
  272. }
  273. };
  274. /**
  275. * Returns an object that contains a new `CancelToken` and a function that, when called,
  276. * cancels the `CancelToken`.
  277. */
  278. CancelToken.source = function source() {
  279. var cancel;
  280. var token = new CancelToken(function executor(c) {
  281. cancel = c;
  282. });
  283. return {
  284. token: token,
  285. cancel: cancel
  286. };
  287. };
  288. module.exports = CancelToken;
  289. /***/ }),
  290. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  291. /*!***************************************************!*\
  292. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  293. \***************************************************/
  294. /***/ ((module) => {
  295. "use strict";
  296. module.exports = function isCancel(value) {
  297. return !!(value && value.__CANCEL__);
  298. };
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/core/Axios.js":
  301. /*!**********************************************!*\
  302. !*** ./node_modules/axios/lib/core/Axios.js ***!
  303. \**********************************************/
  304. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  305. "use strict";
  306. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  307. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  308. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  309. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  310. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  311. /**
  312. * Create a new instance of Axios
  313. *
  314. * @param {Object} instanceConfig The default config for the instance
  315. */
  316. function Axios(instanceConfig) {
  317. this.defaults = instanceConfig;
  318. this.interceptors = {
  319. request: new InterceptorManager(),
  320. response: new InterceptorManager()
  321. };
  322. }
  323. /**
  324. * Dispatch a request
  325. *
  326. * @param {Object} config The config specific for this request (merged with this.defaults)
  327. */
  328. Axios.prototype.request = function request(config) {
  329. /*eslint no-param-reassign:0*/
  330. // Allow for axios('example/url'[, config]) a la fetch API
  331. if (typeof config === 'string') {
  332. config = arguments[1] || {};
  333. config.url = arguments[0];
  334. } else {
  335. config = config || {};
  336. }
  337. config = mergeConfig(this.defaults, config);
  338. // Set config.method
  339. if (config.method) {
  340. config.method = config.method.toLowerCase();
  341. } else if (this.defaults.method) {
  342. config.method = this.defaults.method.toLowerCase();
  343. } else {
  344. config.method = 'get';
  345. }
  346. // Hook up interceptors middleware
  347. var chain = [dispatchRequest, undefined];
  348. var promise = Promise.resolve(config);
  349. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  350. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  351. });
  352. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  353. chain.push(interceptor.fulfilled, interceptor.rejected);
  354. });
  355. while (chain.length) {
  356. promise = promise.then(chain.shift(), chain.shift());
  357. }
  358. return promise;
  359. };
  360. Axios.prototype.getUri = function getUri(config) {
  361. config = mergeConfig(this.defaults, config);
  362. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  363. };
  364. // Provide aliases for supported request methods
  365. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  366. /*eslint func-names:0*/
  367. Axios.prototype[method] = function(url, config) {
  368. return this.request(mergeConfig(config || {}, {
  369. method: method,
  370. url: url,
  371. data: (config || {}).data
  372. }));
  373. };
  374. });
  375. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  376. /*eslint func-names:0*/
  377. Axios.prototype[method] = function(url, data, config) {
  378. return this.request(mergeConfig(config || {}, {
  379. method: method,
  380. url: url,
  381. data: data
  382. }));
  383. };
  384. });
  385. module.exports = Axios;
  386. /***/ }),
  387. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  388. /*!***********************************************************!*\
  389. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  390. \***********************************************************/
  391. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  392. "use strict";
  393. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  394. function InterceptorManager() {
  395. this.handlers = [];
  396. }
  397. /**
  398. * Add a new interceptor to the stack
  399. *
  400. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  401. * @param {Function} rejected The function to handle `reject` for a `Promise`
  402. *
  403. * @return {Number} An ID used to remove interceptor later
  404. */
  405. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  406. this.handlers.push({
  407. fulfilled: fulfilled,
  408. rejected: rejected
  409. });
  410. return this.handlers.length - 1;
  411. };
  412. /**
  413. * Remove an interceptor from the stack
  414. *
  415. * @param {Number} id The ID that was returned by `use`
  416. */
  417. InterceptorManager.prototype.eject = function eject(id) {
  418. if (this.handlers[id]) {
  419. this.handlers[id] = null;
  420. }
  421. };
  422. /**
  423. * Iterate over all the registered interceptors
  424. *
  425. * This method is particularly useful for skipping over any
  426. * interceptors that may have become `null` calling `eject`.
  427. *
  428. * @param {Function} fn The function to call for each interceptor
  429. */
  430. InterceptorManager.prototype.forEach = function forEach(fn) {
  431. utils.forEach(this.handlers, function forEachHandler(h) {
  432. if (h !== null) {
  433. fn(h);
  434. }
  435. });
  436. };
  437. module.exports = InterceptorManager;
  438. /***/ }),
  439. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  440. /*!******************************************************!*\
  441. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  442. \******************************************************/
  443. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  444. "use strict";
  445. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  446. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  447. /**
  448. * Creates a new URL by combining the baseURL with the requestedURL,
  449. * only when the requestedURL is not already an absolute URL.
  450. * If the requestURL is absolute, this function returns the requestedURL untouched.
  451. *
  452. * @param {string} baseURL The base URL
  453. * @param {string} requestedURL Absolute or relative URL to combine
  454. * @returns {string} The combined full path
  455. */
  456. module.exports = function buildFullPath(baseURL, requestedURL) {
  457. if (baseURL && !isAbsoluteURL(requestedURL)) {
  458. return combineURLs(baseURL, requestedURL);
  459. }
  460. return requestedURL;
  461. };
  462. /***/ }),
  463. /***/ "./node_modules/axios/lib/core/createError.js":
  464. /*!****************************************************!*\
  465. !*** ./node_modules/axios/lib/core/createError.js ***!
  466. \****************************************************/
  467. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  468. "use strict";
  469. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  470. /**
  471. * Create an Error with the specified message, config, error code, request and response.
  472. *
  473. * @param {string} message The error message.
  474. * @param {Object} config The config.
  475. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  476. * @param {Object} [request] The request.
  477. * @param {Object} [response] The response.
  478. * @returns {Error} The created error.
  479. */
  480. module.exports = function createError(message, config, code, request, response) {
  481. var error = new Error(message);
  482. return enhanceError(error, config, code, request, response);
  483. };
  484. /***/ }),
  485. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  486. /*!********************************************************!*\
  487. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  488. \********************************************************/
  489. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  490. "use strict";
  491. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  492. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  493. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  494. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  495. /**
  496. * Throws a `Cancel` if cancellation has been requested.
  497. */
  498. function throwIfCancellationRequested(config) {
  499. if (config.cancelToken) {
  500. config.cancelToken.throwIfRequested();
  501. }
  502. }
  503. /**
  504. * Dispatch a request to the server using the configured adapter.
  505. *
  506. * @param {object} config The config that is to be used for the request
  507. * @returns {Promise} The Promise to be fulfilled
  508. */
  509. module.exports = function dispatchRequest(config) {
  510. throwIfCancellationRequested(config);
  511. // Ensure headers exist
  512. config.headers = config.headers || {};
  513. // Transform request data
  514. config.data = transformData(
  515. config.data,
  516. config.headers,
  517. config.transformRequest
  518. );
  519. // Flatten headers
  520. config.headers = utils.merge(
  521. config.headers.common || {},
  522. config.headers[config.method] || {},
  523. config.headers
  524. );
  525. utils.forEach(
  526. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  527. function cleanHeaderConfig(method) {
  528. delete config.headers[method];
  529. }
  530. );
  531. var adapter = config.adapter || defaults.adapter;
  532. return adapter(config).then(function onAdapterResolution(response) {
  533. throwIfCancellationRequested(config);
  534. // Transform response data
  535. response.data = transformData(
  536. response.data,
  537. response.headers,
  538. config.transformResponse
  539. );
  540. return response;
  541. }, function onAdapterRejection(reason) {
  542. if (!isCancel(reason)) {
  543. throwIfCancellationRequested(config);
  544. // Transform response data
  545. if (reason && reason.response) {
  546. reason.response.data = transformData(
  547. reason.response.data,
  548. reason.response.headers,
  549. config.transformResponse
  550. );
  551. }
  552. }
  553. return Promise.reject(reason);
  554. });
  555. };
  556. /***/ }),
  557. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  558. /*!*****************************************************!*\
  559. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  560. \*****************************************************/
  561. /***/ ((module) => {
  562. "use strict";
  563. /**
  564. * Update an Error with the specified config, error code, and response.
  565. *
  566. * @param {Error} error The error to update.
  567. * @param {Object} config The config.
  568. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  569. * @param {Object} [request] The request.
  570. * @param {Object} [response] The response.
  571. * @returns {Error} The error.
  572. */
  573. module.exports = function enhanceError(error, config, code, request, response) {
  574. error.config = config;
  575. if (code) {
  576. error.code = code;
  577. }
  578. error.request = request;
  579. error.response = response;
  580. error.isAxiosError = true;
  581. error.toJSON = function toJSON() {
  582. return {
  583. // Standard
  584. message: this.message,
  585. name: this.name,
  586. // Microsoft
  587. description: this.description,
  588. number: this.number,
  589. // Mozilla
  590. fileName: this.fileName,
  591. lineNumber: this.lineNumber,
  592. columnNumber: this.columnNumber,
  593. stack: this.stack,
  594. // Axios
  595. config: this.config,
  596. code: this.code
  597. };
  598. };
  599. return error;
  600. };
  601. /***/ }),
  602. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  603. /*!****************************************************!*\
  604. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  605. \****************************************************/
  606. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  607. "use strict";
  608. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  609. /**
  610. * Config-specific merge-function which creates a new config-object
  611. * by merging two configuration objects together.
  612. *
  613. * @param {Object} config1
  614. * @param {Object} config2
  615. * @returns {Object} New object resulting from merging config2 to config1
  616. */
  617. module.exports = function mergeConfig(config1, config2) {
  618. // eslint-disable-next-line no-param-reassign
  619. config2 = config2 || {};
  620. var config = {};
  621. var valueFromConfig2Keys = ['url', 'method', 'data'];
  622. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  623. var defaultToConfig2Keys = [
  624. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  625. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  626. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  627. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  628. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  629. ];
  630. var directMergeKeys = ['validateStatus'];
  631. function getMergedValue(target, source) {
  632. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  633. return utils.merge(target, source);
  634. } else if (utils.isPlainObject(source)) {
  635. return utils.merge({}, source);
  636. } else if (utils.isArray(source)) {
  637. return source.slice();
  638. }
  639. return source;
  640. }
  641. function mergeDeepProperties(prop) {
  642. if (!utils.isUndefined(config2[prop])) {
  643. config[prop] = getMergedValue(config1[prop], config2[prop]);
  644. } else if (!utils.isUndefined(config1[prop])) {
  645. config[prop] = getMergedValue(undefined, config1[prop]);
  646. }
  647. }
  648. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  649. if (!utils.isUndefined(config2[prop])) {
  650. config[prop] = getMergedValue(undefined, config2[prop]);
  651. }
  652. });
  653. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  654. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  655. if (!utils.isUndefined(config2[prop])) {
  656. config[prop] = getMergedValue(undefined, config2[prop]);
  657. } else if (!utils.isUndefined(config1[prop])) {
  658. config[prop] = getMergedValue(undefined, config1[prop]);
  659. }
  660. });
  661. utils.forEach(directMergeKeys, function merge(prop) {
  662. if (prop in config2) {
  663. config[prop] = getMergedValue(config1[prop], config2[prop]);
  664. } else if (prop in config1) {
  665. config[prop] = getMergedValue(undefined, config1[prop]);
  666. }
  667. });
  668. var axiosKeys = valueFromConfig2Keys
  669. .concat(mergeDeepPropertiesKeys)
  670. .concat(defaultToConfig2Keys)
  671. .concat(directMergeKeys);
  672. var otherKeys = Object
  673. .keys(config1)
  674. .concat(Object.keys(config2))
  675. .filter(function filterAxiosKeys(key) {
  676. return axiosKeys.indexOf(key) === -1;
  677. });
  678. utils.forEach(otherKeys, mergeDeepProperties);
  679. return config;
  680. };
  681. /***/ }),
  682. /***/ "./node_modules/axios/lib/core/settle.js":
  683. /*!***********************************************!*\
  684. !*** ./node_modules/axios/lib/core/settle.js ***!
  685. \***********************************************/
  686. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  687. "use strict";
  688. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  689. /**
  690. * Resolve or reject a Promise based on response status.
  691. *
  692. * @param {Function} resolve A function that resolves the promise.
  693. * @param {Function} reject A function that rejects the promise.
  694. * @param {object} response The response.
  695. */
  696. module.exports = function settle(resolve, reject, response) {
  697. var validateStatus = response.config.validateStatus;
  698. if (!response.status || !validateStatus || validateStatus(response.status)) {
  699. resolve(response);
  700. } else {
  701. reject(createError(
  702. 'Request failed with status code ' + response.status,
  703. response.config,
  704. null,
  705. response.request,
  706. response
  707. ));
  708. }
  709. };
  710. /***/ }),
  711. /***/ "./node_modules/axios/lib/core/transformData.js":
  712. /*!******************************************************!*\
  713. !*** ./node_modules/axios/lib/core/transformData.js ***!
  714. \******************************************************/
  715. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  716. "use strict";
  717. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  718. /**
  719. * Transform the data for a request or a response
  720. *
  721. * @param {Object|String} data The data to be transformed
  722. * @param {Array} headers The headers for the request or response
  723. * @param {Array|Function} fns A single function or Array of functions
  724. * @returns {*} The resulting transformed data
  725. */
  726. module.exports = function transformData(data, headers, fns) {
  727. /*eslint no-param-reassign:0*/
  728. utils.forEach(fns, function transform(fn) {
  729. data = fn(data, headers);
  730. });
  731. return data;
  732. };
  733. /***/ }),
  734. /***/ "./node_modules/axios/lib/defaults.js":
  735. /*!********************************************!*\
  736. !*** ./node_modules/axios/lib/defaults.js ***!
  737. \********************************************/
  738. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  739. "use strict";
  740. /* provided dependency */ var process = __webpack_require__(/*! process/browser */ "./node_modules/process/browser.js");
  741. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  742. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  743. var DEFAULT_CONTENT_TYPE = {
  744. 'Content-Type': 'application/x-www-form-urlencoded'
  745. };
  746. function setContentTypeIfUnset(headers, value) {
  747. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  748. headers['Content-Type'] = value;
  749. }
  750. }
  751. function getDefaultAdapter() {
  752. var adapter;
  753. if (typeof XMLHttpRequest !== 'undefined') {
  754. // For browsers use XHR adapter
  755. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  756. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  757. // For node use HTTP adapter
  758. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  759. }
  760. return adapter;
  761. }
  762. var defaults = {
  763. adapter: getDefaultAdapter(),
  764. transformRequest: [function transformRequest(data, headers) {
  765. normalizeHeaderName(headers, 'Accept');
  766. normalizeHeaderName(headers, 'Content-Type');
  767. if (utils.isFormData(data) ||
  768. utils.isArrayBuffer(data) ||
  769. utils.isBuffer(data) ||
  770. utils.isStream(data) ||
  771. utils.isFile(data) ||
  772. utils.isBlob(data)
  773. ) {
  774. return data;
  775. }
  776. if (utils.isArrayBufferView(data)) {
  777. return data.buffer;
  778. }
  779. if (utils.isURLSearchParams(data)) {
  780. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  781. return data.toString();
  782. }
  783. if (utils.isObject(data)) {
  784. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  785. return JSON.stringify(data);
  786. }
  787. return data;
  788. }],
  789. transformResponse: [function transformResponse(data) {
  790. /*eslint no-param-reassign:0*/
  791. if (typeof data === 'string') {
  792. try {
  793. data = JSON.parse(data);
  794. } catch (e) { /* Ignore */ }
  795. }
  796. return data;
  797. }],
  798. /**
  799. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  800. * timeout is not created.
  801. */
  802. timeout: 0,
  803. xsrfCookieName: 'XSRF-TOKEN',
  804. xsrfHeaderName: 'X-XSRF-TOKEN',
  805. maxContentLength: -1,
  806. maxBodyLength: -1,
  807. validateStatus: function validateStatus(status) {
  808. return status >= 200 && status < 300;
  809. }
  810. };
  811. defaults.headers = {
  812. common: {
  813. 'Accept': 'application/json, text/plain, */*'
  814. }
  815. };
  816. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  817. defaults.headers[method] = {};
  818. });
  819. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  820. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  821. });
  822. module.exports = defaults;
  823. /***/ }),
  824. /***/ "./node_modules/axios/lib/helpers/bind.js":
  825. /*!************************************************!*\
  826. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  827. \************************************************/
  828. /***/ ((module) => {
  829. "use strict";
  830. module.exports = function bind(fn, thisArg) {
  831. return function wrap() {
  832. var args = new Array(arguments.length);
  833. for (var i = 0; i < args.length; i++) {
  834. args[i] = arguments[i];
  835. }
  836. return fn.apply(thisArg, args);
  837. };
  838. };
  839. /***/ }),
  840. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  841. /*!****************************************************!*\
  842. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  843. \****************************************************/
  844. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  845. "use strict";
  846. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  847. function encode(val) {
  848. return encodeURIComponent(val).
  849. replace(/%3A/gi, ':').
  850. replace(/%24/g, '$').
  851. replace(/%2C/gi, ',').
  852. replace(/%20/g, '+').
  853. replace(/%5B/gi, '[').
  854. replace(/%5D/gi, ']');
  855. }
  856. /**
  857. * Build a URL by appending params to the end
  858. *
  859. * @param {string} url The base of the url (e.g., http://www.google.com)
  860. * @param {object} [params] The params to be appended
  861. * @returns {string} The formatted url
  862. */
  863. module.exports = function buildURL(url, params, paramsSerializer) {
  864. /*eslint no-param-reassign:0*/
  865. if (!params) {
  866. return url;
  867. }
  868. var serializedParams;
  869. if (paramsSerializer) {
  870. serializedParams = paramsSerializer(params);
  871. } else if (utils.isURLSearchParams(params)) {
  872. serializedParams = params.toString();
  873. } else {
  874. var parts = [];
  875. utils.forEach(params, function serialize(val, key) {
  876. if (val === null || typeof val === 'undefined') {
  877. return;
  878. }
  879. if (utils.isArray(val)) {
  880. key = key + '[]';
  881. } else {
  882. val = [val];
  883. }
  884. utils.forEach(val, function parseValue(v) {
  885. if (utils.isDate(v)) {
  886. v = v.toISOString();
  887. } else if (utils.isObject(v)) {
  888. v = JSON.stringify(v);
  889. }
  890. parts.push(encode(key) + '=' + encode(v));
  891. });
  892. });
  893. serializedParams = parts.join('&');
  894. }
  895. if (serializedParams) {
  896. var hashmarkIndex = url.indexOf('#');
  897. if (hashmarkIndex !== -1) {
  898. url = url.slice(0, hashmarkIndex);
  899. }
  900. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  901. }
  902. return url;
  903. };
  904. /***/ }),
  905. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  906. /*!*******************************************************!*\
  907. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  908. \*******************************************************/
  909. /***/ ((module) => {
  910. "use strict";
  911. /**
  912. * Creates a new URL by combining the specified URLs
  913. *
  914. * @param {string} baseURL The base URL
  915. * @param {string} relativeURL The relative URL
  916. * @returns {string} The combined URL
  917. */
  918. module.exports = function combineURLs(baseURL, relativeURL) {
  919. return relativeURL
  920. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  921. : baseURL;
  922. };
  923. /***/ }),
  924. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  925. /*!***************************************************!*\
  926. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  927. \***************************************************/
  928. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  929. "use strict";
  930. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  931. module.exports = (
  932. utils.isStandardBrowserEnv() ?
  933. // Standard browser envs support document.cookie
  934. (function standardBrowserEnv() {
  935. return {
  936. write: function write(name, value, expires, path, domain, secure) {
  937. var cookie = [];
  938. cookie.push(name + '=' + encodeURIComponent(value));
  939. if (utils.isNumber(expires)) {
  940. cookie.push('expires=' + new Date(expires).toGMTString());
  941. }
  942. if (utils.isString(path)) {
  943. cookie.push('path=' + path);
  944. }
  945. if (utils.isString(domain)) {
  946. cookie.push('domain=' + domain);
  947. }
  948. if (secure === true) {
  949. cookie.push('secure');
  950. }
  951. document.cookie = cookie.join('; ');
  952. },
  953. read: function read(name) {
  954. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  955. return (match ? decodeURIComponent(match[3]) : null);
  956. },
  957. remove: function remove(name) {
  958. this.write(name, '', Date.now() - 86400000);
  959. }
  960. };
  961. })() :
  962. // Non standard browser env (web workers, react-native) lack needed support.
  963. (function nonStandardBrowserEnv() {
  964. return {
  965. write: function write() {},
  966. read: function read() { return null; },
  967. remove: function remove() {}
  968. };
  969. })()
  970. );
  971. /***/ }),
  972. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  973. /*!*********************************************************!*\
  974. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  975. \*********************************************************/
  976. /***/ ((module) => {
  977. "use strict";
  978. /**
  979. * Determines whether the specified URL is absolute
  980. *
  981. * @param {string} url The URL to test
  982. * @returns {boolean} True if the specified URL is absolute, otherwise false
  983. */
  984. module.exports = function isAbsoluteURL(url) {
  985. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  986. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  987. // by any combination of letters, digits, plus, period, or hyphen.
  988. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  989. };
  990. /***/ }),
  991. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  992. /*!********************************************************!*\
  993. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  994. \********************************************************/
  995. /***/ ((module) => {
  996. "use strict";
  997. /**
  998. * Determines whether the payload is an error thrown by Axios
  999. *
  1000. * @param {*} payload The value to test
  1001. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1002. */
  1003. module.exports = function isAxiosError(payload) {
  1004. return (typeof payload === 'object') && (payload.isAxiosError === true);
  1005. };
  1006. /***/ }),
  1007. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1008. /*!***********************************************************!*\
  1009. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1010. \***********************************************************/
  1011. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1012. "use strict";
  1013. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1014. module.exports = (
  1015. utils.isStandardBrowserEnv() ?
  1016. // Standard browser envs have full support of the APIs needed to test
  1017. // whether the request URL is of the same origin as current location.
  1018. (function standardBrowserEnv() {
  1019. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1020. var urlParsingNode = document.createElement('a');
  1021. var originURL;
  1022. /**
  1023. * Parse a URL to discover it's components
  1024. *
  1025. * @param {String} url The URL to be parsed
  1026. * @returns {Object}
  1027. */
  1028. function resolveURL(url) {
  1029. var href = url;
  1030. if (msie) {
  1031. // IE needs attribute set twice to normalize properties
  1032. urlParsingNode.setAttribute('href', href);
  1033. href = urlParsingNode.href;
  1034. }
  1035. urlParsingNode.setAttribute('href', href);
  1036. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1037. return {
  1038. href: urlParsingNode.href,
  1039. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1040. host: urlParsingNode.host,
  1041. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1042. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1043. hostname: urlParsingNode.hostname,
  1044. port: urlParsingNode.port,
  1045. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1046. urlParsingNode.pathname :
  1047. '/' + urlParsingNode.pathname
  1048. };
  1049. }
  1050. originURL = resolveURL(window.location.href);
  1051. /**
  1052. * Determine if a URL shares the same origin as the current location
  1053. *
  1054. * @param {String} requestURL The URL to test
  1055. * @returns {boolean} True if URL shares the same origin, otherwise false
  1056. */
  1057. return function isURLSameOrigin(requestURL) {
  1058. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1059. return (parsed.protocol === originURL.protocol &&
  1060. parsed.host === originURL.host);
  1061. };
  1062. })() :
  1063. // Non standard browser envs (web workers, react-native) lack needed support.
  1064. (function nonStandardBrowserEnv() {
  1065. return function isURLSameOrigin() {
  1066. return true;
  1067. };
  1068. })()
  1069. );
  1070. /***/ }),
  1071. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1072. /*!***************************************************************!*\
  1073. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1074. \***************************************************************/
  1075. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1076. "use strict";
  1077. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1078. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1079. utils.forEach(headers, function processHeader(value, name) {
  1080. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1081. headers[normalizedName] = value;
  1082. delete headers[name];
  1083. }
  1084. });
  1085. };
  1086. /***/ }),
  1087. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1088. /*!********************************************************!*\
  1089. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1090. \********************************************************/
  1091. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1092. "use strict";
  1093. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1094. // Headers whose duplicates are ignored by node
  1095. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1096. var ignoreDuplicateOf = [
  1097. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1098. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1099. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1100. 'referer', 'retry-after', 'user-agent'
  1101. ];
  1102. /**
  1103. * Parse headers into an object
  1104. *
  1105. * ```
  1106. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1107. * Content-Type: application/json
  1108. * Connection: keep-alive
  1109. * Transfer-Encoding: chunked
  1110. * ```
  1111. *
  1112. * @param {String} headers Headers needing to be parsed
  1113. * @returns {Object} Headers parsed into an object
  1114. */
  1115. module.exports = function parseHeaders(headers) {
  1116. var parsed = {};
  1117. var key;
  1118. var val;
  1119. var i;
  1120. if (!headers) { return parsed; }
  1121. utils.forEach(headers.split('\n'), function parser(line) {
  1122. i = line.indexOf(':');
  1123. key = utils.trim(line.substr(0, i)).toLowerCase();
  1124. val = utils.trim(line.substr(i + 1));
  1125. if (key) {
  1126. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1127. return;
  1128. }
  1129. if (key === 'set-cookie') {
  1130. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1131. } else {
  1132. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1133. }
  1134. }
  1135. });
  1136. return parsed;
  1137. };
  1138. /***/ }),
  1139. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1140. /*!**************************************************!*\
  1141. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1142. \**************************************************/
  1143. /***/ ((module) => {
  1144. "use strict";
  1145. /**
  1146. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1147. *
  1148. * Common use case would be to use `Function.prototype.apply`.
  1149. *
  1150. * ```js
  1151. * function f(x, y, z) {}
  1152. * var args = [1, 2, 3];
  1153. * f.apply(null, args);
  1154. * ```
  1155. *
  1156. * With `spread` this example can be re-written.
  1157. *
  1158. * ```js
  1159. * spread(function(x, y, z) {})([1, 2, 3]);
  1160. * ```
  1161. *
  1162. * @param {Function} callback
  1163. * @returns {Function}
  1164. */
  1165. module.exports = function spread(callback) {
  1166. return function wrap(arr) {
  1167. return callback.apply(null, arr);
  1168. };
  1169. };
  1170. /***/ }),
  1171. /***/ "./node_modules/axios/lib/utils.js":
  1172. /*!*****************************************!*\
  1173. !*** ./node_modules/axios/lib/utils.js ***!
  1174. \*****************************************/
  1175. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1176. "use strict";
  1177. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1178. /*global toString:true*/
  1179. // utils is a library of generic helper functions non-specific to axios
  1180. var toString = Object.prototype.toString;
  1181. /**
  1182. * Determine if a value is an Array
  1183. *
  1184. * @param {Object} val The value to test
  1185. * @returns {boolean} True if value is an Array, otherwise false
  1186. */
  1187. function isArray(val) {
  1188. return toString.call(val) === '[object Array]';
  1189. }
  1190. /**
  1191. * Determine if a value is undefined
  1192. *
  1193. * @param {Object} val The value to test
  1194. * @returns {boolean} True if the value is undefined, otherwise false
  1195. */
  1196. function isUndefined(val) {
  1197. return typeof val === 'undefined';
  1198. }
  1199. /**
  1200. * Determine if a value is a Buffer
  1201. *
  1202. * @param {Object} val The value to test
  1203. * @returns {boolean} True if value is a Buffer, otherwise false
  1204. */
  1205. function isBuffer(val) {
  1206. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1207. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1208. }
  1209. /**
  1210. * Determine if a value is an ArrayBuffer
  1211. *
  1212. * @param {Object} val The value to test
  1213. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1214. */
  1215. function isArrayBuffer(val) {
  1216. return toString.call(val) === '[object ArrayBuffer]';
  1217. }
  1218. /**
  1219. * Determine if a value is a FormData
  1220. *
  1221. * @param {Object} val The value to test
  1222. * @returns {boolean} True if value is an FormData, otherwise false
  1223. */
  1224. function isFormData(val) {
  1225. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1226. }
  1227. /**
  1228. * Determine if a value is a view on an ArrayBuffer
  1229. *
  1230. * @param {Object} val The value to test
  1231. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1232. */
  1233. function isArrayBufferView(val) {
  1234. var result;
  1235. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1236. result = ArrayBuffer.isView(val);
  1237. } else {
  1238. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1239. }
  1240. return result;
  1241. }
  1242. /**
  1243. * Determine if a value is a String
  1244. *
  1245. * @param {Object} val The value to test
  1246. * @returns {boolean} True if value is a String, otherwise false
  1247. */
  1248. function isString(val) {
  1249. return typeof val === 'string';
  1250. }
  1251. /**
  1252. * Determine if a value is a Number
  1253. *
  1254. * @param {Object} val The value to test
  1255. * @returns {boolean} True if value is a Number, otherwise false
  1256. */
  1257. function isNumber(val) {
  1258. return typeof val === 'number';
  1259. }
  1260. /**
  1261. * Determine if a value is an Object
  1262. *
  1263. * @param {Object} val The value to test
  1264. * @returns {boolean} True if value is an Object, otherwise false
  1265. */
  1266. function isObject(val) {
  1267. return val !== null && typeof val === 'object';
  1268. }
  1269. /**
  1270. * Determine if a value is a plain Object
  1271. *
  1272. * @param {Object} val The value to test
  1273. * @return {boolean} True if value is a plain Object, otherwise false
  1274. */
  1275. function isPlainObject(val) {
  1276. if (toString.call(val) !== '[object Object]') {
  1277. return false;
  1278. }
  1279. var prototype = Object.getPrototypeOf(val);
  1280. return prototype === null || prototype === Object.prototype;
  1281. }
  1282. /**
  1283. * Determine if a value is a Date
  1284. *
  1285. * @param {Object} val The value to test
  1286. * @returns {boolean} True if value is a Date, otherwise false
  1287. */
  1288. function isDate(val) {
  1289. return toString.call(val) === '[object Date]';
  1290. }
  1291. /**
  1292. * Determine if a value is a File
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is a File, otherwise false
  1296. */
  1297. function isFile(val) {
  1298. return toString.call(val) === '[object File]';
  1299. }
  1300. /**
  1301. * Determine if a value is a Blob
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is a Blob, otherwise false
  1305. */
  1306. function isBlob(val) {
  1307. return toString.call(val) === '[object Blob]';
  1308. }
  1309. /**
  1310. * Determine if a value is a Function
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a Function, otherwise false
  1314. */
  1315. function isFunction(val) {
  1316. return toString.call(val) === '[object Function]';
  1317. }
  1318. /**
  1319. * Determine if a value is a Stream
  1320. *
  1321. * @param {Object} val The value to test
  1322. * @returns {boolean} True if value is a Stream, otherwise false
  1323. */
  1324. function isStream(val) {
  1325. return isObject(val) && isFunction(val.pipe);
  1326. }
  1327. /**
  1328. * Determine if a value is a URLSearchParams object
  1329. *
  1330. * @param {Object} val The value to test
  1331. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1332. */
  1333. function isURLSearchParams(val) {
  1334. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1335. }
  1336. /**
  1337. * Trim excess whitespace off the beginning and end of a string
  1338. *
  1339. * @param {String} str The String to trim
  1340. * @returns {String} The String freed of excess whitespace
  1341. */
  1342. function trim(str) {
  1343. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1344. }
  1345. /**
  1346. * Determine if we're running in a standard browser environment
  1347. *
  1348. * This allows axios to run in a web worker, and react-native.
  1349. * Both environments support XMLHttpRequest, but not fully standard globals.
  1350. *
  1351. * web workers:
  1352. * typeof window -> undefined
  1353. * typeof document -> undefined
  1354. *
  1355. * react-native:
  1356. * navigator.product -> 'ReactNative'
  1357. * nativescript
  1358. * navigator.product -> 'NativeScript' or 'NS'
  1359. */
  1360. function isStandardBrowserEnv() {
  1361. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1362. navigator.product === 'NativeScript' ||
  1363. navigator.product === 'NS')) {
  1364. return false;
  1365. }
  1366. return (
  1367. typeof window !== 'undefined' &&
  1368. typeof document !== 'undefined'
  1369. );
  1370. }
  1371. /**
  1372. * Iterate over an Array or an Object invoking a function for each item.
  1373. *
  1374. * If `obj` is an Array callback will be called passing
  1375. * the value, index, and complete array for each item.
  1376. *
  1377. * If 'obj' is an Object callback will be called passing
  1378. * the value, key, and complete object for each property.
  1379. *
  1380. * @param {Object|Array} obj The object to iterate
  1381. * @param {Function} fn The callback to invoke for each item
  1382. */
  1383. function forEach(obj, fn) {
  1384. // Don't bother if no value provided
  1385. if (obj === null || typeof obj === 'undefined') {
  1386. return;
  1387. }
  1388. // Force an array if not already something iterable
  1389. if (typeof obj !== 'object') {
  1390. /*eslint no-param-reassign:0*/
  1391. obj = [obj];
  1392. }
  1393. if (isArray(obj)) {
  1394. // Iterate over array values
  1395. for (var i = 0, l = obj.length; i < l; i++) {
  1396. fn.call(null, obj[i], i, obj);
  1397. }
  1398. } else {
  1399. // Iterate over object keys
  1400. for (var key in obj) {
  1401. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1402. fn.call(null, obj[key], key, obj);
  1403. }
  1404. }
  1405. }
  1406. }
  1407. /**
  1408. * Accepts varargs expecting each argument to be an object, then
  1409. * immutably merges the properties of each object and returns result.
  1410. *
  1411. * When multiple objects contain the same key the later object in
  1412. * the arguments list will take precedence.
  1413. *
  1414. * Example:
  1415. *
  1416. * ```js
  1417. * var result = merge({foo: 123}, {foo: 456});
  1418. * console.log(result.foo); // outputs 456
  1419. * ```
  1420. *
  1421. * @param {Object} obj1 Object to merge
  1422. * @returns {Object} Result of all merge properties
  1423. */
  1424. function merge(/* obj1, obj2, obj3, ... */) {
  1425. var result = {};
  1426. function assignValue(val, key) {
  1427. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1428. result[key] = merge(result[key], val);
  1429. } else if (isPlainObject(val)) {
  1430. result[key] = merge({}, val);
  1431. } else if (isArray(val)) {
  1432. result[key] = val.slice();
  1433. } else {
  1434. result[key] = val;
  1435. }
  1436. }
  1437. for (var i = 0, l = arguments.length; i < l; i++) {
  1438. forEach(arguments[i], assignValue);
  1439. }
  1440. return result;
  1441. }
  1442. /**
  1443. * Extends object a by mutably adding to it the properties of object b.
  1444. *
  1445. * @param {Object} a The object to be extended
  1446. * @param {Object} b The object to copy properties from
  1447. * @param {Object} thisArg The object to bind function to
  1448. * @return {Object} The resulting value of object a
  1449. */
  1450. function extend(a, b, thisArg) {
  1451. forEach(b, function assignValue(val, key) {
  1452. if (thisArg && typeof val === 'function') {
  1453. a[key] = bind(val, thisArg);
  1454. } else {
  1455. a[key] = val;
  1456. }
  1457. });
  1458. return a;
  1459. }
  1460. /**
  1461. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1462. *
  1463. * @param {string} content with BOM
  1464. * @return {string} content value without BOM
  1465. */
  1466. function stripBOM(content) {
  1467. if (content.charCodeAt(0) === 0xFEFF) {
  1468. content = content.slice(1);
  1469. }
  1470. return content;
  1471. }
  1472. module.exports = {
  1473. isArray: isArray,
  1474. isArrayBuffer: isArrayBuffer,
  1475. isBuffer: isBuffer,
  1476. isFormData: isFormData,
  1477. isArrayBufferView: isArrayBufferView,
  1478. isString: isString,
  1479. isNumber: isNumber,
  1480. isObject: isObject,
  1481. isPlainObject: isPlainObject,
  1482. isUndefined: isUndefined,
  1483. isDate: isDate,
  1484. isFile: isFile,
  1485. isBlob: isBlob,
  1486. isFunction: isFunction,
  1487. isStream: isStream,
  1488. isURLSearchParams: isURLSearchParams,
  1489. isStandardBrowserEnv: isStandardBrowserEnv,
  1490. forEach: forEach,
  1491. merge: merge,
  1492. extend: extend,
  1493. trim: trim,
  1494. stripBOM: stripBOM
  1495. };
  1496. /***/ }),
  1497. /***/ "./resources/js/index.js":
  1498. /*!*******************************!*\
  1499. !*** ./resources/js/index.js ***!
  1500. \*******************************/
  1501. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  1502. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  1503. window.riot = __webpack_require__(/*! riot */ "./node_modules/riot/riot.esm.js");
  1504. /***/ }),
  1505. /***/ "./resources/scss/index.scss":
  1506. /*!***********************************!*\
  1507. !*** ./resources/scss/index.scss ***!
  1508. \***********************************/
  1509. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1510. "use strict";
  1511. __webpack_require__.r(__webpack_exports__);
  1512. // extracted by mini-css-extract-plugin
  1513. /***/ }),
  1514. /***/ "./node_modules/process/browser.js":
  1515. /*!*****************************************!*\
  1516. !*** ./node_modules/process/browser.js ***!
  1517. \*****************************************/
  1518. /***/ ((module) => {
  1519. // shim for using process in browser
  1520. var process = module.exports = {};
  1521. // cached from whatever global is present so that test runners that stub it
  1522. // don't break things. But we need to wrap it in a try catch in case it is
  1523. // wrapped in strict mode code which doesn't define any globals. It's inside a
  1524. // function because try/catches deoptimize in certain engines.
  1525. var cachedSetTimeout;
  1526. var cachedClearTimeout;
  1527. function defaultSetTimout() {
  1528. throw new Error('setTimeout has not been defined');
  1529. }
  1530. function defaultClearTimeout () {
  1531. throw new Error('clearTimeout has not been defined');
  1532. }
  1533. (function () {
  1534. try {
  1535. if (typeof setTimeout === 'function') {
  1536. cachedSetTimeout = setTimeout;
  1537. } else {
  1538. cachedSetTimeout = defaultSetTimout;
  1539. }
  1540. } catch (e) {
  1541. cachedSetTimeout = defaultSetTimout;
  1542. }
  1543. try {
  1544. if (typeof clearTimeout === 'function') {
  1545. cachedClearTimeout = clearTimeout;
  1546. } else {
  1547. cachedClearTimeout = defaultClearTimeout;
  1548. }
  1549. } catch (e) {
  1550. cachedClearTimeout = defaultClearTimeout;
  1551. }
  1552. } ())
  1553. function runTimeout(fun) {
  1554. if (cachedSetTimeout === setTimeout) {
  1555. //normal enviroments in sane situations
  1556. return setTimeout(fun, 0);
  1557. }
  1558. // if setTimeout wasn't available but was latter defined
  1559. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  1560. cachedSetTimeout = setTimeout;
  1561. return setTimeout(fun, 0);
  1562. }
  1563. try {
  1564. // when when somebody has screwed with setTimeout but no I.E. maddness
  1565. return cachedSetTimeout(fun, 0);
  1566. } catch(e){
  1567. try {
  1568. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1569. return cachedSetTimeout.call(null, fun, 0);
  1570. } catch(e){
  1571. // 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
  1572. return cachedSetTimeout.call(this, fun, 0);
  1573. }
  1574. }
  1575. }
  1576. function runClearTimeout(marker) {
  1577. if (cachedClearTimeout === clearTimeout) {
  1578. //normal enviroments in sane situations
  1579. return clearTimeout(marker);
  1580. }
  1581. // if clearTimeout wasn't available but was latter defined
  1582. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  1583. cachedClearTimeout = clearTimeout;
  1584. return clearTimeout(marker);
  1585. }
  1586. try {
  1587. // when when somebody has screwed with setTimeout but no I.E. maddness
  1588. return cachedClearTimeout(marker);
  1589. } catch (e){
  1590. try {
  1591. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1592. return cachedClearTimeout.call(null, marker);
  1593. } catch (e){
  1594. // 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.
  1595. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  1596. return cachedClearTimeout.call(this, marker);
  1597. }
  1598. }
  1599. }
  1600. var queue = [];
  1601. var draining = false;
  1602. var currentQueue;
  1603. var queueIndex = -1;
  1604. function cleanUpNextTick() {
  1605. if (!draining || !currentQueue) {
  1606. return;
  1607. }
  1608. draining = false;
  1609. if (currentQueue.length) {
  1610. queue = currentQueue.concat(queue);
  1611. } else {
  1612. queueIndex = -1;
  1613. }
  1614. if (queue.length) {
  1615. drainQueue();
  1616. }
  1617. }
  1618. function drainQueue() {
  1619. if (draining) {
  1620. return;
  1621. }
  1622. var timeout = runTimeout(cleanUpNextTick);
  1623. draining = true;
  1624. var len = queue.length;
  1625. while(len) {
  1626. currentQueue = queue;
  1627. queue = [];
  1628. while (++queueIndex < len) {
  1629. if (currentQueue) {
  1630. currentQueue[queueIndex].run();
  1631. }
  1632. }
  1633. queueIndex = -1;
  1634. len = queue.length;
  1635. }
  1636. currentQueue = null;
  1637. draining = false;
  1638. runClearTimeout(timeout);
  1639. }
  1640. process.nextTick = function (fun) {
  1641. var args = new Array(arguments.length - 1);
  1642. if (arguments.length > 1) {
  1643. for (var i = 1; i < arguments.length; i++) {
  1644. args[i - 1] = arguments[i];
  1645. }
  1646. }
  1647. queue.push(new Item(fun, args));
  1648. if (queue.length === 1 && !draining) {
  1649. runTimeout(drainQueue);
  1650. }
  1651. };
  1652. // v8 likes predictible objects
  1653. function Item(fun, array) {
  1654. this.fun = fun;
  1655. this.array = array;
  1656. }
  1657. Item.prototype.run = function () {
  1658. this.fun.apply(null, this.array);
  1659. };
  1660. process.title = 'browser';
  1661. process.browser = true;
  1662. process.env = {};
  1663. process.argv = [];
  1664. process.version = ''; // empty string to avoid regexp issues
  1665. process.versions = {};
  1666. function noop() {}
  1667. process.on = noop;
  1668. process.addListener = noop;
  1669. process.once = noop;
  1670. process.off = noop;
  1671. process.removeListener = noop;
  1672. process.removeAllListeners = noop;
  1673. process.emit = noop;
  1674. process.prependListener = noop;
  1675. process.prependOnceListener = noop;
  1676. process.listeners = function (name) { return [] }
  1677. process.binding = function (name) {
  1678. throw new Error('process.binding is not supported');
  1679. };
  1680. process.cwd = function () { return '/' };
  1681. process.chdir = function (dir) {
  1682. throw new Error('process.chdir is not supported');
  1683. };
  1684. process.umask = function() { return 0; };
  1685. /***/ }),
  1686. /***/ "./node_modules/riot/riot.esm.js":
  1687. /*!***************************************!*\
  1688. !*** ./node_modules/riot/riot.esm.js ***!
  1689. \***************************************/
  1690. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1691. "use strict";
  1692. __webpack_require__.r(__webpack_exports__);
  1693. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1694. /* harmony export */ "__": () => (/* binding */ __),
  1695. /* harmony export */ "component": () => (/* binding */ component),
  1696. /* harmony export */ "install": () => (/* binding */ install),
  1697. /* harmony export */ "mount": () => (/* binding */ mount),
  1698. /* harmony export */ "pure": () => (/* binding */ pure),
  1699. /* harmony export */ "register": () => (/* binding */ register),
  1700. /* harmony export */ "uninstall": () => (/* binding */ uninstall),
  1701. /* harmony export */ "unmount": () => (/* binding */ unmount),
  1702. /* harmony export */ "unregister": () => (/* binding */ unregister),
  1703. /* harmony export */ "version": () => (/* binding */ version),
  1704. /* harmony export */ "withTypes": () => (/* binding */ withTypes)
  1705. /* harmony export */ });
  1706. /* Riot v6.0.1, @license MIT */
  1707. /**
  1708. * Convert a string from camel case to dash-case
  1709. * @param {string} string - probably a component tag name
  1710. * @returns {string} component name normalized
  1711. */
  1712. function camelToDashCase(string) {
  1713. return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
  1714. }
  1715. /**
  1716. * Convert a string containing dashes to camel case
  1717. * @param {string} string - input string
  1718. * @returns {string} my-string -> myString
  1719. */
  1720. function dashToCamelCase(string) {
  1721. return string.replace(/-(\w)/g, (_, c) => c.toUpperCase());
  1722. }
  1723. /**
  1724. * Get all the element attributes as object
  1725. * @param {HTMLElement} element - DOM node we want to parse
  1726. * @returns {Object} all the attributes found as a key value pairs
  1727. */
  1728. function DOMattributesToObject(element) {
  1729. return Array.from(element.attributes).reduce((acc, attribute) => {
  1730. acc[dashToCamelCase(attribute.name)] = attribute.value;
  1731. return acc;
  1732. }, {});
  1733. }
  1734. /**
  1735. * Move all the child nodes from a source tag to another
  1736. * @param {HTMLElement} source - source node
  1737. * @param {HTMLElement} target - target node
  1738. * @returns {undefined} it's a void method ¯\_()_/¯
  1739. */
  1740. // Ignore this helper because it's needed only for svg tags
  1741. function moveChildren(source, target) {
  1742. if (source.firstChild) {
  1743. target.appendChild(source.firstChild);
  1744. moveChildren(source, target);
  1745. }
  1746. }
  1747. /**
  1748. * Remove the child nodes from any DOM node
  1749. * @param {HTMLElement} node - target node
  1750. * @returns {undefined}
  1751. */
  1752. function cleanNode(node) {
  1753. clearChildren(node.childNodes);
  1754. }
  1755. /**
  1756. * Clear multiple children in a node
  1757. * @param {HTMLElement[]} children - direct children nodes
  1758. * @returns {undefined}
  1759. */
  1760. function clearChildren(children) {
  1761. Array.from(children).forEach(removeChild);
  1762. }
  1763. /**
  1764. * Remove a node
  1765. * @param {HTMLElement}node - node to remove
  1766. * @returns {undefined}
  1767. */
  1768. const removeChild = node => node && node.parentNode && node.parentNode.removeChild(node);
  1769. /**
  1770. * Insert before a node
  1771. * @param {HTMLElement} newNode - node to insert
  1772. * @param {HTMLElement} refNode - ref child
  1773. * @returns {undefined}
  1774. */
  1775. const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode);
  1776. /**
  1777. * Replace a node
  1778. * @param {HTMLElement} newNode - new node to add to the DOM
  1779. * @param {HTMLElement} replaced - node to replace
  1780. * @returns {undefined}
  1781. */
  1782. const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced);
  1783. // Riot.js constants that can be used accross more modules
  1784. const COMPONENTS_IMPLEMENTATION_MAP$1 = new Map(),
  1785. DOM_COMPONENT_INSTANCE_PROPERTY$1 = Symbol('riot-component'),
  1786. PLUGINS_SET$1 = new Set(),
  1787. IS_DIRECTIVE = 'is',
  1788. VALUE_ATTRIBUTE = 'value',
  1789. MOUNT_METHOD_KEY = 'mount',
  1790. UPDATE_METHOD_KEY = 'update',
  1791. UNMOUNT_METHOD_KEY = 'unmount',
  1792. SHOULD_UPDATE_KEY = 'shouldUpdate',
  1793. ON_BEFORE_MOUNT_KEY = 'onBeforeMount',
  1794. ON_MOUNTED_KEY = 'onMounted',
  1795. ON_BEFORE_UPDATE_KEY = 'onBeforeUpdate',
  1796. ON_UPDATED_KEY = 'onUpdated',
  1797. ON_BEFORE_UNMOUNT_KEY = 'onBeforeUnmount',
  1798. ON_UNMOUNTED_KEY = 'onUnmounted',
  1799. PROPS_KEY = 'props',
  1800. STATE_KEY = 'state',
  1801. SLOTS_KEY = 'slots',
  1802. ROOT_KEY = 'root',
  1803. IS_PURE_SYMBOL = Symbol('pure'),
  1804. IS_COMPONENT_UPDATING = Symbol('is_updating'),
  1805. PARENT_KEY_SYMBOL = Symbol('parent'),
  1806. ATTRIBUTES_KEY_SYMBOL = Symbol('attributes'),
  1807. TEMPLATE_KEY_SYMBOL = Symbol('template');
  1808. var globals = /*#__PURE__*/Object.freeze({
  1809. __proto__: null,
  1810. COMPONENTS_IMPLEMENTATION_MAP: COMPONENTS_IMPLEMENTATION_MAP$1,
  1811. DOM_COMPONENT_INSTANCE_PROPERTY: DOM_COMPONENT_INSTANCE_PROPERTY$1,
  1812. PLUGINS_SET: PLUGINS_SET$1,
  1813. IS_DIRECTIVE: IS_DIRECTIVE,
  1814. VALUE_ATTRIBUTE: VALUE_ATTRIBUTE,
  1815. MOUNT_METHOD_KEY: MOUNT_METHOD_KEY,
  1816. UPDATE_METHOD_KEY: UPDATE_METHOD_KEY,
  1817. UNMOUNT_METHOD_KEY: UNMOUNT_METHOD_KEY,
  1818. SHOULD_UPDATE_KEY: SHOULD_UPDATE_KEY,
  1819. ON_BEFORE_MOUNT_KEY: ON_BEFORE_MOUNT_KEY,
  1820. ON_MOUNTED_KEY: ON_MOUNTED_KEY,
  1821. ON_BEFORE_UPDATE_KEY: ON_BEFORE_UPDATE_KEY,
  1822. ON_UPDATED_KEY: ON_UPDATED_KEY,
  1823. ON_BEFORE_UNMOUNT_KEY: ON_BEFORE_UNMOUNT_KEY,
  1824. ON_UNMOUNTED_KEY: ON_UNMOUNTED_KEY,
  1825. PROPS_KEY: PROPS_KEY,
  1826. STATE_KEY: STATE_KEY,
  1827. SLOTS_KEY: SLOTS_KEY,
  1828. ROOT_KEY: ROOT_KEY,
  1829. IS_PURE_SYMBOL: IS_PURE_SYMBOL,
  1830. IS_COMPONENT_UPDATING: IS_COMPONENT_UPDATING,
  1831. PARENT_KEY_SYMBOL: PARENT_KEY_SYMBOL,
  1832. ATTRIBUTES_KEY_SYMBOL: ATTRIBUTES_KEY_SYMBOL,
  1833. TEMPLATE_KEY_SYMBOL: TEMPLATE_KEY_SYMBOL
  1834. });
  1835. const EACH = 0;
  1836. const IF = 1;
  1837. const SIMPLE = 2;
  1838. const TAG = 3;
  1839. const SLOT = 4;
  1840. var bindingTypes = {
  1841. EACH,
  1842. IF,
  1843. SIMPLE,
  1844. TAG,
  1845. SLOT
  1846. };
  1847. const ATTRIBUTE = 0;
  1848. const EVENT = 1;
  1849. const TEXT = 2;
  1850. const VALUE = 3;
  1851. var expressionTypes = {
  1852. ATTRIBUTE,
  1853. EVENT,
  1854. TEXT,
  1855. VALUE
  1856. };
  1857. const HEAD_SYMBOL = Symbol('head');
  1858. const TAIL_SYMBOL = Symbol('tail');
  1859. /**
  1860. * Create the <template> fragments text nodes
  1861. * @return {Object} {{head: Text, tail: Text}}
  1862. */
  1863. function createHeadTailPlaceholders() {
  1864. const head = document.createTextNode('');
  1865. const tail = document.createTextNode('');
  1866. head[HEAD_SYMBOL] = true;
  1867. tail[TAIL_SYMBOL] = true;
  1868. return {
  1869. head,
  1870. tail
  1871. };
  1872. }
  1873. /**
  1874. * Create the template meta object in case of <template> fragments
  1875. * @param {TemplateChunk} componentTemplate - template chunk object
  1876. * @returns {Object} the meta property that will be passed to the mount function of the TemplateChunk
  1877. */
  1878. function createTemplateMeta(componentTemplate) {
  1879. const fragment = componentTemplate.dom.cloneNode(true);
  1880. const {
  1881. head,
  1882. tail
  1883. } = createHeadTailPlaceholders();
  1884. return {
  1885. avoidDOMInjection: true,
  1886. fragment,
  1887. head,
  1888. tail,
  1889. children: [head, ...Array.from(fragment.childNodes), tail]
  1890. };
  1891. }
  1892. /**
  1893. * Helper function to set an immutable property
  1894. * @param {Object} source - object where the new property will be set
  1895. * @param {string} key - object key where the new property will be stored
  1896. * @param {*} value - value of the new property
  1897. * @param {Object} options - set the propery overriding the default options
  1898. * @returns {Object} - the original object modified
  1899. */
  1900. function defineProperty(source, key, value, options) {
  1901. if (options === void 0) {
  1902. options = {};
  1903. }
  1904. /* eslint-disable fp/no-mutating-methods */
  1905. Object.defineProperty(source, key, Object.assign({
  1906. value,
  1907. enumerable: false,
  1908. writable: false,
  1909. configurable: true
  1910. }, options));
  1911. /* eslint-enable fp/no-mutating-methods */
  1912. return source;
  1913. }
  1914. /**
  1915. * Define multiple properties on a target object
  1916. * @param {Object} source - object where the new properties will be set
  1917. * @param {Object} properties - object containing as key pair the key + value properties
  1918. * @param {Object} options - set the propery overriding the default options
  1919. * @returns {Object} the original object modified
  1920. */
  1921. function defineProperties(source, properties, options) {
  1922. Object.entries(properties).forEach(_ref => {
  1923. let [key, value] = _ref;
  1924. defineProperty(source, key, value, options);
  1925. });
  1926. return source;
  1927. }
  1928. /**
  1929. * Define default properties if they don't exist on the source object
  1930. * @param {Object} source - object that will receive the default properties
  1931. * @param {Object} defaults - object containing additional optional keys
  1932. * @returns {Object} the original object received enhanced
  1933. */
  1934. function defineDefaults(source, defaults) {
  1935. Object.entries(defaults).forEach(_ref2 => {
  1936. let [key, value] = _ref2;
  1937. if (!source[key]) source[key] = value;
  1938. });
  1939. return source;
  1940. }
  1941. /**
  1942. * Get the current <template> fragment children located in between the head and tail comments
  1943. * @param {Comment} head - head comment node
  1944. * @param {Comment} tail - tail comment node
  1945. * @return {Array[]} children list of the nodes found in this template fragment
  1946. */
  1947. function getFragmentChildren(_ref) {
  1948. let {
  1949. head,
  1950. tail
  1951. } = _ref;
  1952. const nodes = walkNodes([head], head.nextSibling, n => n === tail, false);
  1953. nodes.push(tail);
  1954. return nodes;
  1955. }
  1956. /**
  1957. * Recursive function to walk all the <template> children nodes
  1958. * @param {Array[]} children - children nodes collection
  1959. * @param {ChildNode} node - current node
  1960. * @param {Function} check - exit function check
  1961. * @param {boolean} isFilterActive - filter flag to skip nodes managed by other bindings
  1962. * @returns {Array[]} children list of the nodes found in this template fragment
  1963. */
  1964. function walkNodes(children, node, check, isFilterActive) {
  1965. const {
  1966. nextSibling
  1967. } = node; // filter tail and head nodes together with all the nodes in between
  1968. // this is needed only to fix a really ugly edge case https://github.com/riot/riot/issues/2892
  1969. if (!isFilterActive && !node[HEAD_SYMBOL] && !node[TAIL_SYMBOL]) {
  1970. children.push(node);
  1971. }
  1972. if (!nextSibling || check(node)) return children;
  1973. return walkNodes(children, nextSibling, check, // activate the filters to skip nodes between <template> fragments that will be managed by other bindings
  1974. isFilterActive && !node[TAIL_SYMBOL] || nextSibling[HEAD_SYMBOL]);
  1975. }
  1976. /**
  1977. * Quick type checking
  1978. * @param {*} element - anything
  1979. * @param {string} type - type definition
  1980. * @returns {boolean} true if the type corresponds
  1981. */
  1982. function checkType(element, type) {
  1983. return typeof element === type;
  1984. }
  1985. /**
  1986. * Check if an element is part of an svg
  1987. * @param {HTMLElement} el - element to check
  1988. * @returns {boolean} true if we are in an svg context
  1989. */
  1990. function isSvg(el) {
  1991. const owner = el.ownerSVGElement;
  1992. return !!owner || owner === null;
  1993. }
  1994. /**
  1995. * Check if an element is a template tag
  1996. * @param {HTMLElement} el - element to check
  1997. * @returns {boolean} true if it's a <template>
  1998. */
  1999. function isTemplate(el) {
  2000. return el.tagName.toLowerCase() === 'template';
  2001. }
  2002. /**
  2003. * Check that will be passed if its argument is a function
  2004. * @param {*} value - value to check
  2005. * @returns {boolean} - true if the value is a function
  2006. */
  2007. function isFunction(value) {
  2008. return checkType(value, 'function');
  2009. }
  2010. /**
  2011. * Check if a value is a Boolean
  2012. * @param {*} value - anything
  2013. * @returns {boolean} true only for the value is a boolean
  2014. */
  2015. function isBoolean(value) {
  2016. return checkType(value, 'boolean');
  2017. }
  2018. /**
  2019. * Check if a value is an Object
  2020. * @param {*} value - anything
  2021. * @returns {boolean} true only for the value is an object
  2022. */
  2023. function isObject(value) {
  2024. return !isNil(value) && value.constructor === Object;
  2025. }
  2026. /**
  2027. * Check if a value is null or undefined
  2028. * @param {*} value - anything
  2029. * @returns {boolean} true only for the 'undefined' and 'null' types
  2030. */
  2031. function isNil(value) {
  2032. return value === null || value === undefined;
  2033. }
  2034. /**
  2035. * ISC License
  2036. *
  2037. * Copyright (c) 2020, Andrea Giammarchi, @WebReflection
  2038. *
  2039. * Permission to use, copy, modify, and/or distribute this software for any
  2040. * purpose with or without fee is hereby granted, provided that the above
  2041. * copyright notice and this permission notice appear in all copies.
  2042. *
  2043. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  2044. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  2045. * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  2046. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  2047. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  2048. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  2049. * PERFORMANCE OF THIS SOFTWARE.
  2050. */
  2051. // fork of https://github.com/WebReflection/udomdiff version 1.1.0
  2052. // due to https://github.com/WebReflection/udomdiff/pull/2
  2053. /* eslint-disable */
  2054. /**
  2055. * @param {Node[]} a The list of current/live children
  2056. * @param {Node[]} b The list of future children
  2057. * @param {(entry: Node, action: number) => Node} get
  2058. * The callback invoked per each entry related DOM operation.
  2059. * @param {Node} [before] The optional node used as anchor to insert before.
  2060. * @returns {Node[]} The same list of future children.
  2061. */
  2062. var udomdiff = ((a, b, get, before) => {
  2063. const bLength = b.length;
  2064. let aEnd = a.length;
  2065. let bEnd = bLength;
  2066. let aStart = 0;
  2067. let bStart = 0;
  2068. let map = null;
  2069. while (aStart < aEnd || bStart < bEnd) {
  2070. // append head, tail, or nodes in between: fast path
  2071. if (aEnd === aStart) {
  2072. // we could be in a situation where the rest of nodes that
  2073. // need to be added are not at the end, and in such case
  2074. // the node to `insertBefore`, if the index is more than 0
  2075. // must be retrieved, otherwise it's gonna be the first item.
  2076. const node = bEnd < bLength ? bStart ? get(b[bStart - 1], -0).nextSibling : get(b[bEnd - bStart], 0) : before;
  2077. while (bStart < bEnd) insertBefore(get(b[bStart++], 1), node);
  2078. } // remove head or tail: fast path
  2079. else if (bEnd === bStart) {
  2080. while (aStart < aEnd) {
  2081. // remove the node only if it's unknown or not live
  2082. if (!map || !map.has(a[aStart])) removeChild(get(a[aStart], -1));
  2083. aStart++;
  2084. }
  2085. } // same node: fast path
  2086. else if (a[aStart] === b[bStart]) {
  2087. aStart++;
  2088. bStart++;
  2089. } // same tail: fast path
  2090. else if (a[aEnd - 1] === b[bEnd - 1]) {
  2091. aEnd--;
  2092. bEnd--;
  2093. } // The once here single last swap "fast path" has been removed in v1.1.0
  2094. // https://github.com/WebReflection/udomdiff/blob/single-final-swap/esm/index.js#L69-L85
  2095. // reverse swap: also fast path
  2096. else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
  2097. // this is a "shrink" operation that could happen in these cases:
  2098. // [1, 2, 3, 4, 5]
  2099. // [1, 4, 3, 2, 5]
  2100. // or asymmetric too
  2101. // [1, 2, 3, 4, 5]
  2102. // [1, 2, 3, 5, 6, 4]
  2103. const node = get(a[--aEnd], -1).nextSibling;
  2104. insertBefore(get(b[bStart++], 1), get(a[aStart++], -1).nextSibling);
  2105. insertBefore(get(b[--bEnd], 1), node); // mark the future index as identical (yeah, it's dirty, but cheap 👍)
  2106. // The main reason to do this, is that when a[aEnd] will be reached,
  2107. // the loop will likely be on the fast path, as identical to b[bEnd].
  2108. // In the best case scenario, the next loop will skip the tail,
  2109. // but in the worst one, this node will be considered as already
  2110. // processed, bailing out pretty quickly from the map index check
  2111. a[aEnd] = b[bEnd];
  2112. } // map based fallback, "slow" path
  2113. else {
  2114. // the map requires an O(bEnd - bStart) operation once
  2115. // to store all future nodes indexes for later purposes.
  2116. // In the worst case scenario, this is a full O(N) cost,
  2117. // and such scenario happens at least when all nodes are different,
  2118. // but also if both first and last items of the lists are different
  2119. if (!map) {
  2120. map = new Map();
  2121. let i = bStart;
  2122. while (i < bEnd) map.set(b[i], i++);
  2123. } // if it's a future node, hence it needs some handling
  2124. if (map.has(a[aStart])) {
  2125. // grab the index of such node, 'cause it might have been processed
  2126. const index = map.get(a[aStart]); // if it's not already processed, look on demand for the next LCS
  2127. if (bStart < index && index < bEnd) {
  2128. let i = aStart; // counts the amount of nodes that are the same in the future
  2129. let sequence = 1;
  2130. while (++i < aEnd && i < bEnd && map.get(a[i]) === index + sequence) sequence++; // effort decision here: if the sequence is longer than replaces
  2131. // needed to reach such sequence, which would brings again this loop
  2132. // to the fast path, prepend the difference before a sequence,
  2133. // and move only the future list index forward, so that aStart
  2134. // and bStart will be aligned again, hence on the fast path.
  2135. // An example considering aStart and bStart are both 0:
  2136. // a: [1, 2, 3, 4]
  2137. // b: [7, 1, 2, 3, 6]
  2138. // this would place 7 before 1 and, from that time on, 1, 2, and 3
  2139. // will be processed at zero cost
  2140. if (sequence > index - bStart) {
  2141. const node = get(a[aStart], 0);
  2142. while (bStart < index) insertBefore(get(b[bStart++], 1), node);
  2143. } // if the effort wasn't good enough, fallback to a replace,
  2144. // moving both source and target indexes forward, hoping that some
  2145. // similar node will be found later on, to go back to the fast path
  2146. else {
  2147. replaceChild(get(b[bStart++], 1), get(a[aStart++], -1));
  2148. }
  2149. } // otherwise move the source forward, 'cause there's nothing to do
  2150. else aStart++;
  2151. } // this node has no meaning in the future list, so it's more than safe
  2152. // to remove it, and check the next live node out instead, meaning
  2153. // that only the live list index should be forwarded
  2154. else removeChild(get(a[aStart++], -1));
  2155. }
  2156. }
  2157. return b;
  2158. });
  2159. const UNMOUNT_SCOPE = Symbol('unmount');
  2160. const EachBinding = {
  2161. // dynamic binding properties
  2162. // childrenMap: null,
  2163. // node: null,
  2164. // root: null,
  2165. // condition: null,
  2166. // evaluate: null,
  2167. // template: null,
  2168. // isTemplateTag: false,
  2169. nodes: [],
  2170. // getKey: null,
  2171. // indexName: null,
  2172. // itemName: null,
  2173. // afterPlaceholder: null,
  2174. // placeholder: null,
  2175. // API methods
  2176. mount(scope, parentScope) {
  2177. return this.update(scope, parentScope);
  2178. },
  2179. update(scope, parentScope) {
  2180. const {
  2181. placeholder,
  2182. nodes,
  2183. childrenMap
  2184. } = this;
  2185. const collection = scope === UNMOUNT_SCOPE ? null : this.evaluate(scope);
  2186. const items = collection ? Array.from(collection) : []; // prepare the diffing
  2187. const {
  2188. newChildrenMap,
  2189. batches,
  2190. futureNodes
  2191. } = createPatch(items, scope, parentScope, this); // patch the DOM only if there are new nodes
  2192. udomdiff(nodes, futureNodes, patch(Array.from(childrenMap.values()), parentScope), placeholder); // trigger the mounts and the updates
  2193. batches.forEach(fn => fn()); // update the children map
  2194. this.childrenMap = newChildrenMap;
  2195. this.nodes = futureNodes; // make sure that the loop edge nodes are marked
  2196. markEdgeNodes(this.nodes);
  2197. return this;
  2198. },
  2199. unmount(scope, parentScope) {
  2200. this.update(UNMOUNT_SCOPE, parentScope);
  2201. return this;
  2202. }
  2203. };
  2204. /**
  2205. * Patch the DOM while diffing
  2206. * @param {any[]} redundant - list of all the children (template, nodes, context) added via each
  2207. * @param {*} parentScope - scope of the parent template
  2208. * @returns {Function} patch function used by domdiff
  2209. */
  2210. function patch(redundant, parentScope) {
  2211. return (item, info) => {
  2212. if (info < 0) {
  2213. // get the last element added to the childrenMap saved previously
  2214. const element = redundant[redundant.length - 1];
  2215. if (element) {
  2216. // get the nodes and the template in stored in the last child of the childrenMap
  2217. const {
  2218. template,
  2219. nodes,
  2220. context
  2221. } = element; // remove the last node (notice <template> tags might have more children nodes)
  2222. nodes.pop(); // notice that we pass null as last argument because
  2223. // the root node and its children will be removed by domdiff
  2224. if (!nodes.length) {
  2225. // we have cleared all the children nodes and we can unmount this template
  2226. redundant.pop();
  2227. template.unmount(context, parentScope, null);
  2228. }
  2229. }
  2230. }
  2231. return item;
  2232. };
  2233. }
  2234. /**
  2235. * Check whether a template must be filtered from a loop
  2236. * @param {Function} condition - filter function
  2237. * @param {Object} context - argument passed to the filter function
  2238. * @returns {boolean} true if this item should be skipped
  2239. */
  2240. function mustFilterItem(condition, context) {
  2241. return condition ? !condition(context) : false;
  2242. }
  2243. /**
  2244. * Extend the scope of the looped template
  2245. * @param {Object} scope - current template scope
  2246. * @param {Object} options - options
  2247. * @param {string} options.itemName - key to identify the looped item in the new context
  2248. * @param {string} options.indexName - key to identify the index of the looped item
  2249. * @param {number} options.index - current index
  2250. * @param {*} options.item - collection item looped
  2251. * @returns {Object} enhanced scope object
  2252. */
  2253. function extendScope(scope, _ref) {
  2254. let {
  2255. itemName,
  2256. indexName,
  2257. index,
  2258. item
  2259. } = _ref;
  2260. defineProperty(scope, itemName, item);
  2261. if (indexName) defineProperty(scope, indexName, index);
  2262. return scope;
  2263. }
  2264. /**
  2265. * Mark the first and last nodes in order to ignore them in case we need to retrieve the <template> fragment nodes
  2266. * @param {Array[]} nodes - each binding nodes list
  2267. * @returns {undefined} void function
  2268. */
  2269. function markEdgeNodes(nodes) {
  2270. const first = nodes[0];
  2271. const last = nodes[nodes.length - 1];
  2272. if (first) first[HEAD_SYMBOL] = true;
  2273. if (last) last[TAIL_SYMBOL] = true;
  2274. }
  2275. /**
  2276. * Loop the current template items
  2277. * @param {Array} items - expression collection value
  2278. * @param {*} scope - template scope
  2279. * @param {*} parentScope - scope of the parent template
  2280. * @param {EachBinding} binding - each binding object instance
  2281. * @returns {Object} data
  2282. * @returns {Map} data.newChildrenMap - a Map containing the new children template structure
  2283. * @returns {Array} data.batches - array containing the template lifecycle functions to trigger
  2284. * @returns {Array} data.futureNodes - array containing the nodes we need to diff
  2285. */
  2286. function createPatch(items, scope, parentScope, binding) {
  2287. const {
  2288. condition,
  2289. template,
  2290. childrenMap,
  2291. itemName,
  2292. getKey,
  2293. indexName,
  2294. root,
  2295. isTemplateTag
  2296. } = binding;
  2297. const newChildrenMap = new Map();
  2298. const batches = [];
  2299. const futureNodes = [];
  2300. items.forEach((item, index) => {
  2301. const context = extendScope(Object.create(scope), {
  2302. itemName,
  2303. indexName,
  2304. index,
  2305. item
  2306. });
  2307. const key = getKey ? getKey(context) : index;
  2308. const oldItem = childrenMap.get(key);
  2309. const nodes = [];
  2310. if (mustFilterItem(condition, context)) {
  2311. return;
  2312. }
  2313. const mustMount = !oldItem;
  2314. const componentTemplate = oldItem ? oldItem.template : template.clone();
  2315. const el = componentTemplate.el || root.cloneNode();
  2316. const meta = isTemplateTag && mustMount ? createTemplateMeta(componentTemplate) : componentTemplate.meta;
  2317. if (mustMount) {
  2318. batches.push(() => componentTemplate.mount(el, context, parentScope, meta));
  2319. } else {
  2320. batches.push(() => componentTemplate.update(context, parentScope));
  2321. } // create the collection of nodes to update or to add
  2322. // in case of template tags we need to add all its children nodes
  2323. if (isTemplateTag) {
  2324. nodes.push(...(mustMount ? meta.children : getFragmentChildren(meta)));
  2325. } else {
  2326. nodes.push(el);
  2327. } // delete the old item from the children map
  2328. childrenMap.delete(key);
  2329. futureNodes.push(...nodes); // update the children map
  2330. newChildrenMap.set(key, {
  2331. nodes,
  2332. template: componentTemplate,
  2333. context,
  2334. index
  2335. });
  2336. });
  2337. return {
  2338. newChildrenMap,
  2339. batches,
  2340. futureNodes
  2341. };
  2342. }
  2343. function create$6(node, _ref2) {
  2344. let {
  2345. evaluate,
  2346. condition,
  2347. itemName,
  2348. indexName,
  2349. getKey,
  2350. template
  2351. } = _ref2;
  2352. const placeholder = document.createTextNode('');
  2353. const root = node.cloneNode();
  2354. insertBefore(placeholder, node);
  2355. removeChild(node);
  2356. return Object.assign({}, EachBinding, {
  2357. childrenMap: new Map(),
  2358. node,
  2359. root,
  2360. condition,
  2361. evaluate,
  2362. isTemplateTag: isTemplate(root),
  2363. template: template.createDOM(node),
  2364. getKey,
  2365. indexName,
  2366. itemName,
  2367. placeholder
  2368. });
  2369. }
  2370. /**
  2371. * Binding responsible for the `if` directive
  2372. */
  2373. const IfBinding = {
  2374. // dynamic binding properties
  2375. // node: null,
  2376. // evaluate: null,
  2377. // isTemplateTag: false,
  2378. // placeholder: null,
  2379. // template: null,
  2380. // API methods
  2381. mount(scope, parentScope) {
  2382. return this.update(scope, parentScope);
  2383. },
  2384. update(scope, parentScope) {
  2385. const value = !!this.evaluate(scope);
  2386. const mustMount = !this.value && value;
  2387. const mustUnmount = this.value && !value;
  2388. const mount = () => {
  2389. const pristine = this.node.cloneNode();
  2390. insertBefore(pristine, this.placeholder);
  2391. this.template = this.template.clone();
  2392. this.template.mount(pristine, scope, parentScope);
  2393. };
  2394. switch (true) {
  2395. case mustMount:
  2396. mount();
  2397. break;
  2398. case mustUnmount:
  2399. this.unmount(scope);
  2400. break;
  2401. default:
  2402. if (value) this.template.update(scope, parentScope);
  2403. }
  2404. this.value = value;
  2405. return this;
  2406. },
  2407. unmount(scope, parentScope) {
  2408. this.template.unmount(scope, parentScope, true);
  2409. return this;
  2410. }
  2411. };
  2412. function create$5(node, _ref) {
  2413. let {
  2414. evaluate,
  2415. template
  2416. } = _ref;
  2417. const placeholder = document.createTextNode('');
  2418. insertBefore(placeholder, node);
  2419. removeChild(node);
  2420. return Object.assign({}, IfBinding, {
  2421. node,
  2422. evaluate,
  2423. placeholder,
  2424. template: template.createDOM(node)
  2425. });
  2426. }
  2427. /**
  2428. * Throw an error with a descriptive message
  2429. * @param { string } message - error message
  2430. * @returns { undefined } hoppla.. at this point the program should stop working
  2431. */
  2432. function panic(message) {
  2433. throw new Error(message);
  2434. }
  2435. /**
  2436. * Returns the memoized (cached) function.
  2437. * // borrowed from https://www.30secondsofcode.org/js/s/memoize
  2438. * @param {Function} fn - function to memoize
  2439. * @returns {Function} memoize function
  2440. */
  2441. function memoize(fn) {
  2442. const cache = new Map();
  2443. const cached = val => {
  2444. return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
  2445. };
  2446. cached.cache = cache;
  2447. return cached;
  2448. }
  2449. /**
  2450. * Evaluate a list of attribute expressions
  2451. * @param {Array} attributes - attribute expressions generated by the riot compiler
  2452. * @returns {Object} key value pairs with the result of the computation
  2453. */
  2454. function evaluateAttributeExpressions(attributes) {
  2455. return attributes.reduce((acc, attribute) => {
  2456. const {
  2457. value,
  2458. type
  2459. } = attribute;
  2460. switch (true) {
  2461. // spread attribute
  2462. case !attribute.name && type === ATTRIBUTE:
  2463. return Object.assign({}, acc, value);
  2464. // value attribute
  2465. case type === VALUE:
  2466. acc.value = attribute.value;
  2467. break;
  2468. // normal attributes
  2469. default:
  2470. acc[dashToCamelCase(attribute.name)] = attribute.value;
  2471. }
  2472. return acc;
  2473. }, {});
  2474. }
  2475. const ElementProto = typeof Element === 'undefined' ? {} : Element.prototype;
  2476. const isNativeHtmlProperty = memoize(name => ElementProto.hasOwnProperty(name)); // eslint-disable-line
  2477. /**
  2478. * Add all the attributes provided
  2479. * @param {HTMLElement} node - target node
  2480. * @param {Object} attributes - object containing the attributes names and values
  2481. * @returns {undefined} sorry it's a void function :(
  2482. */
  2483. function setAllAttributes(node, attributes) {
  2484. Object.entries(attributes).forEach(_ref => {
  2485. let [name, value] = _ref;
  2486. return attributeExpression(node, {
  2487. name
  2488. }, value);
  2489. });
  2490. }
  2491. /**
  2492. * Remove all the attributes provided
  2493. * @param {HTMLElement} node - target node
  2494. * @param {Object} newAttributes - object containing all the new attribute names
  2495. * @param {Object} oldAttributes - object containing all the old attribute names
  2496. * @returns {undefined} sorry it's a void function :(
  2497. */
  2498. function removeAllAttributes(node, newAttributes, oldAttributes) {
  2499. const newKeys = newAttributes ? Object.keys(newAttributes) : [];
  2500. Object.keys(oldAttributes).filter(name => !newKeys.includes(name)).forEach(attribute => node.removeAttribute(attribute));
  2501. }
  2502. /**
  2503. * Check whether the attribute value can be rendered
  2504. * @param {*} value - expression value
  2505. * @returns {boolean} true if we can render this attribute value
  2506. */
  2507. function canRenderAttribute(value) {
  2508. return value === true || ['string', 'number'].includes(typeof value);
  2509. }
  2510. /**
  2511. * Check whether the attribute should be removed
  2512. * @param {*} value - expression value
  2513. * @returns {boolean} boolean - true if the attribute can be removed}
  2514. */
  2515. function shouldRemoveAttribute(value) {
  2516. return !value && value !== 0;
  2517. }
  2518. /**
  2519. * This methods handles the DOM attributes updates
  2520. * @param {HTMLElement} node - target node
  2521. * @param {Object} expression - expression object
  2522. * @param {string} expression.name - attribute name
  2523. * @param {*} value - new expression value
  2524. * @param {*} oldValue - the old expression cached value
  2525. * @returns {undefined}
  2526. */
  2527. function attributeExpression(node, _ref2, value, oldValue) {
  2528. let {
  2529. name
  2530. } = _ref2;
  2531. // is it a spread operator? {...attributes}
  2532. if (!name) {
  2533. if (oldValue) {
  2534. // remove all the old attributes
  2535. removeAllAttributes(node, value, oldValue);
  2536. } // is the value still truthy?
  2537. if (value) {
  2538. setAllAttributes(node, value);
  2539. }
  2540. return;
  2541. } // handle boolean attributes
  2542. if (!isNativeHtmlProperty(name) && (isBoolean(value) || isObject(value) || isFunction(value))) {
  2543. node[name] = value;
  2544. }
  2545. if (shouldRemoveAttribute(value)) {
  2546. node.removeAttribute(name);
  2547. } else if (canRenderAttribute(value)) {
  2548. node.setAttribute(name, normalizeValue(name, value));
  2549. }
  2550. }
  2551. /**
  2552. * Get the value as string
  2553. * @param {string} name - attribute name
  2554. * @param {*} value - user input value
  2555. * @returns {string} input value as string
  2556. */
  2557. function normalizeValue(name, value) {
  2558. // be sure that expressions like selected={ true } will be always rendered as selected='selected'
  2559. return value === true ? name : value;
  2560. }
  2561. const RE_EVENTS_PREFIX = /^on/;
  2562. 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
  2563. const EventListener = {
  2564. handleEvent(event) {
  2565. this[event.type](event);
  2566. }
  2567. };
  2568. const ListenersWeakMap = new WeakMap();
  2569. const createListener = node => {
  2570. const listener = Object.create(EventListener);
  2571. ListenersWeakMap.set(node, listener);
  2572. return listener;
  2573. };
  2574. /**
  2575. * Set a new event listener
  2576. * @param {HTMLElement} node - target node
  2577. * @param {Object} expression - expression object
  2578. * @param {string} expression.name - event name
  2579. * @param {*} value - new expression value
  2580. * @returns {value} the callback just received
  2581. */
  2582. function eventExpression(node, _ref, value) {
  2583. let {
  2584. name
  2585. } = _ref;
  2586. const normalizedEventName = name.replace(RE_EVENTS_PREFIX, '');
  2587. const eventListener = ListenersWeakMap.get(node) || createListener(node);
  2588. const [callback, options] = getCallbackAndOptions(value);
  2589. const handler = eventListener[normalizedEventName];
  2590. const mustRemoveEvent = handler && !callback;
  2591. const mustAddEvent = callback && !handler;
  2592. if (mustRemoveEvent) {
  2593. node.removeEventListener(normalizedEventName, eventListener);
  2594. }
  2595. if (mustAddEvent) {
  2596. node.addEventListener(normalizedEventName, eventListener, options);
  2597. }
  2598. eventListener[normalizedEventName] = callback;
  2599. }
  2600. /**
  2601. * Normalize the user value in order to render a empty string in case of falsy values
  2602. * @param {*} value - user input value
  2603. * @returns {string} hopefully a string
  2604. */
  2605. function normalizeStringValue(value) {
  2606. return isNil(value) ? '' : value;
  2607. }
  2608. /**
  2609. * Get the the target text node to update or create one from of a comment node
  2610. * @param {HTMLElement} node - any html element containing childNodes
  2611. * @param {number} childNodeIndex - index of the text node in the childNodes list
  2612. * @returns {Text} the text node to update
  2613. */
  2614. const getTextNode = (node, childNodeIndex) => {
  2615. const target = node.childNodes[childNodeIndex];
  2616. if (target.nodeType === Node.COMMENT_NODE) {
  2617. const textNode = document.createTextNode('');
  2618. node.replaceChild(textNode, target);
  2619. return textNode;
  2620. }
  2621. return target;
  2622. };
  2623. /**
  2624. * This methods handles a simple text expression update
  2625. * @param {HTMLElement} node - target node
  2626. * @param {Object} data - expression object
  2627. * @param {*} value - new expression value
  2628. * @returns {undefined}
  2629. */
  2630. function textExpression(node, data, value) {
  2631. node.data = normalizeStringValue(value);
  2632. }
  2633. /**
  2634. * This methods handles the input fileds value updates
  2635. * @param {HTMLElement} node - target node
  2636. * @param {Object} expression - expression object
  2637. * @param {*} value - new expression value
  2638. * @returns {undefined}
  2639. */
  2640. function valueExpression(node, expression, value) {
  2641. node.value = normalizeStringValue(value);
  2642. }
  2643. var expressions = {
  2644. [ATTRIBUTE]: attributeExpression,
  2645. [EVENT]: eventExpression,
  2646. [TEXT]: textExpression,
  2647. [VALUE]: valueExpression
  2648. };
  2649. const Expression = {
  2650. // Static props
  2651. // node: null,
  2652. // value: null,
  2653. // API methods
  2654. /**
  2655. * Mount the expression evaluating its initial value
  2656. * @param {*} scope - argument passed to the expression to evaluate its current values
  2657. * @returns {Expression} self
  2658. */
  2659. mount(scope) {
  2660. // hopefully a pure function
  2661. this.value = this.evaluate(scope); // IO() DOM updates
  2662. apply(this, this.value);
  2663. return this;
  2664. },
  2665. /**
  2666. * Update the expression if its value changed
  2667. * @param {*} scope - argument passed to the expression to evaluate its current values
  2668. * @returns {Expression} self
  2669. */
  2670. update(scope) {
  2671. // pure function
  2672. const value = this.evaluate(scope);
  2673. if (this.value !== value) {
  2674. // IO() DOM updates
  2675. apply(this, value);
  2676. this.value = value;
  2677. }
  2678. return this;
  2679. },
  2680. /**
  2681. * Expression teardown method
  2682. * @returns {Expression} self
  2683. */
  2684. unmount() {
  2685. // unmount only the event handling expressions
  2686. if (this.type === EVENT) apply(this, null);
  2687. return this;
  2688. }
  2689. };
  2690. /**
  2691. * IO() function to handle the DOM updates
  2692. * @param {Expression} expression - expression object
  2693. * @param {*} value - current expression value
  2694. * @returns {undefined}
  2695. */
  2696. function apply(expression, value) {
  2697. return expressions[expression.type](expression.node, expression, value, expression.value);
  2698. }
  2699. function create$4(node, data) {
  2700. return Object.assign({}, Expression, data, {
  2701. node: data.type === TEXT ? getTextNode(node, data.childNodeIndex) : node
  2702. });
  2703. }
  2704. /**
  2705. * Create a flat object having as keys a list of methods that if dispatched will propagate
  2706. * on the whole collection
  2707. * @param {Array} collection - collection to iterate
  2708. * @param {Array<string>} methods - methods to execute on each item of the collection
  2709. * @param {*} context - context returned by the new methods created
  2710. * @returns {Object} a new object to simplify the the nested methods dispatching
  2711. */
  2712. function flattenCollectionMethods(collection, methods, context) {
  2713. return methods.reduce((acc, method) => {
  2714. return Object.assign({}, acc, {
  2715. [method]: scope => {
  2716. return collection.map(item => item[method](scope)) && context;
  2717. }
  2718. });
  2719. }, {});
  2720. }
  2721. function create$3(node, _ref) {
  2722. let {
  2723. expressions
  2724. } = _ref;
  2725. return Object.assign({}, flattenCollectionMethods(expressions.map(expression => create$4(node, expression)), ['mount', 'update', 'unmount']));
  2726. }
  2727. function extendParentScope(attributes, scope, parentScope) {
  2728. if (!attributes || !attributes.length) return parentScope;
  2729. const expressions = attributes.map(attr => Object.assign({}, attr, {
  2730. value: attr.evaluate(scope)
  2731. }));
  2732. return Object.assign(Object.create(parentScope || null), evaluateAttributeExpressions(expressions));
  2733. } // this function is only meant to fix an edge case
  2734. // https://github.com/riot/riot/issues/2842
  2735. const getRealParent = (scope, parentScope) => scope[PARENT_KEY_SYMBOL] || parentScope;
  2736. const SlotBinding = {
  2737. // dynamic binding properties
  2738. // node: null,
  2739. // name: null,
  2740. attributes: [],
  2741. // template: null,
  2742. getTemplateScope(scope, parentScope) {
  2743. return extendParentScope(this.attributes, scope, parentScope);
  2744. },
  2745. // API methods
  2746. mount(scope, parentScope) {
  2747. const templateData = scope.slots ? scope.slots.find(_ref => {
  2748. let {
  2749. id
  2750. } = _ref;
  2751. return id === this.name;
  2752. }) : false;
  2753. const {
  2754. parentNode
  2755. } = this.node;
  2756. const realParent = getRealParent(scope, parentScope);
  2757. this.template = templateData && create(templateData.html, templateData.bindings).createDOM(parentNode);
  2758. if (this.template) {
  2759. cleanNode(this.node);
  2760. this.template.mount(this.node, this.getTemplateScope(scope, realParent), realParent);
  2761. this.template.children = Array.from(this.node.childNodes);
  2762. }
  2763. moveSlotInnerContent(this.node);
  2764. removeChild(this.node);
  2765. return this;
  2766. },
  2767. update(scope, parentScope) {
  2768. if (this.template) {
  2769. const realParent = getRealParent(scope, parentScope);
  2770. this.template.update(this.getTemplateScope(scope, realParent), realParent);
  2771. }
  2772. return this;
  2773. },
  2774. unmount(scope, parentScope, mustRemoveRoot) {
  2775. if (this.template) {
  2776. this.template.unmount(this.getTemplateScope(scope, parentScope), null, mustRemoveRoot);
  2777. }
  2778. return this;
  2779. }
  2780. };
  2781. /**
  2782. * Move the inner content of the slots outside of them
  2783. * @param {HTMLElement} slot - slot node
  2784. * @returns {undefined} it's a void method ¯\_()_/¯
  2785. */
  2786. function moveSlotInnerContent(slot) {
  2787. const child = slot && slot.firstChild;
  2788. if (!child) return;
  2789. insertBefore(child, slot);
  2790. moveSlotInnerContent(slot);
  2791. }
  2792. /**
  2793. * Create a single slot binding
  2794. * @param {HTMLElement} node - slot node
  2795. * @param {string} name - slot id
  2796. * @param {AttributeExpressionData[]} attributes - slot attributes
  2797. * @returns {Object} Slot binding object
  2798. */
  2799. function createSlot(node, _ref2) {
  2800. let {
  2801. name,
  2802. attributes
  2803. } = _ref2;
  2804. return Object.assign({}, SlotBinding, {
  2805. attributes,
  2806. node,
  2807. name
  2808. });
  2809. }
  2810. /**
  2811. * Create a new tag object if it was registered before, otherwise fallback to the simple
  2812. * template chunk
  2813. * @param {Function} component - component factory function
  2814. * @param {Array<Object>} slots - array containing the slots markup
  2815. * @param {Array} attributes - dynamic attributes that will be received by the tag element
  2816. * @returns {TagImplementation|TemplateChunk} a tag implementation or a template chunk as fallback
  2817. */
  2818. function getTag(component, slots, attributes) {
  2819. if (slots === void 0) {
  2820. slots = [];
  2821. }
  2822. if (attributes === void 0) {
  2823. attributes = [];
  2824. }
  2825. // if this tag was registered before we will return its implementation
  2826. if (component) {
  2827. return component({
  2828. slots,
  2829. attributes
  2830. });
  2831. } // otherwise we return a template chunk
  2832. return create(slotsToMarkup(slots), [...slotBindings(slots), {
  2833. // the attributes should be registered as binding
  2834. // if we fallback to a normal template chunk
  2835. expressions: attributes.map(attr => {
  2836. return Object.assign({
  2837. type: ATTRIBUTE
  2838. }, attr);
  2839. })
  2840. }]);
  2841. }
  2842. /**
  2843. * Merge all the slots bindings into a single array
  2844. * @param {Array<Object>} slots - slots collection
  2845. * @returns {Array<Bindings>} flatten bindings array
  2846. */
  2847. function slotBindings(slots) {
  2848. return slots.reduce((acc, _ref) => {
  2849. let {
  2850. bindings
  2851. } = _ref;
  2852. return acc.concat(bindings);
  2853. }, []);
  2854. }
  2855. /**
  2856. * Merge all the slots together in a single markup string
  2857. * @param {Array<Object>} slots - slots collection
  2858. * @returns {string} markup of all the slots in a single string
  2859. */
  2860. function slotsToMarkup(slots) {
  2861. return slots.reduce((acc, slot) => {
  2862. return acc + slot.html;
  2863. }, '');
  2864. }
  2865. const TagBinding = {
  2866. // dynamic binding properties
  2867. // node: null,
  2868. // evaluate: null,
  2869. // name: null,
  2870. // slots: null,
  2871. // tag: null,
  2872. // attributes: null,
  2873. // getComponent: null,
  2874. mount(scope) {
  2875. return this.update(scope);
  2876. },
  2877. update(scope, parentScope) {
  2878. const name = this.evaluate(scope); // simple update
  2879. if (name && name === this.name) {
  2880. this.tag.update(scope);
  2881. } else {
  2882. // unmount the old tag if it exists
  2883. this.unmount(scope, parentScope, true); // mount the new tag
  2884. this.name = name;
  2885. this.tag = getTag(this.getComponent(name), this.slots, this.attributes);
  2886. this.tag.mount(this.node, scope);
  2887. }
  2888. return this;
  2889. },
  2890. unmount(scope, parentScope, keepRootTag) {
  2891. if (this.tag) {
  2892. // keep the root tag
  2893. this.tag.unmount(keepRootTag);
  2894. }
  2895. return this;
  2896. }
  2897. };
  2898. function create$2(node, _ref2) {
  2899. let {
  2900. evaluate,
  2901. getComponent,
  2902. slots,
  2903. attributes
  2904. } = _ref2;
  2905. return Object.assign({}, TagBinding, {
  2906. node,
  2907. evaluate,
  2908. slots,
  2909. attributes,
  2910. getComponent
  2911. });
  2912. }
  2913. var bindings = {
  2914. [IF]: create$5,
  2915. [SIMPLE]: create$3,
  2916. [EACH]: create$6,
  2917. [TAG]: create$2,
  2918. [SLOT]: createSlot
  2919. };
  2920. /**
  2921. * Text expressions in a template tag will get childNodeIndex value normalized
  2922. * depending on the position of the <template> tag offset
  2923. * @param {Expression[]} expressions - riot expressions array
  2924. * @param {number} textExpressionsOffset - offset of the <template> tag
  2925. * @returns {Expression[]} expressions containing the text expressions normalized
  2926. */
  2927. function fixTextExpressionsOffset(expressions, textExpressionsOffset) {
  2928. return expressions.map(e => e.type === TEXT ? Object.assign({}, e, {
  2929. childNodeIndex: e.childNodeIndex + textExpressionsOffset
  2930. }) : e);
  2931. }
  2932. /**
  2933. * Bind a new expression object to a DOM node
  2934. * @param {HTMLElement} root - DOM node where to bind the expression
  2935. * @param {TagBindingData} binding - binding data
  2936. * @param {number|null} templateTagOffset - if it's defined we need to fix the text expressions childNodeIndex offset
  2937. * @returns {Binding} Binding object
  2938. */
  2939. function create$1(root, binding, templateTagOffset) {
  2940. const {
  2941. selector,
  2942. type,
  2943. redundantAttribute,
  2944. expressions
  2945. } = binding; // find the node to apply the bindings
  2946. const node = selector ? root.querySelector(selector) : root; // remove eventually additional attributes created only to select this node
  2947. if (redundantAttribute) node.removeAttribute(redundantAttribute);
  2948. const bindingExpressions = expressions || []; // init the binding
  2949. return (bindings[type] || bindings[SIMPLE])(node, Object.assign({}, binding, {
  2950. expressions: templateTagOffset && !selector ? fixTextExpressionsOffset(bindingExpressions, templateTagOffset) : bindingExpressions
  2951. }));
  2952. }
  2953. function createHTMLTree(html, root) {
  2954. const template = isTemplate(root) ? root : document.createElement('template');
  2955. template.innerHTML = html;
  2956. return template.content;
  2957. } // for svg nodes we need a bit more work
  2958. function createSVGTree(html, container) {
  2959. // create the SVGNode
  2960. const svgNode = container.ownerDocument.importNode(new window.DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${html}</svg>`, 'application/xml').documentElement, true);
  2961. return svgNode;
  2962. }
  2963. /**
  2964. * Create the DOM that will be injected
  2965. * @param {Object} root - DOM node to find out the context where the fragment will be created
  2966. * @param {string} html - DOM to create as string
  2967. * @returns {HTMLDocumentFragment|HTMLElement} a new html fragment
  2968. */
  2969. function createDOMTree(root, html) {
  2970. if (isSvg(root)) return createSVGTree(html, root);
  2971. return createHTMLTree(html, root);
  2972. }
  2973. /**
  2974. * Inject the DOM tree into a target node
  2975. * @param {HTMLElement} el - target element
  2976. * @param {DocumentFragment|SVGElement} dom - dom tree to inject
  2977. * @returns {undefined}
  2978. */
  2979. function injectDOM(el, dom) {
  2980. switch (true) {
  2981. case isSvg(el):
  2982. moveChildren(dom, el);
  2983. break;
  2984. case isTemplate(el):
  2985. el.parentNode.replaceChild(dom, el);
  2986. break;
  2987. default:
  2988. el.appendChild(dom);
  2989. }
  2990. }
  2991. /**
  2992. * Create the Template DOM skeleton
  2993. * @param {HTMLElement} el - root node where the DOM will be injected
  2994. * @param {string|HTMLElement} html - HTML markup or HTMLElement that will be injected into the root node
  2995. * @returns {?DocumentFragment} fragment that will be injected into the root node
  2996. */
  2997. function createTemplateDOM(el, html) {
  2998. return html && (typeof html === 'string' ? createDOMTree(el, html) : html);
  2999. }
  3000. /**
  3001. * Get the offset of the <template> tag
  3002. * @param {HTMLElement} parentNode - template tag parent node
  3003. * @param {HTMLElement} el - the template tag we want to render
  3004. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  3005. * @returns {number} offset of the <template> tag calculated from its siblings DOM nodes
  3006. */
  3007. function getTemplateTagOffset(parentNode, el, meta) {
  3008. const siblings = Array.from(parentNode.childNodes);
  3009. return Math.max(siblings.indexOf(el), siblings.indexOf(meta.head) + 1, 0);
  3010. }
  3011. /**
  3012. * Template Chunk model
  3013. * @type {Object}
  3014. */
  3015. const TemplateChunk = Object.freeze({
  3016. // Static props
  3017. // bindings: null,
  3018. // bindingsData: null,
  3019. // html: null,
  3020. // isTemplateTag: false,
  3021. // fragment: null,
  3022. // children: null,
  3023. // dom: null,
  3024. // el: null,
  3025. /**
  3026. * Create the template DOM structure that will be cloned on each mount
  3027. * @param {HTMLElement} el - the root node
  3028. * @returns {TemplateChunk} self
  3029. */
  3030. createDOM(el) {
  3031. // make sure that the DOM gets created before cloning the template
  3032. this.dom = this.dom || createTemplateDOM(el, this.html) || document.createDocumentFragment();
  3033. return this;
  3034. },
  3035. // API methods
  3036. /**
  3037. * Attach the template to a DOM node
  3038. * @param {HTMLElement} el - target DOM node
  3039. * @param {*} scope - template data
  3040. * @param {*} parentScope - scope of the parent template tag
  3041. * @param {Object} meta - meta properties needed to handle the <template> tags in loops
  3042. * @returns {TemplateChunk} self
  3043. */
  3044. mount(el, scope, parentScope, meta) {
  3045. if (meta === void 0) {
  3046. meta = {};
  3047. }
  3048. if (!el) throw new Error('Please provide DOM node to mount properly your template');
  3049. if (this.el) this.unmount(scope); // <template> tags require a bit more work
  3050. // the template fragment might be already created via meta outside of this call
  3051. const {
  3052. fragment,
  3053. children,
  3054. avoidDOMInjection
  3055. } = meta; // <template> bindings of course can not have a root element
  3056. // so we check the parent node to set the query selector bindings
  3057. const {
  3058. parentNode
  3059. } = children ? children[0] : el;
  3060. const isTemplateTag = isTemplate(el);
  3061. const templateTagOffset = isTemplateTag ? getTemplateTagOffset(parentNode, el, meta) : null; // create the DOM if it wasn't created before
  3062. this.createDOM(el); // create the DOM of this template cloning the original DOM structure stored in this instance
  3063. // notice that if a documentFragment was passed (via meta) we will use it instead
  3064. const cloneNode = fragment || this.dom.cloneNode(true); // store root node
  3065. // notice that for template tags the root note will be the parent tag
  3066. this.el = isTemplateTag ? parentNode : el; // create the children array only for the <template> fragments
  3067. this.children = isTemplateTag ? children || Array.from(cloneNode.childNodes) : null; // inject the DOM into the el only if a fragment is available
  3068. if (!avoidDOMInjection && cloneNode) injectDOM(el, cloneNode); // create the bindings
  3069. this.bindings = this.bindingsData.map(binding => create$1(this.el, binding, templateTagOffset));
  3070. this.bindings.forEach(b => b.mount(scope, parentScope)); // store the template meta properties
  3071. this.meta = meta;
  3072. return this;
  3073. },
  3074. /**
  3075. * Update the template with fresh data
  3076. * @param {*} scope - template data
  3077. * @param {*} parentScope - scope of the parent template tag
  3078. * @returns {TemplateChunk} self
  3079. */
  3080. update(scope, parentScope) {
  3081. this.bindings.forEach(b => b.update(scope, parentScope));
  3082. return this;
  3083. },
  3084. /**
  3085. * Remove the template from the node where it was initially mounted
  3086. * @param {*} scope - template data
  3087. * @param {*} parentScope - scope of the parent template tag
  3088. * @param {boolean|null} mustRemoveRoot - if true remove the root element,
  3089. * if false or undefined clean the root tag content, if null don't touch the DOM
  3090. * @returns {TemplateChunk} self
  3091. */
  3092. unmount(scope, parentScope, mustRemoveRoot) {
  3093. if (mustRemoveRoot === void 0) {
  3094. mustRemoveRoot = false;
  3095. }
  3096. const el = this.el;
  3097. if (!el) {
  3098. return this;
  3099. }
  3100. this.bindings.forEach(b => b.unmount(scope, parentScope, mustRemoveRoot));
  3101. switch (true) {
  3102. // pure components should handle the DOM unmount updates by themselves
  3103. // for mustRemoveRoot === null don't touch the DOM
  3104. case el[IS_PURE_SYMBOL] || mustRemoveRoot === null:
  3105. break;
  3106. // if children are declared, clear them
  3107. // applicable for <template> and <slot/> bindings
  3108. case Array.isArray(this.children):
  3109. clearChildren(this.children);
  3110. break;
  3111. // clean the node children only
  3112. case !mustRemoveRoot:
  3113. cleanNode(el);
  3114. break;
  3115. // remove the root node only if the mustRemoveRoot is truly
  3116. case !!mustRemoveRoot:
  3117. removeChild(el);
  3118. break;
  3119. }
  3120. this.el = null;
  3121. return this;
  3122. },
  3123. /**
  3124. * Clone the template chunk
  3125. * @returns {TemplateChunk} a clone of this object resetting the this.el property
  3126. */
  3127. clone() {
  3128. return Object.assign({}, this, {
  3129. meta: {},
  3130. el: null
  3131. });
  3132. }
  3133. });
  3134. /**
  3135. * Create a template chunk wiring also the bindings
  3136. * @param {string|HTMLElement} html - template string
  3137. * @param {BindingData[]} bindings - bindings collection
  3138. * @returns {TemplateChunk} a new TemplateChunk copy
  3139. */
  3140. function create(html, bindings) {
  3141. if (bindings === void 0) {
  3142. bindings = [];
  3143. }
  3144. return Object.assign({}, TemplateChunk, {
  3145. html,
  3146. bindingsData: bindings
  3147. });
  3148. }
  3149. /**
  3150. * Method used to bind expressions to a DOM node
  3151. * @param {string|HTMLElement} html - your static template html structure
  3152. * @param {Array} bindings - list of the expressions to bind to update the markup
  3153. * @returns {TemplateChunk} a new TemplateChunk object having the `update`,`mount`, `unmount` and `clone` methods
  3154. *
  3155. * @example
  3156. *
  3157. * riotDOMBindings
  3158. * .template(
  3159. * `<div expr0><!----></div><div><p expr1><!----><section expr2></section></p>`,
  3160. * [
  3161. * {
  3162. * selector: '[expr0]',
  3163. * redundantAttribute: 'expr0',
  3164. * expressions: [
  3165. * {
  3166. * type: expressionTypes.TEXT,
  3167. * childNodeIndex: 0,
  3168. * evaluate(scope) {
  3169. * return scope.time;
  3170. * },
  3171. * },
  3172. * ],
  3173. * },
  3174. * {
  3175. * selector: '[expr1]',
  3176. * redundantAttribute: 'expr1',
  3177. * expressions: [
  3178. * {
  3179. * type: expressionTypes.TEXT,
  3180. * childNodeIndex: 0,
  3181. * evaluate(scope) {
  3182. * return scope.name;
  3183. * },
  3184. * },
  3185. * {
  3186. * type: 'attribute',
  3187. * name: 'style',
  3188. * evaluate(scope) {
  3189. * return scope.style;
  3190. * },
  3191. * },
  3192. * ],
  3193. * },
  3194. * {
  3195. * selector: '[expr2]',
  3196. * redundantAttribute: 'expr2',
  3197. * type: bindingTypes.IF,
  3198. * evaluate(scope) {
  3199. * return scope.isVisible;
  3200. * },
  3201. * template: riotDOMBindings.template('hello there'),
  3202. * },
  3203. * ]
  3204. * )
  3205. */
  3206. var DOMBindings = /*#__PURE__*/Object.freeze({
  3207. __proto__: null,
  3208. template: create,
  3209. createBinding: create$1,
  3210. createExpression: create$4,
  3211. bindingTypes: bindingTypes,
  3212. expressionTypes: expressionTypes
  3213. });
  3214. function noop() {
  3215. return this;
  3216. }
  3217. /**
  3218. * Autobind the methods of a source object to itself
  3219. * @param {Object} source - probably a riot tag instance
  3220. * @param {Array<string>} methods - list of the methods to autobind
  3221. * @returns {Object} the original object received
  3222. */
  3223. function autobindMethods(source, methods) {
  3224. methods.forEach(method => {
  3225. source[method] = source[method].bind(source);
  3226. });
  3227. return source;
  3228. }
  3229. /**
  3230. * Call the first argument received only if it's a function otherwise return it as it is
  3231. * @param {*} source - anything
  3232. * @returns {*} anything
  3233. */
  3234. function callOrAssign(source) {
  3235. return isFunction(source) ? source.prototype && source.prototype.constructor ? new source() : source() : source;
  3236. }
  3237. /**
  3238. * Converts any DOM node/s to a loopable array
  3239. * @param { HTMLElement|NodeList } els - single html element or a node list
  3240. * @returns { Array } always a loopable object
  3241. */
  3242. function domToArray(els) {
  3243. // can this object be already looped?
  3244. if (!Array.isArray(els)) {
  3245. // is it a node list?
  3246. 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
  3247. // it will be returned as "array" with one single entry
  3248. return [els];
  3249. } // this object could be looped out of the box
  3250. return els;
  3251. }
  3252. /**
  3253. * Simple helper to find DOM nodes returning them as array like loopable object
  3254. * @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
  3255. * @param { HTMLElement } ctx - context defining where the query will search for the DOM nodes
  3256. * @returns { Array } DOM nodes found as array
  3257. */
  3258. function $(selector, ctx) {
  3259. return domToArray(typeof selector === 'string' ? (ctx || document).querySelectorAll(selector) : selector);
  3260. }
  3261. /**
  3262. * Normalize the return values, in case of a single value we avoid to return an array
  3263. * @param { Array } values - list of values we want to return
  3264. * @returns { Array|string|boolean } either the whole list of values or the single one found
  3265. * @private
  3266. */
  3267. const normalize = values => values.length === 1 ? values[0] : values;
  3268. /**
  3269. * Parse all the nodes received to get/remove/check their attributes
  3270. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  3271. * @param { string|Array } name - name or list of attributes
  3272. * @param { string } method - method that will be used to parse the attributes
  3273. * @returns { Array|string } result of the parsing in a list or a single value
  3274. * @private
  3275. */
  3276. function parseNodes(els, name, method) {
  3277. const names = typeof name === 'string' ? [name] : name;
  3278. return normalize(domToArray(els).map(el => {
  3279. return normalize(names.map(n => el[method](n)));
  3280. }));
  3281. }
  3282. /**
  3283. * Set any attribute on a single or a list of DOM nodes
  3284. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  3285. * @param { string|Object } name - either the name of the attribute to set
  3286. * or a list of properties as object key - value
  3287. * @param { string } value - the new value of the attribute (optional)
  3288. * @returns { HTMLElement|NodeList|Array } the original array of elements passed to this function
  3289. *
  3290. * @example
  3291. *
  3292. * import { set } from 'bianco.attr'
  3293. *
  3294. * const img = document.createElement('img')
  3295. *
  3296. * set(img, 'width', 100)
  3297. *
  3298. * // or also
  3299. * set(img, {
  3300. * width: 300,
  3301. * height: 300
  3302. * })
  3303. *
  3304. */
  3305. function set(els, name, value) {
  3306. const attrs = typeof name === 'object' ? name : {
  3307. [name]: value
  3308. };
  3309. const props = Object.keys(attrs);
  3310. domToArray(els).forEach(el => {
  3311. props.forEach(prop => el.setAttribute(prop, attrs[prop]));
  3312. });
  3313. return els;
  3314. }
  3315. /**
  3316. * Get any attribute from a single or a list of DOM nodes
  3317. * @param { HTMLElement|NodeList|Array } els - DOM node/s to parse
  3318. * @param { string|Array } name - name or list of attributes to get
  3319. * @returns { Array|string } list of the attributes found
  3320. *
  3321. * @example
  3322. *
  3323. * import { get } from 'bianco.attr'
  3324. *
  3325. * const img = document.createElement('img')
  3326. *
  3327. * get(img, 'width') // => '200'
  3328. *
  3329. * // or also
  3330. * get(img, ['width', 'height']) // => ['200', '300']
  3331. *
  3332. * // or also
  3333. * get([img1, img2], ['width', 'height']) // => [['200', '300'], ['500', '200']]
  3334. */
  3335. function get(els, name) {
  3336. return parseNodes(els, name, 'getAttribute');
  3337. }
  3338. const CSS_BY_NAME = new Map();
  3339. const STYLE_NODE_SELECTOR = 'style[riot]'; // memoized curried function
  3340. const getStyleNode = (style => {
  3341. return () => {
  3342. // lazy evaluation:
  3343. // if this function was already called before
  3344. // we return its cached result
  3345. if (style) return style; // create a new style element or use an existing one
  3346. // and cache it internally
  3347. style = $(STYLE_NODE_SELECTOR)[0] || document.createElement('style');
  3348. set(style, 'type', 'text/css');
  3349. /* istanbul ignore next */
  3350. if (!style.parentNode) document.head.appendChild(style);
  3351. return style;
  3352. };
  3353. })();
  3354. /**
  3355. * Object that will be used to inject and manage the css of every tag instance
  3356. */
  3357. var cssManager = {
  3358. CSS_BY_NAME,
  3359. /**
  3360. * Save a tag style to be later injected into DOM
  3361. * @param { string } name - if it's passed we will map the css to a tagname
  3362. * @param { string } css - css string
  3363. * @returns {Object} self
  3364. */
  3365. add(name, css) {
  3366. if (!CSS_BY_NAME.has(name)) {
  3367. CSS_BY_NAME.set(name, css);
  3368. this.inject();
  3369. }
  3370. return this;
  3371. },
  3372. /**
  3373. * Inject all previously saved tag styles into DOM
  3374. * innerHTML seems slow: http://jsperf.com/riot-insert-style
  3375. * @returns {Object} self
  3376. */
  3377. inject() {
  3378. getStyleNode().innerHTML = [...CSS_BY_NAME.values()].join('\n');
  3379. return this;
  3380. },
  3381. /**
  3382. * Remove a tag style from the DOM
  3383. * @param {string} name a registered tagname
  3384. * @returns {Object} self
  3385. */
  3386. remove(name) {
  3387. if (CSS_BY_NAME.has(name)) {
  3388. CSS_BY_NAME.delete(name);
  3389. this.inject();
  3390. }
  3391. return this;
  3392. }
  3393. };
  3394. /**
  3395. * Function to curry any javascript method
  3396. * @param {Function} fn - the target function we want to curry
  3397. * @param {...[args]} acc - initial arguments
  3398. * @returns {Function|*} it will return a function until the target function
  3399. * will receive all of its arguments
  3400. */
  3401. function curry(fn) {
  3402. for (var _len = arguments.length, acc = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3403. acc[_key - 1] = arguments[_key];
  3404. }
  3405. return function () {
  3406. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3407. args[_key2] = arguments[_key2];
  3408. }
  3409. args = [...acc, ...args];
  3410. return args.length < fn.length ? curry(fn, ...args) : fn(...args);
  3411. };
  3412. }
  3413. /**
  3414. * Get the tag name of any DOM node
  3415. * @param {HTMLElement} element - DOM node we want to inspect
  3416. * @returns {string} name to identify this dom node in riot
  3417. */
  3418. function getName(element) {
  3419. return get(element, IS_DIRECTIVE) || element.tagName.toLowerCase();
  3420. }
  3421. const COMPONENT_CORE_HELPERS = Object.freeze({
  3422. // component helpers
  3423. $(selector) {
  3424. return $(selector, this.root)[0];
  3425. },
  3426. $$(selector) {
  3427. return $(selector, this.root);
  3428. }
  3429. });
  3430. const PURE_COMPONENT_API = Object.freeze({
  3431. [MOUNT_METHOD_KEY]: noop,
  3432. [UPDATE_METHOD_KEY]: noop,
  3433. [UNMOUNT_METHOD_KEY]: noop
  3434. });
  3435. const COMPONENT_LIFECYCLE_METHODS = Object.freeze({
  3436. [SHOULD_UPDATE_KEY]: noop,
  3437. [ON_BEFORE_MOUNT_KEY]: noop,
  3438. [ON_MOUNTED_KEY]: noop,
  3439. [ON_BEFORE_UPDATE_KEY]: noop,
  3440. [ON_UPDATED_KEY]: noop,
  3441. [ON_BEFORE_UNMOUNT_KEY]: noop,
  3442. [ON_UNMOUNTED_KEY]: noop
  3443. });
  3444. const MOCKED_TEMPLATE_INTERFACE = Object.assign({}, PURE_COMPONENT_API, {
  3445. clone: noop,
  3446. createDOM: noop
  3447. });
  3448. /**
  3449. * Performance optimization for the recursive components
  3450. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  3451. * @returns {Object} component like interface
  3452. */
  3453. const memoizedCreateComponent = memoize(createComponent);
  3454. /**
  3455. * Evaluate the component properties either from its real attributes or from its initial user properties
  3456. * @param {HTMLElement} element - component root
  3457. * @param {Object} initialProps - initial props
  3458. * @returns {Object} component props key value pairs
  3459. */
  3460. function evaluateInitialProps(element, initialProps) {
  3461. if (initialProps === void 0) {
  3462. initialProps = {};
  3463. }
  3464. return Object.assign({}, DOMattributesToObject(element), callOrAssign(initialProps));
  3465. }
  3466. /**
  3467. * Bind a DOM node to its component object
  3468. * @param {HTMLElement} node - html node mounted
  3469. * @param {Object} component - Riot.js component object
  3470. * @returns {Object} the component object received as second argument
  3471. */
  3472. const bindDOMNodeToComponentObject = (node, component) => node[DOM_COMPONENT_INSTANCE_PROPERTY$1] = component;
  3473. /**
  3474. * Wrap the Riot.js core API methods using a mapping function
  3475. * @param {Function} mapFunction - lifting function
  3476. * @returns {Object} an object having the { mount, update, unmount } functions
  3477. */
  3478. function createCoreAPIMethods(mapFunction) {
  3479. return [MOUNT_METHOD_KEY, UPDATE_METHOD_KEY, UNMOUNT_METHOD_KEY].reduce((acc, method) => {
  3480. acc[method] = mapFunction(method);
  3481. return acc;
  3482. }, {});
  3483. }
  3484. /**
  3485. * Factory function to create the component templates only once
  3486. * @param {Function} template - component template creation function
  3487. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  3488. * @returns {TemplateChunk} template chunk object
  3489. */
  3490. function componentTemplateFactory(template, componentWrapper) {
  3491. const components = createSubcomponents(componentWrapper.exports ? componentWrapper.exports.components : {});
  3492. return template(create, expressionTypes, bindingTypes, name => {
  3493. // improve support for recursive components
  3494. if (name === componentWrapper.name) return memoizedCreateComponent(componentWrapper); // return the registered components
  3495. return components[name] || COMPONENTS_IMPLEMENTATION_MAP$1.get(name);
  3496. });
  3497. }
  3498. /**
  3499. * Create a pure component
  3500. * @param {Function} pureFactoryFunction - pure component factory function
  3501. * @param {Array} options.slots - component slots
  3502. * @param {Array} options.attributes - component attributes
  3503. * @param {Array} options.template - template factory function
  3504. * @param {Array} options.template - template factory function
  3505. * @param {any} options.props - initial component properties
  3506. * @returns {Object} pure component object
  3507. */
  3508. function createPureComponent(pureFactoryFunction, _ref) {
  3509. let {
  3510. slots,
  3511. attributes,
  3512. props,
  3513. css,
  3514. template
  3515. } = _ref;
  3516. if (template) panic('Pure components can not have html');
  3517. if (css) panic('Pure components do not have css');
  3518. const component = defineDefaults(pureFactoryFunction({
  3519. slots,
  3520. attributes,
  3521. props
  3522. }), PURE_COMPONENT_API);
  3523. return createCoreAPIMethods(method => function () {
  3524. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3525. args[_key] = arguments[_key];
  3526. }
  3527. // intercept the mount calls to bind the DOM node to the pure object created
  3528. // see also https://github.com/riot/riot/issues/2806
  3529. if (method === MOUNT_METHOD_KEY) {
  3530. const [el] = args; // mark this node as pure element
  3531. el[IS_PURE_SYMBOL] = true;
  3532. bindDOMNodeToComponentObject(el, component);
  3533. }
  3534. component[method](...args);
  3535. return component;
  3536. });
  3537. }
  3538. /**
  3539. * Create the component interface needed for the @riotjs/dom-bindings tag bindings
  3540. * @param {RiotComponentWrapper} componentWrapper - riot compiler generated object
  3541. * @param {string} componentWrapper.css - component css
  3542. * @param {Function} componentWrapper.template - function that will return the dom-bindings template function
  3543. * @param {Object} componentWrapper.exports - component interface
  3544. * @param {string} componentWrapper.name - component name
  3545. * @returns {Object} component like interface
  3546. */
  3547. function createComponent(componentWrapper) {
  3548. const {
  3549. css,
  3550. template,
  3551. exports,
  3552. name
  3553. } = componentWrapper;
  3554. const templateFn = template ? componentTemplateFactory(template, componentWrapper) : MOCKED_TEMPLATE_INTERFACE;
  3555. return _ref2 => {
  3556. let {
  3557. slots,
  3558. attributes,
  3559. props
  3560. } = _ref2;
  3561. // pure components rendering will be managed by the end user
  3562. if (exports && exports[IS_PURE_SYMBOL]) return createPureComponent(exports, {
  3563. slots,
  3564. attributes,
  3565. props,
  3566. css,
  3567. template
  3568. });
  3569. const componentAPI = callOrAssign(exports) || {};
  3570. const component = defineComponent({
  3571. css,
  3572. template: templateFn,
  3573. componentAPI,
  3574. name
  3575. })({
  3576. slots,
  3577. attributes,
  3578. props
  3579. }); // notice that for the components create via tag binding
  3580. // we need to invert the mount (state/parentScope) arguments
  3581. // the template bindings will only forward the parentScope updates
  3582. // and never deal with the component state
  3583. return {
  3584. mount(element, parentScope, state) {
  3585. return component.mount(element, state, parentScope);
  3586. },
  3587. update(parentScope, state) {
  3588. return component.update(state, parentScope);
  3589. },
  3590. unmount(preserveRoot) {
  3591. return component.unmount(preserveRoot);
  3592. }
  3593. };
  3594. };
  3595. }
  3596. /**
  3597. * Component definition function
  3598. * @param {Object} implementation - the componen implementation will be generated via compiler
  3599. * @param {Object} component - the component initial properties
  3600. * @returns {Object} a new component implementation object
  3601. */
  3602. function defineComponent(_ref3) {
  3603. let {
  3604. css,
  3605. template,
  3606. componentAPI,
  3607. name
  3608. } = _ref3;
  3609. // add the component css into the DOM
  3610. if (css && name) cssManager.add(name, css);
  3611. return curry(enhanceComponentAPI)(defineProperties( // set the component defaults without overriding the original component API
  3612. defineDefaults(componentAPI, Object.assign({}, COMPONENT_LIFECYCLE_METHODS, {
  3613. [PROPS_KEY]: {},
  3614. [STATE_KEY]: {}
  3615. })), Object.assign({
  3616. // defined during the component creation
  3617. [SLOTS_KEY]: null,
  3618. [ROOT_KEY]: null
  3619. }, COMPONENT_CORE_HELPERS, {
  3620. name,
  3621. css,
  3622. template
  3623. })));
  3624. }
  3625. /**
  3626. * Create the bindings to update the component attributes
  3627. * @param {HTMLElement} node - node where we will bind the expressions
  3628. * @param {Array} attributes - list of attribute bindings
  3629. * @returns {TemplateChunk} - template bindings object
  3630. */
  3631. function createAttributeBindings(node, attributes) {
  3632. if (attributes === void 0) {
  3633. attributes = [];
  3634. }
  3635. const expressions = attributes.map(a => create$4(node, a));
  3636. const binding = {};
  3637. return Object.assign(binding, Object.assign({
  3638. expressions
  3639. }, createCoreAPIMethods(method => scope => {
  3640. expressions.forEach(e => e[method](scope));
  3641. return binding;
  3642. })));
  3643. }
  3644. /**
  3645. * Create the subcomponents that can be included inside a tag in runtime
  3646. * @param {Object} components - components imported in runtime
  3647. * @returns {Object} all the components transformed into Riot.Component factory functions
  3648. */
  3649. function createSubcomponents(components) {
  3650. if (components === void 0) {
  3651. components = {};
  3652. }
  3653. return Object.entries(callOrAssign(components)).reduce((acc, _ref4) => {
  3654. let [key, value] = _ref4;
  3655. acc[camelToDashCase(key)] = createComponent(value);
  3656. return acc;
  3657. }, {});
  3658. }
  3659. /**
  3660. * Run the component instance through all the plugins set by the user
  3661. * @param {Object} component - component instance
  3662. * @returns {Object} the component enhanced by the plugins
  3663. */
  3664. function runPlugins(component) {
  3665. return [...PLUGINS_SET$1].reduce((c, fn) => fn(c) || c, component);
  3666. }
  3667. /**
  3668. * Compute the component current state merging it with its previous state
  3669. * @param {Object} oldState - previous state object
  3670. * @param {Object} newState - new state givent to the `update` call
  3671. * @returns {Object} new object state
  3672. */
  3673. function computeState(oldState, newState) {
  3674. return Object.assign({}, oldState, callOrAssign(newState));
  3675. }
  3676. /**
  3677. * Add eventually the "is" attribute to link this DOM node to its css
  3678. * @param {HTMLElement} element - target root node
  3679. * @param {string} name - name of the component mounted
  3680. * @returns {undefined} it's a void function
  3681. */
  3682. function addCssHook(element, name) {
  3683. if (getName(element) !== name) {
  3684. set(element, IS_DIRECTIVE, name);
  3685. }
  3686. }
  3687. /**
  3688. * Component creation factory function that will enhance the user provided API
  3689. * @param {Object} component - a component implementation previously defined
  3690. * @param {Array} options.slots - component slots generated via riot compiler
  3691. * @param {Array} options.attributes - attribute expressions generated via riot compiler
  3692. * @returns {Riot.Component} a riot component instance
  3693. */
  3694. function enhanceComponentAPI(component, _ref5) {
  3695. let {
  3696. slots,
  3697. attributes,
  3698. props
  3699. } = _ref5;
  3700. return autobindMethods(runPlugins(defineProperties(isObject(component) ? Object.create(component) : component, {
  3701. mount(element, state, parentScope) {
  3702. if (state === void 0) {
  3703. state = {};
  3704. }
  3705. this[PARENT_KEY_SYMBOL] = parentScope;
  3706. this[ATTRIBUTES_KEY_SYMBOL] = createAttributeBindings(element, attributes).mount(parentScope);
  3707. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, evaluateInitialProps(element, props), evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions))));
  3708. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  3709. this[TEMPLATE_KEY_SYMBOL] = this.template.createDOM(element).clone(); // link this object to the DOM node
  3710. bindDOMNodeToComponentObject(element, this); // add eventually the 'is' attribute
  3711. component.name && addCssHook(element, component.name); // define the root element
  3712. defineProperty(this, ROOT_KEY, element); // define the slots array
  3713. defineProperty(this, SLOTS_KEY, slots); // before mount lifecycle event
  3714. this[ON_BEFORE_MOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]); // mount the template
  3715. this[TEMPLATE_KEY_SYMBOL].mount(element, this, parentScope);
  3716. this[ON_MOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3717. return this;
  3718. },
  3719. update(state, parentScope) {
  3720. if (state === void 0) {
  3721. state = {};
  3722. }
  3723. if (parentScope) {
  3724. this[PARENT_KEY_SYMBOL] = parentScope;
  3725. this[ATTRIBUTES_KEY_SYMBOL].update(parentScope);
  3726. }
  3727. const newProps = evaluateAttributeExpressions(this[ATTRIBUTES_KEY_SYMBOL].expressions);
  3728. if (this[SHOULD_UPDATE_KEY](newProps, this[PROPS_KEY]) === false) return;
  3729. defineProperty(this, PROPS_KEY, Object.freeze(Object.assign({}, this[PROPS_KEY], newProps)));
  3730. this[STATE_KEY] = computeState(this[STATE_KEY], state);
  3731. this[ON_BEFORE_UPDATE_KEY](this[PROPS_KEY], this[STATE_KEY]); // avoiding recursive updates
  3732. // see also https://github.com/riot/riot/issues/2895
  3733. if (!this[IS_COMPONENT_UPDATING]) {
  3734. this[IS_COMPONENT_UPDATING] = true;
  3735. this[TEMPLATE_KEY_SYMBOL].update(this, this[PARENT_KEY_SYMBOL]);
  3736. }
  3737. this[ON_UPDATED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3738. this[IS_COMPONENT_UPDATING] = false;
  3739. return this;
  3740. },
  3741. unmount(preserveRoot) {
  3742. this[ON_BEFORE_UNMOUNT_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3743. this[ATTRIBUTES_KEY_SYMBOL].unmount(); // if the preserveRoot is null the template html will be left untouched
  3744. // in that case the DOM cleanup will happen differently from a parent node
  3745. this[TEMPLATE_KEY_SYMBOL].unmount(this, this[PARENT_KEY_SYMBOL], preserveRoot === null ? null : !preserveRoot);
  3746. this[ON_UNMOUNTED_KEY](this[PROPS_KEY], this[STATE_KEY]);
  3747. return this;
  3748. }
  3749. })), Object.keys(component).filter(prop => isFunction(component[prop])));
  3750. }
  3751. /**
  3752. * Component initialization function starting from a DOM node
  3753. * @param {HTMLElement} element - element to upgrade
  3754. * @param {Object} initialProps - initial component properties
  3755. * @param {string} componentName - component id
  3756. * @returns {Object} a new component instance bound to a DOM node
  3757. */
  3758. function mountComponent(element, initialProps, componentName) {
  3759. const name = componentName || getName(element);
  3760. if (!COMPONENTS_IMPLEMENTATION_MAP$1.has(name)) panic(`The component named "${name}" was never registered`);
  3761. const component = COMPONENTS_IMPLEMENTATION_MAP$1.get(name)({
  3762. props: initialProps
  3763. });
  3764. return component.mount(element);
  3765. }
  3766. /**
  3767. * Similar to compose but performs from left-to-right function composition.<br/>
  3768. * {@link https://30secondsofcode.org/function#composeright see also}
  3769. * @param {...[function]} fns) - list of unary function
  3770. * @returns {*} result of the computation
  3771. */
  3772. /**
  3773. * Performs right-to-left function composition.<br/>
  3774. * Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
  3775. * The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
  3776. * {@link https://30secondsofcode.org/function#compose original source code}
  3777. * @param {...[function]} fns) - list of unary function
  3778. * @returns {*} result of the computation
  3779. */
  3780. function compose() {
  3781. for (var _len2 = arguments.length, fns = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3782. fns[_key2] = arguments[_key2];
  3783. }
  3784. return fns.reduce((f, g) => function () {
  3785. return f(g(...arguments));
  3786. });
  3787. }
  3788. const {
  3789. DOM_COMPONENT_INSTANCE_PROPERTY,
  3790. COMPONENTS_IMPLEMENTATION_MAP,
  3791. PLUGINS_SET
  3792. } = globals;
  3793. /**
  3794. * Riot public api
  3795. */
  3796. /**
  3797. * Register a custom tag by name
  3798. * @param {string} name - component name
  3799. * @param {Object} implementation - tag implementation
  3800. * @returns {Map} map containing all the components implementations
  3801. */
  3802. function register(name, _ref) {
  3803. let {
  3804. css,
  3805. template,
  3806. exports
  3807. } = _ref;
  3808. if (COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was already registered`);
  3809. COMPONENTS_IMPLEMENTATION_MAP.set(name, createComponent({
  3810. name,
  3811. css,
  3812. template,
  3813. exports
  3814. }));
  3815. return COMPONENTS_IMPLEMENTATION_MAP;
  3816. }
  3817. /**
  3818. * Unregister a riot web component
  3819. * @param {string} name - component name
  3820. * @returns {Map} map containing all the components implementations
  3821. */
  3822. function unregister(name) {
  3823. if (!COMPONENTS_IMPLEMENTATION_MAP.has(name)) panic(`The component "${name}" was never registered`);
  3824. COMPONENTS_IMPLEMENTATION_MAP.delete(name);
  3825. cssManager.remove(name);
  3826. return COMPONENTS_IMPLEMENTATION_MAP;
  3827. }
  3828. /**
  3829. * Mounting function that will work only for the components that were globally registered
  3830. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  3831. * @param {Object} initialProps - the initial component properties
  3832. * @param {string} name - optional component name
  3833. * @returns {Array} list of riot components
  3834. */
  3835. function mount(selector, initialProps, name) {
  3836. return $(selector).map(element => mountComponent(element, initialProps, name));
  3837. }
  3838. /**
  3839. * Sweet unmounting helper function for the DOM node mounted manually by the user
  3840. * @param {string|HTMLElement} selector - query for the selection or a DOM element
  3841. * @param {boolean|null} keepRootElement - if true keep the root element
  3842. * @returns {Array} list of nodes unmounted
  3843. */
  3844. function unmount(selector, keepRootElement) {
  3845. return $(selector).map(element => {
  3846. if (element[DOM_COMPONENT_INSTANCE_PROPERTY]) {
  3847. element[DOM_COMPONENT_INSTANCE_PROPERTY].unmount(keepRootElement);
  3848. }
  3849. return element;
  3850. });
  3851. }
  3852. /**
  3853. * Define a riot plugin
  3854. * @param {Function} plugin - function that will receive all the components created
  3855. * @returns {Set} the set containing all the plugins installed
  3856. */
  3857. function install(plugin) {
  3858. if (!isFunction(plugin)) panic('Plugins must be of type function');
  3859. if (PLUGINS_SET.has(plugin)) panic('This plugin was already installed');
  3860. PLUGINS_SET.add(plugin);
  3861. return PLUGINS_SET;
  3862. }
  3863. /**
  3864. * Uninstall a riot plugin
  3865. * @param {Function} plugin - plugin previously installed
  3866. * @returns {Set} the set containing all the plugins installed
  3867. */
  3868. function uninstall(plugin) {
  3869. if (!PLUGINS_SET.has(plugin)) panic('This plugin was never installed');
  3870. PLUGINS_SET.delete(plugin);
  3871. return PLUGINS_SET;
  3872. }
  3873. /**
  3874. * Helper method to create component without relying on the registered ones
  3875. * @param {Object} implementation - component implementation
  3876. * @returns {Function} function that will allow you to mount a riot component on a DOM node
  3877. */
  3878. function component(implementation) {
  3879. return function (el, props, _temp) {
  3880. let {
  3881. slots,
  3882. attributes,
  3883. parentScope
  3884. } = _temp === void 0 ? {} : _temp;
  3885. return compose(c => c.mount(el, parentScope), c => c({
  3886. props,
  3887. slots,
  3888. attributes
  3889. }), createComponent)(implementation);
  3890. };
  3891. }
  3892. /**
  3893. * Lift a riot component Interface into a pure riot object
  3894. * @param {Function} func - RiotPureComponent factory function
  3895. * @returns {Function} the lifted original function received as argument
  3896. */
  3897. function pure(func) {
  3898. if (!isFunction(func)) panic('riot.pure accepts only arguments of type "function"');
  3899. func[IS_PURE_SYMBOL] = true;
  3900. return func;
  3901. }
  3902. /**
  3903. * no-op function needed to add the proper types to your component via typescript
  3904. * @param {Function|Object} component - component default export
  3905. * @returns {Function|Object} returns exactly what it has received
  3906. */
  3907. const withTypes = component => component;
  3908. /** @type {string} current riot version */
  3909. const version = 'v6.0.1'; // expose some internal stuff that might be used from external tools
  3910. const __ = {
  3911. cssManager,
  3912. DOMBindings,
  3913. createComponent,
  3914. defineComponent,
  3915. globals
  3916. };
  3917. /***/ })
  3918. /******/ });
  3919. /************************************************************************/
  3920. /******/ // The module cache
  3921. /******/ var __webpack_module_cache__ = {};
  3922. /******/
  3923. /******/ // The require function
  3924. /******/ function __webpack_require__(moduleId) {
  3925. /******/ // Check if module is in cache
  3926. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  3927. /******/ if (cachedModule !== undefined) {
  3928. /******/ return cachedModule.exports;
  3929. /******/ }
  3930. /******/ // Create a new module (and put it into the cache)
  3931. /******/ var module = __webpack_module_cache__[moduleId] = {
  3932. /******/ // no module.id needed
  3933. /******/ // no module.loaded needed
  3934. /******/ exports: {}
  3935. /******/ };
  3936. /******/
  3937. /******/ // Execute the module function
  3938. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  3939. /******/
  3940. /******/ // Return the exports of the module
  3941. /******/ return module.exports;
  3942. /******/ }
  3943. /******/
  3944. /******/ // expose the modules object (__webpack_modules__)
  3945. /******/ __webpack_require__.m = __webpack_modules__;
  3946. /******/
  3947. /************************************************************************/
  3948. /******/ /* webpack/runtime/chunk loaded */
  3949. /******/ (() => {
  3950. /******/ var deferred = [];
  3951. /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
  3952. /******/ if(chunkIds) {
  3953. /******/ priority = priority || 0;
  3954. /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
  3955. /******/ deferred[i] = [chunkIds, fn, priority];
  3956. /******/ return;
  3957. /******/ }
  3958. /******/ var notFulfilled = Infinity;
  3959. /******/ for (var i = 0; i < deferred.length; i++) {
  3960. /******/ var [chunkIds, fn, priority] = deferred[i];
  3961. /******/ var fulfilled = true;
  3962. /******/ for (var j = 0; j < chunkIds.length; j++) {
  3963. /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
  3964. /******/ chunkIds.splice(j--, 1);
  3965. /******/ } else {
  3966. /******/ fulfilled = false;
  3967. /******/ if(priority < notFulfilled) notFulfilled = priority;
  3968. /******/ }
  3969. /******/ }
  3970. /******/ if(fulfilled) {
  3971. /******/ deferred.splice(i--, 1)
  3972. /******/ result = fn();
  3973. /******/ }
  3974. /******/ }
  3975. /******/ return result;
  3976. /******/ };
  3977. /******/ })();
  3978. /******/
  3979. /******/ /* webpack/runtime/define property getters */
  3980. /******/ (() => {
  3981. /******/ // define getter functions for harmony exports
  3982. /******/ __webpack_require__.d = (exports, definition) => {
  3983. /******/ for(var key in definition) {
  3984. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  3985. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  3986. /******/ }
  3987. /******/ }
  3988. /******/ };
  3989. /******/ })();
  3990. /******/
  3991. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  3992. /******/ (() => {
  3993. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  3994. /******/ })();
  3995. /******/
  3996. /******/ /* webpack/runtime/make namespace object */
  3997. /******/ (() => {
  3998. /******/ // define __esModule on exports
  3999. /******/ __webpack_require__.r = (exports) => {
  4000. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  4001. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  4002. /******/ }
  4003. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  4004. /******/ };
  4005. /******/ })();
  4006. /******/
  4007. /******/ /* webpack/runtime/jsonp chunk loading */
  4008. /******/ (() => {
  4009. /******/ // no baseURI
  4010. /******/
  4011. /******/ // object to store loaded and loading chunks
  4012. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  4013. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  4014. /******/ var installedChunks = {
  4015. /******/ "/public/js/index": 0,
  4016. /******/ "public/css/index": 0
  4017. /******/ };
  4018. /******/
  4019. /******/ // no chunk on demand loading
  4020. /******/
  4021. /******/ // no prefetching
  4022. /******/
  4023. /******/ // no preloaded
  4024. /******/
  4025. /******/ // no HMR
  4026. /******/
  4027. /******/ // no HMR manifest
  4028. /******/
  4029. /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
  4030. /******/
  4031. /******/ // install a JSONP callback for chunk loading
  4032. /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
  4033. /******/ var [chunkIds, moreModules, runtime] = data;
  4034. /******/ // add "moreModules" to the modules object,
  4035. /******/ // then flag all "chunkIds" as loaded and fire callback
  4036. /******/ var moduleId, chunkId, i = 0;
  4037. /******/ for(moduleId in moreModules) {
  4038. /******/ if(__webpack_require__.o(moreModules, moduleId)) {
  4039. /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
  4040. /******/ }
  4041. /******/ }
  4042. /******/ if(runtime) var result = runtime(__webpack_require__);
  4043. /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
  4044. /******/ for(;i < chunkIds.length; i++) {
  4045. /******/ chunkId = chunkIds[i];
  4046. /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
  4047. /******/ installedChunks[chunkId][0]();
  4048. /******/ }
  4049. /******/ installedChunks[chunkIds[i]] = 0;
  4050. /******/ }
  4051. /******/ return __webpack_require__.O(result);
  4052. /******/ }
  4053. /******/
  4054. /******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
  4055. /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
  4056. /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
  4057. /******/ })();
  4058. /******/
  4059. /************************************************************************/
  4060. /******/
  4061. /******/ // startup
  4062. /******/ // Load entry module and return exports
  4063. /******/ // This entry module depends on other loaded chunks and execution need to be delayed
  4064. /******/ __webpack_require__.O(undefined, ["public/css/index"], () => (__webpack_require__("./resources/js/index.js")))
  4065. /******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["public/css/index"], () => (__webpack_require__("./resources/scss/index.scss")))
  4066. /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
  4067. /******/
  4068. /******/ })()
  4069. ;