/*
* 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
*/

/* WEBPACK VAR INJECTION */

/* eslint-disable jsx-a11y/no-static-element-interactions */

/* eslint-disable max-lines */

/* harmony default export */

/* harmony import */

/* import() */

/*#__PURE__*/

/**
* A drawing sketchpad for note taking on lecture slides or empty pages.
*
* @property {boolean} autoSave - controls whether the editor should save the current text to the local storage of the browser at a given time interval
* @property {boolean} feedbackButtons - controls whether to display feedback buttons on each slide
* @property {number} intervalTime - time between auto saves
* @property {boolean} hideInputButtons - controls whether to hide drawing and text input buttons
* @property {boolean} hideNavigationButtons - controls whether to hide buttons for navigating between pages
* @property {boolean} hideSaveButtons - controls whether to hide the save buttons
* @property {boolean} hideTransmitButtons - controls whether to hide buttons for transmitting user actions
* @property {number} brushSize - size of the brush to paint with
* @property {string} color - color of the brush and texts
* @property {number} canvasWidth - width of the canvas element (in px)
* @property {number} canvasHeight - height of the canvas element (in px)
* @property {boolean} dynamicallyHideButtons - controls whether to start hiding buttons when toolbar width is not sufficient (otherwise a new line will be started)
* @property {boolean} fullscreen - controls whether to automatically resize the canvas to the width and height of the browser window
* @property {string} fill - if `horizontal`, fill all available horizontal space when drawing a PDF; if `vertical`, all vertical space is used to prevent y-axis overflow
* @property {boolean} disabled - whether to make the component read-only and forbid drawing on the sketchpad
* @property {string} fontFamily - font family
* @property {number} fontSize - font size
* @property {Object} nodes - components to be rendered on top of specified slides; `keys` should correspond to page numbers, `values` to the components
* @property {number} noPages - initial number of pages
* @property {string} pdf - Link to PDF file for baked-in page backgrounds
* @property {boolean} showTutorial - show a tutorial for the sketchpad
* @property {boolean} transmitOwner - whether owner actions should be transmitted to other users in real-time
* @property {boolean} groupMode - controls whether all user's actions are transmitted to everyone else
* @property {strings} voiceID - voice control identifier
* @property {Object} style - CSS inline styles
* @property {Function} onChange - callback invoked whenever a new line element is drawn
*/

/**
* Converts a base-64 encoded string to a blob.
*
* @param {string} b64Data - base-64 encoded string
* @param {string} [contentType=''] - content type
* @param {integer} [sliceSize=512] - slice size
* @returns {Blob} created blob
*/

/**
* Draws a cardinal spline through given point array. Points must be arranged
* as: [x1, y1, x2, y2, ..., xn, yn]. It adds the points to the current path.
*
* There must be a minimum of two points in the input array but the function
* is only useful where there are three points or more.
*
* The method continues previous path of the context. If you don't want that
* then you need to use moveTo() with the first point from the input array.
*
* The points for the cardinal spline are returned as a new array.
*
* @param {CanvasRenderingContext2D} ctx - context to use
* @param {Array} points - point array
* @param {integer} width - canvas width
* @param {integer} height - canvas height
* @param {number} [tension=0.9] - tension. Typically between [0.0, 1.0] but can be exceeded
* @param {number} [numOfSeg=30] - number of segments between two points (line resolution)
* @param {boolean} [close=false] - Close the ends making the line continuous
* @returns {Float32Array} New array with the calculated points that was added to the path
*/

/**
* Generates a random string with the specified length.
*
* @param {integer} [len=32] - length of string
* @param {integer} [lower=48] - lower ASCII char point
* @param {integer} [upper=126] - upper ASCII char point
* @returns {string} random string with `len` characters
*/

/***/

// 0,1,0,0

// 1,0,0,0

// Add last point:

// Add lines to path:

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

// Canvas to temporarily store data:

// Case: Harmonization not already done on server for anonymous users

// Deselect elements when clicked outside selection path:

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

// EXPORTS //

// Exports

// FUNCTIONS //

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

// Height of sub-rectangle of source image in the destination context

// IE 10+ (native saveAs)

// Insert empty pages at the correct locations:

// MAIN //

// MODULES //

// Module

// Mouse is not clicked anymore...

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

// Only remove all elements from the sending user on the page:

// Own action, clear page:

// Owners should only process actions from selected users:

// 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

// Prevent future logging when redrawing element:

// Prevent scrolling when touching the canvas on iOS in fullscreen mode:

// Render PDF page into canvas context

// Reset background data for inserted slides:

// Restore image before line and redraw smoothed version:

// Return position inside of the canvas element:

// Return promise that immediately resolves as no background needs to be drawn:

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

// Scale all drawing operations by the DPR when no background is present:

// Scale all drawing operations by the DPR:

// Scale the magnifying glass:

// Set to current coordinates:

// Set white background if none present:

// Start rendering pages one by one:

// Update hash of URL:

// Use a minimum line width to make selecting easier:

// Use first touch if available:

// VARIABLES //

// Width of image in destination canvas

// account for vertical scrollbar

// c1

// c2

// c3

// cache inner-loop calculations as they are based on t alone

// calc. points

// copy 1. point and insert at beginning

// eslint-disable-next-line max-depth

// file is a File

// file is an object URL

// for cloning point array

// in ms

// insert end point as first point

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

// options or defaults

// peek at first page and assume it's consistent over all pages

// release reference before dispatching

// second last and last

// y-axis coordinate in destination canvas at which to place top-left corner of source image
