1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3052],{3052:(function(A,r,s){s.r(r),s.d(r,{default:function(){return Z}});var m=function(){var t=this,o=t._self._c,B=t._self._setupProxy;return o("div",{staticClass:"bbnx-poll",class:t.pollClasses},[o("div",{staticClass:"poll-options"},[t._l(t.state.options,function(i){return[o("nx-poll-option",{key:i.id,attrs:{option:i,"show-image":t.showOptionImages,state:t.state},on:{selectOption:t.selectOptionId}})]})],2),t._v(" "),o("div",{staticClass:"poll-footer"},[t.state.votedOptionId||!t.state.active?o("div",{staticClass:"poll-footer--results"},[t.state.active?o("span",[t._v(t._s(t.$t("poll.poll-result-title")))]):!t.state.active&&t.notStarted&&!t.isFinished?o("span",[t._v(t._s(t.$t("poll.not-started"))+" "+t._s(t.pollStartDate))]):t.state.active?t._e():o("span",[t._v(t._s(t.$t("poll.inactive")))])]):o("div",{staticClass:"poll-footer--actions"},[o("button",{staticClass:"bbnx-btn medium vote-action",attrs:{disabled:!t.isCheckedOption,loading:t.isCheckedOption&&t.state.loading},on:{click:t.voteOption}},[t._v(` 2 `+t._s(t.$t("poll.vote"))+` 3 `)]),t._v(" "),o("nx-modal-window",{attrs:{title:t.$t("poll.modal-title"),text:t.$t("poll.modal-text",{site:this.site.name})},scopedSlots:t._u([{key:"actions",fn:function(){return[o("nx-button",{attrs:{text:t.$t("poll.button-login"),tabindex:t.showModal?"0":"-1",type:"button",medium:""},on:{click:t.goToLogin}}),t._v(" "),o("nx-button",{staticClass:"form-user-profile__button",attrs:{text:t.$t("like-modal.button-cancel"),tabindex:t.showModal?"0":"-1",type:"button",medium:"",outline:""},on:{click:t.closeModal}})]},proxy:!0}]),model:{value:t.showModal,callback:function(i){t.showModal=i},expression:"showModal"}})],1)])])},_=[],n=s(7382),g=s(5440),O=s(38),b=function(){var t=this,o=t._self._c,B=t._self._setupProxy;return o("div",{staticClass:"bbnx-poll-option",class:{selected:t.option.selected,results:(t.state.showResults||!t.state.active)&&!t.state.hidden,voted:!!t.state.votedOptionId||!t.state.active,loading:t.state.loading},on:{click:function(i){return t.checkOption(t.option.id)}}},[t.showImage&&t.option.image?o("div",{staticClass:"poll-option--image"},[o("nx-picture",{attrs:{image:t.option.image,imageSourcesByAspectRatio:"mini"}})],1):t._e(),t._v(" "),o("div",{staticClass:"poll-option--content"},[o("div",{staticClass:"poll-option--content--left"},[o("div",{staticClass:"poll-option-title"},[t._v(t._s(t.option.title))])]),t._v(" "),(t.state.showResults||!t.state.active)&&!t.state.hidden?o("div",{staticClass:"poll-option--content--right"},[o("span",{staticClass:"percent"},[t._v(t._s(t.option.percent)+"%")])]):t._e(),t._v(" "),!t.state.active||t.state.showResults&&!t.state.hidden?o("div",{staticClass:"percent-votes",style:{width:t.option.percent?`calc(${t.option.percent}% + 2px)`:"0px"}}):t._e()])])},y=[],x=s(6874),w={name:"nx-poll-option",props:{option:{type:Object,required:!0},showImage:{type:Boolean,default:!0},state:{type:Object,required:!0}},components:{NxPicture:x.Z},methods:{checkOption(e){!this.state.loading&&!this.state.votedOptionId&&this.state.active&&this.$emit("selectOption",e)}}},I=w,p=s(810),P=(0,p.Z)(I,b,y,!1,null,null,null),C=P.exports,c=s(5449),d={getPollData(e){return c.Z.get(`/api/front/poll/${e}`)},votePoll(e,t){return c.Z.post(`/api/front/poll/${e}/vote/${t}`)}},u=((e,t)=>e.map(o=>({id:o.id,title:o.title,votes:o.votes,image:o.image,selected:!!o.selected,percent:t===0?0:Math.round(o.votes*100/t)}))),S=s(7693),l=s.n(S),D=Object.defineProperty,j=Object.defineProperties,M=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable,v=(e,t,o)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))$.call(t,o)&&v(e,o,t[o]);if(h)for(var o of h(t))k.call(t,o)&&v(e,o,t[o]);return e},f=(e,t)=>j(e,M(t)),N={name:"nx-poll",props:{pollId:{type:Number,required:!0},cachedOptions:{type:Array,required:!0},cachedVotes:{type:Number,default:0},cachedActive:{type:Boolean,default:!0},cachedOpen:{type:Boolean,default:!0},startDate:{type:Object,default:null},closeDate:{type:Object,default:null}},components:{NxModalWindow:g.Z,NxButton:O.Z,NxPollOption:C},data(){return{showModal:!1,state:{showResults:!1,loading:!0,pollId:null,options:[],totalVotes:null,active:!0,open:!0,votedOptionId:null,hidden:!1,percent:0}}},computed:f(a(a(a(a({},(0,n.Se)(["site"])),(0,n.Se)(["brickConfig"])),(0,n.Se)(["loginUrl"])),(0,n.Se)("user",["currentUser"])),{pollStartDate(){return l().utc(this.startDate.date).local().format("DD/MM/YYYY - HH:mm")},notStarted(){if(!this.startDate)return null;const e=l()(this.startDate.date);return l()().diff(e)<0},isFinished(){if(!this.closeDate)return null;const e=l()(this.closeDate.date);return l()().diff(e)>0},pollClasses(){return this.brickConfig.pages.poll.classes},checkedOption(){return this.state.options.find(e=>e.selected)},isCheckedOption(){return this.state.options.some(e=>e.selected)},showOptionImages(){return this.state.options.every(e=>!!e.image)}}),created(){this.state.pollId=this.pollId,this.state.options=this.cachedOptions,this.state.totalVotes=this.cachedVotes,this.state.active=this.cachedActive,this.state.open=this.cachedOpen,this.getPollData()},mounted(){this.state.active||(this.state.showResults=!0)},methods:{voteOption(){this.currentUser||this.state.open?this.votePoll
3(this.checkedOption.id):this.showModal=!0},goToLogin(){window.location=this.loginUrl},closeModal(){this.showModal=!1},getPollData(){d.getPollData(this.state.pollId).then(e=>{e&&(this.state.options=u(e.options,e.totalVotes),this.state.totalVotes=e.totalVotes,this.state.active=e.active,this.state.open=e.open,this.state.hidden=e.hidden,this.state.loading=!1,this.checkLocalStoragePoll())}).catch(e=>{console.warn(e)})},selectOptionId(e){const t=this.state.options.find(o=>o.id===e).selected;this.state.options=this.state.options.map(o=>f(a({},o),{selected:!1})),this.state.options.find(o=>o.id===e).selected=!t},voteOptionId(e){this.state.options.find(t=>t.id===e).votes+=1},votePoll(e){return this.state.loading=!0,d.votePoll(this.state.pollId,e).then(()=>{this.voteOptionId(e),this.state.totalVotes+=1,this.state.options=u(this.state.options,this.state.totalVotes),this.state.votedOptionId=e;const t=JSON.parse(localStorage.getItem("bbnx-voted-polls"))||[];t.push({pollId:this.state.pollId,votedOptionId:e}),localStorage.setItem("bbnx-voted-polls",JSON.stringify(t)),this.state.showResults=!0,this.state.loading=!1}).catch(t=>{console.warn(t)})},checkLocalStoragePoll(){const e=JSON.parse(localStorage.getItem("bbnx-voted-polls"));if(e){const t=e.find(o=>o.pollId===this.pollId);t&&(this.voteOptionId(t.votedOptionId),this.selectOptionId(t.votedOptionId),this.state.votedOptionId=t.votedOptionId,this.state.showResults=!0)}}}},R=N,V=(0,p.Z)(R,m,_,!1,null,null,null),Z=V.exports})}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.