1import{aj as H,r as m,D as G,m as P,G as I,j as e,S as w,B as h,aB as M,ak as J,ao as d,I as $,s as c}from"./index-BHYV1lln.js";import{C as V}from"./checkbox-CF-1i_-1.js";import{D as W,a as O,b as Y,c as X,e as Z}from"./dialog-Bxb5MigS.js";import{A as ee,b as se,c as ae,d as te,e as ie,f as re,g as ne,h as le}from"./alert-dialog-B4dc-D2t.js";import{S as oe,a as ce,b as me,c as de,d as K}from"./select-B-Kk3JJZ.js";import{P as ge}from"./PackageDashboard-CnaAcZD0.js";import{P as B}from"./plus-L24ZsNKR.js";import{C as he}from"./chevron-right-DcDiCGNp.js";import{C as ue}from"./remove-formatting-DpTkZxOS.js";import{L as pe}from"./landmark-Cx-YGJ4j.js";import{C as fe}from"./copy-Dzc99l8m.js";import{E as ve}from"./external-link-VDNCUgvg.js";import{T as _e}from"./trash-2-BhuGgOm4.js";import"./index-BUS64PAl.js";import"./index-BdQq_4o_.js";import"./index-nIqYpPff.js";import"./chevron-up-D0eZJR7f.js";import"./LandingEditorDialog-DdIBq8Yl.js";import"./table-DgM6LVnk.js";import"./circle-check-EDYPjJ0n.js";import"./send-ydIRz0Jj.js";import"./mail-CO43FXD8.js";import"./eye-cBPufxrE.js";import"./mouse-pointer-click-DiriEEQe.js";import"./clock-aEx-zjrd.js";import"./circle-x-C-voAnxZ.js";import"./label-G1hkMF8-.js";import"./textarea-uNcfg5GG.js";import"./phone-oLteWBW_.js";import"./history-LHnsFen8.js";import"./circle-alert-CGu5HRiJ.js";import"./underline-6n4Hn87X.js";import"./calendar-DzBOzRvu.js";import"./info-5a-v6YFG.js";import"./triangle-alert-CHLJHL25.js";import"./dollar-sign-CwXkGimQ.js";import"./sanitize-BtXDVghZ.js";import"./type-BkVLfFmn.js";import"./save-BBm-FneN.js";import"./switch-B8o9yomd.js";import"./slugifyFilename-DjoJbnyv.js";import"./loader-circle-BfEEobgN.js";import"./search-DboZCGjR.js";import"./image-BOLWOJqg.js";import"./image-plus-D6s5bxkO.js";import"./images-C71RlOpi.js";import"./grip-vertical-CTkagZEf.js";import"./sparkles-p1-PSij0.js";import"./undo-2-_wvWdQh4.js";import"./addDays-DS-amGtB.js";import"./clipboard-copy-DcbE6fK1.js";import"./pencil-_TbMxo0v.js";import"./monitor-YjdGxcD4.js";import"./settings-2-Ox1S9QiS.js";import"./banknote-Cm7K1XeE.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const xe=H("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);function js(){const[N,f]=m.useState(null),[Q,v]=m.useState(!1),[l,k]=m.useState(null),[_,x]=m.useState(!1),[u,S]=m.useState(""),[g,b]=m.useState(""),[z,D]=m.useState(""),[F,L]=m.useState(!1),y=G(),E=s=>s.toLowerCase().replace(/[áà âä]/g,"a").replace(/[éèêë]/g,"e").replace(/[Ãìîï]/g,"i").replace(/[óòôö]/g,"o").replace(/[ÅÅ]/g,"o").replace(/[úùûü]/g,"u").replace(/[űū]/g,"u").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),{data:o,isLoading:R}=P({queryKey:["admin-csomagok-list"],queryFn:async()=>{const{data:s,error:a}=await c.from("event_packages").select("id, nev, slug, is_active, stripe_buy_button_id, stripe_publishable_key, szep_kartya_url, csomag_kod, event_id, landing_html, events(kontakt_nev)").order("created_at",{ascending:!1});if(a)throw a;return s??[]}}),{data:C}=P({queryKey:["admin-csomagok-submission-counts"],queryFn:async()=>{const{data:s,error:a}=await c.from("landing_submissions").select("package_id, statusz");if(a)throw a;const i={};return s==null||s.forEach(r=>{r.package_id&&(i[r.package_id]||(i[r.package_id]={total:0,uj:0}),i[r.package_id].total++,r.statusz==="uj"&&i[r.package_id].uj++)}),i}}),T=I({mutationFn:async({id:s,keepLanding:a})=>{var r;if(a){const{data:t,error:n}=await c.from("event_packages").select("nev, landing_html, landing_config, landing_sections, custom_fields").eq("id",s).single();if(n)throw n;if(t!=null&&t.landing_html||(r=t==null?void 0:t.landing_sections)!=null&&r.length){const p=Date.now(),{error:j}=await c.from("event_packages").insert({nev:`[Törölt] ${t.nev} landing`,slug:`arvak-${p}
6`,csomag_kod:`ARVAK_${p}`,is_active:!1,ejszakak_szama:2,landing_html:t.landing_html,landing_config:t.landing_config,landing_sections:t.landing_sections,custom_fields:t.custom_fields});if(j)throw j}}const{error:i}=await c.from("event_packages").delete().eq("id",s);if(i)throw i},onSuccess:()=>{y.invalidateQueries({queryKey:["admin-csomagok-list"]}),y.invalidateQueries({queryKey:["admin-csomagok-submission-counts"]}),d.success(_?"Csomag törölve, landing mentve":"Csomag törölve"),k(null),x(!1),N===(l==null?void 0:l.id)&&f(null)},onError:s=>d.error((s==null?void 0:s.message)||"Hiba a törlésnél")}),A=I({mutationFn:async s=>{const{data:a,error:i}=await c.from("event_packages").select("*").eq("id",s).single();if(i)throw i;if(!a)throw new Error("Csomag nem található");const r=Date.now(),{data:t,error:n}=await c.from("event_packages").insert({nev:`${a.nev} (másolat)`,slug:`${a.slug}-masolat-${r}`,csomag_kod:`${a.csomag_kod}_COPY`,is_active:!1,ejszakak_szama:a.ejszakak_szama,leiras:a.leiras,landing_html:a.landing_html,landing_config:a.landing_config,landing_sections:a.landing_sections,landing_mode:a.landing_mode,custom_fields:a.custom_fields,program_leirasok:a.program_leirasok,arak:a.arak,idopontok:a.idopontok,cover_image:a.cover_image,facebook_url:a.facebook_url,stripe_buy_button_id:a.stripe_buy_button_id,stripe_publishable_key:a.stripe_publishable_key,szep_kartya_url:a.szep_kartya_url,event_id:a.event_id}).select("id").single();if(n)throw n;return t==null?void 0:t.id},onSuccess:s=>{y.invalidateQueries({queryKey:["admin-csomagok-list"]}),d.success("Csomag duplikálva"),s&&f(s)},onError:s=>d.error((s==null?void 0:s.message)||"Hiba a duplikálásnál")}),U=async()=>{if(!u.trim()||!g.trim()){d.error("Név és slug kötelezÅ");return}L(!0);try{const s=g.toUpperCase().replace(/-/g,"_").slice(0,20);let a={};if(z){const{data:t,error:n}=await c.from("event_packages").select("landing_html, landing_config, landing_sections, landing_mode, custom_fields").eq("id",z).single();if(n)throw n;t&&(a={landing_html:t.landing_html,landing_config:t.landing_config,landing_sections:t.landing_sections,landing_mode:t.landing_mode,custom_fields:t.custom_fields})}const{data:i,error:r}=await c.from("event_packages").insert({nev:u.trim(),slug:g.trim(),csomag_kod:s,is_active:!0,ejszakak_szama:2,...a}).select("id").single();if(r)throw r;d.success("Csomag létrehozva"),v(!1),S(""),b(""),D(""),y.invalidateQueries({queryKey:["admin-csomagok-list"]}),i!=null&&i.id&&f(i.id)}catch(s){d.error((s==null?void 0:s.message)||"Hiba a létrehozásnál")}finally{L(!1)}},q=(o==null?void 0:o.filter(s=>!!s.landing_html))??[];return R?e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(w,{className:"h-8 w-48"}),e.jsx(w,{className:"h-24 w-full"}),e.jsx(w,{className:"h-24 w-full"})]}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{style:{fontFamily:"'Cormorant Garamond', serif",fontWeight:300,fontSize:"clamp(1.6rem, 2.5vw, 2.2rem)",color:"hsl(var(--mineral-d))"},children:"Csomagok"}),e.jsxs(h,{size:"sm",className:"gap-1 text-xs",onClick:()=>v(!0),children:[e.jsx(B,{size:14})," Ãj csomag"]})]}),!(o!=null&&o.length)&&e.jsx("p",{style:{fontFamily:"Jost, sans-serif",color:"hsl(var(--ink-faint))"},children:"Nincs még csomag létrehozva."}),e.jsx("div",{className:"space-y-3",children:o==null?void 0:o.map(s=>{var p;const a=C==null?void 0:C[s.id],i=N===s.id,r=!!s.stripe_buy_button_id&&!!s.stripe_publishable_key,t=!!s.szep_kartya_url,n=`${window.location.origin}/csomag/${s.slug}`;return e.jsxs("div",{className:"rounded-md border",style:{borderColor:"hsl(var(--rule))"},children:[e.jsxs("button",{onClick:()=>f(i?null:s.id),className:"w-full flex items-center gap-4 p-4 text-left hover:bg-[hsl(var(--muted))] transition-colors",children:[i?e.jsx(M,{size:16,style:{color:"hsl(var(--mineral))"}}):e.jsx(he,{size:16,style:{color:"hsl(var(--ink-faint))"}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{fontFamily:"'Cormorant Garamond', serif",fontWeight:400,fontSize:"1.1rem",color:"hsl(var(--ink))"},children:s.nev}),((p=s.events)==null?void 0:p.kontakt_nev)&&e.jsxs("span",{style:{fontFamily:"Jost, sans-serif",fontSize:"0.62rem",color:"hsl(var(--ink-faint))"},children:["· ",s.events.kontakt_nev]}),e.jsx(J,{variant:s.is_active?"default":"secondary",className:"text-[0.5rem] px-1.5 h-4",children:s.is_active?"AktÃv":"InaktÃv"})]}),e.jsxs("span",{style:{fontFamily:"Jost, sans-serif",fontSize:"0.68rem",color:"hsl(var(--ink-faint))"},children:["/",s.slug]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[((a==null?void 0:a.uj)??0)>0&&e.jsxs(J,{variant:"destructive",className:"text-[0.55rem] px-1.5 h-5",children:[a.uj," új"]}),((a==null?void 0:a.total)??0)>0&&e.jsxs("span",{style:{fontFamily:"Jost, sans-serif",fontSize:"0.65rem",color:"hsl(var(--ink-soft))"},children:[a.total," érdeklÅdÅ"]}
6),e.jsx(ue,{size:14,style:{color:r?"hsl(var(--mineral))":"hsl(var(--ink-faint))"}}),e.jsx(pe,{size:14,style:{color:t?"hsl(var(--mineral))":"hsl(var(--ink-faint))"}})]}),e.jsxs("div",{className:"flex items-center gap-1",onClick:j=>j.stopPropagation(),children:[e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{navigator.clipboard.writeText(n),d.success("Landing URL másolva")},children:e.jsx(fe,{size:12})}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",asChild:!0,children:e.jsx("a",{href:`/csomag/${s.slug}`,target:"_blank",rel:"noopener noreferrer",children:e.jsx(ve,{size:12})})}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Duplikálás",onClick:()=>A.mutate(s.id),disabled:A.isPending,children:e.jsx(xe,{size:12})}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:()=>{k({id:s.id,nev:s.nev}),x(!1)},children:e.jsx(_e,{size:12})})]})]}),i&&e.jsx("div",{className:"border-t p-4",style:{borderColor:"hsl(var(--rule))"},children:e.jsx(ge,{packageId:s.id,slug:s.slug,eventId:s.event_id??void 0,stripeBuyButtonId:s.stripe_buy_button_id??void 0,stripePublishableKey:s.stripe_publishable_key??void 0,szepKartyaUrl:s.szep_kartya_url??void 0})})]},s.id)})}),e.jsx(W,{open:Q,onOpenChange:v,children:e.jsxs(O,{className:"max-w-md",children:[e.jsx(Y,{children:e.jsx(X,{style:{fontFamily:"'Cormorant Garamond', serif",fontWeight:400},children:"Ãj csomag létrehozása"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium mb-1 block",style:{fontFamily:"Jost, sans-serif",color:"hsl(var(--ink-soft))"},children:"Csomag neve"}),e.jsx($,{value:u,onChange:s=>{S(s.target.value),(!g||g===E(u))&&b(E(s.target.value))},placeholder:"pl. LassÃtó Napok",className:"text-sm",style:{fontFamily:"Jost, sans-serif"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium mb-1 block",style:{fontFamily:"Jost, sans-serif",color:"hsl(var(--ink-soft))"},children:"URL slug"}),e.jsx($,{value:g,onChange:s=>b(s.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"pl. lassito-napok",className:"text-sm font-mono"}),e.jsxs("p",{className:"text-[0.6rem] mt-1",style:{fontFamily:"Jost, sans-serif",color:"hsl(var(--ink-faint))"},children:["Publikus URL: /csomag/",g||"..."]})]}),q.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium mb-1 block",style:{fontFamily:"Jost, sans-serif",color:"hsl(var(--ink-soft))"},children:"Landing importálása meglévÅ csomagból (opcionális)"}),e.jsxs(oe,{value:z,onValueChange:D,children:[e.jsx(ce,{className:"text-sm",style:{fontFamily:"Jost, sans-serif"},children:e.jsx(me,{placeholder:"Nincs â üres landing"})}),e.jsxs(de,{children:[e.jsx(K,{value:"none",children:"Nincs â üres landing"}),q.map(s=>e.jsxs(K,{value:s.id,children:[s.nev," ",s.is_active?"":"(inaktÃv)"]},s.id))]})]})]})]}),e.jsxs(Z,{children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>v(!1),children:"Mégse"}),e.jsxs(h,{size:"sm",className:"gap-1",onClick:U,disabled:F||!u.trim(),children:[e.jsx(B,{size:12})," ",F?"Létrehozás...":"Létrehozás"]})]})]})}),e.jsx(ee,{open:!!l,onOpenChange:s=>{s||(k(null),x(!1))},children:e.jsxs(se,{children:[e.jsxs(ae,{children:[e.jsx(te,{children:"Csomag törlése"}),e.jsx(ie,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["Biztosan törlöd a â",l==null?void 0:l.nev,'" csomagot? Az összes hozzá tartozó érdeklÅdÅ (landing submission) is törlÅdik. Ez a művelet nem vonható vissza.']}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(V,{checked:_,onCheckedChange:s=>x(s===!0)}),e.jsx("span",{className:"text-sm",style:{fontFamily:"Jost, sans-serif",color:"hsl(var(--ink))"},children:"Landing oldal megtartása (új csomaghoz rendelhetÅ)"})]}),_&&e.jsx("p",{className:"text-xs",style:{fontFamily:"Jost, sans-serif",color:"hsl(var(--ink-faint))"},children:"A landing tartalom egy inaktÃv csomagként megmarad, amelyet késÅbb importálhatsz egy új csomagba."})]})})]}),e.jsxs(re,{children:[e.jsx(ne,{children:"Mégse"}),e.jsx(le,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>l&&T.mutate({id:l.id,keepLanding:_}),children:"Törlés"})]})]})})]})}export{js 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.