1import{r as m,u as V,R as N,a as Q,j as r}from"./index-L9AYrVUw.js";import{d as Z,ah as F,P as J,C as _,R as q,u as U}from"./PlanAccessModal-P_W2GThH.js";import{s as K}from"./productFunnel-DiJFcMU2.js";import{b as X,s as ee}from"./durableRepository-CrJ1KOcD.js";import{p as te}from"./productBoardIntent-BZb8CQGl.js";import{N as re,B as ae}from"./BoardCard-Vj24tRtg.js";import{F as se,e as oe}from"./FloatingTopMenu-CIhwk2RR.js";import{l as ie,f as W,H as k,k as ne}from"./history-CQXQpNXw.js";import{b as M,r as z}from"./worksMode-DPF33FWh.js";import{s as G}from"./generationAdapter-BXonAKVC.js";import{i as H}from"./privateMedia-B7Po080i.js";import{c as de}from"./locale-Cctu0V3Y.js";import"./jobRuntime-D9imWnJq.js";import"./durableDocument-CwDQPJIK.js";import"./boardSaveRetry-DOnjTgch.js";import"./quickActions-Bt6kGa-B.js";import"./snewDefault-bcI9V4vY.js";import"./christmasCreativeDirections-Ceo-u5n5.js";import"./recipes-CtHnj9D9.js";import"./antiStock-CfefI4TX.js";import"./sanitized-commercial-metrics-Ctrrpq63.js";import"./canvasDocument-BD3jeUPg.js";import"./stagingProductStyleBinding-BNVQaSKK.js";import"./stagingComposerPrompt-ut90SPpr.js";import"./Plus.es-BeVefyFz.js";import"./thumbnail-card-ZiWJf1m1.js";import"./skeleton-CthpmC5T.js";import"./dropdown-menu-mjIVraPt.js";import"./index-Eo00qZvG.js";import"./index-BKpKuXmL.js";import"./useProgressiveImageSource-CrIWUb3O.js";import"./SnewLogo-Cg53XTnQ.js";import"./aspectRatios-DDqw6bsx.js";import"./visualDirection-6RyRmTlC.js";const le=24;async function ue(g){const i=[...new Set(g.flatMap(n=>n.thumbnail_refs).filter(H))],x=i.length?await G(i):new Map;return Promise.all(g.map(async n=>{const E=await z(n.thumbnail_refs,async a=>new Map(a.flatMap(b=>x.has(b)?[[b,x.get(b)]]:[])));return{id:n.id,title:n.title,thumbnails:E.urls,thumbnailUnavailable:E.unavailable,updatedAt:W(Date.parse(n.updated_at)),createdAt:Date.parse(n.created_at??n.updated_at),updatedAtTimestamp:Date.parse(n.updated_at),assetCount:n.asset_count,archivedAt:n.archived_at}}))}function ce(g,i,x,n=!1){const[E,a]=m.useState([]),[b,y]=m.useState(0),[S,p]=m.useState(null),[t,f]=m.useState("loading"),[L,j]=m.useState(!1),[D,R]=m.useState(!1),h=m.useRef(!1),w=m.useRef(null),d=m.useRef(0),v=m.useCallback(async u=>{var c;const B=++d.current;u?j(!0):h.current||f("loading");try{if(M){if(!x){B===d.current&&(a([]),y(0),p(null),f(n?"loading":"auth-required"));return}const s=ie(x).filter(l=>l.assetCount>0&&!!l.archivedAt==(g==="archived")).filter(l=>l.title.toLocaleLowerCase().includes(i.trim().toLocaleLowerCase())),A=[...new Set(s.flatMap(l=>l.thumbnailRefs??[]).filter(H))],C=A.length?await G(A):new Map,T=await Promise.all(s.map(async l=>{const $=await z(l.thumbnailRefs??[],async Y=>new Map(Y.flatMap(O=>C.has(O)?[[O,C.get(O)]]:[])));return{id:l.id,title:l.title,thumbnails:$.urls,thumbnailUnavailable:$.unavailable,updatedAt:W(l.updatedAt),createdAt:l.createdAt,updatedAtTimestamp:l.updatedAt,assetCount:l.assetCount,archivedAt:l.archivedAt??null}}));if(B!==d.current)return;a(T),y(T.length),p(null),h.current=!0,R(!1),f("ready");return}const o=await X({mode:g,limit:le,search:i,before:u?S:null}),e=await ue(o.boards);if(B!==d.current)return;a(s=>u?[...s,...e.filter(A=>!s.some(C=>C.id===A.id))]:e),y(o.total),w.current=((c=o.boards[0])==null?void 0:c.user_id)??w.current,p(o.next),h.current=!0,R(!1),f("ready")}catch(o){if(B!==d.current)return;typeof o=="object"&&o!==null&&"code"in o&&o.code==="AUTH_REQUIRED"?(h.current=!1,a([]),y(0),p(null),R(!1),f("auth-required")):!u&&h.current?(R(!0),f("ready")):(u||a([]),f("error"))}finally{B===d.current&&j(!1)}},[S,g,i,x,n]);m.useEffect(()=>{if(M){h.current=!1,a([]),y(0),p(null),v(!1);const c=()=>{v(!1)};return window.addEventListener(k,c),window.addEventListener("storage",c),()=>{d.current+=1,window.removeEventListener(k,c),window.removeEventListener("storage",c)}}p(null),v(!1);const u=()=>{p(null),v(!1)},{data:B}=K.auth.onAuthStateChange((c,o)=>{if(c==="SIGNED_OUT")d.current+=1,h.current=!1,a([]),y(0),p(null),f("auth-required");else if(c==="SIGNED_IN"||c==="USER_UPDATED"){const e=(o==null?void 0:o.user.id)??null;w.current&&e&&w.current!==e&&(d.current+=1,h.current=!1,a([]),y(0),p(null),f("loading")),w.current=e,u()}});return window.addEventListener(k,u),window.addEventListener("online",u),()=>{d.current+=1,B.subscription.unsubscribe(),window.removeEventListener(k,u),window.removeEventListener("online",u)}},[g,i,x,n]);const I=m.useCallback(()=>{!L&&S&&E.length<b&&v(!0)},[E.length,S,v,L,b]),P=m.useCallback(()=>{p(null),v(!1)},[v]);return{boards:E,total:b,status:t,refreshError:D,loadingMore:L,hasMore:!!S&&E.length<b,loadMore:I,retry:P}}const me=9,Ye=()=>{const g=V(),[i,x]=N.useState(""),[n,E]=N.useState(!1),[a,b]=N.useState("active"),[y,S]=N.useState(null),{lang:p}=Q(),t=p==="en",{user:f,loading:L}=Z(),j=f?te(f):null,[D,R]=N.useState("");N.useEffect(()=>{const e=window.setTimeout(()=>R(i.trim()),250);return()=>window.clearTimeout(e)},[i]);const{boards:h,total:w,status:d,loadingMore:v,hasMore:I,loadMore:P,retry:u}=ce(a,D,j,L),B=async(e,s)=>{const A=s==="delete"?t?"delete":"excluir":s==="archive"?t?"archive":"arquivar":t?"restore":"restaurar";if(!(s==="delete"&&!window.confirm(t?`Delete â${e.title}â? The Board will be permanently removed from Works.`:`Excluir â${e.title}â? O Board sairá definitivamente de Works.`))){S(e.id);try{if(M){if(!j||s==="delete")throw new Error("BROWSER_BOARD_ACTION_UNAVAILABLE");ne(j,e.id,s==="archive")}else await ee(e.id,s);window.dispatchEvent(new CustomEvent(k)),U.success(s==="delete"?t?"Board deleted":"Board excluÃdo":s==="archive"?t?"Board archived":"Board arquivado":t?"Board restored":"Board restaurado")}catch(C){const T=typeof C=="object"&&C!==null&&"code"in C&&C.code==="BOARD_CONFLICT";U.error(T?t?`You cannot ${A} while a generation is in progress.`:`Não é possÃvel ${A} enquanto uma geração está em andamento.`:t?`Could not ${A} the Board.`:`Não foi possÃvel ${A} o Board.`)}finally{S(null)}}},c=e=>g(`/board?${new URLSearchParams({boardId:e.id,boardTitle:e.title}).toString()}`,{state:{openBoard:!0,boardId:e.id,boardTitle:e.title,_ts:Date.now()}}),o=h;return r.jsxs("div",{style:{minHeight:"100vh",background:"hsl(var(--background))",padding:"0 0 80px",fontFamily:"var(--font-sans, Inter, sans-serif)"},children:[r.jsx(se,{}),F,r.jsxs("div",{style:{width:"100%",maxWidth:J.contentMaxWidth,margin:"0 auto",boxSizing:"border-box",padding:"112px 32px 0"},children:[F,r.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:24,marginBottom:24},children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[r.jsx("h1",{style:{fontSize:22,fontWeight:500,color:`hsl(${_.text.primary})`,letterSpacing:"-0.014em",margin:0},children:t?"Works":"Projetos"}),r.jsx("span",{style:{fontSize:13,color:`hsl(${_.text.tertiary})`},children:d==="ready"?w:"â"})]}),(w>=me||i.length>0)&&r.jsx("input",{value:i,onChange:e=>x(e.target.value),placeholder:t?"Search Boards":"Procurar Board",style:{width:240,height:32,padding:"0 12px",borderRadius:q.md,border:"none",background:`hsl(${_.bg.tertiary})`,fontSize:13,fontFamily:"inherit",outline:"none"}})]}),r.jsx("div",{className:"mb-8 flex items-end gap-6",role:"tablist","aria-label":t?"Filter Boards":"Filtrar Boards",children:["active","archived"].map(e=>r.jsx("button",{type:"button",role:"tab",onClick:()=>{b(e),x("")},"aria-selected":a===e,className:de("pb-1 text-[26px] font-medium tracking-[-0.02em] transition-colors",a===e?"text-foreground":"text-muted-foreground
1/50 hover:text-muted-foreground"),children:e==="active"?t?"Active":"Ativos":t?"Archived":"Arquivados"},e))}),d==="auth-required"?r.jsx("button",{onClick:()=>g("/signin?next=%2Fboards"),className:"snew-main-action rounded-full px-6 py-3",children:t?"Sign in to view your Boards":"Entrar para ver seus Boards"}):d==="error"?r.jsxs("div",{role:"alert",className:"flex items-center gap-3",children:[r.jsx("span",{children:t?"Could not load your Boards. Your data was not deleted.":"Não foi possÃvel carregar seus Boards. Seus dados não foram apagados."}),r.jsx("button",{type:"button",onClick:u,className:"snew-main-action rounded-full px-4 py-2 text-sm",children:t?"Try again":"Tentar novamente"})]}):d==="loading"?r.jsx("p",{role:"status",children:t?"Loading your Boardsâ¦":"Carregando seus Boardsâ¦"}):a==="archived"&&o.length===0&&!i.trim()?r.jsx("div",{className:"rounded-snew-lg bg-background px-6 py-16 text-center text-sm text-muted-foreground",children:t?"No archived Boards.":"Nenhum Board arquivado."}):o.length===0&&i.trim()?r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6,padding:"72px 24px",borderRadius:q.lg,background:"#FFFFFF"},children:[r.jsx("span",{style:{fontSize:14,fontWeight:500,color:`hsl(${_.text.primary})`},children:t?"No Board with that name":"Nenhum Board com esse nome"}),r.jsxs("span",{style:{fontSize:11,color:`hsl(${_.text.tertiary})`},children:[t?"Searching for":"Procurando por"," â",i.trim(),"â"]})]}):r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:16,rowGap:28},children:[!i.trim()&&a==="active"&&r.jsx(re,{onClick:()=>g("/board",{state:{openBoard:!0,blankBoard:!0,boardTitle:oe,initialBoardAssets:[],_ts:Date.now()}})}),o.map(e=>r.jsxs("div",{className:"group/board relative",children:[r.jsx(ae,{board:e,onOpen:c}),r.jsxs("div",{className:"absolute right-3 top-3 flex gap-1 opacity-100 transition-opacity sm:opacity-0 sm:group-hover/board:opacity-100 sm:focus-within:opacity-100",children:[r.jsx("button",{type:"button",disabled:y===e.id,onClick:s=>{s.stopPropagation(),B(e,a==="active"?"archive":"restore")},className:"rounded-full bg-background/95 px-3 py-1.5 text-xs font-medium text-foreground shadow-sm hover:bg-background disabled:opacity-50",children:a==="active"?t?"Archive":"Arquivar":t?"Restore":"Restaurar"}),!M&&r.jsx("button",{type:"button",disabled:y===e.id,onClick:s=>{s.stopPropagation(),B(e,"delete")},className:"rounded-full bg-background/95 px-3 py-1.5 text-xs font-medium text-destructive shadow-sm hover:bg-background disabled:opacity-50",children:t?"Delete":"Excluir"})]})]},e.id)),I&&r.jsx("div",{className:"col-span-full flex justify-center pt-4",children:r.jsx("button",{type:"button",disabled:v,onClick:P,className:"rounded-full bg-muted px-5 py-2.5 text-sm font-medium text-foreground hover:bg-muted/80 disabled:opacity-50",children:v?t?"Loadingâ¦":"Carregandoâ¦":t?`Load more (${h.length} of ${w})`:`Carregar mais (${h.length} de ${w})`})})]})]})]})};export{Ye 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.