1import{j as t,r as g}from"./react-vendor-Bmz6tUQp.js";import{S as D}from"./StudioLayout-BYsr_yz8.js";import{z as T,aV as C,aZ as u,ac as R,af as S,c as h,aY as E,aG as L,a_ as $,s,a$ as x}from"./index-yGQYYxOL.js";import{T as q,a as B,b as _,c as d,d as F,e as n}from"./table-DtS6AAHC.js";import{u as I,a as w}from"./react-query-CqJKaf_6.js";import{f as K,a as M}from"./date-utils-Ds47y5fu.js";import"./layoutChromeContext-B8wOgQHq.js";import"./sheet-E8V6rKho.js";import"./radix-ui-ZQ4NEGId.js";import"./scroll-area-CTXX4zJD.js";import"./hover-card-7maBKw4z.js";import"./useSandboxMode-D_xQP-6P.js";import"./layers-CpshUOTI.js";import"./flask-conical-CbacJeSM.js";import"./CheckoutEventHost-DTjSeBaM.js";import"./command-CluFf2dJ.js";import"./avatar-Cu9l6v2F.js";import"./alert-dialog-DcweoeJj.js";import"./chevrons-up-down-CBiGMD1Q.js";import"./useModuleFlags-CdeIEbS-.js";import"./ticket-BrOjEY3k.js";import"./gift-DPC0uSzX.js";import"./arrow-up-right-B2bL_gsk.js";import"./arrow-down-right-CdcpUIER.js";import"./repeat-CdPkxNh-.js";import"./landmark-BzHnqUmp.js";import"./packScope-D5KvCWlo.js";import"./SeasonalProgramSelector-i80cPjae.js";import"./avatars-FpSs625g.js";import"./alert-N9R4W8y9.js";import"./EnrollmentDocumentSigning-D5w4_n8g.js";import"./tuitionCalculations-BCmDh-j0.js";import"./history-DzHj0DaW.js";import"./ConflictWarning-DuPNVCy_.js";import"./undo-2-C8h_iE3k.js";import"./collapsible-CjtbkKBh.js";import"./calendar-CI5PK0Q8.js";import"./zap-D2y2fmbF.js";import"./rateAmounts-DjE2hUmd.js";import"./credit-card-DVHhs4a_.js";import"./AddPaymentMethodDialog-DpGIWcRz.js";import"./stripe-4dsDpqVd.js";import"./tag-VQ_d03WQ.js";import"./lock-open-DXN290KW.js";import"./referralProgram-B1hs7wTI.js";import"./arrow-right-BBWc1p1Z.js";import"./shopping-cart-nAoolajn.js";import"./storeMath-BJplKfgF.js";import"./image-off-B53MuFwj.js";import"./minus-D9KCJT7p.js";import"./introOfferEligibility-CLHQ33ZG.js";import"./paymentDescription-S6ACYrN5.js";import"./introBatch-dnpWxUB_.js";import"./introOncePerStudent-B1ymvFx2.js";import"./StaffAvailability-BHLGK4OV.js";import"./toggle-group-BwbsK1Pg.js";import"./dates-TkbJcaEO.js";import"./link-2-CC_XOAG7.js";import"./Time12hField-lTraPXdk.js";import"./circle-x-BIvEwQZj.js";import"./door-open-Dd3MU-bp.js";import"./leadToFamily-B2Jta7c-.js";import"./email-fEKTod52.js";import"./ServiceFormSheet-BEXjESYC.js";import"./supabase-CPi6FgBv.js";import"./AddStaffDialog-CKRKjcrn.js";import"./CreateChannelDialog-Cwsjwrqi.js";import"./channelRoles-D1UUtVN4.js";import"./useStudioRoles-0L_i-vuY.js";import"./SetWorkScheduleDialog-BPpA5mSI.js";import"./roleDisplay-BvKkYxGU.js";import"./db-DT2Nhm7F.js";import"./StudioLockUI-XbU6XMA1.js";import"./package-open-Oon1UvkU.js";import"./mapPaymentMethod-DpmmB6ms.js";import"./percent-CGFo9efH.js";import"./processingFees-BPjqP-T6.js";import"./useResolvedStudioId-4NhI4ymN.js";import"./StudioScopeContext-DuERlA3v.js";import"./activityLogger-Cr_Ddowq.js";import"./packageCredits-98BipLn6.js";import"./payLater-CC4-3rUn.js";import"./supabaseIdChunks-Bef6Gi88.js";import"./banknote-BbYRhTf4.js";import"./ellipsis-D2TBdRN-.js";import"./checklistUtils-BF3l88q6.js";import"./useFeatureFlag-BQmFEfzc.js";import"./arrow-up-fLJe0fUX.js";import"./arrow-down-YhA2-Eqi.js";import"./TopBarUserMenu-D8AfRGrC.js";import"./message-square-C2MpRloI.js";import"./eventPlacement-CxUvVAat.js";import"./key-round-Rozap10J.js";import"./life-buoy-CvukGkh3.js";import"./book-marked-DC4I9rXP.js";import"./file-pen-line-ClC3QSrv.js";import"./clipboard-check-DnlMutle.js";import"./scale-DQhJnEse.js";import"./images-0KWJvGb3.js";import"./useStudioClock-BV29loct.js";import"./useAppFeedback-DVBm9OLN.js";import"./sendOutcome-Blx-hQVw.js";import"./FeedbackTicketThread-C3Ic3tY0.js";import"./downloadFile-B8X4qcmL.js";import"./file-spreadsheet-B0hdakas.js";import"./file-sEqy5CI3.js";import"./useMediaRecorder-C35rVl4a.js";import"./uploadSupportMedia-CY3YTW9D.js";import"./FeedbackDialog-B_Xdk0aP.js";import"./ScreenshotUploader-IpnSsi0A.js";import"./square-DfCeLVVY.js";import"./video-CXDthndq.js";import"./video-off-BAq7GLjx.js";import"./file-video-B6qkh9-2.js";import"./screen-share-D5I0bSFL.js";import"./JamesAiConsentDialog-B_Jl1HMJ.js";import"./shield-check-Dg6kcWe4.js";import"./square-pen-BxenKDf2.js";import"./upload-D_sV-C0w.js";import"./circle-play-Cv3LVOD-.js";import"./circle-minus-BvA0rUCD.js";import"./james-ai-agent-DSsDrMLy.js";import"./panel-left-CZb2YaGv.js";import"./menu-CXOcmPTi.js";import"./trending-up-K4Zq70Yn.js";import"./jennie-ai-agent-DIt0f-HY.js";import"./thumbs-up-DYJDjyU_.js";import"./dancingPhrases-B3HunkER.js";import"./MicButton-DOqoLZvO.js";import"./audio-lines-m0fDaGb0.js";import"./charts-DLQlTo8W.js";import"./useKeyboardVisible-Dm6ZVDxB.js";import"./dismissZone-vOinvYL-.js";import"./wrench-cS05I5Y8.js";import"./lightbulb-ZzBiLCXi.js";import"./circle-help-Boo2N3NC.js";import"./paintbrush-22ysdIW8.js";import"./shield-BtFSReAn.js";import"./circle-user-BlBQfICZ.js";import"./usePushNotifications-DTPEoVzI.js";import"./bell-off-YzDEq4go.js";import"./notificationHelpers-BT4lqAsq.js";import"./returnPrivateLessonFunding-BopnlTuv.js";import"./approvePauseRequest-DwfcpBgy.js";import"./pauseRequest-CMo-lL7S.js";import"./tuitionStatus-cuz0eS7N.js";import"./user-check-Cqz0fEDT.js";import"./safeDate-BH0LNSae.js";import"./delete-DdyWALXL.js";import"./list-ordered-WPkA24dh.js";import"./grid-3x3-bKSoNtWU.js";import"./useResolvedWebsite-WjuqtQ3e.js";import"./websiteThemes-D_MfvKIa.js";import"./SubscriptionStatusBadge-WWq9_E4h.js";import"./message-square-heart-B-ZrICxh.js";import"./layout-grid-CP6mNKCe.js";import"./log-out-MFjqza9q.js";import"./bot-T3lzkDrB.js";import"./layout-template-CrlpYtgy.js";import"./useStudioManifest-BL3NEXkb.js";import"./progress-C2bS0x0J.js";import"./videoEmbed-CVesTdUy.js";import"./useTrainingVideos-CKooHSdn.js";import"./VideoThumbnail-BtN21rf5.js";import"./briefcase-business-DZlPVk8C.js";import"./film-azEen_NK.js";import"./tv-SEln45V-.js";import"./panel-top-Bj9X5x5d.js";import"./monitor-B838Tejj.js";import"./csvHelpers-cOovc_ea.js";import"./sounds-BzUHSmji.js";import"./AddLeadDialog-5YtkAL-1.js";import"./leadInfoGate-BaL96Lqq.js";import"./AddCustomerModal-CXxyUY6A.js";import"./contactValidation-CEoU_un0.js";import"./frontDeskSignup-Z2lXeCYl.js";import"./useStaffNotifications-K9qSU-Mm.js";import"./useClockInOut-BhEp6E_L.js";import"./posthog-B4nvxm9K.js";import"./twilio-C1U8FCrE.js";const f={family:"Family",student:"Student",class:"Class",program:"Program"},P={family:"bg-purple-100 text-purple-800 hover:bg-purple-100",student:"bg-green-100 text-green-800 hover:bg-green-100",class:"bg-sky-100 text-sky-800 hover:bg-sky-100",program:"bg-amber-100 text-amber-800 hover:bg-amber-100"};function Q(i){if(!i)return"â";const m=new Date(i).getTime()-Date.now(),o=Math.ceil(m/(1e3*60*60*24));return o<=0?"purging soon":`${o}d left`}function z({studioId:i}){const m=I(),[o,l]=g.useState(null),{data:c,isLoading:y}=w({queryKey:["recently-deleted",i],enabled:!!i,queryFn:async()=>{const e=r=>r.eq("studio_id",i).not("deleted_at","is",null),[a,b,N,k]=await Promise.all([e(s.from("families").select("id, name, deleted_at, scheduled_purge_at")),e(s.from("students").select("id, first_name, last_name, deleted_at, scheduled_purge_at")),e(s.from("classes").select("id, name, deleted_at, scheduled_purge_at")),e(s.from("programs").select("id, name, deleted_at, scheduled_purge_at"))]),p=[];
1return(a.data??[]).forEach(r=>p.push({kind:"family",id:r.id,name:r.name||"Family",deleted_at:r.deleted_at,scheduled_purge_at:r.scheduled_purge_at})),(b.data??[]).forEach(r=>p.push({kind:"student",id:r.id,name:[r.first_name,r.last_name].filter(Boolean).join(" ")||"Student",deleted_at:r.deleted_at,scheduled_purge_at:r.scheduled_purge_at})),(N.data??[]).forEach(r=>p.push({kind:"class",id:r.id,name:r.name||"Class",deleted_at:r.deleted_at,scheduled_purge_at:r.scheduled_purge_at})),(k.data??[]).forEach(r=>p.push({kind:"program",id:r.id,name:r.name||"Program",deleted_at:r.deleted_at,scheduled_purge_at:r.scheduled_purge_at})),p.sort((r,v)=>new Date(v.deleted_at).getTime()-new Date(r.deleted_at).getTime())}}),j=async e=>{l(e.id);try{const{error:a}=e.kind==="class"?await s.rpc("restore_class",{p_class_id:e.id}):e.kind==="program"?await s.rpc("restore_program",{p_program_id:e.id}):await s.rpc("restore_record",{p_table:e.kind==="family"?"families":"students",p_id:e.id});if(a)throw a;x.success(`Restored ${f[e.kind].toLowerCase()} "${e.name}"`),m.invalidateQueries({queryKey:["recently-deleted",i]})}catch(a){x.error(`Couldn't restore: ${a.message??"unknown error"}`)}finally{l(null)}};return t.jsxs("div",{className:"space-y-4 p-4 sm:p-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(u,{className:"h-5 w-5"}),t.jsx("h1",{className:"text-2xl font-bold",children:"Recently Deleted"})]}),t.jsx("p",{className:"text-sm text-muted-foreground -mt-2",children:"Deleted families, students, classes, and programs are kept for 14 days. Restore anything here before it's permanently removed."}),t.jsx(R,{children:t.jsx(S,{className:"p-0",children:y?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(h,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):c!=null&&c.length?t.jsxs(q,{children:[t.jsx(B,{children:t.jsxs(_,{children:[t.jsx(d,{children:"Type"}),t.jsx(d,{children:"Name"}),t.jsx(d,{children:"Deleted"}),t.jsx(d,{children:"Recovery window"}),t.jsx(d,{className:"text-right",children:"Restore"})]})}),t.jsx(F,{children:c.map(e=>t.jsxs(_,{children:[t.jsx(n,{children:t.jsx(E,{variant:"secondary",className:P[e.kind],children:f[e.kind]})}),t.jsx(n,{children:t.jsx("span",{className:"text-sm font-medium",children:e.name})}),t.jsx(n,{children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-sm",children:K(new Date(e.deleted_at),"MMM d, yyyy h:mm a")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:M(new Date(e.deleted_at),{addSuffix:!0})})]})}),t.jsx(n,{children:t.jsx("span",{className:"text-sm text-muted-foreground",children:Q(e.scheduled_purge_at)})}),t.jsx(n,{className:"text-right",children:t.jsx(L,{variant:"outline",size:"sm",disabled:o===e.id,onClick:()=>j(e),children:o===e.id?t.jsx(h,{className:"h-4 w-4 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx($,{className:"h-4 w-4 mr-1.5"}),"Restore"]})})})]},`${e.kind}-${e.id}`))})]}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[t.jsx(u,{className:"h-8 w-8 mb-2 opacity-50"}),t.jsx("p",{children:"Nothing deleted recently"})]})})})]})}function ai(){const{studioId:i}=T(),m=C(),o=(m==null?void 0:m.studioId)||i,l=m?g.Fragment:D;return o?t.jsx(l,{children:t.jsx(z,{studioId:o})}):null}export{ai 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.