import{_ as O,B,i as F,G as I,a6 as M,U as w,r as g,o as n,a as m,w as u,l as d,p as v,q as o,b as r,D as x,F as b,e as k,v as f,u as z}from"./main-DtyiNRRn.js";import{P as E}from"./PaginationProgressBar-BeoLQCaE.js";import{T as H}from"./TeaserBigImageElementFi-Dvg2Y453.js";import U from"./SectionDividerFi-DDwt5OTB.js";const V={name:"OverviewTeasersFi",components:{LoadingIndicator:B,ComponentWrapper:F,GridContainerFi:I,SectionDividerFi:U,TabNavigationFi:M,TeaserBigImageElementFi:H,PaginationProgressBar:E},props:{fields:{type:Object,default:()=>({})},apiUrl:{type:String,default:null,required:!0},customType:{type:String,default:null}},data(){return{isLoading:!0,currentTag:null,teaserList:[],teaserCount:0,page:0,pageSize:9,filtered:!1}},computed:{type(){var e,t;return this.customType||((t=(e=this.fields)==null?void 0:e.type)==null?void 0:t.value)},allTag(){var e,t;return{id:0,text:(t=(e=this.fields)==null?void 0:e.allTagsLabel)==null?void 0:t.value}},tags(){var e,t;return(t=(e=this.fields)==null?void 0:e.tags)!=null&&t.length?this.fields.tags.filter(i=>{var l,a;return((a=(l=i.fields)==null?void 0:l.tagName)==null?void 0:a.value)&&i.fields.tagName.value!==""}):[]},tagsLogicalOr(){var e,t;return!!((t=(e=this.fields)==null?void 0:e.tagsLogicalOr)!=null&&t.value)},activateFilters(){var e,t;return!!((t=(e=this.fields)==null?void 0:e.activateFilters)!=null&&t.value&&this.tabNavigation)},tabNavigation(){if(this.tags.length){const e=this.tags.map((t,i)=>{var l,a;return{id:i+1,text:(a=(l=t.fields)==null?void 0:l.tagName)==null?void 0:a.value,tagId:t.id}});return[this.allTag,...e]}return null},activeTag(){return this.currentTag?this.currentTag:this.allTag},pagingPercentage(){return 100*this.teaserList.length/this.teaserCount},fetchParams(){var p,h,_;const e=(h=(p=this.fields)==null?void 0:p.usePageId)!=null&&h.value?this.$fischer.pageId():null,t=this.$fischer.siteLanguage()||null,i=this.type!==this.customType?this.type:null,l=this.customType==="NewsPage"?this.$fischer.user.email():null;let a=null;return this.activeTag.id===0&&((_=this.tags)!=null&&_.length)?a=this.tags.map(T=>T.id).join("|"):this.activeTag.id!==0&&(a=this.activeTag.tagId),{pageid:e,type:i,lang:t,tags:a,tagslogicalor:this.tagsLogicalOr,email:l,page:this.page,pageSize:this.pageSize}}},mounted(){this.fetchData()},methods:{tabChanged(e){this.isLoading=!0,this.currentTag=e,this.filtered=e.id!==0,this.fetchData()},fetchData(){w.get(this.apiUrl,{params:this.fetchParams}).then(e=>{var t;(t=e.data)!=null&&t.Data&&(this.teaserCount=e.data.Data.TotalSearchResults,this.teaserList=e.data.Data.TeaserList),this.isLoading=!1}).catch(e=>{console.error(e),this.isLoading=!1})},fetchMore(){this.page+=1,w.get(this.apiUrl,{params:this.fetchParams}).then(e=>{var t;(t=e.data)!=null&&t.Data&&(this.teaserList=[...this.teaserList,...e.data.Data.TeaserList]),this.isLoading=!1}).catch(e=>{console.error(e),this.isLoading=!1})},loadMoreDict(e,t){let i=null;switch(this.type){case"StoryPage":i=this.$dict.get("teaser-Overview.Pagination.Show-Stories",[e,t]);break;case"ReferencePage":i=this.$dict.get("teaser-Overview.Pagination.Show-References",[e,t]);break;case"NewsPage":i=this.$dict.get("teaser-Overview.Pagination.Show-News",[e,t]);break;default:i=this.$dict.get("teaser-Overview.Pagination.Default",[e,t])}return i}}},q={class:"fi-col-span-full"},R={class:"fi-col-start-1 md:fi-col-start-2 fi-col-end-13 md:fi-col-end-12"},j=["innerHTML"],G=["innerHTML"],W={class:"fi-col-span-full"},A={class:"overview-teasers-fi__teasers"},J={key:1},K={key:2},Q={key:0},X={key:1};function Y(e,t,i,l,a,c){const p=g("tab-navigation-fi"),h=g("grid-container-fi"),_=g("loading-indicator"),T=g("button-fi"),P=g("teaser-big-image-element-fi"),L=g("section-divider-fi"),C=g("pagination-progress-bar"),N=g("component-wrapper");return n(),m(N,{class:"overview-teasers-fi"},{default:u(()=>[d(h,{container:!1},{default:u(()=>[v("div",q,[c.activateFilters?(n(),m(p,{key:0,class:"overview-teasers-fi__tab-navigation","tab-navigation":c.tabNavigation,"is-slider":!0,onChange:t[0]||(t[0]=s=>c.tabChanged(s))},null,8,["tab-navigation"])):o("",!0)])]),_:1}),d(h,null,{default:u(()=>{var s;return[v("div",R,[e.isEditMode?(n(),r("h3",{key:0,class:"overview-teasers-fi__headline",innerHTML:i.fields.headline.editable},null,8,j)):o("",!0),!e.isEditMode&&((s=i.fields.headline)!=null&&s.value)?(n(),r("h3",{key:1,class:"overview-teasers-fi__headline",innerHTML:i.fields.headline.value},null,8,G)):o("",!0)])]}),_:1}),d(h,{container:!1},{default:u(()=>[v("div",W,[d(x,{"enter-active-class":"animated fadeIn fastest","leave-active-class":"animated fadeOut fastest",mode:"out-in"},{default:u(()=>[a.teaserList?(n(),r("div",{key:a.currentTag?a.currentTag.id:0},[v("div",A,[a.isLoading?(n(),m(_,{key:0,variant:"spinnerLocal",class:"spinner-local--rebrush",dark:!0})):o("",!0),(n(!0),r(b,null,k(a.teaserList,(s,S)=>(n(),r(b,null,[s.Document?(n(),m(P,{key:s.Document.ItemLink,image:s.Document.Thumbnail?{src:s.Document.Thumbnail,alt:s.Document.TeaserTitle}:null,"image-pos-right":S%2!==0,"bg-color":"light"},{content:u(()=>{var y;return[s.Document.TagNames?(n(!0),r(b,{key:0},k(s.Document.TagNames.split("|"),D=>(n(),r("span",{key:D,class:"badge-fi"},f(D),1))),128)):o("",!0),s.Document.TeaserTitle?(n(),r("h3",J,f(s.Document.TeaserTitle),1)):o("",!0),s.Document.PreviewText?(n(),r("p",K,f(s.Document.PreviewText),1)):o("",!0),s.Document.ItemLink&&((y=i.fields.teaserButtonText)!=null&&y.value)?(n(),m(T,{key:3,href:s.Document.ItemLink,class:"button-fi__tertiary","natural-events":""},{default:u(()=>[z(f(i.fields.teaserButtonText.value),1)]),_:2},1032,["href"])):o("",!0)]}),_:2},1032,["image","image-pos-right"])):o("",!0)],64))),256))]),d(L),d(C,{"pagination-page":a.page+1,"pagination-total":a.teaserCount,"progressbar-value":c.pagingPercentage,"disabled-state":a.isLoading,"show-more-button":a.teaserList.length<a.teaserCount,"query-params":null,onLoadmore:c.fetchMore},{default:u(()=>[(a.page+1)*a.pageSize<=a.teaserCount?(n(),r("span",Q,f(c.loadMoreDict((a.page+1)*a.pageSize,a.teaserCount)),1)):(n(),r("span",X,f(c.loadMoreDict(a.teaserCount,a.teaserCount)),1))]),_:1},8,["pagination-page","pagination-total","progressbar-value","disabled-state","show-more-button","onLoadmore"]),d(L)])):o("",!0)]),_:1})])]),_:1})]),_:1})}const ae=O(V,[["render",Y],["__scopeId","data-v-1e855f9d"]]);export{ae as O};