1import{j as e}from"./app-Bn8axf2m.js";import{H as k,r as z,u as A}from"./vendor-D8BamyIx.js";import{A as S}from"./AppLayout-DDnh82Xe.js";import{B as u}from"./button-BJHJ0j8Y.js";import{C as E,b as L,c as I,d as R,a as T}from"./card-D0Qy6Ld2.js";import{C as j}from"./checkbox-BwmQmhgX.js";import{I as N}from"./input-Jv8uXHpu.js";import{L as v}from"./label-Cg1Qz0vJ.js";import{c as F}from"./utils-DCADjnpI.js";import{C as H}from"./check-s0EwGkyq.js";import{S as M}from"./save-70nsVxIW.js";import{A as P,a as U}from"./arrow-up-Bzsnglqx.js";import{T as B}from"./trash-2-DOnMnHQN.js";import{P as O}from"./plus-CPqruDw4.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";const D=()=>({label:"",category_id:null,url:"",opens_in_new_tab:!1,is_highlighted:!1,is_active:!0});function $e({locations:l,menus:n,categories:d,pages:x,limits:c,siteName:p}){return e.jsxs(S,{title:"Navigation",description:`The menus readers see on ${p}. Empty menus fall back to your busiest categories.`,children:[e.jsx(k,{title:"Navigation"}),e.jsx("div",{className:"grid gap-6",children:l.map(t=>e.jsx(V,{location:t,initial:n[t.value]??[],categories:d,pages:x,limit:c[t.value]??t.limit,nesting:t.nesting},t.value))})]})}function V({location:l,initial:n,categories:d,pages:x,limit:c,nesting:p}){const[t,h]=z.useState(n.map(r=>({...r,children:r.children??[]}))),{put:C,processing:y,recentlySuccessful:_,transform:w}=A({}),$=()=>{w(()=>({location:l.value,items:t})),C("/admin/menus",{preserveScroll:!0})},m=(r,a)=>h(s=>s.map((o,i)=>i===r?{...o,...a}:o)),b=(r,a)=>h(s=>{const o=r+a,i=s[r],f=s[o];if(i===void 0||f===void 0)return s;const g=[...s];return g[r]=f,g[o]=i,g});return e.jsxs(E,{children:[e.jsxs(L,{className:"flex-row items-start justify-between space-y-0",children:[e.jsxs("div",{children:[e.jsx(I,{className:"text-base",children:l.label}),e.jsxs(R,{children:[l.hint," Up to ",c," items fit comfortably",p?", each with one level of dropdown.":"."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[_&&e.jsxs("span",{className:"text-muted-foreground flex items-center gap-1 text-sm",children:[e.jsx(H,{className:"size-3.5"}),"Saved"]}),e.jsxs(u,{size:"sm",onClick:$,disabled:y,children:[e.jsx(M,{className:"size-4"}),"Save"]})]})]}),e.jsxs(T,{className:"space-y-3",children:[t.length===0&&e.jsx("p",{className:"text-muted-foreground rounded-md border border-dashed p-6 text-center text-sm",children:p?"Empty. The header currently shows your busiest categories automatically â adding one item here replaces that.":"Empty. Nothing extra is shown in the footer."}),t.map((r,a)=>e.jsxs("div",{className:F("rounded-lg border p-3",!r.is_active&&"opacity-60",a>=c&&"border-amber-500/50"),children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"grid min-w-40 flex-1 gap-1.5",children:[e.jsx(v,{htmlFor:`${l.value}-label-${a}`,children:"Label"}),e.jsx(N,{id:`${l.value}-label-${a}`,value:r.label,placeholder:"Reviews",onChange:s=>m(a,{label:s.target.value})})]}),e.jsxs("div",{className:"grid min-w-48 flex-1 gap-1.5",children:[e.jsx(v,{htmlFor:`${l.value}-dest-${a}`,children:"Points at"}),e.jsxs("select",{id:`${l.value}-dest-${a}`,className:"border-input bg-background h-9 rounded-md border px-3 text-sm",value:r.category_id!==null?`category:${r.category_id}`:`url:${r.url??""}`,onChange:s=>{const[o,i]=q(s.target.value);m(a,o==="category"?{category_id:Number(i),url:null}:{category_id:null,url:i})},children:[e.jsx("optgroup",{label:"Category",children:d.map(s=>e.jsx("option",{value:`category:${s.id}`,children:s.name},s.id))}),e.jsx("optgroup",{label:"Page",children:x.map(s=>e.jsx("option",{value:`url:${s.url}`,children:s.title},s.url))}),e.jsxs("optgroup",{label:"Other",children:[e.jsx("option",{value:"url:/articles",children:"All articles"}),e.jsx("option",{value:`url:${r.category_id===null?r.url??"":""}`,children:"Custom URLâ¦"})]})]})]}),r.category_id===null&&e.jsxs("div",{className:"grid min-w-48 flex-1 gap-1.5",children:[e.jsx(v,{htmlFor:`${l.value}-url-${a}`,children:"URL"}),e.jsx(N,{id:`${l.value}-url-${a}`,value:r.url??"",placeholder:"/about or https://example.com",onChange:s=>m(a,{url:s.target.value})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":`Move ${r.label||"item"} up`,disabled:a===0,onClick:()=>b(a,-1),children:e.jsx(P,{className:"size-4"})}),e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":`Move ${r.label||"item"} down`,disabled:a===t.length-1,onClick:()=>b(a,1),children:e.jsx(U,{className:"size-4"})}),e.jsx(u,{variant:"ghost",size:"icon-sm","aria-label":`Remove ${r.label||"item"}`,onClick:()=>h(s=>s.filter((o,i)=>i!==a)),children:e.jsx(B,{className:"size-4"})})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx(j,{checked:r.is_active,onCheckedChange:s=>m(a,{is_active:s===!0})}),"Visible"]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx(j,{checked:r.opens_in_new_tab,onCheckedChange:s=>m(a,{opens_in_new_tab:s===!0})}),"New tab"]}),p&&e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx(j,{checked:r.is_highlighted,onCheckedChange:s=>m(a,{is_highlighted:s===!0})}),"Highlight"]})]}),a>
1=c&&e.jsxs("p",{className:"mt-2 text-xs text-amber-600 dark:text-amber-400",children:["Beyond item ",c," this is likely to wrap or overflow on a laptop. It will still save."]})]},a)),e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>h(r=>[...r,{...D(),category_id:d[0]?.id??null,url:d[0]?null:"/articles"}]),children:[e.jsx(O,{className:"size-4"}),"Add item"]})]})]})}function q(l){const n=l.indexOf(":");return n===-1?[l,""]:[l.slice(0,n),l.slice(n+1)]}export{$e 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.