1import{av as x,u as f,r as l,j as e}from"./index-L9AYrVUw.js";import{u,aY as y,aZ as v,a4 as b,a_ as j,aE as w}from"./PlanAccessModal-P_W2GThH.js";import{h as k}from"./App-DyVHSnY3.js";import{n as T}from"./Play.es-DBh2Tn7f.js";import{f as I}from"./boardsMockData-DqHpMT8B.js";import"./productFunnel-DiJFcMU2.js";import"./locale-Cctu0V3Y.js";import"./FloatingTopMenu-CIhwk2RR.js";import"./SnewLogo-Cg53XTnQ.js";import"./index-p7aFGi8o.js";import"./Trash.es-D2Zs5Rpt.js";import"./dissolve-CQo8GAUH.js";const O=()=>{const{id:t}=x(),i=f(),[n,c]=l.useState(!1),r=l.useMemo(()=>t?I(t):void 0,[t]);if(l.useEffect(()=>{const o=s=>{s.key==="Escape"&&i("/boards")};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[i]),l.useEffect(()=>{t&&!r&&(u.error("Template não encontrado"),i("/boards"))},[t,r,i]),!r)return null;const h=async()=>{c(!0),setTimeout(()=>{u.success("Template adicionado aos seus boards"),i("/generate-image",{state:{fromTemplateId:r.id}})},600)},g=l.useMemo(()=>{if(r.assets.length===0)return{minX:0,minY:0,width:1200,height:720};let o=1/0,s=1/0,m=-1/0,p=-1/0;for(const a of r.assets)o=Math.min(o,a.x),s=Math.min(s,a.y),m=Math.max(m,a.x+a.width),p=Math.max(p,a.y+a.height);const d=80;return{minX:o-d,minY:s-d,width:m-o+d*2,height:p-s+d*2}},[r]);return e.jsxs("div",{style:{minHeight:"100vh",background:"hsl(var(--background))",display:"flex",flexDirection:"column"},children:[e.jsxs("header",{style:{height:60,background:"hsl(var(--card))",borderBottom:"1px solid hsl(var(--border))",padding:"0 24px",display:"flex",alignItems:"center",justifyContent:"space-between",position:"sticky",top:0,zIndex:30},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[e.jsxs(y,{delayDuration:120,children:[e.jsx(v,{asChild:!0,children:e.jsx("button",{onClick:()=>i("/boards"),"aria-label":"Voltar",style:{width:32,height:32,borderRadius:8,background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"hsl(var(--muted-foreground))",fontFamily:"inherit"},onMouseEnter:o=>o.currentTarget.style.background="hsl(var(--muted))",onMouseLeave:o=>o.currentTarget.style.background="transparent",children:e.jsx(b,{size:16})})}),e.jsx(j,{side:"bottom",sideOffset:8,children:"Voltar"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,color:"hsl(var(--foreground))"},children:r.title}),e.jsxs("div",{style:{fontSize:10,color:"hsl(var(--muted-foreground))",marginTop:1},children:["Modelo · ",r.subtitle]})]})]}),e.jsx("button",{onClick:h,disabled:n,style:{height:36,padding:"0 16px",background:"hsl(var(--foreground))",color:"hsl(var(--background))",border:"none",borderRadius:8,fontSize:12,fontWeight:500,cursor:n?"wait":"pointer",display:"flex",alignItems:"center",gap:8,fontFamily:"inherit",opacity:n?.6:1,transition:"opacity 0.12s"},children:n?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:12,className:"animate-spin"}),"Clonandoâ¦"]}):e.jsx(e.Fragment,{children:"Usar este modelo"})})]}),r.description&&e.jsx("div",{style:{maxWidth:720,margin:"0 auto",padding:"20px 24px 0",fontSize:12,color:"hsl(var(--muted-foreground))",textAlign:"center"},children:r.description}),e.jsx("div",{style:{flex:1,padding:"24px",display:"flex",justifyContent:"center",alignItems:"flex-start"},children:e.jsx(z,{assets:r.assets,bounds:g})})]})},z=({assets:t,bounds:i})=>e.jsx("div",{style:{position:"relative",width:"100%",maxWidth:1100,aspectRatio:`${i.width} / ${i.height}`,background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:12,overflow:"hidden",backgroundImage:"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)",backgroundSize:"20px 20px"},children:t.map(n=>{const c=(n.x-i.minX)/i.width*100,r=(n.y-i.minY)/i.height*100,h=n.width/i.width*100,g=n.height/i.height*100;return e.jsx("div",{style:{position:"absolute",left:`${c}%`,top:`${r}%`,width:`${h}%`,height:`${g}%`,borderRadius:8,overflow:"hidden",background:"hsl(var(--background))",border:"1px solid hsl(var(--border))",boxShadow:"0 2px 8px hsl(var(--foreground) / 0.04)"},children:e.jsx(C,{asset:n})},n.id)})}),C=({asset:t})=>t.type==="image"&&t.imageUrl?e.jsx("img",{src:t.imageUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):t.type==="video"?e.jsxs("div",{style:{width:"100%",height:"100%",position:"relative"},children:[t.imageUrl&&e.jsx("img",{src:t.imageUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("div",{style:{width:40,height:40,borderRadius:999,background:"rgba(255,255,255,0.92)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(T,{size:16,weight:"fill",color:"hsl(var(--foreground))"})})})]}):e.jsxs("div",{style:{width:"100%",height:"100%",padding:14,display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"hsl(var(--muted-foreground))",fontSize:9,textTransform:"uppercase",letterSpacing:"0.08em"},children:[e.jsx(k,{size:11})," Documento"]}),e.jsx("div",{style:{fontSize:12,fontWeight:500,color:"hsl(var(--foreground))"},children:t.documentTitle??"Documento"}),e.jsx("div",{style:{fontSize:11,color:"hsl(var(--muted-foreground))",lineHeight:1.4,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:4,WebkitBoxOrient:"vertical"},children:t.documentExcerpt})]});
1export{O 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.