From 79150f423ba2dfaed6fcd40e85e0a473d3cf9a82 Mon Sep 17 00:00:00 2001 From: Timur Minulin Date: Mon, 22 Apr 2019 17:23:47 +0300 Subject: [PATCH] fix: Use cross-fetch instead of isomorphic-fetch to allow React-Native builds (#92) * fix: Use cross-fetch instead of isomorphic-fetch to allow React-Native builds * fix: remove eslint instruction because using ponyfill * fix: add built files after removing comment --- .../dist/cubejs-client-core.esm.js | 786 ++++ .../dist/cubejs-client-core.js | 3 +- .../dist/cubejs-client-core.umd.js | 944 ++--- packages/cubejs-client-core/package.json | 2 +- packages/cubejs-client-core/src/index.js | 5 +- packages/cubejs-client-core/yarn.lock | 41 +- .../cubejs-react/dist/cubejs-react.esm.js | 599 ++++ .../cubejs-react/dist/cubejs-react.umd.js | 3168 ++++------------- 8 files changed, 2646 insertions(+), 2902 deletions(-) create mode 100644 packages/cubejs-client-core/dist/cubejs-client-core.esm.js create mode 100644 packages/cubejs-react/dist/cubejs-react.esm.js diff --git a/packages/cubejs-client-core/dist/cubejs-client-core.esm.js b/packages/cubejs-client-core/dist/cubejs-client-core.esm.js new file mode 100644 index 0000000000000..d656450fdabfc --- /dev/null +++ b/packages/cubejs-client-core/dist/cubejs-client-core.esm.js @@ -0,0 +1,786 @@ +import 'core-js/modules/es6.number.constructor'; +import 'core-js/modules/es6.number.parse-float'; +import _objectSpread from '@babel/runtime/helpers/objectSpread'; +import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; +import 'core-js/modules/es6.object.assign'; +import _defineProperty from '@babel/runtime/helpers/defineProperty'; +import 'core-js/modules/es6.array.reduce'; +import 'core-js/modules/es6.array.find'; +import 'core-js/modules/es6.array.filter'; +import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; +import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; +import _createClass from '@babel/runtime/helpers/createClass'; +import 'core-js/modules/es6.string.iterator'; +import 'core-js/modules/es6.array.from'; +import 'core-js/modules/es6.array.map'; +import { groupBy, pipe, toPairs, uniq, filter, map, unnest, dropLast, equals, reduce, minBy, maxBy, fromPairs } from 'ramda'; +import Moment from 'moment'; +import momentRange from 'moment-range'; +import 'core-js/modules/web.dom.iterable'; +import 'core-js/modules/es6.array.iterator'; +import 'core-js/modules/es6.object.keys'; +import 'core-js/modules/es6.array.is-array'; +import 'core-js/modules/es6.regexp.split'; +import 'core-js/modules/es6.function.name'; +import _regeneratorRuntime from '@babel/runtime/regenerator'; +import 'regenerator-runtime/runtime'; +import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; +import 'core-js/modules/es6.promise'; +import fetch from 'cross-fetch'; + +var moment = momentRange.extendMoment(Moment); +var TIME_SERIES = { + day: function day(range) { + return Array.from(range.by('day')).map(function (d) { + return d.format('YYYY-MM-DDT00:00:00.000'); + }); + }, + month: function month(range) { + return Array.from(range.snapTo('month').by('month')).map(function (d) { + return d.format('YYYY-MM-01T00:00:00.000'); + }); + }, + year: function year(range) { + return Array.from(range.snapTo('year').by('year')).map(function (d) { + return d.format('YYYY-01-01T00:00:00.000'); + }); + }, + hour: function hour(range) { + return Array.from(range.by('hour')).map(function (d) { + return d.format('YYYY-MM-DDTHH:00:00.000'); + }); + }, + week: function week(range) { + return Array.from(range.snapTo('isoweek').by('week')).map(function (d) { + return d.startOf('isoweek').format('YYYY-MM-DDT00:00:00.000'); + }); + } +}; + +var ResultSet = +/*#__PURE__*/ +function () { + function ResultSet(loadResponse) { + _classCallCheck(this, ResultSet); + + this.loadResponse = loadResponse; + } + + _createClass(ResultSet, [{ + key: "series", + value: function series(pivotConfig) { + var _this = this; + + return this.seriesNames(pivotConfig).map(function (_ref) { + var title = _ref.title, + key = _ref.key; + return { + title: title, + series: _this.chartPivot(pivotConfig).map(function (_ref2) { + var category = _ref2.category, + x = _ref2.x, + obj = _objectWithoutProperties(_ref2, ["category", "x"]); + + return { + value: obj[key], + category: category, + x: x + }; + }) + }; + }); + } + }, { + key: "axisValues", + value: function axisValues(axis) { + var query = this.loadResponse.query; + return function (row) { + var value = function value(measure) { + return axis.filter(function (d) { + return d !== 'measures'; + }).map(function (d) { + return row[d] != null ? row[d] : null; + }).concat(measure ? [measure] : []); + }; + + if (axis.find(function (d) { + return d === 'measures'; + }) && (query.measures || []).length) { + return query.measures.map(value); + } + + return [value()]; + }; + } + }, { + key: "axisValuesString", + value: function axisValuesString(axisValues, delimiter) { + var formatValue = function formatValue(v) { + if (v == null) { + return '∅'; + } else if (v === '') { + return '[Empty string]'; + } else { + return v; + } + }; + + return axisValues.map(formatValue).join(delimiter || ':'); + } + }, { + key: "normalizePivotConfig", + value: function normalizePivotConfig(pivotConfig) { + var query = this.loadResponse.query; + var timeDimensions = (query.timeDimensions || []).filter(function (td) { + return !!td.granularity; + }); + pivotConfig = pivotConfig || (timeDimensions.length ? { + x: timeDimensions.map(function (td) { + return td.dimension; + }), + y: query.dimensions || [] + } : { + x: query.dimensions || [], + y: [] + }); + + if (!pivotConfig.x.concat(pivotConfig.y).find(function (d) { + return d === 'measures'; + })) { + pivotConfig.y = pivotConfig.y.concat(['measures']); + } + + if (pivotConfig.fillMissingDates == null) { + pivotConfig.fillMissingDates = true; + } + + return pivotConfig; + } + }, { + key: "timeSeries", + value: function timeSeries(timeDimension) { + if (!timeDimension.granularity) { + return null; + } + + var dateRange = timeDimension.dateRange; + + if (!dateRange) { + var dates = pipe(map(function (row) { + return row[timeDimension.dimension] && moment(row[timeDimension.dimension]); + }), filter(function (r) { + return !!r; + }))(this.loadResponse.data); + dateRange = dates.length && [reduce(minBy(function (d) { + return d.toDate(); + }), dates[0], dates), reduce(maxBy(function (d) { + return d.toDate(); + }), dates[0], dates)] || null; + } + + if (!dateRange) { + return null; + } + + var start = moment(dateRange[0]).format('YYYY-MM-DD 00:00:00'); + var end = moment(dateRange[1]).format('YYYY-MM-DD 23:59:59'); + var range = moment.range(start, end); + + if (!TIME_SERIES[timeDimension.granularity]) { + throw new Error("Unsupported time granularity: ".concat(timeDimension.granularity)); + } + + return TIME_SERIES[timeDimension.granularity](range); + } + }, { + key: "pivot", + value: function pivot(pivotConfig) { + var _this2 = this; + + pivotConfig = this.normalizePivotConfig(pivotConfig); + var groupByXAxis = groupBy(function (_ref3) { + var xValues = _ref3.xValues; + return _this2.axisValuesString(xValues); + }); // eslint-disable-next-line no-unused-vars + + var measureValue = function measureValue(row, measure, xValues) { + return row[measure]; + }; + + if (pivotConfig.fillMissingDates && pivotConfig.x.length === 1 && equals(pivotConfig.x, (this.loadResponse.query.timeDimensions || []).filter(function (td) { + return !!td.granularity; + }).map(function (td) { + return td.dimension; + }))) { + var series = this.timeSeries(this.loadResponse.query.timeDimensions[0]); + + if (series) { + groupByXAxis = function groupByXAxis(rows) { + var byXValues = groupBy(function (_ref4) { + var xValues = _ref4.xValues; + return moment(xValues[0]).format(moment.HTML5_FMT.DATETIME_LOCAL_MS); + }, rows); + return series.map(function (d) { + return _defineProperty({}, d, byXValues[d] || [{ + xValues: [d], + row: {} + }]); + }).reduce(function (a, b) { + return Object.assign(a, b); + }, {}); + }; // eslint-disable-next-line no-unused-vars + + + measureValue = function measureValue(row, measure, xValues) { + return row[measure] || 0; + }; + } + } + + var xGrouped = pipe(map(function (row) { + return _this2.axisValues(pivotConfig.x)(row).map(function (xValues) { + return { + xValues: xValues, + row: row + }; + }); + }), unnest, groupByXAxis, toPairs)(this.loadResponse.data); + var allYValues = pipe(map( // eslint-disable-next-line no-unused-vars + function (_ref6) { + var _ref7 = _slicedToArray(_ref6, 2), + xValuesString = _ref7[0], + rows = _ref7[1]; + + return unnest(rows.map(function (_ref8) { + var row = _ref8.row; + return _this2.axisValues(pivotConfig.y)(row); + })); + }), unnest, uniq)(xGrouped); // eslint-disable-next-line no-unused-vars + + return xGrouped.map(function (_ref9) { + var _ref10 = _slicedToArray(_ref9, 2), + xValuesString = _ref10[0], + rows = _ref10[1]; + + var xValues = rows[0].xValues; + var yGrouped = pipe(map(function (_ref11) { + var row = _ref11.row; + return _this2.axisValues(pivotConfig.y)(row).map(function (yValues) { + return { + yValues: yValues, + row: row + }; + }); + }), unnest, groupBy(function (_ref12) { + var yValues = _ref12.yValues; + return _this2.axisValuesString(yValues); + }))(rows); + return { + xValues: xValues, + yValuesArray: unnest(allYValues.map(function (yValues) { + var measure = pivotConfig.x.find(function (d) { + return d === 'measures'; + }) ? ResultSet.measureFromAxis(xValues) : ResultSet.measureFromAxis(yValues); + return (yGrouped[_this2.axisValuesString(yValues)] || [{ + row: {} + }]).map(function (_ref13) { + var row = _ref13.row; + return [yValues, measureValue(row, measure, xValues)]; + }); + })) + }; + }); + } + }, { + key: "pivotedRows", + value: function pivotedRows(pivotConfig) { + // TODO + return this.chartPivot(pivotConfig); + } + }, { + key: "chartPivot", + value: function chartPivot(pivotConfig) { + var _this3 = this; + + return this.pivot(pivotConfig).map(function (_ref14) { + var xValues = _ref14.xValues, + yValuesArray = _ref14.yValuesArray; + return _objectSpread({ + category: _this3.axisValuesString(xValues, ', '), + // TODO deprecated + x: _this3.axisValuesString(xValues, ', ') + }, yValuesArray.map(function (_ref15) { + var _ref16 = _slicedToArray(_ref15, 2), + yValues = _ref16[0], + m = _ref16[1]; + + return _defineProperty({}, _this3.axisValuesString(yValues, ', '), m && Number.parseFloat(m)); + }).reduce(function (a, b) { + return Object.assign(a, b); + }, {})); + }); + } + }, { + key: "tablePivot", + value: function tablePivot(pivotConfig) { + var normalizedPivotConfig = this.normalizePivotConfig(pivotConfig); + + var valueToObject = function valueToObject(valuesArray, measureValue) { + return function (field, index) { + return _defineProperty({}, field === 'measures' ? valuesArray[index] : field, field === 'measures' ? measureValue : valuesArray[index]); + }; + }; + + return this.pivot(pivotConfig).map(function (_ref19) { + var xValues = _ref19.xValues, + yValuesArray = _ref19.yValuesArray; + return yValuesArray.map(function (_ref20) { + var _ref21 = _slicedToArray(_ref20, 2), + yValues = _ref21[0], + m = _ref21[1]; + + return normalizedPivotConfig.x.map(valueToObject(xValues, m)).concat(normalizedPivotConfig.y.map(valueToObject(yValues, m))).reduce(function (a, b) { + return Object.assign(a, b); + }, {}); + }); + }).reduce(function (a, b) { + return a.concat(b); + }); + } + }, { + key: "tableColumns", + value: function tableColumns(pivotConfig) { + var _this4 = this; + + var normalizedPivotConfig = this.normalizePivotConfig(pivotConfig); + + var column = function column(field) { + return field === 'measures' ? (_this4.query().measures || []).map(function (m) { + return { + key: m, + title: _this4.loadResponse.annotation.measures[m].title + }; + }) : [{ + key: field, + title: (_this4.loadResponse.annotation.dimensions[field] || _this4.loadResponse.annotation.timeDimensions[field]).title + }]; + }; + + return normalizedPivotConfig.x.map(column).concat(normalizedPivotConfig.y.map(column)).reduce(function (a, b) { + return a.concat(b); + }); + } + }, { + key: "totalRow", + value: function totalRow() { + return this.chartPivot()[0]; + } + }, { + key: "categories", + value: function categories(pivotConfig) { + // TODO + return this.chartPivot(pivotConfig); + } + }, { + key: "seriesNames", + value: function seriesNames(pivotConfig) { + var _this5 = this; + + pivotConfig = this.normalizePivotConfig(pivotConfig); + return pipe(map(this.axisValues(pivotConfig.y)), unnest, uniq)(this.loadResponse.data).map(function (axisValues) { + return { + title: _this5.axisValuesString(pivotConfig.y.find(function (d) { + return d === 'measures'; + }) ? dropLast(1, axisValues).concat(_this5.loadResponse.annotation.measures[ResultSet.measureFromAxis(axisValues)].title) : axisValues, ', '), + key: _this5.axisValuesString(axisValues) + }; + }); + } + }, { + key: "query", + value: function query() { + return this.loadResponse.query; + } + }, { + key: "rawData", + value: function rawData() { + return this.loadResponse.data; + } + }], [{ + key: "measureFromAxis", + value: function measureFromAxis(axisValues) { + return axisValues[axisValues.length - 1]; + } + }]); + + return ResultSet; +}(); + +var SqlQuery = +/*#__PURE__*/ +function () { + function SqlQuery(sqlQuery) { + _classCallCheck(this, SqlQuery); + + this.sqlQuery = sqlQuery; + } + + _createClass(SqlQuery, [{ + key: "rawQuery", + value: function rawQuery() { + return this.sqlQuery.sql; + } + }, { + key: "sql", + value: function sql() { + return this.rawQuery().sql[0]; + } + }]); + + return SqlQuery; +}(); + +var memberMap = function memberMap(memberArray) { + return fromPairs(memberArray.map(function (m) { + return [m.name, m]; + })); +}; + +var operators = { + string: [{ + name: 'contains', + title: 'contains' + }, { + name: 'notContains', + title: 'does not contain' + }, { + name: 'equals', + title: 'equals' + }, { + name: 'notEquals', + title: 'does not equal' + }, { + name: 'set', + title: 'is set' + }, { + name: 'notSet', + title: 'is not set' + }], + number: [{ + name: 'equals', + title: 'equals' + }, { + name: 'notEquals', + title: 'does not equal' + }, { + name: 'set', + title: 'is set' + }, { + name: 'notSet', + title: 'is not set' + }, { + name: 'gt', + title: '>' + }, { + name: 'gte', + title: '>=' + }, { + name: 'lt', + title: '<' + }, { + name: 'lte', + title: '<=' + }] +}; + +var Meta = +/*#__PURE__*/ +function () { + function Meta(metaResponse) { + _classCallCheck(this, Meta); + + this.meta = metaResponse; + var cubes = this.meta.cubes; + this.cubes = cubes; + this.cubesMap = fromPairs(cubes.map(function (c) { + return [c.name, { + measures: memberMap(c.measures), + dimensions: memberMap(c.dimensions), + segments: memberMap(c.segments) + }]; + })); + } + + _createClass(Meta, [{ + key: "membersForQuery", + value: function membersForQuery(query, memberType) { + return unnest(this.cubes.map(function (c) { + return c[memberType]; + })); + } + }, { + key: "resolveMember", + value: function resolveMember(memberName, memberType) { + var _this = this; + + var _memberName$split = memberName.split('.'), + _memberName$split2 = _slicedToArray(_memberName$split, 1), + cube = _memberName$split2[0]; + + if (!this.cubesMap[cube]) { + return { + title: memberName, + error: "Cube not found ".concat(cube, " for path '").concat(memberName, "'") + }; + } + + var memberTypes = Array.isArray(memberType) ? memberType : [memberType]; + var member = memberTypes.map(function (type) { + return _this.cubesMap[cube][type] && _this.cubesMap[cube][type][memberName]; + }).find(function (m) { + return m; + }); + + if (!member) { + return { + title: memberName, + error: "Path not found '".concat(memberName, "'") + }; + } + + return member; + } + }, { + key: "defaultTimeDimensionNameFor", + value: function defaultTimeDimensionNameFor(memberName) { + var _this2 = this; + + var _memberName$split3 = memberName.split('.'), + _memberName$split4 = _slicedToArray(_memberName$split3, 1), + cube = _memberName$split4[0]; + + if (!this.cubesMap[cube]) { + return null; + } + + return Object.keys(this.cubesMap[cube].dimensions || {}).find(function (d) { + return _this2.cubesMap[cube].dimensions[d].type === 'time'; + }); + } + }, { + key: "filterOperatorsForMember", + value: function filterOperatorsForMember(memberName, memberType) { + var member = this.resolveMember(memberName, memberType); + return operators[member.type] || operators.string; + } + }]); + + return Meta; +}(); + +var ProgressResult = +/*#__PURE__*/ +function () { + function ProgressResult(progressResponse) { + _classCallCheck(this, ProgressResult); + + this.progressResponse = progressResponse; + } + + _createClass(ProgressResult, [{ + key: "stage", + value: function stage() { + return this.progressResponse.stage; + } + }, { + key: "timeElapsed", + value: function timeElapsed() { + return this.progressResponse.timeElapsed; + } + }]); + + return ProgressResult; +}(); + +var API_URL = "https://statsbot.co/cubejs-api/v1"; +var mutexCounter = 0; +var MUTEX_ERROR = 'Mutex has been changed'; + +var mutexPromise = function mutexPromise(promise) { + return new Promise(function (resolve, reject) { + promise.then(function (r) { + return resolve(r); + }, function (e) { + return e !== MUTEX_ERROR && reject(e); + }); + }); +}; + +var CubejsApi = +/*#__PURE__*/ +function () { + function CubejsApi(apiToken, options) { + _classCallCheck(this, CubejsApi); + + options = options || {}; + this.apiToken = apiToken; + this.apiUrl = options.apiUrl || API_URL; + } + + _createClass(CubejsApi, [{ + key: "request", + value: function request(url, config) { + return fetch("".concat(this.apiUrl).concat(url), Object.assign({ + headers: { + Authorization: this.apiToken, + 'Content-Type': 'application/json' + } + }, config || {})); + } + }, { + key: "loadMethod", + value: function loadMethod(request, toResult, options, callback) { + var mutexValue = ++mutexCounter; + + if (typeof options === 'function' && !callback) { + callback = options; + options = undefined; + } + + options = options || {}; + var mutexKey = options.mutexKey || 'default'; + + if (options.mutexObj) { + options.mutexObj[mutexKey] = mutexValue; + } + + var checkMutex = function checkMutex() { + if (options.mutexObj && options.mutexObj[mutexKey] !== mutexValue) { + throw MUTEX_ERROR; + } + }; + + var loadImpl = + /*#__PURE__*/ + function () { + var _ref = _asyncToGenerator( + /*#__PURE__*/ + _regeneratorRuntime.mark(function _callee() { + var response, body; + return _regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return request(); + + case 2: + response = _context.sent; + + if (!(response.status === 502)) { + _context.next = 6; + break; + } + + checkMutex(); + return _context.abrupt("return", loadImpl()); + + case 6: + _context.next = 8; + return response.json(); + + case 8: + body = _context.sent; + + if (!(body.error === 'Continue wait')) { + _context.next = 13; + break; + } + + checkMutex(); + + if (options.progressCallback) { + options.progressCallback(new ProgressResult(body)); + } + + return _context.abrupt("return", loadImpl()); + + case 13: + if (!(response.status !== 200)) { + _context.next = 16; + break; + } + + checkMutex(); + throw new Error(body.error); + + case 16: + checkMutex(); + return _context.abrupt("return", toResult(body)); + + case 18: + case "end": + return _context.stop(); + } + } + }, _callee, this); + })); + + return function loadImpl() { + return _ref.apply(this, arguments); + }; + }(); + + if (callback) { + mutexPromise(loadImpl()).then(function (r) { + return callback(null, r); + }, function (e) { + return callback(e); + }); + } else { + return mutexPromise(loadImpl()); + } + } + }, { + key: "load", + value: function load(query, options, callback) { + var _this = this; + + return this.loadMethod(function () { + return _this.request("/load?query=".concat(encodeURIComponent(JSON.stringify(query)))); + }, function (body) { + return new ResultSet(body); + }, options, callback); + } + }, { + key: "sql", + value: function sql(query, options, callback) { + var _this2 = this; + + return this.loadMethod(function () { + return _this2.request("/sql?query=".concat(JSON.stringify(query))); + }, function (body) { + return new SqlQuery(body); + }, options, callback); + } + }, { + key: "meta", + value: function meta(options, callback) { + var _this3 = this; + + return this.loadMethod(function () { + return _this3.request("/meta"); + }, function (body) { + return new Meta(body); + }, options, callback); + } + }]); + + return CubejsApi; +}(); + +var index = (function (apiToken, options) { + return new CubejsApi(apiToken, options); +}); + +export default index; diff --git a/packages/cubejs-client-core/dist/cubejs-client-core.js b/packages/cubejs-client-core/dist/cubejs-client-core.js index c3603cd7ababd..85b6989e0f311 100644 --- a/packages/cubejs-client-core/dist/cubejs-client-core.js +++ b/packages/cubejs-client-core/dist/cubejs-client-core.js @@ -30,7 +30,7 @@ var _regeneratorRuntime = _interopDefault(require('@babel/runtime/regenerator')) require('regenerator-runtime/runtime'); var _asyncToGenerator = _interopDefault(require('@babel/runtime/helpers/asyncToGenerator')); require('core-js/modules/es6.promise'); -require('isomorphic-fetch'); +var fetch = _interopDefault(require('cross-fetch')); var moment = momentRange.extendMoment(Moment); var TIME_SERIES = { @@ -634,7 +634,6 @@ function () { _createClass(CubejsApi, [{ key: "request", value: function request(url, config) { - // eslint-disable-next-line no-undef return fetch("".concat(this.apiUrl).concat(url), Object.assign({ headers: { Authorization: this.apiToken, diff --git a/packages/cubejs-client-core/dist/cubejs-client-core.umd.js b/packages/cubejs-client-core/dist/cubejs-client-core.umd.js index 01828950c4821..2ced08b602fbb 100644 --- a/packages/cubejs-client-core/dist/cubejs-client-core.umd.js +++ b/packages/cubejs-client-core/dist/cubejs-client-core.umd.js @@ -2668,33 +2668,6 @@ _export(_export.S + _export.F, 'Object', { assign: _objectAssign }); - var arraySlice = [].slice; - var factories = {}; - - var construct = function (F, len, args) { - if (!(len in factories)) { - for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']'; - // eslint-disable-next-line no-new-func - factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')'); - } return factories[len](F, args); - }; - - var _bind = Function.bind || function bind(that /* , ...args */) { - var fn = _aFunction(this); - var partArgs = arraySlice.call(arguments, 1); - var bound = function (/* args... */) { - var args = partArgs.concat(arraySlice.call(arguments)); - return this instanceof bound ? construct(fn, args.length, args) : _invoke(fn, args, that); - }; - if (_isObject(fn.prototype)) bound.prototype = fn.prototype; - return bound; - }; - - // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) - - - _export(_export.P, 'Function', { bind: _bind }); - var _fixReWks = function (KEY, length, exec) { var SYMBOL = _wks(KEY); var fns = exec(_defined, SYMBOL, ''[KEY]); @@ -3765,540 +3738,574 @@ DataView: _typedBuffer.DataView }); - var support = { - searchParams: 'URLSearchParams' in self, - iterable: 'Symbol' in self && 'iterator' in Symbol, - blob: 'FileReader' in self && 'Blob' in self && function () { - try { - new Blob(); - return true; - } catch (e) { - return false; + var browserPonyfill = createCommonjsModule(function (module, exports) { + var __self__ = function (root) { + function F() { + this.fetch = false; } - }(), - formData: 'FormData' in self, - arrayBuffer: 'ArrayBuffer' in self - }; - function isDataView(obj) { - return obj && DataView.prototype.isPrototypeOf(obj); - } + F.prototype = root; + return new F(); + }(typeof self !== 'undefined' ? self : commonjsGlobal); - if (support.arrayBuffer) { - var viewClasses = ['[object Int8Array]', '[object Uint8Array]', '[object Uint8ClampedArray]', '[object Int16Array]', '[object Uint16Array]', '[object Int32Array]', '[object Uint32Array]', '[object Float32Array]', '[object Float64Array]']; + (function (self) { + var irrelevant = function (exports) { + var support = { + searchParams: 'URLSearchParams' in self, + iterable: 'Symbol' in self && 'iterator' in Symbol, + blob: 'FileReader' in self && 'Blob' in self && function () { + try { + new Blob(); + return true; + } catch (e) { + return false; + } + }(), + formData: 'FormData' in self, + arrayBuffer: 'ArrayBuffer' in self + }; - var isArrayBufferView = ArrayBuffer.isView || function (obj) { - return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1; - }; - } + function isDataView(obj) { + return obj && DataView.prototype.isPrototypeOf(obj); + } - function normalizeName(name) { - if (typeof name !== 'string') { - name = String(name); - } + if (support.arrayBuffer) { + var viewClasses = ['[object Int8Array]', '[object Uint8Array]', '[object Uint8ClampedArray]', '[object Int16Array]', '[object Uint16Array]', '[object Int32Array]', '[object Uint32Array]', '[object Float32Array]', '[object Float64Array]']; - if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { - throw new TypeError('Invalid character in header field name'); - } + var isArrayBufferView = ArrayBuffer.isView || function (obj) { + return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1; + }; + } - return name.toLowerCase(); - } + function normalizeName(name) { + if (typeof name !== 'string') { + name = String(name); + } - function normalizeValue(value) { - if (typeof value !== 'string') { - value = String(value); - } + if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { + throw new TypeError('Invalid character in header field name'); + } - return value; - } // Build a destructive iterator for the value list + return name.toLowerCase(); + } + function normalizeValue(value) { + if (typeof value !== 'string') { + value = String(value); + } - function iteratorFor(items) { - var iterator = { - next: function next() { - var value = items.shift(); - return { - done: value === undefined, - value: value - }; - } - }; + return value; + } // Build a destructive iterator for the value list - if (support.iterable) { - iterator[Symbol.iterator] = function () { - return iterator; - }; - } - return iterator; - } + function iteratorFor(items) { + var iterator = { + next: function next() { + var value = items.shift(); + return { + done: value === undefined, + value: value + }; + } + }; - function Headers(headers) { - this.map = {}; - - if (headers instanceof Headers) { - headers.forEach(function (value, name) { - this.append(name, value); - }, this); - } else if (Array.isArray(headers)) { - headers.forEach(function (header) { - this.append(header[0], header[1]); - }, this); - } else if (headers) { - Object.getOwnPropertyNames(headers).forEach(function (name) { - this.append(name, headers[name]); - }, this); - } - } + if (support.iterable) { + iterator[Symbol.iterator] = function () { + return iterator; + }; + } - Headers.prototype.append = function (name, value) { - name = normalizeName(name); - value = normalizeValue(value); - var oldValue = this.map[name]; - this.map[name] = oldValue ? oldValue + ', ' + value : value; - }; + return iterator; + } - Headers.prototype['delete'] = function (name) { - delete this.map[normalizeName(name)]; - }; + function Headers(headers) { + this.map = {}; - Headers.prototype.get = function (name) { - name = normalizeName(name); - return this.has(name) ? this.map[name] : null; - }; + if (headers instanceof Headers) { + headers.forEach(function (value, name) { + this.append(name, value); + }, this); + } else if (Array.isArray(headers)) { + headers.forEach(function (header) { + this.append(header[0], header[1]); + }, this); + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function (name) { + this.append(name, headers[name]); + }, this); + } + } - Headers.prototype.has = function (name) { - return this.map.hasOwnProperty(normalizeName(name)); - }; + Headers.prototype.append = function (name, value) { + name = normalizeName(name); + value = normalizeValue(value); + var oldValue = this.map[name]; + this.map[name] = oldValue ? oldValue + ', ' + value : value; + }; - Headers.prototype.set = function (name, value) { - this.map[normalizeName(name)] = normalizeValue(value); - }; + Headers.prototype['delete'] = function (name) { + delete this.map[normalizeName(name)]; + }; - Headers.prototype.forEach = function (callback, thisArg) { - for (var name in this.map) { - if (this.map.hasOwnProperty(name)) { - callback.call(thisArg, this.map[name], name, this); - } - } - }; + Headers.prototype.get = function (name) { + name = normalizeName(name); + return this.has(name) ? this.map[name] : null; + }; - Headers.prototype.keys = function () { - var items = []; - this.forEach(function (value, name) { - items.push(name); - }); - return iteratorFor(items); - }; + Headers.prototype.has = function (name) { + return this.map.hasOwnProperty(normalizeName(name)); + }; - Headers.prototype.values = function () { - var items = []; - this.forEach(function (value) { - items.push(value); - }); - return iteratorFor(items); - }; + Headers.prototype.set = function (name, value) { + this.map[normalizeName(name)] = normalizeValue(value); + }; - Headers.prototype.entries = function () { - var items = []; - this.forEach(function (value, name) { - items.push([name, value]); - }); - return iteratorFor(items); - }; + Headers.prototype.forEach = function (callback, thisArg) { + for (var name in this.map) { + if (this.map.hasOwnProperty(name)) { + callback.call(thisArg, this.map[name], name, this); + } + } + }; - if (support.iterable) { - Headers.prototype[Symbol.iterator] = Headers.prototype.entries; - } + Headers.prototype.keys = function () { + var items = []; + this.forEach(function (value, name) { + items.push(name); + }); + return iteratorFor(items); + }; - function consumed(body) { - if (body.bodyUsed) { - return Promise.reject(new TypeError('Already read')); - } + Headers.prototype.values = function () { + var items = []; + this.forEach(function (value) { + items.push(value); + }); + return iteratorFor(items); + }; - body.bodyUsed = true; - } + Headers.prototype.entries = function () { + var items = []; + this.forEach(function (value, name) { + items.push([name, value]); + }); + return iteratorFor(items); + }; - function fileReaderReady(reader) { - return new Promise(function (resolve, reject) { - reader.onload = function () { - resolve(reader.result); - }; + if (support.iterable) { + Headers.prototype[Symbol.iterator] = Headers.prototype.entries; + } - reader.onerror = function () { - reject(reader.error); - }; - }); - } + function consumed(body) { + if (body.bodyUsed) { + return Promise.reject(new TypeError('Already read')); + } - function readBlobAsArrayBuffer(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsArrayBuffer(blob); - return promise; - } + body.bodyUsed = true; + } - function readBlobAsText(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsText(blob); - return promise; - } + function fileReaderReady(reader) { + return new Promise(function (resolve, reject) { + reader.onload = function () { + resolve(reader.result); + }; - function readArrayBufferAsText(buf) { - var view = new Uint8Array(buf); - var chars = new Array(view.length); + reader.onerror = function () { + reject(reader.error); + }; + }); + } - for (var i = 0; i < view.length; i++) { - chars[i] = String.fromCharCode(view[i]); - } + function readBlobAsArrayBuffer(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsArrayBuffer(blob); + return promise; + } - return chars.join(''); - } + function readBlobAsText(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsText(blob); + return promise; + } - function bufferClone(buf) { - if (buf.slice) { - return buf.slice(0); - } else { - var view = new Uint8Array(buf.byteLength); - view.set(new Uint8Array(buf)); - return view.buffer; - } - } + function readArrayBufferAsText(buf) { + var view = new Uint8Array(buf); + var chars = new Array(view.length); - function Body() { - this.bodyUsed = false; - - this._initBody = function (body) { - this._bodyInit = body; - - if (!body) { - this._bodyText = ''; - } else if (typeof body === 'string') { - this._bodyText = body; - } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { - this._bodyBlob = body; - } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { - this._bodyFormData = body; - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this._bodyText = body.toString(); - } else if (support.arrayBuffer && support.blob && isDataView(body)) { - this._bodyArrayBuffer = bufferClone(body.buffer); // IE 10-11 can't handle a DataView body. - - this._bodyInit = new Blob([this._bodyArrayBuffer]); - } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { - this._bodyArrayBuffer = bufferClone(body); - } else { - this._bodyText = body = Object.prototype.toString.call(body); - } + for (var i = 0; i < view.length; i++) { + chars[i] = String.fromCharCode(view[i]); + } - if (!this.headers.get('content-type')) { - if (typeof body === 'string') { - this.headers.set('content-type', 'text/plain;charset=UTF-8'); - } else if (this._bodyBlob && this._bodyBlob.type) { - this.headers.set('content-type', this._bodyBlob.type); - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + return chars.join(''); } - } - }; - if (support.blob) { - this.blob = function () { - var rejected = consumed(this); + function bufferClone(buf) { + if (buf.slice) { + return buf.slice(0); + } else { + var view = new Uint8Array(buf.byteLength); + view.set(new Uint8Array(buf)); + return view.buffer; + } + } + + function Body() { + this.bodyUsed = false; + + this._initBody = function (body) { + this._bodyInit = body; + + if (!body) { + this._bodyText = ''; + } else if (typeof body === 'string') { + this._bodyText = body; + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body; + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body; + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this._bodyText = body.toString(); + } else if (support.arrayBuffer && support.blob && isDataView(body)) { + this._bodyArrayBuffer = bufferClone(body.buffer); // IE 10-11 can't handle a DataView body. + + this._bodyInit = new Blob([this._bodyArrayBuffer]); + } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { + this._bodyArrayBuffer = bufferClone(body); + } else { + this._bodyText = body = Object.prototype.toString.call(body); + } + + if (!this.headers.get('content-type')) { + if (typeof body === 'string') { + this.headers.set('content-type', 'text/plain;charset=UTF-8'); + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set('content-type', this._bodyBlob.type); + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + } + } + }; - if (rejected) { - return rejected; - } + if (support.blob) { + this.blob = function () { + var rejected = consumed(this); - if (this._bodyBlob) { - return Promise.resolve(this._bodyBlob); - } else if (this._bodyArrayBuffer) { - return Promise.resolve(new Blob([this._bodyArrayBuffer])); - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as blob'); - } else { - return Promise.resolve(new Blob([this._bodyText])); - } - }; + if (rejected) { + return rejected; + } - this.arrayBuffer = function () { - if (this._bodyArrayBuffer) { - return consumed(this) || Promise.resolve(this._bodyArrayBuffer); - } else { - return this.blob().then(readBlobAsArrayBuffer); - } - }; - } + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob); + } else if (this._bodyArrayBuffer) { + return Promise.resolve(new Blob([this._bodyArrayBuffer])); + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as blob'); + } else { + return Promise.resolve(new Blob([this._bodyText])); + } + }; - this.text = function () { - var rejected = consumed(this); + this.arrayBuffer = function () { + if (this._bodyArrayBuffer) { + return consumed(this) || Promise.resolve(this._bodyArrayBuffer); + } else { + return this.blob().then(readBlobAsArrayBuffer); + } + }; + } - if (rejected) { - return rejected; - } + this.text = function () { + var rejected = consumed(this); - if (this._bodyBlob) { - return readBlobAsText(this._bodyBlob); - } else if (this._bodyArrayBuffer) { - return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)); - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as text'); - } else { - return Promise.resolve(this._bodyText); - } - }; + if (rejected) { + return rejected; + } - if (support.formData) { - this.formData = function () { - return this.text().then(decode); - }; - } + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob); + } else if (this._bodyArrayBuffer) { + return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)); + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as text'); + } else { + return Promise.resolve(this._bodyText); + } + }; - this.json = function () { - return this.text().then(JSON.parse); - }; + if (support.formData) { + this.formData = function () { + return this.text().then(decode); + }; + } - return this; - } // HTTP methods whose capitalization should be normalized + this.json = function () { + return this.text().then(JSON.parse); + }; + return this; + } // HTTP methods whose capitalization should be normalized - var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; - function normalizeMethod(method) { - var upcased = method.toUpperCase(); - return methods.indexOf(upcased) > -1 ? upcased : method; - } + var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; - function Request(input, options) { - options = options || {}; - var body = options.body; + function normalizeMethod(method) { + var upcased = method.toUpperCase(); + return methods.indexOf(upcased) > -1 ? upcased : method; + } - if (input instanceof Request) { - if (input.bodyUsed) { - throw new TypeError('Already read'); - } + function Request(input, options) { + options = options || {}; + var body = options.body; - this.url = input.url; - this.credentials = input.credentials; + if (input instanceof Request) { + if (input.bodyUsed) { + throw new TypeError('Already read'); + } - if (!options.headers) { - this.headers = new Headers(input.headers); - } + this.url = input.url; + this.credentials = input.credentials; - this.method = input.method; - this.mode = input.mode; - this.signal = input.signal; + if (!options.headers) { + this.headers = new Headers(input.headers); + } - if (!body && input._bodyInit != null) { - body = input._bodyInit; - input.bodyUsed = true; - } - } else { - this.url = String(input); - } + this.method = input.method; + this.mode = input.mode; + this.signal = input.signal; - this.credentials = options.credentials || this.credentials || 'same-origin'; + if (!body && input._bodyInit != null) { + body = input._bodyInit; + input.bodyUsed = true; + } + } else { + this.url = String(input); + } - if (options.headers || !this.headers) { - this.headers = new Headers(options.headers); - } + this.credentials = options.credentials || this.credentials || 'same-origin'; - this.method = normalizeMethod(options.method || this.method || 'GET'); - this.mode = options.mode || this.mode || null; - this.signal = options.signal || this.signal; - this.referrer = null; + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers); + } - if ((this.method === 'GET' || this.method === 'HEAD') && body) { - throw new TypeError('Body not allowed for GET or HEAD requests'); - } + this.method = normalizeMethod(options.method || this.method || 'GET'); + this.mode = options.mode || this.mode || null; + this.signal = options.signal || this.signal; + this.referrer = null; - this._initBody(body); - } + if ((this.method === 'GET' || this.method === 'HEAD') && body) { + throw new TypeError('Body not allowed for GET or HEAD requests'); + } - Request.prototype.clone = function () { - return new Request(this, { - body: this._bodyInit - }); - }; + this._initBody(body); + } - function decode(body) { - var form = new FormData(); - body.trim().split('&').forEach(function (bytes) { - if (bytes) { - var split = bytes.split('='); - var name = split.shift().replace(/\+/g, ' '); - var value = split.join('=').replace(/\+/g, ' '); - form.append(decodeURIComponent(name), decodeURIComponent(value)); - } - }); - return form; - } + Request.prototype.clone = function () { + return new Request(this, { + body: this._bodyInit + }); + }; - function parseHeaders(rawHeaders) { - var headers = new Headers(); // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space - // https://tools.ietf.org/html/rfc7230#section-3.2 + function decode(body) { + var form = new FormData(); + body.trim().split('&').forEach(function (bytes) { + if (bytes) { + var split = bytes.split('='); + var name = split.shift().replace(/\+/g, ' '); + var value = split.join('=').replace(/\+/g, ' '); + form.append(decodeURIComponent(name), decodeURIComponent(value)); + } + }); + return form; + } - var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); - preProcessedHeaders.split(/\r?\n/).forEach(function (line) { - var parts = line.split(':'); - var key = parts.shift().trim(); + function parseHeaders(rawHeaders) { + var headers = new Headers(); // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space + // https://tools.ietf.org/html/rfc7230#section-3.2 - if (key) { - var value = parts.join(':').trim(); - headers.append(key, value); - } - }); - return headers; - } + var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); + preProcessedHeaders.split(/\r?\n/).forEach(function (line) { + var parts = line.split(':'); + var key = parts.shift().trim(); - Body.call(Request.prototype); - function Response(bodyInit, options) { - if (!options) { - options = {}; - } + if (key) { + var value = parts.join(':').trim(); + headers.append(key, value); + } + }); + return headers; + } - this.type = 'default'; - this.status = options.status === undefined ? 200 : options.status; - this.ok = this.status >= 200 && this.status < 300; - this.statusText = 'statusText' in options ? options.statusText : 'OK'; - this.headers = new Headers(options.headers); - this.url = options.url || ''; + Body.call(Request.prototype); - this._initBody(bodyInit); - } - Body.call(Response.prototype); - - Response.prototype.clone = function () { - return new Response(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new Headers(this.headers), - url: this.url - }); - }; + function Response(bodyInit, options) { + if (!options) { + options = {}; + } - Response.error = function () { - var response = new Response(null, { - status: 0, - statusText: '' - }); - response.type = 'error'; - return response; - }; + this.type = 'default'; + this.status = options.status === undefined ? 200 : options.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = 'statusText' in options ? options.statusText : 'OK'; + this.headers = new Headers(options.headers); + this.url = options.url || ''; - var redirectStatuses = [301, 302, 303, 307, 308]; + this._initBody(bodyInit); + } - Response.redirect = function (url, status) { - if (redirectStatuses.indexOf(status) === -1) { - throw new RangeError('Invalid status code'); - } + Body.call(Response.prototype); - return new Response(null, { - status: status, - headers: { - location: url - } - }); - }; + Response.prototype.clone = function () { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }); + }; - var DOMException = self.DOMException; + Response.error = function () { + var response = new Response(null, { + status: 0, + statusText: '' + }); + response.type = 'error'; + return response; + }; - try { - new DOMException(); - } catch (err) { - DOMException = function DOMException(message, name) { - this.message = message; - this.name = name; - var error = Error(message); - this.stack = error.stack; - }; + var redirectStatuses = [301, 302, 303, 307, 308]; - DOMException.prototype = Object.create(Error.prototype); - DOMException.prototype.constructor = DOMException; - } + Response.redirect = function (url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError('Invalid status code'); + } - function fetch$1(input, init) { - return new Promise(function (resolve, reject) { - var request = new Request(input, init); + return new Response(null, { + status: status, + headers: { + location: url + } + }); + }; - if (request.signal && request.signal.aborted) { - return reject(new DOMException('Aborted', 'AbortError')); - } + exports.DOMException = self.DOMException; - var xhr = new XMLHttpRequest(); + try { + new exports.DOMException(); + } catch (err) { + exports.DOMException = function (message, name) { + this.message = message; + this.name = name; + var error = Error(message); + this.stack = error.stack; + }; - function abortXhr() { - xhr.abort(); - } + exports.DOMException.prototype = Object.create(Error.prototype); + exports.DOMException.prototype.constructor = exports.DOMException; + } - xhr.onload = function () { - var options = { - status: xhr.status, - statusText: xhr.statusText, - headers: parseHeaders(xhr.getAllResponseHeaders() || '') - }; - options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); - var body = 'response' in xhr ? xhr.response : xhr.responseText; - resolve(new Response(body, options)); - }; + function fetch(input, init) { + return new Promise(function (resolve, reject) { + var request = new Request(input, init); - xhr.onerror = function () { - reject(new TypeError('Network request failed')); - }; + if (request.signal && request.signal.aborted) { + return reject(new exports.DOMException('Aborted', 'AbortError')); + } - xhr.ontimeout = function () { - reject(new TypeError('Network request failed')); - }; + var xhr = new XMLHttpRequest(); - xhr.onabort = function () { - reject(new DOMException('Aborted', 'AbortError')); - }; + function abortXhr() { + xhr.abort(); + } - xhr.open(request.method, request.url, true); + xhr.onload = function () { + var options = { + status: xhr.status, + statusText: xhr.statusText, + headers: parseHeaders(xhr.getAllResponseHeaders() || '') + }; + options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); + var body = 'response' in xhr ? xhr.response : xhr.responseText; + resolve(new Response(body, options)); + }; - if (request.credentials === 'include') { - xhr.withCredentials = true; - } else if (request.credentials === 'omit') { - xhr.withCredentials = false; - } + xhr.onerror = function () { + reject(new TypeError('Network request failed')); + }; - if ('responseType' in xhr && support.blob) { - xhr.responseType = 'blob'; - } + xhr.ontimeout = function () { + reject(new TypeError('Network request failed')); + }; - request.headers.forEach(function (value, name) { - xhr.setRequestHeader(name, value); - }); + xhr.onabort = function () { + reject(new exports.DOMException('Aborted', 'AbortError')); + }; - if (request.signal) { - request.signal.addEventListener('abort', abortXhr); + xhr.open(request.method, request.url, true); - xhr.onreadystatechange = function () { - // DONE (success or failure) - if (xhr.readyState === 4) { - request.signal.removeEventListener('abort', abortXhr); - } - }; - } + if (request.credentials === 'include') { + xhr.withCredentials = true; + } else if (request.credentials === 'omit') { + xhr.withCredentials = false; + } - xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); - }); - } - fetch$1.polyfill = true; + if ('responseType' in xhr && support.blob) { + xhr.responseType = 'blob'; + } - if (!self.fetch) { - self.fetch = fetch$1; - self.Headers = Headers; - self.Request = Request; - self.Response = Response; - } + request.headers.forEach(function (value, name) { + xhr.setRequestHeader(name, value); + }); - // on the global object (window or self) - // - // Return that as the export for use in Webpack, Browserify etc. + if (request.signal) { + request.signal.addEventListener('abort', abortXhr); - var fetchNpmBrowserify = self.fetch.bind(self); + xhr.onreadystatechange = function () { + // DONE (success or failure) + if (xhr.readyState === 4) { + request.signal.removeEventListener('abort', abortXhr); + } + }; + } + + xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); + }); + } + + fetch.polyfill = true; + + if (!self.fetch) { + self.fetch = fetch; + self.Headers = Headers; + self.Request = Request; + self.Response = Response; + } + + exports.Headers = Headers; + exports.Request = Request; + exports.Response = Response; + exports.fetch = fetch; + return exports; + }({}); + })(__self__); + + delete __self__.fetch.polyfill; + exports = __self__.fetch; // To enable: import fetch from 'cross-fetch' + + exports.default = __self__.fetch; // For TypeScript consumers without esModuleInterop. + + exports.fetch = __self__.fetch; // To enable: import {fetch} from 'cross-fetch' + + exports.Headers = __self__.Headers; + exports.Request = __self__.Request; + exports.Response = __self__.Response; + module.exports = exports; + }); + var browserPonyfill_1 = browserPonyfill.fetch; + var browserPonyfill_2 = browserPonyfill.Headers; + var browserPonyfill_3 = browserPonyfill.Request; + var browserPonyfill_4 = browserPonyfill.Response; var setPrototypeOf = _setProto.set; var _inheritIfRequired = function (that, target, C) { @@ -14596,8 +14603,7 @@ _createClass(CubejsApi, [{ key: "request", value: function request(url, config) { - // eslint-disable-next-line no-undef - return fetch("".concat(this.apiUrl).concat(url), Object.assign({ + return browserPonyfill("".concat(this.apiUrl).concat(url), Object.assign({ headers: { Authorization: this.apiToken, 'Content-Type': 'application/json' diff --git a/packages/cubejs-client-core/package.json b/packages/cubejs-client-core/package.json index ce9a09dae7e35..8d306227d3d45 100644 --- a/packages/cubejs-client-core/package.json +++ b/packages/cubejs-client-core/package.json @@ -7,7 +7,7 @@ "dependencies": { "@babel/runtime": "^7.1.2", "core-js": "^2.5.3", - "isomorphic-fetch": "^2.2.1", + "cross-fetch": "^3.0.2", "moment": "^2.22.2", "moment-range": "^4.0.1", "ramda": "^0.25.0" diff --git a/packages/cubejs-client-core/src/index.js b/packages/cubejs-client-core/src/index.js index 03f11192b2a7a..e8081785f693a 100644 --- a/packages/cubejs-client-core/src/index.js +++ b/packages/cubejs-client-core/src/index.js @@ -1,4 +1,4 @@ -import 'isomorphic-fetch'; +import fetch from 'cross-fetch'; import ResultSet from './ResultSet'; import SqlQuery from './SqlQuery'; import Meta from './Meta'; @@ -24,7 +24,6 @@ class CubejsApi { } request(url, config) { - // eslint-disable-next-line no-undef return fetch( `${this.apiUrl}${url}`, Object.assign({ headers: { Authorization: this.apiToken, 'Content-Type': 'application/json' }}, config || {}) @@ -109,4 +108,4 @@ class CubejsApi { export default (apiToken, options) => { return new CubejsApi(apiToken, options); -}; \ No newline at end of file +}; diff --git a/packages/cubejs-client-core/yarn.lock b/packages/cubejs-client-core/yarn.lock index 08f142151ee32..d3e04a0e57150 100644 --- a/packages/cubejs-client-core/yarn.lock +++ b/packages/cubejs-client-core/yarn.lock @@ -1064,6 +1064,14 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= +cross-fetch@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.2.tgz#b7136491967031949c7f86b15903aef4fa3f1768" + integrity sha512-a4Z0EJ5Nck6QtMy9ZqloLfpvu2uMV3sBfMCR+CgSBCZc6z5KR4bfEiD3dkepH8iZgJMXQpTqf8FjMmvu/GMFkg== + dependencies: + node-fetch "2.3.0" + whatwg-fetch "3.0.0" + cross-spawn@^6.0.0: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -1224,13 +1232,6 @@ electron-to-chromium@^1.3.103: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.113.tgz#b1ccf619df7295aea17bc6951dc689632629e4a9" integrity sha512-De+lPAxEcpxvqPTyZAXELNpRZXABRxf+uL/rSykstQhzj/B0l1150G/ExIIxKc16lI89Hgz81J0BHAcbTqK49g== -encoding@^0.1.11: - version "0.1.12" - resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" - integrity sha1-U4tm8+5izRq1HsMjgp0flIDHS+s= - dependencies: - iconv-lite "~0.4.13" - end-of-stream@^1.1.0: version "1.4.1" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" @@ -1680,7 +1681,7 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -iconv-lite@0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: +iconv-lite@0.4.24, iconv-lite@^0.4.4: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -1860,7 +1861,7 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" -is-stream@^1.0.1, is-stream@^1.1.0: +is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= @@ -1909,14 +1910,6 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= -isomorphic-fetch@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" - integrity sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk= - dependencies: - node-fetch "^1.0.1" - whatwg-fetch ">=0.10.0" - isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -2720,13 +2713,10 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== -node-fetch@^1.0.1: - version "1.7.3" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" - integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ== - dependencies: - encoding "^0.1.11" - is-stream "^1.0.1" +node-fetch@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5" + integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA== node-int64@^0.4.0: version "0.4.0" @@ -3913,9 +3903,10 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3: dependencies: iconv-lite "0.4.24" -whatwg-fetch@>=0.10.0: +whatwg-fetch@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" + integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q== whatwg-mimetype@^2.1.0, whatwg-mimetype@^2.2.0: version "2.3.0" diff --git a/packages/cubejs-react/dist/cubejs-react.esm.js b/packages/cubejs-react/dist/cubejs-react.esm.js new file mode 100644 index 0000000000000..0c3a8db3b2794 --- /dev/null +++ b/packages/cubejs-react/dist/cubejs-react.esm.js @@ -0,0 +1,599 @@ +import 'core-js/modules/es6.array.map'; +import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; +import 'core-js/modules/es6.promise'; +import 'core-js/modules/web.dom.iterable'; +import 'core-js/modules/es6.array.iterator'; +import 'core-js/modules/es6.string.iterator'; +import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; +import _createClass from '@babel/runtime/helpers/createClass'; +import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn'; +import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf'; +import _inherits from '@babel/runtime/helpers/inherits'; +import React from 'react'; +import { func, object, any, bool } from 'prop-types'; +import { equals, toPairs, fromPairs } from 'ramda'; +import _extends from '@babel/runtime/helpers/extends'; +import _objectSpread from '@babel/runtime/helpers/objectSpread'; +import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; +import 'core-js/modules/es6.array.filter'; +import _defineProperty from '@babel/runtime/helpers/defineProperty'; +import 'core-js/modules/es6.function.name'; +import _regeneratorRuntime from '@babel/runtime/regenerator'; +import 'regenerator-runtime/runtime'; +import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; + +var QueryRenderer = +/*#__PURE__*/ +function (_React$Component) { + _inherits(QueryRenderer, _React$Component); + + function QueryRenderer(props) { + var _this; + + _classCallCheck(this, QueryRenderer); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(QueryRenderer).call(this, props)); + _this.state = {}; + _this.mutexObj = {}; + return _this; + } + + _createClass(QueryRenderer, [{ + key: "componentDidMount", + value: function componentDidMount() { + var _this$props = this.props, + query = _this$props.query, + queries = _this$props.queries; + + if (query) { + this.load(query); + } + + if (queries) { + this.loadQueries(queries); + } + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps) { + var _this$props2 = this.props, + query = _this$props2.query, + queries = _this$props2.queries; + + if (!equals(prevProps.query, query)) { + this.load(query); + } + + if (!equals(prevProps.queries, queries)) { + this.loadQueries(queries); + } + } + }, { + key: "isQueryPresent", + value: function isQueryPresent(query) { + return query.measures && query.measures.length || query.dimensions && query.dimensions.length || query.timeDimensions && query.timeDimensions.length; + } + }, { + key: "load", + value: function load(query) { + var _this2 = this; + + this.setState({ + isLoading: true, + resultSet: null, + error: null, + sqlQuery: null + }); + var _this$props3 = this.props, + loadSql = _this$props3.loadSql, + cubejsApi = _this$props3.cubejsApi; + + if (query && this.isQueryPresent(query)) { + if (loadSql === 'only') { + cubejsApi.sql(query, { + mutexObj: this.mutexObj, + mutexKey: 'sql' + }).then(function (sqlQuery) { + return _this2.setState({ + sqlQuery: sqlQuery, + error: null, + isLoading: false + }); + }).catch(function (error) { + return _this2.setState({ + resultSet: null, + error: error, + isLoading: false + }); + }); + } else if (loadSql) { + Promise.all([cubejsApi.sql(query, { + mutexObj: this.mutexObj, + mutexKey: 'sql' + }), cubejsApi.load(query, { + mutexObj: this.mutexObj, + mutexKey: 'query' + })]).then(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + sqlQuery = _ref2[0], + resultSet = _ref2[1]; + + return _this2.setState({ + sqlQuery: sqlQuery, + resultSet: resultSet, + error: null, + isLoading: false + }); + }).catch(function (error) { + return _this2.setState({ + resultSet: null, + error: error, + isLoading: false + }); + }); + } else { + cubejsApi.load(query, { + mutexObj: this.mutexObj, + mutexKey: 'query' + }).then(function (resultSet) { + return _this2.setState({ + resultSet: resultSet, + error: null, + isLoading: false + }); + }).catch(function (error) { + return _this2.setState({ + resultSet: null, + error: error, + isLoading: false + }); + }); + } + } + } + }, { + key: "loadQueries", + value: function loadQueries(queries) { + var _this3 = this; + + this.setState({ + isLoading: true, + resultSet: null, + error: null + }); + var resultPromises = Promise.all(toPairs(queries).map(function (_ref3) { + var _ref4 = _slicedToArray(_ref3, 2), + name = _ref4[0], + query = _ref4[1]; + + return _this3.props.cubejsApi.load(query, { + mutexObj: _this3.mutexObj, + mutexKey: name + }).then(function (r) { + return [name, r]; + }); + })); + resultPromises.then(function (resultSet) { + return _this3.setState({ + resultSet: fromPairs(resultSet), + error: null, + isLoading: false + }); + }).catch(function (error) { + return _this3.setState({ + resultSet: null, + error: error, + isLoading: false + }); + }); + } + }, { + key: "render", + value: function render() { + var loadState = { + error: this.state.error, + resultSet: this.props.queries ? this.state.resultSet || {} : this.state.resultSet, + loadingState: { + isLoading: this.state.isLoading + }, + sqlQuery: this.state.sqlQuery + }; + + if (this.props.render) { + return this.props.render(loadState); + } + + return null; + } + }]); + + return QueryRenderer; +}(React.Component); +QueryRenderer.propTypes = { + render: func, + afterRender: func, + cubejsApi: object.isRequired, + query: object, + queries: object, + loadSql: any +}; +QueryRenderer.defaultProps = { + query: {} +}; + +var QueryRendererWithTotals = (function (_ref) { + var query = _ref.query, + restProps = _objectWithoutProperties(_ref, ["query"]); + + return React.createElement(QueryRenderer, _extends({ + queries: { + totals: _objectSpread({}, query, { + dimensions: [], + timeDimensions: query.timeDimensions ? query.timeDimensions.map(function (td) { + return _objectSpread({}, td, { + granularity: null + }); + }) : undefined + }), + main: query + } + }, restProps)); +}); + +var QueryBuilder = +/*#__PURE__*/ +function (_React$Component) { + _inherits(QueryBuilder, _React$Component); + + function QueryBuilder(props) { + var _this; + + _classCallCheck(this, QueryBuilder); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(QueryBuilder).call(this, props)); + _this.state = { + query: props.query, + chartType: 'line' + }; + return _this; + } + + _createClass(QueryBuilder, [{ + key: "componentDidMount", + value: function () { + var _componentDidMount = _asyncToGenerator( + /*#__PURE__*/ + _regeneratorRuntime.mark(function _callee() { + var cubejsApi, meta; + return _regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + cubejsApi = this.props.cubejsApi; + _context.next = 3; + return cubejsApi.meta(); + + case 3: + meta = _context.sent; + this.setState({ + meta: meta + }); + + case 5: + case "end": + return _context.stop(); + } + } + }, _callee, this); + })); + + return function componentDidMount() { + return _componentDidMount.apply(this, arguments); + }; + }() + }, { + key: "isQueryPresent", + value: function isQueryPresent() { + var query = this.state.query; + return query.measures && query.measures.length || query.dimensions && query.dimensions.length || query.timeDimensions && query.timeDimensions.length; + } + }, { + key: "prepareRenderProps", + value: function prepareRenderProps(queryRendererProps) { + var _this2 = this; + + var getName = function getName(member) { + return member.name; + }; + + var toTimeDimension = function toTimeDimension(member) { + return { + dimension: member.dimension.name, + granularity: member.granularity, + dateRange: member.dateRange + }; + }; + + var toFilter = function toFilter(member) { + return { + dimension: member.dimension.name, + operator: member.operator, + values: member.values + }; + }; + + var updateMethods = function updateMethods(memberType) { + var toQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getName; + return { + add: function add(member) { + var query = _this2.state.query; + + _this2.setState(_this2.applyStateChangeHeuristics({ + query: _objectSpread({}, query, _defineProperty({}, memberType, (query[memberType] || []).concat(toQuery(member)))) + })); + }, + remove: function remove(member) { + var query = _this2.state.query; + var members = (query[memberType] || []).concat([]); + members.splice(member.index, 1); + return _this2.setState(_this2.applyStateChangeHeuristics({ + query: _objectSpread({}, query, _defineProperty({}, memberType, members)) + })); + }, + update: function update(member, updateWith) { + var query = _this2.state.query; + var members = (query[memberType] || []).concat([]); + members.splice(member.index, 1, toQuery(updateWith)); + return _this2.setState(_this2.applyStateChangeHeuristics({ + query: _objectSpread({}, query, _defineProperty({}, memberType, members)) + })); + } + }; + }; + + var granularities = [{ + name: undefined, + title: 'w/o grouping' + }, { + name: 'hour', + title: 'Hour' + }, { + name: 'day', + title: 'Day' + }, { + name: 'week', + title: 'Week' + }, { + name: 'month', + title: 'Month' + }, { + name: 'year', + title: 'Year' + }]; + var _this$state = this.state, + meta = _this$state.meta, + query = _this$state.query, + chartType = _this$state.chartType; + return _objectSpread({ + meta: meta, + query: query, + validatedQuery: this.validatedQuery(), + isQueryPresent: this.isQueryPresent(), + chartType: chartType, + measures: (meta && query.measures || []).map(function (m, i) { + return _objectSpread({ + index: i + }, meta.resolveMember(m, 'measures')); + }), + dimensions: (meta && query.dimensions || []).map(function (m, i) { + return _objectSpread({ + index: i + }, meta.resolveMember(m, 'dimensions')); + }), + segments: (meta && query.segments || []).map(function (m, i) { + return _objectSpread({ + index: i + }, meta.resolveMember(m, 'segments')); + }), + timeDimensions: (meta && query.timeDimensions || []).map(function (m, i) { + return _objectSpread({}, m, { + dimension: _objectSpread({}, meta.resolveMember(m.dimension, 'dimensions'), { + granularities: granularities + }), + index: i + }); + }), + filters: (meta && query.filters || []).map(function (m, i) { + return _objectSpread({}, m, { + dimension: meta.resolveMember(m.dimension, ['dimensions', 'measures']), + operators: meta.filterOperatorsForMember(m.dimension, ['dimensions', 'measures']), + index: i + }); + }), + availableMeasures: meta && meta.membersForQuery(query, 'measures') || [], + availableDimensions: meta && meta.membersForQuery(query, 'dimensions') || [], + availableTimeDimensions: (meta && meta.membersForQuery(query, 'dimensions') || []).filter(function (m) { + return m.type === 'time'; + }), + availableSegments: meta && meta.membersForQuery(query, 'segments') || [], + updateMeasures: updateMethods('measures'), + updateDimensions: updateMethods('dimensions'), + updateSegments: updateMethods('segments'), + updateTimeDimensions: updateMethods('timeDimensions', toTimeDimension), + updateFilters: updateMethods('filters', toFilter), + updateChartType: function updateChartType(newChartType) { + return _this2.setState(_this2.applyStateChangeHeuristics({ + chartType: newChartType + })); + } + }, queryRendererProps); + } + }, { + key: "validatedQuery", + value: function validatedQuery() { + var query = this.state.query; + return _objectSpread({}, query, { + filters: (query.filters || []).filter(function (f) { + return f.operator; + }) + }); + } + }, { + key: "defaultHeuristics", + value: function defaultHeuristics(newState) { + var _this$state2 = this.state, + query = _this$state2.query, + sessionGranularity = _this$state2.sessionGranularity; + var defaultGranularity = sessionGranularity || 'day'; + + if (newState.query) { + var oldQuery = query; + var newQuery = newState.query; + var meta = this.state.meta; + + if ((oldQuery.timeDimensions || []).length === 1 && (newQuery.timeDimensions || []).length === 1 && newQuery.timeDimensions[0].granularity && oldQuery.timeDimensions[0].granularity !== newQuery.timeDimensions[0].granularity) { + newState = _objectSpread({}, newState, { + sessionGranularity: newQuery.timeDimensions[0].granularity + }); + } + + if ((oldQuery.measures || []).length === 0 && (newQuery.measures || []).length > 0 || (oldQuery.measures || []).length === 1 && (newQuery.measures || []).length === 1 && oldQuery.measures[0] !== newQuery.measures[0]) { + var defaultTimeDimension = meta.defaultTimeDimensionNameFor(newQuery.measures[0]); + newQuery = _objectSpread({}, newQuery, { + timeDimensions: defaultTimeDimension ? [{ + dimension: defaultTimeDimension, + granularity: defaultGranularity + }] : [] + }); + return _objectSpread({}, newState, { + query: newQuery, + chartType: defaultTimeDimension ? 'line' : 'number' + }); + } + + if ((oldQuery.dimensions || []).length === 0 && (newQuery.dimensions || []).length > 0) { + newQuery = _objectSpread({}, newQuery, { + timeDimensions: (newQuery.timeDimensions || []).map(function (td) { + return _objectSpread({}, td, { + granularity: undefined + }); + }) + }); + return _objectSpread({}, newState, { + query: newQuery, + chartType: 'table' + }); + } + + if ((oldQuery.dimensions || []).length > 0 && (newQuery.dimensions || []).length === 0) { + newQuery = _objectSpread({}, newQuery, { + timeDimensions: (newQuery.timeDimensions || []).map(function (td) { + return _objectSpread({}, td, { + granularity: td.granularity || defaultGranularity + }); + }) + }); + return _objectSpread({}, newState, { + query: newQuery, + chartType: (newQuery.timeDimensions || []).length ? 'line' : 'number' + }); + } + + if (((oldQuery.dimensions || []).length > 0 || (oldQuery.measures || []).length > 0) && (newQuery.dimensions || []).length === 0 && (newQuery.measures || []).length === 0) { + newQuery = _objectSpread({}, newQuery, { + timeDimensions: [], + filters: [] + }); + return _objectSpread({}, newState, { + query: newQuery, + sessionGranularity: null + }); + } + + return newState; + } + + if (newState.chartType) { + var newChartType = newState.chartType; + + if ((newChartType === 'line' || newChartType === 'area') && (query.timeDimensions || []).length === 1 && !query.timeDimensions[0].granularity) { + var _query$timeDimensions = _slicedToArray(query.timeDimensions, 1), + td = _query$timeDimensions[0]; + + return _objectSpread({}, newState, { + query: _objectSpread({}, query, { + timeDimensions: [_objectSpread({}, td, { + granularity: defaultGranularity + })] + }) + }); + } + + if ((newChartType === 'pie' || newChartType === 'table' || newChartType === 'number') && (query.timeDimensions || []).length === 1 && query.timeDimensions[0].granularity) { + var _query$timeDimensions2 = _slicedToArray(query.timeDimensions, 1), + _td = _query$timeDimensions2[0]; + + return _objectSpread({}, newState, { + query: _objectSpread({}, query, { + timeDimensions: [_objectSpread({}, _td, { + granularity: undefined + })] + }) + }); + } + } + + return newState; + } + }, { + key: "applyStateChangeHeuristics", + value: function applyStateChangeHeuristics(newState) { + var _this$props = this.props, + stateChangeHeuristics = _this$props.stateChangeHeuristics, + disableHeuristics = _this$props.disableHeuristics; + + if (disableHeuristics) { + return newState; + } + + return stateChangeHeuristics && stateChangeHeuristics(this.state, newState) || this.defaultHeuristics(newState); + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + var _this$props2 = this.props, + cubejsApi = _this$props2.cubejsApi, + _render = _this$props2.render; + return React.createElement(QueryRenderer, { + query: this.validatedQuery(), + cubejsApi: cubejsApi, + render: function render(queryRendererProps) { + if (_render) { + return _render(_this3.prepareRenderProps(queryRendererProps)); + } + + return null; + } + }); + } + }]); + + return QueryBuilder; +}(React.Component); +QueryBuilder.propTypes = { + render: func, + stateChangeHeuristics: func, + cubejsApi: object.isRequired, + disableHeuristics: bool, + query: object +}; +QueryBuilder.defaultProps = { + query: {}, + stateChangeHeuristics: null, + disableHeuristics: false, + render: null +}; + +export { QueryRenderer, QueryRendererWithTotals, QueryBuilder }; diff --git a/packages/cubejs-react/dist/cubejs-react.umd.js b/packages/cubejs-react/dist/cubejs-react.umd.js index 036ff2e35c380..c6a83251e1303 100644 --- a/packages/cubejs-react/dist/cubejs-react.umd.js +++ b/packages/cubejs-react/dist/cubejs-react.umd.js @@ -267,7 +267,7 @@ return store[key] || (store[key] = value !== undefined ? value : {}); })('versions', []).push({ version: _core.version, - mode: _library ? 'pure' : 'global', + mode: 'global', copyright: '© 2018 Denis Pushkarev (zloirock.ru)' }); }); @@ -369,20 +369,6 @@ } }); - function _typeof(obj) { - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); - } - function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); @@ -1189,10 +1175,10 @@ return capability.promise; } }); - _export(_export.S + _export.F * (!USE_NATIVE), PROMISE, { + _export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, { // 25.4.4.6 Promise.resolve(x) resolve: function resolve(x) { - return _promiseResolve(this, x); + return _promiseResolve(_library && this === Wrapper ? $Promise : this, x); } }); _export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) { @@ -1577,7 +1563,7 @@ }); function _isPlaceholder(a) { - return a != null && _typeof(a) === 'object' && a['@@functional/placeholder'] === true; + return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true; } /** @@ -1588,7 +1574,6 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ - function _curry1(fn) { return function f1(a) { if (arguments.length === 0 || _isPlaceholder(a)) { @@ -1618,10 +1603,7 @@ * var t = R.always('Tee'); * t(); //=> 'Tee' */ - - var always = - /*#__PURE__*/ - _curry1(function always(val) { + var always = /*#__PURE__*/_curry1(function always(val) { return function () { return val; }; @@ -1642,10 +1624,7 @@ * * R.F(); //=> false */ - - var F = - /*#__PURE__*/ - always(false); + var F = /*#__PURE__*/always(false); /** * A function that always returns `true`. Any passed in parameters are ignored. @@ -1662,10 +1641,7 @@ * * R.T(); //=> true */ - - var T = - /*#__PURE__*/ - always(true); + var T = /*#__PURE__*/always(true); /** * A special placeholder value used to specify "gaps" within curried functions, @@ -1694,167 +1670,6 @@ * greet('Alice'); //=> 'Hello, Alice!' */ - var f$2 = {}.propertyIsEnumerable; - - var _objectPie = { - f: f$2 - }; - - var gOPD = Object.getOwnPropertyDescriptor; - - var f$3 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) { - O = _toIobject(O); - P = _toPrimitive(P, true); - if (_ie8DomDefine) try { - return gOPD(O, P); - } catch (e) { /* empty */ } - if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); - }; - - var _objectGopd = { - f: f$3 - }; - - // Works with __proto__ only. Old v8 can't work with null proto objects. - /* eslint-disable no-proto */ - - - var check = function (O, proto) { - _anObject(O); - if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); - }; - var _setProto = { - set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line - function (test, buggy, set) { - try { - set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2); - set(test, []); - buggy = !(test instanceof Array); - } catch (e) { buggy = true; } - return function setPrototypeOf(O, proto) { - check(O, proto); - if (buggy) O.__proto__ = proto; - else set(O, proto); - return O; - }; - }({}, false) : undefined), - check: check - }; - - var setPrototypeOf = _setProto.set; - var _inheritIfRequired = function (that, target, C) { - var S = target.constructor; - var P; - if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf) { - setPrototypeOf(that, P); - } return that; - }; - - // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) - - var hiddenKeys = _enumBugKeys.concat('length', 'prototype'); - - var f$4 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { - return _objectKeysInternal(O, hiddenKeys); - }; - - var _objectGopn = { - f: f$4 - }; - - var _stringWs = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; - - var space = '[' + _stringWs + ']'; - var non = '\u200b\u0085'; - var ltrim = RegExp('^' + space + space + '*'); - var rtrim = RegExp(space + space + '*$'); - - var exporter = function (KEY, exec, ALIAS) { - var exp = {}; - var FORCE = _fails(function () { - return !!_stringWs[KEY]() || non[KEY]() != non; - }); - var fn = exp[KEY] = FORCE ? exec(trim) : _stringWs[KEY]; - if (ALIAS) exp[ALIAS] = fn; - _export(_export.P + _export.F * FORCE, 'String', exp); - }; - - // 1 -> String#trimLeft - // 2 -> String#trimRight - // 3 -> String#trim - var trim = exporter.trim = function (string, TYPE) { - string = String(_defined(string)); - if (TYPE & 1) string = string.replace(ltrim, ''); - if (TYPE & 2) string = string.replace(rtrim, ''); - return string; - }; - - var _stringTrim = exporter; - - var gOPN = _objectGopn.f; - var gOPD$1 = _objectGopd.f; - var dP$1 = _objectDp.f; - var $trim = _stringTrim.trim; - var NUMBER = 'Number'; - var $Number = _global[NUMBER]; - var Base = $Number; - var proto$1 = $Number.prototype; - // Opera ~12 has broken Object#toString - var BROKEN_COF = _cof(_objectCreate(proto$1)) == NUMBER; - var TRIM = 'trim' in String.prototype; - - // 7.1.3 ToNumber(argument) - var toNumber = function (argument) { - var it = _toPrimitive(argument, false); - if (typeof it == 'string' && it.length > 2) { - it = TRIM ? it.trim() : $trim(it, 3); - var first = it.charCodeAt(0); - var third, radix, maxCode; - if (first === 43 || first === 45) { - third = it.charCodeAt(2); - if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix - } else if (first === 48) { - switch (it.charCodeAt(1)) { - case 66: case 98: radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i - case 79: case 111: radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i - default: return +it; - } - for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) { - code = digits.charCodeAt(i); - // parseInt parses a string to a first unavailable symbol - // but ToNumber should return NaN if a string contains unavailable symbols - if (code < 48 || code > maxCode) return NaN; - } return parseInt(digits, radix); - } - } return +it; - }; - - if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) { - $Number = function Number(value) { - var it = arguments.length < 1 ? 0 : value; - var that = this; - return that instanceof $Number - // check on 1..constructor(foo) case - && (BROKEN_COF ? _fails(function () { proto$1.valueOf.call(that); }) : _cof(that) != NUMBER) - ? _inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it); - }; - for (var keys = _descriptors ? gOPN(Base) : ( - // ES3: - 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + - // ES6 (in case, if modules with ES6 Number statics required before): - 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + - 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger' - ).split(','), j = 0, key$1; keys.length > j; j++) { - if (_has(Base, key$1 = keys[j]) && !_has($Number, key$1)) { - dP$1($Number, key$1, gOPD$1(Base, key$1)); - } - } - $Number.prototype = proto$1; - proto$1.constructor = $Number; - _redefine(_global, NUMBER, $Number); - } - /** * Optimized internal two-arity curry function. * @@ -1863,18 +1678,15 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ - function _curry2(fn) { return function f2(a, b) { switch (arguments.length) { case 0: return f2; - case 1: return _isPlaceholder(a) ? f2 : _curry1(function (_b) { return fn(a, _b); }); - default: return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function (_a) { return fn(_a, b); @@ -1902,10 +1714,7 @@ * R.add(2, 3); //=> 5 * R.add(7)(10); //=> 17 */ - - var add = - /*#__PURE__*/ - _curry2(function add(a, b) { + var add = /*#__PURE__*/_curry2(function add(a, b) { return Number(a) + Number(b); }); @@ -1927,20 +1736,17 @@ var len1 = set1.length; var len2 = set2.length; var result = []; - idx = 0; + idx = 0; while (idx < len1) { result[result.length] = set1[idx]; idx += 1; } - idx = 0; - while (idx < len2) { result[result.length] = set2[idx]; idx += 1; } - return result; } @@ -1951,57 +1757,46 @@ return function () { return fn.apply(this, arguments); }; - case 1: return function (a0) { return fn.apply(this, arguments); }; - case 2: return function (a0, a1) { return fn.apply(this, arguments); }; - case 3: return function (a0, a1, a2) { return fn.apply(this, arguments); }; - case 4: return function (a0, a1, a2, a3) { return fn.apply(this, arguments); }; - case 5: return function (a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; - case 6: return function (a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; - case 7: return function (a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; - case 8: return function (a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; - case 9: return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; - case 10: return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; - default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); } @@ -2017,33 +1812,26 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ - function _curryN(length, received, fn) { return function () { var combined = []; var argsIdx = 0; var left = length; var combinedIdx = 0; - while (combinedIdx < received.length || argsIdx < arguments.length) { var result; - if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) { result = received[combinedIdx]; } else { result = arguments[argsIdx]; argsIdx += 1; } - combined[combinedIdx] = result; - if (!_isPlaceholder(result)) { left -= 1; } - combinedIdx += 1; } - return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn)); }; } @@ -2090,14 +1878,10 @@ * var g = f(3); * g(4); //=> 10 */ - - var curryN = - /*#__PURE__*/ - _curry2(function curryN(length, fn) { + var curryN = /*#__PURE__*/_curry2(function curryN(length, fn) { if (length === 1) { return _curry1(fn); } - return _arity(length, _curryN(length, [], fn)); }); @@ -2109,18 +1893,15 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ - function _curry3(fn) { return function f3(a, b, c) { switch (arguments.length) { case 0: return f3; - case 1: return _isPlaceholder(a) ? f3 : _curry2(function (_b, _c) { return fn(a, _b, _c); }); - case 2: return _isPlaceholder(a) && _isPlaceholder(b) ? f3 : _isPlaceholder(a) ? _curry2(function (_a, _c) { return fn(_a, b, _c); @@ -2129,7 +1910,6 @@ }) : _curry1(function (_c) { return fn(a, b, _c); }); - default: return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function (_a, _b) { return fn(_a, _b, c); @@ -2148,64 +1928,6 @@ }; } - // 21.2.5.3 get RegExp.prototype.flags - - var _flags = function () { - var that = _anObject(this); - var result = ''; - if (that.global) result += 'g'; - if (that.ignoreCase) result += 'i'; - if (that.multiline) result += 'm'; - if (that.unicode) result += 'u'; - if (that.sticky) result += 'y'; - return result; - }; - - // 21.2.5.3 get RegExp.prototype.flags() - if (_descriptors && /./g.flags != 'g') _objectDp.f(RegExp.prototype, 'flags', { - configurable: true, - get: _flags - }); - - var TO_STRING = 'toString'; - var $toString = /./[TO_STRING]; - - var define = function (fn) { - _redefine(RegExp.prototype, TO_STRING, fn, true); - }; - - // 21.2.5.14 RegExp.prototype.toString() - if (_fails(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) { - define(function toString() { - var R = _anObject(this); - return '/'.concat(R.source, '/', - 'flags' in R ? R.flags : !_descriptors && R instanceof RegExp ? _flags.call(R) : undefined); - }); - // FF44- RegExp#toString has a wrong name - } else if ($toString.name != TO_STRING) { - define(function toString() { - return $toString.call(this); - }); - } - - var DateProto = Date.prototype; - var INVALID_DATE = 'Invalid Date'; - var TO_STRING$1 = 'toString'; - var $toString$1 = DateProto[TO_STRING$1]; - var getTime = DateProto.getTime; - if (new Date(NaN) + '' != INVALID_DATE) { - _redefine(DateProto, TO_STRING$1, function toString() { - var value = getTime.call(this); - // eslint-disable-next-line no-self-compare - return value === value ? $toString$1.call(this) : INVALID_DATE; - }); - } - - // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) - - - _export(_export.S, 'Array', { isArray: _isArray }); - /** * Tests whether or not an object is an array. * @@ -2240,43 +1962,36 @@ * @param {Function} fn default ramda implementation * @return {Function} A function that dispatches on object in list position */ - function _dispatchable(methodNames, xf, fn) { return function () { if (arguments.length === 0) { return fn(); } - var args = Array.prototype.slice.call(arguments, 0); var obj = args.pop(); - if (!_isArray$1(obj)) { var idx = 0; - while (idx < methodNames.length) { if (typeof obj[methodNames[idx]] === 'function') { return obj[methodNames[idx]].apply(obj, args); } - idx += 1; } - if (_isTransformer(obj)) { var transducer = xf.apply(null, args); return transducer(obj); } } - return fn.apply(this, arguments); }; } var _xfBase = { - init: function init() { + init: function () { return this.xf['@@transducer/init'](); }, - result: function result(_result) { - return this.xf['@@transducer/result'](_result); + result: function (result) { + return this.xf['@@transducer/result'](result); } }; @@ -2297,10 +2012,7 @@ * R.max(789, 123); //=> 789 * R.max('a', 'b'); //=> 'b' */ - - var max$1 = - /*#__PURE__*/ - _curry2(function max(a, b) { + var max$1 = /*#__PURE__*/_curry2(function max(a, b) { return b > a ? b : a; }); @@ -2308,401 +2020,13 @@ var idx = 0; var len = functor.length; var result = Array(len); - while (idx < len) { result[idx] = fn(functor[idx]); idx += 1; } - return result; } - var _arrayReduce = function (that, callbackfn, aLen, memo, isRight) { - _aFunction(callbackfn); - var O = _toObject(that); - var self = _iobject(O); - var length = _toLength(O.length); - var index = isRight ? length - 1 : 0; - var i = isRight ? -1 : 1; - if (aLen < 2) for (;;) { - if (index in self) { - memo = self[index]; - index += i; - break; - } - index += i; - if (isRight ? index < 0 : length <= index) { - throw TypeError('Reduce of empty array with no initial value'); - } - } - for (;isRight ? index >= 0 : length > index; index += i) if (index in self) { - memo = callbackfn(memo, self[index], index, O); - } - return memo; - }; - - _export(_export.P + _export.F * !_strictMethod([].reduce, true), 'Array', { - // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue]) - reduce: function reduce(callbackfn /* , initialValue */) { - return _arrayReduce(this, callbackfn, arguments.length, arguments[1], false); - } - }); - - var f$5 = _wks; - - var _wksExt = { - f: f$5 - }; - - var defineProperty = _objectDp.f; - var _wksDefine = function (name) { - var $Symbol = _core.Symbol || (_core.Symbol = _global.Symbol || {}); - if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: _wksExt.f(name) }); - }; - - _wksDefine('asyncIterator'); - - var _meta = createCommonjsModule(function (module) { - var META = _uid('meta'); - - - var setDesc = _objectDp.f; - var id = 0; - var isExtensible = Object.isExtensible || function () { - return true; - }; - var FREEZE = !_fails(function () { - return isExtensible(Object.preventExtensions({})); - }); - var setMeta = function (it) { - setDesc(it, META, { value: { - i: 'O' + ++id, // object ID - w: {} // weak collections IDs - } }); - }; - var fastKey = function (it, create) { - // return primitive with prefix - if (!_isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; - if (!_has(it, META)) { - // can't set metadata to uncaught frozen object - if (!isExtensible(it)) return 'F'; - // not necessary to add metadata - if (!create) return 'E'; - // add missing metadata - setMeta(it); - // return object ID - } return it[META].i; - }; - var getWeak = function (it, create) { - if (!_has(it, META)) { - // can't set metadata to uncaught frozen object - if (!isExtensible(it)) return true; - // not necessary to add metadata - if (!create) return false; - // add missing metadata - setMeta(it); - // return hash weak collections IDs - } return it[META].w; - }; - // add metadata on freeze-family methods calling - var onFreeze = function (it) { - if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it); - return it; - }; - var meta = module.exports = { - KEY: META, - NEED: false, - fastKey: fastKey, - getWeak: getWeak, - onFreeze: onFreeze - }; - }); - var _meta_1 = _meta.KEY; - var _meta_2 = _meta.NEED; - var _meta_3 = _meta.fastKey; - var _meta_4 = _meta.getWeak; - var _meta_5 = _meta.onFreeze; - - var f$6 = Object.getOwnPropertySymbols; - - var _objectGops = { - f: f$6 - }; - - // all enumerable object keys, includes symbols - - - - var _enumKeys = function (it) { - var result = _objectKeys(it); - var getSymbols = _objectGops.f; - if (getSymbols) { - var symbols = getSymbols(it); - var isEnum = _objectPie.f; - var i = 0; - var key; - while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key); - } return result; - }; - - // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window - - var gOPN$1 = _objectGopn.f; - var toString$1 = {}.toString; - - var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames - ? Object.getOwnPropertyNames(window) : []; - - var getWindowNames = function (it) { - try { - return gOPN$1(it); - } catch (e) { - return windowNames.slice(); - } - }; - - var f$7 = function getOwnPropertyNames(it) { - return windowNames && toString$1.call(it) == '[object Window]' ? getWindowNames(it) : gOPN$1(_toIobject(it)); - }; - - var _objectGopnExt = { - f: f$7 - }; - - // ECMAScript 6 symbols shim - - - - - - var META = _meta.KEY; - - - - - - - - - - - - - - - - - - - - var gOPD$2 = _objectGopd.f; - var dP$2 = _objectDp.f; - var gOPN$2 = _objectGopnExt.f; - var $Symbol = _global.Symbol; - var $JSON = _global.JSON; - var _stringify = $JSON && $JSON.stringify; - var PROTOTYPE$2 = 'prototype'; - var HIDDEN = _wks('_hidden'); - var TO_PRIMITIVE = _wks('toPrimitive'); - var isEnum = {}.propertyIsEnumerable; - var SymbolRegistry = _shared('symbol-registry'); - var AllSymbols = _shared('symbols'); - var OPSymbols = _shared('op-symbols'); - var ObjectProto$1 = Object[PROTOTYPE$2]; - var USE_NATIVE$1 = typeof $Symbol == 'function'; - var QObject = _global.QObject; - // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 - var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild; - - // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 - var setSymbolDesc = _descriptors && _fails(function () { - return _objectCreate(dP$2({}, 'a', { - get: function () { return dP$2(this, 'a', { value: 7 }).a; } - })).a != 7; - }) ? function (it, key, D) { - var protoDesc = gOPD$2(ObjectProto$1, key); - if (protoDesc) delete ObjectProto$1[key]; - dP$2(it, key, D); - if (protoDesc && it !== ObjectProto$1) dP$2(ObjectProto$1, key, protoDesc); - } : dP$2; - - var wrap = function (tag) { - var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]); - sym._k = tag; - return sym; - }; - - var isSymbol = USE_NATIVE$1 && typeof $Symbol.iterator == 'symbol' ? function (it) { - return typeof it == 'symbol'; - } : function (it) { - return it instanceof $Symbol; - }; - - var $defineProperty = function defineProperty(it, key, D) { - if (it === ObjectProto$1) $defineProperty(OPSymbols, key, D); - _anObject(it); - key = _toPrimitive(key, true); - _anObject(D); - if (_has(AllSymbols, key)) { - if (!D.enumerable) { - if (!_has(it, HIDDEN)) dP$2(it, HIDDEN, _propertyDesc(1, {})); - it[HIDDEN][key] = true; - } else { - if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; - D = _objectCreate(D, { enumerable: _propertyDesc(0, false) }); - } return setSymbolDesc(it, key, D); - } return dP$2(it, key, D); - }; - var $defineProperties = function defineProperties(it, P) { - _anObject(it); - var keys = _enumKeys(P = _toIobject(P)); - var i = 0; - var l = keys.length; - var key; - while (l > i) $defineProperty(it, key = keys[i++], P[key]); - return it; - }; - var $create = function create(it, P) { - return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P); - }; - var $propertyIsEnumerable = function propertyIsEnumerable(key) { - var E = isEnum.call(this, key = _toPrimitive(key, true)); - if (this === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false; - return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true; - }; - var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { - it = _toIobject(it); - key = _toPrimitive(key, true); - if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return; - var D = gOPD$2(it, key); - if (D && _has(AllSymbols, key) && !(_has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; - return D; - }; - var $getOwnPropertyNames = function getOwnPropertyNames(it) { - var names = gOPN$2(_toIobject(it)); - var result = []; - var i = 0; - var key; - while (names.length > i) { - if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); - } return result; - }; - var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { - var IS_OP = it === ObjectProto$1; - var names = gOPN$2(IS_OP ? OPSymbols : _toIobject(it)); - var result = []; - var i = 0; - var key; - while (names.length > i) { - if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto$1, key) : true)) result.push(AllSymbols[key]); - } return result; - }; - - // 19.4.1.1 Symbol([description]) - if (!USE_NATIVE$1) { - $Symbol = function Symbol() { - if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); - var tag = _uid(arguments.length > 0 ? arguments[0] : undefined); - var $set = function (value) { - if (this === ObjectProto$1) $set.call(OPSymbols, value); - if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; - setSymbolDesc(this, tag, _propertyDesc(1, value)); - }; - if (_descriptors && setter) setSymbolDesc(ObjectProto$1, tag, { configurable: true, set: $set }); - return wrap(tag); - }; - _redefine($Symbol[PROTOTYPE$2], 'toString', function toString() { - return this._k; - }); - - _objectGopd.f = $getOwnPropertyDescriptor; - _objectDp.f = $defineProperty; - _objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames; - _objectPie.f = $propertyIsEnumerable; - _objectGops.f = $getOwnPropertySymbols; - - if (_descriptors && !_library) { - _redefine(ObjectProto$1, 'propertyIsEnumerable', $propertyIsEnumerable, true); - } - - _wksExt.f = function (name) { - return wrap(_wks(name)); - }; - } - - _export(_export.G + _export.W + _export.F * !USE_NATIVE$1, { Symbol: $Symbol }); - - for (var es6Symbols = ( - // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 - 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables' - ).split(','), j$1 = 0; es6Symbols.length > j$1;)_wks(es6Symbols[j$1++]); - - for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]); - - _export(_export.S + _export.F * !USE_NATIVE$1, 'Symbol', { - // 19.4.2.1 Symbol.for(key) - 'for': function (key) { - return _has(SymbolRegistry, key += '') - ? SymbolRegistry[key] - : SymbolRegistry[key] = $Symbol(key); - }, - // 19.4.2.5 Symbol.keyFor(sym) - keyFor: function keyFor(sym) { - if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); - for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key; - }, - useSetter: function () { setter = true; }, - useSimple: function () { setter = false; } - }); - - _export(_export.S + _export.F * !USE_NATIVE$1, 'Object', { - // 19.1.2.2 Object.create(O [, Properties]) - create: $create, - // 19.1.2.4 Object.defineProperty(O, P, Attributes) - defineProperty: $defineProperty, - // 19.1.2.3 Object.defineProperties(O, Properties) - defineProperties: $defineProperties, - // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) - getOwnPropertyDescriptor: $getOwnPropertyDescriptor, - // 19.1.2.7 Object.getOwnPropertyNames(O) - getOwnPropertyNames: $getOwnPropertyNames, - // 19.1.2.8 Object.getOwnPropertySymbols(O) - getOwnPropertySymbols: $getOwnPropertySymbols - }); - - // 24.3.2 JSON.stringify(value [, replacer [, space]]) - $JSON && _export(_export.S + _export.F * (!USE_NATIVE$1 || _fails(function () { - var S = $Symbol(); - // MS Edge converts symbol values to JSON as {} - // WebKit converts symbol values to JSON as null - // V8 throws on boxed symbols - return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; - })), 'JSON', { - stringify: function stringify(it) { - var args = [it]; - var i = 1; - var replacer, $replacer; - while (arguments.length > i) args.push(arguments[i++]); - $replacer = replacer = args[1]; - if (!_isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined - if (!_isArray(replacer)) replacer = function (key, value) { - if (typeof $replacer == 'function') value = $replacer.call(this, key, value); - if (!isSymbol(value)) return value; - }; - args[1] = replacer; - return _stringify.apply($JSON, args); - } - }); - - // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) - $Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf); - // 19.4.3.5 Symbol.prototype[@@toStringTag] - _setToStringTag($Symbol, 'Symbol'); - // 20.2.1.9 Math[@@toStringTag] - _setToStringTag(Math, 'Math', true); - // 24.3.3 JSON[@@toStringTag] - _setToStringTag(_global.JSON, 'JSON', true); - function _isString(x) { return Object.prototype.toString.call(x) === '[object String]'; } @@ -2724,56 +2048,41 @@ * _isArrayLike({length: 10}); //=> false * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true */ - - var _isArrayLike = - /*#__PURE__*/ - _curry1(function isArrayLike(x) { + var _isArrayLike = /*#__PURE__*/_curry1(function isArrayLike(x) { if (_isArray$1(x)) { return true; } - if (!x) { return false; } - - if (_typeof(x) !== 'object') { + if (typeof x !== 'object') { return false; } - if (_isString(x)) { return false; } - if (x.nodeType === 1) { return !!x.length; } - if (x.length === 0) { return true; } - if (x.length > 0) { return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); } - return false; }); - var XWrap = - /*#__PURE__*/ - function () { + var XWrap = /*#__PURE__*/function () { function XWrap(fn) { this.f = fn; } - XWrap.prototype['@@transducer/init'] = function () { throw new Error('init not implemented on XWrap'); }; - XWrap.prototype['@@transducer/result'] = function (acc) { return acc; }; - XWrap.prototype['@@transducer/step'] = function (acc, x) { return this.f(acc, x); }; @@ -2807,47 +2116,36 @@ * // logs {a: 2} * @symb R.bind(f, o)(a, b) = f.call(o, a, b) */ - - var bind = - /*#__PURE__*/ - _curry2(function bind(fn, thisObj) { + var bind = /*#__PURE__*/_curry2(function bind(fn, thisObj) { return _arity(fn.length, function () { return fn.apply(thisObj, arguments); }); }); - function _arrayReduce$1(xf, acc, list) { + function _arrayReduce(xf, acc, list) { var idx = 0; var len = list.length; - while (idx < len) { acc = xf['@@transducer/step'](acc, list[idx]); - if (acc && acc['@@transducer/reduced']) { acc = acc['@@transducer/value']; break; } - idx += 1; } - return xf['@@transducer/result'](acc); } function _iterableReduce(xf, acc, iter) { var step = iter.next(); - while (!step.done) { acc = xf['@@transducer/step'](acc, step.value); - if (acc && acc['@@transducer/reduced']) { acc = acc['@@transducer/value']; break; } - step = iter.next(); } - return xf['@@transducer/result'](acc); } @@ -2856,27 +2154,23 @@ } var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator'; + function _reduce(fn, acc, list) { if (typeof fn === 'function') { fn = _xwrap(fn); } - if (_isArrayLike(list)) { - return _arrayReduce$1(fn, acc, list); + return _arrayReduce(fn, acc, list); } - if (typeof list['fantasy-land/reduce'] === 'function') { return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); } - if (list[symIterator] != null) { return _iterableReduce(fn, acc, list[symIterator]()); } - if (typeof list.next === 'function') { return _iterableReduce(fn, acc, list); } - if (typeof list.reduce === 'function') { return _methodReduce(fn, acc, list, 'reduce'); } @@ -2884,17 +2178,13 @@ throw new TypeError('reduce: list must be array or iterable'); } - var XMap = - /*#__PURE__*/ - function () { + var XMap = /*#__PURE__*/function () { function XMap(f, xf) { this.xf = xf; this.f = f; } - XMap.prototype['@@transducer/init'] = _xfBase.init; XMap.prototype['@@transducer/result'] = _xfBase.result; - XMap.prototype['@@transducer/step'] = function (result, input) { return this.xf['@@transducer/step'](result, this.f(input)); }; @@ -2902,74 +2192,43 @@ return XMap; }(); - var _xmap = - /*#__PURE__*/ - _curry2(function _xmap(f, xf) { + var _xmap = /*#__PURE__*/_curry2(function _xmap(f, xf) { return new XMap(f, xf); }); - // most Object methods by ES6 should accept primitives - - - - var _objectSap = function (KEY, exec) { - var fn = (_core.Object || {})[KEY] || Object[KEY]; - var exp = {}; - exp[KEY] = exec(fn); - _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp); - }; - - // 19.1.2.14 Object.keys(O) - - - - _objectSap('keys', function () { - return function keys(it) { - return _objectKeys(_toObject(it)); - }; - }); - function _has$1(prop, obj) { return Object.prototype.hasOwnProperty.call(obj, prop); } - var toString$2 = Object.prototype.toString; - - var _isArguments = function _isArguments() { - return toString$2.call(arguments) === '[object Arguments]' ? function _isArguments(x) { - return toString$2.call(x) === '[object Arguments]'; + var toString$1 = Object.prototype.toString; + var _isArguments = function () { + return toString$1.call(arguments) === '[object Arguments]' ? function _isArguments(x) { + return toString$1.call(x) === '[object Arguments]'; } : function _isArguments(x) { return _has$1('callee', x); }; }; - var hasEnumBug = ! - /*#__PURE__*/ - { - toString: null - }.propertyIsEnumerable('toString'); - var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug - - var hasArgsEnumBug = - /*#__PURE__*/ - function () { + // cover IE < 9 keys issues + var hasEnumBug = ! /*#__PURE__*/{ toString: null }.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + // Safari bug + var hasArgsEnumBug = /*#__PURE__*/function () { return arguments.propertyIsEnumerable('length'); }(); var contains = function contains(list, item) { var idx = 0; - while (idx < list.length) { if (list[idx] === item) { return true; } - idx += 1; } - return false; }; + /** * Returns a list containing the names of all the enumerable own properties of * the supplied object. @@ -2988,46 +2247,33 @@ * * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] */ - - var _keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? function keys(obj) { return Object(obj) !== obj ? [] : Object.keys(obj); } : function keys(obj) { if (Object(obj) !== obj) { return []; } - var prop, nIdx; var ks = []; - var checkArgsLength = hasArgsEnumBug && _isArguments(obj); - for (prop in obj) { if (_has$1(prop, obj) && (!checkArgsLength || prop !== 'length')) { ks[ks.length] = prop; } } - if (hasEnumBug) { nIdx = nonEnumerableProps.length - 1; - while (nIdx >= 0) { prop = nonEnumerableProps[nIdx]; - if (_has$1(prop, obj) && !contains(ks, prop)) { ks[ks.length] = prop; } - nIdx -= 1; } } - return ks; }; - - var keys$1 = - /*#__PURE__*/ - _curry1(_keys); + var keys = /*#__PURE__*/_curry1(_keys); /** * Takes a function and @@ -3064,24 +2310,17 @@ * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } * @symb R.map(f, functor_o) = functor_o.map(f) */ - - var map = - /*#__PURE__*/ - _curry2( - /*#__PURE__*/ - _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { + var map = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { switch (Object.prototype.toString.call(functor)) { case '[object Function]': return curryN(functor.length, function () { return fn.call(this, functor.apply(this, arguments)); }); - case '[object Object]': return _reduce(function (acc, key) { acc[key] = fn(functor[key]); return acc; - }, {}, keys$1(functor)); - + }, {}, keys(functor)); default: return _map(fn, functor); } @@ -3105,22 +2344,16 @@ * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined */ - - var path = - /*#__PURE__*/ - _curry2(function path(paths, obj) { + var path = /*#__PURE__*/_curry2(function path(paths, obj) { var val = obj; var idx = 0; - while (idx < paths.length) { if (val == null) { return; } - val = val[paths[idx]]; idx += 1; } - return val; }); @@ -3143,9 +2376,7 @@ * R.prop('x', {}); //=> undefined */ - var prop = - /*#__PURE__*/ - _curry2(function prop(p, obj) { + var prop = /*#__PURE__*/_curry2(function prop(p, obj) { return path([p], obj); }); @@ -3174,10 +2405,7 @@ * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] */ - - var pluck = - /*#__PURE__*/ - _curry2(function pluck(p, list) { + var pluck = /*#__PURE__*/_curry2(function pluck(p, list) { return map(prop(p), list); }); @@ -3227,10 +2455,7 @@ * * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) */ - - var reduce = - /*#__PURE__*/ - _curry3(_reduce); + var reduce = /*#__PURE__*/_curry3(_reduce); /** * ap applies a list of functions to a list of values. @@ -3258,29 +2483,24 @@ * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] */ - - var ap = - /*#__PURE__*/ - _curry2(function ap(applyF, applyX) { + var ap = /*#__PURE__*/_curry2(function ap(applyF, applyX) { return typeof applyX['fantasy-land/ap'] === 'function' ? applyX['fantasy-land/ap'](applyF) : typeof applyF.ap === 'function' ? applyF.ap(applyX) : typeof applyF === 'function' ? function (x) { return applyF(x)(applyX(x)); - } : // else + } : + // else _reduce(function (acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF); }); - // 20.1.2.3 Number.isInteger(number) - - var floor$1 = Math.floor; - var _isInteger = function isInteger(it) { - return !_isObject(it) && isFinite(it) && floor$1(it) === it; - }; - - // 20.1.2.3 Number.isInteger(number) - - - _export(_export.S, 'Number', { isInteger: _isInteger }); + /** + * Determine if the passed argument is an integer. + * + * @private + * @param {*} n + * @category Type + * @return {Boolean} + */ function _isFunction(x) { return Object.prototype.toString.call(x) === '[object Function]'; @@ -3303,10 +2523,7 @@ * var madd3 = R.liftN(3, (...args) => R.sum(args)); * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] */ - - var liftN = - /*#__PURE__*/ - _curry2(function liftN(arity, fn) { + var liftN = /*#__PURE__*/_curry2(function liftN(arity, fn) { var lifted = curryN(arity, fn); return curryN(arity, function () { return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); @@ -3335,10 +2552,7 @@ * * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] */ - - var lift = - /*#__PURE__*/ - _curry1(function lift(fn) { + var lift = /*#__PURE__*/_curry1(function lift(fn) { return liftN(fn.length, fn); }); @@ -3383,10 +2597,7 @@ * var g = f(3); * g(4); //=> 10 */ - - var curry = - /*#__PURE__*/ - _curry1(function curry(fn) { + var curry = /*#__PURE__*/_curry1(function curry(fn) { return curryN(fn.length, fn); }); @@ -3422,10 +2633,7 @@ * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' * @symb R.call(f, a, b) = f(a, b) */ - - var call = - /*#__PURE__*/ - curry(function call(fn) { + var call = /*#__PURE__*/curry(function call(fn) { return fn.apply(this, Array.prototype.slice.call(arguments, 1)); }); @@ -3435,7 +2643,6 @@ * * @private */ - function _makeFlat(recursive) { return function flatt(list) { var value, jlen, j; @@ -3448,7 +2655,6 @@ value = recursive ? flatt(list[idx]) : list[idx]; j = 0; jlen = value.length; - while (j < jlen) { result[result.length] = value[j]; j += 1; @@ -3456,10 +2662,8 @@ } else { result[result.length] = list[idx]; } - idx += 1; } - return result; }; } @@ -3471,13 +2675,13 @@ }; } - var preservingReduced = function preservingReduced(xf) { + var preservingReduced = function (xf) { return { '@@transducer/init': _xfBase.init, - '@@transducer/result': function transducerResult(result) { + '@@transducer/result': function (result) { return xf['@@transducer/result'](result); }, - '@@transducer/step': function transducerStep(result, input) { + '@@transducer/step': function (result, input) { var ret = xf['@@transducer/step'](result, input); return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; } @@ -3488,18 +2692,16 @@ var rxf = preservingReduced(xf); return { '@@transducer/init': _xfBase.init, - '@@transducer/result': function transducerResult(result) { + '@@transducer/result': function (result) { return rxf['@@transducer/result'](result); }, - '@@transducer/step': function transducerStep(result, input) { + '@@transducer/step': function (result, input) { return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); } }; }; - var _xchain = - /*#__PURE__*/ - _curry2(function _xchain(f, xf) { + var _xchain = /*#__PURE__*/_curry2(function _xchain(f, xf) { return map(f, _flatCat(xf)); }); @@ -3525,72 +2727,15 @@ * * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] */ - - var chain = - /*#__PURE__*/ - _curry2( - /*#__PURE__*/ - _dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { + var chain = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { if (typeof monad === 'function') { return function (x) { return fn(monad(x))(x); }; } - return _makeFlat(false)(map(fn, monad)); })); - // 7.2.8 IsRegExp(argument) - - - var MATCH = _wks('match'); - var _isRegexp = function (it) { - var isRegExp; - return _isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : _cof(it) == 'RegExp'); - }; - - var dP$3 = _objectDp.f; - var gOPN$3 = _objectGopn.f; - - - var $RegExp = _global.RegExp; - var Base$1 = $RegExp; - var proto$2 = $RegExp.prototype; - var re1 = /a/g; - var re2 = /a/g; - // "new" creates a new object, old webkit buggy here - var CORRECT_NEW = new $RegExp(re1) !== re1; - - if (_descriptors && (!CORRECT_NEW || _fails(function () { - re2[_wks('match')] = false; - // RegExp constructor can alter flags and IsRegExp works correct with @@match - return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i'; - }))) { - $RegExp = function RegExp(p, f) { - var tiRE = this instanceof $RegExp; - var piRE = _isRegexp(p); - var fiU = f === undefined; - return !tiRE && piRE && p.constructor === $RegExp && fiU ? p - : _inheritIfRequired(CORRECT_NEW - ? new Base$1(piRE && !fiU ? p.source : p, f) - : Base$1((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? _flags.call(p) : f) - , tiRE ? this : proto$2, $RegExp); - }; - var proxy = function (key) { - key in $RegExp || dP$3($RegExp, key, { - configurable: true, - get: function () { return Base$1[key]; }, - set: function (it) { Base$1[key] = it; } - }); - }; - for (var keys$2 = gOPN$3(Base$1), i$1 = 0; keys$2.length > i$1;) proxy(keys$2[i$1++]); - proto$2.constructor = $RegExp; - $RegExp.prototype = proto$2; - _redefine(_global, 'RegExp', $RegExp); - } - - _setSpecies('RegExp'); - /** * Gives a single-word string description of the (native) type of a value, * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not @@ -3616,10 +2761,7 @@ * R.type(() => {}); //=> "Function" * R.type(undefined); //=> "Undefined" */ - - var type = - /*#__PURE__*/ - _curry1(function type(val) { + var type = /*#__PURE__*/_curry1(function type(val) { return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1); }); @@ -3642,10 +2784,7 @@ * R.not(0); //=> true * R.not(1); //=> false */ - - var not = - /*#__PURE__*/ - _curry1(function not(a) { + var not = /*#__PURE__*/_curry1(function not(a) { return !a; }); @@ -3671,10 +2810,7 @@ * isNil(7); //=> false * isNotNil(7); //=> true */ - - var complement = - /*#__PURE__*/ - lift(not); + var complement = /*#__PURE__*/lift(not); function _pipe(f, g) { return function () { @@ -3692,15 +2828,12 @@ * @param {String} methodname property to check for a custom implementation * @return {Object} Whatever the return value of the method is. */ - function _checkForMethod(methodname, fn) { return function () { var length = arguments.length; - if (length === 0) { return fn(); } - var obj = arguments[length - 1]; return _isArray$1(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); }; @@ -3730,12 +2863,7 @@ * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] * R.slice(0, 3, 'ramda'); //=> 'ram' */ - - var slice = - /*#__PURE__*/ - _curry3( - /*#__PURE__*/ - _checkForMethod('slice', function slice(fromIndex, toIndex, list) { + var slice = /*#__PURE__*/_curry3( /*#__PURE__*/_checkForMethod('slice', function slice(fromIndex, toIndex, list) { return Array.prototype.slice.call(list, fromIndex, toIndex); })); @@ -3766,14 +2894,7 @@ * R.tail('a'); //=> '' * R.tail(''); //=> '' */ - - var tail = - /*#__PURE__*/ - _curry1( - /*#__PURE__*/ - _checkForMethod('tail', - /*#__PURE__*/ - slice(1, Infinity))); + var tail = /*#__PURE__*/_curry1( /*#__PURE__*/_checkForMethod('tail', /*#__PURE__*/slice(1, Infinity))); /** * Performs left-to-right function composition. The leftmost function may have @@ -3798,108 +2919,13 @@ * f(3, 4); // -(3^4) + 1 * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) */ - function pipe() { if (arguments.length === 0) { throw new Error('pipe requires at least one argument'); } - return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments))); } - var _fixReWks = function (KEY, length, exec) { - var SYMBOL = _wks(KEY); - var fns = exec(_defined, SYMBOL, ''[KEY]); - var strfn = fns[0]; - var rxfn = fns[1]; - if (_fails(function () { - var O = {}; - O[SYMBOL] = function () { return 7; }; - return ''[KEY](O) != 7; - })) { - _redefine(String.prototype, KEY, strfn); - _hide(RegExp.prototype, SYMBOL, length == 2 - // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue) - // 21.2.5.11 RegExp.prototype[@@split](string, limit) - ? function (string, arg) { return rxfn.call(string, this, arg); } - // 21.2.5.6 RegExp.prototype[@@match](string) - // 21.2.5.9 RegExp.prototype[@@search](string) - : function (string) { return rxfn.call(string, this); } - ); - } - }; - - // @@split logic - _fixReWks('split', 2, function (defined, SPLIT, $split) { - var isRegExp = _isRegexp; - var _split = $split; - var $push = [].push; - var $SPLIT = 'split'; - var LENGTH = 'length'; - var LAST_INDEX = 'lastIndex'; - if ( - 'abbc'[$SPLIT](/(b)*/)[1] == 'c' || - 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 || - 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 || - '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 || - '.'[$SPLIT](/()()/)[LENGTH] > 1 || - ''[$SPLIT](/.?/)[LENGTH] - ) { - var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group - // based on es5-shim implementation, need to rework it - $split = function (separator, limit) { - var string = String(this); - if (separator === undefined && limit === 0) return []; - // If `separator` is not a regex, use native split - if (!isRegExp(separator)) return _split.call(string, separator, limit); - var output = []; - var flags = (separator.ignoreCase ? 'i' : '') + - (separator.multiline ? 'm' : '') + - (separator.unicode ? 'u' : '') + - (separator.sticky ? 'y' : ''); - var lastLastIndex = 0; - var splitLimit = limit === undefined ? 4294967295 : limit >>> 0; - // Make `global` and avoid `lastIndex` issues by working with a copy - var separatorCopy = new RegExp(separator.source, flags + 'g'); - var separator2, match, lastIndex, lastLength, i; - // Doesn't need flags gy, but they don't hurt - if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); - while (match = separatorCopy.exec(string)) { - // `separatorCopy.lastIndex` is not reliable cross-browser - lastIndex = match.index + match[0][LENGTH]; - if (lastIndex > lastLastIndex) { - output.push(string.slice(lastLastIndex, match.index)); - // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG - // eslint-disable-next-line no-loop-func - if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () { - for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined; - }); - if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1)); - lastLength = match[0][LENGTH]; - lastLastIndex = lastIndex; - if (output[LENGTH] >= splitLimit) break; - } - if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop - } - if (lastLastIndex === string[LENGTH]) { - if (lastLength || !separatorCopy.test('')) output.push(''); - } else output.push(string.slice(lastLastIndex)); - return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output; - }; - // Chakra, V8 - } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) { - $split = function (separator, limit) { - return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit); - }; - } - // 21.1.3.17 String.prototype.split(separator, limit) - return [function split(separator, limit) { - var O = defined(this); - var fn = separator == undefined ? undefined : separator[SPLIT]; - return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit); - }, $split]; - }); - /** * Returns a new list or string with the elements or characters in reverse * order. @@ -3924,10 +2950,7 @@ * R.reverse('a'); //=> 'a' * R.reverse(''); //=> '' */ - - var reverse = - /*#__PURE__*/ - _curry1(function reverse(list) { + var reverse = /*#__PURE__*/_curry1(function reverse(list) { return _isString(list) ? list.split('').reverse().join('') : Array.prototype.slice.call(list, 0).reverse(); }); @@ -3955,73 +2978,19 @@ * * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) */ - function compose() { if (arguments.length === 0) { throw new Error('compose requires at least one argument'); } - return pipe.apply(this, reverse(arguments)); } - var $sort = [].sort; - var test = [1, 2, 3]; - - _export(_export.P + _export.F * (_fails(function () { - // IE8- - test.sort(undefined); - }) || !_fails(function () { - // V8 bug - test.sort(null); - // Old WebKit - }) || !_strictMethod($sort)), 'Array', { - // 22.1.3.25 Array.prototype.sort(comparefn) - sort: function sort(comparefn) { - return comparefn === undefined - ? $sort.call(_toObject(this)) - : $sort.call(_toObject(this), _aFunction(comparefn)); - } - }); - - var $indexOf = _arrayIncludes(false); - var $native = [].indexOf; - var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0; - - _export(_export.P + _export.F * (NEGATIVE_ZERO || !_strictMethod($native)), 'Array', { - // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex]) - indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { - return NEGATIVE_ZERO - // convert -0 to +0 - ? $native.apply(this, arguments) || 0 - : $indexOf(this, searchElement, arguments[1]); - } - }); - - var dP$4 = _objectDp.f; - var FProto = Function.prototype; - var nameRE = /^\s*function ([^ (]*)/; - var NAME$1 = 'name'; - - // 19.2.4.2 name - NAME$1 in FProto || _descriptors && dP$4(FProto, NAME$1, { - configurable: true, - get: function () { - try { - return ('' + this).match(nameRE)[1]; - } catch (e) { - return ''; - } - } - }); - function _arrayFromIterator(iter) { var list = []; var next; - while (!(next = iter.next()).done) { list.push(next.value); } - return list; } @@ -4033,23 +3002,11 @@ if (pred(x, list[idx])) { return true; } - idx += 1; } - return false; } - // @@match logic - _fixReWks('match', 1, function (defined, MATCH, $match) { - // 21.1.3.11 String.prototype.match(regexp) - return [function match(regexp) { - var O = defined(this); - var fn = regexp == undefined ? undefined : regexp[MATCH]; - return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); - }, $match]; - }); - function _functionName(f) { // String(x => x) evaluates to "x => x", so the pattern may not match. var match = String(f).match(/^function (\w*)/); @@ -4079,10 +3036,7 @@ * R.identical(0, -0); //=> false * R.identical(NaN, NaN); //=> true */ - - var identical = - /*#__PURE__*/ - _curry2(function identical(a, b) { + var identical = /*#__PURE__*/_curry2(function identical(a, b) { // SameValue algorithm if (a === b) { // Steps 1-5, 7-10 @@ -4107,14 +3061,13 @@ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { var a = _arrayFromIterator(aIterator); - var b = _arrayFromIterator(bIterator); function eq(_a, _b) { return _equals(_a, _b, stackA.slice(), stackB.slice()); - } // if *a* array contains any element that is not included in *b* - + } + // if *a* array contains any element that is not included in *b* return !_containsWith(function (b, aItem) { return !_containsWith(eq, aItem, b); }, b, a); @@ -4150,43 +3103,33 @@ if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') { return a === b; } - break; - case 'Boolean': case 'Number': case 'String': - if (!(_typeof(a) === _typeof(b) && identical(a.valueOf(), b.valueOf()))) { + if (!(typeof a === typeof b && identical(a.valueOf(), b.valueOf()))) { return false; } - break; - case 'Date': if (!identical(a.valueOf(), b.valueOf())) { return false; } - break; - case 'Error': return a.name === b.name && a.message === b.message; - case 'RegExp': if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) { return false; } - break; } var idx = stackA.length - 1; - while (idx >= 0) { if (stackA[idx] === a) { return stackB[idx] === b; } - idx -= 1; } @@ -4197,14 +3140,12 @@ } return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); - case 'Set': if (a.size !== b.size) { return false; } return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); - case 'Arguments': case 'Array': case 'Object': @@ -4225,32 +3166,27 @@ case 'Float64Array': case 'ArrayBuffer': break; - default: // Values of other types are only equal if identical. return false; } - var keysA = keys$1(a); - - if (keysA.length !== keys$1(b).length) { + var keysA = keys(a); + if (keysA.length !== keys(b).length) { return false; } var extendedStackA = stackA.concat([a]); var extendedStackB = stackB.concat([b]); - idx = keysA.length - 1; + idx = keysA.length - 1; while (idx >= 0) { var key = keysA[idx]; - if (!(_has$1(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { return false; } - idx -= 1; } - return true; } @@ -4279,53 +3215,42 @@ * var b = {}; b.v = b; * R.equals(a, b); //=> true */ - - var equals = - /*#__PURE__*/ - _curry2(function equals(a, b) { + var equals = /*#__PURE__*/_curry2(function equals(a, b) { return _equals(a, b, [], []); }); function _indexOf(list, a, idx) { - var inf, item; // Array.prototype.indexOf doesn't exist below IE9 - + var inf, item; + // Array.prototype.indexOf doesn't exist below IE9 if (typeof list.indexOf === 'function') { - switch (_typeof(a)) { + switch (typeof a) { case 'number': if (a === 0) { // manually crawl the list to distinguish between +0 and -0 inf = 1 / a; - while (idx < list.length) { item = list[idx]; - if (item === 0 && 1 / item === inf) { return idx; } - idx += 1; } - return -1; } else if (a !== a) { // NaN while (idx < list.length) { item = list[idx]; - if (typeof item === 'number' && item !== item) { return idx; } - idx += 1; } - return -1; - } // non-zero numbers can utilise Set - - + } + // non-zero numbers can utilise Set return list.indexOf(a, idx); - // all these types can utilise Set + // all these types can utilise Set case 'string': case 'boolean': case 'function': @@ -4337,19 +3262,15 @@ // null can utilise Set return list.indexOf(a, idx); } - } - } // anything else not covered above, defer to R.equals - - + } + // anything else not covered above, defer to R.equals while (idx < list.length) { if (equals(list[idx], a)) { return idx; } - idx += 1; } - return -1; } @@ -4357,59 +3278,13 @@ return _indexOf(list, a, 0) >= 0; } - // @@replace logic - _fixReWks('replace', 2, function (defined, REPLACE, $replace) { - // 21.1.3.14 String.prototype.replace(searchValue, replaceValue) - return [function replace(searchValue, replaceValue) { - var O = defined(this); - var fn = searchValue == undefined ? undefined : searchValue[REPLACE]; - return fn !== undefined - ? fn.call(searchValue, O, replaceValue) - : $replace.call(String(O), searchValue, replaceValue); - }, $replace]; - }); - function _quote(s) { var escaped = s.replace(/\\/g, '\\\\').replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace .replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t').replace(/\v/g, '\\v').replace(/\0/g, '\\0'); + return '"' + escaped.replace(/"/g, '\\"') + '"'; } - // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() - - var getTime$1 = Date.prototype.getTime; - var $toISOString = Date.prototype.toISOString; - - var lz = function (num) { - return num > 9 ? num : '0' + num; - }; - - // PhantomJS / old WebKit has a broken implementations - var _dateToIsoString = (_fails(function () { - return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z'; - }) || !_fails(function () { - $toISOString.call(new Date(NaN)); - })) ? function toISOString() { - if (!isFinite(getTime$1.call(this))) throw RangeError('Invalid time value'); - var d = this; - var y = d.getUTCFullYear(); - var m = d.getUTCMilliseconds(); - var s = y < 0 ? '-' : y > 9999 ? '+' : ''; - return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) + - '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) + - 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) + - ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; - } : $toISOString; - - // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() - - - - // PhantomJS / old WebKit has a broken implementations - _export(_export.P + _export.F * (Date.prototype.toISOString !== _dateToIsoString), 'Date', { - toISOString: _dateToIsoString - }); - /** * Polyfill from . */ @@ -4438,10 +3313,8 @@ if (fn(list[idx])) { result[result.length] = list[idx]; } - idx += 1; } - return result; } @@ -4449,17 +3322,13 @@ return Object.prototype.toString.call(x) === '[object Object]'; } - var XFilter = - /*#__PURE__*/ - function () { + var XFilter = /*#__PURE__*/function () { function XFilter(f, xf) { this.xf = xf; this.f = f; } - XFilter.prototype['@@transducer/init'] = _xfBase.init; XFilter.prototype['@@transducer/result'] = _xfBase.result; - XFilter.prototype['@@transducer/step'] = function (result, input) { return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; }; @@ -4467,9 +3336,7 @@ return XFilter; }(); - var _xfilter = - /*#__PURE__*/ - _curry2(function _xfilter(f, xf) { + var _xfilter = /*#__PURE__*/_curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); @@ -4500,19 +3367,14 @@ * * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ - - var filter = - /*#__PURE__*/ - _curry2( - /*#__PURE__*/ - _dispatchable(['filter'], _xfilter, function (pred, filterable) { + var filter = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['filter'], _xfilter, function (pred, filterable) { return _isObject$1(filterable) ? _reduce(function (acc, key) { if (pred(filterable[key])) { acc[key] = filterable[key]; } - return acc; - }, {}, keys$1(filterable)) : // else + }, {}, keys(filterable)) : + // else _filter(pred, filterable); })); @@ -4540,10 +3402,7 @@ * * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ - - var reject = - /*#__PURE__*/ - _curry2(function reject(pred, filterable) { + var reject = /*#__PURE__*/_curry2(function reject(pred, filterable) { return filter(_complement(pred), filterable); }); @@ -4551,52 +3410,43 @@ var recur = function recur(y) { var xs = seen.concat([x]); return _contains(y, xs) ? '' : _toString(y, xs); - }; // mapPairs :: (Object, [String]) -> [String] - + }; - var mapPairs = function mapPairs(obj, keys) { + // mapPairs :: (Object, [String]) -> [String] + var mapPairs = function (obj, keys$$1) { return _map(function (k) { return _quote(k) + ': ' + recur(obj[k]); - }, keys.slice().sort()); + }, keys$$1.slice().sort()); }; switch (Object.prototype.toString.call(x)) { case '[object Arguments]': return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))'; - case '[object Array]': return '[' + _map(recur, x).concat(mapPairs(x, reject(function (k) { - return /^\d+$/.test(k); - }, keys$1(x)))).join(', ') + ']'; - + return (/^\d+$/.test(k) + ); + }, keys(x)))).join(', ') + ']'; case '[object Boolean]': - return _typeof(x) === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); - + return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); case '[object Date]': return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; - case '[object Null]': return 'null'; - case '[object Number]': - return _typeof(x) === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); - + return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); case '[object String]': - return _typeof(x) === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); - + return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); case '[object Undefined]': return 'undefined'; - default: if (typeof x.toString === 'function') { var repr = x.toString(); - if (repr !== '[object Object]') { return repr; } } - - return '{' + mapPairs(x, keys$1(x)).join(', ') + '}'; + return '{' + mapPairs(x, keys(x)).join(', ') + '}'; } } @@ -4636,10 +3486,7 @@ * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' */ - - var toString$3 = - /*#__PURE__*/ - _curry1(function toString(val) { + var toString$2 = /*#__PURE__*/_curry1(function toString(val) { return _toString(val, []); }); @@ -4670,10 +3517,7 @@ * * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) */ - - var converge = - /*#__PURE__*/ - _curry2(function converge(after, fns) { + var converge = /*#__PURE__*/_curry2(function converge(after, fns) { return curryN(reduce(max$1, 0, pluck('length', fns)), function () { var args = arguments; var context = this; @@ -4683,9 +3527,7 @@ }); }); - var XReduceBy = - /*#__PURE__*/ - function () { + var XReduceBy = /*#__PURE__*/function () { function XReduceBy(valueFn, valueAcc, keyFn, xf) { this.valueFn = valueFn; this.valueAcc = valueAcc; @@ -4693,27 +3535,21 @@ this.xf = xf; this.inputs = {}; } - XReduceBy.prototype['@@transducer/init'] = _xfBase.init; - XReduceBy.prototype['@@transducer/result'] = function (result) { var key; - for (key in this.inputs) { if (_has$1(key, this.inputs)) { result = this.xf['@@transducer/step'](result, this.inputs[key]); - if (result['@@transducer/reduced']) { result = result['@@transducer/value']; break; } } } - this.inputs = null; return this.xf['@@transducer/result'](result); }; - XReduceBy.prototype['@@transducer/step'] = function (result, input) { var key = this.keyFn(input); this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; @@ -4724,9 +3560,7 @@ return XReduceBy; }(); - var _xreduceBy = - /*#__PURE__*/ - _curryN(4, [], function _xreduceBy(valueFn, valueAcc, keyFn, xf) { + var _xreduceBy = /*#__PURE__*/_curryN(4, [], function _xreduceBy(valueFn, valueAcc, keyFn, xf) { return new XReduceBy(valueFn, valueAcc, keyFn, xf); }); @@ -4774,12 +3608,7 @@ * // 'F': ['Bart'] * // } */ - - var reduceBy = - /*#__PURE__*/ - _curryN(4, [], - /*#__PURE__*/ - _dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) { + var reduceBy = /*#__PURE__*/_curryN(4, [], /*#__PURE__*/_dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) { return _reduce(function (acc, elt) { var key = keyFn(elt); acc[key] = valueFn(_has$1(key, acc) ? acc[key] : valueAcc, elt); @@ -4811,10 +3640,7 @@ * var letters = ['a', 'b', 'A', 'a', 'B', 'c']; * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} */ - - var countBy = - /*#__PURE__*/ - reduceBy(function (acc, elem) { + var countBy = /*#__PURE__*/reduceBy(function (acc, elem) { return acc + 1; }, 0); @@ -4833,14 +3659,9 @@ * * R.dec(42); //=> 41 */ + var dec = /*#__PURE__*/add(-1); - var dec = - /*#__PURE__*/ - add(-1); - - var XDropRepeatsWith = - /*#__PURE__*/ - function () { + var XDropRepeatsWith = /*#__PURE__*/function () { function XDropRepeatsWith(pred, xf) { this.xf = xf; this.pred = pred; @@ -4850,16 +3671,13 @@ XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; - XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) { var sameAsLast = false; - if (!this.seenFirstValue) { this.seenFirstValue = true; } else if (this.pred(this.lastValue, input)) { sameAsLast = true; } - this.lastValue = input; return sameAsLast ? result : this.xf['@@transducer/step'](result, input); }; @@ -4867,9 +3685,7 @@ return XDropRepeatsWith; }(); - var _xdropRepeatsWith = - /*#__PURE__*/ - _curry2(function _xdropRepeatsWith(pred, xf) { + var _xdropRepeatsWith = /*#__PURE__*/_curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); @@ -4899,10 +3715,7 @@ * @symb R.nth(0, [a, b, c]) = a * @symb R.nth(1, [a, b, c]) = b */ - - var nth = - /*#__PURE__*/ - _curry2(function nth(offset, list) { + var nth = /*#__PURE__*/_curry2(function nth(offset, list) { var idx = offset < 0 ? list.length + offset : offset; return _isString(list) ? list.charAt(idx) : list[idx]; }); @@ -4927,10 +3740,7 @@ * R.last('abc'); //=> 'c' * R.last(''); //=> '' */ - - var last = - /*#__PURE__*/ - nth(-1); + var last = /*#__PURE__*/nth(-1); /** * Returns a new list without any consecutively repeating elements. Equality is @@ -4953,28 +3763,19 @@ * var l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] */ - - var dropRepeatsWith = - /*#__PURE__*/ - _curry2( - /*#__PURE__*/ - _dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { + var dropRepeatsWith = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { var result = []; var idx = 1; var len = list.length; - if (len !== 0) { result[0] = list[0]; - while (idx < len) { if (!pred(last(result), list[idx])) { result[result.length] = list[idx]; } - idx += 1; } } - return result; })); @@ -4996,16 +3797,7 @@ * * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] */ - - var dropRepeats = - /*#__PURE__*/ - _curry1( - /*#__PURE__*/ - _dispatchable([], - /*#__PURE__*/ - _xdropRepeatsWith(equals), - /*#__PURE__*/ - dropRepeatsWith(equals))); + var dropRepeats = /*#__PURE__*/_curry1( /*#__PURE__*/_dispatchable([], /*#__PURE__*/_xdropRepeatsWith(equals), /*#__PURE__*/dropRepeatsWith(equals))); /** * Returns a new function much like the supplied one, except that the first two @@ -5027,10 +3819,7 @@ * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] * @symb R.flip(f)(a, b, c) = f(b, a, c) */ - - var flip = - /*#__PURE__*/ - _curry1(function flip(fn) { + var flip = /*#__PURE__*/_curry1(function flip(fn) { return curryN(fn.length, function (a, b) { var args = Array.prototype.slice.call(arguments, 0); args[0] = b; @@ -5055,18 +3844,13 @@ * * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} */ - - var fromPairs = - /*#__PURE__*/ - _curry1(function fromPairs(pairs) { + var fromPairs = /*#__PURE__*/_curry1(function fromPairs(pairs) { var result = {}; var idx = 0; - while (idx < pairs.length) { result[pairs[idx][0]] = pairs[idx][1]; idx += 1; } - return result; }); @@ -5110,18 +3894,10 @@ * // 'F': [{name: 'Eddy', score: 58}] * // } */ - - var groupBy = - /*#__PURE__*/ - _curry2( - /*#__PURE__*/ - _checkForMethod('groupBy', - /*#__PURE__*/ - reduceBy(function (acc, item) { + var groupBy = /*#__PURE__*/_curry2( /*#__PURE__*/_checkForMethod('groupBy', /*#__PURE__*/reduceBy(function (acc, item) { if (acc == null) { acc = []; } - acc.push(item); return acc; }, null))); @@ -5147,10 +3923,7 @@ * R.head('abc'); //=> 'a' * R.head(''); //=> '' */ - - var head = - /*#__PURE__*/ - nth(0); + var head = /*#__PURE__*/nth(0); function _identity(x) { return x; @@ -5175,10 +3948,7 @@ * R.identity(obj) === obj; //=> true * @symb R.identity(a) = a */ - - var identity = - /*#__PURE__*/ - _curry1(_identity); + var identity = /*#__PURE__*/_curry1(_identity); /** * Increments its argument. @@ -5195,10 +3965,7 @@ * * R.inc(42); //=> 43 */ - - var inc = - /*#__PURE__*/ - add(1); + var inc = /*#__PURE__*/add(1); /** * Given a function that generates a key, turns a list of objects into an @@ -5222,10 +3989,7 @@ * R.indexBy(R.prop('id'), list); * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} */ - - var indexBy = - /*#__PURE__*/ - reduceBy(function (acc, elem) { + var indexBy = /*#__PURE__*/reduceBy(function (acc, elem) { return elem; }, null); @@ -5253,268 +4017,32 @@ * R.init('a'); //=> '' * R.init(''); //=> '' */ + var init = /*#__PURE__*/slice(0, -1); - var init = - /*#__PURE__*/ - slice(0, -1); - - var _validateCollection = function (it, TYPE) { - if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); - return it; - }; - - var dP$5 = _objectDp.f; - - - - - - - - - - var fastKey = _meta.fastKey; - - var SIZE = _descriptors ? '_s' : 'size'; - - var getEntry = function (that, key) { - // fast case - var index = fastKey(key); - var entry; - if (index !== 'F') return that._i[index]; - // frozen object case - for (entry = that._f; entry; entry = entry.n) { - if (entry.k == key) return entry; - } - }; - - var _collectionStrong = { - getConstructor: function (wrapper, NAME, IS_MAP, ADDER) { - var C = wrapper(function (that, iterable) { - _anInstance(that, C, NAME, '_i'); - that._t = NAME; // collection type - that._i = _objectCreate(null); // index - that._f = undefined; // first entry - that._l = undefined; // last entry - that[SIZE] = 0; // size - if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); - }); - _redefineAll(C.prototype, { - // 23.1.3.1 Map.prototype.clear() - // 23.2.3.2 Set.prototype.clear() - clear: function clear() { - for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) { - entry.r = true; - if (entry.p) entry.p = entry.p.n = undefined; - delete data[entry.i]; - } - that._f = that._l = undefined; - that[SIZE] = 0; - }, - // 23.1.3.3 Map.prototype.delete(key) - // 23.2.3.4 Set.prototype.delete(value) - 'delete': function (key) { - var that = _validateCollection(this, NAME); - var entry = getEntry(that, key); - if (entry) { - var next = entry.n; - var prev = entry.p; - delete that._i[entry.i]; - entry.r = true; - if (prev) prev.n = next; - if (next) next.p = prev; - if (that._f == entry) that._f = next; - if (that._l == entry) that._l = prev; - that[SIZE]--; - } return !!entry; - }, - // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) - // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) - forEach: function forEach(callbackfn /* , that = undefined */) { - _validateCollection(this, NAME); - var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); - var entry; - while (entry = entry ? entry.n : this._f) { - f(entry.v, entry.k, this); - // revert to the last existing entry - while (entry && entry.r) entry = entry.p; - } - }, - // 23.1.3.7 Map.prototype.has(key) - // 23.2.3.7 Set.prototype.has(value) - has: function has(key) { - return !!getEntry(_validateCollection(this, NAME), key); - } - }); - if (_descriptors) dP$5(C.prototype, 'size', { - get: function () { - return _validateCollection(this, NAME)[SIZE]; - } - }); - return C; - }, - def: function (that, key, value) { - var entry = getEntry(that, key); - var prev, index; - // change existing entry - if (entry) { - entry.v = value; - // create new entry - } else { - that._l = entry = { - i: index = fastKey(key, true), // <- index - k: key, // <- key - v: value, // <- value - p: prev = that._l, // <- previous entry - n: undefined, // <- next entry - r: false // <- removed - }; - if (!that._f) that._f = entry; - if (prev) prev.n = entry; - that[SIZE]++; - // add to index - if (index !== 'F') that._i[index] = entry; - } return that; - }, - getEntry: getEntry, - setStrong: function (C, NAME, IS_MAP) { - // add .keys, .values, .entries, [@@iterator] - // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 - _iterDefine(C, NAME, function (iterated, kind) { - this._t = _validateCollection(iterated, NAME); // target - this._k = kind; // kind - this._l = undefined; // previous - }, function () { - var that = this; - var kind = that._k; - var entry = that._l; - // revert to the last existing entry - while (entry && entry.r) entry = entry.p; - // get next entry - if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) { - // or finish the iteration - that._t = undefined; - return _iterStep(1); - } - // return step by kind - if (kind == 'keys') return _iterStep(0, entry.k); - if (kind == 'values') return _iterStep(0, entry.v); - return _iterStep(0, [entry.k, entry.v]); - }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); - - // add [@@species], 23.1.2.2, 23.2.2.2 - _setSpecies(NAME); - } - }; - - var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { - var Base = _global[NAME]; - var C = Base; - var ADDER = IS_MAP ? 'set' : 'add'; - var proto = C && C.prototype; - var O = {}; - var fixMethod = function (KEY) { - var fn = proto[KEY]; - _redefine(proto, KEY, - KEY == 'delete' ? function (a) { - return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); - } : KEY == 'has' ? function has(a) { - return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); - } : KEY == 'get' ? function get(a) { - return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); - } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; } - : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; } - ); - }; - if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () { - new C().entries().next(); - }))) { - // create collection constructor - C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); - _redefineAll(C.prototype, methods); - _meta.NEED = true; - } else { - var instance = new C(); - // early implementations not supports chaining - var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; - // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false - var THROWS_ON_PRIMITIVES = _fails(function () { instance.has(1); }); - // most early implementations doesn't supports iterables, most modern - not close it correctly - var ACCEPT_ITERABLES = _iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new - // for early implementations -0 and +0 not the same - var BUGGY_ZERO = !IS_WEAK && _fails(function () { - // V8 ~ Chromium 42- fails only with 5+ elements - var $instance = new C(); - var index = 5; - while (index--) $instance[ADDER](index, index); - return !$instance.has(-0); - }); - if (!ACCEPT_ITERABLES) { - C = wrapper(function (target, iterable) { - _anInstance(target, C, NAME); - var that = _inheritIfRequired(new Base(), target, C); - if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); - return that; - }); - C.prototype = proto; - proto.constructor = C; - } - if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { - fixMethod('delete'); - fixMethod('has'); - IS_MAP && fixMethod('get'); - } - if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); - // weak collections should not contains .clear method - if (IS_WEAK && proto.clear) delete proto.clear; - } - - _setToStringTag(C, NAME); - - O[NAME] = C; - _export(_export.G + _export.W + _export.F * (C != Base), O); - - if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); - - return C; - }; - - var SET = 'Set'; - - // 23.2 Set Objects - var es6_set = _collection(SET, function (get) { - return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; - }, { - // 23.2.3.1 Set.prototype.add(value) - add: function add(value) { - return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value); - } - }, _collectionStrong); - - var _Set = - /*#__PURE__*/ - function () { + var _Set = /*#__PURE__*/function () { function _Set() { /* globals Set */ this._nativeSet = typeof Set === 'function' ? new Set() : null; this._items = {}; - } // until we figure out why jsdoc chokes on this + } + + // until we figure out why jsdoc chokes on this // @param item The item to add to the Set // @returns {boolean} true if the item did not exist prior, otherwise false // - - _Set.prototype.add = function (item) { return !hasOrAdd(item, true, this); - }; // + }; + + // // @param item The item to check for existence in the Set // @returns {boolean} true if the item exists in the Set, otherwise false // - - _Set.prototype.has = function (item) { return hasOrAdd(item, false, this); - }; // + }; + + // // Combines the logic for checking whether an item is a member of the set and // for adding a new item to the set. // @@ -5524,16 +4052,12 @@ // @param set The set instance to check or add to. // @return {boolean} true if the item already existed, otherwise false. // - - return _Set; }(); function hasOrAdd(item, shouldAdd, set) { - var type = _typeof(item); - + var type = typeof item; var prevSize, newSize; - switch (type) { case 'string': case 'number': @@ -5545,18 +4069,14 @@ if (shouldAdd) { set._items['-0'] = true; } - return false; } - } // these types can all utilise the native Set - - + } + // these types can all utilise the native Set if (set._nativeSet !== null) { if (shouldAdd) { prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; return newSize === prevSize; } else { @@ -5568,7 +4088,6 @@ set._items[type] = {}; set._items[type][item] = true; } - return false; } else if (item in set._items[type]) { return true; @@ -5576,7 +4095,6 @@ if (shouldAdd) { set._items[type][item] = true; } - return false; } } @@ -5586,21 +4104,18 @@ // representing [ falseExists, trueExists ] if (type in set._items) { var bIdx = item ? 1 : 0; - if (set._items[type][bIdx]) { return true; } else { if (shouldAdd) { set._items[type][bIdx] = true; } - return false; } } else { if (shouldAdd) { set._items[type] = item ? [false, true] : [true, false]; } - return false; } @@ -5609,9 +4124,7 @@ if (set._nativeSet !== null) { if (shouldAdd) { prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; return newSize === prevSize; } else { @@ -5622,18 +4135,14 @@ if (shouldAdd) { set._items[type] = [item]; } - return false; } - if (!_contains(item, set._items[type])) { if (shouldAdd) { set._items[type].push(item); } - return false; } - return true; } @@ -5644,7 +4153,6 @@ if (shouldAdd) { set._items[type] = true; } - return false; } @@ -5654,40 +4162,31 @@ if (shouldAdd) { set._items['null'] = true; } - return false; } - return true; } - /* falls through */ - default: // reduce the search size of heterogeneous sets by creating buckets // for each type. type = Object.prototype.toString.call(item); - if (!(type in set._items)) { if (shouldAdd) { set._items[type] = [item]; } - return false; - } // scan through all previously applied items - - + } + // scan through all previously applied items if (!_contains(item, set._items[type])) { if (shouldAdd) { set._items[type].push(item); } - return false; } - return true; } - } // A simple Set type that honours R.equals semantics + } /** * Returns a new list containing only one copy of each element in the original @@ -5707,10 +4206,7 @@ * * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] */ - - var uniqBy = - /*#__PURE__*/ - _curry2(function uniqBy(fn, list) { + var uniqBy = /*#__PURE__*/_curry2(function uniqBy(fn, list) { var set = new _Set(); var result = []; var idx = 0; @@ -5719,14 +4215,11 @@ while (idx < list.length) { item = list[idx]; appliedItem = fn(item); - if (set.add(appliedItem)) { result.push(item); } - idx += 1; } - return result; }); @@ -5747,49 +4240,7 @@ * R.uniq([1, '1']); //=> [1, '1'] * R.uniq([[42], [42]]); //=> [[42]] */ - - var uniq = - /*#__PURE__*/ - uniqBy(identity); - - // 19.1.2.1 Object.assign(target, source, ...) - - - - - - var $assign = Object.assign; - - // should work with symbols and should have deterministic property order (V8 bug) - var _objectAssign = !$assign || _fails(function () { - var A = {}; - var B = {}; - // eslint-disable-next-line no-undef - var S = Symbol(); - var K = 'abcdefghijklmnopqrst'; - A[S] = 7; - K.split('').forEach(function (k) { B[k] = k; }); - return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; - }) ? function assign(target, source) { // eslint-disable-line no-unused-vars - var T = _toObject(target); - var aLen = arguments.length; - var index = 1; - var getSymbols = _objectGops.f; - var isEnum = _objectPie.f; - while (aLen > index) { - var S = _iobject(arguments[index++]); - var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S); - var length = keys.length; - var j = 0; - var key; - while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; - } return T; - } : $assign; - - // 19.1.3.1 Object.assign(target, source) - - - _export(_export.S + _export.F, 'Object', { assign: _objectAssign }); + var uniq = /*#__PURE__*/uniqBy(identity); /** * Turns a named method with a specified arity into a function that can be @@ -5818,18 +4269,13 @@ * @symb R.invoker(1, 'method')(a, o) = o['method'](a) * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) */ - - var invoker = - /*#__PURE__*/ - _curry2(function invoker(arity, method) { + var invoker = /*#__PURE__*/_curry2(function invoker(arity, method) { return curryN(arity + 1, function () { var target = arguments[arity]; - if (target != null && _isFunction(target[method])) { return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity)); } - - throw new TypeError(toString$3(target) + ' does not have a method named "' + method + '"'); + throw new TypeError(toString$2(target) + ' does not have a method named "' + method + '"'); }); }); @@ -5852,10 +4298,7 @@ * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' * R.join('|', [1, 2, 3]); //=> '1|2|3' */ - - var join = - /*#__PURE__*/ - invoker(1, 'join'); + var join = /*#__PURE__*/invoker(1, 'join'); /** * juxt applies a list of functions to a list of values. @@ -5874,33 +4317,12 @@ * getRange(3, 4, 9, -3); //=> [-3, 9] * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] */ - - var juxt = - /*#__PURE__*/ - _curry1(function juxt(fns) { + var juxt = /*#__PURE__*/_curry1(function juxt(fns) { return converge(function () { return Array.prototype.slice.call(arguments, 0); }, fns); }); - var $native$1 = [].lastIndexOf; - var NEGATIVE_ZERO$1 = !!$native$1 && 1 / [1].lastIndexOf(1, -0) < 0; - - _export(_export.P + _export.F * (NEGATIVE_ZERO$1 || !_strictMethod($native$1)), 'Array', { - // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex]) - lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) { - // convert -0 to +0 - if (NEGATIVE_ZERO$1) return $native$1.apply(this, arguments) || 0; - var O = _toIobject(this); - var length = _toLength(O.length); - var index = length - 1; - if (arguments.length > 1) index = Math.min(index, _toInteger(arguments[1])); - if (index < 0) index = length + index; - for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0; - return -1; - } - }); - /** * Adds together all the elements of a list. * @@ -5916,10 +4338,7 @@ * * R.sum([2,4,6,8,100,1]); //=> 121 */ - - var sum = - /*#__PURE__*/ - reduce(add, 0); + var sum = /*#__PURE__*/reduce(add, 0); /** * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an @@ -5950,18 +4369,13 @@ * factorial(5); //=> 120 * count; //=> 1 */ - - var memoizeWith = - /*#__PURE__*/ - _curry2(function memoizeWith(mFn, fn) { + var memoizeWith = /*#__PURE__*/_curry2(function memoizeWith(mFn, fn) { var cache = {}; return _arity(fn.length, function () { var key = mFn.apply(this, arguments); - if (!_has$1(key, cache)) { cache[key] = fn.apply(this, arguments); } - return cache[key]; }); }); @@ -5994,11 +4408,8 @@ * factorial(5); //=> 120 * count; //=> 1 */ - - var memoize = - /*#__PURE__*/ - memoizeWith(function () { - return toString$3(arguments); + var memoize = /*#__PURE__*/memoizeWith(function () { + return toString$2(arguments); }); /** @@ -6021,10 +4432,7 @@ * triple(4); //=> 12 * R.multiply(2, 5); //=> 10 */ - - var multiply = - /*#__PURE__*/ - _curry2(function multiply(a, b) { + var multiply = /*#__PURE__*/_curry2(function multiply(a, b) { return a * b; }); @@ -6060,12 +4468,7 @@ * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) */ - - var partialRight = - /*#__PURE__*/ - _createPartialApplicator( - /*#__PURE__*/ - flip(_concat)); + var partialRight = /*#__PURE__*/_createPartialApplicator( /*#__PURE__*/flip(_concat)); /** * Takes a predicate and a list or other `Filterable` object and returns the @@ -6091,10 +4494,7 @@ * R.partition(R.contains('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] */ - - var partition = - /*#__PURE__*/ - juxt([filter, reject]); + var partition = /*#__PURE__*/juxt([filter, reject]); /** * Similar to `pick` except that this one includes a `key: undefined` pair for @@ -6114,20 +4514,15 @@ * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} */ - - var pickAll = - /*#__PURE__*/ - _curry2(function pickAll(names, obj) { + var pickAll = /*#__PURE__*/_curry2(function pickAll(names, obj) { var result = {}; var idx = 0; var len = names.length; - while (idx < len) { var name = names[idx]; result[name] = obj[name]; idx += 1; } - return result; }); @@ -6146,10 +4541,7 @@ * * R.product([2,4,6,8,100,1]); //=> 38400 */ - - var product = - /*#__PURE__*/ - reduce(multiply, 1); + var product = /*#__PURE__*/reduce(multiply, 1); /** * Accepts a function `fn` and a list of transformer functions and returns a @@ -6180,19 +4572,14 @@ * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) */ - - var useWith = - /*#__PURE__*/ - _curry2(function useWith(fn, transformers) { + var useWith = /*#__PURE__*/_curry2(function useWith(fn, transformers) { return curryN(transformers.length, function () { var args = []; var idx = 0; - while (idx < transformers.length) { args.push(transformers[idx].call(this, arguments[idx])); idx += 1; } - return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); }); }); @@ -6216,10 +4603,7 @@ * var kids = [abby, fred]; * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] */ - - var project = - /*#__PURE__*/ - useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity + var project = /*#__PURE__*/useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity /** * Splits a string into an array of strings based on the given @@ -6241,10 +4625,7 @@ * * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] */ - - var split = - /*#__PURE__*/ - invoker(1, 'split'); + var split = /*#__PURE__*/invoker(1, 'split'); /** * The lower case version of a string. @@ -6261,10 +4642,7 @@ * * R.toLower('XYZ'); //=> 'xyz' */ - - var toLower = - /*#__PURE__*/ - invoker(0, 'toLowerCase'); + var toLower = /*#__PURE__*/invoker(0, 'toLowerCase'); /** * Converts an object into an array of key, value arrays. Only the object's @@ -6284,18 +4662,13 @@ * * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] */ - - var toPairs = - /*#__PURE__*/ - _curry1(function toPairs(obj) { + var toPairs = /*#__PURE__*/_curry1(function toPairs(obj) { var pairs = []; - for (var prop in obj) { if (_has$1(prop, obj)) { pairs[pairs.length] = [prop, obj[prop]]; } } - return pairs; }); @@ -6314,10 +4687,7 @@ * * R.toUpper('abc'); //=> 'ABC' */ - - var toUpper = - /*#__PURE__*/ - invoker(0, 'toUpperCase'); + var toUpper = /*#__PURE__*/invoker(0, 'toUpperCase'); /** * Initializes a transducer using supplied iterator function. Returns a single @@ -6366,22 +4736,12 @@ * var firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] */ - - var transduce = - /*#__PURE__*/ - curryN(4, function transduce(xf, fn, acc, list) { + var transduce = /*#__PURE__*/curryN(4, function transduce(xf, fn, acc, list) { return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); }); - // 21.1.3.25 String.prototype.trim() - _stringTrim('trim', function ($trim) { - return function trim() { - return $trim(this, 3); - }; - }); - - var ws = "\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003" + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + "\u2029\uFEFF"; - var zeroWidth = "\u200B"; + var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + '\u2029\uFEFF'; + var zeroWidth = '\u200b'; var hasProtoTrim = typeof String.prototype.trim === 'function'; /** * Removes (strips) whitespace from both ends of the string. @@ -6398,12 +4758,7 @@ * R.trim(' xyz '); //=> 'xyz' * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] */ - - var _trim = !hasProtoTrim || - /*#__PURE__*/ - ws.trim() || ! - /*#__PURE__*/ - zeroWidth.trim() ? function trim(str) { + var _trim = !hasProtoTrim || /*#__PURE__*/ws.trim() || ! /*#__PURE__*/zeroWidth.trim() ? function trim(str) { var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); return str.replace(beginRx, '').replace(endRx, ''); @@ -6428,12 +4783,7 @@ * * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] */ - - var union = - /*#__PURE__*/ - _curry2( - /*#__PURE__*/ - compose(uniq, _concat)); + var union = /*#__PURE__*/_curry2( /*#__PURE__*/compose(uniq, _concat)); /** * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from @@ -6452,10 +4802,7 @@ * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] */ - - var unnest = - /*#__PURE__*/ - chain(_identity); + var unnest = /*#__PURE__*/chain(_identity); var QueryRenderer = /*#__PURE__*/ @@ -6684,216 +5031,213 @@ } }); - // 19.1.3.19 Object.setPrototypeOf(O, proto) - - _export(_export.S, 'Object', { setPrototypeOf: _setProto.set }); - - var $forEach = _arrayMethods(0); - var STRICT = _strictMethod([].forEach, true); + var dP$1 = _objectDp.f; + var FProto = Function.prototype; + var nameRE = /^\s*function ([^ (]*)/; + var NAME$1 = 'name'; - _export(_export.P + _export.F * !STRICT, 'Array', { - // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg]) - forEach: function forEach(callbackfn /* , thisArg */) { - return $forEach(this, callbackfn, arguments[1]); + // 19.2.4.2 name + NAME$1 in FProto || _descriptors && dP$1(FProto, NAME$1, { + configurable: true, + get: function () { + try { + return ('' + this).match(nameRE)[1]; + } catch (e) { + return ''; + } } }); - // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) - _export(_export.S, 'Object', { create: _objectCreate }); - var runtime = createCommonjsModule(function (module) { - /** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - !function (global) { - - var Op = Object.prototype; - var hasOwn = Op.hasOwnProperty; - var undefined; // More compressible than void 0. - - var $Symbol = typeof Symbol === "function" ? Symbol : {}; - var iteratorSymbol = $Symbol.iterator || "@@iterator"; - var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; - var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; - var runtime = global.regeneratorRuntime; - - if (runtime) { - { - // If regeneratorRuntime is defined globally and we're in a module, - // make the exports object identical to regeneratorRuntime. - module.exports = runtime; - } // Don't bother evaluating the rest of this file if the runtime was - // already defined globally. - - - return; - } // Define the runtime globally (as expected by generated code) as either - // module.exports (if we're in a module) or a new, empty object. - - - runtime = global.regeneratorRuntime = module.exports; - - function wrap(innerFn, outerFn, self, tryLocsList) { - // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. - var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; - var generator = Object.create(protoGenerator.prototype); - var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, - // .throw, and .return methods. - - generator._invoke = makeInvokeMethod(innerFn, self, context); - return generator; - } + /** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ - runtime.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion - // record like context.tryEntries[i].completion. This interface could - // have been (and was previously) designed to take a closure to be - // invoked without arguments, but in all the cases we care about we - // already have an existing method we want to call, so there's no need - // to create a new function object. We can even get away with assuming - // the method takes exactly one argument, since that happens to be true - // in every case, so we don't have to touch the arguments object. The - // only additional allocation required is the completion record, which - // has a stable shape and so hopefully should be cheap to allocate. - - function tryCatch(fn, obj, arg) { - try { - return { - type: "normal", - arg: fn.call(obj, arg) - }; - } catch (err) { - return { - type: "throw", - arg: err - }; - } + !(function(global) { + + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; + var undefined; // More compressible than void 0. + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; + var runtime = global.regeneratorRuntime; + if (runtime) { + { + // If regeneratorRuntime is defined globally and we're in a module, + // make the exports object identical to regeneratorRuntime. + module.exports = runtime; } + // Don't bother evaluating the rest of this file if the runtime was + // already defined globally. + return; + } - var GenStateSuspendedStart = "suspendedStart"; - var GenStateSuspendedYield = "suspendedYield"; - var GenStateExecuting = "executing"; - var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as - // breaking out of the dispatch switch statement. - - var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and - // .constructor.prototype properties for functions that return Generator - // objects. For full spec compliance, you may wish to configure your - // minifier not to mangle the names of these two functions. - - function Generator() {} - - function GeneratorFunction() {} - - function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that - // don't natively support it. - + // Define the runtime globally (as expected by generated code) as either + // module.exports (if we're in a module) or a new, empty object. + runtime = global.regeneratorRuntime = module.exports; - var IteratorPrototype = {}; + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; + var generator = Object.create(protoGenerator.prototype); + var context = new Context(tryLocsList || []); - IteratorPrototype[iteratorSymbol] = function () { - return this; - }; + // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + generator._invoke = makeInvokeMethod(innerFn, self, context); - var getProto = Object.getPrototypeOf; - var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); - - if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { - // This environment has a native %IteratorPrototype%; use it instead - // of the polyfill. - IteratorPrototype = NativeIteratorPrototype; + return generator; + } + runtime.wrap = wrap; + + // Try/catch helper to minimize deoptimizations. Returns a completion + // record like context.tryEntries[i].completion. This interface could + // have been (and was previously) designed to take a closure to be + // invoked without arguments, but in all the cases we care about we + // already have an existing method we want to call, so there's no need + // to create a new function object. We can even get away with assuming + // the method takes exactly one argument, since that happens to be true + // in every case, so we don't have to touch the arguments object. The + // only additional allocation required is the completion record, which + // has a stable shape and so hopefully should be cheap to allocate. + function tryCatch(fn, obj, arg) { + try { + return { type: "normal", arg: fn.call(obj, arg) }; + } catch (err) { + return { type: "throw", arg: err }; } + } - var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); - GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; - GeneratorFunctionPrototype.constructor = GeneratorFunction; - GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the - // Iterator interface in terms of a single ._invoke method. + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; + + // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. + var ContinueSentinel = {}; + + // Dummy constructor functions that we use as the .constructor and + // .constructor.prototype properties for functions that return Generator + // objects. For full spec compliance, you may wish to configure your + // minifier not to mangle the names of these two functions. + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + + // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + var IteratorPrototype = {}; + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function (method) { - prototype[method] = function (arg) { - return this._invoke(method, arg); - }; - }); - } + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + if (NativeIteratorPrototype && + NativeIteratorPrototype !== Op && + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; + } - runtime.isGeneratorFunction = function (genFun) { - var ctor = typeof genFun === "function" && genFun.constructor; - return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can - // do is to check its .name property. - (ctor.displayName || ctor.name) === "GeneratorFunction" : false; - }; + var Gp = GeneratorFunctionPrototype.prototype = + Generator.prototype = Object.create(IteratorPrototype); + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = + GeneratorFunction.displayName = "GeneratorFunction"; + + // Helper for defining the .next, .throw, and .return methods of the + // Iterator interface in terms of a single ._invoke method. + function defineIteratorMethods(prototype) { + ["next", "throw", "return"].forEach(function(method) { + prototype[method] = function(arg) { + return this._invoke(method, arg); + }; + }); + } - runtime.mark = function (genFun) { - if (Object.setPrototypeOf) { - Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); - } else { - genFun.__proto__ = GeneratorFunctionPrototype; + runtime.isGeneratorFunction = function(genFun) { + var ctor = typeof genFun === "function" && genFun.constructor; + return ctor + ? ctor === GeneratorFunction || + // For the native GeneratorFunction constructor, the best we can + // do is to check its .name property. + (ctor.displayName || ctor.name) === "GeneratorFunction" + : false; + }; - if (!(toStringTagSymbol in genFun)) { - genFun[toStringTagSymbol] = "GeneratorFunction"; - } + runtime.mark = function(genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + } else { + genFun.__proto__ = GeneratorFunctionPrototype; + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; } + } + genFun.prototype = Object.create(Gp); + return genFun; + }; - genFun.prototype = Object.create(Gp); - return genFun; - }; // Within the body of any async function, `await x` is transformed to - // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test - // `hasOwn.call(value, "__await")` to determine if the yielded value is - // meant to be awaited. - - - runtime.awrap = function (arg) { - return { - __await: arg - }; - }; - - function AsyncIterator(generator) { - function invoke(method, arg, resolve, reject) { - var record = tryCatch(generator[method], generator, arg); - - if (record.type === "throw") { - reject(record.arg); - } else { - var result = record.arg; - var value = result.value; - - if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) { - return Promise.resolve(value.__await).then(function (value) { - invoke("next", value, resolve, reject); - }, function (err) { - invoke("throw", err, resolve, reject); - }); - } + // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. + runtime.awrap = function(arg) { + return { __await: arg }; + }; - return Promise.resolve(value).then(function (unwrapped) { - // When a yielded Promise is resolved, its final value becomes - // the .value of the Promise<{value,done}> result for the - // current iteration. - result.value = unwrapped; - resolve(result); - }, function (error) { - // If a rejected Promise was yielded, throw the rejection back - // into the async generator function so it can be handled there. - return invoke("throw", error, resolve, reject); + function AsyncIterator(generator) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + if (value && + typeof value === "object" && + hasOwn.call(value, "__await")) { + return Promise.resolve(value.__await).then(function(value) { + invoke("next", value, resolve, reject); + }, function(err) { + invoke("throw", err, resolve, reject); }); } + + return Promise.resolve(value).then(function(unwrapped) { + // When a yielded Promise is resolved, its final value becomes + // the .value of the Promise<{value,done}> result for the + // current iteration. + result.value = unwrapped; + resolve(result); + }, function(error) { + // If a rejected Promise was yielded, throw the rejection back + // into the async generator function so it can be handled there. + return invoke("throw", error, resolve, reject); + }); } + } - var previousPromise; + var previousPromise; - function enqueue(method, arg) { - function callInvokeWithMethodAndArg() { - return new Promise(function (resolve, reject) { - invoke(method, arg, resolve, reject); - }); - } + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new Promise(function(resolve, reject) { + invoke(method, arg, resolve, reject); + }); + } - return previousPromise = // If enqueue has been called before, then we want to wait until + return previousPromise = + // If enqueue has been called before, then we want to wait until // all previous Promises have been resolved before calling invoke, // so that results are always delivered in the correct order. If // enqueue has not been called before, then it is important to @@ -6905,504 +5249,524 @@ // execute code before the first await. Since we implement simple // async functions in terms of async generators, it is especially // important to get this right, even though it requires care. - previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later - // invocations of the iterator. - callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); - } // Define the unified helper method that is used to implement .next, - // .throw, and .return (see defineIteratorMethods). - - - this._invoke = enqueue; + previousPromise ? previousPromise.then( + callInvokeWithMethodAndArg, + // Avoid propagating failures to Promises returned by later + // invocations of the iterator. + callInvokeWithMethodAndArg + ) : callInvokeWithMethodAndArg(); } - defineIteratorMethods(AsyncIterator.prototype); - - AsyncIterator.prototype[asyncIteratorSymbol] = function () { - return this; - }; - - runtime.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of - // AsyncIterator objects; they just return a Promise for the value of - // the final result produced by the iterator. + // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + this._invoke = enqueue; + } - runtime.async = function (innerFn, outerFn, self, tryLocsList) { - var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList)); - return runtime.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. - : iter.next().then(function (result) { - return result.done ? result.value : iter.next(); - }); - }; + defineIteratorMethods(AsyncIterator.prototype); + AsyncIterator.prototype[asyncIteratorSymbol] = function () { + return this; + }; + runtime.AsyncIterator = AsyncIterator; + + // Note that simple async functions are implemented on top of + // AsyncIterator objects; they just return a Promise for the value of + // the final result produced by the iterator. + runtime.async = function(innerFn, outerFn, self, tryLocsList) { + var iter = new AsyncIterator( + wrap(innerFn, outerFn, self, tryLocsList) + ); - function makeInvokeMethod(innerFn, self, context) { - var state = GenStateSuspendedStart; - return function invoke(method, arg) { - if (state === GenStateExecuting) { - throw new Error("Generator is already running"); - } + return runtime.isGeneratorFunction(outerFn) + ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function(result) { + return result.done ? result.value : iter.next(); + }); + }; - if (state === GenStateCompleted) { - if (method === "throw") { - throw arg; - } // Be forgiving, per 25.3.3.3.3 of the spec: - // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); + } - return doneResult(); + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; } - context.method = method; - context.arg = arg; - - while (true) { - var delegate = context.delegate; + // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + return doneResult(); + } - if (delegate) { - var delegateResult = maybeInvokeDelegate(delegate, context); + context.method = method; + context.arg = arg; - if (delegateResult) { - if (delegateResult === ContinueSentinel) continue; - return delegateResult; - } + while (true) { + var delegate = context.delegate; + if (delegate) { + var delegateResult = maybeInvokeDelegate(delegate, context); + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; } + } - if (context.method === "next") { - // Setting context._sent for legacy support of Babel's - // function.sent implementation. - context.sent = context._sent = context.arg; - } else if (context.method === "throw") { - if (state === GenStateSuspendedStart) { - state = GenStateCompleted; - throw context.arg; - } + if (context.method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = context.arg; - context.dispatchException(context.arg); - } else if (context.method === "return") { - context.abrupt("return", context.arg); + } else if (context.method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw context.arg; } - state = GenStateExecuting; - var record = tryCatch(innerFn, self, context); + context.dispatchException(context.arg); - if (record.type === "normal") { - // If an exception is thrown from innerFn, we leave state === - // GenStateExecuting and loop back for another invocation. - state = context.done ? GenStateCompleted : GenStateSuspendedYield; + } else if (context.method === "return") { + context.abrupt("return", context.arg); + } - if (record.arg === ContinueSentinel) { - continue; - } + state = GenStateExecuting; - return { - value: record.arg, - done: context.done - }; - } else if (record.type === "throw") { - state = GenStateCompleted; // Dispatch the exception by looping back around to the - // context.dispatchException(context.arg) call above. + var record = tryCatch(innerFn, self, context); + if (record.type === "normal") { + // If an exception is thrown from innerFn, we leave state === + // GenStateExecuting and loop back for another invocation. + state = context.done + ? GenStateCompleted + : GenStateSuspendedYield; - context.method = "throw"; - context.arg = record.arg; - } - } - }; - } // Call delegate.iterator[context.method](context.arg) and handle the - // result, either by returning a { value, done } result from the - // delegate iterator, or by modifying context.method and context.arg, - // setting context.delegate to null, and returning the ContinueSentinel. - - - function maybeInvokeDelegate(delegate, context) { - var method = delegate.iterator[context.method]; - - if (method === undefined) { - // A .throw or .return when the delegate iterator has no .throw - // method always terminates the yield* loop. - context.delegate = null; - - if (context.method === "throw") { - if (delegate.iterator.return) { - // If the delegate iterator has a return method, give it a - // chance to clean up. - context.method = "return"; - context.arg = undefined; - maybeInvokeDelegate(delegate, context); - - if (context.method === "throw") { - // If maybeInvokeDelegate(context) changed context.method from - // "return" to "throw", let that override the TypeError below. - return ContinueSentinel; - } + if (record.arg === ContinueSentinel) { + continue; } + return { + value: record.arg, + done: context.done + }; + + } else if (record.type === "throw") { + state = GenStateCompleted; + // Dispatch the exception by looping back around to the + // context.dispatchException(context.arg) call above. context.method = "throw"; - context.arg = new TypeError("The iterator does not provide a 'throw' method"); + context.arg = record.arg; } - - return ContinueSentinel; } + }; + } - var record = tryCatch(method, delegate.iterator, context.arg); + // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; - if (record.type === "throw") { - context.method = "throw"; - context.arg = record.arg; - context.delegate = null; - return ContinueSentinel; - } + if (context.method === "throw") { + if (delegate.iterator.return) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); - var info = record.arg; + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } + } - if (!info) { context.method = "throw"; - context.arg = new TypeError("iterator result is not an object"); - context.delegate = null; - return ContinueSentinel; + context.arg = new TypeError( + "The iterator does not provide a 'throw' method"); } - if (info.done) { - // Assign the result of the finished delegate to the temporary - // variable specified by delegate.resultName (see delegateYield). - context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield). + return ContinueSentinel; + } - context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the - // exception, let the outer generator proceed normally. If - // context.method was "next", forget context.arg since it has been - // "consumed" by the delegate iterator. If context.method was - // "return", allow the original .return call to continue in the - // outer generator. + var record = tryCatch(method, delegate.iterator, context.arg); - if (context.method !== "return") { - context.method = "next"; - context.arg = undefined; - } - } else { - // Re-yield the result returned by the delegate method. - return info; - } // The delegate iterator is finished, so forget it and continue with - // the outer generator. + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } + var info = record.arg; + if (! info) { + context.method = "throw"; + context.arg = new TypeError("iterator result is not an object"); context.delegate = null; return ContinueSentinel; - } // Define Generator.prototype.{next,throw,return} in terms of the - // unified ._invoke helper method. + } + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; + + // Resume execution at the desired location (see delegateYield). + context.next = delegate.nextLoc; + + // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; + } - defineIteratorMethods(Gp); - Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the - // @@iterator function is called on it. Some browsers' implementations of the - // iterator prototype chain incorrectly implement this, causing the Generator - // object to not be returned from this call. This ensures that doesn't happen. - // See https://github.com/facebook/regenerator/issues/274 for more details. + } else { + // Re-yield the result returned by the delegate method. + return info; + } - Gp[iteratorSymbol] = function () { - return this; - }; + // The delegate iterator is finished, so forget it and continue with + // the outer generator. + context.delegate = null; + return ContinueSentinel; + } - Gp.toString = function () { - return "[object Generator]"; - }; + // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. + defineIteratorMethods(Gp); - function pushTryEntry(locs) { - var entry = { - tryLoc: locs[0] - }; + Gp[toStringTagSymbol] = "Generator"; - if (1 in locs) { - entry.catchLoc = locs[1]; - } + // A Generator should always return itself as the iterator object when the + // @@iterator function is called on it. Some browsers' implementations of the + // iterator prototype chain incorrectly implement this, causing the Generator + // object to not be returned from this call. This ensures that doesn't happen. + // See https://github.com/facebook/regenerator/issues/274 for more details. + Gp[iteratorSymbol] = function() { + return this; + }; - if (2 in locs) { - entry.finallyLoc = locs[2]; - entry.afterLoc = locs[3]; - } + Gp.toString = function() { + return "[object Generator]"; + }; - this.tryEntries.push(entry); - } + function pushTryEntry(locs) { + var entry = { tryLoc: locs[0] }; - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal"; - delete record.arg; - entry.completion = record; + if (1 in locs) { + entry.catchLoc = locs[1]; } - function Context(tryLocsList) { - // The root entry object (effectively a try statement without a catch - // or a finally block) gives us a place to store values thrown from - // locations where there is no enclosing try statement. - this.tryEntries = [{ - tryLoc: "root" - }]; - tryLocsList.forEach(pushTryEntry, this); - this.reset(true); + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; } - runtime.keys = function (object) { - var keys = []; - - for (var key in object) { - keys.push(key); - } - - keys.reverse(); // Rather than returning an object with a next method, we keep - // things simple and return the next function itself. + this.tryEntries.push(entry); + } - return function next() { - while (keys.length) { - var key = keys.pop(); + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; + } - if (key in object) { - next.value = key; - next.done = false; - return next; - } - } // To avoid creating an additional object, we just hang the .value - // and .done properties off the next function object itself. This - // also ensures that the minifier will not anonymize the function. + function Context(tryLocsList) { + // The root entry object (effectively a try statement without a catch + // or a finally block) gives us a place to store values thrown from + // locations where there is no enclosing try statement. + this.tryEntries = [{ tryLoc: "root" }]; + tryLocsList.forEach(pushTryEntry, this); + this.reset(true); + } + runtime.keys = function(object) { + var keys = []; + for (var key in object) { + keys.push(key); + } + keys.reverse(); + + // Rather than returning an object with a next method, we keep + // things simple and return the next function itself. + return function next() { + while (keys.length) { + var key = keys.pop(); + if (key in object) { + next.value = key; + next.done = false; + return next; + } + } - next.done = true; - return next; - }; + // To avoid creating an additional object, we just hang the .value + // and .done properties off the next function object itself. This + // also ensures that the minifier will not anonymize the function. + next.done = true; + return next; }; + }; - function values(iterable) { - if (iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - - if (iteratorMethod) { - return iteratorMethod.call(iterable); - } + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; + if (iteratorMethod) { + return iteratorMethod.call(iterable); + } - if (typeof iterable.next === "function") { - return iterable; - } + if (typeof iterable.next === "function") { + return iterable; + } - if (!isNaN(iterable.length)) { - var i = -1, - next = function next() { - while (++i < iterable.length) { - if (hasOwn.call(iterable, i)) { - next.value = iterable[i]; - next.done = false; - return next; - } + if (!isNaN(iterable.length)) { + var i = -1, next = function next() { + while (++i < iterable.length) { + if (hasOwn.call(iterable, i)) { + next.value = iterable[i]; + next.done = false; + return next; } + } - next.value = undefined; - next.done = true; - return next; - }; - - return next.next = next; - } - } // Return an iterator with no values. - + next.value = undefined; + next.done = true; - return { - next: doneResult - }; - } - - runtime.values = values; + return next; + }; - function doneResult() { - return { - value: undefined, - done: true - }; + return next.next = next; + } } - Context.prototype = { - constructor: Context, - reset: function reset(skipTempReset) { - this.prev = 0; - this.next = 0; // Resetting context._sent for legacy support of Babel's - // function.sent implementation. + // Return an iterator with no values. + return { next: doneResult }; + } + runtime.values = values; - this.sent = this._sent = undefined; - this.done = false; - this.delegate = null; - this.method = "next"; - this.arg = undefined; - this.tryEntries.forEach(resetTryEntry); + function doneResult() { + return { value: undefined, done: true }; + } - if (!skipTempReset) { - for (var name in this) { - // Not sure about the optimal order of these conditions: - if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { - this[name] = undefined; - } + Context.prototype = { + constructor: Context, + + reset: function(skipTempReset) { + this.prev = 0; + this.next = 0; + // Resetting context._sent for legacy support of Babel's + // function.sent implementation. + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; + + this.method = "next"; + this.arg = undefined; + + this.tryEntries.forEach(resetTryEntry); + + if (!skipTempReset) { + for (var name in this) { + // Not sure about the optimal order of these conditions: + if (name.charAt(0) === "t" && + hasOwn.call(this, name) && + !isNaN(+name.slice(1))) { + this[name] = undefined; } } - }, - stop: function stop() { - this.done = true; - var rootEntry = this.tryEntries[0]; - var rootRecord = rootEntry.completion; - - if (rootRecord.type === "throw") { - throw rootRecord.arg; - } + } + }, - return this.rval; - }, - dispatchException: function dispatchException(exception) { - if (this.done) { - throw exception; - } + stop: function() { + this.done = true; - var context = this; + var rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } - function handle(loc, caught) { - record.type = "throw"; - record.arg = exception; - context.next = loc; + return this.rval; + }, - if (caught) { - // If the dispatched exception was caught by a catch block, - // then let that catch block handle the exception normally. - context.method = "next"; - context.arg = undefined; - } + dispatchException: function(exception) { + if (this.done) { + throw exception; + } - return !!caught; + var context = this; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; + + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; } - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - var record = entry.completion; + return !! caught; + } - if (entry.tryLoc === "root") { - // Exception thrown outside of any try block that could handle - // it, so set the completion value of the entire function to - // throw the exception. - return handle("end"); - } + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"); - var hasFinally = hasOwn.call(entry, "finallyLoc"); - - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } else if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - } else if (hasCatch) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } - } else if (hasFinally) { - if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - } else { - throw new Error("try statement without catch or finally"); - } - } - } - }, - abrupt: function abrupt(type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - - if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; - } + if (entry.tryLoc === "root") { + // Exception thrown outside of any try block that could handle + // it, so set the completion value of the entire function to + // throw the exception. + return handle("end"); } - if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { - // Ignore the finally entry if control is not jumping to a - // location outside the try/catch block. - finallyEntry = null; - } + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); - var record = finallyEntry ? finallyEntry.completion : {}; - record.type = type; - record.arg = arg; + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } - if (finallyEntry) { - this.method = "next"; - this.next = finallyEntry.finallyLoc; - return ContinueSentinel; - } + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } - return this.complete(record); - }, - complete: function complete(record, afterLoc) { - if (record.type === "throw") { - throw record.arg; + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } + + } else { + throw new Error("try statement without catch or finally"); + } } + } + }, - if (record.type === "break" || record.type === "continue") { - this.next = record.arg; - } else if (record.type === "return") { - this.rval = this.arg = record.arg; - this.method = "return"; - this.next = "end"; - } else if (record.type === "normal" && afterLoc) { - this.next = afterLoc; + abrupt: function(type, arg) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc <= this.prev && + hasOwn.call(entry, "finallyLoc") && + this.prev < entry.finallyLoc) { + var finallyEntry = entry; + break; } + } - return ContinueSentinel; - }, - finish: function finish(finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; + if (finallyEntry && + (type === "break" || + type === "continue") && + finallyEntry.tryLoc <= arg && + arg <= finallyEntry.finallyLoc) { + // Ignore the finally entry if control is not jumping to a + // location outside the try/catch block. + finallyEntry = null; + } - if (entry.finallyLoc === finallyLoc) { - this.complete(entry.completion, entry.afterLoc); - resetTryEntry(entry); - return ContinueSentinel; - } - } - }, - "catch": function _catch(tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; + + if (finallyEntry) { + this.method = "next"; + this.next = finallyEntry.finallyLoc; + return ContinueSentinel; + } - if (entry.tryLoc === tryLoc) { - var record = entry.completion; + return this.complete(record); + }, - if (record.type === "throw") { - var thrown = record.arg; - resetTryEntry(entry); - } + complete: function(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; + } - return thrown; - } - } // The context.catch method must only be called with a location - // argument that corresponds to a known catch block. + if (record.type === "break" || + record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = this.arg = record.arg; + this.method = "return"; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } + return ContinueSentinel; + }, - throw new Error("illegal catch attempt"); - }, - delegateYield: function delegateYield(iterable, resultName, nextLoc) { - this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }; + finish: function(finallyLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.finallyLoc === finallyLoc) { + this.complete(entry.completion, entry.afterLoc); + resetTryEntry(entry); + return ContinueSentinel; + } + } + }, - if (this.method === "next") { - // Deliberately forget the last sent value so that we don't - // accidentally pass it on to the delegate. - this.arg = undefined; + "catch": function(tryLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc === tryLoc) { + var record = entry.completion; + if (record.type === "throw") { + var thrown = record.arg; + resetTryEntry(entry); + } + return thrown; } + } - return ContinueSentinel; + // The context.catch method must only be called with a location + // argument that corresponds to a known catch block. + throw new Error("illegal catch attempt"); + }, + + delegateYield: function(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; + + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; } - }; - }( // In sloppy mode, unbound `this` refers to the global object, fallback to + + return ContinueSentinel; + } + }; + })( + // In sloppy mode, unbound `this` refers to the global object, fallback to // Function constructor if we're in global strict mode. That is sadly a form // of indirect eval which violates Content Security Policy. - function () { - return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self; - }() || Function("return this")()); + (function() { + return this || (typeof self === "object" && self); + })() || Function("return this")() + ); }); var QueryBuilder =