PageSourceSearch

https://conversahub.ai/assets/Calendar-CNOrgJqE.js

js conversahub.ai collected 2026-10-05 15:31:04 UTC 33,811 bytes, 5 lines download raw bytes

1import{j as t,A as ee,m as A,$ as N,aF as te,bF as nt,bt as rt,aj as ot,a5 as ct,y as it,as as _e,X as De,aL as dt,ak as Ce,k as Se,aW as L,V as ze,C as xt,P as pt,b1 as ut,bG as mt,f as gt,ay as $e,N as ht,I as bt}from"./vendor-ui-CD0lB9-C.js";import{u as ft,r}from"./vendor-react-D3UwUeXW.js";import{a as x}from"./vendor-socket-DBwSfdIm.js";import{u as jt}from"./useConfirm-d9S3A1AY.js";import{u as vt}from"./index-nIlOdFcw.js";import"./ConfirmModal-BYZXzcYT.js";const ae={scheduled:"bg-blue-100 text-blue-700 border-blue-200",completed:"bg-emerald-100 text-emerald-700 border-emerald-200",cancelled:"bg-red-100 text-red-700 border-red-200",no_show:"bg-amber-100 text-amber-700 border-amber-200"};let se={};const wt=[{value:"general",key:"calendar.general",color:"bg-slate-500"},{value:"videollamada",key:"calendar.videocall",color:"bg-blue-500"},{value:"consulta",key:"calendar.consultation",color:"bg-purple-500"},{value:"servicio",key:"calendar.technicalService",color:"bg-amber-500"},{value:"seguimiento",key:"calendar.followUp",color:"bg-teal-500"},{value:"demo",key:"calendar.demoPresentation",color:"bg-indigo-500"},{value:"wa_flow",key:"calendar.waFlow",color:"bg-green-500"}];function h(_){return String(_).padStart(2,"0")}function U(_){const s=_||new Date;return`${s.getFullYear()}-${h(s.getMonth()+1)}-${h(s.getDate())}T${h(s.getHours())}:${h(s.getMinutes())}`}function zt(){const _=ft(),{t:s}=vt();se={scheduled:s("calendar.scheduled"),completed:s("calendar.completed"),cancelled:s("calendar.cancelled"),no_show:s("calendar.noShow")};const{confirm:le,ConfirmDialog:Te}=jt(),[D,Me]=r.useState([]),[Ae,ne]=r.useState(!0),[V,b]=r.useState(new Date),[w,Le]=r.useState("month"),[Ee,y]=r.useState(!1),[f,re]=r.useState(null),[W,oe]=r.useState(!1),[Fe,Pe]=r.useState([]),[Ie,Oe]=r.useState([]),[o,g]=r.useState({title:"",description:"",start_at:"",end_at:"",contact_id:"",agent_id:"",location:"",notes:"",status:"scheduled",appointment_type:"general"}),[ce,Ye]=r.useState(!1),[j,C]=r.useState({days:[1,2,3,4,5],start_hour:"09:00",end_hour:"18:00",vacations:[]}),[ie,de]=r.useState(!1),[E,xe]=r.useState(""),pe=wt.map(e=>({...e,label:s(e.key)})),[F,Ge]=r.useState(pe),P=e=>F.find(a=>a.value===e)||F[0]||pe[0],[ue,B]=r.useState(!1),[X,me]=r.useState(!1),[He,Re]=r.useState(!0),I=r.useRef(null),[ge,he]=r.useState(!1),[K,be]=r.useState(null),p=(e,a="success")=>{be({msg:e,type:a}),setTimeout(()=>be(null),4e3)},d=V.getFullYear(),c=V.getMonth(),O=s("calendar.months"),q=s("calendar.daysShort"),v=r.useCallback(async()=>{ne(!0);try{const e=new Date(d,c,1).toISOString(),a=new Date(d,c+2,0).toISOString();console.log("[Calendar] Loading appointments:",{from:e,to:a,year:d,month:c});const[l,i,u]=await Promise.all([x.get(`/api/crm/appointments?from=${e}&to=${a}`),x.get("/api/agents"),x.get("/api/contacts-with-orders")]),n=Array.isArray(l.data)?l.data:[];console.log("[Calendar] Loaded appointments:",n.length,n.slice(0,3)),Me(n),Pe(i.data||[]),Oe(Array.isArray(u.data)?u.data:[])}catch(e){const a=e.response?.data?.error||e.response?.data?.message||e.message;console.error("[Calendar] Load error:",a,e.response?.status,e.response?.data)}ne(!1)},[d,c]);r.useEffect(()=>{v()},[v]),r.useEffect(()=>{x.get("/api/crm/tenant/schedule-config").then(e=>{e.data?.config&&Object.keys(e.data.config).length&&C(e.data.config)}).catch(()=>{}),x.get("/api/crm/google-calendar/status").then(e=>{B(!!e.data?.connected)}).catch(()=>{}).finally(()=>Re(!1)),x.get("/api/crm/vertical/config").then(e=>{const a=e.data?.appointment_types;Array.isArray(a)&&a.length>0&&Ge(a)}).catch(()=>{})},[]),r.useEffect(()=>{const e=a=>{a.data?.type==="google_calendar_connected"&&(B(!0),p(s("calendar.gcalConnected")))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);async function Ue(){de(!0);try{await x.put("/api/crm/tenant/schedule-config",{config:j}),p(s("calendar.schedulesSaved"))}catch{p(s("calendar.saveError"),"error")}de(!1)}function Ve(e){C(a=>({...a,days:a.days.includes(e)?a.days.filter(l=>l!==e):[...a.days,e].sort()}))}function We(){E&&(C(e=>({...e,vacations:[...e.vacations||[],E].sort()})),xe(""))}function Be(e){C(a=>({...a,vacations:(a.vacations||[]).filter(l=>l!==e)}))}function J(e){const a=e?new Date(e):new Date;a.setHours(10,0,0);const l=new Date(a);l.setHours(11,0,0),re(null),g({title:"",description:"",start_at:U(a),end_at:U(l),contact_id:"",agent_id:"",location:"",notes:"",status:"scheduled",appointment_type:"general"}),y(!0)}
1function Q(e){re(e),g({title:e.title,description:e.description||"",start_at:U(new Date(e.start_at)),end_at:U(new Date(e.end_at)),contact_id:e.contact_id||"",agent_id:e.agent_id||"",location:e.location||"",notes:e.notes||"",status:e.status||"scheduled",appointment_type:e.appointment_type||"general"}),y(!0)}async function Xe(){if(!(!o.title||!o.start_at||!o.end_at)){oe(!0);try{const e={...o,start_at:new Date(o.start_at).toISOString(),end_at:new Date(o.end_at).toISOString(),contact_id:o.contact_id||null,agent_id:o.agent_id||null,appointment_type:o.appointment_type||"general"};f?await x.put(`/api/crm/appointments/${f.id}`,e):await x.post("/api/crm/appointments",e),y(!1),v(),p(s(f?"calendar.appointmentUpdated":"calendar.appointmentCreated"))}catch{p(s("calendar.saveError"),"error")}oe(!1)}}async function fe(e){await le({title:s("calendar.deleteTitle"),message:s("calendar.deleteMessage"),confirmText:s("calendar.delete"),type:"danger"})&&(await x.delete(`/api/crm/appointments/${e}`).catch(()=>{}),v())}async function Ke(e,a){await x.put(`/api/crm/appointments/${e}`,{...D.find(l=>l.id===e),status:a}).catch(()=>{}),v()}async function qe(){try{const{data:e}=await x.get("/api/crm/google-calendar/auth-url");e.url&&window.open(e.url,"gcal_auth","width=600,height=700")}catch(e){p(e.response?.data?.error||s("calendar.connectError"),"error")}}async function Je(){if(await le({title:s("calendar.disconnectTitle"),message:s("calendar.disconnectMessage"),confirmText:s("calendar.disconnect"),type:"danger"}))try{await x.post("/api/crm/google-calendar/disconnect"),B(!1),p(s("calendar.gcalDisconnected"))}catch{p(s("calendar.disconnectError"),"error")}}async function Qe(){me(!0);try{const{data:e}=await x.post("/api/crm/google-calendar/sync");console.log("[Calendar] Sync result:",e);const a=[s("calendar.syncNew",{count:e.created||0}),s("calendar.syncUpdated",{count:e.updated||0})];e.skipped&&a.push(s("calendar.syncSkipped",{count:e.skipped})),p(s("calendar.syncResult",{details:a.join(", "),total:e.total||0})),await v(),console.log("[Calendar] Appointments after reload:",D.length)}catch(e){console.error("[Calendar] Sync error:",e.response?.data||e.message),p(e.response?.data?.error||s("calendar.syncError"),"error")}me(!1)}async function Ze(e){const a=e.target.files?.[0];if(a){he(!0);try{const l=await a.text(),{data:i}=await x.post("/api/crm/appointments/import-ics",{ics_content:l});p(s("calendar.importedCount",{count:i.imported||0})),v()}catch(l){p(l.response?.data?.error||s("calendar.importError"),"error")}he(!1),I.current&&(I.current.value="")}}const et=new Date(d,c,1).getDay(),je=new Date(d,c+1,0).getDate(),T=[];for(let e=0;e<et;e++)T.push(null);for(let e=1;e<=je;e++)T.push(e);for(;T.length%7!==0;)T.push(null);const M={};D.forEach(e=>{const a=new Date(e.start_at);if(a.getFullYear()===d&&a.getMonth()===c){const l=a.getDate();M[l]||(M[l]=[]),M[l].push(e)}});const S=(()=>{const e=new Date(V),a=e.getDay(),l=new Date(e);return l.setDate(e.getDate()-a),Array.from({length:7},(i,u)=>{const n=new Date(l);return n.setDate(l.getDate()+u),n})})(),tt=Array.from({length:14},(e,a)=>a+7),at=e=>{const a=`${e.getFullYear()}-${h(e.getMonth()+1)}-${h(e.getDate())}`;return D.filter(l=>{const i=new Date(l.start_at);return`${i.getFullYear()}-${h(i.getMonth()+1)}-${h(i.getDate())}`===a})},[z,ve]=r.useState(null),we=(e,a)=>{ve(a),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",String(a.id))},ye=async(e,a)=>{if(e.preventDefault(),!z)return;const l=new Date(z.start_at),i=new Date(z.end_at).getTime()-l.getTime(),u=new Date(a);u.setHours(l.getHours(),l.getMinutes(),0);const n=new Date(u.getTime()+i);try{await x.put(`/api/crm/appointments/${z.id}`,{...z,start_at:u.toISOString(),end_at:n.toISOString()}),p(s("calendar.appointmentMoved")),v()}catch{p(s("calendar.moveError"),"error")}ve(null)},ke=e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},Z=[],st=new Date(d,c,1).getDay();for(let e=0;e<st;e++)Z.push(null);for(let e=1;e<=je;e++)Z.push(e);const Y=new Date().getDate(),G=new Date().getMonth(),H=new Date().getFullYear();return t.jsxs("div",{className:"fixed inset-0 md:relative md:inset-auto md:min-
1h-screen p-4 md:p-6 pb-16 md:pb-6 space-y-4 md:space-y-6 overflow-y-auto z-[25] md:z-auto bg-[#f8fafc]",style:{paddingTop:"max(1rem, env(safe-area-inset-top))"},children:[t.jsx(ee,{children:K&&t.jsx(A.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:`fixed top-4 right-4 z-50 px-5 py-3 rounded-2xl font-bold text-sm shadow-lg ${K.type==="error"?"bg-red-500 text-white":"bg-emerald-500 text-white"}`,children:K.msg})}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 bg-teal-500 rounded-2xl flex items-center justify-center text-white shadow-lg shadow-teal-500/20",children:t.jsx(N,{size:20,strokeWidth:2.5})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-black text-slate-900 tracking-tight",children:s("calendar.title")}),t.jsx("p",{className:"text-xs text-slate-400",children:s("calendar.subtitle")})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[!He&&(ue?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsxs("button",{onClick:Qe,disabled:X,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-blue-50 border border-blue-200 text-[10px] font-black uppercase tracking-widest text-blue-600 hover:bg-blue-100 transition-all disabled:opacity-50",children:[t.jsx(te,{size:12,className:X?"animate-spin":""})," ",s(X?"calendar.syncing":"calendar.syncGoogle")]}),t.jsx("button",{onClick:Je,title:s("calendar.disconnectGcalTooltip"),className:"p-2 rounded-xl bg-white border border-slate-200 text-slate-400 hover:text-red-500 hover:border-red-200 transition-all",children:t.jsx(nt,{size:13})})]}):t.jsxs("button",{onClick:qe,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-white border border-slate-200 text-[10px] font-black uppercase tracking-widest text-slate-600 hover:bg-blue-50 hover:border-blue-200 hover:text-blue-600 transition-all",children:[t.jsx(rt,{size:13})," Google Calendar"]})),t.jsx("input",{ref:I,type:"file",accept:".ics,.ical",onChange:Ze,className:"hidden"}),t.jsxs("button",{onClick:()=>I.current?.click(),disabled:ge,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-white border border-slate-200 text-[10px] font-black uppercase tracking-widest text-slate-600 hover:bg-slate-50 transition-all disabled:opacity-50",children:[t.jsx(ot,{size:13})," ",s(ge?"calendar.importing":"calendar.importIcsBtn")]}),t.jsxs("button",{onClick:()=>Ye(e=>!e),className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-white border border-slate-200 text-[10px] font-black uppercase tracking-widest text-slate-600 hover:bg-slate-50 transition-all",children:[t.jsx(ct,{size:13})," ",s("calendar.schedule"),t.jsx(it,{size:12,className:`transition-transform ${ce?"rotate-180":""}`})]}),t.jsx("div",{className:"flex bg-white border border-slate-200 rounded-xl overflow-hidden",children:[{k:"month",l:s("calendar.month")},{k:"week",l:s("calendar.week")},{k:"list",l:s("calendar.list")}].map(e=>t.jsx("button",{onClick:()=>Le(e.k),className:`px-3 py-2 text-[10px] font-black uppercase tracking-widest transition-all ${w===e.k?"bg-teal-500 text-white":"text-slate-500 hover:bg-slate-50"}`,children:e.l},e.k))}),t.jsxs("button",{onClick:()=>J(),className:"flex items-center gap-2 px-5 py-2.5 bg-slate-900 text-white rounded-2xl text-[10px] font-black uppercase tracking-widest hover:bg-teal-600 transition-all shadow-lg active:scale-95",children:[t.jsx(_e,{size:14})," ",s("calendar.newAppointment")]})]})]}),t.jsx(ee,{children:ce&&t.jsx(A.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:t.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-5 space-y-4 shadow-sm",children:[t.jsx("h3",{className:"text-[10px] font-black text-slate-500 uppercase tracking-widest",children:s("calendar.scheduleTitle")}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider block mb-2",children:s("calendar.workingDays")}),t.jsx("div",{className:"flex gap-2",children:q.map((e,a)=>t.jsx("button",{onClick:()=>Ve(a),className:`px-3 py-2 rounded-xl text-xs font-bold transition-all ${j.days.includes(a)?"bg-teal-500 text-white shadow-sm":"bg-slate-100 text-slate-400 hover:bg-slate-200"}`,children:e},a))})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider block mb-1",children:s("calendar.startHour")}
1),t.jsx("input",{type:"time",value:j.start_hour,onChange:e=>C(a=>({...a,start_hour:e.target.value})),className:"w-full p-3 border border-slate-200 rounded-xl bg-slate-50 text-sm outline-none focus:border-teal-400"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider block mb-1",children:s("calendar.endHour")}),t.jsx("input",{type:"time",value:j.end_hour,onChange:e=>C(a=>({...a,end_hour:e.target.value})),className:"w-full p-3 border border-slate-200 rounded-xl bg-slate-50 text-sm outline-none focus:border-teal-400"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider block mb-2",children:s("calendar.unavailableDays")}),t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("input",{type:"date",value:E,onChange:e=>xe(e.target.value),className:"p-2.5 border border-slate-200 rounded-xl bg-slate-50 text-sm outline-none focus:border-teal-400"}),t.jsxs("button",{onClick:We,disabled:!E,className:"flex items-center gap-1.5 px-3 py-2.5 bg-slate-900 text-white rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-teal-600 transition-all disabled:opacity-50",children:[t.jsx(_e,{size:12})," ",s("calendar.add")]})]}),(j.vacations||[]).length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:j.vacations.map(e=>t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-red-50 border border-red-200 text-red-600 rounded-lg text-xs font-bold",children:[e,t.jsx("button",{onClick:()=>Be(e),className:"hover:text-red-800",children:t.jsx(De,{size:11})})]},e))})]}),t.jsxs("button",{onClick:Ue,disabled:ie,className:"flex items-center gap-2 bg-teal-600 hover:bg-teal-700 text-white px-5 py-2.5 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all active:scale-95 disabled:opacity-50",children:[t.jsx(dt,{size:13})," ",s(ie?"calendar.savingSchedule":"calendar.saveSchedule")]})]})})}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"hidden lg:block w-52 shrink-0",children:[t.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm p-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("button",{onClick:()=>b(e=>new Date(e.getFullYear(),e.getMonth()-1,1)),className:"p-1 rounded hover:bg-slate-100",children:t.jsx(Ce,{size:14})}),t.jsxs("span",{className:"text-xs font-black text-slate-700",children:[O[c].slice(0,3)," ",d]}),t.jsx("button",{onClick:()=>b(e=>new Date(e.getFullYear(),e.getMonth()+1,1)),className:"p-1 rounded hover:bg-slate-100",children:t.jsx(Se,{size:14})})]}),t.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[s("calendar.daysInitials").map((e,a)=>t.jsx("div",{className:"text-[9px] font-bold text-slate-400 py-0.5",children:e},a)),Z.map((e,a)=>{const l=e&&e===Y&&c===G&&d===H,i=e&&w==="week"&&S.some(n=>n.getDate()===e&&n.getMonth()===c),u=e&&M[e]?.length>0;return t.jsxs("button",{disabled:!e,onClick:()=>e&&b(new Date(d,c,e)),className:`w-7 h-7 rounded-full text-[11px] font-bold transition-all ${e?l?"bg-teal-500 text-white":i?"bg-teal-100 text-teal-700":"hover:bg-slate-100 text-slate-600":""}`,children:[e||"",u&&!l&&t.jsx("span",{className:"block w-1 h-1 rounded-full bg-teal-400 mx-auto -mt-0.5"})]},a)})]})]}),t.jsxs("div",{className:"mt-3 bg-white rounded-2xl border border-slate-200 shadow-sm p-3 space-y-1.5",children:[t.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest",children:s("calendar.types")}),F.map(e=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${e.color}`}),t.jsx("span",{className:"text-[10px] text-slate-600 font-medium",children:e.label})]},e.value))]})]}),t.jsxs("div",{className:"flex-1 min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between sm:justify-start gap-2 sm:gap-4 bg-white rounded-2xl border border-slate-200 px-3 py-2 shadow-sm",children:[t.jsx("button",{onClick:()=>{b(w==="week"?e=>{const a=new Date(e);return a.setDate(a.getDate()-7),a}:e=>
1new Date(e.getFullYear(),e.getMonth()-1,1))},className:"p-2 rounded-xl hover:bg-slate-100 transition-colors",children:t.jsx(Ce,{size:18})}),t.jsx("h2",{className:"text-lg font-black text-slate-900 min-w-[140px] text-center",children:w==="week"?`${S[0].getDate()} - ${S[6].getDate()} ${O[S[6].getMonth()].slice(0,3)}`:`${O[c]} ${d}`}),t.jsx("button",{onClick:()=>{b(w==="week"?e=>{const a=new Date(e);return a.setDate(a.getDate()+7),a}:e=>new Date(e.getFullYear(),e.getMonth()+1,1))},className:"p-2 rounded-xl hover:bg-slate-100 transition-colors",children:t.jsx(Se,{size:18})}),t.jsx("button",{onClick:()=>b(new Date),className:"px-3 py-1.5 rounded-xl bg-teal-50 text-teal-600 text-[10px] font-black uppercase tracking-widest hover:bg-teal-100 transition-all",children:s("calendar.today")}),ue&&t.jsxs("span",{className:"hidden sm:flex items-center gap-1.5 px-2.5 py-1 bg-blue-50 border border-blue-200 text-blue-600 rounded-full text-[9px] font-black uppercase tracking-widest",children:[t.jsx(L,{size:10})," Google"]})]}),Ae?t.jsxs("div",{className:"flex items-center justify-center py-20 text-slate-400",children:[t.jsx(te,{size:20,className:"animate-spin mr-3"})," ",s("calendar.loading")]}):w==="month"?t.jsxs("div",{className:"bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden",children:[t.jsx("div",{className:"grid grid-cols-7 border-b border-slate-100",children:q.map(e=>t.jsx("div",{className:"py-3 text-center text-[10px] font-black text-slate-400 uppercase tracking-widest",children:e},e))}),t.jsx("div",{className:"grid grid-cols-7",children:T.map((e,a)=>{const l=e&&e===Y&&c===G&&d===H,i=e?M[e]||[]:[],u=e?`${d}-${h(c+1)}-${h(e)}`:"",n=e&&(j.vacations||[]).includes(u),k=e?new Date(d,c,e).getDay():-1,$=e&&!(j.days||[]).includes(k),Ne=n||$;return t.jsx("div",{onClick:()=>e&&J(new Date(d,c,e)),onDragOver:e?ke:void 0,onDrop:e?m=>ye(m,new Date(d,c,e)):void 0,className:`min-h-[60px] sm:min-h-[100px] p-1.5 sm:p-2 border-b border-r border-slate-100 cursor-pointer transition-colors
2                    ${e?Ne?"bg-red-50/40":"hover:bg-teal-50/30":"bg-slate-50/50"}
3                    ${l?"bg-teal-50":""}
4                    ${z&&e?"hover:bg-teal-100/50":""}`,children:e&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`w-7 h-7 flex items-center justify-center rounded-full text-sm font-black mb-1
5                        ${l?"bg-teal-500 text-white":Ne?"text-red-400":"text-slate-600"}`,children:e}),n&&t.jsx("div",{className:"text-[9px] font-bold text-red-400 mb-0.5",children:s("calendar.vacation")}),$&&!n&&t.jsx("div",{className:"text-[9px] font-bold text-slate-400 mb-0.5",children:s("calendar.nonWorking")}),t.jsxs("div",{className:"space-y-0.5",children:[i.slice(0,3).map(m=>{const lt=P(m.appointment_type).color;return t.jsxs("div",{draggable:!0,onDragStart:R=>{R.stopPropagation(),we(R,m)},onClick:R=>{R.stopPropagation(),Q(m)},className:`text-[10px] font-bold pl-0 pr-1.5 py-0.5 rounded-md truncate border cursor-grab active:cursor-grabbing hover:opacity-80 flex items-center gap-1 overflow-hidden ${ae[m.status]||"bg-slate-100 text-slate-600 border-slate-200"}`,children:[t.jsx("span",{className:`w-1 self-stretch shrink-0 rounded-l-md ${lt}`}),m.meet_link&&t.jsx(L,{size:8,className:"shrink-0 text-blue-500"}),m.google_event_id&&!m.meet_link&&t.jsx(N,{size:8,className:"shrink-0 text-blue-400"}),t.jsxs("span",{className:"truncate",children:[new Date(m.start_at).toLocaleTimeString("es-MX",{hour:"2-digit",minute:"2-digit"})," ",m.title]})]},m.id)}),i.length>3&&t.jsx("div",{className:"text-[9px] text-slate-400 font-bold px-1",children:s("calendar.more",{count:i.length-3})})]})]})},a)})})]}):w==="week"?t.jsxs("div",{className:"bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"grid grid-cols-[60px_repeat(7,1fr)] border-b border-slate-100",children:[t.jsx("div",{className:"py-3 text-center text-[9px] font-bold text-slate-300"}),S.map((e,a)=>{const l=e.getDate()===Y&&e.getMonth()===G&&e.getFullYear()===H;return t.jsxs("div",{className:`py-2 text-center border-l border-slate-100 ${l?"bg-teal-50":""}`,children:[t.jsx("p",{className:"text-[9px] font-bold text-slate-400 uppercase",children:q[e.getDay()]}),t.jsx("p",{className:`text-lg font-black ${l?"text-teal-600":"text-slate-700"}`,children:e.getDate()})]},a)})]}),t.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:tt.map(e=>t.jsxs("div",{className:"grid grid-cols-[60px_repeat(7,1fr)] min-h-[56px] border-b border-slate-50",children:[t.jsxs("div",{className:"text-[10px] font-bold text-slate-400 text-right pr-2 pt-1",children:[h(e),":00"]}),S.map((a,l)=>{const i=at(a).filter(n=>new Date(n.start_at).getHours()===e),u=a.getDate()===Y&&a.getMonth()===G&&a.getFullYear()===H;return t.jsx("div",{onClick:()=>{const n=new Date(a);n.setHours(e,0),J(n)},onDragOver:ke,onDrop:n=>{const k=new Date(a);k.setHours(e,0),ye(n,k)},className:`border-l border-slate-100 p-0.5 cursor-pointer hover:bg-teal-50/30 transition-colors ${u?"bg-teal-50/20":""}`,children:i.map(n=>{const k=P(n.appointment_type).color;return t.jsxs("div",{draggable:!0,onDragStart:$=>we($,n),onClick:$=>{$.stopPropagation(),Q(n)},className:`text-[9px] font-bold px-1.5 py-1 rounded-md mb-0.5 cursor-grab active:cursor-grabbing truncate border ${ae[n.status]||"bg-slate-100 text-slate-600 border-slate-200"}`,children:[t.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full mr-1 ${k}`}),new Date(n.start_at).toLocaleTimeString("es-MX",{hour:"2-digit",minute:"2-digit"})," ",n.title]},n.id)})},l)})]},e))})]}):t.jsx("div",{className:"space-y-3",children:D.length===0?t.jsxs("div",{className:"text-center py-16 bg-white rounded-3xl border border-slate-200",children:[t.jsx(N,{size:32,className:"text-slate-300 mx-auto mb-3"}),t.jsx("p",{className:"text-slate-400 font-bold",children:s("calendar.noAppointments")})]}):D.map(e=>t.jsxs(A.div,{layout:!0,className:"bg-white rounded-2xl border border-slate-200 shadow-sm p-4 flex items-start gap-4 hover:shadow-md transition-all",children:[t.jsxs("div",{className:"w-12 text-center shrink-0",children:[t.jsx("p",{className:"text-2xl font-black text-slate-900",children:new Date(e.start_at).getDate()}),t.jsx("p",{className:"text-[10px] font-bold text-slate-400 uppercase",children:O[new Date(e.start_at).getMonth()].slice(0,3)})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h3",{className:"font-black text-slate-900 text-sm",children:e.title}),t.jsx("span",{className:`text-[9px] font-black px-2 py-0.5 rounded-full border ${ae[e.status]}`,children:se[e.status]||e.status}),t.jsxs("span",{className:`inline-flex items-center gap-1 text-[9px] font-bold px-2 py-0.5 rounded-full text-white ${P(e.appointment_type).color}`,children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white/40"}),P(e.appointment_type).label]}),e.google_event_id&&t.jsxs("span",{className:"text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-blue-50 border border-blue-200 text-blue-500",children:[t.jsx(N,{size:9,className:"inline -mt-px"})," Google"]}),e.meet_link&&t.jsxs("a",{href:e.meet_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[9px] font-black px-2 py-0.5 rounded-full bg-blue-50 border border-blue-200 text-blue-600 hover:bg-blue-100 transition-colors",children:[t.jsx(L,{size:9})," Meet",t.jsx(ze,{size:8})]})]}),t.jsxs("div",{className:"flex items-center gap-4 mt-1 text-[11px] text-slate-500 font-medium flex-wrap",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(xt,{size:11})," ",new Date(e.start_at).toLocaleTimeString("es-MX",{hour:"2-digit",minute:"2-digit"})," — ",new Date(e.end_at).toLocaleTimeString("es-MX",{hour:"2-digit",minute:"2-digit"})]}),e.contact_name&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(pt,{size:11})," ",e.contact_name]}),e.agent_name&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(ut,{size:11})," ",e.agent_name]}),e.location&&t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(mt,{size:11})," ",e.location]})]})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.meet_link&&t.jsx("a",{href:e.meet_link,target:"_blank",rel:"noopener noreferrer",title:s("calendar.openVideocall"),className:"p-1.5 rounded-xl bg-blue-50 text-blue-600 hover:bg-blue-500 hover:text-white transition-all",children:t.jsx(L,{size:13})}),e.status==="scheduled"&&t.jsx("button",{onClick:()=>Ke(e.id,"completed"),title:s("calendar.markCompleted"),className:"p-1.5 rounded-xl bg-emerald-50 text-emerald-600 hover:bg-emerald-500 hover:text-white transition-all",children:t.jsx(gt,{size:13})}),t.jsx("button",{onClick:()=>Q(e),className:"p-1.5 rounded-xl hover:bg-slate-100 text-slate-400 hover:text-slate-700 transition-all",children:t.jsx(N,{size:13})}),t.jsx("button",{onClick:()=>fe(e.id),className:"p-1.5 rounded-xl hover:bg-red-50 text-slate-400 hover:text-red-500 transition-all",children:t.jsx($e,{size:13})})]})]},e.id))}),t.jsx(ee,{children:Ee&&t.jsx(A.div,{initial:{opacity:0}
5,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onMouseDown:e=>{e.target===e.currentTarget&&y(!1)},children:t.jsxs(A.div,{initial:{scale:.95,y:20},animate:{scale:1,y:0},exit:{scale:.95},className:"w-full h-full sm:h-auto max-w-lg bg-white sm:rounded-3xl shadow-2xl overflow-hidden sm:max-h-[90vh] flex flex-col",children:[t.jsxs("div",{className:"p-5 border-b border-slate-100 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"font-black text-slate-900",children:s(f?"calendar.editAppointment":"calendar.newAppointment")}),f?.meet_link&&t.jsxs("a",{href:f.meet_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[10px] font-bold text-blue-500 hover:text-blue-700 mt-0.5",children:[t.jsx(L,{size:11})," ",s("calendar.openVideocall")," ",t.jsx(ze,{size:9})]})]}),t.jsx("button",{onClick:()=>y(!1),className:"p-2 rounded-xl hover:bg-slate-100",children:t.jsx(De,{size:18})})]}),t.jsxs("div",{className:"p-5 space-y-4 overflow-y-auto flex-1",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.titleLabel")}),t.jsx("input",{value:o.title,onChange:e=>g(a=>({...a,title:e.target.value})),placeholder:s("calendar.titlePlaceholder"),className:"w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.startLabel")}),t.jsx("input",{type:"datetime-local",value:o.start_at,onChange:e=>g(a=>({...a,start_at:e.target.value})),className:"w-full px-3 py-2.5 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.endLabel")}),t.jsx("input",{type:"datetime-local",value:o.end_at,onChange:e=>g(a=>({...a,end_at:e.target.value})),className:"w-full px-3 py-2.5 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500"})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.typeLabel")}),t.jsx("select",{value:o.appointment_type,onChange:e=>g(a=>({...a,appointment_type:e.target.value})),className:"w-full px-3 py-2.5 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500",children:F.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.statusLabel")}),t.jsx("select",{value:o.status,onChange:e=>g(a=>({...a,status:e.target.value})),className:"w-full px-3 py-2.5 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500",children:Object.entries(se).map(([e,a])=>t.jsx("option",{value:e,children:a},e))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.agentLabel")}),t.jsxs("select",{value:o.agent_id,onChange:e=>g(a=>({...a,agent_id:e.target.value})),className:"w-full px-3 py-2.5 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500",children:[t.jsx("option",{value:"",children:s("dashboard.unassigned")}),Fe.map(e=>t.jsx("option",{value:e.id,children:e.display_name||e.username},e.id))]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.contactLabel")}),t.jsxs("select",{value:o.contact_id,onChange:e=>g(a=>({...a,contact_id:e.target.value})),className:"w-full px-3 py-2.5 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500",children:[t.jsx("option",{value:"",children:s("calendar.noContact")}),Ie.map(e=>t.jsx("option",{value:e.id,children:e.name||e.phone||`#${e.id}`},e.id))]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.locationLabel")}),t.jsx("input",{value:o.location,onChange:e=>g(a=>({...a,location:e.target.value})),placeholder:s("calendar.locationPlaceholder"),className:"w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] font-black text-slate-400 uppercase tracking-widest block mb-1",children:s("calendar.descriptionLabel")}),t.jsx("textarea",{value:o.description,onChange:e=>g(a=>({...a,description:e.target.value})),rows:3,placeholder:s("calendar.descriptionPlaceholder"),className:"w-full px-4 py-3 rounded-xl bg-slate-50 border border-slate-200 text-sm outline-none focus:border-teal-500 resize-none"})]})]}),t.jsxs("div",{className:"p-5 border-t border-slate-100 flex gap-3",children:[f&&t.jsx("button",{onClick:()=>fe(f.id).then(()=>y(!1)),className:"px-4 py-3 rounded-2xl bg-red-50 text-red-500 font-black text-xs uppercase tracking-widest hover:bg-red-500 hover:text-white transition-all",children:t.jsx($e,{size:13})}),t.jsx("button",{onClick:()=>y(!1),className:"flex-1 py-3 rounded-2xl bg-slate-100 text-slate-600 font-black text-xs uppercase tracking-widest hover:bg-slate-200 transition-all",children:s("calendar.cancel")}),t.jsxs("button",{onClick:Xe,disabled:W||!o.title||!o.start_at||!o.end_at,className:"flex-1 py-3 rounded-2xl bg-slate-900 text-white font-black text-xs uppercase tracking-widest hover:bg-teal-600 transition-all disabled:opacity-40 flex items-center justify-center gap-2",children:[W?t.jsx(te,{size:13,className:"animate-spin"}):t.jsx(N,{size:13}),s(W?"calendar.saving":"calendar.save")]})]})]})})})]})]}),t.jsx(Te,{}),t.jsxs("div",{className:"md:hidden fixed bottom-0 left-0 right-0 z-30 bg-slate-900/95 backdrop-blur-md border-t border-slate-700/50 flex items-stretch",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[t.jsxs("button",{onClick:()=>_("/"),className:"flex-1 flex flex-col items-center justify-center py-2.5 gap-1 text-[9px] font-black uppercase tracking-widest text-slate-500 active:text-slate-300 relative",children:[t.jsx(ht,{size:21}),s("dashboard.chats")]}),t.jsxs("button",{onClick:()=>_("/"),className:"flex-1 flex flex-col items-center justify-center py-2.5 gap-1 text-[9px] font-black uppercase tracking-widest text-slate-500 active:text-slate-300 relative",children:[t.jsx(bt,{size:21}),s("dashboard.catalog")]}),t.jsxs("button",{className:"flex-1 flex flex-col items-center justify-center py-2.5 gap-1 text-[9px] font-black uppercase tracking-widest text-emerald-400 relative",children:[t.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-8 h-0.5 bg-emerald-400 rounded-full"}),t.jsx(N,{size:21}),s("dashboard.schedule")]})]})]})}export{zt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.