|
1
|
|
-var fe=Object.defineProperty;var ge=(t,a,e)=>a in t?fe(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e;var Z=(t,a,e)=>ge(t,typeof a!="symbol"?a+"":a,e);import{M as pe}from"./Model.js?ver=1.3.20";import{r as b,e as c,o as n,d as o,b as _,m as D,a as d,t as p,w as m,f as S,u as Y,F as T,g as N,X as ve,O as be,h as P,c as C,l as z,i as L,x as Q,G as ye,n as O,Q as ae,v as _e,q,A as ce,B as ue,S as we,R as he,z as J,U as Ve,a1 as Ce,J as Se}from"./vue.esm-bundler.js?ver=1.3.20";import{S as A,I as G}from"./IconButton.js?ver=1.3.20";import{R as E}from"./Rest.js?ver=1.3.20";import{a as ee,u as ke}from"./vue-router.js?ver=1.3.20";import{U as R}from"./Url.js?ver=1.3.20";import{A as W}from"./Arr.js?ver=1.3.20";import{t as $,A as le,a as ie}from"./Translator.js?ver=1.3.20";import{d as te}from"./dayjs.min.js?ver=1.3.20";import{u as $e,t as Te}from"./timezone.js?ver=1.3.20";import{n as B}from"./Notify.js?ver=1.3.20";import{_ as I}from"./DynamicIcon.js?ver=1.3.20";import{_ as j}from"./_plugin-vue_export-helper.js?ver=1.3.20";import{E as Ae}from"./index3.js?ver=1.3.20";import{E as X}from"./index.js?ver=1.3.20";import{U as Fe}from"./Utils.js?ver=1.3.20";import{T as me}from"./Badge.js?ver=1.3.20";const xe={name:"ProFeatureNotice",methods:{translate:$},components:{DynamicIcon:I},props:{title:{type:String},text:{type:String}}},Pe={class:"fct-pro-feature-notice-wrap"},Ie={class:"fct-pro-feature-content"},Ne={class:"fct-pro-feature-icon"},Oe={key:0,class:"fct-pro-feature-title"},De={key:1,class:"fct-pro-feature-text"};function Ue(t,a,e,i,s,l){const h=b("DynamicIcon"),u=b("el-button");return n(),c("div",Pe,[o("div",Ie,[o("div",Ne,[d(h,{name:"Crown"})]),e.title?(n(),c("h4",Oe,p(e.title),1)):_("",!0),e.text?(n(),c("p",De,p(e.text),1)):_("",!0),D(t.$slots,"default"),d(u,{type:"primary",tag:"a",href:"https://fluentcart.com/discount-deal",target:"_blank"},{default:m(()=>[d(h,{name:"Crown"}),S(" "+p(l.translate("Upgrade to Pro")),1)]),_:1})])])}const Be=j(xe,[["render",Ue]]),je={class:"fluent-cart-admin-pages"},Ee={class:"fct-pro-feature-title"},qe=["innerHTML"],ze={key:0,class:"fct-feature-list"},Me=["innerHTML"],Re={__name:"Features",props:{featureName:String,featureDescription:String,features:Array,onClose:Function},setup(t){return(a,e)=>(n(),c("div",je,[d(Be,null,{default:m(()=>[o("h4",Ee,p(Y($)("%s requires FluentCart Pro",t.featureName)),1),t.featureDescription?(n(),c("p",{key:0,class:"fct-pro-feature-text",innerHTML:t.featureDescription},null,8,qe)):_("",!0)]),_:1}),t.features.length?(n(),c("ul",ze,[(n(!0),c(T,null,N(t.features,i=>(n(),c("li",{key:i,innerHTML:i},null,8,Me))),128))])):_("",!0)]))}};class Qe{constructor(){Z(this,"$message",Ae);Z(this,"duration",1e3)}success(a){this.show(a,"success")}error(a){this.show(a,"error")}info(a){this.show(a,"info")}show(a,e="success",i=40,s=1e3){this.$message({type:e,offset:i,message:a,dangerouslyUseHTMLString:!0,duration:s??this.duration})}showFeaturesCTA(a,e,i,s){let l=null;s&&(l=s.appContext),X({title:$("Pro Feature"),message:ve(Re,{featureName:a,featureDescription:e,features:i}),customClass:"fluent-cart-pro-cta",showCancelButton:!1,showConfirmButton:!1,showFooter:!1,showClose:!0},l)}}const se=new Qe;class wl extends pe{constructor(e={}){super();Z(this,"data",{callbacks:{onDataLoaded:null},tableData:[],search:"",advanceFilters:[[]],searching:!1,selectedView:"",sorting:{sortBy:"id",sortType:"DESC"},paginate:{current_page:1,per_page:10,last_page:1,total:0,from:1,to:10},filterType:"simple",columns:[],loading:!1,inputRef:P(null),nextPageCount:10,user_tz:null,showDeleteBulkAction:!1,savedViews:[],activeSavedViewId:null,savedViewQueryParams:null,showSaveViewDialog:!1});be(()=>{this.setupInitialData(),te.extend($e),te.extend(Te),this.data.user_tz=te.tz.guess(),this.data.vueInstance=e.instance,e.fetch!==!1&&this.fetch()})}onDataLoaded(e){this.data.callbacks.onDataLoaded=e}setupInitialData(){this.setupInitialTab(),this.setupInitialColumnVisibility(),this.setupInitialFilterType(),this.setupInitialAdvanceFilter(),this.setupInitialSearch(),this.setupInitialPagination(),this.setupSavedViews()}setupInitialSearch(){this.isRouteSearchApplied()&&(this.data.search=this.isRouteSearchApplied(),this.data.searching=!0)}setupInitialPagination(){const e=A.get(this.getPerPageStorageName()),i=A.get(this.getCurrentPageStorageName());this.data.paginate.per_page=parseInt(e)||10,this.data.paginate.current_page=parseInt(i)||1}setupInitialTab(){var h;const i=(h=ee().query.active_view)==null?void 0:h.toString(),s=this.getTabsCount()?this.getTabs():{};if(i){if(s.hasOwnProperty(i)){this.data.selectedView=i;return}this.data.pendingViewFromUrl=i,this.data.selectedView=this.getDefaultView();return}const l=A.get(this.getTabStorageName());if(typeof l=="string"&&s.hasOwnProperty(l)){this.data.selectedView=l;return}typeof l=="string"&&l!==""&&(this.data.pendingViewFromStorage=l),this.data.selectedView=this.getDefaultView()}setupSavedViews(){this.data.savedViews=W.get(window,`fluentCartAdminApp.table_config.${this.getTableName()}.saved_views`)||[];const e=this.data.pendingViewFromUrl||this.data.pendingViewFromStorage;if(delete this.data.pendingViewFromUrl,delete this.data.pendingViewFromStorage,e){const i=this.data.savedViews.find(s=>s.slug===e||String(s.id)===String(e));i?(this.data.activeSavedViewId=i.slug,this.data.savedViewQueryParams=i.query_params,this._resetLiveFilter(),this.data.selectedView=this.getDefaultView()):(this.data.selectedView=this.getDefaultView(),A.set(this.getTabStorageName(),this.getDefaultView()),R.pushToVueUrl(null,{active_view:this.getDefaultView()}))}}handleTabChanged(e){const i=!!this.data.activeSavedViewId;i&&(this.data.activeSavedViewId=null,this.data.savedViewQueryParams=null,this._resetLiveFilter()),!(e===this.data.selectedView&&!i)&&(this.data.selectedView=e,this.data.paginate.current_page=1,this.setCurrentPage(1),A.set(this.getTabStorageName(),this.data.selectedView),R.pushToVueUrl(null,{active_view:this.data.selectedView}),this.fetch())}getSelectedTab(){return this.data.selectedView}setupInitialColumnVisibility(){let e=A.get(this.getColumnStorageName());if(Array.isArray(e))this.data.columns=e;else{let i=[];for(let s of this.getToggleableColumns())i.push(s.value);this.data.columns=i}}isSearching(){return this.data.searching!==!1}openSearch(){this.data.activeSavedViewId&&this.data.savedViewQueryParams&&this.data.savedViewQueryParams.filter_type!=="advanced"&&this._prefillFiltersFromParams(this.data.savedViewQueryParams),this.data.searching=!this.isUsingAdvanceFilter(),A.set(this.getToggleSearchingStorageName(),this.data.searching),this.fetch()}closeSearch(){this.data.searching=!1,this.data.search="",A.set(this.getToggleSearchingStorageName(),this.data.searching),this.fetch()}showBulkDeleteAction(e=null){this.data.showDeleteBulkAction=e,A.set(this.getDeleteBulkActionStorageName(),this.data.showDeleteBulkAction)}useFullWidthSearch(){return!1}handleSortChange(){this.fetch()}isUsingSimpleFilter(){return this.data.filterType==="simple"}setupInitialFilterType(){if(!this.isProActive()){this.data.filterType="simple";return}if(this.isRouteActiveViewApplied()||this.isRouteSearchApplied()){this.data.filterType="simple";return}const e=A.get(this.getFilterTypeStorageName());if(["simple","advanced"].includes(e)){if(e==="advanced"&&!this.isAdvanceFilterEnabled())return;this.data.filterType=e}const i=A.get(this.getToggleSearchingStorageName());i&&(this.data.searching=i);const s=A.get(this.getDeleteBulkActionStorageName());s&&(this.data.showDeleteBulkAction=s)}onFilterTypeChanged(e){e==="advanced"&&(this.data.searching=!1,this.data.search="",this.data.activeSavedViewId&&this.data.savedViewQueryParams&&this.data.savedViewQueryParams.filter_type==="advanced"&&this._prefillFiltersFromParams(this.data.savedViewQueryParams)),e==="simple"&&this.fetch(),A.set(this.getFilterTypeStorageName(),this.data.filterType)}setupInitialAdvanceFilter(){let e=A.get(this.getAdvancedFilterStorageName());typeof e=="string"&&(e=[[]]),this.data.advanceFilters=e}isProActive(){return le.get("app_config.isProActive")}applyAdvancedFilter(e=!1){if(!this.isProActive()){e||se.showFeaturesCTA($("Advanced Filter"),$("Advanced filter is only available in pro version"),[],this.data.vueInstance),this.storeAdvanceFilter();return}this.setCurrentPage(1),this.fetch(),this.storeAdvanceFilter()}storeAdvanceFilter(){A.set(this.getAdvancedFilterStorageName(),this.data.advanceFilters)}isUsingAdvanceFilter(){return this.data.filterType==="advanced"}addAdvanceFilterGroup(){this.data.advanceFilters.push([])}removeAdvanceFilterGroup(e){this.data.advanceFilters.length>1&&this.data.advanceFilters.splice(e,1),this.storeAdvanceFilter()}clearAdvanceFilter(){this.data.advanceFilters=[[]],this.applyAdvancedFilter()}getAdvanceFilterOptions(){return W.get(window,`fluentCartAdminApp.table_config.${this.getTableName()}.filters.advance`)}getSearchGuideOptions(){return W.get(window,`fluentCartAdminApp.table_config.${this.getTableName()}.filters.guide`)||[]}isAdvanceFilterEnabled(){return this.getAdvanceFilterOptions()!==null}buildQueryParams(){const e={per_page:this.data.paginate.per_page,page:this.data.paginate.current_page,sort_by:this.data.sorting.sortBy,sort_type:this.data.sorting.sortType,with:this.with(),scopes:this.scopes()};return this.data.activeSavedViewId?e.active_view=this.data.activeSavedViewId:this.isUsingAdvanceFilter()||(e.active_view=this.data.selectedView),this.isUsingAdvanceFilter()?(e.filter_type="advanced",e.advanced_filters=JSON.stringify(this.data.advanceFilters)):(e.filter_type="simple",e.search=this.data.search),e}search(){R.pushToVueUrl(null,{search:this.data.search}),this.fetch()}fetch(){this.data.loading=!0;let e=this.buildQueryParams();e.user_tz=this.data.user_tz,E.get(this.getFetchUrl(),e).then(i=>{const s=this.parseResponse(i);this.data.tableData=s.data,this.data.paginate.total=s.total,this.data.paginate.last_page=s.last_page,this.data.paginate.from=s.from,this.data.paginate.to=s.to,this.data.nextPageCount=this.guessNextPageCount(s),typeof this.data.callbacks.onDataLoaded=="function"&&this.data.callbacks.onDataLoaded(i)}).catch(i=>{var s;i.status_code=="422"?B.validationErrors(i):B.error((s=i.data)==null?void 0:s.message),this.data.tableData=[]}).finally(()=>{this.data.loading=!1})}getTableData(){return this.data.tableData}isLoading(){return this.data.loading===!0}getDefaultView(){return"all"}handleColumnVisibilityChange(){A.set(this.getColumnStorageName(),this.data.columns)}handlePerPageChange(){this.data.paginate.current_page=1,this.setCurrentPage(1),A.set(this.getPerPageStorageName(),this.data.paginate.per_page),this.fetch()}handlePageChange(){this.fetch(),this.setCurrentPage()}setCurrentPage(e){A.set(this.getCurrentPageStorageName(),e||this.data.paginate.current_page)}getCurrentPage(){return A.get(this.getCurrentPageStorageName())}getColumnStorageName(){return`${this.getTableName()}_columns`}getTabStorageName(){return`${this.getTableName()}_tab`}getFilterTypeStorageName(){return`${this.getTableName()}_filter_type`}getAdvancedFilterStorageName(){return`${this.getTableName()}_advanced_filter`}getPerPageStorageName(){return`${this.getTableName()}_per_page`}getCurrentPageStorageName(){return`${this.getTableName()}_current_page`}getToggleSearchingStorageName(){return`${this.getTableName()}_toggle_searching`}getDeleteBulkActionStorageName(){return`${this.getTableName()}_delete_bulk_action`}getSavedViews(){return this.data.savedViews}getActiveSavedViewId(){return this.data.activeSavedViewId}getCurrentUserId(){return le.get("me.id")}isViewOwner(e){return e.owner_id===this.getCurrentUserId()}promptAndSaveView(){if(!this.isProActive()){se.showFeaturesCTA($("Saved Views"),$("Saved views is only available in pro version"),[],this.data.vueInstance);return}this.data.showSaveViewDialog=!0}_resetLiveFilter(){this.data.search="",this.data.searching=!1,this.data.advanceFilters=[[]],this.data.filterType="simple",A.set(this.getFilterTypeStorageName(),"simple")}_prefillFiltersFromParams(e){if(e){if(e.filter_type==="advanced"&&e.advanced_filters){let i;try{i=typeof e.advanced_filters=="string"?JSON.parse(e.advanced_filters):e.advanced_filters}catch{i=[[]]}this.data.advanceFilters=Array.isArray(i)?i:[[]],this.data.search="",this.data.searching=!1,this.data.filterType="advanced"}else this.data.search=e.search||"",this.data.advanceFilters=[[]],this.data.searching=!!e.search,this.data.filterType="simple",e.active_view&&(this.data.selectedView=e.active_view);A.set(this.getFilterTypeStorageName(),this.data.filterType)}}_buildViewQueryParams(){const e={filter_type:this.data.filterType};return this.data.filterType==="advanced"?e.advanced_filters=JSON.stringify(this.data.advanceFilters):(e.search=this.data.search,e.active_view=this.data.selectedView),e}saveCurrentView(e,i,s){if(this.data.savedViews.length>=20)return B.error($("Maximum of 20 saved views reached")),null;const l=this._buildViewQueryParams();return E.post("saved-views",{object_type:this.getTableName(),name:e,description:i||"",is_public:s||!1,query_params:l}).then(h=>{const u=h.view;u.object_type=this.getTableName(),this.data.savedViews.push(u),this._syncGlobalSavedViews(),this.data.activeSavedViewId=u.slug,this.data.savedViewQueryParams=u.query_params,this._resetLiveFilter(),this.data.selectedView=this.getDefaultView(),A.set(this.getTabStorageName(),u.slug),R.pushToVueUrl(null,{active_view:u.slug})}).catch(h=>{var u;B.error(((u=h.data)==null?void 0:u.message)||$("Failed to save view"))})}applySavedView(e){const i=this.data.savedViews.find(s=>s.slug===e);i&&(this.data.activeSavedViewId=e,this.data.savedViewQueryParams=i.query_params,this._resetLiveFilter(),this.data.selectedView=this.getDefaultView(),this.data.paginate.current_page=1,this.setCurrentPage(1),A.set(this.getTabStorageName(),e),R.pushToVueUrl(null,{active_view:e}),this.fetch())}updateSavedView(e){const i=this.data.savedViews.find(l=>l.slug===e);if(!i)return;const s=this._buildViewQueryParams();E.put("saved-views/"+i.id,{query_params:s}).then(l=>{i.query_params=s}).catch(l=>{var h;B.error(((h=l.data)==null?void 0:h.message)||$("Failed to update view"))})}deleteSavedView(e){const i=this.data.savedViews.find(s=>s.slug===e);i&&E.delete("saved-views/"+i.id).then(()=>{const s=this.data.savedViews.findIndex(l=>l.slug===e);s!==-1&&this.data.savedViews.splice(s,1),this._syncGlobalSavedViews(),this.data.activeSavedViewId===e&&(this.data.activeSavedViewId=null,this.data.savedViewQueryParams=null,this.data.selectedView=this.getDefaultView(),this.data.filterType="simple",this.data.advanceFilters=[[]],this.data.search="",this.data.searching=!1,A.set(this.getFilterTypeStorageName(),"simple"),A.set(this.getTabStorageName(),this.getDefaultView()),R.pushToVueUrl(null,{active_view:this.getDefaultView()}),this.fetch())}).catch(s=>{var l;B.error(((l=s.data)==null?void 0:l.message)||$("Failed to delete view"))})}renameSavedView(e,i){const s=this.data.savedViews.find(l=>l.slug===e);s&&E.put("saved-views/"+s.id,{name:i}).then(l=>{s.name=i,this._syncGlobalSavedViews()}).catch(l=>{var h;B.error(((h=l.data)==null?void 0:h.message)||$("Failed to rename view"))})}_syncGlobalSavedViews(){if(window.fluentCartAdminApp&&window.fluentCartAdminApp.table_config){const e=this.getTableName();window.fluentCartAdminApp.table_config[e]||(window.fluentCartAdminApp.table_config[e]={}),window.fluentCartAdminApp.table_config[e].saved_views=this.data.savedViews}}isColumnVisible(e){return this.data.columns.includes(e)}getSearchHint(){throw new Error("Override getSearchHint method")}getFetchUrl(){throw new Error("Override getFetchUrl method")}getTabs(){throw new Error("Override getTabs method")}getTabsCount(){const e=this.getTabs();return e?Object.keys(e).length:0}getToggleableColumns(){throw new Error("Override getToggleableColumns method")}getSortableColumns(){throw new Error("Override getSortableColumns method")}getTableName(){throw new Error("Override getTableName method")}parseResponse(e){throw new Error("Override parseResponse method")}with(){return[]}scopes(){return[]}isRouteActiveViewApplied(){return ee().query.active_view||!1}isRouteSearchApplied(){return ee().query.search||!1}guessNextPageCount(e){const{total:i,to:s,per_page:l,current_page:h,last_page:u}=e;if(h>=u)return 1;const r=i-s;return Math.max(1,Math.min(l,r))}get nextPageCount(){return this.data.nextPageCount}guessTitle(){let e=this.getTableName();return e=e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase(),e=e.replace(/_?table$/,""),e.split("_").map(i=>i.charAt(0).toLowerCase()+i.slice(1)).join(" ")}isFiltering(){return this.isUsingAdvanceFilter()?(this.data.advanceFilters||[]).some(e=>Array.isArray(e)&&e.length>0)?"advanced":!1:this.data.search!==""?"search":this.data.selectedView!=="all"?"tab":!1}emptyMessageFiltered(e){return e==="search"||e==="tab"?$("No %s found based on your search",this.guessTitle()):$("No %s found based on your filter",this.guessTitle())}getEmptyMessage(){return $("No %s found",this.guessTitle())}get emptyMessage(){const e=this.isFiltering();return e?this.emptyMessageFiltered(e):this.getEmptyMessage()}getCustomColumns(){return W.get(window,`fluentCartAdminApp.table_config.${this.getTableName()}.filters.columns`)||{}}}const Ge={props:{table:{type:Object,required:!1},pagerSizes:{type:Boolean,default:!0},pagination:{required:!0,type:Object},extra_sizes:{required:!1,type:Array,default(){return[]}},hide_on_single:{required:!1,type:Boolean,default(){return!0}},background:{type:Boolean,default:!0},layout:{type:String,default:"prev, pager, next, slot"},pager_count:{type:Number,default:5}},data(){return{currentPage:1,pickerObserver:null,paginationUpdating:!1}},computed:{page_sizes(){const t=[];this.pagination.per_page<10&&t.push(this.pagination.per_page);const a=[10,20,50,80,100,120,150];return[...t,...a,...this.extra_sizes]},totalPage(){const t=this.pagination.per_page,a=this.pagination.total;return isNaN(a)||a<=0?0:Math.ceil(a/t)}},watch:{pagination:{immediate:!0,handler(t,a){setTimeout(()=>{this.translatePickerElements()},400)}},"pagination.last_page":{handler(t,a){t!==a&&(this.paginationUpdating=!0,this.$nextTick(()=>{this.paginationUpdating=!1}))},flush:"sync"}},methods:{translateNumber:ie,translate:$,changePage(t){var e;if(this.paginationUpdating)return;let a=this.getCurrentPageCount(t,this.pagination.per_page);this.currentPage=t,this.pagination.current_page=t,this.$emit("currentPageChanged",{page:t,currentPageCount:a}),this.$emit("fetch"),(e=this.table)==null||e.handlePageChange(),setTimeout(()=>{this.translatePickerElements()},300)},changeSize(t){var a;this.currentPage=1,this.pagination.current_page=1,this.$emit("onPerPageChanged",t),this.$emit("fetch"),(a=this.table)==null||a.handlePerPageChange()},getCurrentPageCount(t,a){return(t<this.pagination.last_page?a:this.pagination.total%a)||a},translatePickerElements(){const t=document.querySelector(".el-pagination.is-background");if(!t)return;t.querySelectorAll("li.number").forEach(i=>{const s=i.textContent.trim();if(s&&/\d/.test(s)&&!i.dataset.translated){const l=ie(s);i.style.setProperty("--translated-number",`"${l}"`),i.dataset.translated="1"}})}},mounted(){this.translatePickerElements()}},He={class:"pagination-wrap"},We={key:0,class:"pager-wrap"},Je={class:"text"},Ye={class:"el-pagination"},Ke={class:"text"};function Ze(t,a,e,i,s,l){const h=b("el-option"),u=b("el-select"),r=b("el-pagination");return n(),c("div",He,[e.pagerSizes?(n(),c("div",We,[o("span",Je,p(l.translate("Page %1$s of %2$s",l.translateNumber(s.currentPage),l.translateNumber(l.totalPage))),1),o("div",Ye,[d(u,{onChange:l.changeSize,modelValue:e.pagination.per_page,"onUpdate:modelValue":a[0]||(a[0]=f=>e.pagination.per_page=f),placeholder:l.translate("Select")},{default:m(()=>[(n(!0),c(T,null,N(l.page_sizes,f=>(n(),C(h,{key:f,label:l.translate("%s / page",l.translateNumber(f)),value:f},null,8,["label","value"]))),128))]),_:1},8,["onChange","modelValue","placeholder"])]),o("span",Ke,p(l.translate("Total %s",l.translateNumber(e.pagination.total))),1)])):_("",!0),d(r,{ref:"paginationRef","hide-on-single-page":e.hide_on_single,background:e.background,"current-page":e.pagination.current_page,layout:e.layout,onCurrentChange:l.changePage,"page-sizes":l.page_sizes,total:e.pagination.total,"pager-count":e.pager_count,"page-size":e.pagination.per_page},{default:m(f=>[S(p(f),1)]),_:1},8,["hide-on-single-page","background","current-page","layout","onCurrentChange","page-sizes","total","pager-count","page-size"])])}const Xe=j(Ge,[["render",Ze]]),Le={class:"filter-popover-item"},et={class:"filter-popover-title"},ne={__name:"ColumnVisibility",props:{table:Object},setup(t){return(a,e)=>{const i=b("el-checkbox"),s=b("el-checkbox-group"),l=b("el-tooltip"),h=b("el-popover");return n(),C(h,{trigger:"click",placement:"bottom-start",width:"240","popper-class":"filter-popover"},{reference:m(()=>[o("span",null,[d(l,{effect:"light",content:a.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:m(()=>[d(G,{tag:"button"},{default:m(()=>[d(I,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:m(()=>[o("div",Le,[o("h3",et,p(a.$t("Columns")),1),d(s,{onChange:e[0]||(e[0]=()=>{t.table.handleColumnVisibilityChange()}),class:"fct-checkbox-blocks",modelValue:t.table.data.columns,"onUpdate:modelValue":e[1]||(e[1]=u=>t.table.data.columns=u)},{default:m(()=>[(n(!0),c(T,null,N(t.table.getToggleableColumns(),u=>(n(),C(i,{key:u.value,value:u.value,label:u.label},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})}}},tt={class:"filter-popover-item"},at={class:"filter-popover-title"},oe={__name:"ColumnSort",props:{table:Object},setup(t){return(a,e)=>{const i=b("el-radio"),s=b("el-radio-group"),l=b("el-radio-button"),h=b("el-tooltip"),u=b("el-popover");return n(),C(u,{trigger:"click",placement:"bottom-start",width:"240","popper-class":"filter-popover"},{reference:m(()=>[o("span",null,[d(h,{effect:"light",content:a.$t("Sort"),placement:"top","popper-class":"fct-tooltip"},{default:m(()=>[d(G,{tag:"button"},{default:m(()=>[d(I,{name:"ArrowUpDown"})]),_:1})]),_:1},8,["content"])])]),default:m(()=>[o("div",tt,[o("h3",at,p(a.$t("Sort By")),1),d(s,{onChange:e[0]||(e[0]=()=>{t.table.handleSortChange()}),class:"fct-radios-blocks",modelValue:t.table.data.sorting.sortBy,"onUpdate:modelValue":e[1]||(e[1]=r=>t.table.data.sorting.sortBy=r)},{default:m(()=>[(n(!0),c(T,null,N(t.table.getSortableColumns(),r=>(n(),C(i,{key:r.value,value:r.value,label:r.label},null,8,["value","label"]))),128))]),_:1},8,["modelValue"]),e[4]||(e[4]=o("hr",null,null,-1)),d(s,{onChange:e[2]||(e[2]=()=>{t.table.handleSortChange()}),size:"small",modelValue:t.table.data.sorting.sortType,"onUpdate:modelValue":e[3]||(e[3]=r=>t.table.data.sorting.sortType=r)},{default:m(()=>[d(l,{value:"ASC"},{default:m(()=>[S(p(a.$t("Ascending")),1)]),_:1}),d(l,{value:"DESC"},{default:m(()=>[S(p(a.$t("Descending")),1)]),_:1})]),_:1},8,["modelValue"])])]),_:1})}}},lt={__name:"FluidTab",props:{activeIndex:null,hasIcon:{type:Boolean,default:!1},small:{type:Boolean,default:!1}},setup(t,{expose:a}){const e=t,i=P(null),s=P(0),l=P(0),h=P(0),u=P(0),r=P(null),f=z(()=>({left:`${s.value}px`,top:`${l.value}px`,width:`${h.value}px`,height:`${u.value}px`})),k=v=>{if(!i.value||!v)return;const F=i.value.getBoundingClientRect(),{left:U,width:x,height:H,top:w}=v.getBoundingClientRect();s.value=U-F.left,l.value=w-F.top,h.value=x,u.value=H,r.value=v},y=v=>{if(!i.value)return;const F=i.value.children;F[v]&&k(F[v])},g=()=>{Q(()=>{if(!i.value)return;const v=i.value.children,F=Array.from(v).find(U=>U.classList.contains("active"));F&&k(F)})},V=v=>r.value===v;return a({setActiveByActiveClass:g,setActiveByIndex:y}),ae("setActiveItem",k),ae("isActiveItem",V),window.addEventListener("resize",()=>{r.value&&k(r.value)}),L(()=>{Q(()=>{e.activeIndex?y(e.activeIndex-1):g()})}),(v,F)=>(n(),c("div",{class:O(`fct-fluid-tab ${t.hasIcon?"is-icon":""} ${t.small?"small":""}`),ref_key:"tab",ref:i},[o("div",{class:"fct-fluid-tab-active-bar",style:ye(f.value)},null,4),D(v.$slots,"default")],2))}},it={name:"FluidTabItem",props:{label:String,requiredConfirmation:{type:Boolean,default:!1},onClick:{type:Function,default:null}},inject:["setActiveItem","isActiveItem"],data(){return{isActive:!1}},mounted(){this.updateActive()},methods:{clicked(){if(this.requiredConfirmation){typeof this.onClick=="function"&&this.onClick(this.updateActive);return}this.updateActive(),this.$emit("click")},updateActive(){var t;(t=this.$refs)!=null&&t.btn&&this.setActiveItem(this.$refs.btn),this.isActive=this.isActiveItem(this.$refs.btn)}},updated(){this.isActive=this.isActiveItem(this.$refs.btn)}};function st(t,a,e,i,s,l){return n(),c("span",{class:"fct-fluid-tab-item",onClick:a[0]||(a[0]=(...h)=>l.clicked&&l.clicked(...h)),ref:"btn"},[e.label?(n(),c(T,{key:0},[S(p(e.label),1)],64)):D(t.$slots,"default",{key:1})],512)}const re=j(it,[["render",st]]),nt={class:"inline-flex items-center gap-1"},ot={key:0,xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"opacity-40"},rt={key:0,style:{display:"flex","align-items":"center","justify-content":"space-between",width:"100%"}},dt={class:"select-label"},ct={key:0,class:"select-desc"},ut=["onClick"],ht={xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{opacity:"0.6"}},mt={key:1},ft={class:"select-label"},gt={class:"select-desc"},pt={__name:"FilterTabs",props:{table:Object},setup(t){const a=t,e=P(""),i=z(()=>{const y=a.table.getTabs(),g=Object.entries(y),v=a.table.getSavedViews().map(w=>[w.slug,{title:w.name,isCustomView:!0,viewId:w.slug,description:w.description||"",is_public:w.is_public,owner_id:w.owner_id}]),F=[...g,...v];let U=F.slice(0,4);const x=Object.fromEntries(U),H=Object.fromEntries(F.filter(([w])=>!x.hasOwnProperty(w)));return{visibleTabs:x,excludedTabs:H}}),s=P(null);L(()=>{const y=a.table.getActiveSavedViewId();y&&i.value.excludedTabs.hasOwnProperty(y)?e.value=y:i.value.excludedTabs.hasOwnProperty(a.table.getSelectedTab())&&(e.value=a.table.getSelectedTab())}),_e(()=>a.table.data.activeSavedViewId,y=>{Q(()=>{s.value&&(y&&i.value.excludedTabs.hasOwnProperty(y)?(e.value=y,s.value.setActiveByIndex(-1)):s.value.setActiveByActiveClass())})});const l=(y,g)=>{const V=a.table.getActiveSavedViewId();return g&&g.isCustomView?V===g.viewId:!V&&a.table.getSelectedTab()===y},h=(y,g)=>{a.table.isUsingAdvanceFilter()&&!(g&&g.isCustomView)||(g&&g.isCustomView?(a.table.applySavedView(g.viewId),i.value.excludedTabs.hasOwnProperty(g.viewId)||(e.value="")):(a.table.handleTabChanged(y),i.value.excludedTabs.hasOwnProperty(a.table.getSelectedTab())||(e.value="")))},u=y=>{const g=i.value.excludedTabs[y];g&&g.isCustomView?a.table.applySavedView(g.viewId):a.table.isUsingAdvanceFilter()||a.table.handleTabChanged(y)},r=()=>{setTimeout(()=>{const y=a.table.getActiveSavedViewId();let g=-1;if(!y){const V=Object.keys(i.value.visibleTabs).indexOf(a.table.getSelectedTab());g=V!==-1?V+1:-1}s.value.setActiveByIndex(g)},50)},f=async(y,g)=>{try{const{value:V}=await X.prompt($("Enter a new name"),$("Rename View"),{confirmButtonText:$("Save"),cancelButtonText:$("Cancel"),inputValue:g,inputValidator:v=>!!(v!=null&&v.trim())||$("Name is required")});V&&V.trim()&&a.table.renameSavedView(y,V.trim())}catch{}},k=async y=>{try{await X.confirm($("Are you sure you want to delete this view?"),$("Delete View"),{confirmButtonText:$("Delete"),cancelButtonText:$("Cancel"),type:"warning"}),a.table.deleteSavedView(y),e.value===y&&(e.value="")}catch{}};return(y,g)=>{const V=b("el-dropdown-item"),v=b("el-dropdown-menu"),F=b("el-dropdown"),U=b("el-tooltip"),x=b("el-option"),H=b("el-select");return n(),C(lt,{class:O(t.table.isUsingAdvanceFilter()&&!t.table.getActiveSavedViewId()?"is-disabled":""),ref_key:"fluidTab",ref:s},{default:m(()=>[(n(!0),c(T,null,N(i.value.visibleTabs,(w,M)=>(n(),C(re,{key:M,class:O(l(M,w)?"active":""),onClick:()=>h(M,w)},{default:m(()=>[w&&w.isCustomView?(n(),C(U,{key:0,content:w.description||"",disabled:!w.description,placement:"top",effect:"light","popper-class":"fct-tooltip"},{default:m(()=>[o("span",nt,[o("span",null,p(w.title),1),w.is_public?(n(),c("svg",ot,g[4]||(g[4]=[o("circle",{cx:"12",cy:"12",r:"10"},null,-1),o("path",{d:"M2 12h20"},null,-1),o("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"},null,-1)]))):_("",!0),t.table.isViewOwner(w)?(n(),C(F,{key:1,trigger:"click",onCommand:K=>{K==="rename"?f(w.viewId,w.title):K==="update"?t.table.updateSavedView(w.viewId):K==="delete"&&k(w.viewId)},onClick:g[1]||(g[1]=q(()=>{},["stop"]))},{dropdown:m(()=>[d(v,null,{default:m(()=>[d(V,{command:"rename"},{default:m(()=>[S(p(y.$t("Rename")),1)]),_:1}),d(V,{command:"update"},{default:m(()=>[S(p(y.$t("Update filters")),1)]),_:1}),d(V,{command:"delete",divided:""},{default:m(()=>[S(p(y.$t("Delete")),1)]),_:1})]),_:1})]),default:m(()=>[o("span",{class:"inline-flex items-center text-system-light cursor-pointer opacity-50 hover:opacity-100 dark:text-gray-400 [&_svg]:w-3 [&_svg]:h-3",onClick:g[0]||(g[0]=q(()=>{},["stop"]))},[d(I,{name:"ChevronDown"})])]),_:2},1032,["onCommand"])):_("",!0)])]),_:2},1032,["content","disabled"])):(n(),c(T,{key:1},[S(p(typeof w=="object"?w.title:w),1)],64))]),_:2},1032,["class","onClick"]))),128)),Object.keys(i.value.excludedTabs).length>0?(n(),C(re,{key:0,class:"fct-fluid-tab-select-wrap"},{default:m(()=>[d(H,{placeholder:Y($)("More views"),modelValue:e.value,"onUpdate:modelValue":g[2]||(g[2]=w=>e.value=w),onChange:u,onVisibleChange:g[3]||(g[3]=w=>{w||r()}),class:O(["w-[120px]",{active:e.value}]),"popper-class":"fct-fluid-tab-select"},{default:m(()=>[(n(!0),c(T,null,N(i.value.excludedTabs,(w,M)=>(n(),C(x,{key:M,label:typeof w=="object"?w.title:w,value:M},{default:m(()=>[w&&w.isCustomView?(n(),c("div",rt,[o("div",null,[o("div",dt,p(w.title),1),w.description?(n(),c("div",ct,p(w.description),1)):_("",!0)]),t.table.isViewOwner(w)?(n(),c("span",{key:0,style:{display:"inline-flex","align-items":"center",cursor:"pointer",padding:"2px"},onClick:q(K=>k(w.viewId),["stop"])},[(n(),c("svg",ht,g[5]||(g[5]=[o("polyline",{points:"3 6 5 6 21 6"},null,-1),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])))],8,ut)):_("",!0)])):typeof w=="object"?(n(),c("div",mt,[o("div",ft,p(w.title),1),o("div",gt,p(w.description),1)])):(n(),c(T,{key:2},[S(p(w),1)],64))]),_:2},1032,["label","value"]))),128))]),_:1},8,["placeholder","modelValue","class"])]),_:1})):_("",!0)]),_:1},8,["class"])}}},vt={key:0,class:"fct-alert-icon"},bt={__name:"Alert",props:{type:{type:String,default:""},content:{type:String,default:""},icon:{type:String,default:""},closable:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:a}){const e=t,i=z(()=>({"fct-alert":!0,"fct-alert-info":e.type==="info","fct-alert-success":e.type==="success","fct-alert-warning":e.type==="warning","fct-alert-error":e.type==="error"})),s=a,l=()=>{s("close")};return(h,u)=>(n(),c("div",{class:O(i.value)},[t.icon?(n(),c("div",vt,[d(I,{name:t.icon},null,8,["name"])])):_("",!0),h.$slots.content?D(h.$slots,"content",{key:1}):(n(),c(T,{key:2},[S(p(t.content),1)],64)),t.closable?(n(),c("div",{key:3,class:"fct-alert-close",onClick:l},[d(I,{name:"Cross"})])):_("",!0),D(h.$slots,"default")],2))}},yt={class:"fct-search-guide-wrap"},_t={class:"fct-search-guide-example"},wt={class:"fct-search-guide-list"},Vt={class:"fct-search-guide-example"},Ct={class:"fct-search-guide-examples-list"},St={key:0},kt=["onClick"],$t={class:"example-query"},Tt={class:"click-hint"},At={class:"fct-search-guide-example"},Ft={class:"fct-search-guide-examples-list"},xt=["onClick"],Pt={class:"example-query"},It={class:"example-description"},Nt={key:0,class:"example-description"},Ot={key:0,class:"click-hint"},de={__name:"SearchGuide",props:{table:{type:Object,required:!0}},setup(t){const a=P(!1),e=P("examples"),i=t,s=l=>{i.table.data.search=l,i.table.search(),a.value=!1};return(l,h)=>{const u=b("el-button"),r=b("el-tag"),f=b("el-tab-pane"),k=b("el-tabs"),y=b("el-dialog");return n(),c(T,null,[d(u,{class:"fct-search-guide-btn",link:"",size:"small",onClick:h[0]||(h[0]=g=>a.value=!0)},{default:m(()=>[S(p(l.$t("Search Help")),1)]),_:1}),d(y,{modelValue:a.value,"onUpdate:modelValue":h[2]||(h[2]=g=>a.value=g),title:l.$t("Search Operators Guide"),"append-to-body":!0,class:"fct-search-guide-dialog"},{default:m(()=>[o("div",yt,[o("div",_t,[o("h5",null,p(l.$t("Available Operators")),1),o("ul",wt,[o("li",null,[d(r,{type:"info"},{default:m(()=>[S("> "+p(l.$t("Greater Than")),1)]),_:1})]),o("li",null,[d(r,{type:"info"},{default:m(()=>[S("< "+p(l.$t("Less Than")),1)]),_:1})]),o("li",null,[d(r,{type:"info"},{default:m(()=>[S(">= "+p(l.$t("Greater Than or Equal")),1)]),_:1})]),o("li",null,[d(r,{type:"info"},{default:m(()=>[S("<= "+p(l.$t("Less Than or Equal")),1)]),_:1})]),o("li",null,[d(r,{type:"info"},{default:m(()=>[S("= "+p(l.$t("Equal")),1)]),_:1})]),o("li",null,[d(r,{type:"info"},{default:m(()=>[S("!= "+p(l.$t("Not Equal")),1)]),_:1})])])]),d(bt,{icon:"InformationFill",type:"info",content:l.$t("Note: For plain text searches, simply type your query without operators. The system will search across all text fields.")},null,8,["content"]),d(k,{modelValue:e.value,"onUpdate:modelValue":h[1]||(h[1]=g=>e.value=g),class:"demo-tabs"},{default:m(()=>[d(f,{label:l.$t("Examples"),name:"examples"},{default:m(()=>[o("div",Vt,[o("div",Ct,[(n(!0),c(T,null,N(t.table.getSearchGuideOptions(),(g,V)=>{var v;return n(),c(T,{key:V},[(v=g.examples)!=null&&v.length?(n(),c("h5",St,p(Y($)("Field: ")+V),1)):_("",!0),(n(!0),c(T,null,N(g.examples,(F,U)=>(n(),c("div",{key:U,class:"fct-search-guide-example-item",onClick:()=>{s(F)}},[o("div",null,[o("div",$t,p(F),1)]),o("div",Tt,p(l.$t("Click to try")),1)],8,kt))),128))],64)}),128))])])]),_:1},8,["label"]),d(f,{label:l.$t("Fields"),name:"fields"},{default:m(()=>[o("div",At,[o("div",Ft,[(n(!0),c(T,null,N(t.table.getSearchGuideOptions(),(g,V)=>{var v;return n(),c("div",{key:V,class:"fct-search-guide-example-item",onClick:()=>{Array.isArray(g.examples)&&g.examples.length>0&&s(g.examples[0])}},[o("div",null,[o("div",Pt,p(V),1),o("div",It,p(g.description),1),g.note?(n(),c("div",Nt,p(g.note),1)):_("",!0)]),(v=g.examples)!=null&&v.length?(n(),c("div",Ot,p(l.$t("Click to try")),1)):_("",!0)],8,xt)}),128))])])]),_:1},8,["label"])]),_:1},8,["modelValue"])])]),_:1},8,["modelValue","title"])],64)}}},Dt={class:"relative"},Ut={key:0,class:"absolute top-0 left-0 w-full h-full"},Bt={class:"h-full w-full"},jt={__name:"RemoteTreeSelect",props:ce({table:{type:Object,required:!0},itemConfig:{type:Object,required:!0}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const a=t,e=ue(t,"modelValue"),i=P(""),s=P(a.itemConfig.options??[]),l=P(!1),h=async()=>{i.value.toString().length===0&&s.value.length>0||(l.value=!0,E.get("advance_filter/get-filter-options",{search:i.value,remote_data_key:a.itemConfig.remote_data_key,include_ids:e.value,limit:a.itemConfig.limit}).then(r=>{s.value=r.options}).catch(r=>{B.error(r)}).finally(()=>{l.value=!1}))},u=r=>{i.value=r,h()};return L(()=>{typeof s.value=="object"&&Object.values(s.value).length>0||h()}),(r,f)=>{const k=b("el-tree-select"),y=we("loading");return n(),c("div",Dt,[d(k,{modelValue:e.value,"onUpdate:modelValue":f[0]||(f[0]=g=>e.value=g),data:s.value,multiple:"",filterable:"","check-strictly":t.itemConfig.check_strictly||!1,"show-checkbox":"","reserve-keyword":!1,"filter-method":Y(Fe).debounce(u,500),"render-after-expand":!0,size:"small",onChange:f[1]||(f[1]=()=>{t.table.applyAdvancedFilter()})},null,8,["modelValue","data","check-strictly","filter-method"]),l.value?(n(),c("div",Ut,[he(o("div",Bt,null,512),[[y,!0]])])):_("",!0)])}}},Et={__name:"SelectItem",props:ce({table:{type:Object,required:!0},itemConfig:{type:Object,required:!0}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const a=t,e=ue(t,"modelValue"),i=P({}),s=P(!1),l=z(()=>a.itemConfig.remote?i.value:a.itemConfig.options||{}),h=async r=>{a.itemConfig.remote&&(s.value=!0,E.get("advance_filter/get-filter-options",{search:r,remote_data_key:a.itemConfig.remote_data_key,include_ids:e.value,limit:a.itemConfig.limit}).then(f=>{i.value=f.options}).catch(f=>{B.error(f),i.value={}}).finally(()=>{s.value=!1}))},u=()=>{a.table.applyAdvancedFilter()};return L(()=>{h("")}),(r,f)=>{const k=b("el-option"),y=b("el-select");return t.itemConfig.options||t.itemConfig.remote?(n(),C(y,{key:0,onChange:u,"remote-method":h,size:"small",modelValue:e.value,"onUpdate:modelValue":f[0]||(f[0]=g=>e.value=g),multiple:t.itemConfig.is_multiple,placeholder:Y($)("Select Option"),remote:!0,filterable:t.itemConfig.remote,"remote-show-suffix":t.itemConfig.remote,loading:s.value},{default:m(()=>[(n(!0),c(T,null,N(l.value,(g,V)=>(n(),C(k,{key:V,value:V,label:g},null,8,["value","label"]))),128))]),_:1},8,["modelValue","multiple","placeholder","filterable","remote-show-suffix","loading"])):_("",!0)}}},qt={name:"FilterItem",props:["item","filterLabels","table"],components:{SelectItem:Et,RemoteTreeSelect:jt,DynamicIcon:I,IconButton:G},data(){return{}},computed:{operatorOptionsNative(){var s,l,h;const t=((s=this.itemConfig)==null?void 0:s.type)||"text",a=(l=this.itemConfig)==null?void 0:l.filter_type,e=(h=this.itemConfig)==null?void 0:h.operators;if(a==="custom"&&e)return e;const i={text:{"=":this.$t("Equal"),"!=":this.$t("Doesn't equal"),contains:this.$t("Includes"),not_contains:this.$t("Doesn't includes")},numeric:{">":this.$t("Greater Than"),"<":this.$t("Less Than"),"=":this.$t("Equal"),"!=":this.$t("Doesn't equal")},remote_tree_select:{contains:this.$t("Includes"),not_contains:this.$t("Doesn't includes")},dates:{before:this.$t("Before"),after:this.$t("After"),date_equal:this.$t("At the date"),days_before:this.$t("Days before"),days_within:this.$t("Within days")}};return t==="selections"?this.itemConfig.is_multiple?{in:{title:this.$t("Includes any of"),description:this.$t("At least one matches")},in_all:{title:this.$t("Includes all of"),description:this.$t("All must match")},not_in:{title:this.$t("Exclude if any"),description:this.$t("Exclude if one matches")},not_in_all:{title:this.$t("Exclude if all"),description:this.$t("Exclude only if all match")}}:this.itemConfig.is_only_in?{in:this.$t("Includes in")}:{"=":this.$t("Is"),"!=":this.$t("Is Not")}:W.get(i,t,{})},operatorOptions(){return this.operatorOptionsNative},itemConfig(){const t=this.item.source.join("-");return this.filterLabels[t]||{}}},methods:{removeItem(){this.$emit("removeItem")},getProviderLabel(t){return t?(t=t.replace(/_/g," ").replace(/-/g," "),t.charAt(0).toUpperCase()+t.slice(1)):""},operatorSelected(t){!t&&this.item.operator&&setTimeout(()=>{jQuery(this.$el).find(".fct-filter-value input").focus()},200)},applyFilter(){setTimeout(()=>{this.table.applyAdvancedFilter()},200)}},mounted(){if(!this.item.operator){const t=Object.keys(this.operatorOptions);t.length&&(this.item.operator=t[0],jQuery(this.$el).find(".fct-filter-value input").focus(),jQuery(this.$el).find(".fct-filter-operator .el-select").trigger("click"))}}},zt={class:"w-[250px] fct-filter-label"},Mt={class:"fct-filter-operator w-[190px]"},Rt={key:0,class:"fct-operator-description p-2"},Qt={style:{"padding-left":"8px"}},Gt={class:"fct-filter-value"},Ht={class:"w-[40px] text-right fct-filter-action"};function Wt(t,a,e,i,s,l){const h=b("el-option"),u=b("el-select"),r=b("el-input"),f=b("el-date-picker"),k=b("SelectItem"),y=b("RemoteTreeSelect"),g=b("DynamicIcon"),V=b("IconButton");return n(),c("tr",null,[o("td",zt,[S(p(l.getProviderLabel(l.itemConfig.provider))+" ",1),a[8]||(a[8]=o("span",{class:"fct-provider-separator"},"/",-1)),S(" "+p(l.itemConfig.label),1)]),o("td",Mt,[d(u,{size:"small",placeholder:t.$t("Select Operator"),modelValue:e.item.operator,"onUpdate:modelValue":a[0]||(a[0]=v=>e.item.operator=v),onVisibleChange:l.operatorSelected,onChange:a[1]||(a[1]=()=>{const v=typeof e.item.value=="object"?Object.values(e.item.value):e.item.value;(Array.isArray(v)&&v>0||v.toString().length>0)&&e.table.applyAdvancedFilter()})},{default:m(()=>[(n(!0),c(T,null,N(l.operatorOptions,(v,F)=>(n(),c(T,{key:F},[typeof v=="string"?(n(),C(h,{key:0,value:F,label:v},null,8,["value","label"])):(n(),C(h,{key:1,style:{height:"auto"},value:F,label:v.title},{default:m(()=>[v.description?(n(),c("p",Rt,[o("span",null,[S(p(v.title)+" ",1),a[9]||(a[9]=o("br",null,null,-1)),o("span",Qt,"- "+p(v.description),1)])])):_("",!0)]),_:2},1032,["value","label"]))],64))),128))]),_:1},8,["placeholder","modelValue","onVisibleChange"])]),o("td",Gt,[!l.itemConfig.type||l.itemConfig.type==="text"?(n(),C(r,{key:0,size:"small",placeholder:t.$t("Condition Value"),type:"text",modelValue:e.item.value,"onUpdate:modelValue":a[2]||(a[2]=v=>e.item.value=v),onKeydown:J(l.applyFilter,["enter"])},null,8,["placeholder","modelValue","onKeydown"])):l.itemConfig.type==="numeric"?(n(),C(r,{key:1,size:"small",type:"number",placeholder:t.$t("Condition Value"),modelValue:e.item.value,"onUpdate:modelValue":a[3]||(a[3]=v=>e.item.value=v),onKeydown:J(l.applyFilter,["enter"])},null,8,["placeholder","modelValue","onKeydown"])):l.itemConfig.type==="dates"?(n(),c(T,{key:2},[e.item.operator==="days_before"||e.item.operator==="days_within"?(n(),C(r,{key:0,size:"small",type:"number",placeholder:t.$t("Days"),modelValue:e.item.value,"onUpdate:modelValue":a[4]||(a[4]=v=>e.item.value=v),onKeydown:J(l.applyFilter,["enter"])},null,8,["placeholder","modelValue","onKeydown"])):e.item.operator?(n(),C(f,{key:1,onChange:l.applyFilter,type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",size:"small",modelValue:e.item.value,"onUpdate:modelValue":a[5]||(a[5]=v=>e.item.value=v)},null,8,["onChange","modelValue"])):_("",!0)],64)):_("",!0),l.itemConfig.type==="selections"?(n(),C(k,{key:3,table:e.table,"item-config":l.itemConfig,modelValue:e.item.value,"onUpdate:modelValue":a[6]||(a[6]=v=>e.item.value=v)},null,8,["table","item-config","modelValue"])):_("",!0),l.itemConfig.type==="remote_tree_select"?(n(),C(y,{key:4,table:e.table,"item-config":l.itemConfig,modelValue:e.item.value,"onUpdate:modelValue":a[7]||(a[7]=v=>e.item.value=v)},null,8,["table","item-config","modelValue"])):_("",!0)]),o("td",Ht,[d(V,{onClick:l.removeItem,size:"x-small",bg:"info",tag:"button"},{default:m(()=>[d(g,{name:"Delete"})]),_:1},8,["onClick"])])])}const Jt=j(qt,[["render",Wt]]),Yt={name:"_CascaderPanel",props:{options:{type:Array,required:!0},modelValue:{type:Array,default:()=>[]}},components:{TransitionAccordion:me},emits:["update:modelValue","change"],data(){return{openPanel:null}},methods:{toggleOpen(t){this.openPanel=this.openPanel===t?null:t},selectOption(t,a){const e=[t,a];this.$emit("update:modelValue",e),this.$emit("change",e),this.openPanel=null}}},Kt={class:"fct-cascader-panel"},Zt=["onClick"],Xt={class:"fct-cascader-content"},Lt=["onClick"];function ea(t,a,e,i,s,l){const h=b("TransitionAccordion");return n(),c("div",Kt,[(n(!0),c(T,null,N(e.options,u=>(n(),c("div",{key:u.value,class:"fct-cascader-option"},[o("div",{class:"fct-cascader-button",onClick:r=>l.toggleOpen(u.value)},p(u.label),9,Zt),d(h,{visible:s.openPanel===u.value},{default:m(()=>[he(o("ul",Xt,[(n(!0),c(T,null,N(u.children,r=>(n(),c("li",{class:"fct-cascader-item",key:r.value,onClick:f=>l.selectOption(u.value,r.value)},p(r.label),9,Lt))),128))],512),[[Ve,s.openPanel===u.value]])]),_:2},1032,["visible"])]))),128))])}const ta=j(Yt,[["render",ea]]),aa={class:"fct-advanced-filters"},la={key:0,class:"w-full"},ia={class:"fct-advanced-filter-intro"},sa={class:"fct-cascader-panel-wrap"},na={class:"px-2"},oa={__name:"_Filters",props:{table:{required:!0},items:{type:Array,default:()=>[]},filtersLength:{type:Number},filterOptions:{type:Array,default:()=>[]},filterIndex:{type:Number,required:!0}},setup(t){const a=t,e=P(null),i=P([]),s=P(!1),l=z(()=>{const r={};return a.filterOptions.forEach(f=>{f.children&&f.children.forEach(k=>{r[`${f.value}-${k.value}`]={provider:f.value,...k}})}),r}),h=r=>{if(i.value.length===2){const f=a.filterOptions.find(y=>y.value===r[0]),k=f==null?void 0:f.children.find(y=>y.value===r[1]);k&&(a.items.push({source:[...i.value],filter_type:k.filter_type,operator:"",value:"",column:k.column,relation:k.relation}),s.value=!1,Q(()=>{e.value&&e.value.hide()}),i.value=[])}},u=r=>{Q(()=>{a.items.splice(r,1),a.table.applyAdvancedFilter(!0)})};return(r,f)=>{const k=b("el-cascader-panel"),y=b("el-button"),g=b("el-popover");return n(),c("div",aa,[t.items.length?(n(),c("table",la,[o("tbody",null,[(n(!0),c(T,null,N(t.items,(V,v)=>(n(),C(Jt,{table:t.table,key:v,filterLabels:l.value,item:V,onRemoveItem:F=>u(v)},null,8,["table","filterLabels","item","onRemoveItem"]))),128))])])):_("",!0),o("div",ia,[d(g,{placement:"right",width:"450","popper-class":"fct-advanced-filter-popover",trigger:"click",ref_key:"popoverRef",ref:e},{reference:m(()=>[d(y,{class:"el-button--x-small"},{default:m(()=>[d(I,{name:"Plus"}),S(" "+p(r.$t("Add")),1)]),_:1})]),default:m(()=>[o("div",sa,[d(ta,{options:t.filterOptions,modelValue:i.value,"onUpdate:modelValue":f[0]||(f[0]=V=>i.value=V),onChange:h},null,8,["options","modelValue"]),d(k,{style:{width:"100%"},options:t.filterOptions,modelValue:i.value,"onUpdate:modelValue":f[1]||(f[1]=V=>i.value=V),onChange:h},null,8,["options","modelValue"])])]),_:1},512),o("span",na,p(r.$t("Add new properties")),1),t.items.length===0?(n(),C(G,{key:0,onClick:f[2]||(f[2]=()=>{t.table.removeAdvanceFilterGroup(t.filterIndex)}),class:"float-end",size:"x-small",bg:"info",tag:"button",disabled:t.filtersLength<=1},{default:m(()=>[d(I,{name:"Delete"})]),_:1},8,["disabled"])):_("",!0)])])}}},ra={class:"fct-advanced-filter-container"},da={class:"fct-advanced-filter-wrap"},ca={key:0,class:"fct-condition-or-wrap"},ua={class:"fct-condition-or"},ha={class:"fct-condition-or-wrap"},ma={class:"fct-advanced-filter-footer justify-end"},fa={__name:"AdvancedFilter",props:{table:Object},setup(t){const a=t,e=z(()=>(a.table.data.advanceFilters||[]).some(s=>Array.isArray(s)&&s.length>0)),i=()=>{a.table.promptAndSaveView()};return(s,l)=>{const h=b("el-button");return n(),C(me,{visible:t.table.isUsingAdvanceFilter()},{default:m(()=>[o("div",ra,[o("div",da,[(n(!0),c(T,null,N(t.table.data.advanceFilters,(u,r)=>(n(),c("div",{class:"fct-advanced-filter",key:r},[d(oa,{filterIndex:r,table:t.table,items:u,filtersLength:t.table.data.advanceFilters.length,filterOptions:t.table.getAdvanceFilterOptions()},null,8,["filterIndex","table","items","filtersLength","filterOptions"]),r<t.table.data.advanceFilters.length-1?(n(),c("div",ca,[o("div",ua,p(s.$t("or")),1)])):_("",!0)]))),128))]),o("div",ha,[o("div",{class:"fct-condition-or",onClick:l[0]||(l[0]=u=>t.table.addAdvanceFilterGroup())},[d(I,{name:"Plus"}),S(" "+p(s.$t("or")),1)])]),o("div",ma,[d(h,{onClick:l[1]||(l[1]=()=>t.table.clearAdvanceFilter()),text:"",class:"el-button--x-small"},{default:m(()=>[S(p(s.$t("Reset")),1)]),_:1}),d(h,{onClick:l[2]||(l[2]=()=>t.table.applyAdvancedFilter()),type:"primary",class:"el-button--x-small"},{default:m(()=>[S(p(s.$t("Apply")),1)]),_:1}),d(h,{onClick:i,text:"",class:"el-button--x-small",disabled:!e.value},{default:m(()=>[d(I,{name:"Plus"}),S(" "+p(s.$t("Save as view")),1)]),_:1},8,["disabled"])])])]),_:1},8,["visible"])}}},ga={class:"fct-filter-tabs-mobile"},pa={key:0},va={class:"select-label"},ba={class:"select-desc"},ya={class:"flex items-center justify-between w-full"},_a={class:"text-sm text-system-dark dark:text-gray-50"},wa=["onClick"],Va={xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{opacity:"0.6"}},Ca={__name:"FilterTabsMobile",props:{table:Object},setup(t){const a=t,e=async l=>{try{await X.confirm($("Are you sure you want to delete this view?"),$("Delete View"),{confirmButtonText:$("Delete"),cancelButtonText:$("Cancel"),type:"warning"}),a.table.deleteSavedView(l)}catch{}},i=z({get(){const l=a.table.getActiveSavedViewId();return l||a.table.getSelectedTab()},set(){}}),s=l=>{a.table.getSavedViews().some(u=>u.slug===l)?a.table.applySavedView(l):a.table.isUsingAdvanceFilter()||a.table.handleTabChanged(l)};return(l,h)=>{const u=b("el-option"),r=b("el-select");return n(),c("div",ga,[d(r,{modelValue:i.value,"onUpdate:modelValue":h[0]||(h[0]=f=>i.value=f),onChange:h[1]||(h[1]=f=>{s(f)}),"popper-class":"fct-fluid-tab-select",size:"small"},{default:m(()=>[(n(!0),c(T,null,N(t.table.getTabs(),(f,k)=>(n(),C(u,{key:k,label:f.title||f,value:k},{default:m(()=>[typeof f=="object"?(n(),c("div",pa,[o("div",va,p(f.title),1),o("div",ba,p(f.description),1)])):(n(),c(T,{key:1},[S(p(f),1)],64))]),_:2},1032,["label","value"]))),128)),(n(!0),c(T,null,N(t.table.getSavedViews(),f=>(n(),C(u,{key:f.slug,label:f.name,value:f.slug},{default:m(()=>[o("div",ya,[o("span",_a,p(f.name),1),t.table.isProActive()&&t.table.isViewOwner(f)?(n(),c("span",{key:0,style:{display:"inline-flex","align-items":"center",cursor:"pointer",padding:"2px"},onClick:q(k=>e(f.slug),["stop"])},[(n(),c("svg",Va,h[2]||(h[2]=[o("polyline",{points:"3 6 5 6 21 6"},null,-1),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},null,-1)])))],8,wa)):_("",!0)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue"])])}}},Sa={class:"fct-card"},ka={class:"fct-card-header-top"},$a={class:"fct-card-header-left flex-1"},Ta={class:"fct-mobile-header-actions md:hidden"},Aa={class:"fct-btn-group sm"},Fa={key:1},xa={class:"flex items-center justify-between pt-1"},Pa={class:"text-xs text-system-light dark:text-gray-300"},Ia={class:"fct-card-header-actions"},Na={key:0,class:"fct-advanced-filter-toggle-wrapper"},Oa={class:"fct-btn-group sm hidden md:flex"},Da={key:0,class:"filter-search-wrap"},Ua={class:"search-bar"},Ba={class:"flex items-center justify-between pt-2"},ja={class:"text-xs text-system-light dark:text-gray-300"},Ea={class:"fct-card-body"},qa={class:"fct-table-wrapper-inner"},za={key:0,class:"block md:hidden"},Ma={class:"flex items-center gap-2"},Ra={class:"text-sm text-system-mid dark:text-gray-300"},Qa={class:"dialog-footer"},Vl={__name:"TableWrapper",props:{table:Object,classicTabStyle:!1,hasMobileSlot:!1},setup(t){const a=t,e=Ce("search-input"),i=()=>{a.table.openSearch(),Q(()=>{e.value.focus()})},s=Se({name:"",description:"",is_public:!1}),l=()=>{s.name="",s.description="",s.is_public=!1,a.table.promptAndSaveView()},h=()=>{if(!s.name||!s.name.trim()){B.error($("Name is required"));return}if(s.name.trim().length>50){B.error($("Name must be 50 characters or fewer"));return}const u=a.table.saveCurrentView(s.name.trim(),s.description.trim(),s.is_public);u&&u.then&&u.then(()=>{a.table.data.showSaveViewDialog=!1})};return(u,r)=>{var U;const f=b("el-tooltip"),k=b("el-input"),y=b("el-button"),g=b("el-switch"),V=b("el-form-item"),v=b("el-form"),F=b("el-dialog");return n(),c("div",{class:O(["fct-table-wrapper",t.hasMobileSlot?"fct-table-wrapper-mobile":""])},[o("div",Sa,[o("div",{class:O(["fct-card-header",t.table.useFullWidthSearch()?"is-full-width-search":""])},[o("div",ka,[o("div",$a,[t.table.getTabsCount()&&!t.table.isUsingAdvanceFilter()?(n(),C(pt,{key:0,class:O(`hide-animation-on-mobile hidden md:inline-flex ${t.classicTabStyle?"classic-tab-style":""}`),table:t.table},null,8,["class","table"])):_("",!0),o("div",Ta,[t.table.getTabsCount()&&!t.table.isUsingAdvanceFilter()?(n(),C(Ca,{key:0,table:t.table},null,8,["table"])):_("",!0),o("div",Aa,[!t.table.isSearching()&&!t.table.useFullWidthSearch()?(n(),C(f,{key:0,effect:"light",content:u.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:m(()=>[d(G,{tag:"button",onClick:q(i,["prevent"]),disabled:!t.table.isUsingSimpleFilter()},{default:m(()=>[d(I,{name:"Search"})]),_:1},8,["disabled"])]),_:1},8,["content"])):_("",!0),t.table.getToggleableColumns().length?(n(),C(ne,{key:1,table:t.table},null,8,["table"])):_("",!0),t.table.getSortableColumns().length?(n(),C(oe,{key:2,table:t.table},null,8,["table"])):_("",!0)])]),t.table.useFullWidthSearch()&&!t.table.isUsingAdvanceFilter()?(n(),c("div",Fa,[o("div",{class:O(`search-bar is-transparent ${t.table.isUsingAdvanceFilter()?"is-unable-advanced-filter":""}`)},[d(k,{placeholder:u.$t("Search"),ref:"search-input",onClear:r[0]||(r[0]=()=>{t.table.search()}),onKeyup:r[1]||(r[1]=J(()=>{t.table.search()},["enter"])),modelValue:t.table.data.search,"onUpdate:modelValue":r[2]||(r[2]=x=>t.table.data.search=x),type:"text",clearable:""},{prefix:m(()=>[d(I,{name:"Search"})]),_:1},8,["placeholder","modelValue"])],2),o("div",xa,[o("div",Pa,[S(p(t.table.getSearchHint())+" ",1),(U=t.table.getSearchGuideOptions())!=null&&U.length?(n(),C(de,{key:0,table:t.table},null,8,["table"])):_("",!0)]),d(y,{text:"",class:"el-button--x-small",onClick:l,disabled:!t.table.data.search},{default:m(()=>[d(I,{name:"Plus"}),S(" "+p(u.$t("Save as view")),1)]),_:1},8,["disabled"])])])):_("",!0)]),o("div",Ia,[t.table.isAdvanceFilterEnabled()?(n(),c("div",Na,[d(g,{class:"fct-advanced-filter-toggle",onChange:r[3]||(r[3]=x=>{t.table.onFilterTypeChanged(x)}),"active-value":"advanced","inactive-value":"simple",modelValue:t.table.data.filterType,"onUpdate:modelValue":r[4]||(r[4]=x=>t.table.data.filterType=x),"active-text":u.$t("Advanced Filter"),size:"small"},null,8,["modelValue","active-text"])])):_("",!0),o("div",Oa,[!t.table.isSearching()&&!t.table.useFullWidthSearch()?(n(),C(f,{key:0,effect:"light",content:u.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:m(()=>[d(G,{tag:"button",onClick:q(i,["prevent"]),disabled:!t.table.isUsingSimpleFilter()},{default:m(()=>[d(I,{name:"Search"})]),_:1},8,["disabled"])]),_:1},8,["content"])):_("",!0),t.table.getToggleableColumns().length?(n(),C(ne,{key:1,table:t.table},null,8,["table"])):_("",!0),t.table.getSortableColumns().length?(n(),C(oe,{key:2,table:t.table},null,8,["table"])):_("",!0)])])]),d(fa,{table:t.table},null,8,["table"]),t.table.isSearching()&&!t.table.useFullWidthSearch()?(n(),c("div",Da,[o("div",Ua,[d(k,{ref:"search-input",onClear:r[5]||(r[5]=()=>{t.table.search()}),onKeyup:r[6]||(r[6]=J(()=>{t.table.search()},["enter"])),modelValue:t.table.data.search,"onUpdate:modelValue":r[7]||(r[7]=x=>t.table.data.search=x),type:"text",placeholder:u.$t("Search"),clearable:""},{prefix:m(()=>[d(I,{name:"Search"})]),_:1},8,["modelValue","placeholder"]),o("div",Ba,[o("div",ja,[S(p(t.table.getSearchHint())+" ",1),d(de,{table:t.table},null,8,["table"])]),d(y,{text:"",class:"el-button--x-small",onClick:l,disabled:!t.table.data.search},{default:m(()=>[d(I,{name:"Plus"}),S(" "+p(u.$t("Save as view")),1)]),_:1},8,["disabled"])])]),d(y,{text:"",onClick:r[8]||(r[8]=()=>{t.table.closeSearch()})},{default:m(()=>[S(p(u.$t("Cancel")),1)]),_:1})])):_("",!0)],2),o("div",Ea,[o("div",qa,[o("div",{class:O({"hidden md:block":t.hasMobileSlot,block:!t.hasMobileSlot})},[D(u.$slots,"default")],2),t.hasMobileSlot?(n(),c("div",za,[D(u.$slots,"mobile")])):_("",!0),d(Xe,{table:t.table,hide_on_single:!1,pagination:t.table.data.paginate},null,8,["table","pagination"])])])]),d(F,{modelValue:t.table.data.showSaveViewDialog,"onUpdate:modelValue":r[13]||(r[13]=x=>t.table.data.showSaveViewDialog=x),title:u.$t("Save View"),width:"420px","close-on-click-modal":!1,"append-to":"#fct_admin_app_wrapper"},{footer:m(()=>[o("div",Qa,[d(y,{onClick:r[12]||(r[12]=x=>t.table.data.showSaveViewDialog=!1)},{default:m(()=>[S(p(u.$t("Cancel")),1)]),_:1}),d(y,{type:"primary",onClick:h},{default:m(()=>[S(p(u.$t("Save")),1)]),_:1})])]),default:m(()=>[d(v,{"label-position":"top",onSubmit:q(h,["prevent"])},{default:m(()=>[d(V,{label:u.$t("Name")},{default:m(()=>[d(k,{modelValue:s.name,"onUpdate:modelValue":r[9]||(r[9]=x=>s.name=x),placeholder:u.$t("View name"),maxlength:"50"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),d(V,{label:u.$t("Description")},{default:m(()=>[d(k,{modelValue:s.description,"onUpdate:modelValue":r[10]||(r[10]=x=>s.description=x),placeholder:u.$t("Optional description"),type:"textarea",rows:2},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),d(V,null,{default:m(()=>[o("div",Ma,[d(g,{modelValue:s.is_public,"onUpdate:modelValue":r[11]||(r[11]=x=>s.is_public=x),size:"small"},null,8,["modelValue"]),o("span",Ra,p(u.$t("Make public (visible to all users)")),1)])]),_:1})]),_:1})]),_:1},8,["modelValue","title"])],2)}}},Ga={class:"table-cell"},Cl={__name:"RouteCell",props:{to:{type:Object,required:!0},params:{type:Object,default:()=>({})}},setup(t){const a=t;return ke(),(e,i)=>{const s=b("router-link");return n(),C(s,{class:"link block cursor-pointer route-cell",to:a.to},{default:m(()=>[o("div",Ga,[D(e.$slots,"default")])]),_:3},8,["to"])}}},Ha={name:"Card",props:{border:{type:Boolean}}};function Wa(t,a,e,i,s,l){return n(),c("div",{class:O(`fct-card ${e.border?"fct-card-border":""}`)},[D(t.$slots,"default")],2)}const Sl=j(Ha,[["render",Wa]]),Ja={name:"CardHeader",components:{DynamicIcon:I},props:{title:{type:String},text:{type:String},border_bottom:{type:Boolean},icon:{type:String},title_size:{type:String},img:{type:String}}},Ya={key:0,class:"flex-1"},Ka=["src"],Za={key:1,class:"fct-card-header-text"},Xa={key:1,class:"fct-card-header-actions"};function La(t,a,e,i,s,l){const h=b("dynamic-icon");return n(),c("div",{class:O(`fct-card-header ${e.border_bottom?"border-bottom":""}`)},[e.title||e.text||t.$slots.title?(n(),c("div",Ya,[e.title||e.text?(n(),c(T,{key:0},[e.title?(n(),c("h2",{key:0,class:O(`fct-card-header-title ${e.title_size?"is-"+e.title_size:""}`)},[e.icon?(n(),C(h,{key:0,name:e.icon},null,8,["name"])):_("",!0),e.img?(n(),c("img",{key:1,src:e.img,alt:""},null,8,Ka)):_("",!0),S(" "+p(e.title),1)],2)):_("",!0),e.text?(n(),c("p",Za,p(e.text),1)):_("",!0)],64)):_("",!0),t.$slots.title?D(t.$slots,"title",{key:1}):_("",!0)])):_("",!0),t.$slots.action?(n(),c("div",Xa,[D(t.$slots,"action")])):_("",!0),D(t.$slots,"default")],2)}const kl=j(Ja,[["render",La]]),el={name:"CardBody"},tl={class:"fct-card-body"};function al(t,a,e,i,s,l){return n(),c("div",tl,[D(t.$slots,"default")])}const $l=j(el,[["render",al]]);export{kl as C,re as F,Be as P,wl as T,Cl as _,Vl as a,lt as b,$l as c,Sl as d,bt as e,Xe as f,pt as g,fa as h,se as m}; |