PageSourceSearch

https://m.wingu.se/packs/poll-cnVu4Cr1.js

js wingu.se collected 2026-09-29 15:10:43 UTC 4,987 bytes, 2 lines download raw bytes

1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-C21x__mS.js";import{a as n,c as r,s as i}from"./react-intl-DlKP8ATg.js";import{t as a}from"./jsx-runtime-BdxMnOeJ.js";import{i as o,t as s}from"./react-spring_web.modern-C6ohYUSs.js";import"./store-BKpYtGn4.js";import{i as c,o as l}from"./api-CGawW2vu.js";import{a as u,o as d,s as f,t as p}from"./typed_functions-Whap35TF.js";import{J as m,Q as h,tt as g}from"./accounts_typed-AgBHJ2f3.js";import{n as _}from"./modal-CMPL9eyP.js";import{t as v}from"./classnames-CfLRLWYq.js";import{t as y}from"./icon-BNrUFRb_.js";import{i as b}from"./identity_context-CLXpzjnM.js";import{t as x}from"./html-CzpiK0AH.js";import{t as S}from"./check-C3BKu3lm.js";import{t as C}from"./relative_timestamp-BOzlsJjy.js";var w=e(t()),T=e(g()),E=e(v()),D=e=>c(`v1/polls/${e}`),O=(e,t)=>l(`v1/polls/${e}/votes`,{choices:t}),k=p(`poll/importFetched`,(e,{dispatch:t,getState:n})=>{let{poll:r}=e;t(m({polls:[h(r,n().polls[r.id])]}))}),A=u(`poll/vote`,({pollId:e,choices:t})=>O(e,t),async(e,{dispatch:t,discardLoadData:n})=>(await t(k({poll:e})),n)),j=u(`poll/fetch`,({pollId:e})=>D(e),async(e,{dispatch:t})=>{await t(k({poll:e}))}),M=a(),N=i({closed:{id:`poll.closed`,defaultMessage:`Closed`},voted:{id:`poll.voted`,defaultMessage:`You voted for this answer`},votes:{id:`poll.votes`,defaultMessage:`{votes,plural,one{# vote} other{# votes}}`}}),P=e=>e!==null&&new Date(e).getTime()<Date.now(),F=({pollId:e,disabled:t,accountId:i,statusUrl:a})=>{let o=f(t=>t.polls[e]),s=b(),c=r(),l=d(),[u,p]=(0,w.useState)(!1),[m,h]=(0,w.useState)({}),g=(0,w.useMemo)(()=>o?o.expired||P(o.expires_at):!1,[o]),v=(0,w.useMemo)(()=>o?.expires_at?g?c.formatMessage(N.closed):(0,M.jsx)(C,{hasFuture:!0,timestamp:o.expires_at}):null,[g,c,o]),y=(0,w.useMemo)(()=>o?o.voters_count?(0,M.jsx)(n,{id:`poll.total_people`,defaultMessage:`{count, plural, one {# person} other {# people}}`,values:{count:o.voters_count}}):(0,M.jsx)(n,{id:`poll.total_votes`,defaultMessage:`{count, plural, one {# vote} other {# votes}}`,values:{count:o.votes_count}}):null,[o]),x=t||Object.values(m).every(e=>!e),S=(0,w.useCallback)(()=>{x||(s.signedIn?l(A({pollId:e,choices:Object.keys(m)})):l(_({modalType:`INTERACTION`,modalProps:{accountId:i,intent:`vote`,url:a}})))},[x,l,s,e,m,i,a]),T=(0,w.useCallback)(()=>{p(!0)},[]),E=(0,w.useCallback)(()=>{t||l(j({pollId:e}))},[t,l,e]),D=(0,w.useCallback)(e=>{o&&(o.multiple?h(t=>({...t,[e]:!t[e]})):h({[e]:!0}))},[o]);if(!o)return null;let O=o.voted||u||g;return(0,M.jsxs)(`div`,{className:`poll`,children:[(0,M.jsx)(`ul`,{children:o.options.map((e,t)=>(0,M.jsx)(I,{index:t,poll:o,option:e,showResults:O,active:!!m[t],onChange:D},e.title||t))}),(0,M.jsxs)(`div`,{className:`poll__footer`,children:[!O&&(0,M.jsx)(`button`,{className:`button button-secondary`,disabled:x,onClick:S,type:`button`,children:(0,M.jsx)(n,{id:`poll.vote`,defaultMessage:`Vote`})}),!O&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:`poll__link`,onClick:T,type:`button`,children:(0,M.jsx)(n,{id:`poll.reveal`,defaultMessage:`See results`})}),` `,`·`,` `]}),O&&!t&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:`poll__link`,onClick:E,type:`button`,children:(0,M.jsx)(n,{id:`poll.refresh`,defaultMessage:`Refresh`})}),` `,`·`,` `]}),y,o.expires_at&&(0,M.jsxs)(M.Fragment,{children:[` · `,v]})]})]})},I=e=>{let{active:t,lang:n,disabled:i,poll:a,option:c,index:l,showResults:u,onChange:d}=e,f=c.voted||a.own_votes?.includes(l),p=c.translation?.title??c.title,m=r(),h=(0,w.useMemo)(()=>{let e=a.voters_count??a.votes_count;return e===0?0:c.votes_count/e*100},[c,a]),g=(0,w.useMemo)(()=>a.options.filter(e=>e.title!==c.title).every(e=>c.votes_count>=e.votes_count),[a,c]),_=(0,w.useMemo)(()=>{let e=c.translation?.titleHtml??c.titleHtml;return e||=(0,T.default)(p),e},[c,p]),v=(0,w.useCallback)(()=>{d(l)},[l,d]),b=(0,w.useCallback)(e=>{(e.key===`Enter`||e.key===` `)&&(d(l),e.stopPropagation(),e.preventDefault())},[l,d]),C=o({from:{width:`0%`},to:{width:`${h}%`}});return(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`label`,{className:(0,E.default)(`poll__option`,{selectable:!u}),children:[(0,M.jsx)(`input`,{name:`vote-options`,type:a.multiple?`checkbox`:`radio`,value:l,checked:t,onChange:v,disabled:i}),!u&&(0,M.jsx)(`span`,{className:(0,E.default)(`poll__input`,{checkbox:a.multiple,active:t}),tabIndex:0,role:a.multiple?`checkbox`:`radio`,onKeyDown:b,"aria-checked":t,"aria-label":p,lang:n,"data-index":l}),u&&(0,M.jsxs)(`span`,{className:`poll__number`,title:m.formatMessage(N.votes,{votes:c.votes_count}),children:[Math.round(h),`%`]}),(0,M.jsx)(x,{className:`poll__option__text translate`,lang:n,htmlString:_,extraEmojis:a.emojis}),!!f&&(0,M.jsx)(`span`,{className:`poll__voted`,children:(0,M.jsx)(y,{id:`check`,icon:S,className:`poll__voted__mark`,"aria-label":m.formatMessage(N.voted)})})]}),u&&(0,M.jsx)(s.span,{className:(0,E.default)(`poll__chart`,{leading:g}),style:C})]})};export{F as t};
2//# sourceMappingURL=poll-cnVu4Cr1.js.map

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.