/*
* Adapted from MIT-licensed code.
*
* Copyright (c) 2014. Athan Reines.
*
* @source https://github.com/compute-io/max
*/

/*
* Adapted from MIT-licensed code.
*
* Copyright (c) 2014. Athan Reines.
*
* @source https://github.com/compute-io/min
*/

/*
* Adapted from:
*
* FileSaver.js
* A saveAs() FileSaver implementation.
* 1.3.8
* 2018-03-22 14:03:47
*
* By Eli Grey, https://eligrey.com
* License: MIT
*   See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
*
* @source http://purl.eligrey.com/github/FileSaver.js/blob/master/src/FileSaver.js
*/

/*
* Dragging behavior adapted from code by:
*
* Copyright (c) 2019 by Matt Lockyer (https://codepen.io/mattlockyer/pen/LydeLj)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/* (ignored) */

/* WEBPACK VAR INJECTION */

/* eslint-disable react/no-unused-prop-types */

/* eslint-disable-next-line react/no-danger */

/* harmony default export */

/* harmony import */

/*#__PURE__*/

/**
* A component rendering data in a tabular display. Built on top of [react-table](https://react-table.js.org/).
*
* @property {(Object|Array)} data - A data object or array to be viewed. If it is an object, the keys correspond to column values while an array will expect an array of objects with a named field corresponding to each column
* @property {Object} dataInfo - object with `info` string array describing the data set, the `name` of the dataset, an `object` of `variables` with keys corresponding to variable names and values to variable descriptions, an a `showOnStartup` boolean controlling whether to display the info modal on startup
* @property {Array} editable - array of names for columns that shall be editable
* @property {boolean} deletable - controls whether columns for which no `info` exist have a button which when clicked calls the `onColumnDelete` callback function
* @property {Array<string>} undeletableVars - array of variable names of columns which may not be deleted
* @property {boolean} filterable - controls whether columns are filterable
* @property {boolean} showRemove - indicates whether to display checkboxes for rows to be removed
* @property {boolean} showIdColumn - controls whether to show an ID column
* @property {Object} style - An object allowing for custom css styling. Defaults to an empty object
* @property {Function} getTrProps - callback function executed for each row to customize its styling (passed table state, row info,
column, and the table instance)
* @property {Function} onClickRemove - A function specifying an action to take for rows removed from the data (defaults to an empty function)
* @property {Function} onColumnDelete - function invoked with the name of a column when the respective delete button for a column is clicked
* @property {Function} onEdit - function invoked with the updated data set after the value of a cell was changed by the user (only applies when table is `editable`)
* @property {Function} onTutorialCompletion - function invoked when user has completed the data table tutorial
*/

/**
* Computes the maximum value of a numeric array.
*
* @param {Array} arr - array of values
* @returns {number} max value
*/

/**
* Computes the minimum value of an array.
*
* @param {Array} arr - array of values
* @returns {number} min value
*/

/***/

// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html

// Attach `id` column:

// Case: `data` is already an array of observations

// Case: `data` is an object with keys for the various variables

// Cast values to strings for select component to work and sort:

// Do not attach `id` column:

// Don't create more object URLs than needed:

// EXPORTS //

// Exports

// FUNCTIONS //

// First try a download, then web filesystem, then object URLs:

// IE 10+ (native saveAs)

// MAIN //

// MODULES //

// Module

// On any filesystem errors, revert to saving with object URLs:

// PROPERTIES //

// Prepend BOM for UTF-8 XML and text/* types (including HTML). Note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF

// Run re-order events:

// Safari doesn't allow downloading of blob URLs:

// See: https://github.com/JedWatson/react-select/issues/3117

// Update draggable attribute to handle Firefox bug (https://stackoverflow.com/questions/21680363/prevent-drag-event-to-interfere-with-input-elements-in-firefox-using-html5-drag)

// VARIABLES //

// eslint-disable-line react/no-danger

// file is a File

// file is an object URL

// in ms

// only get URL when necessary in case Blob.js hasn't overridden it yet

// release reference before dispatching
