import{$ as i}from"./iframe-DSGyX7_4.js";import{c as t}from"./helpers-DDTkKuvc.js";import{c as B}from"./ButtonComponent-C1nc5If8.js";const R=[{legend:null,name:"vote",options:["Sehr gut, angesichts der hohen Inzidenzen","Mir ist das egal","Die Regel ist zu hart"]}],C=[{legend:"Sie sind?",name:"group",options:["Couch-Trainer","Fan","Fußball-Profi"]},{legend:"Soll der Bundestrainer abtreten?",name:"choice",options:["ja","nein"]}];class b{constructor(e){this.section=e.addClass("initiated"),this.formBox=e.find(".form-box"),this.form=e.find("form"),this.initSize(),this.form.data("show-result")?this.loadResult():this.initOptions()}initSize(){new ResizeObserver(s=>{s.map(n=>{const o=n.borderBoxSize[0].inlineSize;window.requestAnimationFrame(()=>{o<500?this.section.attr("data-size","sm"):o<1e3?this.section.attr("data-size","md"):this.section.attr("data-size","lg")})})}).observe(this.section.get(0))}initOptions(){this.form.find('input[type="radio"]').on("change",e=>{this.form.find('input[type="radio"]:checked').length===this.form.find("fieldset").length&&this.loadResult()})}loadResult(){this.form.attr("method")==="get"?i.get(this.form.attr("action"),this.form.serialize()).done(e=>{this.insertResult(e)}):i.post(this.form.attr("action"),this.form.serialize()).done(e=>{this.insertResult(e)})}insertResult(e){const s=this.formBox.outerHeight()-this.form.outerHeight();this.formBox.css("height",this.formBox.outerHeight()+"px"),this.result=i(e).appendTo(this.formBox),this.formBox.css("height",this.result.outerHeight()+s+"px"),this.animateResult(),setTimeout(()=>{this.section.addClass("show-result")},50),setTimeout(()=>{this.formBox.removeAttr("style")},800)}animateResult(){const e=this.result.find(".sub-result-wrapper");e.each((s,n)=>{i('<span class="bar" />').prependTo(i(n)).css("transition-delay",(s/10).toString()+"s")}),setTimeout(()=>{e.each((s,n)=>{const o=i(n);o.find(".bar").css("width",parseInt(o.find(".value").text())+"%")})},500)}}i("body").on("ihk-init dynamic-component-loaded gfi-dynamic-init",()=>{i(".survey:not(.initiated)").each((h,e)=>{new b(i(e))})});const D=({kicker:h="Schnellumfrage",headline:e="Einführung von 2G im Einzelhandel: Was halten Sie davon?",copy:s="Hier können Sie abstimmen:",method:n="get",data:o=R})=>{const d=t("section",["participation"]),x=t("div",["container"],null,d),c=t("div",["vot-teaser","survey","variant-subtle-secondary"],null,x),m=t("div",["text-box"],null,c);t("p",["kicker"],h,m),t("h3",[],e,m),t("p",[],s,m);const y=t("div",["form-box"],null,c),r=t("form",["vot-form"],null,y);return r.id="voting-form",r.action="./html/survey-simple.html",r.dataset.showResultUrl="./html/survey-simple.html",r.dataset.showResult="false",r.method=n,o.map(a=>{const u=t("fieldset",[],null,r);a.legend&&t("legend",[],a.legend,u);const S=t("div",["choices-wrapper"],null,u),z=t("ul",["choices"],null,S);a.options.map((f,w)=>{const p=a.name+"-"+w,v=t("li",["choice"],null,z),l=t("input",[],null,v),g=B({elementType:"label",color:"white",label:f,size:"medium"});v.appendChild(g),l.name=a.name,l.id=p,l.type="radio",l.value=f,g.setAttribute("for",p)})}),new b(i(c)),d};export{C as S,R as a,D as c};
