1import{bM as v,i as we,j as e,bS as ye,t as Ne,s as w,l as D,J as z,bT as ke,$ as ee,b as J,F as re,r as T,v as S,w as P,x as L,I as F,y as _,L as ie,B as K,D as Te,k as Se,a2 as xe,ar as Pe,as as _e,aw as le,ax as ce,ay as de,at as Ce,b9 as Le,ba as Fe,bc as Ae,bb as De,bd as Ie,be as Ee,ao as Ue,a as He,bI as $e,bU as Oe}from"./index.BbKy4Oqu.js";import{r as x,a as he,B as fe,am as G,u as je,bl as ve,an as Re,X as me,D as ue,ao as ze,Y as Be,f as Ke,aW as Me,h as Ve}from"./icons.D6Qwvxuf.js";import{R as qe}from"./rich-text-editor.D_Ou3WVy.js";import{S as We,a as Ge,b as Je,c as Qe,d as U}from"./select.Dtx19b0H.js";import{S as Q}from"./section-action-bar.C7oqQxaO.js";import{F as ge}from"./FilePickerModal.C4fJyw7s.js";import{b as Xe}from"./useAnsprechpartner.BVHJQDvT.js";import"./htmlSanitizer.BN9aftvP.js";import"./purify.es.DqNA57iZ.js";import"./useFileUpload.B3QBZy89.js";import"./useImageCompression.CU6qlJgR.js";import"./alert-dialog.BkaAxK72.js";import"./FileManager.CkQXZW1l.js";const Ye=v.object({traegername:v.string().optional(),status:v.enum(["Pausiert","Online","Nicht erstellt","Entwurf","Archiviert"]).optional(),art_des_traegers:v.string().optional(),about_text:v.string().optional(),website:v.string().optional().refine(a=>!a||a===""||/^https?:\/\/.+/.test(a),{message:"Ungültige URL"}),instagram:v.string().optional(),facebook:v.string().optional(),linkedin:v.string().optional(),strasse:v.string().optional(),ort:v.string().optional(),postleitzahl_id:v.number().optional().nullable(),einrichtungen:v.number().optional().nullable(),mitarbeiter:v.number().optional().nullable(),ansprechpartner_id:v.string().uuid().optional().or(v.literal("")).nullable()}),be=x.createContext(void 0);function Ze({children:a,traegerId:d}){const[y,u]=x.useState(!0),[b,i]=x.useState(!1),[g,c]=x.useState(null),[j,H]=x.useState(null),[$,I]=x.useState(null),[C,p]=x.useState([]),[n,N]=x.useState(!1),k=we({resolver:Ne(Ye),mode:"onChange",defaultValues:{traegername:"",status:"Entwurf"}}),O=r=>{if(r.startsWith("http"))return r;const{data:m}=w.storage.from("kita-images").getPublicUrl(r);return m.publicUrl},V=he.useRef(n),M=he.useRef(g);V.current=n,M.current=g,x.useEffect(()=>{if(!j)return;const r=k.watch(m=>{const s=JSON.stringify(m)!==JSON.stringify(j),l=M.current!==null||V.current;i(s||l)});return()=>r.unsubscribe()},[k,j]),x.useEffect(()=>{if(j)if(g!==null||n)i(!0);else{const r=JSON.stringify(k.getValues())!==JSON.stringify(j);i(r)}},[g,n,j,k]),x.useEffect(()=>{(async()=>{if(d)try{u(!0);let m=w.from("Traeger").select("*").eq("Traegernummer",parseInt(String(d))).single(),{data:s,error:l}=await m;if(l&&l.code==="PGRST116"&&(m=w.from("Traeger").select("*").eq("id",String(d)).single(),{data:s,error:l}=await m),l){D.error("Error fetching träger:",l),z.error("Fehler beim Laden der Träger-Daten");return}if(s){const t={traegername:s.Traegername||"",status:s.status||"Entwurf",art_des_traegers:s.art_des_traegers||void 0,about_text:s.about_text||"",website:s.website||"",instagram:s.instagram||"",facebook:s.facebook||"",linkedin:s.linkedin||"",strasse:s.strasse||"",ort:s.ort||"",postleitzahl_id:s.postleitzahl_id,einrichtungen:s.einrichtungen,mitarbeiter:s.mitarbeiter,ansprechpartner_id:s.ansprechpartner_id||""};k.reset(t),H(t),I(s.logo||null);const o=[];if(s.headerphoto&&o.push({type:"saved",url:s.headerphoto,preview:O(s.headerphoto),isHeader:!0}),s.gallery&&Array.isArray(s.gallery))for(const f of s.gallery)f!==s.headerphoto&&o.push({type:"saved",url:f,preview:O(f),isHeader:!1});p(o),N(!1)}}catch(m){D.error("Error loading träger data:",m),z.error("Fehler beim Laden der Träger-Daten")}finally{u(!1)}})()},[d,k]);const W={form:k,isDirty:b,isLoading:y,saveForm:async()=>{try{const r=k.getValues();if(r.website&&r.website!==""&&!/^https?:\/\/.+/.test(r.website)){z.error("Bitte geben Sie eine gültige URL ein (muss mit http:// oder https:// beginnen)");return}D.debug("[TraegerSave] Starting save. Photos:",C.length,C.map(h=>({type:h.type,isHeader:h.isHeader,url:h.url,hasFile:!!h.file})));const m=await Promise.all(C.map(async h=>{if(h.type==="new"&&h.file){const E=h.file.name.split(".").pop(),B=`${d}-photo-${Date.now()}-${Math.random().toString(36).slice(2)}.${E}`;D.debug("[TraegerSave] Uploading photo:",B);const{error:Z}=await w.storage.from("kita-images").upload(`traeger/${B}`,h.file,{upsert:!0});return Z?(D.error("[TraegerSave] Upload error:",Z),z.error(`Fehler beim Hochladen: ${Z.message}`),{...h,url:null}):(D.debug("[TraegerSave] Upload success:",`traeger/${B}`),{...h,url:`traeger/${B}`})}return h})),s=m.find(h=>h.isHeader),l=m.filter(h=>!h.isHeader&&h.url),t=s?.url||null,o=l.map(h=>
1h.url).filter(Boolean);D.debug("[TraegerSave] headerPhotoPath:",t,"galleryPaths:",o);let f=w.from("Traeger").update({Traegername:r.traegername,status:r.status,art_des_traegers:r.art_des_traegers,about_text:r.about_text,website:r.website,instagram:r.instagram,facebook:r.facebook,linkedin:r.linkedin,strasse:r.strasse,ort:r.ort,postleitzahl_id:r.postleitzahl_id,einrichtungen:r.einrichtungen,mitarbeiter:r.mitarbeiter,ansprechpartner_id:r.ansprechpartner_id||null,headerphoto:t,gallery:o,last_modified:new Date().toISOString().split("T")[0]}).eq("Traegernummer",parseInt(String(d))),{error:R}=await f;if(R&&R.code==="PGRST116"&&(f=w.from("Traeger").update({Traegername:r.traegername,status:r.status,art_des_traegers:r.art_des_traegers,about_text:r.about_text,website:r.website,instagram:r.instagram,facebook:r.facebook,linkedin:r.linkedin,strasse:r.strasse,ort:r.ort,postleitzahl_id:r.postleitzahl_id,einrichtungen:r.einrichtungen,mitarbeiter:r.mitarbeiter,ansprechpartner_id:r.ansprechpartner_id||null,headerphoto:t,gallery:o,last_modified:new Date().toISOString().split("T")[0]}).eq("id",String(d)),{error:R}=await f),R){D.error("Error saving träger:",R),z.error("Fehler beim Speichern der Träger-Daten");return}if(g){const h=g.name.split(".").pop(),E=`${d}-logo.${h}`,{error:B}=await w.storage.from("kita-images").upload(`traeger/${E}`,g,{upsert:!0});B||await w.from("Traeger").update({logo:`traeger/${E}`}).eq("Traegernummer",d)}const{data:A}=await w.from("Traeger").select("headerphoto, logo, gallery").eq("Traegernummer",d).single();if(A){I(A.logo||null);const h=[];if(A.headerphoto&&h.push({type:"saved",url:A.headerphoto,preview:O(A.headerphoto),isHeader:!0}),A.gallery&&Array.isArray(A.gallery))for(const E of A.gallery)E!==A.headerphoto&&h.push({type:"saved",url:E,preview:O(E),isHeader:!1});p(h)}z.success("Träger-Daten erfolgreich gespeichert");const oe=k.getValues();k.reset(oe),H(oe),i(!1),N(!1),c(null)}catch(r){D.error("Error saving träger:",r),z.error("Fehler beim Speichern der Träger-Daten")}},traegerId:d,logo:g,setLogo:c,savedLogoUrl:$,deleteSavedLogo:async()=>{if($){const{error:r}=await w.storage.from("kita-images").remove([$]);r||(await w.from("Traeger").update({logo:null}).eq("Traegernummer",d),I(null))}},photos:C,addPhotos:r=>{const m=r.map((s,l)=>({type:"new",file:s,preview:URL.createObjectURL(s),isHeader:C.length===0&&l===0&&!C.some(t=>t.isHeader)}));p(s=>{const l=[...s,...m];return!l.some(t=>t.isHeader)&&l.length>0&&(l[0].isHeader=!0),l}),N(!0)},addPhotoUrls:r=>{const m=r.filter(Boolean).map(s=>({type:"saved",url:s,preview:s.startsWith("http")?s:w.storage.from("kita-images").getPublicUrl(s).data.publicUrl,isHeader:!1}));p(s=>{const l=[...s,...m];return!l.some(t=>t.isHeader)&&l.length>0&&(l[0].isHeader=!0),l}),N(!0)},removePhoto:r=>{p(m=>{const s=m[r],l=m.filter((t,o)=>o!==r);return s?.isHeader&&l.length>0&&(l[0].isHeader=!0),s?.type==="new"&&s.preview&&URL.revokeObjectURL(s.preview),s?.type==="saved"&&s.url&&w.storage.from("kita-images").remove([s.url]),l}),N(!0)},setPhotoAsHeader:r=>{p(m=>m.map((s,l)=>({...s,isHeader:l===r}))),N(!0)}};return e.jsx(be.Provider,{value:W,children:e.jsx(ye,{...k,children:a})})}function X(){const a=x.useContext(be);if(a===void 0)throw new Error("useTraegerForm must be used within a TraegerFormProvider");return a}const er=[{title:"Grundinformationen",section:"grundinfo",icon:fe},{title:"Bilder und Logo",section:"bilder",icon:G},{title:"Adresse & Kontakt",section:"adresse",icon:je},{title:"Social Media",section:"social-media",icon:ve}];function pe(){return e.jsx("div",{className:"border-b bg-background",children:e.jsx("nav",{className:"flex items-center gap-1 px-3 sm:px-6 overflow-x-auto",children:er.map(a=>e.jsxs(ke,{to:`/traeger/${a.section}`,className:({isActive:d})=>ee("flex items-center gap-2 px-3 sm:px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap border-b-2 border-transparent hover:text-primary hover:border-primary/30",d&&"text-primary border-primary"),children:[e.jsx(a.icon,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:a.title})]},a.section))})})}function rr(){const{form:a,isDirty:d,saveForm:y,traegerId:u,isLoading:b}=X();J();const i=async()=>{await y()},g=()=>{window.open(`/t/${u}`,"_blank")};return e.jsxs("div",{className:"flex flex-col min-h-screen",children:[e.jsxs("div",{className:"flex-1 space-y-4 sm:sp
1ace-y-6 p-0 sm:p-6 pb-24",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10 shrink-0",children:e.jsx(fe,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold",children:"Grundinformationen"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Grundlegende Informationen über Ihren Träger"})]})]}),e.jsx(re,{...a,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{control:a.control,name:"traegername",render:({field:c})=>e.jsxs(S,{children:[e.jsx(P,{children:"Trägername *"}),e.jsx(L,{children:e.jsx(F,{placeholder:"Name des Trägers",...c})}),e.jsx(_,{})]})}),e.jsx(T,{control:a.control,name:"art_des_traegers",render:({field:c})=>e.jsxs(S,{children:[e.jsx(P,{children:"Art des Trägers"}),e.jsxs(We,{onValueChange:c.onChange,value:c.value||"",children:[e.jsx(L,{children:e.jsx(Ge,{children:e.jsx(Je,{placeholder:"Art des Trägers auswählen"})})}),e.jsxs(Qe,{children:[e.jsx(U,{value:"Arbeiterwohlfahrt (AWO)",children:"Arbeiterwohlfahrt (AWO)"}),e.jsx(U,{value:"Betriebskita",children:"Betriebskita"}),e.jsx(U,{value:"Elterninitiative (EKT)",children:"Elterninitiative (EKT)"}),e.jsx(U,{value:"Evangelische Kirche",children:"Evangelische Kirche"}),e.jsx(U,{value:"Freier Träger",children:"Freier Träger"}),e.jsx(U,{value:"Katholische Kirche",children:"Katholische Kirche"}),e.jsx(U,{value:"Kommunaler Träger",children:"Kommunaler Träger"}),e.jsx(U,{value:"Verein",children:"Verein"})]})]}),e.jsx(_,{})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(T,{control:a.control,name:"einrichtungen",render:({field:c})=>e.jsxs(S,{children:[e.jsx(P,{children:"Anzahl Einrichtungen"}),e.jsx(L,{children:e.jsx(F,{type:"number",placeholder:"0",...c,onChange:j=>c.onChange(parseInt(j.target.value)||void 0)})}),e.jsx(_,{})]})}),e.jsx(T,{control:a.control,name:"mitarbeiter",render:({field:c})=>e.jsxs(S,{children:[e.jsx(P,{children:"Anzahl Mitarbeiter"}),e.jsx(L,{children:e.jsx(F,{type:"number",placeholder:"0",...c,onChange:j=>c.onChange(parseInt(j.target.value)||void 0)})}),e.jsx(_,{})]})})]}),e.jsx(T,{control:a.control,name:"about_text",render:({field:c})=>e.jsxs(S,{children:[e.jsx(P,{children:"Ãber den Träger"}),e.jsx(L,{children:e.jsx(qe,{value:c.value||"",onChange:c.onChange,placeholder:"Beschreiben Sie Ihren Träger, seine Mission und Werte..."})}),e.jsx(_,{})]})})]})})]}),e.jsx(Q,{onSave:i,isDirty:d,showPreview:!0,onPreview:g,previewLabel:"Träger ansehen"})]})}function sr(){const{isDirty:a,saveForm:d,traegerId:y,logo:u,setLogo:b,savedLogoUrl:i,deleteSavedLogo:g,photos:c,addPhotos:j,addPhotoUrls:H,removePhoto:$,setPhotoAsHeader:I}=X(),[C,p]=x.useState(null),[n,N]=x.useState(null),[k,O]=x.useState(!1),[V,M]=x.useState(!1);J();const q=x.useRef(null),se=x.useRef(null),te=()=>{window.open(`/t/${y}`,"_blank")},ae=t=>{const o=t.target.files?.[0];o&&b(o)},ne=t=>{const o=Array.from(t.target.files||[]).filter(f=>f.type.startsWith("image/"));o.length>0&&j(o)},Y=(t,o)=>{t.preventDefault(),p(o)},W=t=>{t.preventDefault(),p(null)},r=t=>{t.preventDefault(),p(null);const o=t.dataTransfer.files?.[0];o&&o.type.startsWith("image/")&&b(o)},m=t=>{t.preventDefault(),p(null);const o=Array.from(t.dataTransfer.files||[]).filter(f=>f.type.startsWith("image/"));o.length>0&&j(o)},s=()=>{b(null),q.current&&(q.current.value="")},l=t=>{if(t.startsWith("http"))return t;const{data:o}=w.storage.from("kita-images").getPublicUrl(t);return o.publicUrl};return e.jsxs("div",{className:"space-y-6 sm:space-y-8 pb-24",children:[e.jsx("div",{className:"space-y-4 sm:space-y-6",children:e.jsxs("div",{className:"flex items-center gap-3 mb-4 sm:mb-6",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-primary/10 to-primary/5 shrink-0",children:e.jsx(G,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Bilder & Logo"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verwalten Sie die visuellen Elemente Ihres Trägers"})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ie,{className:"text-base font-medium",children:"Logo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Das Logo Ihres Trägers (empfohlene GröÃe: 200x200px, quadratisch)"}),e.jsx("input",{ref:q,type:"file",accept:"image/*",onChange:ae,className:"hidden"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-3",children:[(u||i)&&e.jsxs("div",{className:"relative group rounded-lg overflow-hidden border shadow-sm hover:shadow-md transition-all duration-300 aspect-square",children:[e.jsx("img",{src:u?URL.createObjectURL(u):l(i),alt:"Logo",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors duration-300"}),e.jsx(K,{type:"button",variant:"destructive",size:"sm",className:"absolute top-1.5 right-1.5 h-5 w-5 p-0 opacity-0 group-hover:opacity-100 transition-all duration-300",onClick:u?s:g,children:e.jsx(me,{className:"h-3 w-3"})})]}),!(u||i)&&e.jsxs("button",{type:"button",onClick:()=>O(!0),onDragOver:t=>Y(t,"logo"),onDragLeave:W,onDrop:r,className:`aspect-square rounded-lg border-2 border-dashed flex flex-col items-center justify-center gap-1.5 cursor-pointer transition-all duration-200 ${C==="logo"?"border-primary bg-primary/5":"border-muted-foreground
1/25 hover:border-muted-foreground/40 hover:bg-muted/30"}`,children:[e.jsx(ue,{className:"h-6 w-6 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Upload"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ie,{className:"text-base font-medium",children:"Fotos des Trägers"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Laden Sie Fotos Ihres Trägers hoch. Das erste Bild wird automatisch als Header-Bild verwendet.",e.jsx("br",{}),e.jsx("span",{className:"font-medium text-foreground",children:"Wichtig:"})," Als Header-Bild werden ausschlieÃlich AuÃenaufnahmen der Einrichtung akzeptiert (kein Logo, keine Innenaufnahmen, keine Personen)."]}),e.jsx("input",{ref:se,type:"file",accept:"image/*",multiple:!0,onChange:ne,className:"hidden"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-3",children:[c.map((t,o)=>e.jsxs("div",{className:`relative group rounded-lg overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 aspect-square cursor-pointer ${t.isHeader?"ring-2 ring-primary":"border"} ${t.type==="new"?"ring-2 ring-primary/30":""}`,onClick:()=>N(o),children:[e.jsx("img",{src:t.preview,alt:`Foto ${o+1}`,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors duration-300"}),t.isHeader?e.jsxs("div",{className:"absolute top-1.5 left-1.5 bg-primary text-primary-foreground text-[10px] font-semibold px-1.5 py-0.5 rounded flex items-center gap-1",children:[e.jsx(G,{className:"h-3 w-3"}),"Header"]}):e.jsxs(K,{type:"button",variant:"secondary",size:"sm",className:"absolute top-1.5 left-1.5 h-5 px-1.5 text-[10px] opacity-0 group-hover:opacity-100 transition-all duration-300",onClick:f=>{f.stopPropagation(),I(o)},children:[e.jsx(G,{className:"h-3 w-3 mr-1"}),"Header"]}),t.type==="new"&&e.jsx("div",{className:"absolute bottom-1.5 left-1.5 bg-primary text-primary-foreground text-[9px] px-1.5 py-0.5 rounded",children:"Neu"}),e.jsx(K,{type:"button",variant:"destructive",size:"sm",className:"absolute top-1.5 right-1.5 h-5 w-5 p-0 opacity-0 group-hover:opacity-100 transition-all duration-300",onClick:f=>{f.stopPropagation(),$(o)},children:e.jsx(me,{className:"h-3 w-3"})})]},`photo-${o}`)),e.jsxs("button",{type:"button",onClick:()=>M(!0),onDragOver:t=>Y(t,"photos"),onDragLeave:W,onDrop:m,className:`aspect-square rounded-lg border-2 border-dashed flex flex-col items-center justify-center gap-1.5 cursor-pointer transition-all duration-200 ${C==="photos"?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/40 hover:bg-muted/30"}`,children:[e.jsx(ue,{className:"h-6 w-6 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Upload"})]})]})]}),e.jsx(Q,{onSave:d,isDirty:a,isSubmitting:!1,showPreview:!0,onPreview:te,previewLabel:"Träger ansehen"}),e.jsx(Te,{open:n!==null,onOpenChange:()=>N(null),children:e.jsx(Se,{className:"max-w-4xl p-0 bg-black/95 border-none overflow-hidden",children:n!==null&&c[n]&&e.jsxs("div",{className:"relative flex items-center justify-center min-h-[60vh]",children:[e.jsx("img",{src:c[n].preview,alt:"Vorschau",className:"max-w-full max-h-[80vh] object-contain"}),c.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"absolute left-2 top-1/2 -translate-y-1/2 text-white hover:bg-white/20 h-10 w-10 p-0",onClick:()=>N(n===0?c.length-1:n-1),children:e.jsx(Be,{className:"h-6 w-6"})}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 text-white hover:bg-white/20 h-10 w-10 p-0",onClick:()=>N(n===c.length-1?0:n+1),children:e.jsx(Ke,{className:"h-6 w-6"})})]}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[n+1," / ",c.length]})]})})}),e.jsx(ge,{open:k,onOpenChange:O,onSelect:async t=>{if(t.file_url)try{const f=await(await fetch(t.file_url)).blob(),R=t.name||"logo";b(new File([f],R,{type:f.type||"image/*"}))}catch{}},filterType:"image/",title:"Logo auswählen"}),e.jsx(ge,{open:V,onOpenChange:M,onSelect:t=>{t.file_url&&H([t.file_url])},onSelectMany:t=>H(t.map(o=>
1o.file_url).filter(Boolean)),filterType:"image/",title:"Foto auswählen"})]})}function tr({value:a,onValueChange:d,placeholder:y="Ansprechpartner auswählen...",className:u,traegerId:b}){const[i,g]=x.useState(!1),c=xe(),j=b||c,{data:H=[],isLoading:$}=Xe(j),I=(n,N)=>`${n.charAt(0)}${N.charAt(0)}`.toUpperCase(),C=H,p=C.find(n=>n.id===a);return e.jsxs(Pe,{open:i,onOpenChange:g,children:[e.jsx(_e,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":i,className:ee("w-full justify-between",u),children:[p?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(le,{className:"h-6 w-6",children:[e.jsx(ce,{src:p.foto_url||""}),e.jsx(de,{className:"text-xs",children:I(p.vorname,p.nachname)})]}),e.jsxs("span",{children:[p.vorname," ",p.nachname]}),e.jsxs("span",{className:"text-muted-foreground",children:["- ",p.position]})]}):y,e.jsx(Me,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Ce,{className:"w-full p-0 z-[1000] bg-background border border-border",align:"start",children:e.jsxs(Le,{className:"bg-background",children:[e.jsx(Fe,{placeholder:"Ansprechpartner suchen..."}),e.jsxs(Ae,{children:[e.jsx(De,{children:$?"Lädt...":j?"Keine Ansprechpartner für diesen Träger gefunden.":"Keine Ansprechpartner gefunden."}),e.jsx(Ie,{children:C.map(n=>e.jsx(Ee,{value:`${n.vorname} ${n.nachname} ${n.position}`,onSelect:()=>{d(n.id===a?"":n.id),g(!1)},className:"cursor-pointer hover:bg-accent hover:text-accent-foreground",children:e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsxs(le,{className:"h-8 w-8",children:[e.jsx(ce,{src:n.foto_url||""}),e.jsx(de,{className:"text-xs",children:I(n.vorname,n.nachname)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[n.vorname," ",n.nachname]}),e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:n.position}),n.kitas&&n.kitas.length>0&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:n.kitas[0].Einrichtungsname})]}),e.jsx(Ve,{className:ee("h-4 w-4",a===n.id?"opacity-100":"opacity-0")})]})},n.id))})]})]})})]})}function ar(){const{form:a,isDirty:d,saveForm:y,traegerId:u}=X();J();const b=()=>{window.open(`/t/${u}`,"_blank")};return e.jsxs("div",{className:"flex flex-col min-h-screen",children:[e.jsxs("div",{className:"flex-1 space-y-4 sm:space-y-6 p-0 sm:p-6 pb-24",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10 shrink-0",children:e.jsx(je,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold",children:"Adresse & Kontakt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Kontaktinformationen und Standort Ihres Trägers"})]})]}),e.jsx(re,{...a,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{control:a.control,name:"strasse",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"StraÃe"}),e.jsx(L,{children:e.jsx(F,{placeholder:"MusterstraÃe 123",...i})}),e.jsx(_,{})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(T,{control:a.control,name:"postleitzahl_id",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"Postleitzahl"}),e.jsx(L,{children:e.jsx(F,{type:"number",placeholder:"12345",...i,onChange:g=>i.onChange(parseInt(g.target.value)||void 0)})}),e.jsx(_,{})]})}),e.jsx(T,{control:a.control,name:"ort",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"Ort"}),e.jsx(L,{children:e.jsx(F,{placeholder:"Musterstadt",...i})}),e.jsx(_,{})]})})]}),e.jsx(T,{control:a.control,name:"website",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"Website URL"}),e.jsx(L,{children:e.jsx(F,{placeholder:"https://www.beispiel-traeger.de",...i})}),e.jsx(_,{})]})}),e.jsx(T,{control:a.control,name:"ansprechpartner_id",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"Hauptansprechpartner"}),e.jsx(tr,{value:i.value||"",onValueChange:g=>{i.onChange(g)},placeholder:"Ansprechpartner auswählen...",traegerId:u}),e.jsx(_,{})]})})]})})]}),e.jsx(Q,{onSave:y,isDirty:d,showPreview:!0,onPreview:b,previewLabel:"Träger ansehen"})]})}function nr(){const{form:a,isDirty:d,saveForm:y,traegerId:u}=X();J();const b=()=>{window.open(`/t/${u}`,"_blank")};return e.jsxs("div",{className:"flex flex-col min-h-screen",children:[e.jsxs("div",{className:"flex-1 space-y-4 sm:sp
1ace-y-6 p-0 sm:p-6 pb-24",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10 shrink-0",children:e.jsx(ve,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold",children:"Social Media"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verknüpfen Sie Ihre Social Media Kanäle"})]})]}),e.jsx(re,{...a,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{control:a.control,name:"instagram",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"Instagram"}),e.jsx(L,{children:e.jsx(F,{placeholder:"https://instagram.com/ihr-traeger",...i})}),e.jsx(_,{})]})}),e.jsx(T,{control:a.control,name:"facebook",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"Facebook"}),e.jsx(L,{children:e.jsx(F,{placeholder:"https://facebook.com/ihr-traeger",...i})}),e.jsx(_,{})]})}),e.jsx(T,{control:a.control,name:"linkedin",render:({field:i})=>e.jsxs(S,{children:[e.jsx(P,{children:"LinkedIn"}),e.jsx(L,{children:e.jsx(F,{placeholder:"https://linkedin.com/company/ihr-traeger",...i})}),e.jsx(_,{})]})})]})})]}),e.jsx(Q,{onSave:y,isDirty:d,showPreview:!0,onPreview:b,previewLabel:"Träger ansehen"})]})}function vr(){const{section:a}=Ue(),{profile:d,hasRole:y}=He(),u=xe();if(y("admin")&&!u)return e.jsx($e,{navigation:e.jsx(pe,{}),children:null});if(!u)return e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Kein Träger zugewiesen"}),e.jsx("p",{className:"text-muted-foreground",children:"Sie sind keinem Träger zugewiesen und können diese Seite nicht bearbeiten."})]})});const b=()=>{switch(a){case"grundinfo":return e.jsx(rr,{});case"bilder":return e.jsx(sr,{});case"adresse":return e.jsx(ar,{});case"social-media":return e.jsx(nr,{});default:return e.jsx(Oe,{to:"/traeger/grundinfo",replace:!0})}};return e.jsx(Ze,{traegerId:u,children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(pe,{}),e.jsx("div",{className:"flex-1 p-3 sm:p-6",children:b()})]})})}export{vr 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.