2 lines
34 KiB
JavaScript
2 lines
34 KiB
JavaScript
(this["webpackJsonppicturestory-v2-client"]=this["webpackJsonppicturestory-v2-client"]||[]).push([[8],{149:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),o=n(3),i=n.n(o),c=n(24),l=n(48),s=n(7),u=n(52),p=n(25),m=function(e){var t=e.tab;return r.a.createElement("li",{className:"".concat(t.activeClass?"active":""," c-SideBarTab")},r.a.createElement(p.b,{to:t.href},r.a.createElement("i",{className:"fas ".concat(t.tabImage)}),r.a.createElement("span",{className:"hideable hide"},t.tabText)),t.subList&&r.a.createElement("ul",{className:"collapse list-unstyled",id:"pageSubmenu"},r.a.createElement("li",null,r.a.createElement(p.b,{to:"#"},"Repo")),r.a.createElement("li",null,r.a.createElement(p.b,{to:"#"},"Issues")),r.a.createElement("li",null,r.a.createElement(p.b,{to:"#"},"Admin"))))};m.propTypes={tab:i.a.object};var f=m,d=n(58),h=n.n(d),b=function(e){Object(a.useEffect)((function(){h()("#sidebar.active > span").on("click",(function(){h()("#sidebar").css("transform","translateX(85px)"),h()("#sidebar").css("box-shadow","rgb(224, 151, 32) 10px 10px 30px"),h()(".triangle").removeClass("animation")})),h()("*").on("click",(function(e){0===h()(e.target).closest("#sidebar").length&&(h()("#sidebar").css("transform","translateX(0px)"),h()("#sidebar").css("box-shadow",""),h()(".triangle").addClass("animation"))}))}));var t=[{href:"homeSubmenu",tabImage:"fa-home",tabText:"Home",activeClass:!0,subList:!1},{href:"about",tabImage:"fa-briefcase",tabText:"About",activeClass:!1,subList:!1},{href:"pageSubmenu",tabImage:"fa-copy",tabText:"Tasks",activeClass:!1,subList:!0},{href:"favorites",tabImage:"fa-image",tabText:"Favorites",activeClass:!1,subList:!1},{href:"question",tabImage:"fa-question",tabText:"FAQ",activeClass:!1,subList:!1},{href:"contact",tabImage:"fa-paper-plane",tabText:"Contact",activeClass:!1,subList:!1}],n=t&&t.map((function(e,t){return r.a.createElement(f,{tab:e,key:t})}));return r.a.createElement("nav",{id:"sidebar",className:"c-SideBar active"},r.a.createElement("span",{className:"triangle animation",id:"pullOutButton"}),r.a.createElement("div",{className:"sidebar-header"},r.a.createElement("button",{type:"button",id:"sidebarCollapse",className:"btn btn-info",onClick:function(){var e=+h()("#sidebar").css("transform").split(/[()]/)[1].split(",")[4];e&&255===e?h()("#sidebar").css("transform","translateX(85px)"):e&&85===e&&h()("#sidebar").css("transform","translateX(255px)"),h()("#sidebar").toggleClass("active"),h()(".hideable").toggleClass("hide"),h()(".triangle").addClass("animation")}},r.a.createElement("i",{className:"fas fa-align-justify"})),r.a.createElement("h3",{className:"logotext"},"Ecstatica")),r.a.createElement("ul",{className:"list-unstyled components"},n))};b.propTypes={tabsData:i.a.array};var y=b;function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],a=!0,r=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(a=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(l){r=!0,o=l}finally{try{a||null==c.return||c.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var v=function(e){var t=e.toolData,n=g(Object(a.useState)(t.icon),2),o=n[0],i=n[1],c=function(e,t){var n=h()(e.target).find("i").addBack("i");(n&&n[0]&&n[0].innerHTML)===t.icon?i(t.iconHovered):i(t.icon)};return r.a.createElement("li",{id:t.id,className:"nav-item",onClick:t.clickHandler},r.a.createElement(p.b,{to:"#",className:"nav-link"},r.a.createElement("i",{className:"material-icons md-light md-36",onMouseEnter:function(e){return c(e,t)},onMouseLeave:function(e){return c(e,t)}},o)))};v.propTypes={toolData:i.a.object};var E=v,w=n(133),O=n(154),S=n(155),C=n(137),j=n(138),k=n(101),x=n.n(k),N=n(98),T=n.n(N),_=n(100),P=n.n(_),D=n(102),A=n.n(D);function F(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],a=!0,r=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(a=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(l){r=!0,o=l}finally{try{a||null==c.return||c.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var M=Object(w.a)((function(e){return{grow:{flexGrow:1},menuButton:{marginRight:e.spacing(2)},sectionDesktop:I({display:"none",float:"right"},e.breakpoints.up("md"),{display:"flex"}),sectionMobile:I({display:"flex"},e.breakpoints.up("md"),{display:"none"})}})),U={uploaderModalStateDispatcher:function(e){return Object(s.o)(e)}},R=Object(c.b)(null,U)((function(e){var t=M(),n=F(r.a.useState(null),2),a=n[0],o=n[1],i=F(r.a.useState(null),2),c=i[0],l=i[1],s=Boolean(a),u=Boolean(c),p=function(e){o(e.currentTarget)},m=function(){l(null)},f=function(e,t){o(null),m(),"Upload Image/s"===e.currentTarget.innerText&&t(!0)},d="primary-search-account-menu",h=r.a.createElement(O.a,{anchorEl:a,anchorOrigin:{vertical:"top",horizontal:"right"},id:d,keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:s,onClose:f},r.a.createElement(S.a,{onClick:f},"Profile"),r.a.createElement(S.a,{onClick:f},"My account"),r.a.createElement(S.a,{onClick:function(t){return f(t,e.uploaderModalStateDispatcher)}},"Upload Image/s")),b=r.a.createElement(O.a,{anchorEl:c,anchorOrigin:{vertical:"top",horizontal:"right"},id:"primary-search-account-menu-mobile",keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:u,onClose:m},r.a.createElement(S.a,null,r.a.createElement(C.a,{"aria-label":"show 4 new mails",color:"inherit"},r.a.createElement(j.a,{badgeContent:4,color:"secondary"},r.a.createElement(T.a,null))),r.a.createElement("p",null,"Messages")),r.a.createElement(S.a,null,r.a.createElement(C.a,{"aria-label":"show 11 new notifications",color:"inherit"},r.a.createElement(j.a,{badgeContent:11,color:"secondary"},r.a.createElement(P.a,null))),r.a.createElement("p",null,"Notifications")),r.a.createElement(S.a,{onClick:p},r.a.createElement(C.a,{"aria-label":"account of current user","aria-controls":"primary-search-account-menu","aria-haspopup":"true",color:"inherit"},r.a.createElement(x.a,null)),r.a.createElement("p",null,"Profile")));return r.a.createElement("div",{className:t.grow},r.a.createElement("div",{className:t.sectionDesktop},r.a.createElement(C.a,{"aria-label":"show 4 new mails",color:"inherit"},r.a.createElement(j.a,{badgeContent:4,color:"secondary"},r.a.createElement(T.a,{style:{width:"1.5em",height:"1.5em",top:"-5px",position:"relative",right:"-2px"}}))),r.a.createElement(C.a,{"aria-label":"show 17 new notifications",color:"inherit"},r.a.createElement(j.a,{badgeContent:17,color:"secondary"},r.a.createElement(P.a,{style:{width:"1.5em",height:"1.5em",top:"-5px",position:"relative",right:"-2px"}}))),r.a.createElement(C.a,{edge:"end","aria-label":"account of current user","aria-controls":d,"aria-haspopup":"true",onClick:p,color:"inherit"},r.a.createElement(x.a,{style:{width:"1.5em",height:"1.5em",top:"-5px",position:"relative",right:"-2px"}}))),r.a.createElement("div",{className:t.sectionMobile},r.a.createElement(C.a,{"aria-label":"show more","aria-controls":"primary-search-account-menu-mobile","aria-haspopup":"true",onClick:function(e){l(e.currentTarget)},color:"inherit"},r.a.createElement(A.a,null))),b,h)}));function H(e){return(H="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function V(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function B(e){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function L(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var G=function(e){function t(e){var n,a,r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a=this,(n=!(r=B(t).call(this,e))||"object"!==H(r)&&"function"!==typeof r?L(a):r).registerSpeechHandlers=n.registerSpeechHandlers.bind(L(n)),n.startSpeechRecognition=n.startSpeechRecognition.bind(L(n)),n.state={commandToolItemsData:[{id:"btnFavorites",icon:"star_border",iconHovered:"star",clickHandler:n.props.save},{id:"btnClearCommand",icon:"delete_outline",iconHovered:"delete",clickHandler:n.props.reset},{id:"btnFireCommand",icon:"send",iconHovered:"send",clickHandler:n.props.execute},{id:"btnSTTCommand",icon:"mic_none",iconHovered:"mic",clickHandler:n.startSpeechRecognition}]},n}var n,a,o;return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&z(e,t)}(t,e),n=t,(a=[{key:"componentDidMount",value:function(){this.registerSpeechHandlers()}},{key:"startSpeechRecognition",value:function(){/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)&&this.recognition.start()}},{key:"registerSpeechHandlers",value:function(){var e,t=h()("#command");try{e=window.SpeechRecognition||window.mozSpeechRecognition||window.msSpeechRecognition||window.webkitSpeechRecognition,this.recognition=new e}catch(n){console.error(n),h()(".no-browser-support").show(),h()(".app").hide()}this.recognition.onstart=function(){t.val("Voice recognition activated. Try speaking into the microphone.")},this.recognition.onspeechend=function(){t.val("You were quiet for a while so voice recognition turned itself off.")},this.recognition.onerror=function(e){"no-speech"===e.error&&t.val("No speech was detected. Try again.")},this.recognition.onresult=function(e){var t="",n=e.resultIndex,a=e.results[n][0].transcript;1===n&&a===e.results[0][0].transcript||(t+=a,h()("#command").val(t))}}},{key:"render",value:function(){var e=this.state.commandToolItemsData,t=e&&e.map((function(e,t){return r.a.createElement(E,{toolData:e,key:t})}));return r.a.createElement("div",{className:"collapse navbar-collapse c-CommandAndUserTools",id:"navbarSupportedContent"},r.a.createElement("ul",{className:"nav navbar-nav ml-auto c-commandTools"},t),r.a.createElement(R,null))}}])&&V(n.prototype,a),o&&V(n,o),t}(r.a.Component);G.propTypes={execute:i.a.func,reset:i.a.func,save:i.a.func};var q=G;var K=function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.message=t,this.isUser=n,this.timeStamp=Date.now()};function X(e){return(X="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function W(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function J(e){return(J=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var $=function(e){function t(e){var n,a,r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a=this,(n=!(r=J(t).call(this,e))||"object"!==X(r)&&"function"!==typeof r?Y(a):r).state={chatView:!1},n.registerMouseAndKeyboardHandlers=n.registerMouseAndKeyboardHandlers.bind(Y(n)),n.showContextMenu=n.showContextMenu.bind(Y(n)),n.initiateDomOpsOnEnter=n.initiateDomOpsOnEnter.bind(Y(n)),n.toggleChatView=n.toggleChatView.bind(Y(n)),n.executeCommand=n.executeCommand.bind(Y(n)),n.timerId=0,n}var n,a,o;return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(t,e),n=t,(a=[{key:"componentDidMount",value:function(){this.registerMouseAndKeyboardHandlers()}},{key:"initiateDomOpsOnEnter",value:function(e,t,n){if(13===(e.keyCode?e.keyCode:e.which))return t(),void clearTimeout(this.timerId);clearTimeout(this.timerId),this.timerId=setTimeout(t,n)}},{key:"saveToFavorites",value:function(){}},{key:"resetCommand",value:function(){h()("#command").val(""),h()("#command").focus()}},{key:"registerMouseAndKeyboardHandlers",value:function(){var e=this;h()("*").on("click",(function(t){e.contextMenuFirstDisplay?e.contextMenuFirstDisplay=!1:(h()("#inputSelectionContextMenu").removeClass("show").hide(),e.contextMenuDisplayed=!1)}))}},{key:"showContextMenu",value:function(e){if(!0!==this.contextMenuDisplayed){var t=e.target;if(t.value.length>2&&0===t.selectionStart&&t.selectionEnd===t.value.length){var n=e.pageY-10,a=e.pageX-90;h()("#inputSelectionContextMenu").css({display:"block",top:n,left:a}).addClass("show"),this.contextMenuFirstDisplay=!0,this.contextMenuDisplayed=!0}}}},{key:"executeCommand",value:function(){var e=h()("#command");e.toggleClass("loading");var t=e.val(),n=new K(t,!0);this.props.dispatchMessage(n)}},{key:"toggleChatView",value:function(){this.setState({chatView:!this.state.chatView}),this.props.dispatchShowChatView(!this.state.chatView)}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{id:"header",className:"c-CommandPrompt headerprompt",onDragEnd:this.showContextMenu},r.a.createElement("div",{className:"prompt"},r.a.createElement("p",{className:"promptext"},"$_"),r.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"equalizer hide",viewBox:"0 0 80 80"},r.a.createElement("rect",{className:"bar",transform:"translate(13,30)"}),r.a.createElement("rect",{className:"bar",transform:"translate(25,30)"}),r.a.createElement("rect",{className:"bar",transform:"translate(37,30)"}),r.a.createElement("rect",{className:"bar",transform:"translate(49,30)"}),r.a.createElement("rect",{className:"bar",transform:"translate(61,30)"}))),r.a.createElement("nav",{className:"navbar navbar-expand-lg navbar-light"},r.a.createElement("div",{className:"container-fluid"},r.a.createElement("div",{className:"c-iFieldContainer"},r.a.createElement("input",{type:"text",className:"form-control",placeholder:"What you need...",name:"command",id:"command",onKeyUp:function(t){return e.initiateDomOpsOnEnter(t,e.executeCommand,2e3)},onClick:this.showContextMenu}),r.a.createElement("button",{className:"btn btn-primary",onClick:this.toggleChatView},this.state.chatView?"Hide Chat":"Show Chat")),r.a.createElement("div",{className:"dropdown-menu","aria-labelledby":"dropdownMenuButton",id:"inputSelectionContextMenu"},r.a.createElement(p.b,{to:"#",className:"dropdown-item",onClick:this.executeCommand},"Fire"),r.a.createElement(p.b,{to:"#",className:"dropdown-item",onClick:this.resetCommand},"Clear"),r.a.createElement(p.b,{to:"#",className:"dropdown-item",onClick:this.saveToFavorites},"Add to Favorites")),r.a.createElement(q,{execute:this.executeCommand,reset:this.resetCommand,save:this.saveToFavorites}))),r.a.createElement("input",{type:"hidden",id:"intentHidden",value:"createissue"}))}}])&&W(n.prototype,a),o&&W(n,o),t}(r.a.Component);$.props={dispatchMessage:i.a.func,dispatchShowChatView:i.a.func};var Z={dispatchMessage:function(e){return Object(s.m)(e)},dispatchShowChatView:function(e){return Object(s.k)(e)}},ee=Object(c.b)(null,Z)($),te=n(72),ne=n(153),ae=n(157),re=n(147),oe=n(136),ie=Object(w.a)((function(e){return{modal:{display:"flex",alignItems:"center",justifyContent:"center"},paper:{backgroundColor:e.palette.background.paper,border:"2px solid #000",boxShadow:e.shadows[5],padding:e.spacing(2,4,3),width:"85%",height:"85%"},polygon:{fill:e.palette.common.white,stroke:e.palette.divider,strokeWidth:1}}})),ce=function(e){var t=ie();return r.a.createElement("div",{className:"c-ImageViewer"},r.a.createElement(ne.a,{"aria-labelledby":"transition-modal-title","aria-describedby":"transition-modal-description",className:t.modal,open:e.modalState||!1,onClose:function(){return e.handleCloseDispatcher(!1)},closeAfterTransition:!0,BackdropComponent:ae.a,BackdropProps:{timeout:500}},r.a.createElement(re.a,{in:e.modalState||!1},r.a.createElement(oe.a,{elevation:4,className:t.paper}))))};ce.propTypes={handleCloseDispatcher:i.a.func,modalState:i.a.bool,selectedImage:i.a.string};var le=Object(l.createPropsSelector)({modalState:u.d,selectedImage:u.a}),se={handleCloseDispatcher:s.n},ue=Object(c.b)(le,se)(ce),pe=function(e){return r.a.createElement("div",{className:"c-PrincipalContent"},r.a.createElement(te.a,null),r.a.createElement(ue,null))},me=n(46);function fe(e){return(fe="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function de(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function he(e){return(he=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function be(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ye(e,t){return(ye=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var ge=function(e){function t(e){var n,a,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a=this,(n=!(o=he(t).call(this,e))||"object"!==fe(o)&&"function"!==typeof o?be(a):o).state={hightlight:!1},n.fileInputRef=r.a.createRef(),n.openFileDialog=n.openFileDialog.bind(be(n)),n.onFilesAdded=n.onFilesAdded.bind(be(n)),n.onDragOver=n.onDragOver.bind(be(n)),n.onDragLeave=n.onDragLeave.bind(be(n)),n.onDrop=n.onDrop.bind(be(n)),n}var n,a,o;return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ye(e,t)}(t,e),n=t,(a=[{key:"openFileDialog",value:function(){this.props.disabled||this.fileInputRef.current.click()}},{key:"onFilesAdded",value:function(e){if(!this.props.disabled){var t=e.target.files;if(this.props.onFilesAdded){var n=this.fileListToArray(t);this.props.onFilesAdded(n)}}}},{key:"fileListToArray",value:function(e){for(var t=[],n=0;n<e.length;n++)t.push(e.item(n));return t}},{key:"onDragOver",value:function(e){e.preventDefault(),this.props.disabled||this.setState({hightlight:!0})}},{key:"onDragLeave",value:function(){this.setState({hightlight:!1})}},{key:"onDrop",value:function(e){if(e.preventDefault(),!this.props.disabled){var t=e.dataTransfer.files;if(this.props.onFilesAdded){var n=this.fileListToArray(t);this.props.onFilesAdded(n)}this.setState({hightlight:!1})}}},{key:"render",value:function(){return r.a.createElement("div",{className:"c-Dropzone ".concat(this.state.hightlight?"Highlight":""),onClick:this.openFileDialog,onDragOver:this.onDragOver,onDragLeave:this.onDragLeave,onDrop:this.onDrop,style:{cursor:this.props.disabled?"default":"pointer"}},r.a.createElement("img",{alt:"upload",className:"Icon",src:"/images/cloud.jpg"}),r.a.createElement("input",{ref:this.fileInputRef,className:"FileInput",type:"file",multiple:!0,onChange:this.onFilesAdded}),r.a.createElement("span",null,"Upload Files"))}}])&&de(n.prototype,a),o&&de(n,o),t}(r.a.Component);ge.propTypes={onFilesAdded:i.a.func};var ve=ge;function Ee(e){return(Ee="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function we(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Oe(e,t){return!t||"object"!==Ee(t)&&"function"!==typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Se(e){return(Se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Ce(e,t){return(Ce=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var je=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=Oe(this,Se(t).call(this,e))).state={},n}var n,a,o;return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ce(e,t)}(t,e),n=t,(a=[{key:"render",value:function(){return r.a.createElement("div",{className:"c-Progress"},r.a.createElement("div",{className:"Progress",style:{width:this.props.progress+"%"}}))}}])&&we(n.prototype,a),o&&we(n,o),t}(a.Component);function ke(e){return(ke="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function xe(e,t,n,a,r,o,i){try{var c=e[o](i),l=c.value}catch(s){return void n(s)}c.done?t(l):Promise.resolve(l).then(a,r)}function Ne(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function Te(e){return(Te=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _e(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Pe(e,t){return(Pe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var De=function(e){function t(e){var n,a,r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a=this,(n=!(r=Te(t).call(this,e))||"object"!==ke(r)&&"function"!==typeof r?_e(a):r).state={files:[],imageURI:[],uploading:!1,uploadProgress:{},successfullUploaded:!1},n.onFilesAdded=n.onFilesAdded.bind(_e(n)),n.upload=n.upload.bind(_e(n)),n.sendRequest=n.sendRequest.bind(_e(n)),n.renderActions=n.renderActions.bind(_e(n)),n.renderProgress=n.renderProgress.bind(_e(n)),n.compressAndUploadFiles=n.compressAndUploadFiles.bind(_e(n)),n.compress=n.compress.bind(_e(n)),n}var n,a,o;return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Pe(e,t)}(t,e),n=t,(a=[{key:"onFilesAdded",value:function(e){this.setState((function(t){return{files:t.files.concat(e)}}))}},{key:"renderProgress",value:function(e){var t=this.state.uploadProgress[e.name];if(this.state.uploading||this.state.successfullUploaded)return r.a.createElement("div",{className:"ProgressWrapper"},r.a.createElement(je,{progress:t?t.percentage:0}),r.a.createElement("img",{className:"CheckIcon",alt:"done",src:"/images/cloud.jpg",style:{opacity:t&&"done"===t.state?.5:0}}))}},{key:"renderActions",value:function(){var e=this;return this.state.successfullUploaded?r.a.createElement("button",{onClick:function(){return e.setState({files:[],successfullUploaded:!1})}},"Clear"):r.a.createElement("button",{disabled:this.state.files.length<0||this.state.uploading,onClick:function(){return e.compressAndUploadFiles(e.uploadFile)}},"Upload")}},{key:"compressAndUploadFiles",value:function(){var e=this;this.state.files.forEach((function(t){e.compress(t).then((function(t){e.setState({uploadProgress:{},uploading:!0}),e.upload(t)}))}))}},{key:"compress",value:function(e){return new Promise((function(t,n){var a=e.name,r=new FileReader,o=[];r.onload=function(n){var r=new Image;r.src=n.target.result,r.onload=function(){o.push(e);var n=document.createElement("canvas");n.width=500,n.height=300;var i=n.getContext("2d");i.drawImage(r,0,0,500,300),i.canvas.toBlob((function(e){o.push(new File([e],"".concat(a.split(".")[0],"_compressed_60.").concat(a.split(".")[1]),{type:"image/jpeg",lastModified:Date.now()})),i.canvas.toBlob((function(e){o.push(new File([e],"".concat(a.split(".")[0],"_compressed_20.").concat(a.split(".")[1]),{type:"image/jpeg",lastModified:Date.now()})),t(o)}),"image/jpeg",.2)}),"image/jpeg",.6)}},r.onerror=function(e){return console.log(e)},r.readAsDataURL(e)}))}},{key:"upload",value:function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({uploadProgress:{},uploading:!0}),(n=[]).push(this.sendRequest(t)),e.prev=3,e.next=6,Promise.all(n).then((function(e){return console.log("result === "+e)})).catch((function(e){return console.log("error === "+e)}));case 6:this.setState({successfullUploaded:!0,uploading:!1}),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(3),this.setState({successfullUploaded:!0,uploading:!1});case 12:case"end":return e.stop()}}),e,this,[[3,9]])})),function(){var t=this,n=arguments;return new Promise((function(a,r){var o=e.apply(t,n);function i(e){xe(o,a,r,i,c,"next",e)}function c(e){xe(o,a,r,i,c,"throw",e)}i(void 0)}))});return function(e){return t.apply(this,arguments)}}()},{key:"sendRequest",value:function(e){return new Promise((function(t,n){var a=new FormData;e.forEach((function(e){a.append("file",e,e.name)})),fetch("http://localhost:3001/upload",{method:"post",body:a}).then((function(e){return e.json()})).then((function(e){return t(console.log(e))})).catch((function(e){return n(e)}))}))}},{key:"render",value:function(){var e=this,t=this.props,n=t.classes,a=t.modalState,o=t.handleCloseDispatcher;return r.a.createElement("div",{className:"c-Uploader"},r.a.createElement(ne.a,{"aria-labelledby":"transition-modal-title","aria-describedby":"transition-modal-description",className:n.modal,open:a||!1,onClose:function(){return o(!1)},closeAfterTransition:!0,BackdropComponent:ae.a,BackdropProps:{timeout:500}},r.a.createElement(re.a,{in:a||!1},r.a.createElement(oe.a,{elevation:4,className:n.paper},r.a.createElement("span",{className:"Title"},"Upload Files"),r.a.createElement("div",{className:"Content"},r.a.createElement("div",null,r.a.createElement(ve,{onFilesAdded:this.onFilesAdded,disabled:this.state.uploading||this.state.successfullUploaded})),r.a.createElement("div",{className:"Files"},this.state.files.map((function(t){return r.a.createElement("div",{key:t.name,className:"Row"},r.a.createElement("span",{className:"Filename"},t.name),e.renderProgress(t))})))),r.a.createElement("div",{className:"Actions"},this.renderActions())))))}}])&&Ne(n.prototype,a),o&&Ne(n,o),t}(r.a.Component);De.propTypes={classes:i.a.object.isRequired,handleCloseDispatcher:i.a.func,modalState:i.a.bool};var Ae=Object(l.createPropsSelector)({modalState:u.e}),Fe={handleCloseDispatcher:s.o},Ie=Object(c.b)(Ae,Fe)(Object(me.a)((function(e){return{modal:{display:"flex",alignItems:"center",justifyContent:"center"},paper:{backgroundColor:e.palette.background.paper,border:"2px solid #000",boxShadow:e.shadows[5],padding:e.spacing(2,4,3),width:"40%"}}}))(De)),Me=function(e){var t=e.chat,n=["c-ChatCard",t.isUser?"rightFloater":""].join(" ");return r.a.createElement("div",{className:n},r.a.createElement("p",null,t.text))};Me.propTypes={};var Ue=Me,Re=function(e){var t=["c-ChatView",e.chatView?"pad":""].join(" "),n=["c-display flex",e.chatView?"show":""].join(" "),a=[{isUser:!1,text:"Do something"},{isUser:!0,text:"Do something else"},{isUser:!0,text:"Try againg"},{isUser:!1,text:"Got response from server"},{isUser:!0,text:"13 images found"},{isUser:!1,text:"Find colorful images"}],o=a&&a.map((function(e){return r.a.createElement(Ue,{chat:e})}));return r.a.createElement("div",{className:t},r.a.createElement("div",{className:n},o))};Re.propTypes={chatView:i.a.bool};var He=Object(l.createPropsSelector)({chatView:u.b}),Ve=Object(c.b)(He,null)(Re);function Be(e){return(Be="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Le(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function ze(e,t){return!t||"object"!==Be(t)&&"function"!==typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ge(e){return(Ge=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function qe(e,t){return(qe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Ke=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=ze(this,Ge(t).call(this,e))).pageType="home",n}var n,a,o;return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&qe(e,t)}(t,e),n=t,(a=[{key:"componentDidMount",value:function(){(0,this.props.initializeHome)()}},{key:"render",value:function(){return r.a.createElement("div",{className:"Home"},r.a.createElement("div",{className:"c-background",style:{backgroundImage:"url(".concat(this.props.backgroundImage,")")}}),r.a.createElement(y,null),r.a.createElement(ee,null),r.a.createElement(Ve,null),r.a.createElement(pe,null),r.a.createElement(Ie,null))}}])&&Le(n.prototype,a),o&&Le(n,o),t}(r.a.Component);Ke.propTypes={backgroundImage:i.a.string,initializeHome:i.a.func};var Xe=Object(l.createPropsSelector)({backgroundImage:u.a}),We={initializeHome:s.j},Je=Object(c.b)(Xe,We)(Ke);t.default=Je},52:function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"d",(function(){return c})),n.d(t,"e",(function(){return l})),n.d(t,"c",(function(){return s})),n.d(t,"b",(function(){return u}));var a=n(53),r=n(48),o=Object(a.createSelector)((function(e){return e.data}),(function(e){return e.pages.home})),i=Object(r.createGetSelector)(o,"backgroundImage"),c=Object(r.createGetSelector)(o,"modalOpened"),l=Object(r.createGetSelector)(o,"uploadModalOpened"),s=(Object(r.createGetSelector)(o,"formValues"),Object(r.createGetSelector)(o,"formErrors"),Object(r.createGetSelector)(o,"images")),u=Object(r.createGetSelector)(o,"chatView")},72:function(e,t,n){"use strict";var a=n(0),r=n.n(a),o=n(3),i=n.n(o),c=n(24),l=n(48),s=n(52),u=n(7),p=n(133),m=n(139),f=n(140),d=n(142),h=n(145),b=n(144),y=n(143),g=n(146),v=n(141),E=function(e){var t=e.image;return r.a.createElement("div",{className:"c-ImageHeader"},r.a.createElement("div",{className:"avatar",style:{backgroundImage:"url(".concat(t.imageUrl,")")}}))};E.propTypes={image:i.a.object};var w=E;function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],a=!0,r=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(a=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(l){r=!0,o=l}finally{try{a||null==c.return||c.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var S=Object(p.a)({card:{maxWidth:345},media:{height:140}}),C=function(e){var t=e.image,n=S(),o=O(Object(a.useState)(""),2),i=o[0],c=o[1];Object(a.useEffect)((function(){var e="data:image/jpeg;base64,"+l(t.img.data.data);t.img.imageUrl=e,c(e)}),[t.img.data.data,t.img.imageUrl]);var l=function(e){var t="";return[].slice.call(new Uint8Array(e)).forEach((function(e){return t+=String.fromCharCode(e)})),window.btoa(t)};return r.a.createElement(m.a,{className:"".concat(n.card," c-Image"),onClick:function(){return e.updateBackgroundDispatcher(i)}},r.a.createElement(f.a,{avatar:r.a.createElement(w,{image:t.img}),title:t.img.name,style:{textTransform:"capitalize"}}),r.a.createElement(d.a,null,r.a.createElement(y.a,{className:n.media,image:i,title:t.img.name}),r.a.createElement(b.a,null,r.a.createElement(v.a,{gutterBottom:!0,variant:"h5",component:"h2"},t.img.name),r.a.createElement(v.a,{variant:"body2",color:"textSecondary",component:"p"},t.img.description))),r.a.createElement(h.a,null,r.a.createElement(g.a,{size:"small",color:"primary"},"Like"),r.a.createElement(g.a,{size:"small",color:"primary"},"Share"),r.a.createElement(g.a,{size:"small",color:"primary"},"More")))};C.propTypes={image:i.a.object,updateBackgroundDispatcher:i.a.func};var j={updateBackgroundDispatcher:u.l},k=Object(c.b)(null,j)(C);function x(e){return(x="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function N(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function T(e,t){return!t||"object"!==x(t)&&"function"!==typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function P(e,t){return(P=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var D=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),T(this,_(t).apply(this,arguments))}var n,a,o;return function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&P(e,t)}(t,e),n=t,(a=[{key:"render",value:function(){var e=this.props.images,t=e&&e.map((function(e,t){return r.a.createElement(k,{image:e,key:t})}));return r.a.createElement("div",{className:"container-fluid c-ImageContainer"},r.a.createElement("div",{className:"row c-Images"},t))}}])&&N(n.prototype,a),o&&N(n,o),t}(r.a.Component);D.propTypes={images:i.a.array};var A=Object(l.createPropsSelector)({images:s.c}),F=Object(c.b)(A,null)(D);t.a=F}}]);
|
|
//# sourceMappingURL=8.8e6e1df7.chunk.js.map
|