import{a as e,c as t,i as n,l as r,m as i,n as a,o,r as s,s as c,t as l,u}from"./x-DnG5sti3.js";var d=e(`award`,[[`path`,{d:`m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526`,key:`1yiouv`}],[`circle`,{cx:`12`,cy:`8`,r:`6`,key:`1vp47v`}]]),f=e(`building-2`,[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]]),p=e(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),m=e(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),h=e(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),g=e(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),_=e(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),v=e(`images`,[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]),y=e(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),b=e(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),x=e(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),S=e(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),C=e(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),w=e(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),T=e(`save`,[[`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`}]]),E=e(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),D=e(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),O=e(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),k=e(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),A=i(u(),1),j=r(),M=t(),N=`admin`,P=`admin123`,F=`static-admin-session`;function I(){return localStorage.getItem(`admin_token`)}function ee(e){localStorage.setItem(`admin_token`,e)}function L(){localStorage.removeItem(`admin_token`)}function R(e=I()){return e===F}function te(e,t){if(e===N&&t===P)return{token:F,expiresAt:null,mode:`static`};throw Error(`Invalid credentials`)}async function z(e,t={}){let n={...t.headers};t.body instanceof FormData||(n[`Content-Type`]=`application/json`);let r=I();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`${o}${e}`,{...t,headers:n}),a=await i.json().catch(()=>({}));if(!i.ok){let e=i.status===404?`API not found. Deploy server/ and run: npm run server (port 3001)`:i.status===502?`API server unreachable. Start Node on the host (port 3001).`:`Request failed`;throw Error(a.error||e)}return a}var B={login:async(e,t)=>{try{return await z(`/api/auth/login`,{method:`POST`,body:JSON.stringify({username:e,password:t})})}catch{return te(e,t)}},me:async()=>R()?{username:N,mode:`static`}:z(`/api/auth/me`),getContent:()=>z(`/api/content`),updateSection:(e,t)=>z(`/api/content/${e}`,{method:`PUT`,body:JSON.stringify(t)}),changePassword:(e,t)=>z(`/api/auth/password`,{method:`PUT`,body:JSON.stringify({currentPassword:e,newPassword:t})}),upload:async e=>{let t=new FormData;return t.append(`file`,e),z(`/api/upload`,{method:`POST`,body:t})}};function V({value:e,onChange:t,label:n=`Image`}){let[r,i]=(0,A.useState)(!1);return(0,M.jsxs)(`div`,{className:`form-field`,children:[(0,M.jsx)(`label`,{className:`form-label`,children:n}),e&&(0,M.jsx)(`div`,{className:`form-preview`,children:e.match(/\.(mp4|webm)$/i)?(0,M.jsx)(`video`,{src:e,controls:!0}):(0,M.jsx)(`img`,{src:e,alt:``})}),(0,M.jsx)(`input`,{type:`text`,className:`form-input`,value:e||``,onChange:e=>t(e.target.value),placeholder:`Paste URL or upload a file below`}),(0,M.jsxs)(`label`,{className:`form-upload-btn`,children:[(0,M.jsx)(k,{size:14}),r?`Uploading...`:`Choose file`,(0,M.jsx)(`input`,{type:`file`,accept:`image/*,video/mp4`,onChange:async e=>{let n=e.target.files?.[0];if(n){i(!0);try{let{url:e}=await B.upload(n);t(e)}catch(e){alert(e.message)}finally{i(!1)}}},hidden:!0,disabled:r})]})]})}function H({label:e,value:t,onChange:n,multiline:r=!1,type:i=`text`}){return(0,M.jsxs)(`div`,{className:`form-field`,children:[(0,M.jsx)(`label`,{className:`form-label`,children:e}),r?(0,M.jsx)(`textarea`,{className:`form-textarea`,value:t||``,onChange:e=>n(e.target.value),rows:4}):(0,M.jsx)(`input`,{type:i,className:`form-input`,value:t||``,onChange:e=>n(e.target.value)})]})}function U({label:e,items:t,onChange:n,fields:r}){let i=(e,r,i)=>{n(t.map((t,n)=>n===e?{...t,[r]:i}:t))},a=()=>{let e=r.reduce((e,t)=>({...e,[t.key]:t.default??``}),{id:Date.now()});n([...t,e])},o=e=>n(t.filter((t,n)=>n!==e));return(0,M.jsxs)(`div`,{className:`array-section`,children:[(0,M.jsxs)(`div`,{className:`array-header`,children:[(0,M.jsx)(`h4`,{className:`array-title`,children:e}),(0,M.jsxs)(`button`,{type:`button`,onClick:a,className:`array-add-btn`,children:[(0,M.jsx)(w,{size:14}),` Add item`]})]}),t.length===0&&(0,M.jsx)(`p`,{style:{color:`#94a3b8`,fontSize:`0.85rem`,margin:`0 0 1rem`},children:`No items yet. Click "Add item" to create one.`}),t.map((e,t)=>(0,M.jsxs)(`div`,{className:`array-item`,children:[(0,M.jsxs)(`div`,{className:`array-item-header`,children:[(0,M.jsxs)(`span`,{className:`array-item-badge`,children:[`Item `,t+1]}),(0,M.jsxs)(`button`,{type:`button`,onClick:()=>o(t),className:`array-remove-btn`,children:[(0,M.jsx)(O,{size:12}),` Remove`]})]}),r.map(n=>n.type===`image`?(0,M.jsx)(V,{label:n.label,value:e[n.key],onChange:e=>i(t,n.key,e)},n.key):(0,M.jsx)(H,{label:n.label,value:e[n.key],onChange:e=>i(t,n.key,e),multiline:n.multiline},n.key))]},e.id??t))]})}var W={hero:`home`,about:`aboutus`,certifications:`certifications`,services:`services`,whyUs:`whyus`,gallery:`featured-gallery`,products:`products`,insights:`insights`,footer:`contactus`};function G(e,t,n){if(!e||!n)return e;let r={...e};return t===`hero`?(r.hero=n.hero??r.hero,r.metrics=n.metrics??r.metrics):t===`about`?(r.about=n.about??r.about,r.partners=n.partners??r.partners):r[t]=n,r}var K=`/citpl_website/preview.html`,q=1440,J=900;function ne({section:e,label:t,content:n,sectionData:r}){let i=(0,A.useRef)(null),a=(0,A.useRef)(null),o=(0,A.useRef)({}),s=(0,A.useRef)(null),c=W[e]||`home`,[l,u]=(0,A.useState)(.45),[d,f]=(0,A.useState)(!1),[p,m]=(0,A.useState)(!1),[_,v]=(0,A.useState)(!1);o.current={content:n,sectionData:r,section:e,anchor:c},(0,A.useEffect)(()=>{let e=window.setTimeout(()=>v(!0),50);return()=>window.clearTimeout(e)},[]),(0,A.useEffect)(()=>{let e=e=>{e.origin===window.location.origin&&e.data?.type===`PREVIEW_READY`&&m(!0)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),(0,A.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>{let t=e.clientWidth;u(t>0?t/q:.45)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let y=(0,A.useCallback)((e=!1)=>{let t=()=>{let e=a.current,{content:t,sectionData:n,section:r,anchor:i}=o.current;!e?.contentWindow||!t||!n||e.contentWindow.postMessage({type:`ADMIN_PREVIEW`,section:r,anchor:i,fullContent:G(t,r,n)},window.location.origin)};if(e){window.clearTimeout(s.current),t();return}window.clearTimeout(s.current),s.current=window.setTimeout(t,200)},[]);(0,A.useEffect)(()=>{d&&y(!0)},[d,e,c,d,y]),(0,A.useEffect)(()=>{if(d)return y(!1),()=>window.clearTimeout(s.current)},[n,r,d,y]);let b=()=>{f(!0),y(!0)},x=!_||!d||!p;return(0,M.jsxs)(`aside`,{className:`admin-preview-panel`,children:[(0,M.jsxs)(`div`,{className:`admin-preview-panel-header`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`span`,{className:`admin-preview-eyebrow`,children:[(0,M.jsx)(g,{size:14}),`Live preview`]}),(0,M.jsx)(`h3`,{children:t})]}),(0,M.jsxs)(`a`,{href:`/citpl_website/#${c}`,target:`_blank`,rel:`noopener noreferrer`,className:`admin-preview-open`,children:[(0,M.jsx)(h,{size:13}),`Open`]})]}),(0,M.jsxs)(`div`,{className:`admin-preview-shell`,children:[(0,M.jsxs)(`div`,{className:`admin-preview-chrome`,children:[(0,M.jsx)(`span`,{className:`admin-preview-dot`}),(0,M.jsx)(`span`,{className:`admin-preview-dot`}),(0,M.jsx)(`span`,{className:`admin-preview-dot`}),(0,M.jsxs)(`span`,{className:`admin-preview-url`,children:[`/`,c]})]}),(0,M.jsxs)(`div`,{className:`admin-preview-viewport`,ref:i,style:{height:J*l},children:[x&&(0,M.jsxs)(`div`,{className:`admin-preview-loading`,children:[(0,M.jsx)(`div`,{className:`admin-spinner`}),(0,M.jsx)(`span`,{children:`Loading preview…`})]}),_&&(0,M.jsx)(`div`,{className:`admin-preview-stage`,style:{width:q*l,height:J*l,opacity:+!x},children:(0,M.jsx)(`iframe`,{ref:a,src:K,title:`${t} preview`,className:`admin-preview-iframe`,onLoad:b,style:{width:q,height:J,transform:`scale(${l})`}})})]})]}),(0,M.jsx)(`p`,{className:`admin-preview-note`,children:`Updates as you edit. Save to publish to the live site.`})]})}function Y(e,t){if(!e||t===`dashboard`||t===`settings`)return null;if(t===`hero`)return{hero:structuredClone(e.hero??{}),metrics:structuredClone(e.metrics??[])};if(t===`about`)return{about:structuredClone(e.about??{}),partners:structuredClone(e.partners??{logos:[]})};let n=e[t];return n?structuredClone(n):null}var X=`/citpl_website/`,Z=[{label:`Overview`,items:[{id:`dashboard`,label:`Dashboard`,icon:y,desc:`Overview and quick access to all sections`}]},{label:`Page Content`,items:[{id:`hero`,label:`Hero & Metrics`,icon:a,desc:`Homepage headline, video, and statistics`},{id:`about`,label:`About & Partners`,icon:f,desc:`About section and partner logos`},{id:`certifications`,label:`Certifications`,icon:d,desc:`Certification badges and headings`},{id:`services`,label:`Services`,icon:b,desc:`Service cards and section copy`},{id:`whyUs`,label:`Why Us`,icon:D,desc:`Value propositions and images`},{id:`gallery`,label:`Gallery`,icon:v,desc:`Featured case studies and gallery items`},{id:`products`,label:`Products`,icon:C,desc:`Product suite cards and stats`},{id:`insights`,label:`Insights`,icon:_,desc:`Blog and insight carousel items`},{id:`footer`,label:`Footer & Links`,icon:x,desc:`CTA, social links, and footer navigation`}]},{label:`Account`,items:[{id:`settings`,label:`Settings`,icon:E,desc:`Password and account preferences`}]}],Q=Z.flatMap(e=>e.items),re=Object.fromEntries(Q.map(e=>[e.id,e.desc]));function ie({message:e,type:t}){return e?(0,M.jsxs)(`div`,{className:`toast ${t}`,children:[t===`success`?(0,M.jsx)(m,{size:18}):(0,M.jsx)(p,{size:18}),e]}):null}function ae(){let e=(0,A.useRef)(null),t=(0,A.useRef)(null),[n,r]=(0,A.useState)(.5),[i,a]=(0,A.useState)(!1),o=1280,s=`${X}preview.html`;return(0,A.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(t.clientWidth/o)};n();let i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[]),(0,A.useEffect)(()=>{let e=setTimeout(()=>{try{let e=t.current?.contentDocument;(!e?.body||e.body.childElementCount===0)&&a(!0)}catch{a(!0)}},2e3);return()=>clearTimeout(e)},[]),(0,M.jsxs)(`div`,{className:`login-preview`,children:[(0,M.jsxs)(`div`,{className:`login-preview-intro`,children:[(0,M.jsx)(`img`,{src:`${X}assets/cavin_logo.svg`,alt:`Cavin Infotech`}),(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h1`,{children:[`Content `,(0,M.jsx)(`span`,{children:`Manager`})]}),(0,M.jsx)(`p`,{children:`Preview the live website before you sign in. Edits publish instantly after login.`})]}),(0,M.jsxs)(`a`,{href:X,target:`_blank`,rel:`noopener noreferrer`,className:`login-preview-link`,children:[(0,M.jsx)(h,{size:14}),`Open full site`]})]}),(0,M.jsxs)(`div`,{className:`login-preview-shell`,children:[(0,M.jsxs)(`div`,{className:`login-preview-chrome`,children:[(0,M.jsx)(`span`,{className:`login-preview-dot`}),(0,M.jsx)(`span`,{className:`login-preview-dot`}),(0,M.jsx)(`span`,{className:`login-preview-dot`}),(0,M.jsx)(`span`,{className:`login-preview-url`,children:`cavininfotech.com`})]}),(0,M.jsx)(`div`,{className:`login-preview-viewport`,ref:e,style:{height:800*n},children:i?(0,M.jsxs)(`div`,{className:`login-preview-fallback`,children:[(0,M.jsx)(`p`,{children:`Inline preview is blocked by the server's frame policy.`}),(0,M.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`login-preview-link`,children:[(0,M.jsx)(h,{size:14}),`Open preview`]})]}):(0,M.jsx)(`div`,{className:`login-preview-stage`,style:{width:o*n,height:800*n},children:(0,M.jsx)(`iframe`,{ref:t,src:s,title:`Website preview`,className:`login-preview-iframe`,style:{width:o,height:800,transform:`scale(${n})`}})})})]})]})}function oe({onLogin:e}){let[t,n]=(0,A.useState)(`admin`),[r,i]=(0,A.useState)(`admin123`),[a,o]=(0,A.useState)(``),[s,c]=(0,A.useState)(!1);return(0,M.jsxs)(`div`,{className:`login-page`,children:[(0,M.jsx)(ae,{}),(0,M.jsx)(`div`,{className:`login-form-side`,children:(0,M.jsxs)(`form`,{className:`login-card`,onSubmit:async n=>{n.preventDefault(),c(!0),o(``);try{let{token:n}=await B.login(t,r);ee(n),e()}catch(e){o(e.message)}finally{c(!1)}},children:[(0,M.jsx)(`h2`,{children:`Welcome back`}),(0,M.jsx)(`p`,{className:`login-subtitle`,children:`Sign in to your admin account`}),a&&(0,M.jsxs)(`div`,{className:`login-error`,children:[(0,M.jsx)(p,{size:16}),a]}),(0,M.jsx)(H,{label:`Username`,value:t,onChange:n}),(0,M.jsx)(H,{label:`Password`,value:r,onChange:i,type:`password`}),(0,M.jsx)(`button`,{type:`submit`,className:`btn-primary`,disabled:s,children:s?`Signing in...`:`Sign in`})]})})]})}function $({loading:e,error:t}){return(0,M.jsx)(`div`,{className:`admin-editor-placeholder`,children:e?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`admin-spinner`}),(0,M.jsx)(`p`,{children:`Loading section content...`})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(p,{size:22}),(0,M.jsx)(`p`,{children:t||`Unable to load this section.`})]})})}var se=class extends A.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,M.jsxs)(`div`,{className:`admin-card admin-editor-placeholder`,children:[(0,M.jsx)(p,{size:22}),(0,M.jsx)(`p`,{children:`Something went wrong loading this section.`}),(0,M.jsx)(`p`,{style:{fontSize:`0.8rem`,color:`#94a3b8`},children:this.state.error.message}),(0,M.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>this.setState({error:null}),children:`Try again`})]}):this.props.children}};function ce({section:e,data:t,onChange:n}){if(!t)return(0,M.jsx)($,{loading:!1,error:`No content found for this section.`});switch(e){case`hero`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(V,{label:`Hero Video`,value:t.hero?.video,onChange:e=>n({...t,hero:{...t.hero,video:e}})}),(0,M.jsx)(H,{label:`Badge Text`,value:t.hero?.badge,onChange:e=>n({...t,hero:{...t.hero,badge:e}})}),(0,M.jsx)(H,{label:`Headline`,value:t.hero?.headline,onChange:e=>n({...t,hero:{...t.hero,headline:e}})}),(0,M.jsx)(H,{label:`Subheadline`,value:t.hero?.subheadline,onChange:e=>n({...t,hero:{...t.hero,subheadline:e}})}),(0,M.jsx)(U,{label:`Metrics`,items:t.metrics||[],onChange:e=>n({...t,metrics:e}),fields:[{key:`value`,label:`Value`},{key:`label`,label:`Label`}]})]});case`about`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`About Heading`,value:t.about?.heading,onChange:e=>n({about:{...t.about,heading:e},partners:t.partners})}),(0,M.jsx)(V,{label:`Badge Image`,value:t.about?.badgeImage,onChange:e=>n({about:{...t.about,badgeImage:e},partners:t.partners})}),(0,M.jsx)(H,{label:`Badge Alt Text`,value:t.about?.badgeAlt,onChange:e=>n({about:{...t.about,badgeAlt:e},partners:t.partners})}),(0,M.jsx)(V,{label:`Background Image`,value:t.about?.backgroundImage,onChange:e=>n({about:{...t.about,backgroundImage:e},partners:t.partners})}),(0,M.jsx)(H,{label:`Partners Heading`,value:t.partners?.heading,onChange:e=>n({about:t.about,partners:{...t.partners,heading:e}})}),(0,M.jsx)(H,{label:`Partners Subheading`,value:t.partners?.subheading,onChange:e=>n({about:t.about,partners:{...t.partners,subheading:e}})}),(0,M.jsx)(H,{label:`Partners Body`,value:t.partners?.body,onChange:e=>n({about:t.about,partners:{...t.partners,body:e}}),multiline:!0}),(0,M.jsx)(U,{label:`Partner Logos`,items:t.partners?.logos||[],onChange:e=>n({about:t.about,partners:{...t.partners,logos:e}}),fields:[{key:`name`,label:`Name`},{key:`image`,label:`Logo`,type:`image`}]})]});case`certifications`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`Section Heading`,value:t.heading,onChange:e=>n({...t,heading:e})}),(0,M.jsx)(U,{label:`Certifications`,items:t.items||[],onChange:e=>n({...t,items:e}),fields:[{key:`image`,label:`Image`,type:`image`},{key:`alt`,label:`Alt Text`}]})]});case`services`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,M.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,M.jsx)(H,{label:`Intro`,value:t.intro,onChange:e=>n({...t,intro:e}),multiline:!0}),(0,M.jsx)(U,{label:`Service Cards`,items:t.items||[],onChange:e=>n({...t,items:e}),fields:[{key:`number`,label:`Number`},{key:`title`,label:`Title`},{key:`boldStatement`,label:`Bold Statement`},{key:`description`,label:`Description`,multiline:!0},{key:`cta`,label:`CTA Text`}]})]});case`whyUs`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,M.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,M.jsx)(U,{label:`Value Cards`,items:t.cards||[],onChange:e=>n({...t,cards:e}),fields:[{key:`title`,label:`Title`},{key:`description`,label:`Description`,multiline:!0}]}),(0,M.jsx)(U,{label:`Images`,items:t.images||[],onChange:e=>n({...t,images:e}),fields:[{key:`src`,label:`Image`,type:`image`},{key:`alt`,label:`Alt Text`}]})]});case`gallery`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,M.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,M.jsx)(H,{label:`Subtitle`,value:t.subtitle,onChange:e=>n({...t,subtitle:e}),multiline:!0}),(0,M.jsx)(U,{label:`Gallery Items`,items:t.items||[],onChange:e=>n({...t,items:e}),fields:[{key:`title`,label:`Title`},{key:`category`,label:`Category`},{key:`excerpt`,label:`Excerpt`,multiline:!0},{key:`image`,label:`Image`,type:`image`},{key:`readTime`,label:`Read Time`}]})]});case`products`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,M.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,M.jsx)(H,{label:`Subtitle`,value:t.subtitle,onChange:e=>n({...t,subtitle:e}),multiline:!0}),(0,M.jsx)(U,{label:`Products`,items:t.items||[],onChange:e=>n({...t,items:e}),fields:[{key:`name`,label:`Name`},{key:`description`,label:`Description`,multiline:!0},{key:`image`,label:`Dashboard Image`,type:`image`}]})]});case`insights`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,M.jsx)(H,{label:`Subtitle`,value:t.subtitle,onChange:e=>n({...t,subtitle:e}),multiline:!0}),(0,M.jsx)(U,{label:`Insight Cards`,items:t.items||[],onChange:e=>n({...t,items:e}),fields:[{key:`category`,label:`Category`},{key:`title`,label:`Title`},{key:`date`,label:`Date`},{key:`excerpt`,label:`Excerpt`,multiline:!0},{key:`image`,label:`Image`,type:`image`}]})]});case`footer`:return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(H,{label:`CTA Headline`,value:t.cta?.headline,onChange:e=>n({...t,cta:{...t.cta,headline:e}})}),(0,M.jsx)(H,{label:`CTA Body`,value:t.cta?.body,onChange:e=>n({...t,cta:{...t.cta,body:e}}),multiline:!0}),(0,M.jsx)(V,{label:`CTA Image`,value:t.cta?.image,onChange:e=>n({...t,cta:{...t.cta,image:e}})}),(0,M.jsx)(H,{label:`Primary Button`,value:t.cta?.primaryButton,onChange:e=>n({...t,cta:{...t.cta,primaryButton:e}})}),(0,M.jsx)(H,{label:`Secondary Button`,value:t.cta?.secondaryButton,onChange:e=>n({...t,cta:{...t.cta,secondaryButton:e}})}),(0,M.jsx)(U,{label:`Quick Links`,items:t.quickLinks||[],onChange:e=>n({...t,quickLinks:e}),fields:[{key:`label`,label:`Label`},{key:`href`,label:`Link`}]}),(0,M.jsx)(U,{label:`Product Links`,items:t.productLinks||[],onChange:e=>n({...t,productLinks:e}),fields:[{key:`label`,label:`Label`},{key:`href`,label:`Link`}]}),(0,M.jsx)(U,{label:`Social Links`,items:t.social||[],onChange:e=>n({...t,social:e}),fields:[{key:`platform`,label:`Platform`},{key:`url`,label:`URL`}]}),(0,M.jsx)(U,{label:`Legal Links`,items:t.legal||[],onChange:e=>n({...t,legal:e}),fields:[{key:`label`,label:`Label`},{key:`href`,label:`Link`}]})]});default:return null}}function le(){let[e,t]=(0,A.useState)(``),[n,r]=(0,A.useState)(``),[i,a]=(0,A.useState)(``);return(0,M.jsxs)(`div`,{className:`admin-card settings-card`,children:[(0,M.jsx)(`h1`,{children:`Settings`}),(0,M.jsx)(`p`,{className:`subtitle`,children:`Update your admin password. Use at least 6 characters.`}),(0,M.jsxs)(`form`,{onSubmit:async i=>{i.preventDefault();try{await B.changePassword(e,n),a(`Password updated successfully`),t(``),r(``)}catch(e){a(e.message)}},children:[(0,M.jsx)(H,{label:`Current Password`,value:e,onChange:t,type:`password`}),(0,M.jsx)(H,{label:`New Password`,value:n,onChange:r,type:`password`}),i&&(0,M.jsx)(`p`,{className:i.includes(`success`)?`msg-success`:`msg-error`,children:i}),(0,M.jsx)(`button`,{type:`submit`,className:`btn-primary`,style:{marginTop:`0.5rem`},children:`Update Password`})]})]})}function ue(e){return e?new Date(e).toLocaleString(`en-IN`,{day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`}function de(){let[e,t]=(0,A.useState)(!1),[r,i]=(0,A.useState)(!0),[a,o]=(0,A.useState)(`dashboard`),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)(!1),[m,g]=(0,A.useState)(``),[_,v]=(0,A.useState)(null),[y,b]=(0,A.useState)(!1),[x,C]=(0,A.useState)({message:``,type:``}),[w,E]=(0,A.useState)(!1),[D,O]=(0,A.useState)(null),k=(e,t)=>{C({message:e,type:t}),setTimeout(()=>C({message:``,type:``}),3500)},j=e=>{if(o(e),E(!1),e===`dashboard`||e===`settings`){v(null);return}u&&v(Y(u,e))};(0,A.useEffect)(()=>{let e=()=>{window.innerWidth>900&&E(!1)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,A.useEffect)(()=>{if(!I()){i(!1);return}B.me().then(()=>{t(!0),i(!1)}).catch(()=>{L(),i(!1)})},[]),(0,A.useEffect)(()=>{if(!e)return;let t=document.createElement(`link`);t.rel=`prefetch`,t.href=`${X}preview.html`,document.head.appendChild(t),p(!0),g(``),B.getContent().then(e=>{let{_updatedAt:t,...n}=e;d(n),O(t)}).catch(e=>{console.warn(`Admin content API failed, using seed fallback:`,e.message),d(c),g(`Could not reach the API. Showing default content — start the server with npm run dev.`)}).finally(()=>p(!1))},[e]),(0,A.useEffect)(()=>{!u||a===`dashboard`||a===`settings`||v(Y(u,a))},[u,a]);let N=async()=>{b(!0);try{a===`hero`?(await B.updateSection(`hero`,_.hero),await B.updateSection(`metrics`,_.metrics)):a===`about`?(await B.updateSection(`about`,_.about),await B.updateSection(`partners`,_.partners)):await B.updateSection(a,_);let{_updatedAt:e,...t}=await B.getContent();d(t),O(e),k(`Changes saved successfully`,`success`)}catch(e){k(e.message,`error`)}finally{b(!1)}};if(r)return(0,M.jsxs)(`div`,{className:`admin-loading`,children:[(0,M.jsx)(`div`,{className:`admin-spinner`}),(0,M.jsx)(`span`,{children:`Loading admin panel...`})]});if(!e)return(0,M.jsx)(oe,{onLogin:()=>t(!0)});let P=Q.find(e=>e.id===a),F=a!==`dashboard`&&a!==`settings`;return(0,M.jsxs)(`div`,{className:`admin-layout`,children:[(0,M.jsx)(`button`,{type:`button`,className:`admin-mobile-toggle`,"aria-label":`Toggle menu`,onClick:()=>E(e=>!e),children:w?(0,M.jsx)(l,{size:20}):(0,M.jsx)(s,{size:20})}),(0,M.jsx)(`div`,{className:`admin-sidebar-overlay ${w?`visible`:``}`,onClick:()=>E(!1)}),(0,M.jsxs)(`aside`,{className:`admin-sidebar ${w?`open`:``}`,children:[(0,M.jsxs)(`div`,{className:`admin-sidebar-brand`,children:[(0,M.jsx)(`img`,{src:`${X}assets/cavin_logo.svg`,alt:`Cavin Infotech`}),(0,M.jsx)(`h2`,{children:`Content Manager`}),(0,M.jsx)(`p`,{children:`Cavin Infotech Website`})]}),(0,M.jsx)(`nav`,{className:`admin-nav`,children:Z.map(e=>(0,M.jsxs)(`div`,{className:`admin-nav-group`,children:[(0,M.jsx)(`div`,{className:`admin-nav-group-label`,children:e.label}),e.items.map(({id:e,label:t,icon:n})=>(0,M.jsxs)(`button`,{type:`button`,className:a===e?`active`:``,onClick:()=>j(e),children:[(0,M.jsx)(n,{size:17}),t]},e))]},e.label))}),(0,M.jsx)(`div`,{className:`admin-sidebar-footer`,children:(0,M.jsxs)(`button`,{type:`button`,className:`logout-btn`,onClick:()=>{L(),t(!1)},children:[(0,M.jsx)(S,{size:15}),`Sign out`]})})]}),(0,M.jsxs)(`div`,{className:`admin-main-wrap`,children:[(0,M.jsxs)(`header`,{className:`admin-topbar`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h1`,{className:`admin-topbar-title`,children:P?.label||`Admin`}),(0,M.jsx)(`p`,{className:`admin-topbar-sub`,children:re[a]})]}),(0,M.jsxs)(`div`,{className:`admin-topbar-actions`,children:[(0,M.jsxs)(`a`,{href:X,target:`_blank`,rel:`noopener noreferrer`,className:`btn-ghost`,children:[(0,M.jsx)(h,{size:14}),`View site`]}),F&&(0,M.jsxs)(`button`,{type:`button`,className:`btn-primary`,onClick:N,disabled:y,children:[(0,M.jsx)(T,{size:15}),y?`Saving...`:`Save changes`]})]})]}),(0,M.jsx)(`main`,{className:`admin-main`,children:a===`dashboard`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`dashboard-welcome`,children:[(0,M.jsx)(`h2`,{children:`Welcome to your CMS`}),(0,M.jsx)(`p`,{children:`Edit any section below. All changes are saved to the database and appear on the live website immediately.`}),(0,M.jsx)(`div`,{className:`dashboard-meta`,children:(0,M.jsxs)(`span`,{className:`dashboard-meta-item`,children:[(0,M.jsx)(n,{size:13}),`Last updated: `,ue(D)]})})]}),(0,M.jsx)(`div`,{className:`dashboard-grid`,children:Q.filter(e=>e.id!==`dashboard`).map(({id:e,label:t,icon:n,desc:r})=>(0,M.jsxs)(`button`,{type:`button`,className:`dashboard-tile`,onClick:()=>j(e),children:[(0,M.jsx)(`div`,{className:`dashboard-tile-icon`,children:(0,M.jsx)(n,{size:20})}),(0,M.jsx)(`h3`,{children:t}),(0,M.jsx)(`p`,{children:r})]},e))})]}):a===`settings`?(0,M.jsx)(le,{}):(0,M.jsx)(se,{children:(0,M.jsxs)(`div`,{className:`admin-editor-layout`,children:[(0,M.jsxs)(`div`,{className:`admin-editor-form admin-card`,children:[f||!_?(0,M.jsx)($,{loading:f,error:m}):(0,M.jsx)(ce,{section:a,data:_,onChange:v},a),(0,M.jsxs)(`div`,{className:`save-bar`,children:[(0,M.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>j(`dashboard`),children:`Cancel`}),(0,M.jsxs)(`button`,{type:`button`,className:`btn-primary`,onClick:N,disabled:y||!_,children:[(0,M.jsx)(T,{size:15}),y?`Saving...`:`Save changes`]})]})]}),!f&&u&&_&&(0,M.jsx)(ne,{section:a,label:P?.label||`Section`,content:u,sectionData:_})]})})})]}),(0,M.jsx)(ie,{...x})]})}(0,j.createRoot)(document.getElementById(`root`)).render((0,M.jsx)(A.StrictMode,{children:(0,M.jsx)(de,{})}));