import{r as t,h as i,H as s}from"./p-c1e62c18.js";import"./p-3c3b4f3f.js";import{L as e}from"./p-6f02ee7c.js";function r(t){if(t&&t.sort)return t.sort}const n=class{constructor(i){t(this,i),this.list=e.init()}async invalidate(t){this.list=e.init()}fetchList(t=!1){const{list:i,quickFilter:s}=this;if(i.isPending||i.isEndReached()||i.error&&!t)return;const{query:e,table:n}=this.view;this.list=i.beforeFetch();const o=function(t,i){let s=t?t.filter:void 0;return i&&(s=t&&t.filter?{operator:"and",filters:[t.filter,i]}:i),s}(e,s);this.apiData.query(n.name,{fields:e.fields,filter:o,limit:25,skip:i.data?i.data.length:0,sort:r(e)}).then((t=>{this.list=i.afterFetch(t)}),(t=>{this.list=i.afterFetchError(t)}))}componentWillLoad(){this.fetchList()}render(){const{list:t,view:e}=this;return i(s,null,i("div",{class:"mt-3 pt-3"},t.data&&i("dvn-card-list-view",{config:e.ui,fields:e.table.fields,items:t.data}),t.error&&i("devingen-error-card",{error:t.error,message:"Fetching list failed.",onRetry:()=>this.fetchList(!0)})))}};export{n as dvn_app_view_list_view_card}