text: (this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{292:function(e,t,n){},409:function(e,t,n){"use strict";n.r(t);var a,i,c,r,s,o,l=n(0),d=n.n(l),j=n(44),u=n.n(j),h=(n(291),n(292),n(33)),b=n(269),m=n(435),O=n(437),x=n(432),g=n(268),p=n(71),v=n(26),y=n(20),f=n(441),C=n(427),w=n(438),k=n(434),S=n(443),_=(n(202),n(35)),N=n.n(_),I=n(62),L=n(28),M=n(436),E=n(425),T=n(426),F=n(448),H=n(96),A=n(439),Q=Object(A.a)(a||(a=Object(H.a)(["\n  mutation login($email: String!, $password: String!) {\n    login(email: $email, password: $password) {\n      token\n      user {\n        _id\n        username\n        email\n      }\n    }\n  }\n"]))),D=Object(A.a)(i||(i=Object(H.a)(["\n    mutation saveHomeCity($homeCity: cityInput!) {\n        saveHomeCity(homeCity: $homeCity) {\n            username\n            homeCity{\n              name\n              region\n              population\n            }\n            savedCities{\n              name\n            }\n            } \n    }\n  \n"]))),P=Object(A.a)(c||(c=Object(H.a)(["\n  mutation addUser($username: String!, $email: String!, $password: String!) {\n    addUser(username: $username, email: $email, password: $password) {\n      token\n      user {\n        _id\n        username\n        email\n      }\n    }\n  }\n"]))),B=Object(A.a)(r||(r=Object(H.a)(["\n  mutation saveCity($city: cityInput) {\n    saveCity(city: $city) {\n      _id\n      username\n      savedCities {\n        cityId\n        name\n        image\n        healthcare\n        taxation\n        education\n        housing\n        costOfLiving\n        safety\n        environmentalQuality\n        economy\n        population\n        region\n      }\n    }\n  }\n"]))),q=Object(A.a)(s||(s=Object(H.a)(["\n  mutation removeCity($cityId: ID!) {\n    removeCity(cityId: $cityId) {\n       _id\n      username\n      savedCities {\n        cityId\n        name\n        image\n        healthcare\n        taxation\n        education\n        housing\n        costOfLiving\n        safety\n        environmentalQuality\n        economy\n        population\n        region\n      }\n    }\n  }\n"]))),$=n(14),K=n(15),z=n(219),G=new(function(){function e(){Object($.a)(this,e)}return Object(K.a)(e,[{key:"getProfile",value:function(){return Object(z.a)(this.getToken())}},{key:"loggedIn",value:function(){var e=this.getToken();return!(!e||this.isTokenExpired(e))}},{key:"isTokenExpired",value:function(e){return Object(z.a)(e).exp<Date.now()/1e3&&(localStorage.removeItem("id_token"),!0)}},{key:"getToken",value:function(){return localStorage.getItem("id_token")}},{key:"login",value:function(e){localStorage.setItem("id_token",e),window.location.assign("/")}},{key:"logout",value:function(){localStorage.removeItem("id_token"),window.location.assign("/")}}]),e}()),Y=n(1),U=function(){var e=Object(l.useState)({username:"",email:"",password:""}),t=Object(y.a)(e,2),n=t[0],a=t[1],i=Object(l.useState)(!1),c=Object(y.a)(i,1)[0],r=Object(l.useState)(!1),s=Object(y.a)(r,2),o=s[0],d=s[1],j=Object(F.a)(P),u=Object(y.a)(j,2),b=u[0],m=u[1].error;Object(l.useEffect)((function(){d(!!m)}),[m]);var O=function(e){var t=e.target,i=t.name,c=t.value;a(Object(h.a)(Object(h.a)({},n),{},Object(L.a)({},i,c)))},x=function(){var e=Object(I.a)(N.a.mark((function e(t){var i,c;return N.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log(n),t.preventDefault(),!1===t.currentTarget.checkValidity()&&(t.preventDefault(),t.stopPropagation()),e.prev=4,e.next=7,b({variables:Object(h.a)({},n)});case 7:i=e.sent,c=i.data,G.login(c.addUser.token),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(4),console.error(e.t0),d(!0);case 16:a({username:"",email:"",password:""});case 17:case"end":return e.stop()}}),e,null,[[4,12]])})));return function(t){return e.apply(this,arguments)}}();return Object(Y.jsx)(Y.Fragment,{children:Object(Y.jsxs)(M.a,{noValidate:!0,validated:c,onSubmit:x,children:[Object(Y.jsx)(E.a,{dismissible:!0,onClose:function(){return d(!1)},show:o,variant:"danger",children:"Something went wrong with your signup!"}),Object(Y.jsxs)(M.a.Group,{children:[Object(Y.jsx)(M.a.Label,{htmlFor:"username",children:"Username"}),Object(Y.jsx)(M.a.Control,{type:"text",placeholder:"Your username",name:"username",onChange:O,value:n.username,required:!0}),Object(Y.jsx)(M.a.Control.Feedback,{type:"invalid",children:"Username is required!"})]}),Object(Y.jsxs)(M.a.Group,{children:[Object(Y.jsx)(M.a.Label,{htmlFor:"email",children:"Email"}),Object(Y.jsx)(M.a.Control,{type:"email",placeholder:"Your email address",name:"email",onChange:O,value:n.email,required:!0}),Object(Y.jsx)(M.a.Control.Feedback,{type:"invalid",children:"Email is required!"})]}),Object(Y.jsxs)(M.a.Group,{children:[Object(Y.jsx)(M.a.Label,{htmlFor:"password",children:"Password"}),Object(Y.jsx)(M.a.Control,{type:"password",placeholder:"Your password",name:"password",onChange:O,value:n.password,required:!0}),Object(Y.jsx)(M.a.Control.Feedback,{type:"invalid",children:"Password is required!"})]}),Object(Y.jsx)(T.a,{className:"mt-10",disabled:!(n.username&&n.email&&n.password),type:"submit",variant:"success",children:"Submit"})]})})},V=function(){var e=Object(l.useState)({email:"",password:""}),t=Object(y.a)(e,2),n=t[0],a=t[1],i=Object(l.useState)(!1),c=Object(y.a)(i,1)[0],r=Object(l.useState)(!1),s=Object(y.a)(r,2),o=s[0],j=s[1],u=Object(F.a)(Q),b=Object(y.a)(u,2),m=b[0],O=b[1].error;Object(l.useEffect)((function(){j(!!O)}),[O]);var x=function(e){var t=e.target,i=t.name,c=t.value;a(Object(h.a)(Object(h.a)({},n),{},Object(L.a)({},i,c)))},g=function(){var e=Object(I.a)(N.a.mark((function e(t){var i,c;return N.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),!1===t.currentTarget.checkValidity()&&(t.preventDefault(),t.stopPropagation()),e.prev=3,e.next=6,m({variables:Object(h.a)({},n)});case 6:i=e.sent,c=i.data,G.login(c.login.token),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(3),console.error(e.t0),j(!0);case 15:a({username:"",email:"",password:""});case 16:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t){return e.apply(this,arguments)}}();return Object(Y.jsx)(d.a.Fragment,{children:Object(Y.jsxs)(M.a,{noValidate:!0,validated:c,onSubmit:g,className:"p-3",children:[Object(Y.jsx)(E.a,{dismissible:!0,onClose:function(){return j(!1)},show:o,variant:"danger",children:"Error: Login credentials are incorrect."}),Object(Y.jsxs)(M.a.Group,{children:[Object(Y.jsx)(M.a.Label,{htmlFor:"email",children:"Email"}),Object(Y.jsx)(M.a.Control,{type:"text",placeholder:"Enter your email",name:"email",onChange:x,value:n.email,required:!0}),Object(Y.jsx)(M.a.Control.Feedback,{type:"invalid",children:"Error: Email is required."})]}),Object(Y.jsxs)(M.a.Group,{children:[Object(Y.jsx)(M.a.Label,{htmlFor:"password",children:"Password"}),Object(Y.jsx)(M.a.Control,{type:"password",placeholder:"Enter your password",name:"password",onChange:x,value:n.password,required:!0}),Object(Y.jsx)(M.a.Control.Feedback,{type:"invalid",children:"Error: Password is required."})]}),Object(Y.jsx)(T.a,{className:"mt-10",disabled:!(n.email&&n.password),type:"submit",variant:"success",children:"Submit"})]})})},J=n(72),W=n(70),R=function(){var e=Object(l.useState)(!1),t=Object(y.a)(e,2),n=t[0],a=t[1];return Object(Y.jsxs)(d.a.Fragment,{children:[Object(Y.jsx)(f.a,{className:"navi p-4",bg:"dark",variant:"dark",expand:"lg",children:Object(Y.jsxs)(C.a,{fluid:!0,children:[Object(Y.jsx)(f.a.Brand,{as:p.b,to:"/",children:Object(Y.jsxs)("span",{className:"mx-5 h2",children:[Object(Y.jsx)(W.a,{className:"home-logo",icon:J.d}),"Home City"]})}),Object(Y.jsx)(f.a.Toggle,{"aria-controls":"navbar"}),Object(Y.jsx)(f.a.Collapse,{id:"navbar",children:Object(Y.jsxs)(w.a,{className:"ml-auto",children:[Object(Y.jsx)(w.a.Link,{as:p.b,to:"/",children:"Search Cities"}),G.loggedIn()?Object(Y.jsxs)(Y.Fragment,{children:[Object(Y.jsx)(w.a.Link,{as:p.b,to:"/profile",children:"See Your Cities"}),Object(Y.jsx)(w.a.Link,{onClick:G.logout,as:p.b,to:"/",children:"Logout"})]}):Object(Y.jsx)(w.a.Link,{onClick:function(){return a(!0)},children:"Login/Sign Up"})]})})]})}),Object(Y.jsx)(k.a,{size:"lg",show:n,onHide:function(){return a(!1)},"aria-labelledby":"signup-modal",children:Object(Y.jsxs)(S.a.Container,{defaultActiveKey:"login",children:[Object(Y.jsx)(k.a.Header,{closeButton:!0,children:Object(Y.jsx)(k.a.Title,{id:"signup-modal",children:"Login"})}),Object(Y.jsxs)(k.a.Body,{children:[Object(Y.jsxs)(w.a,{variant:"pills",className:"mb-4",children:[Object(Y.jsx)(w.a.Item,{children:Object(Y.jsx)(w.a.Link,{eventKey:"login",className:"btn-link",children:"Login"})}),Object(Y.jsx)(w.a.Item,{children:Object(Y.jsx)(w.a.Link,{eventKey:"signup",className:"btn-link",children:"Sign Up"})})]}),Object(Y.jsxs)(S.a.Content,{children:[Object(Y.jsx)(S.a.Pane,{eventKey:"login",children:Object(Y.jsx)(V,{handleModalClose:function(){return a(!1)}})}),Object(Y.jsx)(S.a.Pane,{eventKey:"signup",children:Object(Y.jsx)(U,{handleModalClose:function(){return a(!1)}})})]})]})]})})]})},X=n(36),Z=n(442),ee=Object(A.a)(o||(o=Object(H.a)(["\n  query me {\n    me {\n      _id\n      username\n      email\n      cityCount\n      homeCity{\n        cityId\n        name\n        image\n        healthcare\n        taxation\n        education\n        housing\n        costOfLiving\n        safety\n        environmentalQuality\n        economy\n        population\n        region\n      }\n      savedCities {\n        _id\n        cityId\n        name\n        image\n        healthcare\n        taxation\n        education\n        housing\n        costOfLiving\n        safety\n        environmentalQuality\n        economy\n        population\n        region\n      }\n    }\n  }\n"]))),te=function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},ne=n(428),ae=n(187),ie=n(429),ce=n(444),re=n(446);var se=function(){var e=Object(Z.a)(ee,{}),t=e.loading,n=e.error,a=e.data;console.log(n),console.log(a);var i=Object(l.useState)([]),c=Object(y.a)(i,2),r=c[0],s=c[1],o=Object(l.useState)(""),j=Object(y.a)(o,2),u=j[0],h=j[1],b=Object(l.useState)([]),m=Object(y.a)(b,2),O=m[0],x=m[1];Object(l.useEffect)((function(){var e;if(!t&&(null===a||void 0===a||null===(e=a.me)||void 0===e?void 0:e.savedCities)){var n=a.me.savedCities.map((function(e){return e.cityId}));x(n)}}),[t]);var g=Object(F.a)(D),p=Object(y.a)(g,2),v=p[0],f=p[1].saveHomeError,C=Object(F.a)(B),w=Object(y.a)(C,1)[0],k=function(e){var t=e.suggestions,n=e.searchInput,a=e.onSelectSuggestion,i=e.displaySuggestions,c=e.selectedSuggestion,r=e.onKeyDown;return n&&i?t.length>0?Object(Y.jsx)("ul",{className:"suggestions-list",children:t.map((function(e,t){var n="suggestion ".concat(c===t?"selected":"");return Object(Y.jsx)("li",{tabIndex:0,className:n,onClick:function(){return a(t)},onKeyDown:r,children:e},t)}))}):Object(Y.jsxs)("div",{className:"no-suggestions",children:[" ",Object(Y.jsx)(W.a,{icon:J.c}),"\xa0\xa0No suggestions are available"]}):Object(Y.jsx)(Y.Fragment,{})},S=d.a.useState([]),_=Object(y.a)(S,2),L=_[0],E=_[1],T=d.a.useState(0),H=Object(y.a)(T,2),A=H[0],Q=H[1],P=d.a.useState(!1),q=Object(y.a)(P,2),$=q[0],K=q[1],z=["New York, New York","Los Angeles, California","Chicago, Illinois","Houston, Texas","Phoenix, Arizona","Philadelphia, Pennsylvania","San Antonio, Texas","San Diego, California","Dallas, Texas","San Jose, California","Austin, Texas","Jacksonville, Florida","Fort Worth, Texas","Columbus, Ohio","Charlotte, North Carolina","San Francisco, California","Indianapolis, Indiana","Seattle, Washington","Denver, Colorado","Washington, DC","Boston, Massachusetts","El Paso, Texas","Nashville-Davidson, Tennessee","Detroit, Michigan","Oklahoma City, Oklahoma","Portland, Oregon","Las Vegas, Nevada","Memphis, Tennessee","Louisville-Jefferson County, Kentucky","Baltimore, Maryland","Milwaukee, Wisconsin","Albuquerque, N.M.","Tucson, Arizona","Fresno, California","Mesa, Arizona","Sacramento, California","Atlanta, Georgia","Kansas City, Missouri","Colorado Springs, Colorado","Omaha, Nebraska","Raleigh, North Carolina","Miami, Florida","Long Beach, California","Virginia Beach, Virginia","Oakland, California","Minneapolis, Minnesota","Tulsa, Oklahoma","Tampa, Florida","Arlington, Texas","New Orleans, Louisiana"],U=function(){var e=Object(I.a)(N.a.mark((function e(t){var n,a,i,c,r,o,l,d,j,b;return N.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),u){e.next=3;break}return e.abrupt("return",!1);case 3:return e.prev=3,e.next=6,fetch("https://api.teleport.org/api/cities/?search=".concat(u,"&limit=1&embed=city%3Asearch-results%2Fcity%3Aitem%2Fcity%3Aurban_area%2Fua%3Ascores"));case 6:if((n=e.sent).ok){e.next=9;break}throw new Error("something went wrong!");case 9:return e.next=11,n.json();case 11:return a=e.sent,i=a._embedded["city:search-results"],c=i[0]._embedded["city:item"].population,i[0].population=te(c),r=i[0]._embedded["city:item"]._embedded["city:urban_area"]._embedded["ua:scores"].categories,i[0].housing=Math.round(r[0].score_out_of_10),i[0].costOfLiving=Math.round(r[1].score_out_of_10),i[0].safety=Math.round(r[7].score_out_of_10),i[0].healthcare=Math.round(r[8].score_out_of_10),i[0].education=Math.round(r[9].score_out_of_10),i[0].environmentalQuality=Math.round(r[10].score_out_of_10),i[0].economy=Math.round(r[11].score_out_of_10),i[0].taxation=Math.round(r[12].score_out_of_10),i[0].cityId=i[0]._embedded["city:item"].geoname_id,o=i[0]._embedded["city:item"]._embedded["city:urban_area"]._links["ua:images"].href,e.next=28,fetch("".concat(o));case 28:if((l=e.sent).ok){e.next=31;break}throw new Error("something went wrong!");case 31:return e.next=33,l.json();case 33:d=e.sent,j=d.photos[0].image.web,i[0].image=j,b=i[0]._embedded["city:item"]._embedded["city:urban_area"].full_name,i[0].region=b,s(i),h(""),e.next=45;break;case 42:e.prev=42,e.t0=e.catch(3),console.error(e.t0);case 45:case"end":return e.stop()}}),e,null,[[3,42]])})));return function(t){return e.apply(this,arguments)}}(),V=function(e,t){return null!==e&&e.name===t.matching_full_name},R=function(){var e=Object(I.a)(N.a.mark((function e(t){var n,a,i,c;return N.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.find((function(e){return e.cityId===t})),G.loggedIn()?G.getToken():null){e.next=4;break}return e.abrupt("return",!1);case 4:return e.prev=4,a={cityId:n._embedded["city:item"].geoname_id,name:n.matching_full_name,healthcare:n.healthcare,taxation:n.taxation,education:n.education,costOfLiving:n.costOfLiving,housing:n.housing,safety:n.safety,environmentalQuality:n.environmentalQuality,economy:n.economy,image:n.image,region:n.region,population:parseInt(n.population.replace(/,/g,""),10)},console.log(a),e.next=9,v({variables:{homeCity:a}});case 9:if(i=e.sent,console.log("save home error",f),i.data){e.next=13;break}throw new Error("something went wrong!");case 13:(c=document.getElementById("saveHomeCityBtn")).innerHTML="City is your Home City",c.setAttribute("disabled",!0),e.next=21;break;case 18:e.prev=18,e.t0=e.catch(4),console.error(e.t0);case 21:case"end":return e.stop()}}),e,null,[[4,18]])})));return function(t){return e.apply(this,arguments)}}(),se=function(){var e=Object(I.a)(N.a.mark((function e(t){var n,a,i,c;return N.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.find((function(e){return e.cityId===t})),G.loggedIn()?G.getToken():null){e.next=4;break}return e.abrupt("return",!1);case 4:return e.prev=4,console.log(n),a={cityId:n._embedded["city:item"].geoname_id,name:n.matching_full_name,healthcare:n.healthcare,taxation:n.taxation,education:n.education,costOfLiving:n.costOfLiving,housing:n.housing,safety:n.safety,environmentalQuality:n.environmentalQuality,economy:n.economy,image:n.image,region:n.region,population:parseInt(n.population.replace(/,/g,""),10)},e.next=9,w({variables:{city:a}});case 9:if(i=e.sent,console.log(w),i.data){e.next=13;break}throw new Error("something went wrong!");case 13:x([].concat(Object(X.a)(O),[a.cityId])),(c=document.getElementById("saveCityBtn")).innerHTML="This city has already been saved!",c.setAttribute("disabled",!0),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(4),console.error(e.t0);case 22:case"end":return e.stop()}}),e,null,[[4,19]])})));return function(t){return e.apply(this,arguments)}}();return Object(Y.jsxs)(Y.Fragment,{children:[Object(Y.jsx)(ne.a,{fluid:!0,className:"text-light jumboGrad home-search",children:Object(Y.jsx)(ie.a,{style:{width:"70rem"},className:"p-5 jumbo",children:Object(Y.jsxs)(M.a,{className:"p-5",onSubmit:U,children:[Object(Y.jsxs)("h1",{className:"text-center font-normal",children:["Search for your future ",Object(Y.jsx)("span",{className:"home-city",children:"home city"})]}),Object(Y.jsxs)(M.a.Row,{children:[Object(Y.jsx)(M.a.Label,{className:"text-left display-block",children:"City, State "}),Object(Y.jsxs)("div",{className:"input-group",children:[Object(Y.jsx)(M.a.Control,{size:"lg",className:"user-input form-control-large",type:"text",onChange:function(e){var t=e.target.value;h(t);var n=z.filter((function(e){return e.toLowerCase().includes(t.toLowerCase())}));E(n),K(!0)},value:u,placeholder:"Enter city name"}),Object(Y.jsx)(k,{onBlur:function(){return alert("blur"),K(!1)},searchInput:u,selectedSuggestion:A,onSelectSuggestion:function(e){Q(e),h(L[e]),E([]),K(!1)},displaySuggestions:$,suggestions:L}),Object(Y.jsxs)(ce.a,{light:!0,type:"submit",children:[Object(Y.jsx)(W.a,{icon:J.e}),Object(Y.jsx)("span",{children:"\xa0\xa0Search"})]})]})]})]})})}),Object(Y.jsx)(ie.a,{className:"p-5",children:r.map((function(e){return console.log(e),Object(Y.jsxs)("div",{children:[Object(Y.jsxs)(re.a,{stackable:!0,columns:2,children:[Object(Y.jsx)(re.a.Column,{children:Object(Y.jsxs)("div",{children:[Object(Y.jsxs)("h2",{children:["City: ",e.matching_full_name]}),G.loggedIn()&&Object(Y.jsx)(ce.a,{primary:!0,disabled:O.includes(e.cityId+"")||O.includes(e.cityId),className:"btn-block btn-info",id:"saveCityBtn",onClick:function(){return se(e.cityId)},children:O.includes(e.cityId+"")||O.includes(e.cityId)?"City has been saved":"Save this City"}),G.loggedIn()&&!t&&void 0===n&&Object(Y.jsx)(ce.a,{disabled:V(a.me.homeCity,e),id:"saveHomeCityBtn",primary:!0,onClick:function(){return R(e.cityId)},children:V(a.me.homeCity,e)?"City is your Home City":"Set as Home City"}),Object(Y.jsxs)("h3",{children:[Object(Y.jsx)("span",{className:"bold",children:"Population: "}),Object(Y.jsx)("span",{children:e.population})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Region: "}),Object(Y.jsx)("span",{children:e.region})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Healthcare: "}),Object(Y.jsxs)("span",{children:[e.healthcare," of 10"]})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Taxation: "}),Object(Y.jsxs)("span",{children:[e.taxation," of 10"]})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Education: "}),Object(Y.jsxs)("span",{children:[e.education," of 10"]})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Housing: "}),Object(Y.jsxs)("span",{children:[e.housing," of 10"]})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Cost of Living: "}),Object(Y.jsxs)("span",{children:[e.costOfLiving," of 10"]})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Safety: "}),Object(Y.jsxs)("span",{children:[e.safety," of 10"]})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Environmental Quality: "}),Object(Y.jsxs)("span",{children:[e.environmentalQuality," of 10"]})]}),Object(Y.jsxs)("div",{children:[Object(Y.jsx)("span",{className:"bold",children:"Economy: "}),Object(Y.jsxs)("span",{children:[e.economy," of 10"]})]})]})}),Object(Y.jsx)(re.a.Column,{className:"image-cropper",children:Object(Y.jsx)("img",{src:e.image,className:"city-pic",alt:"img not found"})})]}),Object(Y.jsx)(ie.a,{children:Object(Y.jsx)("div",{children:Object(Y.jsx)(ae.a,{data:{labels:["Healthcare","Taxation","Education","Housing","Living","Safety","Environment","Economy"],datasets:[{label:"Score",data:["".concat(e.healthcare),"".concat(e.taxation),"".concat(e.education),"".concat(e.housing),"".concat(e.costOfLiving),"".concat(e.safety),"".concat(e.environmentalQuality),"".concat(e.economy)],backgroundColor:["rgba(255, 99, 132, 0.2)","rgba(54, 162, 235, 0.2)","rgba(255, 206, 86, 0.2)","rgba(75, 192, 192, 0.2)","rgba(153, 102, 255, 0.2)","rgba(255, 159, 64, 0.2)"],borderColor:["rgba(255, 99, 132, 1)","rgba(54, 162, 235, 1)","rgba(255, 206, 86, 1)","rgba(75, 192, 192, 1)","rgba(153, 102, 255, 1)","rgba(255, 159, 64, 1)"],borderWidth:1}]},height:400,width:500,options:{maintainAspectRatio:!1,scales:{y:{suggestedMin:0,suggestedMax:10}}}})})})]},e.matching_full_name)}))})]})},oe=n(138),le=function(e){var t=e.headerIcon,n=e.title,a=e.text;return Object(Y.jsxs)(oe.a,{bg:"light",text:"dark",style:{width:"18rem",margin:"10px",textAlign:"center"},children:[Object(Y.jsxs)(oe.a.Header,{children:[t,Object(Y.jsx)(oe.a.Title,{children:n})]}),Object(Y.jsx)(oe.a.Body,{children:Object(Y.jsx)(oe.a.Text,{children:a})})]})},de=function(){var e=[{headerIcon:Object(Y.jsx)(W.a,{icon:J.e}),title:"Search",text:"Search for U.S. cities to find population statistics and quality of life scores."},{headerIcon:Object(Y.jsx)(W.a,{icon:J.a}),title:"Analyze",text:"Get healthcare, taxation, education, housing, cost of living, safety, environmental quality & economy scores."},{headerIcon:Object(Y.jsx)(W.a,{icon:J.b}),title:"Compare",text:"See how your home city compares with your possible future home cities."}];return Object(Y.jsx)("div",{className:"row my-5 justify-content-between p-5",children:e.map((function(e,t){return Object(Y.jsx)(le,Object(h.a)({},e),t)}))})},je=function(){return Object(Y.jsxs)(Y.Fragment,{children:[Object(Y.jsx)(se,{}),Object(Y.jsx)(de,{})]})},ue=n(431),he=n(262),be=n(91),me=function(e){var t=localStorage.getItem("saved_cities")?JSON.parse(localStorage.getItem("saved_cities")):null;if(!t)return!1;var n=null===t||void 0===t?void 0:t.filter((function(t){return t!==e}));return localStorage.setItem("saved_cities",JSON.stringify(n)),!0},Oe=n(430),xe=n(433),ge=function(){var e,t,n=Object(l.useState)([]),a=Object(y.a)(n,2),i=a[0],c=a[1],r=Object(Z.a)(ee),s=r.loading,o=r.data,d=(null===o||void 0===o?void 0:o.me)||[];return s?Object(Y.jsx)("h2",{children:"LOADING..."}):Object(Y.jsxs)(C.a,{children:[Object(Y.jsx)("h3",{children:(null===(e=d.savedCities)||void 0===e?void 0:e.length)>1?"Select 2 cities to compare. You have ".concat(d.savedCities.length," ").concat(1===d.savedCities.length?"city":"cities"," saved."):"You need at least 2 saved cities to compare. Search for more cities"}),Object(Y.jsx)(xe.a,{className:"mb-10",placeholder:"Saved City",onChange:function(e,t){var n=t.value;c(n)},fluid:!0,multiple:!0,selection:!0,options:null===(t=d.savedCities)||void 0===t?void 0:t.map((function(e){return{key:e._id,value:e._id,text:e.name,disabled:i.length>1}}))}),null===i||void 0===i?void 0:i.map((function(e,t){if(1===i.length){var n=r(i[0]);return n.population=te(n[0].population),n.healthcare=Math.round(n[0].healthcare),n.taxation=Math.round(n[0].taxation),n.education=Math.round(n[0].education),n.housing=Math.round(n[0].housing),n.costOfLiving=Math.round(n[0].costOfLiving),n.safety=Math.round(n[0].safety),n.environmentalQuality=Math.round(n[0].environmentalQuality),n.economy=Math.round(n[0].economy),Object(Y.jsxs)(Oe.a,{responsive:!0,striped:!0,bordered:!0,hover:!0,children:[Object(Y.jsx)("thead",{children:Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("th",{children:"City"}),Object(Y.jsx)("th",{children:n[0].name})]})}),Object(Y.jsxs)("tbody",{children:[Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Population"}),Object(Y.jsx)("td",{children:n.population})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Healthcare"}),Object(Y.jsx)("td",{children:n.healthcare})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Taxation"}),Object(Y.jsx)("td",{children:n.taxation})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Education"}),Object(Y.jsx)("td",{children:n.education})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Housing"}),Object(Y.jsx)("td",{children:n.housing})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Living"}),Object(Y.jsx)("td",{children:n.costOfLiving})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Safety"}),Object(Y.jsx)("td",{children:n.safety})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Environment"}),Object(Y.jsx)("td",{children:n.environmentalQuality})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Economy"}),Object(Y.jsx)("td",{children:n.economy})]})]})]},n[0]._id)}if(2===i.length){var a=r(i[0]),c=r(i[1]);if(a.population=te(a[0].population),c.population=te(c[0].population),a.population=te(a[0].population),a.healthcare=Math.round(a[0].healthcare),a.taxation=Math.round(a[0].taxation),a.education=Math.round(a[0].education),a.housing=Math.round(a[0].housing),a.costOfLiving=Math.round(a[0].costOfLiving),a.safety=Math.round(a[0].safety),a.environmentalQuality=Math.round(a[0].environmentalQuality),a.economy=Math.round(a[0].economy),c.population=te(c[0].population),c.healthcare=Math.round(c[0].healthcare),c.taxation=Math.round(c[0].taxation),c.education=Math.round(c[0].education),c.housing=Math.round(c[0].housing),c.costOfLiving=Math.round(c[0].costOfLiving),c.safety=Math.round(c[0].safety),c.environmentalQuality=Math.round(c[0].environmentalQuality),c.economy=Math.round(c[0].economy),1===t)return Object(Y.jsxs)(Oe.a,{responsive:!0,striped:!0,bordered:!0,hover:!0,children:[Object(Y.jsx)("thead",{children:Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("th",{children:"City"}),Object(Y.jsx)("th",{children:a[0].name}),Object(Y.jsx)("th",{children:c[0].name})]})}),Object(Y.jsxs)("tbody",{children:[Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Population"}),Object(Y.jsx)("td",{children:a.population}),Object(Y.jsx)("td",{children:c.population})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Healthcare"}),Object(Y.jsx)("td",{children:a.healthcare}),Object(Y.jsx)("td",{children:c.healthcare})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Taxation"}),Object(Y.jsx)("td",{children:a.taxation}),Object(Y.jsx)("td",{children:c.taxation})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Education"}),Object(Y.jsx)("td",{children:a.education}),Object(Y.jsx)("td",{children:c.education})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Housing"}),Object(Y.jsx)("td",{children:a.housing}),Object(Y.jsx)("td",{children:c.housing})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Living"}),Object(Y.jsx)("td",{children:a.costOfLiving}),Object(Y.jsx)("td",{children:c.costOfLiving})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Safety"}),Object(Y.jsx)("td",{children:a.safety}),Object(Y.jsx)("td",{children:c.safety})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Environment"}),Object(Y.jsx)("td",{children:a.environmentalQuality}),Object(Y.jsx)("td",{children:c.environmentalQuality})]}),Object(Y.jsxs)("tr",{children:[Object(Y.jsx)("td",{children:"Economy"}),Object(Y.jsx)("td",{children:a.economy}),Object(Y.jsx)("td",{children:c.economy})]})]})]},a[0]._id)}function r(e){var t;return null===(t=d.savedCities)||void 0===t?void 0:t.filter((function(t){return t._id===e}))}}))]})},pe=n(440),ve=n(137),ye=n(270),fe=(n.p,function(){var e=Object(Z.a)(ee,{fetchPolicy:"network-only"}),t=e.loading,n=e.data;console.log(n);var a=Object(F.a)(q),i=Object(y.a)(a,1)[0],c=(null===n||void 0===n?void 0:n.me)||{};if(console.log(c),!(null===c||void 0===c?void 0:c.username))return Object(Y.jsx)("h4",{children:"You need to be logged in to see this. Use the navigation links above to sign up or log in!"});var r=function(){var e=Object(I.a)(N.a.mark((function e(t){return N.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(G.loggedIn()?G.getToken():null){e.next=3;break}return e.abrupt("return",!1);case 3:return e.prev=3,e.next=6,i({variables:{cityId:t}});case 6:if(e.sent.data){e.next=9;break}throw new Error("something went wrong!");case 9:me(t),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(3),console.error(e.t0);case 15:case"end":return e.stop()}}),e,null,[[3,12]])})));return function(t){return e.apply(this,arguments)}}();return t?Object(Y.jsx)("h2",{children:"LOADING..."}):Object(Y.jsx)(Y.Fragment,{children:Object(Y.jsx)(ne.a,{fluid:!0,className:"m-3",children:Object(Y.jsxs)(ue.a,{children:[Object(Y.jsx)(he.a,{className:"mb-2 mt-3 about-me",sm:12,md:5,children:Object(Y.jsxs)(C.a,{children:[Object(Y.jsxs)(pe.a,{fluid:!0,children:[Object(Y.jsxs)(pe.a.Content,{className:"text-left",children:[Object(Y.jsx)(pe.a.Header,{children:Object(Y.jsx)("h1",{children:n.me.username})}),Object(Y.jsx)(pe.a.Meta,{children:n.me.email}),Object(Y.jsx)(pe.a.Description,{children:n.me.homeCity&&Object(Y.jsxs)("h3",{children:[n.me.username," is currently living in ",n.me.homeCity.name.split(",")[0],"."]})})]}),Object(Y.jsx)(pe.a.Content,{extra:!0,children:Object(Y.jsxs)("div",{className:"display-flex align-center ",children:[Object(Y.jsx)(ve.a,{disabled:!0,name:"building",size:"large"}),Object(Y.jsxs)("span",{children:[n.me.savedCities.length," saved cities"]})]})}),n.me.homeCity&&Object(Y.jsx)(pe.a.Content,{extra:!0,children:Object(Y.jsxs)("div",{className:"display-flex align-center ",children:[Object(Y.jsx)(ve.a,{disabled:!0,name:"home",size:"large"}),Object(Y.jsx)("span",{children:n.me.homeCity.name})]})})]}),n.me.homeCity?Object(Y.jsxs)(pe.a,{fluid:!0,children:[Object(Y.jsx)(ye.a,{src:n.me.homeCity.image,wrapped:!0,ui:!1}),Object(Y.jsxs)(pe.a.Content,{children:[Object(Y.jsx)(pe.a.Header,{children:n.me.homeCity.name.split(",")[0]}),Object(Y.jsx)(pe.a.Meta,{children:n.me.homeCity.name}),Object(Y.jsxs)(pe.a.Description,{children:["Population: ",te(n.me.homeCity.population)]})]})]}):Object(Y.jsx)(p.b,{to:"/",children:Object(Y.jsx)(T.a,{variant:"danger",children:"Search for your home city"})})]})}),Object(Y.jsxs)(he.a,{sm:12,md:7,className:"mt-3",children:[Object(Y.jsxs)(C.a,{className:"scores",children:[Object(Y.jsx)("h2",{children:" City Compare"}),Object(Y.jsx)(ge,{})]}),Object(Y.jsxs)(C.a,{className:"data",children:[" ",Object(Y.jsxs)("h2",{children:[" Your ",c.cityCount," Saved Cities!"]})," "]}),Object(Y.jsx)(C.a,{className:"scores",children:Object(Y.jsx)(S.a.Container,{className:"",sm:12,id:"left-tabs-example",children:Object(Y.jsxs)(ue.a,{children:[Object(Y.jsx)(he.a,{sm:12,children:Object(Y.jsx)(S.a.Content,{children:c.savedCities.map((function(e){return Object(Y.jsxs)(S.a.Pane,{eventKey:e.cityId,transition:be.a,children:[Object(Y.jsx)(ue.a,{className:"CityChartName",children:Object(Y.jsxs)("h3",{children:[" Viewing ",e.name,Object(Y.jsx)(T.a,{variant:"outline-danger delete",size:"sm",onClick:function(){return r(e.cityId)},children:"Delete city"})]})}),Object(Y.jsx)(ae.a,{className:"mb-3",data:{labels:["Healthcare","Taxation","Education","Housing","Living","Safety","Environment","Economy"],datasets:[{label:"Score",data:["".concat(e.healthcare),"".concat(e.taxation),"".concat(e.education),"".concat(e.housing),"".concat(e.costOfLiving),"".concat(e.safety),"".concat(e.environmentalQuality),"".concat(e.economy)],backgroundColor:["rgba(255, 99, 132, 0.2)","rgba(54, 162, 235, 0.2)","rgba(255, 206, 86, 0.2)","rgba(75, 192, 192, 0.2)","rgba(153, 102, 255, 0.2)","rgba(255, 159, 64, 0.2)"],borderColor:["rgba(255, 99, 132, 1)","rgba(54, 162, 235, 1)","rgba(255, 206, 86, 1)","rgba(75, 192, 192, 1)","rgba(153, 102, 255, 1)","rgba(255, 159, 64, 1)"],borderWidth:1}]},height:60,width:200,options:{responsive:!0,maintainAspectRatio:!0,scales:{y:{suggestedMin:0,suggestedMax:5}}}})]})}))})}),Object(Y.jsx)(he.a,{sm:12,className:"display-flex flex-wrap",children:c.savedCities.map((function(e){return Object(Y.jsx)(w.a,{defaultActiveKey:e.cityId,variant:"pills",children:Object(Y.jsx)(w.a.Item,{children:Object(Y.jsxs)(w.a.Link,{className:"p-2 pb-2",eventKey:e.cityId,children:[" ",e.name]})})},e.cityId)}))})]})})})]})]})})})}),Ce=function(){return Object(Y.jsx)("footer",{children:"\xa9 2021 Home City"})},we=Object(b.a)({uri:"/graphql"}),ke=Object(g.a)((function(e,t){var n=t.headers,a=localStorage.getItem("id_token");return{headers:Object(h.a)(Object(h.a)({},n),{},{authorization:a?"Bearer ".concat(a):""})}})),Se=new m.a({link:ke.concat(we),cache:new O.a});var _e=function(){return Object(Y.jsx)(x.a,{client:Se,children:Object(Y.jsx)(p.a,{children:Object(Y.jsxs)(Y.Fragment,{children:[Object(Y.jsx)(R,{}),Object(Y.jsxs)(v.c,{children:[Object(Y.jsx)(v.a,{exact:!0,path:"/",component:je}),Object(Y.jsx)(v.a,{exact:!0,path:"/profile",component:fe}),Object(Y.jsx)(v.a,{render:function(){return Object(Y.jsx)("h1",{className:"display-2",children:"Wrong page!"})}})]}),Object(Y.jsx)(Ce,{})]})})})};u.a.render(Object(Y.jsx)(_e,{}),document.getElementById("root"))}},[[409,1,2]]]);
  //# sourceMappingURL=main.8e9e6f7d.chunk.js.map