import{d as p}from"./dates-BwbkmdBX.js";import{i as n,f}from"./vendor-C0xXhvfi.js";import{f as h}from"./format-money-BKWmhW0z.js";/* empty css                       */import{G as c}from"./get-BPcJq8yA.js";let u=function(){return{notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},transactions:[],totalPages:1,perPage:50,page:1,tableColumns:{description:{enabled:!0},source:{enabled:!0},destination:{enabled:!0},amount:{enabled:!0}},table:null,formatMoney(t,i){return h(t,i)},format(t){return f(t,n.t("config.date_time_fns"))},init(){this.getTransactions(this.page)},getTransactions(t){this.notifications.wait.show=!0,this.notifications.wait.text=n.t("firefly.wait_loading_data"),this.transactions=[];const i=window.location.href.split("/"),a=i[i.length-1];new c().list({page:t,type:a}).then(s=>{this.parseTransactions(s.data.data),this.totalPages=s.data.meta.pagination.total_pages,this.perPage=s.data.meta.pagination.per_page,this.page=s.data.meta.pagination.current_page}).catch(s=>{this.notifications.wait.show=!1,this.notifications.error.show=!0,this.notifications.error.text=s.response.data.message})},previousPage(){this.page>1&&this.page--,this.getTransactions(this.page)},nextPage(){this.page<this.totalPages&&this.page++,this.getTransactions(this.page)},gotoPage(t){t>0&&t<=this.totalPages&&(this.page=t),this.getTransactions(this.page)},parseTransactions(t){for(let i in t)if(t.hasOwnProperty(i)){let a=t[i],o=a.attributes.transactions.length>1,s=!0;for(let r in a.attributes.transactions)if(a.attributes.transactions.hasOwnProperty(r)){let e=a.attributes.transactions[r];e.split=o,e.icon="fa fa-solid fa-arrow-left",e.firstSplit=s,e.group_title=a.attributes.group_title,e.id=a.id,e.created_at=a.attributes.created_at,e.updated_at=a.attributes.updated_at,e.user=a.attributes.user,e.user_group=a.attributes.user_group,s=!1,this.transactions.push(e)}}this.notifications.wait.show=!1,console.log("refresh!")}}},l={index:u,dates:p};function g(){Object.keys(l).forEach(t=>{console.log(`Loading page component "${t}"`);let i=l[t]();Alpine.data(t,()=>i)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),g()});window.bootstrapped&&(console.log("Loaded through window variable."),g());
