import{s as Et,a as rt,e as ft,b as Xt,u as Gt,g as Kt,d as Qt,r as Zt,f as er,o as ar,n as sr}from"../chunks/DHedsUi_.js";import{S as Dt,i as Ct,k as Ae,l as me,m as de,n as Oe,o as Me,p as Be,d as c,x as ct,A as gt,s as ye,q as nr,a as ne,b as n,r as ce,u as f,z as Ce,c as u,e as g,g as k,v as ve,f as U,w as ht,h as d,j as x,t as q,D as or,B as jt,y as ir}from"../chunks/G8UKEBBn.js";import{I as tr,g as rr,a as lr,e as qe}from"../chunks/C1tDbyYL.js";import{a as wt}from"../chunks/DjUyxgK6.js";import{C as ur}from"../chunks/B9ru2HtO.js";import{R as dr}from"../chunks/Db8cSFEn.js";import{P as cr}from"../chunks/CLS07P5K.js";import{X as fr}from"../chunks/C_l6I72z.js";import{C as gr}from"../chunks/zQrtb5Kq.js";function hr(l){let e;const t=l[2].default,r=Xt(t,l,l[3],null);return{c(){r&&r.c()},l(a){r&&r.l(a)},m(a,s){r&&r.m(a,s),e=!0},p(a,s){r&&r.p&&(!e||s&8)&&Gt(r,t,a,a[3],e?Qt(t,a[3],s,null):Kt(a[3]),null)},i(a){e||(de(r,a),e=!0)},o(a){me(r,a),e=!1},d(a){r&&r.d(a)}}}function _r(l){let e,t;const r=[{name:"chevron-left"},l[1],{iconNode:l[0]}];let a={$$slots:{default:[hr]},$$scope:{ctx:l}};for(let s=0;s{t(1,e=rt(rt({},e),ft(i))),"$$scope"in i&&t(3,a=i.$$scope)},e=ft(e),[s,e,r,a]}class br extends Dt{constructor(e){super(),Ct(this,e,pr,_r,Et,{})}}function mr(l){let e;const t=l[2].default,r=Xt(t,l,l[3],null);return{c(){r&&r.c()},l(a){r&&r.l(a)},m(a,s){r&&r.m(a,s),e=!0},p(a,s){r&&r.p&&(!e||s&8)&&Gt(r,t,a,a[3],e?Qt(t,a[3],s,null):Kt(a[3]),null)},i(a){e||(de(r,a),e=!0)},o(a){me(r,a),e=!1},d(a){r&&r.d(a)}}}function vr(l){let e,t;const r=[{name:"chevron-right"},l[1],{iconNode:l[0]}];let a={$$slots:{default:[mr]},$$scope:{ctx:l}};for(let s=0;s{t(1,e=rt(rt({},e),ft(i))),"$$scope"in i&&t(3,a=i.$$scope)},e=ft(e),[s,e,r,a]}class kr extends Dt{constructor(e){super(),Ct(this,e,yr,vr,Et,{})}}function At(l,e,t){const r=l.slice();return r[38]=e[t],r}function Ot(l,e,t){const r=l.slice();r[41]=e[t],r[45]=t;const a=r[4][r[41]]??null;r[42]=a;const s=!!r[42];return r[43]=s,r}function Mt(l,e,t){const r=l.slice();return r[46]=e[t],r}function Bt(l,e,t){const r=l.slice();return r[38]=e[t],r}function Lt(l){let e,t;return{c(){e=d("p"),t=q(l[11]),this.h()},l(r){e=u(r,"P",{class:!0});var a=g(e);t=U(a,l[11]),a.forEach(c),this.h()},h(){f(e,"class","text-sm text-green-600 dark:text-green-400 mb-3")},m(r,a){ne(r,e,a),n(e,t)},p(r,a){a[0]&2048&&ye(t,r[11])},d(r){r&&c(e)}}}function zt(l){let e,t;return{c(){e=d("p"),t=q(l[12]),this.h()},l(r){e=u(r,"P",{class:!0});var a=g(e);t=U(a,l[12]),a.forEach(c),this.h()},h(){f(e,"class","text-sm text-red-500 dark:text-red-400 mb-3")},m(r,a){ne(r,e,a),n(e,t)},p(r,a){a[0]&4096&&ye(t,r[12])},d(r){r&&c(e)}}}function Ut(l){let e,t=l[38].name+"",r,a;return{c(){e=d("option"),r=q(t),this.h()},l(s){e=u(s,"OPTION",{});var i=g(e);r=U(i,t),i.forEach(c),this.h()},h(){e.__value=a=l[38].id,Ce(e,e.__value)},m(s,i){ne(s,e,i),n(e,r)},p(s,i){i[0]&32&&t!==(t=s[38].name+"")&&ye(r,t),i[0]&32&&a!==(a=s[38].id)&&(e.__value=a,Ce(e,e.__value))},d(s){s&&c(e)}}}function qt(l){let e,t=l[46]+"",r;return{c(){e=d("div"),r=q(t),this.h()},l(a){e=u(a,"DIV",{class:!0});var s=g(e);r=U(s,t),s.forEach(c),this.h()},h(){f(e,"class","py-3 text-center text-xs font-medium text-gray-400 dark:text-gray-500")},m(a,s){ne(a,e,s),n(e,r)},p:sr,d(a){a&&c(e)}}}function Ft(l){let e,t=l[41]+"",r,a,s,i=l[42]&&l[42].start_date===`${l[0]}-${String(l[1]+1).padStart(2,"0")}-${String(l[41]).padStart(2,"0")}`,S,D=i&&Jt(l);return{c(){e=d("span"),r=q(t),s=x(),D&&D.c(),S=ht(),this.h()},l(h){e=u(h,"SPAN",{class:!0});var p=g(e);r=U(p,t),p.forEach(c),s=k(h),D&&D.l(h),S=ht(),this.h()},h(){f(e,"class",a="text-xs font-medium "+(l[20](l[41])?"bg-blue-600 text-white w-6 h-6 flex items-center justify-center rounded-full":"text-gray-700 dark:text-gray-300"))},m(h,p){ne(h,e,p),n(e,r),ne(h,s,p),D&&D.m(h,p),ne(h,S,p)},p(h,p){p[0]&32768&&t!==(t=h[41]+"")&&ye(r,t),p[0]&32768&&a!==(a="text-xs font-medium "+(h[20](h[41])?"bg-blue-600 text-white w-6 h-6 flex items-center justify-center rounded-full":"text-gray-700 dark:text-gray-300"))&&f(e,"class",a),p[0]&32787&&(i=h[42]&&h[42].start_date===`${h[0]}-${String(h[1]+1).padStart(2,"0")}-${String(h[41]).padStart(2,"0")}`),i?D?D.p(h,p):(D=Jt(h),D.c(),D.m(S.parentNode,S)):D&&(D.d(1),D=null)},d(h){h&&(c(e),c(s),c(S)),D&&D.d(h)}}}function Jt(l){let e,t=(l[42].title||(l[42].source==="airbnb"?"Airbnb":"Locataire"))+"",r,a;return{c(){e=d("div"),r=q(t),this.h()},l(s){e=u(s,"DIV",{class:!0});var i=g(e);r=U(i,t),i.forEach(c),this.h()},h(){f(e,"class",a="mt-1 text-xs px-1.5 py-0.5 rounded font-medium truncate "+(l[42].source==="airbnb"?"bg-orange-200 text-orange-800 dark:bg-orange-900 dark:text-orange-200":"bg-blue-200 text-blue-800 dark:bg-blue-900 dark:text-blue-200"))},m(s,i){ne(s,e,i),n(e,r)},p(s,i){i[0]&32784&&t!==(t=(s[42].title||(s[42].source==="airbnb"?"Airbnb":"Locataire"))+"")&&ye(r,t),i[0]&32784&&a!==(a="mt-1 text-xs px-1.5 py-0.5 rounded font-medium truncate "+(s[42].source==="airbnb"?"bg-orange-200 text-orange-800 dark:bg-orange-900 dark:text-orange-200":"bg-blue-200 text-blue-800 dark:bg-blue-900 dark:text-blue-200"))&&f(e,"class",a)},d(s){s&&c(e)}}}function Ht(l){let e,t,r,a=l[41]&&Ft(l);return{c(){e=d("div"),a&&a.c(),t=x(),this.h()},l(s){e=u(s,"DIV",{class:!0});var i=g(e);a&&a.l(i),t=k(i),i.forEach(c),this.h()},h(){f(e,"class",r="border-b border-r border-gray-50 dark:border-gray-800/50 min-h-[72px] p-2 relative "+(l[41]?"":"bg-gray-50/50 dark:bg-gray-800/20")+" "+(l[43]?l[42].source==="airbnb"?"bg-orange-50 dark:bg-orange-950/30":"bg-blue-50 dark:bg-blue-950/30":""))},m(s,i){ne(s,e,i),a&&a.m(e,null),n(e,t)},p(s,i){s[41]?a?a.p(s,i):(a=Ft(s),a.c(),a.m(e,t)):a&&(a.d(1),a=null),i[0]&32784&&r!==(r="border-b border-r border-gray-50 dark:border-gray-800/50 min-h-[72px] p-2 relative "+(s[41]?"":"bg-gray-50/50 dark:bg-gray-800/20")+" "+(s[43]?s[42].source==="airbnb"?"bg-orange-50 dark:bg-orange-950/30":"bg-blue-50 dark:bg-blue-950/30":""))&&f(e,"class",r)},d(s){s&&c(e),a&&a.d()}}}function Rt(l){let e,t,r,a,s="Ajouter une période d'occupation",i,S,D,h,p,B,F,R,L="Bien *",C,m,Y,V="Sélectionner...",te,J,N,oe="Intitulé",Le,re,H,$,j,fe,ge="Arrivée *",Ie,le,$e,ie,he,ke="Départ *",_e,ue,K,w,I,ae="Annuler",A,v,z,Fe,xe,Je,He;D=new fr({props:{size:18}});let O=l[8]&&Yt(l),se=qe(l[5]),T=[];for(let y=0;yl[29].call(m)),f(N,"class","block text-xs font-medium text-gray-500 mb-1"),f(re,"placeholder","Ex: Famille Dupont"),f(re,"class","w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),f(fe,"class","block text-xs font-medium text-gray-500 mb-1"),f(le,"type","date"),f(le,"class","w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),f(he,"class","block text-xs font-medium text-gray-500 mb-1"),f(ue,"type","date"),f(ue,"class","w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),f($,"class","grid grid-cols-2 gap-4"),f(p,"class","px-6 py-5 space-y-4"),f(I,"class","px-4 py-2 text-sm text-gray-600 dark:text-gray-400"),f(v,"class","flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition-colors"),f(w,"class","flex justify-end gap-3 px-6 py-4 border-t border-gray-100 dark:border-gray-800"),f(t,"class","bg-white dark:bg-gray-900 rounded-2xl w-full max-w-md shadow-xl border border-gray-100 dark:border-gray-800"),f(e,"class","fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4")},m(y,Q){ne(y,e,Q),n(e,t),n(t,r),n(r,a),n(r,i),n(r,S),Oe(D,S,null),n(t,h),n(t,p),O&&O.m(p,null),n(p,B),n(p,F),n(F,R),n(F,C),n(F,m),n(m,Y);for(let E=0;El[27].call(N)),f($,"class","p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors"),f(ge,"class","text-base font-semibold text-gray-900 dark:text-white w-36 text-center"),f(ke,"class","p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors"),f(H,"class","flex items-center gap-2 ml-auto"),f(J,"class","flex flex-wrap items-center gap-3 mb-5"),f(I,"class","text-xs text-gray-500 dark:text-gray-400"),f(xe,"class","text-sm font-normal text-gray-400"),f(v,"class","text-2xl font-semibold text-gray-900 dark:text-white mt-1"),f(w,"class","bg-white dark:bg-gray-900 rounded-xl p-4 border border-gray-100 dark:border-gray-800"),f(T,"class","text-xs text-gray-500 dark:text-gray-400"),f(E,"class","text-2xl font-semibold text-gray-900 dark:text-white mt-1"),f(se,"class","bg-white dark:bg-gray-900 rounded-xl p-4 border border-gray-100 dark:border-gray-800"),f(Se,"class","text-xs text-gray-500 dark:text-gray-400"),f(Te,"class","text-2xl font-semibold text-gray-900 dark:text-white mt-1"),f(pe,"class","bg-white dark:bg-gray-900 rounded-xl p-4 border border-gray-100 dark:border-gray-800"),f(K,"class","grid grid-cols-3 gap-3 mb-5"),f(Ne,"class","grid grid-cols-7 border-b border-gray-100 dark:border-gray-800"),f(Ye,"class","grid grid-cols-7"),f(De,"class","bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 overflow-hidden"),f(We,"class","flex gap-4 mt-3 text-xs text-gray-500 dark:text-gray-400"),f(e,"class","p-6 max-w-5xl mx-auto")},m(o,b){ne(o,e,b),n(e,t),n(t,r),Oe(a,r,null),n(r,s),n(r,i),n(t,D),n(t,h),n(h,p),Oe(B,p,null),n(p,F),n(h,R),n(h,L),Oe(C,L,null),n(L,m),n(e,Y),Z&&Z.m(e,null),n(e,V),ee&&ee.m(e,null),n(e,te),n(e,J),n(J,N),n(N,oe);for(let P=0;P{M=null}),nr())},i(o){Ve||(de(a.$$.fragment,o),de(B.$$.fragment,o),de(C.$$.fragment,o),de(j.$$.fragment,o),de(_e.$$.fragment,o),de(M),Ve=!0)},o(o){me(a.$$.fragment,o),me(B.$$.fragment,o),me(C.$$.fragment,o),me(j.$$.fragment,o),me(_e.$$.fragment,o),me(M),Ve=!1},d(o){o&&(c(e),c(lt),c(Ge)),Ae(a),Ae(B),Ae(C),Z&&Z.d(),ee&&ee.d(),ct(W,o),Ae(j),Ae(_e),ct(X,o),ct(G,o),M&&M.d(o),bt=!1,Zt(St)}}}function wr(l,e,t){let r,a,s,i,S,D,h=[],p=[],B="",F=!1,R="",L=new Date,C=L.getFullYear(),m=L.getMonth();const Y=()=>({property_id:"",title:"",start_date:L.toISOString().slice(0,10),end_date:L.toISOString().slice(0,10),notes:""});let V=Y();ar(async()=>{t(5,h=await wt.properties.list()||[]),await te()});async function te(){const w=`${C}-${String(m+1).padStart(2,"0")}-01`,I=new Date(C,m+1,0).getDate(),ae=`${C}-${String(m+1).padStart(2,"0")}-${I}`,A={from:w,to:ae};B&&(A.property_id=B),t(25,p=await wt.calendar.list(A)||[])}function J(){m===0?(t(1,m=11),t(0,C--,C)):t(1,m--,m),te()}function N(){m===11?(t(1,m=0),t(0,C++,C)):t(1,m++,m),te()}function oe(w){return w===L.getDate()&&m===L.getMonth()&&C===L.getFullYear()}const Le=["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],re=["Lun","Mar","Mer","Jeu","Ven","Sam","Dim"];let H=!1,$="",j="";async function fe(){t(10,H=!0),t(11,$=""),t(12,j="");try{const I=await(await fetch("/api/calendar/sync",{method:"POST",credentials:"include"})).json(),ae=I.reduce((v,z)=>v+(z.imported||0),0),A=I.filter(v=>v.error);A.length>0?t(12,j=A.map(v=>`${v.property}: ${v.error}`).join(" | ")):t(11,$=`${ae} événement(s) importé(s)`),await te()}catch(w){t(12,j="Erreur de synchronisation: "+w.message)}t(10,H=!1)}async function ge(){if(t(8,R=""),!V.property_id||!V.start_date||!V.end_date){t(8,R="Bien et dates requis.");return}try{await wt.calendar.createEvent(V),t(7,F=!1),await te()}catch(w){t(8,R=w.message)}}const Ie=()=>{t(7,F=!0),t(9,V=Y()),t(8,R="")};function le(){B=jt(this),t(6,B),t(5,h)}const $e=()=>t(7,F=!1);function ie(){V.property_id=jt(this),t(9,V),t(5,h)}function he(){V.title=this.value,t(9,V),t(5,h)}function ke(){V.start_date=this.value,t(9,V),t(5,h)}function _e(){V.end_date=this.value,t(9,V),t(5,h)}const ue=()=>t(7,F=!1),K=()=>t(7,F=!1);return l.$$.update=()=>{l.$$.dirty[0]&3&&t(15,r=(()=>{const w=new Date(C,m,1).getDay(),I=new Date(C,m+1,0).getDate(),ae=[],A=w===0?6:w-1;for(let v=0;v{const w={},I=`${C}-${String(m+1).padStart(2,"0")}`,ae=new Date(C,m+1,0).getDate();for(let A=1;A<=ae;A++){const v=`${I}-${String(A).padStart(2,"0")}`;w[A]=p.find(z=>v>=z.start_date&&(z.source==="airbnb"?v0?Math.round(s/i*100):0),l.$$.dirty[0]&33554435&&t(13,D=(()=>{const w=`${C}-${String(m+1).padStart(2,"0")}`;return p.filter(I=>I.start_date.startsWith(w)).length})())},[C,m,i,s,a,h,B,F,R,V,H,$,j,D,S,r,Y,te,J,N,oe,Le,re,fe,ge,p,Ie,le,$e,ie,he,ke,_e,ue,K]}class $r extends Dt{constructor(e){super(),Ct(this,e,wr,xr,Et,{},null,[-1,-1])}}export{$r as component};