Files
citpl_cms_react_express_pos…/dist/assets/admin-D28kGkNT.js
T
sandhiya-hepl bc4c4f22ca path correction
2026-07-20 12:58:36 +05:30

1 line
29 KiB
JavaScript

import{a as e,c as t,d as n,f as r,g as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./x-gyvy4NrT.js";var f=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`}]]),p=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`}]]),m=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`}]]),h=e(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),g=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`}]]),_=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`}]]),v=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`}]]),y=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`}]]),b=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`}]]),x=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`}]]),S=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`}]]),C=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`}]]),w=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`}]]),T=e(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),E=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`}]]),D=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`}]]),O=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`}]]),k=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`}]]),A=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`}]]),j=i(r(),1),M=n(),N=t(),P=`admin`,F=`admin123`,I=`static-admin-session`;function L(){return localStorage.getItem(`admin_token`)}function ee(e){localStorage.setItem(`admin_token`,e)}function R(){localStorage.removeItem(`admin_token`)}function te(e=L()){return e===I}function ne(e,t){if(e===P&&t===F)return{token:I,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=L();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`${c}${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 ne(e,t)}},me:async()=>te()?{username:P,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,j.useState)(!1);return(0,N.jsxs)(`div`,{className:`form-field`,children:[(0,N.jsx)(`label`,{className:`form-label`,children:n}),e&&(0,N.jsx)(`div`,{className:`form-preview`,children:e.match(/\.(mp4|webm)$/i)?(0,N.jsx)(`video`,{src:o(e),controls:!0}):(0,N.jsx)(`img`,{src:o(e),alt:``})}),(0,N.jsx)(`input`,{type:`text`,className:`form-input`,value:e||``,onChange:e=>t(e.target.value),placeholder:`Paste URL or upload a file below`}),(0,N.jsxs)(`label`,{className:`form-upload-btn`,children:[(0,N.jsx)(A,{size:14}),r?`Uploading...`:`Choose file`,(0,N.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,N.jsxs)(`div`,{className:`form-field`,children:[(0,N.jsx)(`label`,{className:`form-label`,children:e}),r?(0,N.jsx)(`textarea`,{className:`form-textarea`,value:t||``,onChange:e=>n(e.target.value),rows:4}):(0,N.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,N.jsxs)(`div`,{className:`array-section`,children:[(0,N.jsxs)(`div`,{className:`array-header`,children:[(0,N.jsx)(`h4`,{className:`array-title`,children:e}),(0,N.jsxs)(`button`,{type:`button`,onClick:a,className:`array-add-btn`,children:[(0,N.jsx)(T,{size:14}),` Add item`]})]}),t.length===0&&(0,N.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,N.jsxs)(`div`,{className:`array-item`,children:[(0,N.jsxs)(`div`,{className:`array-item-header`,children:[(0,N.jsxs)(`span`,{className:`array-item-badge`,children:[`Item `,t+1]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(t),className:`array-remove-btn`,children:[(0,N.jsx)(k,{size:12}),` Remove`]})]}),r.map(n=>n.type===`image`?(0,N.jsx)(V,{label:n.label,value:e[n.key],onChange:e=>i(t,n.key,e)},n.key):(0,N.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 re({section:e,label:t,content:n,sectionData:r}){let i=(0,j.useRef)(null),a=(0,j.useRef)(null),o=(0,j.useRef)({}),s=(0,j.useRef)(null),c=W[e]||`home`,[l,u]=(0,j.useState)(.45),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),[h,v]=(0,j.useState)(!1);o.current={content:n,sectionData:r,section:e,anchor:c},(0,j.useEffect)(()=>{let e=window.setTimeout(()=>v(!0),50);return()=>window.clearTimeout(e)},[]),(0,j.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,j.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,j.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,j.useEffect)(()=>{d&&y(!0)},[d,e,c,d,y]),(0,j.useEffect)(()=>{if(d)return y(!1),()=>window.clearTimeout(s.current)},[n,r,d,y]);let b=()=>{f(!0),y(!0)},x=!h||!d||!p;return(0,N.jsxs)(`aside`,{className:`admin-preview-panel`,children:[(0,N.jsxs)(`div`,{className:`admin-preview-panel-header`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`span`,{className:`admin-preview-eyebrow`,children:[(0,N.jsx)(_,{size:14}),`Live preview`]}),(0,N.jsx)(`h3`,{children:t})]}),(0,N.jsxs)(`a`,{href:`/citpl_website/#${c}`,target:`_blank`,rel:`noopener noreferrer`,className:`admin-preview-open`,children:[(0,N.jsx)(g,{size:13}),`Open`]})]}),(0,N.jsxs)(`div`,{className:`admin-preview-shell`,children:[(0,N.jsxs)(`div`,{className:`admin-preview-chrome`,children:[(0,N.jsx)(`span`,{className:`admin-preview-dot`}),(0,N.jsx)(`span`,{className:`admin-preview-dot`}),(0,N.jsx)(`span`,{className:`admin-preview-dot`}),(0,N.jsxs)(`span`,{className:`admin-preview-url`,children:[`/`,c]})]}),(0,N.jsxs)(`div`,{className:`admin-preview-viewport`,ref:i,style:{height:J*l},children:[x&&(0,N.jsxs)(`div`,{className:`admin-preview-loading`,children:[(0,N.jsx)(`div`,{className:`admin-spinner`}),(0,N.jsx)(`span`,{children:`Loading preview…`})]}),h&&(0,N.jsx)(`div`,{className:`admin-preview-stage`,style:{width:q*l,height:J*l,opacity:+!x},children:(0,N.jsx)(`iframe`,{ref:a,src:K,title:`${t} preview`,className:`admin-preview-iframe`,onLoad:b,style:{width:q,height:J,transform:`scale(${l})`}})})]})]}),(0,N.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:b,desc:`Overview and quick access to all sections`}]},{label:`Page Content`,items:[{id:`hero`,label:`Hero & Metrics`,icon:s,desc:`Homepage headline, video, and statistics`},{id:`about`,label:`About & Partners`,icon:p,desc:`About section and partner logos`},{id:`certifications`,label:`Certifications`,icon:f,desc:`Certification badges and headings`},{id:`services`,label:`Services`,icon:x,desc:`Service cards and section copy`},{id:`whyUs`,label:`Why Us`,icon:O,desc:`Value propositions and images`},{id:`gallery`,label:`Gallery`,icon:y,desc:`Featured case studies and gallery items`},{id:`products`,label:`Products`,icon:w,desc:`Product suite cards and stats`},{id:`insights`,label:`Insights`,icon:v,desc:`Blog and insight carousel items`},{id:`footer`,label:`Footer & Links`,icon:S,desc:`CTA, social links, and footer navigation`}]},{label:`Account`,items:[{id:`settings`,label:`Settings`,icon:D,desc:`Password and account preferences`}]}],Q=Z.flatMap(e=>e.items),ie=Object.fromEntries(Q.map(e=>[e.id,e.desc]));function ae({message:e,type:t}){return e?(0,N.jsxs)(`div`,{className:`toast ${t}`,children:[t===`success`?(0,N.jsx)(h,{size:18}):(0,N.jsx)(m,{size:18}),e]}):null}function oe(){let e=(0,j.useRef)(null),t=(0,j.useRef)(null),[n,r]=(0,j.useState)(.5),[i,a]=(0,j.useState)(!1),o=1280,s=`${X}preview.html`;return(0,j.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,j.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,N.jsxs)(`div`,{className:`login-preview`,children:[(0,N.jsxs)(`div`,{className:`login-preview-intro`,children:[(0,N.jsx)(`img`,{src:`${X}assets/cavin_logo.svg`,alt:`Cavin Infotech`}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`h1`,{children:[`Content `,(0,N.jsx)(`span`,{children:`Manager`})]}),(0,N.jsx)(`p`,{children:`Preview the live website before you sign in. Edits publish instantly after login.`})]}),(0,N.jsxs)(`a`,{href:X,target:`_blank`,rel:`noopener noreferrer`,className:`login-preview-link`,children:[(0,N.jsx)(g,{size:14}),`Open full site`]})]}),(0,N.jsxs)(`div`,{className:`login-preview-shell`,children:[(0,N.jsxs)(`div`,{className:`login-preview-chrome`,children:[(0,N.jsx)(`span`,{className:`login-preview-dot`}),(0,N.jsx)(`span`,{className:`login-preview-dot`}),(0,N.jsx)(`span`,{className:`login-preview-dot`}),(0,N.jsx)(`span`,{className:`login-preview-url`,children:`cavininfotech.com`})]}),(0,N.jsx)(`div`,{className:`login-preview-viewport`,ref:e,style:{height:800*n},children:i?(0,N.jsxs)(`div`,{className:`login-preview-fallback`,children:[(0,N.jsx)(`p`,{children:`Inline preview is blocked by the server's frame policy.`}),(0,N.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`login-preview-link`,children:[(0,N.jsx)(g,{size:14}),`Open preview`]})]}):(0,N.jsx)(`div`,{className:`login-preview-stage`,style:{width:o*n,height:800*n},children:(0,N.jsx)(`iframe`,{ref:t,src:s,title:`Website preview`,className:`login-preview-iframe`,style:{width:o,height:800,transform:`scale(${n})`}})})})]})]})}function se({onLogin:e}){let[t,n]=(0,j.useState)(`admin`),[r,i]=(0,j.useState)(`admin123`),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(!1);return(0,N.jsxs)(`div`,{className:`login-page`,children:[(0,N.jsx)(oe,{}),(0,N.jsx)(`div`,{className:`login-form-side`,children:(0,N.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,N.jsx)(`h2`,{children:`Welcome back`}),(0,N.jsx)(`p`,{className:`login-subtitle`,children:`Sign in to your admin account`}),a&&(0,N.jsxs)(`div`,{className:`login-error`,children:[(0,N.jsx)(m,{size:16}),a]}),(0,N.jsx)(H,{label:`Username`,value:t,onChange:n}),(0,N.jsx)(H,{label:`Password`,value:r,onChange:i,type:`password`}),(0,N.jsx)(`button`,{type:`submit`,className:`btn-primary`,disabled:s,children:s?`Signing in...`:`Sign in`})]})})]})}function $({loading:e,error:t}){return(0,N.jsx)(`div`,{className:`admin-editor-placeholder`,children:e?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`admin-spinner`}),(0,N.jsx)(`p`,{children:`Loading section content...`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(m,{size:22}),(0,N.jsx)(`p`,{children:t||`Unable to load this section.`})]})})}var ce=class extends j.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}render(){return this.state.error?(0,N.jsxs)(`div`,{className:`admin-card admin-editor-placeholder`,children:[(0,N.jsx)(m,{size:22}),(0,N.jsx)(`p`,{children:`Something went wrong loading this section.`}),(0,N.jsx)(`p`,{style:{fontSize:`0.8rem`,color:`#94a3b8`},children:this.state.error.message}),(0,N.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>this.setState({error:null}),children:`Try again`})]}):this.props.children}};function le({section:e,data:t,onChange:n}){if(!t)return(0,N.jsx)($,{loading:!1,error:`No content found for this section.`});switch(e){case`hero`:return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(V,{label:`Hero Video`,value:t.hero?.video,onChange:e=>n({...t,hero:{...t.hero,video:e}})}),(0,N.jsx)(H,{label:`Badge Text`,value:t.hero?.badge,onChange:e=>n({...t,hero:{...t.hero,badge:e}})}),(0,N.jsx)(H,{label:`Headline`,value:t.hero?.headline,onChange:e=>n({...t,hero:{...t.hero,headline:e}})}),(0,N.jsx)(H,{label:`Subheadline`,value:t.hero?.subheadline,onChange:e=>n({...t,hero:{...t.hero,subheadline:e}})}),(0,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`About Heading`,value:t.about?.heading,onChange:e=>n({about:{...t.about,heading:e},partners:t.partners})}),(0,N.jsx)(V,{label:`Badge Image`,value:t.about?.badgeImage,onChange:e=>n({about:{...t.about,badgeImage:e},partners:t.partners})}),(0,N.jsx)(H,{label:`Badge Alt Text`,value:t.about?.badgeAlt,onChange:e=>n({about:{...t.about,badgeAlt:e},partners:t.partners})}),(0,N.jsx)(V,{label:`Background Image`,value:t.about?.backgroundImage,onChange:e=>n({about:{...t.about,backgroundImage:e},partners:t.partners})}),(0,N.jsx)(H,{label:`Partners Heading`,value:t.partners?.heading,onChange:e=>n({about:t.about,partners:{...t.partners,heading:e}})}),(0,N.jsx)(H,{label:`Partners Subheading`,value:t.partners?.subheading,onChange:e=>n({about:t.about,partners:{...t.partners,subheading:e}})}),(0,N.jsx)(H,{label:`Partners Body`,value:t.partners?.body,onChange:e=>n({about:t.about,partners:{...t.partners,body:e}}),multiline:!0}),(0,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`Section Heading`,value:t.heading,onChange:e=>n({...t,heading:e})}),(0,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,N.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,N.jsx)(H,{label:`Intro`,value:t.intro,onChange:e=>n({...t,intro:e}),multiline:!0}),(0,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,N.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,N.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,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,N.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,N.jsx)(H,{label:`Subtitle`,value:t.subtitle,onChange:e=>n({...t,subtitle:e}),multiline:!0}),(0,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`Eyebrow`,value:t.eyebrow,onChange:e=>n({...t,eyebrow:e})}),(0,N.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,N.jsx)(H,{label:`Subtitle`,value:t.subtitle,onChange:e=>n({...t,subtitle:e}),multiline:!0}),(0,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`Title`,value:t.title,onChange:e=>n({...t,title:e})}),(0,N.jsx)(H,{label:`Subtitle`,value:t.subtitle,onChange:e=>n({...t,subtitle:e}),multiline:!0}),(0,N.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,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(H,{label:`CTA Headline`,value:t.cta?.headline,onChange:e=>n({...t,cta:{...t.cta,headline:e}})}),(0,N.jsx)(H,{label:`CTA Body`,value:t.cta?.body,onChange:e=>n({...t,cta:{...t.cta,body:e}}),multiline:!0}),(0,N.jsx)(V,{label:`CTA Image`,value:t.cta?.image,onChange:e=>n({...t,cta:{...t.cta,image:e}})}),(0,N.jsx)(H,{label:`Primary Button`,value:t.cta?.primaryButton,onChange:e=>n({...t,cta:{...t.cta,primaryButton:e}})}),(0,N.jsx)(H,{label:`Secondary Button`,value:t.cta?.secondaryButton,onChange:e=>n({...t,cta:{...t.cta,secondaryButton:e}})}),(0,N.jsx)(U,{label:`Quick Links`,items:t.quickLinks||[],onChange:e=>n({...t,quickLinks:e}),fields:[{key:`label`,label:`Label`},{key:`href`,label:`Link`}]}),(0,N.jsx)(U,{label:`Product Links`,items:t.productLinks||[],onChange:e=>n({...t,productLinks:e}),fields:[{key:`label`,label:`Label`},{key:`href`,label:`Link`}]}),(0,N.jsx)(U,{label:`Social Links`,items:t.social||[],onChange:e=>n({...t,social:e}),fields:[{key:`platform`,label:`Platform`},{key:`url`,label:`URL`}]}),(0,N.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 ue(){let[e,t]=(0,j.useState)(``),[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(``);return(0,N.jsxs)(`div`,{className:`admin-card settings-card`,children:[(0,N.jsx)(`h1`,{children:`Settings`}),(0,N.jsx)(`p`,{className:`subtitle`,children:`Update your admin password. Use at least 6 characters.`}),(0,N.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,N.jsx)(H,{label:`Current Password`,value:e,onChange:t,type:`password`}),(0,N.jsx)(H,{label:`New Password`,value:n,onChange:r,type:`password`}),i&&(0,N.jsx)(`p`,{className:i.includes(`success`)?`msg-success`:`msg-error`,children:i}),(0,N.jsx)(`button`,{type:`submit`,className:`btn-primary`,style:{marginTop:`0.5rem`},children:`Update Password`})]})]})}function de(e){return e?new Date(e).toLocaleString(`en-IN`,{day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`}):``}function fe(){let[e,t]=(0,j.useState)(!1),[n,r]=(0,j.useState)(!0),[i,o]=(0,j.useState)(`dashboard`),[s,c]=(0,j.useState)(null),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(``),[_,v]=(0,j.useState)(null),[y,b]=(0,j.useState)(!1),[x,S]=(0,j.useState)({message:``,type:``}),[w,T]=(0,j.useState)(!1),[D,O]=(0,j.useState)(null),k=(e,t)=>{S({message:e,type:t}),setTimeout(()=>S({message:``,type:``}),3500)},A=e=>{if(o(e),T(!1),e===`dashboard`||e===`settings`){v(null);return}s&&v(Y(s,e))};(0,j.useEffect)(()=>{let e=()=>{window.innerWidth>900&&T(!1)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,j.useEffect)(()=>{if(!L()){r(!1);return}B.me().then(()=>{t(!0),r(!1)}).catch(()=>{R(),r(!1)})},[]),(0,j.useEffect)(()=>{if(!e)return;let t=document.createElement(`link`);t.rel=`prefetch`,t.href=`${X}preview.html`,document.head.appendChild(t),p(!0),h(``),B.getContent().then(e=>{let{_updatedAt:t,...n}=e;c(n),O(t)}).catch(e=>{console.warn(`Admin content API failed, using seed fallback:`,e.message),c(u),h(`Could not reach the API. Showing default content — start the server with npm run dev.`)}).finally(()=>p(!1))},[e]),(0,j.useEffect)(()=>{!s||i===`dashboard`||i===`settings`||v(Y(s,i))},[s,i]);let M=async()=>{b(!0);try{i===`hero`?(await B.updateSection(`hero`,_.hero),await B.updateSection(`metrics`,_.metrics)):i===`about`?(await B.updateSection(`about`,_.about),await B.updateSection(`partners`,_.partners)):await B.updateSection(i,_);let{_updatedAt:e,...t}=await B.getContent();c(t),O(e),k(`Changes saved successfully`,`success`)}catch(e){k(e.message,`error`)}finally{b(!1)}};if(n)return(0,N.jsxs)(`div`,{className:`admin-loading`,children:[(0,N.jsx)(`div`,{className:`admin-spinner`}),(0,N.jsx)(`span`,{children:`Loading admin panel...`})]});if(!e)return(0,N.jsx)(se,{onLogin:()=>t(!0)});let P=Q.find(e=>e.id===i),F=i!==`dashboard`&&i!==`settings`;return(0,N.jsxs)(`div`,{className:`admin-layout`,children:[(0,N.jsx)(`button`,{type:`button`,className:`admin-mobile-toggle`,"aria-label":`Toggle menu`,onClick:()=>T(e=>!e),children:w?(0,N.jsx)(d,{size:20}):(0,N.jsx)(l,{size:20})}),(0,N.jsx)(`div`,{className:`admin-sidebar-overlay ${w?`visible`:``}`,onClick:()=>T(!1)}),(0,N.jsxs)(`aside`,{className:`admin-sidebar ${w?`open`:``}`,children:[(0,N.jsxs)(`div`,{className:`admin-sidebar-brand`,children:[(0,N.jsx)(`img`,{src:`${X}assets/cavin_logo.svg`,alt:`Cavin Infotech`}),(0,N.jsx)(`h2`,{children:`Content Manager`}),(0,N.jsx)(`p`,{children:`Cavin Infotech Website`})]}),(0,N.jsx)(`nav`,{className:`admin-nav`,children:Z.map(e=>(0,N.jsxs)(`div`,{className:`admin-nav-group`,children:[(0,N.jsx)(`div`,{className:`admin-nav-group-label`,children:e.label}),e.items.map(({id:e,label:t,icon:n})=>(0,N.jsxs)(`button`,{type:`button`,className:i===e?`active`:``,onClick:()=>A(e),children:[(0,N.jsx)(n,{size:17}),t]},e))]},e.label))}),(0,N.jsx)(`div`,{className:`admin-sidebar-footer`,children:(0,N.jsxs)(`button`,{type:`button`,className:`logout-btn`,onClick:()=>{R(),t(!1)},children:[(0,N.jsx)(C,{size:15}),`Sign out`]})})]}),(0,N.jsxs)(`div`,{className:`admin-main-wrap`,children:[(0,N.jsxs)(`header`,{className:`admin-topbar`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`admin-topbar-title`,children:P?.label||`Admin`}),(0,N.jsx)(`p`,{className:`admin-topbar-sub`,children:ie[i]})]}),(0,N.jsxs)(`div`,{className:`admin-topbar-actions`,children:[(0,N.jsxs)(`a`,{href:X,target:`_blank`,rel:`noopener noreferrer`,className:`btn-ghost`,children:[(0,N.jsx)(g,{size:14}),`View site`]}),F&&(0,N.jsxs)(`button`,{type:`button`,className:`btn-primary`,onClick:M,disabled:y,children:[(0,N.jsx)(E,{size:15}),y?`Saving...`:`Save changes`]})]})]}),(0,N.jsx)(`main`,{className:`admin-main`,children:i===`dashboard`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`dashboard-welcome`,children:[(0,N.jsx)(`h2`,{children:`Welcome to your CMS`}),(0,N.jsx)(`p`,{children:`Edit any section below. All changes are saved to the database and appear on the live website immediately.`}),(0,N.jsx)(`div`,{className:`dashboard-meta`,children:(0,N.jsxs)(`span`,{className:`dashboard-meta-item`,children:[(0,N.jsx)(a,{size:13}),`Last updated: `,de(D)]})})]}),(0,N.jsx)(`div`,{className:`dashboard-grid`,children:Q.filter(e=>e.id!==`dashboard`).map(({id:e,label:t,icon:n,desc:r})=>(0,N.jsxs)(`button`,{type:`button`,className:`dashboard-tile`,onClick:()=>A(e),children:[(0,N.jsx)(`div`,{className:`dashboard-tile-icon`,children:(0,N.jsx)(n,{size:20})}),(0,N.jsx)(`h3`,{children:t}),(0,N.jsx)(`p`,{children:r})]},e))})]}):i===`settings`?(0,N.jsx)(ue,{}):(0,N.jsx)(ce,{children:(0,N.jsxs)(`div`,{className:`admin-editor-layout`,children:[(0,N.jsxs)(`div`,{className:`admin-editor-form admin-card`,children:[f||!_?(0,N.jsx)($,{loading:f,error:m}):(0,N.jsx)(le,{section:i,data:_,onChange:v},i),(0,N.jsxs)(`div`,{className:`save-bar`,children:[(0,N.jsx)(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>A(`dashboard`),children:`Cancel`}),(0,N.jsxs)(`button`,{type:`button`,className:`btn-primary`,onClick:M,disabled:y||!_,children:[(0,N.jsx)(E,{size:15}),y?`Saving...`:`Save changes`]})]})]}),!f&&s&&_&&(0,N.jsx)(re,{section:i,label:P?.label||`Section`,content:s,sectionData:_})]})})})]}),(0,N.jsx)(ae,{...x})]})}(0,M.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(j.StrictMode,{children:(0,N.jsx)(fe,{})}));