import{s as ut,a as Xe,e as tt,b as qt,u as Gt,g as Kt,d as Rt,r as Zt,f as Be,o as Xt,n as De,i as el}from"../chunks/DHedsUi_.js";import{S as ft,i as _t,k as Fe,l as ee,m as Y,n as $e,o as Le,p as Ae,d as f,x as Oe,A as de,z as oe,q as lt,u as b,a as $,b as c,r as U,E as xt,c as h,e as y,g as T,v as Ee,h as g,j as I,s as Ie,f as ce,t as ue,y as rt,w as Ct,B as He}from"../chunks/G8UKEBBn.js";import{I as Jt,g as Qt,a as Wt,e as j,u as tl,o as ll}from"../chunks/C1tDbyYL.js";import{a as We}from"../chunks/DjUyxgK6.js";import{F as rl}from"../chunks/CNY58Upt.js";import{U as nl}from"../chunks/Betcpvy2.js";import{D as ol}from"../chunks/BojKV9te.js";import{T as al}from"../chunks/7MWtQ_HQ.js";const sl=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function il(n){let e;const t=n[2].default,l=qt(t,n,n[3],null);return{c(){l&&l.c()},l(r){l&&l.l(r)},m(r,a){l&&l.m(r,a),e=!0},p(r,a){l&&l.p&&(!e||a&8)&&Gt(l,t,r,r[3],e?Rt(t,r[3],a,null):Kt(r[3]),null)},i(r){e||(Y(l,r),e=!0)},o(r){ee(l,r),e=!1},d(r){l&&l.d(r)}}}function cl(n){let e,t;const l=[{name:"archive"},n[1],{iconNode:n[0]}];let r={$$slots:{default:[il]},$$scope:{ctx:n}};for(let a=0;a{t(1,e=Xe(Xe({},e),tt(o))),"$$scope"in o&&t(3,r=o.$$scope)},e=tt(e),[a,e,l,r]}class fl extends ft{constructor(e){super(),_t(this,e,ul,cl,ut,{})}}function _l(n){let e;const t=n[2].default,l=qt(t,n,n[3],null);return{c(){l&&l.c()},l(r){l&&l.l(r)},m(r,a){l&&l.m(r,a),e=!0},p(r,a){l&&l.p&&(!e||a&8)&&Gt(l,t,r,r[3],e?Rt(t,r[3],a,null):Kt(r[3]),null)},i(r){e||(Y(l,r),e=!0)},o(r){ee(l,r),e=!1},d(r){l&&l.d(r)}}}function dl(n){let e,t;const l=[{name:"folder-open"},n[1],{iconNode:n[0]}];let r={$$slots:{default:[_l]},$$scope:{ctx:n}};for(let a=0;a{t(1,e=Xe(Xe({},e),tt(o))),"$$scope"in o&&t(3,r=o.$$scope)},e=tt(e),[a,e,l,r]}class gl extends ft{constructor(e){super(),_t(this,e,hl,dl,ut,{})}}const{Boolean:pl}=sl;function Tt(n,e,t){const l=n.slice();return l[44]=e[t][0],l[45]=e[t][1],l}function It(n,e,t){const l=n.slice();return l[48]=e[t],l[50]=t,l}function bl(n,e,t){const l=n.slice();return l[41]=e[t],l}function Dt(n,e,t){const l=n.slice();return l[51]=e[t],l}function Pt(n,e,t){const l=n.slice();return l[54]=e[t],l}function Nt(n,e,t){const l=n.slice();return l[57]=e[t],l}function Ot(n,e,t){const l=n.slice();return l[54]=e[t],l}function St(n,e,t){const l=n.slice();return l[57]=e[t],l}function Vt(n,e,t){const l=n.slice();return l[54]=e[t],l}function zt(n,e,t){const l=n.slice();return l[57]=e[t],l}function Ft(n){let e,t=n[57].name+"",l,r;return{c(){e=g("option"),l=ue(t),this.h()},l(a){e=h(a,"OPTION",{});var o=y(e);l=ce(o,t),o.forEach(f),this.h()},h(){e.__value=r=n[57].id,oe(e,e.__value)},m(a,o){$(a,e,o),c(e,l)},p(a,o){o[0]&2&&t!==(t=a[57].name+"")&&Ie(l,t),o[0]&2&&r!==(r=a[57].id)&&(e.__value=r,oe(e,e.__value))},d(a){a&&f(e)}}}function $t(n){let e,t=n[54]+"",l;return{c(){e=g("option"),l=ue(t),this.h()},l(r){e=h(r,"OPTION",{});var a=y(e);l=ce(a,t),a.forEach(f),this.h()},h(){e.__value=n[54],oe(e,e.__value)},m(r,a){$(r,e,a),c(e,l)},p:De,d(r){r&&f(e)}}}function Lt(n){let e,t=n[57].name+"",l,r;return{c(){e=g("option"),l=ue(t),this.h()},l(a){e=h(a,"OPTION",{});var o=y(e);l=ce(o,t),o.forEach(f),this.h()},h(){e.__value=r=n[57].id,oe(e,e.__value)},m(a,o){$(a,e,o),c(e,l)},p(a,o){o[0]&2&&t!==(t=a[57].name+"")&&Ie(l,t),o[0]&2&&r!==(r=a[57].id)&&(e.__value=r,oe(e,e.__value))},d(a){a&&f(e)}}}function At(n){let e,t,l=n[54]+"",r;return{c(){e=g("option"),t=ue("Année "),r=ue(l),this.h()},l(a){e=h(a,"OPTION",{});var o=y(e);t=ce(o,"Année "),r=ce(o,l),o.forEach(f),this.h()},h(){e.__value=n[54],oe(e,e.__value)},m(a,o){$(a,e,o),c(e,t),c(e,r)},p:De,d(a){a&&f(e)}}}function Ut(n){let e,t;return{c(){e=g("p"),t=ue(n[4]),this.h()},l(l){e=h(l,"P",{class:!0});var r=y(e);t=ce(r,n[4]),r.forEach(f),this.h()},h(){b(e,"class","text-red-500 text-sm mb-3")},m(l,r){$(l,e,r),c(e,t)},p(l,r){r[0]&16&&Ie(t,l[4])},d(l){l&&f(e)}}}function ml(n){let e,t,l,r='Glissez vos fichiers ici ou cliquez pour choisir',a,o,u="PDF, images, tableurs acceptés",d;return e=new nl({props:{size:24,class:"mx-auto mb-2 text-gray-300 dark:text-gray-600"}}),{c(){Ae(e.$$.fragment),t=I(),l=g("p"),l.innerHTML=r,a=I(),o=g("p"),o.textContent=u,this.h()},l(_){Le(e.$$.fragment,_),t=T(_),l=h(_,"P",{class:!0,"data-svelte-h":!0}),Ee(l)!=="svelte-4vcs0z"&&(l.innerHTML=r),a=T(_),o=h(_,"P",{class:!0,"data-svelte-h":!0}),Ee(o)!=="svelte-1k4zvv4"&&(o.textContent=u),this.h()},h(){b(l,"class","text-sm text-gray-500 dark:text-gray-400"),b(o,"class","text-xs text-gray-400 dark:text-gray-500 mt-1")},m(_,x){$e(e,_,x),$(_,t,x),$(_,l,x),$(_,a,x),$(_,o,x),d=!0},i(_){d||(Y(e.$$.fragment,_),d=!0)},o(_){ee(e.$$.fragment,_),d=!1},d(_){_&&(f(t),f(l),f(a),f(o)),Fe(e,_)}}}function vl(n){let e,t="⏳ Upload en cours...";return{c(){e=g("div"),e.textContent=t,this.h()},l(l){e=h(l,"DIV",{class:!0,"data-svelte-h":!0}),Ee(e)!=="svelte-15ydiq4"&&(e.textContent=t),this.h()},h(){b(e,"class","text-blue-600 dark:text-blue-400 text-sm")},m(l,r){$(l,e,r)},i:De,o:De,d(l){l&&f(e)}}}function jt(n){let e,t=n[57].name+"",l,r;return{c(){e=g("option"),l=ue(t),this.h()},l(a){e=h(a,"OPTION",{});var o=y(e);l=ce(o,t),o.forEach(f),this.h()},h(){e.__value=r=n[57].id,oe(e,e.__value)},m(a,o){$(a,e,o),c(e,l)},p(a,o){o[0]&2&&t!==(t=a[57].name+"")&&Ie(l,t),o[0]&2&&r!==(r=a[57].id)&&(e.__value=r,oe(e,e.__value))},d(a){a&&f(e)}}}function Bt(n){let e,t=n[54]+"",l;return{c(){e=g("option"),l=ue(t),this.h()},l(r){e=h(r,"OPTION",{});var a=y(e);l=ce(a,t),a.forEach(f),this.h()},h(){e.__value=n[54],oe(e,e.__value)},m(r,a){$(r,e,a),c(e,l)},p:De,d(r){r&&f(e)}}}function Ht(n){let e,t=n[51]+"",l,r;return{c(){e=g("option"),l=ue(t),this.h()},l(a){e=h(a,"OPTION",{});var o=y(e);l=ce(o,t),o.forEach(f),this.h()},h(){e.__value=r=n[51],oe(e,e.__value)},m(a,o){$(a,e,o),c(e,l)},p(a,o){o[0]&65536&&t!==(t=a[51]+"")&&Ie(l,t),o[0]&65536&&r!==(r=a[51])&&(e.__value=r,oe(e,e.__value))},d(a){a&&f(e)}}}function kl(n){let e,t,l=j(n[15]),r=[];for(let o=0;oee(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o0?"border-t border-gray-50 dark:border-gray-800":"")+" hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors"),this.first=t},m(A,F){$(A,t,F),c(t,l),c(l,a),c(t,o),c(t,u),c(u,d),c(d,x),c(u,L),c(u,D),c(D,v),c(D,E),c(D,P),c(t,fe),c(t,V),c(V,ae),$e(te,ae,null),c(V,z),c(V,q),$e(pe,q,null),c(t,xe),O=!0,Pe||(le=[U(ae,"click",Ue),U(q,"click",he)],Pe=!0)},p(A,F){e=A,(!O||F[0]&32768)&&r!==(r=e[24](e[48].mime_type)+"")&&Ie(a,r),(!O||F[0]&32768)&&_!==(_=e[48].original_name+"")&&Ie(x,_),(!O||F[0]&32768)&&w!==(w=e[48].property_name+"")&&Ie(v,w),(!O||F[0]&32768)&&M!==(M=e[25](e[48].created_at)+"")&&Ie(P,M),(!O||F[0]&32768&&B!==(B="flex items-center gap-4 px-4 py-3 "+(e[50]>0?"border-t border-gray-50 dark:border-gray-800":"")+" hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors"))&&b(t,"class",B)},i(A){O||(Y(te.$$.fragment,A),Y(pe.$$.fragment,A),O=!0)},o(A){ee(te.$$.fragment,A),ee(pe.$$.fragment,A),O=!1},d(A){A&&f(t),Fe(te),Fe(pe),Pe=!1,Zt(le)}}}function Mt(n){let e,t,l=n[44]+"",r,a,o,u=[],d=new Map,_,x,L=j(n[45]);const D=w=>w[48].id;for(let w=0;wn[26].call(E)),b(P,"class","px-2 py-1 rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none"),n[14]===void 0&&Be(()=>n[27].call(P)),b(V,"class","px-3 py-1 bg-blue-600 hover:bg-blue-700 text-white text-sm rounded-lg transition-colors"),b(_,"class","flex items-center gap-2 bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 px-4 py-2"),b(t,"class","flex items-center justify-between gap-3 mb-6"),b(q,"class","text-sm font-medium text-gray-700 dark:text-gray-300 mb-4"),b(O,"class","px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),n[10]===void 0&&Be(()=>n[28].call(O)),b(le,"class","px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),n[11]===void 0&&Be(()=>n[29].call(le)),b(he,"placeholder","Catégorie (ex: Loyers, Travaux…)"),b(he,"class","px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 min-w-48"),b(B,"class","flex flex-wrap gap-3 mb-4"),b(G,"class",ke="border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-colors "+(n[8]?"border-blue-400 bg-blue-50 dark:bg-blue-950/30":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600")),b(_e,"type","file"),_e.multiple=!0,b(_e,"class","hidden"),b(_e,"accept",".pdf,.jpg,.jpeg,.png,.xlsx,.csv,.doc,.docx"),b(z,"class","bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 p-5 mb-5"),ye.__value="",oe(ye,ye.__value),b(se,"class","px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),n[5]===void 0&&Be(()=>n[35].call(se)),we.__value="",oe(we,we.__value),b(N,"class","px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),n[6]===void 0&&Be(()=>n[36].call(N)),Ne.__value="",oe(Ne,Ne.__value),b(ge,"class","px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),n[7]===void 0&&Be(()=>n[37].call(ge)),b(be,"class","flex flex-wrap gap-3 mb-5"),b(e,"class","p-6 max-w-5xl mx-auto")},m(s,k){$(s,e,k),c(e,t),c(t,l),$e(r,l,null),c(l,a),c(l,o),c(t,d),c(t,_),$e(x,_,null),c(_,L),c(_,D),c(_,v),c(_,E);for(let m=0;m{je[m]=null}),lt(),re=je[H],re||(re=je[H]=pt[H](s),re.c()),Y(re,1),re.m(G,null)),(!et||k[0]&256&&ke!==(ke="border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-colors "+(s[8]?"border-blue-400 bg-blue-50 dark:bg-blue-950/30":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600")))&&b(G,"class",ke),k[0]&2){Ke=j(s[1]);let i;for(i=0;i{Ve[ze]=null}),lt(),ve=Ve[me],ve?ve.p(s,k):(ve=Ve[me]=mt[me](s),ve.c()),Y(ve,1),ve.m(e,null))},i(s){et||(Y(r.$$.fragment,s),Y(x.$$.fragment,s),Y(re),Y(ve),et=!0)},o(s){ee(r.$$.fragment,s),ee(x.$$.fragment,s),ee(re),ee(ve),et=!1},d(s){s&&f(e),Fe(r),Fe(x),Oe(K,s),Oe(R,s),Oe(Z,s),Oe(J,s),ne&&ne.d(),je[H].d(),n[34](null),Oe(Q,s),Oe(W,s),Oe(X,s),Ve[me].d(),at=!1,Zt(gt)}}}function Cl(n,e,t){let l,r,a=[],o=[],u=!0,d=!1,_="",x="",L=String(new Date().getFullYear()),D="",w=!1,v,E="",M=String(new Date().getFullYear()),P="",fe="",V=String(new Date().getFullYear());const ae=Array.from({length:5},(p,ie)=>String(new Date().getFullYear()-ie));Xt(async()=>{t(1,o=await We.properties.list()||[]),o.length>0&&(t(10,E=o[0].id),t(13,fe=o[0].id)),await te()});async function te(){t(2,u=!0);const p={};x&&(p.property_id=x),L&&(p.fiscal_year=L),D&&(p.category=D),t(0,a=await We.documents.list(p)||[]),t(2,u=!1)}async function z(p){if(!E){t(4,_="Sélectionnez un bien avant d'uploader.");return}t(4,_=""),t(3,d=!0);for(const ie of p){const N=new FormData;N.append("file",ie),N.append("property_id",E),N.append("fiscal_year",M),N.append("category",P);try{await We.documents.upload(N)}catch(we){t(4,_=`Erreur upload "${ie.name}": ${we.message}`)}}t(3,d=!1),await te()}function q(p){t(8,w=!1),z([...p.dataTransfer.files])}function pe(p){z([...p.target.files]),p.target.value=""}async function xe(p,ie){confirm(`Supprimer "${ie}" ?`)&&(await We.documents.delete(p),await te())}function B(p){window.open(We.documents.download(p),"_blank")}function O(){const p={year:V};fe&&(p.property_id=fe),window.open(We.documents.exportUrl(p),"_blank")}const Pe=p=>p?p.includes("pdf")?"📕":p.includes("image")?"🖼️":p.includes("spreadsheet")||p.includes("excel")||p.includes("csv")?"📊":p.includes("word")||p.includes("document")?"📝":"📄":"📄",le=p=>new Date(p).toLocaleDateString("fr-FR");function Ue(){fe=He(this),t(13,fe),t(1,o)}function he(){V=He(this),t(14,V),t(17,ae)}function A(){E=He(this),t(10,E),t(1,o)}function F(){M=He(this),t(11,M),t(17,ae)}function G(){P=this.value,t(12,P)}const H=()=>t(8,w=!0),re=()=>t(8,w=!1),ke=()=>v.click();function Ce(p){el[p?"unshift":"push"](()=>{v=p,t(9,v)})}function _e(){x=He(this),t(5,x),t(1,o)}function Se(){L=He(this),t(6,L),t(17,ae)}function be(){D=He(this),t(7,D),t(16,l),t(0,a)}const se=p=>B(p.id),ye=p=>xe(p.id,p.original_name);return n.$$.update=()=>{n.$$.dirty[0]&1&&t(16,l=[...new Set(a.map(p=>p.category).filter(Boolean))].sort()),n.$$.dirty[0]&1&&t(15,r=(()=>{const p={};for(const ie of a){const N=ie.category||"Sans catégorie";p[N]||(p[N]=[]),p[N].push(ie)}return Object.entries(p).sort(([ie],[N])=>ie.localeCompare(N))})())},[a,o,u,d,_,x,L,D,w,v,E,M,P,fe,V,r,l,ae,te,q,pe,xe,B,O,Pe,le,Ue,he,A,F,G,H,re,ke,Ce,_e,Se,be,se,ye]}class zl extends ft{constructor(e){super(),_t(this,e,Cl,xl,ut,{},null,[-1,-1,-1])}}export{zl as component};