PageSourceSearch

https://app.messengeros.com/horizon/assets/TemplateHtmlEditor-CeOKwM5R.js

js messengeros.com collected 2026-09-24 20:06:34 UTC 6,301 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-DCi8225z.js";import{r as s,ak as L,p as z,G as D,x as q,aN as F,X as H,aa as M}from"./vendor-misc-CSkfjhjg.js";import{u as $,a as I}from"./vendor-query-CxQsBGEV.js";import{P as Q,a as T,b as O}from"./react-resizable-panels.browser.esm-BjJk5CvX.js";import{a as N,B as h,D as G,p as A,q as J,r as U,I as V,s as W}from"./index-C_TNWsIx.js";import{R as X,o as Y,h as Z,E as _}from"./index-Crzz5pH7.js";import{c as ee,a as te}from"./vendor-react-DSN8fZTn.js";const se=_.theme({"&":{fontFamily:"'Cascadia Code','JetBrains Mono','Fira Code',Consolas,monospace"},".cm-content":{fontFamily:"'Cascadia Code','JetBrains Mono','Fira Code',Consolas,monospace"}});function ae({open:a,onClose:b,onSend:k,sending:i,result:f}){const[p,m]=s.useState(""),[r,x]=s.useState([]),u=()=>{const t=p.trim().toLowerCase();if(!t)return;const c=t.split(/[\s,;]+/).filter(Boolean),o=[...r];for(const y of c)!o.includes(y)&&o.length<7&&o.push(y);x(o),m("")},g=t=>x(c=>c.filter(o=>o!==t)),j=t=>{(t.key==="Enter"||t.key===","||t.key===" ")&&(t.preventDefault(),u())};return s.useEffect(()=>{a&&(m(""),x([]))},[a]),e.jsx(G,{open:a,onOpenChange:t=>!t&&b(),children:e.jsxs(A,{className:"sm:max-w-md","aria-describedby":void 0,children:[e.jsx(J,{children:e.jsx(U,{children:"Send test email"})}),e.jsxs("div",{className:"space-y-3 py-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter up to 7 email addresses. The current HTML will be sent as-is."}),r.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-secondary px-2.5 py-0.5 text-xs font-medium",children:[t,e.jsx("button",{onClick:()=>g(t),className:"text-muted-foreground hover:text-foreground",type:"button",children:e.jsx(H,{className:"h-3 w-3"})})]},t))}),r.length<7&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{placeholder:"[email protected]",value:p,onChange:t=>m(t.target.value),onKeyDown:j,onBlur:u,type:"email",autoComplete:"off"}),e.jsx(h,{type:"button",variant:"outline",size:"icon",onClick:u,children:e.jsx(M,{className:"h-4 w-4"})})]}),f&&e.jsx("div",{className:`rounded-md px-3 py-2 text-sm ${f.ok?"bg-green-50 text-green-800 border border-green-200 dark:bg-green-950/30 dark:text-green-300 dark:border-green-900/50":"bg-destructive/10 text-destructive border border-destructive/20"}`,children:f.message})]}),e.jsxs(W,{children:[e.jsx(h,{variant:"ghost",onClick:b,disabled:i,children:"Cancel"}),e.jsxs(h,{onClick:()=>k(r),disabled:i||r.length===0,children:[i?e.jsx(D,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(z,{className:"mr-2 h-4 w-4"}),i?"Sending...":"Send test"]})]})]})})}const me=()=>{const{id:a,channel:b="email"}=ee(),k=te(),i=$(),f=`/channels/${b}/templates/${a}/edit`,[p,m]=s.useState(""),r=s.useRef("");r.current=p;const[x,u]=s.useState(""),[g,j]=s.useState(!1),[t,c]=s.useState(!1),[o,y]=s.useState(!1),[P,E]=s.useState(!1),[B,v]=s.useState(null),w=s.useRef(null),{data:d}=I({queryKey:["template-body",a],queryFn:async()=>(await N.get(`/backend/templates/${a}/body`)).json()});s.useEffect(()=>{(d==null?void 0:d.body)!==void 0&&(m(d.body??""),u(d.body??""))},[d==null?void 0:d.body]);const K=s.useCallback(n=>{m(n),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(n),400)},[]),S=s.useCallback(async()=>{j(!0),c(!1);try{(await N.put(`/backend/templates/${a}/html`,{html:r.current,bodyEditor:"html"})).ok&&(c(!0),setTimeout(()=>c(!1),2500),i.invalidateQueries({queryKey:["template-body",a]}),i.invalidateQueries({queryKey:["template-detail",a]}),i.invalidateQueries({queryKey:["templates"]}))}finally{j(!1)}},[a]),R=async n=>{E(!0),v(null);try{const l=await N.post(`/backend/templates/${a}/send-test`,{html:r.current,sendTo:n}),C=await l.json();l.ok&&C.ok?v({ok:!0,message:`Test email sent to: ${C.sentTo}`}):v({ok:!1,message:C.error??"Failed to send test email."})}catch{v({ok:!1,message:"Network error. Please try again."})}finally{E(!1)}};return s.useEffect(()=>{const n=l=>{(l.ctrlKey||l.metaKey)&&l.key==="s"&&(l.preventDefault(),S())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[S]),e.jsxs("div",{style:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("header",{style:{height:52,flexShrink:0,display:"flex",alignItems:"center",gap:12,padding:"0 16px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--card))"},children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>
1k(f),children:e.jsx(L,{className:"h-4 w-4"})}),e.jsx("div",{style:{width:1,height:20,background:"hsl(var(--border))"}}),e.jsx("span",{style:{fontSize:14,fontWeight:600},children:"HTML Editor"}),e.jsx("div",{style:{flex:1}}),e.jsx("span",{style:{fontSize:12,color:"hsl(var(--muted-foreground))"},children:"Ctrl+S to save"}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>{v(null),y(!0)},children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),"Send test"]}),e.jsxs(h,{onClick:S,disabled:g,size:"sm",children:[g?e.jsx(D,{className:"mr-2 h-4 w-4 animate-spin"}):t?e.jsx(q,{className:"mr-2 h-4 w-4 text-green-500"}):e.jsx(F,{className:"mr-2 h-4 w-4"}),g?"Saving...":t?"Saved":"Save"]})]}),e.jsxs(Q,{direction:"horizontal",style:{flex:1,minHeight:0},children:[e.jsx(T,{defaultSize:50,minSize:20,children:e.jsx(X,{value:p,height:"100%",theme:Y,extensions:[Z(),se],onChange:K,style:{height:"100%",fontSize:13},basicSetup:{lineNumbers:!0,foldGutter:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,indentOnInput:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,searchKeymap:!1}})}),e.jsx(O,{style:{width:5,background:"hsl(var(--border))",cursor:"col-resize",flexShrink:0,transition:"background 0.15s"},onDragging:n=>{const l=document.getElementById("tpl-html-resize-handle");l&&(l.style.background=n?"hsl(var(--primary))":"hsl(var(--border))")},id:"tpl-html-resize-handle"}),e.jsx(T,{defaultSize:50,minSize:20,children:e.jsx("iframe",{srcDoc:x||"<body style='margin:0;padding:32px;font-family:sans-serif;color:#888'>Preview will appear here...</body>",title:"Preview",sandbox:"allow-same-origin allow-scripts",style:{width:"100%",height:"100%",border:"none",background:"#ffffff",display:"block"}})})]}),e.jsx(ae,{open:o,onClose:()=>y(!1),onSend:R,sending:P,result:B})]})};export{me 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.