1import{r as T,s as m,j as e,d as be}from"./index-CLTM18rh.js";import{u as se}from"./AdminContext-B2hLlcqc.js";import{e as ae,f as te}from"./recurrence-CPz9Lig3.js";const J={event:"Veranstaltung",news:"News-Artikel",dossier:"Dossier",product:"Produkt"},fe={event:"bg-blue-100 text-blue-700 dark:bg-blue-950/50 dark:text-blue-300",news:"bg-amber-100 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300",dossier:"bg-purple-100 text-purple-700 dark:bg-purple-950/50 dark:text-purple-300",product:"bg-green-100 text-green-700 dark:bg-green-950/50 dark:text-green-300"},ve=".pdf,.doc,.docx,.txt,.md,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain",g="w-full px-3 py-2 rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 text-zinc-900 dark:text-white placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-transparent text-sm";function f({label:t,children:r,hint:n}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:t}),r,n&&e.jsx("p",{className:"mt-1 text-xs text-zinc-400",children:n})]})}function K({allTags:t,tagIds:r,onChange:n}){return t.length===0?null:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(a=>{const s=r.includes(a.id);return e.jsx("button",{type:"button",onClick:()=>n(s?r.filter(o=>o!==a.id):[...r,a.id]),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors ${s?"border-transparent text-white":"border-zinc-200 dark:border-zinc-700 text-zinc-500 dark:text-zinc-400 hover:border-zinc-300 dark:hover:border-zinc-600"}`,style:s?{backgroundColor:"#6b7280"}:void 0,children:a.name},a.id)})})]})}function Z(){return e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-zinc-400",children:"Englisch"}),e.jsx("div",{className:"flex-1 h-px bg-zinc-200 dark:bg-zinc-800"})]})}function Q({url:t,onRemove:r}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Bild (automatisch aus dem Dokument)"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("img",{src:t,alt:"",loading:"lazy",className:"h-24 w-auto rounded-lg border border-zinc-200 dark:border-zinc-700 object-cover"}),e.jsx("button",{type:"button",onClick:r,className:"text-xs text-zinc-400 hover:text-red-500 transition-colors",children:"Bild entfernen"})]})]})}function je({data:t,onChange:r,allTags:n,primaryTagNames:a}){const s=t.recurrence,o=s?ae(s):[],{permissions:c,eventOrganizers:k}=se(),j=c.perm_events_own&&!c.perm_events;return T.useEffect(()=>{j&&k.length>0&&!k.includes(t.organizer??"")&&r("organizer",k[0])},[j]),e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{label:"Titel *",children:e.jsx("input",{className:g,value:t.title??"",onChange:l=>r("title",l.target.value)})}),s&&e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-900 bg-amber-50 dark:bg-amber-950/20 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-xs font-semibold text-amber-900 dark:text-amber-200",children:["⺠Wiederkehrende Veranstaltung â ",o.length," ",o.length===1?"Termin":"Termine"]}),e.jsx("button",{type:"button",onClick:()=>r("recurrence",null),className:"text-xs text-amber-700 dark:text-amber-300 hover:underline shrink-0",children:"Als Einzeltermin"})]}),o.length>0&&e.jsxs("p",{className:"text-xs text-amber-700 dark:text-amber-300 font-mono",children:[te(o[0]),o.length>1&&` ⦠${te(o[o.length-1])}`]}),e.jsx("p",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Beim Veröffentlichen wird pro Termin eine Veranstaltung erstellt. Feinabstimmung danach unter /admin/events."})]}),e.jsx(f,{label:s?"Datum (erster Termin)":"Datum",children:e.jsx("input",{type:"date",className:g,value:t.date??"",onChange:l=>r("date",l.target.value)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(f,{label:"Startzeit",children:e.jsx("input",{type:"time",className:g,value:t.time_from??"",onChange:l=>r("time_from",l.target.value)})}),e.jsx(f,{label:"Endzeit",children:e.jsx("input",{type:"time",className:g,value:t.time_to??"",onChange:l=>r("time_to",l.target.value)})})]}),e.jsx(f,{label:"Enddatum",children:e.jsx("input",{type:"date",className:g,value:t.end_date??"",onChange:l=>r("end_date",l.target.value)})}),e.jsx(f,{label:"Zusätzliche Informationen zum Ort",children:e.jsx("input",{className:g,value:t.location??"",onChange:l=>r("location",l.target.value)})}),e.jsxs(f,{label:"Adresse",children:[e.jsx("input",{className:g,value:t.address??"",onChange:l=>r("address",l.target.value)}),t.lat&&t.lng?e.jsxs("p",{className:"mt-1 text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3",fill:"
1currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z",clipRule:"evenodd"})}),String(t.lat),", ",String(t.lng)]}):t._geocoding?e.jsxs("p",{className:"mt-1 text-xs text-zinc-400 flex items-center gap-1",children:[e.jsx("span",{className:"w-3 h-3 rounded-full border border-current border-t-transparent animate-spin inline-block"}),"Koordinaten werden gesuchtâ¦"]}):t._geocodeFailed?e.jsx("p",{className:"mt-1 text-xs text-amber-600 dark:text-amber-400",children:"Adresse nicht gefunden â Koordinaten manuell prüfen."}):null]}),e.jsx(f,{label:"Veranstalter",children:j?k.length>1?e.jsx("select",{className:g,value:t.organizer??k[0],onChange:l=>r("organizer",l.target.value),children:k.map(l=>e.jsx("option",{value:l,children:l},l))}):e.jsx("input",{className:`${g} opacity-70 cursor-not-allowed`,readOnly:!0,value:t.organizer||k[0]||"",title:"Als Kurator ist der Veranstalter fest vorgegeben."}):e.jsx("input",{className:g,value:t.organizer??"",onChange:l=>r("organizer",l.target.value)})}),e.jsx(f,{label:"Beschreibung",children:e.jsx("textarea",{rows:4,className:g,value:t.description??"",onChange:l=>r("description",l.target.value)})}),e.jsx(f,{label:"Hauptkategorie",children:e.jsxs("select",{className:g,value:t.category??"",onChange:l=>r("category",l.target.value),children:[e.jsx("option",{value:"",children:"â wählen â"}),a.map(l=>e.jsx("option",{value:l,children:l},l))]})}),e.jsx(K,{allTags:n,tagIds:t._tagIds??[],onChange:l=>r("_tagIds",l)}),t._coverImageUrl?e.jsx(Q,{url:t._coverImageUrl,onRemove:()=>r("_coverImageUrl",null)}):null,e.jsx(Z,{}),e.jsx(f,{label:"Titel (EN)",children:e.jsx("input",{className:g,value:t.title_en??"",onChange:l=>r("title_en",l.target.value),placeholder:"English titleâ¦"})}),e.jsx(f,{label:"Beschreibung (EN)",children:e.jsx("textarea",{rows:4,className:g,value:t.description_en??"",onChange:l=>r("description_en",l.target.value),placeholder:"English descriptionâ¦"})})]})}function ke({data:t,onChange:r,allTags:n}){const a=["Präsidium","OGK","Kommission Bäckeranlage","Kommission Raumplanung","Politik","Verein","Quartier","Sonstiges"];return e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{label:"Titel *",children:e.jsx("input",{className:g,value:t.title??"",onChange:s=>r("title",s.target.value)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(f,{label:"Kategorie",children:e.jsx("select",{className:g,value:t.category??"",onChange:s=>r("category",s.target.value),children:a.map(s=>e.jsx("option",{children:s},s))})}),e.jsx(f,{label:"Datum",children:e.jsx("input",{type:"date",className:g,value:t.published_at??"",onChange:s=>r("published_at",s.target.value)})})]}),e.jsx(f,{label:"Autor",children:e.jsx("input",{className:g,value:t.author??"",onChange:s=>r("author",s.target.value)})}),e.jsx(f,{label:"Zusammenfassung",children:e.jsx("textarea",{rows:2,className:g,value:t.summary??"",onChange:s=>r("summary",s.target.value)})}),e.jsx(f,{label:"Text",children:e.jsx("textarea",{rows:8,className:g,value:t.body??"",onChange:s=>r("body",s.target.value)})}),e.jsx(K,{allTags:n,tagIds:t._tagIds??[],onChange:s=>r("_tagIds",s)}),t._coverImageUrl?e.jsx(Q,{url:t._coverImageUrl,onRemove:()=>r("_coverImageUrl",null)}):null,e.jsx(Z,{}),e.jsx(f,{label:"Titel (EN)",children:e.jsx("input",{className:g,value:t.title_en??"",onChange:s=>r("title_en",s.target.value),placeholder:"English titleâ¦"})}),e.jsx(f,{label:"Zusammenfassung (EN)",children:e.jsx("textarea",{rows:2,className:g,value:t.summary_en??"",onChange:s=>r("summary_en",s.target.value),placeholder:"English summaryâ¦"})}),e.jsx(f,{label:"Text (EN)",children:e.jsx("textarea",{rows:8,className:g,value:t.body_en??"",onChange:s=>r("body_en",s.target.value),placeholder:"English bodyâ¦"})})]})}function ye({data:t,onChange:r,allTags:n}){const a=["In Bearbeitung","In Vernehmlassung","Abgeschlossen"],s=t.milestones??[];function o(c){r("milestones",s.filter((k,j)=>j!==c))}return e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{label:"Titel *",children:e.jsx("input",{className:g,value:t.title??"",onChange:c=>r("title",c.target.value)})}),e.jsx(f,{label:"Status",children:e.jsx("select",{className:g,value:t.status??"In Bearbeitung",onChange:c=>r("status",c.target.value),children:a.map(c=>e.jsx("option",{children:c},c))})}),e.jsx(f,{label:"Beschreibung",children:e.jsx("textarea",{rows:3,className:g,value:t.description??"",onChange:c=>r("description",c.target.value)})}),e.jsx(f,{label:"Details",children:e.jsx("textarea",{rows:4,className:g,value:t.detail??"",onChange:c=>r("detail",c.target.value)})}),e.jsx(K,{allTags:n,tagIds:t._tagIds??[],onChange:c=>r("_tagIds",c)}),s.length>0&&e.jsx(f,{label:`Meilensteine (${s.length})`,hint:"Erkannt aus dem Dokument. Werden beim Veröffentlichen automatisch angelegt â entferne hier, was nicht passt. Nachträglich editierbar im Dossier-Edit.",children:e.jsx("ul",{className:"space-y-1.5",children:s.map((c,k)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx("span",{className:"shrink-0 font-mono text-xs text-zinc-500 mt-0.5",children:c.planned_date||c.planned_year||"â"}),e.jsx("span",{className:"flex-1 text-zinc-700 dark:text-zinc-300",children:c.title??"â"}),e.jsx("button",{type:"button",onClick:()=>o(k),className:"shrink-0 text-xs text-zinc-400 hover:text-red-600 dark:hover:text-red-400","aria-label":"Meilenstein entfernen",children:"Ã"})]},k))})}),e.jsx(Z,{}),e.jsx(f,{label:"Titel (EN)",children:e.jsx("input",{className:g,value:t.title_en??"",onChange:c=>r("title_en",c.target.value),placeholder:"English titleâ¦"})}),e.jsx(f,{label:"Beschreibung (EN)",children:e.jsx("textarea",{rows:3,className:g,value:t.description_en??"",onChange:c=>r("description_en",c.target.value),placeholder:"English descriptionâ¦"})}),e.jsx(f,{label:"Details (EN)",children:e.jsx("textarea",{rows:4,className:g,value:t.detail_en??"",onChange:c=>r("detail_en",c.target.value),placeholder:"English detailâ¦"})})]})}function _e({data:t,onChange:r,allTags:n}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{label:"Name *",children:e.jsx("input",{className:g,value:t.name??"",onChange:a=>r("name",a.target.value)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(f,{label:"Preis (CHF)",children:e.jsx("input",{type:"number",step:"0.05",className:g,value:t.price??"",onChange:a=>r("price",a.target.value?parseFloat(a.target.value):null)})}),e.jsx(f,{label:"Kategorie",children:e.jsx("input",{className:g,value:t.category??"",onChange:a=>r("category",a.target.value)})})]}),e.jsx(f,{label:"Beschreibung",children:e.jsx("textarea",{rows:3,className:g,value:t.description??"",onChange:a=>r("description",a.target.value)})}),e.jsx(K,{allTags:n,tagIds:t._tagIds??[],onChange:a=>r("_tagIds",a)}),t._coverImageUrl?e.jsx(Q,{url:t._coverImageUrl,onRemove:()=>r("_coverImageUrl",null)}):null,e.jsx(Z,{}),e.jsx(f,{label:"Name (EN)",children:e.jsx("input",{className:g,value:t.name_en??"",onChange:a=>r("name_en",a.target.value),placeholder:"English nameâ¦"})}),e.jsx(f,{label:"Beschreibung (EN)",children:e.jsx("textarea",{rows:3,className:g,value:t.description_en??"",onChange:a=>r("description_en",a.target.value),placeholder:"English descriptionâ¦"})})]})}function Ne({draft:t,onUpdate:r,onUpdateMultiple:n,onDiscard:a,onPublish:s,onSetDuplicateAction:o,onSetMergeFeld:c,onBestehend:k,onSetFlyer:j,onSetPlanerVerknuepfen:l,publishingAll:A,allowedTypes:_,tagsByType:z,primaryTagNames:y}){const{data:u,type:v}=t,E=_.has(v),I=t.status==="published",D=t.status==="publishing",N=v==="event"&&!!u.recurrence,p=!N,S=t.duplicateAction??"create",$=t.duplicate?.matchId,P=t.bestehend!==void 0;T.useEffect(()=>{if(!$||P||t.type!=="event")return;let w=!0;return m.from("events").select("id, title, date, end_date, time_from, time_to, location, address, organizer, description, image_url, info_url").eq("id",$).maybeSingle().then(({data:F})=>{w&&k(t.id,F??null)}),()=>{w=!1}},[$,P,t.id,t.type,k]);const B=t.bestehend?ie(t.data,t.bestehend):[],U=t.mergeFelder??{},L=!!t.duplicate&&p&&S==="replace",R=!!t.duplicate&&p&&S==="merge";return e.jsxs("div",{className:`bg-white dark:bg-zinc-900 rounded-xl border overflow-hidden transition-opacity ${I?"opacity-60 border-green-200 dark:border-green-900":"border-zinc-200 dark:border-zinc-800"}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-zinc-100 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-800/50",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`text-sm font-bold px-3 py-1 rounded-lg ${fe[v]??"bg-zinc-100 text-zinc-600"}`,children:J[v]??v}),I&&e.jsx("span",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:L?"â Ersetzt":R?"â Zusammengeführt":"â Publiziert"})]}),e.jsxs("span",{className:"text-xs text-zinc-400 dark:text-zinc-500",children:["aus ",t.fileName]})]}),!I&&e.jsx("button",{onClick:()=>a(t.id),className:"text-xs text-zinc-400 hover:text-red-500 transition-colors",children:"Verwerfen"})]}),!I&&!E&&e.jsxs("div",{className:"p-5",children:[e.jsxs("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:["Keine Berechtigung zum Erstellen von ",J[v]??v,"."]}),e.jsx("button",{onClick:()=>a(t.id),className:"mt-3 px-4 py-2 text-sm text-zinc-500 hover:text-zinc-900 dark:hover:text-white transition-colors",children:"Verwerfen"})]}),!I&&E&&e.jsxs("div",{className:"p-5",children:[t.planer&&t.type==="event"&&!N&&e.jsxs("div",{className:"flex items-start gap-2.5 mb-4 px-3.5 py-3 rounded-lg bg-sky-50 dark:bg-sky-950/30 border border-sky-200 dark:border-sky-800/50",children:[e.jsx("svg",{className:"w-4 h-4 text-sky-500 dark:text-sky-400 mt-0.5 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-sky-700 dark:text-sky-400",children:"Vorhaben im Veranstaltungsplaner gefunden"}),e.jsx("p",{className:"text-xs text-sky-600 dark:text-sky-500 mt-0.5",children:t.planer.message}),e.jsxs("label",{className:"flex items-start gap-2 mt-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.planerVerknuepfen===!0,onChange:w=>l(t.id,w.target.checked),className:"mt-0.5 w-3.5 h-3.5 rounded text-sky-600 focus:ring-sky-500"}),e.jsxs("span",{className:"text-xs text-sky-800 dark:text-sky-200",children:[e.jsxs("span",{className:"font-medium",children:["Nach dem Veröffentlichen mit «",t.planer.planTitle,"» verknüpfen"]}),t.planer.bestehende>0&&" â als zusätzlichen Anlass dieses Vorhabens",!t.planer.sicher&&e.jsx("span",{className:"block text-sky-600 dark:text-sky-500",children:"Nur das Datum stimmt überein, der Titel nicht â bitte prüfen."})]})]})]})]}),t.duplicate&&e.jsxs("div",{className:"flex items-start gap-2.5 mb-4 px-3.5 py-3 rounded-lg bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800/50",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-500 dark:text-amber-400 mt-0.5 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-amber-700 dark:text-amber-400",children:"Mögliches Duplikat erkannt"}
1),e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500 mt-0.5",children:t.duplicate.message}),e.jsxs("a",{href:t.duplicate.matchUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-xs font-medium text-amber-700 dark:text-amber-300 hover:underline",children:["Bestehenden Eintrag öffnen",e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]}),p?e.jsxs("div",{className:"mt-2.5 flex flex-col gap-1.5 border-t border-amber-200/70 dark:border-amber-800/40 pt-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:`dup-${t.id}`,checked:S==="create",onChange:()=>o(t.id,"create"),className:"mt-0.5 w-3.5 h-3.5 text-red-600 focus:ring-red-500"}),e.jsxs("span",{className:"text-xs text-amber-800 dark:text-amber-200",children:[e.jsx("span",{className:"font-medium",children:"Trotzdem neu anlegen"})," â als zusätzlichen Eintrag erstellen"]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:`dup-${t.id}`,checked:S==="replace",onChange:()=>o(t.id,"replace"),className:"mt-0.5 w-3.5 h-3.5 text-red-600 focus:ring-red-500"}),e.jsxs("span",{className:"text-xs text-amber-800 dark:text-amber-200",children:[e.jsx("span",{className:"font-medium",children:"Bestehenden Eintrag ersetzen"})," â überschreibt den bestehenden Eintrag vollständig mit diesen Daten"]})]}),t.type==="event"&&e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:`dup-${t.id}`,checked:S==="merge",onChange:()=>o(t.id,"merge"),className:"mt-0.5 w-3.5 h-3.5 text-red-600 focus:ring-red-500"}),e.jsxs("span",{className:"text-xs text-amber-800 dark:text-amber-200",children:[e.jsx("span",{className:"font-medium",children:"Zusammenführen"})," â nur die angehakten Felder in den bestehenden Eintrag übernehmen"]})]})]}):e.jsx("p",{className:"mt-2 text-xs text-amber-600 dark:text-amber-500",children:"Wiederkehrende Veranstaltung â wird als neue Terminserie angelegt."}),p&&t.type==="event"&&t.bestehend!==void 0&&(t.bestehend===null?e.jsx("p",{className:"mt-2 text-xs text-amber-600 dark:text-amber-500",children:"Der bestehende Eintrag liess sich nicht laden, darum kein Vergleich."}):e.jsx(Ce,{unterschiede:B,felder:U,onFeld:(w,F)=>c(t.id,w,F)}))]})]}),v==="event"&&e.jsx(je,{data:u,onChange:(w,F)=>r(t.id,w,F),onChangeMultiple:w=>n(t.id,w),allTags:z.event??[],primaryTagNames:y}),v==="news"&&e.jsx(ke,{data:u,onChange:(w,F)=>r(t.id,w,F),allTags:z.news??[]}),v==="dossier"&&e.jsx(ye,{data:u,onChange:(w,F)=>r(t.id,w,F),allTags:z.dossier??[]}),v==="product"&&e.jsx(_e,{data:u,onChange:(w,F)=>r(t.id,w,F),allTags:z.product??[]}),t.status==="error"&&e.jsx("p",{className:"mt-3 text-sm text-red-600 dark:text-red-400",children:t.errorMsg}),t.quelle&&t.type==="event"&&e.jsxs("label",{className:"mt-3 flex items-start gap-2 cursor-pointer rounded-lg border border-zinc-200 dark:border-zinc-700 px-3 py-2.5",children:[e.jsx("input",{type:"checkbox",checked:t.flyerAnhaengen===!0,onChange:w=>j(t.id,w.target.checked),className:"mt-0.5 w-4 h-4 accent-red-600"}),e.jsxs("span",{className:"text-xs text-zinc-700 dark:text-zinc-300",children:[e.jsxs("span",{className:"font-medium",children:["«",t.quelle.dateiname,"» an die Veranstaltung hängen"]}),e.jsxs("span",{className:"block text-zinc-500 dark:text-zinc-400 mt-0.5",children:["Die Datei, aus der diese Angaben stammen. Sie erscheint danach als Dokument bei der Veranstaltung, ",Math.round(t.quelle.groesse/1024)," KB."]})]})]}),!A&&e.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[e.jsx("button",{onClick:()=>s(t.id),disabled:D,className:"px-4 py-2 bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors",children:L?D?"Ersetzenâ¦":"Ersetzen":R?D?"Zusammenführenâ¦":"Zusammenführen":D?"Publizierenâ¦"
1:"Publizieren"}),e.jsx("button",{onClick:()=>a(t.id),className:"px-4 py-2 text-sm text-zinc-500 hover:text-zinc-900 dark:hover:text-white transition-colors",children:"Verwerfen"})]}),A&&D&&e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm text-zinc-500",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-red-500 border-t-transparent animate-spin"}),"Publizierenâ¦"]})]})]})}async function we(t){const r=async n=>{const a=`https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(n)}&format=json&limit=1`,o=await(await fetch(a,{headers:{"Accept-Language":"de"}})).json();return Array.isArray(o)&&o.length>0?{lat:parseFloat(o[0].lat).toFixed(6),lng:parseFloat(o[0].lon).toFixed(6)}:null};try{return await r(t)??await r(`${t}, Zürich`)}catch{return null}}async function ze(t){const{data:{session:r}}=await m.auth.getSession(),n=t.data,a=t.duplicate&&t.duplicateAction==="replace"?t.duplicate.matchId:null;if(t.type==="event"){const s=(n.category||"").trim()||"Sonstiges",{data:o}=await m.from("tags").select("id").eq("is_primary",!0).eq("name",s).limit(1);let c=o?.[0]?.id??null;if(!c){const{data:u}=await m.from("tags").select("id").eq("is_primary",!0).eq("name","Sonstiges").limit(1);c=u?.[0]?.id??null}const k={title:n.title,title_en:n.title_en||null,end_date:n.end_date||null,time_from:n.time_from||null,time_to:n.time_to||null,location:n.location||null,address:n.address||null,lat:n.lat?parseFloat(n.lat):null,lng:n.lng?parseFloat(n.lng):null,organizer:n.organizer||null,description:n.description||null,description_en:n.description_en||null,main_tag_id:c,image_url:n._coverImageUrl||null,info_url:n._infoUrl||null},j=n._tagIds??[],l=n.recurrence;if(l&&typeof l=="object"){const u=ae(l);if(u.length===0)return{error:"Wiederholung ergab keine Termine â bitte Datum/Zeitraum prüfen."};if(u.length>100)return{error:`Wiederholung ergäbe ${u.length} Termine â bitte Zeitraum verkleinern.`};const v=globalThis.crypto.randomUUID(),E=n.title?.trim()||null,I=u.map(p=>({...k,end_date:null,date:p,series_id:v,series_label:E,creator_id:r?.user.id})),{data:D,error:N}=await m.from("events").insert(I).select("id");return N?{error:N.message}:(j.length>0&&D&&await m.from("event_tags").insert(D.flatMap(p=>j.map(S=>({event_id:p.id,tag_id:S})))),{})}const A=async u=>{if(!t.quelle||t.flyerAnhaengen!==!0)return null;const{error:v}=await m.from("event_attachments").insert({event_id:u,title:"Flyer",file_path:t.quelle.pfad,file_name:t.quelle.dateiname,content_type:t.quelle.typ,size_bytes:t.quelle.groesse});return v?`Veranstaltung gespeichert, aber «${t.quelle.dateiname}» liess sich nicht anhängen: ${v.message}`:null};async function _(u){if(!t.planer||t.planerVerknuepfen!==!0)return null;const{error:v}=await m.from("event_plan_events").upsert({plan_id:t.planer.planId,event_id:u},{onConflict:"plan_id,event_id"});if(v)return`Veranstaltung erstellt, aber die Verknüpfung mit «${t.planer.planTitle}» scheiterte: ${v.message}`;await m.from("event_plans").update({event_id:u,updated_at:new Date().toISOString()}).eq("id",t.planer.planId).is("event_id",null);const{data:E}=await m.from("anlaesse").select("id").eq("event_plan_id",t.planer.planId).maybeSingle();return E&&await m.from("events").update({anlass_id:E.id}).eq("id",u),null}if(t.duplicate&&t.duplicateAction==="merge"){const u=t.mergeFelder??{},v=Object.entries(u).filter(([,p])=>p).map(([p])=>p);if(v.length===0)return{error:"Zusammenführen ohne angehaktes Feld ändert nichts. Wähle mindestens eines, oder verwirf den Entwurf."};const E={};for(const p of v){const S=p==="image_url"?"_coverImageUrl":p==="info_url"?"_infoUrl":p;E[p]=n[S]||null}const{error:I}=await m.from("events").update(E).eq("id",t.duplicate.matchId);if(I)return{error:I.message};const D=await A(t.duplicate.matchId);if(D)return{error:D};const N=await _(t.duplicate.matchId);return N?{error:N}:{}}if(a){const{error:u}=await m.from("events").update({...k,date:n.date||null}).eq("id",a);if(u)return{error:u.message};await m.from("event_tags").delete().eq("event_id",a),j.length>0&&await m.from("event_tags").insert(j.map(I=>({event_id:a,tag_id:I})));const v=await A(a);if(v)return{error:v};const E=await _(a);return E?{error:E}:{}}const{data:z,error:y}=await m.from("events").insert({...k,date:n.date||null,creator_id:r?.user.id}).select("id").single();if(y)return{error:y.message};if(j.length>0&&z&&await m.from("event_tags").insert(j.map(u=>({event_id:z.id,tag_id:u}))),z){const u=await A(z.id);if(u)return{error:u}}if(z){const u=await _(z.id);if(u)return{error:u}}return{}}if(t.type==="news"){const s={title:n.title,title_en:n.title_en||null,summary:n.summary||null,summary_en:n.summary_en||null,body:n.body||null,body_en:n.body_en||null,author:n.author||null,category:n.category||"Sonstiges",published_at:n.published_at||new Date().toISOString().slice(0,10),image_url:n._coverImageUrl||null},o=n._tagIds??[];
1if(a){const{error:j}=await m.from("news_articles").update(s).eq("id",a);return j?{error:j.message}:(await m.from("news_tags").delete().eq("article_id",a),o.length>0&&await m.from("news_tags").insert(o.map(l=>({article_id:a,tag_id:l}))),{})}const{data:c,error:k}=await m.from("news_articles").insert({...s,author_id:r?.user.id}).select("id").single();return k?{error:k.message}:(o.length>0&&c&&await m.from("news_tags").insert(o.map(j=>({article_id:c.id,tag_id:j}))),{})}if(t.type==="dossier"){const s={title:n.title,title_en:n.title_en||null,description:n.description||null,description_en:n.description_en||null,status:n.status||"In Bearbeitung",detail:n.detail||null,detail_en:n.detail_en||null},o=n._tagIds??[];if(a){const{error:l}=await m.from("dossiers").update(s).eq("id",a);return l?{error:l.message}:(await m.from("dossier_tags").delete().eq("dossier_id",a),o.length>0&&await m.from("dossier_tags").insert(o.map(A=>({dossier_id:a,tag_id:A}))),{})}const{data:c,error:k}=await m.from("dossiers").insert({...s,is_archived:!1}).select("id").single();if(k)return{error:k.message};o.length>0&&c&&await m.from("dossier_tags").insert(o.map(l=>({dossier_id:c.id,tag_id:l})));const j=n.milestones??[];if(c&&Array.isArray(j)&&j.length>0){const l=/^\d{4}-\d{2}-\d{2}$/,A=j.map((_,z)=>{const y=_,u=typeof y.title=="string"?y.title.trim():"";if(!u)return null;const v=typeof y.planned_date=="string"?y.planned_date.trim():"",E=l.test(v)?v:null;let I=null;if(!E&&(typeof y.planned_year=="number"||typeof y.planned_year=="string")){const p=typeof y.planned_year=="number"?y.planned_year:parseInt(String(y.planned_year).trim(),10);Number.isInteger(p)&&p>=1900&&p<=2100&&(I=p)}const D=typeof y.external_url=="string"?y.external_url.trim():"",N=/^https?:\/\//i.test(D)?D:null;return{dossier_id:c.id,title:u,title_en:typeof y.title_en=="string"&&y.title_en.trim()?y.title_en.trim():null,description:typeof y.description=="string"&&y.description.trim()?y.description.trim():null,description_en:typeof y.description_en=="string"&&y.description_en.trim()?y.description_en.trim():null,planned_date:E,planned_year:I,external_url:N,sort_order:z}}).filter(_=>_!==null);if(A.length>0){const{error:_}=await m.from("dossier_milestones").insert(A);_&&console.warn("[publishDraft dossier] milestone insert failed",_)}}return{}}if(t.type==="product"){const s={name:n.name,name_en:n.name_en||null,description:n.description||null,description_en:n.description_en||null,price:n.price??null,category:n.category||null,image_url:n._coverImageUrl||null},o=n._tagIds??[];if(a){const{error:j}=await m.from("products").update(s).eq("id",a);return j?{error:j.message}:(await m.from("product_tags").delete().eq("product_id",a),o.length>0&&await m.from("product_tags").insert(o.map(l=>({product_id:a,tag_id:l}))),{})}const{data:c,error:k}=await m.from("products").insert({...s,active:!0}).select("id").single();return k?{error:k.message}:(o.length>0&&c&&await m.from("product_tags").insert(o.map(j=>({product_id:c.id,tag_id:j}))),{})}return{error:"Unbekannter Typ"}}function Fe({onDone:t}){const{permissions:r,eventOrganizers:n}=se(),a=r.perm_events_own&&!r.perm_events,s=r.perm_import||a&&n.length>0,o=new Set([...r.perm_events||r.perm_events_own?["event"]:[],...r.perm_news?["news"]:[],...r.perm_dossiers?["dossier"]:[],...r.perm_products?["product"]:[]]),[c,k]=T.useState({}),[j,l]=T.useState([]);T.useEffect(()=>{Promise.all([m.from("tags").select("id, name").eq("for_events",!0).order("sort_order").order("name"),m.from("tags").select("id, name").eq("for_news",!0).order("sort_order").order("name"),m.from("tags").select("id, name").eq("for_dossiers",!0).order("sort_order").order("name"),m.from("tags").select("id, name").eq("for_products",!0).order("sort_order").order("name"),m.from("tags").select("name").eq("is_primary",!0).order("name")]).then(([i,b,x,d,h])=>{k({event:i.data??[],news:b.data??[],dossier:x.data??[],product:d.data??[]}),l((h.data??[]).map(V=>V.name))})},[]);const A=T.useRef(null),[_,z]=T.useState([]),[y,u]=T.useState(""),[v,E]=T.useState("auto"),[I,D]=T.useState(!1),[N,p]=T.useState([]),[S,$]=T.useState(null),[P,B]=T.useState(!1),[U,L]=T.useState(!1);function R(i){z(Array.from(i.target.files??[])),u(""),p([]),$(null)}function w(i){i.preventDefault(),B(!1);const b=Array.from(i.dataTransfer.files);b.length>0&&(z(b),u(""),p([]),$(null))}async function F(i){const b=i.filter(x=>x.type==="event"&&x.data.address&&!x.data.lat);for(const x of b){p(h=>h.map(V=>V.id===x.id?{...V,data:{...V.data,_geocoding:!0}}:V)),await new Promise(h=>setTimeout(h,400));const d=await we(x.data.address);p(h=>h.map(V=>V.id===x.id?{...V,data:{...V.data,_geocoding:!1,_geocodeFailed:!d,...d??{}}}:V))}}async function le(){const i=y.trim();if(_.length===0&&!i)return;D(!0),$(null),p([]);const{data:{session:b}}=await m.auth.getSession();try{let x;if(_.length>0){const q=[];for(const C of _){const G=(C.name.split(".").pop()||"bin").toLowerCase(),ge=`imports/${Date.now()}-${Math.random().toString(36).slice(2)}.${G}`,{data:X,error:ee}=await m.storage.from("documents").upload(ge,C,{contentType:C.type||void 0});if(ee||!X){$(`Upload fehlgeschlagen: ${ee?.message??"unbekannter Fehler"}`),D(!1);return}
1q.push({path:X.path,name:C.name,mime:C.type||"application/octet-stream"})}x={typeHint:v,storageFiles:q}}else x={typeHint:v,url:i};const d=await fetch("/api/admin/import",{method:"POST",headers:{Authorization:`Bearer ${b?.access_token??""}`,"Content-Type":"application/json"},body:JSON.stringify(x)});let h;const V=await d.text();try{h=JSON.parse(V)}catch{$(`Server-Fehler (HTTP ${d.status}): ${V.slice(0,200)}`);return}if(!d.ok){$(h.error??`HTTP ${d.status}`);return}const H=[];for(const q of h.results){if(q.drafts.length===0){const C=q.error?`«${q.fileName}»: ${q.error}`:`Keine Inhalte aus «${q.fileName}» extrahiert.`;$(G=>[G,C].filter(Boolean).join(" "))}for(const C of q.drafts)H.push({id:Math.random().toString(36).slice(2),fileName:q.fileName,type:C.type,data:C.data,status:"pending",duplicate:C.duplicate,quelle:q.quelle,flyerAnhaengen:!!q.quelle?.typ.includes("pdf"),duplicateAction:C.duplicate?"create":void 0,planer:C.planer,planerVerknuepfen:C.planer?C.planer.sicher:void 0})}p(H),F(H)}catch(x){$(x instanceof Error?x.message:"Unbekannter Fehler")}finally{D(!1)}}function oe(i,b,x){p(d=>d.map(h=>h.id===i?{...h,data:{...h.data,[b]:x}}:h))}function ce(i,b){p(x=>x.map(d=>d.id===i?{...d,data:{...d.data,...b}}:d))}function de(i){const x=N.find(d=>d.id===i)?.quelle?.pfad;x&&!N.some(d=>d.id!==i&&d.quelle?.pfad===x)&&m.storage.from("documents").remove([x]),p(d=>d.filter(h=>h.id!==i))}function me(i,b){p(x=>x.map(d=>d.id===i?{...d,duplicateAction:b}:d))}const ue=T.useCallback((i,b)=>{p(x=>x.map(d=>{if(d.id!==i)return d;const h=b?De(ie(d.data,b)):{};return{...d,bestehend:b,mergeFelder:h}}))},[]);function pe(i,b){p(x=>x.map(d=>d.id===i?{...d,flyerAnhaengen:b}:d))}function xe(i,b,x){p(d=>d.map(h=>h.id===i?{...h,mergeFelder:{...h.mergeFelder??{},[b]:x}}:h))}async function Y(i){const b=N.find(d=>d.id===i);if(!b||!o.has(b.type))return;p(d=>d.map(h=>h.id===i?{...h,status:"publishing"}:h));const{error:x}=await ze(b);p(d=>d.map(h=>h.id===i?{...h,status:x?"error":"published",errorMsg:x}:h))}async function he(){L(!0);const i=N.filter(b=>(b.status==="pending"||b.status==="error")&&o.has(b.type));for(const b of i)await Y(b.id);L(!1)}const W=N.filter(i=>(i.status==="pending"||i.status==="error")&&o.has(i.type)).length,M=N.filter(i=>i.status==="published").length,O=N.length;return s?e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("button",{onClick:t,className:"text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.jsx("h1",{className:"text-xl font-bold text-zinc-900 dark:text-white",children:"KI-Import"})]}),N.length===0&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{onClick:()=>A.current?.click(),onDragOver:i=>{i.preventDefault(),B(!0)},onDragEnter:i=>{i.preventDefault(),B(!0)},onDragLeave:()=>B(!1),onDrop:w,className:`border-2 border-dashed rounded-xl p-10 text-center cursor-pointer transition-colors group ${P?"border-red-500 bg-red-50 dark:bg-red-950/20":"border-zinc-300 dark:border-zinc-700 hover:border-red-400 dark:hover:border-red-600"}`,children:[e.jsx("svg",{className:`w-8 h-8 mx-auto mb-3 transition-colors ${P?"text-red-500":"text-zinc-300 dark:text-zinc-600 group-hover:text-red-400"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),e.jsx("p",{className:"text-sm font-medium text-zinc-600 dark:text-zinc-400",children:_.length>0?`${_.length} Datei${_.length>1?"en":""} ausgewählt`:"Dateien auswählen oder hier ablegen"}),e.jsx("p",{className:"text-xs text-zinc-400 dark:text-zinc-500 mt-1",children:"PDF, Word (.docx), Textdatei"}),_.length>0&&e.jsx("ul",{className:"mt-3 space-y-0.5",children:_.map(i=>e.jsx("li",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:i.name},i.name))}),e.jsx("input",{ref:A,type:"file",accept:ve,multiple:!0,className:"hidden",onChange:R})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-px bg-zinc-200 dark:bg-zinc-800"}),e.jsx("span",{className:"text-xs font-medium text-zinc-400 dark:text-zinc-500",children:"oder"}),e.jsx("div",{className:"flex-1 h-px bg-zinc-200 dark:bg-zinc-800"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-2",children:"Von einer Webseite"}),e.jsx("input",{type:"url",value:y,onChange:i=>{u(i.target.value),i.target.value&&z([])},onBlur:i=>u(be(i.target.value)),placeholder:"https://⦠oder www.â¦",className:g}),e.jsx("p",{className:"text-xs text-zinc-400 dark:text-zinc-500 mt-1.5",children:"Der Inhalt der Seite wird ausgelesen und anal
1ysiert â z. B. eine Veranstaltungsseite."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-3",children:"Inhaltstyp"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["auto","event","news","dossier","product"].filter(i=>i==="auto"||o.has(i)).map(i=>e.jsx("button",{onClick:()=>E(i),className:`px-3.5 py-1.5 rounded-lg text-sm font-medium transition-colors border ${v===i?"bg-red-600 text-white border-red-600":"bg-white dark:bg-zinc-800 text-zinc-600 dark:text-zinc-400 border-zinc-300 dark:border-zinc-700 hover:border-zinc-400"}`,children:i==="auto"?"Auto-erkennen":J[i]},i))}),v==="auto"&&e.jsx("p",{className:"text-xs text-zinc-400 mt-2",children:"Import erkennt den Typ anhand des Dokumentinhalts automatisch."})]}),S&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:S}),e.jsx("button",{onClick:le,disabled:_.length===0&&!y.trim()||I,className:"flex items-center gap-2 px-5 py-2.5 bg-red-600 hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition-colors",children:I?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white border-t-transparent animate-spin"}),_.length>0?"Analysiert Dokumentâ¦":"Analysiert Webseiteâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),"Importieren"]})})]}),N.length>0&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{children:W>0?e.jsx("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:M>0?`${M} von ${O} publiziert`:`${O} Entwurf${O>1?"e":""} zur Ãberprüfung`}):e.jsxs("p",{className:"text-sm text-green-600 dark:text-green-400 font-medium",children:["Alle ",M," Einträge publiziert."]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[W>=2&&!U&&e.jsxs("button",{onClick:he,className:"flex items-center gap-2 px-4 py-2 bg-red-600 hover:bg-red-700 text-white text-sm font-medium rounded-lg transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Alle erstellen (",W,")"]}),U&&e.jsxs("span",{className:"flex items-center gap-2 text-sm text-zinc-500",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-red-500 border-t-transparent animate-spin"}),M,"/",O," publiziertâ¦"]}),e.jsx("button",{onClick:()=>{p([]),z([]),u("")},className:"text-xs text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",children:"Neu importieren"})]})]}),S&&e.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-400",children:S}),N.map(i=>e.jsx(Ne,{draft:i,onUpdate:oe,onUpdateMultiple:ce,onDiscard:de,onPublish:Y,onSetDuplicateAction:me,onSetMergeFeld:xe,onBestehend:ue,onSetFlyer:pe,onSetPlanerVerknuepfen:(b,x)=>p(d=>d.map(h=>h.id===b?{...h,planerVerknuepfen:x}:h)),publishingAll:U,allowedTypes:o,tagsByType:c,primaryTagNames:j},i.id)),W===0&&M>0&&e.jsx("button",{onClick:t,className:"px-5 py-2.5 bg-zinc-900 dark:bg-zinc-100 text-white dark:text-zinc-900 text-sm font-medium rounded-lg hover:opacity-90 transition-opacity",children:"Zurück zum Dashboard"})]})]}):e.jsx("div",{className:"py-20 text-center text-zinc-400 text-sm",children:"Keine Berechtigung zum Importieren."})}const Ee=[{key:"title",label:"Titel"},{key:"date",label:"Datum"},{key:"end_date",label:"Enddatum"},{key:"time_from",label:"Beginn"},{key:"time_to",label:"Ende"},{key:"location",label:"Ort"},{key:"address",label:"Adresse"},{key:"organizer",label:"Veranstalter"},{key:"description",label:"Beschreibung"},{key:"image_url",label:"Bild",entwurf:"_coverImageUrl"},{key:"info_url",label:"Infolink",entwurf:"_infoUrl"}],Ie=t=>t==null?"":String(t).trim(),re=(t,r)=>{const n=Ie(r);return n?t==="time_from"||t==="time_to"?n.slice(0,5):n:""};function ie(t,r){const n=[];
1for(const a of Ee){const s=re(a.key,r[a.key]),o=re(a.key,t[a.entwurf??a.key]);s!==o&&(!s&&!o||n.push({key:a.key,label:a.label,alt:s,neu:o,nurNeu:!s&&!!o,nurAlt:!!s&&!o}))}return n}function De(t){return Object.fromEntries(t.map(r=>[r.key,r.nurNeu]))}function ne({text:t,leer:r}){return t?e.jsxs("span",{className:"text-zinc-700 dark:text-zinc-300 break-words",children:[t.slice(0,220),t.length>220?"â¦":""]}):e.jsx("span",{className:"text-zinc-400 italic",children:r})}function Ce({unterschiede:t,felder:r,onFeld:n}){if(t.length===0)return e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-2",children:"Kein Unterschied gefunden: Der Entwurf sagt dasselbe wie der bestehende Eintrag. Dann genügt «Verwerfen»."});const a=t.filter(s=>r[s.key]).length;return e.jsxs("div",{className:"mt-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2 mb-1.5",children:[e.jsxs("p",{className:"text-xs font-semibold text-amber-700 dark:text-amber-300",children:[t.length," ",t.length===1?"Unterschied":"Unterschiede"]}),e.jsx("p",{className:"text-[11.5px] text-amber-600 dark:text-amber-500",children:a===0?"Vorgeschlagen: nichts übernehmen, alles bleibt wie es ist.":`Vorgeschlagen: ${a} ${a===1?"Feld":"Felder"} übernehmen.`})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800/50 divide-y divide-amber-200/60 dark:divide-amber-800/30 overflow-hidden",children:t.map(s=>e.jsxs("div",{className:"px-2.5 py-2 text-[12px] bg-white/60 dark:bg-zinc-900/40",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("span",{className:"font-semibold text-zinc-700 dark:text-zinc-200 w-24 shrink-0",children:s.label}),e.jsxs("label",{className:"ml-auto flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r[s.key]??!1,onChange:o=>n(s.key,o.target.checked),className:"w-3.5 h-3.5 accent-red-600"}),e.jsx("span",{className:r[s.key]?"text-red-700 dark:text-red-400 font-medium":"text-zinc-500",children:r[s.key]?"übernehmen":"behalten"})]})]}),e.jsxs("div",{className:"mt-1 grid sm:grid-cols-2 gap-x-3 gap-y-1",children:[e.jsxs("div",{className:r[s.key]?"opacity-50":"",children:[e.jsx("p",{className:"text-[10.5px] uppercase tracking-wide text-zinc-400",children:"bisher"}),e.jsx(ne,{text:s.alt,leer:"leer"})]}),e.jsxs("div",{className:r[s.key]?"":"opacity-50",children:[e.jsx("p",{className:"text-[10.5px] uppercase tracking-wide text-zinc-400",children:"aus dem Import"}),e.jsx(ne,{text:s.neu,leer:"leer"})]})]}),s.nurAlt&&r[s.key]&&e.jsx("p",{className:"mt-1 text-[11.5px] text-red-700 dark:text-red-400",children:"Der Import hat hier nichts. Ãbernehmen löscht, was dasteht."})]},s.key))})]})}export{Fe as AdminImport,Ce as VergleichsTabelle,De as mergeVorschlag,ie as unterschiede};
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.