import{a0 as d,a as g,bw as p,j as s,a1 as f,a2 as A,a3 as y,T as t,M as v,bR as h,au as F,V as x,t as C,z as I,r as j,at as N,J as L}from"./main-D6SjkSWq.js";import{u as z}from"./menu-item-form-BWmE5-iQ.js";import{A as D,a as c}from"./accordion-ClGroL7V.js";import{u as R}from"./use-filter-BCo2bw6z.js";import{A as S}from"./Add-DqbkGfuM.js";import{L as T,a as k}from"./list--2y4kqxI.js";import{u as w}from"./uc-first-pSl3nM3z.js";function J({title:o=s.jsx(t,{message:"Add menu item"})}){const{type:r}=d(),{data:a}=g(p.settings.menuEditorConfig()),i=z(),m=(a==null?void 0:a.categories)||[],n=r==="drawer"?"max-h-auto":"max-h-240 overflow-y-auto";return s.jsxs(f,{size:r==="drawer"?"md":"sm",children:[s.jsx(A,{children:o}),s.jsx(y,{children:s.jsxs(D,{variant:"outline",children:[s.jsx(c,{label:s.jsx(t,{message:"Link"}),bodyClassName:n,children:s.jsx(Q,{})}),s.jsx(c,{label:s.jsx(t,{message:"Route"}),bodyClassName:n,children:s.jsx(b,{items:i})}),m.map(l=>s.jsx(c,{bodyClassName:n,label:s.jsx(t,{message:l.name}),children:s.jsx(b,{items:l.items})},l.name))]})})]})}function Q(){const o=v({defaultValues:{id:h(6),type:"link",target:"_blank"}}),{close:r}=d();return s.jsxs(F,{form:o,onSubmit:a=>{r(a)},children:[s.jsx(x,{required:!0,name:"label",label:s.jsx(t,{message:"Label"}),className:"mb-20"}),s.jsx(x,{required:!0,type:"url",name:"action",placeholder:"https://",label:s.jsx(t,{message:"Url"}),className:"mb-20"}),s.jsx("div",{className:"text-right",children:s.jsx(C,{type:"submit",variant:"flat",color:"primary",size:"xs",children:s.jsx(t,{message:"Add to menu"})})})]})}function b({items:o}){const{trans:r}=I(),{close:a}=d(),[i,m]=j.useState(""),{contains:n}=R({sensitivity:"base"}),l=o.filter(e=>n(e.action??"",i));return s.jsxs(j.Fragment,{children:[s.jsx(N,{placeholder:r(L("Search...")),value:i,size:"sm",onChange:e=>m(e.target.value),className:"mb-12"}),s.jsx(T,{children:l.map(e=>s.jsx(k,{startIcon:s.jsx(S,{size:"sm"}),onSelected:()=>{if(e.label){const u=e.label.split("/").pop();e.label=u?w(u):e.label,e.id=h(6)}e.target||(e.target="_self"),a(e)},children:e.label},e.id))})]})}export{J as A};
