PageSourceSearch

https://8004.ch/assets/AdminDossierForm-kmXKPWG6.js

js 8004.ch collected 2026-09-25 07:31:49 UTC 26,697 bytes, 1 lines download raw bytes

1import{r as h,s as k,j as t,d as I}from"./index-CLTM18rh.js";import{T as _e}from"./TagSelect-DLcoOtLD.js";import{u as Ne}from"./useTranslating-CBNKkigt.js";import{T as J}from"./TranslateButton-CwJtN3CI.js";import{b as ze}from"./bestaetige-CpNFuPQa.js";import"./callTranslate-CSi3EPWY.js";function ye(a,g){return a?"date":g!=null?"year":"none"}function K(a){return a.planned_date?a.planned_date:a.planned_year!=null?`${a.planned_year.toString().padStart(4,"0")}-01-01`:null}function we(a){if(!a)return null;const g="/storage/v1/object/public/images/",m=a.indexOf(g);return m!==-1?a.slice(m+g.length):null}function De(a){if(!a)return null;const g="/storage/v1/object/public/documents/",m=a.indexOf(g);return m!==-1?a.slice(m+g.length):null}function Y(a){try{const g=a.split("?")[0],m=g.slice(g.lastIndexOf("/")+1);return decodeURIComponent(m)||m}catch{return a}}function Ce(a){return a.toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Se(a){return a?new Date(a).toLocaleDateString("de-CH",{day:"numeric",month:"short",year:"numeric"}):"—"}const Ee={title:"",description:"",detail:"",external_url:"",slug:"",is_archived:!1,title_en:"",description_en:"",detail_en:"",owner_id:""};function y({label:a,children:g,hint:m}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-zinc-700 dark:text-zinc-300 mb-1.5",children:a}),g,m&&t.jsx("p",{className:"mt-1 text-xs text-zinc-400",children:m})]})}const b="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",Me="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 focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-transparent text-sm",A="flex-shrink-0 px-3 py-2 text-xs font-medium rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-50 dark:hover:bg-zinc-700 disabled:opacity-40 transition-colors whitespace-nowrap";function R({className:a="w-4 h-4"}){return t.jsxs("svg",{className:a,fill:"currentColor",viewBox:"0 0 16 16",children:[t.jsx("circle",{cx:"5",cy:"3",r:"1"}),t.jsx("circle",{cx:"11",cy:"3",r:"1"}),t.jsx("circle",{cx:"5",cy:"8",r:"1"}),t.jsx("circle",{cx:"11",cy:"8",r:"1"}),t.jsx("circle",{cx:"5",cy:"13",r:"1"}),t.jsx("circle",{cx:"11",cy:"13",r:"1"})]})}function qe({id:a,onSaved:g,onCancel:m}){const[c,D]=h.useState(Ee),[_,N]=h.useState(!!a),[z,d]=h.useState(!1),[u,f]=h.useState(null),{translating:v,busy:w,translate:M}=Ne(),[U,V]=h.useState([]),[Q,X]=h.useState([]);h.useEffect(()=>{k.from("profiles").select("id, display_name").eq("active",!0).order("display_name").then(({data:e})=>X(e??[]))},[]);const[x,E]=h.useState([]),ee=h.useRef(new Map),[te,O]=h.useState(new Set),[$,H]=h.useState(new Set),[L,ne]=h.useState(new Set),[F,P]=h.useState({}),[B,q]=h.useState(null),[re,W]=h.useState(null);h.useEffect(()=>{a&&(Promise.all([k.from("dossiers").select("*").eq("id",a).single(),k.from("dossier_tags").select("tag_id").eq("dossier_id",a)]).then(([{data:e},{data:i}])=>{e&&D({title:e.title??"",description:e.description??"",detail:e.detail??"",external_url:e.external_url??"",slug:e.slug??"",is_archived:e.is_archived??!1,title_en:e.title_en??"",description_en:e.description_en??"",detail_en:e.detail_en??"",owner_id:e.owner_id??""}),V((i??[]).map(r=>r.tag_id)),N(!1)}),k.from("dossier_milestones").select("*").eq("dossier_id",a).order("sort_order").then(({data:e})=>{const i=(e??[]).map(n=>({id:n.id,title:n.title??"",description:n.description??null,title_en:n.title_en??null,description_en:n.description_en??null,planned_date:n.planned_date??null,planned_year:n.planned_year??null,links:Array.isArray(n.links)?n.links:[],images:Array.isArray(n.images)?n.images:[],documents:Array.isArray(n.documents)?n.documents:[],external_url:n.external_url??null,image_url:n.image_url??null,sort_order:n.sort_order??0}));
1E(i),ee.current=new Map(i.map(n=>[n.id,structuredClone(n)]));const r={};for(const n of i)r[n.id]=ye(n.planned_date,n.planned_year);P(r)}))},[a]);function j(e,i){D(r=>({...r,[e]:i}))}function T(e){H(i=>i.has(e)?i:new Set(i).add(e))}function p(e,i){E(r=>r.map(n=>n.id===e?{...n,...i}:n)),T(e)}function Z(e){O(i=>{const r=new Set(i);return r.has(e)?r.delete(e):r.add(e),r})}function ie(){const e=`new-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,i={id:e,title:"Neuer Meilenstein",description:null,title_en:null,description_en:null,planned_date:null,planned_year:null,links:[],images:[],documents:[],external_url:null,image_url:null,sort_order:x.length,_isNew:!0};E(r=>[...r,i]),O(r=>new Set(r).add(e)),P(r=>({...r,[e]:"none"})),T(e)}async function se(e){if(!await ze('Diesen Meilenstein wirklich entfernen? Die Änderung wird mit „Speichern" wirksam.'))return;const i=x.find(r=>r.id===e);E(r=>r.filter(n=>n.id!==e)),i&&!i._isNew&&ne(r=>new Set(r).add(e)),H(r=>{const n=new Set(r);return n.delete(e),n}),O(r=>{const n=new Set(r);return n.delete(e),n})}function le(e,i){e===i||e<0||i<0||E(r=>{const n=[...r],[l]=n.splice(e,1);return n.splice(i,0,l),n.map((s,o)=>(s.sort_order!==o&&T(s.id),{...s,sort_order:o}))})}function ae(){if(x.length<2)return;const e=[...x].sort((i,r)=>{const n=K(i),l=K(r);return n&&l?n.localeCompare(l):n?-1:l?1:0});E(e.map((i,r)=>(i.sort_order!==r&&T(i.id),{...i,sort_order:r})))}function oe(e){const i=x.find(r=>r.id===e);i&&p(e,{links:[...i.links,{url:"",label:null}]})}function ce(e,i,r){const n=x.find(l=>l.id===e);n&&p(e,{links:n.links.map((l,s)=>s===i?{...l,...r}:l)})}function de(e,i){const r=x.find(n=>n.id===e);r&&p(e,{links:r.links.filter((n,l)=>l!==i)})}function ue(e,i,r){const n=x.find(o=>o.id===e);if(!n||i===r)return;const l=[...n.links],[s]=l.splice(i,1);l.splice(r,0,s),p(e,{links:l})}async function xe(e,i){const r=x.find(S=>S.id===e);if(!r)return;const n=(i.name.split(".").pop()||"png").toLowerCase(),l=`dossier-milestones/${Date.now()}-${Math.random().toString(36).slice(2)}.${n}`,{data:s,error:o}=await k.storage.from("images").upload(l,i,{contentType:i.type||void 0});if(o||!s){f(`Bild-Upload fehlgeschlagen: ${o?.message??"unbekannter Fehler"}`);return}const C=k.storage.from("images").getPublicUrl(s.path).data.publicUrl;p(e,{images:[...r.images,{url:C,alt:null}]})}function pe(e,i,r){const n=x.find(l=>l.id===e);n&&p(e,{images:n.images.map((l,s)=>s===i?{...l,...r}:l)})}async function he(e,i){const r=x.find(s=>s.id===e);if(!r)return;const n=r.images[i]?.url;p(e,{images:r.images.filter((s,o)=>o!==i)});const l=we(n??null);l&&await k.storage.from("images").remove([l])}function me(e,i,r){const n=x.find(o=>o.id===e);if(!n||i===r)return;const l=[...n.images],[s]=l.splice(i,1);l.splice(r,0,s),p(e,{images:l})}async function ge(e,i){const r=x.find(S=>S.id===e);if(!r)return;const n=(i.name.split(".").pop()||"pdf").toLowerCase(),l=`dossier-milestones/${Date.now()}-${Math.random().toString(36).slice(2)}.${n}`,{data:s,error:o}=await k.storage.from("documents").upload(l,i,{contentType:i.type||void 0});if(o||!s){f(`Dokument-Upload fehlgeschlagen: ${o?.message??"unbekannter Fehler"}`);return}const C=k.storage.from("documents").getPublicUrl(s.path).data.publicUrl;p(e,{documents:[...r.documents,{url:C,label:i.name}]})}function fe(e,i,r){const n=x.find(l=>l.id===e);n&&p(e,{documents:n.documents.map((l,s)=>s===i?{...l,...r}:l)})}async function be(e,i){const r=x.find(s=>s.id===e);if(!r)return;const n=r.documents[i]?.url;p(e,{documents:r.documents.filter((s,o)=>o!==i)});const l=De(n??null);l&&await k.storage.from("documents").remove([l])}function ve(e,i,r){const n=x.find(o=>o.id===e);if(!n||i===r)return;const l=[...n.documents],[s]=l.splice(i,1);l.splice(r,0,s),p(e,{documents:l})}async function G(e,i,r){await M(e,i,r)}async function ke(e){e.preventDefault(),d(!0),f(null);const i={title:c.title,description:c.description||null,detail:c.detail||null,external_url:c.external_url||null,slug:c.slug||null,is_archived:c.is_archived,title_en:c.title_en||null,description_en:c.description_en||null,detail_en:c.detail_en||null,owner_id:c.owner_id||null};let r=a;if(a){const{error:n}=await k.from("dossiers").update(i).eq("id",a);if(n){f(n.message),d(!1);return}}else{const{data:n,error:l}=await k.from("dossiers").insert(i).select("id").single();if(l||!n){f(l?.message??"Fehler"),d(!1);return}r=n.id}if(!r){d(!1);return}if(await k.from("dossier_tags").delete().eq("dossier_id",r),U.length>0&&await k.from("dossier_tags").insert(U.map(n=>({dossier_id:r,tag_id:n}))),L.size>0){const{error:n}=await k.from("dossier_milestones").delete().in("id",[...L]);if(n){f(`Meilenstein löschen: ${n.message}`),d(!1);return}}for(const n of x){const l=$.has(n.id);if(!n._isNew&&!l)continue;
1const s={dossier_id:r,title:n.title,description:n.description??null,title_en:n.title_en??null,description_en:n.description_en??null,planned_date:n.planned_date??null,planned_year:n.planned_year??null,links:n.links,images:n.images,documents:n.documents,external_url:n.links[0]?.url??null,image_url:n.images[0]?.url??null,sort_order:n.sort_order};if(n._isNew){const{error:o}=await k.from("dossier_milestones").insert(s);if(o){f(`Meilenstein anlegen: ${o.message}`),d(!1);return}}else{const{error:o}=await k.from("dossier_milestones").update(s).eq("id",n.id);if(o){f(`Meilenstein speichern: ${o.message}`),d(!1);return}}}d(!1),g(a?void 0:r)}return _?t.jsx("div",{className:"py-20 text-center text-zinc-400 text-sm",children:"Lädt…"}):t.jsxs("form",{onSubmit:ke,className:"max-w-3xl space-y-8 pb-32",children:[t.jsx("h1",{className:"text-xl font-bold text-zinc-900 dark:text-white",children:a?"Dossier bearbeiten":"Neues Dossier"}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(y,{label:"Titel *",children:t.jsx("input",{required:!0,className:b,value:c.title,onChange:e=>j("title",e.target.value)})}),t.jsx(y,{label:"Titel (EN)",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{className:b+" flex-1",value:c.title_en,onChange:e=>j("title_en",e.target.value),placeholder:"English title…"}),t.jsx("button",{type:"button",onClick:()=>M("title_en",c.title,e=>j("title_en",e)),disabled:!c.title.trim()||w,className:A,children:v==="title_en"?"…":"→ EN"})]})}),t.jsx(y,{label:"Slug",hint:"Optional. Wird in der URL verwendet, z. B. /quartier/raumplanung/<slug>.",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{className:b+" flex-1 font-mono",value:c.slug,onChange:e=>j("slug",e.target.value),placeholder:"z. B. parkplatz-hohlstrasse"}),t.jsx("button",{type:"button",onClick:()=>j("slug",Ce(c.title)),className:A,children:"↻ aus Titel"})]})}),t.jsx(y,{label:"Verantwortliche Person",hint:"Bekommt eine Erinnerung per E-Mail, wenn das Dossier seit mehr als 2 Monaten keinen Meilenstein-Eintrag mehr hatte. Ohne Auswahl wird keine Erinnerung versendet — das Dossier erscheint weiterhin in der Routinen-Übersicht «Vernachlässigte Dossiers».",children:t.jsxs("select",{className:b,value:c.owner_id,onChange:e=>j("owner_id",e.target.value),children:[t.jsx("option",{value:"",children:"— nicht zugewiesen —"}),Q.map(e=>t.jsx("option",{value:e.id,children:e.display_name},e.id))]})}),t.jsx(y,{label:"Beschreibung",children:t.jsx("textarea",{rows:3,className:b,value:c.description,onChange:e=>j("description",e.target.value)})}),t.jsx(y,{label:"Beschreibung (EN)",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("textarea",{rows:3,className:b+" flex-1",value:c.description_en,onChange:e=>j("description_en",e.target.value),placeholder:"English description…"}),t.jsx("button",{type:"button",onClick:()=>M("description_en",c.description,e=>j("description_en",e)),disabled:!c.description.trim()||w,className:A,children:v==="description_en"?"…":"→ EN"})]})}),t.jsx(y,{label:"Details",children:t.jsx("textarea",{rows:3,className:b,value:c.detail,onChange:e=>j("detail",e.target.value),placeholder:"Ergänzende Informationen zum aktuellen Stand"})}),t.jsx(y,{label:"Details (EN)",children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx("textarea",{rows:3,className:b+" flex-1",value:c.detail_en,onChange:e=>j("detail_en",e.target.value),placeholder:"English detail…"}),t.jsx("button",{type:"button",onClick:()=>M("detail_en",c.detail,e=>j("detail_en",e)),disabled:!c.detail.trim()||w,className:A,children:v==="detail_en"?"…":"→ EN"})]})}),t.jsx(y,{label:"Externer Link",children:t.jsx("input",{type:"url",className:b,value:c.external_url,onBlur:e=>j("external_url",I(e.target.value)),onChange:e=>j("external_url",e.target.value),placeholder:"https://…"})}),t.jsx(y,{label:"Tags",children:t.jsx(_e,{itemType:"dossiers",selectedIds:U,onChange:V})}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-zinc-700 dark:text-zinc-300",children:[t.jsx("input",{type:"checkbox",checked:c.is_archived,onChange:e=>j("is_archived",e.target.checked)}
1),'Archiviert (in „Rückblick" verschoben)']})]}),a&&t.jsxs("div",{className:"border-t border-zinc-200 dark:border-zinc-800 pt-8",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 gap-3 flex-wrap",children:[t.jsx("h2",{className:"text-base font-semibold text-zinc-900 dark:text-white",children:"Meilensteine"}),t.jsxs("div",{className:"flex items-center gap-4",children:[x.length>1&&t.jsxs("button",{type:"button",onClick:ae,className:"flex items-center gap-1.5 text-sm text-zinc-500 dark:text-zinc-400 hover:text-zinc-800 dark:hover:text-zinc-200 font-medium",title:"Alle Meilensteine chronologisch nach Datum sortieren. Einträge ohne Datum landen am Ende.",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})}),"Nach Datum sortieren"]}),t.jsxs("button",{type:"button",onClick:ie,className:"flex items-center gap-1.5 text-sm text-red-600 dark:text-red-400 hover:underline font-medium",children:[t.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Meilenstein hinzufügen"]})]})]}),x.length===0&&t.jsx("p",{className:"text-sm text-zinc-400 mb-4",children:"Noch keine Meilensteine."}),t.jsx("div",{className:"space-y-3",children:x.map((e,i)=>{const r=te.has(e.id),n=$.has(e.id)||e._isNew,l=re===i&&B!==i;return t.jsxs("div",{onDragOver:s=>{s.preventDefault(),W(i)},onDrop:()=>{B!==null&&le(B,i),q(null),W(null)},className:`rounded-xl border overflow-hidden transition-colors ${l?"border-red-400 bg-red-50/40 dark:border-red-700 dark:bg-red-900/10":"border-zinc-200 dark:border-zinc-800"} ${B===i?"opacity-50":""}`,children:[t.jsxs("div",{className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-zinc-50 dark:hover:bg-zinc-800/50 transition-colors",children:[t.jsx("button",{type:"button",draggable:!0,onDragStart:()=>q(i),onDragEnd:()=>{q(null),W(null)},className:"cursor-grab active:cursor-grabbing text-zinc-400 hover:text-zinc-600 dark:text-zinc-500 dark:hover:text-zinc-300 flex-shrink-0",title:"Zum Verschieben ziehen","aria-label":"Meilenstein verschieben",children:t.jsx(R,{})}),t.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold border-2 border-zinc-300 dark:border-zinc-600 text-zinc-400",children:i+1}),t.jsxs("button",{type:"button",onClick:()=>Z(e.id),className:"flex-1 flex items-center gap-3 min-w-0 text-left",children:[t.jsx("span",{className:"flex-1 text-sm font-medium text-zinc-900 dark:text-white truncate",children:e.title||"(kein Titel)"}),(e.planned_date||e.planned_year!=null)&&t.jsx("span",{className:"text-xs text-zinc-400 dark:text-zinc-500 flex-shrink-0",children:e.planned_date?Se(e.planned_date):e.planned_year}),n&&t.jsx("span",{title:e._isNew?"Neuer, noch nicht gespeicherter Meilenstein":"Ungespeicherte Änderungen",className:"inline-flex items-center gap-1 text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300 flex-shrink-0",children:"● geändert"})]}),t.jsx("button",{type:"button",onClick:()=>Z(e.id),"aria-label":r?"Einklappen":"Ausklappen",className:"flex-shrink-0 p-1",children:t.jsx("svg",{className:`w-4 h-4 text-zinc-400 transition-transform ${r?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),r&&t.jsxs("div",{className:"px-4 pb-4 border-t border-zinc-100 dark:border-zinc-800 pt-3 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Titel *"}),t.jsx("input",{className:b,value:e.title,onChange:s=>p(e.id,{title:s.target.value})})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Beschreibung"}),t.jsx("textarea",{rows:2,className:b,value:e.description??"",onChange:s=>p(e.id,{description:s.target.value})})]}),t.jsxs("div",{className:"border-t border-zinc-100 dark:border-zinc-800 pt-3 space-y-2",children:[t.jsx("p",{className:"text-xs font-medium text-zinc-400",children:"EN"}),t.jsxs("div",{className:"flex gap-2 items-start",children:[t.jsx("input",{className:b+" flex-1",placeholder:"Title EN…",value:e.title_en??"",onChange:s=>p(e.id,{title_en:s.target.value})}),t.jsx(J,{source:e.title,onClick:()=>G(`${e.id}-title_en`,e.title,s=>p(e.id,{title_en:s})),loading:v===`${e.id}-title_en`,disabled:w&&v!==`${e.id}-title_en`})]}),t.jsxs("div",{className:"flex gap-2 items-start",children:[t.jsx("textarea",{rows:2,className:b+" flex-1",placeholder:"Description 
1EN…",value:e.description_en??"",onChange:s=>p(e.id,{description_en:s.target.value})}),t.jsx(J,{source:e.description??"",onClick:()=>G(`${e.id}-description_en`,e.description??"",s=>p(e.id,{description_en:s})),loading:v===`${e.id}-description_en`,disabled:w&&v!==`${e.id}-description_en`})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Zeitangabe"}),t.jsx("div",{className:"flex gap-1 rounded-lg border border-zinc-200 dark:border-zinc-700 p-0.5 text-xs",children:["date","year","none"].map(s=>{const o=(F[e.id]??"date")===s,C=s==="date"?"Datum":s==="year"?"Nur Jahr":"Keine";return t.jsx("button",{type:"button",onClick:()=>{P(je=>({...je,[e.id]:s}));const S={};s!=="date"&&(S.planned_date=null),s!=="year"&&(S.planned_year=null),p(e.id,S)},className:`flex-1 px-2 py-1.5 rounded-md font-medium transition-colors ${o?"bg-red-600 text-white":"text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700"}`,children:C},s)})}),(F[e.id]??"date")==="date"&&t.jsx("input",{type:"date",className:Me+" w-full mt-2",value:e.planned_date??"",onChange:s=>p(e.id,{planned_date:s.target.value||null})}),(F[e.id]??"date")==="year"&&t.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",placeholder:"z.B. 1787 oder 2024",className:b+" mt-2",value:e.planned_year??"",onChange:s=>{const o=s.target.value.replace(/[^0-9]/g,"");if(o===""){p(e.id,{planned_year:null});return}const C=parseInt(o,10);p(e.id,{planned_year:Number.isFinite(C)?C:null})}})]}),t.jsx($e,{links:e.links,onAdd:()=>oe(e.id),onChange:(s,o)=>ce(e.id,s,o),onRemove:s=>de(e.id,s),onReorder:(s,o)=>ue(e.id,s,o)}),t.jsx(Le,{images:e.images,onAdd:s=>xe(e.id,s),onChange:(s,o)=>pe(e.id,s,o),onRemove:s=>he(e.id,s),onReorder:(s,o)=>me(e.id,s,o)}),t.jsx(Te,{documents:e.documents,onAdd:s=>ge(e.id,s),onChange:(s,o)=>fe(e.id,s,o),onRemove:s=>be(e.id,s),onReorder:(s,o)=>ve(e.id,s,o)}),t.jsx("div",{className:"pt-2 border-t border-zinc-100 dark:border-zinc-800",children:t.jsx("button",{type:"button",onClick:()=>se(e.id),className:"text-xs text-zinc-400 hover:text-red-600 dark:hover:text-red-400 transition-colors",children:"Meilenstein entfernen"})})]})]},e.id)})})]}),u&&t.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:u}),t.jsxs("div",{className:"sticky bottom-4 flex items-center gap-3 bg-white/95 dark:bg-zinc-900/95 backdrop-blur rounded-lg px-4 py-3 border border-zinc-200 dark:border-zinc-700 shadow-sm",children:[t.jsx("button",{type:"submit",disabled:z||!c.title.trim(),className:"px-5 py-2.5 text-sm font-medium bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white rounded-lg transition-colors",children:z?"Speichert…":"Speichern"}),t.jsx("button",{type:"button",onClick:m,className:"px-3 py-1.5 text-sm text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-white",children:"Abbrechen"}),($.size>0||L.size>0)&&t.jsx("span",{className:"ml-auto text-xs text-amber-700 dark:text-amber-300",children:(()=>{const e=x.filter(l=>l._isNew).length,i=[...$].filter(l=>!x.find(s=>s.id===l)?._isNew).length,r=L.size,n=[];return e&&n.push(`${e} neu`),i&&n.push(`${i} geändert`),r&&n.push(`${r} entfernt`),n.length?`Ungespeichert: ${n.join(" · ")}`:""})()})]})]})}function $e({links:a,onAdd:g,onChange:m,onRemove:c,onReorder:D}){const[_,N]=h.useState(null);return t.jsxs("div",{className:"border-t border-zinc-100 dark:border-zinc-800 pt-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-500 dark:text-zinc-400",children:"Links"}),t.jsx("button",{type:"button",onClick:g,className:"text-xs text-red-600 dark:text-red-400 hover:underline font-medium",children:"+ Link"})]}),a.length===0?t.jsx("p",{className:"text-xs text-zinc-400 italic",children:"Noch keine Links."}):t.jsx("div",{className:"space-y-2",children:a.map((z,d)=>t.jsxs("div",{onDragOver:u=>u.preventDefault(),onDrop:()=>{_!==null&&D(_,d),N(null)},className:`flex items-center gap-2 ${_===d?"opacity-50":""}`,children:[t.jsx("span",{draggable:!0,onDragStart:()=>N(d),onDragEnd:()=>N(null),className:"cursor-grab active:cursor-grabbing text-zinc-400 hover:text-zinc-600 shrink-0",children:t.jsx(R,{className:"w-3.5 h-3.5"})}),t.jsx("input",{placeholder:"Bezeichnung (optional)",value:z.label??"",onChange:u=>m(d,{label:u.target.value||null}),className:b+" flex-1"}),t.jsx("input",{type:"url",placeholder:"https://… oder www.…",onBlur:u=>m(d,{url:I(u.target.value)}),value:z.url,onChange:u=>m(d,{url:u.target.value}),className:b+" flex-[2]"}),t.jsx("button",{type:"button",onClick:()=>c(d),className:"text-zinc-400 hover:text-red-500 px-1",title:"Link entfernen",children:"×"})]},d))})]})}function Le({images:a,onAdd:g,onChange:m,onRemove:c,onReorder:D}){const[_,N]=h.useState(null),z=h.useRef(null);return t.jsxs("div",{className:"border-t border-zinc-100 dark:border-zinc-800 pt-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-500 dark:text-zinc-400",children:"Bilder"}),t.jsxs("label",{className:"text-xs text-red-600 dark:text-red-400 hover:underline font-medium cursor-pointer",children:["+ Bild hochladen",t.jsx("input",{ref:z,type:"file",accept:"image/*",className:"hidden",onChange:async d=>{const u=d.target.files?.[0];u&&await g(u),z.current&&(z.current.value="")}})]})]}),a.length===0?t.jsx("p",{className:"text-xs text-zinc-400 italic",children:"Noch keine Bilder."}):t.jsx("div",{className:"space-y-2",children:a.map((d,u)=>t.jsxs("div",{onDragOver:f=>f.preventDefault(),onDrop:()=>{_!==null&&D(_,u),N(null)},className:`flex items-center gap-2 ${_===u?"opacity-50":""}`,children:[t.jsx("span",{draggable:!0,onDragStart:()=>N(u),onDragEnd:()=>N(null),className:"cursor-grab active:cursor-grabbing text-zinc-400 hover:text-zinc-600 shrink-0",children:t.jsx(R,{className:"w-3.5 h-3.5"})}),t.jsx("img",{src:d.url,alt:"",loading:"lazy",className:"w-14 h-14 roun
1ded-lg object-cover border border-zinc-200 dark:border-zinc-700 shrink-0"}),t.jsx("input",{placeholder:"Alt-Text (optional)",value:d.alt??"",onChange:f=>m(u,{alt:f.target.value||null}),className:b+" flex-1"}),u===0&&t.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-zinc-100 dark:bg-zinc-800 text-zinc-500",children:"primär"}),t.jsx("button",{type:"button",onClick:()=>c(u),className:"text-zinc-400 hover:text-red-500 px-1",title:"Bild entfernen",children:"×"})]},u))})]})}const Be=".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,application/pdf";function Te({documents:a,onAdd:g,onChange:m,onRemove:c,onReorder:D}){const[_,N]=h.useState(null),[z,d]=h.useState(!1),u=h.useRef(null);return t.jsxs("div",{className:"border-t border-zinc-100 dark:border-zinc-800 pt-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-xs font-medium text-zinc-500 dark:text-zinc-400",children:"Dokumente"}),t.jsxs("label",{className:`text-xs font-medium ${z?"text-zinc-400 cursor-wait":"text-red-600 dark:text-red-400 hover:underline cursor-pointer"}`,children:[z?"Lädt hoch…":"+ Dokument hochladen",t.jsx("input",{ref:u,type:"file",accept:Be,className:"hidden",disabled:z,onChange:async f=>{const v=f.target.files?.[0];if(v){d(!0);try{await g(v)}finally{d(!1)}}u.current&&(u.current.value="")}})]})]}),a.length===0?t.jsx("p",{className:"text-xs text-zinc-400 italic",children:"Noch keine Dokumente. PDF, Word, Excel u. a."}):t.jsx("div",{className:"space-y-2",children:a.map((f,v)=>t.jsxs("div",{onDragOver:w=>w.preventDefault(),onDrop:()=>{_!==null&&D(_,v),N(null)},className:`flex items-center gap-2 ${_===v?"opacity-50":""}`,children:[t.jsx("span",{draggable:!0,onDragStart:()=>N(v),onDragEnd:()=>N(null),className:"cursor-grab active:cursor-grabbing text-zinc-400 hover:text-zinc-600 shrink-0",children:t.jsx(R,{className:"w-3.5 h-3.5"})}),t.jsx("svg",{className:"w-5 h-5 text-zinc-400 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),t.jsx("input",{placeholder:"Bezeichnung (optional)",value:f.label??"",onChange:w=>m(v,{label:w.target.value||null}),className:b+" flex-1"}),t.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-zinc-400 hover:text-red-600 dark:hover:text-red-400 underline truncate max-w-[8rem] shrink-0",title:Y(f.url),children:Y(f.url)}),t.jsx("button",{type:"button",onClick:()=>c(v),className:"text-zinc-400 hover:text-red-500 px-1",title:"Dokument entfernen",children:"×"})]},v))})]})}export{qe as AdminDossierForm};

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.