import{r as t,d as n,t as o,j as e,H as g,cj as f,as as j,f as c,cf as u}from"./vendor-laZsiqLO.js";import{A as C}from"./AdminLayout-Cg-VwQ1I.js";import{S as y}from"./SettingsLayout-nVJO7Ep3.js";import{C as b,a as N,b as v,c as S,d as k}from"./card-BKDXjfy_.js";import{B as _}from"./button-B8f8jW4H.js";import{L as l}from"./label-BDbCc0wv.js";import{T as m}from"./textarea-B6YN8A27.js";import"./utils-RgT4yCq8.js";import"./admin-D0dR58a0.js";import"./bootstrap-CBwglqL9.js";/* empty css            */import"./dropdown-menu-CpMN0BZ0.js";import"./sheet-Cp4V1hdh.js";import"./avatar-1RNhlzAH.js";import"./useFlashMessages-CQoLOBuv.js";import"./separator-DMopkgTA.js";function q(){const[x,h]=t.useState(!0),[i,d]=t.useState(!1),[s,r]=t.useState({header_code:"",footer_code:""});t.useEffect(()=>{n.get("/api/admin/settings/code-injection").then(a=>{r({header_code:a.data.header_code||"",footer_code:a.data.footer_code||""})}).catch(()=>o.error("Failed to load settings.")).finally(()=>h(!1))},[]);const p=async()=>{d(!0);try{await n.post("/api/admin/settings/code-injection",s),o.success("Code injection settings updated.")}catch{o.error("Failed to save settings.")}finally{d(!1)}};return e.jsxs(C,{header:"Settings",children:[e.jsx(g,{title:"Code Injection"}),e.jsx(y,{children:e.jsxs(b,{className:"border-orange-200 dark:border-orange-900",children:[e.jsxs(N,{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(f,{className:"w-5 h-5 text-orange-600"})," Header & Footer Code"]}),e.jsx(S,{children:"Inject custom scripts (Analytics, Chat widgets, Pixel) globally."})]}),e.jsxs(k,{className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"bg-orange-50 dark:bg-orange-950/20 p-4 rounded-md border border-orange-100 dark:border-orange-900/50 flex gap-3 text-sm text-orange-800 dark:text-orange-200",children:[e.jsx(j,{className:"w-5 h-5 shrink-0"}),e.jsxs("p",{children:[e.jsx("strong",{children:"Warning:"})," Invalid HTML or JavaScript here can break your site layout or functionality. Please double-check your code before saving."]})]}),x?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(c,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(l,{className:"text-base",children:"Header Code (Inside <head>)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Suitable for verification tags, CSS styles, and critical scripts."}),e.jsx(m,{value:s.header_code,onChange:a=>r({...s,header_code:a.target.value}),className:"font-mono text-xs h-48 resize-y bg-muted/50",placeholder:"<script>...<\/script>",spellCheck:!1})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(l,{className:"text-base",children:"Footer Code (Before </body>)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Best for Analytics, Chat widgets, and non-blocking JS."}),e.jsx(m,{value:s.footer_code,onChange:a=>r({...s,footer_code:a.target.value}),className:"font-mono text-xs h-48 resize-y bg-muted/50",placeholder:"<script>...<\/script>",spellCheck:!1})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(_,{onClick:p,disabled:i,className:"min-w-[150px]",children:[i?e.jsx(c,{className:"me-2 h-4 w-4 animate-spin"}):e.jsx(u,{className:"me-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{q as default};
