1import{a as b,x as h,r as d,j as e,p as x}from"./index-BViqvD-p.js";import{a as v,e as y,s as f,c as j,T as E}from"./TemplateEditor-o-3gvdZe.js";import"./useMutation-C9Ur2pfw.js";import"./query-CKA4v1Ib.js";import"./hookGuards-D-YjZ-SB.js";import"./contract-z18VkiUx.js";import"./broadcasts.mapper-DWldNMD3.js";function S(t){return{sourceType:t.sourceType,subject:t.current?.subject??"",preheader:t.current?.preheader??"",bodySource:t.current?.bodySource??""}}function A(){const t=b(),{templateId:u}=h(),a=v(u),i=y(u),[o,p]=d.useState(null),n=a.data,l=n?.current?.versionId??null,r=n?o!==null&&o.base===l?o.content:S(n):null,m=d.useCallback(s=>p({base:l,content:s}),[l]),g=d.useCallback(()=>{r&&i.mutate(r)},[r,i]),c=(n?.current?.versionNumber??0)+1;return e.jsxs("div",{"data-component":"TemplateDetailPage",style:{maxWidth:960,margin:"40px auto",padding:"0 20px",fontFamily:"system-ui, sans-serif"},children:[e.jsx("button",{type:"button",onClick:()=>void t(x.difusionTemplates),style:{...f,marginBottom:16},children:"â Plantillas"}),a.isLoading&&e.jsx("div",{"data-element":"loading",style:{padding:40,textAlign:"center",color:"#9CA3AF"},children:"Cargando plantilla..."}),a.isError&&e.jsx("div",{"data-element":"error",style:{padding:16,background:"#FEE2E2",borderRadius:8,color:"#991B1B",fontSize:14},children:"Error al cargar la plantilla."}),n&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{style:{fontFamily:"var(--font-display)",fontSize:24,fontWeight:600,margin:"0 0 4px"},children:n.name}),e.jsxs("p",{style:{color:"#6B7280",fontSize:14,margin:"0 0 16px"},children:[j(n.sourceType),n.current?` · vigente: v${n.current.versionNumber}`:" · sin versión publicada",!n.isActive&&" · inactiva: no se pueden publicar versiones",n.description&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),n.description]})]}),e.jsxs("div",{"data-element":"versions",style:{border:"1px solid #E5E7EB",borderRadius:8,padding:16,marginBottom:24},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:8},children:"Versiones publicadas"}),n.versions.length===0&&e.jsx("div",{style:{fontSize:13,color:"#6B7280"},children:"Ninguna."}),e.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:13},children:n.versions.map(s=>e.jsxs("li",{children:["v",s.versionNumber," · ",new Date(s.createdAt).toLocaleString("es-CL")," · ",s.subject]},s.versionId))})]}),n.isActive&&r&&e.jsxs(e.Fragment,{children:[e.jsxs("h2",{style:{fontSize:16,fontWeight:600,margin:"0 0 4px"},children:["Publicar la versión ",c]}),e.jsxs("p",{style:{color:"#6B7280",fontSize:13,margin:"0 0 12px"},children:["Lo publicado no cambia: las campañas ya preparadas siguen con su versión. Publicar crea la v",c,"."]}),e.jsx(E,{content:r,onChange:m,sourceTypeLocked:!0,publishLabel:`Publicar versión ${c}`,publishPending:i.isPending,publishError:i.error,onPublish:g}),i.isSuccess&&e.jsxs("div",{"data-element":"published",style:{fontSize:13,color:"#065F46",marginTop:8},children:["Publicada la v",i.data.versionNumber,"."]})]})]})]})}export{A as default}; 2//# sourceMappingURL=TemplateDetailPage-lidAFefv.js.map
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.