import{a as T,r as R,o as B,y as a,z as e,U as n,I as u,P as M,J as f,K as x,C as b,A as m,a8 as D,D as l,S as h,H as w,L as k,ak as q}from"./EchoChannel-CIXLa9Py.js";import z from"./LogoLoader-JEHqUbzn.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const j="/build/assets/Arrow-Right-Small-BUcTD_qa.svg",I={class:"grid lg:grid-cols-3 gap-12"},H={class:"flex col-span-full items-center font-light text-xs tracking-widest"},$={class:"uppercase mr-4"},X={key:0,class:"col-span-full text-sm"},A={key:1,class:"my-8 col-span-full flex justify-center items-center"},E={class:"self-stretch"},F={key:0,class:"p-4 grid grid-rows-[auto_1fr_auto] bg-white h-full"},G={class:"grid grid-cols-[auto_1fr] gap-4"},J=["src"],K={class:"grid content-start"},W={class:"text-lg font-semibold"},Y={class:"tracking-widest text-qorus-grey-dark font-light text-xs uppercase"},Z={key:0,class:"mt-4 tracking-widest text-qorus-grey-dark font-light text-xs uppercase"},Q={class:"mt-4 text-qorus-grey-dark font-light text-sm"},ee=["href","title"],te=["src"],se={key:1,class:"flex gap-4 justify-end"},oe={class:"flex flex-col gap-1 text-qorus-grey-mid"},re=["disabled","onUpdate:modelValue","value","onChange"],ae={class:"text-base font-normal"},le={key:1,class:"p-4 grid grid-rows-[auto_1fr_auto] h-full bg-white"},ne={class:"flex flex-col gap-4"},ie=["src"],ce={class:"grid content-start"},de={class:"text-lg font-semibold"},ue={class:"mt-4 text-qorus-grey-dark font-light text-sm"},pe=["href","title"],he=["src"],ge={key:1,class:"flex gap-4 justify-end"},fe={class:"flex flex-col gap-1 text-qorus-grey-mid"},xe=["disabled","onUpdate:modelValue","value","onChange"],me={class:"text-base font-normal"},ye={key:2,class:"p-4 grid grid-rows-[auto_1fr_auto] bg-white h-full"},_e={class:"flex flex-col gap-4"},ve=["src"],be={class:"grid content-start"},we={class:"text-lg font-semibold"},ke={class:"mt-4 text-qorus-grey-dark font-light text-sm"},qe=["href","title"],je=["src"],Ve={key:1,class:"flex gap-4 justify-end"},Ce={class:"flex flex-col gap-1 text-qorus-grey-mid"},Te=["disabled","onUpdate:modelValue","value","onChange"],Pe={class:"text-base font-normal"},Ne={key:2,class:"flex gap-4 justify-end"},Oe={class:"bg-white max-w-[1200px] w-[min(100%, 1200px)] h-screen lg:h-auto grid"},Se={class:"w-full grid justify-center items-center gap-8 p-8"},Ue={class:"flex flex-col gap-8 mt-8"},Le={key:0,class:"grid grid-cols-[auto_auto_1fr] gap-4 items-center"},Re={class:"w-24 flex justify-center"},Be=["src"],Me={key:0,class:"text-sm"},De={key:1,class:"text-sm"},ze={key:2,class:"text-sm max-w-[128px]"},Ie={class:"flex justify-center gap-4 mt-8"},He={class:"bg-white max-w-[1200px] w-[min(100%, 1200px)] h-screen lg:h-auto grid"},$e={class:"w-full"},Xe={class:"grid justify-center items-center p-8"},Ae={class:"flex justify-center gap-4 mt-8"},Ee=["href"],Fe={class:"bg-white max-w-[1200px] w-[min(100%, 1200px)] h-screen lg:h-auto grid"},Ge={class:"w-full"},Je={class:"grid justify-center items-center p-8"},Ke={class:"font-normal text-base max-w-sm text-center text-qorus-grey-mid mt-4"},We={class:"flex justify-center gap-4 mt-8"},Ye=["href"],tt={__name:"VoteCategory",props:{ableToVote:Boolean,csrf:String,primaryText:String,secondaryText:String,award:Number,title:String,subTitle:String,nextCategory:Number,categoryIndex:Number,category:Object,guest:Boolean},emits:["changeCategory","hasVoted","showGuestPopup","expired"],setup(c,{emit:P}){const p=c,g=P,V=T(!0),_=T(null),o=R({votes:[null,null,null],validationPopupOpened:!1,thankPopupOpened:!1,alreadyVote:!1,errorPopup:!1,errorMessage:""}),v=function(i,s){o.votes=o.votes.map((t,r)=>t!==null&&r!==s&&t.id===i.id?null:t),o.votes.filter(t=>t).length===3&&(o.validationPopupOpened=!0)},N=function(){S()},O=async()=>{try{const s=await(await fetch("/award/"+p.award+"/category/"+p.category.id+"/nominations/",{headers:{"X-Requested-With":"XMLHttpRequest"}})).json();_.value=s.nominations,s.votedNominations&&(o.votes=s.votedNominations.map(t=>{const r=_.value.filter(d=>d.id===t);return r.length?r[0]:null})),o.alreadyVote=!!s.votedNominations,o.alreadyVote&&g("hasVoted",p.categoryIndex)}catch(i){console.error(i)}V.value=!1},S=async function(){try{const i=await fetch("/award/"+p.award+"/vote",{method:"POST",headers:{"X-CSRF-TOKEN":p.csrf,"Content-Type":"application/json"},body:JSON.stringify({categoryId:p.category.id,votes:o.votes})});if(i.status===419)return o.validationPopupOpened=!1,g("expired");if(i.ok)return o.validationPopupOpened=!1,o.alreadyVote=!0,o.thankPopupOpened=!0;const s=await i.json();o.validationPopupOpened=!1,o.errorPopup=!0,o.errorMessage=s.message}catch(i){console.error(i)}},U=function(){o.votes=[null,null,null],o.validationPopupOpened=!1},L=function(){o.thankPopupOpened=!1,g("changeCategory",p.nextCategory),g("hasVoted",p.categoryIndex)},y=function(i){let s="th";return i%10===1&&i%100!==11?s="st":i%10===2&&i%100!==12?s="nd":i%10===3&&i%100!==13&&(s="rd"),s};return B(()=>{O()}),(i,s)=>(l(),a("div",null,[e("div",I,[e("div",H,[e("h2",$,n(c.title),1),s[1]||(s[1]=e("div",{class:"grow h-separator"},null,-1))]),c.subTitle?(l(),a("p",X,n(c.subTitle),1)):u("",!0),V.value?(l(),a("div",A,[M(z)])):(l(!0),a(f,{key:2},x(_.value,t=>(l(),a("div",E,[t.type==="contact"?(l(),a("div",F,[e("div",G,[e("img",{class:"self-start w-24 h-24 rounded-full object-cover",src:t.imageUrl,alt:""},null,8,J),e("div",K,[e("strong",W,n(t.fullName),1),e("span",Y,n(t.jobTitle),1),t.accountName?(l(),a("span",Z,n(t.accountName),1)):u("",!0)])]),e("div",Q,n(t.cardDescription),1),t.url?(l(),a("a",{key:0,href:t.url,title:t.urlTitle??"Nominee Content Page",target:"_blank",class:"my-4 text-sm font-semibold text-qorus-purple hover:underline cursor-pointer flex items-center gap-2"},[s[2]||(s[2]=h(" Read more ")),e("img",{src:w(j),class:"h-4"},null,8,te)],8,ee)):u("",!0),c.ableToVote?(l(),a("div",se,[(l(),a(f,null,x([0,1,2],r=>e("label",oe,[k(e("input",{class:"w-6 h-6 cursor-pointer accent-qorus-purple",disabled:o.alreadyVote,type:"radio","onUpdate:modelValue":d=>o.votes[r]=d,value:t,onChange:d=>v(t,r)},null,40,re),[[q,o.votes[r]]]),e("span",ae,[h(n(r+1),1),e("sup",null,n(y(r+1)),1)])])),64))])):u("",!0)])):u("",!0),t.type==="account"?(l(),a("div",le,[e("div",ne,[e("img",{class:"w-48 h-24 object-contain self-center",src:t.imageUrl,alt:""},null,8,ie),e("div",ce,[e("strong",de,n(t.name),1)])]),e("div",ue,n(t.cardDescription),1),t.url?(l(),a("a",{key:0,href:t.url,title:t.urlTitle??"Nomination Content Page",target:"_blank",class:"my-4 text-sm font-semibold text-qorus-purple hover:underline cursor-pointer flex items-center gap-2"},[s[3]||(s[3]=h(" Read more ")),e("img",{src:w(j),class:"h-4"},null,8,he)],8,pe)):u("",!0),c.ableToVote?(l(),a("div",ge,[(l(),a(f,null,x([0,1,2],r=>e("label",fe,[k(e("input",{class:"w-6 h-6 cursor-pointer accent-qorus-purple",disabled:o.alreadyVote,type:"radio","onUpdate:modelValue":d=>o.votes[r]=d,value:t,onChange:d=>v(t,r)},null,40,xe),[[q,o.votes[r]]]),e("span",me,[h(n(r+1),1),e("sup",null,n(y(r+1)),1)])])),64))])):u("",!0)])):u("",!0),t.type==="innovation"?(l(),a("div",ye,[e("div",_e,[e("img",{class:"w-48 h-24 object-contain self-center",src:t.imageUrl,alt:""},null,8,ve),e("div",be,[e("strong",we,n(t.name),1)])]),e("div",ke,n(t.cardDescription),1),t.url?(l(),a("a",{key:0,href:t.url,title:t.urlTitle??"Nomination Content Page",target:"_blank",class:"my-4 text-sm font-semibold text-qorus-purple hover:underline cursor-pointer flex items-center gap-2"},[s[4]||(s[4]=h(" Read more ")),e("img",{src:w(j),class:"h-4"},null,8,je)],8,qe)):u("",!0),c.ableToVote&&!c.guest?(l(),a("div",Ve,[(l(),a(f,null,x([0,1,2],r=>e("label",Ce,[k(e("input",{class:"w-6 h-6 cursor-pointer accent-qorus-purple",disabled:o.alreadyVote,type:"radio","onUpdate:modelValue":d=>o.votes[r]=d,value:t,onChange:d=>v(t,r)},null,40,Te),[[q,o.votes[r]]]),e("span",Pe,[h(n(r+1),1),e("sup",null,n(y(r+1)),1)])])),64))])):c.ableToVote&&c.guest?(l(),a("div",Ne,[e("button",{onClick:s[0]||(s[0]=r=>g("showGuestPopup")),class:"py-2 px-4 font-semibold inline-flex text-base transition-all items-center border-2 border-qorus-purple text-qorus-purple hover:bg-qorus-purple hover:text-white"},"Vote")])):u("",!0)])):u("",!0)]))),256))]),e("div",{class:m(["fixed inset-0 bg-black/50 items-center justify-center z-30",[o.validationPopupOpened?"grid":"hidden"]])},[e("div",Oe,[e("div",Se,[e("div",null,[s[5]||(s[5]=e("h3",{class:"text-xl font-semibold text-center"},"Happy with your podium?",-1)),s[6]||(s[6]=e("p",{class:"font-normal text-base max-w-sm text-center text-qorus-grey-mid mt-4"}," Have a last look because once cast, your vote can’t be changed ",-1)),e("ol",Ue,[(l(!0),a(f,null,x(o.votes,(t,r)=>{var d,C;return l(),a("li",null,[t?(l(),a("p",Le,[e("span",{class:m(["text-4xl font-normal w-12",[r===0?c.primaryText:"",r===1?"text-qorus-grey-mid":"",r===2?c.secondaryText:""]])},[h(n(r+1),1),e("sup",null,n(y(r+1)),1)],2),e("figure",Re,[e("img",{class:m([t.type==="contact"?"w-12 h-12 rounded-full object-cover":"w-24 h-12 object-contain"]),src:t.imageUrl,alt:""},null,10,Be)]),t.type==="contact"?(l(),a("span",Me,n(t.fullName),1)):t.type==="account"?(l(),a("span",De,n(t.name),1)):t.type==="innovation"&&((d=t==null?void 0:t.accounts)==null?void 0:d.length)>0?(l(),a("span",ze,n((C=t.accounts[0])==null?void 0:C.name),1)):u("",!0)])):u("",!0)])}),256))]),e("div",Ie,[e("button",{onClick:b(U,["prevent"]),class:"text-base justify-center grow font-light inline-flex items-center px-4 py-1 text-qorus-purple border-2 border-qorus-purple hover:text-white hover:bg-qorus-purple"}," Cancel "),e("button",{onClick:b(N,["prevent"]),class:"text-base justify-center grow font-light inline-flex items-center px-4 py-1 text-white bg-qorus-purple border-2 border-qorus-purple hover:brightness-90"}," Cast vote ")])])])])],2),e("div",{class:m(["fixed inset-0 bg-black/50 items-center justify-center z-30",[o.thankPopupOpened?"grid":"hidden"]])},[e("div",He,[e("div",$e,[e("div",Xe,[s[7]||(s[7]=D('<h3 class="text-xl font-semibold text-center">Thanks for voting!</h3><div class="flex justify-self-center items-center justify-center w-16 h-16 rounded-full bg-qorus-purple mt-4"><svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M26.8038 5L9.97685 20.675L3.19623 14.774L1.875 16.069C2.53561 16.7899 9.55306 24.5357 9.97685 25L11.1111 23.8271L28.125 6.29505L26.8038 5Z" fill="white"></path></svg></div><p class="font-normal text-base max-w-sm text-center text-qorus-grey-mid mt-4"> Your category vote was counted </p>',3)),e("div",Ae,[e("a",{href:"/award/"+c.award,class:"text-base justify-center grow font-light inline-flex items-center px-4 py-1 text-qorus-purple border-2 border-qorus-purple hover:text-white hover:bg-qorus-purple"}," Back to awards ",8,Ee),e("button",{onClick:b(L,["prevent"]),class:"text-base justify-center grow font-light inline-flex items-center px-4 py-1 text-white bg-qorus-purple border-2 border-qorus-purple hover:brightness-90"}," Next Category ")])])])])],2),e("div",{class:m(["fixed inset-0 bg-black/50 items-center justify-center z-30",[o.errorPopup?"grid":"hidden"]])},[e("div",Fe,[e("div",Ge,[e("div",Je,[s[9]||(s[9]=e("h3",{class:"text-xl font-semibold text-center"},"There is an error with your vote",-1)),e("p",Ke,n(o.errorMessage),1),e("div",We,[e("a",{href:"/award/"+c.award,class:"text-base justify-center grow font-light inline-flex items-center px-4 py-1 text-qorus-purple border-2 border-qorus-purple hover:text-white hover:bg-qorus-purple"}," Back to awards ",8,Ye),s[8]||(s[8]=e("a",{href:"javascript:window.location.reload()",class:"text-base justify-center grow font-light inline-flex items-center px-4 py-1 text-white bg-qorus-purple border-2 border-qorus-purple hover:brightness-90"}," Refresh ",-1))])])])])],2)]))}};export{tt as default};