Plugin Directory

Changeset 3169216


Ignore:
Timestamp:
10/15/2024 11:22:56 AM (18 months ago)
Author:
melioze
Message:

fix expenses download files

Location:
my-easy-compta
Files:
794 added
17 edited

Legend:

Unmodified
Added
Removed
  • my-easy-compta/trunk/assets/dist/api.min.js

    r3167980 r3169216  
    1 (function(t,a){const x=s,e=t();for(;[];)try{if(parseInt(x(453))/1*(-parseInt(x(454))/2)+-parseInt(x(469))/3+parseInt(x(462))/4*(parseInt(x(464))/5)+-parseInt(x(459))/6+-parseInt(x(471))/7*(parseInt(x(461))/8)+parseInt(x(467))/9+parseInt(x(460))/10===a)break;e.push(e.shift())}catch{e.push(e.shift())}})(f,727667);function s(t,a){const x=f();return s=function(e,n){return e=e-453,x[e]},s(t,a)}function u(t,a,x="\u20AC"){const e=s,n=parseFloat(t),o=parseFloat(a),r=n*(o/100);return(n+r)[e(456)](2).replace(/\B(?=(\d{3})+(?!\d))/g," ")+" "+x}function l(t,a="\u20AC"){const x=s;return parseFloat(t).toFixed(2)[x(466)](/\B(?=(\d{3})+(?!\d))/g," ")+" "+a}function f(){const t=["visible","1169uGzQMC","indexOf","before","split","...","37RzjzkO","34014NjmXit","Invalid Date","toFixed","push","type","3858120URBCzx","23965870GcqLga","22840HxqmMZ","56964aDIONg","toString","215HyUVDm","length","replace","1594188xUHIMy","YYYY","2128053HHNgLR"];return f=function(){return t},f()}function _(t,a){const x=s;let e=[];if(a<=5)for(let n=1;n<=a;n++)e.push(n);else if(t<=3){for(let n=1;n<=5;n++)e[x(457)](n);e[x(457)](x(475)),e[x(457)](a)}else if(t>a-3){e[x(457)](1),e.push(x(475));for(let n=a-4;n<=a;n++)e[x(457)](n)}else{e[x(457)](1),e[x(457)](x(475));for(let n=t-1;n<=t+1;n++)e[x(457)](n);e[x(457)](x(475)),e[x(457)](a)}return e}function h(t,a,x){const e=s,n=parseFloat(t)[e(456)](2)[e(466)](/\B(?=(\d{3})+(?!\d))/g," ");return x===e(473)?a+" "+n:n+" "+a}function m(t,a,x){const e=s;t.message=a,t[e(458)]=x,t[e(470)]=!![],setTimeout(()=>{const n=e;t[n(470)]=![]},3e3)}function d(){const t=["16248vcddLO","1lMzmvZ","6548808QdTwlJ","nonce","10166717qTCmIO","/wp-json/my-easy-compta/v1/settings/get","4638fgANRY","/wp-json/my-easy-compta/v1/settings/currency/","6335UzGXrw","3812080AtvRne","2366244YtuHXJ","statusText","GET","Failed to fetch VAT data:","application/json","10FLYypX","default_currency","165AWoXRX","vat_active","13MPYZtD","default_vat","error","message","symbol","json","Failed to fetch currency data:","541934eDQMEH","8QpiFsL"];return d=function(){return t},d()}(function(t,a){const x=p,e=t();for(;[];)try{if(parseInt(x(285))/1*(-parseInt(x(282))/2)+-parseInt(x(273))/3*(parseInt(x(284))/4)+parseInt(x(265))/5+parseInt(x(262))/6*(parseInt(x(264))/7)+-parseInt(x(283))/8*(-parseInt(x(266))/9)+parseInt(x(271))/10*(-parseInt(x(260))/11)+-parseInt(x(286))/12*(-parseInt(x(275))/13)===a)break;e.push(e.shift())}catch{e.push(e.shift())}})(d,852007);function p(t,a){const x=d();return p=function(e,n){return e=e-260,x[e]},p(t,a)}async function y(){const t=p;try{const a=await fetch(t(261),{method:t(268),headers:{"Content-Type":t(270),"X-WP-Nonce":myEasyComptaAdmin[t(287)]}});if(a.ok){const x=await a[t(280)]();let e=null,n=null,o=null;if(x[t(272)]){const r=x[t(272)],c=await fetch(t(263)+r,{method:t(268),headers:{"Content-Type":t(270),"X-WP-Nonce":myEasyComptaAdmin[t(287)]}});c.ok?e=(await c.json())[t(279)]:console[t(277)](t(281),c.statusText)}if(x[t(274)]==1){const r=x[t(276)],c=await fetch("/wp-json/my-easy-compta/v1/settings/vat/"+r,{method:t(268),headers:{"Content-Type":t(270),"X-WP-Nonce":myEasyComptaAdmin.nonce}});c.ok?n=await c[t(280)]():console[t(277)](t(269),c[t(267)]);const i=await fetch("/wp-json/my-easy-compta/v1/settings/vats",{method:t(268),headers:{"Content-Type":t(270),"X-WP-Nonce":myEasyComptaAdmin[t(287)]}});i.ok?o=await i[t(280)]():console[t(277)](t(269),i[t(267)])}else n=0,o=0;return{settings:x,currencySymbol:e,vatData:n,listVatData:o}}else{const x=await a[t(280)]();throw new Error(x[t(278)])}}catch(a){throw console[t(277)](a),new Error(a[t(278)])}}export{l as a,h as b,u as c,y as f,_ as g,m as s};
     1function i(){const t=["280808ozXmat","YYYY","before","22098mUzgzE","Invalid Date","push","104DBFsxd","2230MGQqhz","617pWOfQN","10705743pPOSnz","indexOf","4wesNfB","type","...","18369000ZPHBmf","split","replace","1045uXIIrq","281757NqbMsi","length","toFixed","172991iboSVp","570RNaSfd"];return i=function(){return t},i()}(function(t,a){const e=c,x=t();for(;[];)try{if(parseInt(e(196))/1*(-parseInt(e(195))/2)+parseInt(e(206))/3*(parseInt(e(199))/4)+parseInt(e(205))/5*(-parseInt(e(191))/6)+parseInt(e(209))/7*(parseInt(e(194))/8)+-parseInt(e(197))/9+-parseInt(e(210))/10*(-parseInt(e(211))/11)+parseInt(e(202))/12===a)break;x.push(x.shift())}catch{x.push(x.shift())}})(i,753805);function d(t,a,e="\u20AC"){const x=c,n=parseFloat(t),o=parseFloat(a),r=n*(o/100);return(n+r)[x(208)](2)[x(204)](/\B(?=(\d{3})+(?!\d))/g," ")+" "+e}function l(t,a="\u20AC"){return parseFloat(t).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g," ")+" "+a}function c(t,a){const e=i();return c=function(x,n){return x=x-191,e[x]},c(t,a)}function _(t,a){const e=c;let x=[];if(a<=5)for(let n=1;n<=a;n++)x[e(193)](n);else if(t<=3){for(let n=1;n<=5;n++)x[e(193)](n);x[e(193)](e(201)),x.push(a)}else if(t>a-3){x.push(1),x.push(e(201));for(let n=a-4;n<=a;n++)x[e(193)](n)}else{x[e(193)](1),x.push(e(201));for(let n=t-1;n<=t+1;n++)x[e(193)](n);x[e(193)](e(201)),x[e(193)](a)}return x}function h(t,a,e){const x=c,n=parseFloat(t)[x(208)](2).replace(/\B(?=(\d{3})+(?!\d))/g," ");return e===x(213)?a+" "+n:n+" "+a}function m(t,a,e){const x=c;t.message=a,t[x(200)]=e,t.visible=!![],setTimeout(()=>{t.visible=![]},3e3)}(function(t,a){const e=p,x=t();for(;[];)try{if(parseInt(e(336))/1*(parseInt(e(339))/2)+parseInt(e(345))/3+parseInt(e(338))/4+parseInt(e(344))/5*(-parseInt(e(330))/6)+-parseInt(e(335))/7+-parseInt(e(343))/8+parseInt(e(337))/9===a)break;x.push(x.shift())}catch{x.push(x.shift())}})(u,487678);async function b(){const t=p;try{const a=await fetch(t(332),{method:t(333),headers:{"Content-Type":t(349),"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(a.ok){const e=await a[t(346)]();let x=null,n=null,o=null;if(e.default_currency){const r=e[t(331)],s=await fetch(t(328)+r,{method:t(333),headers:{"Content-Type":t(349),"X-WP-Nonce":myEasyComptaAdmin[t(348)]}});s.ok?x=(await s[t(346)]())[t(334)]:console.error(t(340),s.statusText)}if(e[t(351)]==1){const r=e.default_vat,s=await fetch(t(341)+r,{method:t(333),headers:{"Content-Type":t(349),"X-WP-Nonce":myEasyComptaAdmin.nonce}});s.ok?n=await s[t(346)]():console[t(342)](t(350),s[t(352)]);const f=await fetch(t(329),{method:t(333),headers:{"Content-Type":t(349),"X-WP-Nonce":myEasyComptaAdmin[t(348)]}});f.ok?o=await f[t(346)]():console[t(342)](t(350),f.statusText)}else n=0,o=0;return{settings:e,currencySymbol:x,vatData:n,listVatData:o}}else{const e=await a[t(346)]();throw new Error(e[t(347)])}}catch(a){throw console[t(342)](a),new Error(a.message)}}function p(t,a){const e=u();return p=function(x,n){return x=x-328,e[x]},p(t,a)}function u(){const t=["3900610kVFNxD","1438VuEnwN","10572156mjqPOC","603884zCxNwV","614bAvMPY","Failed to fetch currency data:","/wp-json/my-easy-compta/v1/settings/vat/","error","5858608SvigBO","387935KzIoLt","961383ICGYHl","json","message","nonce","application/json","Failed to fetch VAT data:","vat_active","statusText","/wp-json/my-easy-compta/v1/settings/currency/","/wp-json/my-easy-compta/v1/settings/vats","24rmgPfP","default_currency","/wp-json/my-easy-compta/v1/settings/get","GET","symbol"];return u=function(){return t},u()}export{l as a,h as b,d as c,b as f,_ as g,m as s};
  • my-easy-compta/trunk/assets/dist/app.min.js

    r3167980 r3169216  
    1 import{_ as u,o as a,c as o,a as t,t as i,F as f,r as x,b as h,d as p,e as v,f as b,h as E}from"./plugin-vue_export-helper.min.js";const C={name:"Stats",data(){return{unpaidAmountsByCurrency:[],MonthExpenses:0,currentMonthEarnings:"",totalEarnings:"",symbol:"",loading:!1}},mounted(){this.calculateUnpaidAmount(),this.calculateCurrentMonthExpenses(),this.fetchCurrentMonthEarnings(),this.fetchTotalEarnings()},methods:{async calculateUnpaidAmount(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/unpaid-invoices",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json(),r=[];for(const l in n){const{total_amount:e,symbol:c}=n[l];r.push({currencyId:l,total_amount:e,symbol:c})}this.unpaidAmountsByCurrency=r,this.loading=!1}catch(s){console.error("Erreur lors du calcul des montants impay\xE9s :",s),this.loading=!1}},async calculateCurrentMonthExpenses(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/expenses-month",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();this.MonthExpenses=n.total_expenses,this.symbol=n.default_currency,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des d\xE9penses du mois en cours :",s),this.loading=!1}},async fetchCurrentMonthEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/current-month-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.currentMonthEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des revenus du mois en cours :",s),this.loading=!1}},async fetchTotalEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/total-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.totalEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration de la totalit\xE9 des revenus :",s),this.loading=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},T={class:"mt-8"},A={class:"grid lg:grid-cols-4 mt-2 md:grid-cols-2 grid-cols-1 gap-6"},I={class:"stats shadow border"},M={class:"stat"},j=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-hand-holding-usd text-4xl"})],-1),P={class:"stat-title dark:text-slate-300"},$={class:"stat-value dark:text-slate-300 text-primary"},B={key:0},H=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),N=[H],S={key:1},G={class:"stats shadow border"},W={class:"stat"},X=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-receipt text-4xl"})],-1),V={class:"stat-title dark:text-slate-300"},F={class:"stat-value dark:text-slate-300 text-primary"},U={key:0},D=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),R=[D],O={key:1},Z={key:0},z={key:1},J={class:"stat-desc"},L={class:"stats shadow border"},Q={class:"stat"},Y=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"far fa-money-bill-alt text-4xl"})],-1),q={class:"stat-title dark:text-slate-300"},K={class:"stat-value dark:text-slate-300 text-primary"},ss={key:0},ts=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),es=[ts],ns={key:1},as={key:0},os={key:1},is={class:"stat-desc"},rs={class:"stats shadow border"},cs={class:"stat"},ls=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-file-invoice-dollar text-4xl"})],-1),ds={class:"stat-title dark:text-slate-300"},hs={class:"stat-value dark:text-slate-300 text-primary"},_s={key:0},ms=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),us=[ms],ps={key:1},vs={key:0},ys={key:1},fs=t("div",{class:"stat-desc"},null,-1);function xs(s,n,r,l,e,c){return a(),o("div",T,[t("div",A,[t("div",I,[t("div",M,[j,t("div",P,i(c.translations.unpaid),1),t("div",$,[e.loading?(a(),o("div",B,N)):(a(),o("div",S,[(a(!0),o(f,null,x(e.unpaidAmountsByCurrency,d=>(a(),o("div",{key:d.currencyId},i(d.total_amount)+i(d.symbol),1))),128))]))])])]),t("div",G,[t("div",W,[X,t("div",V,i(c.translations.expenses),1),t("div",F,[e.loading?(a(),o("div",U,R)):(a(),o("div",O,[e.MonthExpenses?(a(),o("span",Z,i(e.MonthExpenses)+i(e.symbol),1)):(a(),o("span",z," 0"+i(e.symbol),1))]))]),t("div",J,i(c.translations.current_month),1)])]),t("div",L,[t("div",Q,[Y,t("div",q,i(c.translations.earnings),1),t("div",K,[e.loading?(a(),o("div",ss,es)):(a(),o("div",ns,[e.currentMonthEarnings?(a(),o("span",as,i(e.currentMonthEarnings.total)+" "+i(e.currentMonthEarnings.default_currency_symbol),1)):(a(),o("span",os," 0"+i(e.symbol),1))]))]),t("div",is,i(c.translations.current_month),1)])]),t("div",rs,[t("div",cs,[ls,t("div",ds,i(c.translations.all_Earnings),1),t("div",hs,[e.loading?(a(),o("div",_s,us)):(a(),o("div",ps,[e.totalEarnings?(a(),o("span",vs,i(e.totalEarnings.total)+" "+i(e.totalEarnings.default_currency_symbol),1)):(a(),o("span",ys," 0"+i(e.totalEarnings.default_currency_symbol),1))]))]),fs])])])])}var gs=u(C,[["render",xs]]);const ws={name:"BarChart",data(){return{payments:[],expenses:[],months:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchMonthlyPaymentsExpenses()},methods:{async fetchMonthlyPaymentsExpenses(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/monthly-payments-expenses",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.payments=n.payments,this.expenses=n.expenses,this.months=n.months,this.loading=!1,this.$nextTick(()=>{this.loadChart()})}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements et des d\xE9penses mensuels:",s),this.loading=!1}},loadChart(){typeof Chart!="undefined"?this.createChart():console.error("Chart.js is not loaded")},createChart(){const s=this.translations,n=document.getElementById("bar-chart").getContext("2d");new Chart(n,{type:"bar",data:{labels:this.months,datasets:[{label:s.earnings,backgroundColor:"#42A5F5",data:this.payments},{label:s.expenses,backgroundColor:"#FF00AA",data:this.expenses}]},options:{responsive:!0,scales:{x:{beginAtZero:!0},y:{beginAtZero:!0}}}})}}},ks={class:"text-xl font-semibold"},bs=t("div",{class:"divider mt-2"},null,-1),Es={class:"h-full w-full pb-6"},Cs={key:0},Ts=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),As=[Ts],Is={key:1,id:"bar-chart"};function Ms(s,n,r,l,e,c){return a(),o("div",null,[t("div",ks,i(c.translations.annual_payments_overview),1),bs,t("div",Es,[e.loading?(a(),o("div",Cs,As)):(a(),o("canvas",Is))])])}var js=u(ws,[["render",Ms]]);const Ps={name:"InvoicesHistory",data(){return{recentPayments:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchRecentPayments()},methods:{async fetchRecentPayments(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/recent-payments",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.recentPayments=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements r\xE9cents:",s),this.loading=!1}}}},$s={class:"text-xl font-semibold"},Bs=t("div",{class:"divider mt-2"},null,-1),Hs={class:"overflow-x-auto"},Ns={key:0},Ss=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),Gs=[Ss],Ws={key:1},Xs={class:"text-gray-500"},Vs={key:2,class:"table table-xs ecwp-table-dash-invoice"},Fs={class:"badge badge-outline badge-success badge-sm"};function Us(s,n,r,l,e,c){return a(),o("div",null,[t("div",$s,i(c.translations.recently_paid_invoice),1),Bs,t("div",Hs,[e.loading?(a(),o("div",Ns,Gs)):e.recentPayments.length===0?(a(),o("div",Ws,[t("div",Xs,i(c.translations.no_data_for_moment),1)])):(a(),o("table",Vs,[t("tbody",null,[(a(!0),o(f,null,x(e.recentPayments,d=>(a(),o("tr",{key:d.invoice_number},[t("td",null,i(d.invoice_number),1),t("td",null,i(d.total_amount)+i(d.symbol),1),t("td",null,[t("span",Fs,i(d.method_name),1)])]))),128))])]))])])}var Ds=u(Ps,[["render",Us]]);const Rs={name:"Dashboard",components:{Stats:gs,BarChart:js,InvoicesHistory:Ds},methods:{setTheme(s){document.documentElement.setAttribute("data-theme",s),localStorage.setItem("theme",s)},toggleTheme(){document.documentElement.getAttribute("data-theme")==="dark"?this.setTheme("winter"):this.setTheme("dark")}},mounted(){const s=localStorage.getItem("theme");s?this.setTheme(s):window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&this.setTheme("dark")},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Os={class:"relative pt-2 pr-4"},Zs={class:"ecwp-swap swap swap-rotate bg-base-100 p-2 mt-10"},zs=t("i",{class:"swap-off far fa-sun text-xl"},null,-1),Js=t("i",{class:"swap-on far fa-moon text-xl"},null,-1),Ls={class:"grid lg:grid-cols-3 mt-4 grid-cols-1 gap-6"},Qs={class:"card w-full p-6 bg-base-100 shadow-xl col-span-2 mt-4"},Ys={class:"card w-full p-6 bg-base-100 shadow-xl mt-4"};function qs(s,n,r,l,e,c){const d=p("Stats"),g=p("BarChart"),w=p("InvoicesHistory");return a(),o("div",Os,[t("label",Zs,[t("input",{type:"checkbox",class:"theme-controller",onChange:n[0]||(n[0]=(...k)=>c.toggleTheme&&c.toggleTheme(...k))},null,32),zs,Js]),v(d),t("div",Ls,[t("div",Qs,[v(g)]),t("div",Ys,[v(w)])])])}var Ks=u(Rs,[["render",qs]]);function _(){const s=["5916534dDgcHt","40VWUJiy","2279528uBosRi","8950545pUfPOS","15335EYlNen","mount","3835632HMlcme","#my-easy-compta-admin-app","16wGSzwW","1525269VGQiOy","6042092pyXdVI"];return _=function(){return s},_()}const y=m;(function(s,n){const r=m,l=s();for(;[];)try{if(parseInt(r(403))/1+parseInt(r(396))/2+parseInt(r(400))/3+parseInt(r(402))/4*(parseInt(r(398))/5)+parseInt(r(394))/6+parseInt(r(393))/7+parseInt(r(395))/8*(-parseInt(r(397))/9)===n)break;l.push(l.shift())}catch{l.push(l.shift())}})(_,832565);function m(s,n){const r=_();return m=function(l,e){return l=l-393,r[l]},m(s,n)}const st=b({render:()=>E(Ks)});st[y(399)](y(401));
     1import{_ as p,o as a,c as o,a as t,t as i,F as f,r as x,b as h,d as u,e as v,f as b,h as E}from"./plugin-vue_export-helper.min.js";const C={name:"Stats",data(){return{unpaidAmountsByCurrency:[],MonthExpenses:0,currentMonthEarnings:"",totalEarnings:"",symbol:"",loading:!1}},mounted(){this.calculateUnpaidAmount(),this.calculateCurrentMonthExpenses(),this.fetchCurrentMonthEarnings(),this.fetchTotalEarnings()},methods:{async calculateUnpaidAmount(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/unpaid-invoices",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json(),r=[];for(const l in n){const{total_amount:e,symbol:c}=n[l];r.push({currencyId:l,total_amount:e,symbol:c})}this.unpaidAmountsByCurrency=r,this.loading=!1}catch(s){console.error("Erreur lors du calcul des montants impay\xE9s :",s),this.loading=!1}},async calculateCurrentMonthExpenses(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/expenses-month",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();this.MonthExpenses=n.total_expenses,this.symbol=n.default_currency,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des d\xE9penses du mois en cours :",s),this.loading=!1}},async fetchCurrentMonthEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/current-month-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.currentMonthEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des revenus du mois en cours :",s),this.loading=!1}},async fetchTotalEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/total-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.totalEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration de la totalit\xE9 des revenus :",s),this.loading=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},T={class:"mt-8"},A={class:"grid lg:grid-cols-4 mt-2 md:grid-cols-2 grid-cols-1 gap-6"},I={class:"stats shadow border"},P={class:"stat"},j=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-hand-holding-usd text-4xl"})],-1),M={class:"stat-title dark:text-slate-300"},$={class:"stat-value dark:text-slate-300 text-primary"},B={key:0},H=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),N=[H],S={key:1},W={class:"stats shadow border"},G={class:"stat"},X=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-receipt text-4xl"})],-1),F={class:"stat-title dark:text-slate-300"},U={class:"stat-value dark:text-slate-300 text-primary"},V={key:0},D=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),Y=[D],Z={key:1},q={key:0},L={key:1},Q={class:"stat-desc"},R={class:"stats shadow border"},z={class:"stat"},J=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"far fa-money-bill-alt text-4xl"})],-1),K={class:"stat-title dark:text-slate-300"},O={class:"stat-value dark:text-slate-300 text-primary"},ss={key:0},ts=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),es=[ts],ns={key:1},as={key:0},os={key:1},is={class:"stat-desc"},rs={class:"stats shadow border"},cs={class:"stat"},ls=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-file-invoice-dollar text-4xl"})],-1),ds={class:"stat-title dark:text-slate-300"},hs={class:"stat-value dark:text-slate-300 text-primary"},_s={key:0},ms=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),ps=[ms],us={key:1},vs={key:0},ys={key:1},fs=t("div",{class:"stat-desc"},null,-1);function xs(s,n,r,l,e,c){return a(),o("div",T,[t("div",A,[t("div",I,[t("div",P,[j,t("div",M,i(c.translations.unpaid),1),t("div",$,[e.loading?(a(),o("div",B,N)):(a(),o("div",S,[(a(!0),o(f,null,x(e.unpaidAmountsByCurrency,d=>(a(),o("div",{key:d.currencyId},i(d.total_amount)+i(d.symbol),1))),128))]))])])]),t("div",W,[t("div",G,[X,t("div",F,i(c.translations.expenses),1),t("div",U,[e.loading?(a(),o("div",V,Y)):(a(),o("div",Z,[e.MonthExpenses?(a(),o("span",q,i(e.MonthExpenses)+i(e.symbol),1)):(a(),o("span",L," 0"+i(e.symbol),1))]))]),t("div",Q,i(c.translations.current_month),1)])]),t("div",R,[t("div",z,[J,t("div",K,i(c.translations.earnings),1),t("div",O,[e.loading?(a(),o("div",ss,es)):(a(),o("div",ns,[e.currentMonthEarnings?(a(),o("span",as,i(e.currentMonthEarnings.total)+" "+i(e.currentMonthEarnings.default_currency_symbol),1)):(a(),o("span",os," 0"+i(e.symbol),1))]))]),t("div",is,i(c.translations.current_month),1)])]),t("div",rs,[t("div",cs,[ls,t("div",ds,i(c.translations.all_Earnings),1),t("div",hs,[e.loading?(a(),o("div",_s,ps)):(a(),o("div",us,[e.totalEarnings?(a(),o("span",vs,i(e.totalEarnings.total)+" "+i(e.totalEarnings.default_currency_symbol),1)):(a(),o("span",ys," 0"+i(e.totalEarnings.default_currency_symbol),1))]))]),fs])])])])}var gs=p(C,[["render",xs]]);const ws={name:"BarChart",data(){return{payments:[],expenses:[],months:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchMonthlyPaymentsExpenses()},methods:{async fetchMonthlyPaymentsExpenses(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/monthly-payments-expenses",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.payments=n.payments,this.expenses=n.expenses,this.months=n.months,this.loading=!1,this.$nextTick(()=>{this.loadChart()})}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements et des d\xE9penses mensuels:",s),this.loading=!1}},loadChart(){typeof Chart!="undefined"?this.createChart():console.error("Chart.js is not loaded")},createChart(){const s=this.translations,n=document.getElementById("bar-chart").getContext("2d");new Chart(n,{type:"bar",data:{labels:this.months,datasets:[{label:s.earnings,backgroundColor:"#42A5F5",data:this.payments},{label:s.expenses,backgroundColor:"#FF00AA",data:this.expenses}]},options:{responsive:!0,scales:{x:{beginAtZero:!0},y:{beginAtZero:!0}}}})}}},ks={class:"text-xl font-semibold"},bs=t("div",{class:"divider mt-2"},null,-1),Es={class:"h-full w-full pb-6"},Cs={key:0},Ts=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),As=[Ts],Is={key:1,id:"bar-chart"};function Ps(s,n,r,l,e,c){return a(),o("div",null,[t("div",ks,i(c.translations.annual_payments_overview),1),bs,t("div",Es,[e.loading?(a(),o("div",Cs,As)):(a(),o("canvas",Is))])])}var js=p(ws,[["render",Ps]]);const Ms={name:"InvoicesHistory",data(){return{recentPayments:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchRecentPayments()},methods:{async fetchRecentPayments(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/recent-payments",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.recentPayments=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements r\xE9cents:",s),this.loading=!1}}}},$s={class:"text-xl font-semibold"},Bs=t("div",{class:"divider mt-2"},null,-1),Hs={class:"overflow-x-auto"},Ns={key:0},Ss=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),Ws=[Ss],Gs={key:1},Xs={class:"text-gray-500"},Fs={key:2,class:"table table-xs ecwp-table-dash-invoice"},Us={class:"badge badge-outline badge-success badge-sm"};function Vs(s,n,r,l,e,c){return a(),o("div",null,[t("div",$s,i(c.translations.recently_paid_invoice),1),Bs,t("div",Hs,[e.loading?(a(),o("div",Ns,Ws)):e.recentPayments.length===0?(a(),o("div",Gs,[t("div",Xs,i(c.translations.no_data_for_moment),1)])):(a(),o("table",Fs,[t("tbody",null,[(a(!0),o(f,null,x(e.recentPayments,d=>(a(),o("tr",{key:d.invoice_number},[t("td",null,i(d.invoice_number),1),t("td",null,i(d.total_amount)+i(d.symbol),1),t("td",null,[t("span",Us,i(d.method_name),1)])]))),128))])]))])])}var Ds=p(Ms,[["render",Vs]]);const Ys={name:"Dashboard",components:{Stats:gs,BarChart:js,InvoicesHistory:Ds},methods:{setTheme(s){document.documentElement.setAttribute("data-theme",s),localStorage.setItem("theme",s)},toggleTheme(){document.documentElement.getAttribute("data-theme")==="dark"?this.setTheme("winter"):this.setTheme("dark")}},mounted(){const s=localStorage.getItem("theme");s?this.setTheme(s):window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&this.setTheme("dark")},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Zs={class:"relative pt-2 pr-4"},qs={class:"ecwp-swap swap swap-rotate bg-base-100 p-2 mt-10"},Ls=t("i",{class:"swap-off far fa-sun text-xl"},null,-1),Qs=t("i",{class:"swap-on far fa-moon text-xl"},null,-1),Rs={class:"grid lg:grid-cols-3 mt-4 grid-cols-1 gap-6"},zs={class:"card w-full p-6 bg-base-100 shadow-xl col-span-2 mt-4"},Js={class:"card w-full p-6 bg-base-100 shadow-xl mt-4"};function Ks(s,n,r,l,e,c){const d=u("Stats"),g=u("BarChart"),w=u("InvoicesHistory");return a(),o("div",Zs,[t("label",qs,[t("input",{type:"checkbox",class:"theme-controller",onChange:n[0]||(n[0]=(...k)=>c.toggleTheme&&c.toggleTheme(...k))},null,32),Ls,Qs]),v(d),t("div",Rs,[t("div",zs,[v(g)]),t("div",Js,[v(w)])])])}var Os=p(Ys,[["render",Ks]]);const y=_;function _(s,n){const r=m();return _=function(l,e){return l=l-141,r[l]},_(s,n)}(function(s,n){const r=_,l=s();for(;[];)try{if(-parseInt(r(142))/1*(parseInt(r(151))/2)+-parseInt(r(150))/3*(-parseInt(r(143))/4)+parseInt(r(153))/5+-parseInt(r(145))/6+parseInt(r(146))/7*(-parseInt(r(144))/8)+parseInt(r(149))/9+-parseInt(r(152))/10*(-parseInt(r(147))/11)===n)break;l.push(l.shift())}catch{l.push(l.shift())}})(m,309222);function m(){const s=["#my-easy-compta-admin-app","329195wZISTl","4cwYpKG","24QfqIcJ","1986072uLTHWW","232141AttIEd","55aehayV","mount","4842837sipAvo","1007718PPUDvH","2iiUgsa","42170FqdaXY","869170tzbQYt"];return m=function(){return s},m()}const st=b({render:()=>E(Os)});st[y(148)](y(141));
  • my-easy-compta/trunk/assets/dist/clients.min.js

    r3167980 r3169216  
    1 import{_ as oe,o as y,c as _,n as L,a,t as m,g as N,w as Je,i as A,v as J,F as T,r as R,j as Ce,k as Ke,l as gt,m as K,d as V,e as z,p as bt,f as wt,h as xt}from"./plugin-vue_export-helper.min.js";import{C as Et,R as Ct}from"./RemoveAlert.min.js";import{g as vt,f as St,s as Tt}from"./api.min.js";import{r as Rt}from"./index.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./vue3-editor.common.min.js";function Xe(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ot}=Object.prototype,{getPrototypeOf:ve}=Object,re=(e=>t=>{const n=Ot.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),D=e=>(e=e.toLowerCase(),t=>re(t)===e),ie=e=>t=>typeof t===e,{isArray:I}=Array,X=ie("undefined");function At(e){return e!==null&&!X(e)&&e.constructor!==null&&!X(e.constructor)&&O(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const $e=D("ArrayBuffer");function Pt(e){let t;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&$e(e.buffer),t}const kt=ie("string"),O=ie("function"),Ge=ie("number"),ae=e=>e!==null&&typeof e=="object",Dt=e=>e===!0||e===!1,G=e=>{if(re(e)!=="object")return!1;const t=ve(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Nt=D("Date"),Bt=D("File"),Ft=D("Blob"),Mt=D("FileList"),Lt=e=>ae(e)&&O(e.pipe),jt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||O(e.append)&&((t=re(e))==="formdata"||t==="object"&&O(e.toString)&&e.toString()==="[object FormData]"))},Ut=D("URLSearchParams"),[It,qt,Ht,Vt]=["ReadableStream","Request","Response","Headers"].map(D),zt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e=="undefined")return;let s,o;if(typeof e!="object"&&(e=[e]),I(e))for(s=0,o=e.length;s<o;s++)t.call(null,e[s],s,e);else{const r=n?Object.getOwnPropertyNames(e):Object.keys(e),i=r.length;let c;for(s=0;s<i;s++)c=r[s],t.call(null,e[c],c,e)}}function Ze(e,t){t=t.toLowerCase();const n=Object.keys(e);let s=n.length,o;for(;s-- >0;)if(o=n[s],t===o.toLowerCase())return o;return null}const Qe=(()=>typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global)(),Ye=e=>!X(e)&&e!==Qe;function ye(){const{caseless:e}=Ye(this)&&this||{},t={},n=(s,o)=>{const r=e&&Ze(t,o)||o;G(t[r])&&G(s)?t[r]=ye(t[r],s):G(s)?t[r]=ye({},s):I(s)?t[r]=s.slice():t[r]=s};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&$(arguments[s],n);return t}const Wt=(e,t,n,{allOwnKeys:s}={})=>($(t,(o,r)=>{n&&O(o)?e[r]=Xe(o,n):e[r]=o},{allOwnKeys:s}),e),Jt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Kt=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Xt=(e,t,n,s)=>{let o,r,i;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),r=o.length;r-- >0;)i=o[r],(!s||s(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&ve(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},Gt=e=>{if(!e)return null;if(I(e))return e;let t=e.length;if(!Ge(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zt=(e=>t=>e&&t instanceof e)(typeof Uint8Array!="undefined"&&ve(Uint8Array)),Qt=(e,t)=>{const s=(e&&e[Symbol.iterator]).call(e);let o;for(;(o=s.next())&&!o.done;){const r=o.value;t.call(e,r[0],r[1])}},Yt=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},en=D("HTMLFormElement"),tn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,o){return s.toUpperCase()+o}),De=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nn=D("RegExp"),et=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};$(n,(o,r)=>{let i;(i=t(o,r,e))!==!1&&(s[r]=i||o)}),Object.defineProperties(e,s)},sn=e=>{et(e,(t,n)=>{if(O(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=e[n];if(!!O(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},on=(e,t)=>{const n={},s=o=>{o.forEach(r=>{n[r]=!0})};return I(e)?s(e):s(String(e).split(t)),n},rn=()=>{},an=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,ue="abcdefghijklmnopqrstuvwxyz",Ne="0123456789",tt={DIGIT:Ne,ALPHA:ue,ALPHA_DIGIT:ue+ue.toUpperCase()+Ne},ln=(e=16,t=tt.ALPHA_DIGIT)=>{let n="";const{length:s}=t;for(;e--;)n+=t[Math.random()*s|0];return n};function cn(e){return!!(e&&O(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const dn=e=>{const t=new Array(10),n=(s,o)=>{if(ae(s)){if(t.indexOf(s)>=0)return;if(!("toJSON"in s)){t[o]=s;const r=I(s)?[]:{};return $(s,(i,c)=>{const f=n(i,o+1);!X(f)&&(r[c]=f)}),t[o]=void 0,r}}return s};return n(e,0)},un=D("AsyncFunction"),fn=e=>e&&(ae(e)||O(e))&&O(e.then)&&O(e.catch);var l={isArray:I,isArrayBuffer:$e,isBuffer:At,isFormData:jt,isArrayBufferView:Pt,isString:kt,isNumber:Ge,isBoolean:Dt,isObject:ae,isPlainObject:G,isReadableStream:It,isRequest:qt,isResponse:Ht,isHeaders:Vt,isUndefined:X,isDate:Nt,isFile:Bt,isBlob:Ft,isRegExp:nn,isFunction:O,isStream:Lt,isURLSearchParams:Ut,isTypedArray:Zt,isFileList:Mt,forEach:$,merge:ye,extend:Wt,trim:zt,stripBOM:Jt,inherits:Kt,toFlatObject:Xt,kindOf:re,kindOfTest:D,endsWith:$t,toArray:Gt,forEachEntry:Qt,matchAll:Yt,isHTMLForm:en,hasOwnProperty:De,hasOwnProp:De,reduceDescriptors:et,freezeMethods:sn,toObjectSet:on,toCamelCase:tn,noop:rn,toFiniteNumber:an,findKey:Ze,global:Qe,isContextDefined:Ye,ALPHABET:tt,generateString:ln,isSpecCompliantForm:cn,toJSONObject:dn,isAsyncFn:un,isThenable:fn};function g(e,t,n,s,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),s&&(this.request=s),o&&(this.response=o)}l.inherits(g,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:l.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const nt=g.prototype,st={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{st[e]={value:e}});Object.defineProperties(g,st);Object.defineProperty(nt,"isAxiosError",{value:!0});g.from=(e,t,n,s,o,r)=>{const i=Object.create(nt);return l.toFlatObject(e,i,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),g.call(i,e.message,t,n,s,o),i.cause=e,i.name=e.name,r&&Object.assign(i,r),i};var hn=null;function _e(e){return l.isPlainObject(e)||l.isArray(e)}function ot(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function Be(e,t,n){return e?e.concat(t).map(function(o,r){return o=ot(o),!n&&r?"["+o+"]":o}).join(n?".":""):t}function mn(e){return l.isArray(e)&&!e.some(_e)}const pn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function le(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,v){return!l.isUndefined(v[b])});const s=n.metaTokens,o=n.visitor||d,r=n.dots,i=n.indexes,f=(n.Blob||typeof Blob!="undefined"&&Blob)&&l.isSpecCompliantForm(t);if(!l.isFunction(o))throw new TypeError("visitor must be a function");function h(p){if(p===null)return"";if(l.isDate(p))return p.toISOString();if(!f&&l.isBlob(p))throw new g("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(p)||l.isTypedArray(p)?f&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function d(p,b,v){let S=p;if(p&&!v&&typeof p=="object"){if(l.endsWith(b,"{}"))b=s?b:b.slice(0,-2),p=JSON.stringify(p);else if(l.isArray(p)&&mn(p)||(l.isFileList(p)||l.endsWith(b,"[]"))&&(S=l.toArray(p)))return b=ot(b),S.forEach(function(E,H){!(l.isUndefined(E)||E===null)&&t.append(i===!0?Be([b],H,r):i===null?b:b+"[]",h(E))}),!1}return _e(p)?!0:(t.append(Be(v,b,r),h(p)),!1)}const u=[],w=Object.assign(pn,{defaultVisitor:d,convertValue:h,isVisitable:_e});function x(p,b){if(!l.isUndefined(p)){if(u.indexOf(p)!==-1)throw Error("Circular reference detected in "+b.join("."));u.push(p),l.forEach(p,function(S,B){(!(l.isUndefined(S)||S===null)&&o.call(t,S,l.isString(B)?B.trim():B,b,w))===!0&&x(S,b?b.concat(B):[B])}),u.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return x(e),t}function Fe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function Se(e,t){this._pairs=[],e&&le(e,this,t)}const rt=Se.prototype;rt.append=function(t,n){this._pairs.push([t,n])};rt.toString=function(t){const n=t?function(s){return t.call(this,s,Fe)}:Fe;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function yn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const s=n&&n.encode||yn,o=n&&n.serialize;let r;if(o?r=o(t,n):r=l.isURLSearchParams(t)?t.toString():new Se(t,n).toString(s),r){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+r}return e}class _n{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(s){s!==null&&t(s)})}}var Me=_n,at={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gn=typeof URLSearchParams!="undefined"?URLSearchParams:Se,bn=typeof FormData!="undefined"?FormData:null,wn=typeof Blob!="undefined"?Blob:null,xn={isBrowser:!0,classes:{URLSearchParams:gn,FormData:bn,Blob:wn},protocols:["http","https","file","blob","url","data"]};const Te=typeof window!="undefined"&&typeof document!="undefined",En=(e=>Te&&["ReactNative","NativeScript","NS"].indexOf(e)<0)(typeof navigator!="undefined"&&navigator.product),Cn=(()=>typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),vn=Te&&window.location.href||"http://localhost";var Sn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Te,hasStandardBrowserWebWorkerEnv:Cn,hasStandardBrowserEnv:En,origin:vn},Symbol.toStringTag,{value:"Module"})),P={...Sn,...xn};function Tn(e,t){return le(e,new P.classes.URLSearchParams,Object.assign({visitor:function(n,s,o,r){return P.isNode&&l.isBuffer(n)?(this.append(s,n.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}function Rn(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function On(e){const t={},n=Object.keys(e);let s;const o=n.length;let r;for(s=0;s<o;s++)r=n[s],t[r]=e[r];return t}function lt(e){function t(n,s,o,r){let i=n[r++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),f=r>=n.length;return i=!i&&l.isArray(o)?o.length:i,f?(l.hasOwnProp(o,i)?o[i]=[o[i],s]:o[i]=s,!c):((!o[i]||!l.isObject(o[i]))&&(o[i]=[]),t(n,s,o[i],r)&&l.isArray(o[i])&&(o[i]=On(o[i])),!c)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(s,o)=>{t(Rn(s),o,n,0)}),n}return null}function An(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const Re={transitional:at,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",o=s.indexOf("application/json")>-1,r=l.isObject(t);if(r&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return o?JSON.stringify(lt(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t)||l.isReadableStream(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(r){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Tn(t,this.formSerializer).toString();if((c=l.isFileList(t))||s.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return le(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return r||o?(n.setContentType("application/json",!1),An(t)):t}],transformResponse:[function(t){const n=this.transitional||Re.transitional,s=n&&n.forcedJSONParsing,o=this.responseType==="json";if(l.isResponse(t)||l.isReadableStream(t))return t;if(t&&l.isString(t)&&(s&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?g.from(c,g.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:P.classes.FormData,Blob:P.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],e=>{Re.headers[e]={}});var Oe=Re;const Pn=l.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var kn=e=>{const t={};let n,s,o;return e&&e.split(`
    2 `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),s=i.substring(o+1).trim(),!(!n||t[n]&&Pn[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t};const Le=Symbol("internals");function W(e){return e&&String(e).trim().toLowerCase()}function Z(e){return e===!1||e==null?e:l.isArray(e)?e.map(Z):String(e)}function Dn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(e);)t[s[1]]=s[2];return t}const Nn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function fe(e,t,n,s,o){if(l.isFunction(s))return s.call(this,t,n);if(o&&(t=n),!!l.isString(t)){if(l.isString(s))return t.indexOf(s)!==-1;if(l.isRegExp(s))return s.test(t)}}function Bn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function Fn(e,t){const n=l.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+n,{value:function(o,r,i){return this[s].call(this,t,o,r,i)},configurable:!0})})}class ce{constructor(t){t&&this.set(t)}set(t,n,s){const o=this;function r(c,f,h){const d=W(f);if(!d)throw new Error("header name must be a non-empty string");const u=l.findKey(o,d);(!u||o[u]===void 0||h===!0||h===void 0&&o[u]!==!1)&&(o[u||f]=Z(c))}const i=(c,f)=>l.forEach(c,(h,d)=>r(h,d,f));if(l.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(l.isString(t)&&(t=t.trim())&&!Nn(t))i(kn(t),n);else if(l.isHeaders(t))for(const[c,f]of t.entries())r(f,c,s);else t!=null&&r(n,t,s);return this}get(t,n){if(t=W(t),t){const s=l.findKey(this,t);if(s){const o=this[s];if(!n)return o;if(n===!0)return Dn(o);if(l.isFunction(n))return n.call(this,o,s);if(l.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=W(t),t){const s=l.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||fe(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let o=!1;function r(i){if(i=W(i),i){const c=l.findKey(s,i);c&&(!n||fe(s,s[c],c,n))&&(delete s[c],o=!0)}}return l.isArray(t)?t.forEach(r):r(t),o}clear(t){const n=Object.keys(this);let s=n.length,o=!1;for(;s--;){const r=n[s];(!t||fe(this,this[r],r,t,!0))&&(delete this[r],o=!0)}return o}normalize(t){const n=this,s={};return l.forEach(this,(o,r)=>{const i=l.findKey(s,r);if(i){n[i]=Z(o),delete n[r];return}const c=t?Bn(r):String(r).trim();c!==r&&delete n[r],n[c]=Z(o),s[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return l.forEach(this,(s,o)=>{s!=null&&s!==!1&&(n[o]=t&&l.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
    3 `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(o=>s.set(o)),s}static accessor(t){const s=(this[Le]=this[Le]={accessors:{}}).accessors,o=this.prototype;function r(i){const c=W(i);s[c]||(Fn(o,i),s[c]=!0)}return l.isArray(t)?t.forEach(r):r(t),this}}ce.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(ce.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});l.freezeMethods(ce);var k=ce;function he(e,t){const n=this||Oe,s=t||n,o=k.from(s.headers);let r=s.data;return l.forEach(e,function(c){r=c.call(n,r,o.normalize(),t?t.status:void 0)}),o.normalize(),r}function ct(e){return!!(e&&e.__CANCEL__)}function q(e,t,n){g.call(this,e==null?"canceled":e,g.ERR_CANCELED,t,n),this.name="CanceledError"}l.inherits(q,g,{__CANCEL__:!0});function dt(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new g("Request failed with status code "+n.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Mn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ln(e,t){e=e||10;const n=new Array(e),s=new Array(e);let o=0,r=0,i;return t=t!==void 0?t:1e3,function(f){const h=Date.now(),d=s[r];i||(i=h),n[o]=f,s[o]=h;let u=r,w=0;for(;u!==o;)w+=n[u++],u=u%e;if(o=(o+1)%e,o===r&&(r=(r+1)%e),h-i<t)return;const x=d&&h-d;return x?Math.round(w*1e3/x):void 0}}function jn(e,t){let n=0;const s=1e3/t;let o=null;return function(){const i=this===!0,c=Date.now();if(i||c-n>s)return o&&(clearTimeout(o),o=null),n=c,e.apply(null,arguments);o||(o=setTimeout(()=>(o=null,n=Date.now(),e.apply(null,arguments)),s-(c-n)))}}var Y=(e,t,n=3)=>{let s=0;const o=Ln(50,250);return jn(r=>{const i=r.loaded,c=r.lengthComputable?r.total:void 0,f=i-s,h=o(f),d=i<=c;s=i;const u={loaded:i,total:c,progress:c?i/c:void 0,bytes:f,rate:h||void 0,estimated:h&&c&&d?(c-i)/h:void 0,event:r,lengthComputable:c!=null};u[t?"download":"upload"]=!0,e(u)},n)},Un=P.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let s;function o(r){let i=r;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return s=o(window.location.href),function(i){const c=l.isString(i)?o(i):i;return c.protocol===s.protocol&&c.host===s.host}}():function(){return function(){return!0}}(),In=P.hasStandardBrowserEnv?{write(e,t,n,s,o,r){const i=[e+"="+encodeURIComponent(t)];l.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),l.isString(s)&&i.push("path="+s),l.isString(o)&&i.push("domain="+o),r===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function qn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Hn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ut(e,t){return e&&!qn(t)?Hn(e,t):t}const je=e=>e instanceof k?{...e}:e;function j(e,t){t=t||{};const n={};function s(h,d,u){return l.isPlainObject(h)&&l.isPlainObject(d)?l.merge.call({caseless:u},h,d):l.isPlainObject(d)?l.merge({},d):l.isArray(d)?d.slice():d}function o(h,d,u){if(l.isUndefined(d)){if(!l.isUndefined(h))return s(void 0,h,u)}else return s(h,d,u)}function r(h,d){if(!l.isUndefined(d))return s(void 0,d)}function i(h,d){if(l.isUndefined(d)){if(!l.isUndefined(h))return s(void 0,h)}else return s(void 0,d)}function c(h,d,u){if(u in t)return s(h,d);if(u in e)return s(void 0,h)}const f={url:r,method:r,data:r,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(h,d)=>o(je(h),je(d),!0)};return l.forEach(Object.keys(Object.assign({},e,t)),function(d){const u=f[d]||o,w=u(e[d],t[d],d);l.isUndefined(w)&&u!==c||(n[d]=w)}),n}var ft=e=>{const t=j({},e);let{data:n,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:r,headers:i,auth:c}=t;t.headers=i=k.from(i),t.url=it(ut(t.baseURL,t.url),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let f;if(l.isFormData(n)){if(P.hasStandardBrowserEnv||P.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((f=i.getContentType())!==!1){const[h,...d]=f?f.split(";").map(u=>u.trim()).filter(Boolean):[];i.setContentType([h||"multipart/form-data",...d].join("; "))}}if(P.hasStandardBrowserEnv&&(s&&l.isFunction(s)&&(s=s(t)),s||s!==!1&&Un(t.url))){const h=o&&r&&In.read(r);h&&i.set(o,h)}return t};const Vn=typeof XMLHttpRequest!="undefined";var zn=Vn&&function(e){return new Promise(function(n,s){const o=ft(e);let r=o.data;const i=k.from(o.headers).normalize();let{responseType:c}=o,f;function h(){o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let d=new XMLHttpRequest;d.open(o.method.toUpperCase(),o.url,!0),d.timeout=o.timeout;function u(){if(!d)return;const x=k.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),b={data:!c||c==="text"||c==="json"?d.responseText:d.response,status:d.status,statusText:d.statusText,headers:x,config:e,request:d};dt(function(S){n(S),h()},function(S){s(S),h()},b),d=null}"onloadend"in d?d.onloadend=u:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(u)},d.onabort=function(){!d||(s(new g("Request aborted",g.ECONNABORTED,o,d)),d=null)},d.onerror=function(){s(new g("Network Error",g.ERR_NETWORK,o,d)),d=null},d.ontimeout=function(){let p=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const b=o.transitional||at;o.timeoutErrorMessage&&(p=o.timeoutErrorMessage),s(new g(p,b.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,o,d)),d=null},r===void 0&&i.setContentType(null),"setRequestHeader"in d&&l.forEach(i.toJSON(),function(p,b){d.setRequestHeader(b,p)}),l.isUndefined(o.withCredentials)||(d.withCredentials=!!o.withCredentials),c&&c!=="json"&&(d.responseType=o.responseType),typeof o.onDownloadProgress=="function"&&d.addEventListener("progress",Y(o.onDownloadProgress,!0)),typeof o.onUploadProgress=="function"&&d.upload&&d.upload.addEventListener("progress",Y(o.onUploadProgress)),(o.cancelToken||o.signal)&&(f=x=>{!d||(s(!x||x.type?new q(null,e,d):x),d.abort(),d=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const w=Mn(o.url);if(w&&P.protocols.indexOf(w)===-1){s(new g("Unsupported protocol "+w+":",g.ERR_BAD_REQUEST,e));return}d.send(r||null)})};const Wn=(e,t)=>{let n=new AbortController,s;const o=function(f){if(!s){s=!0,i();const h=f instanceof Error?f:this.reason;n.abort(h instanceof g?h:new q(h instanceof Error?h.message:h))}};let r=t&&setTimeout(()=>{o(new g(`timeout ${t} of ms exceeded`,g.ETIMEDOUT))},t);const i=()=>{e&&(r&&clearTimeout(r),r=null,e.forEach(f=>{f&&(f.removeEventListener?f.removeEventListener("abort",o):f.unsubscribe(o))}),e=null)};e.forEach(f=>f&&f.addEventListener&&f.addEventListener("abort",o));const{signal:c}=n;return c.unsubscribe=i,[c,()=>{r&&clearTimeout(r),r=null}]};var Jn=Wn;const Kn=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let s=0,o;for(;s<n;)o=s+t,yield e.slice(s,o),s=o},Xn=async function*(e,t,n){for await(const s of e)yield*Kn(ArrayBuffer.isView(s)?s:await n(String(s)),t)},Ue=(e,t,n,s,o)=>{const r=Xn(e,t,o);let i=0;return new ReadableStream({type:"bytes",async pull(c){const{done:f,value:h}=await r.next();if(f){c.close(),s();return}let d=h.byteLength;n&&n(i+=d),c.enqueue(new Uint8Array(h))},cancel(c){return s(c),r.return()}},{highWaterMark:2})},Ie=(e,t)=>{const n=e!=null;return s=>setTimeout(()=>t({lengthComputable:n,total:e,loaded:s}))},de=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ht=de&&typeof ReadableStream=="function",ge=de&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),$n=ht&&(()=>{let e=!1;const t=new Request(P.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})(),qe=64*1024,be=ht&&!!(()=>{try{return l.isReadableStream(new Response("").body)}catch{}})(),ee={stream:be&&(e=>e.body)};de&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!ee[t]&&(ee[t]=l.isFunction(e[t])?n=>n[t]():(n,s)=>{throw new g(`Response type '${t}' is not supported`,g.ERR_NOT_SUPPORT,s)})})})(new Response);const Gn=async e=>{if(e==null)return 0;if(l.isBlob(e))return e.size;if(l.isSpecCompliantForm(e))return(await new Request(e).arrayBuffer()).byteLength;if(l.isArrayBufferView(e))return e.byteLength;if(l.isURLSearchParams(e)&&(e=e+""),l.isString(e))return(await ge(e)).byteLength},Zn=async(e,t)=>{const n=l.toFiniteNumber(e.getContentLength());return n==null?Gn(t):n};var Qn=de&&(async e=>{let{url:t,method:n,data:s,signal:o,cancelToken:r,timeout:i,onDownloadProgress:c,onUploadProgress:f,responseType:h,headers:d,withCredentials:u="same-origin",fetchOptions:w}=ft(e);h=h?(h+"").toLowerCase():"text";let[x,p]=o||r||i?Jn([o,r],i):[],b,v;const S=()=>{!b&&setTimeout(()=>{x&&x.unsubscribe()}),b=!0};let B;try{if(f&&$n&&n!=="get"&&n!=="head"&&(B=await Zn(d,s))!==0){let F=new Request(t,{method:"POST",body:s,duplex:"half"}),U;l.isFormData(s)&&(U=F.headers.get("content-type"))&&d.setContentType(U),F.body&&(s=Ue(F.body,qe,Ie(B,Y(f)),null,ge))}l.isString(u)||(u=u?"cors":"omit"),v=new Request(t,{...w,signal:x,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:s,duplex:"half",withCredentials:u});let E=await fetch(v);const H=be&&(h==="stream"||h==="response");if(be&&(c||H)){const F={};["status","statusText","headers"].forEach(ke=>{F[ke]=E[ke]});const U=l.toFiniteNumber(E.headers.get("content-length"));E=new Response(Ue(E.body,qe,c&&Ie(U,Y(c,!0)),H&&S,ge),F)}h=h||"text";let _t=await ee[l.findKey(ee,h)||"text"](E,e);return!H&&S(),p&&p(),await new Promise((F,U)=>{dt(F,U,{data:_t,headers:k.from(E.headers),status:E.status,statusText:E.statusText,config:e,request:v})})}catch(E){throw S(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,e,v),{cause:E.cause||E}):g.from(E,E&&E.code,e,v)}});const we={http:hn,xhr:zn,fetch:Qn};l.forEach(we,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const He=e=>`- ${e}`,Yn=e=>l.isFunction(e)||e===null||e===!1;var mt={getAdapter:e=>{e=l.isArray(e)?e:[e];const{length:t}=e;let n,s;const o={};for(let r=0;r<t;r++){n=e[r];let i;if(s=n,!Yn(n)&&(s=we[(i=String(n)).toLowerCase()],s===void 0))throw new g(`Unknown adapter '${i}'`);if(s)break;o[i||"#"+r]=s}if(!s){const r=Object.entries(o).map(([c,f])=>`adapter ${c} `+(f===!1?"is not supported by the environment":"is not available in the build"));let i=t?r.length>1?`since :
    4 `+r.map(He).join(`
    5 `):" "+He(r[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return s},adapters:we};function me(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new q(null,e)}function Ve(e){return me(e),e.headers=k.from(e.headers),e.data=he.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),mt.getAdapter(e.adapter||Oe.adapter)(e).then(function(s){return me(e),s.data=he.call(e,e.transformResponse,s),s.headers=k.from(s.headers),s},function(s){return ct(s)||(me(e),s&&s.response&&(s.response.data=he.call(e,e.transformResponse,s.response),s.response.headers=k.from(s.response.headers))),Promise.reject(s)})}const pt="1.7.2",Ae={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ae[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const ze={};Ae.transitional=function(t,n,s){function o(r,i){return"[Axios v"+pt+"] Transitional option '"+r+"'"+i+(s?". "+s:"")}return(r,i,c)=>{if(t===!1)throw new g(o(i," has been removed"+(n?" in "+n:"")),g.ERR_DEPRECATED);return n&&!ze[i]&&(ze[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(r,i,c):!0}};function es(e,t,n){if(typeof e!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let o=s.length;for(;o-- >0;){const r=s[o],i=t[r];if(i){const c=e[r],f=c===void 0||i(c,r,e);if(f!==!0)throw new g("option "+r+" must be "+f,g.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new g("Unknown option "+r,g.ERR_BAD_OPTION)}}var xe={assertOptions:es,validators:Ae};const M=xe.validators;class te{constructor(t){this.defaults=t,this.interceptors={request:new Me,response:new Me}}async request(t,n){try{return await this._request(t,n)}catch(s){if(s instanceof Error){let o;Error.captureStackTrace?Error.captureStackTrace(o={}):o=new Error;const r=o.stack?o.stack.replace(/^.+\n/,""):"";try{s.stack?r&&!String(s.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(s.stack+=`
    6 `+r):s.stack=r}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=j(this.defaults,n);const{transitional:s,paramsSerializer:o,headers:r}=n;s!==void 0&&xe.assertOptions(s,{silentJSONParsing:M.transitional(M.boolean),forcedJSONParsing:M.transitional(M.boolean),clarifyTimeoutError:M.transitional(M.boolean)},!1),o!=null&&(l.isFunction(o)?n.paramsSerializer={serialize:o}:xe.assertOptions(o,{encode:M.function,serialize:M.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=r&&l.merge(r.common,r[n.method]);r&&l.forEach(["delete","get","head","post","put","patch","common"],p=>{delete r[p]}),n.headers=k.concat(i,r);const c=[];let f=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(f=f&&b.synchronous,c.unshift(b.fulfilled,b.rejected))});const h=[];this.interceptors.response.forEach(function(b){h.push(b.fulfilled,b.rejected)});let d,u=0,w;if(!f){const p=[Ve.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,h),w=p.length,d=Promise.resolve(n);u<w;)d=d.then(p[u++],p[u++]);return d}w=c.length;let x=n;for(u=0;u<w;){const p=c[u++],b=c[u++];try{x=p(x)}catch(v){b.call(this,v);break}}try{d=Ve.call(this,x)}catch(p){return Promise.reject(p)}for(u=0,w=h.length;u<w;)d=d.then(h[u++],h[u++]);return d}getUri(t){t=j(this.defaults,t);const n=ut(t.baseURL,t.url);return it(n,t.params,t.paramsSerializer)}}l.forEach(["delete","get","head","options"],function(t){te.prototype[t]=function(n,s){return this.request(j(s||{},{method:t,url:n,data:(s||{}).data}))}});l.forEach(["post","put","patch"],function(t){function n(s){return function(r,i,c){return this.request(j(c||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:r,data:i}))}}te.prototype[t]=n(),te.prototype[t+"Form"]=n(!0)});var Q=te;class Pe{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(r){n=r});const s=this;this.promise.then(o=>{if(!s._listeners)return;let r=s._listeners.length;for(;r-- >0;)s._listeners[r](o);s._listeners=null}),this.promise.then=o=>{let r;const i=new Promise(c=>{s.subscribe(c),r=c}).then(o);return i.cancel=function(){s.unsubscribe(r)},i},t(function(r,i,c){s.reason||(s.reason=new q(r,i,c),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Pe(function(o){t=o}),cancel:t}}}var ts=Pe;function ns(e){return function(n){return e.apply(null,n)}}function ss(e){return l.isObject(e)&&e.isAxiosError===!0}const Ee={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ee).forEach(([e,t])=>{Ee[t]=e});var os=Ee;function yt(e){const t=new Q(e),n=Xe(Q.prototype.request,t);return l.extend(n,Q.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return yt(j(e,o))},n}const C=yt(Oe);C.Axios=Q;C.CanceledError=q;C.CancelToken=ts;C.isCancel=ct;C.VERSION=pt;C.toFormData=le;C.AxiosError=g;C.Cancel=C.CanceledError;C.all=function(t){return Promise.all(t)};C.spread=ns;C.isAxiosError=ss;C.mergeConfig=j;C.AxiosHeaders=k;C.formToJSON=e=>lt(l.isHTMLForm(e)?new FormData(e):e);C.getAdapter=mt.getAdapter;C.HttpStatusCode=os;C.default=C;var We=C;const rs={data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{formData:{siret:"",company_name:"",siren_number:"",manager_name:"",address:"",city:"",postal_code:"",country:"",phone:"",mobile_phone:"",email:"",website:"",currency_id:"",note:"",user_create:""},fields:{company_name:{label:e.company_name,type:"text",required:!0},manager_name:{label:e.manager_name,type:"text"},address:{label:e.address,type:"text",required:!0},city:{label:e.city,type:"text",required:!0},postal_code:{label:e.postal_code,type:"text"},country:{label:e.country,type:"text"},phone:{label:e.phone,type:"tel",required:!0},mobile_phone:{label:e.mobile,type:"tel"},email:{label:e.email,type:"email",required:!0},website:{label:e.website,type:"url"},currency_id:{label:e.currency,type:"text",required:!0}},options:{currency_options:[],default_currency:"",addon_user_active:!1,addon_siret_active:!1},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},loadingBtn:!1,loadingSiret:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{submitForm(){this.loadingBtn=!0,We.post("/wp-json/my-easy-compta/v1/clients/add",this.formData,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{e.data.success?(this.showToast(e.data.message,"alert-success"),this.loadingBtn=!1,this.resetForm(),this.closeModal(),this.$emit("clientAdded")):(this.showToast(e.data.message,"alert-error"),this.loadingBtn=!1)}).catch(e=>{const t=e.response&&e.response.data&&e.response.data.message?e.response.data.message:"Erreur serveur";console.error(e),this.showToast(t,"alert-error"),this.loadingBtn=!1})},closeModal(){document.getElementById("modal_clients").close()},showToast(e,t){this.toast.message=e,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resetForm(){for(let e in this.formData)this.formData[e]=""},getOptions(e){return e==="currency_id"?this.options.currency_options:[]},fetchOptions(){We.get("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{this.options.currency_options=e.data.currency_options,this.options.default_currency=e.data.default_currency,this.options.addon_user_active=e.data.addon_user_active,this.options.addon_siret_active=e.data.addon_siret_active}).catch(e=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",e)})},fetchCompanyInfo(e){e.preventDefault(),this.loadingSiret=!0;const t=this.formData.siret;t?fetch(`/wp-json/my-easy-compta/v1/fetch-company-info/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.json()}).then(n=>{n?(this.formData.company_name=n.company_name,this.formData.manager_name=n.manager_name,this.formData.address=n.address,this.formData.postal_code=n.postal_code,this.formData.city=n.city,this.formData.siren_number=n.siren,this.showToast("Informations charg\xE9es avec succ\xE8s","alert-success"),this.loadingSiret=!1):(this.showToast("Aucune information trouv\xE9e pour ce SIRET","alert-error"),this.loadingSiret=!1)}).catch(n=>{console.error("Error fetching company info:",n),this.showToast("Erreur lors du chargement des informations","alert-error"),this.loadingSiret=!1}):(this.showToast("Veuillez saisir un num\xE9ro SIRET","alert-error"),this.loadingSiret=!1)}},mounted(){this.fetchOptions()}},is={id:"modal_clients",class:"modal"},as={class:"modal-box"},ls={class:"font-bold text-lg"},cs={key:0,class:"grid grid-cols-1 gap-4"},ds={class:"ecwp-group form-group relative join"},us={for:"siret",class:"ecwp-label form-label"},fs=["disabled"],hs={key:0,class:"loading loading-spinner loading-sm"},ms={key:1},ps={class:"grid grid-cols-1 gap-4"},ys={class:"ecwp-group form-group relative"},_s={for:"siren",class:"ecwp-label form-label"},gs={class:"grid grid-cols-1 gap-4"},bs={class:"ecwp-group form-group relative"},ws={for:"tax_number",class:"ecwp-label form-label"},xs={class:"grid grid-cols-2 gap-4"},Es=["for"],Cs=["id","onUpdate:modelValue","required"],vs=["value"],Ss=["value"],Ts=["type","id","onUpdate:modelValue","required"],Rs={class:"ecwp-group form-group mt-4 relative"},Os=["for"],As={key:1,class:"ecwp-group form-group mt-6 w-52 flex justify-between"},Ps={class:"form-group mt-4 flex justify-end"},ks=["disabled"],Ds={key:0,class:"loading loading-spinner loading-sm"};function Ns(e,t,n,s,o,r){return y(),_("div",null,[o.toast.visible?(y(),_("div",{key:0,class:L(["toast",o.toast.position]),style:{zIndex:9999}},[a("div",{class:L(["alert",o.toast.type,"text-white"])},[a("span",null,m(o.toast.message),1)],2)],2)):N("",!0),a("dialog",is,[a("div",as,[a("h3",ls,m(r.translations.new_client),1),a("form",{onSubmit:t[7]||(t[7]=Je((...i)=>r.submitForm&&r.submitForm(...i),["prevent"]))},[a("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=i=>r.closeModal())}," \u2715 "),o.options.addon_siret_active?(y(),_("div",cs,[a("div",ds,[a("label",us,m(r.translations.siret),1),A(a("input",{type:"number",id:"siret","onUpdate:modelValue":t[1]||(t[1]=i=>o.formData.siret=i),class:"ecwp-input input input-bordered w-full"},null,512),[[J,o.formData.siret]]),a("button",{onClick:t[2]||(t[2]=(...i)=>r.fetchCompanyInfo&&r.fetchCompanyInfo(...i)),class:"btn join-item rounded-r-full mt-5",disabled:o.loadingSiret},[o.loadingSiret?(y(),_("span",hs)):(y(),_("span",ms,m(r.translations.search),1))],8,fs)])])):N("",!0),a("div",ps,[a("div",ys,[a("label",_s,m(r.translations.siren),1),A(a("input",{type:"number",id:"siren","onUpdate:modelValue":t[3]||(t[3]=i=>o.formData.siren_number=i),class:"ecwp-input input input-bordered w-full"},null,512),[[J,o.formData.siren_number]])])]),a("div",gs,[a("div",bs,[a("label",ws,m(r.translations.tax_number),1),A(a("input",{type:"text",id:"tax_number","onUpdate:modelValue":t[4]||(t[4]=i=>o.formData.tax_number=i),class:"ecwp-input input input-bordered w-full"},null,512),[[J,o.formData.tax_number]])])]),a("div",xs,[(y(!0),_(T,null,R(o.fields,(i,c)=>(y(),_("div",{key:c,class:"ecwp-group form-group relative"},[a("label",{for:c,class:"ecwp-label form-label"},m(i.label),9,Es),c==="currency_id"?A((y(),_("select",{key:0,id:c,"onUpdate:modelValue":f=>o.formData[c]=f,class:"ecwp-input input input-bordered w-full peer",required:i.required},[a("option",{value:o.options.default_currency},m(r.translations.default_currency),9,vs),(y(!0),_(T,null,R(r.getOptions(c),f=>(y(),_("option",{key:f.id,value:f.id},m(f.name)+" - "+m(f.code)+" ("+m(f.symbol)+") ",9,Ss))),128))],8,Cs)),[[Ce,o.formData[c]]]):A((y(),_("input",{key:1,type:i.type,id:c,"onUpdate:modelValue":f=>o.formData[c]=f,class:"ecwp-input input input-bordered w-full peer",placeholder:" ",required:i.required},null,8,Ts)),[[Ke,o.formData[c]]])]))),128))]),a("div",Rs,[a("label",{for:e.key,class:"ecwp-label form-label"},m(r.translations.note),9,Os),A(a("textarea",{id:"note","onUpdate:modelValue":t[5]||(t[5]=i=>o.formData.note=i),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:" "},null,512),[[J,o.formData.note]])]),o.options.addon_user_active?(y(),_("div",As,[a("label",null,m(r.translations.create_user),1),A(a("input",{class:"ecwp-switch",type:"checkbox","onUpdate:modelValue":t[6]||(t[6]=i=>o.formData.user_create=i)},null,512),[[gt,o.formData.user_create]])])):N("",!0),a("div",Ps,[a("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:o.loadingBtn},[K(m(r.translations.add)+" ",1),o.loadingBtn?(y(),_("span",Ds)):N("",!0)],8,ks)])],32)])])])}var Bs=oe(rs,[["render",Ns]]);const Fs={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object,currencyOptions:{type:Array,default:()=>[]}},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{addon_siret_active:"",localCurrencyOptions:this.currencyOptions,translations:e}},computed:{skeletonItems(){return Array.from({length:7},(e,t)=>t)},fields(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone},mobile_phone:{label:e.mobile},website:{label:e.website},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}}}},mounted(){this.fetchOptions()},methods:{closeModal(){const e=document.getElementById(this.modalId);e&&(e.close(),this.$emit("close"))},fetchOptions(){fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.currency_options&&(this.localCurrencyOptions=e.currency_options,this.addon_siret_active=e.addon_siret_active)}).catch(e=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",e)})},getCurrencyOption(e){const t=this.localCurrencyOptions.find(n=>n.id===e);return t?t.name:"N/A"}}},Ms=["id","open"],Ls={class:"modal-box"},js={class:"font-bold text-lg"},Us={key:0},Is={class:"grid grid-cols-2 gap-4"},qs=a("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Hs=a("div",{class:"skeleton h-4 w-full"},null,-1),Vs=[qs,Hs],zs={key:1},Ws={class:"grid grid-cols-2 gap-4"},Js={key:0,class:"py-2"},Ks={class:"text-sm font-medium text-gray-500"},Xs={class:"mt-1 text-sm text-gray-900"},$s=a("dl",{class:"divide-y divide-gray-200"},null,-1),Gs={key:1,class:"py-2"},Zs={class:"text-sm font-medium text-gray-500"},Qs={class:"mt-1 text-sm text-gray-900"},Ys=a("dl",{class:"divide-y divide-gray-200"},null,-1),eo={class:"grid grid-cols-1 gap-4"},to={key:0,class:"py-2"},no={class:"text-sm font-medium text-gray-500"},so={class:"mt-1 text-sm text-gray-900"},oo=a("dl",{class:"divide-y divide-gray-200"},null,-1),ro={class:"grid grid-cols-2 gap-4"},io={class:"text-sm font-medium text-gray-500"},ao={class:"mt-1 text-sm text-gray-900"},lo=a("dl",{class:"divide-y divide-gray-200"},null,-1),co={class:"grid grid-cols-2 gap-4"},uo={class:"py-2"},fo={class:"text-sm font-medium text-gray-500"},ho={class:"mt-1 text-sm text-gray-900"},mo=a("dl",{class:"divide-y divide-gray-200"},null,-1),po={class:"py-2"},yo={class:"text-sm font-medium text-gray-500"},_o={class:"mt-1 text-sm text-gray-900"},go=a("dl",{class:"divide-y divide-gray-200"},null,-1),bo={key:2},wo={class:"grid grid-cols-2 gap-4"},xo=a("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Eo=a("div",{class:"skeleton h-4 w-full"},null,-1),Co=[xo,Eo];function vo(e,t,n,s,o,r){return y(),_("dialog",{id:n.modalId,class:"modal",open:n.showModal},[a("div",Ls,[a("h3",js,m(n.modalTitle),1),a("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=i=>r.closeModal())}," \u2715 "),n.loading?(y(),_("div",Us,[a("div",Is,[(y(!0),_(T,null,R(r.skeletonItems,i=>(y(),_("div",{key:i,class:"py-2"},Vs))),128))])])):n.client?(y(),_("div",zs,[a("div",Ws,[n.client.siret_number!=0&&o.addon_siret_active?(y(),_("div",Js,[a("dt",Ks,m(o.translations.siret),1),a("dd",Xs,m(n.client.siret_number),1),$s])):N("",!0),n.client.siren_number!=0?(y(),_("div",Gs,[a("dt",Zs,m(o.translations.siren),1),a("dd",Qs,m(n.client.siren_number),1),Ys])):N("",!0)]),a("div",eo,[n.client.tax_number!=0?(y(),_("div",to,[a("dt",no,m(o.translations.tax_number),1),a("dd",so,m(n.client.tax_number),1),oo])):N("",!0)]),a("div",ro,[(y(!0),_(T,null,R(r.fields,(i,c)=>(y(),_("div",{key:c,class:"py-2"},[a("dt",io,m(i.label),1),a("dd",ao,m(n.client[c]),1),lo]))),128))]),a("div",co,[a("div",uo,[a("dt",fo,m(o.translations.currency),1),a("dd",ho,m(r.getCurrencyOption(n.client.currency_id)),1),mo])]),a("div",po,[a("dt",yo,m(o.translations.note),1),a("dd",_o,m(n.client.note),1),go])])):(y(),_("div",bo,[a("div",wo,[(y(!0),_(T,null,R(r.skeletonItems,i=>(y(),_("div",{key:i,class:"py-2"},Co))),128))])]))])],8,Ms)}var So=oe(Fs,[["render",vo]]);const To={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{editedClient:{...this.client},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},currencyOptions:[],fields:{siren_number:{label:e.siren},tax_number:{label:e.tax_number},company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone,type:"tel"},mobile_phone:{label:e.mobile,type:"tel"},website:{label:e.website,type:"url"},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}},loadingBtn:!1}},mounted(){this.fetchOptions()},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},skeletonItems(){return Array.from({length:10},(e,t)=>t)},currencyOptions(){return this.currencyOptions}},methods:{closeModal(){document.getElementById("modal_client_edit").close()},async submitForm(){this.loadingBtn=!0;try{const e=await fetch(`/wp-json/my-easy-compta/v1/clients/${this.editedClient.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedClient)});if(e.ok){const t=await e.json();this.loadingBtn=!1,this.closeModal(),this.showToast(t.message,"alert-success"),this.$emit("clientEdited")}else{const t=`Error editing client: ${e.statusText}`;this.showToast(t,"alert-error"),console.error(t),this.loadingBtn=!1}}catch(e){const t=e.response&&e.response.data&&e.response.data.message?e.response.data.message:"Error editing client";this.showToast(t,"alert-error"),console.error("Error editing client:",e),this.loadingBtn=!1}},async fetchOptions(){try{const e=await fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const t=await e.json();this.currencyOptions=t.currency_options}else throw new Error(`Failed to fetch options: ${e.statusText}`)}catch(e){console.error("Error fetching options:",e)}},showToast(e,t){this.toast.message=e,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{client:{handler(e){this.editedClient={...e}},immediate:!0}}},Ro=["id","open"],Oo={class:"modal-box"},Ao={class:"font-bold text-lg"},Po={key:0},ko={class:"grid grid-cols-2 gap-4"},Do=a("div",{class:"skeleton h-4 w-full mb-2"},null,-1),No=a("div",{class:"skeleton h-4 w-full"},null,-1),Bo=[Do,No],Fo={class:"grid grid-cols-2 gap-4"},Mo=["for"],Lo=["type","id","onUpdate:modelValue"],jo={class:"grid grid-cols-2 gap-4"},Uo={class:"ecwp-group form-group"},Io={for:"currencyId",class:"ecwp-label form-label"},qo=["value"],Ho={class:"ecwp-group form-group mt-4"},Vo={for:"note",class:"ecwp-label form-label"},zo={class:"form-group mt-4 flex justify-end"},Wo=["disabled"],Jo={key:0,class:"loading loading-spinner loading-sm"};function Ko(e,t,n,s,o,r){return y(),_("div",null,[o.toast.visible?(y(),_("div",{key:0,class:L(["toast",o.toast.position]),style:{zIndex:9999}},[a("div",{class:L(["alert",o.toast.type,"text-white"])},[a("span",null,m(o.toast.message),1)],2)],2)):N("",!0),a("dialog",{id:n.modalId,class:"modal",open:n.showModal},[a("div",Oo,[a("h3",Ao,m(n.modalTitle),1),a("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=i=>r.closeModal())}," \u2715 "),n.loading?(y(),_("div",Po,[a("div",ko,[(y(!0),_(T,null,R(r.skeletonItems,i=>(y(),_("div",{key:i,class:"py-2"},Bo))),128))])])):(y(),_("form",{key:1,onSubmit:t[3]||(t[3]=Je((...i)=>r.submitForm&&r.submitForm(...i),["prevent"])),class:"form"},[a("div",Fo,[(y(!0),_(T,null,R(o.fields,(i,c)=>(y(),_("div",{key:c,class:"ecwp-group form-group"},[a("label",{for:c,class:"ecwp-label form-label"},m(i.label),9,Mo),A(a("input",{type:i.type||"text",id:c,"onUpdate:modelValue":f=>o.editedClient[c]=f,class:L(["ecwp-input input","input-bordered",i.class||"w-full"])},null,10,Lo),[[Ke,o.editedClient[c]]])]))),128))]),a("div",jo,[a("div",Uo,[a("label",Io,m(r.translations.currency),1),A(a("select",{id:"currencyId","onUpdate:modelValue":t[1]||(t[1]=i=>o.editedClient.currency_id=i),class:"ecwp-input select select-bordered w-full"},[(y(!0),_(T,null,R(r.currencyOptions,(i,c)=>(y(),_("option",{key:c,value:i.id},m(i.name)+" - "+m(i.code)+" ("+m(i.symbol)+") ",9,qo))),128))],512),[[Ce,o.editedClient.currency_id]])])]),a("div",Ho,[a("label",Vo,m(r.translations.note),1),A(a("textarea",{id:"note","onUpdate:modelValue":t[2]||(t[2]=i=>o.editedClient.note=i),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[J,o.editedClient.note]])]),a("div",zo,[a("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:o.loadingBtn},[K(m(r.translations.save)+" ",1),o.loadingBtn?(y(),_("span",Jo)):N("",!0)],8,Wo)])],32))])],8,Ro)])}var Xo=oe(To,[["render",Ko]]);const $o={name:"Clients",components:{Card:Et,AddClientModal:Bs,ClientDetailsModal:So,ClientEditModal:Xo,RemoveModal:Ct},data(){return{clients:[],showClientDetailsModal:!1,editClientModal:!1,showRemoveModal:!1,selectedClient:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,settings:[],loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchClients(),this.loadSettings()},methods:{AddNew(){modal_clients.showModal()},fetchClients(e=1){this.loading=!0;const{perPage:t}=this;fetch(`/wp-json/my-easy-compta/v1/clients?page=${e}&per_page=${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.clients=n.clients,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=n.page,this.perPage=t,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching clients:",n)}).finally(()=>{this.loading=!1})},fetchClientDetails(e){fetch(`/wp-json/my-easy-compta/v1/clients/details/${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.selectedClient=t,this.loadingModal=!1}).catch(t=>{console.error("Error fetching client details:",t),this.loadingModal=!1})},showClientDetails(e){this.loadingModal=!0,this.showClientDetailsModal=!0,modal_client_details.showModal(),this.fetchClientDetails(e.id)},editClient(e){this.loadingModal=!0,this.editClientModal=!0,modal_client_edit.showModal(),this.fetchClientDetails(e.id)},generatePaginationButtons(){this.paginationButtons=vt(this.currentPage,this.totalPages)},goToPage(e){e!=="..."&&this.fetchClients(e)},perPageChanged(){this.fetchClients()},confirmDeleteClient(e){this.selectedClient=e,modal_remove.showModal(),this.showRemoveModal=!0},deleteClient(e){this.loading=!0;const t=e.id;fetch(`/wp-json/my-easy-compta/v1/clients/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.json()}).then(n=>{n.success?(this.fetchClients(),this.showToast(n.message,"alert-success")):(this.showToast(n.message,"alert-error"),console.error("Error deleting client:",n.statusText))}).catch(n=>{console.log(n.message);const s=n&&n.message?n.message:"Error deleting client";s==="This client cannot be deleted because it has associated data."?this.showToast(s,"alert-error"):console.error("Error deleting client:",n)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:e,currencySymbol:t,vatData:n}=await St();this.settings=e,this.default_currency_symbol=t,this.default_vat=n,this.loadingPrice=!1}catch(e){this.showToast(e.message,"alert-error"),this.loadingPrice=!1}},showToast(e,t){Tt(this.toast,e,t)}},computed:{skeletonItems(){return Array.from({length:5},(e,t)=>t)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Go={class:"pt-2 pr-4"},Zo={class:"flex justify-between items-center"},Qo={class:"card-title"},Yo=a("i",{class:"fas fa-plus-circle"},null,-1),er={key:0,class:"ms-2"},tr={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab1"},nr=a("i",{class:"fas fa-file-export"},null,-1),sr=["data-tip"],or={class:"btn btn-outline btn-accent rounded-full",disabled:""},rr=a("i",{class:"fas fa-file-export"},null,-1),ir=a("div",{class:"divider mt-2"},null,-1),ar={class:"flex items-center mb-4"},lr={for:"perPageSelect",class:"mr-2"},cr=["value"],dr={class:"overflow-x-auto"},ur={key:0,class:"table w-full"},fr={class:"flex justify-center"},hr={class:"flex items-center gap-3"},mr={class:"avatar"},pr={class:"mask mask-squircle w-12 h-12"},yr={version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 122.9 122.9",style:{"enable-background":"new 0 0 122.9 122.9"},"xml:space":"preserve"},_r=a("g",null,[a("path",{d:"M61.4,0c17,0,32.3,6.9,43.4,18c11.1,11.1,18,26.5,18,43.4c0,17-6.9,32.3-18,43.4c-11.1,11.1-26.5,18-43.4,18 s-32.3-6.9-43.4-18C6.9,93.8,0,78.4,0,61.4c0-17,6.9-32.3,18-43.4C29.1,6.9,44.5,0,61.4,0L61.4,0z M41.3,54.3c-1.1,0-2,0.3-2.5,0.7 c-0.3,0.2-0.6,0.5-0.7,0.8c-0.2,0.4-0.3,0.8-0.2,1.4c0,1.5,0.8,3.5,2.4,5.8l0,0l0,0l5,8c2,3.2,4.1,6.5,6.8,8.9 c2.5,2.3,5.6,3.9,9.6,3.9c4.4,0,7.6-1.6,10.2-4.1c2.7-2.5,4.9-6,7-9.5l5.7-9.3c1.1-2.4,1.4-4,1.2-5c-0.1-0.6-0.8-0.8-1.8-0.9 c-0.2,0-0.5,0-0.7,0c-0.3,0-0.5,0-0.8,0c-0.2,0-0.3,0-0.4,0c-0.5,0-1,0-1.6-0.1l1.9-8.6c-14.4,2.3-25.2-8.4-40.4-2.1L43,54.4 C42.4,54.4,41.8,54.4,41.3,54.3L41.3,54.3L41.3,54.3L41.3,54.3z M18.8,95.7c7.1-2.5,19.6-3.8,25.4-7.7c1-1.3,2.1-2.9,3.1-4.3 c0.6-0.9,1.1-1.7,1.6-2.3c0.1-0.1,0.2-0.2,0.3-0.3c-2.4-2.5-4.4-5.5-6.3-8.5l-5-8C36,61.8,35,59.3,35,57.3c0-1,0.1-1.9,0.5-2.6 c0.4-0.8,1-1.5,1.7-2c0.4-0.2,0.8-0.5,1.2-0.6c-0.3-4.3-0.4-9.8-0.2-14.4c0.1-1.1,0.3-2.2,0.6-3.3c1.3-4.6,4.5-8.3,8.5-10.8 c1.4-0.9,2.9-1.6,4.6-2.2c2.9-1.1,1.5-5.5,4.7-5.6c7.5-0.2,19.8,6.2,24.6,11.4c2.8,3,4.6,7,4.9,12.3l-0.3,13.1l0,0 c1.4,0.4,2.3,1.3,2.7,2.7c0.4,1.6,0,3.8-1.4,6.9l0,0c0,0.1-0.1,0.1-0.1,0.2l-5.7,9.4c-2.2,3.6-4.5,7.3-7.5,10.1L73.7,82l0,0 c0.4,0.5,0.8,1.1,1.2,1.7c0.8,1.1,1.6,2.4,2.5,3.6c5.3,4.5,19.3,5.9,26.7,8.6c7.6-9.4,12.1-21.4,12.1-34.4c0-15.1-6.1-28.8-16-38.7 c-9.9-9.9-23.6-16-38.7-16s-28.8,6.1-38.7,16c-9.9,9.9-16,23.6-16,38.7C6.7,74.4,11.2,86.3,18.8,95.7L18.8,95.7z M77,90.5 c-1.4-1.6-2.8-3.7-4.1-5.5c-0.4-0.5-0.7-1.1-1.1-1.5c-2.7,2-6,3.3-10.3,3.3c-4.5,0-8-1.6-10.9-4.1c0,0,0,0.1-0.1,0.1 c-0.5,0.7-1,1.4-1.6,2.3c-1.1,1.6-2.3,3.3-3.4,4.8C45.6,100,71.1,106,77,90.5L77,90.5z"})],-1),gr=[_r],br={class:"font-bold"},wr={class:"text-sm opacity-50"},xr={class:"badge badge-ghost badge-sm"},Er={class:"flex justify-end"},Cr=["data-tip"],vr=["onClick"],Sr=a("i",{class:"far fa-eye"},null,-1),Tr=[Sr],Rr=["data-tip"],Or=["onClick"],Ar=a("i",{class:"fas fa-pencil-alt"},null,-1),Pr=[Ar],kr=["data-tip"],Dr=["onClick"],Nr=a("i",{class:"far fa-trash-alt"},null,-1),Br=[Nr],Fr={key:1},Mr=a("div",{class:"flex gap-4 items-center"},[a("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),a("div",{class:"flex flex-col gap-4 w-full"},[a("div",{class:"skeleton h-4 w-full"}),a("div",{class:"skeleton h-4 w-full"})])],-1),Lr=a("div",{class:"divider my-1"},null,-1),jr=[Mr,Lr],Ur={class:"join ecwp_pagination mt-6 pt-4"},Ir=["onClick"];function qr(e,t,n,s,o,r){const i=V("client-details-modal"),c=V("client-edit-modal"),f=V("remove-modal"),h=V("AddClientModal"),d=V("Card");return y(),_("div",Go,[o.toast.visible?(y(),_("div",{key:0,class:L(["toast",o.toast.position]),style:{zIndex:9999}},[a("div",{class:L(["alert",o.toast.type,"text-white"])},[a("span",null,m(o.toast.message),1)],2)],2)):N("",!0),z(i,{loading:o.loadingModal,"show-modal":o.showClientDetailsModal,"modal-id":"modal_client_details","modal-title":r.translations.client_details,client:o.selectedClient,onClose:t[0]||(t[0]=u=>o.showClientDetailsModal=!1)},null,8,["loading","show-modal","modal-title","client"]),z(c,{loading:o.loadingModal,"show-modal":o.editClientModal,"modal-id":"modal_client_edit","modal-title":r.translations.edit_client,client:o.selectedClient,onClose:t[1]||(t[1]=u=>o.editClientModal=!1),onClientEdited:r.fetchClients},null,8,["loading","show-modal","modal-title","client","onClientEdited"]),z(f,{"show-modal":o.showRemoveModal,title:r.translations.are_you_sure,message:r.translations.no_turning_back,confirmText:r.translations.yes_delete_it,cancelText:r.translations.cancel,onConfirm:t[2]||(t[2]=u=>r.deleteClient(o.selectedClient)),onCancel:t[3]||(t[3]=u=>o.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),z(d,{topMargin:"mt-8"},{default:bt(()=>[a("div",Zo,[a("h2",Qo,m(r.translations.clients),1),a("div",null,[a("button",{class:"btn btn-primary rounded-full",onClick:t[4]||(t[4]=(...u)=>r.AddNew&&r.AddNew(...u))},[K(m(r.translations.add)+" ",1),Yo]),o.settings.easy_compta_export_addon_active==1?(y(),_("span",er,[a("a",tr,[K(m(r.translations.export)+" ",1),nr])])):(y(),_("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":r.translations.active_export_addon},[a("button",or,[K(m(r.translations.export)+" ",1),rr])],8,sr))])]),ir,z(h,{onClientAdded:r.fetchClients},null,8,["onClientAdded"]),a("div",ar,[a("label",lr,m(r.translations.display_per_page),1),A(a("select",{id:"perPageSelect","onUpdate:modelValue":t[5]||(t[5]=u=>o.perPage=u),onChange:t[6]||(t[6]=(...u)=>r.perPageChanged&&r.perPageChanged(...u))},[(y(!0),_(T,null,R(o.perPageOptions,u=>(y(),_("option",{key:u,value:u},m(u),9,cr))),128))],544),[[Ce,o.perPage]])]),a("div",dr,[o.loading?(y(),_("div",Fr,[(y(!0),_(T,null,R(o.skeletonRows,u=>(y(),_("div",{key:u,class:"flex flex-col gap-4 w-full"},jr))),128))])):(y(),_("table",ur,[a("thead",null,[a("tr",null,[a("th",null,m(r.translations.company_name),1),a("th",null,m(r.translations.manager_name),1),a("th",null,m(r.translations.email),1),a("th",null,m(r.translations.phone),1),a("th",fr,m(r.translations.actions),1)])]),a("tbody",null,[(y(!0),_(T,null,R(o.clients,u=>(y(),_("tr",{key:u.id},[a("td",null,[a("div",hr,[a("div",mr,[a("div",pr,[(y(),_("svg",yr,gr))])]),a("div",null,[a("div",br,m(u.company_name),1),a("div",wr,[a("span",xr,m(u.city)+" - "+m(u.country),1)])])])]),a("td",null,m(u.manager_name),1),a("td",null,m(u.email),1),a("td",null,m(u.phone),1),a("td",Er,[a("span",{class:"lg:tooltip","data-tip":r.translations.view},[a("button",{class:"btn btn-circle mx-1",onClick:w=>r.showClientDetails(u)},Tr,8,vr)],8,Cr),a("span",{class:"lg:tooltip","data-tip":r.translations.edit},[a("button",{class:"btn btn-circle mx-1",onClick:w=>r.editClient(u)},Pr,8,Or)],8,Rr),a("span",{class:"lg:tooltip","data-tip":r.translations.delete},[a("button",{onClick:w=>r.confirmDeleteClient(u),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Br,8,Dr)],8,kr)])]))),128))])])),a("div",Ur,[(y(!0),_(T,null,R(o.paginationButtons,u=>(y(),_("button",{key:u,class:L(["join-item btn",{"btn-disabled":u==="..."||u===o.currentPage}]),onClick:w=>r.goToPage(u)},m(u),11,Ir))),128))])])]),_:1})])}var Hr=oe($o,[["render",qr]]);const pe=se;(function(e,t){const n=se,s=e();for(;[];)try{if(parseInt(n(210))/1*(parseInt(n(215))/2)+-parseInt(n(218))/3*(parseInt(n(217))/4)+-parseInt(n(207))/5+parseInt(n(214))/6+-parseInt(n(211))/7+-parseInt(n(206))/8+-parseInt(n(216))/9*(-parseInt(n(212))/10)===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(ne,486906);function ne(){const e=["72438YFCath","3393FXjSGD","32IVtIaC","272991anFByo","3929712CjByPB","1368365crMnFV","use","mount","23dofBfg","5667739LmMOZs","28190JUicqr","#my-easy-compta-clients-app","5361876oAyYNq"];return ne=function(){return e},ne()}function se(e,t){const n=ne();return se=function(s,o){return s=s-206,n[s]},se(e,t)}const Vr=wt({render:()=>xt(Hr)});Vr[pe(208)](Rt)[pe(209)](pe(213));
     1import{_ as oe,o as y,c as _,n as M,a,t as m,g as D,w as Je,i as A,v as J,F as T,r as R,j as Ee,k as Xe,l as gt,m as X,d as z,e as V,p as bt,f as wt,h as xt}from"./plugin-vue_export-helper.min.js";import{C as Et,R as vt}from"./RemoveAlert.min.js";import{g as Ct,f as St,s as Tt}from"./api.min.js";import{r as Rt}from"./index.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./vue3-editor.common.min.js";function Ke(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ot}=Object.prototype,{getPrototypeOf:ve}=Object,re=(e=>t=>{const n=Ot.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),N=e=>(e=e.toLowerCase(),t=>re(t)===e),ie=e=>t=>typeof t===e,{isArray:I}=Array,K=ie("undefined");function At(e){return e!==null&&!K(e)&&e.constructor!==null&&!K(e.constructor)&&O(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const $e=N("ArrayBuffer");function Pt(e){let t;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&$e(e.buffer),t}const kt=ie("string"),O=ie("function"),Ge=ie("number"),ae=e=>e!==null&&typeof e=="object",Nt=e=>e===!0||e===!1,G=e=>{if(re(e)!=="object")return!1;const t=ve(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Dt=N("Date"),Bt=N("File"),Ft=N("Blob"),Lt=N("FileList"),Mt=e=>ae(e)&&O(e.pipe),jt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||O(e.append)&&((t=re(e))==="formdata"||t==="object"&&O(e.toString)&&e.toString()==="[object FormData]"))},Ut=N("URLSearchParams"),[It,qt,Ht,zt]=["ReadableStream","Request","Response","Headers"].map(N),Vt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e=="undefined")return;let s,o;if(typeof e!="object"&&(e=[e]),I(e))for(s=0,o=e.length;s<o;s++)t.call(null,e[s],s,e);else{const r=n?Object.getOwnPropertyNames(e):Object.keys(e),i=r.length;let c;for(s=0;s<i;s++)c=r[s],t.call(null,e[c],c,e)}}function Qe(e,t){t=t.toLowerCase();const n=Object.keys(e);let s=n.length,o;for(;s-- >0;)if(o=n[s],t===o.toLowerCase())return o;return null}const Ze=(()=>typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global)(),Ye=e=>!K(e)&&e!==Ze;function pe(){const{caseless:e}=Ye(this)&&this||{},t={},n=(s,o)=>{const r=e&&Qe(t,o)||o;G(t[r])&&G(s)?t[r]=pe(t[r],s):G(s)?t[r]=pe({},s):I(s)?t[r]=s.slice():t[r]=s};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&$(arguments[s],n);return t}const Wt=(e,t,n,{allOwnKeys:s}={})=>($(t,(o,r)=>{n&&O(o)?e[r]=Ke(o,n):e[r]=o},{allOwnKeys:s}),e),Jt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Xt=(e,t,n,s)=>{e.prototype=Object.create(t.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Kt=(e,t,n,s)=>{let o,r,i;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),r=o.length;r-- >0;)i=o[r],(!s||s(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&ve(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$t=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const s=e.indexOf(t,n);return s!==-1&&s===n},Gt=e=>{if(!e)return null;if(I(e))return e;let t=e.length;if(!Ge(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Qt=(e=>t=>e&&t instanceof e)(typeof Uint8Array!="undefined"&&ve(Uint8Array)),Zt=(e,t)=>{const s=(e&&e[Symbol.iterator]).call(e);let o;for(;(o=s.next())&&!o.done;){const r=o.value;t.call(e,r[0],r[1])}},Yt=(e,t)=>{let n;const s=[];for(;(n=e.exec(t))!==null;)s.push(n);return s},en=N("HTMLFormElement"),tn=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,o){return s.toUpperCase()+o}),ke=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nn=N("RegExp"),et=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),s={};$(n,(o,r)=>{let i;(i=t(o,r,e))!==!1&&(s[r]=i||o)}),Object.defineProperties(e,s)},sn=e=>{et(e,(t,n)=>{if(O(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=e[n];if(!!O(s)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},on=(e,t)=>{const n={},s=o=>{o.forEach(r=>{n[r]=!0})};return I(e)?s(e):s(String(e).split(t)),n},rn=()=>{},an=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,ue="abcdefghijklmnopqrstuvwxyz",Ne="0123456789",tt={DIGIT:Ne,ALPHA:ue,ALPHA_DIGIT:ue+ue.toUpperCase()+Ne},ln=(e=16,t=tt.ALPHA_DIGIT)=>{let n="";const{length:s}=t;for(;e--;)n+=t[Math.random()*s|0];return n};function cn(e){return!!(e&&O(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const dn=e=>{const t=new Array(10),n=(s,o)=>{if(ae(s)){if(t.indexOf(s)>=0)return;if(!("toJSON"in s)){t[o]=s;const r=I(s)?[]:{};return $(s,(i,c)=>{const f=n(i,o+1);!K(f)&&(r[c]=f)}),t[o]=void 0,r}}return s};return n(e,0)},un=N("AsyncFunction"),fn=e=>e&&(ae(e)||O(e))&&O(e.then)&&O(e.catch);var l={isArray:I,isArrayBuffer:$e,isBuffer:At,isFormData:jt,isArrayBufferView:Pt,isString:kt,isNumber:Ge,isBoolean:Nt,isObject:ae,isPlainObject:G,isReadableStream:It,isRequest:qt,isResponse:Ht,isHeaders:zt,isUndefined:K,isDate:Dt,isFile:Bt,isBlob:Ft,isRegExp:nn,isFunction:O,isStream:Mt,isURLSearchParams:Ut,isTypedArray:Qt,isFileList:Lt,forEach:$,merge:pe,extend:Wt,trim:Vt,stripBOM:Jt,inherits:Xt,toFlatObject:Kt,kindOf:re,kindOfTest:N,endsWith:$t,toArray:Gt,forEachEntry:Zt,matchAll:Yt,isHTMLForm:en,hasOwnProperty:ke,hasOwnProp:ke,reduceDescriptors:et,freezeMethods:sn,toObjectSet:on,toCamelCase:tn,noop:rn,toFiniteNumber:an,findKey:Qe,global:Ze,isContextDefined:Ye,ALPHABET:tt,generateString:ln,isSpecCompliantForm:cn,toJSONObject:dn,isAsyncFn:un,isThenable:fn};function g(e,t,n,s,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),s&&(this.request=s),o&&(this.response=o)}l.inherits(g,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:l.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const nt=g.prototype,st={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{st[e]={value:e}});Object.defineProperties(g,st);Object.defineProperty(nt,"isAxiosError",{value:!0});g.from=(e,t,n,s,o,r)=>{const i=Object.create(nt);return l.toFlatObject(e,i,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),g.call(i,e.message,t,n,s,o),i.cause=e,i.name=e.name,r&&Object.assign(i,r),i};var hn=null;function ye(e){return l.isPlainObject(e)||l.isArray(e)}function ot(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function De(e,t,n){return e?e.concat(t).map(function(o,r){return o=ot(o),!n&&r?"["+o+"]":o}).join(n?".":""):t}function mn(e){return l.isArray(e)&&!e.some(ye)}const pn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function le(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,C){return!l.isUndefined(C[b])});const s=n.metaTokens,o=n.visitor||d,r=n.dots,i=n.indexes,f=(n.Blob||typeof Blob!="undefined"&&Blob)&&l.isSpecCompliantForm(t);if(!l.isFunction(o))throw new TypeError("visitor must be a function");function h(p){if(p===null)return"";if(l.isDate(p))return p.toISOString();if(!f&&l.isBlob(p))throw new g("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(p)||l.isTypedArray(p)?f&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function d(p,b,C){let S=p;if(p&&!C&&typeof p=="object"){if(l.endsWith(b,"{}"))b=s?b:b.slice(0,-2),p=JSON.stringify(p);else if(l.isArray(p)&&mn(p)||(l.isFileList(p)||l.endsWith(b,"[]"))&&(S=l.toArray(p)))return b=ot(b),S.forEach(function(E,H){!(l.isUndefined(E)||E===null)&&t.append(i===!0?De([b],H,r):i===null?b:b+"[]",h(E))}),!1}return ye(p)?!0:(t.append(De(C,b,r),h(p)),!1)}const u=[],w=Object.assign(pn,{defaultVisitor:d,convertValue:h,isVisitable:ye});function x(p,b){if(!l.isUndefined(p)){if(u.indexOf(p)!==-1)throw Error("Circular reference detected in "+b.join("."));u.push(p),l.forEach(p,function(S,B){(!(l.isUndefined(S)||S===null)&&o.call(t,S,l.isString(B)?B.trim():B,b,w))===!0&&x(S,b?b.concat(B):[B])}),u.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return x(e),t}function Be(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return t[s]})}function Ce(e,t){this._pairs=[],e&&le(e,this,t)}const rt=Ce.prototype;rt.append=function(t,n){this._pairs.push([t,n])};rt.toString=function(t){const n=t?function(s){return t.call(this,s,Be)}:Be;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function yn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function it(e,t,n){if(!t)return e;const s=n&&n.encode||yn,o=n&&n.serialize;let r;if(o?r=o(t,n):r=l.isURLSearchParams(t)?t.toString():new Ce(t,n).toString(s),r){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+r}return e}class _n{constructor(){this.handlers=[]}use(t,n,s){return this.handlers.push({fulfilled:t,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(s){s!==null&&t(s)})}}var Fe=_n,at={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gn=typeof URLSearchParams!="undefined"?URLSearchParams:Ce,bn=typeof FormData!="undefined"?FormData:null,wn=typeof Blob!="undefined"?Blob:null,xn={isBrowser:!0,classes:{URLSearchParams:gn,FormData:bn,Blob:wn},protocols:["http","https","file","blob","url","data"]};const Se=typeof window!="undefined"&&typeof document!="undefined",En=(e=>Se&&["ReactNative","NativeScript","NS"].indexOf(e)<0)(typeof navigator!="undefined"&&navigator.product),vn=(()=>typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),Cn=Se&&window.location.href||"http://localhost";var Sn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Se,hasStandardBrowserWebWorkerEnv:vn,hasStandardBrowserEnv:En,origin:Cn},Symbol.toStringTag,{value:"Module"})),P={...Sn,...xn};function Tn(e,t){return le(e,new P.classes.URLSearchParams,Object.assign({visitor:function(n,s,o,r){return P.isNode&&l.isBuffer(n)?(this.append(s,n.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}function Rn(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function On(e){const t={},n=Object.keys(e);let s;const o=n.length;let r;for(s=0;s<o;s++)r=n[s],t[r]=e[r];return t}function lt(e){function t(n,s,o,r){let i=n[r++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),f=r>=n.length;return i=!i&&l.isArray(o)?o.length:i,f?(l.hasOwnProp(o,i)?o[i]=[o[i],s]:o[i]=s,!c):((!o[i]||!l.isObject(o[i]))&&(o[i]=[]),t(n,s,o[i],r)&&l.isArray(o[i])&&(o[i]=On(o[i])),!c)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(s,o)=>{t(Rn(s),o,n,0)}),n}return null}function An(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(e)}const Te={transitional:at,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const s=n.getContentType()||"",o=s.indexOf("application/json")>-1,r=l.isObject(t);if(r&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return o?JSON.stringify(lt(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t)||l.isReadableStream(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(r){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Tn(t,this.formSerializer).toString();if((c=l.isFileList(t))||s.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return le(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return r||o?(n.setContentType("application/json",!1),An(t)):t}],transformResponse:[function(t){const n=this.transitional||Te.transitional,s=n&&n.forcedJSONParsing,o=this.responseType==="json";if(l.isResponse(t)||l.isReadableStream(t))return t;if(t&&l.isString(t)&&(s&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?g.from(c,g.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:P.classes.FormData,Blob:P.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],e=>{Te.headers[e]={}});var Re=Te;const Pn=l.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var kn=e=>{const t={};let n,s,o;return e&&e.split(`
     2`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),s=i.substring(o+1).trim(),!(!n||t[n]&&Pn[n])&&(n==="set-cookie"?t[n]?t[n].push(s):t[n]=[s]:t[n]=t[n]?t[n]+", "+s:s)}),t};const Le=Symbol("internals");function W(e){return e&&String(e).trim().toLowerCase()}function Q(e){return e===!1||e==null?e:l.isArray(e)?e.map(Q):String(e)}function Nn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(e);)t[s[1]]=s[2];return t}const Dn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function fe(e,t,n,s,o){if(l.isFunction(s))return s.call(this,t,n);if(o&&(t=n),!!l.isString(t)){if(l.isString(s))return t.indexOf(s)!==-1;if(l.isRegExp(s))return s.test(t)}}function Bn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,s)=>n.toUpperCase()+s)}function Fn(e,t){const n=l.toCamelCase(" "+t);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+n,{value:function(o,r,i){return this[s].call(this,t,o,r,i)},configurable:!0})})}class ce{constructor(t){t&&this.set(t)}set(t,n,s){const o=this;function r(c,f,h){const d=W(f);if(!d)throw new Error("header name must be a non-empty string");const u=l.findKey(o,d);(!u||o[u]===void 0||h===!0||h===void 0&&o[u]!==!1)&&(o[u||f]=Q(c))}const i=(c,f)=>l.forEach(c,(h,d)=>r(h,d,f));if(l.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(l.isString(t)&&(t=t.trim())&&!Dn(t))i(kn(t),n);else if(l.isHeaders(t))for(const[c,f]of t.entries())r(f,c,s);else t!=null&&r(n,t,s);return this}get(t,n){if(t=W(t),t){const s=l.findKey(this,t);if(s){const o=this[s];if(!n)return o;if(n===!0)return Nn(o);if(l.isFunction(n))return n.call(this,o,s);if(l.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=W(t),t){const s=l.findKey(this,t);return!!(s&&this[s]!==void 0&&(!n||fe(this,this[s],s,n)))}return!1}delete(t,n){const s=this;let o=!1;function r(i){if(i=W(i),i){const c=l.findKey(s,i);c&&(!n||fe(s,s[c],c,n))&&(delete s[c],o=!0)}}return l.isArray(t)?t.forEach(r):r(t),o}clear(t){const n=Object.keys(this);let s=n.length,o=!1;for(;s--;){const r=n[s];(!t||fe(this,this[r],r,t,!0))&&(delete this[r],o=!0)}return o}normalize(t){const n=this,s={};return l.forEach(this,(o,r)=>{const i=l.findKey(s,r);if(i){n[i]=Q(o),delete n[r];return}const c=t?Bn(r):String(r).trim();c!==r&&delete n[r],n[c]=Q(o),s[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return l.forEach(this,(s,o)=>{s!=null&&s!==!1&&(n[o]=t&&l.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
     3`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const s=new this(t);return n.forEach(o=>s.set(o)),s}static accessor(t){const s=(this[Le]=this[Le]={accessors:{}}).accessors,o=this.prototype;function r(i){const c=W(i);s[c]||(Fn(o,i),s[c]=!0)}return l.isArray(t)?t.forEach(r):r(t),this}}ce.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(ce.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[n]=s}}});l.freezeMethods(ce);var k=ce;function he(e,t){const n=this||Re,s=t||n,o=k.from(s.headers);let r=s.data;return l.forEach(e,function(c){r=c.call(n,r,o.normalize(),t?t.status:void 0)}),o.normalize(),r}function ct(e){return!!(e&&e.__CANCEL__)}function q(e,t,n){g.call(this,e==null?"canceled":e,g.ERR_CANCELED,t,n),this.name="CanceledError"}l.inherits(q,g,{__CANCEL__:!0});function dt(e,t,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):t(new g("Request failed with status code "+n.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ln(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Mn(e,t){e=e||10;const n=new Array(e),s=new Array(e);let o=0,r=0,i;return t=t!==void 0?t:1e3,function(f){const h=Date.now(),d=s[r];i||(i=h),n[o]=f,s[o]=h;let u=r,w=0;for(;u!==o;)w+=n[u++],u=u%e;if(o=(o+1)%e,o===r&&(r=(r+1)%e),h-i<t)return;const x=d&&h-d;return x?Math.round(w*1e3/x):void 0}}function jn(e,t){let n=0;const s=1e3/t;let o=null;return function(){const i=this===!0,c=Date.now();if(i||c-n>s)return o&&(clearTimeout(o),o=null),n=c,e.apply(null,arguments);o||(o=setTimeout(()=>(o=null,n=Date.now(),e.apply(null,arguments)),s-(c-n)))}}var Y=(e,t,n=3)=>{let s=0;const o=Mn(50,250);return jn(r=>{const i=r.loaded,c=r.lengthComputable?r.total:void 0,f=i-s,h=o(f),d=i<=c;s=i;const u={loaded:i,total:c,progress:c?i/c:void 0,bytes:f,rate:h||void 0,estimated:h&&c&&d?(c-i)/h:void 0,event:r,lengthComputable:c!=null};u[t?"download":"upload"]=!0,e(u)},n)},Un=P.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let s;function o(r){let i=r;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return s=o(window.location.href),function(i){const c=l.isString(i)?o(i):i;return c.protocol===s.protocol&&c.host===s.host}}():function(){return function(){return!0}}(),In=P.hasStandardBrowserEnv?{write(e,t,n,s,o,r){const i=[e+"="+encodeURIComponent(t)];l.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),l.isString(s)&&i.push("path="+s),l.isString(o)&&i.push("domain="+o),r===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function qn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Hn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ut(e,t){return e&&!qn(t)?Hn(e,t):t}const Me=e=>e instanceof k?{...e}:e;function j(e,t){t=t||{};const n={};function s(h,d,u){return l.isPlainObject(h)&&l.isPlainObject(d)?l.merge.call({caseless:u},h,d):l.isPlainObject(d)?l.merge({},d):l.isArray(d)?d.slice():d}function o(h,d,u){if(l.isUndefined(d)){if(!l.isUndefined(h))return s(void 0,h,u)}else return s(h,d,u)}function r(h,d){if(!l.isUndefined(d))return s(void 0,d)}function i(h,d){if(l.isUndefined(d)){if(!l.isUndefined(h))return s(void 0,h)}else return s(void 0,d)}function c(h,d,u){if(u in t)return s(h,d);if(u in e)return s(void 0,h)}const f={url:r,method:r,data:r,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(h,d)=>o(Me(h),Me(d),!0)};return l.forEach(Object.keys(Object.assign({},e,t)),function(d){const u=f[d]||o,w=u(e[d],t[d],d);l.isUndefined(w)&&u!==c||(n[d]=w)}),n}var ft=e=>{const t=j({},e);let{data:n,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:r,headers:i,auth:c}=t;t.headers=i=k.from(i),t.url=it(ut(t.baseURL,t.url),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let f;if(l.isFormData(n)){if(P.hasStandardBrowserEnv||P.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((f=i.getContentType())!==!1){const[h,...d]=f?f.split(";").map(u=>u.trim()).filter(Boolean):[];i.setContentType([h||"multipart/form-data",...d].join("; "))}}if(P.hasStandardBrowserEnv&&(s&&l.isFunction(s)&&(s=s(t)),s||s!==!1&&Un(t.url))){const h=o&&r&&In.read(r);h&&i.set(o,h)}return t};const zn=typeof XMLHttpRequest!="undefined";var Vn=zn&&function(e){return new Promise(function(n,s){const o=ft(e);let r=o.data;const i=k.from(o.headers).normalize();let{responseType:c}=o,f;function h(){o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let d=new XMLHttpRequest;d.open(o.method.toUpperCase(),o.url,!0),d.timeout=o.timeout;function u(){if(!d)return;const x=k.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),b={data:!c||c==="text"||c==="json"?d.responseText:d.response,status:d.status,statusText:d.statusText,headers:x,config:e,request:d};dt(function(S){n(S),h()},function(S){s(S),h()},b),d=null}"onloadend"in d?d.onloadend=u:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(u)},d.onabort=function(){!d||(s(new g("Request aborted",g.ECONNABORTED,o,d)),d=null)},d.onerror=function(){s(new g("Network Error",g.ERR_NETWORK,o,d)),d=null},d.ontimeout=function(){let p=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const b=o.transitional||at;o.timeoutErrorMessage&&(p=o.timeoutErrorMessage),s(new g(p,b.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,o,d)),d=null},r===void 0&&i.setContentType(null),"setRequestHeader"in d&&l.forEach(i.toJSON(),function(p,b){d.setRequestHeader(b,p)}),l.isUndefined(o.withCredentials)||(d.withCredentials=!!o.withCredentials),c&&c!=="json"&&(d.responseType=o.responseType),typeof o.onDownloadProgress=="function"&&d.addEventListener("progress",Y(o.onDownloadProgress,!0)),typeof o.onUploadProgress=="function"&&d.upload&&d.upload.addEventListener("progress",Y(o.onUploadProgress)),(o.cancelToken||o.signal)&&(f=x=>{!d||(s(!x||x.type?new q(null,e,d):x),d.abort(),d=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const w=Ln(o.url);if(w&&P.protocols.indexOf(w)===-1){s(new g("Unsupported protocol "+w+":",g.ERR_BAD_REQUEST,e));return}d.send(r||null)})};const Wn=(e,t)=>{let n=new AbortController,s;const o=function(f){if(!s){s=!0,i();const h=f instanceof Error?f:this.reason;n.abort(h instanceof g?h:new q(h instanceof Error?h.message:h))}};let r=t&&setTimeout(()=>{o(new g(`timeout ${t} of ms exceeded`,g.ETIMEDOUT))},t);const i=()=>{e&&(r&&clearTimeout(r),r=null,e.forEach(f=>{f&&(f.removeEventListener?f.removeEventListener("abort",o):f.unsubscribe(o))}),e=null)};e.forEach(f=>f&&f.addEventListener&&f.addEventListener("abort",o));const{signal:c}=n;return c.unsubscribe=i,[c,()=>{r&&clearTimeout(r),r=null}]};var Jn=Wn;const Xn=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let s=0,o;for(;s<n;)o=s+t,yield e.slice(s,o),s=o},Kn=async function*(e,t,n){for await(const s of e)yield*Xn(ArrayBuffer.isView(s)?s:await n(String(s)),t)},je=(e,t,n,s,o)=>{const r=Kn(e,t,o);let i=0;return new ReadableStream({type:"bytes",async pull(c){const{done:f,value:h}=await r.next();if(f){c.close(),s();return}let d=h.byteLength;n&&n(i+=d),c.enqueue(new Uint8Array(h))},cancel(c){return s(c),r.return()}},{highWaterMark:2})},Ue=(e,t)=>{const n=e!=null;return s=>setTimeout(()=>t({lengthComputable:n,total:e,loaded:s}))},de=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",ht=de&&typeof ReadableStream=="function",_e=de&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),$n=ht&&(()=>{let e=!1;const t=new Request(P.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})(),Ie=64*1024,ge=ht&&!!(()=>{try{return l.isReadableStream(new Response("").body)}catch{}})(),ee={stream:ge&&(e=>e.body)};de&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!ee[t]&&(ee[t]=l.isFunction(e[t])?n=>n[t]():(n,s)=>{throw new g(`Response type '${t}' is not supported`,g.ERR_NOT_SUPPORT,s)})})})(new Response);const Gn=async e=>{if(e==null)return 0;if(l.isBlob(e))return e.size;if(l.isSpecCompliantForm(e))return(await new Request(e).arrayBuffer()).byteLength;if(l.isArrayBufferView(e))return e.byteLength;if(l.isURLSearchParams(e)&&(e=e+""),l.isString(e))return(await _e(e)).byteLength},Qn=async(e,t)=>{const n=l.toFiniteNumber(e.getContentLength());return n==null?Gn(t):n};var Zn=de&&(async e=>{let{url:t,method:n,data:s,signal:o,cancelToken:r,timeout:i,onDownloadProgress:c,onUploadProgress:f,responseType:h,headers:d,withCredentials:u="same-origin",fetchOptions:w}=ft(e);h=h?(h+"").toLowerCase():"text";let[x,p]=o||r||i?Jn([o,r],i):[],b,C;const S=()=>{!b&&setTimeout(()=>{x&&x.unsubscribe()}),b=!0};let B;try{if(f&&$n&&n!=="get"&&n!=="head"&&(B=await Qn(d,s))!==0){let F=new Request(t,{method:"POST",body:s,duplex:"half"}),U;l.isFormData(s)&&(U=F.headers.get("content-type"))&&d.setContentType(U),F.body&&(s=je(F.body,Ie,Ue(B,Y(f)),null,_e))}l.isString(u)||(u=u?"cors":"omit"),C=new Request(t,{...w,signal:x,method:n.toUpperCase(),headers:d.normalize().toJSON(),body:s,duplex:"half",withCredentials:u});let E=await fetch(C);const H=ge&&(h==="stream"||h==="response");if(ge&&(c||H)){const F={};["status","statusText","headers"].forEach(Pe=>{F[Pe]=E[Pe]});const U=l.toFiniteNumber(E.headers.get("content-length"));E=new Response(je(E.body,Ie,c&&Ue(U,Y(c,!0)),H&&S,_e),F)}h=h||"text";let _t=await ee[l.findKey(ee,h)||"text"](E,e);return!H&&S(),p&&p(),await new Promise((F,U)=>{dt(F,U,{data:_t,headers:k.from(E.headers),status:E.status,statusText:E.statusText,config:e,request:C})})}catch(E){throw S(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,e,C),{cause:E.cause||E}):g.from(E,E&&E.code,e,C)}});const be={http:hn,xhr:Vn,fetch:Zn};l.forEach(be,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const qe=e=>`- ${e}`,Yn=e=>l.isFunction(e)||e===null||e===!1;var mt={getAdapter:e=>{e=l.isArray(e)?e:[e];const{length:t}=e;let n,s;const o={};for(let r=0;r<t;r++){n=e[r];let i;if(s=n,!Yn(n)&&(s=be[(i=String(n)).toLowerCase()],s===void 0))throw new g(`Unknown adapter '${i}'`);if(s)break;o[i||"#"+r]=s}if(!s){const r=Object.entries(o).map(([c,f])=>`adapter ${c} `+(f===!1?"is not supported by the environment":"is not available in the build"));let i=t?r.length>1?`since :
     4`+r.map(qe).join(`
     5`):" "+qe(r[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return s},adapters:be};function me(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new q(null,e)}function He(e){return me(e),e.headers=k.from(e.headers),e.data=he.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),mt.getAdapter(e.adapter||Re.adapter)(e).then(function(s){return me(e),s.data=he.call(e,e.transformResponse,s),s.headers=k.from(s.headers),s},function(s){return ct(s)||(me(e),s&&s.response&&(s.response.data=he.call(e,e.transformResponse,s.response),s.response.headers=k.from(s.response.headers))),Promise.reject(s)})}const pt="1.7.2",Oe={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Oe[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const ze={};Oe.transitional=function(t,n,s){function o(r,i){return"[Axios v"+pt+"] Transitional option '"+r+"'"+i+(s?". "+s:"")}return(r,i,c)=>{if(t===!1)throw new g(o(i," has been removed"+(n?" in "+n:"")),g.ERR_DEPRECATED);return n&&!ze[i]&&(ze[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(r,i,c):!0}};function es(e,t,n){if(typeof e!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let o=s.length;for(;o-- >0;){const r=s[o],i=t[r];if(i){const c=e[r],f=c===void 0||i(c,r,e);if(f!==!0)throw new g("option "+r+" must be "+f,g.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new g("Unknown option "+r,g.ERR_BAD_OPTION)}}var we={assertOptions:es,validators:Oe};const L=we.validators;class te{constructor(t){this.defaults=t,this.interceptors={request:new Fe,response:new Fe}}async request(t,n){try{return await this._request(t,n)}catch(s){if(s instanceof Error){let o;Error.captureStackTrace?Error.captureStackTrace(o={}):o=new Error;const r=o.stack?o.stack.replace(/^.+\n/,""):"";try{s.stack?r&&!String(s.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(s.stack+=`
     6`+r):s.stack=r}catch{}}throw s}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=j(this.defaults,n);const{transitional:s,paramsSerializer:o,headers:r}=n;s!==void 0&&we.assertOptions(s,{silentJSONParsing:L.transitional(L.boolean),forcedJSONParsing:L.transitional(L.boolean),clarifyTimeoutError:L.transitional(L.boolean)},!1),o!=null&&(l.isFunction(o)?n.paramsSerializer={serialize:o}:we.assertOptions(o,{encode:L.function,serialize:L.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=r&&l.merge(r.common,r[n.method]);r&&l.forEach(["delete","get","head","post","put","patch","common"],p=>{delete r[p]}),n.headers=k.concat(i,r);const c=[];let f=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(f=f&&b.synchronous,c.unshift(b.fulfilled,b.rejected))});const h=[];this.interceptors.response.forEach(function(b){h.push(b.fulfilled,b.rejected)});let d,u=0,w;if(!f){const p=[He.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,h),w=p.length,d=Promise.resolve(n);u<w;)d=d.then(p[u++],p[u++]);return d}w=c.length;let x=n;for(u=0;u<w;){const p=c[u++],b=c[u++];try{x=p(x)}catch(C){b.call(this,C);break}}try{d=He.call(this,x)}catch(p){return Promise.reject(p)}for(u=0,w=h.length;u<w;)d=d.then(h[u++],h[u++]);return d}getUri(t){t=j(this.defaults,t);const n=ut(t.baseURL,t.url);return it(n,t.params,t.paramsSerializer)}}l.forEach(["delete","get","head","options"],function(t){te.prototype[t]=function(n,s){return this.request(j(s||{},{method:t,url:n,data:(s||{}).data}))}});l.forEach(["post","put","patch"],function(t){function n(s){return function(r,i,c){return this.request(j(c||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:r,data:i}))}}te.prototype[t]=n(),te.prototype[t+"Form"]=n(!0)});var Z=te;class Ae{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(r){n=r});const s=this;this.promise.then(o=>{if(!s._listeners)return;let r=s._listeners.length;for(;r-- >0;)s._listeners[r](o);s._listeners=null}),this.promise.then=o=>{let r;const i=new Promise(c=>{s.subscribe(c),r=c}).then(o);return i.cancel=function(){s.unsubscribe(r)},i},t(function(r,i,c){s.reason||(s.reason=new q(r,i,c),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Ae(function(o){t=o}),cancel:t}}}var ts=Ae;function ns(e){return function(n){return e.apply(null,n)}}function ss(e){return l.isObject(e)&&e.isAxiosError===!0}const xe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(xe).forEach(([e,t])=>{xe[t]=e});var os=xe;function yt(e){const t=new Z(e),n=Ke(Z.prototype.request,t);return l.extend(n,Z.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return yt(j(e,o))},n}const v=yt(Re);v.Axios=Z;v.CanceledError=q;v.CancelToken=ts;v.isCancel=ct;v.VERSION=pt;v.toFormData=le;v.AxiosError=g;v.Cancel=v.CanceledError;v.all=function(t){return Promise.all(t)};v.spread=ns;v.isAxiosError=ss;v.mergeConfig=j;v.AxiosHeaders=k;v.formToJSON=e=>lt(l.isHTMLForm(e)?new FormData(e):e);v.getAdapter=mt.getAdapter;v.HttpStatusCode=os;v.default=v;var Ve=v;const rs={data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{formData:{siret:"",company_name:"",siren_number:"",manager_name:"",address:"",city:"",postal_code:"",country:"",phone:"",mobile_phone:"",email:"",website:"",currency_id:"",note:"",user_create:""},fields:{company_name:{label:e.company_name,type:"text",required:!0},manager_name:{label:e.manager_name,type:"text"},address:{label:e.address,type:"text",required:!0},city:{label:e.city,type:"text",required:!0},postal_code:{label:e.postal_code,type:"text"},country:{label:e.country,type:"text"},phone:{label:e.phone,type:"tel",required:!0},mobile_phone:{label:e.mobile,type:"tel"},email:{label:e.email,type:"email",required:!0},website:{label:e.website,type:"url"},currency_id:{label:e.currency,type:"text",required:!0}},options:{currency_options:[],default_currency:"",addon_user_active:!1,addon_siret_active:!1},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},loadingBtn:!1,loadingSiret:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{submitForm(){this.loadingBtn=!0,Ve.post("/wp-json/my-easy-compta/v1/clients/add",this.formData,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{e.data.success?(this.showToast(e.data.message,"alert-success"),this.loadingBtn=!1,this.resetForm(),this.closeModal(),this.$emit("clientAdded")):(this.showToast(e.data.message,"alert-error"),this.loadingBtn=!1)}).catch(e=>{const t=e.response&&e.response.data&&e.response.data.message?e.response.data.message:"Erreur serveur";console.error(e),this.showToast(t,"alert-error"),this.loadingBtn=!1})},closeModal(){document.getElementById("modal_clients").close()},showToast(e,t){this.toast.message=e,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resetForm(){for(let e in this.formData)this.formData[e]=""},getOptions(e){return e==="currency_id"?this.options.currency_options:[]},fetchOptions(){Ve.get("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{this.options.currency_options=e.data.currency_options,this.options.default_currency=e.data.default_currency,this.options.addon_user_active=e.data.addon_user_active,this.options.addon_siret_active=e.data.addon_siret_active}).catch(e=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",e)})},fetchCompanyInfo(e){e.preventDefault(),this.loadingSiret=!0;const t=this.formData.siret;t?fetch(`/wp-json/my-easy-compta/v1/fetch-company-info/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.json()}).then(n=>{n?(this.formData.company_name=n.company_name,this.formData.manager_name=n.manager_name,this.formData.address=n.address,this.formData.postal_code=n.postal_code,this.formData.city=n.city,this.formData.siren_number=n.siren,this.showToast("Informations charg\xE9es avec succ\xE8s","alert-success"),this.loadingSiret=!1):(this.showToast("Aucune information trouv\xE9e pour ce SIRET","alert-error"),this.loadingSiret=!1)}).catch(n=>{console.error("Error fetching company info:",n),this.showToast("Erreur lors du chargement des informations","alert-error"),this.loadingSiret=!1}):(this.showToast("Veuillez saisir un num\xE9ro SIRET","alert-error"),this.loadingSiret=!1)}},mounted(){this.fetchOptions()}},is={id:"modal_clients",class:"modal"},as={class:"modal-box"},ls={class:"font-bold text-lg"},cs={key:0,class:"grid grid-cols-1 gap-4"},ds={class:"ecwp-group form-group relative join"},us={for:"siret",class:"ecwp-label form-label"},fs=["disabled"],hs={key:0,class:"loading loading-spinner loading-sm"},ms={key:1},ps={class:"grid grid-cols-1 gap-4"},ys={class:"ecwp-group form-group relative"},_s={for:"siren",class:"ecwp-label form-label"},gs={class:"grid grid-cols-1 gap-4"},bs={class:"ecwp-group form-group relative"},ws={for:"tax_number",class:"ecwp-label form-label"},xs={class:"grid grid-cols-2 gap-4"},Es=["for"],vs=["id","onUpdate:modelValue","required"],Cs=["value"],Ss=["value"],Ts=["type","id","onUpdate:modelValue","required"],Rs={class:"ecwp-group form-group mt-4 relative"},Os=["for"],As={key:1,class:"ecwp-group form-group mt-6 w-52 flex justify-between"},Ps={class:"form-group mt-4 flex justify-end"},ks=["disabled"],Ns={key:0,class:"loading loading-spinner loading-sm"};function Ds(e,t,n,s,o,r){return y(),_("div",null,[o.toast.visible?(y(),_("div",{key:0,class:M(["toast",o.toast.position]),style:{zIndex:9999}},[a("div",{class:M(["alert",o.toast.type,"text-white"])},[a("span",null,m(o.toast.message),1)],2)],2)):D("",!0),a("dialog",is,[a("div",as,[a("h3",ls,m(r.translations.new_client),1),a("form",{onSubmit:t[7]||(t[7]=Je((...i)=>r.submitForm&&r.submitForm(...i),["prevent"]))},[a("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=i=>r.closeModal())}," \u2715 "),o.options.addon_siret_active?(y(),_("div",cs,[a("div",ds,[a("label",us,m(r.translations.siret),1),A(a("input",{type:"number",id:"siret","onUpdate:modelValue":t[1]||(t[1]=i=>o.formData.siret=i),class:"ecwp-input input input-bordered w-full"},null,512),[[J,o.formData.siret]]),a("button",{onClick:t[2]||(t[2]=(...i)=>r.fetchCompanyInfo&&r.fetchCompanyInfo(...i)),class:"btn join-item rounded-r-full mt-5",disabled:o.loadingSiret},[o.loadingSiret?(y(),_("span",hs)):(y(),_("span",ms,m(r.translations.search),1))],8,fs)])])):D("",!0),a("div",ps,[a("div",ys,[a("label",_s,m(r.translations.siren),1),A(a("input",{type:"number",id:"siren","onUpdate:modelValue":t[3]||(t[3]=i=>o.formData.siren_number=i),class:"ecwp-input input input-bordered w-full"},null,512),[[J,o.formData.siren_number]])])]),a("div",gs,[a("div",bs,[a("label",ws,m(r.translations.tax_number),1),A(a("input",{type:"text",id:"tax_number","onUpdate:modelValue":t[4]||(t[4]=i=>o.formData.tax_number=i),class:"ecwp-input input input-bordered w-full"},null,512),[[J,o.formData.tax_number]])])]),a("div",xs,[(y(!0),_(T,null,R(o.fields,(i,c)=>(y(),_("div",{key:c,class:"ecwp-group form-group relative"},[a("label",{for:c,class:"ecwp-label form-label"},m(i.label),9,Es),c==="currency_id"?A((y(),_("select",{key:0,id:c,"onUpdate:modelValue":f=>o.formData[c]=f,class:"ecwp-input input input-bordered w-full peer",required:i.required},[a("option",{value:o.options.default_currency},m(r.translations.default_currency),9,Cs),(y(!0),_(T,null,R(r.getOptions(c),f=>(y(),_("option",{key:f.id,value:f.id},m(f.name)+" - "+m(f.code)+" ("+m(f.symbol)+") ",9,Ss))),128))],8,vs)),[[Ee,o.formData[c]]]):A((y(),_("input",{key:1,type:i.type,id:c,"onUpdate:modelValue":f=>o.formData[c]=f,class:"ecwp-input input input-bordered w-full peer",placeholder:" ",required:i.required},null,8,Ts)),[[Xe,o.formData[c]]])]))),128))]),a("div",Rs,[a("label",{for:e.key,class:"ecwp-label form-label"},m(r.translations.note),9,Os),A(a("textarea",{id:"note","onUpdate:modelValue":t[5]||(t[5]=i=>o.formData.note=i),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:" "},null,512),[[J,o.formData.note]])]),o.options.addon_user_active?(y(),_("div",As,[a("label",null,m(r.translations.create_user),1),A(a("input",{class:"ecwp-switch",type:"checkbox","onUpdate:modelValue":t[6]||(t[6]=i=>o.formData.user_create=i)},null,512),[[gt,o.formData.user_create]])])):D("",!0),a("div",Ps,[a("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:o.loadingBtn},[X(m(r.translations.add)+" ",1),o.loadingBtn?(y(),_("span",Ns)):D("",!0)],8,ks)])],32)])])])}var Bs=oe(rs,[["render",Ds]]);const Fs={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object,currencyOptions:{type:Array,default:()=>[]}},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{addon_siret_active:"",localCurrencyOptions:this.currencyOptions,translations:e}},computed:{skeletonItems(){return Array.from({length:7},(e,t)=>t)},fields(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone},mobile_phone:{label:e.mobile},website:{label:e.website},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}}}},mounted(){this.fetchOptions()},methods:{closeModal(){const e=document.getElementById(this.modalId);e&&(e.close(),this.$emit("close"))},fetchOptions(){fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.currency_options&&(this.localCurrencyOptions=e.currency_options,this.addon_siret_active=e.addon_siret_active)}).catch(e=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",e)})},getCurrencyOption(e){const t=this.localCurrencyOptions.find(n=>n.id===e);return t?t.name:"N/A"}}},Ls=["id","open"],Ms={class:"modal-box"},js={class:"font-bold text-lg"},Us={key:0},Is={class:"grid grid-cols-2 gap-4"},qs=a("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Hs=a("div",{class:"skeleton h-4 w-full"},null,-1),zs=[qs,Hs],Vs={key:1},Ws={class:"grid grid-cols-2 gap-4"},Js={key:0,class:"py-2"},Xs={class:"text-sm font-medium text-gray-500"},Ks={class:"mt-1 text-sm text-gray-900"},$s=a("dl",{class:"divide-y divide-gray-200"},null,-1),Gs={key:1,class:"py-2"},Qs={class:"text-sm font-medium text-gray-500"},Zs={class:"mt-1 text-sm text-gray-900"},Ys=a("dl",{class:"divide-y divide-gray-200"},null,-1),eo={class:"grid grid-cols-1 gap-4"},to={key:0,class:"py-2"},no={class:"text-sm font-medium text-gray-500"},so={class:"mt-1 text-sm text-gray-900"},oo=a("dl",{class:"divide-y divide-gray-200"},null,-1),ro={class:"grid grid-cols-2 gap-4"},io={class:"text-sm font-medium text-gray-500"},ao={class:"mt-1 text-sm text-gray-900"},lo=a("dl",{class:"divide-y divide-gray-200"},null,-1),co={class:"grid grid-cols-2 gap-4"},uo={class:"py-2"},fo={class:"text-sm font-medium text-gray-500"},ho={class:"mt-1 text-sm text-gray-900"},mo=a("dl",{class:"divide-y divide-gray-200"},null,-1),po={class:"py-2"},yo={class:"text-sm font-medium text-gray-500"},_o={class:"mt-1 text-sm text-gray-900"},go=a("dl",{class:"divide-y divide-gray-200"},null,-1),bo={key:2},wo={class:"grid grid-cols-2 gap-4"},xo=a("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Eo=a("div",{class:"skeleton h-4 w-full"},null,-1),vo=[xo,Eo];function Co(e,t,n,s,o,r){return y(),_("dialog",{id:n.modalId,class:"modal",open:n.showModal},[a("div",Ms,[a("h3",js,m(n.modalTitle),1),a("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=i=>r.closeModal())}," \u2715 "),n.loading?(y(),_("div",Us,[a("div",Is,[(y(!0),_(T,null,R(r.skeletonItems,i=>(y(),_("div",{key:i,class:"py-2"},zs))),128))])])):n.client?(y(),_("div",Vs,[a("div",Ws,[n.client.siret_number!=0&&o.addon_siret_active?(y(),_("div",Js,[a("dt",Xs,m(o.translations.siret),1),a("dd",Ks,m(n.client.siret_number),1),$s])):D("",!0),n.client.siren_number!=0?(y(),_("div",Gs,[a("dt",Qs,m(o.translations.siren),1),a("dd",Zs,m(n.client.siren_number),1),Ys])):D("",!0)]),a("div",eo,[n.client.tax_number!=0?(y(),_("div",to,[a("dt",no,m(o.translations.tax_number),1),a("dd",so,m(n.client.tax_number),1),oo])):D("",!0)]),a("div",ro,[(y(!0),_(T,null,R(r.fields,(i,c)=>(y(),_("div",{key:c,class:"py-2"},[a("dt",io,m(i.label),1),a("dd",ao,m(n.client[c]),1),lo]))),128))]),a("div",co,[a("div",uo,[a("dt",fo,m(o.translations.currency),1),a("dd",ho,m(r.getCurrencyOption(n.client.currency_id)),1),mo])]),a("div",po,[a("dt",yo,m(o.translations.note),1),a("dd",_o,m(n.client.note),1),go])])):(y(),_("div",bo,[a("div",wo,[(y(!0),_(T,null,R(r.skeletonItems,i=>(y(),_("div",{key:i,class:"py-2"},vo))),128))])]))])],8,Ls)}var So=oe(Fs,[["render",Co]]);const To={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{editedClient:{...this.client},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},currencyOptions:[],fields:{siren_number:{label:e.siren},tax_number:{label:e.tax_number},company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone,type:"tel"},mobile_phone:{label:e.mobile,type:"tel"},website:{label:e.website,type:"url"},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}},loadingBtn:!1}},mounted(){this.fetchOptions()},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},skeletonItems(){return Array.from({length:10},(e,t)=>t)},currencyOptions(){return this.currencyOptions}},methods:{closeModal(){document.getElementById("modal_client_edit").close()},async submitForm(){this.loadingBtn=!0;try{const e=await fetch(`/wp-json/my-easy-compta/v1/clients/${this.editedClient.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedClient)});if(e.ok){const t=await e.json();this.loadingBtn=!1,this.closeModal(),this.showToast(t.message,"alert-success"),this.$emit("clientEdited")}else{const t=`Error editing client: ${e.statusText}`;this.showToast(t,"alert-error"),console.error(t),this.loadingBtn=!1}}catch(e){const t=e.response&&e.response.data&&e.response.data.message?e.response.data.message:"Error editing client";this.showToast(t,"alert-error"),console.error("Error editing client:",e),this.loadingBtn=!1}},async fetchOptions(){try{const e=await fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const t=await e.json();this.currencyOptions=t.currency_options}else throw new Error(`Failed to fetch options: ${e.statusText}`)}catch(e){console.error("Error fetching options:",e)}},showToast(e,t){this.toast.message=e,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{client:{handler(e){this.editedClient={...e}},immediate:!0}}},Ro=["id","open"],Oo={class:"modal-box"},Ao={class:"font-bold text-lg"},Po={key:0},ko={class:"grid grid-cols-2 gap-4"},No=a("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Do=a("div",{class:"skeleton h-4 w-full"},null,-1),Bo=[No,Do],Fo={class:"grid grid-cols-2 gap-4"},Lo=["for"],Mo=["type","id","onUpdate:modelValue"],jo={class:"grid grid-cols-2 gap-4"},Uo={class:"ecwp-group form-group"},Io={for:"currencyId",class:"ecwp-label form-label"},qo=["value"],Ho={class:"ecwp-group form-group mt-4"},zo={for:"note",class:"ecwp-label form-label"},Vo={class:"form-group mt-4 flex justify-end"},Wo=["disabled"],Jo={key:0,class:"loading loading-spinner loading-sm"};function Xo(e,t,n,s,o,r){return y(),_("div",null,[o.toast.visible?(y(),_("div",{key:0,class:M(["toast",o.toast.position]),style:{zIndex:9999}},[a("div",{class:M(["alert",o.toast.type,"text-white"])},[a("span",null,m(o.toast.message),1)],2)],2)):D("",!0),a("dialog",{id:n.modalId,class:"modal",open:n.showModal},[a("div",Oo,[a("h3",Ao,m(n.modalTitle),1),a("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=i=>r.closeModal())}," \u2715 "),n.loading?(y(),_("div",Po,[a("div",ko,[(y(!0),_(T,null,R(r.skeletonItems,i=>(y(),_("div",{key:i,class:"py-2"},Bo))),128))])])):(y(),_("form",{key:1,onSubmit:t[3]||(t[3]=Je((...i)=>r.submitForm&&r.submitForm(...i),["prevent"])),class:"form"},[a("div",Fo,[(y(!0),_(T,null,R(o.fields,(i,c)=>(y(),_("div",{key:c,class:"ecwp-group form-group"},[a("label",{for:c,class:"ecwp-label form-label"},m(i.label),9,Lo),A(a("input",{type:i.type||"text",id:c,"onUpdate:modelValue":f=>o.editedClient[c]=f,class:M(["ecwp-input input","input-bordered",i.class||"w-full"])},null,10,Mo),[[Xe,o.editedClient[c]]])]))),128))]),a("div",jo,[a("div",Uo,[a("label",Io,m(r.translations.currency),1),A(a("select",{id:"currencyId","onUpdate:modelValue":t[1]||(t[1]=i=>o.editedClient.currency_id=i),class:"ecwp-input select select-bordered w-full"},[(y(!0),_(T,null,R(r.currencyOptions,(i,c)=>(y(),_("option",{key:c,value:i.id},m(i.name)+" - "+m(i.code)+" ("+m(i.symbol)+") ",9,qo))),128))],512),[[Ee,o.editedClient.currency_id]])])]),a("div",Ho,[a("label",zo,m(r.translations.note),1),A(a("textarea",{id:"note","onUpdate:modelValue":t[2]||(t[2]=i=>o.editedClient.note=i),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[J,o.editedClient.note]])]),a("div",Vo,[a("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:o.loadingBtn},[X(m(r.translations.save)+" ",1),o.loadingBtn?(y(),_("span",Jo)):D("",!0)],8,Wo)])],32))])],8,Ro)])}var Ko=oe(To,[["render",Xo]]);const $o={name:"Clients",components:{Card:Et,AddClientModal:Bs,ClientDetailsModal:So,ClientEditModal:Ko,RemoveModal:vt},data(){return{clients:[],showClientDetailsModal:!1,editClientModal:!1,showRemoveModal:!1,selectedClient:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,settings:[],loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchClients(),this.loadSettings()},methods:{AddNew(){modal_clients.showModal()},fetchClients(e=1){this.loading=!0;const{perPage:t}=this;fetch(`/wp-json/my-easy-compta/v1/clients?page=${e}&per_page=${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.clients=n.clients,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=n.page,this.perPage=t,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching clients:",n)}).finally(()=>{this.loading=!1})},fetchClientDetails(e){fetch(`/wp-json/my-easy-compta/v1/clients/details/${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.selectedClient=t,this.loadingModal=!1}).catch(t=>{console.error("Error fetching client details:",t),this.loadingModal=!1})},showClientDetails(e){this.loadingModal=!0,this.showClientDetailsModal=!0,modal_client_details.showModal(),this.fetchClientDetails(e.id)},editClient(e){this.loadingModal=!0,this.editClientModal=!0,modal_client_edit.showModal(),this.fetchClientDetails(e.id)},generatePaginationButtons(){this.paginationButtons=Ct(this.currentPage,this.totalPages)},goToPage(e){e!=="..."&&this.fetchClients(e)},perPageChanged(){this.fetchClients()},confirmDeleteClient(e){this.selectedClient=e,modal_remove.showModal(),this.showRemoveModal=!0},deleteClient(e){this.loading=!0;const t=e.id;fetch(`/wp-json/my-easy-compta/v1/clients/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.json()}).then(n=>{n.success?(this.fetchClients(),this.showToast(n.message,"alert-success")):(this.showToast(n.message,"alert-error"),console.error("Error deleting client:",n.statusText))}).catch(n=>{console.log(n.message);const s=n&&n.message?n.message:"Error deleting client";s==="This client cannot be deleted because it has associated data."?this.showToast(s,"alert-error"):console.error("Error deleting client:",n)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:e,currencySymbol:t,vatData:n}=await St();this.settings=e,this.default_currency_symbol=t,this.default_vat=n,this.loadingPrice=!1}catch(e){this.showToast(e.message,"alert-error"),this.loadingPrice=!1}},showToast(e,t){Tt(this.toast,e,t)}},computed:{skeletonItems(){return Array.from({length:5},(e,t)=>t)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Go={class:"pt-2 pr-4"},Qo={class:"flex justify-between items-center"},Zo={class:"card-title"},Yo=a("i",{class:"fas fa-plus-circle"},null,-1),er={key:0,class:"ms-2"},tr={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab1"},nr=a("i",{class:"fas fa-file-export"},null,-1),sr=["data-tip"],or={class:"btn btn-outline btn-accent rounded-full",disabled:""},rr=a("i",{class:"fas fa-file-export"},null,-1),ir=a("div",{class:"divider mt-2"},null,-1),ar={class:"flex items-center mb-4"},lr={for:"perPageSelect",class:"mr-2"},cr=["value"],dr={class:"overflow-x-auto"},ur={key:0,class:"table w-full"},fr={class:"flex justify-center"},hr={class:"flex items-center gap-3"},mr={class:"avatar"},pr={class:"mask mask-squircle w-12 h-12"},yr={version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 122.9 122.9",style:{"enable-background":"new 0 0 122.9 122.9"},"xml:space":"preserve"},_r=a("g",null,[a("path",{d:"M61.4,0c17,0,32.3,6.9,43.4,18c11.1,11.1,18,26.5,18,43.4c0,17-6.9,32.3-18,43.4c-11.1,11.1-26.5,18-43.4,18 s-32.3-6.9-43.4-18C6.9,93.8,0,78.4,0,61.4c0-17,6.9-32.3,18-43.4C29.1,6.9,44.5,0,61.4,0L61.4,0z M41.3,54.3c-1.1,0-2,0.3-2.5,0.7 c-0.3,0.2-0.6,0.5-0.7,0.8c-0.2,0.4-0.3,0.8-0.2,1.4c0,1.5,0.8,3.5,2.4,5.8l0,0l0,0l5,8c2,3.2,4.1,6.5,6.8,8.9 c2.5,2.3,5.6,3.9,9.6,3.9c4.4,0,7.6-1.6,10.2-4.1c2.7-2.5,4.9-6,7-9.5l5.7-9.3c1.1-2.4,1.4-4,1.2-5c-0.1-0.6-0.8-0.8-1.8-0.9 c-0.2,0-0.5,0-0.7,0c-0.3,0-0.5,0-0.8,0c-0.2,0-0.3,0-0.4,0c-0.5,0-1,0-1.6-0.1l1.9-8.6c-14.4,2.3-25.2-8.4-40.4-2.1L43,54.4 C42.4,54.4,41.8,54.4,41.3,54.3L41.3,54.3L41.3,54.3L41.3,54.3z M18.8,95.7c7.1-2.5,19.6-3.8,25.4-7.7c1-1.3,2.1-2.9,3.1-4.3 c0.6-0.9,1.1-1.7,1.6-2.3c0.1-0.1,0.2-0.2,0.3-0.3c-2.4-2.5-4.4-5.5-6.3-8.5l-5-8C36,61.8,35,59.3,35,57.3c0-1,0.1-1.9,0.5-2.6 c0.4-0.8,1-1.5,1.7-2c0.4-0.2,0.8-0.5,1.2-0.6c-0.3-4.3-0.4-9.8-0.2-14.4c0.1-1.1,0.3-2.2,0.6-3.3c1.3-4.6,4.5-8.3,8.5-10.8 c1.4-0.9,2.9-1.6,4.6-2.2c2.9-1.1,1.5-5.5,4.7-5.6c7.5-0.2,19.8,6.2,24.6,11.4c2.8,3,4.6,7,4.9,12.3l-0.3,13.1l0,0 c1.4,0.4,2.3,1.3,2.7,2.7c0.4,1.6,0,3.8-1.4,6.9l0,0c0,0.1-0.1,0.1-0.1,0.2l-5.7,9.4c-2.2,3.6-4.5,7.3-7.5,10.1L73.7,82l0,0 c0.4,0.5,0.8,1.1,1.2,1.7c0.8,1.1,1.6,2.4,2.5,3.6c5.3,4.5,19.3,5.9,26.7,8.6c7.6-9.4,12.1-21.4,12.1-34.4c0-15.1-6.1-28.8-16-38.7 c-9.9-9.9-23.6-16-38.7-16s-28.8,6.1-38.7,16c-9.9,9.9-16,23.6-16,38.7C6.7,74.4,11.2,86.3,18.8,95.7L18.8,95.7z M77,90.5 c-1.4-1.6-2.8-3.7-4.1-5.5c-0.4-0.5-0.7-1.1-1.1-1.5c-2.7,2-6,3.3-10.3,3.3c-4.5,0-8-1.6-10.9-4.1c0,0,0,0.1-0.1,0.1 c-0.5,0.7-1,1.4-1.6,2.3c-1.1,1.6-2.3,3.3-3.4,4.8C45.6,100,71.1,106,77,90.5L77,90.5z"})],-1),gr=[_r],br={class:"font-bold"},wr={class:"text-sm opacity-50"},xr={class:"badge badge-ghost badge-sm"},Er={class:"flex justify-end"},vr=["data-tip"],Cr=["onClick"],Sr=a("i",{class:"far fa-eye"},null,-1),Tr=[Sr],Rr=["data-tip"],Or=["onClick"],Ar=a("i",{class:"fas fa-pencil-alt"},null,-1),Pr=[Ar],kr=["data-tip"],Nr=["onClick"],Dr=a("i",{class:"far fa-trash-alt"},null,-1),Br=[Dr],Fr={key:1},Lr=a("div",{class:"flex gap-4 items-center"},[a("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),a("div",{class:"flex flex-col gap-4 w-full"},[a("div",{class:"skeleton h-4 w-full"}),a("div",{class:"skeleton h-4 w-full"})])],-1),Mr=a("div",{class:"divider my-1"},null,-1),jr=[Lr,Mr],Ur={class:"join ecwp_pagination mt-6 pt-4"},Ir=["onClick"];function qr(e,t,n,s,o,r){const i=z("client-details-modal"),c=z("client-edit-modal"),f=z("remove-modal"),h=z("AddClientModal"),d=z("Card");return y(),_("div",Go,[o.toast.visible?(y(),_("div",{key:0,class:M(["toast",o.toast.position]),style:{zIndex:9999}},[a("div",{class:M(["alert",o.toast.type,"text-white"])},[a("span",null,m(o.toast.message),1)],2)],2)):D("",!0),V(i,{loading:o.loadingModal,"show-modal":o.showClientDetailsModal,"modal-id":"modal_client_details","modal-title":r.translations.client_details,client:o.selectedClient,onClose:t[0]||(t[0]=u=>o.showClientDetailsModal=!1)},null,8,["loading","show-modal","modal-title","client"]),V(c,{loading:o.loadingModal,"show-modal":o.editClientModal,"modal-id":"modal_client_edit","modal-title":r.translations.edit_client,client:o.selectedClient,onClose:t[1]||(t[1]=u=>o.editClientModal=!1),onClientEdited:r.fetchClients},null,8,["loading","show-modal","modal-title","client","onClientEdited"]),V(f,{"show-modal":o.showRemoveModal,title:r.translations.are_you_sure,message:r.translations.no_turning_back,confirmText:r.translations.yes_delete_it,cancelText:r.translations.cancel,onConfirm:t[2]||(t[2]=u=>r.deleteClient(o.selectedClient)),onCancel:t[3]||(t[3]=u=>o.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),V(d,{topMargin:"mt-8"},{default:bt(()=>[a("div",Qo,[a("h2",Zo,m(r.translations.clients),1),a("div",null,[a("button",{class:"btn btn-primary rounded-full",onClick:t[4]||(t[4]=(...u)=>r.AddNew&&r.AddNew(...u))},[X(m(r.translations.add)+" ",1),Yo]),o.settings.easy_compta_export_addon_active==1?(y(),_("span",er,[a("a",tr,[X(m(r.translations.export)+" ",1),nr])])):(y(),_("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":r.translations.active_export_addon},[a("button",or,[X(m(r.translations.export)+" ",1),rr])],8,sr))])]),ir,V(h,{onClientAdded:r.fetchClients},null,8,["onClientAdded"]),a("div",ar,[a("label",lr,m(r.translations.display_per_page),1),A(a("select",{id:"perPageSelect","onUpdate:modelValue":t[5]||(t[5]=u=>o.perPage=u),onChange:t[6]||(t[6]=(...u)=>r.perPageChanged&&r.perPageChanged(...u))},[(y(!0),_(T,null,R(o.perPageOptions,u=>(y(),_("option",{key:u,value:u},m(u),9,cr))),128))],544),[[Ee,o.perPage]])]),a("div",dr,[o.loading?(y(),_("div",Fr,[(y(!0),_(T,null,R(o.skeletonRows,u=>(y(),_("div",{key:u,class:"flex flex-col gap-4 w-full"},jr))),128))])):(y(),_("table",ur,[a("thead",null,[a("tr",null,[a("th",null,m(r.translations.company_name),1),a("th",null,m(r.translations.manager_name),1),a("th",null,m(r.translations.email),1),a("th",null,m(r.translations.phone),1),a("th",fr,m(r.translations.actions),1)])]),a("tbody",null,[(y(!0),_(T,null,R(o.clients,u=>(y(),_("tr",{key:u.id},[a("td",null,[a("div",hr,[a("div",mr,[a("div",pr,[(y(),_("svg",yr,gr))])]),a("div",null,[a("div",br,m(u.company_name),1),a("div",wr,[a("span",xr,m(u.city)+" - "+m(u.country),1)])])])]),a("td",null,m(u.manager_name),1),a("td",null,m(u.email),1),a("td",null,m(u.phone),1),a("td",Er,[a("span",{class:"lg:tooltip","data-tip":r.translations.view},[a("button",{class:"btn btn-circle mx-1",onClick:w=>r.showClientDetails(u)},Tr,8,Cr)],8,vr),a("span",{class:"lg:tooltip","data-tip":r.translations.edit},[a("button",{class:"btn btn-circle mx-1",onClick:w=>r.editClient(u)},Pr,8,Or)],8,Rr),a("span",{class:"lg:tooltip","data-tip":r.translations.delete},[a("button",{onClick:w=>r.confirmDeleteClient(u),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Br,8,Nr)],8,kr)])]))),128))])])),a("div",Ur,[(y(!0),_(T,null,R(o.paginationButtons,u=>(y(),_("button",{key:u,class:M(["join-item btn",{"btn-disabled":u==="..."||u===o.currentPage}]),onClick:w=>r.goToPage(u)},m(u),11,Ir))),128))])])]),_:1})])}var Hr=oe($o,[["render",qr]]);const We=ne;function ne(e,t){const n=se();return ne=function(s,o){return s=s-356,n[s]},ne(e,t)}(function(e,t){const n=ne,s=e();for(;[];)try{if(-parseInt(n(365))/1*(parseInt(n(367))/2)+-parseInt(n(360))/3+parseInt(n(358))/4*(-parseInt(n(356))/5)+-parseInt(n(364))/6+parseInt(n(359))/7*(-parseInt(n(363))/8)+-parseInt(n(361))/9+parseInt(n(366))/10===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(se,351326);function se(){const e=["2962215PZjiPW","#my-easy-compta-clients-app","66032yeBvun","268122NhGxjw","17435VjsLgA","24563930pFciPv","32bzNeNX","24755oRQIOX","mount","368LPzvBk","420QRgvie","1504659nWCzcd"];return se=function(){return e},se()}const zr=wt({render:()=>xt(Hr)});zr.use(Rt)[We(357)](We(362));
  • my-easy-compta/trunk/assets/dist/credits.min.js

    r3167980 r3169216  
    1 import{_ as b,d as x,o as r,c as d,n as f,a as t,t as i,g,e as y,p as C,i as k,F as h,r as u,j as T,f as I,h as j}from"./plugin-vue_export-helper.min.js";import{C as E,R as B}from"./RemoveAlert.min.js";import{g as M,b as R,s as D,f as A}from"./api.min.js";const S={name:"Credits",components:{Card:E,RemoveModal:B},data(){return{credits:[],selectedCredit:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingPdfId:null,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchCredits(),this.loadSettings()},methods:{fetchCredits(n=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/credits?page=${n}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(o=>o.json()).then(o=>{this.credits=o.credits,this.totalCount=o.total_count,this.totalPages=o.total_pages,this.currentPage=o.page,this.perPage=e,this.generatePaginationButtons()}).catch(o=>{console.error("Error fetching credits:",o)}).finally(()=>{this.loading=!1})},generatePaginationButtons(){this.paginationButtons=M(this.currentPage,this.totalPages)},goToPage(n){n!=="..."&&this.fetchCredits(n)},perPageChanged(){this.fetchCredits()},formatAmount(n,e){return R(n,e,this.settings.currency_position)},showToast(n,e){D(this.toast,n,e)},confirmDeleteCredit(n){this.selectedCredit=n,modal_remove.showModal(),this.showRemoveModal=!0},deleteCredit(n){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/credits/${n}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchCredits(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting credit:",e.statusText))}).catch(e=>{console.error("Error deleting credit:",e)})},exportToPDF(n){this.loadingPdfId=n,fetch(`/wp-json/my-easy-compta/v1/credits/pdf/${n}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loadingPdfId=null,new Error("Network response was not ok");return this.loadingPdfId=null,e.blob()}).then(e=>{const o=URL.createObjectURL(e);this.loadingPdfId=null,window.open(o)}).catch(e=>{this.loadingPdfId=null,console.error("There was a problem with the fetch operation:",e)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:n,currencySymbol:e,vatData:o}=await A();this.settings=n,this.default_currency_symbol=e,this.default_vat=o,this.loadingPrice=!1}catch(n){this.showToast(n.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},L={class:"pt-2 pr-4"},V={class:"flex justify-between items-center"},F={class:"card-title"},N=t("div",{class:"divider mt-2"},null,-1),U={class:"flex items-center mb-4"},W={for:"perPageSelect",class:"mr-2"},O=["value"],X={class:"overflow-x-auto"},z={key:0,class:"table w-full"},G={class:"flex justify-end"},q={key:0},H={key:1},J=t("span",{class:"loading loading-bars loading-sm"},null,-1),Q=[J],Z={class:"flex justify-end"},K=["data-tip"],Y=["onClick"],$=t("i",{class:"far fa-trash-alt"},null,-1),tt=[$],et=["data-tip"],st=["onClick","disabled"],nt={key:0,class:"far fa-file-pdf","aria-hidden":"true"},ot={key:1,class:"loading loading-spinner loading-sm"},at={key:1},lt=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),it=t("div",{class:"divider my-1"},null,-1),rt=[lt,it],dt={class:"join ecwp_pagination mt-6 pt-4"},ct=["onClick"];function ht(n,e,o,c,a,l){const w=x("remove-modal"),P=x("Card");return r(),d("div",L,[a.toast.visible?(r(),d("div",{key:0,class:f(["toast",a.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",a.toast.type,"text-white"])},[t("span",null,i(a.toast.message),1)],2)],2)):g("",!0),y(w,{"show-modal":a.showRemoveModal,title:l.translations.are_you_sure,message:l.translations.no_turning_back,confirmText:l.translations.yes_delete_it,cancelText:l.translations.cancel,onConfirm:e[0]||(e[0]=s=>this.deleteCredit(a.selectedCredit)),onCancel:e[1]||(e[1]=s=>a.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),y(P,{topMargin:"mt-8"},{default:C(()=>[t("div",V,[t("h2",F,i(l.translations.credits),1)]),N,t("div",U,[t("label",W,i(l.translations.display_per_page),1),k(t("select",{id:"perPageSelect","onUpdate:modelValue":e[2]||(e[2]=s=>a.perPage=s),onChange:e[3]||(e[3]=(...s)=>l.perPageChanged&&l.perPageChanged(...s))},[(r(!0),d(h,null,u(a.perPageOptions,s=>(r(),d("option",{key:s,value:s},i(s),9,O))),128))],544),[[T,a.perPage]])]),t("div",X,[a.loading?(r(),d("div",at,[(r(!0),d(h,null,u(a.skeletonRows,s=>(r(),d("div",{key:s,class:"flex flex-col gap-4 w-full"},rt))),128))])):(r(),d("table",z,[t("thead",null,[t("tr",null,[t("th",null,i(l.translations.credit_number),1),t("th",null,i(l.translations.invoice_number),1),t("th",null,i(l.translations.client),1),t("th",null,i(l.translations.payment_date),1),t("th",null,i(l.translations.created_at),1),t("th",null,i(l.translations.amount),1),t("th",G,i(l.translations.actions),1)])]),t("tbody",null,[(r(!0),d(h,null,u(a.credits,s=>(r(),d("tr",{key:s.id},[t("td",null,i(s.credit_number),1),t("td",null,i(s.invoice_number),1),t("td",null,i(s.client_name),1),t("td",null,i(s.due_date),1),t("td",null,i(s.created_at),1),t("td",null,[a.loadingPrice?(r(),d("div",H,Q)):(r(),d("div",q,[t("span",null,i(l.formatAmount(s.total_amount,a.default_currency_symbol)),1)]))]),t("td",Z,[t("span",{class:"lg:tooltip","data-tip":l.translations.delete},[t("button",{onClick:p=>l.confirmDeleteCredit(s.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},tt,8,Y)],8,K),t("span",{class:"lg:tooltip","data-tip":l.translations.export},[t("button",{onClick:p=>l.exportToPDF(s.credit_id),class:"btn btn-circle mx-1 text-green-700",disabled:a.loadingPdfId===s.credit_id},[a.loadingPdfId!==s.credit_id?(r(),d("i",nt)):g("",!0),a.loadingPdfId===s.credit_id?(r(),d("span",ot)):g("",!0)],8,st)],8,et)])]))),128))])])),t("div",dt,[(r(!0),d(h,null,u(a.paginationButtons,s=>(r(),d("button",{key:s,class:f(["join-item btn",{"btn-disabled":s==="..."||s===a.currentPage}]),onClick:p=>l.goToPage(s)},i(s),11,ct))),128))])])]),_:1})])}var ut=b(S,[["render",ht]]);const v=_;function _(n,e){const o=m();return _=function(c,a){return c=c-139,o[c]},_(n,e)}(function(n,e){const o=_,c=n();for(;[];)try{if(parseInt(o(148))/1+-parseInt(o(145))/2+parseInt(o(141))/3+-parseInt(o(143))/4+-parseInt(o(142))/5+-parseInt(o(144))/6+parseInt(o(146))/7*(parseInt(o(140))/8)===e)break;c.push(c.shift())}catch{c.push(c.shift())}})(m,600957);function m(){const n=["mount","3001912BgQbMe","3062337uqwMbj","3552295TpffrL","1722952DwBCZH","3095532BPVbJl","2299952ReUpdW","42kLdMtG","#my-easy-compta-credits-app","135839NCPwhj"];return m=function(){return n},m()}const _t=I({render:()=>j(ut)});_t[v(139)](v(147));
     1import{_ as w,d as x,o as r,c,n as g,a as e,t as i,g as f,e as y,p as P,i as C,F as h,r as u,j as k,f as I,h as T}from"./plugin-vue_export-helper.min.js";import{C as j,R as E}from"./RemoveAlert.min.js";import{g as R,b as B,s as M,f as A}from"./api.min.js";const S={name:"Credits",components:{Card:j,RemoveModal:E},data(){return{credits:[],selectedCredit:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingPdfId:null,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchCredits(),this.loadSettings()},methods:{fetchCredits(o=1){this.loading=!0;const{perPage:t}=this;fetch(`/wp-json/my-easy-compta/v1/credits?page=${o}&per_page=${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.credits=n.credits,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=n.page,this.perPage=t,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching credits:",n)}).finally(()=>{this.loading=!1})},generatePaginationButtons(){this.paginationButtons=R(this.currentPage,this.totalPages)},goToPage(o){o!=="..."&&this.fetchCredits(o)},perPageChanged(){this.fetchCredits()},formatAmount(o,t){return B(o,t,this.settings.currency_position)},showToast(o,t){M(this.toast,o,t)},confirmDeleteCredit(o){this.selectedCredit=o,modal_remove.showModal(),this.showRemoveModal=!0},deleteCredit(o){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/credits/${o}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.fetchCredits(),this.showToast(t.message,"alert-success")):(this.showToast(t.message,"alert-error"),console.error("Error deleting credit:",t.statusText))}).catch(t=>{console.error("Error deleting credit:",t)})},exportToPDF(o){this.loadingPdfId=o,fetch(`/wp-json/my-easy-compta/v1/credits/pdf/${o}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw this.loadingPdfId=null,new Error("Network response was not ok");return this.loadingPdfId=null,t.blob()}).then(t=>{const n=URL.createObjectURL(t);this.loadingPdfId=null,window.open(n)}).catch(t=>{this.loadingPdfId=null,console.error("There was a problem with the fetch operation:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:o,currencySymbol:t,vatData:n}=await A();this.settings=o,this.default_currency_symbol=t,this.default_vat=n,this.loadingPrice=!1}catch(o){this.showToast(o.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},D={class:"pt-2 pr-4"},F={class:"flex justify-between items-center"},V={class:"card-title"},W=e("div",{class:"divider mt-2"},null,-1),L={class:"flex items-center mb-4"},U={for:"perPageSelect",class:"mr-2"},z=["value"],N={class:"overflow-x-auto"},O={key:0,class:"table w-full"},X={class:"flex justify-end"},G={key:0},J={key:1},Y=e("span",{class:"loading loading-bars loading-sm"},null,-1),K=[Y],q={class:"flex justify-end"},H=["data-tip"],Q=["onClick"],Z=e("i",{class:"far fa-trash-alt"},null,-1),$=[Z],ee=["data-tip"],te=["onClick","disabled"],se={key:0,class:"far fa-file-pdf","aria-hidden":"true"},ne={key:1,class:"loading loading-spinner loading-sm"},oe={key:1},ae=e("div",{class:"flex gap-4 items-center"},[e("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),e("div",{class:"flex flex-col gap-4 w-full"},[e("div",{class:"skeleton h-4 w-full"}),e("div",{class:"skeleton h-4 w-full"})])],-1),le=e("div",{class:"divider my-1"},null,-1),ie=[ae,le],re={class:"join ecwp_pagination mt-6 pt-4"},ce=["onClick"];function de(o,t,n,d,a,l){const b=x("remove-modal"),v=x("Card");return r(),c("div",D,[a.toast.visible?(r(),c("div",{key:0,class:g(["toast",a.toast.position]),style:{zIndex:9999}},[e("div",{class:g(["alert",a.toast.type,"text-white"])},[e("span",null,i(a.toast.message),1)],2)],2)):f("",!0),y(b,{"show-modal":a.showRemoveModal,title:l.translations.are_you_sure,message:l.translations.no_turning_back,confirmText:l.translations.yes_delete_it,cancelText:l.translations.cancel,onConfirm:t[0]||(t[0]=s=>this.deleteCredit(a.selectedCredit)),onCancel:t[1]||(t[1]=s=>a.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),y(v,{topMargin:"mt-8"},{default:P(()=>[e("div",F,[e("h2",V,i(l.translations.credits),1)]),W,e("div",L,[e("label",U,i(l.translations.display_per_page),1),C(e("select",{id:"perPageSelect","onUpdate:modelValue":t[2]||(t[2]=s=>a.perPage=s),onChange:t[3]||(t[3]=(...s)=>l.perPageChanged&&l.perPageChanged(...s))},[(r(!0),c(h,null,u(a.perPageOptions,s=>(r(),c("option",{key:s,value:s},i(s),9,z))),128))],544),[[k,a.perPage]])]),e("div",N,[a.loading?(r(),c("div",oe,[(r(!0),c(h,null,u(a.skeletonRows,s=>(r(),c("div",{key:s,class:"flex flex-col gap-4 w-full"},ie))),128))])):(r(),c("table",O,[e("thead",null,[e("tr",null,[e("th",null,i(l.translations.credit_number),1),e("th",null,i(l.translations.invoice_number),1),e("th",null,i(l.translations.client),1),e("th",null,i(l.translations.payment_date),1),e("th",null,i(l.translations.created_at),1),e("th",null,i(l.translations.amount),1),e("th",X,i(l.translations.actions),1)])]),e("tbody",null,[(r(!0),c(h,null,u(a.credits,s=>(r(),c("tr",{key:s.id},[e("td",null,i(s.credit_number),1),e("td",null,i(s.invoice_number),1),e("td",null,i(s.client_name),1),e("td",null,i(s.due_date),1),e("td",null,i(s.created_at),1),e("td",null,[a.loadingPrice?(r(),c("div",J,K)):(r(),c("div",G,[e("span",null,i(l.formatAmount(s.total_amount,a.default_currency_symbol)),1)]))]),e("td",q,[e("span",{class:"lg:tooltip","data-tip":l.translations.delete},[e("button",{onClick:p=>l.confirmDeleteCredit(s.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},$,8,Q)],8,H),e("span",{class:"lg:tooltip","data-tip":l.translations.export},[e("button",{onClick:p=>l.exportToPDF(s.credit_id),class:"btn btn-circle mx-1 text-green-700",disabled:a.loadingPdfId===s.credit_id},[a.loadingPdfId!==s.credit_id?(r(),c("i",se)):f("",!0),a.loadingPdfId===s.credit_id?(r(),c("span",ne)):f("",!0)],8,te)],8,ee)])]))),128))])])),e("div",re,[(r(!0),c(h,null,u(a.paginationButtons,s=>(r(),c("button",{key:s,class:g(["join-item btn",{"btn-disabled":s==="..."||s===a.currentPage}]),onClick:p=>l.goToPage(s)},i(s),11,ce))),128))])])]),_:1})])}var he=w(S,[["render",de]]);const ue=_;(function(o,t){const n=_,d=o();for(;[];)try{if(parseInt(n(183))/1*(-parseInt(n(188))/2)+-parseInt(n(191))/3*(-parseInt(n(180))/4)+parseInt(n(190))/5+parseInt(n(189))/6+parseInt(n(186))/7*(-parseInt(n(182))/8)+-parseInt(n(184))/9+parseInt(n(187))/10*(-parseInt(n(185))/11)===t)break;d.push(d.shift())}catch{d.push(d.shift())}})(m,990295);const _e=I({render:()=>T(he)});_e[ue(181)]("#my-easy-compta-credits-app");function _(o,t){const n=m();return _=function(d,a){return d=d-180,n[d]},_(o,t)}function m(){const o=["3340784zMPRlP","7366188gchBaU","8797195spxrSk","87JtAgWS","262824cbMBjY","mount","48FtIVGl","1cWYjLw","12936924sehPFT","6195794AhRKtg","269773WnlCwU","10tnJukV"];return m=function(){return o},m()}
  • my-easy-compta/trunk/assets/dist/expenses.min.js

    r3167980 r3169216  
    1 import{_ as P,o as a,c as i,a as t,t as d,w as j,F as g,r as x,n as f,i as y,k as B,g as _,j as E,v as M,m as w,d as b,H as T,e as v,p as V,f as I,h as S}from"./plugin-vue_export-helper.min.js";import{C as U,R as F}from"./RemoveAlert.min.js";import{T as N}from"./VueSearchSelect.min.js";import{V as O}from"./vue-datepicker.min.js";import{f as W,g as R,b as q,s as X}from"./api.min.js";const z={data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{loadingBtn:!1,formData:{amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},options:{clients:[],categories:[]},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async fetchOptions(){try{const s=await fetch("/wp-json/my-easy-compta/v1/expenses/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}),e=await fetch("/wp-json/my-easy-compta/v1/expenses/categories",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const r=await e.json();this.options.categories=r;const u=await s.json();this.options.clients=u}else console.error("Erreur lors de la r\xE9cup\xE9ration des cat\xE9gories")}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des options:",s)}},async submitForm(){this.loadingBtn=!0;const s=new FormData;s.append("amount",this.formData.amount),s.append("expense_date",this.formData.expense_date),s.append("client_id",this.formData.client_id),s.append("category_id",this.formData.category_id),this.$refs.attachment.files[0]&&s.append("attachment",this.$refs.attachment.files[0]),s.append("note",this.formData.note);try{const e=await fetch("/wp-json/my-easy-compta/v1/expenses",{method:"POST",body:s,headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const r=await e.json();this.loadingBtn=!1,this.$emit("expenseAdded"),this.resetForm(),this.closeModal()}else console.error("Erreur lors de l'ajout de la d\xE9pense"),this.loadingBtn=!1}catch(e){console.error("Erreur lors de l'ajout de la d\xE9pense:",e),this.loadingBtn=!1}},closeModal(){document.getElementById("modal_expenses").close()},resetForm(){this.formData={amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},this.$refs.attachment.value=null}},mounted(){this.fetchOptions()}},H={id:"modal_expenses",class:"modal"},L={class:"modal-box"},Y={class:"font-bold text-lg"},J={class:"grid grid-cols-2 gap-4"},K=["for"],Q=["type","id","onUpdate:modelValue"],G=["id"],Z=["value"],$={value:""},ee=["value"],te={class:"ecwp-group form-group relative"},se={for:"attachment",class:"ecwp-label form-label"},ne={type:"file",id:"attachment",ref:"attachment",class:"ecwp-input input input-bordered w-full peer"},oe={class:"ecwp-group form-group mt-4 relative"},ae={for:"note",class:"ecwp-label form-label"},le={class:"form-group mt-4 flex justify-end"},ie=["disabled"],re={key:0,class:"loading loading-spinner loading-sm"};function de(s,e,r,u,n,o){return a(),i("div",null,[t("dialog",H,[t("div",L,[t("h3",Y,d(o.translations.add),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...h)=>o.closeModal&&o.closeModal(...h))}," \u2715 "),t("form",{onSubmit:e[5]||(e[5]=j((...h)=>o.submitForm&&o.submitForm(...h),["prevent"]))},[t("div",J,[(a(!0),i(g,null,x(n.fields,(h,p)=>(a(),i("div",{key:p,class:"ecwp-group form-group"},[t("label",{for:p,class:f(["ecwp-label form-label",p==="client_id"?"label-search":""])},d(h.label),11,K),p!=="category_id"&&p!=="client_id"&&p!=="expense_date"?y((a(),i("input",{key:0,type:h.type||"text",id:p,"onUpdate:modelValue":c=>n.formData[p]=c,class:f(["ecwp-input input","input-bordered",h.class||"w-full"])},null,10,Q)),[[B,n.formData[p]]]):_("",!0),p==="category_id"?y((a(),i("select",{key:1,id:p,"onUpdate:modelValue":e[1]||(e[1]=c=>n.formData.category_id=c),class:f(["ecwp-input input","input-bordered",h.class||"w-full"])},[(a(!0),i(g,null,x(n.options.categories,c=>(a(),i("option",{key:c.id,value:c.id},d(c.name),9,Z))),128))],10,G)),[[E,n.formData.category_id]]):_("",!0),p==="client_id"?y((a(),i("select",{key:2,id:"client_id","onUpdate:modelValue":e[2]||(e[2]=c=>n.formData.client_id=c),class:"ecwp-input input input-bordered w-full peer"},[t("option",$,d(o.translations.select_client),1),(a(!0),i(g,null,x(n.options.clients,c=>(a(),i("option",{key:c.id,value:c.id},d(c.company_name),9,ee))),128))],512)),[[E,n.formData.client_id]]):_("",!0),p=="expense_date"?y((a(),i("input",{key:3,type:"date",id:"expense_date","onUpdate:modelValue":e[3]||(e[3]=c=>n.formData.expense_date=c),class:"ecwp-input input input-bordered w-full peer",placeholder:"Date de d\xE9pense",required:""},null,512)),[[M,n.formData.expense_date]]):_("",!0)]))),128))]),t("div",te,[t("label",se,d(o.translations.attached_file),1),t("input",ne,null,512)]),t("div",oe,[t("label",ae,d(o.translations.note),1),y(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=h=>n.formData.note=h),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:"Note"},null,512),[[M,n.formData.note]])]),t("div",le,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(d(o.translations.add)+" ",1),n.loadingBtn?(a(),i("span",re)):_("",!0)],8,ie)])],32)])])])}var ce=P(z,[["render",de]]);const pe={components:{ModelSelect:N,VueDatePicker:O},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},expense:{type:Object,default:()=>({id:null,expense_date:"",client_id:"",amount:"",category_id:"",notes:""})},categories:Array,clients:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedExpense:{...this.expense},loadingBtn:!1,clientOptions:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const e=s.getDate().toString().padStart(2,"0"),r=(s.getMonth()+1).toString().padStart(2,"0"),u=s.getFullYear();return`${e}-${r}-${u}`}},skeletonItems(){return Array.from({length:10},(s,e)=>e)},categoriesExpenses(){return this.categories},clients(){return this.clients}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/expenses/${this.editedExpense.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedExpense)});if(s.ok){const e=await s.json();this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("expenseEdited"),this.loadingBtn=!1}else{const e=`Error editing expense: ${s.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(s){const e=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing expense";this.showToast(e,"alert-error"),console.error("Error editing expense:",s),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{expense:{handler(s){this.editedExpense={...s}},immediate:!0}}},ue=["id","open"],me={class:"modal-box"},he={class:"font-bold text-lg"},_e={key:0},fe={class:"grid grid-cols-2 gap-4"},ge=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),xe=t("div",{class:"skeleton h-4 w-full"},null,-1),ye=[ge,xe],be={class:"grid grid-cols-2 gap-4"},we=["for"],ve=["type","id","onUpdate:modelValue"],Ee=["id"],ke=["value"],Ce={class:"ecwp-group form-group mt-4"},Me={for:"note",class:"ecwp-label form-label"},Pe={class:"form-group mt-4 flex justify-end"},De=["disabled"],Te={key:0,class:"loading loading-spinner loading-sm"};function Ae(s,e,r,u,n,o){const h=b("model-select"),p=b("VueDatePicker");return a(),i("div",null,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):_("",!0),t("dialog",{id:r.modalId,class:"modal",open:r.showModal},[t("div",me,[t("h3",he,d(r.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...c)=>o.closeModal&&o.closeModal(...c))}," \u2715 "),r.loading?(a(),i("div",_e,[t("div",fe,[(a(!0),i(g,null,x(o.skeletonItems,c=>(a(),i("div",{key:c,class:"py-2"},ye))),128))])])):(a(),i("form",{key:1,onSubmit:e[5]||(e[5]=j((...c)=>o.submitForm&&o.submitForm(...c),["prevent"])),class:"form"},[t("div",be,[(a(!0),i(g,null,x(n.fields,(c,m)=>(a(),i("div",{key:m,class:"ecwp-group form-group"},[t("label",{for:m,class:f(["ecwp-label form-label",m==="client_id"?"label-search":""])},d(c.label),11,we),m!=="category_id"&&m!=="client_id"&&m!=="expense_date"?y((a(),i("input",{key:0,type:c.type||"text",id:m,"onUpdate:modelValue":l=>n.editedExpense[m]=l,class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},null,10,ve)),[[B,n.editedExpense[m]]]):_("",!0),m==="category_id"?y((a(),i("select",{key:1,id:m,"onUpdate:modelValue":e[1]||(e[1]=l=>n.editedExpense.category_id=l),class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},[(a(!0),i(g,null,x(o.categoriesExpenses,l=>(a(),i("option",{key:l.id,value:l.id},d(l.name),9,ke))),128))],10,Ee)),[[E,n.editedExpense.category_id]]):_("",!0),m==="client_id"?(a(),T(h,{key:2,modelValue:n.editedExpense.client_id,"onUpdate:modelValue":e[2]||(e[2]=l=>n.editedExpense.client_id=l),options:o.clients,label:"text","track-by":"value",placeholder:o.translations.select,class:"ecwp-input input input-bordered w-full",required:""},null,8,["modelValue","options","placeholder"])):_("",!0),m=="expense_date"?(a(),T(p,{key:3,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedExpense.expense_date,"onUpdate:modelValue":e[3]||(e[3]=l=>n.editedExpense.expense_date=l),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,locale:"fr",required:""},null,8,["modelValue","format"])):_("",!0)]))),128))]),t("div",Ce,[t("label",Me,d(o.translations.note),1),y(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=c=>n.editedExpense.notes=c),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[M,n.editedExpense.notes]])]),t("div",Pe,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(d(o.translations.save)+" ",1),n.loadingBtn?(a(),i("span",Te)):_("",!0)],8,De)])],32))])],8,ue)])}var je=P(pe,[["render",Ae]]);const Be={name:"Expenses",components:{Card:U,AddExpenseModal:ce,ExpenseEditModal:je,RemoveModal:F},data(){return{expenses:[],categoriesExpenses:[],listClients:[],clientOptions:[],currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},editExpenseModal:!1,showRemoveModal:!1,selectedExpense:null}},created(){this.fetchExpenses(),this.loadSettings()},methods:{AddNew(){modal_expenses.showModal()},isImage(s){return["jpg","jpeg","png","gif","webp"].includes(s)},fetchExpenses(s=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/expenses?page=${s}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(r=>r.json()).then(r=>{this.expenses=r.expenses,this.totalPages=r.total_pages,this.currentPage=r.page,this.totalCount=r.total_count,this.perPage=e,this.generatePaginationButtons()}).catch(r=>{console.error("Error fetching expenses:",r)}).finally(()=>{this.loading=!1})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:e,vatData:r}=await W();this.settings=s,this.default_currency_symbol=e,this.default_vat=r,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}},generatePaginationButtons(){this.paginationButtons=R(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchExpenses(s)},perPageChanged(){this.fetchExpenses()},formatAmount(s,e){return q(s,e,this.settings.currency_position)},showToast(s,e){X(this.toast,s,e)},editExpense(s){this.loadingModal=!0,this.editExpenseModal=!0,modal_expense_edit.showModal(),this.fetchExpenseDetails(s)},fetchExpenseDetails(s){fetch(`/wp-json/my-easy-compta/v1/expenses/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedExpense=e,this.categoriesExpenses=e.categories_expenses,this.listClients=e.list_clients,this.clientOptions=this.listClients.map(r=>({value:r.id,text:`${r.company_name}`})),this.loadingModal=!1}).catch(e=>{console.error("Error fetching payment details:",e),this.loadingModal=!1})},confirmDeleteExpense(s){this.selectedExpense=s,modal_remove.showModal(),this.showRemoveModal=!0},deleteExpense(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/expenses/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchExpenses(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting expense:",e.statusText))}).catch(e=>{console.error("Error deleting expense:",e)}),this.showRemoveModal=!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},defaultImage(){return window.myEasyComptaAdmin.pluginUrl+"/assets/img/file.svg"}}},Ve={class:"pt-2 pr-4"},Ie={class:"flex justify-between items-center"},Se={class:"card-title"},Ue=t("i",{class:"fas fa-plus-circle"},null,-1),Fe={key:0,class:"ms-2"},Ne={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab5"},Oe=t("i",{class:"fas fa-file-export"},null,-1),We=["data-tip"],Re={class:"btn btn-outline btn-accent rounded-full",disabled:""},qe=t("i",{class:"fas fa-file-export"},null,-1),Xe=t("div",{class:"divider mt-2"},null,-1),ze={class:"flex items-center mb-4"},He={for:"perPageSelect",class:"mr-2"},Le=["value"],Ye={class:"overflow-x-auto"},Je={key:0,class:"table w-full"},Ke={class:"flex justify-center"},Qe={key:0},Ge={key:1},Ze=t("span",{class:"loading loading-bars loading-sm"},null,-1),$e=[Ze],et={key:0,class:"avatar"},tt={key:0,class:"w-16 mask mask-squircle"},st=["href"],nt=["src"],ot={key:1,class:"w-16 mask mask-squircle"},at=["href"],lt=["src"],it={class:"flex justify-end"},rt=["data-tip"],dt=["onClick"],ct=t("i",{class:"fas fa-pencil-alt"},null,-1),pt=[ct],ut=["data-tip"],mt=["onClick"],ht=t("i",{class:"far fa-trash-alt"},null,-1),_t=[ht],ft={key:1},gt=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),xt=t("div",{class:"divider my-1"},null,-1),yt=[gt,xt],bt={class:"join ecwp_pagination mt-6 pt-4"},wt=["onClick"];function vt(s,e,r,u,n,o){const h=b("AddExpenseModal"),p=b("expense-edit-modal"),c=b("remove-modal"),m=b("Card");return a(),i("div",Ve,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):_("",!0),v(h,{onExpenseAdded:o.fetchExpenses},null,8,["onExpenseAdded"]),v(p,{loading:n.loading,"show-modal":n.editExpenseModal,"modal-id":"modal_expense_edit","modal-title":o.translations.edit_expense,expense:n.selectedExpense,categories:n.categoriesExpenses,clients:n.clientOptions,onExpenseEdited:o.fetchExpenses},null,8,["loading","show-modal","modal-title","expense","categories","clients","onExpenseEdited"]),v(c,{"show-modal":n.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=l=>this.deleteExpense(n.selectedExpense)),onCancel:e[1]||(e[1]=l=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),v(m,{topMargin:"mt-8"},{default:V(()=>[t("div",Ie,[t("h2",Se,d(o.translations.expenses),1),t("div",null,[t("button",{class:"btn btn-primary rounded-full",onClick:e[2]||(e[2]=(...l)=>o.AddNew&&o.AddNew(...l))},[w(d(o.translations.add)+" ",1),Ue]),n.settings.easy_compta_export_addon_active==1?(a(),i("span",Fe,[t("a",Ne,[w(d(o.translations.export)+" ",1),Oe])])):(a(),i("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[t("button",Re,[w(d(o.translations.export)+" ",1),qe])],8,We))])]),Xe,t("div",ze,[t("label",He,d(o.translations.display_per_page),1),y(t("select",{id:"perPageSelect","onUpdate:modelValue":e[3]||(e[3]=l=>n.perPage=l),onChange:e[4]||(e[4]=(...l)=>o.perPageChanged&&o.perPageChanged(...l))},[(a(!0),i(g,null,x(n.perPageOptions,l=>(a(),i("option",{key:l,value:l},d(l),9,Le))),128))],544),[[E,n.perPage]])]),t("div",Ye,[n.loading?(a(),i("div",ft,[(a(!0),i(g,null,x(n.skeletonRows,l=>(a(),i("div",{key:l,class:"flex flex-col gap-4 w-full"},yt))),128))])):(a(),i("table",Je,[t("thead",null,[t("tr",null,[t("th",null,d(o.translations.expense_date),1),t("th",null,d(o.translations.amount),1),t("th",null,d(o.translations.client),1),t("th",null,d(o.translations.category),1),t("th",null,d(o.translations.attachment),1),t("th",null,d(o.translations.note),1),t("th",Ke,d(o.translations.actions),1)])]),t("tbody",null,[(a(!0),i(g,null,x(n.expenses,l=>(a(),i("tr",{key:l.id},[t("td",null,d(l.expense_date),1),t("td",null,[n.loadingPrice?(a(),i("div",Ge,$e)):(a(),i("div",Qe,[t("span",null,d(o.formatAmount(l.amount,n.default_currency_symbol)),1)]))]),t("td",null,d(l.company_name),1),t("td",null,d(l.name),1),t("td",null,[l.attachment_url?(a(),i("div",et,[o.isImage(l.type)?(a(),i("div",tt,[t("a",{href:l.attachment_url,target:"_blank"},[t("img",{src:l.attachment_url},null,8,nt)],8,st)])):(a(),i("div",ot,[t("a",{href:l.attachment_url,target:"_blank"},[t("img",{src:o.defaultImage},null,8,lt)],8,at)]))])):_("",!0)]),t("td",null,d(l.notes),1),t("td",it,[t("span",{class:"lg:tooltip","data-tip":o.translations.edit},[t("button",{onClick:D=>o.editExpense(l.id),class:"btn btn-circle mx-1"},pt,8,dt)],8,rt),t("span",{class:"lg:tooltip","data-tip":o.translations.delete},[t("button",{onClick:D=>o.confirmDeleteExpense(l.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},_t,8,mt)],8,ut)])]))),128))])])),t("div",bt,[(a(!0),i(g,null,x(n.paginationButtons,l=>(a(),i("button",{key:l,class:f(["join-item btn",{"btn-disabled":l==="..."||l===n.currentPage}]),onClick:D=>o.goToPage(l)},d(l),11,wt))),128))])])]),_:1})])}var Et=P(Be,[["render",vt]]);const A=k;(function(s,e){const r=k,u=s();for(;[];)try{if(-parseInt(r(410))/1*(-parseInt(r(411))/2)+-parseInt(r(405))/3+parseInt(r(400))/4+-parseInt(r(402))/5+-parseInt(r(409))/6*(-parseInt(r(404))/7)+parseInt(r(407))/8*(-parseInt(r(408))/9)+parseInt(r(401))/10===e)break;u.push(u.shift())}catch{u.push(u.shift())}})(C,384615);const kt=I({render:()=>S(Et)});function k(s,e){const r=C();return k=function(u,n){return u=u-400,r[u]},k(s,e)}function C(){const s=["mount","5176FFWwiM","1071gHCvBq","6xOhWKb","265067oWczlO","2wSDdUV","1803056jFyaoW","1840550AYEcLu","1420755NMmNde","#my-easy-compta-expenses-app","1044743tMCxlH","910128kMQvhp"];return C=function(){return s},C()}kt[A(406)](A(403));
     1import{_ as M,o as a,c as i,n as f,a as t,t as d,g as _,w as A,F as g,r as x,i as y,k as B,j as E,v as P,m as w,d as b,H as D,e as v,p as V,f as I,h as S}from"./plugin-vue_export-helper.min.js";import{C as U,R as F}from"./RemoveAlert.min.js";import{T as N}from"./VueSearchSelect.min.js";import{V as O}from"./vue-datepicker.min.js";import{f as R,g as X,b as q,s as W}from"./api.min.js";const z={data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{loadingBtn:!1,formData:{amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},options:{clients:[],categories:[]},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async fetchOptions(){try{const s=await fetch("/wp-json/my-easy-compta/v1/expenses/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}),e=await fetch("/wp-json/my-easy-compta/v1/expenses/categories",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const r=await e.json();this.options.categories=r;const u=await s.json();this.options.clients=u}else this.showToast("Erreur lors de la r\xE9cup\xE9ration des cat\xE9gories","alert-error"),console.error("Erreur lors de la r\xE9cup\xE9ration des cat\xE9gories")}catch(s){this.showToast(s,"alert-error"),console.error("Erreur lors de la r\xE9cup\xE9ration des options:",s)}},async submitForm(){this.loadingBtn=!0;const s=new FormData;s.append("amount",this.formData.amount),s.append("expense_date",this.formData.expense_date),s.append("client_id",this.formData.client_id),s.append("category_id",this.formData.category_id),this.$refs.attachment.files[0]&&s.append("attachment",this.$refs.attachment.files[0]),s.append("note",this.formData.note);try{const e=await fetch("/wp-json/my-easy-compta/v1/expenses",{method:"POST",body:s,headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}),r=await e.json();e.ok?(this.loadingBtn=!1,this.$emit("expenseAdded"),this.showToast(r.message,"alert-success"),this.resetForm(),this.closeModal()):(this.showToast(r.message||"Erreur lors de l'ajout de la d\xE9pense","alert-error"),console.error("Erreur lors de l'ajout de la d\xE9pense"),this.loadingBtn=!1)}catch(e){this.showToast(e,"alert-error"),console.error("Erreur lors de l'ajout de la d\xE9pense:",e),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},closeModal(){document.getElementById("modal_expenses").close()},resetForm(){this.formData={amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},this.$refs.attachment.value=null}},mounted(){this.fetchOptions()}},L={id:"modal_expenses",class:"modal"},G={class:"modal-box"},H={class:"font-bold text-lg"},Y={class:"grid grid-cols-2 gap-4"},Z=["for"],J=["type","id","onUpdate:modelValue"],Q=["id"],K=["value"],$={value:""},ee=["value"],te={class:"ecwp-group form-group relative"},se={for:"attachment",class:"ecwp-label form-label"},ne={type:"file",id:"attachment",ref:"attachment",class:"ecwp-input input input-bordered w-full peer"},oe={class:"ecwp-group form-group mt-4 relative"},ae={for:"note",class:"ecwp-label form-label"},le={class:"form-group mt-4 flex justify-end"},ie=["disabled"],re={key:0,class:"loading loading-spinner loading-sm"};function de(s,e,r,u,n,o){return a(),i("div",null,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):_("",!0),t("dialog",L,[t("div",G,[t("h3",H,d(o.translations.add),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...h)=>o.closeModal&&o.closeModal(...h))}," \u2715 "),t("form",{onSubmit:e[5]||(e[5]=A((...h)=>o.submitForm&&o.submitForm(...h),["prevent"]))},[t("div",Y,[(a(!0),i(g,null,x(n.fields,(h,p)=>(a(),i("div",{key:p,class:"ecwp-group form-group"},[t("label",{for:p,class:f(["ecwp-label form-label",p==="client_id"?"label-search":""])},d(h.label),11,Z),p!=="category_id"&&p!=="client_id"&&p!=="expense_date"?y((a(),i("input",{key:0,type:h.type||"text",id:p,"onUpdate:modelValue":c=>n.formData[p]=c,class:f(["ecwp-input input","input-bordered",h.class||"w-full"])},null,10,J)),[[B,n.formData[p]]]):_("",!0),p==="category_id"?y((a(),i("select",{key:1,id:p,"onUpdate:modelValue":e[1]||(e[1]=c=>n.formData.category_id=c),class:f(["ecwp-input input","input-bordered",h.class||"w-full"])},[(a(!0),i(g,null,x(n.options.categories,c=>(a(),i("option",{key:c.id,value:c.id},d(c.name),9,K))),128))],10,Q)),[[E,n.formData.category_id]]):_("",!0),p==="client_id"?y((a(),i("select",{key:2,id:"client_id","onUpdate:modelValue":e[2]||(e[2]=c=>n.formData.client_id=c),class:"ecwp-input input input-bordered w-full peer"},[t("option",$,d(o.translations.select_client),1),(a(!0),i(g,null,x(n.options.clients,c=>(a(),i("option",{key:c.id,value:c.id},d(c.company_name),9,ee))),128))],512)),[[E,n.formData.client_id]]):_("",!0),p=="expense_date"?y((a(),i("input",{key:3,type:"date",id:"expense_date","onUpdate:modelValue":e[3]||(e[3]=c=>n.formData.expense_date=c),class:"ecwp-input input input-bordered w-full peer",placeholder:"Date de d\xE9pense",required:""},null,512)),[[P,n.formData.expense_date]]):_("",!0)]))),128))]),t("div",te,[t("label",se,d(o.translations.attached_file),1),t("input",ne,null,512)]),t("div",oe,[t("label",ae,d(o.translations.note),1),y(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=h=>n.formData.note=h),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:"Note"},null,512),[[P,n.formData.note]])]),t("div",le,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(d(o.translations.add)+" ",1),n.loadingBtn?(a(),i("span",re)):_("",!0)],8,ie)])],32)])])])}var ce=M(z,[["render",de]]);const pe={components:{ModelSelect:N,VueDatePicker:O},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},expense:{type:Object,default:()=>({id:null,expense_date:"",client_id:"",amount:"",category_id:"",notes:""})},categories:Array,clients:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedExpense:{...this.expense},loadingBtn:!1,clientOptions:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const e=s.getDate().toString().padStart(2,"0"),r=(s.getMonth()+1).toString().padStart(2,"0"),u=s.getFullYear();return`${e}-${r}-${u}`}},skeletonItems(){return Array.from({length:10},(s,e)=>e)},categoriesExpenses(){return this.categories},clients(){return this.clients}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/expenses/${this.editedExpense.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedExpense)});if(s.ok){const e=await s.json();this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("expenseEdited"),this.loadingBtn=!1}else{const e=`Error editing expense: ${s.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(s){const e=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing expense";this.showToast(e,"alert-error"),console.error("Error editing expense:",s),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{expense:{handler(s){this.editedExpense={...s}},immediate:!0}}},ue=["id","open"],me={class:"modal-box"},he={class:"font-bold text-lg"},_e={key:0},fe={class:"grid grid-cols-2 gap-4"},ge=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),xe=t("div",{class:"skeleton h-4 w-full"},null,-1),ye=[ge,xe],be={class:"grid grid-cols-2 gap-4"},we=["for"],ve=["type","id","onUpdate:modelValue"],Ee=["id"],ke=["value"],Ce={class:"ecwp-group form-group mt-4"},Pe={for:"note",class:"ecwp-label form-label"},Me={class:"form-group mt-4 flex justify-end"},Te=["disabled"],De={key:0,class:"loading loading-spinner loading-sm"};function je(s,e,r,u,n,o){const h=b("model-select"),p=b("VueDatePicker");return a(),i("div",null,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):_("",!0),t("dialog",{id:r.modalId,class:"modal",open:r.showModal},[t("div",me,[t("h3",he,d(r.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...c)=>o.closeModal&&o.closeModal(...c))}," \u2715 "),r.loading?(a(),i("div",_e,[t("div",fe,[(a(!0),i(g,null,x(o.skeletonItems,c=>(a(),i("div",{key:c,class:"py-2"},ye))),128))])])):(a(),i("form",{key:1,onSubmit:e[5]||(e[5]=A((...c)=>o.submitForm&&o.submitForm(...c),["prevent"])),class:"form"},[t("div",be,[(a(!0),i(g,null,x(n.fields,(c,m)=>(a(),i("div",{key:m,class:"ecwp-group form-group"},[t("label",{for:m,class:f(["ecwp-label form-label",m==="client_id"?"label-search":""])},d(c.label),11,we),m!=="category_id"&&m!=="client_id"&&m!=="expense_date"?y((a(),i("input",{key:0,type:c.type||"text",id:m,"onUpdate:modelValue":l=>n.editedExpense[m]=l,class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},null,10,ve)),[[B,n.editedExpense[m]]]):_("",!0),m==="category_id"?y((a(),i("select",{key:1,id:m,"onUpdate:modelValue":e[1]||(e[1]=l=>n.editedExpense.category_id=l),class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},[(a(!0),i(g,null,x(o.categoriesExpenses,l=>(a(),i("option",{key:l.id,value:l.id},d(l.name),9,ke))),128))],10,Ee)),[[E,n.editedExpense.category_id]]):_("",!0),m==="client_id"?(a(),D(h,{key:2,modelValue:n.editedExpense.client_id,"onUpdate:modelValue":e[2]||(e[2]=l=>n.editedExpense.client_id=l),options:o.clients,label:"text","track-by":"value",placeholder:o.translations.select,class:"ecwp-input input input-bordered w-full",required:""},null,8,["modelValue","options","placeholder"])):_("",!0),m=="expense_date"?(a(),D(p,{key:3,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedExpense.expense_date,"onUpdate:modelValue":e[3]||(e[3]=l=>n.editedExpense.expense_date=l),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,locale:"fr",required:""},null,8,["modelValue","format"])):_("",!0)]))),128))]),t("div",Ce,[t("label",Pe,d(o.translations.note),1),y(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=c=>n.editedExpense.notes=c),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[P,n.editedExpense.notes]])]),t("div",Me,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(d(o.translations.save)+" ",1),n.loadingBtn?(a(),i("span",De)):_("",!0)],8,Te)])],32))])],8,ue)])}var Ae=M(pe,[["render",je]]);const Be={name:"Expenses",components:{Card:U,AddExpenseModal:ce,ExpenseEditModal:Ae,RemoveModal:F},data(){return{expenses:[],categoriesExpenses:[],listClients:[],clientOptions:[],currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},editExpenseModal:!1,showRemoveModal:!1,selectedExpense:null}},created(){this.fetchExpenses(),this.loadSettings()},methods:{AddNew(){modal_expenses.showModal()},isImage(s){return["jpg","jpeg","png","gif","webp"].includes(s)},fetchExpenses(s=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/expenses?page=${s}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(r=>r.json()).then(r=>{this.expenses=r.expenses,this.totalPages=r.total_pages,this.currentPage=r.page,this.totalCount=r.total_count,this.perPage=e,this.generatePaginationButtons()}).catch(r=>{console.error("Error fetching expenses:",r)}).finally(()=>{this.loading=!1})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:e,vatData:r}=await R();this.settings=s,this.default_currency_symbol=e,this.default_vat=r,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}},generatePaginationButtons(){this.paginationButtons=X(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchExpenses(s)},perPageChanged(){this.fetchExpenses()},formatAmount(s,e){return q(s,e,this.settings.currency_position)},showToast(s,e){W(this.toast,s,e)},editExpense(s){this.loadingModal=!0,this.editExpenseModal=!0,modal_expense_edit.showModal(),this.fetchExpenseDetails(s)},fetchExpenseDetails(s){fetch(`/wp-json/my-easy-compta/v1/expenses/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedExpense=e,this.categoriesExpenses=e.categories_expenses,this.listClients=e.list_clients,this.clientOptions=this.listClients.map(r=>({value:r.id,text:`${r.company_name}`})),this.loadingModal=!1}).catch(e=>{console.error("Error fetching payment details:",e),this.loadingModal=!1})},confirmDeleteExpense(s){this.selectedExpense=s,modal_remove.showModal(),this.showRemoveModal=!0},deleteExpense(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/expenses/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchExpenses(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting expense:",e.statusText))}).catch(e=>{console.error("Error deleting expense:",e)}),this.showRemoveModal=!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},defaultImage(){return window.myEasyComptaAdmin.pluginUrl+"/assets/img/file.svg"}}},Ve={class:"pt-2 pr-4"},Ie={class:"flex justify-between items-center"},Se={class:"card-title"},Ue=t("i",{class:"fas fa-plus-circle"},null,-1),Fe={key:0,class:"ms-2"},Ne={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab5"},Oe=t("i",{class:"fas fa-file-export"},null,-1),Re=["data-tip"],Xe={class:"btn btn-outline btn-accent rounded-full",disabled:""},qe=t("i",{class:"fas fa-file-export"},null,-1),We=t("div",{class:"divider mt-2"},null,-1),ze={class:"flex items-center mb-4"},Le={for:"perPageSelect",class:"mr-2"},Ge=["value"],He={class:"overflow-x-auto"},Ye={key:0,class:"table w-full"},Ze={class:"flex justify-center"},Je={key:0},Qe={key:1},Ke=t("span",{class:"loading loading-bars loading-sm"},null,-1),$e=[Ke],et={key:0,class:"avatar"},tt={key:0,class:"w-16 mask mask-squircle"},st=["href"],nt=["src"],ot={key:1,class:"w-16 mask mask-squircle"},at=["href"],lt=["src"],it={class:"flex justify-end"},rt=["data-tip"],dt=["onClick"],ct=t("i",{class:"fas fa-pencil-alt"},null,-1),pt=[ct],ut=["data-tip"],mt=["onClick"],ht=t("i",{class:"far fa-trash-alt"},null,-1),_t=[ht],ft={key:1},gt=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),xt=t("div",{class:"divider my-1"},null,-1),yt=[gt,xt],bt={class:"join ecwp_pagination mt-6 pt-4"},wt=["onClick"];function vt(s,e,r,u,n,o){const h=b("AddExpenseModal"),p=b("expense-edit-modal"),c=b("remove-modal"),m=b("Card");return a(),i("div",Ve,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):_("",!0),v(h,{onExpenseAdded:o.fetchExpenses},null,8,["onExpenseAdded"]),v(p,{loading:n.loading,"show-modal":n.editExpenseModal,"modal-id":"modal_expense_edit","modal-title":o.translations.edit_expense,expense:n.selectedExpense,categories:n.categoriesExpenses,clients:n.clientOptions,onExpenseEdited:o.fetchExpenses},null,8,["loading","show-modal","modal-title","expense","categories","clients","onExpenseEdited"]),v(c,{"show-modal":n.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=l=>this.deleteExpense(n.selectedExpense)),onCancel:e[1]||(e[1]=l=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),v(m,{topMargin:"mt-8"},{default:V(()=>[t("div",Ie,[t("h2",Se,d(o.translations.expenses),1),t("div",null,[t("button",{class:"btn btn-primary rounded-full",onClick:e[2]||(e[2]=(...l)=>o.AddNew&&o.AddNew(...l))},[w(d(o.translations.add)+" ",1),Ue]),n.settings.easy_compta_export_addon_active==1?(a(),i("span",Fe,[t("a",Ne,[w(d(o.translations.export)+" ",1),Oe])])):(a(),i("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[t("button",Xe,[w(d(o.translations.export)+" ",1),qe])],8,Re))])]),We,t("div",ze,[t("label",Le,d(o.translations.display_per_page),1),y(t("select",{id:"perPageSelect","onUpdate:modelValue":e[3]||(e[3]=l=>n.perPage=l),onChange:e[4]||(e[4]=(...l)=>o.perPageChanged&&o.perPageChanged(...l))},[(a(!0),i(g,null,x(n.perPageOptions,l=>(a(),i("option",{key:l,value:l},d(l),9,Ge))),128))],544),[[E,n.perPage]])]),t("div",He,[n.loading?(a(),i("div",ft,[(a(!0),i(g,null,x(n.skeletonRows,l=>(a(),i("div",{key:l,class:"flex flex-col gap-4 w-full"},yt))),128))])):(a(),i("table",Ye,[t("thead",null,[t("tr",null,[t("th",null,d(o.translations.expense_date),1),t("th",null,d(o.translations.amount),1),t("th",null,d(o.translations.client),1),t("th",null,d(o.translations.category),1),t("th",null,d(o.translations.attachment),1),t("th",null,d(o.translations.note),1),t("th",Ze,d(o.translations.actions),1)])]),t("tbody",null,[(a(!0),i(g,null,x(n.expenses,l=>(a(),i("tr",{key:l.id},[t("td",null,d(l.expense_date),1),t("td",null,[n.loadingPrice?(a(),i("div",Qe,$e)):(a(),i("div",Je,[t("span",null,d(o.formatAmount(l.amount,n.default_currency_symbol)),1)]))]),t("td",null,d(l.company_name),1),t("td",null,d(l.name),1),t("td",null,[l.attachment_url?(a(),i("div",et,[o.isImage(l.type)?(a(),i("div",tt,[t("a",{href:l.attachment_url,target:"_blank"},[t("img",{src:l.attachment_url},null,8,nt)],8,st)])):(a(),i("div",ot,[t("a",{href:l.attachment_url,target:"_blank"},[t("img",{src:o.defaultImage},null,8,lt)],8,at)]))])):_("",!0)]),t("td",null,d(l.notes),1),t("td",it,[t("span",{class:"lg:tooltip","data-tip":o.translations.edit},[t("button",{onClick:T=>o.editExpense(l.id),class:"btn btn-circle mx-1"},pt,8,dt)],8,rt),t("span",{class:"lg:tooltip","data-tip":o.translations.delete},[t("button",{onClick:T=>o.confirmDeleteExpense(l.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},_t,8,mt)],8,ut)])]))),128))])])),t("div",bt,[(a(!0),i(g,null,x(n.paginationButtons,l=>(a(),i("button",{key:l,class:f(["join-item btn",{"btn-disabled":l==="..."||l===n.currentPage}]),onClick:T=>o.goToPage(l)},d(l),11,wt))),128))])])]),_:1})])}var Et=M(Be,[["render",vt]]);const j=C;(function(s,e){const r=C,u=s();for(;[];)try{if(-parseInt(r(239))/1+-parseInt(r(236))/2+-parseInt(r(237))/3+parseInt(r(238))/4+parseInt(r(241))/5*(parseInt(r(242))/6)+parseInt(r(234))/7+parseInt(r(233))/8*(-parseInt(r(243))/9)===e)break;u.push(u.shift())}catch{u.push(u.shift())}})(k,627458);function k(){const s=["3443848FSmCrb","408398ItZuBC","#my-easy-compta-expenses-app","2335OtvZSE","14982tqkHXr","9utUkOR","12406920EEPLXY","5582423aMpGuv","mount","452174IgDRGp","35226VDNVVQ"];return k=function(){return s},k()}function C(s,e){const r=k();return C=function(u,n){return u=u-233,r[u]},C(s,e)}const kt=I({render:()=>S(Et)});kt[j(235)](j(240));
  • my-easy-compta/trunk/assets/dist/index.min.js

    r3167980 r3169216  
    1 import{s as Ps,u as ut,q as Ms,x as js,y as Jn,z as qs,A as yt,B as Ee,h as Kn,C as Kt,D as Rs,E as Os,_ as oe,d as j,o as r,c,n as k,a as i,t as l,g as _,e as D,p as re,i as B,v as J,j as ve,m as w,w as K,F as W,r as X,G as Zn,H as Vs}from"./plugin-vue_export-helper.min.js";import{C as Xe,R as xt}from"./RemoveAlert.min.js";import{T as Lt}from"./VueSearchSelect.min.js";import{V as Ct}from"./vue-datepicker.min.js";import{f as zt,c as $n,a as es,g as ts,b as ns,s as ss}from"./api.min.js";import{v as It}from"./vue3-editor.common.min.js";/*!
     1import{s as Ds,u as ut,q as Ms,x as js,y as Jn,z as qs,A as yt,B as Ee,h as Kn,C as Kt,D as Os,E as Rs,_ as oe,d as j,o as r,c,n as k,a as i,t as l,g as _,e as P,p as re,i as B,v as J,j as ye,m as w,w as K,F as W,r as X,G as Zn,H as Vs}from"./plugin-vue_export-helper.min.js";import{C as Xe,R as xt}from"./RemoveAlert.min.js";import{T as Lt}from"./VueSearchSelect.min.js";import{V as Ct}from"./vue-datepicker.min.js";import{f as zt,c as $n,a as es,g as ts,b as ns,s as ss}from"./api.min.js";import{v as It}from"./vue3-editor.common.min.js";/*!
    22  * vue-router v4.4.0
    33  * (c) 2024 Eduardo San Martin Morote
    44  * @license MIT
    5   */const Ke=typeof document!="undefined";function Ns(t){return t.__esModule||t[Symbol.toStringTag]==="Module"}const U=Object.assign;function Zt(t,e){const s={};for(const a in e){const n=e[a];s[a]=Ie(n)?n.map(t):t(n)}return s}const ht=()=>{},Ie=Array.isArray,os=/#/g,Bs=/&/g,Fs=/\//g,Ws=/=/g,Qs=/\?/g,is=/\+/g,Xs=/%5B/g,Us=/%5D/g,as=/%5E/g,Ls=/%60/g,ls=/%7B/g,zs=/%7C/g,rs=/%7D/g,Hs=/%20/g;function vn(t){return encodeURI(""+t).replace(zs,"|").replace(Xs,"[").replace(Us,"]")}function Gs(t){return vn(t).replace(ls,"{").replace(rs,"}").replace(as,"^")}function un(t){return vn(t).replace(is,"%2B").replace(Hs,"+").replace(os,"%23").replace(Bs,"%26").replace(Ls,"`").replace(ls,"{").replace(rs,"}").replace(as,"^")}function Ys(t){return un(t).replace(Ws,"%3D")}function Js(t){return vn(t).replace(os,"%23").replace(Qs,"%3F")}function Ks(t){return t==null?"":Js(t).replace(Fs,"%2F")}function bt(t){try{return decodeURIComponent(""+t)}catch{}return""+t}const Zs=/\/$/,$s=t=>t.replace(Zs,"");function $t(t,e,s="/"){let a,n={},o="",f="";const m=e.indexOf("#");let p=e.indexOf("?");return m<p&&m>=0&&(p=-1),p>-1&&(a=e.slice(0,p),o=e.slice(p+1,m>-1?m:e.length),n=t(o)),m>-1&&(a=a||e.slice(0,m),f=e.slice(m,e.length)),a=so(a!=null?a:e,s),{fullPath:a+(o&&"?")+o+f,path:a,query:n,hash:bt(f)}}function eo(t,e){const s=e.query?t(e.query):"";return e.path+(s&&"?")+s+(e.hash||"")}function En(t,e){return!e||!t.toLowerCase().startsWith(e.toLowerCase())?t:t.slice(e.length)||"/"}function to(t,e,s){const a=e.matched.length-1,n=s.matched.length-1;return a>-1&&a===n&&tt(e.matched[a],s.matched[n])&&cs(e.params,s.params)&&t(e.query)===t(s.query)&&e.hash===s.hash}function tt(t,e){return(t.aliasOf||t)===(e.aliasOf||e)}function cs(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!no(t[s],e[s]))return!1;return!0}function no(t,e){return Ie(t)?kn(t,e):Ie(e)?kn(e,t):t===e}function kn(t,e){return Ie(e)?t.length===e.length&&t.every((s,a)=>s===e[a]):t.length===1&&t[0]===e}function so(t,e){if(t.startsWith("/"))return t;if(!t)return e;const s=e.split("/"),a=t.split("/"),n=a[a.length-1];(n===".."||n===".")&&a.push("");let o=s.length-1,f,m;for(f=0;f<a.length;f++)if(m=a[f],m!==".")if(m==="..")o>1&&o--;else break;return s.slice(0,o).join("/")+"/"+a.slice(f).join("/")}const Ne={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};var wt;(function(t){t.pop="pop",t.push="push"})(wt||(wt={}));var mt;(function(t){t.back="back",t.forward="forward",t.unknown=""})(mt||(mt={}));function oo(t){if(!t)if(Ke){const e=document.querySelector("base");t=e&&e.getAttribute("href")||"/",t=t.replace(/^\w+:\/\/[^\/]+/,"")}else t="/";return t[0]!=="/"&&t[0]!=="#"&&(t="/"+t),$s(t)}const io=/^[^#]+#/;function ao(t,e){return t.replace(io,"#")+e}function lo(t,e){const s=document.documentElement.getBoundingClientRect(),a=t.getBoundingClientRect();return{behavior:e.behavior,left:a.left-s.left-(e.left||0),top:a.top-s.top-(e.top||0)}}const Ht=()=>({left:window.scrollX,top:window.scrollY});function ro(t){let e;if("el"in t){const s=t.el,a=typeof s=="string"&&s.startsWith("#"),n=typeof s=="string"?a?document.getElementById(s.slice(1)):document.querySelector(s):s;if(!n)return;e=lo(n,t)}else e=t;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(e.left!=null?e.left:window.scrollX,e.top!=null?e.top:window.scrollY)}function Tn(t,e){return(history.state?history.state.position-e:-1)+t}const hn=new Map;function co(t,e){hn.set(t,e)}function uo(t){const e=hn.get(t);return hn.delete(t),e}let ho=()=>location.protocol+"//"+location.host;function ds(t,e){const{pathname:s,search:a,hash:n}=e,o=t.indexOf("#");if(o>-1){let m=n.includes(t.slice(o))?t.slice(o).length:1,p=n.slice(m);return p[0]!=="/"&&(p="/"+p),En(p,"")}return En(s,t)+a+n}function mo(t,e,s,a){let n=[],o=[],f=null;const m=({state:g})=>{const v=ds(t,location),C=s.value,E=e.value;let O=0;if(g){if(s.value=v,e.value=g,f&&f===C){f=null;return}O=E?g.position-E.position:0}else a(v);n.forEach(F=>{F(s.value,C,{delta:O,type:wt.pop,direction:O?O>0?mt.forward:mt.back:mt.unknown})})};function p(){f=s.value}function d(g){n.push(g);const v=()=>{const C=n.indexOf(g);C>-1&&n.splice(C,1)};return o.push(v),v}function u(){const{history:g}=window;!g.state||g.replaceState(U({},g.state,{scroll:Ht()}),"")}function h(){for(const g of o)g();o=[],window.removeEventListener("popstate",m),window.removeEventListener("beforeunload",u)}return window.addEventListener("popstate",m),window.addEventListener("beforeunload",u,{passive:!0}),{pauseListeners:p,listen:d,destroy:h}}function An(t,e,s,a=!1,n=!1){return{back:t,current:e,forward:s,replaced:a,position:window.history.length,scroll:n?Ht():null}}function fo(t){const{history:e,location:s}=window,a={value:ds(t,s)},n={value:e.state};n.value||o(a.value,{back:null,current:a.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function o(p,d,u){const h=t.indexOf("#"),g=h>-1?(s.host&&document.querySelector("base")?t:t.slice(h))+p:ho()+t+p;try{e[u?"replaceState":"pushState"](d,"",g),n.value=d}catch(v){console.error(v),s[u?"replace":"assign"](g)}}function f(p,d){const u=U({},e.state,An(n.value.back,p,n.value.forward,!0),d,{position:n.value.position});o(p,u,!0),a.value=p}function m(p,d){const u=U({},n.value,e.state,{forward:p,scroll:Ht()});o(u.current,u,!0);const h=U({},An(a.value,p,null),{position:u.position+1},d);o(p,h,!1),a.value=p}return{location:a,state:n,push:m,replace:f}}function po(t){t=oo(t);const e=fo(t),s=mo(t,e.state,e.location,e.replace);function a(o,f=!0){f||s.pauseListeners(),history.go(o)}const n=U({location:"",base:t,go:a,createHref:ao.bind(null,t)},e,s);return Object.defineProperty(n,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(n,"state",{enumerable:!0,get:()=>e.state.value}),n}function _o(t){return t=location.host?t||location.pathname+location.search:"",t.includes("#")||(t+="#"),po(t)}function go(t){return typeof t=="string"||t&&typeof t=="object"}function us(t){return typeof t=="string"||typeof t=="symbol"}const hs=Symbol("");var Sn;(function(t){t[t.aborted=4]="aborted",t[t.cancelled=8]="cancelled",t[t.duplicated=16]="duplicated"})(Sn||(Sn={}));function nt(t,e){return U(new Error,{type:t,[hs]:!0},e)}function Me(t,e){return t instanceof Error&&hs in t&&(e==null||!!(t.type&e))}const Dn="[^/]+?",vo={sensitive:!1,strict:!1,start:!0,end:!0},yo=/[.+*?^${}()[\]/\\]/g;function bo(t,e){const s=U({},vo,e),a=[];let n=s.start?"^":"";const o=[];for(const d of t){const u=d.length?[]:[90];s.strict&&!d.length&&(n+="/");for(let h=0;h<d.length;h++){const g=d[h];let v=40+(s.sensitive?.25:0);if(g.type===0)h||(n+="/"),n+=g.value.replace(yo,"\\$&"),v+=40;else if(g.type===1){const{value:C,repeatable:E,optional:O,regexp:F}=g;o.push({name:C,repeatable:E,optional:O});const P=F||Dn;if(P!==Dn){v+=10;try{new RegExp(`(${P})`)}catch(z){throw new Error(`Invalid custom RegExp for param "${C}" (${P}): `+z.message)}}let q=E?`((?:${P})(?:/(?:${P}))*)`:`(${P})`;h||(q=O&&d.length<2?`(?:/${q})`:"/"+q),O&&(q+="?"),n+=q,v+=20,O&&(v+=-8),E&&(v+=-20),P===".*"&&(v+=-50)}u.push(v)}a.push(u)}if(s.strict&&s.end){const d=a.length-1;a[d][a[d].length-1]+=.7000000000000001}s.strict||(n+="/?"),s.end?n+="$":s.strict&&(n+="(?:/|$)");const f=new RegExp(n,s.sensitive?"":"i");function m(d){const u=d.match(f),h={};if(!u)return null;for(let g=1;g<u.length;g++){const v=u[g]||"",C=o[g-1];h[C.name]=v&&C.repeatable?v.split("/"):v}return h}function p(d){let u="",h=!1;for(const g of t){(!h||!u.endsWith("/"))&&(u+="/"),h=!1;for(const v of g)if(v.type===0)u+=v.value;else if(v.type===1){const{value:C,repeatable:E,optional:O}=v,F=C in d?d[C]:"";if(Ie(F)&&!E)throw new Error(`Provided param "${C}" is an array but it is not repeatable (* or + modifiers)`);const P=Ie(F)?F.join("/"):F;if(!P)if(O)g.length<2&&(u.endsWith("/")?u=u.slice(0,-1):h=!0);else throw new Error(`Missing required param "${C}"`);u+=P}}return u||"/"}return{re:f,score:a,keys:o,parse:m,stringify:p}}function wo(t,e){let s=0;for(;s<t.length&&s<e.length;){const a=e[s]-t[s];if(a)return a;s++}return t.length<e.length?t.length===1&&t[0]===40+40?-1:1:t.length>e.length?e.length===1&&e[0]===40+40?1:-1:0}function ms(t,e){let s=0;const a=t.score,n=e.score;for(;s<a.length&&s<n.length;){const o=wo(a[s],n[s]);if(o)return o;s++}if(Math.abs(n.length-a.length)===1){if(Pn(a))return 1;if(Pn(n))return-1}return n.length-a.length}function Pn(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const xo={type:0,value:""},Co=/[a-zA-Z0-9_]/;function Io(t){if(!t)return[[]];if(t==="/")return[[xo]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(v){throw new Error(`ERR (${s})/"${d}": ${v}`)}let s=0,a=s;const n=[];let o;function f(){o&&n.push(o),o=[]}let m=0,p,d="",u="";function h(){!d||(s===0?o.push({type:0,value:d}):s===1||s===2||s===3?(o.length>1&&(p==="*"||p==="+")&&e(`A repeatable param (${d}) must be alone in its segment. eg: '/:ids+.`),o.push({type:1,value:d,regexp:u,repeatable:p==="*"||p==="+",optional:p==="*"||p==="?"})):e("Invalid state to consume buffer"),d="")}function g(){d+=p}for(;m<t.length;){if(p=t[m++],p==="\\"&&s!==2){a=s,s=4;continue}switch(s){case 0:p==="/"?(d&&h(),f()):p===":"?(h(),s=1):g();break;case 4:g(),s=a;break;case 1:p==="("?s=2:Co.test(p)?g():(h(),s=0,p!=="*"&&p!=="?"&&p!=="+"&&m--);break;case 2:p===")"?u[u.length-1]=="\\"?u=u.slice(0,-1)+p:s=3:u+=p;break;case 3:h(),s=0,p!=="*"&&p!=="?"&&p!=="+"&&m--,u="";break;default:e("Unknown state");break}}return s===2&&e(`Unfinished custom RegExp for param "${d}"`),h(),f(),n}function Eo(t,e,s){const a=bo(Io(t.path),s),n=U(a,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function ko(t,e){const s=[],a=new Map;e=qn({strict:!1,end:!0,sensitive:!1},e);function n(h){return a.get(h)}function o(h,g,v){const C=!v,E=To(h);E.aliasOf=v&&v.record;const O=qn(e,h),F=[E];if("alias"in h){const z=typeof h.alias=="string"?[h.alias]:h.alias;for(const ce of z)F.push(U({},E,{components:v?v.record.components:E.components,path:ce,aliasOf:v?v.record:E}))}let P,q;for(const z of F){const{path:ce}=z;if(g&&ce[0]!=="/"){const ne=g.record.path,Z=ne[ne.length-1]==="/"?"":"/";z.path=g.record.path+(ce&&Z+ce)}if(P=Eo(z,g,O),v?v.alias.push(P):(q=q||P,q!==P&&q.alias.push(P),C&&h.name&&!jn(P)&&f(h.name)),fs(P)&&p(P),E.children){const ne=E.children;for(let Z=0;Z<ne.length;Z++)o(ne[Z],P,v&&v.children[Z])}v=v||P}return q?()=>{f(q)}:ht}function f(h){if(us(h)){const g=a.get(h);g&&(a.delete(h),s.splice(s.indexOf(g),1),g.children.forEach(f),g.alias.forEach(f))}else{const g=s.indexOf(h);g>-1&&(s.splice(g,1),h.record.name&&a.delete(h.record.name),h.children.forEach(f),h.alias.forEach(f))}}function m(){return s}function p(h){const g=Do(h,s);s.splice(g,0,h),h.record.name&&!jn(h)&&a.set(h.record.name,h)}function d(h,g){let v,C={},E,O;if("name"in h&&h.name){if(v=a.get(h.name),!v)throw nt(1,{location:h});O=v.record.name,C=U(Mn(g.params,v.keys.filter(q=>!q.optional).concat(v.parent?v.parent.keys.filter(q=>q.optional):[]).map(q=>q.name)),h.params&&Mn(h.params,v.keys.map(q=>q.name))),E=v.stringify(C)}else if(h.path!=null)E=h.path,v=s.find(q=>q.re.test(E)),v&&(C=v.parse(E),O=v.record.name);else{if(v=g.name?a.get(g.name):s.find(q=>q.re.test(g.path)),!v)throw nt(1,{location:h,currentLocation:g});O=v.record.name,C=U({},g.params,h.params),E=v.stringify(C)}const F=[];let P=v;for(;P;)F.unshift(P.record),P=P.parent;return{name:O,path:E,params:C,matched:F,meta:So(F)}}t.forEach(h=>o(h));function u(){s.length=0,a.clear()}return{addRoute:o,resolve:d,removeRoute:f,clearRoutes:u,getRoutes:m,getRecordMatcher:n}}function Mn(t,e){const s={};for(const a of e)a in t&&(s[a]=t[a]);return s}function To(t){return{path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:void 0,beforeEnter:t.beforeEnter,props:Ao(t),children:t.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in t?t.components||null:t.component&&{default:t.component}}}function Ao(t){const e={},s=t.props||!1;if("component"in t)e.default=s;else for(const a in t.components)e[a]=typeof s=="object"?s[a]:s;return e}function jn(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function So(t){return t.reduce((e,s)=>U(e,s.meta),{})}function qn(t,e){const s={};for(const a in t)s[a]=a in e?e[a]:t[a];return s}function Do(t,e){let s=0,a=e.length;for(;s!==a;){const o=s+a>>1;ms(t,e[o])<0?a=o:s=o+1}const n=Po(t);return n&&(a=e.lastIndexOf(n,a-1)),a}function Po(t){let e=t;for(;e=e.parent;)if(fs(e)&&ms(t,e)===0)return e}function fs({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function Mo(t){const e={};if(t===""||t==="?")return e;const a=(t[0]==="?"?t.slice(1):t).split("&");for(let n=0;n<a.length;++n){const o=a[n].replace(is," "),f=o.indexOf("="),m=bt(f<0?o:o.slice(0,f)),p=f<0?null:bt(o.slice(f+1));if(m in e){let d=e[m];Ie(d)||(d=e[m]=[d]),d.push(p)}else e[m]=p}return e}function Rn(t){let e="";for(let s in t){const a=t[s];if(s=Ys(s),a==null){a!==void 0&&(e+=(e.length?"&":"")+s);continue}(Ie(a)?a.map(o=>o&&un(o)):[a&&un(a)]).forEach(o=>{o!==void 0&&(e+=(e.length?"&":"")+s,o!=null&&(e+="="+o))})}return e}function jo(t){const e={};for(const s in t){const a=t[s];a!==void 0&&(e[s]=Ie(a)?a.map(n=>n==null?null:""+n):a==null?a:""+a)}return e}const qo=Symbol(""),On=Symbol(""),yn=Symbol(""),ps=Symbol(""),mn=Symbol("");function lt(){let t=[];function e(a){return t.push(a),()=>{const n=t.indexOf(a);n>-1&&t.splice(n,1)}}function s(){t=[]}return{add:e,list:()=>t.slice(),reset:s}}function Be(t,e,s,a,n,o=f=>f()){const f=a&&(a.enterCallbacks[n]=a.enterCallbacks[n]||[]);return()=>new Promise((m,p)=>{const d=g=>{g===!1?p(nt(4,{from:s,to:e})):g instanceof Error?p(g):go(g)?p(nt(2,{from:e,to:g})):(f&&a.enterCallbacks[n]===f&&typeof g=="function"&&f.push(g),m())},u=o(()=>t.call(a&&a.instances[n],e,s,d));let h=Promise.resolve(u);t.length<3&&(h=h.then(d)),h.catch(g=>p(g))})}function en(t,e,s,a,n=o=>o()){const o=[];for(const f of t)for(const m in f.components){let p=f.components[m];if(!(e!=="beforeRouteEnter"&&!f.instances[m]))if(Ro(p)){const u=(p.__vccOpts||p)[e];u&&o.push(Be(u,s,a,f,m,n))}else{let d=p();o.push(()=>d.then(u=>{if(!u)return Promise.reject(new Error(`Couldn't resolve component "${m}" at "${f.path}"`));const h=Ns(u)?u.default:u;f.components[m]=h;const v=(h.__vccOpts||h)[e];return v&&Be(v,s,a,f,m,n)()}))}}return o}function Ro(t){return typeof t=="object"||"displayName"in t||"props"in t||"__vccOpts"in t}function Vn(t){const e=yt(yn),s=yt(ps),a=Ee(()=>{const p=ut(t.to);return e.resolve(p)}),n=Ee(()=>{const{matched:p}=a.value,{length:d}=p,u=p[d-1],h=s.matched;if(!u||!h.length)return-1;const g=h.findIndex(tt.bind(null,u));if(g>-1)return g;const v=Nn(p[d-2]);return d>1&&Nn(u)===v&&h[h.length-1].path!==v?h.findIndex(tt.bind(null,p[d-2])):g}),o=Ee(()=>n.value>-1&&Bo(s.params,a.value.params)),f=Ee(()=>n.value>-1&&n.value===s.matched.length-1&&cs(s.params,a.value.params));function m(p={}){return No(p)?e[ut(t.replace)?"replace":"push"](ut(t.to)).catch(ht):Promise.resolve()}return{route:a,href:Ee(()=>a.value.href),isActive:o,isExactActive:f,navigate:m}}const Oo=Jn({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:Vn,setup(t,{slots:e}){const s=qs(Vn(t)),{options:a}=yt(yn),n=Ee(()=>({[Bn(t.activeClass,a.linkActiveClass,"router-link-active")]:s.isActive,[Bn(t.exactActiveClass,a.linkExactActiveClass,"router-link-exact-active")]:s.isExactActive}));return()=>{const o=e.default&&e.default(s);return t.custom?o:Kn("a",{"aria-current":s.isExactActive?t.ariaCurrentValue:null,href:s.href,onClick:s.navigate,class:n.value},o)}}}),Vo=Oo;function No(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function Bo(t,e){for(const s in e){const a=e[s],n=t[s];if(typeof a=="string"){if(a!==n)return!1}else if(!Ie(n)||n.length!==a.length||a.some((o,f)=>o!==n[f]))return!1}return!0}function Nn(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const Bn=(t,e,s)=>t!=null?t:e!=null?e:s,Fo=Jn({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:s}){const a=yt(mn),n=Ee(()=>t.route||a.value),o=yt(On,0),f=Ee(()=>{let d=ut(o);const{matched:u}=n.value;let h;for(;(h=u[d])&&!h.components;)d++;return d}),m=Ee(()=>n.value.matched[f.value]);Kt(On,Ee(()=>f.value+1)),Kt(qo,m),Kt(mn,n);const p=Rs();return Os(()=>[p.value,m.value,t.name],([d,u,h],[g,v,C])=>{u&&(u.instances[h]=d,v&&v!==u&&d&&d===g&&(u.leaveGuards.size||(u.leaveGuards=v.leaveGuards),u.updateGuards.size||(u.updateGuards=v.updateGuards))),d&&u&&(!v||!tt(u,v)||!g)&&(u.enterCallbacks[h]||[]).forEach(E=>E(d))},{flush:"post"}),()=>{const d=n.value,u=t.name,h=m.value,g=h&&h.components[u];if(!g)return Fn(s.default,{Component:g,route:d});const v=h.props[u],C=v?v===!0?d.params:typeof v=="function"?v(d):v:null,O=Kn(g,U({},C,e,{onVnodeUnmounted:F=>{F.component.isUnmounted&&(h.instances[u]=null)},ref:p}));return Fn(s.default,{Component:O,route:d})||O}}});function Fn(t,e){if(!t)return null;const s=t(e);return s.length===1?s[0]:s}const Wo=Fo;function Qo(t){const e=ko(t.routes,t),s=t.parseQuery||Mo,a=t.stringifyQuery||Rn,n=t.history,o=lt(),f=lt(),m=lt(),p=Ps(Ne);let d=Ne;Ke&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Zt.bind(null,y=>""+y),h=Zt.bind(null,Ks),g=Zt.bind(null,bt);function v(y,I){let x,T;return us(y)?(x=e.getRecordMatcher(y),T=I):T=y,e.addRoute(T,x)}function C(y){const I=e.getRecordMatcher(y);I&&e.removeRoute(I)}function E(){return e.getRoutes().map(y=>y.record)}function O(y){return!!e.getRecordMatcher(y)}function F(y,I){if(I=U({},I||p.value),typeof y=="string"){const R=$t(s,y,I.path),se=e.resolve({path:R.path},I),at=n.createHref(R.fullPath);return U(R,se,{params:g(se.params),hash:bt(R.hash),redirectedFrom:void 0,href:at})}let x;if(y.path!=null)x=U({},y,{path:$t(s,y.path,I.path).path});else{const R=U({},y.params);for(const se in R)R[se]==null&&delete R[se];x=U({},y,{params:h(R)}),I.params=h(I.params)}const T=e.resolve(x,I),L=y.hash||"";T.params=u(g(T.params));const $=eo(a,U({},y,{hash:Gs(L),path:T.path})),V=n.createHref($);return U({fullPath:$,hash:L,query:a===Rn?jo(y.query):y.query||{}},T,{redirectedFrom:void 0,href:V})}function P(y){return typeof y=="string"?$t(s,y,p.value.path):U({},y)}function q(y,I){if(d!==y)return nt(8,{from:I,to:y})}function z(y){return Z(y)}function ce(y){return z(U(P(y),{replace:!0}))}function ne(y){const I=y.matched[y.matched.length-1];if(I&&I.redirect){const{redirect:x}=I;let T=typeof x=="function"?x(y):x;return typeof T=="string"&&(T=T.includes("?")||T.includes("#")?T=P(T):{path:T},T.params={}),U({query:y.query,hash:y.hash,params:T.path!=null?{}:y.params},T)}}function Z(y,I){const x=d=F(y),T=p.value,L=y.state,$=y.force,V=y.replace===!0,R=ne(x);if(R)return Z(U(P(R),{state:typeof R=="object"?U({},L,R.state):L,force:$,replace:V}),I||x);const se=x;se.redirectedFrom=I;let at;return!$&&to(a,T,x)&&(at=nt(16,{to:se,from:T}),ot(T,T,!0,!1)),(at?Promise.resolve(at):Oe(se,T)).catch(he=>Me(he)?Me(he,2)?he:Tt(he):Pe(he,se,T)).then(he=>{if(he){if(Me(he,2))return Z(U({replace:V},P(he.to),{state:typeof he.to=="object"?U({},L,he.to.state):L,force:$}),I||se)}else he=Ve(se,T,!0,V,L);return ye(se,T,he),he})}function Ue(y,I){const x=q(y,I);return x?Promise.reject(x):Promise.resolve()}function ie(y){const I=At.values().next().value;return I&&typeof I.runWithContext=="function"?I.runWithContext(y):y()}function Oe(y,I){let x;const[T,L,$]=Xo(y,I);x=en(T.reverse(),"beforeRouteLeave",y,I);for(const R of T)R.leaveGuards.forEach(se=>{x.push(Be(se,y,I))});const V=Ue.bind(null,y,I);return x.push(V),Ge(x).then(()=>{x=[];for(const R of o.list())x.push(Be(R,y,I));return x.push(V),Ge(x)}).then(()=>{x=en(L,"beforeRouteUpdate",y,I);for(const R of L)R.updateGuards.forEach(se=>{x.push(Be(se,y,I))});return x.push(V),Ge(x)}).then(()=>{x=[];for(const R of $)if(R.beforeEnter)if(Ie(R.beforeEnter))for(const se of R.beforeEnter)x.push(Be(se,y,I));else x.push(Be(R.beforeEnter,y,I));return x.push(V),Ge(x)}).then(()=>(y.matched.forEach(R=>R.enterCallbacks={}),x=en($,"beforeRouteEnter",y,I,ie),x.push(V),Ge(x))).then(()=>{x=[];for(const R of f.list())x.push(Be(R,y,I));return x.push(V),Ge(x)}).catch(R=>Me(R,8)?R:Promise.reject(R))}function ye(y,I,x){m.list().forEach(T=>ie(()=>T(y,I,x)))}function Ve(y,I,x,T,L){const $=q(y,I);if($)return $;const V=I===Ne,R=Ke?history.state:{};x&&(T||V?n.replace(y.fullPath,U({scroll:V&&R&&R.scroll},L)):n.push(y.fullPath,L)),p.value=y,ot(y,I,x,V),Tt()}let de;function Ae(){de||(de=n.listen((y,I,x)=>{if(!In.listening)return;const T=F(y),L=ne(T);if(L){Z(U(L,{replace:!0}),T).catch(ht);return}d=T;const $=p.value;Ke&&co(Tn($.fullPath,x.delta),Ht()),Oe(T,$).catch(V=>Me(V,12)?V:Me(V,2)?(Z(V.to,T).then(R=>{Me(R,20)&&!x.delta&&x.type===wt.pop&&n.go(-1,!1)}).catch(ht),Promise.reject()):(x.delta&&n.go(-x.delta,!1),Pe(V,T,$))).then(V=>{V=V||Ve(T,$,!1),V&&(x.delta&&!Me(V,8)?n.go(-x.delta,!1):x.type===wt.pop&&Me(V,20)&&n.go(-1,!1)),ye(T,$,V)}).catch(ht)}))}let Se=lt(),be=lt(),De;function Pe(y,I,x){Tt(y);const T=be.list();return T.length?T.forEach(L=>L(y,I,x)):console.error(y),Promise.reject(y)}function Yt(){return De&&p.value!==Ne?Promise.resolve():new Promise((y,I)=>{Se.add([y,I])})}function Tt(y){return De||(De=!y,Ae(),Se.list().forEach(([I,x])=>y?x(y):I()),Se.reset()),y}function ot(y,I,x,T){const{scrollBehavior:L}=t;if(!Ke||!L)return Promise.resolve();const $=!x&&uo(Tn(y.fullPath,0))||(T||!x)&&history.state&&history.state.scroll||null;return js().then(()=>L(y,I,$)).then(V=>V&&ro(V)).catch(V=>Pe(V,y,I))}const it=y=>n.go(y);let Jt;const At=new Set,In={currentRoute:p,listening:!0,addRoute:v,removeRoute:C,clearRoutes:e.clearRoutes,hasRoute:O,getRoutes:E,resolve:F,options:t,push:z,replace:ce,go:it,back:()=>it(-1),forward:()=>it(1),beforeEach:o.add,beforeResolve:f.add,afterEach:m.add,onError:be.add,isReady:Yt,install(y){const I=this;y.component("RouterLink",Vo),y.component("RouterView",Wo),y.config.globalProperties.$router=I,Object.defineProperty(y.config.globalProperties,"$route",{enumerable:!0,get:()=>ut(p)}),Ke&&!Jt&&p.value===Ne&&(Jt=!0,z(n.location).catch(L=>{}));const x={};for(const L in Ne)Object.defineProperty(x,L,{get:()=>p.value[L],enumerable:!0});y.provide(yn,I),y.provide(ps,Ms(x)),y.provide(mn,p);const T=y.unmount;At.add(y),y.unmount=function(){At.delete(y),At.size<1&&(d=Ne,de&&de(),de=null,p.value=Ne,Jt=!1,De=!1),T()}}};function Ge(y){return y.reduce((I,x)=>I.then(()=>ie(x)),Promise.resolve())}return In}function Xo(t,e){const s=[],a=[],n=[],o=Math.max(e.matched.length,t.matched.length);for(let f=0;f<o;f++){const m=e.matched[f];m&&(t.matched.find(d=>tt(d,m))?a.push(m):s.push(m));const p=t.matched[f];p&&(e.matched.find(d=>tt(d,p))||n.push(p))}return[s,a,n]}const Uo={name:"QuoteEdit",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{quote:{quote_number:"",due_date:"",provisional_start_date:"",client_id:"",client:null,status:""},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchQuoteDetails()},methods:{cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.quote.client_id&&this.setClientById(this.quote.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchQuoteDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?(this.quote=e,this.setClientById(this.quote.client_id)):(console.error("Error fetching quote details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching quote details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.quote.client=this.clients.find(e=>e.id===t)||null,this.quote.client_id=t},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting quote:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Lo={class:"pt-2 pr-4"},zo={class:"flex justify-between items-center mb-4"},Ho={class:"card-title"},Go=i("div",{class:"divider mt-2"},null,-1),Yo={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Jo={class:"grid grid-cols-3 gap-4"},Ko={class:"ecwp-group form-group mb-4"},Zo={for:"quoteNumber",class:"ecwp-label"},$o={class:"ecwp-group form-group mb-4"},ei={for:"quoteDate",class:"ecwp-label"},ti={class:"ecwp-group form-group mb-4"},ni={for:"quoteProvisanalDate",class:"ecwp-label"},si={class:"grid grid-cols-2 gap-4"},oi={class:"ecwp-group form-group mb-4"},ii={for:"client",class:"ecwp-label"},ai={class:"ecwp-group form-group mb-4"},li={for:"status",class:"ecwp-label"},ri={value:"draft"},ci={value:"pending"},di={value:"approved"},ui={value:"rejected"},hi={class:"flex justify-between"},mi=["disabled"],fi={key:0,class:"loading loading-spinner loading-sm"};function pi(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",Lo,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),D(p,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:re(()=>[i("div",zo,[i("h2",Ho,l(o.translations.edit_quote),1)]),Go,n.loading?(r(),c("div",Yo)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitQuote&&o.submitQuote(...d),["prevent"]))},[i("div",Jo,[i("div",Ko,[i("label",Zo,l(o.translations.quote_number),1),B(i("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.quote.quote_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[J,n.quote.quote_number]])]),i("div",$o,[i("label",ei,l(o.translations.due_date),1),D(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.quote.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])]),i("div",ti,[i("label",ni,l(o.translations.provisional_date),1),D(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteProvisanalDate",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=d=>n.quote.provisional_start_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])])]),i("div",si,[i("div",oi,[i("label",ii,l(o.translations.company_name),1),D(m,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[3]||(e[3]=d=>n.quote.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",ai,[i("label",li,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=d=>n.quote.status=d),required:"",class:k(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[i("option",ri,l(o.translations.draft),1),i("option",ci,l(o.translations.pending),1),i("option",di,l(o.translations.approved),1),i("option",ui,l(o.translations.rejected),1)],2),[[ve,n.quote.status]])])]),i("div",hi,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",fi)):_("",!0)],8,mi)])],32)]),_:1})])}var _s=oe(Uo,[["render",pi]]);const _i={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm"),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm").close()}}},gi=["open"],vi={class:"modal-box"},yi={class:"font-bold text-lg"},bi=i("div",{class:"text-center text-red-400 mb-2"},[i("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),wi={class:"text-lg font-semibold text-center"},xi={class:"my-4 text-center text-xl"},Ci={class:"flex justify-between space-x-4"};function Ii(t,e,s,a,n,o){return r(),c("div",null,[i("dialog",{id:"modal_confirm",class:"modal",open:t.showModal},[i("div",vi,[i("h3",yi,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...f)=>o.closeModal&&o.closeModal(...f))}," \u2715 "),bi,i("h2",wi,l(s.title),1),i("p",xi,l(s.message),1),i("div",Ci,[i("button",{onClick:e[1]||(e[1]=(...f)=>o.onCancel&&o.onCancel(...f)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[2]||(e[2]=(...f)=>o.onConfirm&&o.onConfirm(...f)),class:"btn rounded-full btn-error text-white"},l(s.confirmText),1)])])],8,gi)])}var bn=oe(_i,[["render",Ii]]);const Ei={name:"QuotesList",components:{Card:Xe,QuoteEditModal:_s,ConfirmModal:bn,RemoveModal:xt},data(){return{quotes:[],showQuoteDetailsModal:!1,editQuoteModal:!1,selectedQuote:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchQuotes(),this.loadSettings()},methods:{fetchQuotes(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/quotes?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.quotes=s.quotes,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching quotes:",s)}).finally(()=>{this.loading=!1})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return $n(t,this.default_vat.rate)},calculateWithoutVAT(t){return es(t)},generatePaginationButtons(){this.paginationButtons=ts(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchQuotes(t)},perPageChanged(){this.fetchQuotes()},formatAmount(t,e){return ns(t,e,this.settings.currency_position)},confirmDuplicateQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},duplicateQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/duplicate/${t}`,{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotes(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error duplicate quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},confirmDeleteQuote(t){this.selectedQuote=t,modal_remove.showModal(),this.showRemoveModal=!0},deleteQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotes(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},showToast(t,e){ss(this.toast,t,e)}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},ki={class:"pt-2 pr-4"},Ti={class:"flex justify-between items-center"},Ai={class:"card-title"},Si={class:"btn btn-primary rounded-full"},Di=i("i",{class:"fas fa-plus-circle"},null,-1),Pi={key:0,class:"ms-2"},Mi={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab2"},ji=i("i",{class:"fas fa-file-export"},null,-1),qi=["data-tip"],Ri={class:"btn btn-outline btn-accent rounded-full",disabled:""},Oi=i("i",{class:"fas fa-file-export"},null,-1),Vi=i("div",{class:"divider mt-2"},null,-1),Ni={class:"flex items-center mb-4"},Bi={for:"perPageSelect",class:"mr-2"},Fi=["value"],Wi={class:"overflow-x-auto"},Qi={key:0,class:"table w-full"},Xi={class:"flex justify-center"},Ui={key:0,class:"badge badge-warning badge-outline badge-sm"},Li={key:1,class:"badge badge-secondary badge-outline badge-sm"},zi={key:2,class:"badge badge-success badge-outline badge-sm"},Hi={key:3,class:"badge badge-error badge-outline badge-sm"},Gi={key:0},Yi={key:0},Ji={key:0},Ki={key:1},Zi={key:1},$i={key:0},ea={key:1},ta={key:1},na=i("span",{class:"loading loading-bars loading-sm"},null,-1),sa=[na],oa={key:0},ia={key:1},aa=i("span",{class:"loading loading-bars loading-sm"},null,-1),la=[aa],ra={key:0},ca={key:1},da=i("span",{class:"loading loading-bars loading-sm"},null,-1),ua=[da],ha={class:"flex justify-end"},ma=["data-tip"],fa=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"far fa-eye"})],-1),pa=["data-tip"],_a=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"fas fa-pencil-alt"})],-1),ga=["data-tip"],va=["onClick"],ya=i("i",{class:"far fa-copy"},null,-1),ba=[ya],wa=["data-tip"],xa=["onClick"],Ca=i("i",{class:"far fa-trash-alt"},null,-1),Ia=[Ca],Ea={key:1},ka=i("div",{class:"flex gap-4 items-center"},[i("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),i("div",{class:"flex flex-col gap-4 w-full"},[i("div",{class:"skeleton h-4 w-full"}),i("div",{class:"skeleton h-4 w-full"})])],-1),Ta=i("div",{class:"divider my-1"},null,-1),Aa=[ka,Ta],Sa={class:"join ecwp_pagination mt-6 pt-4"},Da=["onClick"];function Pa(t,e,s,a,n,o){const f=j("confirm-modal"),m=j("remove-modal"),p=j("router-link"),d=j("Card");return r(),c("div",ki,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),D(f,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=u=>this.duplicateQuote(n.selectedQuote)),onCancel:e[1]||(e[1]=u=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),D(m,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[2]||(e[2]=u=>this.deleteQuote(n.selectedQuote)),onCancel:e[3]||(e[3]=u=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),D(d,{topMargin:"mt-8"},{default:re(()=>[i("div",Ti,[i("h2",Ai,l(o.translations.quotes),1),i("div",null,[D(p,{to:{name:"QuoteNew"}},{default:re(()=>[i("button",Si,[w(l(o.translations.add)+" ",1),Di])]),_:1}),n.settings.easy_compta_export_addon_active==1?(r(),c("span",Pi,[i("a",Mi,[w(l(o.translations.export)+" ",1),ji])])):(r(),c("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[i("button",Ri,[w(l(o.translations.export)+" ",1),Oi])],8,qi))])]),Vi,i("div",Ni,[i("label",Bi,l(o.translations.display_per_page),1),B(i("select",{id:"perPageSelect","onUpdate:modelValue":e[4]||(e[4]=u=>n.perPage=u),onChange:e[5]||(e[5]=(...u)=>o.perPageChanged&&o.perPageChanged(...u))},[(r(!0),c(W,null,X(n.perPageOptions,u=>(r(),c("option",{key:u,value:u},l(u),9,Fi))),128))],544),[[ve,n.perPage]])]),i("div",Wi,[n.loading?(r(),c("div",Ea,[(r(!0),c(W,null,X(n.skeletonRows,u=>(r(),c("div",{key:u,class:"flex flex-col gap-4 w-full"},Aa))),128))])):(r(),c("table",Qi,[i("thead",null,[i("tr",null,[i("th",null,l(o.translations.quote_number),1),i("th",null,l(o.translations.client),1),i("th",null,l(o.translations.status),1),i("th",null,l(o.translations.total),1),i("th",null,l(o.translations.due_date),1),i("th",null,l(o.translations.created_at),1),i("th",Xi,l(o.translations.actions),1)])]),i("tbody",null,[(r(!0),c(W,null,X(n.quotes,u=>(r(),c("tr",{key:u.id},[i("td",null,l(u.quote_number),1),i("td",null,l(u.client_name),1),i("td",null,[u.status=="draft"?(r(),c("span",Ui,l(o.translations.draft),1)):_("",!0),u.status=="pending"?(r(),c("span",Li,l(o.translations.pending),1)):_("",!0),u.status=="approved"?(r(),c("span",zi,l(o.translations.approved),1)):_("",!0),u.status=="rejected"?(r(),c("span",Hi,l(o.translations.rejected),1)):_("",!0)]),i("td",null,[n.loadingPrice?(r(),c("div",ta,sa)):(r(),c("div",Gi,[n.settings.vat_active==1?(r(),c("div",Yi,[n.default_currency_symbol==u.client_currency||u.client_currency==null?(r(),c("span",Ji,l(o.formatAmount(u.total_amount,n.default_currency_symbol)),1)):(r(),c("span",Ki,l(o.formatAmount(u.total_amount,u.client_currency)),1))])):(r(),c("div",Zi,[n.default_currency_symbol==u.client_currency||u.client_currency==null?(r(),c("span",$i,l(o.formatAmount(u.total_amount,n.default_currency_symbol)),1)):(r(),c("span",ea,l(o.formatAmount(u.total_amount,u.client_currency)),1))]))]))]),i("td",null,[n.loadingPrice?(r(),c("div",ia,la)):(r(),c("div",oa,l(u.due_date),1))]),i("td",null,[n.loadingPrice?(r(),c("div",ca,ua)):(r(),c("div",ra,l(u.created),1))]),i("td",ha,[i("span",{class:"lg:tooltip","data-tip":o.translations.view},[D(p,{to:{name:"QuoteViewDetail",params:{id:u.id}}},{default:re(()=>[fa]),_:2},1032,["to"])],8,ma),i("span",{class:"lg:tooltip","data-tip":o.translations.edit},[D(p,{to:{name:"QuoteEdit",params:{id:u.id}}},{default:re(()=>[_a]),_:2},1032,["to"])],8,pa),i("span",{class:"lg:tooltip","data-tip":o.translations.duplicate},[i("button",{onClick:h=>o.confirmDuplicateQuote(u.id),class:"btn btn-circle text-purple-600 hover:text-purple-900 mx-1"},ba,8,va)],8,ga),i("span",{class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:h=>o.confirmDeleteQuote(u.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Ia,8,xa)],8,wa)])]))),128))])]))]),i("div",Sa,[(r(!0),c(W,null,X(n.paginationButtons,u=>(r(),c("button",{key:u,class:k(["join-item btn",{"btn-disabled":u==="..."||u===n.currentPage}]),onClick:h=>o.goToPage(u)},l(u),11,Da))),128))])]),_:1})])}var Ma=oe(Ei,[["render",Pa]]);const ja={name:"sendQuote",components:{VueEditor:It.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,quoteId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"quote",id:this.quoteId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},qa=["id","open"],Ra={class:"modal-box"},Oa={class:"font-bold text-lg"},Va={key:0},Na={class:"grid grid-cols-1 gap-4"},Ba=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Fa=i("div",{class:"skeleton h-4 w-full"},null,-1),Wa=[Ba,Fa],Qa={class:"grid grid-cols-1 gap-4"},Xa=["type"],Ua=["for"],La=["id","value","disabled","onInput"],za={key:1},Ha=["for"],Ga={class:"form-group mt-4 flex justify-end"},Ya=["disabled"],Ja={key:0,class:"loading loading-spinner loading-sm"};function Ka(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",Ra,[i("h3",Oa,l(o.translations.send_quote),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",Va,[i("div",Na,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},Wa))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",Qa,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,Ua),i("input",{id:p,class:k(["ecwp-input input input-bordered",m.class||"w-full"]),value:m.value,disabled:m.disabled,onInput:d=>o.updateFieldValue(p,d.target.value)},null,42,La)],8,Xa)):(r(),c("div",za,[i("label",{for:p,class:"form-label"},l(m.label),9,Ha),D(f,{modelValue:m.value,"onUpdate:modelValue":d=>m.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",Ga,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.send)+" ",1),n.loadingBtn?(r(),c("span",Ja)):_("",!0)],8,Ya)])],32))])],8,qa)])}var Za=oe(ja,[["render",Ka]]);const $a={components:{VueDatePicker:Ct},props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},totalAmount:{type:String,required:!0},currency:{type:String,required:!0},advanceSold:{type:String,required:!0},quoteId:{type:Number,required:!0}},data(){return{showError:!1,selectedType:"",inputValue:0,due_date:"",invoiceSolded:!1,establishedAdvances:[],loading:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}},remainingAmount(){this.loading=!0;const t=this.establishedAdvances.reduce((e,s)=>{const a=parseFloat(s.advance_amount);return isNaN(a)?(console.error("Erreur: advance_amount n'est pas un nombre valide",s.advance_amount),e):e+a},0);return this.totalAmount-t},inputValueExceeds(){return this.remainingAmount==0?!0:this.selectedType==="percentage"?this.calculatedAmount>this.remainingAmount:this.selectedType==="fixed"?this.inputValue>this.remainingAmount:!1},calculatedAmount(){return this.selectedType==="percentage"?this.inputValue/100*this.remainingAmount:this.inputValue}},created(){this.fetchEstablishedAdvances(this.quoteId)},methods:{fetchEstablishedAdvances(t){const e=`/wp-json/my-easy-compta/v1/advance/${t}`;fetch(e,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.establishedAdvances=s}).catch(s=>{console.error("Error fetching advances:",s)})},onConfirm(){if(!this.inputValueExceeds){if(this.advanceSold=="no_sold"){if(!this.inputValue||!this.due_date||this.advanceSold=="no_sold"&&!this.selectedType){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:this.selectedType,value:this.inputValue,date:this.due_date})}else{if(!this.due_date){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:"fixed",value:this.remainingAmount,date:this.due_date})}this.closeModal()}},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_advance").close()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},el=["open"],tl={class:"modal-box overflow-visible"},nl={class:"font-bold text-lg"},sl={class:"text-lg font-semibold text-center"},ol={class:"my-4 text-center text-xl"},il={key:0,class:"text-red-500 text-sm"},al={class:"grid grid-cols-2 gap-4"},ll={key:0},rl={class:"flex ecwp-group form-group mb-4"},cl=i("label",{for:"advance-type",class:"ecwp-label"},"Type",-1),dl=i("option",{value:"percentage"},"Pourcentage",-1),ul=i("option",{value:"fixed"},"Montant fixe",-1),hl=[dl,ul],ml={key:1},fl={class:"flex ecwp-group form-group mb-4"},pl=i("label",{for:"advance-type",class:"ecwp-label"},"Valeur",-1),_l={class:"absolute items-center border rounded-md right-0 top-6"},gl={class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"},vl={key:0},yl={key:1},bl={key:1,class:"mt-2"},wl={class:"text-sm"},xl={key:2,class:"flex ecwp-group form-group mb-4"},Cl={for:"quoteDate",class:"ecwp-label"},Il={key:3},El={class:"flex justify-between space-x-4 mt-4"},kl=["disabled"];function Tl(t,e,s,a,n,o){const f=j("VueDatePicker");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:"modal_advance",class:"modal",open:s.isVisible},[i("div",tl,[i("h3",nl,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...m)=>o.closeModal&&o.closeModal(...m))}," \u2715 "),i("h2",sl,l(s.title),1),i("p",ol," Montant total restant : "+l(o.remainingAmount)+" "+l(s.currency),1),o.inputValueExceeds&&!n.invoiceSolded?(r(),c("p",il," Le montant s\xE9lectionn\xE9 d\xE9passe le montant total du devis. ")):_("",!0),i("div",al,[s.advanceSold=="no_sold"&&!n.invoiceSolded?(r(),c("div",ll,[i("div",rl,[cl,B(i("select",{"onUpdate:modelValue":e[1]||(e[1]=m=>n.selectedType=m),id:"advance-type",class:k(["ecwp-select ecwp-input input input-bordered w-full",{"input-error":!n.selectedType&&n.showError}])},hl,2),[[ve,n.selectedType]])])])):_("",!0),n.selectedType&&s.advanceSold=="no_sold"&&!n.invoiceSolded?(r(),c("div",ml,[i("div",fl,[pl,B(i("input",{"onUpdate:modelValue":e[2]||(e[2]=m=>n.inputValue=m),type:"text",id:"advance-value",class:k([{"input-error":!n.inputValue&&n.showError},"ecwp-input input input-bordered w-full"])},null,2),[[J,n.inputValue]]),i("div",_l,[i("div",gl,[n.selectedType==="percentage"?(r(),c("span",vl,"%")):(r(),c("span",yl,l(s.currency),1))])])])])):_("",!0)]),n.selectedType==="percentage"&&!o.inputValueExceeds&!n.invoiceSolded?(r(),c("div",bl,[i("p",wl," Montant bas\xE9 sur le pourcentage: "+l(o.calculatedAmount)+" "+l(s.currency),1)])):_("",!0),n.invoiceSolded?_("",!0):(r(),c("div",xl,[i("label",Cl,l(o.translations.due_date),1),D(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.inputValue&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.due_date,"onUpdate:modelValue":e[3]||(e[3]=m=>n.due_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date","class"])])),n.invoiceSolded?(r(),c("div",Il,"Facture d\xE9j\xE0 sold\xE9")):_("",!0),i("div",El,[i("button",{onClick:e[4]||(e[4]=(...m)=>o.onCancel&&o.onCancel(...m)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[5]||(e[5]=(...m)=>o.onConfirm&&o.onConfirm(...m)),disabled:o.inputValueExceeds,class:"btn rounded-full btn-error text-white"},l(s.confirmText),9,kl)])])],8,el)])}var Al=oe($a,[["render",Tl]]);const Sl={name:"QuoteNavBar",components:{SendQuoteModal:Za,ConfirmModal:bn,AdvanceModal:Al},props:{quoteInfo:Object,emailActive:Number,advanceActive:Number,currency:String,noItems:Boolean},data(){return{selectedQuote:null,advanceSold:!1,sendQuoteModal:!1,loadingModal:!1,loadingPdf:!1,loading:!1,client_detail:null,subject:"",content:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async changeQuoteStatus(t){try{const s=await(await fetch("/wp-json/my-easy-compta/v1/quotes/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.quoteInfo.id,status:t})})).json();s.success?(this.quoteInfo.status=t,this.quoteInfo.total_amount=s.total_amount,this.showToast(s.message,"alert-success")):(console.error("Failed to update quote status:",s.message),this.showToast(s.message,"alert-error"))}catch(e){console.error("An error occurred while updating quote status:",e),this.showToast(e,"alert-error")}},convertToInvoice(t){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-quote/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.success?(this.showToast(e.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:e.id}})):this.showToast(e.message,"alert-error")}).catch(e=>{console.error("Error converting quote:",e),this.showToast(e.message,"alert-error")})},handleAdvanceInvoiceConfirm(t){const{type:e,value:s,date:a}=t;this.convertAdvanceInvoice(this.selectedQuote,e,s,a)},convertAdvanceInvoice(t,e,s,a){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-advance/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({advance_type:e,advance_value:s,advance_date:a})}).then(n=>n.json()).then(n=>{n.success?(this.showToast(n.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:n.id}})):this.showToast(n.message,"alert-error")}).catch(n=>{console.error("Error converting quote:",n),this.showToast(n.message,"alert-error")})},confirmConvertQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},ConvertAdvanceQuote(t,e){this.selectedQuote=t,this.advanceSold=e,modal_advance.showModal(),this.showRemoveModal=!0},exportToPDF(){this.loadingPdf=!0;const t=this.quoteInfo.id;fetch(`/wp-json/my-easy-compta/v1/quotes/pdf/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return this.loadingPdf=!1,e.blob()}).then(e=>{const s=URL.createObjectURL(e);window.open(s),this.loadingPdf=!1}).catch(e=>{console.error("There was a problem with the fetch operation:",e),this.loadingPdf=!1})},sendQuote(t){this.loadingModal=!0,this.sendQuoteModal=!0,modal_send_quote.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok){const e=await t.json();this.subject=e.email_quote_subject,this.content=e.email_quote_content,this.loading=!1}else{const e=await t.json();this.showToast(e.message,"alert-error"),this.loading=!1}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Dl={key:0},Pl={key:1},Ml={key:3,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},jl=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),ql=[jl],Rl={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},Ol=i("div",{class:"dropdown"},[i("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),i("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[i("li",null,[i("a",null,"Item 1")]),i("li",null,[i("a",null,"Parent"),i("ul",{class:"p-2"},[i("li",null,[i("a",null,"Submenu 1")]),i("li",null,[i("a",null,"Submenu 2")])])]),i("li",null,[i("a",null,"Item 3")])])],-1),Vl={class:"hidden lg:flex gap-2"},Nl={class:"btn btn-sm"},Bl=i("i",{class:"far fa-edit"},null,-1),Fl=i("i",{class:"fa fa-check"},null,-1),Wl=["data-tip"],Ql={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Xl=i("i",{class:"fas fa-check"},null,-1),Ul=i("i",{class:"fa fa-check"},null,-1),Ll=i("i",{class:"fa fa-times"},null,-1),zl={key:4},Hl={class:"dropdown"},Gl={tabindex:"0",role:"button",class:"btn btn-sm"},Yl=i("i",{class:"fas fa-exchange-alt"},null,-1),Jl={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},Kl={key:0},Zl={key:5},$l=i("i",{class:"fas fa-exchange-alt"},null,-1),er={class:"flex gap-2"},tr=i("i",{class:"fas fa-paper-plane"},null,-1),nr={key:0,class:"far fa-envelope"},sr=["data-tip"],or={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},ir=i("i",{class:"fas fa-paper-plane"},null,-1),ar=["data-tip"],lr={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},rr=i("i",{class:"fas fa-paper-plane"},null,-1),cr=["disabled"],dr=i("i",{class:"far fa-file-pdf"},null,-1),ur={key:0,class:"loading loading-spinner loading-sm"};function hr(t,e,s,a,n,o){const f=j("send-quote-modal"),m=j("confirm-modal"),p=j("advance-modal"),d=j("router-link");return r(),c("div",null,[s.emailActive==1?(r(),c("div",Dl,[D(f,{loading:n.loadingModal,"show-modal":n.sendQuoteModal,"modal-id":"modal_send_quote",client:n.client_detail,"quote-id":s.quoteInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=u=>n.sendQuoteModal=!1)},null,8,["loading","show-modal","client","quote-id","subject","content"])])):_("",!0),D(m,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[1]||(e[1]=u=>this.convertToInvoice(n.selectedQuote)),onCancel:e[2]||(e[2]=u=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.advanceActive==1?(r(),c("div",Pl,[D(p,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,"total-amount":s.quoteInfo.total_amount,currency:s.currency,quoteId:s.quoteInfo.id,"advance-sold":n.advanceSold,onConfirm:o.handleAdvanceInvoiceConfirm,onCancel:e[3]||(e[3]=u=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","total-amount","currency","quoteId","advance-sold","onConfirm"])])):_("",!0),n.toast.visible?(r(),c("div",{key:2,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),n.loading?(r(),c("div",Ml,ql)):_("",!0),i("div",Rl,[i("div",null,[Ol,i("div",Vl,[D(d,{to:{name:"QuoteEdit",params:{id:s.quoteInfo.id}}},{default:re(()=>[i("button",Nl,[Bl,w(l(o.translations.edit_quote),1)])]),_:1},8,["to"]),s.quoteInfo.status=="draft"&&!s.noItems?(r(),c("button",{key:0,class:"btn btn-outline btn-success btn-sm",onClick:e[4]||(e[4]=u=>o.changeQuoteStatus("pending"))},[Fl,w(" "+l(o.translations.validate_quote),1)])):_("",!0),s.quoteInfo.status=="draft"&&s.noItems?(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.min_article},[i("button",Ql,[Xl,w(" "+l(o.translations.validate_quote),1)])],8,Wl)):_("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="rejected")&&!s.noItems?(r(),c("button",{key:2,class:"btn btn-outline btn-success btn-sm",onClick:e[5]||(e[5]=u=>o.changeQuoteStatus("approved"))},[Ul,w(" "+l(o.translations.mark_as_accepted),1)])):_("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="approved")&&!s.noItems?(r(),c("button",{key:3,class:"btn btn-outline btn-error btn-sm",onClick:e[6]||(e[6]=u=>o.changeQuoteStatus("rejected"))},[Ll,w(" "+l(o.translations.mark_as_rejected),1)])):_("",!0),s.advanceActive==1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(r(),c("div",zl,[i("div",Hl,[i("div",Gl,[Yl,w(" "+l(o.translations.convertToInvoice),1)]),i("ul",Jl,[s.quoteInfo.advance!=1?(r(),c("li",Kl,[i("a",{href:"#",onClick:e[7]||(e[7]=K(u=>o.confirmConvertQuote(s.quoteInfo.id),["prevent"]))}," Facture global ")])):_("",!0),i("li",null,[i("a",{href:"#",onClick:e[8]||(e[8]=K(u=>o.ConvertAdvanceQuote(s.quoteInfo.id,"no_sold"),["prevent"]))}," Facture d'acompte "),s.quoteInfo.advance!=0?(r(),c("a",{key:0,href:"#",onClick:e[9]||(e[9]=K(u=>o.ConvertAdvanceQuote(s.quoteInfo.id,"sold"),["prevent"]))}," Facture du solde ")):_("",!0)])])])])):_("",!0),s.advanceActive!=1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(r(),c("div",Zl,[i("button",{onClick:e[10]||(e[10]=u=>o.confirmConvertQuote(s.quoteInfo.id)),class:"btn btn-sm"},[$l,w(" "+l(o.translations.convertToInvoice),1)])])):_("",!0)])]),i("div",er,[s.emailActive==1&&!s.noItems?(r(),c("button",{key:0,onClick:e[11]||(e[11]=K(u=>o.sendQuote(s.quoteInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[tr,w(" "+l(o.translations.send_quote)+" ",1),s.quoteInfo.sent==1?(r(),c("i",nr)):_("",!0)])):s.emailActive==0?(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[i("button",or,[ir,w(" "+l(o.translations.send_quote),1)])],8,sr)):s.emailActive==1&&s.noItems?(r(),c("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.min_article},[i("button",lr,[rr,w(" "+l(o.translations.send_quote),1)])],8,ar)):_("",!0),i("button",{onClick:e[12]||(e[12]=(...u)=>o.exportToPDF&&o.exportToPDF(...u)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[dr,w(" "+l(o.translations.exportToPDF)+" ",1),n.loadingPdf?(r(),c("span",ur)):_("",!0)],8,cr)])])])}var mr=oe(Sl,[["render",hr]]);const fr={components:{VueEditor:It.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:t.item_name},item_description:{label:t.description,type:"textarea"},quantity:{label:t.quantity,type:"number"},vat_rate:{label:"Taux de TVA",type:"number"},unit_price:{label:t.unit_price,type:"number"},discount:{label:t.discount,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/quotes/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},pr=["id","open"],_r={class:"modal-box"},gr={class:"font-bold text-lg"},vr={key:0},yr={class:"grid grid-cols-1 gap-4"},br=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),wr=i("div",{class:"skeleton h-4 w-full"},null,-1),xr=[br,wr],Cr={class:"grid grid-cols-1 gap-4"},Ir=["type"],Er=["for"],kr=["id","onUpdate:modelValue"],Tr={key:1},Ar=["for"],Sr={class:"form-group mt-4 flex justify-end"},Dr=["disabled"],Pr={key:0,class:"loading loading-spinner loading-sm"};function Mr(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",_r,[i("h3",gr,l(s.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",vr,[i("div",yr,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},xr))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",Cr,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,Er),B(i("input",{id:p,"onUpdate:modelValue":d=>n.editedItem[p]=d,class:k(["ecwp-input input input-bordered",m.class||"w-full"])},null,10,kr),[[J,n.editedItem[p]]])],8,Ir)):(r(),c("div",Tr,[i("label",{for:p,class:"form-label"},l(m.label),9,Ar),D(f,{id:p,modelValue:n.editedItem[p],"onUpdate:modelValue":d=>n.editedItem[p]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",Sr,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",Pr)):_("",!0)],8,Dr)])],32))])],8,pr)])}var jr=oe(fr,[["render",Mr]]);/**!
     5  */const Ke=typeof document!="undefined";function Ns(t){return t.__esModule||t[Symbol.toStringTag]==="Module"}const U=Object.assign;function Zt(t,e){const s={};for(const a in e){const n=e[a];s[a]=Ie(n)?n.map(t):t(n)}return s}const ht=()=>{},Ie=Array.isArray,os=/#/g,Bs=/&/g,Fs=/\//g,Ws=/=/g,Qs=/\?/g,is=/\+/g,Xs=/%5B/g,Us=/%5D/g,as=/%5E/g,Ls=/%60/g,ls=/%7B/g,zs=/%7C/g,rs=/%7D/g,Hs=/%20/g;function vn(t){return encodeURI(""+t).replace(zs,"|").replace(Xs,"[").replace(Us,"]")}function Gs(t){return vn(t).replace(ls,"{").replace(rs,"}").replace(as,"^")}function un(t){return vn(t).replace(is,"%2B").replace(Hs,"+").replace(os,"%23").replace(Bs,"%26").replace(Ls,"`").replace(ls,"{").replace(rs,"}").replace(as,"^")}function Ys(t){return un(t).replace(Ws,"%3D")}function Js(t){return vn(t).replace(os,"%23").replace(Qs,"%3F")}function Ks(t){return t==null?"":Js(t).replace(Fs,"%2F")}function bt(t){try{return decodeURIComponent(""+t)}catch{}return""+t}const Zs=/\/$/,$s=t=>t.replace(Zs,"");function $t(t,e,s="/"){let a,n={},o="",f="";const m=e.indexOf("#");let p=e.indexOf("?");return m<p&&m>=0&&(p=-1),p>-1&&(a=e.slice(0,p),o=e.slice(p+1,m>-1?m:e.length),n=t(o)),m>-1&&(a=a||e.slice(0,m),f=e.slice(m,e.length)),a=so(a!=null?a:e,s),{fullPath:a+(o&&"?")+o+f,path:a,query:n,hash:bt(f)}}function eo(t,e){const s=e.query?t(e.query):"";return e.path+(s&&"?")+s+(e.hash||"")}function En(t,e){return!e||!t.toLowerCase().startsWith(e.toLowerCase())?t:t.slice(e.length)||"/"}function to(t,e,s){const a=e.matched.length-1,n=s.matched.length-1;return a>-1&&a===n&&tt(e.matched[a],s.matched[n])&&cs(e.params,s.params)&&t(e.query)===t(s.query)&&e.hash===s.hash}function tt(t,e){return(t.aliasOf||t)===(e.aliasOf||e)}function cs(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!no(t[s],e[s]))return!1;return!0}function no(t,e){return Ie(t)?kn(t,e):Ie(e)?kn(e,t):t===e}function kn(t,e){return Ie(e)?t.length===e.length&&t.every((s,a)=>s===e[a]):t.length===1&&t[0]===e}function so(t,e){if(t.startsWith("/"))return t;if(!t)return e;const s=e.split("/"),a=t.split("/"),n=a[a.length-1];(n===".."||n===".")&&a.push("");let o=s.length-1,f,m;for(f=0;f<a.length;f++)if(m=a[f],m!==".")if(m==="..")o>1&&o--;else break;return s.slice(0,o).join("/")+"/"+a.slice(f).join("/")}const Ne={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};var wt;(function(t){t.pop="pop",t.push="push"})(wt||(wt={}));var mt;(function(t){t.back="back",t.forward="forward",t.unknown=""})(mt||(mt={}));function oo(t){if(!t)if(Ke){const e=document.querySelector("base");t=e&&e.getAttribute("href")||"/",t=t.replace(/^\w+:\/\/[^\/]+/,"")}else t="/";return t[0]!=="/"&&t[0]!=="#"&&(t="/"+t),$s(t)}const io=/^[^#]+#/;function ao(t,e){return t.replace(io,"#")+e}function lo(t,e){const s=document.documentElement.getBoundingClientRect(),a=t.getBoundingClientRect();return{behavior:e.behavior,left:a.left-s.left-(e.left||0),top:a.top-s.top-(e.top||0)}}const Ht=()=>({left:window.scrollX,top:window.scrollY});function ro(t){let e;if("el"in t){const s=t.el,a=typeof s=="string"&&s.startsWith("#"),n=typeof s=="string"?a?document.getElementById(s.slice(1)):document.querySelector(s):s;if(!n)return;e=lo(n,t)}else e=t;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(e.left!=null?e.left:window.scrollX,e.top!=null?e.top:window.scrollY)}function Tn(t,e){return(history.state?history.state.position-e:-1)+t}const hn=new Map;function co(t,e){hn.set(t,e)}function uo(t){const e=hn.get(t);return hn.delete(t),e}let ho=()=>location.protocol+"//"+location.host;function ds(t,e){const{pathname:s,search:a,hash:n}=e,o=t.indexOf("#");if(o>-1){let m=n.includes(t.slice(o))?t.slice(o).length:1,p=n.slice(m);return p[0]!=="/"&&(p="/"+p),En(p,"")}return En(s,t)+a+n}function mo(t,e,s,a){let n=[],o=[],f=null;const m=({state:g})=>{const v=ds(t,location),C=s.value,E=e.value;let R=0;if(g){if(s.value=v,e.value=g,f&&f===C){f=null;return}R=E?g.position-E.position:0}else a(v);n.forEach(F=>{F(s.value,C,{delta:R,type:wt.pop,direction:R?R>0?mt.forward:mt.back:mt.unknown})})};function p(){f=s.value}function d(g){n.push(g);const v=()=>{const C=n.indexOf(g);C>-1&&n.splice(C,1)};return o.push(v),v}function u(){const{history:g}=window;!g.state||g.replaceState(U({},g.state,{scroll:Ht()}),"")}function h(){for(const g of o)g();o=[],window.removeEventListener("popstate",m),window.removeEventListener("beforeunload",u)}return window.addEventListener("popstate",m),window.addEventListener("beforeunload",u,{passive:!0}),{pauseListeners:p,listen:d,destroy:h}}function An(t,e,s,a=!1,n=!1){return{back:t,current:e,forward:s,replaced:a,position:window.history.length,scroll:n?Ht():null}}function fo(t){const{history:e,location:s}=window,a={value:ds(t,s)},n={value:e.state};n.value||o(a.value,{back:null,current:a.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function o(p,d,u){const h=t.indexOf("#"),g=h>-1?(s.host&&document.querySelector("base")?t:t.slice(h))+p:ho()+t+p;try{e[u?"replaceState":"pushState"](d,"",g),n.value=d}catch(v){console.error(v),s[u?"replace":"assign"](g)}}function f(p,d){const u=U({},e.state,An(n.value.back,p,n.value.forward,!0),d,{position:n.value.position});o(p,u,!0),a.value=p}function m(p,d){const u=U({},n.value,e.state,{forward:p,scroll:Ht()});o(u.current,u,!0);const h=U({},An(a.value,p,null),{position:u.position+1},d);o(p,h,!1),a.value=p}return{location:a,state:n,push:m,replace:f}}function po(t){t=oo(t);const e=fo(t),s=mo(t,e.state,e.location,e.replace);function a(o,f=!0){f||s.pauseListeners(),history.go(o)}const n=U({location:"",base:t,go:a,createHref:ao.bind(null,t)},e,s);return Object.defineProperty(n,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(n,"state",{enumerable:!0,get:()=>e.state.value}),n}function _o(t){return t=location.host?t||location.pathname+location.search:"",t.includes("#")||(t+="#"),po(t)}function go(t){return typeof t=="string"||t&&typeof t=="object"}function us(t){return typeof t=="string"||typeof t=="symbol"}const hs=Symbol("");var Sn;(function(t){t[t.aborted=4]="aborted",t[t.cancelled=8]="cancelled",t[t.duplicated=16]="duplicated"})(Sn||(Sn={}));function nt(t,e){return U(new Error,{type:t,[hs]:!0},e)}function Me(t,e){return t instanceof Error&&hs in t&&(e==null||!!(t.type&e))}const Pn="[^/]+?",vo={sensitive:!1,strict:!1,start:!0,end:!0},yo=/[.+*?^${}()[\]/\\]/g;function bo(t,e){const s=U({},vo,e),a=[];let n=s.start?"^":"";const o=[];for(const d of t){const u=d.length?[]:[90];s.strict&&!d.length&&(n+="/");for(let h=0;h<d.length;h++){const g=d[h];let v=40+(s.sensitive?.25:0);if(g.type===0)h||(n+="/"),n+=g.value.replace(yo,"\\$&"),v+=40;else if(g.type===1){const{value:C,repeatable:E,optional:R,regexp:F}=g;o.push({name:C,repeatable:E,optional:R});const D=F||Pn;if(D!==Pn){v+=10;try{new RegExp(`(${D})`)}catch(z){throw new Error(`Invalid custom RegExp for param "${C}" (${D}): `+z.message)}}let q=E?`((?:${D})(?:/(?:${D}))*)`:`(${D})`;h||(q=R&&d.length<2?`(?:/${q})`:"/"+q),R&&(q+="?"),n+=q,v+=20,R&&(v+=-8),E&&(v+=-20),D===".*"&&(v+=-50)}u.push(v)}a.push(u)}if(s.strict&&s.end){const d=a.length-1;a[d][a[d].length-1]+=.7000000000000001}s.strict||(n+="/?"),s.end?n+="$":s.strict&&(n+="(?:/|$)");const f=new RegExp(n,s.sensitive?"":"i");function m(d){const u=d.match(f),h={};if(!u)return null;for(let g=1;g<u.length;g++){const v=u[g]||"",C=o[g-1];h[C.name]=v&&C.repeatable?v.split("/"):v}return h}function p(d){let u="",h=!1;for(const g of t){(!h||!u.endsWith("/"))&&(u+="/"),h=!1;for(const v of g)if(v.type===0)u+=v.value;else if(v.type===1){const{value:C,repeatable:E,optional:R}=v,F=C in d?d[C]:"";if(Ie(F)&&!E)throw new Error(`Provided param "${C}" is an array but it is not repeatable (* or + modifiers)`);const D=Ie(F)?F.join("/"):F;if(!D)if(R)g.length<2&&(u.endsWith("/")?u=u.slice(0,-1):h=!0);else throw new Error(`Missing required param "${C}"`);u+=D}}return u||"/"}return{re:f,score:a,keys:o,parse:m,stringify:p}}function wo(t,e){let s=0;for(;s<t.length&&s<e.length;){const a=e[s]-t[s];if(a)return a;s++}return t.length<e.length?t.length===1&&t[0]===40+40?-1:1:t.length>e.length?e.length===1&&e[0]===40+40?1:-1:0}function ms(t,e){let s=0;const a=t.score,n=e.score;for(;s<a.length&&s<n.length;){const o=wo(a[s],n[s]);if(o)return o;s++}if(Math.abs(n.length-a.length)===1){if(Dn(a))return 1;if(Dn(n))return-1}return n.length-a.length}function Dn(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const xo={type:0,value:""},Co=/[a-zA-Z0-9_]/;function Io(t){if(!t)return[[]];if(t==="/")return[[xo]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(v){throw new Error(`ERR (${s})/"${d}": ${v}`)}let s=0,a=s;const n=[];let o;function f(){o&&n.push(o),o=[]}let m=0,p,d="",u="";function h(){!d||(s===0?o.push({type:0,value:d}):s===1||s===2||s===3?(o.length>1&&(p==="*"||p==="+")&&e(`A repeatable param (${d}) must be alone in its segment. eg: '/:ids+.`),o.push({type:1,value:d,regexp:u,repeatable:p==="*"||p==="+",optional:p==="*"||p==="?"})):e("Invalid state to consume buffer"),d="")}function g(){d+=p}for(;m<t.length;){if(p=t[m++],p==="\\"&&s!==2){a=s,s=4;continue}switch(s){case 0:p==="/"?(d&&h(),f()):p===":"?(h(),s=1):g();break;case 4:g(),s=a;break;case 1:p==="("?s=2:Co.test(p)?g():(h(),s=0,p!=="*"&&p!=="?"&&p!=="+"&&m--);break;case 2:p===")"?u[u.length-1]=="\\"?u=u.slice(0,-1)+p:s=3:u+=p;break;case 3:h(),s=0,p!=="*"&&p!=="?"&&p!=="+"&&m--,u="";break;default:e("Unknown state");break}}return s===2&&e(`Unfinished custom RegExp for param "${d}"`),h(),f(),n}function Eo(t,e,s){const a=bo(Io(t.path),s),n=U(a,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function ko(t,e){const s=[],a=new Map;e=qn({strict:!1,end:!0,sensitive:!1},e);function n(h){return a.get(h)}function o(h,g,v){const C=!v,E=To(h);E.aliasOf=v&&v.record;const R=qn(e,h),F=[E];if("alias"in h){const z=typeof h.alias=="string"?[h.alias]:h.alias;for(const ce of z)F.push(U({},E,{components:v?v.record.components:E.components,path:ce,aliasOf:v?v.record:E}))}let D,q;for(const z of F){const{path:ce}=z;if(g&&ce[0]!=="/"){const ne=g.record.path,Z=ne[ne.length-1]==="/"?"":"/";z.path=g.record.path+(ce&&Z+ce)}if(D=Eo(z,g,R),v?v.alias.push(D):(q=q||D,q!==D&&q.alias.push(D),C&&h.name&&!jn(D)&&f(h.name)),fs(D)&&p(D),E.children){const ne=E.children;for(let Z=0;Z<ne.length;Z++)o(ne[Z],D,v&&v.children[Z])}v=v||D}return q?()=>{f(q)}:ht}function f(h){if(us(h)){const g=a.get(h);g&&(a.delete(h),s.splice(s.indexOf(g),1),g.children.forEach(f),g.alias.forEach(f))}else{const g=s.indexOf(h);g>-1&&(s.splice(g,1),h.record.name&&a.delete(h.record.name),h.children.forEach(f),h.alias.forEach(f))}}function m(){return s}function p(h){const g=Po(h,s);s.splice(g,0,h),h.record.name&&!jn(h)&&a.set(h.record.name,h)}function d(h,g){let v,C={},E,R;if("name"in h&&h.name){if(v=a.get(h.name),!v)throw nt(1,{location:h});R=v.record.name,C=U(Mn(g.params,v.keys.filter(q=>!q.optional).concat(v.parent?v.parent.keys.filter(q=>q.optional):[]).map(q=>q.name)),h.params&&Mn(h.params,v.keys.map(q=>q.name))),E=v.stringify(C)}else if(h.path!=null)E=h.path,v=s.find(q=>q.re.test(E)),v&&(C=v.parse(E),R=v.record.name);else{if(v=g.name?a.get(g.name):s.find(q=>q.re.test(g.path)),!v)throw nt(1,{location:h,currentLocation:g});R=v.record.name,C=U({},g.params,h.params),E=v.stringify(C)}const F=[];let D=v;for(;D;)F.unshift(D.record),D=D.parent;return{name:R,path:E,params:C,matched:F,meta:So(F)}}t.forEach(h=>o(h));function u(){s.length=0,a.clear()}return{addRoute:o,resolve:d,removeRoute:f,clearRoutes:u,getRoutes:m,getRecordMatcher:n}}function Mn(t,e){const s={};for(const a of e)a in t&&(s[a]=t[a]);return s}function To(t){return{path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:void 0,beforeEnter:t.beforeEnter,props:Ao(t),children:t.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in t?t.components||null:t.component&&{default:t.component}}}function Ao(t){const e={},s=t.props||!1;if("component"in t)e.default=s;else for(const a in t.components)e[a]=typeof s=="object"?s[a]:s;return e}function jn(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function So(t){return t.reduce((e,s)=>U(e,s.meta),{})}function qn(t,e){const s={};for(const a in t)s[a]=a in e?e[a]:t[a];return s}function Po(t,e){let s=0,a=e.length;for(;s!==a;){const o=s+a>>1;ms(t,e[o])<0?a=o:s=o+1}const n=Do(t);return n&&(a=e.lastIndexOf(n,a-1)),a}function Do(t){let e=t;for(;e=e.parent;)if(fs(e)&&ms(t,e)===0)return e}function fs({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function Mo(t){const e={};if(t===""||t==="?")return e;const a=(t[0]==="?"?t.slice(1):t).split("&");for(let n=0;n<a.length;++n){const o=a[n].replace(is," "),f=o.indexOf("="),m=bt(f<0?o:o.slice(0,f)),p=f<0?null:bt(o.slice(f+1));if(m in e){let d=e[m];Ie(d)||(d=e[m]=[d]),d.push(p)}else e[m]=p}return e}function On(t){let e="";for(let s in t){const a=t[s];if(s=Ys(s),a==null){a!==void 0&&(e+=(e.length?"&":"")+s);continue}(Ie(a)?a.map(o=>o&&un(o)):[a&&un(a)]).forEach(o=>{o!==void 0&&(e+=(e.length?"&":"")+s,o!=null&&(e+="="+o))})}return e}function jo(t){const e={};for(const s in t){const a=t[s];a!==void 0&&(e[s]=Ie(a)?a.map(n=>n==null?null:""+n):a==null?a:""+a)}return e}const qo=Symbol(""),Rn=Symbol(""),yn=Symbol(""),ps=Symbol(""),mn=Symbol("");function lt(){let t=[];function e(a){return t.push(a),()=>{const n=t.indexOf(a);n>-1&&t.splice(n,1)}}function s(){t=[]}return{add:e,list:()=>t.slice(),reset:s}}function Be(t,e,s,a,n,o=f=>f()){const f=a&&(a.enterCallbacks[n]=a.enterCallbacks[n]||[]);return()=>new Promise((m,p)=>{const d=g=>{g===!1?p(nt(4,{from:s,to:e})):g instanceof Error?p(g):go(g)?p(nt(2,{from:e,to:g})):(f&&a.enterCallbacks[n]===f&&typeof g=="function"&&f.push(g),m())},u=o(()=>t.call(a&&a.instances[n],e,s,d));let h=Promise.resolve(u);t.length<3&&(h=h.then(d)),h.catch(g=>p(g))})}function en(t,e,s,a,n=o=>o()){const o=[];for(const f of t)for(const m in f.components){let p=f.components[m];if(!(e!=="beforeRouteEnter"&&!f.instances[m]))if(Oo(p)){const u=(p.__vccOpts||p)[e];u&&o.push(Be(u,s,a,f,m,n))}else{let d=p();o.push(()=>d.then(u=>{if(!u)return Promise.reject(new Error(`Couldn't resolve component "${m}" at "${f.path}"`));const h=Ns(u)?u.default:u;f.components[m]=h;const v=(h.__vccOpts||h)[e];return v&&Be(v,s,a,f,m,n)()}))}}return o}function Oo(t){return typeof t=="object"||"displayName"in t||"props"in t||"__vccOpts"in t}function Vn(t){const e=yt(yn),s=yt(ps),a=Ee(()=>{const p=ut(t.to);return e.resolve(p)}),n=Ee(()=>{const{matched:p}=a.value,{length:d}=p,u=p[d-1],h=s.matched;if(!u||!h.length)return-1;const g=h.findIndex(tt.bind(null,u));if(g>-1)return g;const v=Nn(p[d-2]);return d>1&&Nn(u)===v&&h[h.length-1].path!==v?h.findIndex(tt.bind(null,p[d-2])):g}),o=Ee(()=>n.value>-1&&Bo(s.params,a.value.params)),f=Ee(()=>n.value>-1&&n.value===s.matched.length-1&&cs(s.params,a.value.params));function m(p={}){return No(p)?e[ut(t.replace)?"replace":"push"](ut(t.to)).catch(ht):Promise.resolve()}return{route:a,href:Ee(()=>a.value.href),isActive:o,isExactActive:f,navigate:m}}const Ro=Jn({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:Vn,setup(t,{slots:e}){const s=qs(Vn(t)),{options:a}=yt(yn),n=Ee(()=>({[Bn(t.activeClass,a.linkActiveClass,"router-link-active")]:s.isActive,[Bn(t.exactActiveClass,a.linkExactActiveClass,"router-link-exact-active")]:s.isExactActive}));return()=>{const o=e.default&&e.default(s);return t.custom?o:Kn("a",{"aria-current":s.isExactActive?t.ariaCurrentValue:null,href:s.href,onClick:s.navigate,class:n.value},o)}}}),Vo=Ro;function No(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function Bo(t,e){for(const s in e){const a=e[s],n=t[s];if(typeof a=="string"){if(a!==n)return!1}else if(!Ie(n)||n.length!==a.length||a.some((o,f)=>o!==n[f]))return!1}return!0}function Nn(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const Bn=(t,e,s)=>t!=null?t:e!=null?e:s,Fo=Jn({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:s}){const a=yt(mn),n=Ee(()=>t.route||a.value),o=yt(Rn,0),f=Ee(()=>{let d=ut(o);const{matched:u}=n.value;let h;for(;(h=u[d])&&!h.components;)d++;return d}),m=Ee(()=>n.value.matched[f.value]);Kt(Rn,Ee(()=>f.value+1)),Kt(qo,m),Kt(mn,n);const p=Os();return Rs(()=>[p.value,m.value,t.name],([d,u,h],[g,v,C])=>{u&&(u.instances[h]=d,v&&v!==u&&d&&d===g&&(u.leaveGuards.size||(u.leaveGuards=v.leaveGuards),u.updateGuards.size||(u.updateGuards=v.updateGuards))),d&&u&&(!v||!tt(u,v)||!g)&&(u.enterCallbacks[h]||[]).forEach(E=>E(d))},{flush:"post"}),()=>{const d=n.value,u=t.name,h=m.value,g=h&&h.components[u];if(!g)return Fn(s.default,{Component:g,route:d});const v=h.props[u],C=v?v===!0?d.params:typeof v=="function"?v(d):v:null,R=Kn(g,U({},C,e,{onVnodeUnmounted:F=>{F.component.isUnmounted&&(h.instances[u]=null)},ref:p}));return Fn(s.default,{Component:R,route:d})||R}}});function Fn(t,e){if(!t)return null;const s=t(e);return s.length===1?s[0]:s}const Wo=Fo;function Qo(t){const e=ko(t.routes,t),s=t.parseQuery||Mo,a=t.stringifyQuery||On,n=t.history,o=lt(),f=lt(),m=lt(),p=Ds(Ne);let d=Ne;Ke&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Zt.bind(null,y=>""+y),h=Zt.bind(null,Ks),g=Zt.bind(null,bt);function v(y,I){let x,T;return us(y)?(x=e.getRecordMatcher(y),T=I):T=y,e.addRoute(T,x)}function C(y){const I=e.getRecordMatcher(y);I&&e.removeRoute(I)}function E(){return e.getRoutes().map(y=>y.record)}function R(y){return!!e.getRecordMatcher(y)}function F(y,I){if(I=U({},I||p.value),typeof y=="string"){const O=$t(s,y,I.path),se=e.resolve({path:O.path},I),at=n.createHref(O.fullPath);return U(O,se,{params:g(se.params),hash:bt(O.hash),redirectedFrom:void 0,href:at})}let x;if(y.path!=null)x=U({},y,{path:$t(s,y.path,I.path).path});else{const O=U({},y.params);for(const se in O)O[se]==null&&delete O[se];x=U({},y,{params:h(O)}),I.params=h(I.params)}const T=e.resolve(x,I),L=y.hash||"";T.params=u(g(T.params));const $=eo(a,U({},y,{hash:Gs(L),path:T.path})),V=n.createHref($);return U({fullPath:$,hash:L,query:a===On?jo(y.query):y.query||{}},T,{redirectedFrom:void 0,href:V})}function D(y){return typeof y=="string"?$t(s,y,p.value.path):U({},y)}function q(y,I){if(d!==y)return nt(8,{from:I,to:y})}function z(y){return Z(y)}function ce(y){return z(U(D(y),{replace:!0}))}function ne(y){const I=y.matched[y.matched.length-1];if(I&&I.redirect){const{redirect:x}=I;let T=typeof x=="function"?x(y):x;return typeof T=="string"&&(T=T.includes("?")||T.includes("#")?T=D(T):{path:T},T.params={}),U({query:y.query,hash:y.hash,params:T.path!=null?{}:y.params},T)}}function Z(y,I){const x=d=F(y),T=p.value,L=y.state,$=y.force,V=y.replace===!0,O=ne(x);if(O)return Z(U(D(O),{state:typeof O=="object"?U({},L,O.state):L,force:$,replace:V}),I||x);const se=x;se.redirectedFrom=I;let at;return!$&&to(a,T,x)&&(at=nt(16,{to:se,from:T}),ot(T,T,!0,!1)),(at?Promise.resolve(at):Re(se,T)).catch(me=>Me(me)?Me(me,2)?me:Tt(me):De(me,se,T)).then(me=>{if(me){if(Me(me,2))return Z(U({replace:V},D(me.to),{state:typeof me.to=="object"?U({},L,me.to.state):L,force:$}),I||se)}else me=Ve(se,T,!0,V,L);return be(se,T,me),me})}function Ue(y,I){const x=q(y,I);return x?Promise.reject(x):Promise.resolve()}function ie(y){const I=At.values().next().value;return I&&typeof I.runWithContext=="function"?I.runWithContext(y):y()}function Re(y,I){let x;const[T,L,$]=Xo(y,I);x=en(T.reverse(),"beforeRouteLeave",y,I);for(const O of T)O.leaveGuards.forEach(se=>{x.push(Be(se,y,I))});const V=Ue.bind(null,y,I);return x.push(V),Ge(x).then(()=>{x=[];for(const O of o.list())x.push(Be(O,y,I));return x.push(V),Ge(x)}).then(()=>{x=en(L,"beforeRouteUpdate",y,I);for(const O of L)O.updateGuards.forEach(se=>{x.push(Be(se,y,I))});return x.push(V),Ge(x)}).then(()=>{x=[];for(const O of $)if(O.beforeEnter)if(Ie(O.beforeEnter))for(const se of O.beforeEnter)x.push(Be(se,y,I));else x.push(Be(O.beforeEnter,y,I));return x.push(V),Ge(x)}).then(()=>(y.matched.forEach(O=>O.enterCallbacks={}),x=en($,"beforeRouteEnter",y,I,ie),x.push(V),Ge(x))).then(()=>{x=[];for(const O of f.list())x.push(Be(O,y,I));return x.push(V),Ge(x)}).catch(O=>Me(O,8)?O:Promise.reject(O))}function be(y,I,x){m.list().forEach(T=>ie(()=>T(y,I,x)))}function Ve(y,I,x,T,L){const $=q(y,I);if($)return $;const V=I===Ne,O=Ke?history.state:{};x&&(T||V?n.replace(y.fullPath,U({scroll:V&&O&&O.scroll},L)):n.push(y.fullPath,L)),p.value=y,ot(y,I,x,V),Tt()}let de;function Ae(){de||(de=n.listen((y,I,x)=>{if(!In.listening)return;const T=F(y),L=ne(T);if(L){Z(U(L,{replace:!0}),T).catch(ht);return}d=T;const $=p.value;Ke&&co(Tn($.fullPath,x.delta),Ht()),Re(T,$).catch(V=>Me(V,12)?V:Me(V,2)?(Z(V.to,T).then(O=>{Me(O,20)&&!x.delta&&x.type===wt.pop&&n.go(-1,!1)}).catch(ht),Promise.reject()):(x.delta&&n.go(-x.delta,!1),De(V,T,$))).then(V=>{V=V||Ve(T,$,!1),V&&(x.delta&&!Me(V,8)?n.go(-x.delta,!1):x.type===wt.pop&&Me(V,20)&&n.go(-1,!1)),be(T,$,V)}).catch(ht)}))}let Se=lt(),we=lt(),Pe;function De(y,I,x){Tt(y);const T=we.list();return T.length?T.forEach(L=>L(y,I,x)):console.error(y),Promise.reject(y)}function Yt(){return Pe&&p.value!==Ne?Promise.resolve():new Promise((y,I)=>{Se.add([y,I])})}function Tt(y){return Pe||(Pe=!y,Ae(),Se.list().forEach(([I,x])=>y?x(y):I()),Se.reset()),y}function ot(y,I,x,T){const{scrollBehavior:L}=t;if(!Ke||!L)return Promise.resolve();const $=!x&&uo(Tn(y.fullPath,0))||(T||!x)&&history.state&&history.state.scroll||null;return js().then(()=>L(y,I,$)).then(V=>V&&ro(V)).catch(V=>De(V,y,I))}const it=y=>n.go(y);let Jt;const At=new Set,In={currentRoute:p,listening:!0,addRoute:v,removeRoute:C,clearRoutes:e.clearRoutes,hasRoute:R,getRoutes:E,resolve:F,options:t,push:z,replace:ce,go:it,back:()=>it(-1),forward:()=>it(1),beforeEach:o.add,beforeResolve:f.add,afterEach:m.add,onError:we.add,isReady:Yt,install(y){const I=this;y.component("RouterLink",Vo),y.component("RouterView",Wo),y.config.globalProperties.$router=I,Object.defineProperty(y.config.globalProperties,"$route",{enumerable:!0,get:()=>ut(p)}),Ke&&!Jt&&p.value===Ne&&(Jt=!0,z(n.location).catch(L=>{}));const x={};for(const L in Ne)Object.defineProperty(x,L,{get:()=>p.value[L],enumerable:!0});y.provide(yn,I),y.provide(ps,Ms(x)),y.provide(mn,p);const T=y.unmount;At.add(y),y.unmount=function(){At.delete(y),At.size<1&&(d=Ne,de&&de(),de=null,p.value=Ne,Jt=!1,Pe=!1),T()}}};function Ge(y){return y.reduce((I,x)=>I.then(()=>ie(x)),Promise.resolve())}return In}function Xo(t,e){const s=[],a=[],n=[],o=Math.max(e.matched.length,t.matched.length);for(let f=0;f<o;f++){const m=e.matched[f];m&&(t.matched.find(d=>tt(d,m))?a.push(m):s.push(m));const p=t.matched[f];p&&(e.matched.find(d=>tt(d,p))||n.push(p))}return[s,a,n]}const Uo={name:"QuoteEdit",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{quote:{quote_number:"",due_date:"",provisional_start_date:"",client_id:"",client:null,status:""},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchQuoteDetails()},methods:{cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.quote.client_id&&this.setClientById(this.quote.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchQuoteDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?(this.quote=e,this.setClientById(this.quote.client_id)):(console.error("Error fetching quote details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching quote details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.quote.client=this.clients.find(e=>e.id===t)||null,this.quote.client_id=t},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting quote:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Lo={class:"pt-2 pr-4"},zo={class:"flex justify-between items-center mb-4"},Ho={class:"card-title"},Go=i("div",{class:"divider mt-2"},null,-1),Yo={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Jo={class:"grid grid-cols-3 gap-4"},Ko={class:"ecwp-group form-group mb-4"},Zo={for:"quoteNumber",class:"ecwp-label"},$o={class:"ecwp-group form-group mb-4"},ei={for:"quoteDate",class:"ecwp-label"},ti={class:"ecwp-group form-group mb-4"},ni={for:"quoteProvisanalDate",class:"ecwp-label"},si={class:"grid grid-cols-2 gap-4"},oi={class:"ecwp-group form-group mb-4"},ii={for:"client",class:"ecwp-label"},ai={class:"ecwp-group form-group mb-4"},li={for:"status",class:"ecwp-label"},ri={value:"draft"},ci={value:"pending"},di={value:"approved"},ui={value:"rejected"},hi={class:"flex justify-between"},mi=["disabled"],fi={key:0,class:"loading loading-spinner loading-sm"};function pi(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",Lo,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),P(p,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:re(()=>[i("div",zo,[i("h2",Ho,l(o.translations.edit_quote),1)]),Go,n.loading?(r(),c("div",Yo)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitQuote&&o.submitQuote(...d),["prevent"]))},[i("div",Jo,[i("div",Ko,[i("label",Zo,l(o.translations.quote_number),1),B(i("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.quote.quote_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[J,n.quote.quote_number]])]),i("div",$o,[i("label",ei,l(o.translations.due_date),1),P(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.quote.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])]),i("div",ti,[i("label",ni,l(o.translations.provisional_date),1),P(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteProvisanalDate",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=d=>n.quote.provisional_start_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])])]),i("div",si,[i("div",oi,[i("label",ii,l(o.translations.company_name),1),P(m,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[3]||(e[3]=d=>n.quote.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",ai,[i("label",li,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=d=>n.quote.status=d),required:"",class:k(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[i("option",ri,l(o.translations.draft),1),i("option",ci,l(o.translations.pending),1),i("option",di,l(o.translations.approved),1),i("option",ui,l(o.translations.rejected),1)],2),[[ye,n.quote.status]])])]),i("div",hi,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",fi)):_("",!0)],8,mi)])],32)]),_:1})])}var _s=oe(Uo,[["render",pi]]);const _i={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm"),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm").close()}}},gi=["open"],vi={class:"modal-box"},yi={class:"font-bold text-lg"},bi=i("div",{class:"text-center text-red-400 mb-2"},[i("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),wi={class:"text-lg font-semibold text-center"},xi={class:"my-4 text-center text-xl"},Ci={class:"flex justify-between space-x-4"};function Ii(t,e,s,a,n,o){return r(),c("div",null,[i("dialog",{id:"modal_confirm",class:"modal",open:t.showModal},[i("div",vi,[i("h3",yi,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...f)=>o.closeModal&&o.closeModal(...f))}," \u2715 "),bi,i("h2",wi,l(s.title),1),i("p",xi,l(s.message),1),i("div",Ci,[i("button",{onClick:e[1]||(e[1]=(...f)=>o.onCancel&&o.onCancel(...f)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[2]||(e[2]=(...f)=>o.onConfirm&&o.onConfirm(...f)),class:"btn rounded-full btn-error text-white"},l(s.confirmText),1)])])],8,gi)])}var bn=oe(_i,[["render",Ii]]);const Ei={name:"QuotesList",components:{Card:Xe,QuoteEditModal:_s,ConfirmModal:bn,RemoveModal:xt},data(){return{quotes:[],showQuoteDetailsModal:!1,editQuoteModal:!1,selectedQuote:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchQuotes(),this.loadSettings()},methods:{fetchQuotes(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/quotes?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.quotes=s.quotes,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching quotes:",s)}).finally(()=>{this.loading=!1})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return $n(t,this.default_vat.rate)},calculateWithoutVAT(t){return es(t)},generatePaginationButtons(){this.paginationButtons=ts(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchQuotes(t)},perPageChanged(){this.fetchQuotes()},formatAmount(t,e){return ns(t,e,this.settings.currency_position)},confirmDuplicateQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},duplicateQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/duplicate/${t}`,{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotes(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error duplicate quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},confirmDeleteQuote(t){this.selectedQuote=t,modal_remove.showModal(),this.showRemoveModal=!0},deleteQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotes(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},showToast(t,e){ss(this.toast,t,e)}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},ki={class:"pt-2 pr-4"},Ti={class:"flex justify-between items-center"},Ai={class:"card-title"},Si={class:"btn btn-primary rounded-full"},Pi=i("i",{class:"fas fa-plus-circle"},null,-1),Di={key:0,class:"ms-2"},Mi={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab2"},ji=i("i",{class:"fas fa-file-export"},null,-1),qi=["data-tip"],Oi={class:"btn btn-outline btn-accent rounded-full",disabled:""},Ri=i("i",{class:"fas fa-file-export"},null,-1),Vi=i("div",{class:"divider mt-2"},null,-1),Ni={class:"flex items-center mb-4"},Bi={for:"perPageSelect",class:"mr-2"},Fi=["value"],Wi={class:"overflow-x-auto"},Qi={key:0,class:"table w-full"},Xi={class:"flex justify-center"},Ui={key:0,class:"badge badge-warning badge-outline badge-sm"},Li={key:1,class:"badge badge-secondary badge-outline badge-sm"},zi={key:2,class:"badge badge-success badge-outline badge-sm"},Hi={key:3,class:"badge badge-error badge-outline badge-sm"},Gi={key:0},Yi={key:0},Ji={key:0},Ki={key:1},Zi={key:1},$i={key:0},ea={key:1},ta={key:1},na=i("span",{class:"loading loading-bars loading-sm"},null,-1),sa=[na],oa={key:0},ia={key:1},aa=i("span",{class:"loading loading-bars loading-sm"},null,-1),la=[aa],ra={key:0},ca={key:1},da=i("span",{class:"loading loading-bars loading-sm"},null,-1),ua=[da],ha={class:"flex justify-end"},ma=["data-tip"],fa=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"far fa-eye"})],-1),pa=["data-tip"],_a=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"fas fa-pencil-alt"})],-1),ga=["data-tip"],va=["onClick"],ya=i("i",{class:"far fa-copy"},null,-1),ba=[ya],wa=["data-tip"],xa=["onClick"],Ca=i("i",{class:"far fa-trash-alt"},null,-1),Ia=[Ca],Ea={key:1},ka=i("div",{class:"flex gap-4 items-center"},[i("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),i("div",{class:"flex flex-col gap-4 w-full"},[i("div",{class:"skeleton h-4 w-full"}),i("div",{class:"skeleton h-4 w-full"})])],-1),Ta=i("div",{class:"divider my-1"},null,-1),Aa=[ka,Ta],Sa={class:"join ecwp_pagination mt-6 pt-4"},Pa=["onClick"];function Da(t,e,s,a,n,o){const f=j("confirm-modal"),m=j("remove-modal"),p=j("router-link"),d=j("Card");return r(),c("div",ki,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),P(f,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=u=>this.duplicateQuote(n.selectedQuote)),onCancel:e[1]||(e[1]=u=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(m,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[2]||(e[2]=u=>this.deleteQuote(n.selectedQuote)),onCancel:e[3]||(e[3]=u=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(d,{topMargin:"mt-8"},{default:re(()=>[i("div",Ti,[i("h2",Ai,l(o.translations.quotes),1),i("div",null,[P(p,{to:{name:"QuoteNew"}},{default:re(()=>[i("button",Si,[w(l(o.translations.add)+" ",1),Pi])]),_:1}),n.settings.easy_compta_export_addon_active==1?(r(),c("span",Di,[i("a",Mi,[w(l(o.translations.export)+" ",1),ji])])):(r(),c("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[i("button",Oi,[w(l(o.translations.export)+" ",1),Ri])],8,qi))])]),Vi,i("div",Ni,[i("label",Bi,l(o.translations.display_per_page),1),B(i("select",{id:"perPageSelect","onUpdate:modelValue":e[4]||(e[4]=u=>n.perPage=u),onChange:e[5]||(e[5]=(...u)=>o.perPageChanged&&o.perPageChanged(...u))},[(r(!0),c(W,null,X(n.perPageOptions,u=>(r(),c("option",{key:u,value:u},l(u),9,Fi))),128))],544),[[ye,n.perPage]])]),i("div",Wi,[n.loading?(r(),c("div",Ea,[(r(!0),c(W,null,X(n.skeletonRows,u=>(r(),c("div",{key:u,class:"flex flex-col gap-4 w-full"},Aa))),128))])):(r(),c("table",Qi,[i("thead",null,[i("tr",null,[i("th",null,l(o.translations.quote_number),1),i("th",null,l(o.translations.client),1),i("th",null,l(o.translations.status),1),i("th",null,l(o.translations.total),1),i("th",null,l(o.translations.due_date),1),i("th",null,l(o.translations.created_at),1),i("th",Xi,l(o.translations.actions),1)])]),i("tbody",null,[(r(!0),c(W,null,X(n.quotes,u=>(r(),c("tr",{key:u.id},[i("td",null,l(u.quote_number),1),i("td",null,l(u.client_name),1),i("td",null,[u.status=="draft"?(r(),c("span",Ui,l(o.translations.draft),1)):_("",!0),u.status=="pending"?(r(),c("span",Li,l(o.translations.pending),1)):_("",!0),u.status=="approved"?(r(),c("span",zi,l(o.translations.approved),1)):_("",!0),u.status=="rejected"?(r(),c("span",Hi,l(o.translations.rejected),1)):_("",!0)]),i("td",null,[n.loadingPrice?(r(),c("div",ta,sa)):(r(),c("div",Gi,[n.settings.vat_active==1?(r(),c("div",Yi,[n.default_currency_symbol==u.client_currency||u.client_currency==null?(r(),c("span",Ji,l(o.formatAmount(u.total_amount,n.default_currency_symbol)),1)):(r(),c("span",Ki,l(o.formatAmount(u.total_amount,u.client_currency)),1))])):(r(),c("div",Zi,[n.default_currency_symbol==u.client_currency||u.client_currency==null?(r(),c("span",$i,l(o.formatAmount(u.total_amount,n.default_currency_symbol)),1)):(r(),c("span",ea,l(o.formatAmount(u.total_amount,u.client_currency)),1))]))]))]),i("td",null,[n.loadingPrice?(r(),c("div",ia,la)):(r(),c("div",oa,l(u.due_date),1))]),i("td",null,[n.loadingPrice?(r(),c("div",ca,ua)):(r(),c("div",ra,l(u.created),1))]),i("td",ha,[i("span",{class:"lg:tooltip","data-tip":o.translations.view},[P(p,{to:{name:"QuoteViewDetail",params:{id:u.id}}},{default:re(()=>[fa]),_:2},1032,["to"])],8,ma),i("span",{class:"lg:tooltip","data-tip":o.translations.edit},[P(p,{to:{name:"QuoteEdit",params:{id:u.id}}},{default:re(()=>[_a]),_:2},1032,["to"])],8,pa),i("span",{class:"lg:tooltip","data-tip":o.translations.duplicate},[i("button",{onClick:h=>o.confirmDuplicateQuote(u.id),class:"btn btn-circle text-purple-600 hover:text-purple-900 mx-1"},ba,8,va)],8,ga),i("span",{class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:h=>o.confirmDeleteQuote(u.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Ia,8,xa)],8,wa)])]))),128))])]))]),i("div",Sa,[(r(!0),c(W,null,X(n.paginationButtons,u=>(r(),c("button",{key:u,class:k(["join-item btn",{"btn-disabled":u==="..."||u===n.currentPage}]),onClick:h=>o.goToPage(u)},l(u),11,Pa))),128))])]),_:1})])}var Ma=oe(Ei,[["render",Da]]);const ja={name:"sendQuote",components:{VueEditor:It.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,quoteId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"quote",id:this.quoteId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},qa=["id","open"],Oa={class:"modal-box"},Ra={class:"font-bold text-lg"},Va={key:0},Na={class:"grid grid-cols-1 gap-4"},Ba=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Fa=i("div",{class:"skeleton h-4 w-full"},null,-1),Wa=[Ba,Fa],Qa={class:"grid grid-cols-1 gap-4"},Xa=["type"],Ua=["for"],La=["id","value","disabled","onInput"],za={key:1},Ha=["for"],Ga={class:"form-group mt-4 flex justify-end"},Ya=["disabled"],Ja={key:0,class:"loading loading-spinner loading-sm"};function Ka(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",Oa,[i("h3",Ra,l(o.translations.send_quote),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",Va,[i("div",Na,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},Wa))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",Qa,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,Ua),i("input",{id:p,class:k(["ecwp-input input input-bordered",m.class||"w-full"]),value:m.value,disabled:m.disabled,onInput:d=>o.updateFieldValue(p,d.target.value)},null,42,La)],8,Xa)):(r(),c("div",za,[i("label",{for:p,class:"form-label"},l(m.label),9,Ha),P(f,{modelValue:m.value,"onUpdate:modelValue":d=>m.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",Ga,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.send)+" ",1),n.loadingBtn?(r(),c("span",Ja)):_("",!0)],8,Ya)])],32))])],8,qa)])}var Za=oe(ja,[["render",Ka]]);const $a={components:{VueDatePicker:Ct},props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},totalAmount:{type:String,required:!0},currency:{type:String,required:!0},advanceSold:{type:String,required:!0},quoteId:{type:Number,required:!0}},data(){return{showError:!1,selectedType:"",inputValue:0,due_date:"",invoiceSolded:!1,establishedAdvances:[],loading:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}},remainingAmount(){this.loading=!0;const t=this.establishedAdvances.reduce((e,s)=>{const a=parseFloat(s.advance_amount);return isNaN(a)?(console.error("Erreur: advance_amount n'est pas un nombre valide",s.advance_amount),e):e+a},0);return this.totalAmount-t},inputValueExceeds(){return this.remainingAmount==0?!0:this.selectedType==="percentage"?this.calculatedAmount>this.remainingAmount:this.selectedType==="fixed"?this.inputValue>this.remainingAmount:!1},calculatedAmount(){return this.selectedType==="percentage"?this.inputValue/100*this.remainingAmount:this.inputValue}},created(){this.fetchEstablishedAdvances(this.quoteId)},methods:{fetchEstablishedAdvances(t){const e=`/wp-json/my-easy-compta/v1/advance/${t}`;fetch(e,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.establishedAdvances=s}).catch(s=>{console.error("Error fetching advances:",s)})},onConfirm(){if(!this.inputValueExceeds){if(this.advanceSold=="no_sold"){if(!this.inputValue||!this.due_date||this.advanceSold=="no_sold"&&!this.selectedType){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:this.selectedType,value:this.inputValue,date:this.due_date})}else{if(!this.due_date){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:"fixed",value:this.remainingAmount,date:this.due_date})}this.closeModal()}},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_advance").close()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},el=["open"],tl={class:"modal-box overflow-visible"},nl={class:"font-bold text-lg"},sl={class:"text-lg font-semibold text-center"},ol={class:"my-4 text-center text-xl"},il={key:0,class:"text-red-500 text-sm"},al={class:"grid grid-cols-2 gap-4"},ll={key:0},rl={class:"flex ecwp-group form-group mb-4"},cl=i("label",{for:"advance-type",class:"ecwp-label"},"Type",-1),dl=i("option",{value:"percentage"},"Pourcentage",-1),ul=i("option",{value:"fixed"},"Montant fixe",-1),hl=[dl,ul],ml={key:1},fl={class:"flex ecwp-group form-group mb-4"},pl=i("label",{for:"advance-type",class:"ecwp-label"},"Valeur",-1),_l={class:"absolute items-center border rounded-md right-0 top-6"},gl={class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"},vl={key:0},yl={key:1},bl={key:1,class:"mt-2"},wl={class:"text-sm"},xl={key:2,class:"flex ecwp-group form-group mb-4"},Cl={for:"quoteDate",class:"ecwp-label"},Il={key:3},El={class:"flex justify-between space-x-4 mt-4"},kl=["disabled"];function Tl(t,e,s,a,n,o){const f=j("VueDatePicker");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:"modal_advance",class:"modal",open:s.isVisible},[i("div",tl,[i("h3",nl,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...m)=>o.closeModal&&o.closeModal(...m))}," \u2715 "),i("h2",sl,l(s.title),1),i("p",ol," Montant total restant : "+l(o.remainingAmount)+" "+l(s.currency),1),o.inputValueExceeds&&!n.invoiceSolded?(r(),c("p",il," Le montant s\xE9lectionn\xE9 d\xE9passe le montant total du devis. ")):_("",!0),i("div",al,[s.advanceSold=="no_sold"&&!n.invoiceSolded?(r(),c("div",ll,[i("div",rl,[cl,B(i("select",{"onUpdate:modelValue":e[1]||(e[1]=m=>n.selectedType=m),id:"advance-type",class:k(["ecwp-select ecwp-input input input-bordered w-full",{"input-error":!n.selectedType&&n.showError}])},hl,2),[[ye,n.selectedType]])])])):_("",!0),n.selectedType&&s.advanceSold=="no_sold"&&!n.invoiceSolded?(r(),c("div",ml,[i("div",fl,[pl,B(i("input",{"onUpdate:modelValue":e[2]||(e[2]=m=>n.inputValue=m),type:"text",id:"advance-value",class:k([{"input-error":!n.inputValue&&n.showError},"ecwp-input input input-bordered w-full"])},null,2),[[J,n.inputValue]]),i("div",_l,[i("div",gl,[n.selectedType==="percentage"?(r(),c("span",vl,"%")):(r(),c("span",yl,l(s.currency),1))])])])])):_("",!0)]),n.selectedType==="percentage"&&!o.inputValueExceeds&!n.invoiceSolded?(r(),c("div",bl,[i("p",wl," Montant bas\xE9 sur le pourcentage: "+l(o.calculatedAmount)+" "+l(s.currency),1)])):_("",!0),n.invoiceSolded?_("",!0):(r(),c("div",xl,[i("label",Cl,l(o.translations.due_date),1),P(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.inputValue&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.due_date,"onUpdate:modelValue":e[3]||(e[3]=m=>n.due_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date","class"])])),n.invoiceSolded?(r(),c("div",Il,"Facture d\xE9j\xE0 sold\xE9")):_("",!0),i("div",El,[i("button",{onClick:e[4]||(e[4]=(...m)=>o.onCancel&&o.onCancel(...m)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[5]||(e[5]=(...m)=>o.onConfirm&&o.onConfirm(...m)),disabled:o.inputValueExceeds,class:"btn rounded-full btn-error text-white"},l(s.confirmText),9,kl)])])],8,el)])}var Al=oe($a,[["render",Tl]]);const Sl={name:"QuoteNavBar",components:{SendQuoteModal:Za,ConfirmModal:bn,AdvanceModal:Al},props:{quoteInfo:Object,emailActive:Number,advanceActive:Number,currency:String,noItems:Boolean},data(){return{selectedQuote:null,advanceSold:!1,sendQuoteModal:!1,loadingModal:!1,loadingPdf:!1,loading:!1,client_detail:null,subject:"",content:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async changeQuoteStatus(t){try{const s=await(await fetch("/wp-json/my-easy-compta/v1/quotes/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.quoteInfo.id,status:t})})).json();s.success?(this.quoteInfo.status=t,this.quoteInfo.total_amount=s.total_amount,this.showToast(s.message,"alert-success")):(console.error("Failed to update quote status:",s.message),this.showToast(s.message,"alert-error"))}catch(e){console.error("An error occurred while updating quote status:",e),this.showToast(e,"alert-error")}},convertToInvoice(t){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-quote/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.success?(this.showToast(e.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:e.id}})):this.showToast(e.message,"alert-error")}).catch(e=>{console.error("Error converting quote:",e),this.showToast(e.message,"alert-error")})},handleAdvanceInvoiceConfirm(t){const{type:e,value:s,date:a}=t;this.convertAdvanceInvoice(this.selectedQuote,e,s,a)},convertAdvanceInvoice(t,e,s,a){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-advance/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({advance_type:e,advance_value:s,advance_date:a})}).then(n=>n.json()).then(n=>{n.success?(this.showToast(n.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:n.id}})):this.showToast(n.message,"alert-error")}).catch(n=>{console.error("Error converting quote:",n),this.showToast(n.message,"alert-error")})},confirmConvertQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},ConvertAdvanceQuote(t,e){this.selectedQuote=t,this.advanceSold=e,modal_advance.showModal(),this.showRemoveModal=!0},exportToPDF(){this.loadingPdf=!0;const t=this.quoteInfo.id;fetch(`/wp-json/my-easy-compta/v1/quotes/pdf/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return this.loadingPdf=!1,e.blob()}).then(e=>{const s=URL.createObjectURL(e);window.open(s),this.loadingPdf=!1}).catch(e=>{console.error("There was a problem with the fetch operation:",e),this.loadingPdf=!1})},sendQuote(t){this.loadingModal=!0,this.sendQuoteModal=!0,modal_send_quote.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok){const e=await t.json();this.subject=e.email_quote_subject,this.content=e.email_quote_content,this.loading=!1}else{const e=await t.json();this.showToast(e.message,"alert-error"),this.loading=!1}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Pl={key:0},Dl={key:1},Ml={key:3,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},jl=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),ql=[jl],Ol={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},Rl=i("div",{class:"dropdown"},[i("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),i("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[i("li",null,[i("a",null,"Item 1")]),i("li",null,[i("a",null,"Parent"),i("ul",{class:"p-2"},[i("li",null,[i("a",null,"Submenu 1")]),i("li",null,[i("a",null,"Submenu 2")])])]),i("li",null,[i("a",null,"Item 3")])])],-1),Vl={class:"hidden lg:flex gap-2"},Nl={class:"btn btn-sm"},Bl=i("i",{class:"far fa-edit"},null,-1),Fl=i("i",{class:"fa fa-check"},null,-1),Wl=["data-tip"],Ql={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Xl=i("i",{class:"fas fa-check"},null,-1),Ul=i("i",{class:"fa fa-check"},null,-1),Ll=i("i",{class:"fa fa-times"},null,-1),zl={key:4},Hl={class:"dropdown"},Gl={tabindex:"0",role:"button",class:"btn btn-sm"},Yl=i("i",{class:"fas fa-exchange-alt"},null,-1),Jl={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},Kl={key:0},Zl={key:5},$l=i("i",{class:"fas fa-exchange-alt"},null,-1),er={class:"flex gap-2"},tr=i("i",{class:"fas fa-paper-plane"},null,-1),nr={key:0,class:"far fa-envelope"},sr=["data-tip"],or={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},ir=i("i",{class:"fas fa-paper-plane"},null,-1),ar=["data-tip"],lr={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},rr=i("i",{class:"fas fa-paper-plane"},null,-1),cr=["disabled"],dr=i("i",{class:"far fa-file-pdf"},null,-1),ur={key:0,class:"loading loading-spinner loading-sm"};function hr(t,e,s,a,n,o){const f=j("send-quote-modal"),m=j("confirm-modal"),p=j("advance-modal"),d=j("router-link");return r(),c("div",null,[s.emailActive==1?(r(),c("div",Pl,[P(f,{loading:n.loadingModal,"show-modal":n.sendQuoteModal,"modal-id":"modal_send_quote",client:n.client_detail,"quote-id":s.quoteInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=u=>n.sendQuoteModal=!1)},null,8,["loading","show-modal","client","quote-id","subject","content"])])):_("",!0),P(m,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[1]||(e[1]=u=>this.convertToInvoice(n.selectedQuote)),onCancel:e[2]||(e[2]=u=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.advanceActive==1?(r(),c("div",Dl,[P(p,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,"total-amount":s.quoteInfo.total_amount,currency:s.currency,quoteId:s.quoteInfo.id,"advance-sold":n.advanceSold,onConfirm:o.handleAdvanceInvoiceConfirm,onCancel:e[3]||(e[3]=u=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","total-amount","currency","quoteId","advance-sold","onConfirm"])])):_("",!0),n.toast.visible?(r(),c("div",{key:2,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),n.loading?(r(),c("div",Ml,ql)):_("",!0),i("div",Ol,[i("div",null,[Rl,i("div",Vl,[P(d,{to:{name:"QuoteEdit",params:{id:s.quoteInfo.id}}},{default:re(()=>[i("button",Nl,[Bl,w(l(o.translations.edit_quote),1)])]),_:1},8,["to"]),s.quoteInfo.status=="draft"&&!s.noItems?(r(),c("button",{key:0,class:"btn btn-outline btn-success btn-sm",onClick:e[4]||(e[4]=u=>o.changeQuoteStatus("pending"))},[Fl,w(" "+l(o.translations.validate_quote),1)])):_("",!0),s.quoteInfo.status=="draft"&&s.noItems?(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.min_article},[i("button",Ql,[Xl,w(" "+l(o.translations.validate_quote),1)])],8,Wl)):_("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="rejected")&&!s.noItems?(r(),c("button",{key:2,class:"btn btn-outline btn-success btn-sm",onClick:e[5]||(e[5]=u=>o.changeQuoteStatus("approved"))},[Ul,w(" "+l(o.translations.mark_as_accepted),1)])):_("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="approved")&&!s.noItems?(r(),c("button",{key:3,class:"btn btn-outline btn-error btn-sm",onClick:e[6]||(e[6]=u=>o.changeQuoteStatus("rejected"))},[Ll,w(" "+l(o.translations.mark_as_rejected),1)])):_("",!0),s.advanceActive==1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(r(),c("div",zl,[i("div",Hl,[i("div",Gl,[Yl,w(" "+l(o.translations.convertToInvoice),1)]),i("ul",Jl,[s.quoteInfo.advance!=1?(r(),c("li",Kl,[i("a",{href:"#",onClick:e[7]||(e[7]=K(u=>o.confirmConvertQuote(s.quoteInfo.id),["prevent"]))}," Facture global ")])):_("",!0),i("li",null,[i("a",{href:"#",onClick:e[8]||(e[8]=K(u=>o.ConvertAdvanceQuote(s.quoteInfo.id,"no_sold"),["prevent"]))}," Facture d'acompte "),s.quoteInfo.advance!=0?(r(),c("a",{key:0,href:"#",onClick:e[9]||(e[9]=K(u=>o.ConvertAdvanceQuote(s.quoteInfo.id,"sold"),["prevent"]))}," Facture du solde ")):_("",!0)])])])])):_("",!0),s.advanceActive!=1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(r(),c("div",Zl,[i("button",{onClick:e[10]||(e[10]=u=>o.confirmConvertQuote(s.quoteInfo.id)),class:"btn btn-sm"},[$l,w(" "+l(o.translations.convertToInvoice),1)])])):_("",!0)])]),i("div",er,[s.emailActive==1&&!s.noItems?(r(),c("button",{key:0,onClick:e[11]||(e[11]=K(u=>o.sendQuote(s.quoteInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[tr,w(" "+l(o.translations.send_quote)+" ",1),s.quoteInfo.sent==1?(r(),c("i",nr)):_("",!0)])):s.emailActive==0?(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[i("button",or,[ir,w(" "+l(o.translations.send_quote),1)])],8,sr)):s.emailActive==1&&s.noItems?(r(),c("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.min_article},[i("button",lr,[rr,w(" "+l(o.translations.send_quote),1)])],8,ar)):_("",!0),i("button",{onClick:e[12]||(e[12]=(...u)=>o.exportToPDF&&o.exportToPDF(...u)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[dr,w(" "+l(o.translations.exportToPDF)+" ",1),n.loadingPdf?(r(),c("span",ur)):_("",!0)],8,cr)])])])}var mr=oe(Sl,[["render",hr]]);const fr={components:{VueEditor:It.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:t.item_name},item_description:{label:t.description,type:"textarea"},quantity:{label:t.quantity,type:"number"},vat_rate:{label:"Taux de TVA",type:"number"},unit_price:{label:t.unit_price,type:"number"},discount:{label:t.discount,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/quotes/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},pr=["id","open"],_r={class:"modal-box"},gr={class:"font-bold text-lg"},vr={key:0},yr={class:"grid grid-cols-1 gap-4"},br=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),wr=i("div",{class:"skeleton h-4 w-full"},null,-1),xr=[br,wr],Cr={class:"grid grid-cols-1 gap-4"},Ir=["type"],Er=["for"],kr=["id","onUpdate:modelValue"],Tr={key:1},Ar=["for"],Sr={class:"form-group mt-4 flex justify-end"},Pr=["disabled"],Dr={key:0,class:"loading loading-spinner loading-sm"};function Mr(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",_r,[i("h3",gr,l(s.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",vr,[i("div",yr,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},xr))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",Cr,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,Er),B(i("input",{id:p,"onUpdate:modelValue":d=>n.editedItem[p]=d,class:k(["ecwp-input input input-bordered",m.class||"w-full"])},null,10,kr),[[J,n.editedItem[p]]])],8,Ir)):(r(),c("div",Tr,[i("label",{for:p,class:"form-label"},l(m.label),9,Ar),P(f,{id:p,modelValue:n.editedItem[p],"onUpdate:modelValue":d=>n.editedItem[p]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",Sr,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",Dr)):_("",!0)],8,Pr)])],32))])],8,pr)])}var jr=oe(fr,[["render",Mr]]);/**!
    66 * Sortable 1.15.2
    77 * @author  RubaXa   <trash@rubaxa.org>
    88 * @author  owenm    <owen23355@gmail.com>
    99 * @license MIT
    10  */function Wn(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Te(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Wn(Object(s),!0).forEach(function(a){qr(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Wn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function jt(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jt=function(e){return typeof e}:jt=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jt(t)}function qr(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function qe(){return qe=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},qe.apply(this,arguments)}function Rr(t,e){if(t==null)return{};var s={},a=Object.keys(t),n,o;for(o=0;o<a.length;o++)n=a[o],!(e.indexOf(n)>=0)&&(s[n]=t[n]);return s}function Or(t,e){if(t==null)return{};var s=Rr(t,e),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(e.indexOf(a)>=0)&&(!Object.prototype.propertyIsEnumerable.call(t,a)||(s[a]=t[a]))}return s}var Vr="1.15.2";function je(t){if(typeof window!="undefined"&&window.navigator)return!!navigator.userAgent.match(t)}var Re=je(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Et=je(/Edge/i),Qn=je(/firefox/i),ft=je(/safari/i)&&!je(/chrome/i)&&!je(/android/i),gs=je(/iP(ad|od|hone)/i),vs=je(/chrome/i)&&je(/android/i),ys={capture:!1,passive:!1};function Q(t,e,s){t.addEventListener(e,s,!Re&&ys)}function N(t,e,s){t.removeEventListener(e,s,!Re&&ys)}function Nt(t,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch{return!1}return!1}}function Nr(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function Ce(t,e,s,a){if(t){s=s||document;do{if(e!=null&&(e[0]===">"?t.parentNode===s&&Nt(t,e):Nt(t,e))||a&&t===s)return t;if(t===s)break}while(t=Nr(t))}return null}var Xn=/\s+/g;function fe(t,e,s){if(t&&e)if(t.classList)t.classList[s?"add":"remove"](e);else{var a=(" "+t.className+" ").replace(Xn," ").replace(" "+e+" "," ");t.className=(a+(s?" "+e:"")).replace(Xn," ")}}function S(t,e,s){var a=t&&t.style;if(a){if(s===void 0)return document.defaultView&&document.defaultView.getComputedStyle?s=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(s=t.currentStyle),e===void 0?s:s[e];!(e in a)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),a[e]=s+(typeof s=="string"?"":"px")}}function et(t,e){var s="";if(typeof t=="string")s=t;else do{var a=S(t,"transform");a&&a!=="none"&&(s=a+" "+s)}while(!e&&(t=t.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(s)}function bs(t,e,s){if(t){var a=t.getElementsByTagName(e),n=0,o=a.length;if(s)for(;n<o;n++)s(a[n],n);return a}return[]}function ke(){var t=document.scrollingElement;return t||document.documentElement}function te(t,e,s,a,n){if(!(!t.getBoundingClientRect&&t!==window)){var o,f,m,p,d,u,h;if(t!==window&&t.parentNode&&t!==ke()?(o=t.getBoundingClientRect(),f=o.top,m=o.left,p=o.bottom,d=o.right,u=o.height,h=o.width):(f=0,m=0,p=window.innerHeight,d=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(e||s)&&t!==window&&(n=n||t.parentNode,!Re))do if(n&&n.getBoundingClientRect&&(S(n,"transform")!=="none"||s&&S(n,"position")!=="static")){var g=n.getBoundingClientRect();f-=g.top+parseInt(S(n,"border-top-width")),m-=g.left+parseInt(S(n,"border-left-width")),p=f+o.height,d=m+o.width;break}while(n=n.parentNode);if(a&&t!==window){var v=et(n||t),C=v&&v.a,E=v&&v.d;v&&(f/=E,m/=C,h/=C,u/=E,p=f+u,d=m+h)}return{top:f,left:m,bottom:p,right:d,width:h,height:u}}}function Un(t,e,s){for(var a=Qe(t,!0),n=te(t)[e];a;){var o=te(a)[s],f=void 0;if(s==="top"||s==="left"?f=n>=o:f=n<=o,!f)return a;if(a===ke())break;a=Qe(a,!1)}return!1}function st(t,e,s,a){for(var n=0,o=0,f=t.children;o<f.length;){if(f[o].style.display!=="none"&&f[o]!==A.ghost&&(a||f[o]!==A.dragged)&&Ce(f[o],s.draggable,t,!1)){if(n===e)return f[o];n++}o++}return null}function wn(t,e){for(var s=t.lastElementChild;s&&(s===A.ghost||S(s,"display")==="none"||e&&!Nt(s,e));)s=s.previousElementSibling;return s||null}function ge(t,e){var s=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)t.nodeName.toUpperCase()!=="TEMPLATE"&&t!==A.clone&&(!e||Nt(t,e))&&s++;return s}function Ln(t){var e=0,s=0,a=ke();if(t)do{var n=et(t),o=n.a,f=n.d;e+=t.scrollLeft*o,s+=t.scrollTop*f}while(t!==a&&(t=t.parentNode));return[e,s]}function Br(t,e){for(var s in t)if(!!t.hasOwnProperty(s)){for(var a in e)if(e.hasOwnProperty(a)&&e[a]===t[s][a])return Number(s)}return-1}function Qe(t,e){if(!t||!t.getBoundingClientRect)return ke();var s=t,a=!1;do if(s.clientWidth<s.scrollWidth||s.clientHeight<s.scrollHeight){var n=S(s);if(s.clientWidth<s.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||s.clientHeight<s.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!s.getBoundingClientRect||s===document.body)return ke();if(a||e)return s;a=!0}}while(s=s.parentNode);return ke()}function Fr(t,e){if(t&&e)for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function tn(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}var pt;function ws(t,e){return function(){if(!pt){var s=arguments,a=this;s.length===1?t.call(a,s[0]):t.apply(a,s),pt=setTimeout(function(){pt=void 0},e)}}}function Wr(){clearTimeout(pt),pt=void 0}function xs(t,e,s){t.scrollLeft+=e,t.scrollTop+=s}function Cs(t){var e=window.Polymer,s=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):s?s(t).clone(!0)[0]:t.cloneNode(!0)}function Is(t,e,s){var a={};return Array.from(t.children).forEach(function(n){var o,f,m,p;if(!(!Ce(n,e.draggable,t,!1)||n.animated||n===s)){var d=te(n);a.left=Math.min((o=a.left)!==null&&o!==void 0?o:1/0,d.left),a.top=Math.min((f=a.top)!==null&&f!==void 0?f:1/0,d.top),a.right=Math.max((m=a.right)!==null&&m!==void 0?m:-1/0,d.right),a.bottom=Math.max((p=a.bottom)!==null&&p!==void 0?p:-1/0,d.bottom)}}),a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}var _e="Sortable"+new Date().getTime();function Qr(){var t=[],e;return{captureAnimationState:function(){if(t=[],!!this.options.animation){var a=[].slice.call(this.el.children);a.forEach(function(n){if(!(S(n,"display")==="none"||n===A.ghost)){t.push({target:n,rect:te(n)});var o=Te({},t[t.length-1].rect);if(n.thisAnimationDuration){var f=et(n,!0);f&&(o.top-=f.f,o.left-=f.e)}n.fromRect=o}})}},addAnimationState:function(a){t.push(a)},removeAnimationState:function(a){t.splice(Br(t,{target:a}),1)},animateAll:function(a){var n=this;if(!this.options.animation){clearTimeout(e),typeof a=="function"&&a();return}var o=!1,f=0;t.forEach(function(m){var p=0,d=m.target,u=d.fromRect,h=te(d),g=d.prevFromRect,v=d.prevToRect,C=m.rect,E=et(d,!0);E&&(h.top-=E.f,h.left-=E.e),d.toRect=h,d.thisAnimationDuration&&tn(g,h)&&!tn(u,h)&&(C.top-h.top)/(C.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(p=Ur(C,g,v,n.options)),tn(h,u)||(d.prevFromRect=u,d.prevToRect=h,p||(p=n.options.animation),n.animate(d,C,h,p)),p&&(o=!0,f=Math.max(f,p),clearTimeout(d.animationResetTimer),d.animationResetTimer=setTimeout(function(){d.animationTime=0,d.prevFromRect=null,d.fromRect=null,d.prevToRect=null,d.thisAnimationDuration=null},p),d.thisAnimationDuration=p)}),clearTimeout(e),o?e=setTimeout(function(){typeof a=="function"&&a()},f):typeof a=="function"&&a(),t=[]},animate:function(a,n,o,f){if(f){S(a,"transition",""),S(a,"transform","");var m=et(this.el),p=m&&m.a,d=m&&m.d,u=(n.left-o.left)/(p||1),h=(n.top-o.top)/(d||1);a.animatingX=!!u,a.animatingY=!!h,S(a,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=Xr(a),S(a,"transition","transform "+f+"ms"+(this.options.easing?" "+this.options.easing:"")),S(a,"transform","translate3d(0,0,0)"),typeof a.animated=="number"&&clearTimeout(a.animated),a.animated=setTimeout(function(){S(a,"transition",""),S(a,"transform",""),a.animated=!1,a.animatingX=!1,a.animatingY=!1},f)}}}}function Xr(t){return t.offsetWidth}function Ur(t,e,s,a){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-s.top,2)+Math.pow(e.left-s.left,2))*a.animation}var Ye=[],nn={initializeByDefault:!0},kt={mount:function(e){for(var s in nn)nn.hasOwnProperty(s)&&!(s in e)&&(e[s]=nn[s]);Ye.forEach(function(a){if(a.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),Ye.push(e)},pluginEvent:function(e,s,a){var n=this;this.eventCanceled=!1,a.cancel=function(){n.eventCanceled=!0};var o=e+"Global";Ye.forEach(function(f){!s[f.pluginName]||(s[f.pluginName][o]&&s[f.pluginName][o](Te({sortable:s},a)),s.options[f.pluginName]&&s[f.pluginName][e]&&s[f.pluginName][e](Te({sortable:s},a)))})},initializePlugins:function(e,s,a,n){Ye.forEach(function(m){var p=m.pluginName;if(!(!e.options[p]&&!m.initializeByDefault)){var d=new m(e,s,e.options);d.sortable=e,d.options=e.options,e[p]=d,qe(a,d.defaults)}});for(var o in e.options)if(!!e.options.hasOwnProperty(o)){var f=this.modifyOption(e,o,e.options[o]);typeof f!="undefined"&&(e.options[o]=f)}},getEventProperties:function(e,s){var a={};return Ye.forEach(function(n){typeof n.eventProperties=="function"&&qe(a,n.eventProperties.call(s[n.pluginName],e))}),a},modifyOption:function(e,s,a){var n;return Ye.forEach(function(o){!e[o.pluginName]||o.optionListeners&&typeof o.optionListeners[s]=="function"&&(n=o.optionListeners[s].call(e[o.pluginName],a))}),n}};function Lr(t){var e=t.sortable,s=t.rootEl,a=t.name,n=t.targetEl,o=t.cloneEl,f=t.toEl,m=t.fromEl,p=t.oldIndex,d=t.newIndex,u=t.oldDraggableIndex,h=t.newDraggableIndex,g=t.originalEvent,v=t.putSortable,C=t.extraEventProperties;if(e=e||s&&s[_e],!!e){var E,O=e.options,F="on"+a.charAt(0).toUpperCase()+a.substr(1);window.CustomEvent&&!Re&&!Et?E=new CustomEvent(a,{bubbles:!0,cancelable:!0}):(E=document.createEvent("Event"),E.initEvent(a,!0,!0)),E.to=f||s,E.from=m||s,E.item=n||s,E.clone=o,E.oldIndex=p,E.newIndex=d,E.oldDraggableIndex=u,E.newDraggableIndex=h,E.originalEvent=g,E.pullMode=v?v.lastPutMode:void 0;var P=Te(Te({},C),kt.getEventProperties(a,e));for(var q in P)E[q]=P[q];s&&s.dispatchEvent(E),O[F]&&O[F].call(e,E)}}var zr=["evt"],me=function(e,s){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=a.evt,o=Or(a,zr);kt.pluginEvent.bind(A)(e,s,Te({dragEl:b,parentEl:Y,ghostEl:M,rootEl:H,nextEl:He,lastDownEl:qt,cloneEl:G,cloneHidden:We,dragStarted:rt,putSortable:ae,activeSortable:A.active,originalEvent:n,oldIndex:$e,oldDraggableIndex:_t,newIndex:pe,newDraggableIndex:Fe,hideGhostForTarget:As,unhideGhostForTarget:Ss,cloneNowHidden:function(){We=!0},cloneNowShown:function(){We=!1},dispatchSortableEvent:function(m){ue({sortable:s,name:m,originalEvent:n})}},o))};function ue(t){Lr(Te({putSortable:ae,cloneEl:G,targetEl:b,rootEl:H,oldIndex:$e,oldDraggableIndex:_t,newIndex:pe,newDraggableIndex:Fe},t))}var b,Y,M,H,He,qt,G,We,$e,pe,_t,Fe,St,ae,Ze=!1,Bt=!1,Ft=[],Le,we,sn,on,zn,Hn,rt,Je,gt,vt=!1,Dt=!1,Rt,le,an=[],fn=!1,Wt=[],Gt=typeof document!="undefined",Pt=gs,Gn=Et||Re?"cssFloat":"float",Hr=Gt&&!vs&&!gs&&"draggable"in document.createElement("div"),Es=function(){if(!!Gt){if(Re)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto",t.style.pointerEvents==="auto"}}(),ks=function(e,s){var a=S(e),n=parseInt(a.width)-parseInt(a.paddingLeft)-parseInt(a.paddingRight)-parseInt(a.borderLeftWidth)-parseInt(a.borderRightWidth),o=st(e,0,s),f=st(e,1,s),m=o&&S(o),p=f&&S(f),d=m&&parseInt(m.marginLeft)+parseInt(m.marginRight)+te(o).width,u=p&&parseInt(p.marginLeft)+parseInt(p.marginRight)+te(f).width;if(a.display==="flex")return a.flexDirection==="column"||a.flexDirection==="column-reverse"?"vertical":"horizontal";if(a.display==="grid")return a.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&m.float&&m.float!=="none"){var h=m.float==="left"?"left":"right";return f&&(p.clear==="both"||p.clear===h)?"vertical":"horizontal"}return o&&(m.display==="block"||m.display==="flex"||m.display==="table"||m.display==="grid"||d>=n&&a[Gn]==="none"||f&&a[Gn]==="none"&&d+u>n)?"vertical":"horizontal"},Gr=function(e,s,a){var n=a?e.left:e.top,o=a?e.right:e.bottom,f=a?e.width:e.height,m=a?s.left:s.top,p=a?s.right:s.bottom,d=a?s.width:s.height;return n===m||o===p||n+f/2===m+d/2},Yr=function(e,s){var a;return Ft.some(function(n){var o=n[_e].options.emptyInsertThreshold;if(!(!o||wn(n))){var f=te(n),m=e>=f.left-o&&e<=f.right+o,p=s>=f.top-o&&s<=f.bottom+o;if(m&&p)return a=n}}),a},Ts=function(e){function s(o,f){return function(m,p,d,u){var h=m.options.group.name&&p.options.group.name&&m.options.group.name===p.options.group.name;if(o==null&&(f||h))return!0;if(o==null||o===!1)return!1;if(f&&o==="clone")return o;if(typeof o=="function")return s(o(m,p,d,u),f)(m,p,d,u);var g=(f?m:p).options.group.name;return o===!0||typeof o=="string"&&o===g||o.join&&o.indexOf(g)>-1}}var a={},n=e.group;(!n||jt(n)!="object")&&(n={name:n}),a.name=n.name,a.checkPull=s(n.pull,!0),a.checkPut=s(n.put),a.revertClone=n.revertClone,e.group=a},As=function(){!Es&&M&&S(M,"display","none")},Ss=function(){!Es&&M&&S(M,"display","")};Gt&&!vs&&document.addEventListener("click",function(t){if(Bt)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),Bt=!1,!1},!0);var ze=function(e){if(b){e=e.touches?e.touches[0]:e;var s=Yr(e.clientX,e.clientY);if(s){var a={};for(var n in e)e.hasOwnProperty(n)&&(a[n]=e[n]);a.target=a.rootEl=s,a.preventDefault=void 0,a.stopPropagation=void 0,s[_e]._onDragOver(a)}}},Jr=function(e){b&&b.parentNode[_e]._isOutsideThisEl(e.target)};function A(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=qe({},e),t[_e]=this;var s={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ks(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(f,m){f.setData("Text",m.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:A.supportPointer!==!1&&"PointerEvent"in window&&!ft,emptyInsertThreshold:5};kt.initializePlugins(this,t,s);for(var a in s)!(a in e)&&(e[a]=s[a]);Ts(e);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=e.forceFallback?!1:Hr,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Q(t,"pointerdown",this._onTapStart):(Q(t,"mousedown",this._onTapStart),Q(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(Q(t,"dragover",this),Q(t,"dragenter",this)),Ft.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),qe(this,Qr())}A.prototype={constructor:A,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Je=null)},_getDirection:function(e,s){return typeof this.options.direction=="function"?this.options.direction.call(this,e,s,b):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var s=this,a=this.el,n=this.options,o=n.preventOnFilter,f=e.type,m=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,p=(m||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||p,u=n.filter;if(oc(a),!b&&!(/mousedown|pointerdown/.test(f)&&e.button!==0||n.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&ft&&p&&p.tagName.toUpperCase()==="SELECT")&&(p=Ce(p,n.draggable,a,!1),!(p&&p.animated)&&qt!==p)){if($e=ge(p),_t=ge(p,n.draggable),typeof u=="function"){if(u.call(this,e,p,this)){ue({sortable:s,rootEl:d,name:"filter",targetEl:p,toEl:a,fromEl:a}),me("filter",s,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=Ce(d,h.trim(),a,!1),h)return ue({sortable:s,rootEl:h,name:"filter",targetEl:p,fromEl:a,toEl:a}),me("filter",s,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}n.handle&&!Ce(d,n.handle,a,!1)||this._prepareDragStart(e,m,p)}}},_prepareDragStart:function(e,s,a){var n=this,o=n.el,f=n.options,m=o.ownerDocument,p;if(a&&!b&&a.parentNode===o){var d=te(a);if(H=o,b=a,Y=b.parentNode,He=b.nextSibling,qt=a,St=f.group,A.dragged=b,Le={target:b,clientX:(s||e).clientX,clientY:(s||e).clientY},zn=Le.clientX-d.left,Hn=Le.clientY-d.top,this._lastX=(s||e).clientX,this._lastY=(s||e).clientY,b.style["will-change"]="all",p=function(){if(me("delayEnded",n,{evt:e}),A.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!Qn&&n.nativeDraggable&&(b.draggable=!0),n._triggerDragStart(e,s),ue({sortable:n,name:"choose",originalEvent:e}),fe(b,f.chosenClass,!0)},f.ignore.split(",").forEach(function(u){bs(b,u.trim(),ln)}),Q(m,"dragover",ze),Q(m,"mousemove",ze),Q(m,"touchmove",ze),Q(m,"mouseup",n._onDrop),Q(m,"touchend",n._onDrop),Q(m,"touchcancel",n._onDrop),Qn&&this.nativeDraggable&&(this.options.touchStartThreshold=4,b.draggable=!0),me("delayStart",this,{evt:e}),f.delay&&(!f.delayOnTouchOnly||s)&&(!this.nativeDraggable||!(Et||Re))){if(A.eventCanceled){this._onDrop();return}Q(m,"mouseup",n._disableDelayedDrag),Q(m,"touchend",n._disableDelayedDrag),Q(m,"touchcancel",n._disableDelayedDrag),Q(m,"mousemove",n._delayedDragTouchMoveHandler),Q(m,"touchmove",n._delayedDragTouchMoveHandler),f.supportPointer&&Q(m,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(p,f.delay)}else p()}},_delayedDragTouchMoveHandler:function(e){var s=e.touches?e.touches[0]:e;Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){b&&ln(b),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;N(e,"mouseup",this._disableDelayedDrag),N(e,"touchend",this._disableDelayedDrag),N(e,"touchcancel",this._disableDelayedDrag),N(e,"mousemove",this._delayedDragTouchMoveHandler),N(e,"touchmove",this._delayedDragTouchMoveHandler),N(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,s){s=s||e.pointerType=="touch"&&e,!this.nativeDraggable||s?this.options.supportPointer?Q(document,"pointermove",this._onTouchMove):s?Q(document,"touchmove",this._onTouchMove):Q(document,"mousemove",this._onTouchMove):(Q(b,"dragend",this),Q(H,"dragstart",this._onDragStart));try{document.selection?Ot(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,s){if(Ze=!1,H&&b){me("dragStarted",this,{evt:s}),this.nativeDraggable&&Q(document,"dragover",Jr);var a=this.options;!e&&fe(b,a.dragClass,!1),fe(b,a.ghostClass,!0),A.active=this,e&&this._appendGhost(),ue({sortable:this,name:"start",originalEvent:s})}else this._nulling()},_emulateDragOver:function(){if(we){this._lastX=we.clientX,this._lastY=we.clientY,As();for(var e=document.elementFromPoint(we.clientX,we.clientY),s=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(we.clientX,we.clientY),e!==s);)s=e;if(b.parentNode[_e]._isOutsideThisEl(e),s)do{if(s[_e]){var a=void 0;if(a=s[_e]._onDragOver({clientX:we.clientX,clientY:we.clientY,target:e,rootEl:s}),a&&!this.options.dragoverBubble)break}e=s}while(s=s.parentNode);Ss()}},_onTouchMove:function(e){if(Le){var s=this.options,a=s.fallbackTolerance,n=s.fallbackOffset,o=e.touches?e.touches[0]:e,f=M&&et(M,!0),m=M&&f&&f.a,p=M&&f&&f.d,d=Pt&&le&&Ln(le),u=(o.clientX-Le.clientX+n.x)/(m||1)+(d?d[0]-an[0]:0)/(m||1),h=(o.clientY-Le.clientY+n.y)/(p||1)+(d?d[1]-an[1]:0)/(p||1);if(!A.active&&!Ze){if(a&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<a)return;this._onDragStart(e,!0)}if(M){f?(f.e+=u-(sn||0),f.f+=h-(on||0)):f={a:1,b:0,c:0,d:1,e:u,f:h};var g="matrix(".concat(f.a,",").concat(f.b,",").concat(f.c,",").concat(f.d,",").concat(f.e,",").concat(f.f,")");S(M,"webkitTransform",g),S(M,"mozTransform",g),S(M,"msTransform",g),S(M,"transform",g),sn=u,on=h,we=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!M){var e=this.options.fallbackOnBody?document.body:H,s=te(b,!0,Pt,!0,e),a=this.options;if(Pt){for(le=e;S(le,"position")==="static"&&S(le,"transform")==="none"&&le!==document;)le=le.parentNode;le!==document.body&&le!==document.documentElement?(le===document&&(le=ke()),s.top+=le.scrollTop,s.left+=le.scrollLeft):le=ke(),an=Ln(le)}M=b.cloneNode(!0),fe(M,a.ghostClass,!1),fe(M,a.fallbackClass,!0),fe(M,a.dragClass,!0),S(M,"transition",""),S(M,"transform",""),S(M,"box-sizing","border-box"),S(M,"margin",0),S(M,"top",s.top),S(M,"left",s.left),S(M,"width",s.width),S(M,"height",s.height),S(M,"opacity","0.8"),S(M,"position",Pt?"absolute":"fixed"),S(M,"zIndex","100000"),S(M,"pointerEvents","none"),A.ghost=M,e.appendChild(M),S(M,"transform-origin",zn/parseInt(M.style.width)*100+"% "+Hn/parseInt(M.style.height)*100+"%")}},_onDragStart:function(e,s){var a=this,n=e.dataTransfer,o=a.options;if(me("dragStart",this,{evt:e}),A.eventCanceled){this._onDrop();return}me("setupClone",this),A.eventCanceled||(G=Cs(b),G.removeAttribute("id"),G.draggable=!1,G.style["will-change"]="",this._hideClone(),fe(G,this.options.chosenClass,!1),A.clone=G),a.cloneId=Ot(function(){me("clone",a),!A.eventCanceled&&(a.options.removeCloneOnHide||H.insertBefore(G,b),a._hideClone(),ue({sortable:a,name:"clone"}))}),!s&&fe(b,o.dragClass,!0),s?(Bt=!0,a._loopId=setInterval(a._emulateDragOver,50)):(N(document,"mouseup",a._onDrop),N(document,"touchend",a._onDrop),N(document,"touchcancel",a._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(a,n,b)),Q(document,"drop",a),S(b,"transform","translateZ(0)")),Ze=!0,a._dragStartId=Ot(a._dragStarted.bind(a,s,e)),Q(document,"selectstart",a),rt=!0,ft&&S(document.body,"user-select","none")},_onDragOver:function(e){var s=this.el,a=e.target,n,o,f,m=this.options,p=m.group,d=A.active,u=St===p,h=m.sort,g=ae||d,v,C=this,E=!1;if(fn)return;function O(Pe,Yt){me(Pe,C,Te({evt:e,isOwner:u,axis:v?"vertical":"horizontal",revert:f,dragRect:n,targetRect:o,canSort:h,fromSortable:g,target:a,completed:P,onMove:function(ot,it){return Mt(H,s,b,n,ot,te(ot),e,it)},changed:q},Yt))}function F(){O("dragOverAnimationCapture"),C.captureAnimationState(),C!==g&&g.captureAnimationState()}function P(Pe){return O("dragOverCompleted",{insertion:Pe}),Pe&&(u?d._hideClone():d._showClone(C),C!==g&&(fe(b,ae?ae.options.ghostClass:d.options.ghostClass,!1),fe(b,m.ghostClass,!0)),ae!==C&&C!==A.active?ae=C:C===A.active&&ae&&(ae=null),g===C&&(C._ignoreWhileAnimating=a),C.animateAll(function(){O("dragOverAnimationComplete"),C._ignoreWhileAnimating=null}),C!==g&&(g.animateAll(),g._ignoreWhileAnimating=null)),(a===b&&!b.animated||a===s&&!a.animated)&&(Je=null),!m.dragoverBubble&&!e.rootEl&&a!==document&&(b.parentNode[_e]._isOutsideThisEl(e.target),!Pe&&ze(e)),!m.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),E=!0}function q(){pe=ge(b),Fe=ge(b,m.draggable),ue({sortable:C,name:"change",toEl:s,newIndex:pe,newDraggableIndex:Fe,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),a=Ce(a,m.draggable,s,!0),O("dragOver"),A.eventCanceled)return E;if(b.contains(e.target)||a.animated&&a.animatingX&&a.animatingY||C._ignoreWhileAnimating===a)return P(!1);if(Bt=!1,d&&!m.disabled&&(u?h||(f=Y!==H):ae===this||(this.lastPutMode=St.checkPull(this,d,b,e))&&p.checkPut(this,d,b,e))){if(v=this._getDirection(e,a)==="vertical",n=te(b),O("dragOverValid"),A.eventCanceled)return E;if(f)return Y=H,F(),this._hideClone(),O("revert"),A.eventCanceled||(He?H.insertBefore(b,He):H.appendChild(b)),P(!0);var z=wn(s,m.draggable);if(!z||ec(e,v,this)&&!z.animated){if(z===b)return P(!1);if(z&&s===e.target&&(a=z),a&&(o=te(a)),Mt(H,s,b,n,a,o,e,!!a)!==!1)return F(),z&&z.nextSibling?s.insertBefore(b,z.nextSibling):s.appendChild(b),Y=s,q(),P(!0)}else if(z&&$r(e,v,this)){var ce=st(s,0,m,!0);if(ce===b)return P(!1);if(a=ce,o=te(a),Mt(H,s,b,n,a,o,e,!1)!==!1)return F(),s.insertBefore(b,ce),Y=s,q(),P(!0)}else if(a.parentNode===s){o=te(a);var ne=0,Z,Ue=b.parentNode!==s,ie=!Gr(b.animated&&b.toRect||n,a.animated&&a.toRect||o,v),Oe=v?"top":"left",ye=Un(a,"top","top")||Un(b,"top","top"),Ve=ye?ye.scrollTop:void 0;Je!==a&&(Z=o[Oe],vt=!1,Dt=!ie&&m.invertSwap||Ue),ne=tc(e,a,o,v,ie?1:m.swapThreshold,m.invertedSwapThreshold==null?m.swapThreshold:m.invertedSwapThreshold,Dt,Je===a);var de;if(ne!==0){var Ae=ge(b);do Ae-=ne,de=Y.children[Ae];while(de&&(S(de,"display")==="none"||de===M))}if(ne===0||de===a)return P(!1);Je=a,gt=ne;var Se=a.nextElementSibling,be=!1;be=ne===1;var De=Mt(H,s,b,n,a,o,e,be);if(De!==!1)return(De===1||De===-1)&&(be=De===1),fn=!0,setTimeout(Zr,30),F(),be&&!Se?s.appendChild(b):a.parentNode.insertBefore(b,be?Se:a),ye&&xs(ye,0,Ve-ye.scrollTop),Y=b.parentNode,Z!==void 0&&!Dt&&(Rt=Math.abs(Z-te(a)[Oe])),q(),P(!0)}if(s.contains(b))return P(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){N(document,"mousemove",this._onTouchMove),N(document,"touchmove",this._onTouchMove),N(document,"pointermove",this._onTouchMove),N(document,"dragover",ze),N(document,"mousemove",ze),N(document,"touchmove",ze)},_offUpEvents:function(){var e=this.el.ownerDocument;N(e,"mouseup",this._onDrop),N(e,"touchend",this._onDrop),N(e,"pointerup",this._onDrop),N(e,"touchcancel",this._onDrop),N(document,"selectstart",this)},_onDrop:function(e){var s=this.el,a=this.options;if(pe=ge(b),Fe=ge(b,a.draggable),me("drop",this,{evt:e}),Y=b&&b.parentNode,pe=ge(b),Fe=ge(b,a.draggable),A.eventCanceled){this._nulling();return}Ze=!1,Dt=!1,vt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),pn(this.cloneId),pn(this._dragStartId),this.nativeDraggable&&(N(document,"drop",this),N(s,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),ft&&S(document.body,"user-select",""),S(b,"transform",""),e&&(rt&&(e.cancelable&&e.preventDefault(),!a.dropBubble&&e.stopPropagation()),M&&M.parentNode&&M.parentNode.removeChild(M),(H===Y||ae&&ae.lastPutMode!=="clone")&&G&&G.parentNode&&G.parentNode.removeChild(G),b&&(this.nativeDraggable&&N(b,"dragend",this),ln(b),b.style["will-change"]="",rt&&!Ze&&fe(b,ae?ae.options.ghostClass:this.options.ghostClass,!1),fe(b,this.options.chosenClass,!1),ue({sortable:this,name:"unchoose",toEl:Y,newIndex:null,newDraggableIndex:null,originalEvent:e}),H!==Y?(pe>=0&&(ue({rootEl:Y,name:"add",toEl:Y,fromEl:H,originalEvent:e}),ue({sortable:this,name:"remove",toEl:Y,originalEvent:e}),ue({rootEl:Y,name:"sort",toEl:Y,fromEl:H,originalEvent:e}),ue({sortable:this,name:"sort",toEl:Y,originalEvent:e})),ae&&ae.save()):pe!==$e&&pe>=0&&(ue({sortable:this,name:"update",toEl:Y,originalEvent:e}),ue({sortable:this,name:"sort",toEl:Y,originalEvent:e})),A.active&&((pe==null||pe===-1)&&(pe=$e,Fe=_t),ue({sortable:this,name:"end",toEl:Y,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){me("nulling",this),H=b=Y=M=He=G=qt=We=Le=we=rt=pe=Fe=$e=_t=Je=gt=ae=St=A.dragged=A.ghost=A.clone=A.active=null,Wt.forEach(function(e){e.checked=!0}),Wt.length=sn=on=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":b&&(this._onDragOver(e),Kr(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],s,a=this.el.children,n=0,o=a.length,f=this.options;n<o;n++)s=a[n],Ce(s,f.draggable,this.el,!1)&&e.push(s.getAttribute(f.dataIdAttr)||sc(s));return e},sort:function(e,s){var a={},n=this.el;this.toArray().forEach(function(o,f){var m=n.children[f];Ce(m,this.options.draggable,n,!1)&&(a[o]=m)},this),s&&this.captureAnimationState(),e.forEach(function(o){a[o]&&(n.removeChild(a[o]),n.appendChild(a[o]))}),s&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,s){return Ce(e,s||this.options.draggable,this.el,!1)},option:function(e,s){var a=this.options;if(s===void 0)return a[e];var n=kt.modifyOption(this,e,s);typeof n!="undefined"?a[e]=n:a[e]=s,e==="group"&&Ts(a)},destroy:function(){me("destroy",this);var e=this.el;e[_e]=null,N(e,"mousedown",this._onTapStart),N(e,"touchstart",this._onTapStart),N(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(N(e,"dragover",this),N(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(s){s.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ft.splice(Ft.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!We){if(me("hideClone",this),A.eventCanceled)return;S(G,"display","none"),this.options.removeCloneOnHide&&G.parentNode&&G.parentNode.removeChild(G),We=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(We){if(me("showClone",this),A.eventCanceled)return;b.parentNode==H&&!this.options.group.revertClone?H.insertBefore(G,b):He?H.insertBefore(G,He):H.appendChild(G),this.options.group.revertClone&&this.animate(b,G),S(G,"display",""),We=!1}}};function Kr(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.cancelable&&t.preventDefault()}function Mt(t,e,s,a,n,o,f,m){var p,d=t[_e],u=d.options.onMove,h;return window.CustomEvent&&!Re&&!Et?p=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(p=document.createEvent("Event"),p.initEvent("move",!0,!0)),p.to=e,p.from=t,p.dragged=s,p.draggedRect=a,p.related=n||e,p.relatedRect=o||te(e),p.willInsertAfter=m,p.originalEvent=f,t.dispatchEvent(p),u&&(h=u.call(d,p,f)),h}function ln(t){t.draggable=!1}function Zr(){fn=!1}function $r(t,e,s){var a=te(st(s.el,0,s.options,!0)),n=Is(s.el,s.options,M),o=10;return e?t.clientX<n.left-o||t.clientY<a.top&&t.clientX<a.right:t.clientY<n.top-o||t.clientY<a.bottom&&t.clientX<a.left}function ec(t,e,s){var a=te(wn(s.el,s.options.draggable)),n=Is(s.el,s.options,M),o=10;return e?t.clientX>n.right+o||t.clientY>a.bottom&&t.clientX>a.left:t.clientY>n.bottom+o||t.clientX>a.right&&t.clientY>a.top}function tc(t,e,s,a,n,o,f,m){var p=a?t.clientY:t.clientX,d=a?s.height:s.width,u=a?s.top:s.left,h=a?s.bottom:s.right,g=!1;if(!f){if(m&&Rt<d*n){if(!vt&&(gt===1?p>u+d*o/2:p<h-d*o/2)&&(vt=!0),vt)g=!0;else if(gt===1?p<u+Rt:p>h-Rt)return-gt}else if(p>u+d*(1-n)/2&&p<h-d*(1-n)/2)return nc(e)}return g=g||f,g&&(p<u+d*o/2||p>h-d*o/2)?p>u+d/2?1:-1:0}function nc(t){return ge(b)<ge(t)?1:-1}function sc(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,s=e.length,a=0;s--;)a+=e.charCodeAt(s);return a.toString(36)}function oc(t){Wt.length=0;for(var e=t.getElementsByTagName("input"),s=e.length;s--;){var a=e[s];a.checked&&Wt.push(a)}}function Ot(t){return setTimeout(t,0)}function pn(t){return clearTimeout(t)}Gt&&Q(document,"touchmove",function(t){(A.active||Ze)&&t.cancelable&&t.preventDefault()});A.utils={on:Q,off:N,css:S,find:bs,is:function(e,s){return!!Ce(e,s,e,!1)},extend:Fr,throttle:ws,closest:Ce,toggleClass:fe,clone:Cs,index:ge,nextTick:Ot,cancelNextTick:pn,detectDirection:ks,getChild:st};A.get=function(t){return t[_e]};A.mount=function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];e[0].constructor===Array&&(e=e[0]),e.forEach(function(a){if(!a.prototype||!a.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(a));a.utils&&(A.utils=Te(Te({},A.utils),a.utils)),kt.mount(a)})};A.create=function(t,e){return new A(t,e)};A.version=Vr;var ee=[],ct,_n,gn=!1,rn,cn,Qt,dt;function ic(){function t(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return t.prototype={dragStarted:function(s){var a=s.originalEvent;this.sortable.nativeDraggable?Q(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Q(document,"pointermove",this._handleFallbackAutoScroll):a.touches?Q(document,"touchmove",this._handleFallbackAutoScroll):Q(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(s){var a=s.originalEvent;!this.options.dragOverBubble&&!a.rootEl&&this._handleAutoScroll(a)},drop:function(){this.sortable.nativeDraggable?N(document,"dragover",this._handleAutoScroll):(N(document,"pointermove",this._handleFallbackAutoScroll),N(document,"touchmove",this._handleFallbackAutoScroll),N(document,"mousemove",this._handleFallbackAutoScroll)),Yn(),Vt(),Wr()},nulling:function(){Qt=_n=ct=gn=dt=rn=cn=null,ee.length=0},_handleFallbackAutoScroll:function(s){this._handleAutoScroll(s,!0)},_handleAutoScroll:function(s,a){var n=this,o=(s.touches?s.touches[0]:s).clientX,f=(s.touches?s.touches[0]:s).clientY,m=document.elementFromPoint(o,f);if(Qt=s,a||this.options.forceAutoScrollFallback||Et||Re||ft){dn(s,this.options,m,a);var p=Qe(m,!0);gn&&(!dt||o!==rn||f!==cn)&&(dt&&Yn(),dt=setInterval(function(){var d=Qe(document.elementFromPoint(o,f),!0);d!==p&&(p=d,Vt()),dn(s,n.options,d,a)},10),rn=o,cn=f)}else{if(!this.options.bubbleScroll||Qe(m,!0)===ke()){Vt();return}dn(s,this.options,Qe(m,!1),!1)}}},qe(t,{pluginName:"scroll",initializeByDefault:!0})}function Vt(){ee.forEach(function(t){clearInterval(t.pid)}),ee=[]}function Yn(){clearInterval(dt)}var dn=ws(function(t,e,s,a){if(!!e.scroll){var n=(t.touches?t.touches[0]:t).clientX,o=(t.touches?t.touches[0]:t).clientY,f=e.scrollSensitivity,m=e.scrollSpeed,p=ke(),d=!1,u;_n!==s&&(_n=s,Vt(),ct=e.scroll,u=e.scrollFn,ct===!0&&(ct=Qe(s,!0)));var h=0,g=ct;do{var v=g,C=te(v),E=C.top,O=C.bottom,F=C.left,P=C.right,q=C.width,z=C.height,ce=void 0,ne=void 0,Z=v.scrollWidth,Ue=v.scrollHeight,ie=S(v),Oe=v.scrollLeft,ye=v.scrollTop;v===p?(ce=q<Z&&(ie.overflowX==="auto"||ie.overflowX==="scroll"||ie.overflowX==="visible"),ne=z<Ue&&(ie.overflowY==="auto"||ie.overflowY==="scroll"||ie.overflowY==="visible")):(ce=q<Z&&(ie.overflowX==="auto"||ie.overflowX==="scroll"),ne=z<Ue&&(ie.overflowY==="auto"||ie.overflowY==="scroll"));var Ve=ce&&(Math.abs(P-n)<=f&&Oe+q<Z)-(Math.abs(F-n)<=f&&!!Oe),de=ne&&(Math.abs(O-o)<=f&&ye+z<Ue)-(Math.abs(E-o)<=f&&!!ye);if(!ee[h])for(var Ae=0;Ae<=h;Ae++)ee[Ae]||(ee[Ae]={});(ee[h].vx!=Ve||ee[h].vy!=de||ee[h].el!==v)&&(ee[h].el=v,ee[h].vx=Ve,ee[h].vy=de,clearInterval(ee[h].pid),(Ve!=0||de!=0)&&(d=!0,ee[h].pid=setInterval(function(){a&&this.layer===0&&A.active._onTouchMove(Qt);var Se=ee[this.layer].vy?ee[this.layer].vy*m:0,be=ee[this.layer].vx?ee[this.layer].vx*m:0;typeof u=="function"&&u.call(A.dragged.parentNode[_e],be,Se,t,Qt,ee[this.layer].el)!=="continue"||xs(ee[this.layer].el,be,Se)}.bind({layer:h}),24))),h++}while(e.bubbleScroll&&g!==p&&(g=Qe(g,!1)));gn=d}},30),Ds=function(e){var s=e.originalEvent,a=e.putSortable,n=e.dragEl,o=e.activeSortable,f=e.dispatchSortableEvent,m=e.hideGhostForTarget,p=e.unhideGhostForTarget;if(!!s){var d=a||o;m();var u=s.changedTouches&&s.changedTouches.length?s.changedTouches[0]:s,h=document.elementFromPoint(u.clientX,u.clientY);p(),d&&!d.el.contains(h)&&(f("spill"),this.onSpill({dragEl:n,putSortable:a}))}};function xn(){}xn.prototype={startIndex:null,dragStart:function(e){var s=e.oldDraggableIndex;this.startIndex=s},onSpill:function(e){var s=e.dragEl,a=e.putSortable;this.sortable.captureAnimationState(),a&&a.captureAnimationState();var n=st(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(s,n):this.sortable.el.appendChild(s),this.sortable.animateAll(),a&&a.animateAll()},drop:Ds};qe(xn,{pluginName:"revertOnSpill"});function Cn(){}Cn.prototype={onSpill:function(e){var s=e.dragEl,a=e.putSortable,n=a||this.sortable;n.captureAnimationState(),s.parentNode&&s.parentNode.removeChild(s),n.animateAll()},drop:Ds};qe(Cn,{pluginName:"removeOnSpill"});A.mount(new ic);A.mount(Cn,xn);const ac={name:"QuoteViewDetail",components:{Card:Xe,QuoteNavBar:mr,EditItemModal:jr,RemoveModal:xt},data(){return{selectedItem:null,selectedInvoiceId:null,editItemsModal:!1,no_items:!0,loading:!0,loading_add:!1,quote:[],quoteItems:[],newItem:{loading_del:!1,item_ref:"",item_name:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},vatRate:0,settings:[],list_vats:[],client_detail:[],client_email:null,client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},articles:[],categories:[],showDropdown:!1,refs:[],showDropdownRef:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isQuoteExpired(){const t=new Date().getTime(),e=this.quote.due_date?new Date(this.quote.due_date).getTime():null;return e&&e<t},totalAmountWithoutDiscount(){const t=this.quoteItems.reduce((e,s)=>{const a=s.quantity*s.unit_price;return e+a},0);return this.formatCurrency(t)},totalAmount(){const t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.quoteItems.reduce((a,n)=>a+parseFloat(n.total_amount),0)*this.quote.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)},signatureImageUrl(){const t="/wp-json/my-easy-compta/v1/signature-image/",e=myEasyComptaAdmin.nonce;return`${t}${this.quote.file_sign}?_wpnonce=${e}`}},methods:{getUniqueVATRates(){const t=new Set;return this.quoteItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.quoteItems.forEach(s=>{if(s.vat_rate===t){const a=s.quantity*s.unit_price,n=a*s.discount/100;e+=(a-n)*t/100}}),this.formatCurrency(e)},calculateTotalAmountWithVAT(){let t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.formatCurrency(t)},fetchQuote(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.quote=t,this.fetchClientInfo(t.client_id)):console.error("Quote not found")}).catch(t=>{console.error("Error fetching quote:",t),this.loading=!1})},fetchClientInfo(t){fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.client_email=e.email;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.quoteItems=[],this.loading=!1,this.no_items=!0):(this.quoteItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var a=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;a=s+n}else a=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(a)},calculateTotalWithVat(t,e,s,a){const n=t*e,o=n*a/100,f=n-o,m=f*s/100,p=f+m;return this.formatCurrency(p)},calculateTotal(t,e,s){const a=t*e,n=a*s/100,f=a-n;return this.formatCurrency(f)},submitItems(){this.updateTotal();const t={...this.newItem,quote_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/quotes/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.selectedInvoiceId=e,modal_remove.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.quoteItems.find(a=>a.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({quote_id:e})}).then(a=>a.json()).then(a=>{a.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(a.message,"alert-error"),console.error("Error removing item:",a.message),s.loading_del=!1)}).catch(a=>{this.showToast(a.message,"alert-error"),console.error("Error removing item:",a),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/quotes/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,a){const o=t*e*a/100,f=o*s/100,m=o+f;return this.formatCurrency(m)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.quoteItems[t.oldIndex];this.quoteItems.splice(t.oldIndex,1),this.quoteItems.splice(t.newIndex,0,e);const s=this.quoteItems.map(a=>a.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/quotes/update-quote-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.articles=t}).catch(t=>console.error("Error fetching articles:",t))},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loading=!0,this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:a}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=a,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1,this.loading=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1,this.loading=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchQuote(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");A.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},lc={class:"pt-2 pr-4"},rc={key:1,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},cc=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),dc=[cc],uc={key:2},hc={role:"alert",class:"alert alert-warning"},mc=i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),fc={key:0,class:"relative"},pc={class:"ecwp-watermark"},_c={class:"grid grid-cols-2"},gc={class:"md:col-span-1"},vc=["src"],yc={class:"md:col-span-1 text-right"},bc={class:"text-lg font-semibold"},wc={key:0,class:"badge badge-warning text-white"},xc={key:1,class:"badge badge-secondary text-white"},Cc={key:2,class:"badge badge-success text-white"},Ic={key:3,class:"badge badge-error text-white"},Ec={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},kc=i("br",null,null,-1),Tc=i("br",null,null,-1),Ac=i("br",null,null,-1),Sc=["href"],Dc=i("br",null,null,-1),Pc=i("br",null,null,-1),Mc=i("br",null,null,-1),jc=["href"],qc=i("br",null,null,-1),Rc=["href"],Oc={class:"table mt-8"},Vc=i("th",null,null,-1),Nc={width:"5%"},Bc={width:"19%"},Fc={width:"21%"},Wc={width:"10%",class:"text-center"},Qc={width:"8%",class:"text-center"},Xc={key:0,width:"5%",class:"text-center"},Uc={key:1,width:"5%"},Lc={width:"10%",class:"text-center"},zc={width:"10%",class:"text-right"},Hc=i("th",{width:"18%",class:"text-right inv-actions"},null,-1),Gc=i("td",{class:"draggable-item drag-handle px-2"},[i("i",{class:"fas fa-bars"})],-1),Yc={key:0,class:"badge badge-ghost badge-xs"},Jc=["innerHTML"],Kc={class:"text-center"},Zc={class:"text-center"},$c={key:0},ed={key:1},td={key:0,class:"text-center"},nd={key:1},sd={key:2,class:"text-center"},od=i("br",null,null,-1),id={key:3,class:"text-center"},ad=i("br",null,null,-1),ld={class:"text-right"},rd={key:0},cd={key:1},dd=["data-tip"],ud=["onClick"],hd=i("i",{class:"far fa-edit"},null,-1),md=[hd],fd=["data-tip"],pd=["onClick"],_d={key:0,class:"far fa-trash-alt"},gd={key:1,class:"loading loading-spinner loading-xs"},vd={key:0},yd=i("td",{class:"px-2"},null,-1),bd={class:"align-top px-2"},wd={class:"flex items-center border rounded-md relative"},xd=["placeholder"],Cd={key:0,class:"autocomplete-dropdown bg-base-300"},Id=["onClick","innerHTML"],Ed={class:"align-top px-2"},kd=i("option",{disabled:"",selected:""},"Type",-1),Td=["value"],Ad={class:"flex items-center border rounded-md relative"},Sd=["placeholder"],Dd={key:0,class:"autocomplete-dropdown bg-base-300"},Pd=["onClick","innerHTML"],Md={class:"align-top"},jd={class:"flex items-center rounded-md"},qd=["placeholder"],Rd={class:"align-top"},Od={class:"flex items-center border rounded-lg"},Vd={class:"inline-flex"},Nd=["placeholder"],Bd={class:"align-top"},Fd={class:"flex items-center border rounded-md"},Wd=["placeholder"],Qd={key:0,class:"align-top"},Xd=["value"],Ud={key:1,class:"align-top"},Ld={class:"align-top"},zd={class:"flex items-center border rounded-md"},Hd=["placeholder"],Gd=i("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),Yd={key:2,class:"text-right"},Jd={key:3,class:"text-right"},Kd=["data-tip"],Zd={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},$d={key:0,class:"fa fa-plus"},eu={key:1,class:"loading loading-spinner loading-xs"},tu={colspan:"8",class:"text-right no-border"},nu={class:"text-right"},su={key:0,class:"line-through"},ou=i("td",null,null,-1),iu={colspan:"8",class:"text-right no-border"},au={class:"text-right"},lu=i("td",null,null,-1),ru={colspan:"8",class:"text-right no-border font-bold text-xl"},cu={class:"text-right no-border font-bold text-xl"},du=i("td",null,null,-1),uu={key:2},hu={colspan:"8",class:"text-right no-border"},mu={class:"text-right no-border"},fu={key:3},pu={colspan:"8",class:"text-right no-border"},_u={class:"text-right no-border font-bold text-xl"},gu={key:1,class:"relative"},vu={class:"flex justify-end mt-4"},yu={class:"border-2 border-slate-300 max-w-md"},bu=["src"];function wu(t,e,s,a,n,o){const f=j("QuoteNavBar"),m=j("remove-modal"),p=j("edit-item-modal"),d=j("Card");return r(),c("div",lc,[D(f,{quoteInfo:n.quote,emailActive:n.settings.easy_compta_email_addon_active,advanceActive:n.settings.easy_compta_advance_addon_active,currency:n.default_currency_symbol,noItems:n.no_items},null,8,["quoteInfo","emailActive","advanceActive","currency","noItems"]),n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),D(m,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=u=>this.removeItem(n.selectedItem,n.selectedInvoiceId)),onCancel:e[1]||(e[1]=u=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),n.loading?(r(),c("div",rc,dc)):_("",!0),o.isQuoteExpired&&n.quote.status=="pending"?(r(),c("div",uc,[i("div",hc,[mc,i("span",null,l(o.translations.quote_expired),1)])])):_("",!0),D(d,{topMargin:"mt-8",id:"quote-content"},{default:re(()=>[n.settings.easy_compta_signature_addon_active&&n.quote.signed==1?(r(),c("div",fc,[i("span",pc,l(o.translations.signed),1)])):_("",!0),i("div",_c,[i("div",gc,[i("div",null,[i("img",{src:n.settings.logo_url,style:Zn({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,vc)])]),i("div",yc,[i("p",bc,l(n.quote.quote_number),1),i("div",null,[w(l(o.translations.created_at)+": ",1),i("strong",null,l(n.quote.created_at),1)]),i("div",null,[w(l(o.translations.due_date)+": ",1),i("strong",null,l(n.quote.due_date),1)]),i("div",null,[w(l(o.translations.provisional_date)+": ",1),i("strong",null,l(n.quote.provisional_start_date),1)]),i("div",null,[w(l(o.translations.status)+": ",1),n.quote.status=="draft"?(r(),c("span",wc,l(o.translations.draft),1)):_("",!0),n.quote.status=="pending"?(r(),c("span",xc,l(o.translations.pending),1)):_("",!0),n.quote.status=="approved"?(r(),c("span",Cc,l(o.translations.approved),1)):_("",!0),n.quote.status=="rejected"?(r(),c("span",Ic,l(o.translations.rejected),1)):_("",!0)])])]),i("div",Ec,[i("div",null,[i("strong",null,l(o.translations.bill_to)+":",1),i("h4",null,[i("strong",null,l(n.client_detail.company_name),1)]),i("p",null,[w(l(n.client_detail.address),1),kc,w(" "+l(n.client_detail.postal_code)+", "+l(n.client_detail.city)+" ",1),Tc,w(" "+l(n.client_detail.country),1),Ac,n.client_detail.phone?(r(),c("a",{key:0,href:"tel:"+n.client_detail.phone},l(n.client_detail.phone),9,Sc)):_("",!0)])]),i("div",null,[i("strong",null,l(o.translations.received_from)+":",1),i("h4",null,[i("strong",null,l(n.settings.company_name),1)]),i("p",null,[w(l(n.settings.company_address),1),Dc,w(" "+l(n.settings.postal_code)+", "+l(n.settings.city)+" ",1),Pc,w(" "+l(n.settings.country),1),Mc,n.settings.company_phone?(r(),c("a",{key:0,href:"tel:"+n.settings.company_phone},l(n.settings.company_phone),9,jc)):_("",!0),qc,n.settings.mobile_phone?(r(),c("a",{key:1,href:"tel:"+n.settings.mobile_phone},l(n.settings.mobile_phone),9,Rc)):_("",!0)])])]),D(p,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[2]||(e[2]=u=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),i("form",{onSubmit:e[22]||(e[22]=K((...u)=>o.submitItems&&o.submitItems(...u),["prevent"]))},[i("table",Oc,[i("thead",null,[i("tr",null,[Vc,i("th",Nc,l(o.translations.item_ref),1),i("th",Bc,l(o.translations.item_name),1),i("th",Fc,l(o.translations.description),1),i("th",Wc,l(o.translations.quantity),1),i("th",Qc,l(o.translations.unit_price),1),n.settings.vat_active==1?(r(),c("th",Xc,l(o.translations.vat),1)):(r(),c("th",Uc)),i("th",Lc,l(o.translations.discount),1),i("th",zc,l(o.translations.total),1),Hc])]),i("tbody",null,[(r(!0),c(W,null,X(n.quoteItems,(u,h)=>(r(),c("tr",{key:u.id||h},[Gc,i("td",null,l(u.item_ref),1),i("td",null,[u.category_name?(r(),c("div",Yc,l(u.category_name),1)):_("",!0),i("div",null,l(u.item_name),1)]),i("td",{innerHTML:o.nl2br(u.item_description)},null,8,Jc),i("td",Kc,l(u.quantity),1),i("td",Zc,[w(l(u.unit_price),1),n.default_currency_symbol==n.client_currency?(r(),c("span",$c,l(n.default_currency_symbol),1)):(r(),c("span",ed,l(n.client_currency),1))]),n.settings.vat_active==1?(r(),c("td",td,l(u.vat_rate)+"% ",1)):(r(),c("td",nd)),n.settings.vat_active==1?(r(),c("td",sd,[w(l(u.discount)+"% ",1),od,w(" "+l(o.calculateDiscountAmountWithVAT(u.quantity,u.unit_price,u.vat_rate,u.discount)),1)])):(r(),c("td",id,[w(l(u.discount)+"% ",1),ad,w(" "+l(o.calculateDiscountAmount(u.quantity,u.unit_price,u.discount)),1)])),i("td",ld,[w(l(u.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(r(),c("span",rd,l(n.default_currency_symbol),1)):(r(),c("span",cd,l(n.client_currency),1))]),i("td",null,[n.quote.status=="draft"||n.quote.status=="pending"?(r(),c("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[i("button",{onClick:K(g=>o.editItem(u.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},md,8,ud)],8,dd)):_("",!0),n.quote.status=="draft"||n.quote.status=="pending"?(r(),c("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:K(g=>o.confirmremoveItem(u.id,n.quote.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[u.loading_del?_("",!0):(r(),c("i",_d)),u.loading_del?(r(),c("span",gd)):_("",!0)],8,pd)],8,fd)):_("",!0)])]))),128)),n.quote.status=="draft"||n.quote.status=="pending"?(r(),c("tr",vd,[yd,i("td",bd,[i("div",wd,[B(i("input",{type:"text","onUpdate:modelValue":e[3]||(e[3]=u=>n.newItem.item_ref=u),onInput:e[4]||(e[4]=(...u)=>o.fetchRefs&&o.fetchRefs(...u)),onFocus:e[5]||(e[5]=u=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,xd),[[J,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(r(),c("ul",Cd,[(r(!0),c(W,null,X(n.refs,u=>(r(),c("li",{key:u.ref,onClick:h=>o.selectItem(u),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(u.ref)},null,8,Id))),128))])):_("",!0)])]),i("td",Ed,[B(i("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[6]||(e[6]=u=>n.newItem.item_category=u)},[kd,(r(!0),c(W,null,X(n.categories,u=>(r(),c("option",{key:u.id,value:u.id},l(u.name),9,Td))),128))],512),[[ve,n.newItem.item_category]]),i("div",Ad,[B(i("input",{type:"text","onUpdate:modelValue":e[7]||(e[7]=u=>n.newItem.item_name=u),onInput:e[8]||(e[8]=(...u)=>o.fetchArticles&&o.fetchArticles(...u)),onFocus:e[9]||(e[9]=u=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,Sd),[[J,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(r(),c("ul",Dd,[(r(!0),c(W,null,X(n.articles,u=>(r(),c("li",{key:u.name,onClick:h=>o.selectItem(u),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(u.name)},null,8,Pd))),128))])):_("",!0)])]),i("td",Md,[i("div",jd,[B(i("textarea",{"onUpdate:modelValue":e[10]||(e[10]=u=>n.newItem.item_description=u),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[11]||(e[11]=u=>o.resize()),ref:"textarea"},null,40,qd),[[J,n.newItem.item_description]])])]),i("td",Rd,[i("div",Od,[i("div",Vd,[i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[12]||(e[12]=(...u)=>o.decrease&&o.decrease(...u))}," - "),B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[13]||(e[13]=u=>n.newItem.quantity=u),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[14]||(e[14]=(...u)=>o.updateTotal&&o.updateTotal(...u))},null,40,Nd),[[J,n.newItem.quantity]]),i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[15]||(e[15]=(...u)=>o.increase&&o.increase(...u))}," + ")])])]),i("td",Bd,[i("div",Fd,[B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[16]||(e[16]=u=>n.newItem.unit_price=u),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[17]||(e[17]=(...u)=>o.updateTotal&&o.updateTotal(...u))},null,40,Wd),[[J,n.newItem.unit_price]])])]),n.settings.vat_active==1?(r(),c("td",Qd,[B(i("select",{"onUpdate:modelValue":e[18]||(e[18]=u=>n.newItem.vat_rate=u),onChange:e[19]||(e[19]=(...u)=>o.updateTotal&&o.updateTotal(...u)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(r(!0),c(W,null,X(n.list_vats,u=>(r(),c("option",{key:u,value:u.rate},l(u.rate)+"% ",9,Xd))),128))],544),[[ve,n.newItem.vat_rate]])])):(r(),c("td",Ud)),i("td",Ld,[i("div",zd,[B(i("input",{type:"number",min:"0",max:"100","onUpdate:modelValue":e[20]||(e[20]=u=>n.newItem.discount=u),placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[21]||(e[21]=(...u)=>o.updateTotal&&o.updateTotal(...u))},null,40,Hd),[[J,n.newItem.discount]]),Gd])]),n.settings.vat_active==1?(r(),c("td",Yd,l(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(r(),c("td",Jd,l(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),i("td",null,[i("span",{class:"lg:tooltip","data-tip":o.translations.add},[i("button",Zd,[n.loading_add?_("",!0):(r(),c("i",$d)),n.loading_add?(r(),c("span",eu)):_("",!0)])],8,Kd)])])):_("",!0),i("tr",null,[i("td",tu,[i("strong",null,l(o.translations.subtotal),1)]),i("td",nu,[o.totalAmount!==o.totalAmountWithoutDiscount?(r(),c("span",su,l(o.totalAmountWithoutDiscount),1)):_("",!0),w(" "+l(o.totalAmount),1)]),ou]),n.settings.vat_active==1?(r(!0),c(W,{key:1},X(o.getUniqueVATRates(),(u,h)=>(r(),c("tr",{key:h},[i("td",iu,[i("strong",null,l(o.translations.tax)+" ("+l(u)+"%) ",1)]),i("td",au,l(o.calculateVATForRate(u)),1),lu]))),128)):_("",!0),i("tr",null,[i("td",ru,[i("strong",null,l(o.translations.total),1)]),i("td",cu,l(o.calculateTotalAmountWithVAT()),1),du]),n.client_currency!=n.default_currency_symbol?(r(),c("tr",uu,[i("td",hu,[i("strong",null,l(o.translations.exchange_rate),1)]),i("td",mu,l(n.quote.exchange_rate),1)])):_("",!0),n.client_currency!=n.default_currency_symbol?(r(),c("tr",fu,[i("td",pu,[i("strong",null,l(o.translations.total)+" "+l(n.default_currency_symbol),1)]),i("td",_u,l(o.totalAmountDefaultCurrency)+l(n.default_currency_symbol),1)])):_("",!0)])])],32),n.settings.easy_compta_signature_addon_active&&n.quote.signed==1&&n.quote.file_sign?(r(),c("div",gu,[i("div",vu,[i("span",yu,[i("img",{src:o.signatureImageUrl,alt:"Signature"},null,8,bu)])])])):_("",!0)]),_:1})])}var xu=oe(ac,[["render",wu]]);const Cu={name:"QuoteNew",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{clientOptions:[],clients:[],quote:{number:"",due_date:"",provisional_start_date:"",client_id:"",status:""},showError:!1,loading:!1,loadingBtn:!1,settings:[],last_quote_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},customLabel(t){return t.text},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.quote_prefix}_${String(this.settings.last_quote_id).padStart(4,"0")}`;this.quote.number=s}else{const e=await t.json()}}catch{this.loading=!1}},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/quotes",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting quote:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Iu={class:"pt-2 pr-4"},Eu={class:"flex justify-between items-center mb-4"},ku={class:"card-title"},Tu=i("div",{class:"divider mt-2"},null,-1),Au={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Su={class:"grid grid-cols-3 gap-4"},Du={class:"ecwp-group form-group mb-4"},Pu={for:"quoteNumber",class:"ecwp-label"},Mu={class:"ecwp-group form-group mb-4"},ju={for:"quoteDate",class:"ecwp-label"},qu={class:"ecwp-group form-group mb-4"},Ru={for:"quoteDatePr",class:"ecwp-label"},Ou={class:"grid grid-cols-2 gap-4"},Vu={class:"ecwp-group form-group mb-4"},Nu={for:"client",class:"ecwp-label"},Bu={class:"ecwp-group form-group mb-4"},Fu={for:"status",class:"ecwp-label"},Wu={value:"draft",selected:""},Qu={value:"pending"},Xu={value:"approved"},Uu={value:"rejected"},Lu={class:"flex justify-between"},zu=["disabled"],Hu={key:0,class:"loading loading-spinner loading-sm"};function Gu(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",Iu,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),D(p,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:re(()=>[i("div",Eu,[i("h2",ku,l(o.translations.new_quote),1)]),Tu,n.loading?(r(),c("div",Au)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitQuote&&o.submitQuote(...d),["prevent"]))},[i("div",Su,[i("div",Du,[i("label",Pu,l(o.translations.quote_number),1),B(i("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.quote.number=d),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[J,n.quote.number]])]),i("div",Mu,[i("label",ju,l(o.translations.due_date),1),D(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.quote.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),i("div",qu,[i("label",Ru,l(o.translations.provisional_date),1),D(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteDatePr",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=d=>n.quote.provisional_start_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])])]),i("div",Ou,[i("div",Vu,[i("label",Nu,l(o.translations.company_name),1),D(m,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[3]||(e[3]=d=>n.quote.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",Bu,[i("label",Fu,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=d=>n.quote.status=d),class:k(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[i("option",Wu,l(o.translations.draft),1),i("option",Qu,l(o.translations.pending),1),i("option",Xu,l(o.translations.approved),1),i("option",Uu,l(o.translations.rejected),1)],2),[[ve,n.quote.status]])])]),i("div",Lu,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.submit)+" ",1),n.loadingBtn?(r(),c("span",Hu)):_("",!0)],8,zu)])],32)]),_:1})])}var Yu=oe(Cu,[["render",Gu]]);const Ju={name:"InvoicesList",components:{Card:Xe,RemoveModal:xt},data(){return{invoices:[],showInvoiceDetailsModal:!1,editInvoiceModal:!1,selectedInvoice:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchInvoices(),this.loadSettings()},methods:{fetchInvoices(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/invoices?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.invoices=s.invoices,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching invoices:",s)}).finally(()=>{this.loading=!1})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return $n(t,this.default_vat.rate)},calculateWithoutVAT(t){return es(t)},generatePaginationButtons(){this.paginationButtons=ts(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchInvoices(t)},perPageChanged(){this.fetchInvoices()},formatAmount(t,e){return ns(t,e,this.settings.currency_position)},showToast(t,e){ss(this.toast,t,e)},confirmDeleteInvoice(t){this.selectedInvoice=t,modal_remove.showModal(),this.showRemoveModal=!0},deleteInvoice(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchInvoices(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting invoice:",e.statusText))}).catch(e=>{console.log(e.message);const s=e&&e.message?e.message:"Error deleting client";s==="This client cannot be deleted because it has associated data."?this.showToast(s,"alert-error"):console.error("Error deleting client:",e)})}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Ku={class:"pt-2 pr-4"},Zu={class:"flex justify-between items-center"},$u={class:"card-title"},eh={class:"btn btn-primary rounded-full"},th=i("i",{class:"fas fa-plus-circle"},null,-1),nh={key:0,class:"ms-2"},sh={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab3"},oh=i("i",{class:"fas fa-file-export"},null,-1),ih=["data-tip"],ah={class:"btn btn-outline btn-accent rounded-full",disabled:""},lh=i("i",{class:"fas fa-file-export"},null,-1),rh=i("div",{class:"divider mt-2"},null,-1),ch={class:"flex items-center mb-4"},dh={for:"perPageSelect",class:"mr-2"},uh=["value"],hh={class:"overflow-x-auto"},mh={key:0,class:"table w-full"},fh={class:"flex justify-center"},ph={key:0,class:"badge badge-primary badge-outline badge-sm mr-2"},_h={key:0,class:"badge badge-scondary badge-outline badge-sm"},gh={key:1,class:"badge badge-warning badge-outline badge-sm"},vh={key:2,class:"badge badge-success badge-outline badge-sm"},yh={key:3,class:"badge badge-error badge-outline badge-sm ms-2"},bh={key:0},wh={key:0},xh={key:0},Ch={key:1},Ih={key:0},Eh={key:1},kh={key:1},Th=i("span",{class:"loading loading-bars loading-sm"},null,-1),Ah=[Th],Sh={key:0},Dh={key:1},Ph=i("span",{class:"loading loading-bars loading-sm"},null,-1),Mh=[Ph],jh={key:0},qh={key:1},Rh=i("span",{class:"loading loading-bars loading-sm"},null,-1),Oh=[Rh],Vh={class:"flex justify-end"},Nh=["data-tip"],Bh=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"far fa-eye"})],-1),Fh=["data-tip"],Wh=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"fas fa-pencil-alt"})],-1),Qh=["data-tip"],Xh=["onClick"],Uh=i("i",{class:"far fa-trash-alt"},null,-1),Lh=[Uh],zh={key:1},Hh=i("div",{class:"flex gap-4 items-center"},[i("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),i("div",{class:"flex flex-col gap-4 w-full"},[i("div",{class:"skeleton h-4 w-full"}),i("div",{class:"skeleton h-4 w-full"})])],-1),Gh=i("div",{class:"divider my-1"},null,-1),Yh=[Hh,Gh],Jh={class:"join ecwp_pagination mt-6 pt-4"},Kh=["onClick"];function Zh(t,e,s,a,n,o){const f=j("remove-modal"),m=j("router-link"),p=j("Card");return r(),c("div",Ku,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),D(f,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=d=>this.deleteInvoice(n.selectedInvoice)),onCancel:e[1]||(e[1]=d=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),D(p,{topMargin:"mt-8"},{default:re(()=>[i("div",Zu,[i("h2",$u,l(o.translations.invoices),1),i("div",null,[D(m,{to:{name:"InvoiceNew"}},{default:re(()=>[i("button",eh,[w(l(o.translations.add)+" ",1),th])]),_:1}),n.settings.easy_compta_export_addon_active==1?(r(),c("span",nh,[i("a",sh,[w(l(o.translations.export)+" ",1),oh])])):(r(),c("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[i("button",ah,[w(l(o.translations.export)+" ",1),lh])],8,ih))])]),rh,i("div",ch,[i("label",dh,l(o.translations.display_per_page),1),B(i("select",{id:"perPageSelect","onUpdate:modelValue":e[2]||(e[2]=d=>n.perPage=d),onChange:e[3]||(e[3]=(...d)=>o.perPageChanged&&o.perPageChanged(...d))},[(r(!0),c(W,null,X(n.perPageOptions,d=>(r(),c("option",{key:d,value:d},l(d),9,uh))),128))],544),[[ve,n.perPage]])]),i("div",hh,[n.loading?(r(),c("div",zh,[(r(!0),c(W,null,X(n.skeletonRows,d=>(r(),c("div",{key:d,class:"flex flex-col gap-4 w-full"},Yh))),128))])):(r(),c("table",mh,[i("thead",null,[i("tr",null,[i("th",null,l(o.translations.invoice_number),1),i("th",null,l(o.translations.client),1),i("th",null,l(o.translations.status),1),i("th",null,l(o.translations.total),1),i("th",null,l(o.translations.due_date),1),i("th",null,l(o.translations.created_at),1),i("th",fh,l(o.translations.actions),1)])]),i("tbody",null,[(r(!0),c(W,null,X(n.invoices,d=>(r(),c("tr",{key:d.id},[i("td",null,[d.advance==1?(r(),c("span",ph,l(o.translations.advance),1)):_("",!0),w(l(d.invoice_number),1)]),i("td",null,l(d.client_name),1),i("td",null,[d.status=="draft"?(r(),c("span",_h,l(o.translations.draft),1)):_("",!0),d.status=="unpaid"?(r(),c("span",gh,l(o.translations.unpaid),1)):_("",!0),d.status=="paid"?(r(),c("span",vh,l(o.translations.paid),1)):_("",!0),d.credit=="1"?(r(),c("span",yh,l(o.translations.credit),1)):_("",!0)]),i("td",null,[n.loadingPrice?(r(),c("div",kh,Ah)):(r(),c("div",bh,[n.settings.easy_compta_advance_addon_active&&d.advance==1?(r(),c("div",wh,l(o.formatAmount(d.advance_amount,d.client_currency||n.default_currency_symbol)),1)):_("",!0),n.settings.vat_active==1?(r(),c("div",{key:1,class:k({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(r(),c("span",xh,l(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(r(),c("span",Ch,l(o.formatAmount(d.total_amount,d.client_currency)),1))],2)):(r(),c("div",{key:2,class:k({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(r(),c("span",Ih,l(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(r(),c("span",Eh,l(o.formatAmount(d.total_amount,d.client_currency)),1))],2))]))]),i("td",null,[n.loadingPrice?(r(),c("div",Dh,Mh)):(r(),c("div",Sh,l(d.due_date),1))]),i("td",null,[n.loadingPrice?(r(),c("div",qh,Oh)):(r(),c("div",jh,l(d.created),1))]),i("td",Vh,[i("span",{class:"lg:tooltip","data-tip":o.translations.view},[D(m,{to:{name:"InvoiceViewDetail",params:{id:d.id}}},{default:re(()=>[Bh]),_:2},1032,["to"])],8,Nh),d.status=="draft"?(r(),c("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[D(m,{to:{name:"InvoiceEdit",params:{id:d.id}}},{default:re(()=>[Wh]),_:2},1032,["to"])],8,Fh)):_("",!0),d.status=="draft"?(r(),c("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:u=>o.confirmDeleteInvoice(d.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Lh,8,Xh)],8,Qh)):_("",!0)])]))),128))])]))]),i("div",Jh,[(r(!0),c(W,null,X(n.paginationButtons,d=>(r(),c("button",{key:d,class:k(["join-item btn",{"btn-disabled":d==="..."||d===n.currentPage}]),onClick:u=>o.goToPage(d)},l(d),11,Kh))),128))])]),_:1})])}var $h=oe(Ju,[["render",Zh]]);const em={name:"sendInvoice",components:{VueEditor:It.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"invoice",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},tm=["id","open"],nm={class:"modal-box"},sm={class:"font-bold text-lg"},om={key:0},im={class:"grid grid-cols-1 gap-4"},am=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),lm=i("div",{class:"skeleton h-4 w-full"},null,-1),rm=[am,lm],cm={class:"grid grid-cols-1 gap-4"},dm=["type"],um=["for"],hm=["id","value","disabled","onInput"],mm={key:1},fm=["for"],pm={class:"form-group mt-4 flex justify-end"},_m=["disabled"],gm={key:0,class:"loading loading-spinner loading-sm"};function vm(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",nm,[i("h3",sm,l(o.translations.send_invoice),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",om,[i("div",im,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},rm))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",cm,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,um),i("input",{id:p,class:k(["ecwp-input input input-bordered",m.class||"w-full"]),value:m.value,disabled:m.disabled,onInput:d=>o.updateFieldValue(p,d.target.value)},null,42,hm)],8,dm)):(r(),c("div",mm,[i("label",{for:p,class:"form-label"},l(m.label),9,fm),D(f,{modelValue:m.value,"onUpdate:modelValue":d=>m.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",pm,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.send)+" ",1),n.loadingBtn?(r(),c("span",gm)):_("",!0)],8,_m)])],32))])],8,tm)])}var ym=oe(em,[["render",vm]]);const bm={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:"",paymentMethods:[],hasPaymentMethodError:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchPaymentMethods()},methods:{async fetchPaymentMethods(){try{const t=await fetch("/wp-json/my-easy-compta/v1/payments/methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!t.ok)throw new Error(`Erreur : ${t.status}`);const e=await t.json();this.paymentMethods=e}catch(t){console.error("Erreur lors de la r\xE9cup\xE9ration des m\xE9thodes de paiement :",t)}},onConfirm(){if(!this.selectedPaymentMethod){this.hasPaymentMethodError=!0;return}this.hasPaymentMethodError=!1,this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_paid").close()}}},wm=["open"],xm={class:"modal-box"},Cm={class:"font-bold text-lg"},Im=i("div",{class:"text-center text-red-400 mb-2"},[i("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),Em={class:"text-lg font-semibold text-center"},km={class:"my-4 text-center text-xl"},Tm={key:0,class:"mt-4 mb-4"},Am={class:"ecwp-group form-group"},Sm={for:"payment_method",class:"ecwp-label form-label"},Dm={value:""},Pm=["value"],Mm={class:"flex justify-between space-x-4"};function jm(t,e,s,a,n,o){return r(),c("div",null,[i("dialog",{id:"modal_confirm_paid",class:"modal",open:t.showModal},[i("div",xm,[i("h3",Cm,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...f)=>o.closeModal&&o.closeModal(...f))}," \u2715 "),Im,i("h2",Em,l(s.title),1),i("p",km,l(s.message),1),s.status==="paid"?(r(),c("div",Tm,[i("div",Am,[i("label",Sm,l(o.translations.payment_method),1),B(i("select",{id:"payment_method","onUpdate:modelValue":e[1]||(e[1]=f=>n.selectedPaymentMethod=f),class:k([{"input-error":n.hasPaymentMethodError},"ecwp-input input input-bordered w-full"])},[i("option",Dm,l(o.translations.select),1),(r(!0),c(W,null,X(n.paymentMethods,f=>(r(),c("option",{key:f.id,value:f.id},l(f.method_name),9,Pm))),128))],2),[[ve,n.selectedPaymentMethod]])])])):_("",!0),i("div",Mm,[i("button",{onClick:e[2]||(e[2]=(...f)=>o.onCancel&&o.onCancel(...f)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[3]||(e[3]=(...f)=>o.onConfirm&&o.onConfirm(...f)),class:"btn rounded-full btn-error text-white"},l(s.confirmText),1)])])],8,wm)])}var qm=oe(bm,[["render",jm]]);const Rm={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_credit").close()}}},Om=["open"],Vm={class:"modal-box"},Nm={class:"font-bold text-lg"},Bm=i("div",{class:"text-center text-red-400 mb-2"},[i("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),Fm={class:"text-lg font-semibold text-center"},Wm={class:"my-4 text-center text-xl"},Qm={class:"flex justify-between space-x-4"};function Xm(t,e,s,a,n,o){return r(),c("div",null,[i("dialog",{id:"modal_confirm_credit",class:"modal",open:t.showModal},[i("div",Vm,[i("h3",Nm,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...f)=>o.closeModal&&o.closeModal(...f))}," \u2715 "),Bm,i("h2",Fm,l(s.title),1),i("p",Wm,l(s.message),1),i("div",Qm,[i("button",{onClick:e[1]||(e[1]=(...f)=>o.onCancel&&o.onCancel(...f)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[2]||(e[2]=(...f)=>o.onConfirm&&o.onConfirm(...f)),class:"btn rounded-full btn-error text-white"},l(s.confirmText),1)])])],8,Om)])}var Um=oe(Rm,[["render",Xm]]);const Lm={name:"InvoiceNavBar",components:{SendInvoiceModal:ym,RemoveModal:xt,ConfirmModal:bn,ConfirmModalPaid:qm,ConfirmModalCredit:Um},props:{invoiceInfo:Object,currencyDefault:Object,currencyClient:Object,emailActive:String,qrCodeActive:String,totalAmount:String,noItems:Boolean},data(){return{showConfirmModal:!1,showConfirmCreditModal:!1,loading:!1,sendInvoiceModal:!1,loadingModal:!1,loadingPdf:!1,client_detail:null,selectedStatus:null,subject:"",content:"",showQrCodeModal:!1,qrCodeSrc:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{changeInvoiceStatusWithPaymentMethod(t){const e=this.selectedStatus;this.changeInvoiceStatus(e,t),this.showConfirmModal=!1},async changeInvoiceStatus(t,e){this.loading=!0;try{const a=await(await fetch("/wp-json/my-easy-compta/v1/invoices/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id,status:t,method:e})})).json();a.success?(this.invoiceInfo.status=t,this.loading=!1):(console.error("Failed to update invoice status:",a.message),this.loading=!1)}catch(s){console.error("An error occurred while updating invoice status:",s)}},async addCreditInvoice(){this.loading=!0;try{const e=await(await fetch("/wp-json/my-easy-compta/v1/invoices/credit",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id})})).json();e.success?(this.invoiceInfo.credit=1,this.loading=!1):(console.error("Failed to update invoice status:",e.message),this.loading=!1)}catch(t){console.error("An error occurred while updating invoice status:",t)}},exportToPDF(t){this.loadingPdf=!0;let s=`/wp-json/my-easy-compta/v1/invoices/pdf/${this.invoiceInfo.id}?currency_id=${t}`;fetch(s,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(a=>{if(!a.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return a.blob()}).then(a=>{const n=URL.createObjectURL(a);window.open(n),this.loadingPdf=!1}).catch(a=>{console.error("There was a problem with the fetch operation:",a),this.loadingPdf=!1})},sendInvoice(t){this.loadingModal=!0,this.sendInvoiceModal=!0,modal_send_invoice.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.subject=e.email_invoice_subject,this.content=e.email_invoice_content}else{const e=await t.json();this.showToast(e.message,"alert-error")}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},confirmValidateInvoice(t){this.selectedStatus=t,t=="unpaid"?modal_confirm.showModal():t=="paid"&&modal_confirm_paid.showModal(),this.showConfirmModal=!0},confirmCreditInvoice(){modal_confirm_credit.showModal(),this.showConfirmCreditModal=!0},async generateQRCode(){this.loading=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/generate-qrcode",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_ref:this.invoiceInfo.invoice_number||`Facture #${this.invoiceInfo.number}`,price:parseFloat(this.invoiceInfo.total_amount)})}),e=await t.json();t.ok&&e.qr_code?(this.qrCodeSrc=e.qr_code,this.showQrCodeModal=!0):console.error("Erreur lors de la g\xE9n\xE9ration du QR Code :",e.message)}catch(t){console.error("Erreur lors de l'appel \xE0 l'API pour g\xE9n\xE9rer le QR code :",t)}finally{this.loading=!1}},closeQrCodeModal(){this.showQrCodeModal=!1},downloadQRCode(){const t=document.createElement("a");t.href=this.qrCodeSrc,t.download=`qr_code_${this.invoiceInfo.invoice_number||this.invoiceInfo.number}.png`,t.click()}}},zm={key:0},Hm={key:1,class:"modal modal-open"},Gm={class:"modal-box"},Ym={class:"font-bold text-lg"},Jm={class:"mb-4"},Km=["src"],Zm={class:"flex justify-end space-x-4"},$m={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},ef=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),tf=[ef],nf={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},sf=i("div",{class:"dropdown"},[i("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),i("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[i("li",null,[i("a",null,"Item")]),i("li",null,[i("a",null,"Parent"),i("ul",{class:"p-2"},[i("li",null,[i("a",null,"Submenu")]),i("li",null,[i("a",null,"Submenu")])])]),i("li",null,[i("a",null,"Item")])])],-1),of={class:"hidden lg:flex gap-2"},af={class:"btn btn-sm"},lf=i("i",{class:"far fa-edit"},null,-1),rf={key:1},cf={class:"btn btn-sm",disabled:""},df=i("i",{class:"far fa-edit"},null,-1),uf={key:2},hf=i("i",{class:"fa fa-check"},null,-1),mf={class:"btn btn-outline btn-success btn-sm hover:text-white",disabled:""},ff=i("i",{class:"fa fa-check"},null,-1),pf={key:0},_f={class:"btn btn-sm ms-2",disabled:""},gf=i("i",{class:"fas fa-undo"},null,-1),vf={key:1},yf=i("i",{class:"fas fa-undo"},null,-1),bf=["disabled"],wf=i("i",{class:"far fa-file-pdf"},null,-1),xf={key:0,class:"loading loading-spinner loading-sm"},Cf={class:"flex gap-2"},If=i("i",{class:"fas fa-paper-plane"},null,-1),Ef={key:0},kf={key:1},Tf={key:2,class:"far fa-envelope"},Af=["data-tip"],Sf={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Df=i("i",{class:"fas fa-paper-plane"},null,-1),Pf=["data-tip"],Mf={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},jf=i("i",{class:"fas fa-paper-plane"},null,-1),qf={key:3},Rf=i("i",{class:"fas fa-qrcode"},null,-1),Of={key:1,click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Vf=i("i",{class:"fas fa-qrcode"},null,-1),Nf=["data-tip"],Bf={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Ff=i("i",{class:"fas fa-qrcode"},null,-1),Wf={key:5},Qf={key:0,class:"dropdown dropdown-end"},Xf={tabindex:"0",role:"button",class:"btn btn-outline btn-success btn-sm"},Uf=i("i",{class:"far fa-file-pdf"},null,-1),Lf={key:0,class:"loading loading-spinner loading-sm"},zf={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},Hf=["disabled"],Gf=["disabled"],Yf={key:6},Jf=["disabled"],Kf=i("i",{class:"far fa-file-pdf"},null,-1),Zf={key:0},$f={key:1},ep={key:2,class:"loading loading-spinner loading-sm"},tp=i("i",{class:"fas fa-check"},null,-1),np=["data-tip"],sp={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},op=i("i",{class:"fas fa-check"},null,-1);function ip(t,e,s,a,n,o){const f=j("send-invoice-modal"),m=j("confirm-modal"),p=j("confirm-modal-paid"),d=j("confirm-modal-credit"),u=j("router-link");return r(),c("div",null,[s.emailActive==1?(r(),c("div",zm,[D(f,{loading:n.loadingModal,"show-modal":n.sendInvoiceModal,"modal-id":"modal_send_invoice",client:n.client_detail,"invoice-id":s.invoiceInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=h=>n.sendInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):_("",!0),D(m,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:e[1]||(e[1]=h=>o.changeInvoiceStatus("unpaid")),onCancel:e[2]||(e[2]=h=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status"]),D(p,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:o.changeInvoiceStatusWithPaymentMethod,onCancel:e[3]||(e[3]=h=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status","onConfirm"]),D(d,{"show-modal":n.showConfirmCreditModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[4]||(e[4]=h=>this.addCreditInvoice()),onCancel:e[5]||(e[5]=h=>n.showConfirmCreditModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.qrCodeActive==1&&n.showQrCodeModal?(r(),c("div",Hm,[i("div",Gm,[i("h3",Ym,l(o.translations.download_qr_code),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[6]||(e[6]=h=>o.closeQrCodeModal())}," \u2715 "),i("div",Jm,[i("img",{src:n.qrCodeSrc,alt:"QR Code",class:"max-w-full h-auto mx-auto"},null,8,Km)]),i("div",Zm,[i("button",{onClick:e[7]||(e[7]=(...h)=>o.downloadQRCode&&o.downloadQRCode(...h)),class:"btn btn-primary"},l(o.translations.download_qr_code),1)])])])):_("",!0),n.loading?(r(),c("div",$m,tf)):_("",!0),i("div",nf,[i("div",null,[sf,i("div",of,[s.invoiceInfo.status=="draft"?(r(),Vs(u,{key:0,to:{name:"InvoiceEdit",params:{id:s.invoiceInfo.id}}},{default:re(()=>[i("button",af,[lf,w(" "+l(o.translations.edit_invoice),1)])]),_:1},8,["to"])):(r(),c("div",rf,[i("button",cf,[df,w(" "+l(o.translations.edit_invoice),1)])])),s.invoiceInfo.status=="unpaid"&&!s.noItems?(r(),c("div",uf,[i("button",{class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[8]||(e[8]=h=>o.confirmValidateInvoice("paid"))},[hf,w(" "+l(o.translations.mark_as_paid),1)])])):(r(),c(W,{key:3},[i("div",null,[i("button",mf,[ff,w(" "+l(o.translations.mark_as_paid),1)])]),s.invoiceInfo.credit!=0&&s.invoiceInfo.status=="paid"&&!s.noItems?(r(),c("div",pf,[i("button",_f,[gf,w(" "+l(o.translations.credit_invoice),1)])])):_("",!0),s.invoiceInfo.credit==0&&s.invoiceInfo.status=="paid"&&!s.noItems?(r(),c("div",vf,[i("button",{class:"btn btn-sm ms-2",onClick:e[9]||(e[9]=h=>o.confirmCreditInvoice())},[yf,w(" "+l(o.translations.credit_invoice),1)])])):_("",!0)],64))])]),s.invoiceInfo.status=="draft"?(r(),c("button",{key:0,onClick:e[10]||(e[10]=h=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-secondary btn-sm",disabled:n.loadingPdf},[wf,i("span",null,l(o.translations.previewPDF),1),n.loadingPdf?(r(),c("span",xf)):_("",!0)],8,bf)):_("",!0),i("div",Cf,[s.emailActive==1&&s.invoiceInfo.status!="draft"?(r(),c("button",{key:0,onClick:e[11]||(e[11]=K(h=>o.sendInvoice(s.invoiceInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[If,s.invoiceInfo.sent==1?(r(),c("span",Ef,l(o.translations.resend_invoice),1)):(r(),c("span",kf,l(o.translations.send_invoice),1)),s.invoiceInfo.sent==1?(r(),c("i",Tf)):_("",!0)])):s.emailActive==1&&s.invoiceInfo.status=="draft"?(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.draft_cannot_send},[i("button",Sf,[Df,w(" "+l(o.translations.send_invoice),1)])],8,Af)):(r(),c("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[i("button",Mf,[jf,w(" "+l(o.translations.send_invoice),1)])],8,Pf)),s.qrCodeActive==1?(r(),c("div",qf,[s.invoiceInfo.status=="unpaid"?(r(),c("button",{key:0,class:"btn btn-outline btn-accent btn-sm",onClick:e[12]||(e[12]=(...h)=>o.generateQRCode&&o.generateQRCode(...h))},[Rf,w(" "+l(o.translations.generate_qrcode),1)])):(r(),c("button",Of,[Vf,w(" "+l(o.translations.generate_qrcode),1)]))])):(r(),c("div",{key:4,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_qrcode_addon},[i("button",Bf,[Ff,w(" "+l(o.translations.generate_qrcode),1)])],8,Nf)),s.currencyDefault.currency_id!==s.currencyClient.currency_id?(r(),c("div",Wf,[s.invoiceInfo.status!="draft"?(r(),c("div",Qf,[i("div",Xf,[Uf,w(" "+l(o.translations.exportToPDF)+" ",1),n.loadingPdf?(r(),c("span",Lf)):_("",!0)]),i("ul",zf,[i("li",null,[i("a",{onClick:e[13]||(e[13]=h=>o.exportToPDF(s.currencyDefault.currency_id)),disabled:n.loadingPdf},l(o.translations.invoice_in)+" "+l(s.currencyDefault.currency_symbol),9,Hf)]),i("li",null,[i("a",{onClick:e[14]||(e[14]=h=>o.exportToPDF(s.currencyClient.currency_id)),disabled:n.loadingPdf},l(o.translations.invoice_in)+" "+l(s.currencyClient.currency_symbol),9,Gf)])])])):_("",!0)])):(r(),c("div",Yf,[s.invoiceInfo.status!="draft"?(r(),c("button",{key:0,onClick:e[15]||(e[15]=h=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[Kf,s.invoiceInfo.status!="draft"?(r(),c("span",Zf,l(o.translations.exportToPDF),1)):(r(),c("span",$f,l(o.translations.previewPDF),1)),n.loadingPdf?(r(),c("span",ep)):_("",!0)],8,Jf)):_("",!0)])),s.invoiceInfo.status=="draft"&&!s.noItems?(r(),c("button",{key:7,class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[16]||(e[16]=h=>o.confirmValidateInvoice("unpaid"))},[tp,w(" "+l(o.translations.validateInvoice),1)])):_("",!0),s.invoiceInfo.status=="draft"&&s.noItems?(r(),c("div",{key:8,class:"tooltip tooltip-left tooltip-warning","data-tip":o.translations.min_article},[i("button",sp,[op,w(" "+l(o.translations.validateInvoice),1)])],8,np)):_("",!0)])])])}var ap=oe(Lm,[["render",ip]]);const lp={components:{VueEditor:It.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:"Nom de l'item"},item_description:{label:"Description de l'item",type:"textarea"},quantity:{label:"Quantit\xE9",type:"number"},vat_rate:{label:"Taux de TVA",type:"number"},unit_price:{label:"Prix unitaire",type:"number"},discount:{label:"Remise",type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/invoices/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},rp=["id","open"],cp={class:"modal-box"},dp={class:"font-bold text-lg"},up={key:0},hp={class:"grid grid-cols-1 gap-4"},mp=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),fp=i("div",{class:"skeleton h-4 w-full"},null,-1),pp=[mp,fp],_p={class:"grid grid-cols-1 gap-4"},gp=["type"],vp=["for"],yp=["id","onUpdate:modelValue"],bp={key:1},wp=["for"],xp={class:"form-group mt-4 flex justify-end"},Cp=["disabled"],Ip={key:0,class:"loading loading-spinner loading-sm"};function Ep(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",cp,[i("h3",dp,l(s.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",up,[i("div",hp,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},pp))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",_p,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,vp),B(i("input",{id:p,"onUpdate:modelValue":d=>n.editedItem[p]=d,class:k(["ecwp-input input input-bordered",m.class||"w-full"])},null,10,yp),[[J,n.editedItem[p]]])],8,gp)):(r(),c("div",bp,[i("label",{for:p,class:"form-label"},l(m.label),9,wp),D(f,{id:p,modelValue:n.editedItem[p],"onUpdate:modelValue":d=>n.editedItem[p]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",xp,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",Ip)):_("",!0)],8,Cp)])],32))])],8,rp)])}var kp=oe(lp,[["render",Ep]]);const Tp={name:"sendRemind",components:{VueEditor:It.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"remind",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Ap=["id","open"],Sp={class:"modal-box"},Dp={class:"font-bold text-lg"},Pp={key:0},Mp={class:"grid grid-cols-1 gap-4"},jp=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),qp=i("div",{class:"skeleton h-4 w-full"},null,-1),Rp=[jp,qp],Op={class:"grid grid-cols-1 gap-4"},Vp=["type"],Np=["for"],Bp=["id","value","disabled","onInput"],Fp={key:1},Wp=["for"],Qp={class:"form-group mt-4 flex justify-end"},Xp=["disabled"],Up={key:0,class:"loading loading-spinner loading-sm"};function Lp(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",Sp,[i("h3",Dp,l(o.translations.remind_invoice),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",Pp,[i("div",Mp,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},Rp))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",Op,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,Np),i("input",{id:p,class:k(["ecwp-input input input-bordered",m.class||"w-full"]),value:m.value,disabled:m.disabled,onInput:d=>o.updateFieldValue(p,d.target.value)},null,42,Bp)],8,Vp)):(r(),c("div",Fp,[i("label",{for:p,class:"form-label"},l(m.label),9,Wp),D(f,{modelValue:m.value,"onUpdate:modelValue":d=>m.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",Qp,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.send)+" ",1),n.loadingBtn?(r(),c("span",Up)):_("",!0)],8,Xp)])],32))])],8,Ap)])}var zp=oe(Tp,[["render",Lp]]);const Hp={name:"InvoiceViewDetail",components:{Card:Xe,InvoiceNavBar:ap,EditItemModal:kp,RemoveModal:xt,RemindInvoiceModal:zp},data(){return{selectedItem:null,SelectedInvoiceId:null,editItemsModal:!1,RemindInvoiceModal:!1,no_items:!0,loading:!1,loading_add:!1,invoice:[],invoiceItems:[],newItem:{loading_del:!1,item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},settings:[],client_detail:[],list_vats:[],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",articles:[],categories:[],refs:[],showDropdown:!1,showDropdownRef:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isInvoiceOverdue(){const t=new Date().getTime(),e=this.invoice.due_date?new Date(this.invoice.due_date).getTime():null;return e&&e<t},defaultCurrency(){return{currency_id:this.settings.default_currency,currency_symbol:this.default_currency_symbol}},clientCurrency(){return{currency_id:this.client_detail.currency_id,currency_symbol:this.client_currency}},totalAmountWithoutDiscount(){const t=this.invoiceItems.reduce((e,s)=>{const a=s.quantity*s.unit_price;return e+a},0);return this.formatCurrency(t)},totalAmount(){const t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.invoiceItems.reduce((a,n)=>a+parseFloat(n.total_amount),0)*this.invoice.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)}},methods:{getUniqueVATRates(){const t=new Set;return this.invoiceItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.invoiceItems.forEach(s=>{if(s.vat_rate===t){const a=s.quantity*s.unit_price,n=a*s.discount/100;e+=(a-n)*t/100}}),this.formatCurrency(e)},calculateTotalAmountWithVAT(){let t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.settings.easy_compta_woo_addon_active==1&&(t+=parseFloat(this.invoice.shipping_amount||0)),this.formatCurrency(t)},formatShippingAmout(t){return this.formatShippingCurrency(t)},formatShippingCurrency(t){const s=(parseFloat(t)||0).toFixed(2),a=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${s}${a}`},fetchInvoice(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.invoice=t,this.fetchClientInfo(t.client_id)):console.error("Invoice not found")}).catch(t=>{console.error("Error fetching invoice:",t),this.loading=!1})},fetchClientInfo(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.invoiceItems=[],this.loading=!1,this.no_items=!0):(this.invoiceItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loading=!1,new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var a=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;a=s+n}else a=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(a)},calculateTotalWithVat(t,e,s,a){const n=t*e,o=n*a/100,f=n-o,m=f*s/100,p=f+m;return this.formatCurrency(p)},calculateTotal(t,e,s){const a=t*e,n=a*s/100,f=a-n;return this.formatCurrency(f)},submitItems(){this.updateTotal();const t={...this.newItem,invoice_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/invoices/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.SelectedInvoiceId=e,modal_remove.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.invoiceItems.find(a=>a.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:e})}).then(a=>a.json()).then(a=>{a.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(a.message,"alert-error"),console.error("Error removing item:",a.message),s.loading_del=!1)}).catch(a=>{this.showToast(a.message,"alert-error"),console.error("Error removing item:",a),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/invoices/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,a){const o=t*e*a/100,f=o*s/100,m=o+f;return this.formatCurrency(m)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.invoiceItems[t.oldIndex];this.invoiceItems.splice(t.oldIndex,1),this.invoiceItems.splice(t.newIndex,0,e);const s=this.invoiceItems.map(a=>a.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/invoices/update-invoice-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.articles=t}).catch(t=>console.error("Error fetching articles:",t))},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:a}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=a,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)},sendRemind(t){this.loadingModal=!0,this.RemindInvoiceModal=!0,modal_send_remind.showModal(),this.fetchClientInfo(t),this.loadSettings()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchInvoice(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");A.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},Gp={class:"pt-2 pr-4"},Yp={key:0},Jp={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Kp=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Zp=[Kp],$p={key:3},e_={role:"alert",class:"alert alert-warning"},t_=i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),n_={key:0},s_=["data-tip"],o_={class:"btn btn-sm btn-primary",disabled:""},i_={class:"grid grid-cols-2"},a_={class:"md:col-span-1"},l_=["src"],r_={class:"md:col-span-1 text-right"},c_={class:"text-lg font-semibold"},d_={key:0,class:"badge badge-error text-white"},u_={key:1,class:"badge badge-error text-white"},h_={key:2,class:"badge badge-success text-white"},m_={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},f_=i("br",null,null,-1),p_=i("br",null,null,-1),__=i("br",null,null,-1),g_=["href"],v_=i("br",null,null,-1),y_=i("br",null,null,-1),b_=i("br",null,null,-1),w_=["href"],x_=i("br",null,null,-1),C_=["href"],I_={class:"table mt-8"},E_=i("th",null,null,-1),k_={width:"5%"},T_={width:"19%"},A_={width:"21%"},S_={width:"10%",class:"text-center"},D_={width:"8%",class:"text-center"},P_={key:0,width:"5%",class:"text-center"},M_={key:1,width:"5%"},j_={width:"10%",class:"text-center"},q_={width:"10%",class:"text-right"},R_=i("th",{width:"18%",class:"text-right inv-actions"},null,-1),O_=i("td",{class:"draggable-item drag-handle px-2"},[i("i",{class:"fas fa-bars"})],-1),V_={key:0,class:"badge badge-ghost badge-xs"},N_=["innerHTML"],B_={class:"text-center"},F_={class:"text-center"},W_={key:0},Q_={key:1},X_={key:0,class:"text-center"},U_={key:1},L_={key:2,class:"text-center"},z_=i("br",null,null,-1),H_={key:3,class:"text-center"},G_=i("br",null,null,-1),Y_={class:"text-right"},J_={key:0},K_={key:1},Z_={key:0},$_=["data-tip"],eg=["onClick"],tg=i("i",{class:"far fa-edit"},null,-1),ng=[tg],sg=["data-tip"],og=["onClick"],ig={key:0,class:"far fa-trash-alt"},ag={key:1,class:"loading loading-spinner loading-xs"},lg={key:0},rg=i("td",{class:"px-2"},null,-1),cg={class:"align-top px-2"},dg={class:"flex items-center border rounded-md relative"},ug=["placeholder"],hg={key:0,class:"autocomplete-dropdown bg-base-100"},mg=["onClick","innerHTML"],fg={class:"align-top px-2"},pg=i("option",{disabled:"",selected:""},"Type",-1),_g=["value"],gg={class:"flex items-center border rounded-md relative"},vg=["placeholder"],yg={key:0,class:"autocomplete-dropdown bg-base-100"},bg=["onClick","innerHTML"],wg={class:"align-top"},xg={class:"flex items-center rounded-md"},Cg=["placeholder"],Ig={class:"align-top"},Eg={class:"flex items-center border rounded-lg"},kg={class:"inline-flex"},Tg=["placeholder"],Ag={class:"align-top"},Sg={class:"flex items-center border rounded-md"},Dg=["placeholder"],Pg={key:0,class:"align-top"},Mg=["value"],jg={key:1,class:"align-top"},qg={class:"align-top"},Rg={class:"flex items-center border rounded-md"},Og=["placeholder"],Vg=i("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),Ng={key:2,class:"text-right"},Bg={key:3,class:"text-right"},Fg=["data-tip"],Wg={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},Qg={key:0,class:"fa fa-plus"},Xg={key:1,class:"loading loading-spinner loading-xs"},Ug={colspan:"8",class:"text-right no-border"},Lg={class:"text-right"},zg={key:0,class:"line-through"},Hg=i("td",null,null,-1),Gg={colspan:"8",class:"text-right no-border"},Yg={class:"text-right"},Jg=i("td",null,null,-1),Kg={key:2},Zg={colspan:"8",class:"text-right no-border"},$g={class:"text-right no-border"},ev={colspan:"8",class:"text-right no-border font-bold text-xl"},tv={class:"text-right no-border font-bold text-xl"},nv=i("td",null,null,-1),sv={key:3},ov={colspan:"8",class:"text-right no-border"},iv={class:"text-right no-border"},av={key:4},lv={colspan:"8",class:"text-right no-border"},rv={class:"text-right no-border font-bold text-xl"};function cv(t,e,s,a,n,o){const f=j("InvoiceNavBar"),m=j("remove-modal"),p=j("remind-invoice-modal"),d=j("edit-item-modal"),u=j("Card");return r(),c("div",Gp,[D(f,{invoiceInfo:n.invoice,currencyDefault:o.defaultCurrency,currencyClient:o.clientCurrency,emailActive:n.settings.easy_compta_email_addon_active,qrCodeActive:n.settings.easy_compta_qrcode_addon_active,noItems:n.no_items},null,8,["invoiceInfo","currencyDefault","currencyClient","emailActive","qrCodeActive","noItems"]),D(m,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=h=>this.removeItem(n.selectedItem,n.SelectedInvoiceId)),onCancel:e[1]||(e[1]=h=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),n.settings.easy_compta_email_addon_active==1?(r(),c("div",Yp,[D(p,{loading:t.loadingModal,"show-modal":n.RemindInvoiceModal,"modal-id":"modal_send_remind",client:n.client_detail,"invoice-id":n.invoice.id,subject:n.settings.remind_invoice_subject,content:n.settings.remind_invoice_content,onClose:e[2]||(e[2]=h=>n.RemindInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):_("",!0),n.toast.visible?(r(),c("div",{key:1,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),n.loading?(r(),c("div",Jp,Zp)):_("",!0),o.isInvoiceOverdue&&n.invoice.status=="unpaid"?(r(),c("div",$p,[i("div",e_,[t_,i("span",null,l(o.translations.invoice_overdue),1),n.settings.easy_compta_email_addon_active==1?(r(),c("div",n_,[i("button",{onClick:e[3]||(e[3]=K(h=>o.sendRemind(n.invoice.client_id),["prevent"])),class:"btn btn-sm btn-primary"},l(o.translations.remind_invoice),1)])):(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[i("button",o_,l(o.translations.remind_invoice),1)],8,s_))])])):_("",!0),D(u,{topMargin:"mt-8",id:"invoice-content"},{default:re(()=>[i("div",i_,[i("div",a_,[i("div",null,[i("img",{src:n.settings.logo_url,style:Zn({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,l_)])]),i("div",r_,[i("p",c_,l(n.invoice.invoice_number),1),i("div",null,[w(l(o.translations.created_at)+": ",1),i("strong",null,l(n.invoice.created_at),1)]),i("div",null,[w(l(o.translations.due_date)+": ",1),i("strong",null,l(n.invoice.due_date),1)]),i("div",null,[w(l(o.translations.status)+": ",1),n.invoice.status=="draft"?(r(),c("span",d_,l(o.translations.draft),1)):_("",!0),n.invoice.status=="unpaid"?(r(),c("span",u_,l(o.translations.unpaid),1)):_("",!0),n.invoice.status=="paid"?(r(),c("span",h_,l(o.translations.paid),1)):_("",!0)])])]),i("div",m_,[i("div",null,[i("strong",null,l(o.translations.bill_to)+":",1),i("h4",null,[i("strong",null,l(n.client_detail.company_name),1)]),i("p",null,[w(l(n.client_detail.address),1),f_,w(" "+l(n.client_detail.postal_code)+", "+l(n.client_detail.city)+" ",1),p_,w(" "+l(n.client_detail.country),1),__,n.client_detail.phone?(r(),c("a",{key:0,href:"tel:"+n.client_detail.phone},l(n.client_detail.phone),9,g_)):_("",!0)])]),i("div",null,[i("strong",null,l(o.translations.received_from)+":",1),i("h4",null,[i("strong",null,l(n.settings.company_name),1)]),i("p",null,[w(l(n.settings.company_address),1),v_,w(" "+l(n.settings.postal_code)+", "+l(n.settings.city)+" ",1),y_,w(" "+l(n.settings.country),1),b_,n.settings.company_phone?(r(),c("a",{key:0,href:"tel:"+n.settings.company_phone},l(n.settings.company_phone),9,w_)):_("",!0),x_,n.settings.mobile_phone?(r(),c("a",{key:1,href:"tel:"+n.settings.mobile_phone},l(n.settings.mobile_phone),9,C_)):_("",!0)])])]),D(d,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[4]||(e[4]=h=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),i("form",{onSubmit:e[24]||(e[24]=K((...h)=>o.submitItems&&o.submitItems(...h),["prevent"]))},[i("table",I_,[i("thead",null,[i("tr",null,[E_,i("th",k_,l(o.translations.item_ref),1),i("th",T_,l(o.translations.item_name),1),i("th",A_,l(o.translations.description),1),i("th",S_,l(o.translations.quantity),1),i("th",D_,l(o.translations.unit_price),1),n.settings.vat_active==1?(r(),c("th",P_,l(o.translations.vat),1)):(r(),c("th",M_)),i("th",j_,l(o.translations.discount),1),i("th",q_,l(o.translations.total),1),R_])]),i("tbody",null,[(r(!0),c(W,null,X(n.invoiceItems,(h,g)=>(r(),c("tr",{key:h.id||g},[O_,i("td",null,l(h.item_ref),1),i("td",null,[h.category_name?(r(),c("div",V_,l(h.category_name),1)):_("",!0),i("div",null,l(h.item_name),1)]),i("td",{innerHTML:o.nl2br(h.item_description)},null,8,N_),i("td",B_,l(h.quantity),1),i("td",F_,[w(l(h.unit_price),1),n.default_currency_symbol==n.client_currency?(r(),c("span",W_,l(n.default_currency_symbol),1)):(r(),c("span",Q_,l(n.client_currency),1))]),n.settings.vat_active==1?(r(),c("td",X_,l(h.vat_rate)+"% ",1)):(r(),c("td",U_)),n.settings.vat_active==1?(r(),c("td",L_,[w(l(h.discount)+"% ",1),z_,w(" "+l(o.calculateDiscountAmountWithVAT(h.quantity,h.unit_price,h.vat_rate,h.discount)),1)])):(r(),c("td",H_,[w(l(h.discount)+"% ",1),G_,w(" "+l(o.calculateDiscountAmount(h.quantity,h.unit_price,h.discount)),1)])),i("td",Y_,[w(l(h.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(r(),c("span",J_,l(n.default_currency_symbol),1)):(r(),c("span",K_,l(n.client_currency),1))]),i("td",null,[n.invoice.status=="draft"?(r(),c("div",Z_,[i("span",{class:"lg:tooltip","data-tip":o.translations.edit},[i("button",{onClick:K(v=>o.editItem(h.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},ng,8,eg)],8,$_),i("span",{class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:K(v=>o.confirmremoveItem(h.id,n.invoice.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[h.loading_del?_("",!0):(r(),c("i",ig)),h.loading_del?(r(),c("span",ag)):_("",!0)],8,og)],8,sg)])):_("",!0)])]))),128)),n.invoice.status=="draft"?(r(),c("tr",lg,[rg,i("td",cg,[i("div",dg,[B(i("input",{type:"text","onUpdate:modelValue":e[5]||(e[5]=h=>n.newItem.item_ref=h),onInput:e[6]||(e[6]=(...h)=>o.fetchRefs&&o.fetchRefs(...h)),onFocus:e[7]||(e[7]=h=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 input-xs outline-none"},null,40,ug),[[J,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(r(),c("ul",hg,[(r(!0),c(W,null,X(n.refs,h=>(r(),c("li",{key:h.ref,onClick:g=>o.selectItem(h),class:"autocomplete-item",innerHTML:o.highlightMatch(h.ref)},null,8,mg))),128))])):_("",!0)])]),i("td",fg,[B(i("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[8]||(e[8]=h=>n.newItem.item_category=h)},[pg,(r(!0),c(W,null,X(n.categories,h=>(r(),c("option",{key:h.id,value:h.id},l(h.name),9,_g))),128))],512),[[ve,n.newItem.item_category]]),i("div",gg,[B(i("input",{type:"text","onUpdate:modelValue":e[9]||(e[9]=h=>n.newItem.item_name=h),onInput:e[10]||(e[10]=(...h)=>o.fetchArticles&&o.fetchArticles(...h)),onFocus:e[11]||(e[11]=h=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,vg),[[J,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(r(),c("ul",yg,[(r(!0),c(W,null,X(n.articles,h=>(r(),c("li",{key:h.name,onClick:g=>o.selectItem(h),class:"autocomplete-item bt-primary",innerHTML:o.highlightMatch(h.name)},null,8,bg))),128))])):_("",!0)])]),i("td",wg,[i("div",xg,[B(i("textarea",{"onUpdate:modelValue":e[12]||(e[12]=h=>n.newItem.item_description=h),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[13]||(e[13]=h=>o.resize()),ref:"textarea"},null,40,Cg),[[J,n.newItem.item_description]])])]),i("td",Ig,[i("div",Eg,[i("div",kg,[i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[14]||(e[14]=(...h)=>o.decrease&&o.decrease(...h))}," - "),B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[15]||(e[15]=h=>n.newItem.quantity=h),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[16]||(e[16]=(...h)=>o.updateTotal&&o.updateTotal(...h))},null,40,Tg),[[J,n.newItem.quantity]]),i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[17]||(e[17]=(...h)=>o.increase&&o.increase(...h))}," + ")])])]),i("td",Ag,[i("div",Sg,[B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[18]||(e[18]=h=>n.newItem.unit_price=h),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[19]||(e[19]=(...h)=>o.updateTotal&&o.updateTotal(...h))},null,40,Dg),[[J,n.newItem.unit_price]])])]),n.settings.vat_active==1?(r(),c("td",Pg,[B(i("select",{"onUpdate:modelValue":e[20]||(e[20]=h=>n.newItem.vat_rate=h),onChange:e[21]||(e[21]=(...h)=>o.updateTotal&&o.updateTotal(...h)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(r(!0),c(W,null,X(n.list_vats,h=>(r(),c("option",{key:h,value:h.rate},l(h.rate)+"% ",9,Mg))),128))],544),[[ve,n.newItem.vat_rate]])])):(r(),c("td",jg)),i("td",qg,[i("div",Rg,[B(i("input",{type:"number","onUpdate:modelValue":e[22]||(e[22]=h=>n.newItem.discount=h),min:"0",max:"100",placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[23]||(e[23]=(...h)=>o.updateTotal&&o.updateTotal(...h))},null,40,Og),[[J,n.newItem.discount]]),Vg])]),n.settings.vat_active==1?(r(),c("td",Ng,l(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(r(),c("td",Bg,l(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),i("td",null,[i("span",{class:"lg:tooltip","data-tip":o.translations.add},[i("button",Wg,[n.loading_add?_("",!0):(r(),c("i",Qg)),n.loading_add?(r(),c("span",Xg)):_("",!0)])],8,Fg)])])):_("",!0),i("tr",null,[i("td",Ug,[i("strong",null,l(o.translations.subtotal),1)]),i("td",Lg,[o.totalAmount!==o.totalAmountWithoutDiscount?(r(),c("span",zg,l(o.totalAmountWithoutDiscount),1)):_("",!0),w(" "+l(o.totalAmount),1)]),Hg]),n.settings.vat_active==1?(r(!0),c(W,{key:1},X(o.getUniqueVATRates(),(h,g)=>(r(),c("tr",{key:g},[i("td",Gg,[i("strong",null,l(o.translations.tax)+" ("+l(h)+"%) ",1)]),i("td",Yg,l(o.calculateVATForRate(h)),1),Jg]))),128)):_("",!0),n.invoice.shipping_amount?(r(),c("tr",Kg,[i("td",Zg,[i("strong",null,l(o.translations.shipping_fees),1)]),i("td",$g,l(o.formatShippingAmout(n.invoice.shipping_amount)),1)])):_("",!0),i("tr",null,[i("td",ev,[i("strong",null,l(o.translations.total),1)]),i("td",tv,l(o.calculateTotalAmountWithVAT()),1),nv]),n.client_currency!=n.default_currency_symbol?(r(),c("tr",sv,[i("td",ov,[i("strong",null,l(o.translations.exchange_rate),1)]),i("td",iv,l(n.invoice.exchange_rate),1)])):_("",!0),n.client_currency!=n.default_currency_symbol?(r(),c("tr",av,[i("td",lv,[i("strong",null,l(o.translations.total)+" "+l(n.default_currency_symbol),1)]),i("td",rv,l(o.totalAmountDefaultCurrency)+l(n.default_currency_symbol),1)])):_("",!0)])])],32)]),_:1})])}var dv=oe(Hp,[["render",cv]]);const uv={name:"InvoiceNew",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],last_invoice_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.invoice_prefix}_${String(this.settings.last_invoice_id).padStart(4,"0")}`;this.invoice.number=s}else{const e=await t.json()}}catch{this.loading=!1}},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/invoices",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting invoice:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},hv={class:"pt-2 pr-4"},mv={class:"flex justify-between items-center mb-4"},fv={class:"card-title"},pv=i("div",{class:"divider mt-2"},null,-1),_v={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},gv={class:"grid grid-cols-2 gap-4"},vv={class:"ecwp-group form-group mb-4"},yv={for:"invoiceNumber",class:"ecwp-label"},bv={class:"ecwp-group form-group mb-4"},wv={for:"invoiceDate",class:"ecwp-label"},xv={class:"ecwp-group form-group mb-4"},Cv={for:"client",class:"ecwp-label"},Iv={class:"ecwp-group form-group mb-4"},Ev={for:"status",class:"ecwp-label"},kv={value:"draft"},Tv={key:0,class:"ecwp-group form-group mb-4"},Av={for:"exchangeRate",class:"ecwp-label"},Sv={class:"flex justify-between"},Dv=["disabled"],Pv={key:0,class:"loading loading-spinner loading-sm"};function Mv(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",hv,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),D(p,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:re(()=>[i("div",mv,[i("h2",fv,l(o.translations.new_invoice),1)]),pv,n.loading?(r(),c("div",_v)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitInvoice&&o.submitInvoice(...d),["prevent"]))},[i("div",gv,[i("div",vv,[i("label",yv,l(o.translations.invoice_number),1),B(i("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.invoice.number=d),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[J,n.invoice.number]])]),i("div",bv,[i("label",wv,l(o.translations.due_date),1),D(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.invoice.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),i("div",xv,[i("label",Cv,l(o.translations.company_name),1),D(m,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[2]||(e[2]=d=>n.invoice.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",Iv,[i("label",Ev,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[3]||(e[3]=d=>n.invoice.status=d),class:k(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[i("option",kv,l(o.translations.draft),1)],2),[[ve,n.invoice.status]])]),o.currencyMismatch?(r(),c("div",Tv,[i("label",Av,l(o.translations.exchange_rate),1),B(i("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[4]||(e[4]=d=>n.invoice.exchange_rate=d),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[J,n.invoice.exchange_rate]])])):_("",!0)]),i("div",Sv,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.submit)+" ",1),n.loadingBtn?(r(),c("span",Pv)):_("",!0)],8,Dv)])],32)]),_:1})])}var jv=oe(uv,[["render",Mv]]);const qv={name:"invoiceEdit",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"paid",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchInvoiceDetails()},methods:{cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.invoice.client_id&&this.setClientById(this.invoice.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchInvoiceDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?this.invoice=e:(console.error("Error fetching invoice details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching invoice details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.invoice.client=this.clients.find(e=>e.id===t)||null},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting invoice:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Rv={class:"pt-2 pr-4"},Ov={class:"flex justify-between items-center mb-4"},Vv={class:"card-title"},Nv=i("div",{class:"divider mt-2"},null,-1),Bv={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Fv={class:"grid grid-cols-2 gap-4"},Wv={class:"ecwp-group form-group mb-4"},Qv={for:"invoiceNumber",class:"ecwp-label"},Xv={class:"ecwp-group form-group mb-4"},Uv={for:"invoiceDate",class:"ecwp-label"},Lv={class:"ecwp-group form-group mb-4"},zv={for:"client",class:"ecwp-label"},Hv={class:"ecwp-group form-group mb-4"},Gv={for:"status",class:"ecwp-label"},Yv={value:"draft",selected:""},Jv={value:"unpaid"},Kv={value:"paid"},Zv={key:0,class:"ecwp-group form-group mb-4"},$v={for:"exchangeRate",class:"ecwp-label"},ey={class:"flex justify-between"},ty=["disabled"],ny={key:0,class:"loading loading-spinner loading-sm"};function sy(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",Rv,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),D(p,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:re(()=>[i("div",Ov,[i("h2",Vv,l(o.translations.edit_invoice),1)]),Nv,n.loading?(r(),c("div",Bv)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitInvoice&&o.submitInvoice(...d),["prevent"]))},[i("div",Fv,[i("div",Wv,[i("label",Qv,l(o.translations.invoice_number),1),B(i("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.invoice.invoice_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[J,n.invoice.invoice_number]])]),i("div",Xv,[i("label",Uv,l(o.translations.due_date),1),D(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.invoice.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),i("div",Lv,[i("label",zv,l(o.translations.company_name),1),D(m,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[2]||(e[2]=d=>n.invoice.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",Hv,[i("label",Gv,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[3]||(e[3]=d=>n.invoice.status=d),class:k(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[i("option",Yv,l(o.translations.draft),1),i("option",Jv,l(o.translations.unpaid),1),i("option",Kv,l(o.translations.paid),1)],2),[[ve,n.invoice.status]])]),o.currencyMismatch?(r(),c("div",Zv,[i("label",$v,l(o.translations.exchange_rate),1),B(i("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[4]||(e[4]=d=>n.invoice.exchange_rate=d),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[J,n.invoice.exchange_rate]])])):_("",!0)]),i("div",ey,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",ny)):_("",!0)],8,ty)])],32)]),_:1})])}var oy=oe(qv,[["render",sy]]);const xe=Ut;function Xt(){const t=["318785CkdQQr","1041045FVWfIn","QuoteEdit","496GGcwdh","703200xKLHVo","InvoiceEdit","QuoteViewDetail","/quote/detail/:id","6MJOZVf","QuoteNew","InvoiceViewDetail","17973NSFnHp","/invoice/new","/quote/new","1093784drjkwq","355120CzaQEu","Invoice","Quote","457401RmjiUo","/invoice/edit/:id"];return Xt=function(){return t},Xt()}(function(t,e){const s=Ut,a=t();for(;[];)try{if(-parseInt(s(238))/1+-parseInt(s(242))/2+parseInt(s(239))/3+parseInt(s(232))/4+parseInt(s(233))/5*(parseInt(s(246))/6)+parseInt(s(236))/7+-parseInt(s(241))/8*(-parseInt(s(229))/9)===e)break;a.push(a.shift())}catch{a.push(a.shift())}})(Xt,210257);function Ut(t,e){const s=Xt();return Ut=function(a,n){return a=a-227,s[a]},Ut(t,e)}const iy=[{path:"/quotes",name:xe(235),component:Ma},{path:xe(245),name:xe(244),component:xu},{path:xe(231),name:xe(227),component:Yu},{path:"/quote/edit/:id",name:xe(240),component:_s},{path:"/invoices",name:xe(234),component:$h},{path:"/invoice/detail/:id",name:xe(228),component:dv},{path:xe(237),name:xe(243),component:oy},{path:xe(230),name:"InvoiceNew",component:jv}],hy=Qo({history:_o(),routes:iy});export{hy as r};
     10 */function Wn(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Te(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Wn(Object(s),!0).forEach(function(a){qr(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Wn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function jt(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jt=function(e){return typeof e}:jt=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jt(t)}function qr(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function qe(){return qe=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},qe.apply(this,arguments)}function Or(t,e){if(t==null)return{};var s={},a=Object.keys(t),n,o;for(o=0;o<a.length;o++)n=a[o],!(e.indexOf(n)>=0)&&(s[n]=t[n]);return s}function Rr(t,e){if(t==null)return{};var s=Or(t,e),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(e.indexOf(a)>=0)&&(!Object.prototype.propertyIsEnumerable.call(t,a)||(s[a]=t[a]))}return s}var Vr="1.15.2";function je(t){if(typeof window!="undefined"&&window.navigator)return!!navigator.userAgent.match(t)}var Oe=je(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Et=je(/Edge/i),Qn=je(/firefox/i),ft=je(/safari/i)&&!je(/chrome/i)&&!je(/android/i),gs=je(/iP(ad|od|hone)/i),vs=je(/chrome/i)&&je(/android/i),ys={capture:!1,passive:!1};function Q(t,e,s){t.addEventListener(e,s,!Oe&&ys)}function N(t,e,s){t.removeEventListener(e,s,!Oe&&ys)}function Nt(t,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch{return!1}return!1}}function Nr(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function Ce(t,e,s,a){if(t){s=s||document;do{if(e!=null&&(e[0]===">"?t.parentNode===s&&Nt(t,e):Nt(t,e))||a&&t===s)return t;if(t===s)break}while(t=Nr(t))}return null}var Xn=/\s+/g;function pe(t,e,s){if(t&&e)if(t.classList)t.classList[s?"add":"remove"](e);else{var a=(" "+t.className+" ").replace(Xn," ").replace(" "+e+" "," ");t.className=(a+(s?" "+e:"")).replace(Xn," ")}}function S(t,e,s){var a=t&&t.style;if(a){if(s===void 0)return document.defaultView&&document.defaultView.getComputedStyle?s=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(s=t.currentStyle),e===void 0?s:s[e];!(e in a)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),a[e]=s+(typeof s=="string"?"":"px")}}function et(t,e){var s="";if(typeof t=="string")s=t;else do{var a=S(t,"transform");a&&a!=="none"&&(s=a+" "+s)}while(!e&&(t=t.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(s)}function bs(t,e,s){if(t){var a=t.getElementsByTagName(e),n=0,o=a.length;if(s)for(;n<o;n++)s(a[n],n);return a}return[]}function ke(){var t=document.scrollingElement;return t||document.documentElement}function te(t,e,s,a,n){if(!(!t.getBoundingClientRect&&t!==window)){var o,f,m,p,d,u,h;if(t!==window&&t.parentNode&&t!==ke()?(o=t.getBoundingClientRect(),f=o.top,m=o.left,p=o.bottom,d=o.right,u=o.height,h=o.width):(f=0,m=0,p=window.innerHeight,d=window.innerWidth,u=window.innerHeight,h=window.innerWidth),(e||s)&&t!==window&&(n=n||t.parentNode,!Oe))do if(n&&n.getBoundingClientRect&&(S(n,"transform")!=="none"||s&&S(n,"position")!=="static")){var g=n.getBoundingClientRect();f-=g.top+parseInt(S(n,"border-top-width")),m-=g.left+parseInt(S(n,"border-left-width")),p=f+o.height,d=m+o.width;break}while(n=n.parentNode);if(a&&t!==window){var v=et(n||t),C=v&&v.a,E=v&&v.d;v&&(f/=E,m/=C,h/=C,u/=E,p=f+u,d=m+h)}return{top:f,left:m,bottom:p,right:d,width:h,height:u}}}function Un(t,e,s){for(var a=Qe(t,!0),n=te(t)[e];a;){var o=te(a)[s],f=void 0;if(s==="top"||s==="left"?f=n>=o:f=n<=o,!f)return a;if(a===ke())break;a=Qe(a,!1)}return!1}function st(t,e,s,a){for(var n=0,o=0,f=t.children;o<f.length;){if(f[o].style.display!=="none"&&f[o]!==A.ghost&&(a||f[o]!==A.dragged)&&Ce(f[o],s.draggable,t,!1)){if(n===e)return f[o];n++}o++}return null}function wn(t,e){for(var s=t.lastElementChild;s&&(s===A.ghost||S(s,"display")==="none"||e&&!Nt(s,e));)s=s.previousElementSibling;return s||null}function ve(t,e){var s=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)t.nodeName.toUpperCase()!=="TEMPLATE"&&t!==A.clone&&(!e||Nt(t,e))&&s++;return s}function Ln(t){var e=0,s=0,a=ke();if(t)do{var n=et(t),o=n.a,f=n.d;e+=t.scrollLeft*o,s+=t.scrollTop*f}while(t!==a&&(t=t.parentNode));return[e,s]}function Br(t,e){for(var s in t)if(!!t.hasOwnProperty(s)){for(var a in e)if(e.hasOwnProperty(a)&&e[a]===t[s][a])return Number(s)}return-1}function Qe(t,e){if(!t||!t.getBoundingClientRect)return ke();var s=t,a=!1;do if(s.clientWidth<s.scrollWidth||s.clientHeight<s.scrollHeight){var n=S(s);if(s.clientWidth<s.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||s.clientHeight<s.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!s.getBoundingClientRect||s===document.body)return ke();if(a||e)return s;a=!0}}while(s=s.parentNode);return ke()}function Fr(t,e){if(t&&e)for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function tn(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}var pt;function ws(t,e){return function(){if(!pt){var s=arguments,a=this;s.length===1?t.call(a,s[0]):t.apply(a,s),pt=setTimeout(function(){pt=void 0},e)}}}function Wr(){clearTimeout(pt),pt=void 0}function xs(t,e,s){t.scrollLeft+=e,t.scrollTop+=s}function Cs(t){var e=window.Polymer,s=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):s?s(t).clone(!0)[0]:t.cloneNode(!0)}function Is(t,e,s){var a={};return Array.from(t.children).forEach(function(n){var o,f,m,p;if(!(!Ce(n,e.draggable,t,!1)||n.animated||n===s)){var d=te(n);a.left=Math.min((o=a.left)!==null&&o!==void 0?o:1/0,d.left),a.top=Math.min((f=a.top)!==null&&f!==void 0?f:1/0,d.top),a.right=Math.max((m=a.right)!==null&&m!==void 0?m:-1/0,d.right),a.bottom=Math.max((p=a.bottom)!==null&&p!==void 0?p:-1/0,d.bottom)}}),a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}var ge="Sortable"+new Date().getTime();function Qr(){var t=[],e;return{captureAnimationState:function(){if(t=[],!!this.options.animation){var a=[].slice.call(this.el.children);a.forEach(function(n){if(!(S(n,"display")==="none"||n===A.ghost)){t.push({target:n,rect:te(n)});var o=Te({},t[t.length-1].rect);if(n.thisAnimationDuration){var f=et(n,!0);f&&(o.top-=f.f,o.left-=f.e)}n.fromRect=o}})}},addAnimationState:function(a){t.push(a)},removeAnimationState:function(a){t.splice(Br(t,{target:a}),1)},animateAll:function(a){var n=this;if(!this.options.animation){clearTimeout(e),typeof a=="function"&&a();return}var o=!1,f=0;t.forEach(function(m){var p=0,d=m.target,u=d.fromRect,h=te(d),g=d.prevFromRect,v=d.prevToRect,C=m.rect,E=et(d,!0);E&&(h.top-=E.f,h.left-=E.e),d.toRect=h,d.thisAnimationDuration&&tn(g,h)&&!tn(u,h)&&(C.top-h.top)/(C.left-h.left)===(u.top-h.top)/(u.left-h.left)&&(p=Ur(C,g,v,n.options)),tn(h,u)||(d.prevFromRect=u,d.prevToRect=h,p||(p=n.options.animation),n.animate(d,C,h,p)),p&&(o=!0,f=Math.max(f,p),clearTimeout(d.animationResetTimer),d.animationResetTimer=setTimeout(function(){d.animationTime=0,d.prevFromRect=null,d.fromRect=null,d.prevToRect=null,d.thisAnimationDuration=null},p),d.thisAnimationDuration=p)}),clearTimeout(e),o?e=setTimeout(function(){typeof a=="function"&&a()},f):typeof a=="function"&&a(),t=[]},animate:function(a,n,o,f){if(f){S(a,"transition",""),S(a,"transform","");var m=et(this.el),p=m&&m.a,d=m&&m.d,u=(n.left-o.left)/(p||1),h=(n.top-o.top)/(d||1);a.animatingX=!!u,a.animatingY=!!h,S(a,"transform","translate3d("+u+"px,"+h+"px,0)"),this.forRepaintDummy=Xr(a),S(a,"transition","transform "+f+"ms"+(this.options.easing?" "+this.options.easing:"")),S(a,"transform","translate3d(0,0,0)"),typeof a.animated=="number"&&clearTimeout(a.animated),a.animated=setTimeout(function(){S(a,"transition",""),S(a,"transform",""),a.animated=!1,a.animatingX=!1,a.animatingY=!1},f)}}}}function Xr(t){return t.offsetWidth}function Ur(t,e,s,a){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-s.top,2)+Math.pow(e.left-s.left,2))*a.animation}var Ye=[],nn={initializeByDefault:!0},kt={mount:function(e){for(var s in nn)nn.hasOwnProperty(s)&&!(s in e)&&(e[s]=nn[s]);Ye.forEach(function(a){if(a.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),Ye.push(e)},pluginEvent:function(e,s,a){var n=this;this.eventCanceled=!1,a.cancel=function(){n.eventCanceled=!0};var o=e+"Global";Ye.forEach(function(f){!s[f.pluginName]||(s[f.pluginName][o]&&s[f.pluginName][o](Te({sortable:s},a)),s.options[f.pluginName]&&s[f.pluginName][e]&&s[f.pluginName][e](Te({sortable:s},a)))})},initializePlugins:function(e,s,a,n){Ye.forEach(function(m){var p=m.pluginName;if(!(!e.options[p]&&!m.initializeByDefault)){var d=new m(e,s,e.options);d.sortable=e,d.options=e.options,e[p]=d,qe(a,d.defaults)}});for(var o in e.options)if(!!e.options.hasOwnProperty(o)){var f=this.modifyOption(e,o,e.options[o]);typeof f!="undefined"&&(e.options[o]=f)}},getEventProperties:function(e,s){var a={};return Ye.forEach(function(n){typeof n.eventProperties=="function"&&qe(a,n.eventProperties.call(s[n.pluginName],e))}),a},modifyOption:function(e,s,a){var n;return Ye.forEach(function(o){!e[o.pluginName]||o.optionListeners&&typeof o.optionListeners[s]=="function"&&(n=o.optionListeners[s].call(e[o.pluginName],a))}),n}};function Lr(t){var e=t.sortable,s=t.rootEl,a=t.name,n=t.targetEl,o=t.cloneEl,f=t.toEl,m=t.fromEl,p=t.oldIndex,d=t.newIndex,u=t.oldDraggableIndex,h=t.newDraggableIndex,g=t.originalEvent,v=t.putSortable,C=t.extraEventProperties;if(e=e||s&&s[ge],!!e){var E,R=e.options,F="on"+a.charAt(0).toUpperCase()+a.substr(1);window.CustomEvent&&!Oe&&!Et?E=new CustomEvent(a,{bubbles:!0,cancelable:!0}):(E=document.createEvent("Event"),E.initEvent(a,!0,!0)),E.to=f||s,E.from=m||s,E.item=n||s,E.clone=o,E.oldIndex=p,E.newIndex=d,E.oldDraggableIndex=u,E.newDraggableIndex=h,E.originalEvent=g,E.pullMode=v?v.lastPutMode:void 0;var D=Te(Te({},C),kt.getEventProperties(a,e));for(var q in D)E[q]=D[q];s&&s.dispatchEvent(E),R[F]&&R[F].call(e,E)}}var zr=["evt"],fe=function(e,s){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=a.evt,o=Rr(a,zr);kt.pluginEvent.bind(A)(e,s,Te({dragEl:b,parentEl:Y,ghostEl:M,rootEl:H,nextEl:He,lastDownEl:qt,cloneEl:G,cloneHidden:We,dragStarted:rt,putSortable:ae,activeSortable:A.active,originalEvent:n,oldIndex:$e,oldDraggableIndex:_t,newIndex:_e,newDraggableIndex:Fe,hideGhostForTarget:As,unhideGhostForTarget:Ss,cloneNowHidden:function(){We=!0},cloneNowShown:function(){We=!1},dispatchSortableEvent:function(m){he({sortable:s,name:m,originalEvent:n})}},o))};function he(t){Lr(Te({putSortable:ae,cloneEl:G,targetEl:b,rootEl:H,oldIndex:$e,oldDraggableIndex:_t,newIndex:_e,newDraggableIndex:Fe},t))}var b,Y,M,H,He,qt,G,We,$e,_e,_t,Fe,St,ae,Ze=!1,Bt=!1,Ft=[],Le,xe,sn,on,zn,Hn,rt,Je,gt,vt=!1,Pt=!1,Ot,le,an=[],fn=!1,Wt=[],Gt=typeof document!="undefined",Dt=gs,Gn=Et||Oe?"cssFloat":"float",Hr=Gt&&!vs&&!gs&&"draggable"in document.createElement("div"),Es=function(){if(!!Gt){if(Oe)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto",t.style.pointerEvents==="auto"}}(),ks=function(e,s){var a=S(e),n=parseInt(a.width)-parseInt(a.paddingLeft)-parseInt(a.paddingRight)-parseInt(a.borderLeftWidth)-parseInt(a.borderRightWidth),o=st(e,0,s),f=st(e,1,s),m=o&&S(o),p=f&&S(f),d=m&&parseInt(m.marginLeft)+parseInt(m.marginRight)+te(o).width,u=p&&parseInt(p.marginLeft)+parseInt(p.marginRight)+te(f).width;if(a.display==="flex")return a.flexDirection==="column"||a.flexDirection==="column-reverse"?"vertical":"horizontal";if(a.display==="grid")return a.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&m.float&&m.float!=="none"){var h=m.float==="left"?"left":"right";return f&&(p.clear==="both"||p.clear===h)?"vertical":"horizontal"}return o&&(m.display==="block"||m.display==="flex"||m.display==="table"||m.display==="grid"||d>=n&&a[Gn]==="none"||f&&a[Gn]==="none"&&d+u>n)?"vertical":"horizontal"},Gr=function(e,s,a){var n=a?e.left:e.top,o=a?e.right:e.bottom,f=a?e.width:e.height,m=a?s.left:s.top,p=a?s.right:s.bottom,d=a?s.width:s.height;return n===m||o===p||n+f/2===m+d/2},Yr=function(e,s){var a;return Ft.some(function(n){var o=n[ge].options.emptyInsertThreshold;if(!(!o||wn(n))){var f=te(n),m=e>=f.left-o&&e<=f.right+o,p=s>=f.top-o&&s<=f.bottom+o;if(m&&p)return a=n}}),a},Ts=function(e){function s(o,f){return function(m,p,d,u){var h=m.options.group.name&&p.options.group.name&&m.options.group.name===p.options.group.name;if(o==null&&(f||h))return!0;if(o==null||o===!1)return!1;if(f&&o==="clone")return o;if(typeof o=="function")return s(o(m,p,d,u),f)(m,p,d,u);var g=(f?m:p).options.group.name;return o===!0||typeof o=="string"&&o===g||o.join&&o.indexOf(g)>-1}}var a={},n=e.group;(!n||jt(n)!="object")&&(n={name:n}),a.name=n.name,a.checkPull=s(n.pull,!0),a.checkPut=s(n.put),a.revertClone=n.revertClone,e.group=a},As=function(){!Es&&M&&S(M,"display","none")},Ss=function(){!Es&&M&&S(M,"display","")};Gt&&!vs&&document.addEventListener("click",function(t){if(Bt)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),Bt=!1,!1},!0);var ze=function(e){if(b){e=e.touches?e.touches[0]:e;var s=Yr(e.clientX,e.clientY);if(s){var a={};for(var n in e)e.hasOwnProperty(n)&&(a[n]=e[n]);a.target=a.rootEl=s,a.preventDefault=void 0,a.stopPropagation=void 0,s[ge]._onDragOver(a)}}},Jr=function(e){b&&b.parentNode[ge]._isOutsideThisEl(e.target)};function A(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=qe({},e),t[ge]=this;var s={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ks(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(f,m){f.setData("Text",m.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:A.supportPointer!==!1&&"PointerEvent"in window&&!ft,emptyInsertThreshold:5};kt.initializePlugins(this,t,s);for(var a in s)!(a in e)&&(e[a]=s[a]);Ts(e);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=e.forceFallback?!1:Hr,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Q(t,"pointerdown",this._onTapStart):(Q(t,"mousedown",this._onTapStart),Q(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(Q(t,"dragover",this),Q(t,"dragenter",this)),Ft.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),qe(this,Qr())}A.prototype={constructor:A,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Je=null)},_getDirection:function(e,s){return typeof this.options.direction=="function"?this.options.direction.call(this,e,s,b):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var s=this,a=this.el,n=this.options,o=n.preventOnFilter,f=e.type,m=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,p=(m||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||p,u=n.filter;if(oc(a),!b&&!(/mousedown|pointerdown/.test(f)&&e.button!==0||n.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&ft&&p&&p.tagName.toUpperCase()==="SELECT")&&(p=Ce(p,n.draggable,a,!1),!(p&&p.animated)&&qt!==p)){if($e=ve(p),_t=ve(p,n.draggable),typeof u=="function"){if(u.call(this,e,p,this)){he({sortable:s,rootEl:d,name:"filter",targetEl:p,toEl:a,fromEl:a}),fe("filter",s,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(h){if(h=Ce(d,h.trim(),a,!1),h)return he({sortable:s,rootEl:h,name:"filter",targetEl:p,fromEl:a,toEl:a}),fe("filter",s,{evt:e}),!0}),u)){o&&e.cancelable&&e.preventDefault();return}n.handle&&!Ce(d,n.handle,a,!1)||this._prepareDragStart(e,m,p)}}},_prepareDragStart:function(e,s,a){var n=this,o=n.el,f=n.options,m=o.ownerDocument,p;if(a&&!b&&a.parentNode===o){var d=te(a);if(H=o,b=a,Y=b.parentNode,He=b.nextSibling,qt=a,St=f.group,A.dragged=b,Le={target:b,clientX:(s||e).clientX,clientY:(s||e).clientY},zn=Le.clientX-d.left,Hn=Le.clientY-d.top,this._lastX=(s||e).clientX,this._lastY=(s||e).clientY,b.style["will-change"]="all",p=function(){if(fe("delayEnded",n,{evt:e}),A.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!Qn&&n.nativeDraggable&&(b.draggable=!0),n._triggerDragStart(e,s),he({sortable:n,name:"choose",originalEvent:e}),pe(b,f.chosenClass,!0)},f.ignore.split(",").forEach(function(u){bs(b,u.trim(),ln)}),Q(m,"dragover",ze),Q(m,"mousemove",ze),Q(m,"touchmove",ze),Q(m,"mouseup",n._onDrop),Q(m,"touchend",n._onDrop),Q(m,"touchcancel",n._onDrop),Qn&&this.nativeDraggable&&(this.options.touchStartThreshold=4,b.draggable=!0),fe("delayStart",this,{evt:e}),f.delay&&(!f.delayOnTouchOnly||s)&&(!this.nativeDraggable||!(Et||Oe))){if(A.eventCanceled){this._onDrop();return}Q(m,"mouseup",n._disableDelayedDrag),Q(m,"touchend",n._disableDelayedDrag),Q(m,"touchcancel",n._disableDelayedDrag),Q(m,"mousemove",n._delayedDragTouchMoveHandler),Q(m,"touchmove",n._delayedDragTouchMoveHandler),f.supportPointer&&Q(m,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(p,f.delay)}else p()}},_delayedDragTouchMoveHandler:function(e){var s=e.touches?e.touches[0]:e;Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){b&&ln(b),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;N(e,"mouseup",this._disableDelayedDrag),N(e,"touchend",this._disableDelayedDrag),N(e,"touchcancel",this._disableDelayedDrag),N(e,"mousemove",this._delayedDragTouchMoveHandler),N(e,"touchmove",this._delayedDragTouchMoveHandler),N(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,s){s=s||e.pointerType=="touch"&&e,!this.nativeDraggable||s?this.options.supportPointer?Q(document,"pointermove",this._onTouchMove):s?Q(document,"touchmove",this._onTouchMove):Q(document,"mousemove",this._onTouchMove):(Q(b,"dragend",this),Q(H,"dragstart",this._onDragStart));try{document.selection?Rt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,s){if(Ze=!1,H&&b){fe("dragStarted",this,{evt:s}),this.nativeDraggable&&Q(document,"dragover",Jr);var a=this.options;!e&&pe(b,a.dragClass,!1),pe(b,a.ghostClass,!0),A.active=this,e&&this._appendGhost(),he({sortable:this,name:"start",originalEvent:s})}else this._nulling()},_emulateDragOver:function(){if(xe){this._lastX=xe.clientX,this._lastY=xe.clientY,As();for(var e=document.elementFromPoint(xe.clientX,xe.clientY),s=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(xe.clientX,xe.clientY),e!==s);)s=e;if(b.parentNode[ge]._isOutsideThisEl(e),s)do{if(s[ge]){var a=void 0;if(a=s[ge]._onDragOver({clientX:xe.clientX,clientY:xe.clientY,target:e,rootEl:s}),a&&!this.options.dragoverBubble)break}e=s}while(s=s.parentNode);Ss()}},_onTouchMove:function(e){if(Le){var s=this.options,a=s.fallbackTolerance,n=s.fallbackOffset,o=e.touches?e.touches[0]:e,f=M&&et(M,!0),m=M&&f&&f.a,p=M&&f&&f.d,d=Dt&&le&&Ln(le),u=(o.clientX-Le.clientX+n.x)/(m||1)+(d?d[0]-an[0]:0)/(m||1),h=(o.clientY-Le.clientY+n.y)/(p||1)+(d?d[1]-an[1]:0)/(p||1);if(!A.active&&!Ze){if(a&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<a)return;this._onDragStart(e,!0)}if(M){f?(f.e+=u-(sn||0),f.f+=h-(on||0)):f={a:1,b:0,c:0,d:1,e:u,f:h};var g="matrix(".concat(f.a,",").concat(f.b,",").concat(f.c,",").concat(f.d,",").concat(f.e,",").concat(f.f,")");S(M,"webkitTransform",g),S(M,"mozTransform",g),S(M,"msTransform",g),S(M,"transform",g),sn=u,on=h,xe=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!M){var e=this.options.fallbackOnBody?document.body:H,s=te(b,!0,Dt,!0,e),a=this.options;if(Dt){for(le=e;S(le,"position")==="static"&&S(le,"transform")==="none"&&le!==document;)le=le.parentNode;le!==document.body&&le!==document.documentElement?(le===document&&(le=ke()),s.top+=le.scrollTop,s.left+=le.scrollLeft):le=ke(),an=Ln(le)}M=b.cloneNode(!0),pe(M,a.ghostClass,!1),pe(M,a.fallbackClass,!0),pe(M,a.dragClass,!0),S(M,"transition",""),S(M,"transform",""),S(M,"box-sizing","border-box"),S(M,"margin",0),S(M,"top",s.top),S(M,"left",s.left),S(M,"width",s.width),S(M,"height",s.height),S(M,"opacity","0.8"),S(M,"position",Dt?"absolute":"fixed"),S(M,"zIndex","100000"),S(M,"pointerEvents","none"),A.ghost=M,e.appendChild(M),S(M,"transform-origin",zn/parseInt(M.style.width)*100+"% "+Hn/parseInt(M.style.height)*100+"%")}},_onDragStart:function(e,s){var a=this,n=e.dataTransfer,o=a.options;if(fe("dragStart",this,{evt:e}),A.eventCanceled){this._onDrop();return}fe("setupClone",this),A.eventCanceled||(G=Cs(b),G.removeAttribute("id"),G.draggable=!1,G.style["will-change"]="",this._hideClone(),pe(G,this.options.chosenClass,!1),A.clone=G),a.cloneId=Rt(function(){fe("clone",a),!A.eventCanceled&&(a.options.removeCloneOnHide||H.insertBefore(G,b),a._hideClone(),he({sortable:a,name:"clone"}))}),!s&&pe(b,o.dragClass,!0),s?(Bt=!0,a._loopId=setInterval(a._emulateDragOver,50)):(N(document,"mouseup",a._onDrop),N(document,"touchend",a._onDrop),N(document,"touchcancel",a._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(a,n,b)),Q(document,"drop",a),S(b,"transform","translateZ(0)")),Ze=!0,a._dragStartId=Rt(a._dragStarted.bind(a,s,e)),Q(document,"selectstart",a),rt=!0,ft&&S(document.body,"user-select","none")},_onDragOver:function(e){var s=this.el,a=e.target,n,o,f,m=this.options,p=m.group,d=A.active,u=St===p,h=m.sort,g=ae||d,v,C=this,E=!1;if(fn)return;function R(De,Yt){fe(De,C,Te({evt:e,isOwner:u,axis:v?"vertical":"horizontal",revert:f,dragRect:n,targetRect:o,canSort:h,fromSortable:g,target:a,completed:D,onMove:function(ot,it){return Mt(H,s,b,n,ot,te(ot),e,it)},changed:q},Yt))}function F(){R("dragOverAnimationCapture"),C.captureAnimationState(),C!==g&&g.captureAnimationState()}function D(De){return R("dragOverCompleted",{insertion:De}),De&&(u?d._hideClone():d._showClone(C),C!==g&&(pe(b,ae?ae.options.ghostClass:d.options.ghostClass,!1),pe(b,m.ghostClass,!0)),ae!==C&&C!==A.active?ae=C:C===A.active&&ae&&(ae=null),g===C&&(C._ignoreWhileAnimating=a),C.animateAll(function(){R("dragOverAnimationComplete"),C._ignoreWhileAnimating=null}),C!==g&&(g.animateAll(),g._ignoreWhileAnimating=null)),(a===b&&!b.animated||a===s&&!a.animated)&&(Je=null),!m.dragoverBubble&&!e.rootEl&&a!==document&&(b.parentNode[ge]._isOutsideThisEl(e.target),!De&&ze(e)),!m.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),E=!0}function q(){_e=ve(b),Fe=ve(b,m.draggable),he({sortable:C,name:"change",toEl:s,newIndex:_e,newDraggableIndex:Fe,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),a=Ce(a,m.draggable,s,!0),R("dragOver"),A.eventCanceled)return E;if(b.contains(e.target)||a.animated&&a.animatingX&&a.animatingY||C._ignoreWhileAnimating===a)return D(!1);if(Bt=!1,d&&!m.disabled&&(u?h||(f=Y!==H):ae===this||(this.lastPutMode=St.checkPull(this,d,b,e))&&p.checkPut(this,d,b,e))){if(v=this._getDirection(e,a)==="vertical",n=te(b),R("dragOverValid"),A.eventCanceled)return E;if(f)return Y=H,F(),this._hideClone(),R("revert"),A.eventCanceled||(He?H.insertBefore(b,He):H.appendChild(b)),D(!0);var z=wn(s,m.draggable);if(!z||ec(e,v,this)&&!z.animated){if(z===b)return D(!1);if(z&&s===e.target&&(a=z),a&&(o=te(a)),Mt(H,s,b,n,a,o,e,!!a)!==!1)return F(),z&&z.nextSibling?s.insertBefore(b,z.nextSibling):s.appendChild(b),Y=s,q(),D(!0)}else if(z&&$r(e,v,this)){var ce=st(s,0,m,!0);if(ce===b)return D(!1);if(a=ce,o=te(a),Mt(H,s,b,n,a,o,e,!1)!==!1)return F(),s.insertBefore(b,ce),Y=s,q(),D(!0)}else if(a.parentNode===s){o=te(a);var ne=0,Z,Ue=b.parentNode!==s,ie=!Gr(b.animated&&b.toRect||n,a.animated&&a.toRect||o,v),Re=v?"top":"left",be=Un(a,"top","top")||Un(b,"top","top"),Ve=be?be.scrollTop:void 0;Je!==a&&(Z=o[Re],vt=!1,Pt=!ie&&m.invertSwap||Ue),ne=tc(e,a,o,v,ie?1:m.swapThreshold,m.invertedSwapThreshold==null?m.swapThreshold:m.invertedSwapThreshold,Pt,Je===a);var de;if(ne!==0){var Ae=ve(b);do Ae-=ne,de=Y.children[Ae];while(de&&(S(de,"display")==="none"||de===M))}if(ne===0||de===a)return D(!1);Je=a,gt=ne;var Se=a.nextElementSibling,we=!1;we=ne===1;var Pe=Mt(H,s,b,n,a,o,e,we);if(Pe!==!1)return(Pe===1||Pe===-1)&&(we=Pe===1),fn=!0,setTimeout(Zr,30),F(),we&&!Se?s.appendChild(b):a.parentNode.insertBefore(b,we?Se:a),be&&xs(be,0,Ve-be.scrollTop),Y=b.parentNode,Z!==void 0&&!Pt&&(Ot=Math.abs(Z-te(a)[Re])),q(),D(!0)}if(s.contains(b))return D(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){N(document,"mousemove",this._onTouchMove),N(document,"touchmove",this._onTouchMove),N(document,"pointermove",this._onTouchMove),N(document,"dragover",ze),N(document,"mousemove",ze),N(document,"touchmove",ze)},_offUpEvents:function(){var e=this.el.ownerDocument;N(e,"mouseup",this._onDrop),N(e,"touchend",this._onDrop),N(e,"pointerup",this._onDrop),N(e,"touchcancel",this._onDrop),N(document,"selectstart",this)},_onDrop:function(e){var s=this.el,a=this.options;if(_e=ve(b),Fe=ve(b,a.draggable),fe("drop",this,{evt:e}),Y=b&&b.parentNode,_e=ve(b),Fe=ve(b,a.draggable),A.eventCanceled){this._nulling();return}Ze=!1,Pt=!1,vt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),pn(this.cloneId),pn(this._dragStartId),this.nativeDraggable&&(N(document,"drop",this),N(s,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),ft&&S(document.body,"user-select",""),S(b,"transform",""),e&&(rt&&(e.cancelable&&e.preventDefault(),!a.dropBubble&&e.stopPropagation()),M&&M.parentNode&&M.parentNode.removeChild(M),(H===Y||ae&&ae.lastPutMode!=="clone")&&G&&G.parentNode&&G.parentNode.removeChild(G),b&&(this.nativeDraggable&&N(b,"dragend",this),ln(b),b.style["will-change"]="",rt&&!Ze&&pe(b,ae?ae.options.ghostClass:this.options.ghostClass,!1),pe(b,this.options.chosenClass,!1),he({sortable:this,name:"unchoose",toEl:Y,newIndex:null,newDraggableIndex:null,originalEvent:e}),H!==Y?(_e>=0&&(he({rootEl:Y,name:"add",toEl:Y,fromEl:H,originalEvent:e}),he({sortable:this,name:"remove",toEl:Y,originalEvent:e}),he({rootEl:Y,name:"sort",toEl:Y,fromEl:H,originalEvent:e}),he({sortable:this,name:"sort",toEl:Y,originalEvent:e})),ae&&ae.save()):_e!==$e&&_e>=0&&(he({sortable:this,name:"update",toEl:Y,originalEvent:e}),he({sortable:this,name:"sort",toEl:Y,originalEvent:e})),A.active&&((_e==null||_e===-1)&&(_e=$e,Fe=_t),he({sortable:this,name:"end",toEl:Y,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){fe("nulling",this),H=b=Y=M=He=G=qt=We=Le=xe=rt=_e=Fe=$e=_t=Je=gt=ae=St=A.dragged=A.ghost=A.clone=A.active=null,Wt.forEach(function(e){e.checked=!0}),Wt.length=sn=on=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":b&&(this._onDragOver(e),Kr(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],s,a=this.el.children,n=0,o=a.length,f=this.options;n<o;n++)s=a[n],Ce(s,f.draggable,this.el,!1)&&e.push(s.getAttribute(f.dataIdAttr)||sc(s));return e},sort:function(e,s){var a={},n=this.el;this.toArray().forEach(function(o,f){var m=n.children[f];Ce(m,this.options.draggable,n,!1)&&(a[o]=m)},this),s&&this.captureAnimationState(),e.forEach(function(o){a[o]&&(n.removeChild(a[o]),n.appendChild(a[o]))}),s&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,s){return Ce(e,s||this.options.draggable,this.el,!1)},option:function(e,s){var a=this.options;if(s===void 0)return a[e];var n=kt.modifyOption(this,e,s);typeof n!="undefined"?a[e]=n:a[e]=s,e==="group"&&Ts(a)},destroy:function(){fe("destroy",this);var e=this.el;e[ge]=null,N(e,"mousedown",this._onTapStart),N(e,"touchstart",this._onTapStart),N(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(N(e,"dragover",this),N(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(s){s.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ft.splice(Ft.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!We){if(fe("hideClone",this),A.eventCanceled)return;S(G,"display","none"),this.options.removeCloneOnHide&&G.parentNode&&G.parentNode.removeChild(G),We=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(We){if(fe("showClone",this),A.eventCanceled)return;b.parentNode==H&&!this.options.group.revertClone?H.insertBefore(G,b):He?H.insertBefore(G,He):H.appendChild(G),this.options.group.revertClone&&this.animate(b,G),S(G,"display",""),We=!1}}};function Kr(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.cancelable&&t.preventDefault()}function Mt(t,e,s,a,n,o,f,m){var p,d=t[ge],u=d.options.onMove,h;return window.CustomEvent&&!Oe&&!Et?p=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(p=document.createEvent("Event"),p.initEvent("move",!0,!0)),p.to=e,p.from=t,p.dragged=s,p.draggedRect=a,p.related=n||e,p.relatedRect=o||te(e),p.willInsertAfter=m,p.originalEvent=f,t.dispatchEvent(p),u&&(h=u.call(d,p,f)),h}function ln(t){t.draggable=!1}function Zr(){fn=!1}function $r(t,e,s){var a=te(st(s.el,0,s.options,!0)),n=Is(s.el,s.options,M),o=10;return e?t.clientX<n.left-o||t.clientY<a.top&&t.clientX<a.right:t.clientY<n.top-o||t.clientY<a.bottom&&t.clientX<a.left}function ec(t,e,s){var a=te(wn(s.el,s.options.draggable)),n=Is(s.el,s.options,M),o=10;return e?t.clientX>n.right+o||t.clientY>a.bottom&&t.clientX>a.left:t.clientY>n.bottom+o||t.clientX>a.right&&t.clientY>a.top}function tc(t,e,s,a,n,o,f,m){var p=a?t.clientY:t.clientX,d=a?s.height:s.width,u=a?s.top:s.left,h=a?s.bottom:s.right,g=!1;if(!f){if(m&&Ot<d*n){if(!vt&&(gt===1?p>u+d*o/2:p<h-d*o/2)&&(vt=!0),vt)g=!0;else if(gt===1?p<u+Ot:p>h-Ot)return-gt}else if(p>u+d*(1-n)/2&&p<h-d*(1-n)/2)return nc(e)}return g=g||f,g&&(p<u+d*o/2||p>h-d*o/2)?p>u+d/2?1:-1:0}function nc(t){return ve(b)<ve(t)?1:-1}function sc(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,s=e.length,a=0;s--;)a+=e.charCodeAt(s);return a.toString(36)}function oc(t){Wt.length=0;for(var e=t.getElementsByTagName("input"),s=e.length;s--;){var a=e[s];a.checked&&Wt.push(a)}}function Rt(t){return setTimeout(t,0)}function pn(t){return clearTimeout(t)}Gt&&Q(document,"touchmove",function(t){(A.active||Ze)&&t.cancelable&&t.preventDefault()});A.utils={on:Q,off:N,css:S,find:bs,is:function(e,s){return!!Ce(e,s,e,!1)},extend:Fr,throttle:ws,closest:Ce,toggleClass:pe,clone:Cs,index:ve,nextTick:Rt,cancelNextTick:pn,detectDirection:ks,getChild:st};A.get=function(t){return t[ge]};A.mount=function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];e[0].constructor===Array&&(e=e[0]),e.forEach(function(a){if(!a.prototype||!a.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(a));a.utils&&(A.utils=Te(Te({},A.utils),a.utils)),kt.mount(a)})};A.create=function(t,e){return new A(t,e)};A.version=Vr;var ee=[],ct,_n,gn=!1,rn,cn,Qt,dt;function ic(){function t(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return t.prototype={dragStarted:function(s){var a=s.originalEvent;this.sortable.nativeDraggable?Q(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Q(document,"pointermove",this._handleFallbackAutoScroll):a.touches?Q(document,"touchmove",this._handleFallbackAutoScroll):Q(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(s){var a=s.originalEvent;!this.options.dragOverBubble&&!a.rootEl&&this._handleAutoScroll(a)},drop:function(){this.sortable.nativeDraggable?N(document,"dragover",this._handleAutoScroll):(N(document,"pointermove",this._handleFallbackAutoScroll),N(document,"touchmove",this._handleFallbackAutoScroll),N(document,"mousemove",this._handleFallbackAutoScroll)),Yn(),Vt(),Wr()},nulling:function(){Qt=_n=ct=gn=dt=rn=cn=null,ee.length=0},_handleFallbackAutoScroll:function(s){this._handleAutoScroll(s,!0)},_handleAutoScroll:function(s,a){var n=this,o=(s.touches?s.touches[0]:s).clientX,f=(s.touches?s.touches[0]:s).clientY,m=document.elementFromPoint(o,f);if(Qt=s,a||this.options.forceAutoScrollFallback||Et||Oe||ft){dn(s,this.options,m,a);var p=Qe(m,!0);gn&&(!dt||o!==rn||f!==cn)&&(dt&&Yn(),dt=setInterval(function(){var d=Qe(document.elementFromPoint(o,f),!0);d!==p&&(p=d,Vt()),dn(s,n.options,d,a)},10),rn=o,cn=f)}else{if(!this.options.bubbleScroll||Qe(m,!0)===ke()){Vt();return}dn(s,this.options,Qe(m,!1),!1)}}},qe(t,{pluginName:"scroll",initializeByDefault:!0})}function Vt(){ee.forEach(function(t){clearInterval(t.pid)}),ee=[]}function Yn(){clearInterval(dt)}var dn=ws(function(t,e,s,a){if(!!e.scroll){var n=(t.touches?t.touches[0]:t).clientX,o=(t.touches?t.touches[0]:t).clientY,f=e.scrollSensitivity,m=e.scrollSpeed,p=ke(),d=!1,u;_n!==s&&(_n=s,Vt(),ct=e.scroll,u=e.scrollFn,ct===!0&&(ct=Qe(s,!0)));var h=0,g=ct;do{var v=g,C=te(v),E=C.top,R=C.bottom,F=C.left,D=C.right,q=C.width,z=C.height,ce=void 0,ne=void 0,Z=v.scrollWidth,Ue=v.scrollHeight,ie=S(v),Re=v.scrollLeft,be=v.scrollTop;v===p?(ce=q<Z&&(ie.overflowX==="auto"||ie.overflowX==="scroll"||ie.overflowX==="visible"),ne=z<Ue&&(ie.overflowY==="auto"||ie.overflowY==="scroll"||ie.overflowY==="visible")):(ce=q<Z&&(ie.overflowX==="auto"||ie.overflowX==="scroll"),ne=z<Ue&&(ie.overflowY==="auto"||ie.overflowY==="scroll"));var Ve=ce&&(Math.abs(D-n)<=f&&Re+q<Z)-(Math.abs(F-n)<=f&&!!Re),de=ne&&(Math.abs(R-o)<=f&&be+z<Ue)-(Math.abs(E-o)<=f&&!!be);if(!ee[h])for(var Ae=0;Ae<=h;Ae++)ee[Ae]||(ee[Ae]={});(ee[h].vx!=Ve||ee[h].vy!=de||ee[h].el!==v)&&(ee[h].el=v,ee[h].vx=Ve,ee[h].vy=de,clearInterval(ee[h].pid),(Ve!=0||de!=0)&&(d=!0,ee[h].pid=setInterval(function(){a&&this.layer===0&&A.active._onTouchMove(Qt);var Se=ee[this.layer].vy?ee[this.layer].vy*m:0,we=ee[this.layer].vx?ee[this.layer].vx*m:0;typeof u=="function"&&u.call(A.dragged.parentNode[ge],we,Se,t,Qt,ee[this.layer].el)!=="continue"||xs(ee[this.layer].el,we,Se)}.bind({layer:h}),24))),h++}while(e.bubbleScroll&&g!==p&&(g=Qe(g,!1)));gn=d}},30),Ps=function(e){var s=e.originalEvent,a=e.putSortable,n=e.dragEl,o=e.activeSortable,f=e.dispatchSortableEvent,m=e.hideGhostForTarget,p=e.unhideGhostForTarget;if(!!s){var d=a||o;m();var u=s.changedTouches&&s.changedTouches.length?s.changedTouches[0]:s,h=document.elementFromPoint(u.clientX,u.clientY);p(),d&&!d.el.contains(h)&&(f("spill"),this.onSpill({dragEl:n,putSortable:a}))}};function xn(){}xn.prototype={startIndex:null,dragStart:function(e){var s=e.oldDraggableIndex;this.startIndex=s},onSpill:function(e){var s=e.dragEl,a=e.putSortable;this.sortable.captureAnimationState(),a&&a.captureAnimationState();var n=st(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(s,n):this.sortable.el.appendChild(s),this.sortable.animateAll(),a&&a.animateAll()},drop:Ps};qe(xn,{pluginName:"revertOnSpill"});function Cn(){}Cn.prototype={onSpill:function(e){var s=e.dragEl,a=e.putSortable,n=a||this.sortable;n.captureAnimationState(),s.parentNode&&s.parentNode.removeChild(s),n.animateAll()},drop:Ps};qe(Cn,{pluginName:"removeOnSpill"});A.mount(new ic);A.mount(Cn,xn);const ac={name:"QuoteViewDetail",components:{Card:Xe,QuoteNavBar:mr,EditItemModal:jr,RemoveModal:xt},data(){return{selectedItem:null,selectedInvoiceId:null,editItemsModal:!1,no_items:!0,loading:!0,loading_add:!1,quote:[],quoteItems:[],newItem:{loading_del:!1,item_ref:"",item_name:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},vatRate:0,settings:[],list_vats:[],client_detail:[],client_email:null,client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},articles:[],categories:[],showDropdown:!1,refs:[],showDropdownRef:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isQuoteExpired(){const t=new Date().getTime(),e=this.quote.due_date?new Date(this.quote.due_date).getTime():null;return e&&e<t},totalAmountWithoutDiscount(){const t=this.quoteItems.reduce((e,s)=>{const a=s.quantity*s.unit_price;return e+a},0);return this.formatCurrency(t)},totalAmount(){const t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.quoteItems.reduce((a,n)=>a+parseFloat(n.total_amount),0)*this.quote.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)},signatureImageUrl(){const t="/wp-json/my-easy-compta/v1/signature-image/",e=myEasyComptaAdmin.nonce;return`${t}${this.quote.file_sign}?_wpnonce=${e}`}},methods:{getUniqueVATRates(){const t=new Set;return this.quoteItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.quoteItems.forEach(s=>{if(s.vat_rate===t){const a=s.quantity*s.unit_price,n=a*s.discount/100;e+=(a-n)*t/100}}),this.formatCurrency(e)},calculateTotalAmountWithVAT(){let t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.formatCurrency(t)},fetchQuote(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.quote=t,this.fetchClientInfo(t.client_id)):console.error("Quote not found")}).catch(t=>{console.error("Error fetching quote:",t),this.loading=!1})},fetchClientInfo(t){fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.client_email=e.email;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.quoteItems=[],this.loading=!1,this.no_items=!0):(this.quoteItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var a=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;a=s+n}else a=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(a)},calculateTotalWithVat(t,e,s,a){const n=t*e,o=n*a/100,f=n-o,m=f*s/100,p=f+m;return this.formatCurrency(p)},calculateTotal(t,e,s){const a=t*e,n=a*s/100,f=a-n;return this.formatCurrency(f)},submitItems(){this.updateTotal();const t={...this.newItem,quote_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/quotes/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.selectedInvoiceId=e,modal_remove.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.quoteItems.find(a=>a.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({quote_id:e})}).then(a=>a.json()).then(a=>{a.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(a.message,"alert-error"),console.error("Error removing item:",a.message),s.loading_del=!1)}).catch(a=>{this.showToast(a.message,"alert-error"),console.error("Error removing item:",a),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/quotes/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,a){const o=t*e*a/100,f=o*s/100,m=o+f;return this.formatCurrency(m)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.quoteItems[t.oldIndex];this.quoteItems.splice(t.oldIndex,1),this.quoteItems.splice(t.newIndex,0,e);const s=this.quoteItems.map(a=>a.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/quotes/update-quote-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.articles=t}).catch(t=>console.error("Error fetching articles:",t))},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loading=!0,this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:a}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=a,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1,this.loading=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1,this.loading=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchQuote(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");A.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},lc={class:"pt-2 pr-4"},rc={key:1,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},cc=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),dc=[cc],uc={key:2},hc={role:"alert",class:"alert alert-warning"},mc=i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),fc={key:0,class:"relative"},pc={class:"ecwp-watermark"},_c={class:"grid grid-cols-2"},gc={class:"md:col-span-1"},vc=["src"],yc={class:"md:col-span-1 text-right"},bc={class:"text-lg font-semibold"},wc={key:0,class:"badge badge-warning text-white"},xc={key:1,class:"badge badge-secondary text-white"},Cc={key:2,class:"badge badge-success text-white"},Ic={key:3,class:"badge badge-error text-white"},Ec={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},kc=i("br",null,null,-1),Tc=i("br",null,null,-1),Ac=i("br",null,null,-1),Sc=["href"],Pc=i("br",null,null,-1),Dc=i("br",null,null,-1),Mc=i("br",null,null,-1),jc=["href"],qc=i("br",null,null,-1),Oc=["href"],Rc={class:"table mt-8"},Vc=i("th",null,null,-1),Nc={width:"5%"},Bc={width:"19%"},Fc={width:"21%"},Wc={width:"10%",class:"text-center"},Qc={width:"8%",class:"text-center"},Xc={key:0,width:"5%",class:"text-center"},Uc={key:1,width:"5%"},Lc={width:"10%",class:"text-center"},zc={width:"10%",class:"text-right"},Hc=i("th",{width:"18%",class:"text-right inv-actions"},null,-1),Gc=i("td",{class:"draggable-item drag-handle px-2"},[i("i",{class:"fas fa-bars"})],-1),Yc={key:0,class:"badge badge-ghost badge-xs"},Jc=["innerHTML"],Kc={class:"text-center"},Zc={class:"text-center"},$c={key:0},ed={key:1},td={key:0,class:"text-center"},nd={key:1},sd={key:2,class:"text-center"},od=i("br",null,null,-1),id={key:3,class:"text-center"},ad=i("br",null,null,-1),ld={class:"text-right"},rd={key:0},cd={key:1},dd=["data-tip"],ud=["onClick"],hd=i("i",{class:"far fa-edit"},null,-1),md=[hd],fd=["data-tip"],pd=["onClick"],_d={key:0,class:"far fa-trash-alt"},gd={key:1,class:"loading loading-spinner loading-xs"},vd={key:0},yd=i("td",{class:"px-2"},null,-1),bd={class:"align-top px-2"},wd={class:"flex items-center border rounded-md relative"},xd=["placeholder"],Cd={key:0,class:"autocomplete-dropdown bg-base-300"},Id=["onClick","innerHTML"],Ed={class:"align-top px-2"},kd=i("option",{disabled:"",selected:""},"Type",-1),Td=["value"],Ad={class:"flex items-center border rounded-md relative"},Sd=["placeholder"],Pd={key:0,class:"autocomplete-dropdown bg-base-300"},Dd=["onClick","innerHTML"],Md={class:"align-top"},jd={class:"flex items-center rounded-md"},qd=["placeholder"],Od={class:"align-top"},Rd={class:"flex items-center border rounded-lg"},Vd={class:"inline-flex"},Nd=["placeholder"],Bd={class:"align-top"},Fd={class:"flex items-center border rounded-md"},Wd=["placeholder"],Qd={key:0,class:"align-top"},Xd=["value"],Ud={key:1,class:"align-top"},Ld={class:"align-top"},zd={class:"flex items-center border rounded-md"},Hd=["placeholder"],Gd=i("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),Yd={key:2,class:"text-right"},Jd={key:3,class:"text-right"},Kd=["data-tip"],Zd={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},$d={key:0,class:"fa fa-plus"},eu={key:1,class:"loading loading-spinner loading-xs"},tu={colspan:"8",class:"text-right no-border"},nu={class:"text-right"},su={key:0,class:"line-through"},ou=i("td",null,null,-1),iu={colspan:"8",class:"text-right no-border"},au={class:"text-right"},lu=i("td",null,null,-1),ru={colspan:"8",class:"text-right no-border font-bold text-xl"},cu={class:"text-right no-border font-bold text-xl"},du=i("td",null,null,-1),uu={key:2},hu={colspan:"8",class:"text-right no-border"},mu={class:"text-right no-border"},fu={key:3},pu={colspan:"8",class:"text-right no-border"},_u={class:"text-right no-border font-bold text-xl"},gu={key:1,class:"relative"},vu={class:"flex justify-end mt-4"},yu={class:"border-2 border-slate-300 max-w-md"},bu=["src"];function wu(t,e,s,a,n,o){const f=j("QuoteNavBar"),m=j("remove-modal"),p=j("edit-item-modal"),d=j("Card");return r(),c("div",lc,[P(f,{quoteInfo:n.quote,emailActive:n.settings.easy_compta_email_addon_active,advanceActive:n.settings.easy_compta_advance_addon_active,currency:n.default_currency_symbol,noItems:n.no_items},null,8,["quoteInfo","emailActive","advanceActive","currency","noItems"]),n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),P(m,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=u=>this.removeItem(n.selectedItem,n.selectedInvoiceId)),onCancel:e[1]||(e[1]=u=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),n.loading?(r(),c("div",rc,dc)):_("",!0),o.isQuoteExpired&&n.quote.status=="pending"?(r(),c("div",uc,[i("div",hc,[mc,i("span",null,l(o.translations.quote_expired),1)])])):_("",!0),P(d,{topMargin:"mt-8",id:"quote-content"},{default:re(()=>[n.settings.easy_compta_signature_addon_active&&n.quote.signed==1?(r(),c("div",fc,[i("span",pc,l(o.translations.signed),1)])):_("",!0),i("div",_c,[i("div",gc,[i("div",null,[i("img",{src:n.settings.logo_url,style:Zn({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,vc)])]),i("div",yc,[i("p",bc,l(n.quote.quote_number),1),i("div",null,[w(l(o.translations.created_at)+": ",1),i("strong",null,l(n.quote.created_at),1)]),i("div",null,[w(l(o.translations.due_date)+": ",1),i("strong",null,l(n.quote.due_date),1)]),i("div",null,[w(l(o.translations.provisional_date)+": ",1),i("strong",null,l(n.quote.provisional_start_date),1)]),i("div",null,[w(l(o.translations.status)+": ",1),n.quote.status=="draft"?(r(),c("span",wc,l(o.translations.draft),1)):_("",!0),n.quote.status=="pending"?(r(),c("span",xc,l(o.translations.pending),1)):_("",!0),n.quote.status=="approved"?(r(),c("span",Cc,l(o.translations.approved),1)):_("",!0),n.quote.status=="rejected"?(r(),c("span",Ic,l(o.translations.rejected),1)):_("",!0)])])]),i("div",Ec,[i("div",null,[i("strong",null,l(o.translations.bill_to)+":",1),i("h4",null,[i("strong",null,l(n.client_detail.company_name),1)]),i("p",null,[w(l(n.client_detail.address),1),kc,w(" "+l(n.client_detail.postal_code)+", "+l(n.client_detail.city)+" ",1),Tc,w(" "+l(n.client_detail.country),1),Ac,n.client_detail.phone?(r(),c("a",{key:0,href:"tel:"+n.client_detail.phone},l(n.client_detail.phone),9,Sc)):_("",!0)])]),i("div",null,[i("strong",null,l(o.translations.received_from)+":",1),i("h4",null,[i("strong",null,l(n.settings.company_name),1)]),i("p",null,[w(l(n.settings.company_address),1),Pc,w(" "+l(n.settings.postal_code)+", "+l(n.settings.city)+" ",1),Dc,w(" "+l(n.settings.country),1),Mc,n.settings.company_phone?(r(),c("a",{key:0,href:"tel:"+n.settings.company_phone},l(n.settings.company_phone),9,jc)):_("",!0),qc,n.settings.mobile_phone?(r(),c("a",{key:1,href:"tel:"+n.settings.mobile_phone},l(n.settings.mobile_phone),9,Oc)):_("",!0)])])]),P(p,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[2]||(e[2]=u=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),i("form",{onSubmit:e[22]||(e[22]=K((...u)=>o.submitItems&&o.submitItems(...u),["prevent"]))},[i("table",Rc,[i("thead",null,[i("tr",null,[Vc,i("th",Nc,l(o.translations.item_ref),1),i("th",Bc,l(o.translations.item_name),1),i("th",Fc,l(o.translations.description),1),i("th",Wc,l(o.translations.quantity),1),i("th",Qc,l(o.translations.unit_price),1),n.settings.vat_active==1?(r(),c("th",Xc,l(o.translations.vat),1)):(r(),c("th",Uc)),i("th",Lc,l(o.translations.discount),1),i("th",zc,l(o.translations.total),1),Hc])]),i("tbody",null,[(r(!0),c(W,null,X(n.quoteItems,(u,h)=>(r(),c("tr",{key:u.id||h},[Gc,i("td",null,l(u.item_ref),1),i("td",null,[u.category_name?(r(),c("div",Yc,l(u.category_name),1)):_("",!0),i("div",null,l(u.item_name),1)]),i("td",{innerHTML:o.nl2br(u.item_description)},null,8,Jc),i("td",Kc,l(u.quantity),1),i("td",Zc,[w(l(u.unit_price),1),n.default_currency_symbol==n.client_currency?(r(),c("span",$c,l(n.default_currency_symbol),1)):(r(),c("span",ed,l(n.client_currency),1))]),n.settings.vat_active==1?(r(),c("td",td,l(u.vat_rate)+"% ",1)):(r(),c("td",nd)),n.settings.vat_active==1?(r(),c("td",sd,[w(l(u.discount)+"% ",1),od,w(" "+l(o.calculateDiscountAmountWithVAT(u.quantity,u.unit_price,u.vat_rate,u.discount)),1)])):(r(),c("td",id,[w(l(u.discount)+"% ",1),ad,w(" "+l(o.calculateDiscountAmount(u.quantity,u.unit_price,u.discount)),1)])),i("td",ld,[w(l(u.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(r(),c("span",rd,l(n.default_currency_symbol),1)):(r(),c("span",cd,l(n.client_currency),1))]),i("td",null,[n.quote.status=="draft"||n.quote.status=="pending"?(r(),c("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[i("button",{onClick:K(g=>o.editItem(u.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},md,8,ud)],8,dd)):_("",!0),n.quote.status=="draft"||n.quote.status=="pending"?(r(),c("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:K(g=>o.confirmremoveItem(u.id,n.quote.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[u.loading_del?_("",!0):(r(),c("i",_d)),u.loading_del?(r(),c("span",gd)):_("",!0)],8,pd)],8,fd)):_("",!0)])]))),128)),n.quote.status=="draft"||n.quote.status=="pending"?(r(),c("tr",vd,[yd,i("td",bd,[i("div",wd,[B(i("input",{type:"text","onUpdate:modelValue":e[3]||(e[3]=u=>n.newItem.item_ref=u),onInput:e[4]||(e[4]=(...u)=>o.fetchRefs&&o.fetchRefs(...u)),onFocus:e[5]||(e[5]=u=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,xd),[[J,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(r(),c("ul",Cd,[(r(!0),c(W,null,X(n.refs,u=>(r(),c("li",{key:u.ref,onClick:h=>o.selectItem(u),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(u.ref)},null,8,Id))),128))])):_("",!0)])]),i("td",Ed,[B(i("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[6]||(e[6]=u=>n.newItem.item_category=u)},[kd,(r(!0),c(W,null,X(n.categories,u=>(r(),c("option",{key:u.id,value:u.id},l(u.name),9,Td))),128))],512),[[ye,n.newItem.item_category]]),i("div",Ad,[B(i("input",{type:"text","onUpdate:modelValue":e[7]||(e[7]=u=>n.newItem.item_name=u),onInput:e[8]||(e[8]=(...u)=>o.fetchArticles&&o.fetchArticles(...u)),onFocus:e[9]||(e[9]=u=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,Sd),[[J,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(r(),c("ul",Pd,[(r(!0),c(W,null,X(n.articles,u=>(r(),c("li",{key:u.name,onClick:h=>o.selectItem(u),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(u.name)},null,8,Dd))),128))])):_("",!0)])]),i("td",Md,[i("div",jd,[B(i("textarea",{"onUpdate:modelValue":e[10]||(e[10]=u=>n.newItem.item_description=u),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[11]||(e[11]=u=>o.resize()),ref:"textarea"},null,40,qd),[[J,n.newItem.item_description]])])]),i("td",Od,[i("div",Rd,[i("div",Vd,[i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[12]||(e[12]=(...u)=>o.decrease&&o.decrease(...u))}," - "),B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[13]||(e[13]=u=>n.newItem.quantity=u),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[14]||(e[14]=(...u)=>o.updateTotal&&o.updateTotal(...u))},null,40,Nd),[[J,n.newItem.quantity]]),i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[15]||(e[15]=(...u)=>o.increase&&o.increase(...u))}," + ")])])]),i("td",Bd,[i("div",Fd,[B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[16]||(e[16]=u=>n.newItem.unit_price=u),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[17]||(e[17]=(...u)=>o.updateTotal&&o.updateTotal(...u))},null,40,Wd),[[J,n.newItem.unit_price]])])]),n.settings.vat_active==1?(r(),c("td",Qd,[B(i("select",{"onUpdate:modelValue":e[18]||(e[18]=u=>n.newItem.vat_rate=u),onChange:e[19]||(e[19]=(...u)=>o.updateTotal&&o.updateTotal(...u)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(r(!0),c(W,null,X(n.list_vats,u=>(r(),c("option",{key:u,value:u.rate},l(u.rate)+"% ",9,Xd))),128))],544),[[ye,n.newItem.vat_rate]])])):(r(),c("td",Ud)),i("td",Ld,[i("div",zd,[B(i("input",{type:"number",min:"0",max:"100","onUpdate:modelValue":e[20]||(e[20]=u=>n.newItem.discount=u),placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[21]||(e[21]=(...u)=>o.updateTotal&&o.updateTotal(...u))},null,40,Hd),[[J,n.newItem.discount]]),Gd])]),n.settings.vat_active==1?(r(),c("td",Yd,l(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(r(),c("td",Jd,l(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),i("td",null,[i("span",{class:"lg:tooltip","data-tip":o.translations.add},[i("button",Zd,[n.loading_add?_("",!0):(r(),c("i",$d)),n.loading_add?(r(),c("span",eu)):_("",!0)])],8,Kd)])])):_("",!0),i("tr",null,[i("td",tu,[i("strong",null,l(o.translations.subtotal),1)]),i("td",nu,[o.totalAmount!==o.totalAmountWithoutDiscount?(r(),c("span",su,l(o.totalAmountWithoutDiscount),1)):_("",!0),w(" "+l(o.totalAmount),1)]),ou]),n.settings.vat_active==1?(r(!0),c(W,{key:1},X(o.getUniqueVATRates(),(u,h)=>(r(),c("tr",{key:h},[i("td",iu,[i("strong",null,l(o.translations.tax)+" ("+l(u)+"%) ",1)]),i("td",au,l(o.calculateVATForRate(u)),1),lu]))),128)):_("",!0),i("tr",null,[i("td",ru,[i("strong",null,l(o.translations.total),1)]),i("td",cu,l(o.calculateTotalAmountWithVAT()),1),du]),n.client_currency!=n.default_currency_symbol?(r(),c("tr",uu,[i("td",hu,[i("strong",null,l(o.translations.exchange_rate),1)]),i("td",mu,l(n.quote.exchange_rate),1)])):_("",!0),n.client_currency!=n.default_currency_symbol?(r(),c("tr",fu,[i("td",pu,[i("strong",null,l(o.translations.total)+" "+l(n.default_currency_symbol),1)]),i("td",_u,l(o.totalAmountDefaultCurrency)+l(n.default_currency_symbol),1)])):_("",!0)])])],32),n.settings.easy_compta_signature_addon_active&&n.quote.signed==1&&n.quote.file_sign?(r(),c("div",gu,[i("div",vu,[i("span",yu,[i("img",{src:o.signatureImageUrl,alt:"Signature"},null,8,bu)])])])):_("",!0)]),_:1})])}var xu=oe(ac,[["render",wu]]);const Cu={name:"QuoteNew",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{clientOptions:[],clients:[],quote:{number:"",due_date:"",provisional_start_date:"",client_id:"",status:""},showError:!1,loading:!1,loadingBtn:!1,settings:[],last_quote_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},customLabel(t){return t.text},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.quote_prefix}_${String(this.settings.last_quote_id).padStart(4,"0")}`;this.quote.number=s}else{const e=await t.json()}}catch{this.loading=!1}},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/quotes",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting quote:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Iu={class:"pt-2 pr-4"},Eu={class:"flex justify-between items-center mb-4"},ku={class:"card-title"},Tu=i("div",{class:"divider mt-2"},null,-1),Au={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Su={class:"grid grid-cols-3 gap-4"},Pu={class:"ecwp-group form-group mb-4"},Du={for:"quoteNumber",class:"ecwp-label"},Mu={class:"ecwp-group form-group mb-4"},ju={for:"quoteDate",class:"ecwp-label"},qu={class:"ecwp-group form-group mb-4"},Ou={for:"quoteDatePr",class:"ecwp-label"},Ru={class:"grid grid-cols-2 gap-4"},Vu={class:"ecwp-group form-group mb-4"},Nu={for:"client",class:"ecwp-label"},Bu={class:"ecwp-group form-group mb-4"},Fu={for:"status",class:"ecwp-label"},Wu={value:"draft",selected:""},Qu={value:"pending"},Xu={value:"approved"},Uu={value:"rejected"},Lu={class:"flex justify-between"},zu=["disabled"],Hu={key:0,class:"loading loading-spinner loading-sm"};function Gu(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",Iu,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),P(p,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:re(()=>[i("div",Eu,[i("h2",ku,l(o.translations.new_quote),1)]),Tu,n.loading?(r(),c("div",Au)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitQuote&&o.submitQuote(...d),["prevent"]))},[i("div",Su,[i("div",Pu,[i("label",Du,l(o.translations.quote_number),1),B(i("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.quote.number=d),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[J,n.quote.number]])]),i("div",Mu,[i("label",ju,l(o.translations.due_date),1),P(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.quote.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),i("div",qu,[i("label",Ou,l(o.translations.provisional_date),1),P(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteDatePr",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=d=>n.quote.provisional_start_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])])]),i("div",Ru,[i("div",Vu,[i("label",Nu,l(o.translations.company_name),1),P(m,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[3]||(e[3]=d=>n.quote.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",Bu,[i("label",Fu,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=d=>n.quote.status=d),class:k(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[i("option",Wu,l(o.translations.draft),1),i("option",Qu,l(o.translations.pending),1),i("option",Xu,l(o.translations.approved),1),i("option",Uu,l(o.translations.rejected),1)],2),[[ye,n.quote.status]])])]),i("div",Lu,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.submit)+" ",1),n.loadingBtn?(r(),c("span",Hu)):_("",!0)],8,zu)])],32)]),_:1})])}var Yu=oe(Cu,[["render",Gu]]);const Ju={name:"InvoicesList",components:{Card:Xe,RemoveModal:xt},data(){return{invoices:[],showInvoiceDetailsModal:!1,editInvoiceModal:!1,selectedInvoice:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchInvoices(),this.loadSettings()},methods:{fetchInvoices(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/invoices?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.invoices=s.invoices,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching invoices:",s)}).finally(()=>{this.loading=!1})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return $n(t,this.default_vat.rate)},calculateWithoutVAT(t){return es(t)},generatePaginationButtons(){this.paginationButtons=ts(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchInvoices(t)},perPageChanged(){this.fetchInvoices()},formatAmount(t,e){return ns(t,e,this.settings.currency_position)},showToast(t,e){ss(this.toast,t,e)},confirmDeleteInvoice(t){this.selectedInvoice=t,modal_remove.showModal(),this.showRemoveModal=!0},deleteInvoice(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchInvoices(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting invoice:",e.statusText))}).catch(e=>{console.log(e.message);const s=e&&e.message?e.message:"Error deleting client";s==="This client cannot be deleted because it has associated data."?this.showToast(s,"alert-error"):console.error("Error deleting client:",e)})}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Ku={class:"pt-2 pr-4"},Zu={class:"flex justify-between items-center"},$u={class:"card-title"},eh={class:"btn btn-primary rounded-full"},th=i("i",{class:"fas fa-plus-circle"},null,-1),nh={key:0,class:"ms-2"},sh={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab3"},oh=i("i",{class:"fas fa-file-export"},null,-1),ih=["data-tip"],ah={class:"btn btn-outline btn-accent rounded-full",disabled:""},lh=i("i",{class:"fas fa-file-export"},null,-1),rh=i("div",{class:"divider mt-2"},null,-1),ch={class:"flex items-center mb-4"},dh={for:"perPageSelect",class:"mr-2"},uh=["value"],hh={class:"overflow-x-auto"},mh={key:0,class:"table w-full"},fh={class:"flex justify-center"},ph={key:0,class:"badge badge-primary badge-outline badge-sm mr-2"},_h={key:0,class:"badge badge-scondary badge-outline badge-sm"},gh={key:1,class:"badge badge-warning badge-outline badge-sm"},vh={key:2,class:"badge badge-success badge-outline badge-sm"},yh={key:3,class:"badge badge-error badge-outline badge-sm ms-2"},bh={key:0},wh={key:0},xh={key:0},Ch={key:1},Ih={key:0},Eh={key:1},kh={key:1},Th=i("span",{class:"loading loading-bars loading-sm"},null,-1),Ah=[Th],Sh={key:0},Ph={key:1},Dh=i("span",{class:"loading loading-bars loading-sm"},null,-1),Mh=[Dh],jh={key:0},qh={key:1},Oh=i("span",{class:"loading loading-bars loading-sm"},null,-1),Rh=[Oh],Vh={class:"flex justify-end"},Nh=["data-tip"],Bh=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"far fa-eye"})],-1),Fh=["data-tip"],Wh=i("button",{class:"btn btn-circle mx-1"},[i("i",{class:"fas fa-pencil-alt"})],-1),Qh=["data-tip"],Xh=["onClick"],Uh=i("i",{class:"far fa-trash-alt"},null,-1),Lh=[Uh],zh={key:1},Hh=i("div",{class:"flex gap-4 items-center"},[i("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),i("div",{class:"flex flex-col gap-4 w-full"},[i("div",{class:"skeleton h-4 w-full"}),i("div",{class:"skeleton h-4 w-full"})])],-1),Gh=i("div",{class:"divider my-1"},null,-1),Yh=[Hh,Gh],Jh={class:"join ecwp_pagination mt-6 pt-4"},Kh=["onClick"];function Zh(t,e,s,a,n,o){const f=j("remove-modal"),m=j("router-link"),p=j("Card");return r(),c("div",Ku,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),P(f,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=d=>this.deleteInvoice(n.selectedInvoice)),onCancel:e[1]||(e[1]=d=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(p,{topMargin:"mt-8"},{default:re(()=>[i("div",Zu,[i("h2",$u,l(o.translations.invoices),1),i("div",null,[P(m,{to:{name:"InvoiceNew"}},{default:re(()=>[i("button",eh,[w(l(o.translations.add)+" ",1),th])]),_:1}),n.settings.easy_compta_export_addon_active==1?(r(),c("span",nh,[i("a",sh,[w(l(o.translations.export)+" ",1),oh])])):(r(),c("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[i("button",ah,[w(l(o.translations.export)+" ",1),lh])],8,ih))])]),rh,i("div",ch,[i("label",dh,l(o.translations.display_per_page),1),B(i("select",{id:"perPageSelect","onUpdate:modelValue":e[2]||(e[2]=d=>n.perPage=d),onChange:e[3]||(e[3]=(...d)=>o.perPageChanged&&o.perPageChanged(...d))},[(r(!0),c(W,null,X(n.perPageOptions,d=>(r(),c("option",{key:d,value:d},l(d),9,uh))),128))],544),[[ye,n.perPage]])]),i("div",hh,[n.loading?(r(),c("div",zh,[(r(!0),c(W,null,X(n.skeletonRows,d=>(r(),c("div",{key:d,class:"flex flex-col gap-4 w-full"},Yh))),128))])):(r(),c("table",mh,[i("thead",null,[i("tr",null,[i("th",null,l(o.translations.invoice_number),1),i("th",null,l(o.translations.client),1),i("th",null,l(o.translations.status),1),i("th",null,l(o.translations.total),1),i("th",null,l(o.translations.due_date),1),i("th",null,l(o.translations.created_at),1),i("th",fh,l(o.translations.actions),1)])]),i("tbody",null,[(r(!0),c(W,null,X(n.invoices,d=>(r(),c("tr",{key:d.id},[i("td",null,[d.advance==1?(r(),c("span",ph,l(o.translations.advance),1)):_("",!0),w(l(d.invoice_number),1)]),i("td",null,l(d.client_name),1),i("td",null,[d.status=="draft"?(r(),c("span",_h,l(o.translations.draft),1)):_("",!0),d.status=="unpaid"?(r(),c("span",gh,l(o.translations.unpaid),1)):_("",!0),d.status=="paid"?(r(),c("span",vh,l(o.translations.paid),1)):_("",!0),d.credit=="1"?(r(),c("span",yh,l(o.translations.credit),1)):_("",!0)]),i("td",null,[n.loadingPrice?(r(),c("div",kh,Ah)):(r(),c("div",bh,[n.settings.easy_compta_advance_addon_active&&d.advance==1?(r(),c("div",wh,l(o.formatAmount(d.advance_amount,d.client_currency||n.default_currency_symbol)),1)):_("",!0),n.settings.vat_active==1?(r(),c("div",{key:1,class:k({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(r(),c("span",xh,l(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(r(),c("span",Ch,l(o.formatAmount(d.total_amount,d.client_currency)),1))],2)):(r(),c("div",{key:2,class:k({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(r(),c("span",Ih,l(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(r(),c("span",Eh,l(o.formatAmount(d.total_amount,d.client_currency)),1))],2))]))]),i("td",null,[n.loadingPrice?(r(),c("div",Ph,Mh)):(r(),c("div",Sh,l(d.due_date),1))]),i("td",null,[n.loadingPrice?(r(),c("div",qh,Rh)):(r(),c("div",jh,l(d.created),1))]),i("td",Vh,[i("span",{class:"lg:tooltip","data-tip":o.translations.view},[P(m,{to:{name:"InvoiceViewDetail",params:{id:d.id}}},{default:re(()=>[Bh]),_:2},1032,["to"])],8,Nh),d.status=="draft"?(r(),c("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[P(m,{to:{name:"InvoiceEdit",params:{id:d.id}}},{default:re(()=>[Wh]),_:2},1032,["to"])],8,Fh)):_("",!0),d.status=="draft"?(r(),c("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:u=>o.confirmDeleteInvoice(d.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Lh,8,Xh)],8,Qh)):_("",!0)])]))),128))])]))]),i("div",Jh,[(r(!0),c(W,null,X(n.paginationButtons,d=>(r(),c("button",{key:d,class:k(["join-item btn",{"btn-disabled":d==="..."||d===n.currentPage}]),onClick:u=>o.goToPage(d)},l(d),11,Kh))),128))])]),_:1})])}var $h=oe(Ju,[["render",Zh]]);const em={name:"sendInvoice",components:{VueEditor:It.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"invoice",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},tm=["id","open"],nm={class:"modal-box"},sm={class:"font-bold text-lg"},om={key:0},im={class:"grid grid-cols-1 gap-4"},am=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),lm=i("div",{class:"skeleton h-4 w-full"},null,-1),rm=[am,lm],cm={class:"grid grid-cols-1 gap-4"},dm=["type"],um=["for"],hm=["id","value","disabled","onInput"],mm={key:1},fm=["for"],pm={class:"form-group mt-4 flex justify-end"},_m=["disabled"],gm={key:0,class:"loading loading-spinner loading-sm"};function vm(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",nm,[i("h3",sm,l(o.translations.send_invoice),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",om,[i("div",im,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},rm))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",cm,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,um),i("input",{id:p,class:k(["ecwp-input input input-bordered",m.class||"w-full"]),value:m.value,disabled:m.disabled,onInput:d=>o.updateFieldValue(p,d.target.value)},null,42,hm)],8,dm)):(r(),c("div",mm,[i("label",{for:p,class:"form-label"},l(m.label),9,fm),P(f,{modelValue:m.value,"onUpdate:modelValue":d=>m.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",pm,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.send)+" ",1),n.loadingBtn?(r(),c("span",gm)):_("",!0)],8,_m)])],32))])],8,tm)])}var ym=oe(em,[["render",vm]]);const bm={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:"",paymentMethods:[],hasPaymentMethodError:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchPaymentMethods()},methods:{async fetchPaymentMethods(){try{const t=await fetch("/wp-json/my-easy-compta/v1/payments/methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!t.ok)throw new Error(`Erreur : ${t.status}`);const e=await t.json();this.paymentMethods=e}catch(t){console.error("Erreur lors de la r\xE9cup\xE9ration des m\xE9thodes de paiement :",t)}},onConfirm(){if(!this.selectedPaymentMethod){this.hasPaymentMethodError=!0;return}this.hasPaymentMethodError=!1,this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_paid").close()}}},wm=["open"],xm={class:"modal-box"},Cm={class:"font-bold text-lg"},Im=i("div",{class:"text-center text-red-400 mb-2"},[i("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),Em={class:"text-lg font-semibold text-center"},km={class:"my-4 text-center text-xl"},Tm={key:0,class:"mt-4 mb-4"},Am={class:"ecwp-group form-group"},Sm={for:"payment_method",class:"ecwp-label form-label"},Pm={value:""},Dm=["value"],Mm={class:"flex justify-between space-x-4"};function jm(t,e,s,a,n,o){return r(),c("div",null,[i("dialog",{id:"modal_confirm_paid",class:"modal",open:t.showModal},[i("div",xm,[i("h3",Cm,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...f)=>o.closeModal&&o.closeModal(...f))}," \u2715 "),Im,i("h2",Em,l(s.title),1),i("p",km,l(s.message),1),s.status==="paid"?(r(),c("div",Tm,[i("div",Am,[i("label",Sm,l(o.translations.payment_method),1),B(i("select",{id:"payment_method","onUpdate:modelValue":e[1]||(e[1]=f=>n.selectedPaymentMethod=f),class:k([{"input-error":n.hasPaymentMethodError},"ecwp-input input input-bordered w-full"])},[i("option",Pm,l(o.translations.select),1),(r(!0),c(W,null,X(n.paymentMethods,f=>(r(),c("option",{key:f.id,value:f.id},l(f.method_name),9,Dm))),128))],2),[[ye,n.selectedPaymentMethod]])])])):_("",!0),i("div",Mm,[i("button",{onClick:e[2]||(e[2]=(...f)=>o.onCancel&&o.onCancel(...f)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[3]||(e[3]=(...f)=>o.onConfirm&&o.onConfirm(...f)),class:"btn rounded-full btn-error text-white"},l(s.confirmText),1)])])],8,wm)])}var qm=oe(bm,[["render",jm]]);const Om={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_credit").close()}}},Rm=["open"],Vm={class:"modal-box"},Nm={class:"font-bold text-lg"},Bm=i("div",{class:"text-center text-red-400 mb-2"},[i("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),Fm={class:"text-lg font-semibold text-center"},Wm={class:"my-4 text-center text-xl"},Qm={class:"flex justify-between space-x-4"};function Xm(t,e,s,a,n,o){return r(),c("div",null,[i("dialog",{id:"modal_confirm_credit",class:"modal",open:t.showModal},[i("div",Vm,[i("h3",Nm,l(t.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...f)=>o.closeModal&&o.closeModal(...f))}," \u2715 "),Bm,i("h2",Fm,l(s.title),1),i("p",Wm,l(s.message),1),i("div",Qm,[i("button",{onClick:e[1]||(e[1]=(...f)=>o.onCancel&&o.onCancel(...f)),class:"btn btn-secondary rounded-full"},l(s.cancelText),1),i("button",{onClick:e[2]||(e[2]=(...f)=>o.onConfirm&&o.onConfirm(...f)),class:"btn rounded-full btn-error text-white"},l(s.confirmText),1)])])],8,Rm)])}var Um=oe(Om,[["render",Xm]]);const Lm={name:"InvoiceNavBar",components:{SendInvoiceModal:ym,RemoveModal:xt,ConfirmModal:bn,ConfirmModalPaid:qm,ConfirmModalCredit:Um},props:{invoiceInfo:Object,currencyDefault:Object,currencyClient:Object,emailActive:String,qrCodeActive:String,totalAmount:String,noItems:Boolean},data(){return{showConfirmModal:!1,showConfirmCreditModal:!1,loading:!1,sendInvoiceModal:!1,loadingModal:!1,loadingPdf:!1,client_detail:null,selectedStatus:null,subject:"",content:"",showQrCodeModal:!1,qrCodeSrc:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{changeInvoiceStatusWithPaymentMethod(t){const e=this.selectedStatus;this.changeInvoiceStatus(e,t),this.showConfirmModal=!1},async changeInvoiceStatus(t,e){this.loading=!0;try{const a=await(await fetch("/wp-json/my-easy-compta/v1/invoices/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id,status:t,method:e})})).json();a.success?(this.invoiceInfo.status=t,this.loading=!1):(console.error("Failed to update invoice status:",a.message),this.loading=!1)}catch(s){console.error("An error occurred while updating invoice status:",s)}},async addCreditInvoice(){this.loading=!0;try{const e=await(await fetch("/wp-json/my-easy-compta/v1/invoices/credit",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id})})).json();e.success?(this.invoiceInfo.credit=1,this.loading=!1):(console.error("Failed to update invoice status:",e.message),this.loading=!1)}catch(t){console.error("An error occurred while updating invoice status:",t)}},exportToPDF(t){this.loadingPdf=!0;let s=`/wp-json/my-easy-compta/v1/invoices/pdf/${this.invoiceInfo.id}?currency_id=${t}`;fetch(s,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(a=>{if(!a.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return a.blob()}).then(a=>{const n=URL.createObjectURL(a);window.open(n),this.loadingPdf=!1}).catch(a=>{console.error("There was a problem with the fetch operation:",a),this.loadingPdf=!1})},sendInvoice(t){this.loadingModal=!0,this.sendInvoiceModal=!0,modal_send_invoice.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.subject=e.email_invoice_subject,this.content=e.email_invoice_content}else{const e=await t.json();this.showToast(e.message,"alert-error")}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},confirmValidateInvoice(t){this.selectedStatus=t,t=="unpaid"?modal_confirm.showModal():t=="paid"&&modal_confirm_paid.showModal(),this.showConfirmModal=!0},confirmCreditInvoice(){modal_confirm_credit.showModal(),this.showConfirmCreditModal=!0},async generateQRCode(){this.loading=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/generate-qrcode",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_ref:this.invoiceInfo.invoice_number||`Facture #${this.invoiceInfo.number}`,price:parseFloat(this.invoiceInfo.total_amount)})}),e=await t.json();t.ok&&e.qr_code?(this.qrCodeSrc=e.qr_code,this.showQrCodeModal=!0):console.error("Erreur lors de la g\xE9n\xE9ration du QR Code :",e.message)}catch(t){console.error("Erreur lors de l'appel \xE0 l'API pour g\xE9n\xE9rer le QR code :",t)}finally{this.loading=!1}},closeQrCodeModal(){this.showQrCodeModal=!1},downloadQRCode(){const t=document.createElement("a");t.href=this.qrCodeSrc,t.download=`qr_code_${this.invoiceInfo.invoice_number||this.invoiceInfo.number}.png`,t.click()}}},zm={key:0},Hm={key:1,class:"modal modal-open"},Gm={class:"modal-box"},Ym={class:"font-bold text-lg"},Jm={class:"mb-4"},Km=["src"],Zm={class:"flex justify-end space-x-4"},$m={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},ef=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),tf=[ef],nf={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},sf=i("div",{class:"dropdown"},[i("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),i("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[i("li",null,[i("a",null,"Item")]),i("li",null,[i("a",null,"Parent"),i("ul",{class:"p-2"},[i("li",null,[i("a",null,"Submenu")]),i("li",null,[i("a",null,"Submenu")])])]),i("li",null,[i("a",null,"Item")])])],-1),of={class:"hidden lg:flex gap-2"},af={class:"btn btn-sm"},lf=i("i",{class:"far fa-edit"},null,-1),rf={key:1},cf={class:"btn btn-sm",disabled:""},df=i("i",{class:"far fa-edit"},null,-1),uf={key:2},hf=i("i",{class:"fa fa-check"},null,-1),mf={class:"btn btn-outline btn-success btn-sm hover:text-white",disabled:""},ff=i("i",{class:"fa fa-check"},null,-1),pf={key:0},_f={class:"btn btn-sm ms-2",disabled:""},gf=i("i",{class:"fas fa-undo"},null,-1),vf={key:1},yf=i("i",{class:"fas fa-undo"},null,-1),bf=["disabled"],wf=i("i",{class:"far fa-file-pdf"},null,-1),xf={key:0,class:"loading loading-spinner loading-sm"},Cf={class:"flex gap-2"},If=i("i",{class:"fas fa-paper-plane"},null,-1),Ef={key:0},kf={key:1},Tf={key:2,class:"far fa-envelope"},Af=["data-tip"],Sf={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Pf=i("i",{class:"fas fa-paper-plane"},null,-1),Df=["data-tip"],Mf={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},jf=i("i",{class:"fas fa-paper-plane"},null,-1),qf={key:3},Of=i("i",{class:"fas fa-qrcode"},null,-1),Rf={key:1,click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Vf=i("i",{class:"fas fa-qrcode"},null,-1),Nf=["data-tip"],Bf={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Ff=i("i",{class:"fas fa-qrcode"},null,-1),Wf={key:5},Qf={key:0,class:"dropdown dropdown-end"},Xf={tabindex:"0",role:"button",class:"btn btn-outline btn-success btn-sm"},Uf=i("i",{class:"far fa-file-pdf"},null,-1),Lf={key:0,class:"loading loading-spinner loading-sm"},zf={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},Hf=["disabled"],Gf=["disabled"],Yf={key:6},Jf=["disabled"],Kf=i("i",{class:"far fa-file-pdf"},null,-1),Zf={key:0},$f={key:1},ep={key:2,class:"loading loading-spinner loading-sm"},tp=i("i",{class:"fas fa-check"},null,-1),np=["data-tip"],sp={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},op=i("i",{class:"fas fa-check"},null,-1);function ip(t,e,s,a,n,o){const f=j("send-invoice-modal"),m=j("confirm-modal"),p=j("confirm-modal-paid"),d=j("confirm-modal-credit"),u=j("router-link");return r(),c("div",null,[s.emailActive==1?(r(),c("div",zm,[P(f,{loading:n.loadingModal,"show-modal":n.sendInvoiceModal,"modal-id":"modal_send_invoice",client:n.client_detail,"invoice-id":s.invoiceInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=h=>n.sendInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):_("",!0),P(m,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:e[1]||(e[1]=h=>o.changeInvoiceStatus("unpaid")),onCancel:e[2]||(e[2]=h=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status"]),P(p,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:o.changeInvoiceStatusWithPaymentMethod,onCancel:e[3]||(e[3]=h=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status","onConfirm"]),P(d,{"show-modal":n.showConfirmCreditModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[4]||(e[4]=h=>this.addCreditInvoice()),onCancel:e[5]||(e[5]=h=>n.showConfirmCreditModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.qrCodeActive==1&&n.showQrCodeModal?(r(),c("div",Hm,[i("div",Gm,[i("h3",Ym,l(o.translations.download_qr_code),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[6]||(e[6]=h=>o.closeQrCodeModal())}," \u2715 "),i("div",Jm,[i("img",{src:n.qrCodeSrc,alt:"QR Code",class:"max-w-full h-auto mx-auto"},null,8,Km)]),i("div",Zm,[i("button",{onClick:e[7]||(e[7]=(...h)=>o.downloadQRCode&&o.downloadQRCode(...h)),class:"btn btn-primary"},l(o.translations.download_qr_code),1)])])])):_("",!0),n.loading?(r(),c("div",$m,tf)):_("",!0),i("div",nf,[i("div",null,[sf,i("div",of,[s.invoiceInfo.status=="draft"?(r(),Vs(u,{key:0,to:{name:"InvoiceEdit",params:{id:s.invoiceInfo.id}}},{default:re(()=>[i("button",af,[lf,w(" "+l(o.translations.edit_invoice),1)])]),_:1},8,["to"])):(r(),c("div",rf,[i("button",cf,[df,w(" "+l(o.translations.edit_invoice),1)])])),s.invoiceInfo.status=="unpaid"&&!s.noItems?(r(),c("div",uf,[i("button",{class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[8]||(e[8]=h=>o.confirmValidateInvoice("paid"))},[hf,w(" "+l(o.translations.mark_as_paid),1)])])):(r(),c(W,{key:3},[i("div",null,[i("button",mf,[ff,w(" "+l(o.translations.mark_as_paid),1)])]),s.invoiceInfo.credit!=0&&s.invoiceInfo.status=="paid"&&!s.noItems?(r(),c("div",pf,[i("button",_f,[gf,w(" "+l(o.translations.credit_invoice),1)])])):_("",!0),s.invoiceInfo.credit==0&&s.invoiceInfo.status=="paid"&&!s.noItems?(r(),c("div",vf,[i("button",{class:"btn btn-sm ms-2",onClick:e[9]||(e[9]=h=>o.confirmCreditInvoice())},[yf,w(" "+l(o.translations.credit_invoice),1)])])):_("",!0)],64))])]),s.invoiceInfo.status=="draft"?(r(),c("button",{key:0,onClick:e[10]||(e[10]=h=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-secondary btn-sm",disabled:n.loadingPdf},[wf,i("span",null,l(o.translations.previewPDF),1),n.loadingPdf?(r(),c("span",xf)):_("",!0)],8,bf)):_("",!0),i("div",Cf,[s.emailActive==1&&s.invoiceInfo.status!="draft"?(r(),c("button",{key:0,onClick:e[11]||(e[11]=K(h=>o.sendInvoice(s.invoiceInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[If,s.invoiceInfo.sent==1?(r(),c("span",Ef,l(o.translations.resend_invoice),1)):(r(),c("span",kf,l(o.translations.send_invoice),1)),s.invoiceInfo.sent==1?(r(),c("i",Tf)):_("",!0)])):s.emailActive==1&&s.invoiceInfo.status=="draft"?(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.draft_cannot_send},[i("button",Sf,[Pf,w(" "+l(o.translations.send_invoice),1)])],8,Af)):(r(),c("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[i("button",Mf,[jf,w(" "+l(o.translations.send_invoice),1)])],8,Df)),s.qrCodeActive==1?(r(),c("div",qf,[s.invoiceInfo.status=="unpaid"?(r(),c("button",{key:0,class:"btn btn-outline btn-accent btn-sm",onClick:e[12]||(e[12]=(...h)=>o.generateQRCode&&o.generateQRCode(...h))},[Of,w(" "+l(o.translations.generate_qrcode),1)])):(r(),c("button",Rf,[Vf,w(" "+l(o.translations.generate_qrcode),1)]))])):(r(),c("div",{key:4,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_qrcode_addon},[i("button",Bf,[Ff,w(" "+l(o.translations.generate_qrcode),1)])],8,Nf)),s.currencyDefault.currency_id!==s.currencyClient.currency_id?(r(),c("div",Wf,[s.invoiceInfo.status!="draft"?(r(),c("div",Qf,[i("div",Xf,[Uf,w(" "+l(o.translations.exportToPDF)+" ",1),n.loadingPdf?(r(),c("span",Lf)):_("",!0)]),i("ul",zf,[i("li",null,[i("a",{onClick:e[13]||(e[13]=h=>o.exportToPDF(s.currencyDefault.currency_id)),disabled:n.loadingPdf},l(o.translations.invoice_in)+" "+l(s.currencyDefault.currency_symbol),9,Hf)]),i("li",null,[i("a",{onClick:e[14]||(e[14]=h=>o.exportToPDF(s.currencyClient.currency_id)),disabled:n.loadingPdf},l(o.translations.invoice_in)+" "+l(s.currencyClient.currency_symbol),9,Gf)])])])):_("",!0)])):(r(),c("div",Yf,[s.invoiceInfo.status!="draft"?(r(),c("button",{key:0,onClick:e[15]||(e[15]=h=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[Kf,s.invoiceInfo.status!="draft"?(r(),c("span",Zf,l(o.translations.exportToPDF),1)):(r(),c("span",$f,l(o.translations.previewPDF),1)),n.loadingPdf?(r(),c("span",ep)):_("",!0)],8,Jf)):_("",!0)])),s.invoiceInfo.status=="draft"&&!s.noItems?(r(),c("button",{key:7,class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[16]||(e[16]=h=>o.confirmValidateInvoice("unpaid"))},[tp,w(" "+l(o.translations.validateInvoice),1)])):_("",!0),s.invoiceInfo.status=="draft"&&s.noItems?(r(),c("div",{key:8,class:"tooltip tooltip-left tooltip-warning","data-tip":o.translations.min_article},[i("button",sp,[op,w(" "+l(o.translations.validateInvoice),1)])],8,np)):_("",!0)])])])}var ap=oe(Lm,[["render",ip]]);const lp={components:{VueEditor:It.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:"Nom de l'item"},item_description:{label:"Description de l'item",type:"textarea"},quantity:{label:"Quantit\xE9",type:"number"},vat_rate:{label:"Taux de TVA",type:"number"},unit_price:{label:"Prix unitaire",type:"number"},discount:{label:"Remise",type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/invoices/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},rp=["id","open"],cp={class:"modal-box"},dp={class:"font-bold text-lg"},up={key:0},hp={class:"grid grid-cols-1 gap-4"},mp=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),fp=i("div",{class:"skeleton h-4 w-full"},null,-1),pp=[mp,fp],_p={class:"grid grid-cols-1 gap-4"},gp=["type"],vp=["for"],yp=["id","onUpdate:modelValue"],bp={key:1},wp=["for"],xp={class:"form-group mt-4 flex justify-end"},Cp=["disabled"],Ip={key:0,class:"loading loading-spinner loading-sm"};function Ep(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",cp,[i("h3",dp,l(s.modalTitle),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",up,[i("div",hp,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},pp))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",_p,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,vp),B(i("input",{id:p,"onUpdate:modelValue":d=>n.editedItem[p]=d,class:k(["ecwp-input input input-bordered",m.class||"w-full"])},null,10,yp),[[J,n.editedItem[p]]])],8,gp)):(r(),c("div",bp,[i("label",{for:p,class:"form-label"},l(m.label),9,wp),P(f,{id:p,modelValue:n.editedItem[p],"onUpdate:modelValue":d=>n.editedItem[p]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",xp,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",Ip)):_("",!0)],8,Cp)])],32))])],8,rp)])}var kp=oe(lp,[["render",Ep]]);const Tp={name:"sendRemind",components:{VueEditor:It.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"remind",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Ap=["id","open"],Sp={class:"modal-box"},Pp={class:"font-bold text-lg"},Dp={key:0},Mp={class:"grid grid-cols-1 gap-4"},jp=i("div",{class:"skeleton h-4 w-full mb-2"},null,-1),qp=i("div",{class:"skeleton h-4 w-full"},null,-1),Op=[jp,qp],Rp={class:"grid grid-cols-1 gap-4"},Vp=["type"],Np=["for"],Bp=["id","value","disabled","onInput"],Fp={key:1},Wp=["for"],Qp={class:"form-group mt-4 flex justify-end"},Xp=["disabled"],Up={key:0,class:"loading loading-spinner loading-sm"};function Lp(t,e,s,a,n,o){const f=j("vue-editor");return r(),c("div",null,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),i("dialog",{id:s.modalId,class:"modal",open:s.showModal},[i("div",Sp,[i("h3",Pp,l(o.translations.remind_invoice),1),i("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=m=>o.closeModal())}," \u2715 "),n.loading?(r(),c("div",Dp,[i("div",Mp,[(r(!0),c(W,null,X(o.skeletonItems,m=>(r(),c("div",{key:m,class:"py-2"},Op))),128))])])):(r(),c("form",{key:1,onSubmit:e[1]||(e[1]=K((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[i("div",Rp,[(r(!0),c(W,null,X(n.fields,(m,p)=>(r(),c("div",{key:p,class:"ecwp-group form-group"},[m.type!=="textarea"?(r(),c("div",{key:0,type:m.type||"text"},[i("label",{for:p,class:"ecwp-label form-label"},l(m.label),9,Np),i("input",{id:p,class:k(["ecwp-input input input-bordered",m.class||"w-full"]),value:m.value,disabled:m.disabled,onInput:d=>o.updateFieldValue(p,d.target.value)},null,42,Bp)],8,Vp)):(r(),c("div",Fp,[i("label",{for:p,class:"form-label"},l(m.label),9,Wp),P(f,{modelValue:m.value,"onUpdate:modelValue":d=>m.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),i("div",Qp,[i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.send)+" ",1),n.loadingBtn?(r(),c("span",Up)):_("",!0)],8,Xp)])],32))])],8,Ap)])}var zp=oe(Tp,[["render",Lp]]);const Hp={name:"InvoiceViewDetail",components:{Card:Xe,InvoiceNavBar:ap,EditItemModal:kp,RemoveModal:xt,RemindInvoiceModal:zp},data(){return{selectedItem:null,SelectedInvoiceId:null,editItemsModal:!1,RemindInvoiceModal:!1,no_items:!0,loading:!1,loading_add:!1,invoice:[],invoiceItems:[],newItem:{loading_del:!1,item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},settings:[],client_detail:[],list_vats:[],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",articles:[],categories:[],refs:[],showDropdown:!1,showDropdownRef:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isInvoiceOverdue(){const t=new Date().getTime(),e=this.invoice.due_date?new Date(this.invoice.due_date).getTime():null;return e&&e<t},defaultCurrency(){return{currency_id:this.settings.default_currency,currency_symbol:this.default_currency_symbol}},clientCurrency(){return{currency_id:this.client_detail.currency_id,currency_symbol:this.client_currency}},totalAmountWithoutDiscount(){const t=this.invoiceItems.reduce((e,s)=>{const a=s.quantity*s.unit_price;return e+a},0);return this.formatCurrency(t)},totalAmount(){const t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.invoiceItems.reduce((a,n)=>a+parseFloat(n.total_amount),0)*this.invoice.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)}},methods:{getUniqueVATRates(){const t=new Set;return this.invoiceItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.invoiceItems.forEach(s=>{if(s.vat_rate===t){const a=s.quantity*s.unit_price,n=a*s.discount/100;e+=(a-n)*t/100}}),this.formatCurrency(e)},calculateTotalAmountWithVAT(){let t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.settings.easy_compta_woo_addon_active==1&&(t+=parseFloat(this.invoice.shipping_amount||0)),this.formatCurrency(t)},formatShippingAmout(t){return this.formatShippingCurrency(t)},formatShippingCurrency(t){const s=(parseFloat(t)||0).toFixed(2),a=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${s}${a}`},fetchInvoice(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.invoice=t,this.fetchClientInfo(t.client_id)):console.error("Invoice not found")}).catch(t=>{console.error("Error fetching invoice:",t),this.loading=!1})},fetchClientInfo(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.invoiceItems=[],this.loading=!1,this.no_items=!0):(this.invoiceItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loading=!1,new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var a=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;a=s+n}else a=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(a)},calculateTotalWithVat(t,e,s,a){const n=t*e,o=n*a/100,f=n-o,m=f*s/100,p=f+m;return this.formatCurrency(p)},calculateTotal(t,e,s){const a=t*e,n=a*s/100,f=a-n;return this.formatCurrency(f)},submitItems(){this.updateTotal();const t={...this.newItem,invoice_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/invoices/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.SelectedInvoiceId=e,modal_remove.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.invoiceItems.find(a=>a.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:e})}).then(a=>a.json()).then(a=>{a.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(a.message,"alert-error"),console.error("Error removing item:",a.message),s.loading_del=!1)}).catch(a=>{this.showToast(a.message,"alert-error"),console.error("Error removing item:",a),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/invoices/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,a){const o=t*e*a/100,f=o*s/100,m=o+f;return this.formatCurrency(m)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.invoiceItems[t.oldIndex];this.invoiceItems.splice(t.oldIndex,1),this.invoiceItems.splice(t.newIndex,0,e);const s=this.invoiceItems.map(a=>a.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/invoices/update-invoice-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.articles=t}).catch(t=>console.error("Error fetching articles:",t))},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:a}=await zt();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=a,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)},sendRemind(t){this.loadingModal=!0,this.RemindInvoiceModal=!0,modal_send_remind.showModal(),this.fetchClientInfo(t),this.loadSettings()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchInvoice(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");A.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},Gp={class:"pt-2 pr-4"},Yp={key:0},Jp={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Kp=i("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Zp=[Kp],$p={key:3},e_={role:"alert",class:"alert alert-warning"},t_=i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[i("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),n_={key:0},s_=["data-tip"],o_={class:"btn btn-sm btn-primary",disabled:""},i_={class:"grid grid-cols-2"},a_={class:"md:col-span-1"},l_=["src"],r_={class:"md:col-span-1 text-right"},c_={class:"text-lg font-semibold"},d_={key:0,class:"badge badge-error text-white"},u_={key:1,class:"badge badge-error text-white"},h_={key:2,class:"badge badge-success text-white"},m_={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},f_=i("br",null,null,-1),p_=i("br",null,null,-1),__=i("br",null,null,-1),g_=["href"],v_=i("br",null,null,-1),y_=i("br",null,null,-1),b_=i("br",null,null,-1),w_=["href"],x_=i("br",null,null,-1),C_=["href"],I_={class:"table mt-8"},E_=i("th",null,null,-1),k_={width:"5%"},T_={width:"19%"},A_={width:"21%"},S_={width:"10%",class:"text-center"},P_={width:"8%",class:"text-center"},D_={key:0,width:"5%",class:"text-center"},M_={key:1,width:"5%"},j_={width:"10%",class:"text-center"},q_={width:"10%",class:"text-right"},O_=i("th",{width:"18%",class:"text-right inv-actions"},null,-1),R_=i("td",{class:"draggable-item drag-handle px-2"},[i("i",{class:"fas fa-bars"})],-1),V_={key:0,class:"badge badge-ghost badge-xs"},N_=["innerHTML"],B_={class:"text-center"},F_={class:"text-center"},W_={key:0},Q_={key:1},X_={key:0,class:"text-center"},U_={key:1},L_={key:2,class:"text-center"},z_=i("br",null,null,-1),H_={key:3,class:"text-center"},G_=i("br",null,null,-1),Y_={class:"text-right"},J_={key:0},K_={key:1},Z_={key:0},$_=["data-tip"],eg=["onClick"],tg=i("i",{class:"far fa-edit"},null,-1),ng=[tg],sg=["data-tip"],og=["onClick"],ig={key:0,class:"far fa-trash-alt"},ag={key:1,class:"loading loading-spinner loading-xs"},lg={key:0},rg=i("td",{class:"px-2"},null,-1),cg={class:"align-top px-2"},dg={class:"flex items-center border rounded-md relative"},ug=["placeholder"],hg={key:0,class:"autocomplete-dropdown bg-base-100"},mg=["onClick","innerHTML"],fg={class:"align-top px-2"},pg=i("option",{disabled:"",selected:""},"Type",-1),_g=["value"],gg={class:"flex items-center border rounded-md relative"},vg=["placeholder"],yg={key:0,class:"autocomplete-dropdown bg-base-100"},bg=["onClick","innerHTML"],wg={class:"align-top"},xg={class:"flex items-center rounded-md"},Cg=["placeholder"],Ig={class:"align-top"},Eg={class:"flex items-center border rounded-lg"},kg={class:"inline-flex"},Tg=["placeholder"],Ag={class:"align-top"},Sg={class:"flex items-center border rounded-md"},Pg=["placeholder"],Dg={key:0,class:"align-top"},Mg=["value"],jg={key:1,class:"align-top"},qg={class:"align-top"},Og={class:"flex items-center border rounded-md"},Rg=["placeholder"],Vg=i("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),Ng={key:2,class:"text-right"},Bg={key:3,class:"text-right"},Fg=["data-tip"],Wg={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},Qg={key:0,class:"fa fa-plus"},Xg={key:1,class:"loading loading-spinner loading-xs"},Ug={colspan:"8",class:"text-right no-border"},Lg={class:"text-right"},zg={key:0,class:"line-through"},Hg=i("td",null,null,-1),Gg={colspan:"8",class:"text-right no-border"},Yg={class:"text-right"},Jg=i("td",null,null,-1),Kg={key:2},Zg={colspan:"8",class:"text-right no-border"},$g={class:"text-right no-border"},ev={colspan:"8",class:"text-right no-border font-bold text-xl"},tv={class:"text-right no-border font-bold text-xl"},nv=i("td",null,null,-1),sv={key:3},ov={colspan:"8",class:"text-right no-border"},iv={class:"text-right no-border"},av={key:4},lv={colspan:"8",class:"text-right no-border"},rv={class:"text-right no-border font-bold text-xl"};function cv(t,e,s,a,n,o){const f=j("InvoiceNavBar"),m=j("remove-modal"),p=j("remind-invoice-modal"),d=j("edit-item-modal"),u=j("Card");return r(),c("div",Gp,[P(f,{invoiceInfo:n.invoice,currencyDefault:o.defaultCurrency,currencyClient:o.clientCurrency,emailActive:n.settings.easy_compta_email_addon_active,qrCodeActive:n.settings.easy_compta_qrcode_addon_active,noItems:n.no_items},null,8,["invoiceInfo","currencyDefault","currencyClient","emailActive","qrCodeActive","noItems"]),P(m,{"show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=h=>this.removeItem(n.selectedItem,n.SelectedInvoiceId)),onCancel:e[1]||(e[1]=h=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),n.settings.easy_compta_email_addon_active==1?(r(),c("div",Yp,[P(p,{loading:t.loadingModal,"show-modal":n.RemindInvoiceModal,"modal-id":"modal_send_remind",client:n.client_detail,"invoice-id":n.invoice.id,subject:n.settings.remind_invoice_subject,content:n.settings.remind_invoice_content,onClose:e[2]||(e[2]=h=>n.RemindInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):_("",!0),n.toast.visible?(r(),c("div",{key:1,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),n.loading?(r(),c("div",Jp,Zp)):_("",!0),o.isInvoiceOverdue&&n.invoice.status=="unpaid"?(r(),c("div",$p,[i("div",e_,[t_,i("span",null,l(o.translations.invoice_overdue),1),n.settings.easy_compta_email_addon_active==1?(r(),c("div",n_,[i("button",{onClick:e[3]||(e[3]=K(h=>o.sendRemind(n.invoice.client_id),["prevent"])),class:"btn btn-sm btn-primary"},l(o.translations.remind_invoice),1)])):(r(),c("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[i("button",o_,l(o.translations.remind_invoice),1)],8,s_))])])):_("",!0),P(u,{topMargin:"mt-8",id:"invoice-content"},{default:re(()=>[i("div",i_,[i("div",a_,[i("div",null,[i("img",{src:n.settings.logo_url,style:Zn({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,l_)])]),i("div",r_,[i("p",c_,l(n.invoice.invoice_number),1),i("div",null,[w(l(o.translations.created_at)+": ",1),i("strong",null,l(n.invoice.created_at),1)]),i("div",null,[w(l(o.translations.due_date)+": ",1),i("strong",null,l(n.invoice.due_date),1)]),i("div",null,[w(l(o.translations.status)+": ",1),n.invoice.status=="draft"?(r(),c("span",d_,l(o.translations.draft),1)):_("",!0),n.invoice.status=="unpaid"?(r(),c("span",u_,l(o.translations.unpaid),1)):_("",!0),n.invoice.status=="paid"?(r(),c("span",h_,l(o.translations.paid),1)):_("",!0)])])]),i("div",m_,[i("div",null,[i("strong",null,l(o.translations.bill_to)+":",1),i("h4",null,[i("strong",null,l(n.client_detail.company_name),1)]),i("p",null,[w(l(n.client_detail.address),1),f_,w(" "+l(n.client_detail.postal_code)+", "+l(n.client_detail.city)+" ",1),p_,w(" "+l(n.client_detail.country),1),__,n.client_detail.phone?(r(),c("a",{key:0,href:"tel:"+n.client_detail.phone},l(n.client_detail.phone),9,g_)):_("",!0)])]),i("div",null,[i("strong",null,l(o.translations.received_from)+":",1),i("h4",null,[i("strong",null,l(n.settings.company_name),1)]),i("p",null,[w(l(n.settings.company_address),1),v_,w(" "+l(n.settings.postal_code)+", "+l(n.settings.city)+" ",1),y_,w(" "+l(n.settings.country),1),b_,n.settings.company_phone?(r(),c("a",{key:0,href:"tel:"+n.settings.company_phone},l(n.settings.company_phone),9,w_)):_("",!0),x_,n.settings.mobile_phone?(r(),c("a",{key:1,href:"tel:"+n.settings.mobile_phone},l(n.settings.mobile_phone),9,C_)):_("",!0)])])]),P(d,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[4]||(e[4]=h=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),i("form",{onSubmit:e[24]||(e[24]=K((...h)=>o.submitItems&&o.submitItems(...h),["prevent"]))},[i("table",I_,[i("thead",null,[i("tr",null,[E_,i("th",k_,l(o.translations.item_ref),1),i("th",T_,l(o.translations.item_name),1),i("th",A_,l(o.translations.description),1),i("th",S_,l(o.translations.quantity),1),i("th",P_,l(o.translations.unit_price),1),n.settings.vat_active==1?(r(),c("th",D_,l(o.translations.vat),1)):(r(),c("th",M_)),i("th",j_,l(o.translations.discount),1),i("th",q_,l(o.translations.total),1),O_])]),i("tbody",null,[(r(!0),c(W,null,X(n.invoiceItems,(h,g)=>(r(),c("tr",{key:h.id||g},[R_,i("td",null,l(h.item_ref),1),i("td",null,[h.category_name?(r(),c("div",V_,l(h.category_name),1)):_("",!0),i("div",null,l(h.item_name),1)]),i("td",{innerHTML:o.nl2br(h.item_description)},null,8,N_),i("td",B_,l(h.quantity),1),i("td",F_,[w(l(h.unit_price),1),n.default_currency_symbol==n.client_currency?(r(),c("span",W_,l(n.default_currency_symbol),1)):(r(),c("span",Q_,l(n.client_currency),1))]),n.settings.vat_active==1?(r(),c("td",X_,l(h.vat_rate)+"% ",1)):(r(),c("td",U_)),n.settings.vat_active==1?(r(),c("td",L_,[w(l(h.discount)+"% ",1),z_,w(" "+l(o.calculateDiscountAmountWithVAT(h.quantity,h.unit_price,h.vat_rate,h.discount)),1)])):(r(),c("td",H_,[w(l(h.discount)+"% ",1),G_,w(" "+l(o.calculateDiscountAmount(h.quantity,h.unit_price,h.discount)),1)])),i("td",Y_,[w(l(h.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(r(),c("span",J_,l(n.default_currency_symbol),1)):(r(),c("span",K_,l(n.client_currency),1))]),i("td",null,[n.invoice.status=="draft"?(r(),c("div",Z_,[i("span",{class:"lg:tooltip","data-tip":o.translations.edit},[i("button",{onClick:K(v=>o.editItem(h.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},ng,8,eg)],8,$_),i("span",{class:"lg:tooltip","data-tip":o.translations.delete},[i("button",{onClick:K(v=>o.confirmremoveItem(h.id,n.invoice.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[h.loading_del?_("",!0):(r(),c("i",ig)),h.loading_del?(r(),c("span",ag)):_("",!0)],8,og)],8,sg)])):_("",!0)])]))),128)),n.invoice.status=="draft"?(r(),c("tr",lg,[rg,i("td",cg,[i("div",dg,[B(i("input",{type:"text","onUpdate:modelValue":e[5]||(e[5]=h=>n.newItem.item_ref=h),onInput:e[6]||(e[6]=(...h)=>o.fetchRefs&&o.fetchRefs(...h)),onFocus:e[7]||(e[7]=h=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 input-xs outline-none"},null,40,ug),[[J,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(r(),c("ul",hg,[(r(!0),c(W,null,X(n.refs,h=>(r(),c("li",{key:h.ref,onClick:g=>o.selectItem(h),class:"autocomplete-item",innerHTML:o.highlightMatch(h.ref)},null,8,mg))),128))])):_("",!0)])]),i("td",fg,[B(i("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[8]||(e[8]=h=>n.newItem.item_category=h)},[pg,(r(!0),c(W,null,X(n.categories,h=>(r(),c("option",{key:h.id,value:h.id},l(h.name),9,_g))),128))],512),[[ye,n.newItem.item_category]]),i("div",gg,[B(i("input",{type:"text","onUpdate:modelValue":e[9]||(e[9]=h=>n.newItem.item_name=h),onInput:e[10]||(e[10]=(...h)=>o.fetchArticles&&o.fetchArticles(...h)),onFocus:e[11]||(e[11]=h=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,vg),[[J,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(r(),c("ul",yg,[(r(!0),c(W,null,X(n.articles,h=>(r(),c("li",{key:h.name,onClick:g=>o.selectItem(h),class:"autocomplete-item bt-primary",innerHTML:o.highlightMatch(h.name)},null,8,bg))),128))])):_("",!0)])]),i("td",wg,[i("div",xg,[B(i("textarea",{"onUpdate:modelValue":e[12]||(e[12]=h=>n.newItem.item_description=h),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[13]||(e[13]=h=>o.resize()),ref:"textarea"},null,40,Cg),[[J,n.newItem.item_description]])])]),i("td",Ig,[i("div",Eg,[i("div",kg,[i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[14]||(e[14]=(...h)=>o.decrease&&o.decrease(...h))}," - "),B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[15]||(e[15]=h=>n.newItem.quantity=h),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[16]||(e[16]=(...h)=>o.updateTotal&&o.updateTotal(...h))},null,40,Tg),[[J,n.newItem.quantity]]),i("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[17]||(e[17]=(...h)=>o.increase&&o.increase(...h))}," + ")])])]),i("td",Ag,[i("div",Sg,[B(i("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[18]||(e[18]=h=>n.newItem.unit_price=h),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[19]||(e[19]=(...h)=>o.updateTotal&&o.updateTotal(...h))},null,40,Pg),[[J,n.newItem.unit_price]])])]),n.settings.vat_active==1?(r(),c("td",Dg,[B(i("select",{"onUpdate:modelValue":e[20]||(e[20]=h=>n.newItem.vat_rate=h),onChange:e[21]||(e[21]=(...h)=>o.updateTotal&&o.updateTotal(...h)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(r(!0),c(W,null,X(n.list_vats,h=>(r(),c("option",{key:h,value:h.rate},l(h.rate)+"% ",9,Mg))),128))],544),[[ye,n.newItem.vat_rate]])])):(r(),c("td",jg)),i("td",qg,[i("div",Og,[B(i("input",{type:"number","onUpdate:modelValue":e[22]||(e[22]=h=>n.newItem.discount=h),min:"0",max:"100",placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[23]||(e[23]=(...h)=>o.updateTotal&&o.updateTotal(...h))},null,40,Rg),[[J,n.newItem.discount]]),Vg])]),n.settings.vat_active==1?(r(),c("td",Ng,l(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(r(),c("td",Bg,l(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),i("td",null,[i("span",{class:"lg:tooltip","data-tip":o.translations.add},[i("button",Wg,[n.loading_add?_("",!0):(r(),c("i",Qg)),n.loading_add?(r(),c("span",Xg)):_("",!0)])],8,Fg)])])):_("",!0),i("tr",null,[i("td",Ug,[i("strong",null,l(o.translations.subtotal),1)]),i("td",Lg,[o.totalAmount!==o.totalAmountWithoutDiscount?(r(),c("span",zg,l(o.totalAmountWithoutDiscount),1)):_("",!0),w(" "+l(o.totalAmount),1)]),Hg]),n.settings.vat_active==1?(r(!0),c(W,{key:1},X(o.getUniqueVATRates(),(h,g)=>(r(),c("tr",{key:g},[i("td",Gg,[i("strong",null,l(o.translations.tax)+" ("+l(h)+"%) ",1)]),i("td",Yg,l(o.calculateVATForRate(h)),1),Jg]))),128)):_("",!0),n.invoice.shipping_amount?(r(),c("tr",Kg,[i("td",Zg,[i("strong",null,l(o.translations.shipping_fees),1)]),i("td",$g,l(o.formatShippingAmout(n.invoice.shipping_amount)),1)])):_("",!0),i("tr",null,[i("td",ev,[i("strong",null,l(o.translations.total),1)]),i("td",tv,l(o.calculateTotalAmountWithVAT()),1),nv]),n.client_currency!=n.default_currency_symbol?(r(),c("tr",sv,[i("td",ov,[i("strong",null,l(o.translations.exchange_rate),1)]),i("td",iv,l(n.invoice.exchange_rate),1)])):_("",!0),n.client_currency!=n.default_currency_symbol?(r(),c("tr",av,[i("td",lv,[i("strong",null,l(o.translations.total)+" "+l(n.default_currency_symbol),1)]),i("td",rv,l(o.totalAmountDefaultCurrency)+l(n.default_currency_symbol),1)])):_("",!0)])])],32)]),_:1})])}var dv=oe(Hp,[["render",cv]]);const uv={name:"InvoiceNew",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],last_invoice_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.invoice_prefix}_${String(this.settings.last_invoice_id).padStart(4,"0")}`;this.invoice.number=s}else{const e=await t.json()}}catch{this.loading=!1}},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/invoices",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting invoice:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},hv={class:"pt-2 pr-4"},mv={class:"flex justify-between items-center mb-4"},fv={class:"card-title"},pv=i("div",{class:"divider mt-2"},null,-1),_v={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},gv={class:"grid grid-cols-2 gap-4"},vv={class:"ecwp-group form-group mb-4"},yv={for:"invoiceNumber",class:"ecwp-label"},bv={class:"ecwp-group form-group mb-4"},wv={for:"invoiceDate",class:"ecwp-label"},xv={class:"ecwp-group form-group mb-4"},Cv={for:"client",class:"ecwp-label"},Iv={class:"ecwp-group form-group mb-4"},Ev={for:"status",class:"ecwp-label"},kv={value:"draft"},Tv={key:0,class:"ecwp-group form-group mb-4"},Av={for:"exchangeRate",class:"ecwp-label"},Sv={class:"flex justify-between"},Pv=["disabled"],Dv={key:0,class:"loading loading-spinner loading-sm"};function Mv(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",hv,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),P(p,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:re(()=>[i("div",mv,[i("h2",fv,l(o.translations.new_invoice),1)]),pv,n.loading?(r(),c("div",_v)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitInvoice&&o.submitInvoice(...d),["prevent"]))},[i("div",gv,[i("div",vv,[i("label",yv,l(o.translations.invoice_number),1),B(i("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.invoice.number=d),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[J,n.invoice.number]])]),i("div",bv,[i("label",wv,l(o.translations.due_date),1),P(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.invoice.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),i("div",xv,[i("label",Cv,l(o.translations.company_name),1),P(m,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[2]||(e[2]=d=>n.invoice.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",Iv,[i("label",Ev,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[3]||(e[3]=d=>n.invoice.status=d),class:k(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[i("option",kv,l(o.translations.draft),1)],2),[[ye,n.invoice.status]])]),o.currencyMismatch?(r(),c("div",Tv,[i("label",Av,l(o.translations.exchange_rate),1),B(i("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[4]||(e[4]=d=>n.invoice.exchange_rate=d),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[J,n.invoice.exchange_rate]])])):_("",!0)]),i("div",Sv,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.submit)+" ",1),n.loadingBtn?(r(),c("span",Dv)):_("",!0)],8,Pv)])],32)]),_:1})])}var jv=oe(uv,[["render",Mv]]);const qv={name:"invoiceEdit",components:{Card:Xe,ModelSelect:Lt,VueDatePicker:Ct},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"paid",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getFullYear();return`${e}-${s}-${a}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchInvoiceDetails()},methods:{cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.invoice.client_id&&this.setClientById(this.invoice.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchInvoiceDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?this.invoice=e:(console.error("Error fetching invoice details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching invoice details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.invoice.client=this.clients.find(e=>e.id===t)||null},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting invoice:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Ov={class:"pt-2 pr-4"},Rv={class:"flex justify-between items-center mb-4"},Vv={class:"card-title"},Nv=i("div",{class:"divider mt-2"},null,-1),Bv={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Fv={class:"grid grid-cols-2 gap-4"},Wv={class:"ecwp-group form-group mb-4"},Qv={for:"invoiceNumber",class:"ecwp-label"},Xv={class:"ecwp-group form-group mb-4"},Uv={for:"invoiceDate",class:"ecwp-label"},Lv={class:"ecwp-group form-group mb-4"},zv={for:"client",class:"ecwp-label"},Hv={class:"ecwp-group form-group mb-4"},Gv={for:"status",class:"ecwp-label"},Yv={value:"draft",selected:""},Jv={value:"unpaid"},Kv={value:"paid"},Zv={key:0,class:"ecwp-group form-group mb-4"},$v={for:"exchangeRate",class:"ecwp-label"},ey={class:"flex justify-between"},ty=["disabled"],ny={key:0,class:"loading loading-spinner loading-sm"};function sy(t,e,s,a,n,o){const f=j("VueDatePicker"),m=j("model-select"),p=j("Card");return r(),c("div",Ov,[n.toast.visible?(r(),c("div",{key:0,class:k(["toast",n.toast.position]),style:{zIndex:9999}},[i("div",{class:k(["alert",n.toast.type,"text-white"])},[i("span",null,l(n.toast.message),1)],2)],2)):_("",!0),P(p,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:re(()=>[i("div",Rv,[i("h2",Vv,l(o.translations.edit_invoice),1)]),Nv,n.loading?(r(),c("div",Bv)):_("",!0),i("form",{onSubmit:e[6]||(e[6]=K((...d)=>o.submitInvoice&&o.submitInvoice(...d),["prevent"]))},[i("div",Fv,[i("div",Wv,[i("label",Qv,l(o.translations.invoice_number),1),B(i("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.invoice.invoice_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[J,n.invoice.invoice_number]])]),i("div",Xv,[i("label",Uv,l(o.translations.due_date),1),P(f,{class:k(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.invoice.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),i("div",Lv,[i("label",zv,l(o.translations.company_name),1),P(m,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[2]||(e[2]=d=>n.invoice.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:k(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),i("div",Hv,[i("label",Gv,l(o.translations.status),1),B(i("select",{id:"status","onUpdate:modelValue":e[3]||(e[3]=d=>n.invoice.status=d),class:k(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[i("option",Yv,l(o.translations.draft),1),i("option",Jv,l(o.translations.unpaid),1),i("option",Kv,l(o.translations.paid),1)],2),[[ye,n.invoice.status]])]),o.currencyMismatch?(r(),c("div",Zv,[i("label",$v,l(o.translations.exchange_rate),1),B(i("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[4]||(e[4]=d=>n.invoice.exchange_rate=d),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[J,n.invoice.exchange_rate]])])):_("",!0)]),i("div",ey,[i("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},l(o.translations.cancel),1),i("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(l(o.translations.save)+" ",1),n.loadingBtn?(r(),c("span",ny)):_("",!0)],8,ty)])],32)]),_:1})])}var oy=oe(qv,[["render",sy]]);const ue=Xt;(function(t,e){const s=Xt,a=t();for(;[];)try{if(parseInt(s(345))/1*(-parseInt(s(336))/2)+-parseInt(s(350))/3+-parseInt(s(351))/4+-parseInt(s(346))/5+-parseInt(s(337))/6+-parseInt(s(344))/7*(parseInt(s(339))/8)+parseInt(s(330))/9*(parseInt(s(348))/10)===e)break;a.push(a.shift())}catch{a.push(a.shift())}})(Ut,180356);function Xt(t,e){const s=Ut();return Xt=function(a,n){return a=a-327,s[a]},Xt(t,e)}const iy=[{path:ue(334),name:ue(349),component:Ma},{path:ue(328),name:ue(341),component:xu},{path:ue(338),name:ue(340),component:Yu},{path:ue(327),name:ue(331),component:_s},{path:ue(329),name:ue(347),component:$h},{path:"/invoice/detail/:id",name:ue(335),component:dv},{path:ue(342),name:ue(333),component:oy},{path:ue(343),name:ue(332),component:jv}],hy=Qo({history:_o(),routes:iy});function Ut(){const t=["/quote/new","8eBgfmr","QuoteNew","QuoteViewDetail","/invoice/edit/:id","/invoice/new","1228493mZOvUn","1VbAmTU","1591685BUNWgg","Invoice","2789430tlMbGP","Quote","644178VXobYq","323492LbILUL","/quote/edit/:id","/quote/detail/:id","/invoices","45bOZZen","QuoteEdit","InvoiceNew","InvoiceEdit","/quotes","InvoiceViewDetail","709378htMHtw","421410aqbgta"];return Ut=function(){return t},Ut()}export{hy as r};
  • my-easy-compta/trunk/assets/dist/invoices.min.js

    r3167980 r3169216  
    1 import{_ as i,d as u,o as _,H as d,f as m,h as f}from"./plugin-vue_export-helper.min.js";import{r as b}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const I={name:"Invoices",mounted(){this.$router.push("/invoices")}};function h(n,r,e,t,x,p){const c=u("router-view");return _(),d(c)}var v=i(I,[["render",h]]);const a=o;function o(n,r){const e=s();return o=function(t,x){return t=t-265,e[t]},o(n,r)}(function(n,r){const e=o,t=n();for(;[];)try{if(parseInt(e(275))/1+-parseInt(e(269))/2+parseInt(e(276))/3*(parseInt(e(270))/4)+-parseInt(e(271))/5*(parseInt(e(266))/6)+-parseInt(e(265))/7+parseInt(e(274))/8*(-parseInt(e(268))/9)+parseInt(e(272))/10===r)break;t.push(t.shift())}catch{t.push(t.shift())}})(s,871380);function s(){const n=["use","542088cBGGnv","360602VFLuTB","617096vyGBZQ","10bbpeKC","25224040Emkugl","mount","144aEjeuO","677218NQsckJ","24zNyYnN","9690205bQLTNO","2740926HWBjyW"];return s=function(){return n},s()}const l=m({render:()=>f(v)});l[a(267)](b)[a(273)]("#my-easy-compta-invoices-app");
     1import{_ as i,d as u,o as _,H as f,f as m,h as I}from"./plugin-vue_export-helper.min.js";import{r as d}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const h={name:"Invoices",mounted(){this.$router.push("/invoices")}};function b(e,r,t,n,x,c){const p=u("router-view");return _(),f(p)}var l=i(h,[["render",b]]);const a=o;(function(e,r){const t=o,n=e();for(;[];)try{if(parseInt(t(359))/1*(parseInt(t(355))/2)+-parseInt(t(361))/3+-parseInt(t(360))/4+parseInt(t(354))/5+parseInt(t(357))/6+-parseInt(t(353))/7*(parseInt(t(352))/8)+-parseInt(t(358))/9===r)break;n.push(n.shift())}catch{n.push(n.shift())}})(s,539895);const v=m({render:()=>I(l)});v[a(356)](d)[a(363)](a(362));function o(e,r){const t=s();return o=function(n,x){return n=n-352,t[n]},o(e,r)}function s(){const e=["mount","1289688majnUT","28naILjx","3052945ygZxnL","32cWQFXW","use","5063412QbhsIf","943803dGBTKt","46477gDwpIG","618208WWHduS","2261895Plfisu","#my-easy-compta-invoices-app"];return s=function(){return e},s()}
  • my-easy-compta/trunk/assets/dist/payments.min.js

    r3167980 r3169216  
    1 import{_ as C,d as y,o as i,c as d,n as h,a as t,t as r,g as f,F as p,r as _,w as E,i as g,k as D,j as T,H as I,v as B,m as w,e as P,p as j,f as V,h as S}from"./plugin-vue_export-helper.min.js";import{C as A,R as U}from"./RemoveAlert.min.js";import{V as R}from"./vue-datepicker.min.js";import{g as F,b as X,s as N,f as W}from"./api.min.js";const z={components:{VueDatePicker:R},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},payment:{type:Object,default:()=>({id:null,invoice_number:"",company_name:"",amount:"",payment_method_id:"",payment_date:"",note:"",payment_methods:[]})},disabled:{type:Boolean,default:!0},methods:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedPayment:{...this.payment},loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{invoice_number:{label:s.invoice_number,disabled:this.disabled},company_name:{label:s.client,disabled:this.disabled},amount:{label:s.amount,disabled:!1},payment_method:{label:s.payment_method},payment_date:{label:s.payment_date}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const e=s.getDate().toString().padStart(2,"0"),l=(s.getMonth()+1).toString().padStart(2,"0"),c=s.getFullYear();return`${e}-${l}-${c}`}},paymentMethods(){return this.methods},skeletonItems(){return Array.from({length:10},(s,e)=>e)}},methods:{closeModal(){document.getElementById("modal_payment_edit").close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/payments/${this.editedPayment.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedPayment)});if(s.ok){const e=await s.json();this.closeModal(),this.loadingBtn=!1,this.showToast(e.message,"alert-success"),this.$emit("paymentEdited")}else{this.loadingBtn=!1;const e=`Error editing payment: ${s.statusText}`;this.showToast(e,"alert-error"),console.error(e)}}catch(s){const e=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing payment";this.showToast(e,"alert-error"),console.error("Error editing payment:",s),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{payment:{handler(s){this.editedPayment={...s}},immediate:!0}}},O=["id","open"],L={class:"modal-box"},q={class:"font-bold text-lg"},J={key:0},K={class:"grid grid-cols-2 gap-4"},Y=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),G=t("div",{class:"skeleton h-4 w-full"},null,-1),H=[Y,G],Q={class:"grid grid-cols-2 gap-4"},Z=["for"],$=["type","id","onUpdate:modelValue","disabled"],ee=["id"],te=["value"],se={class:"ecwp-group form-group mt-4"},ne={for:"note",class:"ecwp-label form-label"},ae={class:"form-group mt-4 flex justify-end"},oe=["disabled"],le={key:0,class:"loading loading-spinner loading-sm"};function ie(s,e,l,c,n,o){const x=y("VueDatePicker");return i(),d("div",null,[n.toast.visible?(i(),d("div",{key:0,class:h(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:h(["alert",n.toast.type,"text-white"])},[t("span",null,r(n.toast.message),1)],2)],2)):f("",!0),t("dialog",{id:l.modalId,class:"modal",open:l.showModal},[t("div",L,[t("h3",q,r(l.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...m)=>o.closeModal&&o.closeModal(...m))}," \u2715 "),l.loading?(i(),d("div",J,[t("div",K,[(i(!0),d(p,null,_(o.skeletonItems,m=>(i(),d("div",{key:m,class:"py-2"},H))),128))])])):(i(),d("form",{key:1,onSubmit:e[4]||(e[4]=E((...m)=>o.submitForm&&o.submitForm(...m),["prevent"])),class:"form"},[t("div",Q,[(i(!0),d(p,null,_(n.fields,(m,u)=>(i(),d("div",{key:u,class:"ecwp-group form-group"},[t("label",{for:u,class:"ecwp-label form-label"},r(m.label),9,Z),u!=="payment_method"&&u!=="payment_date"?g((i(),d("input",{key:0,type:m.type||"text",id:u,"onUpdate:modelValue":a=>n.editedPayment[u]=a,class:h(["ecwp-input input","input-bordered",m.class||"w-full"]),disabled:m.disabled},null,10,$)),[[D,n.editedPayment[u]]]):u=="payment_method"?g((i(),d("select",{key:1,id:u,"onUpdate:modelValue":e[1]||(e[1]=a=>n.editedPayment.payment_method_id=a),class:h(["ecwp-input input","input-bordered",m.class||"w-full"])},[(i(!0),d(p,null,_(o.paymentMethods,a=>(i(),d("option",{key:a.id,value:a.id},r(a.method_name),9,te))),128))],10,ee)),[[T,n.editedPayment.payment_method_id]]):u=="payment_date"?(i(),I(x,{key:2,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedPayment.payment_date,"onUpdate:modelValue":e[2]||(e[2]=a=>n.editedPayment.payment_date=a),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date"])):f("",!0)]))),128))]),t("div",se,[t("label",ne,r(o.translations.note),1),g(t("textarea",{id:"note","onUpdate:modelValue":e[3]||(e[3]=m=>n.editedPayment.notes=m),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[B,n.editedPayment.notes]])]),t("div",ae,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[w(r(o.translations.save)+" ",1),n.loadingBtn?(i(),d("span",le)):f("",!0)],8,oe)])],32))])],8,O)])}var de=C(z,[["render",ie]]);const re={name:"Payments",components:{Card:A,PaymentEditModal:de,RemoveModal:U},data(){return{payments:[],paymentMethods:[],paymentForm:{invoice_id:"",client_id:"",amount:"",payment_method_id:"",payment_date:""},editPaymentModal:!1,selectedPayment:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchPayments(),this.loadSettings()},methods:{fetchPayments(s=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/payments?page=${s}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(l=>l.json()).then(l=>{this.payments=l.payments,this.totalCount=l.total_count,this.totalPages=l.total_pages,this.currentPage=l.page,this.perPage=e,this.generatePaginationButtons()}).catch(l=>{console.error("Error fetching payments:",l)}).finally(()=>{this.loading=!1})},editPayment(s){this.loadingModal=!0,this.editPaymentModal=!0,modal_payment_edit.showModal(),this.fetchPaymentDetails(s)},fetchPaymentDetails(s){fetch(`/wp-json/my-easy-compta/v1/payments/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedPayment=e,this.paymentMethods=e.payment_methods,console.log(this.paymentMethods),this.loadingModal=!1}).catch(e=>{console.error("Error fetching payment details:",e),this.loadingModal=!1})},generatePaginationButtons(){this.paginationButtons=F(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchPayments(s)},perPageChanged(){this.fetchPayments()},formatAmount(s,e){return X(s,e,this.settings.currency_position)},showToast(s,e){N(this.toast,s,e)},closePaymentModal(){this.showPaymentModal=!1},confirmDeletePayment(s){this.selectedPayment=s,modal_remove.showModal(),this.showRemoveModal=!0},deletePayment(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/payments/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchPayments(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting payment:",e.statusText))}).catch(e=>{console.error("Error deleting payment:",e)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:e,vatData:l}=await W();this.settings=s,this.default_currency_symbol=e,this.default_vat=l,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},me={class:"pt-2 pr-4"},ce={class:"flex justify-between items-center"},ue={class:"card-title"},he={key:0},pe={class:"btn btn-outline btn-accent rounded-full",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab4"},_e=t("i",{class:"fas fa-file-export"},null,-1),ye=["data-tip"],fe={class:"btn btn-outline btn-accent rounded-full",disabled:""},ge=t("i",{class:"fas fa-file-export"},null,-1),be=t("div",{class:"divider mt-2"},null,-1),ve={class:"flex items-center mb-4"},xe={for:"perPageSelect",class:"mr-2"},Pe=["value"],we={class:"overflow-x-auto"},ke={key:0,class:"table w-full"},Me={class:"flex justify-center"},Ce={key:0},Te={key:1},Ee=t("span",{class:"loading loading-bars loading-sm"},null,-1),De=[Ee],Ie={class:"flex justify-end"},Be=["data-tip"],je=["onClick"],Ve=t("i",{class:"fas fa-pencil-alt"},null,-1),Se=[Ve],Ae=["data-tip"],Ue=["onClick"],Re=t("i",{class:"far fa-trash-alt"},null,-1),Fe=[Re],Xe={key:1},Ne=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),We=t("div",{class:"divider my-1"},null,-1),ze=[Ne,We],Oe={class:"join ecwp_pagination mt-6 pt-4"},Le=["onClick"];function qe(s,e,l,c,n,o){const x=y("payment-edit-modal"),m=y("remove-modal"),u=y("Card");return i(),d("div",me,[n.toast.visible?(i(),d("div",{key:0,class:h(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:h(["alert",n.toast.type,"text-white"])},[t("span",null,r(n.toast.message),1)],2)],2)):f("",!0),P(x,{loading:n.loadingModal,"show-modal":n.editPaymentModal,"modal-id":"modal_payment_edit","modal-title":o.translations.edit_payment,payment:n.selectedPayment,methods:n.paymentMethods,onClose:e[0]||(e[0]=a=>n.editPaymentModal=!1),onPaymentEdited:o.fetchPayments},null,8,["loading","show-modal","modal-title","payment","methods","onPaymentEdited"]),P(m,{"show-modal":n.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[1]||(e[1]=a=>this.deletePayment(n.selectedPayment)),onCancel:e[2]||(e[2]=a=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(u,{topMargin:"mt-8"},{default:j(()=>[t("div",ce,[t("h2",ue,r(o.translations.payments),1),n.settings.easy_compta_export_addon_active==1?(i(),d("div",he,[t("a",pe,[w(r(o.translations.export)+" ",1),_e])])):(i(),d("div",{key:1,class:"tooltip tooltip-left tooltip-warning","data-tip":o.translations.active_export_addon},[t("button",fe,[w(r(o.translations.export)+" ",1),ge])],8,ye))]),be,t("div",ve,[t("label",xe,r(o.translations.display_per_page),1),g(t("select",{id:"perPageSelect","onUpdate:modelValue":e[3]||(e[3]=a=>n.perPage=a),onChange:e[4]||(e[4]=(...a)=>o.perPageChanged&&o.perPageChanged(...a))},[(i(!0),d(p,null,_(n.perPageOptions,a=>(i(),d("option",{key:a,value:a},r(a),9,Pe))),128))],544),[[T,n.perPage]])]),t("div",we,[n.loading?(i(),d("div",Xe,[(i(!0),d(p,null,_(n.skeletonRows,a=>(i(),d("div",{key:a,class:"flex flex-col gap-4 w-full"},ze))),128))])):(i(),d("table",ke,[t("thead",null,[t("tr",null,[t("th",null,r(o.translations.invoice_number),1),t("th",null,r(o.translations.client),1),t("th",null,r(o.translations.payment_date),1),t("th",null,r(o.translations.amount),1),t("th",null,r(o.translations.payment_method),1),t("th",null,r(o.translations.note),1),t("th",Me,r(o.translations.actions),1)])]),t("tbody",null,[(i(!0),d(p,null,_(n.payments,a=>(i(),d("tr",{key:a.id},[t("td",null,r(a.invoice_number),1),t("td",null,r(a.company_name),1),t("td",null,r(a.payment_date),1),t("td",null,[n.loadingPrice?(i(),d("div",Te,De)):(i(),d("div",Ce,[t("span",null,r(o.formatAmount(a.amount,n.default_currency_symbol)),1)]))]),t("td",null,r(a.method_name),1),t("td",null,r(a.notes),1),t("td",Ie,[t("span",{class:"lg:tooltip","data-tip":o.translations.edit},[t("button",{class:"btn btn-circle mx-1",onClick:k=>o.editPayment(a.id)},Se,8,je)],8,Be),t("span",{class:"lg:tooltip","data-tip":o.translations.delete},[t("button",{onClick:k=>o.confirmDeletePayment(a.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Fe,8,Ue)],8,Ae)])]))),128))])])),t("div",Oe,[(i(!0),d(p,null,_(n.paginationButtons,a=>(i(),d("button",{key:a,class:h(["join-item btn",{"btn-disabled":a==="..."||a===n.currentPage}]),onClick:k=>o.goToPage(a)},r(a),11,Le))),128))])])]),_:1})])}var Je=C(re,[["render",qe]]);function b(s,e){const l=v();return b=function(c,n){return c=c-128,l[c]},b(s,e)}function v(){const s=["22856ofIyzg","#my-easy-compta-payments-app","1506dDrrum","mount","7464WhPcke","2255025XEdZUX","5797wfoXAK","510NDggQI","6678xDEfiu","402WYbJVg","2943jKbvdr","620piUhzC","8090fcDvDI","5227884mLbhkG"];return v=function(){return s},v()}const M=b;(function(s,e){const l=b,c=s();for(;[];)try{if(parseInt(l(139))/1*(-parseInt(l(130))/2)+parseInt(l(135))/3*(parseInt(l(128))/4)+parseInt(l(133))/5+-parseInt(l(137))/6*(parseInt(l(136))/7)+-parseInt(l(132))/8*(parseInt(l(138))/9)+parseInt(l(140))/10*(parseInt(l(134))/11)+-parseInt(l(141))/12===e)break;c.push(c.shift())}catch{c.push(c.shift())}})(v,577202);const Ke=V({render:()=>S(Je)});Ke[M(131)](M(129));
     1import{_ as C,d as y,o as i,c as d,n as h,a as t,t as r,g as f,F as p,r as _,w as E,i as g,k as B,j as T,H as I,v as j,m as P,e as w,p as V,f as D,h as S}from"./plugin-vue_export-helper.min.js";import{C as A,R as F}from"./RemoveAlert.min.js";import{V as R}from"./vue-datepicker.min.js";import{g as U,b as z,s as N,f as W}from"./api.min.js";const H={components:{VueDatePicker:R},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},payment:{type:Object,default:()=>({id:null,invoice_number:"",company_name:"",amount:"",payment_method_id:"",payment_date:"",note:"",payment_methods:[]})},disabled:{type:Boolean,default:!0},methods:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedPayment:{...this.payment},loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{invoice_number:{label:s.invoice_number,disabled:this.disabled},company_name:{label:s.client,disabled:this.disabled},amount:{label:s.amount,disabled:!1},payment_method:{label:s.payment_method},payment_date:{label:s.payment_date}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const e=s.getDate().toString().padStart(2,"0"),l=(s.getMonth()+1).toString().padStart(2,"0"),m=s.getFullYear();return`${e}-${l}-${m}`}},paymentMethods(){return this.methods},skeletonItems(){return Array.from({length:10},(s,e)=>e)}},methods:{closeModal(){document.getElementById("modal_payment_edit").close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/payments/${this.editedPayment.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedPayment)});if(s.ok){const e=await s.json();this.closeModal(),this.loadingBtn=!1,this.showToast(e.message,"alert-success"),this.$emit("paymentEdited")}else{this.loadingBtn=!1;const e=`Error editing payment: ${s.statusText}`;this.showToast(e,"alert-error"),console.error(e)}}catch(s){const e=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing payment";this.showToast(e,"alert-error"),console.error("Error editing payment:",s),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{payment:{handler(s){this.editedPayment={...s}},immediate:!0}}},O=["id","open"],X={class:"modal-box"},q={class:"font-bold text-lg"},G={key:0},K={class:"grid grid-cols-2 gap-4"},L=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),J=t("div",{class:"skeleton h-4 w-full"},null,-1),Q=[L,J],Y={class:"grid grid-cols-2 gap-4"},Z=["for"],$=["type","id","onUpdate:modelValue","disabled"],ee=["id"],te=["value"],se={class:"ecwp-group form-group mt-4"},ne={for:"note",class:"ecwp-label form-label"},ae={class:"form-group mt-4 flex justify-end"},oe=["disabled"],le={key:0,class:"loading loading-spinner loading-sm"};function ie(s,e,l,m,n,o){const x=y("VueDatePicker");return i(),d("div",null,[n.toast.visible?(i(),d("div",{key:0,class:h(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:h(["alert",n.toast.type,"text-white"])},[t("span",null,r(n.toast.message),1)],2)],2)):f("",!0),t("dialog",{id:l.modalId,class:"modal",open:l.showModal},[t("div",X,[t("h3",q,r(l.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...c)=>o.closeModal&&o.closeModal(...c))}," \u2715 "),l.loading?(i(),d("div",G,[t("div",K,[(i(!0),d(p,null,_(o.skeletonItems,c=>(i(),d("div",{key:c,class:"py-2"},Q))),128))])])):(i(),d("form",{key:1,onSubmit:e[4]||(e[4]=E((...c)=>o.submitForm&&o.submitForm(...c),["prevent"])),class:"form"},[t("div",Y,[(i(!0),d(p,null,_(n.fields,(c,u)=>(i(),d("div",{key:u,class:"ecwp-group form-group"},[t("label",{for:u,class:"ecwp-label form-label"},r(c.label),9,Z),u!=="payment_method"&&u!=="payment_date"?g((i(),d("input",{key:0,type:c.type||"text",id:u,"onUpdate:modelValue":a=>n.editedPayment[u]=a,class:h(["ecwp-input input","input-bordered",c.class||"w-full"]),disabled:c.disabled},null,10,$)),[[B,n.editedPayment[u]]]):u=="payment_method"?g((i(),d("select",{key:1,id:u,"onUpdate:modelValue":e[1]||(e[1]=a=>n.editedPayment.payment_method_id=a),class:h(["ecwp-input input","input-bordered",c.class||"w-full"])},[(i(!0),d(p,null,_(o.paymentMethods,a=>(i(),d("option",{key:a.id,value:a.id},r(a.method_name),9,te))),128))],10,ee)),[[T,n.editedPayment.payment_method_id]]):u=="payment_date"?(i(),I(x,{key:2,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedPayment.payment_date,"onUpdate:modelValue":e[2]||(e[2]=a=>n.editedPayment.payment_date=a),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date"])):f("",!0)]))),128))]),t("div",se,[t("label",ne,r(o.translations.note),1),g(t("textarea",{id:"note","onUpdate:modelValue":e[3]||(e[3]=c=>n.editedPayment.notes=c),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[j,n.editedPayment.notes]])]),t("div",ae,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[P(r(o.translations.save)+" ",1),n.loadingBtn?(i(),d("span",le)):f("",!0)],8,oe)])],32))])],8,O)])}var de=C(H,[["render",ie]]);const re={name:"Payments",components:{Card:A,PaymentEditModal:de,RemoveModal:F},data(){return{payments:[],paymentMethods:[],paymentForm:{invoice_id:"",client_id:"",amount:"",payment_method_id:"",payment_date:""},editPaymentModal:!1,selectedPayment:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchPayments(),this.loadSettings()},methods:{fetchPayments(s=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/payments?page=${s}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(l=>l.json()).then(l=>{this.payments=l.payments,this.totalCount=l.total_count,this.totalPages=l.total_pages,this.currentPage=l.page,this.perPage=e,this.generatePaginationButtons()}).catch(l=>{console.error("Error fetching payments:",l)}).finally(()=>{this.loading=!1})},editPayment(s){this.loadingModal=!0,this.editPaymentModal=!0,modal_payment_edit.showModal(),this.fetchPaymentDetails(s)},fetchPaymentDetails(s){fetch(`/wp-json/my-easy-compta/v1/payments/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedPayment=e,this.paymentMethods=e.payment_methods,console.log(this.paymentMethods),this.loadingModal=!1}).catch(e=>{console.error("Error fetching payment details:",e),this.loadingModal=!1})},generatePaginationButtons(){this.paginationButtons=U(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchPayments(s)},perPageChanged(){this.fetchPayments()},formatAmount(s,e){return z(s,e,this.settings.currency_position)},showToast(s,e){N(this.toast,s,e)},closePaymentModal(){this.showPaymentModal=!1},confirmDeletePayment(s){this.selectedPayment=s,modal_remove.showModal(),this.showRemoveModal=!0},deletePayment(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/payments/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchPayments(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting payment:",e.statusText))}).catch(e=>{console.error("Error deleting payment:",e)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:e,vatData:l}=await W();this.settings=s,this.default_currency_symbol=e,this.default_vat=l,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},ce={class:"pt-2 pr-4"},me={class:"flex justify-between items-center"},ue={class:"card-title"},he={key:0},pe={class:"btn btn-outline btn-accent rounded-full",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab4"},_e=t("i",{class:"fas fa-file-export"},null,-1),ye=["data-tip"],fe={class:"btn btn-outline btn-accent rounded-full",disabled:""},ge=t("i",{class:"fas fa-file-export"},null,-1),be=t("div",{class:"divider mt-2"},null,-1),ve={class:"flex items-center mb-4"},xe={for:"perPageSelect",class:"mr-2"},we=["value"],Pe={class:"overflow-x-auto"},ke={key:0,class:"table w-full"},Me={class:"flex justify-center"},Ce={key:0},Te={key:1},Ee=t("span",{class:"loading loading-bars loading-sm"},null,-1),Be=[Ee],Ie={class:"flex justify-end"},je=["data-tip"],Ve=["onClick"],De=t("i",{class:"fas fa-pencil-alt"},null,-1),Se=[De],Ae=["data-tip"],Fe=["onClick"],Re=t("i",{class:"far fa-trash-alt"},null,-1),Ue=[Re],ze={key:1},Ne=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),We=t("div",{class:"divider my-1"},null,-1),He=[Ne,We],Oe={class:"join ecwp_pagination mt-6 pt-4"},Xe=["onClick"];function qe(s,e,l,m,n,o){const x=y("payment-edit-modal"),c=y("remove-modal"),u=y("Card");return i(),d("div",ce,[n.toast.visible?(i(),d("div",{key:0,class:h(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:h(["alert",n.toast.type,"text-white"])},[t("span",null,r(n.toast.message),1)],2)],2)):f("",!0),w(x,{loading:n.loadingModal,"show-modal":n.editPaymentModal,"modal-id":"modal_payment_edit","modal-title":o.translations.edit_payment,payment:n.selectedPayment,methods:n.paymentMethods,onClose:e[0]||(e[0]=a=>n.editPaymentModal=!1),onPaymentEdited:o.fetchPayments},null,8,["loading","show-modal","modal-title","payment","methods","onPaymentEdited"]),w(c,{"show-modal":n.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[1]||(e[1]=a=>this.deletePayment(n.selectedPayment)),onCancel:e[2]||(e[2]=a=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),w(u,{topMargin:"mt-8"},{default:V(()=>[t("div",me,[t("h2",ue,r(o.translations.payments),1),n.settings.easy_compta_export_addon_active==1?(i(),d("div",he,[t("a",pe,[P(r(o.translations.export)+" ",1),_e])])):(i(),d("div",{key:1,class:"tooltip tooltip-left tooltip-warning","data-tip":o.translations.active_export_addon},[t("button",fe,[P(r(o.translations.export)+" ",1),ge])],8,ye))]),be,t("div",ve,[t("label",xe,r(o.translations.display_per_page),1),g(t("select",{id:"perPageSelect","onUpdate:modelValue":e[3]||(e[3]=a=>n.perPage=a),onChange:e[4]||(e[4]=(...a)=>o.perPageChanged&&o.perPageChanged(...a))},[(i(!0),d(p,null,_(n.perPageOptions,a=>(i(),d("option",{key:a,value:a},r(a),9,we))),128))],544),[[T,n.perPage]])]),t("div",Pe,[n.loading?(i(),d("div",ze,[(i(!0),d(p,null,_(n.skeletonRows,a=>(i(),d("div",{key:a,class:"flex flex-col gap-4 w-full"},He))),128))])):(i(),d("table",ke,[t("thead",null,[t("tr",null,[t("th",null,r(o.translations.invoice_number),1),t("th",null,r(o.translations.client),1),t("th",null,r(o.translations.payment_date),1),t("th",null,r(o.translations.amount),1),t("th",null,r(o.translations.payment_method),1),t("th",null,r(o.translations.note),1),t("th",Me,r(o.translations.actions),1)])]),t("tbody",null,[(i(!0),d(p,null,_(n.payments,a=>(i(),d("tr",{key:a.id},[t("td",null,r(a.invoice_number),1),t("td",null,r(a.company_name),1),t("td",null,r(a.payment_date),1),t("td",null,[n.loadingPrice?(i(),d("div",Te,Be)):(i(),d("div",Ce,[t("span",null,r(o.formatAmount(a.amount,n.default_currency_symbol)),1)]))]),t("td",null,r(a.method_name),1),t("td",null,r(a.notes),1),t("td",Ie,[t("span",{class:"lg:tooltip","data-tip":o.translations.edit},[t("button",{class:"btn btn-circle mx-1",onClick:k=>o.editPayment(a.id)},Se,8,Ve)],8,je),t("span",{class:"lg:tooltip","data-tip":o.translations.delete},[t("button",{onClick:k=>o.confirmDeletePayment(a.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Ue,8,Fe)],8,Ae)])]))),128))])])),t("div",Oe,[(i(!0),d(p,null,_(n.paginationButtons,a=>(i(),d("button",{key:a,class:h(["join-item btn",{"btn-disabled":a==="..."||a===n.currentPage}]),onClick:k=>o.goToPage(a)},r(a),11,Xe))),128))])])]),_:1})])}var Ge=C(re,[["render",qe]]);const M=b;(function(s,e){const l=b,m=s();for(;[];)try{if(parseInt(l(464))/1*(parseInt(l(466))/2)+parseInt(l(463))/3+parseInt(l(471))/4*(parseInt(l(462))/5)+parseInt(l(472))/6*(-parseInt(l(460))/7)+parseInt(l(469))/8+-parseInt(l(467))/9*(parseInt(l(459))/10)+-parseInt(l(470))/11*(parseInt(l(468))/12)===e)break;m.push(m.shift())}catch{m.push(m.shift())}})(v,989414);function b(s,e){const l=v();return b=function(m,n){return m=m-459,l[m]},b(s,e)}function v(){const s=["4tatMmE","852CFKKST","1688310jayquf","71939Khazuw","#my-easy-compta-payments-app","1924110MBZdHm","4745604dgPUQL","68759oCdGMA","mount","26NCkvWt","27VGnMEH","12omwzmG","3180504jpmvzd","3331669aIEpHE"];return v=function(){return s},v()}const Ke=D({render:()=>S(Ge)});Ke[M(465)](M(461));
  • my-easy-compta/trunk/assets/dist/quotes.min.js

    r3167980 r3169216  
    1 import{_ as c,d as u,o as i,H as _,f,h as m}from"./plugin-vue_export-helper.min.js";import{r as d}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const I={name:"Quotes",mounted(){this.$router.push("/quotes")}};function h(r,n,t,e,x,a){const p=u("router-view");return i(),_(p)}var b=c(I,[["render",h]]);const l=s;function o(){const r=["73310qqWBql","5860332EZLQoQ","928081pNBPtI","6204HNNCey","415RHLORY","8LlupuK","662908jGWAri","3796974UxYMov","3KOAiwd","721820xOvNmB","957xynehN","use"];return o=function(){return r},o()}(function(r,n){const t=s,e=r();for(;[];)try{if(-parseInt(t(314))/1+parseInt(t(317))/2*(parseInt(t(316))/3)+parseInt(t(311))/4*(-parseInt(t(312))/5)+parseInt(t(315))/6+parseInt(t(310))/7+parseInt(t(313))/8*(parseInt(t(309))/9)+parseInt(t(320))/10*(-parseInt(t(318))/11)===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(o,348032);function s(r,n){const t=o();return s=function(e,x){return e=e-309,t[e]},s(r,n)}const v=f({render:()=>m(b)});v[l(319)](d).mount("#my-easy-compta-quotes-app");
     1import{_ as u,d as _,o as i,H as f,f as m,h}from"./plugin-vue_export-helper.min.js";import{r as I}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const d={name:"Quotes",mounted(){this.$router.push("/quotes")}};function l(r,n,t,e,x,p){const c=_("router-view");return i(),f(c)}var $=u(d,[["render",l]]);const a=o;(function(r,n){const t=o,e=r();for(;[];)try{if(parseInt(t(152))/1+parseInt(t(154))/2+parseInt(t(158))/3*(parseInt(t(151))/4)+parseInt(t(148))/5+parseInt(t(155))/6*(-parseInt(t(159))/7)+-parseInt(t(149))/8+-parseInt(t(153))/9===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(s,160378);const v=m({render:()=>h($)});function o(r,n){const t=s();return o=function(e,x){return e=e-148,t[e]},o(r,n)}v[a(157)](I)[a(156)](a(150));function s(){const r=["mount","use","640527oxNIjp","63476HdDYOO","749385sJHulG","1972432YtYQWT","#my-easy-compta-quotes-app","4QtNiHA","198669BUWyeq","563319JEJMZX","395288TbxnWZ","192QhDuLL"];return s=function(){return r},s()}
  • my-easy-compta/trunk/assets/dist/settings.min.js

    r3167980 r3169216  
    1 import{_ as $,d as I,o as c,c as d,n as v,a as e,t as l,g as b,e as x,p as z,m as g,w as k,i as p,v as f,G as C,F as T,r as S,j as V,y as tt,T as et,Z as st,J as nt,f as it,h as ot}from"./plugin-vue_export-helper.min.js";import{C as at,R as lt}from"./RemoveAlert.min.js";import{v as rt}from"./vue3-editor.common.min.js";const ct={name:"Settings",components:{Card:at,VueEditor:rt.exports.VueEditor,RemoveModal:lt},data(){return{loading:!1,selectedTab:1,form:{company_name:"",company_address:"",postal_code:"",city:"",country:"",company_email:"",company_phone:"",mobile_phone:"",fax:"",logo_mentions_active:"",logo_url:"",logo_path:"",default_currency:"",currency_position:"",vat_active:"",default_vat:"",date_format:"",logo_width:"",logo_mentions:"",invoice_color:"",invoice_prefix:"",show_phone:"",show_email:"",show_siren:"",show_tax_number:"",show_watermark:"",show_watermark_only_paid:"",invoice_footer:"",invoice_terms:"",credit_color:"",credit_prefix:"",credit_footer:"",credit_terms:"",quote_color:"",quote_prefix:"",quote_footer:"",quote_terms:"",easy_compta_planning_addon_active:"",easy_compta_email_addon_active:"",easy_compta_payment_addon_active:"",easy_compta_signature_addon_active:"",easy_compta_stats_addon_active:"",easy_compta_qrcode_addon_active:"",easy_compta_stripe_secret_api:"",email_quote_subject:"",email_invoice_subject:"",remind_invoice_subject:"",remind_invoice_content:"",email_quote_content:"",email_invoice_content:"",email_create_account_subject:"",email_create_account_content:"",easycompta_siret_token_api:""},articles:[],categories:[],currencies:[],vats:[],expenses:[],planning:[],payments:[],logoPreviewUrl:"",previewWidth:"",showArticleModal:!1,showCurrencyModal:!1,showVATModal:!1,showPaymentModal:!1,showExpenseModal:!1,showPlanningModal:!1,currencyForm:{id:null,name:"",symbol:""},articleForm:{id:null,ref:"",name:"",description:"",unit_price:""},vatForm:{id:null,description:"",rate:""},paymentForm:{id:null,method_name:""},expenseForm:{id:null,name:""},planningForm:{id:null,name:"",background:"",color:""},showRemoveModal:!1,deleteType:null,selectedId:null,editingArticle:!1,editingCurrency:!1,editingVAT:!1,editingExpense:!1,editingPayment:!1,editingPlanning:!1,activeTabEmail:"tab1",activeTabUsers:"user1",license_key:"",loadingLicense:!1,licenseData:null,installed_versions:{},updatesAvailable:{},errorMessage:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"],["html"]]}},methods:{setActiveTab(s){this.activeTabEmail=s},setActiveTabUsers(s){this.activeTabUsers=s},selectTab(s){this.selectedTab=s,window.location.hash=`tab${s}`},checkHash(){const s=window.location.hash;if(s){const t=parseInt(s.replace("#tab",""));isNaN(t)||(this.selectedTab=t)}},tabClass(s){return this.selectedTab===s?"tab tab-active":"tab"},async fetchSettings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,s.ok){const t=await s.json();this.form={...this.form,...t},this.logoPreviewUrl=t.logo_url||"",this.form.easy_compta_planning_addon_active==1&&this.fetchPlanningCat()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async handleSubmit(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/save",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.form)});if(this.loading=!1,s.ok){const t=await s.json();this.showToast(t,"alert-success")}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async fetchArticles(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/articles",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.articles=t.articles,this.categories=t.categories}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchCurrencies(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/currencies",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.currencies=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchVATs(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/vats",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.vats=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPaymentsMethods(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/payments-methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.payments=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchExpensesCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/expenses-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.expenses=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPlanningCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/planning-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.planning=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async handleLogoUpload(s){const t=s.target.files[0];if(t){const o=new FormData;o.append("logo",t);try{const r=await fetch("/wp-json/my-easy-compta/v1/settings/upload-logo",{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce},body:o});if(r.ok){const i=await r.json();this.form.logo_url=i.url,this.form.logo_path=i.path,this.logoPreviewUrl=i.url,this.showToast("Logo uploaded successfully","alert-success")}else{const i=await r.json();this.showToast(i.message,"alert-error")}}catch(r){this.showToast(r.message,"alert-error")}}},async addArticle(){this.articleForm={id:null,ref:"",name:"",description:"",price:""},this.editingArticle=!1,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async addCurrency(){this.currencyForm={id:null,name:"",symbol:""},this.editingCurrency=!1,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteArticle(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/articles/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.articles=this.articles.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async deleteCategory(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/category/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.categories=this.categories.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async editArticle(s){const t=this.articles.find(o=>o.id===s);this.articleForm={...t},this.editingArticle=!0,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async editCurrency(s){const t=this.currencies.find(o=>o.id===s);this.currencyForm={...t},this.editingCurrency=!0,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteCurrency(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/currencies/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.currencies=this.currencies.filter(o=>o.id!==s),this.showToast("Currency deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveArticle(){const s=this.editingArticle?"PUT":"POST",t=this.editingArticle?`/wp-json/my-easy-compta/v1/settings/articles/${this.articleForm.id}`:"/wp-json/my-easy-compta/v1/settings/articles";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.articleForm)});if(o.ok){const r=await o.json();if(this.editingArticle){const i=this.articles.findIndex(n=>n.id===r.id);this.articles[i]=r}else this.articles.push(r);this.showToast(`Article ${this.editingArticle?"updated":"added"} successfully`,"alert-success"),this.closeArticleModal(),this.fetchArticles()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async saveCurrency(){const s=this.editingCurrency?"PUT":"POST",t=this.editingCurrency?`/wp-json/my-easy-compta/v1/settings/currencies/${this.currencyForm.id}`:"/wp-json/my-easy-compta/v1/settings/currencies";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.currencyForm)});if(o.ok){const r=await o.json();if(this.editingCurrency){const i=this.currencies.findIndex(n=>n.id===r.id);this.currencies[i]=r}else this.currencies.push(r);this.showToast(`Currency ${this.editingCurrency?"updated":"added"} successfully`,"alert-success"),this.closeCurrencyModal(),this.fetchCurrencies()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addVAT(){this.vatForm={id:null,description:"",rate:""},this.editingVAT=!1,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async editVAT(s){const t=this.vats.find(o=>o.id===s);this.vatForm={...t},this.editingVAT=!0,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async deleteVAT(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/vats/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.vats=this.vats.filter(o=>o.id!==s),this.showToast("VAT deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveVAT(){const s=this.editingVAT?"PUT":"POST",t=this.editingVAT?`/wp-json/my-easy-compta/v1/settings/vats/${this.vatForm.id}`:"/wp-json/my-easy-compta/v1/settings/vats";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.vatForm)});if(o.ok){const r=await o.json();if(this.editingVAT){const i=this.vats.findIndex(n=>n.id===r.id);this.vats[i]=r}else this.vats.push(r);this.showToast(`VAT ${this.editingVAT?"updated":"added"} successfully`,"alert-success"),this.closeVATModal(),this.fetchVATs()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPayment(){this.paymentForm={id:null,method_name:""},this.editingPayment=!1,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async editPayment(s){const t=this.payments.find(o=>o.id===s);this.paymentForm={...t},this.editingPayment=!0,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async deletePayment(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/payments-methods/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.payments=this.payments.filter(o=>o.id!==s),this.showToast("Payment method deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePayment(){const s=this.editingPayment?"PUT":"POST",t=this.editingPayment?`/wp-json/my-easy-compta/v1/settings/payments-methods/${this.paymentForm.id}`:"/wp-json/my-easy-compta/v1/settings/payments-methods";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.paymentForm)});if(o.ok){const r=await o.json();if(this.editingPayment){const i=this.payments.findIndex(n=>n.id===r.id);this.payments[i]=r}else this.payments.push(r);this.showToast(`Payment method ${this.editingPayment?"updated":"added"} successfully`,"alert-success"),this.closePaymentModal(),this.fetchPaymentsMethods()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addExpCat(){this.expenseForm={id:null,name:""},this.editingExpense=!1,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async editExpCat(s){const t=this.expenses.find(o=>o.id===s);this.expenseForm={...t},this.editingExpense=!0,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async deleteExpCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/expenses-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.expenses=this.expenses.filter(o=>o.id!==s),this.showToast("Expense category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveExpCat(){const s=this.editingExpense?"PUT":"POST",t=this.editingExpense?`/wp-json/my-easy-compta/v1/settings/expenses-categories/${this.expenseForm.id}`:"/wp-json/my-easy-compta/v1/settings/expenses-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.expenseForm)});if(o.ok){const r=await o.json();if(this.editingExpense){const i=this.expenses.findIndex(n=>n.id===r.id);this.expenses[i]=r}else this.expenses.push(r);this.showToast(`Expense category ${this.editingExpense?"updated":"added"} successfully`,"alert-success"),this.closeExpenseModal(),this.fetchExpensesCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPlanningCat(){this.planningForm={id:null,name:""},this.editingPlanning=!1,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async editPlanningCat(s){const t=this.planning.find(o=>o.id===s);this.planningForm={...t},this.editingPlanning=!0,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async deletePlanningCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/planning-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.planning=this.planning.filter(o=>o.id!==s),this.showToast("Planning category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePlanningCat(){this.loading=!0;const s=this.editingPlanning?"PUT":"POST",t=this.editingPlanning?`/wp-json/my-easy-compta/v1/settings/planning-categories/${this.planningForm.id}`:"/wp-json/my-easy-compta/v1/settings/planning-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.planningForm)});if(o.ok){const r=await o.json();if(this.editingPlanning){const i=this.planning.findIndex(n=>n.id===r.id);this.planning[i]=r,this.loading=!1}else this.planning.push(r),this.loading=!1;this.showToast(`Planning category ${this.editingPlanning?"updated":"added"} successfully`,"alert-success"),this.closePlanningModal(),this.fetchPlanningCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},closeCurrencyModal(){this.showCurrencyModal=!1},closeArticleModal(){this.showArticleModal=!1},closeVATModal(){this.showVATModal=!1},closePaymentModal(){this.showPaymentModal=!1},closeExpenseModal(){this.showExpenseModal=!1},closePlanningModal(){this.showPlanningModal=!1},updatePreviewWidth(){this.previewWidth=this.form.logo_width+"px"},updateVatActive(s){this.form.vat_active=s.target.checked?1:0},updateLogoMentionsActive(s){this.form.logo_mentions_active=s.target.checked?1:0},updateEmailLogsActive(s){this.form.email_log_active=s.target.checked?1:0},updateFormField(s,t){this.form[t]=s.target.checked?1:0},showToast(s,t){this.toast.message=s,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},handleDeletion(s,t){const o=this.getDeletionFunction(s);o?o(t):this.showToast("error","alert-error")},delete_item(s,t){this.deleteType=s,this.selectedId=t,modal_remove.showModal(),this.showRemoveModal=!0},getDeletionFunction(s){switch(s){case"licence":return this.confirmLicense;case"vat":return this.deleteVAT;case"currency":return this.deleteCurrency;case"expense":return this.deleteExpCat;case"payment":return this.deletePayment;case"planning":return this.deletePlanningCat;case"article":return this.deleteArticle;case"category_article":return this.deleteCategory;default:return null}},async checkLicense(){this.loading=!0,this.loadingLicense=!0,this.errorMessage="",this.licenseData=null;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/validate-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key})})).json();t.valid?(this.licenseData=t,await this.storeLicense(t),location.reload()):this.errorMessage=t.message}catch{this.errorMessage="An error occurred while validating the license."}finally{this.loadingLicense=!1}},async refresh_licence(){this.loading=!0;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/refresh-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();t.valid?location.reload():this.errorMessage=t.message}catch{this.errorMessage="An error occurred while refreshing the license."}},async storeLicense(s){try{await fetch("/wp-json/my-easy-compta/v1/license/store-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key,license_data:s})})}catch{this.errorMessage="An error occurred while storing the license.",this.loading=!1}},async loadLicenseDetails(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/check-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();t.valid&&(this.licenseData=t.license_data,this.installed_versions=t.installed_versions,this.license_key="****-****-****-****-****"+this.license_key.substr(this.license_key.length-4),this.loading=!1)}else console.error("Failed to load license details"),this.loading=!1}catch(s){console.error("Error loading license details",s),this.loading=!1}},async confirmLicense(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/delete-license",{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.showToast(t.message,"alert-success"),this.licenseData="",this.license_key="",location.reload()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async checkUpdatePlugin(s,t){try{const r=await(await fetch("/wp-json/my-easy-compta/v1/license/check-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s,current_version:t})})).json();r.success?r.update_available?(this.showToast(this.translations.update_available+" "+r.new_version,"alert-success"),this.updatesAvailable[s]=r.update_available):this.showToast(this.translations.no_update_available,"alert-error"):this.showToast(this.translations.failed_update_available,"alert-error")}catch(o){console.error("Error checking for plugin update:",o),this.showToast(this.translations.failed_update_available,"alert-error")}},async installUpdatePlugin(s){try{const o=await(await fetch("/wp-json/my-easy-compta/v1/license/download-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s})})).json();if(o.success){this.showToast(this.translations.success,"alert-success");const r=document.createElement("a");r.href=o.download_url,r.setAttribute("download",""),document.body.appendChild(r),r.click(),document.body.removeChild(r)}else this.showToast(this.translations.error,"alert-error")}catch(t){console.error("Error checking for plugin update:",t),this.showToast(this.translations.error,"alert-error")}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},beforeUnmount(){window.removeEventListener("hashchange",this.checkHash)},mounted(){this.checkHash(),window.addEventListener("hashchange",this.checkHash),this.fetchSettings(),this.fetchArticles(),this.fetchCurrencies(),this.fetchVATs(),this.fetchPaymentsMethods(),this.fetchExpensesCat(),this.loadLicenseDetails()}},dt={class:"pt-2 pr-4"},ut={class:"flex justify-between items-center"},ht={class:"card-title"},pt=e("div",{class:"divider mt-2"},null,-1),mt={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"},ft={class:"tabs tabs-vertical tabs-boxed col-span-1"},bt=e("i",{class:"fas fa-home mr-2"},null,-1),_t=e("i",{class:"fas fa-tools mr-2"},null,-1),gt=e("i",{class:"fas fa-newspaper mr-2"},null,-1),yt=e("i",{class:"fas fa-file-invoice-dollar mr-2"},null,-1),vt=e("i",{class:"fas fa-undo mr-2"},null,-1),wt=e("i",{class:"far fa-question-circle mr-2"},null,-1),xt=e("i",{class:"fas fa-dollar-sign mr-2"},null,-1),kt=e("i",{class:"fas fa-money-check-alt mr-2"},null,-1),Ct=e("i",{class:"fas fa-shopping-basket mr-2"},null,-1),Tt=e("i",{class:"fas fa-calendar-alt mr-2"},null,-1),Mt=e("i",{class:"far fa-envelope mr-2"},null,-1),At=e("i",{class:"fas fa-user mr-2"},null,-1),St=e("i",{class:"far fa-credit-card mr-2"},null,-1),Pt=e("i",{class:"far fa-chart-bar mr-2"},null,-1),Et=e("i",{class:"fas fa-qrcode mr-2"},null,-1),jt=e("i",{class:"far fa-id-badge mr-2"},null,-1),Vt={class:"col-span-3 p-4 bg-base-300 rounded-lg shadow-md content-tabs"},It={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Ft=e("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Rt=[Ft],Ut={key:1},Dt={class:"text-xl font-semibold mb-4"},Ht={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Yt={class:"ecwp-group form-control"},Nt={class:"ecwp-label label",for:"company-code"},qt={class:"ecwp-group form-control"},Lt={class:"ecwp-label label",for:"tax-number"},Ot={class:"ecwp-group form-control"},Xt={class:"ecwp-label label",for:"company-name"},Wt={class:"ecwp-group form-control"},Bt={class:"ecwp-label label",for:"company-address"},zt={class:"ecwp-group form-control"},Gt={class:"ecwp-label label",for:"postal-code"},Jt={class:"ecwp-group form-control"},Zt={class:"ecwp-label label",for:"city"},Qt={class:"ecwp-group form-control"},Kt={class:"ecwp-label label",for:"country"},$t={class:"ecwp-group form-control"},te={class:"ecwp-label label",for:"company-email"},ee={class:"ecwp-group form-control"},se={class:"ecwp-label label",for:"company-phone"},ne={class:"ecwp-group form-control"},ie={class:"ecwp-label label",for:"mobile-phone"},oe={class:"ecwp-group form-control"},ae={class:"ecwp-label label",for:"fax"},le=e("div",{class:"divider my-4"},null,-1),re={key:0},ce={class:"grid grid-cols-2 gap-4"},de={class:"ecwp-group form-control indicator"},ue={class:"ecwp-label label",for:"company-code"},he=e("span",{class:"indicator-item badge mt-5 border-blue-700"},[e("a",{href:"https://api.gouv.fr/les-api/sirene_v3",target:"_blank"},"?")],-1),pe={class:"mt-6 flex justify-end"},me={type:"submit",class:"btn btn-primary rounded-full"},fe=e("i",{class:"far fa-save"},null,-1),be={key:2},_e={class:"text-xl font-semibold mb-4"},ge={class:"form-control mt-4 mb-1"},ye={class:"cursor-pointer"},ve={class:"label-text mr-2 font-bold"},we=["checked"],xe={key:0,class:"ecwp-group form-control"},ke={class:"ecwp-label label",for:"logo-mentions"},Ce={class:"ecwp-group form-control"},Te={class:"label"},Me={class:"ecwp-file"},Ae={for:"file_logo"},Se=e("i",{class:"fas fa-cloud-upload-alt mr-2"},null,-1),Pe={key:0,class:"max-w-md"},Ee={class:"py-2 font-bold"},je={key:0},Ve=["src"],Ie={class:"ecwp-group form-control"},Fe={class:"ecwp-label label"},Re=["value"],Ue={class:"ecwp-group form-control"},De={class:"ecwp-label label"},He={value:"before"},Ye={value:"after"},Ne={class:"form-control mt-4 mb-1"},qe={class:"cursor-pointer"},Le={class:"label-text mr-2 font-bold"},Oe=["checked"],Xe={key:1,class:"ecwp-group form-control"},We={class:"ecwp-label label"},Be=e("option",{value:"0"},null,-1),ze=["value"],Ge={class:"ecwp-group form-control mt-2"},Je={class:"ecwp-label label"},Ze=e("option",{value:"DD-MM-YYYY",selected:"selected"}," DD-MM-YYYY ",-1),Qe=e("option",{value:"MM-DD-YYYY"},"MM-DD-YYYY",-1),Ke=e("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD",-1),$e=e("option",{value:"YYYY/MM/DD"},"YYYY/MM/DD",-1),ts=e("option",{value:"DD/MM/YYYY"},"DD/MM/YYYY",-1),es=e("option",{value:"MM/DD/YYYY"},"MM/DD/YYYY",-1),ss=e("option",{value:"YYYY.MM.DD"},"YYYY.MM.DD",-1),ns=e("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY",-1),is=e("option",{value:"MM.DD.YYYY"},"MM.DD.YYYY",-1),os=[Ze,Qe,Ke,$e,ts,es,ss,ns,is],as={class:"mt-6 flex justify-end"},ls={type:"submit",class:"btn btn-primary rounded-full"},rs=e("i",{class:"far fa-save"},null,-1),cs={key:3},ds={key:0,id:"modal_article",class:"modal"},us={class:"modal-box"},hs={class:"ecwp-group form-control"},ps={class:"ecwp-label label",for:"name_ref"},ms={class:"ecwp-group form-control"},fs={class:"ecwp-label label",for:"name_article"},bs={class:"ecwp-group form-control"},_s={class:"ecwp-label label",for:"desc_article"},gs={class:"ecwp-group form-control"},ys={class:"ecwp-label label",for:"price_article"},vs={class:"form-group mt-4 flex justify-end"},ws={type:"submit",class:"btn btn-primary rounded-full mx-2"},xs={class:"flex justify-between items-center mb-4"},ks={class:"text-lg font-semibold"},Cs=e("i",{class:"fas fa-plus mr-2"},null,-1),Ts={class:"table-container"},Ms={class:"table w-full"},As=["onClick"],Ss=e("i",{class:"fas fa-edit"},null,-1),Ps=[Ss],Es=["onClick"],js=e("i",{class:"fas fa-trash"},null,-1),Vs=[js],Is=e("div",{class:"divider mt-2 mb-4"},null,-1),Fs={class:"text-xl font-semibold mb-4"},Rs={class:"table-container"},Us={class:"table w-full"},Ds=["onClick"],Hs=e("i",{class:"fas fa-trash"},null,-1),Ys=[Hs],Ns={key:4},qs={class:"text-xl font-semibold mb-4"},Ls={class:"grid grid-cols-2 gap-4"},Os={class:"ecwp-group form-control"},Xs={class:"ecwp-label label",for:"invoice-color"},Ws={class:"ecwp-group form-control"},Bs={class:"ecwp-label label",for:"invoice-prefix"},zs=e("div",{class:"divider my-4"},null,-1),Gs={class:"grid grid-cols-2 gap-4"},Js={class:"form-control mt-4 mb-1"},Zs={class:"cursor-pointer"},Qs=["checked"],Ks={class:"label-text mr-2 font-bold"},$s={class:"form-control mt-4 mb-1"},tn={class:"cursor-pointer"},en=["checked"],sn={class:"label-text mr-2 font-bold"},nn={class:"form-control mt-4 mb-1"},on={class:"cursor-pointer"},an=["checked"],ln={class:"label-text mr-2 font-bold"},rn={class:"form-control mt-4 mb-1"},cn={class:"cursor-pointer"},dn=["checked"],un={class:"label-text mr-2 font-bold"},hn={class:"form-control mt-4 mb-1"},pn={class:"cursor-pointer"},mn=["checked"],fn={class:"label-text mr-2 font-bold"},bn={key:0,class:"form-control mt-4 mb-1"},_n={class:"cursor-pointer"},gn=["checked"],yn={class:"label-text mr-2 font-bold"},vn=e("div",{class:"divider my-4"},null,-1),wn={class:"grid grid-cols-2 gap-4"},xn={class:"ecwp-group form-control"},kn={class:"ecwp-label label",for:"conditions-payment"},Cn={class:"ecwp-group form-control"},Tn={class:"ecwp-label label",for:"mode-payment"},Mn={class:"grid grid-cols-1 gap-4"},An={class:"form-control"},Sn={class:"ecwp-label label",for:"invoice-prefix"},Pn={class:"grid grid-cols-2 gap-4"},En={class:"ecwp-group form-control"},jn={class:"ecwp-label label",for:"invoice-iban"},Vn={class:"ecwp-group form-control"},In={class:"ecwp-label label",for:"invoice-bic"},Fn={class:"form-control"},Rn={class:"ecwp-label label",for:"invoice-prefix"},Un={class:"mt-6 flex justify-end"},Dn={type:"submit",class:"btn btn-primary rounded-full"},Hn=e("i",{class:"far fa-save"},null,-1),Yn={key:5},Nn={class:"text-xl font-semibold mb-4"},qn={class:"grid grid-cols-2 gap-4"},Ln={class:"ecwp-group form-control"},On={class:"ecwp-label label",for:"credit-color"},Xn={class:"ecwp-group form-control"},Wn={class:"ecwp-label label",for:"credit-prefix"},Bn={class:"grid grid-cols-1 gap-4"},zn={class:"form-control"},Gn={class:"ecwp-label label",for:"credit-prefix"},Jn={class:"form-control"},Zn={class:"ecwp-label label",for:"credit-prefix"},Qn={class:"mt-6 flex justify-end"},Kn={type:"submit",class:"btn btn-primary rounded-full"},$n=e("i",{class:"far fa-save"},null,-1),ti={key:6},ei={class:"text-xl font-semibold mb-4"},si={class:"grid grid-cols-2 gap-4"},ni={class:"ecwp-group form-control"},ii={class:"ecwp-label label",for:"quote-color"},oi={class:"ecwp-group form-control"},ai={class:"ecwp-label label",for:"quote-prefix"},li={class:"grid grid-cols-1 gap-4"},ri={class:"form-control"},ci={class:"ecwp-label label",for:"quote-prefix"},di={class:"form-control"},ui={class:"ecwp-label label",for:"quote-prefix"},hi={class:"mt-6 flex justify-end"},pi={type:"submit",class:"btn btn-primary rounded-full"},mi=e("i",{class:"far fa-save"},null,-1),fi={key:7},bi={class:"text-xl font-semibold mb-4"},_i={key:0,id:"modal_currency",class:"modal"},gi={class:"modal-box"},yi={class:"ecwp-group form-control"},vi={class:"ecwp-label label",for:"name_currency"},wi={class:"ecwp-group form-control"},xi={class:"ecwp-label label",for:"symbol_currency"},ki={class:"ecwp-group form-control"},Ci={class:"ecwp-label label",for:"code_currency"},Ti={class:"form-group mt-4 flex justify-end"},Mi={type:"submit",class:"btn btn-primary rounded-full mx-2"},Ai={class:"mb-8"},Si={class:"flex justify-between items-center mb-4"},Pi={class:"text-lg font-semibold"},Ei=e("i",{class:"fas fa-plus mr-2"},null,-1),ji={class:"table-container"},Vi={class:"table w-full"},Ii=["onClick"],Fi=e("i",{class:"fas fa-edit"},null,-1),Ri=[Fi],Ui=["onClick"],Di=e("i",{class:"fas fa-trash"},null,-1),Hi=[Di],Yi={key:0,id:"modal_vat",class:"modal"},Ni={class:"modal-box"},qi={class:"ecwp-group form-control"},Li={class:"ecwp-label label",for:"vat-description"},Oi={class:"ecwp-group form-control"},Xi={class:"ecwp-label label",for:"vat-rate"},Wi={class:"form-group mt-4 flex justify-end"},Bi={type:"submit",class:"btn btn-primary rounded-full mx-2"},zi={class:"flex justify-between items-center mb-4"},Gi={class:"text-lg font-semibold"},Ji=e("i",{class:"fas fa-plus mr-2"},null,-1),Zi={class:"table-container"},Qi={class:"table w-full"},Ki=["onClick"],$i=e("i",{class:"fas fa-edit"},null,-1),to=[$i],eo=["onClick"],so=e("i",{class:"fas fa-trash"},null,-1),no=[so],io={key:8},oo={class:"text-xl font-semibold mb-4"},ao={key:0,id:"modal_payments",class:"modal"},lo={class:"modal-box"},ro={class:"ecwp-group form-control"},co={class:"ecwp-label label",for:"name_payment"},uo={class:"form-group mt-4 flex justify-end"},ho={type:"submit",class:"btn btn-primary rounded-full mx-2"},po={class:"mb-8"},mo={class:"flex justify-between items-center mb-4"},fo={class:"text-lg font-semibold"},bo=e("i",{class:"fas fa-plus mr-2"},null,-1),_o={class:"table-container"},go={class:"table w-full"},yo=["onClick"],vo=e("i",{class:"fas fa-edit"},null,-1),wo=[vo],xo=["onClick"],ko=e("i",{class:"fas fa-trash"},null,-1),Co=[ko],To={key:9},Mo={class:"text-xl font-semibold mb-4"},Ao={key:0,id:"modal_expenses",class:"modal"},So={class:"modal-box"},Po={class:"ecwp-group form-control"},Eo={class:"ecwp-label label",for:"name_expense"},jo={class:"form-group mt-4 flex justify-end"},Vo={type:"submit",class:"btn btn-primary rounded-full mx-2"},Io={class:"mb-8"},Fo={class:"flex justify-between items-center mb-4"},Ro={class:"text-lg font-semibold"},Uo=e("i",{class:"fas fa-plus mr-2"},null,-1),Do={class:"table-container"},Ho={class:"table w-full"},Yo=["onClick"],No=e("i",{class:"fas fa-edit"},null,-1),qo=[No],Lo=["onClick"],Oo=e("i",{class:"fas fa-trash"},null,-1),Xo=[Oo],Wo={key:10},Bo={class:"text-xl font-semibold mb-4"},zo={key:0,id:"modal_planning",class:"modal"},Go={class:"modal-box"},Jo={class:"ecwp-group form-control"},Zo={class:"ecwp-label label",for:"name_planning"},Qo={class:"ecwp-group form-control"},Ko={class:"ecwp-label label",for:"background_planning"},$o={class:"ecwp-group form-control"},ta={class:"ecwp-label label",for:"color_planning"},ea={class:"form-group mt-4 flex justify-end"},sa=["disabled"],na={key:0,class:"loading loading-spinner loading-sm"},ia={class:"mb-8"},oa={class:"flex justify-between items-center mb-4"},aa={class:"text-lg font-semibold"},la=e("i",{class:"fas fa-plus mr-2"},null,-1),ra={class:"table-container"},ca={class:"table w-full"},da=["onClick"],ua=e("i",{class:"fas fa-edit"},null,-1),ha=[ua],pa=["onClick"],ma=e("i",{class:"fas fa-trash"},null,-1),fa=[ma],ba={key:11},_a={class:"text-xl font-semibold mb-4"},ga={class:"form-control mt-4 mb-4"},ya={class:"cursor-pointer"},va={class:"label-text mr-2 font-bold"},wa=["checked"],xa=e("div",{class:"divider mt-2 mb-4"},null,-1),ka={role:"tablist",class:"tabs tabs-boxed"},Ca={key:0,class:"p-4"},Ta={class:"grid grid-cols-1 gap-4"},Ma={class:"ecwp-group form-control"},Aa={class:"ecwp-label label",for:"email_invoice_subject"},Sa={class:"form-control"},Pa={class:"ecwp-label label"},Ea=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),ja={key:1,class:"p-4"},Va={class:"grid grid-cols-1 gap-4"},Ia={class:"ecwp-group form-control"},Fa={class:"ecwp-label label",for:"email_quote_subject"},Ra={class:"form-control"},Ua={class:"ecwp-label label"},Da=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")]),e("pre",null,[e("b",null,"{CREATED_DATE}")]),e("pre",null,[e("b",null,"{DUE_DATE}")])],-1),Ha={key:2,class:"p-4"},Ya={class:"grid grid-cols-1 gap-4"},Na={class:"ecwp-group form-control"},qa={class:"ecwp-label label",for:"remind_invoice_subject"},La={class:"form-control"},Oa={class:"ecwp-label label"},Xa=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),Wa={key:3,class:"p-4"},Ba={role:"alert",class:"alert shadow"},za=e("i",{class:"fas fa-exclamation-circle"},null,-1),Ga={class:"text-xl text-center my-4"},Ja={class:"mt-6 flex justify-end"},Za={type:"submit",class:"btn btn-primary rounded-full"},Qa=e("i",{class:"far fa-save"},null,-1),Ka={key:12},$a={class:"text-xl font-semibold mb-4"},tl={role:"tablist",class:"tabs tabs-boxed"},el={key:0,class:"p-4"},sl={class:"grid grid-cols-1 gap-4"},nl={class:"ecwp-group form-control"},il={class:"ecwp-label label",for:"email_create_account_subject"},ol={class:"form-control"},al={class:"ecwp-label label"},ll=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{USERNAME}")]),e("pre",null,[e("b",null,"{PASSWORD}")])],-1),rl={class:"mt-6 flex justify-end"},cl={type:"submit",class:"btn btn-primary rounded-full"},dl=e("i",{class:"far fa-save"},null,-1),ul={key:1,class:"p-4"},hl={role:"alert",class:"alert shadow"},pl=e("i",{class:"fas fa-exclamation-circle"},null,-1),ml={class:"text-xl text-center my-4"},fl={key:13},bl={class:"text-xl font-semibold mb-4"},_l={class:"grid grid-cols-1 gap-4"},gl={class:"ecwp-group form-control"},yl={class:"ecwp-label label",for:"stripe-mode"},vl={value:"test"},wl={value:"live"},xl={key:0},kl={class:"ecwp-group form-control"},Cl={class:"ecwp-label label",for:"stripe-public-key-test"},Tl={class:"ecwp-group form-control"},Ml={class:"ecwp-label label",for:"stripe-secret-key-test"},Al={key:1},Sl={class:"ecwp-group form-control"},Pl={class:"ecwp-label label",for:"stripe-public-key-live"},El={class:"ecwp-group form-control"},jl={class:"ecwp-label label",for:"stripe-secret-key-live"},Vl={class:"mt-6 flex justify-end"},Il={type:"submit",class:"btn btn-primary rounded-full"},Fl=e("i",{class:"far fa-save"},null,-1),Rl={key:14},Ul={class:"text-xl font-semibold mb-4"},Dl={class:"grid grid-cols-1 gap-4"},Hl={class:"ecwp-group form-control mt-2"},Yl={class:"ecwp-label label",for:"limit-declaration"},Nl={class:"ecwp-group form-control mt-2"},ql={class:"ecwp-label label",for:"limit-tva"},Ll={class:"mt-6 flex justify-end"},Ol={type:"submit",class:"btn btn-primary rounded-full"},Xl=e("i",{class:"far fa-save"},null,-1),Wl={key:15},Bl={class:"text-xl font-semibold mb-4"},zl={class:"grid grid-cols-1 gap-4"},Gl={class:"ecwp-group form-control mt-2"},Jl={class:"ecwp-label label",for:"stripe-api"},Zl={class:"mt-6 flex justify-end"},Ql={type:"submit",class:"btn btn-primary rounded-full"},Kl=e("i",{class:"far fa-save"},null,-1),$l={key:16},tr={class:"text-xl font-semibold mb-4"},er={class:"grid grid-cols-2 gap-4"},sr={class:"ecwp-group form-group relative join"},nr={class:"ecwp-label label",for:"license-code"},ir=["disabled"],or=["disabled"],ar={key:0,class:"loading loading-spinner loading-sm"},lr={key:1},rr={class:"grid grid-cols-1 gap-4"},cr={key:0,class:"error-message"},dr={key:1,class:"overflow-x-auto my-4"},ur={class:"table table-xs table-pin-rows table-pin-cols"},hr=e("i",{class:"fas fa-sync"},null,-1),pr=[hr],mr=e("i",{class:"far fa-trash-alt"},null,-1),fr=[mr],br={class:"table table-xs table-pin-rows table-pin-cols mt-6"},_r=["onClick"],gr=["onClick"],yr=["onClick"];function vr(s,t,o,r,i,n){const m=I("remove-modal"),u=I("color-input"),_=I("vue-editor"),M=I("Card");return c(),d("div",dt,[i.toast.visible?(c(),d("div",{key:0,class:v(["toast",i.toast.position]),style:{zIndex:9999}},[e("div",{class:v(["alert",i.toast.type,"text-white"])},[e("span",null,l(i.toast.message),1)],2)],2)):b("",!0),x(m,{"show-modal":i.showRemoveModal,title:n.translations.are_you_sure,message:n.translations.no_turning_back,confirmText:n.translations.yes_delete_it,cancelText:n.translations.cancel,onConfirm:t[0]||(t[0]=a=>n.handleDeletion(i.deleteType,i.selectedId)),onCancel:t[1]||(t[1]=a=>i.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),x(M,{topMargin:"mt-8"},{default:z(()=>[e("div",ut,[e("h2",ht,l(n.translations.settings),1)]),pt,e("div",mt,[e("div",ft,[e("a",{class:v([n.tabClass(1),"justify-start w-full"]),onClick:t[2]||(t[2]=a=>n.selectTab(1))},[bt,g(" "+l(n.translations.general_settings),1)],2),e("a",{class:v([n.tabClass(2),"justify-start w-full"]),onClick:t[3]||(t[3]=a=>n.selectTab(2))},[_t,g(" "+l(n.translations.system_settings),1)],2),e("a",{class:v([n.tabClass(3),"justify-start w-full"]),onClick:t[4]||(t[4]=a=>n.selectTab(3))},[gt,g(" "+l(n.translations.articles_settings),1)],2),e("a",{class:v([n.tabClass(4),"justify-start w-full"]),onClick:t[5]||(t[5]=a=>n.selectTab(4))},[yt,g(" "+l(n.translations.invoices_settings),1)],2),e("a",{class:v([n.tabClass(5),"justify-start w-full"]),onClick:t[6]||(t[6]=a=>n.selectTab(5))},[vt,g(" "+l(n.translations.credits_settings),1)],2),e("a",{class:v([n.tabClass(6),"justify-start w-full"]),onClick:t[7]||(t[7]=a=>n.selectTab(6))},[wt,g(" "+l(n.translations.quotes_settings),1)],2),e("a",{class:v([n.tabClass(7),"justify-start w-full"]),onClick:t[8]||(t[8]=a=>n.selectTab(7))},[xt,g(" "+l(n.translations.currency_vat_settings),1)],2),e("a",{class:v([n.tabClass(8),"justify-start w-full"]),onClick:t[9]||(t[9]=a=>n.selectTab(8))},[kt,g(" "+l(n.translations.payments_settings),1)],2),e("a",{class:v([n.tabClass(9),"justify-start w-full"]),onClick:t[10]||(t[10]=a=>n.selectTab(9))},[Ct,g(" "+l(n.translations.expenses_settings),1)],2),i.form.easy_compta_planning_addon_active==1?(c(),d("a",{key:0,class:v([n.tabClass(10),"justify-start w-full"]),onClick:t[11]||(t[11]=a=>n.selectTab(10))},[Tt,g(" "+l(n.translations.planning_settings),1)],2)):b("",!0),i.form.easy_compta_email_addon_active==1?(c(),d("a",{key:1,class:v([n.tabClass(11),"justify-start w-full"]),onClick:t[12]||(t[12]=a=>n.selectTab(11))},[Mt,g(" "+l(n.translations.email_settings),1)],2)):b("",!0),i.form.easy_compta_user_addon_active==1?(c(),d("a",{key:2,class:v([n.tabClass(12),"justify-start w-full"]),onClick:t[13]||(t[13]=a=>n.selectTab(12))},[At,g(" "+l(n.translations.users_settings),1)],2)):b("",!0),i.form.easy_compta_payment_addon_active==1?(c(),d("a",{key:3,class:v([n.tabClass(13),"justify-start w-full"]),onClick:t[14]||(t[14]=a=>n.selectTab(13))},[St,g(" "+l(n.translations.stripe_settings),1)],2)):b("",!0),i.form.easy_compta_stats_addon_active==1?(c(),d("a",{key:4,class:v([n.tabClass(14),"justify-start w-full"]),onClick:t[15]||(t[15]=a=>n.selectTab(14))},[Pt,g(" "+l(n.translations.stats_settings),1)],2)):b("",!0),i.form.easy_compta_qrcode_addon_active==1?(c(),d("a",{key:5,class:v([n.tabClass(15),"justify-start w-full"]),onClick:t[16]||(t[16]=a=>n.selectTab(15))},[Et,g(" "+l(n.translations.qrcode_settings),1)],2)):b("",!0),e("a",{class:v([n.tabClass(16),"justify-start w-full"]),onClick:t[17]||(t[17]=a=>n.selectTab(16))},[jt,g(" "+l(n.translations.validation_license),1)],2)]),e("div",Vt,[i.loading?(c(),d("div",It,Rt)):b("",!0),i.selectedTab===1?(c(),d("div",Ut,[e("h2",Dt,l(n.translations.general_settings),1),e("form",{onSubmit:t[30]||(t[30]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Ht,[e("div",Yt,[e("label",Nt,l(n.translations.company_code),1),p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[18]||(t[18]=a=>i.form.company_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_code]])]),e("div",qt,[e("label",Lt,l(n.translations.tax_number),1),p(e("input",{type:"text",id:"tax-number","onUpdate:modelValue":t[19]||(t[19]=a=>i.form.tax_number=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.tax_number]])]),e("div",Ot,[e("label",Xt,l(n.translations.company_name),1),p(e("input",{type:"text",id:"company-name","onUpdate:modelValue":t[20]||(t[20]=a=>i.form.company_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_name]])]),e("div",Wt,[e("label",Bt,l(n.translations.address),1),p(e("input",{type:"text",id:"company-address","onUpdate:modelValue":t[21]||(t[21]=a=>i.form.company_address=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_address]])]),e("div",zt,[e("label",Gt,l(n.translations.postal_code),1),p(e("input",{type:"text",id:"postal-code","onUpdate:modelValue":t[22]||(t[22]=a=>i.form.postal_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.postal_code]])]),e("div",Jt,[e("label",Zt,l(n.translations.city),1),p(e("input",{type:"text",id:"city","onUpdate:modelValue":t[23]||(t[23]=a=>i.form.city=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.city]])]),e("div",Qt,[e("label",Kt,l(n.translations.country),1),p(e("input",{type:"text",id:"country","onUpdate:modelValue":t[24]||(t[24]=a=>i.form.country=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.country]])]),e("div",$t,[e("label",te,l(n.translations.email),1),p(e("input",{type:"email",id:"company-email","onUpdate:modelValue":t[25]||(t[25]=a=>i.form.company_email=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_email]])]),e("div",ee,[e("label",se,l(n.translations.phone),1),p(e("input",{type:"tel",id:"company-phone","onUpdate:modelValue":t[26]||(t[26]=a=>i.form.company_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_phone]])]),e("div",ne,[e("label",ie,l(n.translations.mobile),1),p(e("input",{type:"tel",id:"mobile-phone","onUpdate:modelValue":t[27]||(t[27]=a=>i.form.mobile_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.mobile_phone]])]),e("div",oe,[e("label",ae,l(n.translations.fax),1),p(e("input",{type:"tel",id:"fax","onUpdate:modelValue":t[28]||(t[28]=a=>i.form.fax=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.fax]])])]),le,i.form.easy_compta_siret_addon_active==1?(c(),d("div",re,[e("div",ce,[e("div",de,[e("label",ue,l(n.translations.siret_api_token),1),he,p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[29]||(t[29]=a=>i.form.easycompta_siret_token_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easycompta_siret_token_api]])])])])):b("",!0),e("div",pe,[e("button",me,[fe,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===2?(c(),d("div",be,[e("h2",_e,l(n.translations.system_settings),1),e("form",{onSubmit:t[41]||(t[41]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ge,[e("label",ye,[e("span",ve,l(n.translations.activate_logo_mentions),1),e("input",{type:"checkbox",checked:i.form.logo_mentions_active==1,onChange:t[31]||(t[31]=(...a)=>n.updateLogoMentionsActive&&n.updateLogoMentionsActive(...a)),class:"wcpa-ui-toggle"},null,40,we)])]),i.form.logo_mentions_active==1?(c(),d("div",xe,[e("label",ke,l(n.translations.logo_mentions),1),p(e("input",{type:"text",id:"logo-mentions","onUpdate:modelValue":t[32]||(t[32]=a=>i.form.logo_mentions=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.logo_mentions]])])):b("",!0),e("div",Ce,[e("label",Te,l(n.translations.company_logo),1),e("div",Me,[e("input",{id:"file_logo",type:"file",onChange:t[33]||(t[33]=(...a)=>n.handleLogoUpload&&n.handleLogoUpload(...a)),accept:"image/*",class:"ecwp-file-input file-input file-input-bordered file-input-info w-full max-w-xs"},null,32),e("label",Ae,[e("span",null,[Se,g(l(n.translations.select),1)])])]),i.logoPreviewUrl?(c(),d("div",Pe,[p(e("input",{type:"range",min:"0",max:"400","onUpdate:modelValue":t[34]||(t[34]=a=>i.form.logo_width=a),class:"range mt-4",onChange:t[35]||(t[35]=(...a)=>n.updatePreviewWidth&&n.updatePreviewWidth(...a))},null,544),[[f,i.form.logo_width]]),e("div",Ee,l(i.form.logo_width)+" px",1),i.form.logo_width!==null?(c(),d("div",je,[e("img",{src:i.logoPreviewUrl,alt:"Logo Preview",class:"mb-6",style:C({width:i.form.logo_width+"px"})},null,12,Ve)])):b("",!0)])):b("",!0)]),e("div",Ie,[e("label",Fe,l(n.translations.default_currency),1),p(e("select",{"onUpdate:modelValue":t[36]||(t[36]=a=>i.form.default_currency=a),class:"ecwp-input input input-bordered"},[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("option",{value:a.id,key:a.id},l(a.name)+" ("+l(a.symbol)+") ",9,Re))),128))],512),[[V,i.form.default_currency]])]),e("div",Ue,[e("label",De,l(n.translations.currency_position),1),p(e("select",{"onUpdate:modelValue":t[37]||(t[37]=a=>i.form.currency_position=a),class:"ecwp-input input input-bordered"},[e("option",He,l(n.translations.before_amount),1),e("option",Ye,l(n.translations.after_amount),1)],512),[[V,i.form.currency_position]])]),e("div",Ne,[e("label",qe,[e("span",Le,l(n.translations.activate_vat),1),e("input",{type:"checkbox",checked:i.form.vat_active==1,onChange:t[38]||(t[38]=(...a)=>n.updateVatActive&&n.updateVatActive(...a)),class:"wcpa-ui-toggle"},null,40,Oe)])]),i.form.vat_active==1?(c(),d("div",Xe,[e("label",We,l(n.translations.default_vat),1),p(e("select",{"onUpdate:modelValue":t[39]||(t[39]=a=>i.form.default_vat=a),class:"ecwp-input input input-bordered"},[Be,(c(!0),d(T,null,S(i.vats,a=>(c(),d("option",{value:a.id,key:a.id},l(a.description)+" - "+l(a.rate)+"% ",9,ze))),128))],512),[[V,i.form.default_vat]])])):b("",!0),e("div",Ge,[e("label",Je,l(n.translations.format_date),1),p(e("select",{"onUpdate:modelValue":t[40]||(t[40]=a=>i.form.date_format=a),class:"ecwp-input input input-bordered"},os,512),[[V,i.form.date_format]])]),e("div",as,[e("button",ls,[rs,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===3?(c(),d("div",cs,[i.showArticleModal?(c(),d("dialog",ds,[e("div",us,[e("h3",null,l(i.editingArticle?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[48]||(t[48]=k((...a)=>n.saveArticle&&n.saveArticle(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[42]||(t[42]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))}," \u2715 "),e("div",hs,[e("label",ps,l(n.translations.item_ref),1),p(e("input",{type:"text",id:"name_ref","onUpdate:modelValue":t[43]||(t[43]=a=>i.articleForm.ref=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.ref]])]),e("div",ms,[e("label",fs,l(n.translations.item_name),1),p(e("input",{type:"text",id:"name_article","onUpdate:modelValue":t[44]||(t[44]=a=>i.articleForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.name]])]),e("div",bs,[e("label",_s,l(n.translations.description),1),p(e("textarea",{id:"desc_article","onUpdate:modelValue":t[45]||(t[45]=a=>i.articleForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.description]])]),e("div",gs,[e("label",ys,l(n.translations.unit_price),1),p(e("input",{type:"text",id:"price_article","onUpdate:modelValue":t[46]||(t[46]=a=>i.articleForm.unit_price=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.unit_price]])]),e("div",vs,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[47]||(t[47]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))},l(n.translations.cancel),1),e("button",ws,l(i.editingArticle?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",xs,[e("h3",ks,l(n.translations.articles_settings),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[49]||(t[49]=(...a)=>n.addArticle&&n.addArticle(...a))},[Cs,g(" "+l(n.translations.add),1)])]),e("div",Ts,[e("table",Ms,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.item_ref),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.unit_price),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.articles,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.ref),1),e("td",null,l(a.name),1),e("td",null,l(a.description),1),e("td",null,l(a.unit_price),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editArticle(a.id)},Ps,8,As),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("article",a.id)},Vs,8,Es)])]))),128))])])]),Is,e("h2",Fs,l(n.translations.categories),1),e("div",Rs,[e("table",Us,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.categories,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("category_article",a.id)},Ys,8,Ds)])]))),128))])])])])):b("",!0),i.selectedTab===4?(c(),d("div",Ns,[e("h2",qs,l(n.translations.invoices_settings),1),e("form",{onSubmit:t[65]||(t[65]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Ls,[e("div",Os,[e("label",Xs,l(n.translations.invoice_color),1),p(e("input",{type:"text",id:"invoice-color","onUpdate:modelValue":t[50]||(t[50]=a=>i.form.invoice_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_color]]),x(u,{modelValue:i.form.invoice_color,"onUpdate:modelValue":t[51]||(t[51]=a=>i.form.invoice_color=a)},null,8,["modelValue"])]),e("div",Ws,[e("label",Bs,l(n.translations.invoice_prefix),1),p(e("input",{type:"text",id:"invoice-prefix","onUpdate:modelValue":t[52]||(t[52]=a=>i.form.invoice_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_prefix]])])]),zs,e("div",Gs,[e("div",Js,[e("label",Zs,[e("input",{type:"checkbox",checked:i.form.show_phone==1,onChange:t[53]||(t[53]=a=>n.updateFormField(a,"show_phone")),class:"wcpa-ui-toggle"},null,40,Qs),e("span",Ks,l(n.translations.show_phone),1)])]),e("div",$s,[e("label",tn,[e("input",{type:"checkbox",checked:i.form.show_email==1,onChange:t[54]||(t[54]=a=>n.updateFormField(a,"show_email")),class:"wcpa-ui-toggle"},null,40,en),e("span",sn,l(n.translations.show_email),1)])]),e("div",nn,[e("label",on,[e("input",{type:"checkbox",checked:i.form.show_siren==1,onChange:t[55]||(t[55]=a=>n.updateFormField(a,"show_siren")),class:"wcpa-ui-toggle"},null,40,an),e("span",ln,l(n.translations.show_siren),1)])]),e("div",rn,[e("label",cn,[e("input",{type:"checkbox",checked:i.form.show_tax_number==1,onChange:t[56]||(t[56]=a=>n.updateFormField(a,"show_tax_number")),class:"wcpa-ui-toggle"},null,40,dn),e("span",un,l(n.translations.show_tax_number),1)])]),e("div",hn,[e("label",pn,[e("input",{type:"checkbox",checked:i.form.show_watermark==1,onChange:t[57]||(t[57]=a=>n.updateFormField(a,"show_watermark")),class:"wcpa-ui-toggle"},null,40,mn),e("span",fn,l(n.translations.show_watermark),1)])]),i.form.show_watermark==1?(c(),d("div",bn,[e("label",_n,[e("input",{type:"checkbox",checked:i.form.show_watermark_only_paid==1,onChange:t[58]||(t[58]=a=>n.updateFormField(a,"show_watermark_only_paid")),class:"wcpa-ui-toggle"},null,40,gn),e("span",yn,l(n.translations.show_watermark_only_paid),1)])])):b("",!0)]),vn,e("div",wn,[e("div",xn,[e("label",kn,l(n.translations.payment_conditions),1),p(e("input",{type:"text",id:"conditions-payment","onUpdate:modelValue":t[59]||(t[59]=a=>i.form.payment_conditions=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_conditions]])]),e("div",Cn,[e("label",Tn,l(n.translations.payment_mode),1),p(e("input",{type:"text",id:"mode-payment","onUpdate:modelValue":t[60]||(t[60]=a=>i.form.payment_mode=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_mode]])])]),e("div",Mn,[e("div",An,[e("label",Sn,l(n.translations.invoice_terms),1),e("div",null,[x(_,{modelValue:i.form.invoice_terms,"onUpdate:modelValue":t[61]||(t[61]=a=>i.form.invoice_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",Pn,[e("div",En,[e("label",jn,l(n.translations.invoice_iban),1),p(e("input",{type:"text",id:"invoice-iban","onUpdate:modelValue":t[62]||(t[62]=a=>i.form.invoice_iban=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_iban]])]),e("div",Vn,[e("label",In,l(n.translations.invoice_bic),1),p(e("input",{type:"text",id:"invoice-bic","onUpdate:modelValue":t[63]||(t[63]=a=>i.form.invoice_bic=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_bic]])])]),e("div",Fn,[e("label",Rn,l(n.translations.invoice_footer),1),e("div",null,[x(_,{modelValue:i.form.invoice_footer,"onUpdate:modelValue":t[64]||(t[64]=a=>i.form.invoice_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",Un,[e("button",Dn,[Hn,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===5?(c(),d("div",Yn,[e("h2",Nn,l(n.translations.credits_settings),1),e("form",{onSubmit:t[71]||(t[71]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",qn,[e("div",Ln,[e("label",On,l(n.translations.credit_color),1),p(e("input",{type:"text",id:"credit-color","onUpdate:modelValue":t[66]||(t[66]=a=>i.form.credit_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_color]]),x(u,{modelValue:i.form.credit_color,"onUpdate:modelValue":t[67]||(t[67]=a=>i.form.credit_color=a)},null,8,["modelValue"])]),e("div",Xn,[e("label",Wn,l(n.translations.credit_prefix),1),p(e("input",{type:"text",id:"credit-prefix","onUpdate:modelValue":t[68]||(t[68]=a=>i.form.credit_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_prefix]])])]),e("div",Bn,[e("div",zn,[e("label",Gn,l(n.translations.credit_footer),1),e("div",null,[x(_,{modelValue:i.form.credit_footer,"onUpdate:modelValue":t[69]||(t[69]=a=>i.form.credit_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",Jn,[e("label",Zn,l(n.translations.credit_terms),1),e("div",null,[x(_,{modelValue:i.form.credit_terms,"onUpdate:modelValue":t[70]||(t[70]=a=>i.form.credit_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",Qn,[e("button",Kn,[$n,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===6?(c(),d("div",ti,[e("h2",ei,l(n.translations.quotes_settings),1),e("form",{onSubmit:t[77]||(t[77]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",si,[e("div",ni,[e("label",ii,l(n.translations.quote_color),1),p(e("input",{type:"text",id:"quote-color","onUpdate:modelValue":t[72]||(t[72]=a=>i.form.quote_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_color]]),x(u,{modelValue:i.form.quote_color,"onUpdate:modelValue":t[73]||(t[73]=a=>i.form.quote_color=a)},null,8,["modelValue"])]),e("div",oi,[e("label",ai,l(n.translations.quote_prefix),1),p(e("input",{type:"text",id:"quote-prefix","onUpdate:modelValue":t[74]||(t[74]=a=>i.form.quote_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_prefix]])])]),e("div",li,[e("div",ri,[e("label",ci,l(n.translations.quote_footer),1),e("div",null,[x(_,{modelValue:i.form.quote_footer,"onUpdate:modelValue":t[75]||(t[75]=a=>i.form.quote_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",di,[e("label",ui,l(n.translations.quote_terms),1),e("div",null,[x(_,{modelValue:i.form.quote_terms,"onUpdate:modelValue":t[76]||(t[76]=a=>i.form.quote_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",hi,[e("button",pi,[mi,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===7?(c(),d("div",fi,[e("h2",bi,l(n.translations.currency_vat_settings),1),i.showCurrencyModal?(c(),d("dialog",_i,[e("div",gi,[e("h3",null,l(i.editingCurrency?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[83]||(t[83]=k((...a)=>n.saveCurrency&&n.saveCurrency(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[78]||(t[78]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))}," \u2715 "),e("div",yi,[e("label",vi,l(n.translations.name),1),p(e("input",{type:"text",id:"name_currency","onUpdate:modelValue":t[79]||(t[79]=a=>i.currencyForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.name]])]),e("div",wi,[e("label",xi,l(n.translations.symbol),1),p(e("input",{type:"text",id:"symbol_currency","onUpdate:modelValue":t[80]||(t[80]=a=>i.currencyForm.symbol=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.symbol]])]),e("div",ki,[e("label",Ci,l(n.translations.code),1),p(e("input",{type:"text",id:"code_currency","onUpdate:modelValue":t[81]||(t[81]=a=>i.currencyForm.code=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.code]])]),e("div",Ti,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[82]||(t[82]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))},l(n.translations.cancel),1),e("button",Mi,l(i.editingCurrency?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Ai,[e("div",Si,[e("h3",Pi,l(n.translations.currencies),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[84]||(t[84]=(...a)=>n.addCurrency&&n.addCurrency(...a))},[Ei,g(" "+l(n.translations.add_currency),1)])]),e("div",ji,[e("table",Vi,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.symbol),1),e("th",null,l(n.translations.code),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,l(a.symbol),1),e("td",null,l(a.code),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editCurrency(a.id)},Ri,8,Ii),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("currency",a.id)},Hi,8,Ui)])]))),128))])])])]),e("div",null,[i.showVATModal?(c(),d("dialog",Yi,[e("div",Ni,[e("h3",null,l(i.editingVAT?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[89]||(t[89]=k((...a)=>n.saveVAT&&n.saveVAT(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[85]||(t[85]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))}," \u2715 "),e("div",qi,[e("label",Li,l(n.translations.description),1),p(e("input",{type:"text",id:"vat-description","onUpdate:modelValue":t[86]||(t[86]=a=>i.vatForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.description]])]),e("div",Oi,[e("label",Xi,l(n.translations.rate)+" (%)",1),p(e("input",{type:"text",id:"vat-rate","onUpdate:modelValue":t[87]||(t[87]=a=>i.vatForm.rate=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.rate]])]),e("div",Wi,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[88]||(t[88]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))},l(n.translations.cancel),1),e("button",Bi,l(i.editingVAT?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",zi,[e("h3",Gi,l(n.translations.vat_rates),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[90]||(t[90]=(...a)=>n.addVAT&&n.addVAT(...a))},[Ji,g(" "+l(n.translations.add_vat),1)])]),e("div",Zi,[e("table",Qi,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.rate)+" (%)",1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.vats,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.description),1),e("td",null,l(a.rate),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editVAT(a.id)},to,8,Ki),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("vat",a.id)},no,8,eo)])]))),128))])])])])])):b("",!0),i.selectedTab===8?(c(),d("div",io,[e("h2",oo,l(n.translations.payments_settings),1),i.showPaymentModal?(c(),d("dialog",ao,[e("div",lo,[e("h3",null,l(i.editingPayment?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[94]||(t[94]=k((...a)=>n.savePayment&&n.savePayment(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[91]||(t[91]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))}," \u2715 "),e("div",ro,[e("label",co,l(n.translations.name),1),p(e("input",{type:"text",id:"name_payment","onUpdate:modelValue":t[92]||(t[92]=a=>i.paymentForm.method_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.paymentForm.method_name]])]),e("div",uo,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[93]||(t[93]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))},l(n.translations.cancel),1),e("button",ho,l(i.editingPayment?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",po,[e("div",mo,[e("h3",fo,l(n.translations.payments_methods),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[95]||(t[95]=(...a)=>n.addPayment&&n.addPayment(...a))},[bo,g(l(n.translations.add_method),1)])]),e("div",_o,[e("table",go,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.payments,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.method_name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editPayment(a.id)},wo,8,yo),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("payment",a.id)},Co,8,xo)])]))),128))])])])])])):b("",!0),i.selectedTab===9?(c(),d("div",To,[e("h2",Mo,l(n.translations.expenses_settings),1),i.showExpenseModal?(c(),d("dialog",Ao,[e("div",So,[e("h3",null,l(i.editingExpense?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[99]||(t[99]=k((...a)=>n.saveExpCat&&n.saveExpCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[96]||(t[96]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))}," \u2715 "),e("div",Po,[e("label",Eo,l(n.translations.name),1),p(e("input",{type:"text",id:"name_expense","onUpdate:modelValue":t[97]||(t[97]=a=>i.expenseForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.expenseForm.name]])]),e("div",jo,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[98]||(t[98]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))},l(n.translations.cancel),1),e("button",Vo,l(i.editingExpense?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Io,[e("div",Fo,[e("h3",Ro,l(n.translations.expenses_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[100]||(t[100]=(...a)=>n.addExpCat&&n.addExpCat(...a))},[Uo,g(" "+l(n.translations.add_category),1)])]),e("div",Do,[e("table",Ho,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.expenses,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editExpCat(a.id)},qo,8,Yo),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("expense",a.id)},Xo,8,Lo)])]))),128))])])])])])):b("",!0),i.selectedTab===10?(c(),d("div",Wo,[e("h2",Bo,l(n.translations.planning_settings),1),i.showPlanningModal?(c(),d("dialog",zo,[e("div",Go,[e("h3",null,l(i.editingPlanning?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[108]||(t[108]=k((...a)=>n.savePlanningCat&&n.savePlanningCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[101]||(t[101]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))}," \u2715 "),e("div",Jo,[e("label",Zo,l(n.translations.name),1),p(e("input",{type:"text",id:"name_planning","onUpdate:modelValue":t[102]||(t[102]=a=>i.planningForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.name]])]),e("div",Qo,[e("label",Ko,l(n.translations.background),1),p(e("input",{type:"text",id:"background_planning","onUpdate:modelValue":t[103]||(t[103]=a=>i.planningForm.background=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.background]]),x(u,{modelValue:i.planningForm.background,"onUpdate:modelValue":t[104]||(t[104]=a=>i.planningForm.background=a)},null,8,["modelValue"])]),e("div",$o,[e("label",ta,l(n.translations.text_color),1),p(e("input",{type:"text",id:"color_planning","onUpdate:modelValue":t[105]||(t[105]=a=>i.planningForm.color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.color]]),x(u,{modelValue:i.planningForm.color,"onUpdate:modelValue":t[106]||(t[106]=a=>i.planningForm.color=a)},null,8,["modelValue"])]),e("div",ea,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[107]||(t[107]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))},l(n.translations.cancel),1),e("button",{type:"submit",class:"btn btn-primary rounded-full mx-2",disabled:i.loading},[g(l(i.editingPlanning?n.translations.save:n.translations.add)+" ",1),i.loading?(c(),d("span",na)):b("",!0)],8,sa)])],32)])])):b("",!0),e("div",ia,[e("div",oa,[e("h3",aa,l(n.translations.planning_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[109]||(t[109]=(...a)=>n.addPlanningCat&&n.addPlanningCat(...a))},[la,g(" "+l(n.translations.add_category),1)])]),e("div",ra,[e("table",ca,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.background),1),e("th",null,l(n.translations.color),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.planning,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.background})},null,4)]),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.color})},null,4)]),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editPlanningCat(a.id)},ha,8,da),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("planning",a.id)},fa,8,pa)])]))),128))])])])])])):b("",!0),i.selectedTab===11?(c(),d("div",ba,[e("h2",_a,l(n.translations.email_settings),1),e("form",{onSubmit:t[121]||(t[121]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ga,[e("label",ya,[e("span",va,l(n.translations.email_log_active),1),e("input",{type:"checkbox",checked:i.form.email_log_active==1,onChange:t[110]||(t[110]=(...a)=>n.updateEmailLogsActive&&n.updateEmailLogsActive(...a)),class:"wcpa-ui-toggle"},null,40,wa)])]),xa,e("div",ka,[e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab1"}]),onClick:t[111]||(t[111]=a=>n.setActiveTab("tab1"))},l(n.translations.email_invoice),3),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab2"}]),onClick:t[112]||(t[112]=a=>n.setActiveTab("tab2"))},l(n.translations.email_quote),3),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab3"}]),onClick:t[113]||(t[113]=a=>n.setActiveTab("tab3"))},l(n.translations.invoice_reminder),3),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab4"}]),onClick:t[114]||(t[114]=a=>n.setActiveTab("tab4"))},l(n.translations.payment_received),3)]),i.activeTabEmail==="tab1"?(c(),d("div",Ca,[e("div",Ta,[e("div",Ma,[e("label",Aa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_invoice_subject","onUpdate:modelValue":t[115]||(t[115]=a=>i.form.email_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_invoice_subject]])]),e("div",Sa,[e("label",Pa,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_invoice_content,"onUpdate:modelValue":t[116]||(t[116]=a=>i.form.email_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Ea])])])):b("",!0),i.activeTabEmail==="tab2"?(c(),d("div",ja,[e("div",Va,[e("div",Ia,[e("label",Fa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_quote_subject","onUpdate:modelValue":t[117]||(t[117]=a=>i.form.email_quote_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_quote_subject]])]),e("div",Ra,[e("label",Ua,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_quote_content,"onUpdate:modelValue":t[118]||(t[118]=a=>i.form.email_quote_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Da])])])):b("",!0),i.activeTabEmail==="tab3"?(c(),d("div",Ha,[e("div",Ya,[e("div",Na,[e("label",qa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"remind_invoice_subject","onUpdate:modelValue":t[119]||(t[119]=a=>i.form.remind_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.remind_invoice_subject]])]),e("div",La,[e("label",Oa,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.remind_invoice_content,"onUpdate:modelValue":t[120]||(t[120]=a=>i.form.remind_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Xa])])])):b("",!0),i.activeTabEmail==="tab4"?(c(),d("div",Wa,[e("div",Ba,[za,e("div",null,[e("h2",Ga,l(n.translations.coming_soon),1)])])])):b("",!0),e("div",Ja,[e("button",Za,[Qa,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===12?(c(),d("div",Ka,[e("h2",$a,l(n.translations.users_settings),1),e("div",tl,[e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabUsers==="user1"}]),onClick:t[122]||(t[122]=a=>n.setActiveTabUsers("user1"))}," Automatic create account ",2),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabUsers==="user2"}]),onClick:t[123]||(t[123]=a=>n.setActiveTabUsers("user2"))}," Lost password ",2)]),i.activeTabUsers==="user1"?(c(),d("div",el,[e("form",{onSubmit:t[126]||(t[126]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",sl,[e("div",nl,[e("label",il,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_create_account_subject","onUpdate:modelValue":t[124]||(t[124]=a=>i.form.email_create_account_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_create_account_subject]])]),e("div",ol,[e("label",al,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_create_account_content,"onUpdate:modelValue":t[125]||(t[125]=a=>i.form.email_create_account_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),ll])]),e("div",rl,[e("button",cl,[dl,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.activeTabUsers==="user2"?(c(),d("div",ul,[e("div",hl,[pl,e("div",null,[e("h2",ml,l(n.translations.coming_soon),1)])])])):b("",!0)])):b("",!0),i.selectedTab===13?(c(),d("div",fl,[e("h2",bl,l(n.translations.stripe_settings),1),e("form",{onSubmit:t[132]||(t[132]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",_l,[e("div",gl,[e("label",yl,l(n.translations.stripe_mode),1),p(e("select",{id:"stripe-mode","onUpdate:modelValue":t[127]||(t[127]=a=>i.form.stripe_mode=a),class:"ecwp-input input input-bordered",required:""},[e("option",vl,l(n.translations.test_mode),1),e("option",wl,l(n.translations.live_mode),1)],512),[[V,i.form.stripe_mode]])]),i.form.stripe_mode==="test"?(c(),d("div",xl,[e("div",kl,[e("label",Cl,l(n.translations.stripe_public_key_test),1),p(e("input",{type:"text",id:"stripe-public-key-test","onUpdate:modelValue":t[128]||(t[128]=a=>i.form.stripe_public_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_test]])]),e("div",Tl,[e("label",Ml,l(n.translations.stripe_secret_key_test),1),p(e("input",{type:"text",id:"stripe-secret-key-test","onUpdate:modelValue":t[129]||(t[129]=a=>i.form.stripe_secret_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_test]])])])):b("",!0),i.form.stripe_mode==="live"?(c(),d("div",Al,[e("div",Sl,[e("label",Pl,l(n.translations.stripe_public_key_live),1),p(e("input",{type:"text",id:"stripe-public-key-live","onUpdate:modelValue":t[130]||(t[130]=a=>i.form.stripe_public_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_live]])]),e("div",El,[e("label",jl,l(n.translations.stripe_secret_key_live),1),p(e("input",{type:"text",id:"stripe-secret-key-live","onUpdate:modelValue":t[131]||(t[131]=a=>i.form.stripe_secret_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_live]])])])):b("",!0)]),e("div",Vl,[e("button",Il,[Fl,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===14?(c(),d("div",Rl,[e("h2",Ul,l(n.translations.stats_settings),1),e("form",{onSubmit:t[135]||(t[135]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Dl,[e("div",Hl,[e("label",Yl,l(n.translations.limit_declaration),1),p(e("input",{type:"number",id:"limit-declaration","onUpdate:modelValue":t[133]||(t[133]=a=>i.form.limit_declaration=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_declaration]])]),e("div",Nl,[e("label",ql,l(n.translations.limit_tva),1),p(e("input",{type:"number",id:"limit-tva","onUpdate:modelValue":t[134]||(t[134]=a=>i.form.limit_tva=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_tva]])])]),e("div",Ll,[e("button",Ol,[Xl,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===15?(c(),d("div",Wl,[e("h2",Bl,l(n.translations.qrcode_settings),1),e("form",{onSubmit:t[137]||(t[137]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",zl,[e("div",Gl,[e("label",Jl,l(n.translations.stripe_api),1),p(e("input",{type:"text",id:"stripe-api","onUpdate:modelValue":t[136]||(t[136]=a=>i.form.easy_compta_stripe_secret_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easy_compta_stripe_secret_api]])])]),e("div",Zl,[e("button",Ql,[Kl,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===16?(c(),d("div",$l,[e("h2",tr,l(n.translations.validation_license),1),e("div",er,[e("div",sr,[e("label",nr,l(n.translations.license_key),1),p(e("input",{type:"text",id:"license-code","onUpdate:modelValue":t[138]||(t[138]=a=>i.license_key=a),class:"ecwp-input input input-bordered w-full",disabled:i.licenseData&&i.licenseData.valid,required:""},null,8,ir),[[f,i.license_key]]),e("button",{onClick:t[139]||(t[139]=(...a)=>n.checkLicense&&n.checkLicense(...a)),class:"btn btn-primary join-item rounded-r-full mt-5 -me-1",disabled:i.loadingLicense||i.licenseData&&i.licenseData.valid},[i.loadingLicense?(c(),d("span",ar)):(c(),d("span",lr,l(n.translations.validate),1))],8,or)])]),e("div",rr,[i.errorMessage?(c(),d("div",cr,l(i.errorMessage),1)):b("",!0),i.licenseData?(c(),d("div",dr,[e("table",ur,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.domain),1),e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.activation_date),1),e("th",null,l(n.translations.expiry_date),1),e("th",null,l(n.translations.status),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[e("tr",null,[e("td",null,l(i.licenseData.domain),1),e("td",null,[(c(!0),d(T,null,S(i.licenseData.plugins,(a,y)=>(c(),d("div",{key:y},l(y),1))),128))]),e("td",null,l(i.licenseData.start_date),1),e("td",null,l(i.licenseData.end_date),1),e("td",null,l(i.licenseData.valid?"Valid":"Invalid"),1),e("td",null,[e("button",{onClick:t[140]||(t[140]=a=>n.refresh_licence()),class:"btn btn-circle text-blue-500 hover:text-blue-700 mx-1"},pr),e("button",{onClick:t[141]||(t[141]=a=>n.delete_item("licence","")),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},fr)])])])]),e("table",br,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.slug),1),e("th",null,l(n.translations.installed),1),e("th",null,l(n.translations.version),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.licenseData.plugins,a=>(c(),d("tr",{key:a},[e("td",null,l(a.product_name),1),e("td",null,l(a.product_slug),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[g(l(n.translations.installed),1)],64)):(c(),d(T,{key:1},[g(l(n.translations.not_installed),1)],64))]),e("td",null,l(i.installed_versions[a.product_slug]),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[e("button",{onClick:y=>n.checkUpdatePlugin(a.product_slug,i.installed_versions[a.product_slug]),class:"btn btn-sm text-red-500 hover:text-red-700 mx-1"},l(n.translations.check_update),9,_r),i.updatesAvailable[a.product_slug]?(c(),d("button",{key:0,onClick:y=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-blue-500 hover:text-blue-700 mx-1"},l(n.translations.download),9,gr)):b("",!0)],64)):(c(),d("button",{key:1,onClick:y=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-green-500 hover:green-red-700 mx-1"},l(n.translations.download),9,yr))])]))),128))])])])):b("",!0)])])):b("",!0)])])]),_:1})])}var wr=$(ct,[["render",vr]]);function R(s){return R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(s)}var xr=/^\s+/,kr=/\s+$/;function h(s,t){if(s=s||"",t=t||{},s instanceof h)return s;if(!(this instanceof h))return new h(s,t);var o=Cr(s);this._originalInput=s,this._r=o.r,this._g=o.g,this._b=o.b,this._a=o.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||o.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=o.ok}h.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),o,r,i,n,m,u;return o=t.r/255,r=t.g/255,i=t.b/255,o<=.03928?n=o/12.92:n=Math.pow((o+.055)/1.055,2.4),r<=.03928?m=r/12.92:m=Math.pow((r+.055)/1.055,2.4),i<=.03928?u=i/12.92:u=Math.pow((i+.055)/1.055,2.4),.2126*n+.7152*m+.0722*u},setAlpha:function(t){return this._a=G(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=q(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=q(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.v*100);return this._a==1?"hsv("+o+", "+r+"%, "+i+"%)":"hsva("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=N(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=N(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.l*100);return this._a==1?"hsl("+o+", "+r+"%, "+i+"%)":"hsla("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return L(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return Sr(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(w(this._r,255)*100)+"%",g:Math.round(w(this._g,255)*100)+"%",b:Math.round(w(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%)":"rgba("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:Nr[L(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var o="#"+O(this._r,this._g,this._b,this._a),r=o,i=this._gradientType?"GradientType = 1, ":"";if(t){var n=h(t);r="#"+O(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+o+",endColorstr="+r+")"},toString:function(t){var o=!!t;t=t||this._format;var r=!1,i=this._a<1&&this._a>=0,n=!o&&i&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(r=this.toRgbString()),t==="prgb"&&(r=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(r=this.toHexString()),t==="hex3"&&(r=this.toHexString(!0)),t==="hex4"&&(r=this.toHex8String(!0)),t==="hex8"&&(r=this.toHex8String()),t==="name"&&(r=this.toName()),t==="hsl"&&(r=this.toHslString()),t==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return h(this.toString())},_applyModification:function(t,o){var r=t.apply(null,[this].concat([].slice.call(o)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Vr,arguments)},brighten:function(){return this._applyModification(Ir,arguments)},darken:function(){return this._applyModification(Fr,arguments)},desaturate:function(){return this._applyModification(Pr,arguments)},saturate:function(){return this._applyModification(Er,arguments)},greyscale:function(){return this._applyModification(jr,arguments)},spin:function(){return this._applyModification(Rr,arguments)},_applyCombination:function(t,o){return t.apply(null,[this].concat([].slice.call(o)))},analogous:function(){return this._applyCombination(Hr,arguments)},complement:function(){return this._applyCombination(Ur,arguments)},monochromatic:function(){return this._applyCombination(Yr,arguments)},splitcomplement:function(){return this._applyCombination(Dr,arguments)},triad:function(){return this._applyCombination(X,[3])},tetrad:function(){return this._applyCombination(X,[4])}};h.fromRatio=function(s,t){if(R(s)=="object"){var o={};for(var r in s)s.hasOwnProperty(r)&&(r==="a"?o[r]=s[r]:o[r]=F(s[r]));s=o}return h(s,t)};function Cr(s){var t={r:0,g:0,b:0},o=1,r=null,i=null,n=null,m=!1,u=!1;return typeof s=="string"&&(s=Xr(s)),R(s)=="object"&&(j(s.r)&&j(s.g)&&j(s.b)?(t=Tr(s.r,s.g,s.b),m=!0,u=String(s.r).substr(-1)==="%"?"prgb":"rgb"):j(s.h)&&j(s.s)&&j(s.v)?(r=F(s.s),i=F(s.v),t=Ar(s.h,r,i),m=!0,u="hsv"):j(s.h)&&j(s.s)&&j(s.l)&&(r=F(s.s),n=F(s.l),t=Mr(s.h,r,n),m=!0,u="hsl"),s.hasOwnProperty("a")&&(o=s.a)),o=G(o),{ok:m,format:s.format||u,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:o}}function Tr(s,t,o){return{r:w(s,255)*255,g:w(t,255)*255,b:w(o,255)*255}}function N(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=(r+i)/2;if(r==i)n=m=0;else{var _=r-i;switch(m=u>.5?_/(2-r-i):_/(r+i),r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,l:u}}function Mr(s,t,o){var r,i,n;s=w(s,360),t=w(t,100),o=w(o,100);function m(M,a,y){return y<0&&(y+=1),y>1&&(y-=1),y<1/6?M+(a-M)*6*y:y<1/2?a:y<2/3?M+(a-M)*(2/3-y)*6:M}if(t===0)r=i=n=o;else{var u=o<.5?o*(1+t):o+t-o*t,_=2*o-u;r=m(_,u,s+1/3),i=m(_,u,s),n=m(_,u,s-1/3)}return{r:r*255,g:i*255,b:n*255}}function q(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=r,_=r-i;if(m=r===0?0:_/r,r==i)n=0;else{switch(r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,v:u}}function Ar(s,t,o){s=w(s,360)*6,t=w(t,100),o=w(o,100);var r=Math.floor(s),i=s-r,n=o*(1-t),m=o*(1-i*t),u=o*(1-(1-i)*t),_=r%6,M=[o,m,n,n,u,o][_],a=[u,o,o,m,n,n][_],y=[n,n,u,o,o,m][_];return{r:M*255,g:a*255,b:y*255}}function L(s,t,o,r){var i=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function Sr(s,t,o,r,i){var n=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16)),E(J(r))];return i&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function O(s,t,o,r){var i=[E(J(r)),E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return i.join("")}h.equals=function(s,t){return!s||!t?!1:h(s).toRgbString()==h(t).toRgbString()};h.random=function(){return h.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function Pr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s-=t/100,o.s=H(o.s),h(o)}function Er(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s+=t/100,o.s=H(o.s),h(o)}function jr(s){return h(s).desaturate(100)}function Vr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l+=t/100,o.l=H(o.l),h(o)}function Ir(s,t){t=t===0?0:t||10;var o=h(s).toRgb();return o.r=Math.max(0,Math.min(255,o.r-Math.round(255*-(t/100)))),o.g=Math.max(0,Math.min(255,o.g-Math.round(255*-(t/100)))),o.b=Math.max(0,Math.min(255,o.b-Math.round(255*-(t/100)))),h(o)}function Fr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l-=t/100,o.l=H(o.l),h(o)}function Rr(s,t){var o=h(s).toHsl(),r=(o.h+t)%360;return o.h=r<0?360+r:r,h(o)}function Ur(s){var t=h(s).toHsl();return t.h=(t.h+180)%360,h(t)}function X(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var o=h(s).toHsl(),r=[h(s)],i=360/t,n=1;n<t;n++)r.push(h({h:(o.h+n*i)%360,s:o.s,l:o.l}));return r}function Dr(s){var t=h(s).toHsl(),o=t.h;return[h(s),h({h:(o+72)%360,s:t.s,l:t.l}),h({h:(o+216)%360,s:t.s,l:t.l})]}function Hr(s,t,o){t=t||6,o=o||30;var r=h(s).toHsl(),i=360/o,n=[h(s)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,n.push(h(r));return n}function Yr(s,t){t=t||6;for(var o=h(s).toHsv(),r=o.h,i=o.s,n=o.v,m=[],u=1/t;t--;)m.push(h({h:r,s:i,v:n})),n=(n+u)%1;return m}h.mix=function(s,t,o){o=o===0?0:o||50;var r=h(s).toRgb(),i=h(t).toRgb(),n=o/100,m={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(i.a-r.a)*n+r.a};return h(m)};h.readability=function(s,t){var o=h(s),r=h(t);return(Math.max(o.getLuminance(),r.getLuminance())+.05)/(Math.min(o.getLuminance(),r.getLuminance())+.05)};h.isReadable=function(s,t,o){var r=h.readability(s,t),i,n;switch(n=!1,i=Wr(o),i.level+i.size){case"AAsmall":case"AAAlarge":n=r>=4.5;break;case"AAlarge":n=r>=3;break;case"AAAsmall":n=r>=7;break}return n};h.mostReadable=function(s,t,o){var r=null,i=0,n,m,u,_;o=o||{},m=o.includeFallbackColors,u=o.level,_=o.size;for(var M=0;M<t.length;M++)n=h.readability(s,t[M]),n>i&&(i=n,r=h(t[M]));return h.isReadable(s,r,{level:u,size:_})||!m?r:(o.includeFallbackColors=!1,h.mostReadable(s,["#fff","#000"],o))};var Y=h.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Nr=h.hexNames=qr(Y);function qr(s){var t={};for(var o in s)s.hasOwnProperty(o)&&(t[s[o]]=o);return t}function G(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function w(s,t){Lr(s)&&(s="100%");var o=Or(s);return s=Math.min(t,Math.max(0,parseFloat(s))),o&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function H(s){return Math.min(1,Math.max(0,s))}function A(s){return parseInt(s,16)}function Lr(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function Or(s){return typeof s=="string"&&s.indexOf("%")!=-1}function E(s){return s.length==1?"0"+s:""+s}function F(s){return s<=1&&(s=s*100+"%"),s}function J(s){return Math.round(parseFloat(s)*255).toString(16)}function W(s){return A(s)/255}var P=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",o="(?:"+t+")|(?:"+s+")",r="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?",i="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?";return{CSS_UNIT:new RegExp(o),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function j(s){return!!P.CSS_UNIT.exec(s)}function Xr(s){s=s.replace(xr,"").replace(kr,"").toLowerCase();var t=!1;if(Y[s])s=Y[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var o;return(o=P.rgb.exec(s))?{r:o[1],g:o[2],b:o[3]}:(o=P.rgba.exec(s))?{r:o[1],g:o[2],b:o[3],a:o[4]}:(o=P.hsl.exec(s))?{h:o[1],s:o[2],l:o[3]}:(o=P.hsla.exec(s))?{h:o[1],s:o[2],l:o[3],a:o[4]}:(o=P.hsv.exec(s))?{h:o[1],s:o[2],v:o[3]}:(o=P.hsva.exec(s))?{h:o[1],s:o[2],v:o[3],a:o[4]}:(o=P.hex8.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),a:W(o[4]),format:t?"name":"hex8"}:(o=P.hex6.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),format:t?"name":"hex"}:(o=P.hex4.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),a:W(o[4]+""+o[4]),format:t?"name":"hex8"}:(o=P.hex3.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),format:t?"name":"hex"}:!1}function Wr(s){var t,o;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),o=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),o!=="small"&&o!=="large"&&(o="small"),{level:t,size:o}}var Z={name:"ColorPicker",props:["color","position","boxRect","disableAlpha","disableTextInputs"],emits:["updateColor","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","ready","change"],inject:["tinycolor"],data(){return{h:void 0,s:void 0,v:void 0,a:void 0,hueTranslateX:0,alphaTranslateX:0,saturationTranslateX:0,saturationTranslateY:0,sliderPointerWidth:0,saturationPointerWidth:0,saturationPointerHeight:0,pickerPositionA:{anchor:"top",offset:0},pickerPositionB:{anchor:"left",offset:0},pickerWidth:0,pickerHeight:0,textInputsFormat:"rgb",textInputActive:null,textInputsFreeze:{},arrowColor:"#0f0f0f",sliderWidth:0}},computed:{pureHueBackground(){return{background:"hsl("+this.h+", 100%, 50%)"}},hexString(){return this.color.toHexString()},huePointerStyles(){return{transform:"translate("+(this.hueTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerStyles(){return{transform:"translate("+(this.alphaTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerTransparentStyles(){return{backgroundPosition:-this.alphaTranslateX+"px"}},alphaPointerColorStyles(){return{opacity:this.a}},alphaCanvasStyles(){return{background:"linear-gradient(90deg, transparent 0%, "+this.color.toHexString()+" 100%)"}},saturationPointerStyles(){const s=this.saturationTranslateX-this.saturationPointerWidth*.5,t=this.saturationTranslateY+this.saturationPointerHeight*.5;return{transform:"translate("+s+"px, "+t+"px)"}},arrowsStyles(){return{"--arrow-color":this.arrowColor}},pickerPosition(){const s={},t={top:"bottom",bottom:"top",left:"right",right:"left"};let o;["top","bottom"].includes(this.position[0])?(s.marginLeft=0,s.marginRight=0,o=this.boxRect.height):(s.marginTop=0,s.marginBottom=0,o=this.boxRect.width);let r=t[this.position[0]];return s[r]=o+"px",this.position[1]==="center"?(["left","right"].includes(r)?(r="top",o=this.pickerHeight-this.boxRect.height):(r="left",o=this.pickerWidth-this.boxRect.width),o*=.5):(r=t[this.position[1]],o=0),s[r]=-o+"px",s},textInputs(){const s=this.textInputsFormat,t={};if(["name","hex"].includes(s))t.hex=this.color.toString("hex");else{const o=this.color.toString(s).split("(")[1].slice(0,-1).split(", ");s.split("").forEach((r,i)=>t[r]=o[i])}if(this.disableAlpha||(t.a=Number(this.color.getAlpha().toFixed(2))),t.hasOwnProperty("h")&&(t.h=Math.round(this.h),t.hasOwnProperty("l"))){let o=this.s;const r=this.v||.001,i=(2-o)*r/2;i<.5&&(o*=r/(i*2),t.s=Math.round(o*100)+"%")}return t}},methods:{saturationPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.saturationPickEnd),document.addEventListener("pointermove",this.saturationPickMove),this.saturationPickMove(s),this.emitHook("saturationInputStart",{s:this.s,v:this.v}),this.colorSnapshot=this.color.toRgbString()},saturationPickEnd(s){document.removeEventListener("pointerup",this.saturationPickEnd),document.removeEventListener("pointermove",this.saturationPickMove),this.emitHook("saturationInputEnd",{s:this.s,v:this.v}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},saturationPickMove(s){s.clientX>=this.saturationCanvasRect.x&&s.clientX<=this.saturationCanvasRect.right?this.s=(s.clientX-this.saturationCanvasRect.x)/this.saturationCanvasRect.width:s.clientX<this.saturationCanvasRect.x?this.s=0:this.s=1,s.clientY>=this.saturationCanvasRect.y&&s.clientY<=this.saturationCanvasRect.bottom?this.v=1-(s.clientY-this.saturationCanvasRect.y)/this.saturationCanvasRect.height:s.clientY<this.saturationCanvasRect.y?this.v=1:this.v=0},huePickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.huePickEnd),document.addEventListener("pointermove",this.huePickMove),this.huePickMove(s),this.emitHook("hueInputStart",{h:this.h}),this.colorSnapshot=this.color.toRgbString()},huePickEnd(s){document.removeEventListener("pointerup",this.huePickEnd),document.removeEventListener("pointermove",this.huePickMove),this.emitHook("hueInputEnd",{h:this.h}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},huePickMove(s){s.clientX>=this.hueCanvasRect.x&&s.clientX<=this.hueCanvasRect.right?this.h=(s.clientX-this.hueCanvasRect.x)*360/this.hueCanvasRect.width:s.clientX<this.hueCanvasRect.x?this.h=0:this.h=360},alphaPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.alphaPickEnd),document.addEventListener("pointermove",this.alphaPickMove),this.alphaPickMove(s),this.emitHook("alphaInputStart",{a:this.a}),this.colorSnapshot=this.color.toRgbString()},alphaPickEnd(s){document.removeEventListener("pointerup",this.alphaPickEnd),document.removeEventListener("pointermove",this.alphaPickMove),this.emitHook("alphaInputEnd",{a:this.a}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},alphaPickMove(s){s.clientX>=this.alphaCanvasRect.x&&s.clientX<=this.alphaCanvasRect.right?this.a=(s.clientX-this.alphaCanvasRect.x)/this.alphaCanvasRect.width:s.clientX<this.alphaCanvasRect.x?this.a=0:this.a=1},emitUpdate(s){s=s||{h:this.h,s:this.s,v:this.v,a:this.a},this.$emit("updateColor",s)},emitHook(s,t){if(typeof t=="object")for(let[o,r]of Object.entries(t))t[o]=Number(r.toFixed(3));else t=Number(t.toFixed(3));this.$emit(s,t)},textInputInputHandler(s){const t=s.target.dataset.component;this.textInputsFreeze[t]=s.target.value;let o={...this.textInputsFreeze};if(o.hasOwnProperty("hex")){const n=o.a;o=this.tinycolor(o.hex),o.getFormat()!=="hex8"&&o.setAlpha(n)}else o=this.tinycolor(o);const r=o.toHsv();if(this.textInputsFormat==="hsl"&&(r.h===0&&(r.h=parseInt(this.textInputsFreeze.h)),r.v===0)){let n=this.textInputsFreeze.s;const m=n.indexOf("%")!==-1;n=parseFloat(n),!n||n<0?n=0:(m||n>1)&&(n=Math.min(n*.01,1));const u=.001,_=n*u+u;n=2-2*u/_,r.s=n}const i={h:.5,s:.001,v:.001};t!=="a"?(Object.keys(r).filter(n=>n!=="a").forEach(n=>{const m=this[n],u=r[n];Math.abs(m-u)>i[n]&&(this[n]=u)}),o.getFormat()==="hex8"&&o.getOriginalInput().length>7&&(this.disableAlpha?Object.assign(this.$data,{h:0,s:0,v:0}):(this.a=r.a,this.textInputsFreeze.a=Number(this.a.toFixed(2))))):this.a=r.a},textInputFocusHandler(s){this.textInputActive||(this.textInputsFreeze={...this.textInputs},this.colorSnapshot=this.color.toRgbString()),this.textInputActive=s.target.dataset.component},textInputBlurHandler(s){setTimeout(()=>{this.textInputActive===s.target.dataset.component&&(this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a}),this.textInputsFreeze={},this.textInputActive=null)},0)},textInputFormatChange(s){const t=["rgb","name","hsl"];this.textInputsFormat;let o=t.indexOf(this.textInputsFormat)+s;o<0?o=t.length-1:o===t.length&&(o=0),this.textInputsFormat=t[o]},getCanvasRects(){this.saturationCanvasRect=this.$refs.saturationCanvas.getBoundingClientRect(),this.hueCanvasRect=this.$refs.hueCanvas.getBoundingClientRect(),this.alphaCanvasRect=this.disableAlpha?{}:this.$refs.alphaCanvas.getBoundingClientRect()},init(){const s=this.$refs.pickerRoot,t=window.getComputedStyle(s);Object.assign(this.$data,this.color.toHsv()),window.requestAnimationFrame(()=>{const{width:r,height:i}=s.getBoundingClientRect();this.pickerHeight=i,this.pickerWidth=r,this.getCanvasRects(),this.hueTranslateX=this.h*this.hueCanvasRect.width/360,this.alphaTranslateX=this.a*this.alphaCanvasRect.width,this.saturationTranslateX=this.s*this.saturationCanvasRect.width,this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,this.sliderPointerWidth=this.$refs.huePointer.offsetWidth,this.saturationPointerWidth=this.$refs.saturationPointer.offsetWidth,this.saturationPointerHeight=this.$refs.saturationPointer.offsetHeight,window.requestAnimationFrame(()=>{this.$emit("ready")})});const o=t.getPropertyValue("background-color");this.tinycolor(o).isDark()&&(this.arrowColor="#fbfbfb")},fillCanvas(){let s=this.$refs.hueCanvas,t=s.getContext("2d"),o=t.createLinearGradient(s.width,0,0,0);o.addColorStop(0,"hsl(0,100%,50%)"),o.addColorStop(.17,"hsl(298.8, 100%, 50%)"),o.addColorStop(.33,"hsl(241.2, 100%, 50%)"),o.addColorStop(.5,"hsl(180, 100%, 50%)"),o.addColorStop(.67,"hsl(118.8, 100%, 50%)"),o.addColorStop(.83,"hsl(61.2,100%,50%)"),o.addColorStop(1,"hsl(360,100%,50%)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),s=this.$refs.saturationCanvas,t=s.getContext("2d"),o=t.createLinearGradient(0,0,s.width,0),o.addColorStop(0,"rgba(250,250,250,1)"),o.addColorStop(1,"rgba(250,250,250,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),o=t.createLinearGradient(0,s.height,0,0),o.addColorStop(0,"rgba(0,0,0,1)"),o.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height)}},watch:{h(s,t){this.hueTranslateX=this.h*this.hueCanvasRect.width/360,t!==void 0&&(this.emitUpdate(),this.emitHook("hueInput",{h:this.h}))},s(s,t){this.saturationTranslateX=this.s*this.saturationCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},v(s,t){this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},a(s,t){this.alphaTranslateX=this.a*this.alphaCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("alphaInput",{a:this.a}))}},mounted(){this.getCanvasRects(),this.fillCanvas()},beforeUnmount(){}};const Br={class:"slider-canvas",ref:"saturationCanvas"},zr={class:"slider-container"},Gr={class:"slider-canvas",ref:"hueCanvas"},Jr={class:"slider-active-area"},Zr={class:"slider-container transparency-pattern"},Qr={class:"slider-active-area"},Kr={class:"text-inputs-wrapper"},$r=["for"],tc=["value","id","data-component"];function ec(s,t,o,r,i,n){return c(),d("div",{ref:"pickerRoot",style:C([n.pickerPosition])},[e("div",{class:"saturation-area",style:C(n.pureHueBackground),onPointerdown:t[0]||(t[0]=(...m)=>n.saturationPickStart&&n.saturationPickStart(...m))},[e("canvas",Br,null,512),e("div",{class:"saturation-pointer",ref:"saturationPointer",style:C([n.saturationPointerStyles,{background:n.hexString}])},null,4)],36),e("div",{class:"slider",onPointerdown:t[1]||(t[1]=(...m)=>n.huePickStart&&n.huePickStart(...m))},[e("div",zr,[e("canvas",Gr,null,512)]),e("div",Jr,[e("div",{class:"slider-pointer",ref:"huePointer",style:C([n.huePointerStyles,n.pureHueBackground])},null,4)])],32),o.disableAlpha?b("",!0):(c(),d("div",{key:0,class:"slider",onPointerdown:t[2]||(t[2]=(...m)=>n.alphaPickStart&&n.alphaPickStart(...m))},[e("div",Zr,[e("div",{class:"slider-canvas",ref:"alphaCanvas",style:C(n.alphaCanvasStyles)},null,4)]),e("div",Qr,[e("div",{class:"slider-pointer",ref:"alphaPointer",style:C(n.alphaPointerStyles)},[e("div",{class:"pointer-transparent",style:C(n.alphaPointerTransparentStyles)},[e("div",{class:"pointer-color",style:C([n.alphaPointerColorStyles,{background:n.hexString}])},null,4)],4)],4)])],32)),o.disableTextInputs?b("",!0):(c(),d("div",{key:1,class:"text-inputs-area",style:C({"--outline-color":n.hexString})},[e("div",Kr,[(c(!0),d(T,null,S(i.textInputActive?i.textInputsFreeze:n.textInputs,(m,u)=>(c(),d("div",{key:"text-input-"+u,class:"text-input-container"},[e("label",{for:"text-input-"+u},l(u),9,$r),e("input",{value:m,class:"text-input",autocomplete:"off",spellcheck:"false",id:"text-input-"+u,"data-component":u,onInput:t[3]||(t[3]=k((..._)=>n.textInputInputHandler&&n.textInputInputHandler(..._),["prevent"])),onFocus:t[4]||(t[4]=(..._)=>n.textInputFocusHandler&&n.textInputFocusHandler(..._)),onBlur:t[5]||(t[5]=(..._)=>n.textInputBlurHandler&&n.textInputBlurHandler(..._)),onKeypress:t[6]||(t[6]=nt(_=>_.target.blur(),["enter"]))},null,40,tc)]))),128))]),e("div",{class:"text-format-arrows",style:C(n.arrowsStyles)},[e("div",{class:"arrow up",onClick:t[7]||(t[7]=m=>n.textInputFormatChange(-1))}),e("div",{class:"arrow down",onClick:t[8]||(t[8]=m=>n.textInputFormatChange(1))})],4)],4))],4)}function Q(s,t){t===void 0&&(t={});var o=t.insertAt;if(!(!s||typeof document=="undefined")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",o==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}}var sc=`.color-input .pointer-transparent, .color-input .pointer-color, .color-input .slider-canvas, .color-input .slider-container {
     1import{_ as tt,d as I,o as c,c as d,n as v,a as e,t as l,g as b,e as x,p as G,m as g,w as k,i as p,v as f,G as C,F as T,r as S,j as V,y as et,T as st,Z as nt,J as it,f as ot,h as at}from"./plugin-vue_export-helper.min.js";import{C as lt,R as rt}from"./RemoveAlert.min.js";import{v as ct}from"./vue3-editor.common.min.js";const dt={name:"Settings",components:{Card:lt,VueEditor:ct.exports.VueEditor,RemoveModal:rt},data(){return{loading:!1,selectedTab:1,form:{company_name:"",company_address:"",postal_code:"",city:"",country:"",company_email:"",company_phone:"",mobile_phone:"",fax:"",logo_mentions_active:"",logo_url:"",logo_path:"",default_currency:"",currency_position:"",vat_active:"",default_vat:"",date_format:"",logo_width:"",logo_mentions:"",invoice_color:"",invoice_prefix:"",show_phone:"",show_email:"",show_siren:"",show_tax_number:"",show_watermark:"",show_watermark_only_paid:"",invoice_footer:"",invoice_terms:"",credit_color:"",credit_prefix:"",credit_footer:"",credit_terms:"",quote_color:"",quote_prefix:"",quote_footer:"",quote_terms:"",easy_compta_planning_addon_active:"",easy_compta_email_addon_active:"",easy_compta_payment_addon_active:"",easy_compta_signature_addon_active:"",easy_compta_stats_addon_active:"",easy_compta_qrcode_addon_active:"",easy_compta_stripe_secret_api:"",email_quote_subject:"",email_invoice_subject:"",remind_invoice_subject:"",remind_invoice_content:"",email_quote_content:"",email_invoice_content:"",email_create_account_subject:"",email_create_account_content:"",easycompta_siret_token_api:""},articles:[],categories:[],currencies:[],vats:[],expenses:[],planning:[],payments:[],logoPreviewUrl:"",previewWidth:"",showArticleModal:!1,showCurrencyModal:!1,showVATModal:!1,showPaymentModal:!1,showExpenseModal:!1,showPlanningModal:!1,currencyForm:{id:null,name:"",symbol:""},articleForm:{id:null,ref:"",name:"",description:"",unit_price:""},vatForm:{id:null,description:"",rate:""},paymentForm:{id:null,method_name:""},expenseForm:{id:null,name:""},planningForm:{id:null,name:"",background:"",color:""},showRemoveModal:!1,deleteType:null,selectedId:null,editingArticle:!1,editingCurrency:!1,editingVAT:!1,editingExpense:!1,editingPayment:!1,editingPlanning:!1,activeTabEmail:"tab1",activeTabUsers:"user1",license_key:"",loadingLicense:!1,licenseData:null,installed_versions:{},updatesAvailable:{},errorMessage:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"],["html"]]}},methods:{setActiveTab(s){this.activeTabEmail=s},setActiveTabUsers(s){this.activeTabUsers=s},selectTab(s){this.selectedTab=s,window.location.hash=`tab${s}`},checkHash(){const s=window.location.hash;if(s){const t=parseInt(s.replace("#tab",""));isNaN(t)||(this.selectedTab=t)}},tabClass(s){return this.selectedTab===s?"tab tab-active":"tab"},async fetchSettings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,s.ok){const t=await s.json();this.form={...this.form,...t},this.logoPreviewUrl=t.logo_url||"",this.form.easy_compta_planning_addon_active==1&&this.fetchPlanningCat()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async handleSubmit(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/save",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.form)});if(this.loading=!1,s.ok){const t=await s.json();this.showToast(t,"alert-success")}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async fetchArticles(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/articles",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.articles=t.articles,this.categories=t.categories}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchCurrencies(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/currencies",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.currencies=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchVATs(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/vats",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.vats=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPaymentsMethods(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/payments-methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.payments=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchExpensesCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/expenses-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.expenses=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPlanningCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/planning-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.planning=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async handleLogoUpload(s){const t=s.target.files[0];if(t){const o=new FormData;o.append("logo",t);try{const r=await fetch("/wp-json/my-easy-compta/v1/settings/upload-logo",{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce},body:o});if(r.ok){const i=await r.json();this.form.logo_url=i.url,this.form.logo_path=i.path,this.logoPreviewUrl=i.url,this.showToast("Logo uploaded successfully","alert-success")}else{const i=await r.json();this.showToast(i.message,"alert-error")}}catch(r){this.showToast(r.message,"alert-error")}}},async addArticle(){this.articleForm={id:null,ref:"",name:"",description:"",price:""},this.editingArticle=!1,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async addCurrency(){this.currencyForm={id:null,name:"",symbol:""},this.editingCurrency=!1,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteArticle(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/articles/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.articles=this.articles.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async deleteCategory(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/category/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.categories=this.categories.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async editArticle(s){const t=this.articles.find(o=>o.id===s);this.articleForm={...t},this.editingArticle=!0,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async editCurrency(s){const t=this.currencies.find(o=>o.id===s);this.currencyForm={...t},this.editingCurrency=!0,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteCurrency(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/currencies/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.currencies=this.currencies.filter(o=>o.id!==s),this.showToast("Currency deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveArticle(){const s=this.editingArticle?"PUT":"POST",t=this.editingArticle?`/wp-json/my-easy-compta/v1/settings/articles/${this.articleForm.id}`:"/wp-json/my-easy-compta/v1/settings/articles";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.articleForm)});if(o.ok){const r=await o.json();if(this.editingArticle){const i=this.articles.findIndex(n=>n.id===r.id);this.articles[i]=r}else this.articles.push(r);this.showToast(`Article ${this.editingArticle?"updated":"added"} successfully`,"alert-success"),this.closeArticleModal(),this.fetchArticles()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async saveCurrency(){const s=this.editingCurrency?"PUT":"POST",t=this.editingCurrency?`/wp-json/my-easy-compta/v1/settings/currencies/${this.currencyForm.id}`:"/wp-json/my-easy-compta/v1/settings/currencies";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.currencyForm)});if(o.ok){const r=await o.json();if(this.editingCurrency){const i=this.currencies.findIndex(n=>n.id===r.id);this.currencies[i]=r}else this.currencies.push(r);this.showToast(`Currency ${this.editingCurrency?"updated":"added"} successfully`,"alert-success"),this.closeCurrencyModal(),this.fetchCurrencies()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addVAT(){this.vatForm={id:null,description:"",rate:""},this.editingVAT=!1,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async editVAT(s){const t=this.vats.find(o=>o.id===s);this.vatForm={...t},this.editingVAT=!0,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async deleteVAT(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/vats/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.vats=this.vats.filter(o=>o.id!==s),this.showToast("VAT deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveVAT(){const s=this.editingVAT?"PUT":"POST",t=this.editingVAT?`/wp-json/my-easy-compta/v1/settings/vats/${this.vatForm.id}`:"/wp-json/my-easy-compta/v1/settings/vats";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.vatForm)});if(o.ok){const r=await o.json();if(this.editingVAT){const i=this.vats.findIndex(n=>n.id===r.id);this.vats[i]=r}else this.vats.push(r);this.showToast(`VAT ${this.editingVAT?"updated":"added"} successfully`,"alert-success"),this.closeVATModal(),this.fetchVATs()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPayment(){this.paymentForm={id:null,method_name:""},this.editingPayment=!1,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async editPayment(s){const t=this.payments.find(o=>o.id===s);this.paymentForm={...t},this.editingPayment=!0,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async deletePayment(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/payments-methods/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.payments=this.payments.filter(o=>o.id!==s),this.showToast("Payment method deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePayment(){const s=this.editingPayment?"PUT":"POST",t=this.editingPayment?`/wp-json/my-easy-compta/v1/settings/payments-methods/${this.paymentForm.id}`:"/wp-json/my-easy-compta/v1/settings/payments-methods";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.paymentForm)});if(o.ok){const r=await o.json();if(this.editingPayment){const i=this.payments.findIndex(n=>n.id===r.id);this.payments[i]=r}else this.payments.push(r);this.showToast(`Payment method ${this.editingPayment?"updated":"added"} successfully`,"alert-success"),this.closePaymentModal(),this.fetchPaymentsMethods()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addExpCat(){this.expenseForm={id:null,name:""},this.editingExpense=!1,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async editExpCat(s){const t=this.expenses.find(o=>o.id===s);this.expenseForm={...t},this.editingExpense=!0,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async deleteExpCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/expenses-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.expenses=this.expenses.filter(o=>o.id!==s),this.showToast("Expense category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveExpCat(){const s=this.editingExpense?"PUT":"POST",t=this.editingExpense?`/wp-json/my-easy-compta/v1/settings/expenses-categories/${this.expenseForm.id}`:"/wp-json/my-easy-compta/v1/settings/expenses-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.expenseForm)});if(o.ok){const r=await o.json();if(this.editingExpense){const i=this.expenses.findIndex(n=>n.id===r.id);this.expenses[i]=r}else this.expenses.push(r);this.showToast(`Expense category ${this.editingExpense?"updated":"added"} successfully`,"alert-success"),this.closeExpenseModal(),this.fetchExpensesCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPlanningCat(){this.planningForm={id:null,name:""},this.editingPlanning=!1,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async editPlanningCat(s){const t=this.planning.find(o=>o.id===s);this.planningForm={...t},this.editingPlanning=!0,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async deletePlanningCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/planning-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.planning=this.planning.filter(o=>o.id!==s),this.showToast("Planning category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePlanningCat(){this.loading=!0;const s=this.editingPlanning?"PUT":"POST",t=this.editingPlanning?`/wp-json/my-easy-compta/v1/settings/planning-categories/${this.planningForm.id}`:"/wp-json/my-easy-compta/v1/settings/planning-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.planningForm)});if(o.ok){const r=await o.json();if(this.editingPlanning){const i=this.planning.findIndex(n=>n.id===r.id);this.planning[i]=r,this.loading=!1}else this.planning.push(r),this.loading=!1;this.showToast(`Planning category ${this.editingPlanning?"updated":"added"} successfully`,"alert-success"),this.closePlanningModal(),this.fetchPlanningCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},closeCurrencyModal(){this.showCurrencyModal=!1},closeArticleModal(){this.showArticleModal=!1},closeVATModal(){this.showVATModal=!1},closePaymentModal(){this.showPaymentModal=!1},closeExpenseModal(){this.showExpenseModal=!1},closePlanningModal(){this.showPlanningModal=!1},updatePreviewWidth(){this.previewWidth=this.form.logo_width+"px"},updateVatActive(s){this.form.vat_active=s.target.checked?1:0},updateLogoMentionsActive(s){this.form.logo_mentions_active=s.target.checked?1:0},updateEmailLogsActive(s){this.form.email_log_active=s.target.checked?1:0},updateFormField(s,t){this.form[t]=s.target.checked?1:0},showToast(s,t){this.toast.message=s,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},handleDeletion(s,t){const o=this.getDeletionFunction(s);o?o(t):this.showToast("error","alert-error")},delete_item(s,t){this.deleteType=s,this.selectedId=t,modal_remove.showModal(),this.showRemoveModal=!0},getDeletionFunction(s){switch(s){case"licence":return this.confirmLicense;case"vat":return this.deleteVAT;case"currency":return this.deleteCurrency;case"expense":return this.deleteExpCat;case"payment":return this.deletePayment;case"planning":return this.deletePlanningCat;case"article":return this.deleteArticle;case"category_article":return this.deleteCategory;default:return null}},async checkLicense(){this.loading=!0,this.loadingLicense=!0,this.errorMessage="",this.licenseData=null;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/validate-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key})})).json();t.valid?(this.licenseData=t,await this.storeLicense(t),location.reload()):this.errorMessage=t.message}catch{this.errorMessage="An error occurred while validating the license."}finally{this.loadingLicense=!1}},async refresh_licence(){this.loading=!0;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/refresh-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();t.valid?location.reload():this.errorMessage=t.message}catch{this.errorMessage="An error occurred while refreshing the license."}},async storeLicense(s){try{await fetch("/wp-json/my-easy-compta/v1/license/store-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key,license_data:s})})}catch{this.errorMessage="An error occurred while storing the license.",this.loading=!1}},async loadLicenseDetails(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/check-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();t.valid&&(this.licenseData=t.license_data,this.installed_versions=t.installed_versions,this.license_key="****-****-****-****-****"+this.license_key.substr(this.license_key.length-4),this.loading=!1)}else console.error("Failed to load license details"),this.loading=!1}catch(s){console.error("Error loading license details",s),this.loading=!1}},async confirmLicense(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/delete-license",{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.showToast(t.message,"alert-success"),this.licenseData="",this.license_key="",location.reload()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async checkUpdatePlugin(s,t){try{const r=await(await fetch("/wp-json/my-easy-compta/v1/license/check-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s,current_version:t})})).json();r.success?r.update_available?(this.showToast(this.translations.update_available+" "+r.new_version,"alert-success"),this.updatesAvailable[s]=r.update_available):this.showToast(this.translations.no_update_available,"alert-error"):this.showToast(this.translations.failed_update_available,"alert-error")}catch(o){console.error("Error checking for plugin update:",o),this.showToast(this.translations.failed_update_available,"alert-error")}},async installUpdatePlugin(s){try{const o=await(await fetch("/wp-json/my-easy-compta/v1/license/download-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s})})).json();if(o.success){this.showToast(this.translations.success,"alert-success");const r=document.createElement("a");r.href=o.download_url,r.setAttribute("download",""),document.body.appendChild(r),r.click(),document.body.removeChild(r)}else this.showToast(this.translations.error,"alert-error")}catch(t){console.error("Error checking for plugin update:",t),this.showToast(this.translations.error,"alert-error")}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},beforeUnmount(){window.removeEventListener("hashchange",this.checkHash)},mounted(){this.checkHash(),window.addEventListener("hashchange",this.checkHash),this.fetchSettings(),this.fetchArticles(),this.fetchCurrencies(),this.fetchVATs(),this.fetchPaymentsMethods(),this.fetchExpensesCat(),this.loadLicenseDetails()}},ut={class:"pt-2 pr-4"},ht={class:"flex justify-between items-center"},pt={class:"card-title"},mt=e("div",{class:"divider mt-2"},null,-1),ft={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"},bt={class:"tabs tabs-vertical tabs-boxed col-span-1"},_t=e("i",{class:"fas fa-home mr-2"},null,-1),gt=e("i",{class:"fas fa-tools mr-2"},null,-1),yt=e("i",{class:"fas fa-newspaper mr-2"},null,-1),vt=e("i",{class:"fas fa-file-invoice-dollar mr-2"},null,-1),wt=e("i",{class:"fas fa-undo mr-2"},null,-1),xt=e("i",{class:"far fa-question-circle mr-2"},null,-1),kt=e("i",{class:"fas fa-dollar-sign mr-2"},null,-1),Ct=e("i",{class:"fas fa-money-check-alt mr-2"},null,-1),Tt=e("i",{class:"fas fa-shopping-basket mr-2"},null,-1),Mt=e("i",{class:"fas fa-calendar-alt mr-2"},null,-1),At=e("i",{class:"far fa-envelope mr-2"},null,-1),St=e("i",{class:"fas fa-user mr-2"},null,-1),Pt=e("i",{class:"far fa-credit-card mr-2"},null,-1),Et=e("i",{class:"far fa-chart-bar mr-2"},null,-1),jt=e("i",{class:"fas fa-qrcode mr-2"},null,-1),Vt=e("i",{class:"far fa-id-badge mr-2"},null,-1),It={class:"col-span-3 p-4 bg-base-300 rounded-lg shadow-md content-tabs"},Ft={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Rt=e("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Ut=[Rt],Dt={key:1},Ht={class:"text-xl font-semibold mb-4"},Nt={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Yt={class:"ecwp-group form-control"},qt={class:"ecwp-label label",for:"company-code"},Lt={class:"ecwp-group form-control"},Ot={class:"ecwp-label label",for:"tax-number"},Xt={class:"ecwp-group form-control"},Wt={class:"ecwp-label label",for:"company-name"},Bt={class:"ecwp-group form-control"},zt={class:"ecwp-label label",for:"company-address"},Gt={class:"ecwp-group form-control"},Jt={class:"ecwp-label label",for:"postal-code"},Zt={class:"ecwp-group form-control"},Kt={class:"ecwp-label label",for:"city"},Qt={class:"ecwp-group form-control"},$t={class:"ecwp-label label",for:"country"},te={class:"ecwp-group form-control"},ee={class:"ecwp-label label",for:"company-email"},se={class:"ecwp-group form-control"},ne={class:"ecwp-label label",for:"company-phone"},ie={class:"ecwp-group form-control"},oe={class:"ecwp-label label",for:"mobile-phone"},ae={class:"ecwp-group form-control"},le={class:"ecwp-label label",for:"fax"},re=e("div",{class:"divider my-4"},null,-1),ce={key:0},de={class:"grid grid-cols-2 gap-4"},ue={class:"ecwp-group form-control indicator"},he={class:"ecwp-label label",for:"company-code"},pe=e("span",{class:"indicator-item badge mt-5 border-blue-700"},[e("a",{href:"https://api.gouv.fr/les-api/sirene_v3",target:"_blank"},"?")],-1),me={class:"mt-6 flex justify-end"},fe={type:"submit",class:"btn btn-primary rounded-full"},be=e("i",{class:"far fa-save"},null,-1),_e={key:2},ge={class:"text-xl font-semibold mb-4"},ye={class:"form-control mt-4 mb-1"},ve={class:"cursor-pointer"},we={class:"label-text mr-2 font-bold"},xe=["checked"],ke={key:0,class:"ecwp-group form-control"},Ce={class:"ecwp-label label",for:"logo-mentions"},Te={class:"ecwp-group form-control"},Me={class:"label"},Ae={class:"ecwp-file"},Se={for:"file_logo"},Pe=e("i",{class:"fas fa-cloud-upload-alt mr-2"},null,-1),Ee={key:0,class:"max-w-md"},je={class:"py-2 font-bold"},Ve={key:0},Ie=["src"],Fe={class:"ecwp-group form-control"},Re={class:"ecwp-label label"},Ue=["value"],De={class:"ecwp-group form-control"},He={class:"ecwp-label label"},Ne={value:"before"},Ye={value:"after"},qe={class:"form-control mt-4 mb-1"},Le={class:"cursor-pointer"},Oe={class:"label-text mr-2 font-bold"},Xe=["checked"],We={key:1,class:"ecwp-group form-control"},Be={class:"ecwp-label label"},ze=e("option",{value:"0"},null,-1),Ge=["value"],Je={class:"ecwp-group form-control mt-2"},Ze={class:"ecwp-label label"},Ke=e("option",{value:"DD-MM-YYYY",selected:"selected"}," DD-MM-YYYY ",-1),Qe=e("option",{value:"MM-DD-YYYY"},"MM-DD-YYYY",-1),$e=e("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD",-1),ts=e("option",{value:"YYYY/MM/DD"},"YYYY/MM/DD",-1),es=e("option",{value:"DD/MM/YYYY"},"DD/MM/YYYY",-1),ss=e("option",{value:"MM/DD/YYYY"},"MM/DD/YYYY",-1),ns=e("option",{value:"YYYY.MM.DD"},"YYYY.MM.DD",-1),is=e("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY",-1),os=e("option",{value:"MM.DD.YYYY"},"MM.DD.YYYY",-1),as=[Ke,Qe,$e,ts,es,ss,ns,is,os],ls={class:"mt-6 flex justify-end"},rs={type:"submit",class:"btn btn-primary rounded-full"},cs=e("i",{class:"far fa-save"},null,-1),ds={key:3},us={key:0,id:"modal_article",class:"modal"},hs={class:"modal-box"},ps={class:"ecwp-group form-control"},ms={class:"ecwp-label label",for:"name_ref"},fs={class:"ecwp-group form-control"},bs={class:"ecwp-label label",for:"name_article"},_s={class:"ecwp-group form-control"},gs={class:"ecwp-label label",for:"desc_article"},ys={class:"ecwp-group form-control"},vs={class:"ecwp-label label",for:"price_article"},ws={class:"form-group mt-4 flex justify-end"},xs={type:"submit",class:"btn btn-primary rounded-full mx-2"},ks={class:"flex justify-between items-center mb-4"},Cs={class:"text-lg font-semibold"},Ts=e("i",{class:"fas fa-plus mr-2"},null,-1),Ms={class:"table-container"},As={class:"table w-full"},Ss=["onClick"],Ps=e("i",{class:"fas fa-edit"},null,-1),Es=[Ps],js=["onClick"],Vs=e("i",{class:"fas fa-trash"},null,-1),Is=[Vs],Fs=e("div",{class:"divider mt-2 mb-4"},null,-1),Rs={class:"text-xl font-semibold mb-4"},Us={class:"table-container"},Ds={class:"table w-full"},Hs=["onClick"],Ns=e("i",{class:"fas fa-trash"},null,-1),Ys=[Ns],qs={key:4},Ls={class:"text-xl font-semibold mb-4"},Os={class:"grid grid-cols-2 gap-4"},Xs={class:"ecwp-group form-control"},Ws={class:"ecwp-label label",for:"invoice-color"},Bs={class:"ecwp-group form-control"},zs={class:"ecwp-label label",for:"invoice-prefix"},Gs=e("div",{class:"divider my-4"},null,-1),Js={class:"grid grid-cols-2 gap-4"},Zs={class:"form-control mt-4 mb-1"},Ks={class:"cursor-pointer"},Qs=["checked"],$s={class:"label-text mr-2 font-bold"},tn={class:"form-control mt-4 mb-1"},en={class:"cursor-pointer"},sn=["checked"],nn={class:"label-text mr-2 font-bold"},on={class:"form-control mt-4 mb-1"},an={class:"cursor-pointer"},ln=["checked"],rn={class:"label-text mr-2 font-bold"},cn={class:"form-control mt-4 mb-1"},dn={class:"cursor-pointer"},un=["checked"],hn={class:"label-text mr-2 font-bold"},pn={class:"form-control mt-4 mb-1"},mn={class:"cursor-pointer"},fn=["checked"],bn={class:"label-text mr-2 font-bold"},_n={key:0,class:"form-control mt-4 mb-1"},gn={class:"cursor-pointer"},yn=["checked"],vn={class:"label-text mr-2 font-bold"},wn=e("div",{class:"divider my-4"},null,-1),xn={class:"grid grid-cols-2 gap-4"},kn={class:"ecwp-group form-control"},Cn={class:"ecwp-label label",for:"conditions-payment"},Tn={class:"ecwp-group form-control"},Mn={class:"ecwp-label label",for:"mode-payment"},An={class:"grid grid-cols-1 gap-4"},Sn={class:"form-control"},Pn={class:"ecwp-label label",for:"invoice-prefix"},En={class:"grid grid-cols-2 gap-4"},jn={class:"ecwp-group form-control"},Vn={class:"ecwp-label label",for:"invoice-iban"},In={class:"ecwp-group form-control"},Fn={class:"ecwp-label label",for:"invoice-bic"},Rn={class:"form-control"},Un={class:"ecwp-label label",for:"invoice-prefix"},Dn={class:"mt-6 flex justify-end"},Hn={type:"submit",class:"btn btn-primary rounded-full"},Nn=e("i",{class:"far fa-save"},null,-1),Yn={key:5},qn={class:"text-xl font-semibold mb-4"},Ln={class:"grid grid-cols-2 gap-4"},On={class:"ecwp-group form-control"},Xn={class:"ecwp-label label",for:"credit-color"},Wn={class:"ecwp-group form-control"},Bn={class:"ecwp-label label",for:"credit-prefix"},zn={class:"grid grid-cols-1 gap-4"},Gn={class:"form-control"},Jn={class:"ecwp-label label",for:"credit-prefix"},Zn={class:"form-control"},Kn={class:"ecwp-label label",for:"credit-prefix"},Qn={class:"mt-6 flex justify-end"},$n={type:"submit",class:"btn btn-primary rounded-full"},ti=e("i",{class:"far fa-save"},null,-1),ei={key:6},si={class:"text-xl font-semibold mb-4"},ni={class:"grid grid-cols-2 gap-4"},ii={class:"ecwp-group form-control"},oi={class:"ecwp-label label",for:"quote-color"},ai={class:"ecwp-group form-control"},li={class:"ecwp-label label",for:"quote-prefix"},ri={class:"grid grid-cols-1 gap-4"},ci={class:"form-control"},di={class:"ecwp-label label",for:"quote-prefix"},ui={class:"form-control"},hi={class:"ecwp-label label",for:"quote-prefix"},pi={class:"mt-6 flex justify-end"},mi={type:"submit",class:"btn btn-primary rounded-full"},fi=e("i",{class:"far fa-save"},null,-1),bi={key:7},_i={class:"text-xl font-semibold mb-4"},gi={key:0,id:"modal_currency",class:"modal"},yi={class:"modal-box"},vi={class:"ecwp-group form-control"},wi={class:"ecwp-label label",for:"name_currency"},xi={class:"ecwp-group form-control"},ki={class:"ecwp-label label",for:"symbol_currency"},Ci={class:"ecwp-group form-control"},Ti={class:"ecwp-label label",for:"code_currency"},Mi={class:"form-group mt-4 flex justify-end"},Ai={type:"submit",class:"btn btn-primary rounded-full mx-2"},Si={class:"mb-8"},Pi={class:"flex justify-between items-center mb-4"},Ei={class:"text-lg font-semibold"},ji=e("i",{class:"fas fa-plus mr-2"},null,-1),Vi={class:"table-container"},Ii={class:"table w-full"},Fi=["onClick"],Ri=e("i",{class:"fas fa-edit"},null,-1),Ui=[Ri],Di=["onClick"],Hi=e("i",{class:"fas fa-trash"},null,-1),Ni=[Hi],Yi={key:0,id:"modal_vat",class:"modal"},qi={class:"modal-box"},Li={class:"ecwp-group form-control"},Oi={class:"ecwp-label label",for:"vat-description"},Xi={class:"ecwp-group form-control"},Wi={class:"ecwp-label label",for:"vat-rate"},Bi={class:"form-group mt-4 flex justify-end"},zi={type:"submit",class:"btn btn-primary rounded-full mx-2"},Gi={class:"flex justify-between items-center mb-4"},Ji={class:"text-lg font-semibold"},Zi=e("i",{class:"fas fa-plus mr-2"},null,-1),Ki={class:"table-container"},Qi={class:"table w-full"},$i=["onClick"],to=e("i",{class:"fas fa-edit"},null,-1),eo=[to],so=["onClick"],no=e("i",{class:"fas fa-trash"},null,-1),io=[no],oo={key:8},ao={class:"text-xl font-semibold mb-4"},lo={key:0,id:"modal_payments",class:"modal"},ro={class:"modal-box"},co={class:"ecwp-group form-control"},uo={class:"ecwp-label label",for:"name_payment"},ho={class:"form-group mt-4 flex justify-end"},po={type:"submit",class:"btn btn-primary rounded-full mx-2"},mo={class:"mb-8"},fo={class:"flex justify-between items-center mb-4"},bo={class:"text-lg font-semibold"},_o=e("i",{class:"fas fa-plus mr-2"},null,-1),go={class:"table-container"},yo={class:"table w-full"},vo=["onClick"],wo=e("i",{class:"fas fa-edit"},null,-1),xo=[wo],ko=["onClick"],Co=e("i",{class:"fas fa-trash"},null,-1),To=[Co],Mo={key:9},Ao={class:"text-xl font-semibold mb-4"},So={key:0,id:"modal_expenses",class:"modal"},Po={class:"modal-box"},Eo={class:"ecwp-group form-control"},jo={class:"ecwp-label label",for:"name_expense"},Vo={class:"form-group mt-4 flex justify-end"},Io={type:"submit",class:"btn btn-primary rounded-full mx-2"},Fo={class:"mb-8"},Ro={class:"flex justify-between items-center mb-4"},Uo={class:"text-lg font-semibold"},Do=e("i",{class:"fas fa-plus mr-2"},null,-1),Ho={class:"table-container"},No={class:"table w-full"},Yo=["onClick"],qo=e("i",{class:"fas fa-edit"},null,-1),Lo=[qo],Oo=["onClick"],Xo=e("i",{class:"fas fa-trash"},null,-1),Wo=[Xo],Bo={key:10},zo={class:"text-xl font-semibold mb-4"},Go={key:0,id:"modal_planning",class:"modal"},Jo={class:"modal-box"},Zo={class:"ecwp-group form-control"},Ko={class:"ecwp-label label",for:"name_planning"},Qo={class:"ecwp-group form-control"},$o={class:"ecwp-label label",for:"background_planning"},ta={class:"ecwp-group form-control"},ea={class:"ecwp-label label",for:"color_planning"},sa={class:"form-group mt-4 flex justify-end"},na=["disabled"],ia={key:0,class:"loading loading-spinner loading-sm"},oa={class:"mb-8"},aa={class:"flex justify-between items-center mb-4"},la={class:"text-lg font-semibold"},ra=e("i",{class:"fas fa-plus mr-2"},null,-1),ca={class:"table-container"},da={class:"table w-full"},ua=["onClick"],ha=e("i",{class:"fas fa-edit"},null,-1),pa=[ha],ma=["onClick"],fa=e("i",{class:"fas fa-trash"},null,-1),ba=[fa],_a={key:11},ga={class:"text-xl font-semibold mb-4"},ya={class:"form-control mt-4 mb-4"},va={class:"cursor-pointer"},wa={class:"label-text mr-2 font-bold"},xa=["checked"],ka=e("div",{class:"divider mt-2 mb-4"},null,-1),Ca={role:"tablist",class:"tabs tabs-boxed"},Ta={key:0,class:"p-4"},Ma={class:"grid grid-cols-1 gap-4"},Aa={class:"ecwp-group form-control"},Sa={class:"ecwp-label label",for:"email_invoice_subject"},Pa={class:"form-control"},Ea={class:"ecwp-label label"},ja=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),Va={key:1,class:"p-4"},Ia={class:"grid grid-cols-1 gap-4"},Fa={class:"ecwp-group form-control"},Ra={class:"ecwp-label label",for:"email_quote_subject"},Ua={class:"form-control"},Da={class:"ecwp-label label"},Ha=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")]),e("pre",null,[e("b",null,"{CREATED_DATE}")]),e("pre",null,[e("b",null,"{DUE_DATE}")])],-1),Na={key:2,class:"p-4"},Ya={class:"grid grid-cols-1 gap-4"},qa={class:"ecwp-group form-control"},La={class:"ecwp-label label",for:"remind_invoice_subject"},Oa={class:"form-control"},Xa={class:"ecwp-label label"},Wa=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),Ba={key:3,class:"p-4"},za={role:"alert",class:"alert shadow"},Ga=e("i",{class:"fas fa-exclamation-circle"},null,-1),Ja={class:"text-xl text-center my-4"},Za={class:"mt-6 flex justify-end"},Ka={type:"submit",class:"btn btn-primary rounded-full"},Qa=e("i",{class:"far fa-save"},null,-1),$a={key:12},tl={class:"text-xl font-semibold mb-4"},el={role:"tablist",class:"tabs tabs-boxed"},sl={key:0,class:"p-4"},nl={class:"grid grid-cols-1 gap-4"},il={class:"ecwp-group form-control"},ol={class:"ecwp-label label",for:"email_create_account_subject"},al={class:"form-control"},ll={class:"ecwp-label label"},rl=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{USERNAME}")]),e("pre",null,[e("b",null,"{PASSWORD}")])],-1),cl={class:"mt-6 flex justify-end"},dl={type:"submit",class:"btn btn-primary rounded-full"},ul=e("i",{class:"far fa-save"},null,-1),hl={key:1,class:"p-4"},pl={role:"alert",class:"alert shadow"},ml=e("i",{class:"fas fa-exclamation-circle"},null,-1),fl={class:"text-xl text-center my-4"},bl={key:13},_l={class:"text-xl font-semibold mb-4"},gl={class:"grid grid-cols-1 gap-4"},yl={class:"ecwp-group form-control"},vl={class:"ecwp-label label",for:"stripe-mode"},wl={value:"test"},xl={value:"live"},kl={key:0},Cl={class:"ecwp-group form-control"},Tl={class:"ecwp-label label",for:"stripe-public-key-test"},Ml={class:"ecwp-group form-control"},Al={class:"ecwp-label label",for:"stripe-secret-key-test"},Sl={key:1},Pl={class:"ecwp-group form-control"},El={class:"ecwp-label label",for:"stripe-public-key-live"},jl={class:"ecwp-group form-control"},Vl={class:"ecwp-label label",for:"stripe-secret-key-live"},Il={class:"mt-6 flex justify-end"},Fl={type:"submit",class:"btn btn-primary rounded-full"},Rl=e("i",{class:"far fa-save"},null,-1),Ul={key:14},Dl={class:"text-xl font-semibold mb-4"},Hl={class:"grid grid-cols-1 gap-4"},Nl={class:"ecwp-group form-control mt-2"},Yl={class:"ecwp-label label",for:"limit-declaration"},ql={class:"ecwp-group form-control mt-2"},Ll={class:"ecwp-label label",for:"limit-tva"},Ol={class:"mt-6 flex justify-end"},Xl={type:"submit",class:"btn btn-primary rounded-full"},Wl=e("i",{class:"far fa-save"},null,-1),Bl={key:15},zl={class:"text-xl font-semibold mb-4"},Gl={class:"grid grid-cols-1 gap-4"},Jl={class:"ecwp-group form-control mt-2"},Zl={class:"ecwp-label label",for:"stripe-api"},Kl={class:"mt-6 flex justify-end"},Ql={type:"submit",class:"btn btn-primary rounded-full"},$l=e("i",{class:"far fa-save"},null,-1),tr={key:16},er={class:"text-xl font-semibold mb-4"},sr={class:"grid grid-cols-2 gap-4"},nr={class:"ecwp-group form-group relative join"},ir={class:"ecwp-label label",for:"license-code"},or=["disabled"],ar=["disabled"],lr={key:0,class:"loading loading-spinner loading-sm"},rr={key:1},cr={class:"grid grid-cols-1 gap-4"},dr={key:0,class:"error-message"},ur={key:1,class:"overflow-x-auto my-4"},hr={class:"table table-xs table-pin-rows table-pin-cols"},pr=e("i",{class:"fas fa-sync"},null,-1),mr=[pr],fr=e("i",{class:"far fa-trash-alt"},null,-1),br=[fr],_r={class:"table table-xs table-pin-rows table-pin-cols mt-6"},gr=["onClick"],yr=["onClick"],vr=["onClick"];function wr(s,t,o,r,i,n){const m=I("remove-modal"),u=I("color-input"),_=I("vue-editor"),M=I("Card");return c(),d("div",ut,[i.toast.visible?(c(),d("div",{key:0,class:v(["toast",i.toast.position]),style:{zIndex:9999}},[e("div",{class:v(["alert",i.toast.type,"text-white"])},[e("span",null,l(i.toast.message),1)],2)],2)):b("",!0),x(m,{"show-modal":i.showRemoveModal,title:n.translations.are_you_sure,message:n.translations.no_turning_back,confirmText:n.translations.yes_delete_it,cancelText:n.translations.cancel,onConfirm:t[0]||(t[0]=a=>n.handleDeletion(i.deleteType,i.selectedId)),onCancel:t[1]||(t[1]=a=>i.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),x(M,{topMargin:"mt-8"},{default:G(()=>[e("div",ht,[e("h2",pt,l(n.translations.settings),1)]),mt,e("div",ft,[e("div",bt,[e("a",{class:v([n.tabClass(1),"justify-start w-full"]),onClick:t[2]||(t[2]=a=>n.selectTab(1))},[_t,g(" "+l(n.translations.general_settings),1)],2),e("a",{class:v([n.tabClass(2),"justify-start w-full"]),onClick:t[3]||(t[3]=a=>n.selectTab(2))},[gt,g(" "+l(n.translations.system_settings),1)],2),e("a",{class:v([n.tabClass(3),"justify-start w-full"]),onClick:t[4]||(t[4]=a=>n.selectTab(3))},[yt,g(" "+l(n.translations.articles_settings),1)],2),e("a",{class:v([n.tabClass(4),"justify-start w-full"]),onClick:t[5]||(t[5]=a=>n.selectTab(4))},[vt,g(" "+l(n.translations.invoices_settings),1)],2),e("a",{class:v([n.tabClass(5),"justify-start w-full"]),onClick:t[6]||(t[6]=a=>n.selectTab(5))},[wt,g(" "+l(n.translations.credits_settings),1)],2),e("a",{class:v([n.tabClass(6),"justify-start w-full"]),onClick:t[7]||(t[7]=a=>n.selectTab(6))},[xt,g(" "+l(n.translations.quotes_settings),1)],2),e("a",{class:v([n.tabClass(7),"justify-start w-full"]),onClick:t[8]||(t[8]=a=>n.selectTab(7))},[kt,g(" "+l(n.translations.currency_vat_settings),1)],2),e("a",{class:v([n.tabClass(8),"justify-start w-full"]),onClick:t[9]||(t[9]=a=>n.selectTab(8))},[Ct,g(" "+l(n.translations.payments_settings),1)],2),e("a",{class:v([n.tabClass(9),"justify-start w-full"]),onClick:t[10]||(t[10]=a=>n.selectTab(9))},[Tt,g(" "+l(n.translations.expenses_settings),1)],2),i.form.easy_compta_planning_addon_active==1?(c(),d("a",{key:0,class:v([n.tabClass(10),"justify-start w-full"]),onClick:t[11]||(t[11]=a=>n.selectTab(10))},[Mt,g(" "+l(n.translations.planning_settings),1)],2)):b("",!0),i.form.easy_compta_email_addon_active==1?(c(),d("a",{key:1,class:v([n.tabClass(11),"justify-start w-full"]),onClick:t[12]||(t[12]=a=>n.selectTab(11))},[At,g(" "+l(n.translations.email_settings),1)],2)):b("",!0),i.form.easy_compta_user_addon_active==1?(c(),d("a",{key:2,class:v([n.tabClass(12),"justify-start w-full"]),onClick:t[13]||(t[13]=a=>n.selectTab(12))},[St,g(" "+l(n.translations.users_settings),1)],2)):b("",!0),i.form.easy_compta_payment_addon_active==1?(c(),d("a",{key:3,class:v([n.tabClass(13),"justify-start w-full"]),onClick:t[14]||(t[14]=a=>n.selectTab(13))},[Pt,g(" "+l(n.translations.stripe_settings),1)],2)):b("",!0),i.form.easy_compta_stats_addon_active==1?(c(),d("a",{key:4,class:v([n.tabClass(14),"justify-start w-full"]),onClick:t[15]||(t[15]=a=>n.selectTab(14))},[Et,g(" "+l(n.translations.stats_settings),1)],2)):b("",!0),i.form.easy_compta_qrcode_addon_active==1?(c(),d("a",{key:5,class:v([n.tabClass(15),"justify-start w-full"]),onClick:t[16]||(t[16]=a=>n.selectTab(15))},[jt,g(" "+l(n.translations.qrcode_settings),1)],2)):b("",!0),e("a",{class:v([n.tabClass(16),"justify-start w-full"]),onClick:t[17]||(t[17]=a=>n.selectTab(16))},[Vt,g(" "+l(n.translations.validation_license),1)],2)]),e("div",It,[i.loading?(c(),d("div",Ft,Ut)):b("",!0),i.selectedTab===1?(c(),d("div",Dt,[e("h2",Ht,l(n.translations.general_settings),1),e("form",{onSubmit:t[30]||(t[30]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Nt,[e("div",Yt,[e("label",qt,l(n.translations.company_code),1),p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[18]||(t[18]=a=>i.form.company_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_code]])]),e("div",Lt,[e("label",Ot,l(n.translations.tax_number),1),p(e("input",{type:"text",id:"tax-number","onUpdate:modelValue":t[19]||(t[19]=a=>i.form.tax_number=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.tax_number]])]),e("div",Xt,[e("label",Wt,l(n.translations.company_name),1),p(e("input",{type:"text",id:"company-name","onUpdate:modelValue":t[20]||(t[20]=a=>i.form.company_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_name]])]),e("div",Bt,[e("label",zt,l(n.translations.address),1),p(e("input",{type:"text",id:"company-address","onUpdate:modelValue":t[21]||(t[21]=a=>i.form.company_address=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_address]])]),e("div",Gt,[e("label",Jt,l(n.translations.postal_code),1),p(e("input",{type:"text",id:"postal-code","onUpdate:modelValue":t[22]||(t[22]=a=>i.form.postal_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.postal_code]])]),e("div",Zt,[e("label",Kt,l(n.translations.city),1),p(e("input",{type:"text",id:"city","onUpdate:modelValue":t[23]||(t[23]=a=>i.form.city=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.city]])]),e("div",Qt,[e("label",$t,l(n.translations.country),1),p(e("input",{type:"text",id:"country","onUpdate:modelValue":t[24]||(t[24]=a=>i.form.country=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.country]])]),e("div",te,[e("label",ee,l(n.translations.email),1),p(e("input",{type:"email",id:"company-email","onUpdate:modelValue":t[25]||(t[25]=a=>i.form.company_email=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_email]])]),e("div",se,[e("label",ne,l(n.translations.phone),1),p(e("input",{type:"tel",id:"company-phone","onUpdate:modelValue":t[26]||(t[26]=a=>i.form.company_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_phone]])]),e("div",ie,[e("label",oe,l(n.translations.mobile),1),p(e("input",{type:"tel",id:"mobile-phone","onUpdate:modelValue":t[27]||(t[27]=a=>i.form.mobile_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.mobile_phone]])]),e("div",ae,[e("label",le,l(n.translations.fax),1),p(e("input",{type:"tel",id:"fax","onUpdate:modelValue":t[28]||(t[28]=a=>i.form.fax=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.fax]])])]),re,i.form.easy_compta_siret_addon_active==1?(c(),d("div",ce,[e("div",de,[e("div",ue,[e("label",he,l(n.translations.siret_api_token),1),pe,p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[29]||(t[29]=a=>i.form.easycompta_siret_token_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easycompta_siret_token_api]])])])])):b("",!0),e("div",me,[e("button",fe,[be,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===2?(c(),d("div",_e,[e("h2",ge,l(n.translations.system_settings),1),e("form",{onSubmit:t[41]||(t[41]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ye,[e("label",ve,[e("span",we,l(n.translations.activate_logo_mentions),1),e("input",{type:"checkbox",checked:i.form.logo_mentions_active==1,onChange:t[31]||(t[31]=(...a)=>n.updateLogoMentionsActive&&n.updateLogoMentionsActive(...a)),class:"wcpa-ui-toggle"},null,40,xe)])]),i.form.logo_mentions_active==1?(c(),d("div",ke,[e("label",Ce,l(n.translations.logo_mentions),1),p(e("input",{type:"text",id:"logo-mentions","onUpdate:modelValue":t[32]||(t[32]=a=>i.form.logo_mentions=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.logo_mentions]])])):b("",!0),e("div",Te,[e("label",Me,l(n.translations.company_logo),1),e("div",Ae,[e("input",{id:"file_logo",type:"file",onChange:t[33]||(t[33]=(...a)=>n.handleLogoUpload&&n.handleLogoUpload(...a)),accept:"image/*",class:"ecwp-file-input file-input file-input-bordered file-input-info w-full max-w-xs"},null,32),e("label",Se,[e("span",null,[Pe,g(l(n.translations.select),1)])])]),i.logoPreviewUrl?(c(),d("div",Ee,[p(e("input",{type:"range",min:"0",max:"400","onUpdate:modelValue":t[34]||(t[34]=a=>i.form.logo_width=a),class:"range mt-4",onChange:t[35]||(t[35]=(...a)=>n.updatePreviewWidth&&n.updatePreviewWidth(...a))},null,544),[[f,i.form.logo_width]]),e("div",je,l(i.form.logo_width)+" px",1),i.form.logo_width!==null?(c(),d("div",Ve,[e("img",{src:i.logoPreviewUrl,alt:"Logo Preview",class:"mb-6",style:C({width:i.form.logo_width+"px"})},null,12,Ie)])):b("",!0)])):b("",!0)]),e("div",Fe,[e("label",Re,l(n.translations.default_currency),1),p(e("select",{"onUpdate:modelValue":t[36]||(t[36]=a=>i.form.default_currency=a),class:"ecwp-input input input-bordered"},[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("option",{value:a.id,key:a.id},l(a.name)+" ("+l(a.symbol)+") ",9,Ue))),128))],512),[[V,i.form.default_currency]])]),e("div",De,[e("label",He,l(n.translations.currency_position),1),p(e("select",{"onUpdate:modelValue":t[37]||(t[37]=a=>i.form.currency_position=a),class:"ecwp-input input input-bordered"},[e("option",Ne,l(n.translations.before_amount),1),e("option",Ye,l(n.translations.after_amount),1)],512),[[V,i.form.currency_position]])]),e("div",qe,[e("label",Le,[e("span",Oe,l(n.translations.activate_vat),1),e("input",{type:"checkbox",checked:i.form.vat_active==1,onChange:t[38]||(t[38]=(...a)=>n.updateVatActive&&n.updateVatActive(...a)),class:"wcpa-ui-toggle"},null,40,Xe)])]),i.form.vat_active==1?(c(),d("div",We,[e("label",Be,l(n.translations.default_vat),1),p(e("select",{"onUpdate:modelValue":t[39]||(t[39]=a=>i.form.default_vat=a),class:"ecwp-input input input-bordered"},[ze,(c(!0),d(T,null,S(i.vats,a=>(c(),d("option",{value:a.id,key:a.id},l(a.description)+" - "+l(a.rate)+"% ",9,Ge))),128))],512),[[V,i.form.default_vat]])])):b("",!0),e("div",Je,[e("label",Ze,l(n.translations.format_date),1),p(e("select",{"onUpdate:modelValue":t[40]||(t[40]=a=>i.form.date_format=a),class:"ecwp-input input input-bordered"},as,512),[[V,i.form.date_format]])]),e("div",ls,[e("button",rs,[cs,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===3?(c(),d("div",ds,[i.showArticleModal?(c(),d("dialog",us,[e("div",hs,[e("h3",null,l(i.editingArticle?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[48]||(t[48]=k((...a)=>n.saveArticle&&n.saveArticle(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[42]||(t[42]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))}," \u2715 "),e("div",ps,[e("label",ms,l(n.translations.item_ref),1),p(e("input",{type:"text",id:"name_ref","onUpdate:modelValue":t[43]||(t[43]=a=>i.articleForm.ref=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.ref]])]),e("div",fs,[e("label",bs,l(n.translations.item_name),1),p(e("input",{type:"text",id:"name_article","onUpdate:modelValue":t[44]||(t[44]=a=>i.articleForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.name]])]),e("div",_s,[e("label",gs,l(n.translations.description),1),p(e("textarea",{id:"desc_article","onUpdate:modelValue":t[45]||(t[45]=a=>i.articleForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.description]])]),e("div",ys,[e("label",vs,l(n.translations.unit_price),1),p(e("input",{type:"text",id:"price_article","onUpdate:modelValue":t[46]||(t[46]=a=>i.articleForm.unit_price=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.unit_price]])]),e("div",ws,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[47]||(t[47]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))},l(n.translations.cancel),1),e("button",xs,l(i.editingArticle?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",ks,[e("h3",Cs,l(n.translations.articles_settings),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[49]||(t[49]=(...a)=>n.addArticle&&n.addArticle(...a))},[Ts,g(" "+l(n.translations.add),1)])]),e("div",Ms,[e("table",As,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.item_ref),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.unit_price),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.articles,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.ref),1),e("td",null,l(a.name),1),e("td",null,l(a.description),1),e("td",null,l(a.unit_price),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editArticle(a.id)},Es,8,Ss),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("article",a.id)},Is,8,js)])]))),128))])])]),Fs,e("h2",Rs,l(n.translations.categories),1),e("div",Us,[e("table",Ds,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.categories,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("category_article",a.id)},Ys,8,Hs)])]))),128))])])])])):b("",!0),i.selectedTab===4?(c(),d("div",qs,[e("h2",Ls,l(n.translations.invoices_settings),1),e("form",{onSubmit:t[65]||(t[65]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Os,[e("div",Xs,[e("label",Ws,l(n.translations.invoice_color),1),p(e("input",{type:"text",id:"invoice-color","onUpdate:modelValue":t[50]||(t[50]=a=>i.form.invoice_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_color]]),x(u,{modelValue:i.form.invoice_color,"onUpdate:modelValue":t[51]||(t[51]=a=>i.form.invoice_color=a)},null,8,["modelValue"])]),e("div",Bs,[e("label",zs,l(n.translations.invoice_prefix),1),p(e("input",{type:"text",id:"invoice-prefix","onUpdate:modelValue":t[52]||(t[52]=a=>i.form.invoice_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_prefix]])])]),Gs,e("div",Js,[e("div",Zs,[e("label",Ks,[e("input",{type:"checkbox",checked:i.form.show_phone==1,onChange:t[53]||(t[53]=a=>n.updateFormField(a,"show_phone")),class:"wcpa-ui-toggle"},null,40,Qs),e("span",$s,l(n.translations.show_phone),1)])]),e("div",tn,[e("label",en,[e("input",{type:"checkbox",checked:i.form.show_email==1,onChange:t[54]||(t[54]=a=>n.updateFormField(a,"show_email")),class:"wcpa-ui-toggle"},null,40,sn),e("span",nn,l(n.translations.show_email),1)])]),e("div",on,[e("label",an,[e("input",{type:"checkbox",checked:i.form.show_siren==1,onChange:t[55]||(t[55]=a=>n.updateFormField(a,"show_siren")),class:"wcpa-ui-toggle"},null,40,ln),e("span",rn,l(n.translations.show_siren),1)])]),e("div",cn,[e("label",dn,[e("input",{type:"checkbox",checked:i.form.show_tax_number==1,onChange:t[56]||(t[56]=a=>n.updateFormField(a,"show_tax_number")),class:"wcpa-ui-toggle"},null,40,un),e("span",hn,l(n.translations.show_tax_number),1)])]),e("div",pn,[e("label",mn,[e("input",{type:"checkbox",checked:i.form.show_watermark==1,onChange:t[57]||(t[57]=a=>n.updateFormField(a,"show_watermark")),class:"wcpa-ui-toggle"},null,40,fn),e("span",bn,l(n.translations.show_watermark),1)])]),i.form.show_watermark==1?(c(),d("div",_n,[e("label",gn,[e("input",{type:"checkbox",checked:i.form.show_watermark_only_paid==1,onChange:t[58]||(t[58]=a=>n.updateFormField(a,"show_watermark_only_paid")),class:"wcpa-ui-toggle"},null,40,yn),e("span",vn,l(n.translations.show_watermark_only_paid),1)])])):b("",!0)]),wn,e("div",xn,[e("div",kn,[e("label",Cn,l(n.translations.payment_conditions),1),p(e("input",{type:"text",id:"conditions-payment","onUpdate:modelValue":t[59]||(t[59]=a=>i.form.payment_conditions=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_conditions]])]),e("div",Tn,[e("label",Mn,l(n.translations.payment_mode),1),p(e("input",{type:"text",id:"mode-payment","onUpdate:modelValue":t[60]||(t[60]=a=>i.form.payment_mode=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_mode]])])]),e("div",An,[e("div",Sn,[e("label",Pn,l(n.translations.invoice_terms),1),e("div",null,[x(_,{modelValue:i.form.invoice_terms,"onUpdate:modelValue":t[61]||(t[61]=a=>i.form.invoice_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",En,[e("div",jn,[e("label",Vn,l(n.translations.invoice_iban),1),p(e("input",{type:"text",id:"invoice-iban","onUpdate:modelValue":t[62]||(t[62]=a=>i.form.invoice_iban=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_iban]])]),e("div",In,[e("label",Fn,l(n.translations.invoice_bic),1),p(e("input",{type:"text",id:"invoice-bic","onUpdate:modelValue":t[63]||(t[63]=a=>i.form.invoice_bic=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_bic]])])]),e("div",Rn,[e("label",Un,l(n.translations.invoice_footer),1),e("div",null,[x(_,{modelValue:i.form.invoice_footer,"onUpdate:modelValue":t[64]||(t[64]=a=>i.form.invoice_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",Dn,[e("button",Hn,[Nn,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===5?(c(),d("div",Yn,[e("h2",qn,l(n.translations.credits_settings),1),e("form",{onSubmit:t[71]||(t[71]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Ln,[e("div",On,[e("label",Xn,l(n.translations.credit_color),1),p(e("input",{type:"text",id:"credit-color","onUpdate:modelValue":t[66]||(t[66]=a=>i.form.credit_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_color]]),x(u,{modelValue:i.form.credit_color,"onUpdate:modelValue":t[67]||(t[67]=a=>i.form.credit_color=a)},null,8,["modelValue"])]),e("div",Wn,[e("label",Bn,l(n.translations.credit_prefix),1),p(e("input",{type:"text",id:"credit-prefix","onUpdate:modelValue":t[68]||(t[68]=a=>i.form.credit_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_prefix]])])]),e("div",zn,[e("div",Gn,[e("label",Jn,l(n.translations.credit_footer),1),e("div",null,[x(_,{modelValue:i.form.credit_footer,"onUpdate:modelValue":t[69]||(t[69]=a=>i.form.credit_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",Zn,[e("label",Kn,l(n.translations.credit_terms),1),e("div",null,[x(_,{modelValue:i.form.credit_terms,"onUpdate:modelValue":t[70]||(t[70]=a=>i.form.credit_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",Qn,[e("button",$n,[ti,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===6?(c(),d("div",ei,[e("h2",si,l(n.translations.quotes_settings),1),e("form",{onSubmit:t[77]||(t[77]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ni,[e("div",ii,[e("label",oi,l(n.translations.quote_color),1),p(e("input",{type:"text",id:"quote-color","onUpdate:modelValue":t[72]||(t[72]=a=>i.form.quote_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_color]]),x(u,{modelValue:i.form.quote_color,"onUpdate:modelValue":t[73]||(t[73]=a=>i.form.quote_color=a)},null,8,["modelValue"])]),e("div",ai,[e("label",li,l(n.translations.quote_prefix),1),p(e("input",{type:"text",id:"quote-prefix","onUpdate:modelValue":t[74]||(t[74]=a=>i.form.quote_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_prefix]])])]),e("div",ri,[e("div",ci,[e("label",di,l(n.translations.quote_footer),1),e("div",null,[x(_,{modelValue:i.form.quote_footer,"onUpdate:modelValue":t[75]||(t[75]=a=>i.form.quote_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",ui,[e("label",hi,l(n.translations.quote_terms),1),e("div",null,[x(_,{modelValue:i.form.quote_terms,"onUpdate:modelValue":t[76]||(t[76]=a=>i.form.quote_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",pi,[e("button",mi,[fi,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===7?(c(),d("div",bi,[e("h2",_i,l(n.translations.currency_vat_settings),1),i.showCurrencyModal?(c(),d("dialog",gi,[e("div",yi,[e("h3",null,l(i.editingCurrency?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[83]||(t[83]=k((...a)=>n.saveCurrency&&n.saveCurrency(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[78]||(t[78]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))}," \u2715 "),e("div",vi,[e("label",wi,l(n.translations.name),1),p(e("input",{type:"text",id:"name_currency","onUpdate:modelValue":t[79]||(t[79]=a=>i.currencyForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.name]])]),e("div",xi,[e("label",ki,l(n.translations.symbol),1),p(e("input",{type:"text",id:"symbol_currency","onUpdate:modelValue":t[80]||(t[80]=a=>i.currencyForm.symbol=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.symbol]])]),e("div",Ci,[e("label",Ti,l(n.translations.code),1),p(e("input",{type:"text",id:"code_currency","onUpdate:modelValue":t[81]||(t[81]=a=>i.currencyForm.code=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.code]])]),e("div",Mi,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[82]||(t[82]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))},l(n.translations.cancel),1),e("button",Ai,l(i.editingCurrency?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Si,[e("div",Pi,[e("h3",Ei,l(n.translations.currencies),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[84]||(t[84]=(...a)=>n.addCurrency&&n.addCurrency(...a))},[ji,g(" "+l(n.translations.add_currency),1)])]),e("div",Vi,[e("table",Ii,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.symbol),1),e("th",null,l(n.translations.code),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,l(a.symbol),1),e("td",null,l(a.code),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editCurrency(a.id)},Ui,8,Fi),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("currency",a.id)},Ni,8,Di)])]))),128))])])])]),e("div",null,[i.showVATModal?(c(),d("dialog",Yi,[e("div",qi,[e("h3",null,l(i.editingVAT?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[89]||(t[89]=k((...a)=>n.saveVAT&&n.saveVAT(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[85]||(t[85]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))}," \u2715 "),e("div",Li,[e("label",Oi,l(n.translations.description),1),p(e("input",{type:"text",id:"vat-description","onUpdate:modelValue":t[86]||(t[86]=a=>i.vatForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.description]])]),e("div",Xi,[e("label",Wi,l(n.translations.rate)+" (%)",1),p(e("input",{type:"text",id:"vat-rate","onUpdate:modelValue":t[87]||(t[87]=a=>i.vatForm.rate=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.rate]])]),e("div",Bi,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[88]||(t[88]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))},l(n.translations.cancel),1),e("button",zi,l(i.editingVAT?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Gi,[e("h3",Ji,l(n.translations.vat_rates),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[90]||(t[90]=(...a)=>n.addVAT&&n.addVAT(...a))},[Zi,g(" "+l(n.translations.add_vat),1)])]),e("div",Ki,[e("table",Qi,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.rate)+" (%)",1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.vats,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.description),1),e("td",null,l(a.rate),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editVAT(a.id)},eo,8,$i),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("vat",a.id)},io,8,so)])]))),128))])])])])])):b("",!0),i.selectedTab===8?(c(),d("div",oo,[e("h2",ao,l(n.translations.payments_settings),1),i.showPaymentModal?(c(),d("dialog",lo,[e("div",ro,[e("h3",null,l(i.editingPayment?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[94]||(t[94]=k((...a)=>n.savePayment&&n.savePayment(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[91]||(t[91]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))}," \u2715 "),e("div",co,[e("label",uo,l(n.translations.name),1),p(e("input",{type:"text",id:"name_payment","onUpdate:modelValue":t[92]||(t[92]=a=>i.paymentForm.method_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.paymentForm.method_name]])]),e("div",ho,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[93]||(t[93]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))},l(n.translations.cancel),1),e("button",po,l(i.editingPayment?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",mo,[e("div",fo,[e("h3",bo,l(n.translations.payments_methods),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[95]||(t[95]=(...a)=>n.addPayment&&n.addPayment(...a))},[_o,g(l(n.translations.add_method),1)])]),e("div",go,[e("table",yo,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.payments,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.method_name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editPayment(a.id)},xo,8,vo),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("payment",a.id)},To,8,ko)])]))),128))])])])])])):b("",!0),i.selectedTab===9?(c(),d("div",Mo,[e("h2",Ao,l(n.translations.expenses_settings),1),i.showExpenseModal?(c(),d("dialog",So,[e("div",Po,[e("h3",null,l(i.editingExpense?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[99]||(t[99]=k((...a)=>n.saveExpCat&&n.saveExpCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[96]||(t[96]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))}," \u2715 "),e("div",Eo,[e("label",jo,l(n.translations.name),1),p(e("input",{type:"text",id:"name_expense","onUpdate:modelValue":t[97]||(t[97]=a=>i.expenseForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.expenseForm.name]])]),e("div",Vo,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[98]||(t[98]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))},l(n.translations.cancel),1),e("button",Io,l(i.editingExpense?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Fo,[e("div",Ro,[e("h3",Uo,l(n.translations.expenses_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[100]||(t[100]=(...a)=>n.addExpCat&&n.addExpCat(...a))},[Do,g(" "+l(n.translations.add_category),1)])]),e("div",Ho,[e("table",No,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.expenses,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editExpCat(a.id)},Lo,8,Yo),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("expense",a.id)},Wo,8,Oo)])]))),128))])])])])])):b("",!0),i.selectedTab===10?(c(),d("div",Bo,[e("h2",zo,l(n.translations.planning_settings),1),i.showPlanningModal?(c(),d("dialog",Go,[e("div",Jo,[e("h3",null,l(i.editingPlanning?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[108]||(t[108]=k((...a)=>n.savePlanningCat&&n.savePlanningCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[101]||(t[101]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))}," \u2715 "),e("div",Zo,[e("label",Ko,l(n.translations.name),1),p(e("input",{type:"text",id:"name_planning","onUpdate:modelValue":t[102]||(t[102]=a=>i.planningForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.name]])]),e("div",Qo,[e("label",$o,l(n.translations.background),1),p(e("input",{type:"text",id:"background_planning","onUpdate:modelValue":t[103]||(t[103]=a=>i.planningForm.background=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.background]]),x(u,{modelValue:i.planningForm.background,"onUpdate:modelValue":t[104]||(t[104]=a=>i.planningForm.background=a)},null,8,["modelValue"])]),e("div",ta,[e("label",ea,l(n.translations.text_color),1),p(e("input",{type:"text",id:"color_planning","onUpdate:modelValue":t[105]||(t[105]=a=>i.planningForm.color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.color]]),x(u,{modelValue:i.planningForm.color,"onUpdate:modelValue":t[106]||(t[106]=a=>i.planningForm.color=a)},null,8,["modelValue"])]),e("div",sa,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[107]||(t[107]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))},l(n.translations.cancel),1),e("button",{type:"submit",class:"btn btn-primary rounded-full mx-2",disabled:i.loading},[g(l(i.editingPlanning?n.translations.save:n.translations.add)+" ",1),i.loading?(c(),d("span",ia)):b("",!0)],8,na)])],32)])])):b("",!0),e("div",oa,[e("div",aa,[e("h3",la,l(n.translations.planning_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[109]||(t[109]=(...a)=>n.addPlanningCat&&n.addPlanningCat(...a))},[ra,g(" "+l(n.translations.add_category),1)])]),e("div",ca,[e("table",da,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.background),1),e("th",null,l(n.translations.color),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.planning,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.background})},null,4)]),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.color})},null,4)]),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:y=>n.editPlanningCat(a.id)},pa,8,ua),e("button",{class:"p-2 text-error",onClick:y=>n.delete_item("planning",a.id)},ba,8,ma)])]))),128))])])])])])):b("",!0),i.selectedTab===11?(c(),d("div",_a,[e("h2",ga,l(n.translations.email_settings),1),e("form",{onSubmit:t[121]||(t[121]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ya,[e("label",va,[e("span",wa,l(n.translations.email_log_active),1),e("input",{type:"checkbox",checked:i.form.email_log_active==1,onChange:t[110]||(t[110]=(...a)=>n.updateEmailLogsActive&&n.updateEmailLogsActive(...a)),class:"wcpa-ui-toggle"},null,40,xa)])]),ka,e("div",Ca,[e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab1"}]),onClick:t[111]||(t[111]=a=>n.setActiveTab("tab1"))},l(n.translations.email_invoice),3),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab2"}]),onClick:t[112]||(t[112]=a=>n.setActiveTab("tab2"))},l(n.translations.email_quote),3),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab3"}]),onClick:t[113]||(t[113]=a=>n.setActiveTab("tab3"))},l(n.translations.invoice_reminder),3),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabEmail==="tab4"}]),onClick:t[114]||(t[114]=a=>n.setActiveTab("tab4"))},l(n.translations.payment_received),3)]),i.activeTabEmail==="tab1"?(c(),d("div",Ta,[e("div",Ma,[e("div",Aa,[e("label",Sa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_invoice_subject","onUpdate:modelValue":t[115]||(t[115]=a=>i.form.email_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_invoice_subject]])]),e("div",Pa,[e("label",Ea,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_invoice_content,"onUpdate:modelValue":t[116]||(t[116]=a=>i.form.email_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),ja])])])):b("",!0),i.activeTabEmail==="tab2"?(c(),d("div",Va,[e("div",Ia,[e("div",Fa,[e("label",Ra,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_quote_subject","onUpdate:modelValue":t[117]||(t[117]=a=>i.form.email_quote_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_quote_subject]])]),e("div",Ua,[e("label",Da,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_quote_content,"onUpdate:modelValue":t[118]||(t[118]=a=>i.form.email_quote_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Ha])])])):b("",!0),i.activeTabEmail==="tab3"?(c(),d("div",Na,[e("div",Ya,[e("div",qa,[e("label",La,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"remind_invoice_subject","onUpdate:modelValue":t[119]||(t[119]=a=>i.form.remind_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.remind_invoice_subject]])]),e("div",Oa,[e("label",Xa,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.remind_invoice_content,"onUpdate:modelValue":t[120]||(t[120]=a=>i.form.remind_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Wa])])])):b("",!0),i.activeTabEmail==="tab4"?(c(),d("div",Ba,[e("div",za,[Ga,e("div",null,[e("h2",Ja,l(n.translations.coming_soon),1)])])])):b("",!0),e("div",Za,[e("button",Ka,[Qa,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===12?(c(),d("div",$a,[e("h2",tl,l(n.translations.users_settings),1),e("div",el,[e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabUsers==="user1"}]),onClick:t[122]||(t[122]=a=>n.setActiveTabUsers("user1"))}," Automatic create account ",2),e("a",{role:"tab",class:v(["tab",{"tab-active":i.activeTabUsers==="user2"}]),onClick:t[123]||(t[123]=a=>n.setActiveTabUsers("user2"))}," Lost password ",2)]),i.activeTabUsers==="user1"?(c(),d("div",sl,[e("form",{onSubmit:t[126]||(t[126]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",nl,[e("div",il,[e("label",ol,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_create_account_subject","onUpdate:modelValue":t[124]||(t[124]=a=>i.form.email_create_account_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_create_account_subject]])]),e("div",al,[e("label",ll,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_create_account_content,"onUpdate:modelValue":t[125]||(t[125]=a=>i.form.email_create_account_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),rl])]),e("div",cl,[e("button",dl,[ul,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.activeTabUsers==="user2"?(c(),d("div",hl,[e("div",pl,[ml,e("div",null,[e("h2",fl,l(n.translations.coming_soon),1)])])])):b("",!0)])):b("",!0),i.selectedTab===13?(c(),d("div",bl,[e("h2",_l,l(n.translations.stripe_settings),1),e("form",{onSubmit:t[132]||(t[132]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",gl,[e("div",yl,[e("label",vl,l(n.translations.stripe_mode),1),p(e("select",{id:"stripe-mode","onUpdate:modelValue":t[127]||(t[127]=a=>i.form.stripe_mode=a),class:"ecwp-input input input-bordered",required:""},[e("option",wl,l(n.translations.test_mode),1),e("option",xl,l(n.translations.live_mode),1)],512),[[V,i.form.stripe_mode]])]),i.form.stripe_mode==="test"?(c(),d("div",kl,[e("div",Cl,[e("label",Tl,l(n.translations.stripe_public_key_test),1),p(e("input",{type:"text",id:"stripe-public-key-test","onUpdate:modelValue":t[128]||(t[128]=a=>i.form.stripe_public_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_test]])]),e("div",Ml,[e("label",Al,l(n.translations.stripe_secret_key_test),1),p(e("input",{type:"text",id:"stripe-secret-key-test","onUpdate:modelValue":t[129]||(t[129]=a=>i.form.stripe_secret_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_test]])])])):b("",!0),i.form.stripe_mode==="live"?(c(),d("div",Sl,[e("div",Pl,[e("label",El,l(n.translations.stripe_public_key_live),1),p(e("input",{type:"text",id:"stripe-public-key-live","onUpdate:modelValue":t[130]||(t[130]=a=>i.form.stripe_public_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_live]])]),e("div",jl,[e("label",Vl,l(n.translations.stripe_secret_key_live),1),p(e("input",{type:"text",id:"stripe-secret-key-live","onUpdate:modelValue":t[131]||(t[131]=a=>i.form.stripe_secret_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_live]])])])):b("",!0)]),e("div",Il,[e("button",Fl,[Rl,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===14?(c(),d("div",Ul,[e("h2",Dl,l(n.translations.stats_settings),1),e("form",{onSubmit:t[135]||(t[135]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Hl,[e("div",Nl,[e("label",Yl,l(n.translations.limit_declaration),1),p(e("input",{type:"number",id:"limit-declaration","onUpdate:modelValue":t[133]||(t[133]=a=>i.form.limit_declaration=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_declaration]])]),e("div",ql,[e("label",Ll,l(n.translations.limit_tva),1),p(e("input",{type:"number",id:"limit-tva","onUpdate:modelValue":t[134]||(t[134]=a=>i.form.limit_tva=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_tva]])])]),e("div",Ol,[e("button",Xl,[Wl,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===15?(c(),d("div",Bl,[e("h2",zl,l(n.translations.qrcode_settings),1),e("form",{onSubmit:t[137]||(t[137]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Gl,[e("div",Jl,[e("label",Zl,l(n.translations.stripe_api),1),p(e("input",{type:"text",id:"stripe-api","onUpdate:modelValue":t[136]||(t[136]=a=>i.form.easy_compta_stripe_secret_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easy_compta_stripe_secret_api]])])]),e("div",Kl,[e("button",Ql,[$l,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===16?(c(),d("div",tr,[e("h2",er,l(n.translations.validation_license),1),e("div",sr,[e("div",nr,[e("label",ir,l(n.translations.license_key),1),p(e("input",{type:"text",id:"license-code","onUpdate:modelValue":t[138]||(t[138]=a=>i.license_key=a),class:"ecwp-input input input-bordered w-full",disabled:i.licenseData&&i.licenseData.valid,required:""},null,8,or),[[f,i.license_key]]),e("button",{onClick:t[139]||(t[139]=(...a)=>n.checkLicense&&n.checkLicense(...a)),class:"btn btn-primary join-item rounded-r-full mt-5 -me-1",disabled:i.loadingLicense||i.licenseData&&i.licenseData.valid},[i.loadingLicense?(c(),d("span",lr)):(c(),d("span",rr,l(n.translations.validate),1))],8,ar)])]),e("div",cr,[i.errorMessage?(c(),d("div",dr,l(i.errorMessage),1)):b("",!0),i.licenseData?(c(),d("div",ur,[e("table",hr,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.domain),1),e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.activation_date),1),e("th",null,l(n.translations.expiry_date),1),e("th",null,l(n.translations.status),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[e("tr",null,[e("td",null,l(i.licenseData.domain),1),e("td",null,[(c(!0),d(T,null,S(i.licenseData.plugins,(a,y)=>(c(),d("div",{key:y},l(y),1))),128))]),e("td",null,l(i.licenseData.start_date),1),e("td",null,l(i.licenseData.end_date),1),e("td",null,l(i.licenseData.valid?"Valid":"Invalid"),1),e("td",null,[e("button",{onClick:t[140]||(t[140]=a=>n.refresh_licence()),class:"btn btn-circle text-blue-500 hover:text-blue-700 mx-1"},mr),e("button",{onClick:t[141]||(t[141]=a=>n.delete_item("licence","")),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},br)])])])]),e("table",_r,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.slug),1),e("th",null,l(n.translations.installed),1),e("th",null,l(n.translations.version),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.licenseData.plugins,a=>(c(),d("tr",{key:a},[e("td",null,l(a.product_name),1),e("td",null,l(a.product_slug),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[g(l(n.translations.installed),1)],64)):(c(),d(T,{key:1},[g(l(n.translations.not_installed),1)],64))]),e("td",null,l(i.installed_versions[a.product_slug]),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[e("button",{onClick:y=>n.checkUpdatePlugin(a.product_slug,i.installed_versions[a.product_slug]),class:"btn btn-sm text-red-500 hover:text-red-700 mx-1"},l(n.translations.check_update),9,gr),i.updatesAvailable[a.product_slug]?(c(),d("button",{key:0,onClick:y=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-blue-500 hover:text-blue-700 mx-1"},l(n.translations.download),9,yr)):b("",!0)],64)):(c(),d("button",{key:1,onClick:y=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-green-500 hover:green-red-700 mx-1"},l(n.translations.download),9,vr))])]))),128))])])])):b("",!0)])])):b("",!0)])])]),_:1})])}var xr=tt(dt,[["render",wr]]);function R(s){return R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(s)}var kr=/^\s+/,Cr=/\s+$/;function h(s,t){if(s=s||"",t=t||{},s instanceof h)return s;if(!(this instanceof h))return new h(s,t);var o=Tr(s);this._originalInput=s,this._r=o.r,this._g=o.g,this._b=o.b,this._a=o.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||o.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=o.ok}h.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),o,r,i,n,m,u;return o=t.r/255,r=t.g/255,i=t.b/255,o<=.03928?n=o/12.92:n=Math.pow((o+.055)/1.055,2.4),r<=.03928?m=r/12.92:m=Math.pow((r+.055)/1.055,2.4),i<=.03928?u=i/12.92:u=Math.pow((i+.055)/1.055,2.4),.2126*n+.7152*m+.0722*u},setAlpha:function(t){return this._a=J(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=q(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=q(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.v*100);return this._a==1?"hsv("+o+", "+r+"%, "+i+"%)":"hsva("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=Y(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Y(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.l*100);return this._a==1?"hsl("+o+", "+r+"%, "+i+"%)":"hsla("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return L(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return Pr(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(w(this._r,255)*100)+"%",g:Math.round(w(this._g,255)*100)+"%",b:Math.round(w(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%)":"rgba("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:qr[L(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var o="#"+O(this._r,this._g,this._b,this._a),r=o,i=this._gradientType?"GradientType = 1, ":"";if(t){var n=h(t);r="#"+O(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+o+",endColorstr="+r+")"},toString:function(t){var o=!!t;t=t||this._format;var r=!1,i=this._a<1&&this._a>=0,n=!o&&i&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(r=this.toRgbString()),t==="prgb"&&(r=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(r=this.toHexString()),t==="hex3"&&(r=this.toHexString(!0)),t==="hex4"&&(r=this.toHex8String(!0)),t==="hex8"&&(r=this.toHex8String()),t==="name"&&(r=this.toName()),t==="hsl"&&(r=this.toHslString()),t==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return h(this.toString())},_applyModification:function(t,o){var r=t.apply(null,[this].concat([].slice.call(o)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Ir,arguments)},brighten:function(){return this._applyModification(Fr,arguments)},darken:function(){return this._applyModification(Rr,arguments)},desaturate:function(){return this._applyModification(Er,arguments)},saturate:function(){return this._applyModification(jr,arguments)},greyscale:function(){return this._applyModification(Vr,arguments)},spin:function(){return this._applyModification(Ur,arguments)},_applyCombination:function(t,o){return t.apply(null,[this].concat([].slice.call(o)))},analogous:function(){return this._applyCombination(Nr,arguments)},complement:function(){return this._applyCombination(Dr,arguments)},monochromatic:function(){return this._applyCombination(Yr,arguments)},splitcomplement:function(){return this._applyCombination(Hr,arguments)},triad:function(){return this._applyCombination(X,[3])},tetrad:function(){return this._applyCombination(X,[4])}};h.fromRatio=function(s,t){if(R(s)=="object"){var o={};for(var r in s)s.hasOwnProperty(r)&&(r==="a"?o[r]=s[r]:o[r]=F(s[r]));s=o}return h(s,t)};function Tr(s){var t={r:0,g:0,b:0},o=1,r=null,i=null,n=null,m=!1,u=!1;return typeof s=="string"&&(s=Wr(s)),R(s)=="object"&&(j(s.r)&&j(s.g)&&j(s.b)?(t=Mr(s.r,s.g,s.b),m=!0,u=String(s.r).substr(-1)==="%"?"prgb":"rgb"):j(s.h)&&j(s.s)&&j(s.v)?(r=F(s.s),i=F(s.v),t=Sr(s.h,r,i),m=!0,u="hsv"):j(s.h)&&j(s.s)&&j(s.l)&&(r=F(s.s),n=F(s.l),t=Ar(s.h,r,n),m=!0,u="hsl"),s.hasOwnProperty("a")&&(o=s.a)),o=J(o),{ok:m,format:s.format||u,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:o}}function Mr(s,t,o){return{r:w(s,255)*255,g:w(t,255)*255,b:w(o,255)*255}}function Y(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=(r+i)/2;if(r==i)n=m=0;else{var _=r-i;switch(m=u>.5?_/(2-r-i):_/(r+i),r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,l:u}}function Ar(s,t,o){var r,i,n;s=w(s,360),t=w(t,100),o=w(o,100);function m(M,a,y){return y<0&&(y+=1),y>1&&(y-=1),y<1/6?M+(a-M)*6*y:y<1/2?a:y<2/3?M+(a-M)*(2/3-y)*6:M}if(t===0)r=i=n=o;else{var u=o<.5?o*(1+t):o+t-o*t,_=2*o-u;r=m(_,u,s+1/3),i=m(_,u,s),n=m(_,u,s-1/3)}return{r:r*255,g:i*255,b:n*255}}function q(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=r,_=r-i;if(m=r===0?0:_/r,r==i)n=0;else{switch(r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,v:u}}function Sr(s,t,o){s=w(s,360)*6,t=w(t,100),o=w(o,100);var r=Math.floor(s),i=s-r,n=o*(1-t),m=o*(1-i*t),u=o*(1-(1-i)*t),_=r%6,M=[o,m,n,n,u,o][_],a=[u,o,o,m,n,n][_],y=[n,n,u,o,o,m][_];return{r:M*255,g:a*255,b:y*255}}function L(s,t,o,r){var i=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function Pr(s,t,o,r,i){var n=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16)),E(Z(r))];return i&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function O(s,t,o,r){var i=[E(Z(r)),E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return i.join("")}h.equals=function(s,t){return!s||!t?!1:h(s).toRgbString()==h(t).toRgbString()};h.random=function(){return h.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function Er(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s-=t/100,o.s=H(o.s),h(o)}function jr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s+=t/100,o.s=H(o.s),h(o)}function Vr(s){return h(s).desaturate(100)}function Ir(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l+=t/100,o.l=H(o.l),h(o)}function Fr(s,t){t=t===0?0:t||10;var o=h(s).toRgb();return o.r=Math.max(0,Math.min(255,o.r-Math.round(255*-(t/100)))),o.g=Math.max(0,Math.min(255,o.g-Math.round(255*-(t/100)))),o.b=Math.max(0,Math.min(255,o.b-Math.round(255*-(t/100)))),h(o)}function Rr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l-=t/100,o.l=H(o.l),h(o)}function Ur(s,t){var o=h(s).toHsl(),r=(o.h+t)%360;return o.h=r<0?360+r:r,h(o)}function Dr(s){var t=h(s).toHsl();return t.h=(t.h+180)%360,h(t)}function X(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var o=h(s).toHsl(),r=[h(s)],i=360/t,n=1;n<t;n++)r.push(h({h:(o.h+n*i)%360,s:o.s,l:o.l}));return r}function Hr(s){var t=h(s).toHsl(),o=t.h;return[h(s),h({h:(o+72)%360,s:t.s,l:t.l}),h({h:(o+216)%360,s:t.s,l:t.l})]}function Nr(s,t,o){t=t||6,o=o||30;var r=h(s).toHsl(),i=360/o,n=[h(s)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,n.push(h(r));return n}function Yr(s,t){t=t||6;for(var o=h(s).toHsv(),r=o.h,i=o.s,n=o.v,m=[],u=1/t;t--;)m.push(h({h:r,s:i,v:n})),n=(n+u)%1;return m}h.mix=function(s,t,o){o=o===0?0:o||50;var r=h(s).toRgb(),i=h(t).toRgb(),n=o/100,m={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(i.a-r.a)*n+r.a};return h(m)};h.readability=function(s,t){var o=h(s),r=h(t);return(Math.max(o.getLuminance(),r.getLuminance())+.05)/(Math.min(o.getLuminance(),r.getLuminance())+.05)};h.isReadable=function(s,t,o){var r=h.readability(s,t),i,n;switch(n=!1,i=Br(o),i.level+i.size){case"AAsmall":case"AAAlarge":n=r>=4.5;break;case"AAlarge":n=r>=3;break;case"AAAsmall":n=r>=7;break}return n};h.mostReadable=function(s,t,o){var r=null,i=0,n,m,u,_;o=o||{},m=o.includeFallbackColors,u=o.level,_=o.size;for(var M=0;M<t.length;M++)n=h.readability(s,t[M]),n>i&&(i=n,r=h(t[M]));return h.isReadable(s,r,{level:u,size:_})||!m?r:(o.includeFallbackColors=!1,h.mostReadable(s,["#fff","#000"],o))};var N=h.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},qr=h.hexNames=Lr(N);function Lr(s){var t={};for(var o in s)s.hasOwnProperty(o)&&(t[s[o]]=o);return t}function J(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function w(s,t){Or(s)&&(s="100%");var o=Xr(s);return s=Math.min(t,Math.max(0,parseFloat(s))),o&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function H(s){return Math.min(1,Math.max(0,s))}function A(s){return parseInt(s,16)}function Or(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function Xr(s){return typeof s=="string"&&s.indexOf("%")!=-1}function E(s){return s.length==1?"0"+s:""+s}function F(s){return s<=1&&(s=s*100+"%"),s}function Z(s){return Math.round(parseFloat(s)*255).toString(16)}function W(s){return A(s)/255}var P=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",o="(?:"+t+")|(?:"+s+")",r="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?",i="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?";return{CSS_UNIT:new RegExp(o),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function j(s){return!!P.CSS_UNIT.exec(s)}function Wr(s){s=s.replace(kr,"").replace(Cr,"").toLowerCase();var t=!1;if(N[s])s=N[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var o;return(o=P.rgb.exec(s))?{r:o[1],g:o[2],b:o[3]}:(o=P.rgba.exec(s))?{r:o[1],g:o[2],b:o[3],a:o[4]}:(o=P.hsl.exec(s))?{h:o[1],s:o[2],l:o[3]}:(o=P.hsla.exec(s))?{h:o[1],s:o[2],l:o[3],a:o[4]}:(o=P.hsv.exec(s))?{h:o[1],s:o[2],v:o[3]}:(o=P.hsva.exec(s))?{h:o[1],s:o[2],v:o[3],a:o[4]}:(o=P.hex8.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),a:W(o[4]),format:t?"name":"hex8"}:(o=P.hex6.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),format:t?"name":"hex"}:(o=P.hex4.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),a:W(o[4]+""+o[4]),format:t?"name":"hex8"}:(o=P.hex3.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),format:t?"name":"hex"}:!1}function Br(s){var t,o;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),o=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),o!=="small"&&o!=="large"&&(o="small"),{level:t,size:o}}var K={name:"ColorPicker",props:["color","position","boxRect","disableAlpha","disableTextInputs"],emits:["updateColor","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","ready","change"],inject:["tinycolor"],data(){return{h:void 0,s:void 0,v:void 0,a:void 0,hueTranslateX:0,alphaTranslateX:0,saturationTranslateX:0,saturationTranslateY:0,sliderPointerWidth:0,saturationPointerWidth:0,saturationPointerHeight:0,pickerPositionA:{anchor:"top",offset:0},pickerPositionB:{anchor:"left",offset:0},pickerWidth:0,pickerHeight:0,textInputsFormat:"rgb",textInputActive:null,textInputsFreeze:{},arrowColor:"#0f0f0f",sliderWidth:0}},computed:{pureHueBackground(){return{background:"hsl("+this.h+", 100%, 50%)"}},hexString(){return this.color.toHexString()},huePointerStyles(){return{transform:"translate("+(this.hueTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerStyles(){return{transform:"translate("+(this.alphaTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerTransparentStyles(){return{backgroundPosition:-this.alphaTranslateX+"px"}},alphaPointerColorStyles(){return{opacity:this.a}},alphaCanvasStyles(){return{background:"linear-gradient(90deg, transparent 0%, "+this.color.toHexString()+" 100%)"}},saturationPointerStyles(){const s=this.saturationTranslateX-this.saturationPointerWidth*.5,t=this.saturationTranslateY+this.saturationPointerHeight*.5;return{transform:"translate("+s+"px, "+t+"px)"}},arrowsStyles(){return{"--arrow-color":this.arrowColor}},pickerPosition(){const s={},t={top:"bottom",bottom:"top",left:"right",right:"left"};let o;["top","bottom"].includes(this.position[0])?(s.marginLeft=0,s.marginRight=0,o=this.boxRect.height):(s.marginTop=0,s.marginBottom=0,o=this.boxRect.width);let r=t[this.position[0]];return s[r]=o+"px",this.position[1]==="center"?(["left","right"].includes(r)?(r="top",o=this.pickerHeight-this.boxRect.height):(r="left",o=this.pickerWidth-this.boxRect.width),o*=.5):(r=t[this.position[1]],o=0),s[r]=-o+"px",s},textInputs(){const s=this.textInputsFormat,t={};if(["name","hex"].includes(s))t.hex=this.color.toString("hex");else{const o=this.color.toString(s).split("(")[1].slice(0,-1).split(", ");s.split("").forEach((r,i)=>t[r]=o[i])}if(this.disableAlpha||(t.a=Number(this.color.getAlpha().toFixed(2))),t.hasOwnProperty("h")&&(t.h=Math.round(this.h),t.hasOwnProperty("l"))){let o=this.s;const r=this.v||.001,i=(2-o)*r/2;i<.5&&(o*=r/(i*2),t.s=Math.round(o*100)+"%")}return t}},methods:{saturationPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.saturationPickEnd),document.addEventListener("pointermove",this.saturationPickMove),this.saturationPickMove(s),this.emitHook("saturationInputStart",{s:this.s,v:this.v}),this.colorSnapshot=this.color.toRgbString()},saturationPickEnd(s){document.removeEventListener("pointerup",this.saturationPickEnd),document.removeEventListener("pointermove",this.saturationPickMove),this.emitHook("saturationInputEnd",{s:this.s,v:this.v}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},saturationPickMove(s){s.clientX>=this.saturationCanvasRect.x&&s.clientX<=this.saturationCanvasRect.right?this.s=(s.clientX-this.saturationCanvasRect.x)/this.saturationCanvasRect.width:s.clientX<this.saturationCanvasRect.x?this.s=0:this.s=1,s.clientY>=this.saturationCanvasRect.y&&s.clientY<=this.saturationCanvasRect.bottom?this.v=1-(s.clientY-this.saturationCanvasRect.y)/this.saturationCanvasRect.height:s.clientY<this.saturationCanvasRect.y?this.v=1:this.v=0},huePickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.huePickEnd),document.addEventListener("pointermove",this.huePickMove),this.huePickMove(s),this.emitHook("hueInputStart",{h:this.h}),this.colorSnapshot=this.color.toRgbString()},huePickEnd(s){document.removeEventListener("pointerup",this.huePickEnd),document.removeEventListener("pointermove",this.huePickMove),this.emitHook("hueInputEnd",{h:this.h}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},huePickMove(s){s.clientX>=this.hueCanvasRect.x&&s.clientX<=this.hueCanvasRect.right?this.h=(s.clientX-this.hueCanvasRect.x)*360/this.hueCanvasRect.width:s.clientX<this.hueCanvasRect.x?this.h=0:this.h=360},alphaPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.alphaPickEnd),document.addEventListener("pointermove",this.alphaPickMove),this.alphaPickMove(s),this.emitHook("alphaInputStart",{a:this.a}),this.colorSnapshot=this.color.toRgbString()},alphaPickEnd(s){document.removeEventListener("pointerup",this.alphaPickEnd),document.removeEventListener("pointermove",this.alphaPickMove),this.emitHook("alphaInputEnd",{a:this.a}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},alphaPickMove(s){s.clientX>=this.alphaCanvasRect.x&&s.clientX<=this.alphaCanvasRect.right?this.a=(s.clientX-this.alphaCanvasRect.x)/this.alphaCanvasRect.width:s.clientX<this.alphaCanvasRect.x?this.a=0:this.a=1},emitUpdate(s){s=s||{h:this.h,s:this.s,v:this.v,a:this.a},this.$emit("updateColor",s)},emitHook(s,t){if(typeof t=="object")for(let[o,r]of Object.entries(t))t[o]=Number(r.toFixed(3));else t=Number(t.toFixed(3));this.$emit(s,t)},textInputInputHandler(s){const t=s.target.dataset.component;this.textInputsFreeze[t]=s.target.value;let o={...this.textInputsFreeze};if(o.hasOwnProperty("hex")){const n=o.a;o=this.tinycolor(o.hex),o.getFormat()!=="hex8"&&o.setAlpha(n)}else o=this.tinycolor(o);const r=o.toHsv();if(this.textInputsFormat==="hsl"&&(r.h===0&&(r.h=parseInt(this.textInputsFreeze.h)),r.v===0)){let n=this.textInputsFreeze.s;const m=n.indexOf("%")!==-1;n=parseFloat(n),!n||n<0?n=0:(m||n>1)&&(n=Math.min(n*.01,1));const u=.001,_=n*u+u;n=2-2*u/_,r.s=n}const i={h:.5,s:.001,v:.001};t!=="a"?(Object.keys(r).filter(n=>n!=="a").forEach(n=>{const m=this[n],u=r[n];Math.abs(m-u)>i[n]&&(this[n]=u)}),o.getFormat()==="hex8"&&o.getOriginalInput().length>7&&(this.disableAlpha?Object.assign(this.$data,{h:0,s:0,v:0}):(this.a=r.a,this.textInputsFreeze.a=Number(this.a.toFixed(2))))):this.a=r.a},textInputFocusHandler(s){this.textInputActive||(this.textInputsFreeze={...this.textInputs},this.colorSnapshot=this.color.toRgbString()),this.textInputActive=s.target.dataset.component},textInputBlurHandler(s){setTimeout(()=>{this.textInputActive===s.target.dataset.component&&(this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a}),this.textInputsFreeze={},this.textInputActive=null)},0)},textInputFormatChange(s){const t=["rgb","name","hsl"];this.textInputsFormat;let o=t.indexOf(this.textInputsFormat)+s;o<0?o=t.length-1:o===t.length&&(o=0),this.textInputsFormat=t[o]},getCanvasRects(){this.saturationCanvasRect=this.$refs.saturationCanvas.getBoundingClientRect(),this.hueCanvasRect=this.$refs.hueCanvas.getBoundingClientRect(),this.alphaCanvasRect=this.disableAlpha?{}:this.$refs.alphaCanvas.getBoundingClientRect()},init(){const s=this.$refs.pickerRoot,t=window.getComputedStyle(s);Object.assign(this.$data,this.color.toHsv()),window.requestAnimationFrame(()=>{const{width:r,height:i}=s.getBoundingClientRect();this.pickerHeight=i,this.pickerWidth=r,this.getCanvasRects(),this.hueTranslateX=this.h*this.hueCanvasRect.width/360,this.alphaTranslateX=this.a*this.alphaCanvasRect.width,this.saturationTranslateX=this.s*this.saturationCanvasRect.width,this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,this.sliderPointerWidth=this.$refs.huePointer.offsetWidth,this.saturationPointerWidth=this.$refs.saturationPointer.offsetWidth,this.saturationPointerHeight=this.$refs.saturationPointer.offsetHeight,window.requestAnimationFrame(()=>{this.$emit("ready")})});const o=t.getPropertyValue("background-color");this.tinycolor(o).isDark()&&(this.arrowColor="#fbfbfb")},fillCanvas(){let s=this.$refs.hueCanvas,t=s.getContext("2d"),o=t.createLinearGradient(s.width,0,0,0);o.addColorStop(0,"hsl(0,100%,50%)"),o.addColorStop(.17,"hsl(298.8, 100%, 50%)"),o.addColorStop(.33,"hsl(241.2, 100%, 50%)"),o.addColorStop(.5,"hsl(180, 100%, 50%)"),o.addColorStop(.67,"hsl(118.8, 100%, 50%)"),o.addColorStop(.83,"hsl(61.2,100%,50%)"),o.addColorStop(1,"hsl(360,100%,50%)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),s=this.$refs.saturationCanvas,t=s.getContext("2d"),o=t.createLinearGradient(0,0,s.width,0),o.addColorStop(0,"rgba(250,250,250,1)"),o.addColorStop(1,"rgba(250,250,250,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),o=t.createLinearGradient(0,s.height,0,0),o.addColorStop(0,"rgba(0,0,0,1)"),o.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height)}},watch:{h(s,t){this.hueTranslateX=this.h*this.hueCanvasRect.width/360,t!==void 0&&(this.emitUpdate(),this.emitHook("hueInput",{h:this.h}))},s(s,t){this.saturationTranslateX=this.s*this.saturationCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},v(s,t){this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},a(s,t){this.alphaTranslateX=this.a*this.alphaCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("alphaInput",{a:this.a}))}},mounted(){this.getCanvasRects(),this.fillCanvas()},beforeUnmount(){}};const zr={class:"slider-canvas",ref:"saturationCanvas"},Gr={class:"slider-container"},Jr={class:"slider-canvas",ref:"hueCanvas"},Zr={class:"slider-active-area"},Kr={class:"slider-container transparency-pattern"},Qr={class:"slider-active-area"},$r={class:"text-inputs-wrapper"},tc=["for"],ec=["value","id","data-component"];function sc(s,t,o,r,i,n){return c(),d("div",{ref:"pickerRoot",style:C([n.pickerPosition])},[e("div",{class:"saturation-area",style:C(n.pureHueBackground),onPointerdown:t[0]||(t[0]=(...m)=>n.saturationPickStart&&n.saturationPickStart(...m))},[e("canvas",zr,null,512),e("div",{class:"saturation-pointer",ref:"saturationPointer",style:C([n.saturationPointerStyles,{background:n.hexString}])},null,4)],36),e("div",{class:"slider",onPointerdown:t[1]||(t[1]=(...m)=>n.huePickStart&&n.huePickStart(...m))},[e("div",Gr,[e("canvas",Jr,null,512)]),e("div",Zr,[e("div",{class:"slider-pointer",ref:"huePointer",style:C([n.huePointerStyles,n.pureHueBackground])},null,4)])],32),o.disableAlpha?b("",!0):(c(),d("div",{key:0,class:"slider",onPointerdown:t[2]||(t[2]=(...m)=>n.alphaPickStart&&n.alphaPickStart(...m))},[e("div",Kr,[e("div",{class:"slider-canvas",ref:"alphaCanvas",style:C(n.alphaCanvasStyles)},null,4)]),e("div",Qr,[e("div",{class:"slider-pointer",ref:"alphaPointer",style:C(n.alphaPointerStyles)},[e("div",{class:"pointer-transparent",style:C(n.alphaPointerTransparentStyles)},[e("div",{class:"pointer-color",style:C([n.alphaPointerColorStyles,{background:n.hexString}])},null,4)],4)],4)])],32)),o.disableTextInputs?b("",!0):(c(),d("div",{key:1,class:"text-inputs-area",style:C({"--outline-color":n.hexString})},[e("div",$r,[(c(!0),d(T,null,S(i.textInputActive?i.textInputsFreeze:n.textInputs,(m,u)=>(c(),d("div",{key:"text-input-"+u,class:"text-input-container"},[e("label",{for:"text-input-"+u},l(u),9,tc),e("input",{value:m,class:"text-input",autocomplete:"off",spellcheck:"false",id:"text-input-"+u,"data-component":u,onInput:t[3]||(t[3]=k((..._)=>n.textInputInputHandler&&n.textInputInputHandler(..._),["prevent"])),onFocus:t[4]||(t[4]=(..._)=>n.textInputFocusHandler&&n.textInputFocusHandler(..._)),onBlur:t[5]||(t[5]=(..._)=>n.textInputBlurHandler&&n.textInputBlurHandler(..._)),onKeypress:t[6]||(t[6]=it(_=>_.target.blur(),["enter"]))},null,40,ec)]))),128))]),e("div",{class:"text-format-arrows",style:C(n.arrowsStyles)},[e("div",{class:"arrow up",onClick:t[7]||(t[7]=m=>n.textInputFormatChange(-1))}),e("div",{class:"arrow down",onClick:t[8]||(t[8]=m=>n.textInputFormatChange(1))})],4)],4))],4)}function Q(s,t){t===void 0&&(t={});var o=t.insertAt;if(!(!s||typeof document=="undefined")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",o==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}}var nc=`.color-input .pointer-transparent, .color-input .pointer-color, .color-input .slider-canvas, .color-input .slider-container {
    22  width: 100%;
    33  height: 100%;
     
    111111.color-input .text-format-arrows .arrow:hover {
    112112  opacity: 0.8;
    113 }`;Q(sc);Z.render=ec;var nc="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iMCIgeD0iMCIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iNSIgeD0iNSIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+Cjwvc3ZnPg==";const ic=(s,t)=>{for(;!/^(body|html)$/i.test(s.tagName);){if(s===t)return!0;s=s.parentNode}return!1};var K=tt({name:"ColorInput",props:{modelValue:[String,Object],position:{type:String,default:"bottom"},transition:{type:String,default:"picker-popup"},disableAlpha:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},disableTextInputs:{type:Boolean,default:!1},format:String},emits:["mounted","beforeUnmount","update:modelValue","pickStart","pickEnd","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","change"],components:{ColorPicker:Z},provide:{tinycolor:h},data(){return{color:null,active:!1,ready:!1,hidePicker:!1,boxRect:{},innerBoxRect:{},textInputsFormat:"rgb",originalFormat:"rgb",originalType:null}},computed:{boxColorStyles(){return{background:this.color.toRgbString()}},processedPosition(){const s=["top","right","bottom","left","center"],t={top:"bottom",right:"left",bottom:"top",left:"right"},o=s.slice(0,4).flatMap((i,n)=>s.map(m=>t[i]===m?!1:i===m?i:i+" "+m)).filter(i=>i);let r=this.position.toLowerCase();return o.includes(r)||(r&&console.warn("[vue-color-input]: invalid position -> "+r),r="bottom center"),r=r.split(" "),r[1]=r[1]||"center",r},processedFormat(){let s=["rgb","hsv","hsl"];s=s.concat(s.flatMap(i=>[i+" object","object "+i,i+" string","string "+i])),s=s.concat(["name","hex","hex8"].flatMap(i=>[i,i+" string","string "+i]));let t=this.format,o=!1;t?(t=t.toLowerCase(),s.includes(t)?o=!0:(console.warn("[vue-color-input]: invalid format -> "+t),t=this.originalFormat)):t=this.originalFormat,t=t.split(" ");let r=t.findIndex(i=>["string","object"].includes(i));return r<0?r=["rgb","hsv","hsl"].includes(t[0])?this.originalType:"string":r=t.splice(r,1)[0],t=t[0],{type:r,format:t,force:o}},processedDisableAlpha(){const s=this.processedFormat;return s.force&&["hex","name"].includes(s.format)?!0:this.disableAlpha}},methods:{pickStart(s){this.active||this.disabled||(this.getBoxRect(),this.active=!0,this.ready=!1,this.hidePicker=!0,this.$refs.picker.init(),document.body.addEventListener("pointerdown",this.pickEnd),this.$emit("pickStart"))},pickEnd(s){!this.active||s&&ic(s.target,this.$refs.picker.$refs.pickerRoot)||(document.body.removeEventListener("pointerdown",this.pickEnd),this.active=!1,this.$emit("pickEnd"))},init(){this.color=h(this.modelValue);let s=this.color.getFormat();this.originalFormat=s||"rgb";let t=typeof this.modelValue;this.originalType=["string","object"].includes(t)?t:"string",this.processedFormat,this.output=null,this.color.isValid()||console.warn("[vue-color-input]: invalid color -> "+this.color.getOriginalInput())},emitUpdate(s){s&&(this.color=h(s));let t=this.processedFormat.format;this.color.getAlpha()<1&&["hex","name"].includes(t)&&(this.processedFormat.force?this.color.setAlpha(1):t="rgb"),this.processedFormat.type==="object"?this.output=this.color["to"+t.charAt(0).toUpperCase()+t.slice(1)]():this.output=this.color.toString(t),this.$emit("update:modelValue",this.output)},getBoxRect(){this.boxRect=this.$refs.root.getBoundingClientRect()}},created(){this.init(),this.cssVars={"--transparent-pattern":"url("+nc+")"}},mounted(){this.$emit("mounted")},beforeUnmount(){this.pickEnd(),this.$emit("beforeUnmount")},watch:{modelValue(){let s=typeof this.modelValue=="object"?JSON.stringify(this.modelValue):this.modelValue,t=typeof this.output=="object"?JSON.stringify(this.output):this.output;s!==t&&(this.init(),this.active&&this.$nextTick(function(){this.$refs.picker.init()}))},disabled(){this.pickEnd()},processedDisableAlpha(s){s&&(this.color.setAlpha(1),this.emitUpdate()),this.active&&this.$nextTick(function(){this.$refs.picker.init()})},format(){this.emitUpdate()}}});const oc={class:"inner transparent"};function ac(s,t,o,r,i,n){const m=I("color-picker");return c(),d("div",{class:"color-input user",ref:"root",style:C(s.cssVars)},[e("div",{class:v(["box",{active:s.active,disabled:s.disabled}]),onClick:t[0]||(t[0]=k((...u)=>s.pickStart&&s.pickStart(...u),["stop"])),ref:"box"},[e("div",oc,[e("div",{class:"color",style:C(s.boxColorStyles)},null,4)])],2),x(et,{name:s.transition},{default:z(()=>[p(x(m,{class:"picker-popup",color:this.color,position:s.processedPosition,"disable-alpha":s.processedDisableAlpha,boxRect:s.boxRect,"disable-text-inputs":s.disableTextInputs,style:C({visibility:s.hidePicker?"hidden":""}),onReady:t[1]||(t[1]=u=>s.hidePicker=!1),onUpdateColor:s.emitUpdate,onHueInputStart:t[2]||(t[2]=u=>s.$emit("hueInputStart",u)),onHueInputEnd:t[3]||(t[3]=u=>s.$emit("hueInputEnd",u)),onHueInput:t[4]||(t[4]=u=>s.$emit("hueInput",u)),onAlphaInputStart:t[5]||(t[5]=u=>s.$emit("alphaInputStart",u)),onAlphaInputEnd:t[6]||(t[6]=u=>s.$emit("alphaInputEnd",u)),onAlphaInput:t[7]||(t[7]=u=>s.$emit("alphaInput",u)),onSaturationInputStart:t[8]||(t[8]=u=>s.$emit("saturationInputStart",u)),onSaturationInputEnd:t[9]||(t[9]=u=>s.$emit("saturationInputEnd",u)),onSaturationInput:t[10]||(t[10]=u=>s.$emit("saturationInput",u)),onChange:t[11]||(t[11]=u=>s.$emit("change",u)),ref:"picker"},null,8,["color","position","disable-alpha","boxRect","disable-text-inputs","style","onUpdateColor"]),[[st,s.active]])]),_:1},8,["name"])],4)}var lc=`.color-input .box .color, .color-input .box .transparent {
     113}`;Q(nc);K.render=sc;var ic="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iMCIgeD0iMCIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iNSIgeD0iNSIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+Cjwvc3ZnPg==";const oc=(s,t)=>{for(;!/^(body|html)$/i.test(s.tagName);){if(s===t)return!0;s=s.parentNode}return!1};var $=et({name:"ColorInput",props:{modelValue:[String,Object],position:{type:String,default:"bottom"},transition:{type:String,default:"picker-popup"},disableAlpha:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},disableTextInputs:{type:Boolean,default:!1},format:String},emits:["mounted","beforeUnmount","update:modelValue","pickStart","pickEnd","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","change"],components:{ColorPicker:K},provide:{tinycolor:h},data(){return{color:null,active:!1,ready:!1,hidePicker:!1,boxRect:{},innerBoxRect:{},textInputsFormat:"rgb",originalFormat:"rgb",originalType:null}},computed:{boxColorStyles(){return{background:this.color.toRgbString()}},processedPosition(){const s=["top","right","bottom","left","center"],t={top:"bottom",right:"left",bottom:"top",left:"right"},o=s.slice(0,4).flatMap((i,n)=>s.map(m=>t[i]===m?!1:i===m?i:i+" "+m)).filter(i=>i);let r=this.position.toLowerCase();return o.includes(r)||(r&&console.warn("[vue-color-input]: invalid position -> "+r),r="bottom center"),r=r.split(" "),r[1]=r[1]||"center",r},processedFormat(){let s=["rgb","hsv","hsl"];s=s.concat(s.flatMap(i=>[i+" object","object "+i,i+" string","string "+i])),s=s.concat(["name","hex","hex8"].flatMap(i=>[i,i+" string","string "+i]));let t=this.format,o=!1;t?(t=t.toLowerCase(),s.includes(t)?o=!0:(console.warn("[vue-color-input]: invalid format -> "+t),t=this.originalFormat)):t=this.originalFormat,t=t.split(" ");let r=t.findIndex(i=>["string","object"].includes(i));return r<0?r=["rgb","hsv","hsl"].includes(t[0])?this.originalType:"string":r=t.splice(r,1)[0],t=t[0],{type:r,format:t,force:o}},processedDisableAlpha(){const s=this.processedFormat;return s.force&&["hex","name"].includes(s.format)?!0:this.disableAlpha}},methods:{pickStart(s){this.active||this.disabled||(this.getBoxRect(),this.active=!0,this.ready=!1,this.hidePicker=!0,this.$refs.picker.init(),document.body.addEventListener("pointerdown",this.pickEnd),this.$emit("pickStart"))},pickEnd(s){!this.active||s&&oc(s.target,this.$refs.picker.$refs.pickerRoot)||(document.body.removeEventListener("pointerdown",this.pickEnd),this.active=!1,this.$emit("pickEnd"))},init(){this.color=h(this.modelValue);let s=this.color.getFormat();this.originalFormat=s||"rgb";let t=typeof this.modelValue;this.originalType=["string","object"].includes(t)?t:"string",this.processedFormat,this.output=null,this.color.isValid()||console.warn("[vue-color-input]: invalid color -> "+this.color.getOriginalInput())},emitUpdate(s){s&&(this.color=h(s));let t=this.processedFormat.format;this.color.getAlpha()<1&&["hex","name"].includes(t)&&(this.processedFormat.force?this.color.setAlpha(1):t="rgb"),this.processedFormat.type==="object"?this.output=this.color["to"+t.charAt(0).toUpperCase()+t.slice(1)]():this.output=this.color.toString(t),this.$emit("update:modelValue",this.output)},getBoxRect(){this.boxRect=this.$refs.root.getBoundingClientRect()}},created(){this.init(),this.cssVars={"--transparent-pattern":"url("+ic+")"}},mounted(){this.$emit("mounted")},beforeUnmount(){this.pickEnd(),this.$emit("beforeUnmount")},watch:{modelValue(){let s=typeof this.modelValue=="object"?JSON.stringify(this.modelValue):this.modelValue,t=typeof this.output=="object"?JSON.stringify(this.output):this.output;s!==t&&(this.init(),this.active&&this.$nextTick(function(){this.$refs.picker.init()}))},disabled(){this.pickEnd()},processedDisableAlpha(s){s&&(this.color.setAlpha(1),this.emitUpdate()),this.active&&this.$nextTick(function(){this.$refs.picker.init()})},format(){this.emitUpdate()}}});const ac={class:"inner transparent"};function lc(s,t,o,r,i,n){const m=I("color-picker");return c(),d("div",{class:"color-input user",ref:"root",style:C(s.cssVars)},[e("div",{class:v(["box",{active:s.active,disabled:s.disabled}]),onClick:t[0]||(t[0]=k((...u)=>s.pickStart&&s.pickStart(...u),["stop"])),ref:"box"},[e("div",ac,[e("div",{class:"color",style:C(s.boxColorStyles)},null,4)])],2),x(st,{name:s.transition},{default:G(()=>[p(x(m,{class:"picker-popup",color:this.color,position:s.processedPosition,"disable-alpha":s.processedDisableAlpha,boxRect:s.boxRect,"disable-text-inputs":s.disableTextInputs,style:C({visibility:s.hidePicker?"hidden":""}),onReady:t[1]||(t[1]=u=>s.hidePicker=!1),onUpdateColor:s.emitUpdate,onHueInputStart:t[2]||(t[2]=u=>s.$emit("hueInputStart",u)),onHueInputEnd:t[3]||(t[3]=u=>s.$emit("hueInputEnd",u)),onHueInput:t[4]||(t[4]=u=>s.$emit("hueInput",u)),onAlphaInputStart:t[5]||(t[5]=u=>s.$emit("alphaInputStart",u)),onAlphaInputEnd:t[6]||(t[6]=u=>s.$emit("alphaInputEnd",u)),onAlphaInput:t[7]||(t[7]=u=>s.$emit("alphaInput",u)),onSaturationInputStart:t[8]||(t[8]=u=>s.$emit("saturationInputStart",u)),onSaturationInputEnd:t[9]||(t[9]=u=>s.$emit("saturationInputEnd",u)),onSaturationInput:t[10]||(t[10]=u=>s.$emit("saturationInput",u)),onChange:t[11]||(t[11]=u=>s.$emit("change",u)),ref:"picker"},null,8,["color","position","disable-alpha","boxRect","disable-text-inputs","style","onUpdateColor"]),[[nt,s.active]])]),_:1},8,["name"])],4)}var rc=`.color-input .box .color, .color-input .box .transparent {
    114114  width: 100%;
    115115  height: 100%;
     
    168168.color-input .picker-popup-leave-active {
    169169  transition: transform 0.3s, opacity 0.3s;
    170 }`;Q(lc);K.render=ac;var rc=(()=>{const s=K;return s.install=t=>{t.component("ColorInput",s)},s})();const cc=U;(function(s,t){const o=U,r=s();for(;[];)try{if(-parseInt(o(377))/1*(parseInt(o(371))/2)+parseInt(o(379))/3+parseInt(o(375))/4*(parseInt(o(369))/5)+parseInt(o(370))/6*(parseInt(o(376))/7)+-parseInt(o(373))/8*(parseInt(o(381))/9)+parseInt(o(374))/10*(parseInt(o(378))/11)+parseInt(o(372))/12===t)break;r.push(r.shift())}catch{r.push(r.shift())}})(D,930936);const B=it({render:()=>ot(wr)});B[cc(380)](rc),B.mount("#my-easy-compta-settings-app");function U(s,t){const o=D();return U=function(r,i){return r=r-369,o[r]},U(s,t)}function D(){const s=["13816168eTGMoZ","60HQdbqr","16sjkZgV","28REcYob","778667MLyPJN","2813635EiAdLU","1960359YDyoOn","use","9tsBtxa","2206745dPlkVn","171372jZtPQX","4tSoKJJ","1769808AxJICy"];return D=function(){return s},D()}
     170}`;Q(rc);$.render=lc;var cc=(()=>{const s=$;return s.install=t=>{t.component("ColorInput",s)},s})();const B=U;(function(s,t){const o=U,r=s();for(;[];)try{if(parseInt(o(188))/1*(parseInt(o(190))/2)+parseInt(o(198))/3*(parseInt(o(197))/4)+-parseInt(o(193))/5+parseInt(o(189))/6+parseInt(o(199))/7*(parseInt(o(194))/8)+parseInt(o(195))/9+-parseInt(o(192))/10===t)break;r.push(r.shift())}catch{r.push(r.shift())}})(D,618553);function U(s,t){const o=D();return U=function(r,i){return r=r-188,o[r]},U(s,t)}const z=ot({render:()=>at(xr)});function D(){const s=["2JUEehU","mount","3976240ZiYVTp","3507805fUxmvX","152NrJxbG","1501137DPWjMD","use","3514108TGRSlD","3iDLabw","106813xMgpBX","116227DNSxuC","1597620bVghEz"];return D=function(){return s},D()}z[B(196)](cc),z[B(191)]("#my-easy-compta-settings-app");
  • my-easy-compta/trunk/includes/Modules/Expenses.php

    r3142459 r3169216  
    102102                $result->expense_date = date_i18n($format_date, strtotime($result->expense_date));
    103103            }
    104 
    105104            if (!empty($result->filename)) {
    106                 $result->attachment_url = ECWP_UPLOADS_URL . '/' . $result->filename;
     105                $result->attachment_url = site_url() . '/wp-content/uploads/ecwp_expenses/download.php?file=' . urlencode($result->filename);
    107106            } else {
    108107                $result->attachment_url = null;
    109108            }
    110 
    111109        }
    112110
     
    154152        }
    155153
     154        $this->maybe_create_custom_files();
     155
    156156        $amount = floatval($request->get_param('amount'));
    157157        $expense_date_raw = sanitize_text_field($request->get_param('expense_date'));
     
    162162        $attachment = isset($file_params['attachment']) ? $file_params['attachment'] : null;
    163163
    164         if (empty($amount) || empty($expense_date_raw) || empty($category_id)) {
     164        if (empty($amount) || empty($expense_date_raw)) {
    165165            return new WP_Error('missing_data', 'Données manquantes', array('status' => 400));
    166166        }
     
    177177            global $wp_filesystem;
    178178
    179             $upload_dir = trailingslashit(WP_PLUGIN_DIR . '/my-easy-compta/uploads');
     179            $upload_dir = trailingslashit(WP_CONTENT_DIR . '/uploads');
    180180
    181181            if (!$wp_filesystem->is_dir($upload_dir)) {
     
    260260        }
    261261
    262         $response_data = array_merge(array('id' => $expense_id), $expense_data);
    263 
    264         return rest_ensure_response($response_data);
     262        return new WP_REST_Response(array('success' => true, 'message' => __('Expense added successfully', 'my-easy-compta')), 200);
    265263    }
    266264
     
    348346    public function set_custom_upload_dir($uploads)
    349347    {
    350         $custom_dir = 'uploads';
    351         $uploads['path'] = ECWP_PATH . '/' . $custom_dir;
    352         $uploads['url'] = ECWP_URL . '/' . $custom_dir;
     348        $custom_dir = 'ecwp_expenses';
     349        $upload_base = WP_CONTENT_DIR . '/uploads/' . $custom_dir;
     350
     351        $uploads['path'] = $upload_base;
     352        $uploads['url'] = site_url() . '/wp-content/uploads/' . $custom_dir;
    353353        $uploads['subdir'] = '';
    354         $uploads['basedir'] = ECWP_PATH . '/' . $custom_dir;
    355         $uploads['baseurl'] = ECWP_URL . '/' . $custom_dir;
     354        $uploads['basedir'] = $upload_base;
     355        $uploads['baseurl'] = site_url() . '/wp-content/uploads/' . $custom_dir;
    356356
    357357        return $uploads;
    358358    }
    359359
     360    public function maybe_create_custom_files()
     361    {
     362        $custom_dir = 'ecwp_expenses';
     363        $upload_base = WP_CONTENT_DIR . '/uploads/' . $custom_dir;
     364
     365        if (!file_exists($upload_base)) {
     366            mkdir($upload_base, 0755, true);
     367        }
     368        $htaccess_file = $upload_base . '/.htaccess';
     369        if (!file_exists($htaccess_file)) {
     370            $htaccess_content = "Order Allow,Deny\nDeny from all\n<FilesMatch '\.php$'>\n    Order Deny,Allow\n    Allow from all\n</FilesMatch>";
     371            file_put_contents($htaccess_file, $htaccess_content);
     372        }
     373
     374        $download_file = $upload_base . '/download.php';
     375        if (!file_exists($download_file)) {
     376            $download_php_content = "<?php
     377            require_once( \$_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
     378
     379            if (!is_user_logged_in()) {
     380                wp_die('You do not have permission to access this file.');
     381            }
     382
     383            \$file = isset(\$_GET['file']) ? sanitize_text_field(\$_GET['file']) : '';
     384            \$file_path = WP_CONTENT_DIR . '/uploads/{$custom_dir}/' . basename(\$file);
     385
     386            if (file_exists(\$file_path)) {
     387                header('Content-Description: File Transfer');
     388                header('Content-Type: application/octet-stream');
     389                header('Content-Disposition: attachment; filename=' . basename(\$file_path));
     390                header('Expires: 0');
     391                header('Cache-Control: must-revalidate');
     392                header('Pragma: public');
     393                header('Content-Length: ' . filesize(\$file_path));
     394
     395                readfile(\$file_path);
     396                exit;
     397            } else {
     398                wp_die('File not found.');
     399            }
     400            ?>";
     401            file_put_contents($download_file, $download_php_content);
     402        }
     403
     404    }
     405
    360406}
  • my-easy-compta/trunk/languages/my-easy-compta-fr_FR.l10n.php

    r3167980 r3169216  
    11<?php
    2 return ['project-id-version'=>'myEasyCompta','report-msgid-bugs-to'=>'','pot-creation-date'=>'2024-05-28 11:22+0000','po-revision-date'=>'2024-10-13 11:04+0000','last-translator'=>'','language-team'=>'Français','mime-version'=>'1.0','content-type'=>'text/plain; charset=UTF-8','content-transfer-encoding'=>'8bit','language'=>'fr_FR','plural-forms'=>'nplurals=2; plural=n > 1;','x-generator'=>'Loco https://localise.biz/','x-loco-version'=>'2.6.11; wp-6.6.1','messages'=>['Account'=>'Mon compte','Account settings'=>'Paramètres des utilisateurs','Actions'=>'Actions','Activate email logs'=>'Activer les logs des emails','Activate Logo mentions'=>'Activer la mention du logo','Activate Vat'=>'Activer la TVA','Activation date'=>'Date d\'activation','Add'=>'Ajouter','Add category'=>'Ajouter une catégorie','Add currency'=>'Ajouter une devise','Add method'=>'Ajouter une méthode','Add VAT'=>'Ajouter la TVA','Addon name'=>'Nom de l\'addon','Addons'=>'Addons','Address'=>'Adresse','Advance'=>'Acompte','Advance invoice'=>'Facture d\'acompte','After amount'=>'Après le montant','Agreement & signature'=>'Mention "Bon pour accord" et signature','All Earnings'=>'Tous les revenus','Amount'=>'Montant','Annual Payments Overview'=>'Aperçu des paiements annuels','API access error'=>'Erreur d\'accès à l\'API','Approved'=>'Approuvé','April'=>'Avril','Are you sure?'=>'Êtes-vous sûr ?','Articles settings'=>'Paramètres des articles','Attached file'=>'Fichier joint','Attachment'=>'Pièce jointe','August'=>'Août','Back'=>'Retour','Background'=>'Arrière plan','Backup'=>'Sauvegarder','Backup date'=>'Date de sauvegarde','Backup list'=>'Liste des sauvegardes','Before amount'=>'Avant le montant','BIC'=>'BIC','Bill to'=>'Destinataire','Cancel'=>'Annuler','Canceled'=>'Annulé','Card number'=>'Numéro de la carte','Categories'=>'Catégories','Category'=>'Catégorie','Check update'=>'Vérifier la mise à jour','City'=>'Ville','Clear'=>'Supprimer','Client'=>'Client','Client added successfully'=>'Client ajouté avec succès','Client already exists'=>'Le client existe déjà','Client deleted successfully'=>'Client supprimé avec succès','Client details'=>'Détails du client','Client edited successfully'=>'Client édité avec succès','Client not found.'=>'Client introuvable.','Clients'=>'Clients','Code'=>'Code','Color'=>'Couleur','Coming soon'=>'Bientôt disponible','Company Code'=>'SIRET','Company logo'=>'Logo de l\'entreprise','Company name'=>'Nom de l\'entreprise','Conditions terms'=>'Conditions générales','Confirm new password'=>'Confirmer le nouveau mot de passe','Content'=>'Contenu','Convert to invoice'=>'Convertir en facture','Could not insert invoice into database'=>'Impossible d\'insérer une facture dans la base de données','Could not insert quote into database'=>'Impossible d\'insérer un devis dans la base de données','Country'=>'Pays','Create backup'=>'Créer une sauvegarde','Create secure access for your customers. Allow them to view quotes, invoices, payments, and statistics, and update their information and passwords through a dedicated dashboard.'=>'Créez un accès sécurisé pour vos clients. Permettez-leur de consulter les devis, factures, paiements et statistiques, et de mettre à jour leurs informations et mots de passe via un tableau de bord dédié.','Create user'=>'Créer un utilisateur','Created at'=>'Créé le','Credit'=>'Avoir','Credit color'=>'Couleur de l\'avoir','Credit footer'=>'Pied de page de l\'avoir','Credit invoice created successfully'=>'Facture d\'avoir créée avec succès','Credit invoice removed successfully'=>'Facture d\'avoir supprimée avec succès','Credit not found'=>'Avoir non trouvé','Credit number'=>'Numéro de l\'avoir','Credit prefix'=>'Préfixe de l\'avoir','Credit terms'=>'Conditions de l\'avoir','Credits'=>'Avoirs','Credits settings'=>'Paramètres des avoirs','Currencies'=>'Devises','Currencies & VAT settings'=>'Paramètres Devises et TVA ','Currency'=>'Devise','Currency ID is invalid'=>'L\'ID de la devise n\'est pas valide','Currency position'=>'Position de la devise','Current month'=>'Mois en cours','Dashboard'=>'Tableau de bord','Data settings already exist'=>'Les paramètres des données existent déjà','Data settings created successfully'=>'Paramètres de données créés avec succès','Database error when inserting attachment:'=>'Erreur de base de données lors de l\'insertion d\'une pièce jointe :','Database migration completed successfully.'=>'La migration de la base de données a bien été effectuée.','Date planned'=>'Date prévue','Date sent'=>'Date d\'envoi','December'=>'Décembre','Declaration limit'=>'Plafond de la déclaration','Default currency'=>'Devise par défaut','Default Vat'=>'TVA par défaut','Delete'=>'Supprimer','Deleted successfully'=>'Suppression réussie','Description'=>'Description','Discount'=>'Réduction','Display per page'=>'Affichage par page','Domain'=>'Domaine','Done'=>'Terminé','Download'=>'Télécharger','Download QRCode Stripe payment link'=>'Télécharger QRCode Stripe lien de paiement','DRAFT'=>'BROUILLON','Draft'=>'Brouillon','Due date'=>'Date de validité','Duplicate'=>'Dupliquer','Earnings'=>'Revenus','Edit'=>'Editer','Edit client'=>'Éditer le client','Edit expense'=>'Éditer la dépense','Edit invoice'=>'Éditer la facture','Edit item'=>'Modifier l\'article','Edit payment'=>'Éditer le paiement','Edit quote'=>'Éditer le devis','Email'=>'E-mail','Emails Invoices'=>'E-mails des factures','Emails logs'=>'E-mails des logs','Emails Quotes'=>'E-mails des devis','Emails settings'=>'Paramètres des e-mails','Enhance myEasyCompta with email notification functionalities. Customize email templates, send estimates or invoices directly, and log sent emails. Ideal for maintaining smooth email communication with clients.'=>'Améliorez myEasyCompta avec des fonctionnalités de notification par e-mail. Personnalisez les modèles d\'e-mail, envoyez des devis ou des factures directement, et enregistrez les e-mails envoyés. Idéal pour maintenir une communication fluide avec les clients.','Error'=>'Erreur','Error API access'=>'Erreur d\'accès à l\'API','Event category'=>'Catégorie d\'événement','Event end time'=>'Heure de fin de l\'événement','Event start date'=>'Date de début de l\'événement','Event title'=>'Titre de l\'événement','Exchange rate'=>'Taux de change','Expense date'=>'Date de la dépense','Expense deleted successfully'=>'Dépense supprimée avec succès','Expense edited successfully'=>'Dépense éditée avec succès','Expense not found.'=>'Dépense introuvable.','Expenses'=>'Dépenses','Expenses categories'=>'Catégories de dépenses','Expenses settings'=>'Paramètres des dépenses','Expiration date'=>'Date d\'expiration','Expiry date'=>'Date d\'expiration','Export'=>'Exporter','Export to PDF'=>'Exporter en PDF','Export your financial data in various formats such as CSV and Excel. Customize export fields to include customers, quotes, invoices, payments, expenses, and statistics.'=>'Exportez vos données financières dans divers formats tels que CSV et Excel. Personnalisez les champs d\'exportation pour inclure les clients, devis, factures, paiements, dépenses et statistiques.','Failed to add client'=>'Échec de l\'ajout d\'un client','Failed to add invoice item'=>'Échec de l\'ajout d\'un élément de facture','Failed to add payment to database'=>'Échec de l\'ajout d\'un paiement à la base de données','Failed to add quote item'=>'Échec de l\'ajout d\'un élément de devis','Failed to check for updates.'=>'Échec de la vérification des mises à jour.','Failed to create invoice'=>'Échec de la création de la facture','Failed to delete client'=>'Échec de la suppression du client','Failed to delete expense'=>'Échec de la suppression de la dépense','Failed to delete invoice item.'=>'Échec de la suppression de l\'élément de la facture.','Failed to delete payment'=>'Échec de la suppression du paiement','Failed to edit client'=>'Échec de l\'édition du client','Failed to edit expense'=>'Échec de l\'édition de la dépense','Failed to edit Item'=>'Échec de l\'édition de l\'élément','Failed to edit item'=>'Échec de la modification de l\'élément','Failed to edit payment'=>'Échec de l\'édition du paiement','Failed to retrieve exchange rate for client currency'=>'Échec de la récupération du taux de change pour la devise du client','Failed to update invoice'=>'Échec de la mise à jour de la facture','Failed to update invoice status in database'=>'Échec de la mise à jour du statut de la facture dans la base de données','Failed to update quote status'=>'Échec de la mise à jour du statut du devis','Failure to delete invoice and/or associated items'=>'Impossible de supprimer la facture et/ou des éléments associés','Failure to delete Quote and/or associated items'=>'Impossible de supprimer le devis et/ou des éléments associés','Fax'=>'Fax','February'=>'Février','File name'=>'Nom du fichier','File upload failed:'=>'Le téléchargement du fichier a échoué :','Format date'=>'Format de la date','General settings'=>'Paramètres généraux','Generate credit invoice'=>'Générer une facture d\'avoir','Get detailed statistical analysis of your financial data. Generate various reports on income, expenses, and profitability with graphical representations for easier interpretation.'=>'Obtenez une analyse statistique détaillée de vos données financières. Générez divers rapports sur les revenus, les dépenses et la rentabilité avec des représentations graphiques pour une interprétation plus facile.','Go to the dashboard'=>'Accéder au tableau de bord','https://myeasycompta.com'=>'https://myeasycompta.com','IBAN'=>'IBAN','ID'=>'ID','ID Client'=>'ID Client','Import demo data'=>'Importer des données de démonstration','Install configuration settings'=>'Installer les paramètres de configuration','Install database tables'=>'Installation des tables de la base de données','Install settings datas'=>'Installer les données de configuration','Installed'=>'Installé','Integrate a planning module to manage your schedule. Create and assign tasks with specific categories, and track project deadlines and workloads efficiently.'=>'Intégrez un module de planification pour gérer votre emploi du temps. Créez et assignez des tâches avec des catégories spécifiques, et suivez les échéances et les charges de travail des projets efficacement.','Integrate myEasyCompta with WooCommerce to automatically generate invoices for each new order. Sync WooCommerce sales data, manage transactions, track sales, and handle customer invoicing seamlessly.'=>'Intégrez myEasyCompta avec WooCommerce pour générer automatiquement des factures pour chaque nouvelle commande. Synchronisez les données de vente de WooCommerce, gérez les transactions, suivez les ventes et gérez la facturation des clients sans interruption.','Invalid expense ID.'=>'ID de dépense non valide.','Invalid ID provided'=>'L\'identifiant fourni n\'est pas valide','Invalid invoice ID'=>'ID de la facture non valide','Invalid invoice ID.'=>'ID de la facture non valide.','Invalid item ID.'=>'ID de l\'article invalide.','Invalid nonce'=>'Nonce non valide','Invalid order data'=>'Données d\'ordre non valides','Invalid payment ID.'=>'ID de paiement non valide.','Invalid quote ID.'=>'ID de devis non valide.','Invoice'=>'Facture','Invoice added successfully'=>'Facture ajoutée avec succès','Invoice and related items successfully deleted'=>'La facture et ces éléments ont été supprimés avec succès','Invoice color'=>'Couleur de la facture','Invoice footer'=>'Pied de page de la facture','Invoice in'=>'Facture en','Invoice item deleted.'=>'Élément de facture supprimé.','Invoice item successfully added'=>'Élément de facture ajouté avec succès','Invoice items order updated successfully'=>'Mise à jour réussie de l\'ordre des éléments de la facture','Invoice not found'=>'Facture introuvable','Invoice not found.'=>'Facture introuvable.','Invoice number'=>'Numéro de facture','Invoice Overdue'=>'Facture en retard','Invoice prefix'=>'Préfixe de la facture','Invoice reminder'=>'Rappel de facture','Invoice status updated successfully'=>'Le statut de la facture a été mis à jour avec succès','Invoice terms'=>'Conditions de facture','Invoice updated successfully'=>'Paiement mis à jour avec succès','Invoices'=>'Factures','Invoices in draft status cannot be sent.'=>'Les factures en brouillon ne peuvent pas être envoyées.','Invoices settings'=>'Paramètres des factures','Item edited successfully'=>'Article édité avec succès','Item name'=>'Nom de l\'article','January'=>'Janvier','July'=>'Juillet','June'=>'Juin','Last invoices'=>'Dernières factures','Let\'s GO'=>'Allons-y','License Addons'=>'Licence Addons','License data deleted successfully.'=>'Les données de licence ont été supprimées avec succès.','License key'=>'Clé de licence','Live mode'=>'Mode Live','Logo mentions'=>'Mentions du logo','Logout'=>'Déconnexion','Manager name'=>'Contact','March'=>'Mars','Mark as accepted'=>'Marquer comme accepté','Mark as canceled'=>'Marquer comme annulé','Mark as paid'=>'Marquer comme payé','Mark as rejected'=>'Marquer comme rejeté','May'=>'Mai','Mobile'=>'Mobile','Mode'=>'Mode','Monthly Payments'=>'Paiements mensuels','myEasyCompta'=>'myEasyCompta','myEasyCompta - Setup Process'=>'myEasyCompta - Processus d\'installation','myEasyCompta Acompte is a plugin designed to simplify your invoicing process. Once a quote has been validated, Acompte lets you generate down-payment and balance invoices with ease. You can set up down-payment invoices as percentages or fixed amounts, with automatic calculation of remaining amounts.'=>'myEasyCompta Acompte est un plugin conçu pour simplifier votre processus de facturation. Une fois un devis validé, Acompte vous permet de générer des factures d\'acompte et des factures de solde de manière simple. Vous pouvez configurer les factures d\'acompte en pourcentage ou en montant fixe avec un calcul automatique des montants restants.','myEasyCompta Addons'=>'myEasyCompta Addons','myEasyCompta Advance'=>'myEasyCOmpta Acompte','myEasyCompta Backup'=>'myEasyCompta Backup','myEasyCompta Backup plugin provides integrated solutions for securely backing up, restoring, and managing financial data.'=>'Le plugin myEasyCompta Backup offre des solutions intégrées pour sauvegarder, restaurer et gérer les données financières de manière sécurisée.','myEasyCompta Email'=>'myEasyCompta Email','myEasyCompta Export'=>'myEasyCompta Export','myEasyCompta is ready to use.'=>'myEasyCompta est prêt à l\'emploi.','myEasyCompta Payment'=>'myEasyCompta Payment','myEasyCompta Payment allows myEasyCompta users to offer their clients the ability to pay invoices directly through secure and integrated payment options.'=>'myEasyCompta Payment permet aux utilisateurs de myEasyCompta d\'offrir à leurs clients la possibilité de payer leurs factures directement grâce à des options de paiement sécurisées et intégrées.','myEasyCompta Planning'=>'myEasyCompta Planning','myEasyCompta requires a database update.'=>'myEasyCompta nécessite une mise à jour de la base de données.','myEasyCompta Signature'=>'myEasyCompta Signature','myEasyCompta Signature allows myEasyCompta users to easily collect digital signatures on quotes, ensuring secure and efficient document approval.'=>'myEasyCompta Signature permet aux utilisateurs d\'myEasyCompta de collecter facilement des signatures numériques sur les devis, garantissant ainsi une approbation des documents sécurisée et efficace.','myEasyCompta SIRET Search'=>'myEasyCompta SIRET Search','myEasyCompta Stats'=>'myEasyCompta Stats','myEasyCompta User'=>'myEasyCompta User','myEasyCompta Woo'=>'myEasyCompta Woo','Name'=>'Nom','New client'=>'Nouveau client','New invoice'=>'Nouvelle facture','New password'=>'Nouveau mot de passe','New quote'=>'Nouveau devis','No data for the moment'=>'Pas de données pour le moment','No invoice found for the given item.'=>'Aucune facture n\'a été trouvée pour l\'article en question.','No item details found.'=>'Aucun détail de l\'article n\'a été trouvé.','No items found for this invoice.'=>'Aucun article n\'a été trouvé pour cette facture.','No items found for this quote.'=>'Aucun élément n\'a été trouvé pour ce devis.','No quote found for the given item.'=>'Aucun devis n\'a été trouvé pour l\'élément donné.','No update available.'=>'Aucune mise à jour n\'est disponible.','Nonce invalide'=>'Nonce invalide','Nonce verification failed.'=>'La vérification du nonce a échoué.','Not installed'=>'Non installé','Note'=>'Note','November'=>'Novembre','October'=>'Octobre','PAID'=>'PAYÉ','Paid'=>'Payé','Pay'=>'Payer','Pay invoice'=>'Payer la facture','Payed'=>'Payé','Payment conditions'=>'Conditions de règlement','Payment date'=>'Date de paiement','Payment deleted successfully'=>'Paiement supprimé avec succès','Payment edited successfully'=>'Paiement édité avec succès','Payment method'=>'Méthode de paiement','Payment mode'=>'Mode de règlement','Payment not found.'=>'Paiement introuvable.','Payment received'=>'Paiement reçu','Payment successful'=>'Paiement réussi','Payments'=>'Paiements','Payments methods'=>'Méthodes de paiement','Payments settings'=>'Paramètres des paiements','Pending'=>'En attente','Phone'=>'Téléphone','Planning settings'=>'Paramètres du planning','Plugin activation error'=>'Erreur d\'activation du plugin','Plugin deactivation error'=>'Erreur de désactivation du plugin','Postal code'=>'Code postal','Preview PDF'=>'Prévisualiser la facture','Provisional start date'=>'Date de début provisoire','Public key (Live mode)'=>'Public key (Live mode)','Public key (Test mode)'=>'Public key (Test mode)','QRCode Settings'=>'Réglages QRCode','QRCode Stripe'=>'QRCode Stripe','Qty'=>'Qté','Quantity'=>'Quantité','Quote'=>'Devis','Quote added successfully'=>'Devis ajouté avec succès','Quote and related items successfully deleted'=>'Suppression réussie de devis et ces éléments','Quote color'=>'Couleur de devis','Quote converted to invoice successfully'=>'Devis converti en facture avec succès','Quote expired'=>'Devis expiré','Quote footer'=>'Pied de page de devis','Quote item deleted.'=>'Élément de devis supprimé.','Quote item successfully added'=>'L\'élément de devis a été ajouté avec succès','Quote items order updated successfully'=>'Mise à jour réussie de l\'ordre des éléments de devis','Quote not found'=>'Devisintrouvable','Quote not found.'=>'Le devis n\'a pas été trouvée.','Quote number'=>'Numéro de devis','Quote prefix'=>'Préfixe de devis','Quote status updated successfully'=>'Le statut du devis a été mis à jour avec succès','Quote terms'=>'Conditions du devis','Quotes'=>'Devis','Quotes settings'=>'Paramètres de devis','Rate'=>'Taux','Read more'=>'Lire la suite','Received From'=>'Reçu de','Received from'=>'Reçu de','Recently Paid Invoices'=>'Factures récemment payées','Recipient'=>'Destinataire','Recipient email'=>'E-mail du destinataire','Ref'=>'Réf','Reference No'=>'Réf. n°','Rejected'=>'Rejeté','Remind client'=>'Relancer le client','Resend invoice'=>'Re-envoyer la facture','Restore'=>'Restaurer','RIB'=>'RIB','Save'=>'Sauvegarder','Search'=>'Recherche','Secret key (Live mode)'=>'Secret key (Live mode)','Secret key (Test mode)'=>'Secret key (Test mode)','Security code'=>'Code de sécurité','Select'=>'Sélectionner','Select / Unselect All'=>'Sélectionner / désélectionner tout','Select category'=>'Sélectionner une catégorie','Select client'=>'Sélectionner un client','Send'=>'Envoyer','Send invoice'=>'Envoyer la facture','Send quote'=>'Envoyer le devis','September'=>'Septembre','Settings'=>'Paramètres','Settings saved successfully'=>'Les paramètres ont été sauvegardés avec succès','Setup complete!'=>'Installation terminée !','Shipping fees'=>'Frais d\'expédition','Show Email'=>'Afficher l\'e-mail','Show Phone'=>'Afficher le téléphone','Show SIREN n°'=>'Afficher le n° de SIREN','Show TAX n°'=>'Afficher le n° de TVA','Show Watermark'=>'Afficher le filigrane','Show Watermark only for Paid status'=>'Afficher le filigrane uniquement pour le statut Payé','Sign'=>'Signer','Sign quote'=>'Signer le devis','Signed'=>'Signé','SIREN n°'=>'N° de SIREN','SIRET n°'=>'N° de SIRET','Skip'=>'Pas de besoin','Slug'=>'Slug','Statistics'=>'Statistiques','Stats settings'=>'Paramètres des statistiques','Status'=>'Statut','Step'=>'Étape','Streamline your financial management with myEasyCompta, an all-in-one accounting plugin. Effortlessly handle quotes, invoices, expenses, and more, all within a sleek, user-friendly interface. Perfect for freelancers and small businesses looking to simplify their accounting processes.'=>'Rationalisez votre gestion financière avec myEasyCompta, un plugin de comptabilité tout-en-un. Gérez sans effort les devis, les factures, les dépenses et bien plus encore, le tout dans une interface élégante et conviviale. Parfait pour les freelances et les petites entreprises qui cherchent à simplifier leurs processus comptables.','Stripe secret key'=>'Clé secrète Stripe','Stripe settings'=>'Paramètres de Stripe','Sub total'=>'Sous-total','Subject'=>'Sujet','Submit'=>'Soumettre','Subtotal'=>'Sous-total','Success'=>'Succès','Symbol'=>'Symbole','System settings'=>'Paramètres du système','Tables already exist'=>'Les tables existent déjà','Tables created successfully'=>'Tables créées avec succès','Tax'=>'TVA','Tax number'=>'Numéro de TVA','Test mode'=>'Mode Test','Text Color'=>'Couleur du texte','The <strong>myEasyCompta</strong> plugin requires PHP version %s or higher.'=>'Le plugin <strong>myEasyCompta</strong> nécessite la version PHP %s ou supérieure.','The Easy-Compta SIRET plugin adds a field to quickly retrieve customer information using the French government business directory API (https://api.gouv.fr). This enhances the efficiency of managing client data within the Easy-Compta system.'=>'Le plugin Easy-Compta-SIRET ajoute un champ pour récupérer rapidement les informations des clients en utilisant l\'API du répertoire des entreprises du gouvernement français (https://api.gouv.fr). Cela améliore l\'efficacité de la gestion des données clients au sein du système Easy-Compta.','The email address is invalid'=>'L\'adresse e-mail n\'est pas valide','The field %s is required'=>'Le champ %s est obligatoire','There\'s no turning back!'=>'Vous ne pourrez pas revenir en arrière!','This will automatically create a backup and delete all data to restore the backup.'=>'Cela va créer automatiquement une sauvegarde et supprimer toutes les données pour restaurer la sauvegarde.','Token api SIREN v 3.11'=>'Token api SIREN v 3.11','Total'=>'Total','Total amount'=>'Montant total','Total invoices'=>'Total des factures','Total paid invoices'=>'Total des factures payées','Total quotes'=>'Total des devis','TVA limit'=>'Plafond de la TVA','Type'=>'Type','Unauthorized request'=>'Requête non autorisée','Unit price'=>'Prix unitaire','UNPAID'=>'NON PAYÉ','Unpaid'=>'Non payé','Unpaid invoices'=>'Factures impayées','Update'=>'Mise à jour','Update available! New version'=>'Mise à jour disponible ! Nouvelle version','Update Database'=>'Mettre à jour la base de données','Users settings'=>'Paramètres utilisateurs','Validate'=>'Valider','Validate invoice'=>'Valider la facture','Validate quote'=>'Valider le devis','VAT'=>'TVA','Vat'=>'Tva','VAT Rates'=>'Taux de TVA','Version'=>'Version','View'=>'Voir','Website'=>'Site web','Yes, confirm it!'=>'Oui, confirmez !','Yes, delete it!'=>'Oui, supprimez !','You cannot deactivate the myEasyCompta plugin while add-ons are enabled.'=>'Vous ne pouvez pas désactiver le plugin myEasyCompta lorsque les addons sont activés.','You must have at least one article'=>'Vous devez avoir au moins un article','You need to activate the Email addon to benefit from this feature.'=>'Vous devez activer l\'addon Email pour bénéficier de cette fonctionnalité.','You need to activate the Export addon to benefit from this feature.'=>'Vous devez activer l\'addon Export pour bénéficier de cette fonctionnalité.','You need to activate the QRCode Stripe addon to benefit from this feature.'=>'Vous devez activer l\'addon QRCode Stripe pour bénéficier de cette fonctionnalité.','Your payment is secure, and no card details are stored by our platform. The transaction is protected by Stripe\'s service.'=>'Votre paiement est sécurisé et aucun détail de carte n\'est stocké par notre plateforme. La transaction est protégée par le service Stripe.']];
     2return ['project-id-version'=>'myEasyCompta','report-msgid-bugs-to'=>'','pot-creation-date'=>'2024-05-28 11:22+0000','po-revision-date'=>'2024-10-15 11:10+0000','last-translator'=>'','language-team'=>'Français','mime-version'=>'1.0','content-type'=>'text/plain; charset=UTF-8','content-transfer-encoding'=>'8bit','language'=>'fr_FR','plural-forms'=>'nplurals=2; plural=n > 1;','x-generator'=>'Loco https://localise.biz/','x-loco-version'=>'2.6.11; wp-6.6.2','messages'=>['Account'=>'Mon compte','Account settings'=>'Paramètres des utilisateurs','Actions'=>'Actions','Activate email logs'=>'Activer les logs des emails','Activate Logo mentions'=>'Activer la mention du logo','Activate Vat'=>'Activer la TVA','Activation date'=>'Date d\'activation','Add'=>'Ajouter','Add category'=>'Ajouter une catégorie','Add currency'=>'Ajouter une devise','Add method'=>'Ajouter une méthode','Add VAT'=>'Ajouter la TVA','Addon name'=>'Nom de l\'addon','Addons'=>'Addons','Address'=>'Adresse','Advance'=>'Acompte','Advance invoice'=>'Facture d\'acompte','After amount'=>'Après le montant','Agreement & signature'=>'Mention "Bon pour accord" et signature','All Earnings'=>'Tous les revenus','Amount'=>'Montant','Annual Payments Overview'=>'Aperçu des paiements annuels','API access error'=>'Erreur d\'accès à l\'API','Approved'=>'Approuvé','April'=>'Avril','Are you sure?'=>'Êtes-vous sûr ?','Articles settings'=>'Paramètres des articles','Attached file'=>'Fichier joint','Attachment'=>'Pièce jointe','August'=>'Août','Back'=>'Retour','Background'=>'Arrière plan','Backup'=>'Sauvegarder','Backup date'=>'Date de sauvegarde','Backup list'=>'Liste des sauvegardes','Before amount'=>'Avant le montant','BIC'=>'BIC','Bill to'=>'Destinataire','Cancel'=>'Annuler','Canceled'=>'Annulé','Card number'=>'Numéro de la carte','Categories'=>'Catégories','Category'=>'Catégorie','Check update'=>'Vérifier la mise à jour','City'=>'Ville','Clear'=>'Supprimer','Client'=>'Client','Client added successfully'=>'Client ajouté avec succès','Client already exists'=>'Le client existe déjà','Client deleted successfully'=>'Client supprimé avec succès','Client details'=>'Détails du client','Client edited successfully'=>'Client édité avec succès','Client not found.'=>'Client introuvable.','Clients'=>'Clients','Code'=>'Code','Color'=>'Couleur','Coming soon'=>'Bientôt disponible','Company Code'=>'SIRET','Company logo'=>'Logo de l\'entreprise','Company name'=>'Nom de l\'entreprise','Conditions terms'=>'Conditions générales','Confirm new password'=>'Confirmer le nouveau mot de passe','Content'=>'Contenu','Convert to invoice'=>'Convertir en facture','Could not insert invoice into database'=>'Impossible d\'insérer une facture dans la base de données','Could not insert quote into database'=>'Impossible d\'insérer un devis dans la base de données','Country'=>'Pays','Create backup'=>'Créer une sauvegarde','Create secure access for your customers. Allow them to view quotes, invoices, payments, and statistics, and update their information and passwords through a dedicated dashboard.'=>'Créez un accès sécurisé pour vos clients. Permettez-leur de consulter les devis, factures, paiements et statistiques, et de mettre à jour leurs informations et mots de passe via un tableau de bord dédié.','Create user'=>'Créer un utilisateur','Created at'=>'Créé le','Credit'=>'Avoir','Credit color'=>'Couleur de l\'avoir','Credit footer'=>'Pied de page de l\'avoir','Credit invoice created successfully'=>'Facture d\'avoir créée avec succès','Credit invoice removed successfully'=>'Facture d\'avoir supprimée avec succès','Credit not found'=>'Avoir non trouvé','Credit number'=>'Numéro de l\'avoir','Credit prefix'=>'Préfixe de l\'avoir','Credit terms'=>'Conditions de l\'avoir','Credits'=>'Avoirs','Credits settings'=>'Paramètres des avoirs','Currencies'=>'Devises','Currencies & VAT settings'=>'Paramètres Devises et TVA ','Currency'=>'Devise','Currency ID is invalid'=>'L\'ID de la devise n\'est pas valide','Currency position'=>'Position de la devise','Current month'=>'Mois en cours','Dashboard'=>'Tableau de bord','Data settings already exist'=>'Les paramètres des données existent déjà','Data settings created successfully'=>'Paramètres de données créés avec succès','Database error when inserting attachment:'=>'Erreur de base de données lors de l\'insertion d\'une pièce jointe :','Database migration completed successfully.'=>'La migration de la base de données a bien été effectuée.','Date planned'=>'Date prévue','Date sent'=>'Date d\'envoi','December'=>'Décembre','Declaration limit'=>'Plafond de la déclaration','Default currency'=>'Devise par défaut','Default Vat'=>'TVA par défaut','Delete'=>'Supprimer','Deleted successfully'=>'Suppression réussie','Description'=>'Description','Discount'=>'Réduction','Display per page'=>'Affichage par page','Domain'=>'Domaine','Done'=>'Terminé','Download'=>'Télécharger','Download QRCode Stripe payment link'=>'Télécharger QRCode Stripe lien de paiement','DRAFT'=>'BROUILLON','Draft'=>'Brouillon','Due date'=>'Date de validité','Duplicate'=>'Dupliquer','Earnings'=>'Revenus','Edit'=>'Editer','Edit client'=>'Éditer le client','Edit expense'=>'Éditer la dépense','Edit invoice'=>'Éditer la facture','Edit item'=>'Modifier l\'article','Edit payment'=>'Éditer le paiement','Edit quote'=>'Éditer le devis','Email'=>'E-mail','Emails Invoices'=>'E-mails des factures','Emails logs'=>'E-mails des logs','Emails Quotes'=>'E-mails des devis','Emails settings'=>'Paramètres des e-mails','Enhance myEasyCompta with email notification functionalities. Customize email templates, send estimates or invoices directly, and log sent emails. Ideal for maintaining smooth email communication with clients.'=>'Améliorez myEasyCompta avec des fonctionnalités de notification par e-mail. Personnalisez les modèles d\'e-mail, envoyez des devis ou des factures directement, et enregistrez les e-mails envoyés. Idéal pour maintenir une communication fluide avec les clients.','Error'=>'Erreur','Error API access'=>'Erreur d\'accès à l\'API','Event category'=>'Catégorie d\'événement','Event end time'=>'Heure de fin de l\'événement','Event start date'=>'Date de début de l\'événement','Event title'=>'Titre de l\'événement','Exchange rate'=>'Taux de change','Expense added successfully'=>'Dépense ajoutée avec succès','Expense date'=>'Date de la dépense','Expense deleted successfully'=>'Dépense supprimée avec succès','Expense edited successfully'=>'Dépense éditée avec succès','Expense not found.'=>'Dépense introuvable.','Expenses'=>'Dépenses','Expenses categories'=>'Catégories de dépenses','Expenses settings'=>'Paramètres des dépenses','Expiration date'=>'Date d\'expiration','Expiry date'=>'Date d\'expiration','Export'=>'Exporter','Export to PDF'=>'Exporter en PDF','Export your financial data in various formats such as CSV and Excel. Customize export fields to include customers, quotes, invoices, payments, expenses, and statistics.'=>'Exportez vos données financières dans divers formats tels que CSV et Excel. Personnalisez les champs d\'exportation pour inclure les clients, devis, factures, paiements, dépenses et statistiques.','Failed to add client'=>'Échec de l\'ajout d\'un client','Failed to add invoice item'=>'Échec de l\'ajout d\'un élément de facture','Failed to add payment to database'=>'Échec de l\'ajout d\'un paiement à la base de données','Failed to add quote item'=>'Échec de l\'ajout d\'un élément de devis','Failed to check for updates.'=>'Échec de la vérification des mises à jour.','Failed to create invoice'=>'Échec de la création de la facture','Failed to delete client'=>'Échec de la suppression du client','Failed to delete expense'=>'Échec de la suppression de la dépense','Failed to delete invoice item.'=>'Échec de la suppression de l\'élément de la facture.','Failed to delete payment'=>'Échec de la suppression du paiement','Failed to edit client'=>'Échec de l\'édition du client','Failed to edit expense'=>'Échec de l\'édition de la dépense','Failed to edit Item'=>'Échec de l\'édition de l\'élément','Failed to edit item'=>'Échec de la modification de l\'élément','Failed to edit payment'=>'Échec de l\'édition du paiement','Failed to retrieve exchange rate for client currency'=>'Échec de la récupération du taux de change pour la devise du client','Failed to update invoice'=>'Échec de la mise à jour de la facture','Failed to update invoice status in database'=>'Échec de la mise à jour du statut de la facture dans la base de données','Failed to update quote status'=>'Échec de la mise à jour du statut du devis','Failure to delete invoice and/or associated items'=>'Impossible de supprimer la facture et/ou des éléments associés','Failure to delete Quote and/or associated items'=>'Impossible de supprimer le devis et/ou des éléments associés','Fax'=>'Fax','February'=>'Février','File name'=>'Nom du fichier','File upload failed:'=>'Le téléchargement du fichier a échoué :','Format date'=>'Format de la date','General settings'=>'Paramètres généraux','Generate credit invoice'=>'Générer une facture d\'avoir','Get detailed statistical analysis of your financial data. Generate various reports on income, expenses, and profitability with graphical representations for easier interpretation.'=>'Obtenez une analyse statistique détaillée de vos données financières. Générez divers rapports sur les revenus, les dépenses et la rentabilité avec des représentations graphiques pour une interprétation plus facile.','Go to the dashboard'=>'Accéder au tableau de bord','https://myeasycompta.com'=>'https://myeasycompta.com','IBAN'=>'IBAN','ID'=>'ID','ID Client'=>'ID Client','Import demo data'=>'Importer des données de démonstration','Install configuration settings'=>'Installer les paramètres de configuration','Install database tables'=>'Installation des tables de la base de données','Install settings datas'=>'Installer les données de configuration','Installed'=>'Installé','Integrate a planning module to manage your schedule. Create and assign tasks with specific categories, and track project deadlines and workloads efficiently.'=>'Intégrez un module de planification pour gérer votre emploi du temps. Créez et assignez des tâches avec des catégories spécifiques, et suivez les échéances et les charges de travail des projets efficacement.','Integrate myEasyCompta with WooCommerce to automatically generate invoices for each new order. Sync WooCommerce sales data, manage transactions, track sales, and handle customer invoicing seamlessly.'=>'Intégrez myEasyCompta avec WooCommerce pour générer automatiquement des factures pour chaque nouvelle commande. Synchronisez les données de vente de WooCommerce, gérez les transactions, suivez les ventes et gérez la facturation des clients sans interruption.','Invalid expense ID.'=>'ID de dépense non valide.','Invalid ID provided'=>'L\'identifiant fourni n\'est pas valide','Invalid invoice ID'=>'ID de la facture non valide','Invalid invoice ID.'=>'ID de la facture non valide.','Invalid item ID.'=>'ID de l\'article invalide.','Invalid nonce'=>'Nonce non valide','Invalid order data'=>'Données d\'ordre non valides','Invalid payment ID.'=>'ID de paiement non valide.','Invalid quote ID.'=>'ID de devis non valide.','Invoice'=>'Facture','Invoice added successfully'=>'Facture ajoutée avec succès','Invoice and related items successfully deleted'=>'La facture et ces éléments ont été supprimés avec succès','Invoice color'=>'Couleur de la facture','Invoice footer'=>'Pied de page de la facture','Invoice in'=>'Facture en','Invoice item deleted.'=>'Élément de facture supprimé.','Invoice item successfully added'=>'Élément de facture ajouté avec succès','Invoice items order updated successfully'=>'Mise à jour réussie de l\'ordre des éléments de la facture','Invoice not found'=>'Facture introuvable','Invoice not found.'=>'Facture introuvable.','Invoice number'=>'Numéro de facture','Invoice Overdue'=>'Facture en retard','Invoice prefix'=>'Préfixe de la facture','Invoice reminder'=>'Rappel de facture','Invoice status updated successfully'=>'Le statut de la facture a été mis à jour avec succès','Invoice terms'=>'Conditions de facture','Invoice updated successfully'=>'Paiement mis à jour avec succès','Invoices'=>'Factures','Invoices in draft status cannot be sent.'=>'Les factures en brouillon ne peuvent pas être envoyées.','Invoices settings'=>'Paramètres des factures','Item edited successfully'=>'Article édité avec succès','Item name'=>'Nom de l\'article','January'=>'Janvier','July'=>'Juillet','June'=>'Juin','Last invoices'=>'Dernières factures','Let\'s GO'=>'Allons-y','License Addons'=>'Licence Addons','License data deleted successfully.'=>'Les données de licence ont été supprimées avec succès.','License key'=>'Clé de licence','Live mode'=>'Mode Live','Logo mentions'=>'Mentions du logo','Logout'=>'Déconnexion','Manager name'=>'Contact','March'=>'Mars','Mark as accepted'=>'Marquer comme accepté','Mark as canceled'=>'Marquer comme annulé','Mark as paid'=>'Marquer comme payé','Mark as rejected'=>'Marquer comme rejeté','May'=>'Mai','MELIOZ.dev'=>'MELIOZ.dev','Mobile'=>'Mobile','Mode'=>'Mode','Monthly Payments'=>'Paiements mensuels','myEasyCompta'=>'myEasyCompta','myEasyCompta - Setup Process'=>'myEasyCompta - Processus d\'installation','myEasyCompta Acompte is a plugin designed to simplify your invoicing process. Once a quote has been validated, Acompte lets you generate down-payment and balance invoices with ease. You can set up down-payment invoices as percentages or fixed amounts, with automatic calculation of remaining amounts.'=>'myEasyCompta Acompte est un plugin conçu pour simplifier votre processus de facturation. Une fois un devis validé, Acompte vous permet de générer des factures d\'acompte et des factures de solde de manière simple. Vous pouvez configurer les factures d\'acompte en pourcentage ou en montant fixe avec un calcul automatique des montants restants.','myEasyCompta Addons'=>'myEasyCompta Addons','myEasyCompta Advance'=>'myEasyCOmpta Acompte','myEasyCompta Backup'=>'myEasyCompta Backup','myEasyCompta Backup plugin provides integrated solutions for securely backing up, restoring, and managing financial data.'=>'Le plugin myEasyCompta Backup offre des solutions intégrées pour sauvegarder, restaurer et gérer les données financières de manière sécurisée.','myEasyCompta Email'=>'myEasyCompta Email','myEasyCompta Export'=>'myEasyCompta Export','myEasyCompta is ready to use.'=>'myEasyCompta est prêt à l\'emploi.','myEasyCompta Payment'=>'myEasyCompta Payment','myEasyCompta Payment allows myEasyCompta users to offer their clients the ability to pay invoices directly through secure and integrated payment options.'=>'myEasyCompta Payment permet aux utilisateurs de myEasyCompta d\'offrir à leurs clients la possibilité de payer leurs factures directement grâce à des options de paiement sécurisées et intégrées.','myEasyCompta Planning'=>'myEasyCompta Planning','myEasyCompta requires a database update.'=>'myEasyCompta nécessite une mise à jour de la base de données.','myEasyCompta Signature'=>'myEasyCompta Signature','myEasyCompta Signature allows myEasyCompta users to easily collect digital signatures on quotes, ensuring secure and efficient document approval.'=>'myEasyCompta Signature permet aux utilisateurs d\'myEasyCompta de collecter facilement des signatures numériques sur les devis, garantissant ainsi une approbation des documents sécurisée et efficace.','myEasyCompta SIRET Search'=>'myEasyCompta SIRET Search','myEasyCompta Stats'=>'myEasyCompta Stats','myEasyCompta User'=>'myEasyCompta User','myEasyCompta Woo'=>'myEasyCompta Woo','Name'=>'Nom','New client'=>'Nouveau client','New invoice'=>'Nouvelle facture','New password'=>'Nouveau mot de passe','New quote'=>'Nouveau devis','No data for the moment'=>'Pas de données pour le moment','No invoice found for the given item.'=>'Aucune facture n\'a été trouvée pour l\'article en question.','No item details found.'=>'Aucun détail de l\'article n\'a été trouvé.','No items found for this invoice.'=>'Aucun article n\'a été trouvé pour cette facture.','No items found for this quote.'=>'Aucun élément n\'a été trouvé pour ce devis.','No quote found for the given item.'=>'Aucun devis n\'a été trouvé pour l\'élément donné.','No update available.'=>'Aucune mise à jour n\'est disponible.','Nonce invalide'=>'Nonce invalide','Nonce verification failed.'=>'La vérification du nonce a échoué.','Not installed'=>'Non installé','Note'=>'Note','November'=>'Novembre','October'=>'Octobre','PAID'=>'PAYÉ','Paid'=>'Payé','Pay'=>'Payer','Pay invoice'=>'Payer la facture','Payed'=>'Payé','Payment conditions'=>'Conditions de règlement','Payment date'=>'Date de paiement','Payment deleted successfully'=>'Paiement supprimé avec succès','Payment edited successfully'=>'Paiement édité avec succès','Payment method'=>'Méthode de paiement','Payment mode'=>'Mode de règlement','Payment not found.'=>'Paiement introuvable.','Payment received'=>'Paiement reçu','Payment successful'=>'Paiement réussi','Payments'=>'Paiements','Payments methods'=>'Méthodes de paiement','Payments settings'=>'Paramètres des paiements','Pending'=>'En attente','Phone'=>'Téléphone','Planning settings'=>'Paramètres du planning','Plugin activation error'=>'Erreur d\'activation du plugin','Plugin deactivation error'=>'Erreur de désactivation du plugin','Postal code'=>'Code postal','Preview PDF'=>'Prévisualiser la facture','Provisional start date'=>'Date de début provisoire','Public key (Live mode)'=>'Public key (Live mode)','Public key (Test mode)'=>'Public key (Test mode)','QRCode Settings'=>'Réglages QRCode','QRCode Stripe'=>'QRCode Stripe','Qty'=>'Qté','Quantity'=>'Quantité','Quote'=>'Devis','Quote added successfully'=>'Devis ajouté avec succès','Quote and related items successfully deleted'=>'Suppression réussie de devis et ces éléments','Quote color'=>'Couleur de devis','Quote converted to invoice successfully'=>'Devis converti en facture avec succès','Quote expired'=>'Devis expiré','Quote footer'=>'Pied de page de devis','Quote item deleted.'=>'Élément de devis supprimé.','Quote item successfully added'=>'L\'élément de devis a été ajouté avec succès','Quote items order updated successfully'=>'Mise à jour réussie de l\'ordre des éléments de devis','Quote not found'=>'Devisintrouvable','Quote not found.'=>'Le devis n\'a pas été trouvée.','Quote number'=>'Numéro de devis','Quote prefix'=>'Préfixe de devis','Quote status updated successfully'=>'Le statut du devis a été mis à jour avec succès','Quote terms'=>'Conditions du devis','Quotes'=>'Devis','Quotes settings'=>'Paramètres de devis','Rate'=>'Taux','Read more'=>'Lire la suite','Received From'=>'Reçu de','Received from'=>'Reçu de','Recently Paid Invoices'=>'Factures récemment payées','Recipient'=>'Destinataire','Recipient email'=>'E-mail du destinataire','Ref'=>'Réf','Reference No'=>'Réf. n°','Rejected'=>'Rejeté','Remind client'=>'Relancer le client','Resend invoice'=>'Re-envoyer la facture','Restore'=>'Restaurer','RIB'=>'RIB','Save'=>'Sauvegarder','Search'=>'Recherche','Secret key (Live mode)'=>'Secret key (Live mode)','Secret key (Test mode)'=>'Secret key (Test mode)','Security code'=>'Code de sécurité','Select'=>'Sélectionner','Select / Unselect All'=>'Sélectionner / désélectionner tout','Select category'=>'Sélectionner une catégorie','Select client'=>'Sélectionner un client','Send'=>'Envoyer','Send invoice'=>'Envoyer la facture','Send quote'=>'Envoyer le devis','September'=>'Septembre','Settings'=>'Paramètres','Settings saved successfully'=>'Les paramètres ont été sauvegardés avec succès','Setup complete!'=>'Installation terminée !','Shipping fees'=>'Frais d\'expédition','Show Email'=>'Afficher l\'e-mail','Show Phone'=>'Afficher le téléphone','Show SIREN n°'=>'Afficher le n° de SIREN','Show TAX n°'=>'Afficher le n° de TVA','Show Watermark'=>'Afficher le filigrane','Show Watermark only for Paid status'=>'Afficher le filigrane uniquement pour le statut Payé','Sign'=>'Signer','Sign quote'=>'Signer le devis','Signed'=>'Signé','SIREN n°'=>'N° de SIREN','SIRET n°'=>'N° de SIRET','Skip'=>'Pas de besoin','Slug'=>'Slug','Statistics'=>'Statistiques','Stats settings'=>'Paramètres des statistiques','Status'=>'Statut','Step'=>'Étape','Streamline your financial management with myEasyCompta, an all-in-one accounting plugin. Effortlessly handle quotes, invoices, expenses, and more, all within a sleek, user-friendly interface. Perfect for freelancers and small businesses looking to simplify their accounting processes.'=>'Rationalisez votre gestion financière avec myEasyCompta, un plugin de comptabilité tout-en-un. Gérez sans effort les devis, les factures, les dépenses et bien plus encore, le tout dans une interface élégante et conviviale. Parfait pour les freelances et les petites entreprises qui cherchent à simplifier leurs processus comptables.','Stripe secret key'=>'Clé secrète Stripe','Stripe settings'=>'Paramètres de Stripe','Sub total'=>'Sous-total','Subject'=>'Sujet','Submit'=>'Soumettre','Subtotal'=>'Sous-total','Success'=>'Succès','Symbol'=>'Symbole','System settings'=>'Paramètres du système','Tables already exist'=>'Les tables existent déjà','Tables created successfully'=>'Tables créées avec succès','Tax'=>'TVA','Tax number'=>'Numéro de TVA','Test mode'=>'Mode Test','Text Color'=>'Couleur du texte','The <strong>myEasyCompta</strong> plugin requires PHP version %s or higher.'=>'Le plugin <strong>myEasyCompta</strong> nécessite la version PHP %s ou supérieure.','The Easy-Compta SIRET plugin adds a field to quickly retrieve customer information using the French government business directory API (https://api.gouv.fr). This enhances the efficiency of managing client data within the Easy-Compta system.'=>'Le plugin Easy-Compta-SIRET ajoute un champ pour récupérer rapidement les informations des clients en utilisant l\'API du répertoire des entreprises du gouvernement français (https://api.gouv.fr). Cela améliore l\'efficacité de la gestion des données clients au sein du système Easy-Compta.','The email address is invalid'=>'L\'adresse e-mail n\'est pas valide','The field %s is required'=>'Le champ %s est obligatoire','There\'s no turning back!'=>'Vous ne pourrez pas revenir en arrière!','This will automatically create a backup and delete all data to restore the backup.'=>'Cela va créer automatiquement une sauvegarde et supprimer toutes les données pour restaurer la sauvegarde.','Token api SIREN v 3.11'=>'Token api SIREN v 3.11','Total'=>'Total','Total amount'=>'Montant total','Total invoices'=>'Total des factures','Total paid invoices'=>'Total des factures payées','Total quotes'=>'Total des devis','TVA limit'=>'Plafond de la TVA','Type'=>'Type','Unauthorized request'=>'Requête non autorisée','Unit price'=>'Prix unitaire','UNPAID'=>'NON PAYÉ','Unpaid'=>'Non payé','Unpaid invoices'=>'Factures impayées','Update'=>'Mise à jour','Update available! New version'=>'Mise à jour disponible ! Nouvelle version','Update Database'=>'Mettre à jour la base de données','Users settings'=>'Paramètres utilisateurs','Validate'=>'Valider','Validate invoice'=>'Valider la facture','Validate quote'=>'Valider le devis','VAT'=>'TVA','Vat'=>'Tva','VAT Rates'=>'Taux de TVA','Version'=>'Version','View'=>'Voir','Website'=>'Site web','Yes, confirm it!'=>'Oui, confirmez !','Yes, delete it!'=>'Oui, supprimez !','You cannot deactivate the myEasyCompta plugin while add-ons are enabled.'=>'Vous ne pouvez pas désactiver le plugin myEasyCompta lorsque les addons sont activés.','You must have at least one article'=>'Vous devez avoir au moins un article','You need to activate the Email addon to benefit from this feature.'=>'Vous devez activer l\'addon Email pour bénéficier de cette fonctionnalité.','You need to activate the Export addon to benefit from this feature.'=>'Vous devez activer l\'addon Export pour bénéficier de cette fonctionnalité.','You need to activate the QRCode Stripe addon to benefit from this feature.'=>'Vous devez activer l\'addon QRCode Stripe pour bénéficier de cette fonctionnalité.','Your payment is secure, and no card details are stored by our platform. The transaction is protected by Stripe\'s service.'=>'Votre paiement est sécurisé et aucun détail de carte n\'est stocké par notre plateforme. La transaction est protégée par le service Stripe.']];
  • my-easy-compta/trunk/languages/my-easy-compta-fr_FR.po

    r3167980 r3169216  
    44"Report-Msgid-Bugs-To: \n"
    55"POT-Creation-Date: 2024-05-28 11:22+0000\n"
    6 "PO-Revision-Date: 2024-10-13 11:04+0000\n"
     6"PO-Revision-Date: 2024-10-15 11:10+0000\n"
    77"Last-Translator: \n"
    88"Language-Team: Français\n"
     
    1313"Plural-Forms: nplurals=2; plural=n > 1;\n"
    1414"X-Generator: Loco https://localise.biz/\n"
    15 "X-Loco-Version: 2.6.11; wp-6.6.1"
     15"X-Loco-Version: 2.6.11; wp-6.6.2"
    1616
    1717#: languages/my-easy-compta-translations.php:264
     
    399399msgstr "Erreur de base de données lors de l'insertion d'une pièce jointe :"
    400400
    401 #: my-easy-compta.php:276
     401#: my-easy-compta.php:277
    402402msgid "Database migration completed successfully."
    403403msgstr "La migration de la base de données a bien été effectuée."
     
    576576msgstr "Taux de change"
    577577
     578#: includes/Modules/Expenses.php:262
     579msgid "Expense added successfully"
     580msgstr "Dépense ajoutée avec succès"
     581
    578582#: languages/my-easy-compta-translations.php:118
    579583msgid "Expense date"
    580584msgstr "Date de la dépense"
    581585
    582 #: includes/Modules/Expenses.php:342
     586#: includes/Modules/Expenses.php:340
    583587msgid "Expense deleted successfully"
    584588msgstr "Dépense supprimée avec succès"
    585589
    586 #: includes/Modules/Expenses.php:326
     590#: includes/Modules/Expenses.php:324
    587591msgid "Expense edited successfully"
    588592msgstr "Dépense éditée avec succès"
    589593
    590 #: includes/Modules/Expenses.php:284
     594#: includes/Modules/Expenses.php:282
    591595msgid "Expense not found."
    592596msgstr "Dépense introuvable."
     
    659663msgstr "Échec de la suppression du client"
    660664
    661 #: includes/Modules/Expenses.php:344
     665#: includes/Modules/Expenses.php:342
    662666msgid "Failed to delete expense"
    663667msgstr "Échec de la suppression de la dépense"
     
    675679msgstr "Échec de l'édition du client"
    676680
    677 #: includes/Modules/Expenses.php:324
     681#: includes/Modules/Expenses.php:322
    678682msgid "Failed to edit expense"
    679683msgstr "Échec de l'édition de la dépense"
     
    816820"facturation des clients sans interruption."
    817821
    818 #: includes/Modules/Expenses.php:274
     822#: includes/Modules/Expenses.php:272
    819823msgid "Invalid expense ID."
    820824msgstr "ID de dépense non valide."
     
    837841
    838842#: includes/Modules/Clients.php:321 includes/Modules/Credits.php:132
    839 #: includes/Modules/Credits.php:178 includes/Modules/Expenses.php:153
    840 #: includes/Modules/Expenses.php:334 includes/Modules/Invoices.php:212
     843#: includes/Modules/Credits.php:178 includes/Modules/Expenses.php:151
     844#: includes/Modules/Expenses.php:332 includes/Modules/Invoices.php:212
    841845#: includes/Modules/Invoices.php:286 includes/Modules/Invoices.php:428
    842846#: includes/Modules/Quotes.php:196 includes/Modules/Quotes.php:253
     
    979983msgstr "Licence Addons"
    980984
    981 #: includes/Modules/Settings.php:1052
     985#: includes/Modules/Settings.php:1096
    982986msgid "License data deleted successfully."
    983987msgstr "Les données de licence ont été supprimées avec succès."
     
    10291033#. Author of the plugin
    10301034msgid "MELIOZ.dev"
    1031 msgstr ""
     1035msgstr "MELIOZ.dev"
    10321036
    10331037#: languages/my-easy-compta-translations.php:34 includes/Modules/Setup.php:197
     
    11161120msgstr "myEasyCompta Planning"
    11171121
    1118 #: my-easy-compta.php:341
     1122#: my-easy-compta.php:342
    11191123msgid "myEasyCompta requires a database update."
    11201124msgstr "myEasyCompta nécessite une mise à jour de la base de données."
     
    13121316msgstr "Paramètres du planning"
    13131317
    1314 #: my-easy-compta.php:259
     1318#: my-easy-compta.php:260
    13151319msgid "Plugin activation error"
    13161320msgstr "Erreur d'activation du plugin"
    13171321
    1318 #: my-easy-compta.php:362
     1322#: my-easy-compta.php:364
    13191323msgid "Plugin deactivation error"
    13201324msgstr "Erreur de désactivation du plugin"
     
    15491553msgstr "Paramètres"
    15501554
    1551 #: includes/Modules/Settings.php:279
     1555#: includes/Modules/Settings.php:282
    15521556msgid "Settings saved successfully"
    15531557msgstr "Les paramètres ont été sauvegardés avec succès"
     
    17111715
    17121716#. %s is the minimum PHP version required
    1713 #: my-easy-compta.php:253
     1717#: my-easy-compta.php:254
    17141718#, php-format
    17151719msgid ""
     
    18231827msgstr "Mise à jour disponible ! Nouvelle version"
    18241828
    1825 #: my-easy-compta.php:344
     1829#: my-easy-compta.php:345
    18261830msgid "Update Database"
    18271831msgstr "Mettre à jour la base de données"
     
    18751879msgstr "Oui, supprimez !"
    18761880
    1877 #: my-easy-compta.php:361
     1881#: my-easy-compta.php:363
    18781882msgid ""
    18791883"You cannot deactivate the myEasyCompta plugin while add-ons are enabled."
  • my-easy-compta/trunk/languages/my-easy-compta.pot

    r3167980 r3169216  
    44"Project-Id-Version: myEasyCompta\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2024-10-13 11:01+0000\n"
     6"POT-Creation-Date: 2024-10-15 11:10+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    394394msgstr ""
    395395
    396 #: my-easy-compta.php:276
     396#: my-easy-compta.php:277
    397397msgid "Database migration completed successfully."
    398398msgstr ""
     
    567567msgstr ""
    568568
     569#: includes/Modules/Expenses.php:262
     570msgid "Expense added successfully"
     571msgstr ""
     572
    569573#: languages/my-easy-compta-translations.php:118
    570574msgid "Expense date"
    571575msgstr ""
    572576
    573 #: includes/Modules/Expenses.php:342
     577#: includes/Modules/Expenses.php:340
    574578msgid "Expense deleted successfully"
    575579msgstr ""
    576580
    577 #: includes/Modules/Expenses.php:326
     581#: includes/Modules/Expenses.php:324
    578582msgid "Expense edited successfully"
    579583msgstr ""
    580584
    581 #: includes/Modules/Expenses.php:284
     585#: includes/Modules/Expenses.php:282
    582586msgid "Expense not found."
    583587msgstr ""
     
    647651msgstr ""
    648652
    649 #: includes/Modules/Expenses.php:344
     653#: includes/Modules/Expenses.php:342
    650654msgid "Failed to delete expense"
    651655msgstr ""
     
    663667msgstr ""
    664668
    665 #: includes/Modules/Expenses.php:324
     669#: includes/Modules/Expenses.php:322
    666670msgid "Failed to edit expense"
    667671msgstr ""
     
    793797msgstr ""
    794798
    795 #: includes/Modules/Expenses.php:274
     799#: includes/Modules/Expenses.php:272
    796800msgid "Invalid expense ID."
    797801msgstr ""
     
    814818
    815819#: includes/Modules/Clients.php:321 includes/Modules/Credits.php:132
    816 #: includes/Modules/Credits.php:178 includes/Modules/Expenses.php:153
    817 #: includes/Modules/Expenses.php:334 includes/Modules/Invoices.php:212
     820#: includes/Modules/Credits.php:178 includes/Modules/Expenses.php:151
     821#: includes/Modules/Expenses.php:332 includes/Modules/Invoices.php:212
    818822#: includes/Modules/Invoices.php:286 includes/Modules/Invoices.php:428
    819823#: includes/Modules/Quotes.php:196 includes/Modules/Quotes.php:253
     
    956960msgstr ""
    957961
    958 #: includes/Modules/Settings.php:1052
     962#: includes/Modules/Settings.php:1096
    959963msgid "License data deleted successfully."
    960964msgstr ""
     
    10831087msgstr ""
    10841088
    1085 #: my-easy-compta.php:341
     1089#: my-easy-compta.php:342
    10861090msgid "myEasyCompta requires a database update."
    10871091msgstr ""
     
    12721276msgstr ""
    12731277
    1274 #: my-easy-compta.php:259
     1278#: my-easy-compta.php:260
    12751279msgid "Plugin activation error"
    12761280msgstr ""
    12771281
    1278 #: my-easy-compta.php:362
     1282#: my-easy-compta.php:364
    12791283msgid "Plugin deactivation error"
    12801284msgstr ""
     
    15091513msgstr ""
    15101514
    1511 #: includes/Modules/Settings.php:279
     1515#: includes/Modules/Settings.php:282
    15121516msgid "Settings saved successfully"
    15131517msgstr ""
     
    16661670
    16671671#. %s is the minimum PHP version required
    1668 #: my-easy-compta.php:253
     1672#: my-easy-compta.php:254
    16691673#, php-format
    16701674msgid ""
     
    17641768msgstr ""
    17651769
    1766 #: my-easy-compta.php:344
     1770#: my-easy-compta.php:345
    17671771msgid "Update Database"
    17681772msgstr ""
     
    18161820msgstr ""
    18171821
    1818 #: my-easy-compta.php:361
     1822#: my-easy-compta.php:363
    18191823msgid ""
    18201824"You cannot deactivate the myEasyCompta plugin while add-ons are enabled."
  • my-easy-compta/trunk/my-easy-compta.php

    r3167980 r3169216  
    33 * Plugin Name: myEasyCompta
    44 * Description: Streamline your financial management with myEasyCompta, an all-in-one accounting plugin. Effortlessly handle quotes, invoices, expenses, and more, all within a sleek, user-friendly interface. Perfect for freelancers and small businesses looking to simplify their accounting processes.
    5  * Version: 1.2.3
     5 * Version: 1.2.4
    66 * Author: MELIOZ.dev
    77 * Author URI: https://myeasycompta.com
     
    2222 *
    2323 * @package myEasyCompta
    24  * @since 1.2.3
     24 * @since 1.2.4
    2525 */
    2626
     
    3737     * @var string
    3838     */
    39     public $version = '1.2.3';
     39    public $version = '1.2.4';
     40    private $version_migration_db = false;
    4041
    4142    /**
     
    336337    {
    337338        $installed_db_version = get_option('ecwp_db_version', '1.0.0');
    338 
    339         if (version_compare($installed_db_version, $this->version, '<')) {
    340             echo '<div class="notice notice-warning is-dismissible">
     339        if ($this->version_migration_db == true) {
     340            if (version_compare($installed_db_version, $this->version, '<')) {
     341                echo '<div class="notice notice-warning is-dismissible">
    341342                    <p>' . __('myEasyCompta requires a database update.', 'my-easy-compta') . '</p>
    342343                    <form method="post">
     
    345346                    </form>
    346347                </div>';
     348            }
    347349        }
    348350    }
  • my-easy-compta/trunk/readme.txt

    r3167980 r3169216  
    44Tested up to: 6.6.1
    55Requires PHP: 8.0
    6 Stable tag: 1.2.3
     6Stable tag: 1.2.4
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.