define("discourse/plugins/poll/discourse/components/modal/poll-breakdown",["exports","@ember/component","@ember/object","@ember/service","@ember/string","@ember/template","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/load-script","discourse-common/utils/decorators","discourse-i18n","@ember/template-factory"],(function(e,t,l,o,i,n,s,r,a,p,u,c){"use strict"
var d,h,b,g,m
function f(e,t,l){var o
return(t="symbol"==typeof(o=function(e,t){if("object"!=typeof e||!e)return e
var l=e[Symbol.toPrimitive]
if(void 0!==l){var o=l.call(e,t||"default")
if("object"!=typeof o)return o
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?o:String(o))in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function v(e,t,l,o,i){var n={}
return Object.keys(o).forEach((function(e){n[e]=o[e]})),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=l.slice().reverse().reduce((function(l,o){return o(e,t,l)||l}),n),i&&void 0!==n.initializer&&(n.value=n.initializer?n.initializer.call(i):void 0,n.initializer=void 0),void 0===n.initializer&&(Object.defineProperty(e,t,n),n=null),n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const y=(0,c.createTemplateFactory)({id:"6D02y51O",block:'[[[8,[39,0],[[24,0,"poll-breakdown has-tabs"]],[["@title","@closeModal"],[[28,[37,1],["poll.breakdown.title"],null],[30,1]]],[["headerBelowTitle","body"],[[[[1,"\\n    "],[10,"ul"],[14,0,"modal-tabs"],[12],[1,"\\n      "],[11,"li"],[16,0,[28,[37,2],["modal-tab percentage",[52,[28,[37,4],[[30,0,["displayMode"]],"percentage"],null],"is-active"]],null]],[4,[38,5],["click",[28,[37,6],[[28,[37,7],[[30,0,["displayMode"]]],null],"percentage"],null]],null],[12],[1,[28,[35,1],["poll.breakdown.percentage"],null]],[13],[1,"\\n      "],[11,"li"],[16,0,[28,[37,2],["modal-tab count",[52,[28,[37,4],[[30,0,["displayMode"]],"count"],null],"is-active"]],null]],[4,[38,5],["click",[28,[37,6],[[28,[37,7],[[30,0,["displayMode"]]],null],"count"],null]],null],[12],[1,[28,[35,1],["poll.breakdown.count"],null]],[13],[1,"\\n    "],[13],[1,"\\n  "]],[]],[[[1,"\\n    "],[10,0],[14,0,"poll-breakdown-sidebar"],[12],[1,"\\n      "],[10,2],[14,0,"poll-breakdown-title"],[12],[1,"\\n        "],[1,[30,0,["title"]]],[1,"\\n      "],[13],[1,"\\n\\n      "],[10,0],[14,0,"poll-breakdown-total-votes"],[12],[1,[28,[35,1],["poll.breakdown.votes"],[["count"],[[30,0,["model","poll","voters"]]]]]],[13],[1,"\\n\\n      "],[10,"ul"],[14,0,"poll-breakdown-options"],[12],[1,"\\n"],[42,[28,[37,9],[[28,[37,9],[[30,0,["model","poll","options"]]],null]],null],null,[[[1,"          "],[8,[39,10],null,[["@option","@index","@totalVotes","@optionsCount","@displayMode","@highlightedOption","@onMouseOver","@onMouseOut"],[[30,2],[30,3],[30,0,["totalVotes"]],[30,0,["model","poll","options","length"]],[30,0,["displayMode"]],[30,0,["highlightedOption"]],[28,[37,6],[[28,[37,7],[[30,0,["highlightedOption"]]],null],[30,3]],null],[28,[37,6],[[28,[37,7],[[30,0,["highlightedOption"]]],null],null],null]]],null],[1,"\\n"]],[2,3]],null],[1,"      "],[13],[1,"\\n    "],[13],[1,"\\n\\n    "],[10,0],[14,0,"poll-breakdown-body"],[12],[1,"\\n      "],[10,0],[14,0,"poll-breakdown-body-header"],[12],[1,"\\n        "],[10,"label"],[14,0,"poll-breakdown-body-header-label"],[12],[1,[28,[35,1],["poll.breakdown.breakdown"],null]],[13],[1,"\\n\\n        "],[8,[39,11],[[24,0,"poll-breakdown-dropdown"]],[["@content","@value","@nameProperty","@onChange"],[[30,0,["groupableUserFields"]],[30,0,["groupedBy"]],"label",[28,[37,12],[[30,0],[30,0,["setGrouping"]]],null]]],null],[1,"\\n      "],[13],[1,"\\n\\n      "],[10,0],[14,0,"poll-breakdown-charts"],[12],[1,"\\n"],[42,[28,[37,9],[[28,[37,9],[[30,0,["charts"]]],null]],null],null,[[[1,"          "],[8,[39,13],null,[["@group","@options","@displayMode","@highlightedOption","@setHighlightedOption"],[[28,[37,14],[[30,4],"group"],null],[28,[37,14],[[30,4],"options"],null],[30,0,["displayMode"]],[30,0,["highlightedOption"]],[28,[37,6],[[28,[37,7],[[30,0,["highlightedOption"]]],null]],null]]],null],[1,"\\n"]],[4]],null],[1,"      "],[13],[1,"\\n    "],[13],[1,"\\n  "]],[]]]]]],["@closeModal","option","index","chart"],false,["d-modal","i18n","concat-class","if","eq","on","fn","mut","each","-track-array","poll-breakdown-option","combo-box","action","poll-breakdown-chart","get"]]',moduleName:"discourse/plugins/poll/discourse/components/modal/poll-breakdown.hbs",isStrictMode:!1})
let _=e.default=(d=(0,p.default)("model.poll.title","model.post.topic.title"),h=(0,p.default)("model.groupableUserFields"),b=(0,p.default)("model.poll.options"),g=class extends t.default{constructor(){var e,t,l,o
super(...arguments),e=this,t="dialog",o=this,(l=m)&&Object.defineProperty(e,t,{enumerable:l.enumerable,configurable:l.configurable,writable:l.writable,value:l.initializer?l.initializer.call(o):void 0}),f(this,"model",null),f(this,"charts",null),f(this,"groupedBy",null),f(this,"highlightedOption",null),f(this,"displayMode","percentage")}init(){this.set("groupedBy",this.model.groupableUserFields[0]),(0,a.default)("/javascripts/Chart.min.js").then((()=>(0,a.default)("/javascripts/chartjs-plugin-datalabels.min.js"))).then((()=>{this.fetchGroupedPollData()})),super.init(...arguments)}title(e,t){return e?(0,n.htmlSafe)(e):t}groupableUserFields(e){return e.map((e=>{const t=e.split("_").filter(Boolean)
return t.length>1&&(t[0]=(0,i.classify)(t[0])),{id:e,label:t.join(" ")}}))}totalVotes(e){return e.reduce(((e,t)=>e+t.votes),0)}fetchGroupedPollData(){return(0,s.ajax)("/polls/grouped_poll_results.json",{data:{post_id:this.model.post.id,poll_name:this.model.poll.name,user_field_name:this.groupedBy}}).catch((e=>{e?(0,r.popupAjaxError)(e):this.dialog.alert(u.default.t("poll.error_while_fetching_voters"))})).then((e=>{this.isDestroying||this.isDestroyed||this.set("charts",e.grouped_results)}))}setGrouping(e){this.set("groupedBy",e),this.fetchGroupedPollData()}onSelectPanel(e){this.set("displayMode",e.id)}},m=v(g.prototype,"dialog",[o.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),v(g.prototype,"title",[d],Object.getOwnPropertyDescriptor(g.prototype,"title"),g.prototype),v(g.prototype,"groupableUserFields",[h],Object.getOwnPropertyDescriptor(g.prototype,"groupableUserFields"),g.prototype),v(g.prototype,"totalVotes",[b],Object.getOwnPropertyDescriptor(g.prototype,"totalVotes"),g.prototype),v(g.prototype,"setGrouping",[l.action],Object.getOwnPropertyDescriptor(g.prototype,"setGrouping"),g.prototype),v(g.prototype,"onSelectPanel",[l.action],Object.getOwnPropertyDescriptor(g.prototype,"onSelectPanel"),g.prototype),g);(0,t.setComponentTemplate)(y,_)})),define("discourse/plugins/poll/discourse/components/modal/poll-ui-builder",["exports","@ember/component","@ember/object","@ember/object/computed","@ember/service","@ember-decorators/object","discourse-common/utils/decorators","discourse-i18n","@ember/template-factory"],(function(e,t,l,o,i,n,s,r,a){"use strict"
var p,u,c,d,h,b,g,m,f,v,y,_,w,O,P,x,M,C,k
function j(e,t,l,o){l&&Object.defineProperty(e,t,{enumerable:l.enumerable,configurable:l.configurable,writable:l.writable,value:l.initializer?l.initializer.call(o):void 0})}function T(e,t,l){var o
return(t="symbol"==typeof(o=function(e,t){if("object"!=typeof e||!e)return e
var l=e[Symbol.toPrimitive]
if(void 0!==l){var o=l.call(e,t||"default")
if("object"!=typeof o)return o
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?o:String(o))in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function S(e,t,l,o,i){var n={}
return Object.keys(o).forEach((function(e){n[e]=o[e]})),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=l.slice().reverse().reduce((function(l,o){return o(e,t,l)||l}),n),i&&void 0!==n.initializer&&(n.value=n.initializer?n.initializer.call(i):void 0,n.initializer=void 0),void 0===n.initializer&&(Object.defineProperty(e,t,n),n=null),n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.REGULAR_POLL_TYPE=e.PIE_CHART_TYPE=e.NUMBER_POLL_TYPE=e.MULTIPLE_POLL_TYPE=e.BAR_CHART_TYPE=void 0
const N=(0,a.createTemplateFactory)({id:"dEpF9Aro",block:'[[[8,[39,0],[[24,0,"poll-ui-builder"]],[["@title","@closeModal","@inline"],[[28,[37,1],["poll.ui_builder.title"],null],[30,1],[30,2]]],[["body","footer"],[[[[1,"\\n    "],[10,0],[14,0,"input-group poll-type"],[12],[1,"\\n      "],[11,3],[24,6,""],[16,0,[29,["poll-type-value poll-type-value-regular\\n          ",[52,[30,0,["isRegular"]],"active"]]]],[4,[38,3],["click",[28,[37,4],[[30,0,["updatePollType"]],"regular"],null]],null],[12],[1,"\\n        "],[1,[28,[35,1],["poll.ui_builder.poll_type.regular"],null]],[1,"\\n      "],[13],[1,"\\n\\n      "],[11,3],[24,6,""],[16,0,[29,["poll-type-value poll-type-value-multiple\\n          ",[52,[30,0,["isMultiple"]],"active"]]]],[4,[38,3],["click",[28,[37,4],[[30,0,["updatePollType"]],"multiple"],null]],null],[12],[1,"\\n        "],[1,[28,[35,1],["poll.ui_builder.poll_type.multiple"],null]],[1,"\\n      "],[13],[1,"\\n\\n"],[41,[30,0,["showNumber"]],[[[1,"        "],[11,3],[24,6,""],[16,0,[29,["poll-type-value poll-type-value-number\\n            ",[52,[30,0,["isNumber"]],"active"]]]],[4,[38,3],["click",[28,[37,4],[[30,0,["updatePollType"]],"number"],null]],null],[12],[1,"\\n          "],[1,[28,[35,1],["poll.ui_builder.poll_type.number"],null]],[1,"\\n        "],[13],[1,"\\n"]],[]],null],[1,"    "],[13],[1,"\\n\\n"],[41,[30,0,["showAdvanced"]],[[[1,"      "],[10,0],[14,0,"input-group poll-title"],[12],[1,"\\n        "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_title.label"],null]],[13],[1,"\\n        "],[8,[39,5],null,[["@value"],[[30,0,["pollTitle"]]]],null],[1,"\\n      "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[51,[30,0,["isNumber"]]],[[[1,"      "],[10,0],[14,0,"poll-options"],[12],[1,"\\n"],[41,[30,0,["showAdvanced"]],[[[1,"          "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_options.label"],null]],[13],[1,"\\n          "],[8,[39,7],[[4,[38,3],["input",[30,0,["onOptionsTextChange"]]],null]],[["@value"],[[30,0,["pollOptionsText"]]]],null],[1,""],[41,[30,0,["showMinNumOfOptionsValidation"]],[[[41,[51,[30,0,["minNumOfOptionsValidation","ok"]]],[[[1,"              "],[8,[39,8],null,[["@validation"],[[30,0,["minNumOfOptionsValidation"]]]],null],[1,"\\n"]],[]],null]],[]],null]],[]],[[[42,[28,[37,10],[[28,[37,10],[[30,0,["pollOptions"]]],null]],null],null,[[[1,"            "],[10,0],[14,0,"input-group poll-option-value"],[12],[1,"\\n              "],[11,"input"],[16,2,[30,3,["value"]]],[24,4,"text"],[4,[38,11],null,null],[4,[38,3],["input",[28,[37,4],[[30,0,["updateValue"]],[30,3]],null]],null],[4,[38,3],["keydown",[28,[37,4],[[30,0,["onInputKeydown"]],[30,4]],null]],null],[12],[13],[1,"\\n"],[41,[30,0,["canRemoveOption"]],[[[1,"                "],[8,[39,12],null,[["@icon","@action"],["trash-alt",[28,[37,4],[[30,0,["removeOption"]],[30,3]],null]]],null],[1,"\\n"]],[]],null],[1,"            "],[13],[1,"\\n"]],[3,4]],null],[1,"\\n          "],[10,0],[14,0,"poll-option-controls"],[12],[1,"\\n            "],[8,[39,12],[[24,0,"btn-default poll-option-add"]],[["@icon","@label","@action"],["plus","poll.ui_builder.poll_options.add",[28,[37,4],[[30,0,["addOption"]],-1],null]]],null],[1,"\\n"],[41,[28,[37,13],[[30,0,["showMinNumOfOptionsValidation"]],[28,[37,14],[[30,0,["minNumOfOptionsValidation","ok"]]],null]],null],[[[1,"              "],[8,[39,8],null,[["@validation"],[[30,0,["minNumOfOptionsValidation"]]]],null],[1,"\\n"]],[]],null],[1,"          "],[13],[1,"\\n"]],[]]],[1,"      "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[51,[30,0,["isRegular"]]],[[[1,"      "],[10,0],[14,0,"options"],[12],[1,"\\n        "],[10,0],[14,0,"input-group poll-number"],[12],[1,"\\n          "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_config.min"],null]],[13],[1,"\\n          "],[8,[39,5],[[24,0,"poll-options-min"],[24,"min","1"]],[["@type","@value"],["number",[30,0,["pollMin"]]]],null],[1,"\\n        "],[13],[1,"\\n\\n        "],[10,0],[14,0,"input-group poll-number"],[12],[1,"\\n          "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_config.max"],null]],[13],[1,"\\n          "],[8,[39,5],[[24,0,"poll-options-max"],[24,"min","1"]],[["@type","@value"],["number",[30,0,["pollMax"]]]],null],[1,"\\n        "],[13],[1,"\\n\\n"],[41,[30,0,["isNumber"]],[[[1,"          "],[10,0],[14,0,"input-group poll-number"],[12],[1,"\\n            "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_config.step"],null]],[13],[1,"\\n            "],[8,[39,5],[[24,"min","1"],[24,0,"poll-options-step"]],[["@type","@value"],["number",[30,0,["pollStep"]]]],null],[1,"\\n          "],[13],[1,"\\n"]],[]],null],[1,"      "],[13],[1,"\\n\\n"],[41,[51,[30,0,["minMaxValueValidation","ok"]]],[[[1,"        "],[8,[39,8],null,[["@validation"],[[30,0,["minMaxValueValidation"]]]],null],[1,"\\n"]],[]],null]],[]],null],[1,"\\n    "],[10,0],[14,0,"input-group poll-public"],[12],[1,"\\n      "],[8,[39,15],[[24,0,"poll-toggle-public"],[4,[38,3],["click",[30,0,["togglePublic"]]],null]],[["@state","@label"],[[30,0,["publicPoll"]],"poll.ui_builder.poll_public.label"]],null],[1,"\\n    "],[13],[1,"\\n\\n"],[41,[30,0,["showAdvanced"]],[[[1,"      "],[10,0],[14,0,"input-group poll-allowed-groups"],[12],[1,"\\n        "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_groups.label"],null]],[13],[1,"\\n        "],[8,[39,16],null,[["@content","@value","@onChange","@labelProperty","@valueProperty"],[[30,0,["siteGroups"]],[30,0,["pollGroups"]],[28,[37,17],[[30,0],[28,[37,18],[[30,0,["pollGroups"]]],null]],null],"name","name"]],null],[1,"\\n      "],[13],[1,"\\n\\n      "],[10,0],[14,0,"input-group poll-date"],[12],[1,"\\n        "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.automatic_close.label"],null]],[13],[1,"\\n        "],[8,[39,19],null,[["@date","@onChange","@clearable","@useGlobalPickerContainer"],[[30,0,["pollAutoClose"]],[28,[37,17],[[30,0],[28,[37,18],[[30,0,["pollAutoClose"]]],null]],null],true,true]],null],[1,"\\n      "],[13],[1,"\\n\\n      "],[10,0],[14,0,"input-group poll-select"],[12],[1,"\\n        "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_result.label"],null]],[13],[1,"\\n        "],[8,[39,20],[[24,0,"poll-result"]],[["@content","@value","@valueProperty","@onChange"],[[30,0,["pollResults"]],[30,0,["pollResult"]],"value",[28,[37,17],[[30,0],[28,[37,18],[[30,0,["pollResult"]]],null]],null]]],null],[1,"\\n      "],[13],[1,"\\n\\n"],[41,[51,[30,0,["isNumber"]]],[[[1,"        "],[10,0],[14,0,"input-group poll-select column"],[12],[1,"\\n          "],[10,"label"],[14,0,"input-group-label"],[12],[1,[28,[35,1],["poll.ui_builder.poll_chart_type.label"],null]],[13],[1,"\\n\\n          "],[10,0],[14,0,"radio-group"],[12],[1,"\\n            "],[8,[39,21],null,[["@id","@name","@value","@selection"],["poll-chart-type-bar","poll-chart-type","bar",[30,0,["chartType"]]]],null],[1,"\\n            "],[10,"label"],[14,"for","poll-chart-type-bar"],[12],[1,[28,[35,22],["chart-bar"],null]],[1,"\\n              "],[1,[28,[35,1],["poll.ui_builder.poll_chart_type.bar"],null]],[13],[1,"\\n          "],[13],[1,"\\n\\n          "],[10,0],[14,0,"radio-group"],[12],[1,"\\n            "],[8,[39,21],null,[["@id","@name","@value","@selection"],["poll-chart-type-pie","poll-chart-type","pie",[30,0,["chartType"]]]],null],[1,"\\n            "],[10,"label"],[14,"for","poll-chart-type-pie"],[12],[1,[28,[35,22],["chart-pie"],null]],[1,"\\n              "],[1,[28,[35,1],["poll.ui_builder.poll_chart_type.pie"],null]],[13],[1,"\\n          "],[13],[1,"\\n        "],[13],[1,"\\n"]],[]],null]],[]],null],[1,"  "]],[]],[[[1,"\\n    "],[8,[39,12],[[24,0,"btn-primary insert-poll"]],[["@action","@icon","@label","@disabled"],[[30,0,["insertPoll"]],"chart-bar","poll.ui_builder.insert",[30,0,["disableInsert"]]]],null],[1,"\\n\\n    "],[8,[39,12],[[24,0,"btn-flat"]],[["@label","@action"],["cancel",[30,1]]],null],[1,"\\n\\n    "],[8,[39,12],[[24,0,"btn-default show-advanced"]],[["@action","@icon","@title"],[[30,0,["toggleAdvanced"]],"cog",[52,[30,0,["showAdvanced"]],"poll.ui_builder.hide_advanced","poll.ui_builder.show_advanced"]]],null],[1,"\\n\\n  "]],[]]]]]],["@closeModal","@inline","option","index"],false,["d-modal","i18n","if","on","fn","input","unless","textarea","input-tip","each","-track-array","auto-focus","d-button","and","not","d-toggle-switch","group-chooser","action","mut","date-time-input","combo-box","radio-button","d-icon"]]',moduleName:"discourse/plugins/poll/discourse/components/modal/poll-ui-builder.hbs",isStrictMode:!1}),E=e.BAR_CHART_TYPE="bar",R=e.PIE_CHART_TYPE="pie",A=e.REGULAR_POLL_TYPE="regular",V=e.NUMBER_POLL_TYPE="number",D=e.MULTIPLE_POLL_TYPE="multiple",L="always"
let I=e.default=(p=(0,o.or)("showAdvanced","isNumber"),u=(0,o.gt)("pollOptions.length",1),c=(0,s.default)("currentUser.staff"),d=(0,s.default)("pollType"),h=(0,s.default)("pollType"),b=(0,s.default)("pollType"),g=(0,s.default)("pollOptions.@each.value"),m=(0,s.default)("site.groups"),f=(0,s.default)("chartType","pollType"),v=(0,n.observes)("pollType","pollOptionsCount"),y=(0,s.default)("pollType","pollResult","publicPoll","pollTitle","pollOptions.@each.value","pollMin","pollMax","pollStep","pollGroups","pollAutoClose","chartType"),_=(0,s.default)("isNumber","pollOptionsCount"),w=(0,s.default)("pollOptions.@each.value"),O=(0,s.default)("isMultiple","pollOptionsCount","isNumber","pollMin","pollMax","pollStep"),P=(0,s.default)("minMaxValueValidation","minNumOfOptionsValidation"),x=class extends t.default{constructor(){super(...arguments),j(this,"siteSettings",M,this),T(this,"showAdvanced",!1),T(this,"pollType",A),T(this,"pollTitle",void 0),T(this,"pollOptions",[l.default.create({value:""})]),T(this,"pollOptionsText",""),T(this,"pollMin",1),T(this,"pollMax",2),T(this,"pollStep",1),T(this,"pollGroups",void 0),T(this,"pollAutoClose",void 0),T(this,"pollResult",L),T(this,"chartType",E),T(this,"publicPoll",this.siteSettings.poll_default_public),j(this,"showNumber",C,this),j(this,"canRemoveOption",k,this)}pollResults(e){const t=[{name:r.default.t("poll.ui_builder.poll_result.always"),value:L},{name:r.default.t("poll.ui_builder.poll_result.vote"),value:"on_vote"},{name:r.default.t("poll.ui_builder.poll_result.closed"),value:"on_close"}]
return e&&t.push({name:r.default.t("poll.ui_builder.poll_result.staff"),value:"staff_only"}),t}isRegular(e){return e===A}isNumber(e){return e===V}isMultiple(e){return e===D}pollOptionsCount(e){return(e||[]).filter((e=>e.value.length>0)).length}siteGroups(e){return e.filter((e=>0!==e.id))}isPie(e,t){return t!==V&&e===R}_setPollMinMax(){this.isMultiple?((this.pollMin<=0||this.pollMin>=this.pollMax||this.pollMin>=this.pollOptionsCount)&&this.set("pollMin",this.pollOptionsCount>0?1:0),(this.pollMax<=0||this.pollMin>=this.pollMax||this.pollMax>this.pollOptionsCount)&&this.set("pollMax",this.pollOptionsCount)):this.isNumber&&this.set("pollMax",this.siteSettings.poll_maximum_options)}pollOutput(e,t,l,o,i,n,s,r,a,p,u){let c="[poll",d=""
const h=this.model.toolbarEvent.getText().match(/\[poll(\s+name=[^\s\]]+)*.*\]/gim)
h&&(c+=` name=poll${h.length+1}`)
let b=r
return b<1&&(b=1),e&&(c+=` type=${e}`),t&&(c+=` results=${t}`),n&&e!==A&&(c+=` min=${n}`),s&&e!==A&&(c+=` max=${s}`),e===V&&(c+=` step=${b}`),c+=" public="+(l?"true":"false"),u&&e!==V&&(c+=` chartType=${u}`),a&&a.length>0&&(c+=` groups=${a}`),p&&(c+=` close=${p.toISOString()}`),c+="]",d+=`${c}\n`,o&&(d+=`# ${o.trim()}\n`),i.length>0&&e!==V&&i.forEach((e=>{e.value.length>0&&(d+=`* ${e.value.trim()}\n`)})),d+="[/poll]\n",d}minNumOfOptionsValidation(e,t){if(!e){if(t<1)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.options_min_count")})
if(t>this.siteSettings.poll_maximum_options)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.options_max_count",{count:this.siteSettings.poll_maximum_options})})}return l.default.create({ok:!0})}showMinNumOfOptionsValidation(e){return 1!==e.length||""!==e[0].value}minMaxValueValidation(e,t,o,i,n,s){if(i=parseInt(i,10)||0,n=parseInt(n,10)||0,s=parseInt(s,10)||0,i<0)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.invalid_min_value")})
if(n<0||e&&n>t)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.invalid_max_value")})
if(i>n)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.invalid_values")})
if(o){if(s<1)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.min_step_value")})
const e=(n-i+1)/s
if(e<1)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.options_min_count")})
if(e>this.siteSettings.poll_maximum_options)return l.default.create({failed:!0,reason:r.default.t("poll.ui_builder.help.options_max_count",{count:this.siteSettings.poll_maximum_options})})}return l.default.create({ok:!0})}disableInsert(e,t){return!e.ok||!t.ok}_comboboxOptions(e,t){return[...Array(t-e).keys()].map((t=>({value:t+e,name:t+e})))}onOptionsTextChange(e){this.set("pollOptions",e.target.value.split("\n").map((e=>l.default.create({value:e}))))}insertPoll(){this.model.toolbarEvent.addText(this.pollOutput),this.closeModal()}toggleAdvanced(){this.toggleProperty("showAdvanced"),this.showAdvanced&&this.set("pollOptionsText",this.pollOptions.map((e=>e.value)).join("\n"))}updateValue(e,t){e.set("value",t.target.value)}onInputKeydown(e,t){"Enter"===t.key&&(t.preventDefault(),t.stopPropagation(),""!==t.target.value&&this.addOption(e+1))}addOption(e){-1===e&&(e=this.pollOptions.length)
const t=l.default.create({value:""})
this.pollOptions.insertAt(e,t)}removeOption(e){this.pollOptions.removeObject(e)}updatePollType(e,t){t?.preventDefault(),this.set("pollType",e)}togglePublic(){this.set("publicPoll",!this.publicPoll)}},M=S(x.prototype,"siteSettings",[i.inject],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),C=S(x.prototype,"showNumber",[p],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),k=S(x.prototype,"canRemoveOption",[u],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),S(x.prototype,"pollResults",[c],Object.getOwnPropertyDescriptor(x.prototype,"pollResults"),x.prototype),S(x.prototype,"isRegular",[d],Object.getOwnPropertyDescriptor(x.prototype,"isRegular"),x.prototype),S(x.prototype,"isNumber",[h],Object.getOwnPropertyDescriptor(x.prototype,"isNumber"),x.prototype),S(x.prototype,"isMultiple",[b],Object.getOwnPropertyDescriptor(x.prototype,"isMultiple"),x.prototype),S(x.prototype,"pollOptionsCount",[g],Object.getOwnPropertyDescriptor(x.prototype,"pollOptionsCount"),x.prototype),S(x.prototype,"siteGroups",[m],Object.getOwnPropertyDescriptor(x.prototype,"siteGroups"),x.prototype),S(x.prototype,"isPie",[f],Object.getOwnPropertyDescriptor(x.prototype,"isPie"),x.prototype),S(x.prototype,"_setPollMinMax",[v],Object.getOwnPropertyDescriptor(x.prototype,"_setPollMinMax"),x.prototype),S(x.prototype,"pollOutput",[y],Object.getOwnPropertyDescriptor(x.prototype,"pollOutput"),x.prototype),S(x.prototype,"minNumOfOptionsValidation",[_],Object.getOwnPropertyDescriptor(x.prototype,"minNumOfOptionsValidation"),x.prototype),S(x.prototype,"showMinNumOfOptionsValidation",[w],Object.getOwnPropertyDescriptor(x.prototype,"showMinNumOfOptionsValidation"),x.prototype),S(x.prototype,"minMaxValueValidation",[O],Object.getOwnPropertyDescriptor(x.prototype,"minMaxValueValidation"),x.prototype),S(x.prototype,"disableInsert",[P],Object.getOwnPropertyDescriptor(x.prototype,"disableInsert"),x.prototype),S(x.prototype,"onOptionsTextChange",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"onOptionsTextChange"),x.prototype),S(x.prototype,"insertPoll",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"insertPoll"),x.prototype),S(x.prototype,"toggleAdvanced",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"toggleAdvanced"),x.prototype),S(x.prototype,"updateValue",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"updateValue"),x.prototype),S(x.prototype,"onInputKeydown",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"onInputKeydown"),x.prototype),S(x.prototype,"addOption",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"addOption"),x.prototype),S(x.prototype,"removeOption",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"removeOption"),x.prototype),S(x.prototype,"updatePollType",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"updatePollType"),x.prototype),S(x.prototype,"togglePublic",[l.action],Object.getOwnPropertyDescriptor(x.prototype,"togglePublic"),x.prototype),x);(0,t.setComponentTemplate)(N,I)})),define("discourse/plugins/poll/discourse/components/poll-breakdown-chart",["exports","@ember/component","@ember/object/computed","@ember/runloop","@ember/template","@ember-decorators/component","discourse-common/utils/decorators","discourse-i18n","discourse/plugins/poll/lib/chart-colors","discourse/plugins/poll/discourse/components/modal/poll-ui-builder","@ember/template-factory"],(function(e,t,l,o,i,n,s,r,a,p,u){"use strict"
var c,d,h,b,g,m,f
function v(e,t,l){var o
return(t="symbol"==typeof(o=function(e,t){if("object"!=typeof e||!e)return e
var l=e[Symbol.toPrimitive]
if(void 0!==l){var o=l.call(e,t||"default")
if("object"!=typeof o)return o
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?o:String(o))in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function y(e,t,l,o,i){var n={}
return Object.keys(o).forEach((function(e){n[e]=o[e]})),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=l.slice().reverse().reduce((function(l,o){return o(e,t,l)||l}),n),i&&void 0!==n.initializer&&(n.value=n.initializer?n.initializer.call(i):void 0,n.initializer=void 0),void 0===n.initializer&&(Object.defineProperty(e,t,n),n=null),n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const _=(0,u.createTemplateFactory)({id:"oqA5wA7R",block:'[[[10,"label"],[14,0,"poll-breakdown-chart-label"],[12],[1,[30,1]],[13],[1,"\\n"],[10,"canvas"],[14,0,"poll-breakdown-chart-chart"],[12],[13]],["@group"],false,[]]',moduleName:"discourse/plugins/poll/discourse/components/poll-breakdown-chart.hbs",isStrictMode:!1})
let w=e.default=(c=(0,n.classNames)("poll-breakdown-chart-container"),d=(0,l.mapBy)("options","votes"),h=(0,s.default)("optionColors","index"),b=(0,s.default)("data","displayMode"),c((m=class extends t.default{constructor(){var e,t,l,o
super(...arguments),v(this,"group",null),v(this,"options",null),v(this,"displayMode",null),v(this,"highlightedOption",null),v(this,"setHighlightedOption",null),e=this,t="data",o=this,(l=f)&&Object.defineProperty(e,t,{enumerable:l.enumerable,configurable:l.configurable,writable:l.writable,value:l.initializer?l.initializer.call(o):void 0}),v(this,"_optionToSlice",null),v(this,"_previousHighlightedSliceIndex",null),v(this,"_previousDisplayMode",null)}init(){super.init(...arguments),this._optionToSlice={}}didInsertElement(){super.didInsertElement(...arguments)
const e=this.element.querySelector("canvas")
this._chart=new window.Chart(e.getContext("2d"),this.chartConfig)}didReceiveAttrs(){super.didReceiveAttrs(...arguments),this._chart&&(this._updateDisplayMode(),this._updateHighlight())}willDestroy(){super.willDestroy(...arguments),this._chart&&this._chart.destroy()}colorStyle(e,t){return(0,i.htmlSafe)(`background: ${e[t]};`)}chartConfig(e,t){const l=[]
let i=0
this._optionToSlice={},e.forEach(((e,t)=>{e>0&&(l.push(e),this._optionToSlice[t]=i++)}))
const n=l.reduce(((e,t)=>e+t),0),s=(0,a.getColors)(e.length).filter(((t,l)=>e[l]>0))
return{type:p.PIE_CHART_TYPE,plugins:[window.ChartDataLabels],data:{datasets:[{data:l,backgroundColor:s,hoverBorderColor:"#fff"}]},options:{plugins:{tooltip:!1,datalabels:{color:"#333",backgroundColor:"rgba(255, 255, 255, 0.5)",borderRadius:2,font:{family:getComputedStyle(document.body).fontFamily,size:16},padding:{top:2,right:6,bottom:2,left:6},formatter(e){if("percentage"!==t)return e
return`${r.default.toNumber(e/n*100,{precision:1})}%`}}},responsive:!0,aspectRatio:1.1,animation:{duration:0},onHover:(e,t)=>{if(!t.length)return void(0,o.next)((()=>{this.setHighlightedOption(null)}))
const l=t[0].index,i=Object.keys(this._optionToSlice).find((e=>this._optionToSlice[e]===l));(0,o.next)((()=>{this.setHighlightedOption(Number(i))}))}}}}_updateDisplayMode(){if(this.displayMode!==this._previousDisplayMode){const e=this.chartConfig
this._chart.data.datasets=e.data.datasets,this._chart.options=e.options,this._chart.update(),this._previousDisplayMode=this.displayMode}}_updateHighlight(){const e=[]
if(this.highlightedOption){const t=this._optionToSlice[this.highlightedOption]
void 0!==t&&e.push({datasetIndex:0,index:t})}this._chart.setActiveElements(e),this._chart.update()}},f=y(m.prototype,"data",[d],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),y(m.prototype,"colorStyle",[h],Object.getOwnPropertyDescriptor(m.prototype,"colorStyle"),m.prototype),y(m.prototype,"chartConfig",[b],Object.getOwnPropertyDescriptor(m.prototype,"chartConfig"),m.prototype),g=m))||g);(0,t.setComponentTemplate)(_,w)})),define("discourse/plugins/poll/discourse/components/poll-breakdown-option",["exports","@ember/component","@ember/object/computed","@ember/template","@ember-decorators/component","discourse/lib/computed","discourse-common/utils/decorators","discourse-i18n","discourse/plugins/poll/lib/chart-colors","@ember/template-factory"],(function(e,t,l,o,i,n,s,r,a,p){"use strict"
var u,c,d,h,b,g,m,f,v,y,_
function w(e,t,l,o){l&&Object.defineProperty(e,t,{enumerable:l.enumerable,configurable:l.configurable,writable:l.writable,value:l.initializer?l.initializer.call(o):void 0})}function O(e,t,l){var o
return(t="symbol"==typeof(o=function(e,t){if("object"!=typeof e||!e)return e
var l=e[Symbol.toPrimitive]
if(void 0!==l){var o=l.call(e,t||"default")
if("object"!=typeof o)return o
throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"))?o:String(o))in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function P(e,t,l,o,i){var n={}
return Object.keys(o).forEach((function(e){n[e]=o[e]})),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=l.slice().reverse().reduce((function(l,o){return o(e,t,l)||l}),n),i&&void 0!==n.initializer&&(n.value=n.initializer?n.initializer.call(i):void 0,n.initializer=void 0),void 0===n.initializer&&(Object.defineProperty(e,t,n),n=null),n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const x=(0,p.createTemplateFactory)({id:"NTR1m1S2",block:'[[[11,"li"],[24,0,"poll-breakdown-option"],[16,5,[30,0,["colorBackgroundStyle"]]],[24,"role","button"],[4,[38,0],["mouseover",[30,1]],null],[4,[38,0],["mouseout",[30,2]],null],[12],[1,"\\n  "],[10,1],[14,0,"poll-breakdown-option-color"],[15,5,[30,0,["colorPreviewStyle"]]],[12],[13],[1,"\\n\\n  "],[10,1],[14,0,"poll-breakdown-option-count"],[12],[1,"\\n"],[41,[30,0,["showPercentage"]],[[[1,"      "],[1,[30,0,["percent"]]],[1,"%\\n"]],[]],[[[1,"      "],[1,[30,3,["votes"]]],[1,"\\n"]],[]]],[1,"  "],[13],[1,"\\n  "],[10,1],[14,0,"poll-breakdown-option-text"],[12],[1,[28,[35,2],[[30,3,["html"]]],null]],[13],[1,"\\n"],[13]],["@onMouseOver","@onMouseOut","@option"],false,["on","if","html-safe"]]',moduleName:"discourse/plugins/poll/discourse/components/poll-breakdown-option.hbs",isStrictMode:!1})
let M=e.default=(u=(0,i.tagName)(""),c=(0,n.propertyEqual)("highlightedOption","index"),d=(0,l.equal)("displayMode","percentage"),h=(0,s.default)("option.votes","totalVotes"),b=(0,s.default)("optionsCount"),g=(0,s.default)("highlighted"),m=(0,s.default)("highlighted","optionColors","index"),u((v=class extends t.default{constructor(){super(...arguments),O(this,"option",null),O(this,"index",null),O(this,"totalVotes",null),O(this,"optionsCount",null),O(this,"displayMode",null),O(this,"highlightedOption",null),O(this,"onMouseOver",null),O(this,"onMouseOut",null),w(this,"highlighted",y,this),w(this,"showPercentage",_,this)}percent(e,t){return r.default.toNumber(e/t*100,{precision:1})}optionColors(e){return(0,a.getColors)(e)}colorBackgroundStyle(e){if(e)return(0,o.htmlSafe)("background: rgba(0, 0, 0, 0.1);")}colorPreviewStyle(e,t,l){const i=e?window.Chart.helpers.getHoverColor(t[l]):t[l]
return(0,o.htmlSafe)(`background: ${i};`)}},y=P(v.prototype,"highlighted",[c],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_=P(v.prototype,"showPercentage",[d],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),P(v.prototype,"percent",[h],Object.getOwnPropertyDescriptor(v.prototype,"percent"),v.prototype),P(v.prototype,"optionColors",[b],Object.getOwnPropertyDescriptor(v.prototype,"optionColors"),v.prototype),P(v.prototype,"colorBackgroundStyle",[g],Object.getOwnPropertyDescriptor(v.prototype,"colorBackgroundStyle"),v.prototype),P(v.prototype,"colorPreviewStyle",[m],Object.getOwnPropertyDescriptor(v.prototype,"colorPreviewStyle"),v.prototype),f=v))||f);(0,t.setComponentTemplate)(x,M)})),define("discourse/plugins/poll/discourse/initializers/add-poll-ui-builder",["exports","discourse/lib/plugin-api","discourse/plugins/poll/discourse/components/modal/poll-ui-builder"],(function(e,t,l){"use strict"
function o(e){e.addComposerToolbarPopupMenuOption({action:t=>{e.container.lookup("service:modal").show(l.default,{model:{toolbarEvent:t}})},icon:"chart-bar",label:"poll.ui_builder.title",condition:t=>{const l=e.container.lookup("service:site-settings"),o=e.getCurrentUser()
return l.poll_enabled&&(t.model.topic?.pm_with_non_human_user||o&&(o.staff||o.can_create_poll))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"add-poll-ui-builder",initialize(){(0,t.withPluginApi)("1.14.0",o)}}})),define("discourse/plugins/poll/discourse/initializers/extend-for-poll",["exports","@ember/object","discourse/lib/plugin-api","discourse/widgets/glue","discourse-common/lib/get-owner","discourse-common/utils/decorators"],(function(e,t,l,o,i,n){"use strict"
function s(e,t,l,o,i){var n={}
return Object.keys(o).forEach((function(e){n[e]=o[e]})),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=l.slice().reverse().reduce((function(l,o){return o(e,t,l)||l}),n),i&&void 0!==n.initializer&&(n.value=n.initializer?n.initializer.call(i):void 0,n.initializer=void 0),void 0===n.initializer&&(Object.defineProperty(e,t,n),n=null),n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const r="discourse-poll"
let a=[],p=null
function u(){a.forEach((e=>e.queueRerender()))}function c(){p&&(clearInterval(p),p=null),a.forEach((e=>e.cleanUp())),a=[]}function d(e){var l,d,h
const b=(0,i.getRegister)(e),g=e.container.lookup("service:site-settings").poll_groupable_user_fields
c(),e.modifyClass("controller:topic",(l={pluginId:r,subscribe(){this._super(...arguments),this.messageBus.subscribe(`/polls/${this.model.id}`,this._onPollMessage)},unsubscribe(){this.messageBus.unsubscribe("/polls/*",this._onPollMessage),this._super(...arguments)},_onPollMessage(e){const t=this.get("model.postStream").findLoadedPost(e.post_id)
t?.set("polls",e.polls)}},s(l,"_onPollMessage",[n.bind],Object.getOwnPropertyDescriptor(l,"_onPollMessage"),l),l)),e.modifyClass("model:post",(d=(0,n.observes)("polls"),s(h={pluginId:r,_polls:null,pollsObject:null,pollsChanged(){const e=this.polls
e&&(this._polls=this._polls||{},e.forEach((e=>{this._polls[e.name]?this._polls[e.name].setProperties(e):this._polls[e.name]=t.default.create(e)})),this.set("pollsObject",this._polls),u())}},"pollsChanged",[d],Object.getOwnPropertyDescriptor(h,"pollsChanged"),h),h)),e.includePostAttributes("polls","polls_votes"),e.decorateCookedElement((function(l,i){let n=[...l.querySelectorAll(".poll")]
if(n=n.filter((e=>"BLOCKQUOTE"!==e.parentNode.tagName)),!n.length||!i)return
const s=i.getModel()
e.preventCloak(s.id),s.pollsChanged()
const r=s.pollsObject||{},c=s.polls_votes||{}
p=p||setInterval(u,3e4),n.forEach((e=>{const l=e.dataset.pollName
let i=r[l],n=s,p=c[l]||[]
const u=e.closest(".expanded-quote")?.dataset.postId
if(u&&s.quoted[u]&&(n=s.quoted[u],n=t.default.create(n),i=t.default.create(n.polls.findBy("name",l)),p=n.polls_votes||{},p=p[l]||[]),i){const t=e.querySelector(".poll-title"),s={id:`${l}-${n.id}`,post:n,poll:i,vote:p,hasSavedVote:p.length>0,titleHTML:t?.outerHTML,groupableUserFields:(g||"").split("|").filter(Boolean)},r=new o.default("discourse-poll",b,s)
r.appendTo(e),a.push(r)}}))}),{onlyStream:!0}),e.cleanupStream(c)
e.container.lookup("service:site-settings").poll_enabled&&e.addSearchSuggestion("in:polls")}e.default={name:"extend-for-poll",initialize(){(0,l.withPluginApi)("0.8.7",d)}}})),define("discourse/plugins/poll/discourse/widgets/discourse-poll",["exports","@ember/application","virtual-dom","discourse/lib/ajax","discourse/lib/ajax-error","discourse/lib/formatter","discourse/lib/load-script","discourse/lib/local-dates","discourse/lib/round","discourse/widgets/post","discourse/widgets/raw-html","discourse/widgets/widget","discourse-common/lib/icon-library","discourse-i18n","discourse/plugins/poll/lib/chart-colors","discourse/plugins/poll/lib/even-round","discourse/plugins/poll/discourse/components/modal/poll-breakdown","discourse/plugins/poll/discourse/components/modal/poll-ui-builder"],(function(e,t,l,o,i,n,s,r,a,p,u,c,d,h,b,g,m,f){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const v={exportResults:{className:"btn-default export-results",label:"poll.export-results.label",title:"poll.export-results.title",icon:"download",action:"exportResults"},showBreakdown:{className:"btn-default show-breakdown",label:"poll.breakdown.breakdown",icon:"chart-pie",action:"showBreakdown"},openPoll:{className:"btn-default toggle-status",label:"poll.open.label",title:"poll.open.title",icon:"unlock-alt",action:"toggleStatus"},closePoll:{className:"btn-default toggle-status",label:"poll.close.label",title:"poll.close.title",icon:"lock",action:"toggleStatus"}}
function y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}
const l=document.createElement("span")
return l.innerHTML=e.html,(0,r.applyLocalDates)(l.querySelectorAll(".discourse-local-date"),t),new u.default({html:`<span>${l.innerHTML}</span>`})}function _(e,t){const l=t&&t.groups&&t.groups.split(",").map((e=>e.toLowerCase()))
if(!l)return!0
const o=e&&e.groups&&e.groups.map((e=>e.name.toLowerCase()))
return o&&l.some((e=>o.includes(e)))}(0,c.createWidget)("discourse-poll-option",{tagName:"li",buildAttributes:e=>({tabindex:0,"data-poll-option-id":e.option.id}),html(e){const t=[],{option:l,vote:o}=e,i=o.includes(l.id)
return e.isMultiple?t.push((0,d.iconNode)(i?"far-check-square":"far-square")):t.push((0,d.iconNode)(i?"circle":"far-circle")),t.push(" "),t.push(y(l,this.siteSettings)),t},click(e){e.target.closest("a")||this.sendWidgetAction("toggleOption",this.attrs.option)},keyDown(e){"Enter"===e.key&&this.click(e)}}),(0,c.createWidget)("discourse-poll-load-more",{tagName:"div.poll-voters-toggle-expand",buildKey:e=>`load-more-${e.optionId}`,defaultState:()=>({loading:!1}),html:(e,t)=>t.loading?(0,l.h)("div.spinner.small"):(0,l.h)("a",(0,d.iconNode)("chevron-down")),click(){const{state:e,attrs:t}=this
if(!e.loading)return e.loading=!0,this.sendWidgetAction("fetchVoters",t.optionId).finally((()=>e.loading=!1))}}),(0,c.createWidget)("discourse-poll-voters",{tagName:"ul.poll-voters-list",buildKey:e=>`poll-voters-${e.optionId}`,html(e){const t=e.voters.map((e=>(0,l.h)("li",[(0,p.avatarFor)("tiny",{username:e.username,template:e.avatar_template})," "])))
return e.voters.length<e.totalVotes&&t.push(this.attach("discourse-poll-load-more",e)),(0,l.h)("div.poll-voters",t)}}),(0,c.createWidget)("discourse-poll-standard-results",{tagName:"ul.results",buildKey:e=>`poll-standard-results-${e.id}`,html(e){const{poll:t}=e,o=t.options
if(o){const i=t.voters,n=t.public,s=[...o].sort(((e,t)=>e.votes<t.votes?1:e.votes===t.votes?e.html<t.html?-1:1:-1)),r=0===i?Array(s.length).fill(0):s.map((e=>100*e.votes/i)),a=e.isMultiple?r.map(Math.floor):(0,g.default)(r)
return s.map(((o,i)=>{const s=[],r=a[i].toString(),p=(e.vote||[]).includes(o.id)
return s.push((0,l.h)("div.option",(0,l.h)("p",[(0,l.h)("span.percentage",`${r}%`),y(o,this.siteSettings)]))),s.push((0,l.h)("div.bar-back",(0,l.h)("div.bar",{attributes:{style:`width:${r}%`}}))),n&&s.push(this.attach("discourse-poll-voters",{postId:e.post.id,optionId:o.id,pollName:t.name,totalVotes:o.votes,voters:e.voters&&e.voters[o.id]||[]})),(0,l.h)("li",{className:""+(p?"chosen":"")},s)}))}}}),(0,c.createWidget)("discourse-poll-number-results",{buildKey:e=>`poll-number-results-${e.id}`,html(e){const{poll:t}=e,o=t.options.reduce(((e,t)=>e+parseInt(t.html,10)*parseInt(t.votes,10)),0),i=t.voters,n=0===i?0:(0,a.default)(o/i,-2),s=h.default.t("poll.average_rating",{average:n}),r=[(0,l.h)("div.poll-results-number-rating",new u.default({html:`<span>${s}</span>`}))]
return t.public&&r.push(this.attach("discourse-poll-voters",{totalVotes:t.voters,voters:e.voters||[],postId:e.post.id,pollName:t.name,pollType:t.type})),r}}),(0,c.createWidget)("discourse-poll-container",{tagName:"div.poll-container",buildKey:e=>`poll-container-${e.id}`,services:["dialog"],defaultState:()=>({voters:[]}),html(e,t){const{poll:o}=e,i=o.options
if(e.showResults){const l=[]
e.titleHTML&&l.push(new u.default({html:e.titleHTML})),o.public&&(t.voters=o.preloaded_voters)
const i="number"===o.type?"number":"standard",n="number"===i||e.poll.chart_type!==f.PIE_CHART_TYPE?`discourse-poll-${i}-results`:"discourse-poll-pie-chart"
return l.push(this.attach(n,{...e,voters:t.voters})),l}if(i){const t=[]
return e.titleHTML&&t.push(new u.default({html:e.titleHTML})),_(this.currentUser,o)||t.push((0,l.h)("div.alert.alert-danger",h.default.t("poll.results.groups.title",{groups:o.groups}))),t.push((0,l.h)("ul",i.map((t=>this.attach("discourse-poll-option",{option:t,isMultiple:e.isMultiple,vote:e.vote}))))),t}},fetchVoters(e){const{attrs:t,state:l}=this
let n
return e?(l.voters||(l.voters={}),l.voters[e]||(l.voters[e]=[]),n=l.voters[e].length):(l.voters||(l.voters=[]),n=l.voters.length),(0,o.ajax)("/polls/voters.json",{data:{post_id:t.post.id,poll_name:t.poll.name,option_id:e,page:Math.floor(n/25)+1,limit:25}}).then((o=>{const i=e?l.voters[e]:l.voters,n=e?o.voters[e]:o.voters,s=new Set(i.map((e=>e.username)))
n.forEach((e=>{s.has(e.username)||(s.add(e.username),i.push(e))})),"regular"===t.poll.type&&Object.keys(l.voters).forEach((t=>{e!==t&&(l.voters[t]=l.voters[t].filter((e=>!s.has(e.username))))})),this.scheduleRerender()})).catch((e=>{e?(0,i.popupAjaxError)(e):this.dialog.alert(h.default.t("poll.error_while_fetching_voters"))}))}}),(0,c.createWidget)("discourse-poll-info",{tagName:"div.poll-info",multipleHelpText(e,t,l){if(t>0)if(e===t){if(e>1)return h.default.t("poll.multiple.help.x_options",{count:e})}else{if(e>1)return t<l?h.default.t("poll.multiple.help.between_min_and_max_options",{min:e,max:t}):h.default.t("poll.multiple.help.at_least_min_options",{count:e})
if(t<=l)return h.default.t("poll.multiple.help.up_to_max_options",{count:t})}},html(e){const{poll:t,post:o}=e,i=e.isClosed,s=this.currentUser&&this.currentUser.staff,r=this.currentUser&&o.user_id===this.currentUser.id,a=t.voters,p=[(0,l.h)("div.poll-info_counts-count",[(0,l.h)("span.info-number",a.toString()),(0,l.h)("span.info-label",h.default.t("poll.voters",{count:a}))])],c=[]
if(e.isMultiple)if(e.showResults||e.isClosed){const e=t.options.reduce(((e,t)=>e+parseInt(t.votes,10)),0)
p.push((0,l.h)("div.poll-info_counts-count",[(0,l.h)("span.info-number",e.toString()),(0,l.h)("span.info-label",h.default.t("poll.total_votes",{count:e}))]))}else{const l=this.multipleHelpText(e.min,e.max,t.options.length)
l&&c.push(new u.default({html:`<li>\n                      ${(0,d.iconHTML)("list-ul")}\n                      <span>${l}</span>\n                     </li>`}))}if(t.close){const l=moment.utc(t.close,"YYYY-MM-DD HH:mm:ss Z")
if(l.isValid()){const t=l.format("LLL")
let o,i
if(e.isAutomaticallyClosed){const e=(0,n.relativeAge)(l.toDate(),{addAgo:!0})
o=h.default.t("poll.automatic_close.age",{age:e}),i="lock"}else{const e=moment().to(l,!0)
o=h.default.t("poll.automatic_close.closes_in",{timeLeft:e}),i="far-clock"}c.push(new u.default({html:`<li title="${t}">\n                    ${(0,d.iconHTML)(i)}\n                    <span>${o}</span>\n                   </li>`}))}}let b
return"on_vote"!==t.results||e.hasVoted||r?"on_close"!==t.results||i?"staff_only"!==t.results||s||(b=new u.default({html:`<li>\n                ${(0,d.iconHTML)("shield-alt")}\n                <span>${h.default.t("poll.results.staff.title")}</span>\n               </li>`})):b=new u.default({html:`<li>\n                ${(0,d.iconHTML)("lock")}\n                <span>${h.default.t("poll.results.closed.title")}</span>\n               </li>`}):b=new u.default({html:`<li>\n                ${(0,d.iconHTML)("check")}\n                <span>${h.default.t("poll.results.vote.title")}</span>\n               </li>`}),b&&c.push(b),e.isClosed||e.showResults||!t.public||"staff_only"===t.results||c.push(new u.default({html:`<li>\n                  ${(0,d.iconHTML)("far-eye")}\n                  <span>${h.default.t("poll.public.title")}</span>\n                 </li>`})),[(0,l.h)("div.poll-info_counts",p),(0,l.h)("ul.poll-info_instructions",c)]}}),(0,c.createWidget)("discourse-poll-pie-canvas",{tagName:"canvas.poll-results-canvas",init(e){(0,s.default)("/javascripts/Chart.min.js").then((()=>{const t=function(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}
const o="aspectRatio"in l?l.aspectRatio:2.2,i=t.map((e=>{return t=e,(new DOMParser).parseFromString(t,"text/html").body.textContent||""
var t}))
return{type:f.PIE_CHART_TYPE,data:{datasets:[{data:e,backgroundColor:(0,b.getColors)(e.length)}],labels:i},plugins:[w],options:{responsive:!0,aspectRatio:o,animation:{duration:0},plugins:{legend:{labels:{generateLabels:()=>t.map(((t,l)=>({fillStyle:(0,b.getColors)(e.length)[l],text:t,index:l})))},display:!1},htmlLegend:{containerID:l?.legendContainerId}}}}}(e.poll.options.mapBy("votes"),e.poll.options.mapBy("html"),{legendContainerId:`poll-results-legend-${e.id}`}),l=document.getElementById(`poll-results-chart-${e.id}`)
this._chart=new Chart(l.getContext("2d"),t)}))},willRerenderWidget(){this._chart?.destroy()},buildAttributes:e=>({id:`poll-results-chart-${e.id}`})}),(0,c.createWidget)("discourse-poll-pie-chart",{tagName:"div.poll-results-chart",html(e){const t=[]
if(!e.showResults)return function(e){let t=document.querySelector(`#poll-results-chart-${e}`)
t&&t.parentNode.removeChild(t)}(e.id),t
const o=this.attach("discourse-poll-pie-canvas",e)
return t.push(o),t.push((0,l.h)(`ul#poll-results-legend-${e.id}.pie-chart-legends`)),t}})
const w={id:"htmlLegend",afterUpdate(e,t,l){const o=document.getElementById(l.containerID)
o.innerHTML=""
e.options.plugins.legend.labels.generateLabels(e).forEach((t=>{const l=document.createElement("li")
l.classList.add("legend"),l.onclick=()=>{e.toggleDataVisibility(t.index),e.update()}
const i=document.createElement("span")
i.classList.add("swatch"),i.style.background=t.fillStyle
const n=document.createElement("span")
n.style.color=t.fontColor,n.innerHTML=t.text,e.getDataVisibility(t.index)?l.style.opacity=1:l.style.opacity=.2,l.appendChild(i),l.appendChild(n),o.appendChild(l)}))}};(0,c.createWidget)("discourse-poll-buttons-dropdown",{tagName:"div.poll-buttons-dropdown",buildId:e=>`poll-buttons-dropdown-${e.id}`,transform(e){return{content:this._buildContent(e),onChange:e=>this.sendWidgetAction(e.id,e.param)}},template:function(e,t){var l=[]
return l.push("\n  "),l.push(this.attach("widget-dropdown",{id:this.attrs.id,icon:"cog",label:"poll.options.label",content:this.transformed.content,onChange:this.transformed.onChange,options:this.transformed.options},void 0,void 0)),l.push("\n"),l},optionsCount(e){return this._buildContent(e).length},_buildContent(e){const t=[],l=this.currentUser&&this.currentUser.admin,o=this.siteSettings.data_explorer_enabled,i=this.siteSettings.poll_export_data_explorer_query_id,{poll:n,post:s}=e,r=e.isClosed,a=this.currentUser&&this.currentUser.staff,p=s.get("topic.archived")
if(e.groupableUserFields.length&&n.voters>0){const e={...v.showBreakdown}
e.id=e.action,t.push(e)}if(l&&o&&n.voters>0&&i){const e={...v.exportResults}
e.id=e.action,t.push(e)}if(this.currentUser&&(this.currentUser.id===s.user_id||a)&&!p)if(r){if(!e.isAutomaticallyClosed){const e={...v.openPoll}
e.id=e.action,t.push(e)}}else{const e={...v.closePoll}
e.id=e.action,t.push(e)}return t}}),(0,c.createWidget)("discourse-poll-buttons",{tagName:"div.poll-buttons",html(e){const t=[],{poll:l,post:o}=e,i=o.get("topic.archived"),n=e.isClosed,s="staff_only"===l.results,r=this.currentUser&&this.currentUser.staff,a=this.currentUser&&o.user_id===this.currentUser.id,p=!s&&(n||i),u=this.attach("discourse-poll-buttons-dropdown",e),c=u.optionsCount(e)
if(e.isMultiple&&!p&&!e.showResults){const l=!e.canCastVotes
t.push(this.attach("button",{className:"cast-votes "+(l?"btn-default":"btn-primary"),label:"poll.cast-votes.label",title:"poll.cast-votes.title",icon:l?"far-square":"check",disabled:l,action:"castVotes"}))}if(e.showResults&&!p&&t.push(this.attach("button",{className:"btn-default toggle-results",label:"poll.hide-results.label",title:"poll.hide-results.title",icon:"chevron-left",action:"toggleResults"})),!e.showResults&&!p){let o;("on_vote"!==l.results||e.hasVoted||a)&&("on_close"!==l.results||n)&&("staff_only"!==l.results||r)&&l.voters>0&&(o=this.attach("button",{className:"btn-default toggle-results",label:"poll.show-results.label",title:"poll.show-results.title",icon:"chart-bar",action:"toggleResults"})),e.hasSavedVote&&t.push(this.attach("button",{className:"btn-default remove-vote",label:"poll.remove-vote.label",title:"poll.remove-vote.title",icon:"undo",action:"removeVote"})),o&&t.push(o)}if(c>1)t.push(u)
else if(1===c){const l=u._buildContent(e)[0].id
let o=v[l]
"toggleStatus"===l&&(o=n?v.openPoll:v.closePoll),t.push(this.attach("button",o))}return[t]}})
e.default=(0,c.createWidget)("discourse-poll",{tagName:"div",buildKey:e=>`poll-${e.id}`,services:["dialog"],buildAttributes(e){let t="poll"
return e.poll.chart_type===f.PIE_CHART_TYPE&&(t+=" pie"),{class:t,"data-poll-name":e.poll.name,"data-poll-type":e.poll.type}},defaultState(e){const{poll:t}=e,l="staff_only"===e.poll.results
return{loading:!1,showResults:"on_close"!==t.results&&this.hasVoted()&&!l}},html(e,t){const l="staff_only"===e.poll.results,o=t.showResults||e.post.get("topic.archived")&&!l||this.isClosed()&&!l,i={...e,canCastVotes:this.canCastVotes(),hasVoted:this.hasVoted(),isAutomaticallyClosed:this.isAutomaticallyClosed(),isClosed:this.isClosed(),isMultiple:this.isMultiple(),max:this.max(),min:this.min(),showResults:o}
return[this.attach("discourse-poll-container",i),this.attach("discourse-poll-info",i),this.attach("discourse-poll-buttons",i)]},min(){let e=parseInt(this.attrs.poll.min,10)
return(isNaN(e)||e<0)&&(e=1),e},max(){let e=parseInt(this.attrs.poll.max,10)
const t=this.attrs.poll.options.length
return(isNaN(e)||e>t)&&(e=t),e},isAutomaticallyClosed(){const{poll:e}=this.attrs
return e.close&&moment.utc(e.close,"YYYY-MM-DD HH:mm:ss Z")<=moment()},isClosed(){const{poll:e}=this.attrs
return"closed"===e.status||this.isAutomaticallyClosed()},isMultiple(){const{poll:e}=this.attrs
return"multiple"===e.type},hasVoted(){const{vote:e}=this.attrs
return e&&e.length>0},canCastVotes(){const{state:e,attrs:t}=this
if(this.isClosed()||e.showResults||e.loading)return!1
const l=t.vote.length
return this.isMultiple()?l>=this.min()&&l<=this.max():l>0},toggleStatus(){const{state:e,attrs:t}=this,{post:l,poll:n}=t
this.isAutomaticallyClosed()||this.dialog.yesNoConfirm({message:h.default.t(this.isClosed()?"poll.open.confirm":"poll.close.confirm"),didConfirm:()=>{e.loading=!0
const t=this.isClosed()?"open":"closed";(0,o.ajax)("/polls/toggle_status",{type:"PUT",data:{post_id:l.id,poll_name:n.name,status:t}}).then((()=>{n.set("status",t),"on_close"===n.results&&(e.showResults="closed"===t),this.scheduleRerender()})).catch((e=>{e?(0,i.popupAjaxError)(e):this.dialog.alert(h.default.t("poll.error_while_toggling_status"))})).finally((()=>{e.loading=!1}))}})},toggleResults(){this.state.showResults=!this.state.showResults},removeVote(){const{attrs:e,state:t}=this
return t.loading=!0,(0,o.ajax)("/polls/vote",{type:"DELETE",data:{post_id:e.post.id,poll_name:e.poll.name}}).then((t=>{let{poll:l}=t
e.poll.setProperties(l),e.vote.length=0,e.hasSavedVote=!1,this.appEvents.trigger("poll:voted",l,e.post,e.vote)})).catch((e=>(0,i.popupAjaxError)(e))).finally((()=>{t.loading=!1}))},exportResults(){const{attrs:e}=this,t=this.siteSettings.poll_export_data_explorer_query_id;(0,o.ajax)(`/admin/plugins/explorer/queries/${t}/run.csv`,{type:"POST",data:{params:JSON.stringify({poll_name:e.poll.name,post_id:e.post.id.toString()}),explain:!1,limit:1e6,download:1}}).then((t=>{const l=document.createElement("a"),o=new Blob([t],{type:"text/csv;charset=utf-8;"})
l.href=URL.createObjectURL(o),l.setAttribute("download",`poll-export-${e.poll.name}-${e.post.id}.csv`),l.click(),l.remove()})).catch((e=>{e?(0,i.popupAjaxError)(e):this.dialog.alert(h.default.t("poll.error_while_exporting_results"))}))},showLogin(){this.register.lookup("route:application").send("showLogin")},_toggleOption(e){const{vote:t}=this.attrs,l=t.indexOf(e.id);-1!==l?t.splice(l,1):t.push(e.id)},toggleOption(e){const{attrs:t}=this
if(this.isClosed())return
if(!this.currentUser)return this.showLogin()
if(!_(this.currentUser,this.attrs.poll))return
const{vote:l}=t
return this.isMultiple()||1!==l.length||l[0]!==e.id?(this.isMultiple()||(l.length=0),this._toggleOption(e),this.isMultiple()?void 0:this.castVotes().catch((()=>this._toggleOption(e)))):this.removeVote()},castVotes(){if(!this.canCastVotes())return
if(!this.currentUser)return this.showLogin()
const{attrs:e,state:t}=this
return t.loading=!0,(0,o.ajax)("/polls/vote",{type:"PUT",data:{post_id:e.post.id,poll_name:e.poll.name,options:e.vote}}).then((l=>{let{poll:o}=l
e.hasSavedVote=!0,e.poll.setProperties(o),this.appEvents.trigger("poll:voted",o,e.post,e.vote),"on_close"!==e.poll.results&&(t.showResults=!0),"staff_only"===e.poll.results&&(this.currentUser&&this.currentUser.staff?t.showResults=!0:t.showResults=!1)})).catch((e=>{e?(0,i.popupAjaxError)(e):this.dialog.alert(h.default.t("poll.error_while_casting_votes"))})).finally((()=>{t.loading=!1}))},showBreakdown(){(0,t.getOwner)(this).lookup("service:modal").show(m.default,{model:this.attrs})}})})),define("discourse/plugins/poll/lib/chart-colors",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.getColors=function(e,t){let l
switch(t=t||"cool"){case"cool":l={0:[255,255,255],25:[220,237,200],50:[66,179,213],75:[26,39,62],100:[0,0,0]}
break
case"warm":l={0:[255,255,255],25:[254,235,101],50:[228,82,27],75:[77,52,47],100:[0,0,0]}}let o,i,n=Object.keys(l),s=[]
for(let r=0;r<e;r++){let t
o=(r+1)*(100/(e+1)),i=i||0
for(let e=i;e<n.length;e++){if(!n[e+1]){t=e-1
break}if(o>=n[e]&&o<n[e+1]){t=e
break}}let a=(o-n[t])/(n[t+1]-n[t]),p=[]
for(let e=0;e<3;e++)p.push(Math.round(l[n[t]][e]-(l[n[t]][e]-l[n[t+1]][e])*a))
s.push(`rgb(${p.toString()})`),i=t}return s}})),define("discourse/plugins/poll/lib/discourse-markdown/poll",["exports","discourse-i18n"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.setup=function(e){e.allowList(["div.poll","div.poll-info","div.poll-info_counts","div.poll-info_counts-count","div.poll-container","div.poll-title","div.poll-buttons","div[data-*]","span.info-number","span.info-text","span.info-label","a.button.cast-votes","a.button.toggle-results","li[data-*]"]),function(e){e.registerOptions(((e,t)=>{t.poll_enabled||(e.features.poll=!1),e.pollMaximumOptions=t.poll_maximum_options})),e.registerPlugin((e=>{e.block.bbcode.ruler.push("poll",n)}))}(e)}
/*!
   * Joseph Myer's md5() algorithm wrapped in a self-invoked function to prevent
   * global namespace pollution, modified to hash unicode characters as UTF-8.
   *
   * Copyright 1999-2010, Joseph Myers, Paul Johnston, Greg Holt, Will Bond <will@wbond.net>
   * http://www.myersdaily.org/joseph/javascript/md5-text.html
   * http://pajhome.org.uk/crypt/md5
   *
   * Released under the BSD license
   * http://www.opensource.org/licenses/bsd-license
   */
const l="data-poll-",o=["close","max","min","name","order","public","results","chartType","groups","status","step","type"]
function i(e,t){e.push("text","",0).content="[/"+t+"]"}const n={tag:"poll",before(e,t,l){let o=e.push("text","",0)
o.content=l,o.bbcode_attrs=t.attrs,o.bbcode_type="poll_open"},after(e,n,r){const a=function(e,t){const l=e.indexOf(t)
if(-1===l)return
const o=e.slice(l),i=o.findIndex((e=>"heading_open"===e.type)),n=o.findIndex((e=>"heading_close"===e.type))
if(-1===i||-1===n)return
const s=o.slice(i+1,n)
return e.splice(l+i,n-i+1),s}(e.tokens,n)
let p=function(e,t){let l=e.length-1,o=[],i=[]
for(;e[l]!==t;l--){if(0===l)return
let t=e[l]
if(0===t.level&&"ol"!==t.tag&&"ul"!==t.tag)return
if(1===t.level&&1===t.nesting){if("li"!==t.tag)return
o.push([t,i.reverse().join(" ")])}1===t.level&&1===t.nesting&&"li"===t.tag?i=[]:"text"!==t.type&&"inline"!==t.type||i.push(t.content)}return o.reverse()}(e.tokens,n)
if(!p)return i(e,r)
const u=n.bbcode_attrs,c=[["class","poll"]]
u.status||c.push([l+"status","open"]),o.forEach((e=>{u[e]&&c.push([l+e,u[e]])})),u.name||c.push([l+"name","poll"])
let h=parseInt(u.min,10),g=parseInt(u.max,10),m=parseInt(u.step,10)
m<1&&(m=1)
let f=[],v=new e.Token("poll_open","div",1)
if(v.block=!0,v.attrs=c,f.push(v),v=new e.Token("poll_open","div",1),v.attrs=[["class","poll-container"]],f.push(v),a&&(v=new e.Token("title_open","div",1),v.attrs=[["class","poll-title"]],f.push(v),f.push(...a),v=new e.Token("title_close","div",-1),f.push(v)),"number"===u.type){if(isNaN(h)&&(h=1),isNaN(g)&&(g=e.md.options.discourse.pollMaximumOptions),isNaN(m)&&(m=1),p.length>0)return i(e,r)
v=new e.Token("bullet_list_open","ul",1),f.push(v)
for(let t=h;t<=g;t+=m)v=new e.Token("list_item_open","li",1),p.push([v,String(t)]),f.push(v),v=new e.Token("text","",0),v.content=String(t),f.push(v),v=new e.Token("list_item_close","li",-1),f.push(v)
v=new e.Token("bullet_item_close","",-1),f.push(v)}for(let t=0;t<p.length;t++){v=p[t][0]
let e=p[t][1]
v.attrs=v.attrs||[]
let o=function(e){for(let t=0;t<e.length;t++)e[t]=b(e[t])
return e.join("")}(function(e){e=unescape(encodeURI(e))
let t,l=e.length,o=[1732584193,-271733879,-1732584194,271733878]
for(t=64;t<=e.length;t+=64)s(o,d(e.substring(t-64,t)))
e=e.substring(t-64)
let i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
for(t=0;t<e.length;t++)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3)
if(i[t>>2]|=128<<(t%4<<3),t>55)for(s(o,i),t=0;t<16;t++)i[t]=0
return i[14]=8*l,s(o,i),o}(JSON.stringify([e])))
v.attrs.push([l+"option-id",o])}(function(e,t,l){let o=e.indexOf(t),i=e[o].level
for(e.splice(o,1,...l),l[0].map=t.map;o<e.length;o++){let t=e[o].nesting
t<0&&i--,e[o].level=i,t>0&&i++}})(e.tokens,n,f),e.level=e.tokens[e.tokens.length-1].level,e.push("poll_close","div",-1),v=e.push("poll_open","div",1),v.attrs=[["class","poll-info"]],v=e.push("poll_open","div",1),v.attrs=[["class","poll-info_counts"]],v=e.push("poll_open","div",1),v.attrs=[["class","poll-info_counts-count"]],v=e.push("span_open","span",1),v.block=!1,v.attrs=[["class","info-number"]],v=e.push("text","",0),v.content="0",e.push("span_close","span",-1),v=e.push("span_open","span",1),v.block=!1,v.attrs=[["class","info-label"]],v=e.push("text","",0),v.content=t.default.t("poll.voters",{count:0}),e.push("span_close","span",-1),e.push("poll_close","div",-1),e.push("poll_close","div",-1),e.push("poll_close","div",-1),e.push("poll_close","div",-1)}}
function s(e,t){let l=e[0],o=e[1],i=e[2],n=e[3]
l=a(l,o,i,n,t[0],7,-680876936),n=a(n,l,o,i,t[1],12,-389564586),i=a(i,n,l,o,t[2],17,606105819),o=a(o,i,n,l,t[3],22,-1044525330),l=a(l,o,i,n,t[4],7,-176418897),n=a(n,l,o,i,t[5],12,1200080426),i=a(i,n,l,o,t[6],17,-1473231341),o=a(o,i,n,l,t[7],22,-45705983),l=a(l,o,i,n,t[8],7,1770035416),n=a(n,l,o,i,t[9],12,-1958414417),i=a(i,n,l,o,t[10],17,-42063),o=a(o,i,n,l,t[11],22,-1990404162),l=a(l,o,i,n,t[12],7,1804603682),n=a(n,l,o,i,t[13],12,-40341101),i=a(i,n,l,o,t[14],17,-1502002290),o=a(o,i,n,l,t[15],22,1236535329),l=p(l,o,i,n,t[1],5,-165796510),n=p(n,l,o,i,t[6],9,-1069501632),i=p(i,n,l,o,t[11],14,643717713),o=p(o,i,n,l,t[0],20,-373897302),l=p(l,o,i,n,t[5],5,-701558691),n=p(n,l,o,i,t[10],9,38016083),i=p(i,n,l,o,t[15],14,-660478335),o=p(o,i,n,l,t[4],20,-405537848),l=p(l,o,i,n,t[9],5,568446438),n=p(n,l,o,i,t[14],9,-1019803690),i=p(i,n,l,o,t[3],14,-187363961),o=p(o,i,n,l,t[8],20,1163531501),l=p(l,o,i,n,t[13],5,-1444681467),n=p(n,l,o,i,t[2],9,-51403784)
i=p(i,n,l,o,t[7],14,1735328473),o=p(o,i,n,l,t[12],20,-1926607734),l=u(l,o,i,n,t[5],4,-378558),n=u(n,l,o,i,t[8],11,-2022574463),i=u(i,n,l,o,t[11],16,1839030562),o=u(o,i,n,l,t[14],23,-35309556),l=u(l,o,i,n,t[1],4,-1530992060),n=u(n,l,o,i,t[4],11,1272893353),i=u(i,n,l,o,t[7],16,-155497632),o=u(o,i,n,l,t[10],23,-1094730640),l=u(l,o,i,n,t[13],4,681279174),n=u(n,l,o,i,t[0],11,-358537222),i=u(i,n,l,o,t[3],16,-722521979),o=u(o,i,n,l,t[6],23,76029189),l=u(l,o,i,n,t[9],4,-640364487),n=u(n,l,o,i,t[12],11,-421815835),i=u(i,n,l,o,t[15],16,530742520),o=u(o,i,n,l,t[2],23,-995338651),l=c(l,o,i,n,t[0],6,-198630844),n=c(n,l,o,i,t[7],10,1126891415),i=c(i,n,l,o,t[14],15,-1416354905),o=c(o,i,n,l,t[5],21,-57434055),l=c(l,o,i,n,t[12],6,1700485571),n=c(n,l,o,i,t[3],10,-1894986606),i=c(i,n,l,o,t[10],15,-1051523),o=c(o,i,n,l,t[1],21,-2054922799),l=c(l,o,i,n,t[8],6,1873313359),n=c(n,l,o,i,t[15],10,-30611744),i=c(i,n,l,o,t[6],15,-1560198380),o=c(o,i,n,l,t[13],21,1309151649)
l=c(l,o,i,n,t[4],6,-145523070),n=c(n,l,o,i,t[11],10,-1120210379),i=c(i,n,l,o,t[2],15,718787259),o=c(o,i,n,l,t[9],21,-343485551),e[0]=g(l,e[0]),e[1]=g(o,e[1]),e[2]=g(i,e[2]),e[3]=g(n,e[3])}function r(e,t,l,o,i,n){return t=g(g(t,e),g(o,n)),g(t<<i|t>>>32-i,l)}function a(e,t,l,o,i,n,s){return r(t&l|~t&o,e,t,i,n,s)}function p(e,t,l,o,i,n,s){return r(t&o|l&~o,e,t,i,n,s)}function u(e,t,l,o,i,n,s){return r(t^l^o,e,t,i,n,s)}function c(e,t,l,o,i,n,s){return r(l^(t|~o),e,t,i,n,s)}function d(e){let t,l=[]
for(t=0;t<64;t+=4)l[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24)
return l}let h="0123456789abcdef".split("")
function b(e){let t="",l=0
for(;l<4;l++)t+=h[e>>8*l+4&15]+h[e>>8*l&15]
return t}function g(e,t){return e+t&4294967295}})),define("discourse/plugins/poll/lib/even-round",["exports"],(function(e){"use strict"
function t(e){return 100===e.map((e=>Math.floor(e))).reduce(((e,t)=>e+t))}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(e){let l=e.map((e=>e%1))
const o=Math.ceil(l.reduce(((e,t)=>e+t)))
for(let i=0,n=l.length;i<o&&i<n;i++){let o=0,i=0
for(let e=0;e<l.length;e++)l[e]>o&&(i=e,o=l[e])
if(++e[i],l[i]=0,t(e))break}return e.map((e=>Math.floor(e)))}}))

//# sourceMappingURL=poll-c38b44a06d721be7511061eda1e987daeb63ec660b3cd1585df7e20f0c5e035c.map
//!

;
