PageSourceSearch

https://app.xlift.ai/assets/CalendarPage-B_kG0eVJ.js

js xlift.ai collected 2026-10-05 13:20:37 UTC 9,062 bytes, 6 lines download raw bytes

1import{v as _,ai as Z,o,A as O,j as e,C as Y,G as h,b4 as J,$ as X,T as C,F as R,ao as V,D as ee,X as v,ag as te,S as ae,E as Q,W as se,al as L,a4 as $,a5 as P,U as S,I as ne,a7 as oe,Z as ie,L as N,ay as re}from"./index-dE8a1mPK.js";import{u as le}from"./useConfirm-4D74KrCi.js";import{H as K}from"./HandleLink-CMsO54nu.js";import{S as B}from"./Select-DebRlW67.js";import{I as ce}from"./IconChevronRight-Bs3jiBox.js";import{T as de}from"./Textarea-BtbUvWWM.js";import{I as ue}from"./IconClock-DGXUTa2e.js";import{I as ge}from"./IconTrash-DIXYcrq7.js";import{I as he}from"./IconDeviceFloppy-DgEyIcAH.js";import"./IconExternalLink-DcQXcLz7.js";import"./OptionsDropdown-wonErrz5.js";import"./CheckIcon-DkMc45y2.js";import"./get-env-uyVen0u2.js";/**
2 * @license @tabler/icons-react v3.43.0 - MIT
3 *
4 * This source code is licensed under the MIT license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const xe=[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]],me=_("outline","chevron-left","ChevronLeft",xe),G={"send-dm":"blue",reply:"cyan",like:"pink",retweet:"grape",quote:"indigo",bookmark:"lime",post:"violet",follow:"teal",unfollow:"gray"};function pe(t,r){const l=new Date(Date.UTC(t,r,1)),x=l.getUTCDay(),d=new Date(l);return d.setUTCDate(d.getUTCDate()-x),d}function W(t){return t.toISOString().slice(0,10)}function ze(){var a,g,k,H;const t=Z(),r=new Date,[l,x]=o.useState(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),1))),[d,z]=o.useState(null),[m,F]=o.useState(null),[j,T]=o.useState(null),u=o.useMemo(()=>pe(l.getUTCFullYear(),l.getUTCMonth()),[l]),D=o.useMemo(()=>{const s=new Date(u);return s.setUTCDate(s.getUTCDate()+42),s},[u]),y=O({queryKey:["accounts"],queryFn:()=>S.listAccounts()}),p=O({queryKey:["calendar-events",u.getTime(),D.getTime()],queryFn:()=>S.calendarEvents(u.getTime(),D.getTime()),refetchInterval:18e4}),U=o.useMemo(()=>{var n;const s=new Map;for(const c of((n=p.data)==null?void 0:n.events)||[]){if(d&&c.accountId!==d||m&&c.status!==m)continue;const w=W(new Date(c.scheduledFor)),f=s.get(w)||[];f.push(c),s.set(w,f)}return s},[p.data,d,m]);function b(s){x(n=>new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+s,1)))}function M(){x(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),1)))}const q=o.useMemo(()=>{const s=[];for(let n=0;n<42;n++){const c=new Date(u);c.setUTCDate(c.getUTCDate()+n),s.push(c)}return s},[u]),A=l.getUTCMonth(),E=l.toLocaleString("en-US",{month:"long",year:"numeric",timeZone:"UTC"}),I=W(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())));return e.jsxs(Y,{gap:"md",style:{height:"calc(100vh - 88px)"},children:[e.jsxs(h,{justify:"space-between",wrap:"wrap",gap:"xs",children:[e.jsxs(h,{gap:"xs",children:[e.jsx(J,{size:20}),e.jsx(X,{order:2,children:"Calendar"}),e.jsxs(C,{c:"dimmed",size:"sm",children:[((g=(a=p.data)==null?void 0:a.events)==null?void 0:g.length)||0," scheduled · queued + awaiting-approval"]})]}),e.jsxs(h,{gap:"xs",children:[e.jsx(B,{size:"xs",placeholder:"All accounts",value:d,onChange:z,clearable:!0,data:(((k=y.data)==null?void 0:k.accounts)||[]).map(s=>({value:s.id,label:`@${s.handle}`})),style:{minWidth:140}}),e.jsx(B,{size:"xs",placeholder:"All statuses",value:m,onChange:F,clearable:!0,data:[{value:"queued",label:"queued"},{value:"awaiting-approval",label:"awaiting-approval"}],style:{minWidth:140}}),e.jsx(R,{variant:"default",size:"lg",onClick:()=>p.refetch(),loading:p.isRefetching,children:e.jsx(V,{size:16})})]})]}),e.jsxs(ee,{withBorder:!0,p:0,style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs(h,{justify:"space-between",p:"sm",style:{borderBottom:"1px solid var(--xb-line-soft)"},children:[e.jsxs(h,{gap:"xs",children:[e.jsx(R,{variant:"default",onClick:()=>b(-1),"aria-label":"Previous month",children:e.jsx(me,{size:16})}),e.jsx(C,{fw:600,miw:160,ta:"center",children:E}),e.jsx(R,{variant:"default",onClick:()=>b(1),"aria-label":"Next month",children:e.jsx(ce,{size:16})}),e.jsx(v,{size:"xs",variant:"default",onClick:M,children:"Today"})]}),e.jsx(C,{size:"xs",c:"dimmed",children:"All times UTC"})]}),p.isLoading&&e.jsx(te,{}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",borderBottom:"1px solid var(--xb-line-soft)",flexShrink:0},children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(s=>e.jsx("div",{style:{padding:"6px 8px",fontSize:11,fontWeight:600,color:"var(--xb-muted)"},children:s},s))}),e.jsx(ae,{style:{flex:1},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gridAutoRows:"minmax(96px, 1fr)"},children:q.map(s=>{const n=W(s),c=s.getUTCMonth()===A,w=n===I,f=U.get(n)||[];return e.jsxs("div",{style:{padding:6,borderRight:"1px solid var(--xb-line-soft)",borderBottom:"1px solid var(--xb-line-soft)",background:c?w?"rgba(29,155,240,0.06)":void 0:"var(--xb-bg-soft)",minHeight:96},children:[e.jsxs(h,{justify:"space-between",gap:4,children:[e.jsx(C,{size:"xs",fw:w?700:500,c:c?void 0:"dimmed",children:s.getUTCDate()}),f.length>0&&e.jsx(Q,{size:"xs",variant:"light",children:f.length})]}),e.jsxs(Y,{gap:2,mt:4,children:[f.slice(0,3).map(i=>e.jsx(se,{label:i.text||i.target||i.type,multiline:!0,w:300,disabled:!i.text,children:e.jsxs("button",{onClick:()=>T(i),style:{display:"block",width:"100%",textAlign:"left",padding:"3px 6px",borderRadius:4,fontSize:10,border:"none",cursor:"pointer",background:`var(--mantine-color-${G[i.type]||"gray"}-1)`,color:`var(--mantine-color-${G[i.type]||"gray"}-9)`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[new Date(i.scheduledFor).toUTCString().slice(17,22)," · ",i.type,i.target?` ${i.target}`:""]})},i.id)),f.length>3&&e.jsxs(C,{size:"xs",c:"dimmed",children:["+ ",f.length-3," more"]})]})]},n)})})})]})]}),j&&e.jsx(fe,{event:j,accounts:((H=y.data)==null?void 0:H.accounts)||[],onClose:()=>T(null),onSaved:()=>{t.invalidateQueries({queryKey:["calendar-events"]}),T(null)}})]})}function fe({event:t,accounts:r,onClose:l,onSaved:x}){var I;const{confirm:d,ConfirmDialog:z}
6=le(),[m,F]=o.useState(t.text||""),[j,T]=o.useState(t.target||""),[u,D]=o.useState(t.accountId),[y,p]=o.useState(t.scheduledFor),U=L({mutationFn:()=>S.patchAction(t.id,{text:m!==t.text?m:void 0,target:j!==t.target?j:void 0,accountId:u!==t.accountId?u:void 0,scheduledFor:y!==t.scheduledFor?y:void 0}),onSuccess:()=>{P("Updated"),x()},onError:a=>$(a)}),b=L({mutationFn:()=>S.rejectAction(t.id,"deleted from calendar"),onSuccess:()=>{P("Removed from queue"),x()},onError:a=>$(a)}),M=L({mutationFn:()=>S.patchAction(t.id,{scheduledFor:Date.now()}),onSuccess:()=>{P("Rescheduled for now — will dispatch next tick"),x()},onError:a=>$(a)}),q=o.useMemo(()=>{const a=new Date(y),g=k=>String(k).padStart(2,"0");return`${a.getFullYear()}-${g(a.getMonth()+1)}-${g(a.getDate())}T${g(a.getHours())}:${g(a.getMinutes())}`},[y]),A=r.filter(a=>a.status==="active"),E=t.campaignId?e.jsx(ne,{component:oe,to:`/campaigns/${t.campaignId}`,size:"xs",children:"view campaign"}):null;return e.jsxs(ie,{opened:!0,onClose:l,title:`Edit · ${t.type}`,size:"lg",children:[e.jsxs(Y,{children:[e.jsxs(h,{gap:"xs",children:[e.jsx(Q,{color:"blue",variant:"light",children:t.status}),e.jsx(K,{handle:t.accountHandle,accountId:t.accountId,size:"xs"}),((I=t.target)==null?void 0:I.startsWith("@"))&&e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"xs",c:"dimmed",children:"→"}),e.jsx(K,{handle:t.target,size:"xs"})]}),E]}),t.text!==void 0&&e.jsx(de,{label:"Message",description:"What actually goes out on dispatch (rendered for posts / DMs / replies).",value:m,onChange:a=>F(a.currentTarget.value),autosize:!0,minRows:3,maxRows:10}),(t.target||t.recipientHandle)&&e.jsx(N,{label:"Target",description:"@handle or context label",value:j,onChange:a=>T(a.currentTarget.value)}),e.jsxs(h,{grow:!0,align:"flex-end",children:[e.jsx(B,{label:"Account",value:u,onChange:D,data:A.map(a=>({value:a.id,label:`@${a.handle}`}))}),e.jsx(N,{label:"Scheduled for",type:"datetime-local",value:q,onChange:a=>{const g=new Date(a.currentTarget.value);isNaN(g)||p(g.getTime())},leftSection:e.jsx(ue,{size:14})})]}),e.jsxs(h,{justify:"space-between",mt:"sm",children:[e.jsx(v,{variant:"subtle",color:"red",leftSection:e.jsx(ge,{size:14}),onClick:async()=>{await d({title:"Remove this from the queue?",body:"The action will not dispatch. This is reversible only by manually re-queuing — campaign-driven actions can be re-materialized by pausing + resuming the campaign.",confirmLabel:"Remove"})&&b.mutate()},loading:b.isPending,children:"Delete"}),e.jsxs(h,{gap:"xs",children:[e.jsx(v,{variant:"default",leftSection:e.jsx(re,{size:14}),onClick:()=>M.mutate(),loading:M.isPending,disabled:t.status!=="queued",title:t.status!=="queued"?"Only queued actions can be rushed":"Move to the front of the queue",children:"Send now"}),e.jsx(v,{variant:"default",onClick:l,children:"Cancel"}),e.jsx(v,{leftSection:e.jsx(he,{size:14}),onClick:()=>U.mutate(),loading:U.isPending,children:"Save"})]})]})]}),e.jsx(z,{})]})}export{ze 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.