1import{r as i,j as e}from"./vendor-query-DFCnH4v6.js";import{s as c}from"./supabase-BtEVD_xl.js";import{P as ms}from"./PaginationControls-B-0yIR3r.js";import{u as hs,a as ze,s as us,K as xs,P as gs,D as Ge,c as Oe,S as Fe,v as $e,b as ps,d as qe,C as He}from"./sortable.esm-DJSjvrVq.js";import{B as t}from"./button-D8HXxxX4.js";import{I as B}from"./input-DZ5cefnm.js";import{B as ie}from"./badge-DTmO64u3.js";import{D as js,a as bs,b as fs,c as ys,e as g,d as vs}from"./dropdown-menu-3XZ2iUB6.js";import{D as ee,a as se,b as ae,c as re,d as Ue,e as he}from"./dialog-B6A2FBtW.js";import{A as Ns,a as ws,b as ks,c as Cs,d as Ss,e as _s,f as Ds,g as Ts}from"./alert-dialog-BFHHQKnF.js";import{L as y}from"./label-DhIMFsH-.js";import{T as ue}from"./textarea-yNzJNbLd.js";import{c as As,u as n,L as te}from"./index-Clp4hSBg.js";import{S as Ls}from"./ScheduleSettings-BVECIAho.js";import{u as Es}from"./vendor-react-DkfcCgIP.js";import{S as Ps}from"./search-C1eRkBXS.js";import{B as ge}from"./book-open-Ct94nGGN.js";import{V as pe}from"./video-D8M_EqaG.js";import{S as Be}from"./sparkles-LibEXDV8.js";import{C as q}from"./copy-D5C450uT.js";import{G as Re}from"./grip-vertical-CcouOxSP.js";import{S as xe}from"./star-Dn2VXFvp.js";import{E as Is}from"./ellipsis-CuJ-MRTm.js";import{P as Ve}from"./pencil-Bx-t40Ep.js";import{C as We}from"./calendar-DXvBgBro.js";import{E as Ze}from"./eye-off-DPjh_8OE.js";import{E as Ke}from"./eye-Cr4Blvuo.js";import{G as Je}from"./globe-BLY_izyU.js";import{T as Ye}from"./trash-2-C6obOC7u.js";import{E as Ms}from"./external-link-Cdm2OqVo.js";import"./vendor-supabase-p6GN6XL_.js";import"./chevron-left-BG0VZsoP.js";import"./chevron-right-ZvR13V4J.js";import"./Combination-DsaiUZ0r.js";import"./index-DZ97Xn_Z.js";import"./clock-CU4WIL-_.js";import"./plus-D8TGWBtd.js";/** 2 * @license lucide-react 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 H=As("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]),zs=({template:a,index:P,isAdmin:m,agentSlug:I,handleSetMain:D,openEditDialog:S,navigate:p,openScheduleDialog:T,handleClone:M,handleToggleActive:j,handleToggleVisibility:A,setSelectedTemplate:b,setDeleteOpen:z,copyLink:h,getAgentLink:R})=>{const{attributes:v,listeners:G,setNodeRef:N,transform:O,transition:F,isDragging:o}=qe({id:a.id}),u={transform:He.Transform.toString(O),transition:F,zIndex:o?10:1,position:o?"relative":"static"};return e.jsxs("tr",{ref:N,style:u,className:`hover:bg-gray-50 transition-colors ${o?"bg-purple-50 shadow-lg":""}`,children:[m&&e.jsx("td",{className:"py-4 px-2 w-10",children:e.jsx("button",{...v,...G,className:"text-gray-400 hover:text-gray-600 cursor-grab active:cursor-grabbing p-1 rounded",children:e.jsx(Re,{className:"h-4 w-4"})})}),e.jsxs("td",{className:"py-4 px-2 text-gray-400 font-mono text-sm",children:[P+1,"."]}),e.jsxs("td",{className:"py-4 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-medium text-gray-900",children:a.name}),a.is_main_template&&e.jsxs(ie,{variant:"default",className:"bg-amber-100 text-amber-700 hover:bg-amber-100 border-amber-200",children:[e.jsx(xe,{className:"h-3 w-3 mr-1",fill:"currentColor"})," Main"]})]}),a.description&&e.jsx("div",{className:"text-xs text-gray-400 truncate max-w-xs mt-0.5",children:a.description})]}),e.jsx("td",{className:"py-4 px-2",children:e.jsxs("code",{className:"text-xs text-purple-600 bg-purple-50 px-2 py-1 rounded",children:["/",a.slug]})}),m&&e.jsxs("td",{className:"py-4 px-2",children:[e.jsx(ie,{variant:a.is_active?"default":"secondary",className:a.is_active?"bg-green-100 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500",children:a.is_active?"Active":"Suspended"}),!a.is_visible_to_agent&&e.jsx(ie,{variant:"outline",className:"ml-2 border-amber-200 text-amber-700 bg-amber-50",children:"Draft"})]}),e.jsx("td",{className:"py-4 px-2",children:m?e.jsxs(js,{children:[e.jsx(bs,{asChild:!0,children:e.jsx(t,{variant:"ghost",size:"sm",children:e.jsx(Is,{className:"h-4 w-4"})})}),e.jsxs(fs,{align:"end",children:[e.jsx(ys,{children:"Actions"}),e.jsxs(g,{onClick:()=>D(a),children:[e.jsx(xe,{className:"mr-2 h-4 w-4"})," Set as Main"]}),e.jsxs(g,{onClick:()=>S(a),children:[e.jsx(Ve,{className:"mr-2 h-4 w-4"})," Edit Info"]}),(a.slug.includes("flipbook")||a.content?.type==="flipbook")&&e.jsxs(g,{onClick:()=>p(`/dashboard/templates/${a.id}/flipbook`),children:[e.jsx(ge,{className:"mr-2 h-4 w-4"})," Edit Flipbook Content"]}),(a.slug.includes("webinar")||a.content?.type==="webinar")&&e.jsxs(g,{onClick:()=>p(`/dashboard/templates/${a.id}/webinar-settings`),children:[e.jsx(pe,{className:"mr-2 h-4 w-4"})," Edit Webinar Video"]}),(a.slug.includes("html")||a.content?.type==="html")&&!["belanja","7000"].includes(a.slug)&&e.jsxs(g,{onClick:()=>p(`/dashboard/templates/${a.id}/edit`),children:[e.jsx(H,{className:"mr-2 h-4 w-4"})," Edit HTML Content"]}),e.jsxs(g,{onClick:()=>T(a),children:[e.jsx(We,{className:"mr-2 h-4 w-4"})," Schedule (Template)"]}),e.jsxs(g,{onClick:()=>M(a),children:[e.jsx(q,{className:"mr-2 h-4 w-4"})," Clone"]}),e.jsxs(g,{onClick:()=>j(a),children:[a.is_active?e.jsx(Ze,{className:"mr-2 h-4 w-4"}):e.jsx(Ke,{className:"mr-2 h-4 w-4"}),a.is_active?"Suspend":"Activate"]}),e.jsxs(g,{onClick:()=>A(a),children:[a.is_visible_to_agent?e.jsx(H,{className:"mr-2 h-4 w-4"}):e.jsx(Je,{className:"mr-2 h-4 w-4"}),a.is_visible_to_agent?"Set to Draft":"Publish"]}),e.jsx(vs,{}),e.jsxs(g,{onClick:()=>{b(a),z(!0)},className:"text-red-600",children:[e.jsx(Ye,{className:"mr-2 h-4 w-4"})," Delete"]})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-1 rounded truncate max-w-[200px]",children:["/",a.slug,"/",I||"your-slug"]}),e.jsx(t,{variant:"ghost",size:"sm",onClick:()=>h(a.slug),className:"text-purple-600 hover:text-purple-700",children:e.jsx(q,{className:"h-4 w-4"})}),e.jsx("a",{href:R(a.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(t,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-gray-700",children:e.jsx(Ms,{className:"h-4 w-4"})})})]})})]})},Gs=({template:a,index:P,isAdmin:m,agentSlug:I,handleSetMain:D,openEditDialog:S,navigate:p,openScheduleDialog:T,handleClone:M,handleToggleActive:j,handleToggleVisibility:A,setSelectedTemplate:b,setDeleteOpen:z,copyLink:h,getAgentLink:R})=>{const{attributes:v,listeners:G,setNodeRef:N,transform:O,transition:F,isDragging:o}=qe({id:a.id}),u={transform:He.Transform.toString(O),transition:F,zIndex:o?10:1,position:o?"relative":"static"};return e.jsxs("div",{ref:N,style:u,className:`border-b border-gray-100 pb-6 ${o?"bg-purple-50 shadow-lg p-3 rounded-lg border-b-0":""}`,children:[m&&e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("button",{...v,...G,className:"text-gray-400 hover:text-gray-600 p-2 cursor-grab active:cursor-grabbing w-full flex justify-center bg-gray-50 rounded-md border border-gray-100",children:e.jsx(Re,{className:"h-4 w-4"})})}),e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"text-xs font-mono text-gray-400 pt-1",children:[P+1,"."]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900",children:a.name}),e.jsxs("code",{className:"text-xs text-purple-600 mt-1 block",children:["/",a.slug]})]})]}),m&&e.jsx(ie,{variant:a.is_active?"default":"secondary",className:a.is_active?"bg-green-100 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500",children:a.is_active?"Active":"Off"})]}),!m&&e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs("code",{className:"text-xs text-gray-500 bg-gray-100 px-2 py-2 rounded flex-1 truncate",children:["/",a.slug,"/",I||"..."]}),e.jsxs(t,{size:"sm",onClick:()=>h(a.slug),className:"bg-purple-600 hover:bg-purple-700 h-9",children:[e.jsx(q,{className:"h-4 w-4 mr-1"})," Copy"]})]}),m&&e.jsxs("div",{className:"mt-3 flex gap-2 flex-wrap",children:[e.jsx(t,{size:"sm",variant:a.is_main_template?"default":"outline",onClick:()=>D(a),title:"Set as Main",className:a.is_main_template?"bg-amber-100 text-amber-700 hover:bg-amber-200 border-amber-200":"",children:e.jsx(xe,{className:"h-4 w-4",fill:a.is_main_template?"currentColor":"none"})}),e.jsx(t,{size:"sm",variant:"outline",onClick:()=>S(a),title:"Edit Info",children:e.jsx(Ve,{className:"h-4 w-4"})}),(a.slug.includes("flipbook")||a.content?.type==="flipbook")&&e.jsx(t,{size:"sm",variant:"outline",onClick:()=>p(`/dashboard/templates/${a.id}/flipbook`),title:"Edit Flipbook Content",children:e.jsx(ge,{className:"h-4 w-4 text-purple-600"})}),(a.slug.includes("webinar")||a.content?.type==="webinar")&&e.jsx(t,{size:"sm",variant:"outline",onClick:()=>p(`/dashboard/templates/${a.id}/webinar-settings`),title:"Edit Webinar Video",children:e.jsx(pe,{className:"h-4 w-4 text-blue-600"})}),(a.slug.includes("html")||a.content?.type==="html")&&!["belanja","7000"].includes(a.slug)&&e.jsx(t,{size:"sm",variant:"outline",onClick:()=>p(`/dashboard/templates/${a.id}/edit`),title:"Edit HTML Content",children:e.jsx(H,{className:"h-4 w-4 text-emerald-600"})}),e.jsx(t,{size:"sm",variant:"outline",onClick:()=>T(a),title:"Schedule",children:e.jsx(We,{className:"h-4 w-4"})}),e.jsx(t,{size:"sm",variant:"outline",onClick:()=>M(a),title:"Clone",children:e.jsx(q,{className:"h-4 w-4"})}),e.jsx(t,{size:"sm",variant:"outline",onClick:()=>j(a),title:a.is_active?"Suspend":"Activate",children:a.is_active?e.jsx(Ze,{className:"h-4 w-4"}):e.jsx(Ke,{className:"h-4 w-4"})}),e.jsx(t,{size:"sm",variant:"outline",onClick:()=>A(a),title:a.is_visible_to_agent?"Set to Draft":"Publish",className:a.is_visible_to_agent?"":"bg-amber-50 border-amber-200 text-amber-600",children:a.is_visible_to_agent?e.jsx(H,{className:"h-4 w-4"}):e.jsx(Je,{className:"h-4 w-4"})}),e.jsx(t,{size:"sm",variant:"destructive",onClick:()=>{b(a),z(!0)},title:"Delete",children:e.jsx(Ye,{className:"h-4 w-4"})})]})]})},va=()=>{const a=Es(),[P,m]=i.useState([]),[I,D]=i.useState(!0),[S,p]=i.useState(""),[T,M]=i.useState(null),[j,A]=i.useState(1),b=15,[z,h]=i.useState(!1),[R,v]=i.useState(!1),[G,N]=i.useState(!1),[O,F]=i.useState(!1),[o,u]=i.useState(null),[L,V]=i.useState(""),[$,_]=i.useState(""),[W,Z]=i.useState(""),[K,J]=i.useState(!1),[Qe,je]=i.useState(!1),[Xe,be]=i.useState(!1),[es,fe]=i.useState(!1),[ne,ss]=i.useState("gemini"),[le,as]=i.useState(""),[oe,ye]=i.useState(""),[ce,ve]=i.useState(!1),[rs,Y]=i.useState(!1),[Ne,we]=i.useState(!1),[E,ke]=i.useState({schedule:null,timeZone:"Asia/Kuala_Lumpur",fallbackUrl:""}),Ce=s=>{u(s),ke({schedule:s.recurring_schedule||null,timeZone:s.time_zone||"Asia/Kuala_Lumpur",fallbackUrl:s.fallback_url||""}),Y(!0)},ts=async()=>
6{if(o){we(!0);try{const s={recurring_schedule:E.schedule,time_zone:E.timeZone,fallback_url:E.fallbackUrl},{error:r}=await c.from("templates").update(s).eq("id",o.id);if(r)throw r;n.success("Tetapan jadual berjaya disimpan!"),Y(!1),m(l=>l.map(d=>d.id===o.id?{...d,...s}:d))}catch(s){console.error(s),n.error("Gagal menyimpan jadual")}finally{we(!1)}}},Se=hs(ze(gs,{activationConstraint:{distance:5}}),ze(xs,{coordinateGetter:us})),_e=async s=>{const{active:r,over:l}=s;r.id!==l?.id&&m(d=>{const f=d.findIndex(x=>x.id===r.id),C=d.findIndex(x=>x.id===l?.id),Me=ps(d,f,C),cs=Me.map((x,ds)=>({id:x.id,sort_order:ds}));return Promise.all(cs.map(x=>c.from("templates").update({sort_order:x.sort_order}).eq("id",x.id))).then(()=>{n.success("Susunan berjaya dikemaskini")}).catch(x=>{console.error(x),n.error("Gagal menyimpan susunan")}),Me})};i.useEffect(()=>{w()},[]);const w=async()=>{D(!0);try{const{data:{user:s}}=await c.auth.getUser();let r=!1;if(s){const{data:C}=await c.from("profiles").select("role, slug").eq("id",s.id).single();M(C),r=C?.role==="admin"}let l=c.from("templates").select("*").order("sort_order",{ascending:!0}).order("created_at",{ascending:!1});r||(l=l.eq("is_visible_to_agent",!0));const{data:d,error:f}=await l;if(f)throw f;m(d||[])}catch(s){console.error(s),n.error("Gagal memuatkan template")}finally{D(!1)}},k=T?.role==="admin",de=T?.slug,me=s=>{const r=s||"promo";return`${window.location.origin}/${r}/${de||""}`},De=s=>{const r=me(s);navigator.clipboard.writeText(r),n.success("Link disalin!")},Te=s=>s.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim(),is=async()=>{if(!L.trim()||!$.trim()){n.error("Nama dan Slug diperlukan");return}J(!0);try{const{data:{user:s}}=await c.auth.getUser(),r=Qe,l=Xe,d=es;let f={};r?f={type:"flipbook",slides:[]}:l?f={type:"webinar",videoUrl:""}:d&&(f={type:"html",showFloatingBar:!0});const{error:C}=await c.from("templates").insert({name:L.trim(),slug:$.trim(),description:W.trim()||null,content:f,is_active:!0,created_by:s?.id});if(C){if(C.message.includes("duplicate"))n.error("Slug sudah digunakan.");else throw C;return}n.success("Template berjaya dicipta!"),h(!1),U(),w()}catch(s){console.error(s),n.error(s.message||"Gagal mencipta template")}finally{J(!1)}},ns=async()=>{if(!(!o||!L.trim())){J(!0);try{const{error:s}=await c.from("templates").update({name:L.trim(),description:W.trim()||null,updated_at:new Date().toISOString()}).eq("id",o.id);if(s)throw s;n.success("Template berjaya dikemaskini!"),v(!1),U(),w()}catch(s){console.error(s),n.error("Gagal mengemaskini template")}finally{J(!1)}}},Ae=async s=>{try{const{data:{user:r}}=await c.auth.getUser(),l=`${s.slug}-copy-${Date.now().toString(36)}`,{error:d}=await c.from("templates").insert({name:`${s.name} (Copy)`,slug:l,description:s.description,content:s.content,is_active:!1,created_by:r?.id});if(d)throw d;n.success("Template berjaya diklonkan!"),w()}catch(r){console.error(r),n.error("Gagal mengklonkan template")}},Le=async s=>{try{const{error:r}=await c.from("templates").update({is_active:!s.is_active}).eq("id",s.id);if(r)throw r;n.success(s.is_active?"Template digantung":"Template diaktifkan"),w()}catch(r){console.error(r),n.error("Gagal mengemaskini status")}},Ee=async s=>{try{const r=!s.is_visible_to_agent,{error:l}=await c.from("templates").update({is_visible_to_agent:r}).eq("id",s.id);if(l)throw l;n.success(r?"Template Published (Visible to Agents)":"Template set to Draft (Hidden from Agents)"),w()}catch(r){console.error(r),n.error("Gagal mengemaskini status visibility")}},ls=async()=>{if(o)try{const{error:s}=await c.from("templates").delete().eq("id",o.id);if(s)throw s;n.success("Template berjaya dipadam!"),N(!1),u(null),w()}catch(s){console.error(s),n.error("Gagal memadam template")}},os=async()=>{if(!le.trim()){n.error("Sila masukkan prompt");return}ve(!0),ye(""),setTimeout(()=>{ye(`[${ne.toUpperCase()}] Hasil AI untuk: "${le}" 7 8Ini adalah contoh output. Integrasi sebenar dengan API AI akan ditambah kemudian.`),ve(!1)},1500)},U=()=>{V(""),_(""),Z(""),u(null),je(!1),be(!1),fe(!1)},Pe=s=>{u(s),V(s.name),_(s.slug),Z(s.description||""),v(!0)},Ie=async s=>{try{await c.from("templates").update({is_main_template:!1}).neq("id","00000000-0000-0000-0000-000000000000");const{error:r}=await c.from("templates").update({is_main_template:!0}).eq("id",s.id);if(r)throw r;n.success("Main Template berjaya ditukar!"),w()}catch(r){console.error(r),n.error("Gagal menukar main template")}},Q=P.filter(s=>{const r=S.toLowerCase(),l=s.name.toLowerCase().includes(r)||s.slug.toLowerCase().includes(r);return k?l:l&&s.is_active&&s.is_visible_to_agent!==!1}),X=Q.slice((j-1)*b,j*b);return e.jsxs("div",{className:"w-full space-y-8 p-4 md:p-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 tracking-tight",children:"Templates"}),e.jsx("p",{className:"text-gray-500 mt-2",children:k?"Manage landing page templates.":"Select a template and copy your link."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6 pb-4 border-b border-gray-200 items-start sm:items-center",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 w-full sm:max-w-sm",children:[e.jsx(Ps,{className:"h-4 w-4 text-gray-400 shrink-0"}),e.jsx(B,{placeholder:"Search templates...",value:S,onChange:s=>{p(s.target.value),A(1)},className:"w-full border-gray-200 bg-gray-50"})]}),k&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(t,{onClick:()=>{U(),je(!0),_("flipbook-"),h(!0)},className:"bg-orange-500 hover:bg-orange-600",children:[e.jsx(ge,{className:"mr-2 h-4 w-4"}),"Add Flipbook"]}),e.jsxs(t,{onClick:()=>{U(),be(!0),_("webinar-"),h(!0)},className:"bg-blue-500 hover:bg-blue-600",children:[e.jsx(pe,{className:"mr-2 h-4 w-4"}),"Add Webinar"]}),e.jsxs(t,{onClick:()=>{U(),fe(!0),_("html-"),h(!0)},className:"bg-emerald-500 hover:bg-emerald-600",children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Add HTML"]})]})]}),e.jsx("div",{className:"space-y-6",children:I?e.jsx("div",{className:"text-center py-12 text-gray-400",children:"Loading..."}):Q.length===0?e.jsx("div",{className:"text-center py-12 text-gray-400",children:S?"Tiada template dijumpai.":"Belum ada template."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsx(Ge,{sensors:Se,collisionDetection:Oe,onDragEnd:_e,children:e.jsxs("table",{className:"w-full text-left font-sans",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 text-xs uppercase text-gray-500",children:[k&&e.jsx("th",{className:"pb-4 px-2 w-10"}),e.jsx("th",{className:"pb-4 px-2 w-10 font-bold",children:"#"}),e.jsx("th",{className:"pb-4 px-2 font-bold",children:"Template"}),e.jsx("th",{className:"pb-4 px-2 font-bold",children:"Slug"}),k&&e.jsx("th",{className:"pb-4 px-2 font-bold",children:"Status"}),e.jsx("th",{className:"pb-4 px-2 font-bold",children:k?"Actions":"Link Anda"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:e.jsx(Fe,{items:X.map(s=>s.id),strategy:$e,children:X.map((s,r)=>e.jsx(zs,{template:s,index:(j-1)*b+r,isAdmin:k,agentSlug:de,handleSetMain:Ie,openEditDialog:Pe,navigate:a,openScheduleDialog:Ce,handleClone:Ae,handleToggleActive:Le,handleToggleVisibility:Ee,setSelectedTemplate:u,setDeleteOpen:N,copyLink:De,getAgentLink:me},s.id))})})]})})}),e.jsx("div",{className:"md:hidden space-y-6",children:e.jsx(Ge,{sensors:Se,collisionDetection:Oe,onDragEnd:_e,children:e.jsx(Fe,{items:X.map(s=>s.id),strategy:$e,children:X.map((s,r)=>e.jsx(Gs,{template:s,index:(j-1)*b+r,isAdmin:k,agentSlug:de,handleSetMain:Ie,openEditDialog:Pe,navigate:a,openScheduleDialog:Ce,handleClone:Ae,handleToggleActive:Le,handleToggleVisibility:Ee,setSelectedTemplate:u,setDeleteOpen:N,copyLink:De,getAgentLink:me},s.id))})})}),Q.length>0&&e.jsx(ms,{currentPage:j,totalItems:Q.length,itemsPerPage:b,onPageChange:A})]})}),e.jsx(ee,{open:z,onOpenChange:h,children:e.jsxs(se,{children:[e.jsxs(ae,{children:[e.jsx(re,{children:"Create New Template"}),e.jsx(Ue,{children:"Tambah landing page template baru."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Nama Template"}),e.jsx(B,{value:L,onChange:s=>{V(s.target.value),_(Te(s.target.value))},placeholder:"Promosi Raya 2024"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Slug (URL)"}),e.jsx(B,{value:$,onChange:s=>_(Te(s.target.value)),placeholder:"promosi-raya-2024"}),e.jsxs("p",{className:"text-xs text-gray-400",children:["URL: domain.com/",e.jsx("b",{children:$||"..."}),"/agent-slug"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Penerangan (Optional)"}),e.jsx(ue,{value:W,onChange:s=>Z(s.target.value),placeholder:"Penerangan ringkas...",rows:2})]})]}),e.jsxs(he,{children:[e.jsx(t,{variant:"outline",onClick:()=>h(!1),children:"Batal"}),e.jsxs(t,{onClick:is,disabled:K,className:"bg-purple-600 hover:bg-purple-700",children:[K&&e.jsx(te,{className:"mr-2 h-4 w-4 animate-spin"}),"Cipta"]})]})]})}),e.jsx(ee,{open:R,onOpenChange:v,children:e.jsxs(se,{children:[e.jsx(ae,{children:e.jsx(re,{children:"Edit Template"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Nama Template"}),e.jsx(B,{value:L,onChange:s=>V(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Slug"}),e.jsx(B,{value:$,disabled:!0,className:"bg-gray-100"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Penerangan"}),e.jsx(ue,{value:W,onChange:s=>Z(s.target.value),rows:2})]})]}),e.jsxs(he,{children:[e.jsx(t,{variant:"outline",onClick:()=>v(!1),children:"Batal"}),e.jsxs(t,{onClick:ns,disabled:K,className:"bg-purple-600 hover:bg-purple-700",children:[K&&e.jsx(te,{className:"mr-2 h-4 w-4 animate-spin"}),"Simpan"]})]})]})}),e.jsx(Ns,{open:G,onOpenChange:N,children:e.jsxs(ws,{children:[e.jsxs(ks,{children:[e.jsx(Cs,{children:"Padam Template?"}),e.jsxs(Ss,{children:['Template "',o?.name,'" akan dipadam secara kekal.']})]}),e.jsxs(_s,{children:[e.jsx(Ds,{children:"Batal"}),e.jsx(Ts,{onClick:ls,className:"bg-red-600 hover:bg-red-700",children:"Ya, Padam"})]})]})}),e.jsx(ee,{open:rs,onOpenChange:Y,children:e.jsxs(se,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ae,{children:[e.jsxs(re,{children:["Tetapan Jadual: ",o?.name]}
8),e.jsx(Ue,{children:"Tetapkan waktu operasi untuk template ini."})]}),e.jsx("div",{className:"py-4",children:e.jsx(Ls,{schedule:E.schedule,timeZone:E.timeZone,fallbackUrl:E.fallbackUrl,onChange:s=>ke(r=>({...r,schedule:s.recurring_schedule,timeZone:s.time_zone,fallbackUrl:s.fallback_url||""}))})}),e.jsxs(he,{children:[e.jsx(t,{variant:"outline",onClick:()=>Y(!1),children:"Batal"}),e.jsxs(t,{onClick:ts,disabled:Ne,className:"bg-purple-600 hover:bg-purple-700",children:[Ne&&e.jsx(te,{className:"mr-2 h-4 w-4 animate-spin"}),"Simpan Jadual"]})]})]})}),e.jsx(ee,{open:O,onOpenChange:F,children:e.jsxs(se,{className:"max-w-2xl",children:[e.jsx(ae,{children:e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-5 w-5 text-purple-600"}),"AI Content Generator"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Model AI"}),e.jsx("div",{className:"flex gap-2",children:["gemini","gpt","claude"].map(s=>e.jsxs(t,{variant:ne===s?"default":"outline",size:"sm",onClick:()=>ss(s),className:ne===s?"bg-purple-600":"",children:[s==="gemini"&&"⨠Gemini",s==="gpt"&&"ð¤ GPT-4",s==="claude"&&"ð§ Claude"]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Prompt"}),e.jsx(ue,{value:le,onChange:s=>as(s.target.value),placeholder:"Contoh: Buatkan headline menarik untuk promosi SIM card...",rows:3})]}),e.jsxs(t,{onClick:os,disabled:ce,className:"w-full bg-purple-600 hover:bg-purple-700",children:[ce?e.jsx(te,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Be,{className:"mr-2 h-4 w-4"}),ce?"Menjana...":"Generate"]}),oe&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Hasil"}),e.jsx("div",{className:"bg-gray-50 border rounded-lg p-4 whitespace-pre-wrap text-sm",children:oe}),e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(oe),n.success("Disalin!")},children:[e.jsx(q,{className:"h-4 w-4 mr-1"})," Copy"]})]})]})]})})]})};export{va 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.