import{_ as K}from"./BPZZgRgP.js";import{p as J,e as q,I as Q,g as X,h as Y,G as Z,x as ee,N as te,o,c as r,j as B,a as e,b as H,w,n as d,F as x,r as b,l as L,O as R,t as u,P as S,i as A,d as $,M as se,z as k,q as g,B as oe}from"./CGTxeHv7.js";import{u as ne}from"./nwypRWOF.js";const le=J("/logo.svg"),ae={class:"min-h-screen bg-slate-900 text-white flex"},re={class:"flex items-center gap-3 min-w-0"},ie={class:"flex-1 px-2 py-4 space-y-2 overflow-y-auto overflow-x-hidden"},de={key:0},ue=["onClick"],ce=["innerHTML"],he={class:"ml-2 mt-1 space-y-1 overflow-hidden transition-all duration-200"},ve=["innerHTML"],pe={class:"whitespace-nowrap overflow-hidden"},xe=["innerHTML"],fe={class:"p-4 border-t border-slate-700 overflow-hidden"},ke={class:"flex-1 flex flex-col min-w-0 transition-all duration-300 ease-in-out"},ge={class:"sticky top-0 z-10 bg-slate-800/95 backdrop-blur-sm border-b border-slate-700"},me={class:"flex items-center justify-between h-16 px-4 lg:px-6"},we={class:"flex items-center gap-3"},be={class:"text-lg font-semibold text-white truncate"},_e={class:"flex items-center gap-3"},ye={class:"flex items-center bg-slate-700/50 rounded-lg p-0.5"},Ce=["onClick"],ze={class:"w-8 h-8 rounded-full bg-indigo-600 flex items-center justify-center text-sm font-bold text-white"},Me={class:"hidden sm:block text-sm text-slate-300"},je={key:0,class:"absolute right-0 mt-2 w-56 bg-slate-800 border border-slate-700 rounded-xl shadow-xl py-1 z-50"},Be={class:"px-4 py-3 border-b border-slate-700"},He={class:"text-sm font-medium text-white"},Le={class:"text-xs text-slate-400 mt-0.5"},Re={class:"flex-1 p-4 lg:p-6 overflow-auto"},Te=q({__name:"default",setup(Se){const c=Q(),F=X(),h=Y(),C=ne(),{locale:z,locales:V}=Z(),T=k(()=>V.value),E=k(()=>z.value);function G(){const t=oe("access_token").value;return t?{Authorization:`Bearer ${t}`}:{}}async function N(s){z.value=s;try{await $fetch("/api/v1/auth/me/language",{method:"PATCH",headers:{...G(),"Content-Type":"application/json"},body:{preferred_language:s}})}catch(t){console.error("[Layout] Failed to persist language preference:",t)}}const n=g(!1),i=g(!1),p=g(!1),_=g(null),f=g(new Set(["Központ"])),M=k(()=>h.userEmail||"Ismeretlen Felhasználó"),P=k(()=>{const s=h.userEmail;return s?s.split("@")[0].split(".").map(t=>t[0]).join("").toUpperCase().slice(0,2):"??"}),W=[{title:"Központ",items:[{path:"/",label:"Dashboard",icon:''}]},{title:"Felhasználók & Partnerek",items:[{label:"Garázsok",icon:'',children:[{path:"/garages",label:"Garázsok listája",icon:''}]},{label:"Felhasználók",icon:'',children:[{path:"/",label:"Felhasználók listája",icon:''}]}]},{title:"Pénzügyek",items:[{path:"/packages",label:"Csomagok",icon:''}]},{title:"Rendszer",items:[{path:"/permissions",label:"Jogosultságok",icon:''},{label:"Rendszernaplók",icon:'',children:[{path:"/",label:"Rendszernaplók",icon:''}]}]}],D=k(()=>c.path==="/"?"Dashboard":c.path.startsWith("/permissions")?"Jogosultság Kezelés":c.path.startsWith("/garages")?"Garázsok":c.path.startsWith("/users")?"Felhasználók":c.path.startsWith("/logs")?"Rendszernaplók":c.path.startsWith("/packages")?"Csomagok":"Admin Panel");function y(s){return s==="/"?c.path==="/":c.path.startsWith(s)}function I(s){return s.children?s.children.some(t=>y(t.path)):!1}function O(s){f.value.has(s.label)?f.value.delete(s.label):f.value.add(s.label)}function U(){h.logout(),p.value=!1,F.push("/login")}function j(s){_.value&&!_.value.contains(s.target)&&(p.value=!1)}return ee(()=>{document.addEventListener("click",j),C.fetchRegions().then(()=>{h.user?.region_code&&C.setActiveRegion(h.user.region_code)})}),te(()=>{document.removeEventListener("click",j)}),(s,t)=>{const m=K;return o(),r("div",ae,[n.value?(o(),r("div",{key:0,class:"fixed inset-0 bg-black/50 z-20 lg:hidden",onClick:t[0]||(t[0]=a=>n.value=!1)})):B("",!0),e("aside",{class:d(["fixed lg:static inset-y-0 left-0 z-30 flex flex-col bg-slate-800 border-r border-slate-700 transition-all duration-300 ease-in-out overflow-hidden",n.value||!i.value?"w-52":"w-20"])},[H(m,{to:"/",class:"flex items-center h-16 px-4 border-b border-slate-700 overflow-hidden hover:bg-slate-700/50 transition"},{default:w(()=>[e("div",re,[t[8]||(t[8]=e("img",{src:le,class:"h-8 w-auto flex-shrink-0",alt:"SF Logo"},null,-1)),e("div",{class:d(["transition-all duration-300 ease-in-out overflow-hidden whitespace-nowrap",n.value||!i.value?"opacity-100 max-w-[200px]":"opacity-0 max-w-0"])},[...t[7]||(t[7]=[e("div",{class:"text-sm font-bold text-white leading-tight"},"Service Finder",-1),e("div",{class:"text-[10px] font-semibold uppercase tracking-wider text-indigo-400 leading-tight"},"Admin",-1)])],2)])]),_:1}),e("button",{class:"hidden lg:flex items-center justify-center h-10 mx-2 mt-2 rounded-lg text-slate-400 hover:text-white hover:bg-slate-700 transition flex-shrink-0",onClick:t[1]||(t[1]=a=>i.value=!i.value)},[(o(),r("svg",{class:d(["w-5 h-5 transition-transform duration-300",{"rotate-180":i.value}]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...t[9]||(t[9]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 19l-7-7 7-7m8 14l-7-7 7-7"},null,-1)])],2))]),e("nav",ie,[(o(),r(x,null,b(W,a=>(o(),r(x,{key:a.title},[L(e("div",{class:"px-3 py-1 text-xs font-semibold uppercase tracking-wider text-slate-500 whitespace-nowrap overflow-hidden"},u(a.title),513),[[R,n.value||!i.value]]),(o(!0),r(x,null,b(a.items,l=>(o(),r(x,{key:l.label},[l.children?(o(),r("div",de,[e("button",{class:d(["flex items-center w-full gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition",I(l)?"bg-indigo-600/20 text-indigo-300":"text-slate-300 hover:bg-slate-700 hover:text-white"]),onClick:v=>O(l)},[e("span",{class:"flex-shrink-0 w-5 h-5",innerHTML:l.icon},null,8,ce),e("span",{class:d(["flex-1 text-left whitespace-nowrap overflow-hidden transition-all duration-300 ease-in-out",n.value||!i.value?"opacity-100 max-w-[200px]":"opacity-0 max-w-0"])},u(l.label),3),(o(),r("svg",{class:d(["w-4 h-4 transition-all duration-300 ease-in-out flex-shrink-0",{"rotate-90":f.value.has(l.label),"opacity-100":n.value||!i.value,"opacity-0":i.value&&!n.value}]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...t[10]||(t[10]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))],10,ue),L(e("div",he,[(o(!0),r(x,null,b(l.children,v=>(o(),S(m,{key:v.path,to:v.path,class:d(["flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition",y(v.path)?"bg-indigo-600 text-white":"text-slate-400 hover:bg-slate-700 hover:text-white"]),onClick:t[2]||(t[2]=Ae=>n.value=!1)},{default:w(()=>[e("span",{class:"flex-shrink-0 w-4 h-4",innerHTML:v.icon},null,8,ve),e("span",pe,u(v.label),1)]),_:2},1032,["to","class"]))),128))],512),[[R,f.value.has(l.label)&&(n.value||!i.value)]])])):(o(),S(m,{key:1,to:l.path,class:d(["flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition",y(l.path)?"bg-indigo-600 text-white":"text-slate-300 hover:bg-slate-700 hover:text-white"]),onClick:t[3]||(t[3]=v=>n.value=!1)},{default:w(()=>[e("span",{class:"flex-shrink-0 w-5 h-5",innerHTML:l.icon},null,8,xe),e("span",{class:d(["whitespace-nowrap overflow-hidden transition-all duration-300 ease-in-out",n.value||!i.value?"opacity-100 max-w-[200px]":"opacity-0 max-w-0"])},u(l.label),3)]),_:2},1032,["to","class"]))],64))),128))],64))),64))]),e("div",fe,[e("div",{class:d(["text-xs text-slate-500 whitespace-nowrap transition-all duration-300 ease-in-out",n.value||!i.value?"opacity-100 max-w-[200px]":"opacity-0 max-w-0"])}," ServiceFinder v2.0 ",2)])],2),e("div",ke,[e("header",ge,[e("div",me,[e("div",we,[e("button",{class:"lg:hidden p-2 rounded-lg text-slate-400 hover:text-white hover:bg-slate-700 transition",onClick:t[4]||(t[4]=a=>n.value=!0)},[...t[11]||(t[11]=[e("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h16M4 18h16"})],-1)])]),e("h1",be,u(D.value),1)]),e("div",_e,[e("div",ye,[(o(!0),r(x,null,b(T.value,a=>(o(),r("button",{key:a.code,onClick:l=>N(a.code),class:d(["px-2.5 py-1 text-xs font-medium rounded-md transition",E.value===a.code?"bg-indigo-600 text-white shadow-sm":"text-slate-400 hover:text-white"])},u(a.code==="hu"?"HU":"EN"),11,Ce))),128))]),e("div",{class:"relative",ref_key:"dropdownRef",ref:_},[e("button",{class:"flex items-center gap-2 p-1.5 rounded-lg hover:bg-slate-700 transition",onClick:t[5]||(t[5]=a=>p.value=!p.value)},[e("div",ze,u(P.value),1),e("span",Me,u(M.value),1),t[12]||(t[12]=e("svg",{class:"w-4 h-4 text-slate-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 9l-7 7-7-7"})],-1))]),p.value?(o(),r("div",je,[e("div",Be,[e("p",He,u(M.value),1),e("p",Le,u(A(h).userRole==="SUPERADMIN"?"Super Administrator":A(h).userRole||"Administrator"),1)]),H(m,{to:"/profile",class:"flex items-center gap-3 px-4 py-2.5 text-sm text-slate-300 hover:bg-slate-700 hover:text-white transition",onClick:t[6]||(t[6]=a=>p.value=!1)},{default:w(()=>[...t[13]||(t[13]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})],-1),$(" Profile Settings ",-1)])]),_:1}),e("button",{class:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-red-400 hover:bg-slate-700 hover:text-red-300 transition",onClick:U},[...t[14]||(t[14]=[e("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})],-1),$(" Sign Out ",-1)])])])):B("",!0)],512)])])]),e("main",Re,[se(s.$slots,"default")])])])}}});export{Te as default};