import{r as i,h as t,H as s,g as e,c as r}from"./p-a0569a5f.js";import{g as n}from"./p-2bb9af72.js";import{r as o,c as a}from"./p-f46dff5e.js";import{d as l}from"./p-62d69891.js";import{L as d}from"./p-e7b87b96.js";import{g as c}from"./p-908ea343.js";import{I as p,N as f}from"./p-6cf8ecf7.js";import{t as h}from"./p-baa48dcc.js";import"./p-d343a062.js";import"./p-7737f905.js";import"./p-736ddb06.js";import"./p-eba4bba3.js";function v(i){if(i&&i.sort)return i.sort}let m=class{constructor(t){i(this,t),this.list=d.init(),this.onSimpleFilterChange=({filter:i})=>{this.quickFilter=i,this.fetchList(!0,!0)}}async invalidate(i){this.fetchList(!0,!0)}async retainPosition(){const i=this.el.querySelector(".list-container");i&&(i.scrollTop=this.scrollPosition)}async componentWillLoad(){this.strings=await this.apiSozluk.getContent(this.view.i18nEntryId,l),this.fetchList()}fetchList(i=!1,t=!1){const{list:s,quickFilter:e}=this;if(s.isPending||!t&&s.isEndReached()||s.error&&!i)return;const{query:r,table:l,ui:d}=this.view,c=d.quickSearch?n(d.quickSearch,l.fields):void 0,p=function(i,t,s){let e=i?i.filter:void 0;if(t&&(e=i&&i.filter?{operator:"and",filters:[i.filter,t]}:t),e)return o(a(e),s)}(r,e||c,this.params);this.list=s.beforeFetch(),this.apiData.query(l.name,{fields:r.fields,filter:p,limit:25,skip:t?0:s.data?s.data.length:0,sort:v(r)}).then((i=>{this.list=s.afterFetch(i,!t)}),(i=>{this.list=s.afterFetchError(i)}))}render(){const{list:i,view:e}=this,{ui:r}=e;return t(s,null,r.quickSearch&&t("dvn-filter-simple",{fields:this.view.table.fields,progressing:i.isPending&&!!i.data,config:r.quickSearch,onFilterChange:i=>this.onSimpleFilterChange(i.detail)}),i.data&&t("div",{class:"list-container",onScroll:i=>{const t=i.target;this.scrollPosition=t.scrollTop,t.offsetHeight+t.scrollTop>=t.scrollHeight&&this.fetchList()}},t("dvn-card-list-view",{config:e.ui,fields:e.table.fields,items:i.data,strings:this.strings}),i.isPending&&!r.quickSearch&&t("div",{class:"d-flex justify-content-center pb-3"},t("dvn-progress",{indefinite:!0,tint:"primary"}))),i.isPending&&!i.data&&t("div",{class:"d-flex justify-content-center"},t("dvn-progress",{indefinite:!0,tint:"primary"})),i.error&&t("devingen-error-card",{error:i.error,message:"Fetching list failed.",onRetry:()=>this.fetchList(!0)}))}get el(){return e(this)}};m.style="dvn-app-view-list-view-card{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden;padding:1rem}dvn-app-view-list-view-card dvn-filter-simple{margin-bottom:1rem}dvn-app-view-list-view-card .list-container{-ms-flex:1;flex:1;overflow-y:auto;overflow-x:hidden}";let g=class{constructor(t){i(this,t),this.invalidation=r(this,"invalidation",7),this.notification=r(this,"notification",7),this.action=r(this,"action",7)}async componentWillLoad(){this.strings=await this.apiSozluk.getContent(this.view.i18nEntryId,h)}render(){const{createdMeeting:i,membership:e,user:r,userSettings:n,params:{viewedUserMembershipConfig:o,viewedUserMembership:a},strings:l,view:d}=this;return t(s,{class:"d-block"},t("takvim-available-time-picker",{apiTakvim:this.apiTakvim,userId:r._id,membershipConfigId:e.config._id,userSettings:n,viewedUserId:a.user._id,viewedUserMembershipConfigId:o._id,calendarConfigId:d.table._id,onCreateMeeting:i=>{var t,s;d.successNavigationAction&&(this.createdMeeting=i.detail),null===(s=null===(t=d.events)||void 0===t?void 0:t.success)||void 0===s||s.forEach((i=>{i instanceof p&&this.invalidation.emit(i),i instanceof f&&this.notification.emit(i)}))},strings:l,weekStartDay:n.weekStartDay}),t("dvn-dialog",{title:l.meetingIsScheduled,shown:!!i,onDismiss:()=>this.createdMeeting=void 0},t("div",{slot:"actions"},t("dvn-button",{view:"flat",onClick:()=>this.createdMeeting=void 0},l.stayOnPage),t("dvn-button",{tint:"primary",view:"flat",onClick:()=>this.action.emit(c({},this.createdMeeting,this.view.successNavigationAction))},l.goToMeetingPage))))}};export{m as dvn_app_view_list_view_card,g as dvn_app_view_takvim_available_time_picker_view}