/*! For license information please see dll.SpreadsheetUpload.js.LICENSE.txt */
(window.webpackJsonp_name_hash_=window.webpackJsonp_name_hash_||[]).push([[106],{1062:function(e,t,n){"use strict";n.r(t);var a=n(13),r=n.n(a),o=n(12),l=n.n(o),i=n(7),s=n.n(i),d=n(14),u=n.n(d),c=n(15),p=n.n(c),f=n(8),h=n.n(f),g=n(5),m=n.n(g),v=n(0),y=n.n(v),w=n(1),C=n.n(w),E=n(25),D=n(1201),F=n(3741),x=n.n(F),R=n(3743),U=n.n(R),b=n(481),S=n.n(b),T=n(85),V=n.n(T),_=n(480),P=n.n(_),k=n(19),A=n(279);function L(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,a=h()(e);if(t){var r=h()(this).constructor;n=Reflect.construct(a,arguments,r)}else n=a.apply(this,arguments);return p()(this,n)}}var N=/\r(?!\n)/g,H=function(e){u()(n,e);var t=L(n);function n(e){var a;return r()(this,n),a=t.call(this,e),m()(s()(a),"handleFileUpload",(function(){a.setState({uploading:!0},(function(){var e=new FileReader,t=a.fileUpload.files[0];e.addEventListener("load",a.onFileRead,!1),e.addEventListener("progress",(function(e){if(e.lengthComputable){var t=e.loaded/e.total;a.setState({percentCompleted:t})}}),!1),e.readAsText(t,"utf-8")}))})),m()(s()(a),"onFileRead",(function(e){var t,n,r=e.target.result,o=U()(r);t=V()(o)?",":o.delimiter;var l=(r=S()(r,N,"\n")).indexOf("\n"),i=r.substring(0,l).split(t);a.state.header?(n=i,r=r.substring(l+1)):n=i.map((function(e,t){return"VAR_"+(t+1)})),a.setState({percentCompleted:0,uploading:!1}),x()(r,{delimiter:t,columns:n,cast:!0},(function(e,t){if(e)return a.context.addNotification({title:"Could not read file.",message:"The following error was encountered while trying to read the file:".concat(e.message),level:"error",position:"tr"}),a.props.onUpload(e);a.props.onUpload(null,t)}))})),m()(s()(a),"ignoreDrag",(function(e){e.stopPropagation(),e.preventDefault()})),m()(s()(a),"onFileDrop",(function(e){e.stopPropagation(),e.preventDefault();var t=e.dataTransfer,n=new FileReader,r=null;if(t.items?"file"===t.items[0].kind&&(r=t.items[0].getAsFile()):r=t.files[0],r){if("text/csv"!==r.type)return a.context.addNotification({title:"No CSV file.",message:"The supplied file is not a CSV file.",level:"error",position:"tr"});n.addEventListener("load",a.onFileRead,!1),n.readAsText(r,"utf-8")}})),a.state={percentCompleted:0,uploading:!1,header:!0},a}return l()(n,[{key:"render",value:function(){var e=this,t=P()(100*this.state.percentCompleted);return y.a.createElement(E.default,null,y.a.createElement(E.default.Header,{as:"h2"},this.props.title),y.a.createElement(E.default.Body,null,y.a.createElement("label",{htmlFor:"CSVUpload"},"Please upload a data set (CSV format):"),y.a.createElement("input",{id:"CSVUpload",type:"file",accept:".csv",onChange:this.handleFileUpload,ref:function(t){e.fileUpload=t},style:{margin:"auto"}}),y.a.createElement("p",null,"or"),y.a.createElement("div",{onDrop:this.onFileDrop,onDragOver:this.ignoreDrag,onDragEnd:this.ignoreDrag,style:{minHeight:"150px",width:"250px",border:"1px solid blue",padding:"10px"}},y.a.createElement("span",null,"Drop file here")),y.a.createElement(A.default,{legend:"First row contains variable names",defaultValue:!0,onChange:function(t){e.setState({header:t})}}),this.state.uploading?y.a.createElement(D.default,{now:t,label:"".concat(t,"%")}):null))}}]),n}(v.Component);H.defaultProps={onUpload:function(){},title:"File Upload"},H.propTypes={onUpload:C.a.func,title:C.a.string},H.contextType=k.default,t.default=H},1858:function(e,t){},1859:function(e,t){}}]);