import{$ as t}from"./iframe-DSGyX7_4.js";import{c as a}from"./helpers-DDTkKuvc.js";class r{constructor(i){this.section=i.addClass("initiated"),this.scrolling=!1,this.headlines=[],this.initHeadlines(),this.buildLinks();const e=window.location.href.match(/#(.*)/);e!=null&&this.scrollToTarget(e),t(".main-col .richtext .detail-text a[href='']").attr("href","/")}initHeadlines(){t(".main-col h2, article.col h2, .action-col .richtext h2").each((i,e)=>{const n=t(e),o=n.closest(".action-content"),s=n.closest(".online-magazine-contact").length;!n.closest(".accordion-content").length&&!o.closest(".richtext").length&&!s&&n.text().length>0&&(n.is(".showInTableOfContents")||!n.closest(".link-collection").length)&&this.headlines.push(n)})}buildLinks(){const i=this,e=i.section.find("ul li a");t(e).each((n,o)=>{const s=t(this.headlines[n]);s.length&&(t(s).addClass("has-anchor"),t(s).append(t('<span class="anchor" />').attr("id","titleInText"+n)))}),this.anchors=t(".main-col, article.col, .action-col").find("h2 .anchor"),i.links=i.section.find("a").on("click",n=>{n.preventDefault(),this.handleClick(t(n.currentTarget))})}handleClick(i){const e=parseInt(i.attr("data-index")),n=this.anchors.eq(e).offset().top;let o=Math.round(Math.abs(t(window).scrollTop()-n)/6+300);o>800&&(o=800),this.scrolling=!0,t("html, body").animate({scrollTop:n},o,"swing",()=>{this.scrolling=!1})}scrollToTarget(i){const e=t("#"+i[1]);e.length>0&&t("html, body").animate({scrollTop:e.first().offset().top-10},10)}}t("body").on("ihk-init dynamic-component-loaded gfi-dynamic-init",function(){t(".anchor-links:not(.initiated)").each(()=>{new r(t(this))})});const f=({titles:l=["Beratungsförderung zur Digitalisierung","Eine weitere Headline zwischendurch"]})=>{const i=a("div",["anchor-links","variant-base"]),e=a("ul",["anchors"],null,i);return a("li",["anchors-title"],"Inhalte auf dieser Seite",e),l.map((n,o)=>{const s=a("li",[],null,e),c=a("a",["variant-subtle-primary-hover"],n,s);c.href="#titleInText"+o,c.dataset.index=o.toString()}),t(document).ready(()=>{new r(t(i))}),i};export{f as c};
