1import{D as G,b as I,E as Q,a as U,r as d,j as e,o as v,aW as A,C as V,l as X,c as f,ak as B,X as D,a6 as _,H as J,G as Y,u as Z,al as ee}from"./main-DX7XzkoU.js";import{T as se,a as ae,b as C,c as te}from"./tabs-BuRg9jtd.js";import{B as M}from"./badge-BOGaWzi1.js";import{D as ie,a as re,b as le,c as w,e as ne}from"./dropdown-menu-D6liHcXh.js";import{A as ce,a as oe,b as de,c as me,d as ue,e as he,f as pe,g as xe}from"./alert-dialog-W0hIlYre.js";import{I as N}from"./instagramPublishingService-BVQSHM0o.js";import{t as ge,p as be,e as fe}from"./pt-BR-g-tPW2Ip.js";import{E as je,M as ve}from"./MobileBottomNav-B6c1hPKj.js";import{T as we}from"./trash-2-pjGqSJFK.js";import{E as Ne}from"./external-link-Bhm5X9sQ.js";import{C as k}from"./clock-DZY59rpR.js";import{f as S}from"./format-kQpqiptj.js";import{I as ye}from"./InstagramConnectButton-phCQt2kF.js";import{A as Pe}from"./AppHeader-CzkMBh75.js";import{P as Ce}from"./PageShell-Bd7x8hXC.js";import{P as Se}from"./PageHeader-CM5sf6Dy.js";import{P as L}from"./plus-C6FQ2-b-.js";import{C as Ae}from"./circle-check-DRpR_UoF.js";import{L as ke}from"./list-Cz-Qxedi.js";import"./index-D6Z5KIMn.js";import"./chevron-right-D27HfhtL.js";import"./circle-BXmX70XD.js";import"./CreateContentModal-eREkTihJ.js";import"./referral-code-CAIXjQN4.js";import"./megaphone-B0K-HV7w.js";import"./lightbulb-UJa6zn96.js";import"./sheet-D4yLKOxB.js";import"./image-BBUOngQh.js";import"./smartphone-WGY3uvd5.js";import"./video-BvJDFQSG.js";import"./image-play-FzvV3P2U.js";import"./palette-OTKsHiwO.js";import"./wand-sparkles-CwRAYUwy.js";import"./clapperboard-BoJYuZop.js";import"./layers-UGj9VXD5.js";import"./routes-Dh-CjbFu.js";import"./user-check-BR60HPjZ.js";import"./link-2-CASnJw5r.js";import"./settings-N25lzdMz.js";import"./circle-help-CV3y08qY.js";import"./house-C4ToeB93.js";import"./chart-no-axes-column-CL-SWzid.js";import"./formatDistanceToNow-BwcGd3xH.js";import"./constructNow-CO-G4Rcw.js";import"./endOfMonth-DpURBOFe.js";import"./instagram-uOX4SJX4.js";import"./shield-B57RWQ5_.js";import"./AppInstallBanner-CAnCi_kO.js";import"./ThemeToggle-C5kzRcph.js";import"./monitor-MvsPdGOU.js";import"./history-BQ1iBcZd.js";import"./link-D6mXMmG7.js";import"./user-x-BOA8xi05.js";import"./globe-BBWCCznd.js";import"./download-DFu9GkQ8.js";import"./useInstagramProfiles-D_KQvT_K.js";import"./arrow-left-Cf41rOjY.js";import"./gem-DGeoeC5P.js";import"./menu-B6sRxHFL.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ee=G("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);function H(i){return+ge(i)<Date.now()}function Te({instagramProfileId:i,limit:u,showEmpty:r=!0,status:h,onPostClick:p}){const{t:a,i18n:E}=I(),{toast:n}=Q(),x=U(),g=E.language==="pt"?be:fe,[c,b]=d.useState([]),[y,j]=d.useState(!0),[l,P]=d.useState(null),[R,m]=d.useState(null),T=async()=>{j(!0);try{let s=await N.listScheduledPosts({instagramProfileId:i,limit:u});h&&h.length>0&&(s=s.filter(t=>h.includes(t.status))),b(s)}catch(s){console.error("Error fetching scheduled posts:",s)}finally{j(!1)}};d.useEffect(()=>{T()},[i,u,h]);const z=async s=>{m(s);try{await N.cancelScheduledPost(s)&&(b(c.map(o=>o.id===s?{...o,status:"cancelled"}:o)),n({title:a("publishing.cancelled","Post cancelado")}))}catch{n({title:a("common.error","Erro"),description:a("publishing.cancel_error","Erro ao cancelar post"),variant:"destructive"})}finally{m(null)}},F=async()=>{if(l){m(l);try{await N.deleteScheduledPost(l)&&(b(c.filter(t=>t.id!==l)),n({title:a("publishing.deleted","Post removido")}))}catch{n({title:a("common.error","Erro"),description:a("publishing.delete_error","Erro ao remover post"),variant:"destructive"})}finally{P(null),m(null)}}},q=async s=>{m(s);try{await N.retryFailedPost(s)&&(await T(),n({title:a("publishing.retry_scheduled","Nova tentativa agendada")}))}catch{n({title:a("common.error","Erro"),description:a("publishing.retry_error","Erro ao reagendar"),variant:"destructive"})}finally{m(null)}},$=s=>{const o={pending:{variant:"outline",icon:k,label:a("publishing.status.pending","Pendente")},scheduled:{variant:"outline",icon:A,label:a("publishing.status.scheduled","Agendado")},processing:{variant:"secondary",icon:v,label:a("publishing.status.processing","Processando")},publishing:{variant:"secondary",icon:v,label:a("publishing.status.publishing","Publicando")},published:{variant:"default",icon:J,label:a("publishing.status.published","Publicado")},failed:{variant:"destructive",icon:_,label:a("publishing.status.failed","Falhou")},cancelled:{variant:"outline",icon:D,label:a("publishing.status.cancelled","Cancelado")}}[s],O=o.icon,W=s==="processing"||s==="publishing";return e.jsxs(M,{variant:o.variant,className:"gap-1",children:[e.jsx(O,{className:`w-3 h-3 ${W?"animate-spin":""}`}),o.label]})},K={post:a("postSuggestions.post","Post"),story:a("postSuggestions.story","Story"),story_sequence:a("postSuggestions.storySequence","Sequência de Stories"),carousel:a("postSuggestions.carousel","Carrossel"),reel:a("publishing.reel","Reel")};return y?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(v,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):c.length===0&&r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(A,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-medium text-lg mb-1",children:a("publishing.no_scheduled","Nenhum post agendado")}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-sm",children:a("publishing.no_scheduled_desc","Quando você agendar um post, ele aparecerá aqui.")})]}):c.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2 sm:space-y-3",children:c.map(s=>e.jsx(V,{className:`transition-colors ${p?"cursor-pointer hover:bg-muted/50 active:bg-muted/70":""}`,onClick:()=>p==null?void 0:p(s),children:e.jsx(X,{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex gap-3 sm:gap-4",children:[e.jsxs("div",{className:"relative w-14 h-14 sm:w-16 sm:h-16 rounded-lg overflow-hidden bg-muted shrink-0",children:[s.contentType==="reel"||s.videoUrl?e.jsx("video",{src:s.videoUrl||s.imageUrl,className:"w-full h-full object-cover",muted:!0,playsInl
6ine:!0}):e.jsx("img",{src:s.imageUrl,alt:"Preview",className:"w-full h-full object-cover"}),s.carouselSlides&&s.carouselSlides.length>0&&e.jsxs("div",{className:"absolute bottom-0.5 right-0.5 bg-black/60 text-white text-[10px] px-1 py-0.5 rounded",children:["+",s.carouselSlides.length]}),(s.contentType==="reel"||s.videoUrl)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20",children:e.jsx("div",{className:"w-5 h-5 sm:w-6 sm:h-6 rounded-full bg-white/80 flex items-center justify-center",children:e.jsx("div",{className:"w-0 h-0 border-t-[4px] sm:border-t-[5px] border-t-transparent border-l-[6px] sm:border-l-[8px] border-l-black border-b-[4px] sm:border-b-[5px] border-b-transparent ml-0.5"})})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-1.5 sm:gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 flex-wrap",children:[$(s.status),e.jsx(M,{variant:"outline",className:"text-[10px] sm:text-xs px-1.5 sm:px-2",children:K[s.contentType]})]}),["pending","scheduled","failed","cancelled"].includes(s.status)&&e.jsxs(ie,{children:[e.jsx(re,{asChild:!0,onClick:t=>t.stopPropagation(),children:e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:R===s.id?e.jsx(v,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(je,{className:"w-4 h-4"})})}),e.jsxs(le,{align:"end",children:[["pending","scheduled","failed"].includes(s.status)&&e.jsxs(w,{onClick:t=>{t.stopPropagation(),x(`/dashboard/scheduled/edit/${s.id}`)},children:[e.jsx(Ee,{className:"w-4 h-4 mr-2"}),a("common.edit","Editar")]}),s.status==="failed"&&e.jsxs(w,{onClick:t=>{t.stopPropagation(),q(s.id)},children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),a("publishing.retry","Tentar novamente")]}),["pending","scheduled"].includes(s.status)&&e.jsxs(w,{onClick:t=>{t.stopPropagation(),z(s.id)},children:[e.jsx(D,{className:"w-4 h-4 mr-2"}),a("common.cancel","Cancelar")]}),e.jsx(ne,{}),e.jsxs(w,{onClick:t=>{t.stopPropagation(),P(s.id)},className:"text-destructive",children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),a("common.delete","Excluir")]})]})]}),s.status==="published"&&s.instagramMediaUrl&&e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",onClick:t=>{t.stopPropagation(),window.open(s.instagramMediaUrl,"_blank")},children:e.jsx(Ne,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]}),s.caption&&e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1 line-clamp-1",children:s.caption}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mt-1.5 sm:mt-2 text-[10px] sm:text-xs text-muted-foreground",children:[e.jsx(k,{className:"w-3 h-3 shrink-0"}),s.status==="published"&&s.publishedAt?e.jsxs("span",{className:"truncate",children:[a("publishing.published_at","Publicado")," ",S(s.publishedAt,"dd/MM HH:mm",{locale:g})]}):s.scheduledAt?e.jsx("span",{className:`truncate ${H(s.scheduledAt)&&s.status!=="published"?"text-amber-600":""}`,children:H(s.scheduledAt)?S(s.scheduledAt,"dd/MM HH:mm",{locale:g}):S(s.scheduledAt,"dd/MM HH:mm",{locale:g})}):e.jsx("span",{className:"truncate",children:a("publishing.immediate","Publicação imediata")})]}),s.status==="failed"&&s.errorMessage&&e.jsxs("p",{className:"text-[10px] sm:text-xs text-destructive mt-1 flex items-start gap-1 line-clamp-2",children:[e.jsx(_,{className:"w-3 h-3 shrink-0 mt-0.5"}),e.jsx("span",{className:"line-clamp-2",children:s.errorMessage})]})]})]})})},s.id))}),e.jsx(ce,{open:!!l,onOpenChange:()=>P(null),children:e.jsxs(oe,{children:[e.jsxs(de,{children:[e.jsx(me,{children:a("publishing.delete_confirm_title","Excluir post agendado?")}),e.jsx(ue,{children:a("publishing.delete_confirm_desc","Esta ação não pode ser desfeita.")})]}),e.jsxs(he,{children:[e.jsx(pe,{children:a("common.cancel","Cancelar")}
6),e.jsx(xe,{onClick:F,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:a("common.delete","Excluir")})]})]})})]})}function Is(){const{t:i}=I(),u=U(),{selectedProfile:r}=Y(),{user:h,signOut:p}=Z(),{subscription:a,imagesLeft:E,openCustomerPortal:n}=ee(),[x,g]=d.useState("pending"),[c,b]=d.useState(0),y=()=>{switch(x){case"pending":return["pending","scheduled","processing","publishing"];case"published":return["published"];case"all":default:return}},j=()=>{b(l=>l+1)};return e.jsxs(Ce,{header:e.jsx(Pe,{}),maxWidth:"5xl",bottomNav:e.jsx(ve,{}),children:[e.jsx(Se,{title:i("publishing.scheduled_posts"),subtitle:i("publishing.scheduled_posts_desc"),icon:A,backTo:"/dashboard",actions:e.jsxs(e.Fragment,{children:[e.jsxs(f,{onClick:()=>u("/dashboard/scheduled/create"),className:"hidden sm:flex gap-2",children:[e.jsx(L,{className:"w-4 h-4"}),i("publishing.manual.new_post")]}),e.jsx(f,{variant:"outline",size:"icon",onClick:j,"aria-label":i("common.refresh"),className:"h-9 w-9 shrink-0",children:e.jsx(B,{className:"w-4 h-4"})})]})}),r&&e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsx(ye,{instagramProfileId:r.id,expectedUsername:r.username,variant:"default",profilePicUrl:r.profile_pic_url})}),e.jsxs(se,{value:x,onValueChange:l=>g(l),children:[e.jsxs(ae,{className:"mb-4 w-full grid grid-cols-3 sm:w-auto sm:inline-flex",children:[e.jsxs(C,{value:"pending",className:"flex items-center gap-1.5 text-xs sm:text-sm px-2 sm:px-3",children:[e.jsx(k,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),e.jsx("span",{children:i("publishing.tab.pending","Pendentes")})]}),e.jsxs(C,{value:"published",className:"flex items-center gap-1.5 text-xs sm:text-sm px-2 sm:px-3",children:[e.jsx(Ae,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),e.jsx("span",{children:i("publishing.tab.published","Publicados")})]}),e.jsxs(C,{value:"all",className:"flex items-center gap-1.5 text-xs sm:text-sm px-2 sm:px-3",children:[e.jsx(ke,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),e.jsx("span",{children:i("publishing.tab.all","Todos")})]})]}),e.jsx(te,{value:x,className:"mt-0",children:e.jsx(Te,{instagramProfileId:r==null?void 0:r.id,status:y(),showEmpty:!0},c)})]}),e.jsx("div",{className:"fixed bottom-[calc(88px+var(--sai-bottom))] right-4 z-50 md:hidden",children:e.jsx(f,{onClick:()=>u("/dashboard/scheduled/create"),size:"lg",className:"h-14 w-14 rounded-full shadow-lg shadow-primary/25 hover:shadow-xl hover:shadow-primary/30 transition-all",children:e.jsx(L,{className:"w-6 h-6"})})})]})}export{Is 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.