1import{j as e}from"./app-Bn8axf2m.js";import{r as y,H as A,L as F,u as E}from"./vendor-D8BamyIx.js";import{A as T}from"./AppLayout-DDnh82Xe.js";import{I as z}from"./InputError-9fJul_yf.js";import{B as C}from"./button-BJHJ0j8Y.js";import{C as L,b as I,c as O,d as B,a as D}from"./card-D0Qy6Ld2.js";import{C as H}from"./checkbox-BwmQmhgX.js";import{I as N}from"./input-Jv8uXHpu.js";import{L as S}from"./label-Cg1Qz0vJ.js";import{T as U}from"./textarea-BtuvhiLj.js";import{c as R}from"./utils-DCADjnpI.js";import{A as _}from"./arrow-up-right-DnhfkpfU.js";import{S as $}from"./save-70nsVxIW.js";import{C as q}from"./check-s0EwGkyq.js";/* empty css */import"./AppLogo-DcmacEfU.js";import"./createLucideIcon-CsuOtgaI.js";import"./UserAvatar-xayue2JR.js";import"./index-BYAuPZuj.js";import"./index-CPzEHnIt.js";import"./index-xw87Tvjh.js";import"./dropdown-menu-CW2iYoX1.js";import"./index-DFaUj89F.js";import"./index-DFcVNo6o.js";import"./file-text-DaylnC7C.js";import"./globe-CJdHktb2.js";import"./gauge-CJYVPv0v.js";import"./sparkles-B8Vum2j7.js";import"./shield-check-DX9si8b9.js";import"./FlashMessages-VEWLDp2I.js";import"./info-rA2aT-3L.js";import"./triangle-alert-P9Ytexve.js";import"./circle-check-PhDoMN55.js";import"./x-CrTk-_Ms.js";function G({id:t,value:l,images:d,disabled:i,onChange:o}){const[s,a]=y.useState(!1),[r,c]=y.useState(null),[p,g]=y.useState([]),j=[...p,...d.filter(n=>!p.some(u=>u.id===n.id))],m=j.find(n=>n.id===Number(l)),x=async n=>{a(!0),c(null);try{const u=new FormData;u.append("files[]",n);const w=document.querySelector('meta[name="csrf-token"]')?.content??"",v=await fetch("/api/media/upload",{method:"POST",body:u,headers:{"X-CSRF-TOKEN":w,Accept:"application/json"}}),f=await v.json();if(!v.ok){const h=f?.errors?Object.values(f.errors)[0]:null;c((Array.isArray(h)?h[0]:null)??f?.message??"The upload failed.");return}const b=f?.data?.[0];if(b){const h={id:b.id,name:b.name??n.name,url:b.url};g(k=>[h,...k]),o(h.id)}}catch{c("The upload could not be sent. Check your connection and try again.")}finally{a(!1)}};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("select",{id:t,value:String(l??""),disabled:i,onChange:n=>o(n.target.value===""?null:Number(n.target.value)),className:"border-input bg-background h-9 flex-1 rounded-md border px-3 text-sm",children:[e.jsx("option",{value:"",children:"None â use the site name as type"}),j.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]}),m?e.jsx("img",{src:m.url,alt:"",className:"h-9 w-auto max-w-24 rounded border bg-white object-contain p-0.5"}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp,image/avif,image/gif",disabled:i||s,onChange:n=>{const u=n.target.files?.[0];u&&x(u),n.target.value=""},className:"text-muted-foreground file:bg-secondary file:text-secondary-foreground w-full text-xs file:mr-3 file:rounded-md file:border-0 file:px-3 file:py-1.5 file:text-xs file:font-medium"}),s&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Uploadingâ¦"}),l?e.jsx(C,{type:"button",variant:"ghost",size:"sm",disabled:i,onClick:()=>o(null),children:"Clear"}):null]}),r&&e.jsx("p",{className:"text-destructive text-xs",children:r})]})}function ke({groups:t,definitions:l,values:d,images:i,canEdit:o}){const s=Object.entries(t),[a,r]=y.useState(s[0]?.[0]??"");return e.jsxs(T,{title:"Settings",description:"How the public site presents itself. Nothing here affects how the application runs.",children:[e.jsx(A,{title:"Settings"}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[13rem_minmax(0,1fr)]",children:[e.jsxs("nav",{className:"space-y-1","aria-label":"Setting groups",children:[s.map(([c,p])=>e.jsx("button",{type:"button",onClick:()=>r(c),"aria-current":a===c?"true":void 0,className:R("w-full rounded-md px-3 py-2 text-left text-sm transition-colors",a===c?"bg-accent text-accent-foreground font-medium":"text-muted-foreground hover:bg-accent/60"),children:p.label},c)),e.jsxs(F,{href:"/admin/settings/email",className:"text-muted-foreground hover:bg-accent/60 mt-2 flex items-center justify-between rounded-md border border-dashed px-3 py-2 text-sm transition-colors",children:["Email delivery",e.jsx(_,{className:"size-3.5"})]})]}),s.map(([c,p])=>a===c&&e.jsx(K,{group:p,definitions:l.filter(g=>g.group===c),values:d,images:i,canEdit:o},c))]})]})}function K({group:t,definitions:l,values:d,images:i,canEdit:o}){const s={};l.forEach(m=>{const x=d[m.key];s[m.key]=m.type==="boolean"?!!x:x??""});const{data:a,setData:r,put:c,processing:p,errors:g,recentlySuccessful:j}=E(s);return e.jsxs(L,{children:[e.jsxs(I,{children:[e.jsx(O,{className:"text-base",children:t.label}),e.jsx(B,{children:t.description})]}),e.jsx(D,{children:e.jsxs("form",{onSubmit:m=>{m.preventDefault(),c("/admin/settings",{preserveScroll:!0})},className:"space-y-5",children:[l.map(m=>e.jsx(M,{definition:m,value:a[m.key]??"",error:g[m.key],images:i,disabled:!o,onChange:x=>r(m.key,x)},m.key)),o&&e.jsxs("div",{className:"flex items-center gap-3 border-t pt-4",children:[e.jsxs(C,{type:"submit",size:"sm",disabled:p,children:[e.jsx($,{className:"size-4"}),"Save ",t.label.toLowerCase()]}),j&&e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1 text-sm",children:[e.jsx(q,{className:"size-3.5"}),"Saved"]})]})]})})]})}function M({definition:t,value:l,error:d,images:i,disabled:o,onChange:s}){const a=`setting-${t.key}`;return t.type==="boolean"?e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{id:a,checked:!!l,disabled:o,onCheckedChange:r=>s(r===!0)}),e.jsxs("div",{className:"grid gap-1",children:[e.jsx(S,{htmlFor:a,children:t.label}),t.help&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t.help})]})]}):e.jsxs("div",{className:"grid gap-1.5",children:[e.jsx(S,{htmlFor:a,children:t.label}),t.type==="text"&&e.jsx(U,{id:a,rows:3,value:String(l??""),disabled:o,onChange:r=>s(r.target.value)}),t.type==="select"&&e.jsx("select",{id:a,value:String(l??""),disabled:o,onChange:r=>s(r.target.value),className:"border-input bg-background h-9 rounded-md border px-3 text-sm",children:Object.entries(t.options??{}).map(([r,c])=>e.jsx("option",{value:r,children:c},r))}),t.type==="media"&&e.jsx(G,{id:a,value:l,images:i,disabled:o,onChange:s}),t.type==="colour"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{id:a,type:"color",value:String(l||"#c8102e"),disabled:o,onChange:r=>s(r.target.value),className:"border-input size-9 rounded border bg-transparent"}),e.jsx(N,{value:String(l??""),disabled:o,onChange:r=>s(r.target.value),className:"w-32 font-mono text-xs","aria-label":`${t.label} hex value`})]}),["string","email","url","integer"].includes(t.type)&&e.jsx(N,{id:a,type:t.type==="integer"?"number":t.type==="email"?"email":t.type==="url"?"url":"text",min:t.min??void 0,max:t.max??void 0,value:String(l??""),disabled:o,onChange:r=>s(t.type==="integer"?r.target.value===""?"":Number(r.target.value):r.target.value)}),t.help&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t.help}),e.jsx(z,{message:d})]})}export{ke 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.