"use strict";(self.webpackChunkdont_wait_reach_out=self.webpackChunkdont_wait_reach_out||[]).push([[647],{780:function(e,t,n){var a=n(5617),l=n(7294);t.Z=function(){function e(){document.querySelector(".header__logo").focus()}return l.createElement(l.Fragment,null,l.createElement("button",{className:"btn__top",onClick:function(){(0,a.Z)(0,e)},title:"Back to Top",type:"button"},l.createElement("span",null)))}},955:function(e,t,n){n.r(t);var a=n(7326),l=n(4578),o=n(5444),r=n(3269),c=n(780),i=n(2486),s=n(6380),h=n(49),g=n(7294),d=function(e){function t(t){var n;(n=e.call(this,t)||this).formElement=g.createRef(),n.maxSelections=3,n.minShow=12,n.state={selectedChallenges:[],categoryView:!0,showingAll:!1};var l=(0,a.Z)(n);return n.challengesByCategory={},n.props.data.challenges.nodes.forEach((function(e){var t=e.frontmatter.challengeCategory.frontmatter.title;l.challengesByCategory[t]||(l.challengesByCategory[t]=[]),l.challengesByCategory[t].push(e)})),n.toggleCategory=n.toggleCategory.bind((0,a.Z)(n)),n.toggleShowAll=n.toggleShowAll.bind((0,a.Z)(n)),n.toggleSelection=n.toggleSelection.bind((0,a.Z)(n)),n.updateSelectedChallenges=n.updateSelectedChallenges.bind((0,a.Z)(n)),n.cleanStoredData=n.cleanStoredData.bind((0,a.Z)(n)),n.handleFormReset=n.handleFormReset.bind((0,a.Z)(n)),n.handleFormSubmit=n.handleFormSubmit.bind((0,a.Z)(n)),n.nudgeOnFocus=n.nudgeOnFocus.bind((0,a.Z)(n)),n}(0,l.Z)(t,e);var n=t.prototype;return n.toggleCategory=function(e){this.setState({categoryView:e.target.checked})},n.toggleShowAll=function(e){this.setState({showingAll:!this.state.showingAll})},n.toggleSelection=function(e){var t=this.state.selectedChallenges;if(e.target.checked)t.push(e.target.id);else{var n=t.findIndex((function(t){return t.split("|")[0]===e.target.id}));n>-1&&t.splice(n,1)}this.updateSelectedChallenges(t)},n.handleFormReset=function(e){e.preventDefault(),this.updateSelectedChallenges([])},n.handleFormSubmit=function(e){e.preventDefault(),window.location=this.formElement.current.getAttribute("action")},n.updateSelectedChallenges=function(e){if(window){e=this.cleanStoredData(e),(0,i.m)(e);var t={selectedChallenges:e};this.setState(t)}},n.cleanStoredData=function(e){var t=this;return e.forEach((function(n,a){var l=n.split("|")[0];t.props.data.challenges.nodes.find((function(e){return e.frontmatter.challengePublicId==l}))||(console.log("Removing "+l+" from local storage"),e.splice(a,1))})),(0,i.m)(e),e},n.nudgeOnFocus=function(e){if(document.activeElement==e.target){var t=document.getElementsByClassName("challenges__controls")[0];if(t){var n="input"===e.target.tagName.toLowerCase()?document.querySelector('[for="'+e.target.id+'"]'):e.target,a=t.getBoundingClientRect(),l=a.left+a.width,o=a.top+a.height,r=n.getBoundingClientRect(),c=r.left+r.width,i=r.top+r.height;if((r.left>=a.left&&r.lefta.left||r.left<=a.left&&c>=l)&&(r.top>=a.top&&r.topa.top||r.top<=a.top&&i>o)){var s=0;s=i>o?a.height+(i-o):i-a.top,window.scrollTo(0,Math.ceil(window.scrollY+s))}}}},n.componentDidMount=function(){if(window){var e=(0,i.u)(!1).storedData;e=this.cleanStoredData(e),this.updateSelectedChallenges(e,!0)}},n.componentDidUpdate=function(e,t){if(this.state.showingAll!==t.showingAll&&!this.state.showingAll){var n=document.getElementsByClassName("challenges__more")[0];if(!n)return;window.scrollTo(0,n.getBoundingClientRect().top+window.scrollY-window.innerHeight/2)}},n.render=function(){var e=this,t=Object.keys(this.state.selectedChallenges).length,n=this;function a(e){return g.createElement(g.Fragment,null,g.createElement("ul",{className:"challenges"+(n.state.categoryView?" challenges--categorized":"")+(n.state.showingAll?" challenges--show-all":"")},e.map((function(e,t){var a=n.state.selectedChallenges.find((function(t){return t.split("|")[0]===e.frontmatter.challengePublicId}))||!1,l=e.frontmatter.title.trim();return l+="."!==l.substr(l.length-1)?".":"",g.createElement("li",{key:t},g.createElement("input",{id:e.frontmatter.challengePublicId,type:"checkbox",name:"challenge",value:e.frontmatter.title,onChange:n.toggleSelection,onKeyUp:n.nudgeOnFocus,checked:a,disabled:!a&&n.state.selectedChallenges.length>=n.maxSelections}),g.createElement("label",{className:"challenges__challenge",htmlFor:e.frontmatter.challengePublicId},g.createElement("span",null,l)))}))),!n.state.categoryView&&e.length>n.minShow?g.createElement("div",{className:"challenges__more"},g.createElement("button",{type:"button",className:"btn__secondary",onClick:n.toggleShowAll,onKeyUp:n.nudgeOnFocus},n.state.showingAll?"Show Less":"Show All")):g.createElement(g.Fragment,null))}var l=g.createElement(g.Fragment,null);return l=this.state.categoryView?g.createElement(g.Fragment,null,Object.keys(this.challengesByCategory).map((function(t,n){return g.createElement("div",{key:n},g.createElement("h2",null,t),a(e.challengesByCategory[t]))}))):a(this.props.data.challenges.nodes),g.createElement(r.Z,{location:this.props.location,title:this.props.data.pageData.frontmatter.metaTitle?this.props.data.pageData.frontmatter.metaTitle:this.props.data.pageData.frontmatter.title,metaDescription:this.props.data.pageData.frontmatter.metaDescription,metaKeywords:this.props.data.pageData.frontmatter.metaKeywords,preventIndexing:!0},g.createElement("div",{className:"challenges-header"},g.createElement("div",{className:"grid__container"},g.createElement("div",{className:"challenges-header__left"},g.createElement("h1",{id:"challenges-main-header"},(0,h.ZP)((0,s.Y5)(this.props.data.pageData.frontmatter.directions,!0)))),g.createElement("div",{className:"challenges-header__right"},g.createElement("input",{id:"challenges-by-category",type:"checkbox",checked:!0===n.state.categoryView&&"checked",onChange:this.toggleCategory}),g.createElement("label",{htmlFor:"challenges-by-category"},"Show by category")))),g.createElement("div",{className:"challenges__wrapper"},g.createElement("div",{className:"grid__container"},g.createElement("form",{ref:this.formElement,action:(0,o.dq)("/results/"),onReset:this.handleFormReset,onSubmit:this.handleFormSubmit},g.createElement("div",{role:"radiogroup","aria-labelledby":"challenges-main-header"},l),g.createElement("div",{className:"challenges__controls "+(t>0?"":"challenges__hidden")},t>0?g.createElement("div",{className:"challenges__controls-container"},g.createElement("div",{className:"challenges__controls-left"},g.createElement("p",null,g.createElement("strong",null,t)," of ",this.maxSelections," selected"),g.createElement("button",{type:"reset"},"Unselect everything")),g.createElement("button",{className:"btn__accent",type:"submit"},"All done")):g.createElement(g.Fragment,null),g.createElement(c.Z,null))))))},t}(g.Component);t.default=d},5617:function(e,t){t.Z=function(e,t){void 0===t&&(t=function(){});var n=e.toFixed(),a=function e(){window.pageYOffset.toFixed()===n&&(window.removeEventListener("scroll",e),t())};window.addEventListener("scroll",a),a(),window.scrollTo({top:e,behavior:"smooth"})}},2486:function(e,t,n){n.d(t,{u:function(){return o},m:function(){return r}});var a=n(5785),l="challenges";function o(e){var t=[],n=[],o=[];if(e&&window&&window.location.hash.length&&(t=window.location.hash.substr(1).split(",")).forEach((function(e){var t=e.split("|");n.push(t[0]),t.length>1&&o.push(t[1])})),window&&window.localStorage){var r;try{r=JSON.parse(localStorage.getItem(l))||[]}catch(s){r=[]}var c=[],i=[];Array.isArray(r)||(r=[]),r.length&&(r.forEach((function(e){var t=e.split("|");c.push(t[0]),t.length>1&&i.push(t[1])})),t=(0,a.Z)(new Set([].concat((0,a.Z)(t),(0,a.Z)(r)))),n=(0,a.Z)(new Set([].concat((0,a.Z)(n),c))),o=(0,a.Z)(new Set([].concat((0,a.Z)(o),i))))}return{storedData:t.slice(0,3),challenges:n.slice(0,3),lifeChallenges:o.slice(0,3)}}function r(e){window&&window.localStorage&&localStorage.setItem(l,JSON.stringify(e))}}}]);