PageSourceSearch

https://www.infinityperspectives.de/assets/AdminQuoteEditor-BPA5V3Z6.js

js infinityperspectives.de collected 2026-10-10 01:46:42 UTC 42,178 bytes, 23 lines download raw bytes

1import{c as Re,r as a,s as h,j as e,ab as c,a7 as Pt,a8 as x,k as O,X as Dt,K as as,at as is,u as ls,aG as Me,T as _,ay as G,az as Q,aA as W,aB as J,aC as b,aH as os,ax as M,aj as cs,D as yt,m as Nt,n as wt,o as kt,ac as ds,M as us,ah as p}from"./index-WiYOppbq.js";import{_ as ms,p as ps,a as gs}from"./pdf.worker.min-dS6wF_D2.js";import{A as Ct}from"./AdminLayout-Bx-gy48z.js";import{C as D}from"./card-C_ptBL97.js";import{A as hs,a as xs,b as fs,c as _s,d as js,e as vs,f as bs,g as ys}from"./alert-dialog-hV8mD_Hw.js";import{c as Ns,f as E,l as Fe}from"./quote-calc-CVcD-aCj.js";import{a as ws}from"./pdf-download-C4huH6II.js";import{L as ks}from"./layout-template-BttYDPbV.js";import{F as Cs}from"./file-down-BSAHx4h-.js";import{S as Ss}from"./save-CYYJIimp.js";import{S as St}from"./send-CE7WhniT.js";import{E as As}from"./external-link-tJTWMExB.js";import{P as Oe}from"./plus-BUjSokme.js";import{I as At}from"./image-plus-BGb7D7LO.js";import{P as qs}from"./package-CJ2A47KB.js";import{T as Ps}from"./trash-2-9Wml9UHN.js";import"./sidebar-BhGg8DPR.js";import"./use-mobile-DmL4H4u1.js";import"./separator-CgfkoQb4.js";import"./skeleton-5fXjnHUF.js";import"./file-text-C8T1DGa8.js";import"./image-n7cmdYfv.js";import"./chart-column-ogzJM-AP.js";import"./receipt-aG5UuOtJ.js";import"./truck-6aimhdzq.js";import"./palette-CPVc6nvm.js";import"./wrench-DrbQI_C9.js";import"./settings-Ciuh58AF.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Ds=Re("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Es=Re("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Ts=Re("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]),zs={inquiry:"Shop-Anfrage",contact:"Kontaktformular",quote:"Bestehendes Angebot"};function Ls({onPick:i}){const[f,v]=a.useState(""),[k,m]=a.useState([]),[U,u]=a.useState(!1),[z,C]=a.useState(!1),R=a.useRef(null);return a.useEffect(()=>{if(f.trim().length<2){m([]);return}u(!0);const g=setTimeout(async()=>{const{data:S,error:L}=await h.rpc("search_customer_contacts",{_q:f.trim()});u(!1),!L&&S&&m(S)},220);return()=>clearTimeout(g)},[f]),a.useEffect(()=>{const g=S=>{var L;(L=R.current)!=null&&L.contains(S.target)||C(!1)};return window.addEventListener("mousedown",g),()=>window.removeEventListener("mousedown",g)},[]),e.jsxs("div",{ref:R,className:"relative",children:[e.jsx(c,{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"Kunde suchen (Name, E-Mail, Telefon)"}),e.jsxs("div",{className:"relative",children:[e.jsx(Pt,{className:"h-4 w-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(x,{value:f,placeholder:"Bestehenden Kontakt aus Anfragen laden …",onFocus:()=>C(!0),onChange:g=>{v(g.target.value),C(!0)},className:"pl-9"}),U&&e.jsx(O,{className:"h-4 w-4 absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"})]}),z&&f.trim().length>=2&&e.jsxs("div",{className:"absolute z-30 mt-1 w-full bg-background border border-border rounded-md shadow-lg max-h-80 overflow-auto",children:[k.length===0&&!U&&e.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Kein Treffer."}),k.map((g,S)=>e.jsx("button",{type:"button",onClick:()=>{i(g),C(!1),v(""),m([])},className:"w-full text-left p-3 hover:bg-accent/10 border-b border-border last:border-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:g.name||g.email}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[g.email,g.phone?` · ${g.phone}`:"",g.company?` · ${g.company}`:""]})]}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider bg-muted px-1.5 py-0.5 rounded shrink-0",children:zs[g.source]??g.source})]})},`${g.email}-${S}`))]})]})}function Us({value:i,onChange:f}){const[v,k]=a.useState(""),m=()=>{const u=v.trim();if(u&&/^\S+@\S+\.\S+$/.test(u)){if(i.includes(u)){k("");return}f([...i,u]),k("")}},U=u=>{u.key==="Enter"||u.key===","||u.key==="Tab"?(u.preventDefault(),m()):u.key==="Backspace"&&!v&&i.length&&f(i.slice(0,-1))};return e.jsxs("div",{children:[e.jsx(c,{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"CC-Empfänger"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 border border-input rounded-md p-2 bg-background min-h-[40px]",children:[i.map(u=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-accent/10 text-accent-foreground rounded px-2 py-0.5",children:[u,e.jsx("button",{type:"button",onClick:()=>f(i.filter(z=>z!==u)),className:"hover:text-destructive",children:e.jsx(Dt,{className:"h-3 w-3"})})]}
16,u)),e.jsx(x,{value:v,onChange:u=>k(u.target.value),onKeyDown:U,onBlur:m,placeholder:i.length?"":"[email protected], Enter zum Bestätigen",className:"border-0 shadow-none focus-visible:ring-0 flex-1 min-w-[160px] h-6 p-0"})]})]})}ms.workerSrc=ps;const Is=i=>{const f=[];return i!=null&&i.description&&f.push(String(i.description)),Array.isArray(i==null?void 0:i.longDescription)&&i.longDescription.length&&f.push(i.longDescription.join(`
17
18`)),f.filter(Boolean).join(`
19
20`)||(i==null?void 0:i.tagline)||""},Vs=i=>Array.isArray(i==null?void 0:i.features)&&i.features.length?i.features.map(f=>`• ${f}`).join(`
21`):"",Bs=i=>({item_type:"extra",product_slug:null,product_category:null,name:"",description:"",image_url:null,image_urls:[],delivery_scope:"",quantity:1,unit:"Stück",unit_price_cents:0,price_input:"",discount_type:"none",discount_value:0,sort_order:i,is_optional:!1});function qt(i){const f=String(i).replace(",",".").replace(/[^\d.-]/g,"");if(!f)return 0;const v=Number(f);return Number.isFinite(v)?Math.round(v*100):0}function F(i){return i?(i/100).toFixed(2).replace(".",","):""}const Ms=[{key:"prepay_100",label:"100 % Vorkasse",text:"Zahlung: 100 % Vorkasse nach Auftragsbestätigung."},{key:"split_50_50",label:"50 % Anzahlung + 50 % vor Auslieferung",text:"Zahlung: 50 % Anzahlung bei Auftragsbestätigung, 50 % vor Auslieferung."},{key:"custom",label:"Frei",text:""}];function fn(){const{id:i}=as(),[f]=is(),v=f.get("inquiryId"),k=ls(),m=!i||i==="neu",[U,u]=a.useState(!m||!!v),[z,C]=a.useState(!1),[R,g]=a.useState(!1),[S,L]=a.useState("draft"),[he,Et]=a.useState(""),[$e,Tt]=a.useState(""),[X,Y]=a.useState(""),[xe,ee]=a.useState(""),[T,te]=a.useState(""),[fe,se]=a.useState(""),[_e,Ke]=a.useState(""),[je,Ze]=a.useState(""),[ve,He]=a.useState(""),[ne,be]=a.useState(`Hi {{first_name}},
22
23vielen Dank für deine Anfrage. Ich habe dir hier persönlich ein Angebot zusammengestellt – schau es dir in Ruhe an. Bei Fragen melde dich gerne direkt bei mir.`),[re,I]=a.useState("Zahlung: 50 % Anzahlung bei Auftragsbestätigung, 50 % vor Auslieferung. Lieferzeit ca. 6 Wochen ab Auftragsbestätigung. Preise in EUR zzgl. gesetzlicher MwSt."),[Ge,Qe]=a.useState(""),[ye,We]=a.useState(()=>{const t=new Date;return t.setDate(t.getDate()+30),t.toISOString().slice(0,10)}),[N,P]=a.useState([]),[V,Ne]=a.useState("none"),[$,we]=a.useState(0),[ae,Je]=a.useState([]),[Fs,ke]=a.useState("net"),[Xe,Ye]=a.useState(7),[et,ie]=a.useState(null),[K,Ce]=a.useState(null),[tt,st]=a.useState([]),[nt,rt]=a.useState(!1),le=a.useRef(null),[zt,Se]=a.useState(!1),[Z,Ae]=a.useState(""),[qe,Lt]=a.useState({}),[Ut,It]=a.useState({}),[A,Pe]=a.useState("business"),[De,at]=a.useState(""),[it,lt]=a.useState("custom"),[Ee,ot]=a.useState([]),[Te,Vt]=a.useState([]),[Bt,Mt]=a.useState(!1),[Ft,oe]=a.useState(!1),[ze,ct]=a.useState(""),[dt,ut]=a.useState(""),[mt,pt]=a.useState(!1),[w,Le]=a.useState(null),[gt,ce]=a.useState([]),ht=async()=>{const{data:t}=await h.from("quote_cover_images").select("id,title,image_url").eq("active",!0).order("sort_order").order("created_at",{ascending:!1});st(t??[])};a.useEffect(()=>{document.title=m?"Neues Angebot · Admin":"Angebot bearbeiten · Admin"},[m]),a.useEffect(()=>()=>{w&&URL.revokeObjectURL(w)},[w]),a.useEffect(()=>{(async()=>{const{data:t}=await h.from("shop_quote_templates").select("*").order("name");ot(t??[])})(),(async()=>{const{data:t}=await h.from("shop_delivery_terms").select("*").order("sort_order").order("name"),n=t??[];if(Vt(n),m&&!Bt){const s=n.find(r=>r.is_default);s!=null&&s.body&&(I(s.body),Mt(!0))}})()},[m]);const[Ue,Ot]=a.useState([]);a.useEffect(()=>{(async()=>{const{data:t}=await h.from("shop_product_overrides").select("slug, quote_price_cents, quote_description, quote_delivery_scope, quote_unit, quote_image_urls"),n={},s={};(t??[]).forEach(r=>{r.quote_price_cents!=null&&(n[r.slug]=r.quote_price_cents),s[r.slug]=r}),Lt(n),It(s)})(),(async()=>{const{data:t}=await h.from("quote_custom_products").select("*").eq("active",!0).order("sort_order").order("name");Ot(t??[])})(),ht()},[]),a.useEffect(()=>{const t=()=>ht();return window.addEventListener("focus",t),()=>window.removeEventListener("focus",t)},[]);const xt=t=>{const n=Me.find(o=>o.slug===t);if(!n)return null;const s=Ut[t]??{}
23,r=Array.isArray(s.quote_image_urls)?s.quote_image_urls.filter(Boolean):[],l=r.length?r:n.images??[];return{slug:n.slug,category:n.category,name:n.name,description:s.quote_description&&String(s.quote_description).trim()||Is(n),delivery_scope:s.quote_delivery_scope&&String(s.quote_delivery_scope).trim()||Vs(n),unit:s.quote_unit&&String(s.quote_unit).trim()||"Stück",images:l,unit_price_cents:qe[t]??0}};a.useEffect(()=>{m||(async()=>{u(!0);const{data:t}=await h.from("shop_quotes").select("*").eq("id",i).single(),{data:n}=await h.from("shop_quote_items").select("*").eq("quote_id",i).order("sort_order");t&&(L(t.status),Et(t.quote_number),Tt(t.public_token),Y(t.customer_name),ee(t.customer_company??""),te(t.customer_email),se(t.customer_phone??""),Ke(t.customer_street??""),Ze(t.customer_zip??""),He(t.customer_city??""),be(t.intro_text??""),I(t.terms_text??""),Qe(t.internal_notes??""),We(t.valid_until),Ne(t.discount_type??"none"),we(Number(t.discount_value??0)),Je(t.cc_emails??[]),ke(t.price_display_mode??"net"),Pe(t.customer_type??"business"),at(t.delivery_time_text??""),lt(t.payment_terms_preset??"custom"),Ye(Number(t.followup_days??7)),ie(t.inquiry_id??null),Ce(t.cover_image_url??null)),n&&P(n.map(s=>({id:s.id,item_type:s.item_type,product_slug:s.product_slug,product_category:s.product_category,name:s.name,description:s.description??"",image_url:s.image_url,image_urls:Array.isArray(s.image_urls)?s.image_urls:s.image_url?[s.image_url]:[],delivery_scope:s.delivery_scope??"",quantity:Number(s.quantity),unit:s.unit??"Stück",unit_price_cents:s.unit_price_cents,price_input:F(s.unit_price_cents??0),discount_type:s.discount_type,discount_value:Number(s.discount_value??0),sort_order:s.sort_order,is_optional:!!s.is_optional}))),u(!1)})()},[i,m]),a.useEffect(()=>{!v||!m||(async()=>{u(!0);const{data:t}=await h.from("shop_inquiries").select("*").eq("id",v).single();if(t){Y(t.customer_name),ee(t.customer_company??""),te(t.customer_email),se(t.customer_phone??""),ie(v);const n=[],s=(r,l)=>{const o=xt(r);o&&n.push({item_type:"product",product_slug:o.slug,product_category:o.category,name:o.name,description:o.description,image_url:o.images[0]??null,image_urls:o.images,delivery_scope:o.delivery_scope,quantity:l||1,unit:o.unit,unit_price_cents:o.unit_price_cents,price_input:F(o.unit_price_cents),discount_type:"none",discount_value:0,sort_order:n.length,is_optional:!1})};t.items&&Array.isArray(t.items)&&t.items.length>0?t.items.forEach(r=>s(r.slug||r.product_slug,r.qty||r.quantity||1)):t.product_slug&&s(t.product_slug,t.quantity||1),P(n)}u(!1)})()},[v,m,qe]);const j=a.useMemo(()=>Ns(N,V,$),[N,V,$]),y=(t,n)=>{P(s=>s.map((r,l)=>l===t?{...r,...n}:r))},Rt=t=>P(n=>n.filter((s,r)=>r!==t).map((s,r)=>({...s,sort_order:r}))),ft=(t,n)=>{P(s=>{const r=[...s],l=t+n;return l<0||l>=r.length?s:([r[t],r[l]]=[r[l],r[t]],r.map((o,d)=>({...o,sort_order:d})))})},$t=t=>{const n=xt(t);n&&(P(s=>[...s,{item_type:"product",product_slug:n.slug,product_category:n.category,name:n.name,description:n.description,image_url:n.images[0]??null,image_urls:n.images,delivery_scope:n.delivery_scope,quantity:1,unit:n.unit,unit_price_cents:n.unit_price_cents,price_input:F(n.unit_price_cents),discount_type:"none",discount_value:0,sort_order:s.length,is_optional:!1}]),Se(!1),Ae(""))},Kt=t=>{P(n=>{var s;return[...n,{item_type:"product",product_slug:null,product_category:t.category??null,name:t.name,description:t.description??"",image_url:((s=t.image_urls)==null?void 0:s[0])??null,image_urls:Array.isArray(t.image_urls)?t.image_urls:[],delivery_scope:t.delivery_scope??"",quantity:1,unit:t.unit||"Stück",unit_price_cents:t.price_cents??0,price_input:F(t.price_cents??0),discount_type:"none",discount_value:0,sort_order:n.length,is_optional:!1}]}),Se(!1),Ae("")},Zt=()=>P(t=>[...t,Bs(t.length)]),Ht=a.useMemo(()=>{const t=Z.trim().toLowerCase();return t?Me.filter(n=>[n.name,n.slug,n.category].some(s=>s.toLowerCase().includes(t))).slice(0,30):Me.slice(0,30)},[Z]),_t=a.useMemo(()=>{const t=Z.trim().toLowerCase();return t?Ue.filter(n=>[n.name,n.category].some(s=>(s??"").toLowerCase().includes(t))):Ue},[Z,Ue]),Gt=()=>{if(!X.trim())return"Kundenname fehlt";if(!T.trim()||!/@/.test(T))return"Kunden-E-Mail fehlt/ungültig";if(N.length===0)return"Mindestens eine Position hinzufügen";for(const t of N)if(!t.name.trim())return"Alle Positionen brauchen einen Namen";return null},Qt=()=>{w&&URL.revokeObjectURL(w),Le(null),ce([])},Ie=async(t,n)=>{const s=K;if(Ce(t),Qt(),m||!i)return;const{error:r}=await h.from("shop_quotes").update({cover_image_url:t,pdf_path:null,updated_at:new Date().toISOString()}).eq("id",i);if(r){Ce(s),p.error(r.message||"Titelbild konnte nicht gespeichert werden");return}p.success(n??(t?"Titelbild übernommen – bitte PDF-Vorschau neu öffnen":"Titelbild entfernt"))},Wt=async t=>{if(!t)return;if(!t.type.startsWith("image/")){p.error("Bitte ein Bild auswählen");return}if(t.size>15*1024*1024){p.error("Datei zu groß (max. 15 MB)");return}rt(!0);const n=p.loading("Titelbild wird hochgeladen und übernommen…");try{const s=(t.name.split(".").pop()||"jpg").toLowerCase(),l=`quote-covers/${crypto.randomUUID()}.${s}`,{error:o}=await h.storage.from("branding-uploads").upload(l,t,{contentType:t.type,upsert:!1,cacheControl:"0"});if(o)throw o;const{data:d}=h.storage.from("branding-uploads").getPublicUrl(l),B=t.name.replace(/\.[^.]+$/,""),{data:H,error:ue}=await h.from("quote_cover_images").insert({title:B,image_url:d.publicUrl,storage_path:l,sort_order:0,active:!0}).select("id,title,image_url").single();if(ue)throw ue;H&&st(me=>[H,...me.filter(pe=>pe.id!==H.id)]),await Ie(d.publicUrl,"Neues Titelbild hochgeladen und für dieses Angebot übernommen"),le.current&&(le.current.value="")}catch(s){p.error((s==null?void 0:s.message)??"Titelbild konnte nicht hochgeladen werden")}finally{p.dismiss(n),rt(!1)}},jt=async()=>{const t=Gt();if(t)return p.error(t),null;C(!0);const n=A==="private"?"gross":"net",s={status:S,customer_name:X,customer_company:xe||null,customer_email:T,customer_phone:fe||null,customer_street:_e||null,customer_zip:je||null,customer_city:ve||null,intro_text:ne,terms_text:re,internal_notes:Ge,valid_until:ye,discount_type:V,discount_value:$,subtotal_net_cents:j.subtotal_net_cents,discount_cents:j.discount_cents,net_cents:j.net_cents,tax_rate:19,tax_cents:j.tax_cents,gross_cents:j.gross_cents,inquiry_id:et,cc_emails:ae,price_display_mode:n,customer_type:A,delivery_time_text:De||null,payment_terms_preset:it||null,followup_days:Xe,cover_image_url:K};let r=i;if(m){const{data:l,error:o}=await h.from("shop_quotes").insert(s).select("id").single();if(o||!l)return C(!1),p.error((o==null?void 0:o.message)??"Fehler beim Speichern"),null;r=l.id}else{const{error:l}=await h.from("shop_quotes").update(s).eq("id",r);
23if(l)return C(!1),p.error(l.message),null}if(await h.from("shop_quote_items").delete().eq("quote_id",r),N.length>0){const l=N.map((d,B)=>({quote_id:r,item_type:d.item_type,product_slug:d.product_slug,product_category:d.product_category,name:d.name,description:d.description||null,image_url:d.image_url,quantity:d.quantity,unit:d.unit,image_urls:d.image_urls??[],delivery_scope:d.delivery_scope||null,unit_price_cents:d.unit_price_cents,discount_type:d.discount_type,discount_value:d.discount_value,line_net_cents:Fe(d),is_optional:d.is_optional,sort_order:B})),{error:o}=await h.from("shop_quote_items").insert(l);if(o)return C(!1),p.error(o.message),null}return C(!1),r},Jt=async()=>{const t=await jt();t&&(p.success("Angebot gespeichert"),m&&k(`/admin/angebote/${t}`))},[Xt,Ve]=a.useState(!1),Yt=()=>{if(!T.trim()||!/@/.test(T)){p.error("Bitte gültige Kunden-E-Mail eintragen, bevor du sendest.");return}Ve(!0)},es=async()=>{Ve(!1);const t=await jt();if(!t)return;g(!0);const{data:n,error:s}=await h.functions.invoke("send-quote",{body:{quote_id:t}});if(g(!1),s||n!=null&&n.error){p.error((n==null?void 0:n.error)??(s==null?void 0:s.message)??"Versand fehlgeschlagen");return}p.success("Angebot versendet"),k(`/admin/angebote/${t}`)},ts=t=>{Y(t.name??""),te(t.email??""),se(t.phone??""),t.company&&ee(t.company),t.inquiry_id&&m&&ie(t.inquiry_id),p.success("Kontakt übernommen")},ss=t=>{const n=Ee.find(s=>s.id===t);n&&(n.intro_text&&be(n.intro_text),n.terms_text&&I(n.terms_text),n.discount_type&&Ne(n.discount_type),n.discount_value!=null&&we(Number(n.discount_value)),Array.isArray(n.items)&&P(n.items.map((s,r)=>({item_type:s.item_type??"extra",product_slug:s.product_slug??null,product_category:s.product_category??null,name:s.name??"",description:s.description??"",image_url:s.image_url??null,image_urls:Array.isArray(s.image_urls)?s.image_urls:s.image_url?[s.image_url]:[],delivery_scope:s.delivery_scope??"",quantity:Number(s.quantity??1),unit:s.unit??"Stück",unit_price_cents:Number(s.unit_price_cents??0),price_input:F(Number(s.unit_price_cents??0)),discount_type:s.discount_type??"none",discount_value:Number(s.discount_value??0),sort_order:r,is_optional:!!s.is_optional}))),p.success(`Vorlage „${n.name}" geladen`))},ns=async()=>{if(!ze.trim()){p.error("Name fehlt");return}const{error:t}=await h.from("shop_quote_templates").insert({name:ze.trim(),description:dt.trim()||null,intro_text:ne||null,terms_text:re||null,discount_type:V,discount_value:$,items:N.map((s,r)=>({...s,sort_order:r}))});if(t){p.error(t.message);return}p.success("Vorlage gespeichert"),oe(!1),ct(""),ut("");const{data:n}=await h.from("shop_quote_templates").select("*").order("name");ot(n??[])},rs=async t=>{var n,s,r;pt(!0);try{ce([]);const l=t!==void 0?t:K,o=await h.functions.invoke("generate-quote-pdf",{body:{preview:!0,payload:{quote_number:he||"VORSCHAU",customer_name:X,customer_company:xe||null,customer_email:T||null,customer_phone:fe||null,customer_street:_e||null,customer_zip:je||null,customer_city:ve||null,customer_type:A,intro_text:ne,terms_text:re,delivery_time_text:De||null,price_display_mode:A==="private"?"gross":"net",valid_until:ye,created_at:new Date().toISOString(),subtotal_net_cents:j.subtotal_net_cents,discount_cents:j.discount_cents,net_cents:j.net_cents,tax_rate:19,tax_cents:j.tax_cents,gross_cents:j.gross_cents,items:N.map(q=>({...q,line_net_cents:Fe(q)})),cover_image_url:l}}}),d=(n=o.data)==null?void 0:n.pdf_base64;if(!d){const q=((s=o.error)==null?void 0:s.message)||((r=o.data)==null?void 0:r.error)||"Vorschau fehlgeschlagen";p.error(q);return}const B=Uint8Array.from(atob(d),q=>q.charCodeAt(0)),H=new Blob([B],{type:"application/pdf"}),ue=URL.createObjectURL(H),me=await gs({data:B.slice()}).promise,pe=[];for(let q=1;q<=me.numPages;q+=1){const vt=await me.getPage(q),Be=vt.getViewport({scale:1.6}),ge=document.createElement("canvas"),bt=ge.getContext("2d");if(!bt)throw new Error("PDF-Vorschau konnte nicht erstellt werden");ge.width=Math.ceil(Be.width),ge.height=Math.ceil(Be.height),await vt.render({canvasContext:bt,viewport:Be}).promise,pe.push(ge.toDataURL("image/png"))}w&&URL.revokeObjectURL(w),Le(ue),ce(pe)}catch(l){p.error((l==null?void 0:l.message)||"Vorschau fehlgeschlagen")}finally{pt(!1)}};if(U)return e.jsx(Ct,{title:"Angebot",children:e.jsx("div",{className:"py-20 text-center",children:e.jsx(O,{className:"h-6 w-6 animate-spin inline text-muted-foreground"})})});const de=$e?`${window.location.origin}/angebot/${$e}`:null;return e.jsxs(Ct,{title:m?"Neues Angebot":`Angebot ${he}`,subtitle:m?"Konfigurator":`Status: ${S}`,actions:e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>k("/admin/angebote"),children:"Zurück"}),Ee.length>0&&e.jsxs(G,{onValueChange:ss,children:[e.jsxs(Q,{className:"w-[180px] h-9",children:[e.jsx(ks,{className:"h-4 w-4 mr-2"}),e.jsx(W,{placeholder:"Aus Vorlage laden"})]}),e.jsx(J,{children:Ee.map(t=>e.jsx(b,{value:t.id,children:t.name},t.id))})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>oe(!0),disabled:N.length===0,children:[e.jsx(Ts,{className:"h-4 w-4 md:mr-2"}),e.jsx("span",{className:"hidden md:inline",children:"Als Vorlage"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>rs(),disabled:mt||N.length===0,children:[mt?e.jsx(O,{className:"h-4 w-4 animate-spin md:mr-2"}):e.jsx(Cs,{className:"h-4 w-4 md:mr-2"}),e.jsx("span",{className:"hidden md:inline",children:"PDF-Vorschau"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:Jt,disabled:z,children:[z?e.jsx(O,{className:"h-4 w-4 animate-spin md:mr-2"}):e.jsx(Ss,{className:"h-4 w-4 md:mr-2"}),e.jsx("span",{className:"hidden md:inline",children:"Entwurf speichern"})]}),e.jsxs(_,{size:"sm",onClick:Yt,disabled:R||z,children:[R?e.jsx(O,{className:"h-4 w-4 animate-spin md:mr-2"}):e.jsx(St,{className:"h-4 w-4 md:mr-2"}),"Angebot senden"]})]}),children:[de&&e.jsxs(D,{className:"p-3 mb-4 bg-accent/5 border-accent/20 flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("div",{className:"uppercase tracking-widest text-accent font-semibold text-[10px]",children:"Öffentlicher Link"}),e.jsx("a",{href:de,target:"_blank",rel:"noreferrer",className:"text-sm font-mono hover:underline",children:de})]}),e.jsx(_,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs("a",{href:de,target:"_blank",rel:"noreferrer",children:[e.jsx(As,{className:"h-3 w-3 mr-2"}),"Vorschau"]})})]}),e.jsxs("div",{className:"grid lg:grid-cols-[1fr_360px] gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(D,{className:"p-5",children:[e.jsx("h3",{className:"font-semibold mb-4",children:"Kunde"}),e.jsx("div",{className:"mb-4",children:e.jsx(Ls,{onPick:ts})}),et&&e.jsxs("div",{className:"mb-3 text-xs",children:[e.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-accent/10 text-accent-foreground px-2 py-0.5",children:"Aus Anfrage verknüpft"}),e.jsx("button",{type:"button",onClick:()=>ie(null),className:"ml-2 text-muted-foreground hover:underline",children:"entfernen"})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(c,{children:"Name *"}),e.jsx(x,{value:X,onChange:t=>Y(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Firma"}),e.jsx(x,{value:xe,onChange:t=>ee(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{children:"E-Mail *"}),e.jsx(x,{type:"email",value:T,onChange:t=>te(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Telefon"}),e.jsx(x,{value:fe,onChange:t=>se(t.target.value)})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(c,{children:"Straße"}),e.jsx(x,{value:_e,onChange:t=>Ke(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{children:"PLZ"}),e.jsx(x,{value:je,onChange:t=>Ze(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Ort"}),e.jsx(x,{value:ve,onChange:t=>He(t.target.value)})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Us,{value:ae,onChange:Je})})]})]}),e.jsxs(D,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold",children:"Positionen"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(_,{size:"sm",variant:"outline",onClick:()=>Se(t=>!t),children:[e.jsx(Oe,{className:"h-4 w-4 mr-2"}),"Produkt"]}),e.jsxs(_,{size:"sm",variant:"outline",onClick:Zt,children:[e.jsx(Oe,{className:"h-4 w-4 mr-2"}),"Freie Position"]})]})]}),zt&&e.jsxs(D,{className:"p-3 mb-4 bg-muted/30",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(Pt,{className:"h-4 w-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(x,{autoFocus:!0,placeholder:"Produkt suchen …",value:Z,onChange:t=>Ae(t.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"max-h-80 overflow-auto divide-y divide-border",children:[_t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-widest text-muted-foreground bg-muted/40",children:"Eigene Angebots-Produkte"}),_t.map(t=>{var n;return e.jsxs("button",{onClick:()=>Kt(t),className:"w-full flex items-center gap-3 p-2 hover:bg-accent/10 text-left",children:[(n=t.image_urls)!=null&&n[0]?e.jsx("img",{src:t.image_urls[0],alt:"",className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded bg-muted grid place-items-center",children:e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.category})]}),t.price_cents>0&&e.jsx("span",{className:"text-xs font-semibold text-accent",children:E(t.price_cents)})]},`cp-${t.id}`)}),e.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-widest text-muted-foreground bg-muted/40",children:"Shop-Produkte"})]}),Ht.map(t=>{var r;const n=os.find(l=>l.slug===t.category),s=qe[t.slug];return e.jsxs("button",{onClick:()=>$t(t.slug),className:"w-full flex items-center gap-3 p-2 hover:bg-accent/10 text-left",children:[((r=t.images)==null?void 0:r[0])&&e.jsx("img",{src:t.images[0],alt:"",className:"h-10 w-10 rounded object-cover"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:(n==null?void 0:n.name)??t.category})]}),s!=null&&e.jsx("span",{className:"text-xs font-semibold text-accent",children:E(s)})]},t.slug)})]})]}),N.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Noch keine Positionen. Füge Produkte oder freie Zeilen hinzu."}):e.jsx("div",{className:"space-y-3",children:N.map((t,n)=>e.jsx(D,{className:"p-3",children:e.jsxs("div",{className:"flex gap-3 items-start",children:[t.image_url?e.jsx("img",{src:t.image_url,alt:"",className:"h-16 w-16 rounded object-cover shrink-0"}):e.jsx("div",{className:"h-16 w-16 rounded bg-muted shrink-0 grid place-items-center text-[10px] text-muted-foreground uppercase",children:"Zusatz"}),e.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[e.jsx(x,{value:t.name,placeholder:"Bezeichnung",onChange:s=>y(n,{name:s.target.value}),className:"font-medium"}),e.jsx(M,{rows:2,value:t.description,placeholder:"Beschreibung / Details",onChange:s=>y(n,{description:s.target.value})}
23),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2 items-end",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[10px] uppercase tracking-wide",children:"Menge"}),e.jsx(x,{type:"number",step:"1",min:"0",value:t.quantity,onChange:s=>y(n,{quantity:Number(s.target.value)})})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[10px] uppercase tracking-wide",children:"Einheit"}),e.jsx(x,{value:t.unit,onChange:s=>y(n,{unit:s.target.value})})]}),e.jsxs("div",{children:[e.jsxs(c,{className:"text-[10px] uppercase tracking-wide",children:["Preis ",A==="private"?"brutto":"netto"," €"]}),e.jsx(x,{inputMode:"decimal",placeholder:"0,00",value:t.price_input,onChange:s=>y(n,{price_input:s.target.value,unit_price_cents:qt(s.target.value)}),onBlur:s=>{const r=qt(s.target.value);y(n,{unit_price_cents:r,price_input:r?F(r):""})}})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[10px] uppercase tracking-wide",children:"Rabatt"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(G,{value:t.discount_type,onValueChange:s=>y(n,{discount_type:s}),children:[e.jsx(Q,{className:"w-[90px]",children:e.jsx(W,{})}),e.jsxs(J,{children:[e.jsx(b,{value:"none",children:"–"}),e.jsx(b,{value:"percent",children:"%"}),e.jsx(b,{value:"amount",children:"€"})]})]}),e.jsx(x,{type:"number",value:t.discount_value,disabled:t.discount_type==="none",onChange:s=>y(n,{discount_value:Number(s.target.value)})})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs(c,{className:"text-[10px] uppercase tracking-wide",children:["Zeile ",A==="private"?"brutto":"netto"]}),e.jsx("div",{className:`font-semibold pt-2 ${t.is_optional?"text-muted-foreground line-through":""}`,children:E(Fe(t))})]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer select-none pt-1",children:[e.jsx("input",{type:"checkbox",checked:t.is_optional,onChange:s=>y(n,{is_optional:s.target.checked}),className:"h-4 w-4 accent-current"}),e.jsx("span",{className:t.is_optional?"font-semibold text-accent":"text-muted-foreground",children:"Optionale Position (Preis wird nicht in Gesamtsumme eingerechnet)"})]}),e.jsxs("div",{className:"pt-2 border-t border-border/50",children:[e.jsxs(c,{className:"text-[10px] uppercase tracking-wide flex items-center gap-1",children:[e.jsx(At,{className:"h-3 w-3"}),"Bilder (",t.image_urls.length,")"]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-1",children:[t.image_urls.map((s,r)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:s,alt:"",className:`h-14 w-14 rounded object-cover border ${r===0?"border-accent border-2":"border-border"}`}),e.jsx("button",{type:"button",onClick:()=>{const l=t.image_urls.filter((o,d)=>d!==r);y(n,{image_urls:l,image_url:l[0]??null})},className:"absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Dt,{className:"h-2.5 w-2.5"})}),r!==0&&e.jsx("button",{type:"button",onClick:()=>{const l=[s,...t.image_urls.filter((o,d)=>d!==r)];y(n,{image_urls:l,image_url:l[0]})},className:"absolute -bottom-1 -right-1 bg-accent text-accent-foreground rounded-full p-0.5 opacity-0 group-hover:opacity-100 text-[8px] px-1",title:"Als Hauptbild",children:"★"})]},r)),e.jsx("div",{className:"flex items-center",children:e.jsx(x,{placeholder:"Bild-URL hinzufügen",className:"h-14 w-40 text-xs",onKeyDown:s=>{if(s.key==="Enter"){const r=s.target.value.trim();if(r){const l=[...t.image_urls,r];y(n,{image_urls:l,image_url:t.image_url??r}),s.target.value=""}}}})})]})]}),e.jsxs("div",{className:"pt-2 border-t border-border/50",children:[e.jsxs(c,{className:"text-[10px] uppercase tracking-wide flex items-center gap-1",children:[e.jsx(qs,{className:"h-3 w-3"}),"Lieferumfang"]}),e.jsx(M,{rows:4,value:t.delivery_scope,placeholder:"• Bulletpoints, was im Lieferumfang enthalten ist …",onChange:s=>y(n,{delivery_scope:s.target.value}),className:"mt-1 text-sm"})]})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(_,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ft(n,-1),children:e.jsx(Es,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ft(n,1),children:e.jsx(Ds,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>Rt(n),children:e.jsx(Ps,{className:"h-3 w-3"})})]})]})}
23,n))})]}),e.jsxs(D,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{children:[e.jsx(c,{children:"Titelbild für Angebot (PDF-Cover & Online-Hero)"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Wähle ein Titelbild oder lade es direkt hier hoch. Die bestehende PDF-Vorschau wird danach bewusst zurückgesetzt."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:le,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:t=>{var n;return Wt((n=t.target.files)==null?void 0:n[0])}}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>{var t;return(t=le.current)==null?void 0:t.click()},disabled:nt,children:[nt?e.jsx(O,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(cs,{className:"h-4 w-4 mr-1"}),"Hochladen & auswählen"]}),K&&e.jsx(_,{variant:"outline",size:"sm",onClick:()=>Ie(null),children:"Entfernen"}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>window.open("/admin/angebote/titelbilder","_blank"),children:[e.jsx(At,{className:"h-4 w-4 mr-1"})," Verwalten"]})]})]}),tt.length===0?e.jsxs("div",{className:"rounded-md border border-dashed border-border p-4 text-sm text-muted-foreground",children:["Noch keine Titelbilder hochgeladen. ",e.jsx("a",{href:"/admin/angebote/titelbilder",target:"_blank",rel:"noreferrer",className:"underline",children:"Jetzt anlegen"}),"."]}):e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4",children:tt.map(t=>{const n=K===t.image_url;return e.jsxs("button",{type:"button",onClick:()=>Ie(n?null:t.image_url),className:`group relative overflow-hidden rounded-md border-2 transition ${n?"border-accent ring-2 ring-accent/40":"border-transparent hover:border-border"}`,title:t.title,children:[e.jsx("div",{className:"aspect-[3/2] bg-muted",children:e.jsx("img",{src:t.image_url,alt:t.title,loading:"lazy",className:"h-full w-full object-cover"})}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-1.5 text-left text-[10px] font-medium text-white line-clamp-1",children:t.title}),n&&e.jsx("div",{className:"absolute right-1 top-1 rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-accent-foreground",children:"✓"})]},t.id)})})]}),e.jsxs(D,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{children:"Einleitungstext (an den Kunden)"}),e.jsx(M,{rows:3,value:ne,onChange:t=>be(t.target.value)})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(c,{children:"Lieferbedingungen / Konditionen"}),e.jsxs("div",{className:"flex items-center gap-2",children:[Te.length>0&&e.jsxs(G,{onValueChange:t=>{const n=Te.find(s=>s.id===t);n!=null&&n.body&&I(n.body)},children:[e.jsx(Q,{className:"w-[200px] h-8",children:e.jsx(W,{placeholder:"Textbaustein wählen …"})}),e.jsx(J,{children:Te.map(t=>e.jsxs(b,{value:t.id,children:[t.name,t.is_default?" (Standard)":""]},t.id))})]}),e.jsx(_,{asChild:!0,variant:"ghost",size:"sm",className:"h-8 text-xs",children:e.jsx("a",{href:"/admin/lieferbedingungen",target:"_blank",rel:"noreferrer",children:"Verwalten"})})]})]}),e.jsx(M,{rows:5,value:re,onChange:t=>I(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Interne Notiz (nur intern)"}),e.jsx(M,{rows:2,value:Ge,onChange:t=>Qe(t.target.value)})]})]})]}),e.jsxs("div",{className:"space-y-4 lg:sticky lg:top-4 lg:self-start",children:[e.jsxs(D,{className:"p-5",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Kalkulation"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Zwischensumme netto"}),e.jsx("span",{className:"font-mono",children:E(j.subtotal_net_cents)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(c,{className:"text-[10px] uppercase tracking-wide",children:"Gesamt-Rabatt"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(G,{value:V,onValueChange:t=>Ne(t),children:[e.jsx(Q,{className:"w-[100px]",children:e.jsx(W,{})}),e.jsxs(J,{children:[e.jsx(b,{value:"none",children:"Kein"}),e.jsx(b,{value:"percent",children:"Prozent"}),e.jsx(b,{value:"amount",children:"Betrag €"})]})]}),e.jsx(x,{type:"number",value:$,disabled:V==="none",onChange:t=>we(Number(t.target.value))})]})]}),j.discount_cents>0&&e.jsxs("div",{className:"flex justify-between text-accent",children:[e.jsx("span",{children:"Rabatt"}),e.jsxs("span",{className:"font-mono",children:["− ",E(j.discount_cents)]})]}),e.jsxs("div",{className:"flex justify-between border-t border-border pt-2",children:[e.jsx("span",{children:"Netto"}),e.jsx("span",{className:"font-mono",children:E(j.net_cents)})]}),A==="private"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-muted-foreground",children:[e.jsx("span",{children:"enth. MwSt 19 %"}),e.jsx("span",{className:"font-mono",children:E(j.tax_cents)})]}),e.jsxs("div",{className:"flex justify-between text-lg font-bold border-t border-border pt-2",children:[e.jsx("span",{children:"Brutto (inkl. MwSt)"}),e.jsx("span",{className:"font-mono",children:E(j.gross_cents)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-lg font-bold border-t border-border pt-2",children:[e.jsx("span",{children:"Gesamt netto"}),e.jsx("span",{className:"font-mono",children:E(j.net_cents)})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground pt-1",children:"zzgl. gesetzlicher MwSt (wird beim Geschäftskunden nicht ausgewiesen)"})]})]})]}),e.jsxs(D,{className:"p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx(c,{children:"Kundenart"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-1",children:[e.jsx("button",{type:"button",onClick:()=>{Pe("business"),ke("net")},className:`px-3 py-2 rounded border text-sm ${A==="business"?"border-accent bg-accent/10 font-semibold":"border-border"}`,children:"Geschäft (netto)"}),e.jsx("button",{type:"button",onClick:()=>{Pe("private"),ke("gross")},className:`px-3 py-2 rounded border text-sm ${A==="private"?"border-accent bg-accent/10 font-semibold":"border-border"}`,children:"Privat (brutto)"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:A==="business"?"Preise werden netto ohne MwSt-Ausweis dargestellt.":"MwSt ist im Angebotspreis enthalten."})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Gültig bis"}),e.jsx(x,{type:"date",value:ye,onChange:t=>We(t.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Lieferzeit"}),e.jsx(x,{value:De,onChange:t=>at(t.target.value),placeholder:"z. B. 4–6 Wochen ab Auftragsbestätigung"})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Zahlungsbedingungen"}),e.jsx("div",{className:"grid gap-1 mt-1",children:Ms.map(t=>e.jsx("button",{type:"button",onClick:()=>{lt(t.key),t.text&&I(t.text)},className:`text-left px-2 py-1.5 rounded border text-xs ${it===t.key?"border-accent bg-accent/10 font-semibold":"border-border"}`,children:t.label},t.key))})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Follow-up nach (Tagen)"}),e.jsx(x,{type:"number",min:0,value:Xe,onChange:t=>Ye(Number(t.target.value))}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"0 = keine automatische Nachfrage."})]}),!m&&e.jsxs("div",{children:[e.jsx(c,{children:"Status"}),e.jsxs(G,{value:S,onValueChange:L,children:[e.jsx(Q,{children:e.jsx(W,{})}),e.jsxs(J,{children:[e.jsx(b,{value:"draft",children:"Entwurf"}),e.jsx(b,{value:"sent",children:"Versendet"}),e.jsx(b,{value:"viewed",children:"Angesehen"}),e.jsx(b,{value:"accepted",children:"Angenommen"}),e.jsx(b,{value:"declined",children:"Abgelehnt"}),e.jsx(b,{value:"expired",children:"Abgelaufen"})]})]})]})]})]})]}),e.jsx(yt,{open:Ft,onOpenChange:oe,children:e.jsxs(Nt,{children:[e.jsx(wt,{children:e.jsx(kt,{children:"Als Vorlage speichern"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(c,{children:"Name *"}),e.jsx(x,{value:ze,onChange:t=>ct(t.target.value),placeholder:"z. B. Fotobox H + Backdrop + Lieferung"})]}),e.jsxs("div",{children:[e.jsx(c,{children:"Beschreibung"}),e.jsx(M,{rows:2,value:dt,onChange:t=>ut(t.target.value)})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Aktuelle Positionen, Rabatt, Einleitungstext und Konditionen werden gespeichert. Kundendaten werden nicht übernommen."})]}),e.jsxs(ds,{children:[e.jsx(_,{variant:"outline",onClick:()=>oe(!1),children:"Abbrechen"}),e.jsx(_,{onClick:ns,children:"Speichern"})]})]})}),e.jsx(yt,{open:!!w,onOpenChange:t=>{t||(w&&URL.revokeObjectURL(w),Le(null),ce([]))},children:e.jsxs(Nt,{className:"max-w-5xl h-[90vh] p-0 flex flex-col overflow-hidden",children:[e.jsxs(wt,{className:"p-4 border-b flex-row items-center justify-between gap-2",children:[e.jsx(kt,{children:"PDF-Vorschau"}),w&&e.jsx(_,{type:"button",variant:"outline",size:"sm",className:"mr-8",onClick:()=>ws(w,`${he||"angebot"}-vorschau.pdf`),children:"Herunterladen"})]}),gt.length>0&&e.jsx("div",{className:"flex-1 overflow-auto bg-muted/40 p-4 md:p-6 space-y-5",children:gt.map((t,n)=>e.jsx("img",{src:t,alt:`PDF-Vorschauseite ${n+1}`,className:"mx-auto w-full max-w-[860px] rounded border border-border bg-background shadow-sm"},n))})]})}),e.jsx(hs,{open:Xt,onOpenChange:Ve,children:e.jsxs(xs,{children:[e.jsxs(fs,{children:[e.jsx(_s,{children:"Angebot jetzt wirklich senden?"}),e.jsx(js,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{children:"Das Angebot wird per E-Mail an folgende Adresse verschickt:"}),e.jsxs("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex items-center gap-2",children:[e.jsx(us,{className:"h-4 w-4 text-accent shrink-0"}),e.jsx("span",{className:"font-mono text-sm break-all",children:T||"—"})]}),ae.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["CC: ",ae.join(", ")
23]})]})})]}),e.jsxs(vs,{children:[e.jsx(bs,{children:"Abbrechen"}),e.jsxs(ys,{onClick:es,children:[e.jsx(St,{className:"h-4 w-4 mr-2"}),"Ja, jetzt senden"]})]})]})})]})}export{fn 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.