1import{U as u,O as e,B as y,I as n,X as $,d as B,e as P,h as H,i as U,T as c,C as R,p as v,Z as d}from"./index-IBHyG7M_.js";import{L as l}from"./label-DPfgYCkJ.js";import{T as Q,b as z,c as b,a as S}from"./tabs-F1J2brUq.js";import{T as G,d as V,e as T,c as p,a as X,b as f}from"./table-CG-0Fq2Z.js";import{B as Z}from"./badge-CXQjseq-.js";import{P as K}from"./plus-CSRmdP_D.js";import{S as W}from"./search-CrgSiNi5.js";import{P as Y}from"./pencil-Bs1O0sP_.js";import{T as ee}from"./trash-2-DdyChubd.js";import{C as h}from"./circle-check-big-DH4MQJ0h.js";import{C as m}from"./circle-alert-wRXHwVT2.js";const r=w=>{try{const C=JSON.parse(w);return Array.isArray(C)}catch{return!1}},L={title:"",slug:"",category_name:"",category_slug:"",tagline:"",hero_subtitle:"",description:"",long_overview:"",icon:"",features:"[]",benefits:"[]",process_steps:"[]",service_inclusions:"[]",industry_use_cases:"[]",technologies:"[]",faqs:"[]",cta_heading:"",cta_text:"",is_published:!1,seo_title:"",seo_description:"",og_image:"",canonical_url:"",sort_order:0};function ue(){const[w,C]=u.useState([]),[D,_]=u.useState(!1),[N,q]=u.useState(null),[s,i]=u.useState(L),[j,I]=u.useState(""),[x,o]=u.useState({features:!1,benefits:!1,process_steps:!1,service_inclusions:!1,industry_use_cases:!1,technologies:!1,faqs:!1}),O=async()=>{const t=await v.services.list();C(t||[])};u.useEffect(()=>{O()},[]);const E=()=>{i(L),q(null),o({features:!1,benefits:!1,process_steps:!1,service_inclusions:!1,industry_use_cases:!1,technologies:!1,faqs:!1}),_(!0)},A=async t=>{const a=await v.services.get(t);a&&(i({title:a.title||"",slug:a.slug||"",category_name:a.category_name||"",category_slug:a.category_slug||"",tagline:a.tagline||"",hero_subtitle:a.hero_subtitle||"",description:a.description||"",long_overview:a.long_overview||"",icon:a.icon||"",features:JSON.stringify(a.features||[]),benefits:JSON.stringify(a.benefits||[]),process_steps:JSON.stringify(a.process_steps||[]),service_inclusions:JSON.stringify(a.service_inclusions||[]),industry_use_cases:JSON.stringify(a.industry_use_cases||[]),technologies:JSON.stringify(a.technologies||[]),faqs:JSON.stringify(a.faqs||[]),cta_heading:a.cta_heading||"",cta_text:a.cta_text||"",is_published:a.is_published||!1,seo_title:a.seo_title||"",seo_description:a.seo_description||"",og_image:a.og_image||"",canonical_url:a.canonical_url||"",sort_order:a.sort_order||0}
1),o({features:!r(JSON.stringify(a.features||[])),benefits:!r(JSON.stringify(a.benefits||[])),process_steps:!r(JSON.stringify(a.process_steps||[])),service_inclusions:!r(JSON.stringify(a.service_inclusions||[])),industry_use_cases:!r(JSON.stringify(a.industry_use_cases||[])),technologies:!r(JSON.stringify(a.technologies||[])),faqs:!r(JSON.stringify(a.faqs||[]))}),q(t),_(!0))},F=async()=>{if(!s.title.trim()){d.error("Title is required");return}if(!s.slug.trim()){d.error("Slug is required");return}const t=["features","benefits","process_steps","service_inclusions","industry_use_cases","technologies","faqs"],a={...s};try{for(const g of t)try{const J=JSON.parse(s[g]);if(!Array.isArray(J)){d.error(`${g.replace(/_/g," ")}: Must be a JSON array (e.g., ["item1", "item2"])`);return}a[g]=J}catch{d.error(`${g.replace(/_/g," ")}: Invalid JSON syntax. Expected format: ["item1", "item2"]`);return}N?(await v.services.update(N,a),d.success("Service updated")):(await v.services.create(a),d.success("Service created")),_(!1),O()}catch(g){d.error(g.message||"Failed to save service")}},M=async t=>{if(confirm("Delete this service?"))try{await v.services.delete(t),d.success("Service deleted"),O()}catch(a){d.error(a.message||"Failed to delete service")}},k=w.filter(t=>t.title.toLowerCase().includes(j.toLowerCase())||t.category_name.toLowerCase().includes(j.toLowerCase()));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-display font-bold text-foreground",children:"Services"}),e.jsxs(y,{onClick:E,className:"gap-2",children:[e.jsx(K,{className:"w-4 h-4"}),"New Service"]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(n,{value:j,onChange:t=>I(t.target.value),placeholder:"Search services...",className:"pl-9"}),j&&e.jsx("button",{onClick:()=>I(""),className:"absolute right-2 top-1/2 -translate-y-1/2",children:e.jsx($,{className:"w-4 h-4 text-muted-foreground"})})]}),e.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:e.jsxs(G,{children:[e.jsx(V,{children:e.jsxs(T,{children:[e.jsx(p,{children:"Title"}),e.jsx(p,{children:"Category"}),e.jsx(p,{children:"Status"}),e.jsx(p,{children:"Created"}),e.jsx(p,{className:"w-20",children:"Actions"})]})}),e.jsxs(X,{children:[k.map(t=>e.jsxs(T,{children:[e.jsx(f,{className:"font-medium max-w-xs truncate",children:t.title}),e.jsx(f,{children:t.category_name}),e.jsx(f,{children:e.jsx(Z,{variant:t.is_published?"default":"secondary",children:t.is_published?"Published":"Draft"})}),e.jsx(f,{className:"text-sm text-muted-foreground",children:new Date(t.created_at).toLocaleDateString()}),e.jsx(f,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>A(t.id),children:e.jsx(Y,{className:"w-4 h-4"})}),e.jsx(y,{variant:"ghost",size:"icon",onClick:()=>M(t.id),children:e.jsx(ee,{className:"w-4 h-4 text-destructive"})})]})})]},t.id)),k.length===0&&e.jsx(T,{children:e.jsx(f,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:j?"No results found":"No services yet"})})]})]})}),e.jsx(B,{open:D,onOpenChange:_,children:e.jsxs(P,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(H,{children:e.jsx(U,{children:N?"Edit Service":"New Service"})}),e.jsxs(Q,{defaultValue:"basic",className:"space-y-4",children:[e.jsxs(z,{className:"grid w-full grid-cols-4",children:[e.jsx(b,{value:"basic",children:"Basic"}),e.jsx(b,{value:"content",children:"Content"}),e.jsx(b,{value:"lists",children:"Lists"}),e.jsx(b,{value:"seo",children:"SEO"})]}),e.jsxs(S,{value:"basic",className:"space-y-4",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{children:"Title *"}),e.jsx(n,{value:s.title,onChange:t=>i({...s,title:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Slug *"}),e.jsx(n,{value:s.slug,onChange:t=>i({...s,slug:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Category Name *"}),e.jsx(n,{value:s.category_name,onChange:t=>i({...s,category_name:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Category Slug *"}),e.jsx(n,{value:s.category_slug,onChange:t=>i({...s,category_slug:t.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Tagline"}),e.jsx(n,{value:s.tagline,onChange:t=>i({...s,tagline:t.target.value}),placeholder:"Short tagline"})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Hero Subtitle"}),e.jsx(n,{value:s.hero_subtitle,onChange:t=>i({...s,hero_subtitle:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Icon (Lucide name)"}),e.jsx(n,{value:s.icon,onChange:t=>i({...s,icon:t.target.value}),placeholder:"e.g., Cloud, Database, Shield"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"pub",checked:s.is_published,onChange:t=>i({...s,is_published:t.target.checked}),className:"w-4 h-4"}),e.jsx(l,{htmlFor:"pub",className:"cursor-pointer",children:"Published"})]})]}),e.jsxs(S,{value:"content",className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{children:"Short Description"}),e.jsx(c,{value:s.description,onChange:t=>i({...s,description:t.target.value}),rows:3})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Long Overview"}),e.jsx(c,{value:s.long_overview,onChange:t=>i({...s,long_overview:t.target.value}),rows:4})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{children:"CTA Heading"}),e.jsx(n,{value:s.cta_heading,onChange:t=>i({...s,cta_heading:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(l,{children:"CTA Text"}),e.jsx(n,{value:s.cta_text,onChange:t=>i({...s,cta_text:t.target.value})})]})]})]}),e.jsxs(S,{value:"lists",className:"space-y-4",children:[e.jsxs(R,{className:"p-3 bg-muted/30 text-xs text-muted-foreground",children:[e.jsx("div",{className:"font-medium mb-1",children:"JSON Format Guide"}),"Enter JSON arrays for list items. Examples:",e.jsxs("ul",{className:"mt-1 space-y-0.5",children:[e.jsx("li",{children:'⢠Simple strings: ["Item 1", "Item 2", "Item 3"]'}),e.jsxs("li",{children:["⢠Objects: [","{",'"title": "Step 1", "desc": "Description"',"}",", ","{",'"title": "Step 2"',"}","]"]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(l,{className:"flex-1",children:"Features (JSON)"}),r(s.features)?e.jsx(h,{className:"w-4 h-4 text-green-600"}):s.features.trim()&&e.jsx(m,{className:"w-4 h-4 text-red-600"})]}),e.jsx(c,{value:s.features,onChange:t=>{i({...s,features:t.target.value}),o({...x,features:!1})},rows:3,className:`font-mono text-sm ${!r(s.features)&&s.features.trim()?"border-red-500":""}`}),!r(s.features)&&s.features.trim()&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:'â Invalid JSON. Must be an array like: ["item1", "item2"]'})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(l,{className:"flex-1",children:"Benefits (JSON)"}),r(s.benefits)?e.jsx(h,{className:"w-4 h-4 text-green-600"}):s.benefits.trim()&&e.jsx(m,{className:"w-4 h-4 text-red-600"})]}),e.jsx(c,{value:s.benefits,onChange:t=>
1{i({...s,benefits:t.target.value}),o({...x,benefits:!1})},rows:3,className:`font-mono text-sm ${!r(s.benefits)&&s.benefits.trim()?"border-red-500":""}`}),!r(s.benefits)&&s.benefits.trim()&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:'â Invalid JSON. Must be an array like: ["item1", "item2"]'})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(l,{className:"flex-1",children:"Process Steps (JSON)"}),r(s.process_steps)?e.jsx(h,{className:"w-4 h-4 text-green-600"}):s.process_steps.trim()&&e.jsx(m,{className:"w-4 h-4 text-red-600"})]}),e.jsx(c,{value:s.process_steps,onChange:t=>{i({...s,process_steps:t.target.value}),o({...x,process_steps:!1})},rows:3,className:`font-mono text-sm ${!r(s.process_steps)&&s.process_steps.trim()?"border-red-500":""}`}),!r(s.process_steps)&&s.process_steps.trim()&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:'â Invalid JSON. Must be an array like: ["item1", "item2"]'})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(l,{className:"flex-1",children:"Service Inclusions (JSON)"}),r(s.service_inclusions)?e.jsx(h,{className:"w-4 h-4 text-green-600"}):s.service_inclusions.trim()&&e.jsx(m,{className:"w-4 h-4 text-red-600"})]}),e.jsx(c,{value:s.service_inclusions,onChange:t=>{i({...s,service_inclusions:t.target.value}),o({...x,service_inclusions:!1})},rows:3,className:`font-mono text-sm ${!r(s.service_inclusions)&&s.service_inclusions.trim()?"border-red-500":""}`}),!r(s.service_inclusions)&&s.service_inclusions.trim()&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:'â Invalid JSON. Must be an array like: ["item1", "item2"]'})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(l,{className:"flex-1",children:"Industry Use Cases (JSON)"}),r(s.industry_use_cases)?e.jsx(h,{className:"w-4 h-4 text-green-600"}):s.industry_use_cases.trim()&&e.jsx(m,{className:"w-4 h-4 text-red-600"})]}),e.jsx(c,{value:s.industry_use_cases,onChange:t=>{i({...s,industry_use_cases:t.target.value}),o({...x,industry_use_cases:!1})},rows:3,className:`font-mono text-sm ${!r(s.industry_use_cases)&&s.industry_use_cases.trim()?"border-red-500":""}`}),!r(s.industry_use_cases)&&s.industry_use_cases.trim()&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:'â Invalid JSON. Must be an array like: ["item1", "item2"]'})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(l,{className:"flex-1",children:"Technologies (JSON)"}),r(s.technologies)?e.jsx(h,{className:"w-4 h-4 text-green-600"}):s.technologies.trim()&&e.jsx(m,{className:"w-4 h-4 text-red-600"})]}),e.jsx(c,{value:s.technologies,onChange:t=>{i({...s,technologies:t.target.value}),o({...x,technologies:!1})},rows:3,className:`font-mono text-sm ${!r(s.technologies)&&s.technologies.trim()?"border-red-500":""}`}),!r(s.technologies)&&s.technologies.trim()&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:'â Invalid JSON. Must be an array like: ["item1", "item2"]'})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(l,{className:"flex-1",children:"FAQs (JSON)"}),r(s.faqs)?e.jsx(h,{className:"w-4 h-4 text-green-600"}):s.faqs.trim()&&e.jsx(m,{className:"w-4 h-4 text-red-600"})]}),e.jsx(c,{value:s.faqs,onChange:t=>{i({...s,faqs:t.target.value}),o({...x,faqs:!1})},rows:3,className:`font-mono text-sm ${!r(s.faqs)&&s.faqs.trim()?"border-red-500":""}`}),!r(s.faqs)&&s.faqs.trim()&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:'â Invalid JSON. Must be an array like: ["item1", "item2"]'})]})]}),e.jsxs(S,{value:"seo",className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{children:"SEO Title"}),e.jsx(n,{value:s.seo_title,onChange:t=>i({...s,seo_title:t.target.value}),maxLength:60}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s.seo_title.length,"/60"]})]}),e.jsxs("div",{children:[e.jsx(l,{children:"SEO Description"}),e.jsx(c,{value:s.seo_description,onChange:t=>
1i({...s,seo_description:t.target.value}),maxLength:160,rows:3}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s.seo_description.length,"/160"]})]}),e.jsxs("div",{children:[e.jsx(l,{children:"OG Image URL"}),e.jsx(n,{value:s.og_image,onChange:t=>i({...s,og_image:t.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Canonical URL"}),e.jsx(n,{value:s.canonical_url,onChange:t=>i({...s,canonical_url:t.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(l,{children:"Sort Order"}),e.jsx(n,{type:"number",value:s.sort_order,onChange:t=>i({...s,sort_order:parseInt(t.target.value)||0})})]})]})]}),e.jsx(y,{onClick:F,className:"w-full bg-gradient-electric text-white",children:N?"Update Service":"Create Service"})]})})]})}export{ue 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.