1import{_ as K}from"./BGRz0kGJ.js";import{d as Y,aR as q,k as i,p as G,c as d,a,e as r,w as f,u as n,B as S,C as L,s as $,y as Q,F as V,r as z,aD as W,x as X,ay as D,aQ as Z,o,f as H,g as I,t as B}from"./BbWie7Ce.js";import{u as ee}from"./Dw_ADdf1.js";import{_}from"./BMPkIzVd.js";import{u as te}from"./DbrUsWDX.js";import{A as ae}from"./D_KNUqGf.js";import{E as se}from"./Cv4P8D6n.js";import{L as U}from"./Z1u4Xffz.js";import{c as A}from"./ho-u98wB.js";import{S as ne}from"./B7Bw5v5m.js";import{S as oe}from"./DJ7ecIBc.js";import"./BEHD0UYf.js";import"./DTBO2sEn.js";import"./wvbZMDsL.js";/** 2 * @license lucide-vue-next 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 le=A("MonitorIcon",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** 7 * @license lucide-vue-next v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const re=A("SaveIcon",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),ie={class:"h-[calc(100vh-4rem)] flex flex-col"},de={class:"flex items-center justify-between border-b px-4 py-3 flex-shrink-0 bg-background/95 backdrop-blur"},ue={class:"flex items-center gap-3 min-w-0"},ce={class:"min-w-0"},pe={class:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5"},ve={class:"flex items-center gap-2 flex-shrink-0"},me={class:"flex items-center gap-2 mr-2"},ge={class:"flex flex-1 overflow-hidden"},fe={class:"w-[420px] flex flex-col border-r bg-background flex-shrink-0"},xe={key:0,class:"text-center py-8"},he={class:"mt-4 space-y-2"},ye=["onClick"],_e={key:0,class:"flex items-center gap-2"},we={key:1,class:"whitespace-pre-wrap"},be={key:2,class:"whitespace-pre-wrap"},ke={class:"border-t p-3"},Ce={class:"flex gap-2"},Se={class:"flex-1 bg-muted/30 overflow-hidden flex flex-col"},Le={key:0,class:"flex-1 flex items-center justify-center"},$e={class:"text-center text-muted-foreground"},Be=["srcdoc"],je=Y({__name:"[id]",setup(Ee){const{initSEO:F}=te({title:"Edit Landing Page",noindex:!0});F();const N=q();Z();const{toast:w}=ee(),b=N.params.id,u=i(""),v=i(""),m=i(!1),c=i(""),s=i([]),g=i(""),x=i(!1),h=i(!1),y=i(),O=i(),R=["Create a SaaS product landing page with pricing","Build a modern agency portfolio page","Design a product launch countdown page","Create an event registration landing page"];G(async()=>{try{const e=(await $fetch("/api/admin/landing-pages",{credentials:"include"})).find(p=>p._id===b);if(e&&(u.value=e.title,v.value=e.slug,m.value=e.isActive,c.value=e.htmlContent||"",e.chatHistory))try{s.value=JSON.parse(e.chatHistory)}catch{}}catch{w({title:"Error",description:"Failed to load page.",variant:"destructive"})}});const k=async l=>{const e=l||g.value.trim();if(!(!e||x.value)){g.value="",s.value.push({role:"user",content:e}),s.value.push({role:"assistant",content:"__generating__"}),x.value=!0,await D(),E();try{const p=await $fetch("/api/admin/landing-pages/generate",{method:"POST",body:{messages:s.value.filter(t=>t.content!=="__generating__").map(t=>({role:t.role,content:t.content})),currentHtml:c.value||void 0},credentials:"include"});s.value=s.value.filter(t=>t.content!=="__generating__"),p.html&&(c.value=p.html,s.value.push({role:"assistant",content:`â Landing page ${c.value?"updated":"generated"}! Check the preview on the right. 12 13You can describe any changes you'd like to make.`}),!u.value&&s.value.length<=3&&(u.value=e.slice(0,60),v.value=M(u.value)))}catch(p){s.value=s.value.filter(t=>t.content!=="__generating__"),s.value.push({role:"assistant",content:`â Error: ${p.data?.statusMessage||p.message||"Failed to generate. Please try again."}`})}finally{x.value=!1,await D(),E()}}},j=l=>l.includes("<!DOCTYPE")||l.includes("<html")?"â Landing page generated! Check the preview.":l,E=()=>{y.value&&(y.value.scrollTop=y.value.scrollHeight)},M=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),P=async()=>{h.value=!0;try{await $fetch(`/api/admin/landing-pages/${b}`,{method:"PUT",body:{title:u.value||"Untitled",slug:v.value||M(u.value||"untitled"),htmlContent:c.value,isActive:m.value,chatHistory:JSON.stringify(s.value)},credentials:"include"}),w({title:"Saved",description:"Landing page saved successfully."})}catch{w({title:"Error",description:"Failed to save.",variant:"destructive"})}finally{h.value=!1}},C=()=>{b&&(u.value||v.value)&&P()},J=()=>{if(v.value)window.open(`/lp/${v.value}`,"_blank");else{const l=new Blob([c.value],{type:"text/html"});window.open(URL.createObjectURL(l),"_blank")}};return(l,e)=>{const p=K;return o(),d("div",ie,[a("div",de,[a("div",ue,[r(n(_),{variant:"ghost",size:"sm","as-child":""},{default:f(()=>[r(p,{to:"/dashboard/admin/landing-pages"},{default:f(()=>[r(n(ae),{class:"h-4 w-4"})]),_:1})]),_:1}),a("div",ce,[S(a("input",{"onUpdate:modelValue":e[0]||(e[0]=t=>u.value=t),class:"text-lg font-semibold bg-transparent border-none outline-none w-full placeholder:text-muted-foreground",placeholder:"Untitled Landing Page",onBlur:C},null,544),[[L,u.value]]),a("div",pe,[e[6]||(e[6]=a("span",{class:"font-mono bg-muted px-1.5 py-0.5 rounded"},"/lp/",-1)),S(a("input",{"onUpdate:modelValue":e[1]||(e[1]=t=>v.value=t),class:"bg-transparent border-none outline-none font-mono text-xs placeholder:text-muted-foreground",placeholder:"page-slug",onBlur:C},null,544),[[L,v.value]])])])]),a("div",ve,[a("div",me,[e[7]||(e[7]=a("label",{class:"text-sm text-muted-foreground"},"Active",-1)),a("button",{class:$(["relative inline-flex h-5 w-9 items-center rounded-full transition-colors",m.value?"bg-primary":"bg-muted"]),onClick:e[2]||(e[2]=t=>{m.value=!m.value,C()})},[a("span",{class:$(["inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform",m.value?"translate-x-[18px]":"translate-x-1"])},null,2)],2)]),r(n(_),{variant:"outline",size:"sm",disabled:!c.value,onClick:J},{default:f(()=>[r(n(se),{class:"h-4 w-4 mr-1"}),e[8]||(e[8]=H(" Preview ",-1))]),_:1,__:[8]},8,["disabled"]),r(n(_),{size:"sm",disabled:h.value,onClick:P},{default:f(()=>[h.value?(o(),I(n(U),{key:0,class:"h-4 w-4 mr-1 animate-spin"})):(o(),I(n(re),{key:1,class:"h-4 w-4 mr-1"})),e[9]||(e[9]=H(" Save ",-1))]),_:1,__:[9]},8,["disabled"])])]),a("div",ge,[a("div",fe,[a("div",{ref_key:"chatContainer",ref:y,class:"flex-1 overflow-y-auto p-4 space-y-4"},[s.value.length===0?(o(),d("div",xe,[r(n(ne),{class:"h-10 w-10 mx-auto mb-3 text-primary/60"}),e[10]||(e[10]=a("h3",{class:"font-semibold text-lg"},"AI Landing Page Builder",-1)),e[11]||(e[11]=a("p",{class:"text-sm text-muted-foreground mt-2 max-w-[280px] mx-auto"}," Describe the landing page you want to create and I'll generate it for you. ",-1)),a("div",he,[(o(),d(V,null,z(R,t=>a("button",{key:t,class:"block w-full text-left text-sm px-3 py-2 rounded-lg border hover:bg-muted/50 transition-colors text-muted-foreground hover:text-foreground",onClick:T=>k(t)},B(t),9,ye)),64))])])):Q("",!0),(o(!0),d(V,null,z(s.value,(t,T)=>(o(),d("div",{key:T,class:$(["max-w-[360px] rounded-2xl px-4 py-2.5 text-sm leading-relaxed",t.role==="user"?"ml-auto bg-primary text-primary-foreground":"bg-muted"])},[t.role==="assistant"&&t.content==="__generating__"?(o(),d("div",_e,[r(n(U),{class:"h-4 w-4 animate-spin"}),e[12]||(e[12]=a("span",{class:"text-muted-foreground"},"Generating landing page...",-1))])):t.role==="assistant"?(o(),d("div",we,B(j(t.content)),1)):(o(),d("div",be,B(t.content),1))],2))),128))],512),a("div",ke,[a("div",Ce,[S(a("textarea",{ref:"chatInput","onUpdate:modelValue":e[3]||(e[3]=t=>g.value=t),class:"flex-1 resize-none rounded-lg border bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:"Describe your landing page...",rows:"2",onKeydown:e[4]||(e[4]=W(X(t=>k(),["exact","prevent"]),["enter"]))}
13,null,544),[[L,g.value]]),r(n(_),{size:"sm",class:"self-end",disabled:!g.value.trim()||x.value,onClick:e[5]||(e[5]=t=>k())},{default:f(()=>[r(n(oe),{class:"h-4 w-4"})]),_:1},8,["disabled"])])])]),a("div",Se,[c.value?(o(),d("iframe",{key:1,ref_key:"previewFrame",ref:O,srcdoc:c.value,class:"flex-1 w-full border-0 bg-white",sandbox:"allow-scripts allow-same-origin"},null,8,Be)):(o(),d("div",Le,[a("div",$e,[r(n(le),{class:"h-16 w-16 mx-auto mb-4 opacity-30"}),e[13]||(e[13]=a("p",{class:"font-medium"},"Live Preview",-1)),e[14]||(e[14]=a("p",{class:"text-sm mt-1"},"Start a conversation to generate your landing page",-1))])]))])])])}}});export{je 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.