PageSourceSearch

https://vfeditor.com/_next/static/chunks/9278.b5c015aa47cdf247.js

js vfeditor.com collected 2026-10-06 15:12:30 UTC 152,961 bytes, 137 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9278,9674],{9278:(e,t,n)=>{n.r(t),n.d(t,{default:()=>ep});var i=n(5155),l=n(2115),r=n(9997),o=n(1531),a=n(9058),s=n(9674);async function d(e,t={}){let n=s.auth.currentUser;if(!n)throw Error("Not logged in");let i=await n.getIdToken(),l=await fetch(e,{...t,headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json",...t.headers||{}}});if(!l.ok)throw Error(`${l.status} ${l.statusText}`);return l.json()}let c=e=>Math.round(e).toLocaleString("cs-CZ"),p=e=>`${c(e)} Kč`,h=e=>`${e.toLocaleString("cs-CZ",{minimumFractionDigits:0,maximumFractionDigits:2})} Kč`,u=e=>null!==e&&isFinite(e)?`${e.toLocaleString("cs-CZ")} %`:"—",x=e=>["led","\xfano","bře","dub","kvě","čvn","čvc","srp","z\xe1ř","ř\xedj","lis","pro"][Number(e.slice(5))-1]??e,g="#30d158",f="#ff453a",m="#0a84ff",y="#bf5af2",b="#ff9f0a",j="#64d2ff",v="#ffd60a",k="#f5f5f7",S="#98989d",z="#636366",C="#141416",w="#26262a",T="#232327",E={fontVariantNumeric:"tabular-nums",fontFeatureSettings:'"tnum"'};function R({children:e,style:t}){return(0,i.jsx)("div",{style:{background:C,border:`1px solid ${w}`,borderRadius:20,padding:"20px 22px",...t},children:e})}function A({children:e}){return(0,i.jsx)("div",{style:{fontSize:11,fontWeight:600,color:S,letterSpacing:.2,marginBottom:8},children:e})}function P({value:e,suffix:t=" vs. min. měs\xedc"}){if(null===e)return null;let n=e>=0;return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:n?g:f,fontSize:12,fontWeight:600,...E},children:[(0,i.jsx)("span",{style:{fontSize:9},children:n?"▲":"▼"}),Math.abs(e)," %",(0,i.jsx)("span",{style:{color:z,fontWeight:500},children:t})]})}function $({label:e,value:t,trend:n,sub:l,color:r}){return(0,i.jsxs)(R,{style:{flex:1,minWidth:0},children:[(0,i.jsx)(A,{children:e}),(0,i.jsx)("div",{style:{fontSize:32,fontWeight:700,letterSpacing:"-1.2px",lineHeight:1.05,color:r??k,...E,whiteSpace:"nowrap"},children:t}),(0,i.jsxs)("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:2},children:[void 0!==n&&(0,i.jsx)(P,{value:n??null}),l&&(0,i.jsx)("div",{style:{fontSize:12,color:z,...E},children:l})]})]})}function M({label:e,value:t,sub:n,color:l}){return(0,i.jsxs)(R,{style:{padding:"14px 16px",borderRadius:14},children:[(0,i.jsx)("div",{style:{fontSize:11,color:S,marginBottom:5},children:e}),(0,i.jsx)("div",{style:{fontSize:19,fontWeight:700,letterSpacing:"-0.4px",color:l??k,...E},children:t}),n&&(0,i.jsx)("div",{style:{fontSize:11,color:z,marginTop:3,...E},children:n})]})}function W({data:e,color:t,height:n=120,labelEvery:l=0}){let r=Math.max(...e.map(e=>e.value),1);return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:3,height:n},children:e.map((e,n)=>(0,i.jsx)("div",{title:`${e.label}: ${c(e.value)}`,style:{flex:1,minWidth:3,display:"flex",flexDirection:"column",justifyContent:"flex-end",height:"100%"},children:(0,i.jsx)("div",{style:{height:0===e.value?2:`${Math.max(3,e.value/r*100)}%`,background:0===e.value?T:t,borderRadius:3,opacity:0===e.value?.6:.9}})},n))}),l>0&&(0,i.jsx)("div",{style:{display:"flex",gap:3,marginTop:6},children:e.map((e,t)=>(0,i.jsx)("div",{style:{flex:1,minWidth:3,textAlign:"center",fontSize:9.5,color:z,...E},children:t%l==0?e.label:""},t))})]})}function I({data:e,color:t,uid:n,height:l=110}){let r=e.filter(e=>null!==e);if(r.length<2)return(0,i.jsx)("div",{style:{height:l,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:z},children:"Zat\xedm m\xe1lo dat — graf se dopln\xed během p\xe1r dn\xed."});let o=Math.max(...r),a=Math.min(...r),s=o-a||1,d=e.length,c=e.map((e,t)=>null===e?null:[t/(d-1)*600,l-5-(e-a)/s*(l-10)]),p=[],h=[];c.forEach(e=>{e?h.push(e):h.length&&(p.push(h),h=[])}),h.length&&p.push(h);let u=p.map(e=>e.map((e,t)=>`${t?"L":"M"} ${e[0].toFixed(1)} ${e[1].toFixed(1)}`).join(" ")).join(" "),x=c.find(e=>e),g=[...c].reverse().find(e=>e),f=`${u} L ${g[0].toFixed(1)} ${l} L ${x[0].toFixed(1)} ${l} Z`,m=`grad-${n}`;return(0,i.jsxs)("svg",{width:"100%",height:l,viewBox:`0 0 600 ${l}`,preserveAspectRatio:"none",style:{display:"block"},children:[(0,i.jsx)("defs",{children:(0,i.jsxs)("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,i.jsx)("stop",{offset:"0%",stopColor:t,stopOpacity:.25}),(0,i.jsx)("stop",{offset:"100%",stopColor:t,stopOpacity:0})]})}),(0,i.jsx)("path",{d:f,fill:`url(#${m})`}),(0,i.jsx)("path",{d:u,fill:"none",stroke:t,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]})}function N({parts:e,size:t=150}){let n=e.reduce((e,t)=>
1e+t.value,0),l=t/2-10,r=t/2,o=t/2,a=2*Math.PI*l,s=0;return(0,i.jsxs)("svg",{width:t,height:t,style:{transform:"rotate(-90deg)",flexShrink:0},children:[(0,i.jsx)("circle",{cx:r,cy:o,r:l,fill:"none",stroke:T,strokeWidth:13}),n>0&&e.map((e,t)=>{let d=e.value/n,c=(0,i.jsx)("circle",{cx:r,cy:o,r:l,fill:"none",stroke:e.color,strokeWidth:13,strokeDasharray:`${Math.max(d*a-2,.01)} ${a}`,strokeDashoffset:-s*a,strokeLinecap:"round"},t);return s+=d,c})]})}function B(e){return e.length<2?null:(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginTop:6,fontSize:10,color:z,...E},children:[(0,i.jsxs)("span",{children:[e[0].date.slice(5).replace("-",". "),"."]}),(0,i.jsxs)("span",{children:[e[e.length-1].date.slice(5).replace("-",". "),"."]})]})}function F({d:e}){let t=e.history,n=e.monthly.map(e=>({label:x(e.month),value:e.revenueCzk})),l=e.monthly.map(e=>({label:x(e.month),value:e.paid}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10},children:[(0,i.jsx)($,{label:"Tržby tento měs\xedc",value:p(e.revenue.monthCzk),trend:e.revenue.monthGrowth,sub:`celkem ${p(e.revenue.totalCzk)}`,color:g}),(0,i.jsx)($,{label:"Hrub\xe1 marže",value:u(e.profit.grossMarginPct),sub:`hrub\xfd zisk celkem ${p(e.profit.grossTotalCzk)}`,color:(e.profit.grossMarginPct??0)>=0?k:f}),(0,i.jsx)($,{label:"Aktivn\xed uživatel\xe9 (měs\xedc)",value:c(e.users.activeMonth),sub:`t\xfdden ${e.users.activeWeek} \xb7 dnes ${e.users.activeToday}`,color:m}),(0,i.jsx)($,{label:"Prodan\xe1 videa (měs\xedc)",value:c(e.projects.paidMonth),trend:e.projects.paidMonthGrowth,sub:`\xd8 ${e.projects.avgPaidPerMonth.toLocaleString("cs-CZ")} / měs\xedc`,color:y})]}),(0,i.jsxs)(R,{style:{marginTop:10},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)(A,{children:"Tržby po měs\xedc\xedch"}),(0,i.jsxs)("div",{style:{fontSize:26,fontWeight:700,letterSpacing:"-0.8px",color:k,...E},children:[p(e.revenue.yearCzk)," ",(0,i.jsx)("span",{style:{fontSize:13,fontWeight:500,color:z},children:"letos"})]})]}),(0,i.jsx)(P,{value:e.revenue.monthGrowth})]}),(0,i.jsx)("div",{style:{marginTop:16},children:(0,i.jsx)(W,{data:n,color:g,height:140,labelEvery:1})})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginTop:10},children:[(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"Prodan\xe1 videa po měs\xedc\xedch"}),(0,i.jsx)(W,{data:l,color:y,height:100,labelEvery:2})]}),(0,i.jsxs)(R,{children:[(0,i.jsxs)(A,{children:["Kumulativn\xed tržby (posledn\xedch ",t.length," dn\xed)"]}),(0,i.jsx)(I,{data:t.map(e=>e.revenueTotalCzk),color:g,uid:"ov-rev",height:100}),B(t)]})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:8,marginTop:10},children:[(0,i.jsx)(M,{label:"Registrace",value:c(e.users.total),sub:`+${e.users.newThisMonth} tento měs\xedc`}),(0,i.jsx)(M,{label:"Konverze na plat\xedc\xed",value:u(e.marketing.conversionPct),sub:`${e.marketing.payingUsers} z\xe1kazn\xedků`,color:j}),(0,i.jsx)(M,{label:"ARPU",value:p(e.revenue.arpuCzk),sub:"tržby / registrace"}),(0,i.jsx)(M,{label:"\xd8 n\xe1kupů / z\xe1kazn\xedk",value:e.marketing.avgPurchasesPerCustomer.toLocaleString("cs-CZ"),sub:"za dobu existence"}),(0,i.jsx)(M,{label:"AI n\xe1klady celkem",value:p(e.costs.aiTotalCzk),color:b}),(0,i.jsx)(M,{label:"Marže na 1 video",value:p(e.unit.contributionCzk),sub:u(e.unit.contributionMarginPct),color:g})]})]})}function L({d:e,onConfigSaved:t}){let n=e.costs.monthIsMeasured?null:(0,i.jsx)("span",{style:{fontSize:10,color:b,fontWeight:600,marginLeft:6},children:"odhad"}),l=(e,t,n,l,r)=>(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1.4fr 1fr 1fr 1fr",gap:8,padding:"10px 0",borderTop:`1px solid ${w}`,alignItems:"baseline",fontWeight:r?.strong?700:400},children:[(0,i.jsx)("div",{style:{fontSize:13,color:r?.strong?k:S},children:e}),[t,n,l].map((e,t)=>(0,i.jsx)("div",{style:{fontSize:r?.strong?15:13.5,color:r?.color??k,textAlign:"right",...E},children:e},t))]}
1),r=[{label:`Kling video \xb7 \xd8 ${e.unit.avgClipsPerProject.toLocaleString("cs-CZ")} klipů`,value:e.unit.klingCzk,color:y},{label:`Nano Banana \xb7 ${e.unit.nanoBananaImagesPerProject} fotek`,value:e.unit.nanoBananaCzk,color:v},...e.unit.gptCzk>0?[{label:`GPT Image \xb7 ${e.unit.gptImagesPerProject} fotek`,value:e.unit.gptCzk,color:j}]:[]],o=[{label:"Kling AI (video)",value:e.costs.klingCzk,color:y,calls:e.costs.klingCalls,usd:e.costs.klingUsd},{label:"Nano Banana (vylepšen\xed fotek)",value:e.costs.nanoBananaCzk,color:v,calls:e.costs.nanoBananaCalls,usd:e.costs.nanoBananaUsd},{label:"GPT Image",value:e.costs.gptCzk,color:j,calls:e.costs.gptImageCalls,usd:e.costs.gptUsd}];return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"V\xfdsledovka"}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1.4fr 1fr 1fr 1fr",gap:8,paddingBottom:8},children:[(0,i.jsx)("div",{}),["Tento měs\xedc","Minul\xfd měs\xedc","Celkem"].map(e=>(0,i.jsx)("div",{style:{fontSize:11,fontWeight:600,color:z,textAlign:"right"},children:e},e))]}),l("Tržby",p(e.revenue.monthCzk),p(e.revenue.lastMonthCzk),p(e.revenue.totalCzk),{color:g}),l((0,i.jsxs)(i.Fragment,{children:["AI n\xe1klady",n]}),`−${p(e.costs.monthCzk)}`,"\xb7",`−${p(e.costs.aiTotalCzk)}`,{color:f}),e.costs.fixedMonthCzk>0&&l("Fixn\xed n\xe1klady (hosting…)",`−${p(e.costs.fixedMonthCzk)}`,`−${p(e.costs.fixedMonthCzk)}`,"\xb7",{color:f}),l("Zisk",p(e.profit.monthNetCzk),"\xb7",p(e.profit.grossTotalCzk),{strong:!0,color:e.profit.monthNetCzk>=0?g:f}),l("Marže",u(e.revenue.monthCzk>0?Math.round(e.profit.monthNetCzk/e.revenue.monthCzk*100):null),"\xb7",u(e.profit.grossMarginPct),{strong:!0})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:10,marginTop:10},children:[(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"Ekonomika jednoho videa"}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[(0,i.jsx)("div",{style:{fontSize:30,fontWeight:700,letterSpacing:"-1px",color:g,...E},children:p(e.unit.contributionCzk)}),(0,i.jsxs)("div",{style:{fontSize:12.5,color:S},children:["čist\xe9ho z jednoho prodan\xe9ho videa \xb7 marže ",u(e.unit.contributionMarginPct)]})]}),(0,i.jsxs)("div",{style:{display:"flex",height:10,borderRadius:999,overflow:"hidden",background:T,marginTop:16},children:[r.map((t,n)=>(0,i.jsx)("div",{title:`${t.label}: ${h(t.value)}`,style:{width:`${t.value/Math.max(e.unit.effectivePriceCzk,1)*100}%`,background:t.color,minWidth:3*(t.value>0)}},n)),(0,i.jsx)("div",{style:{flex:1,background:g,opacity:.85}})]}),(0,i.jsxs)("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:7},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13},children:[(0,i.jsx)("span",{style:{color:S},children:"Prodejn\xed cena (efektivn\xed)"}),(0,i.jsx)("span",{style:{color:k,fontWeight:600,...E},children:p(e.unit.effectivePriceCzk)})]}),r.map((e,t)=>(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13},children:[(0,i.jsxs)("span",{style:{color:S,display:"flex",alignItems:"center",gap:7},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:2,background:e.color,display:"inline-block"}}),e.label]}),(0,i.jsxs)("span",{style:{color:f,...E},children:["−",h(e.value)]})]},t)),(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13,borderTop:`1px solid ${w}`,paddingTop:8},children:[(0,i.jsx)("span",{style:{color:k,fontWeight:700},children:"Př\xedspěvkov\xe1 marže"}),(0,i.jsx)("span",{style:{color:g,fontWeight:700,...E},children:p(e.unit.contributionCzk)})]})]})]}),(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"AI n\xe1klady celkem"}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:18},children:[(0,i.jsx)(N,{parts:o.map(e=>({label:e.label,value:e.value,color:e.color}))}),(0,i.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:10},children:[(0,i.jsx)("div",{style:{fontSize:24,fontWeight:700,letterSpacing:"-0.6px",color:k,...E},children:p(e.costs.aiTotalCzk)}),o.map((e,t)=>(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12.5},children:[(0,i.jsxs)("span",{style:{color:S,display:"flex",alignItems:"center",gap:7},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:2,background:e.color,display:"inline-block"}}),e.label]}),(0,i.jsx)("span",{style:{color:k,fontWeight:600,...E},children:p(e.value)})]}),(0,i.jsxs)("div",{style:{fontSize:10.5,color:z,marginLeft:15,...E}
1,children:[c(e.calls),"\xd7 \xb7 $",e.usd.toLocaleString("cs-CZ")]})]},t))]})]}),(0,i.jsxs)("div",{style:{fontSize:10.5,color:z,marginTop:12,lineHeight:1.5},children:["Vylepšen\xed fotek (Nano Banana) a GPT se měř\xed od 5. 7. 2026 — starš\xed vol\xe1n\xed v součtu nejsou.",e.costs.gptCostIsExact?" GPT cena je přesn\xe1 (z OpenAI usage).":""]})]})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,marginTop:10},children:[(0,i.jsx)(M,{label:"Zaplacen\xe1 videa",value:c(e.projects.paidTotal),sub:`tržby ${p(e.revenue.totalCzk)}`,color:g}),(0,i.jsx)(M,{label:"Zdarma (promo 100 %)",value:c(e.projects.freeTotal),sub:`hodnota ${p(e.marketing.giveawayValueCzk)}`,color:b}),(0,i.jsx)(M,{label:"Efektivn\xed cena",value:p(e.revenue.effectivePriceCzk),sub:`cen\xedk ${p(e.unit.priceCzk)}`}),(0,i.jsx)(M,{label:"Tržby za 90 dn\xed",value:p(e.revenue.last90Czk)})]}),(0,i.jsx)(D,{config:e.config,onSaved:t})]})}let O=[{key:"pricePerProjectCzk",label:"Cena projektu (Kč)"},{key:"klingUsdPerClip",label:"Kling — $ / 5s klip",step:"0.001"},{key:"nanoBananaUsdPerImage",label:"Nano Banana — $ / foto",step:"0.001"},{key:"gptUsdPerImage",label:"GPT — $ / foto",step:"0.001"},{key:"nanoBananaImagesPerProject",label:"\xd8 vylepšen\xfdch fotek / projekt"},{key:"gptImagesPerProject",label:"\xd8 GPT fotek / projekt"},{key:"usdToCzk",label:"Kurz USD → CZK",step:"0.1"},{key:"eurToCzk",label:"Kurz EUR → CZK",step:"0.1"},{key:"fixedCostsCzkPerMonth",label:"Fixn\xed n\xe1klady (Kč / měs\xedc)"}];function D({config:e,onSaved:t}){let[n,r]=(0,l.useState)(!1),[o,a]=(0,l.useState)({}),[s,c]=(0,l.useState)(!1),[p,h]=(0,l.useState)("");(0,l.useEffect)(()=>{let t={};for(let n of O)t[n.key]=String(e[n.key]);a(t)},[e]);let u=async()=>{c(!0),h("");try{let e={};for(let t of O){let n=Number(o[t.key]);isFinite(n)&&n>=0&&(e[t.key]=n)}await d("/api/admin/stats/config",{method:"POST",body:JSON.stringify(e)}),h("Uloženo — přepoč\xedt\xe1v\xe1m…"),t()}catch(e){h("Chyba při ukl\xe1d\xe1n\xed: "+String(e))}finally{c(!1)}};return(0,i.jsxs)(R,{style:{marginTop:10,padding:n?"18px 22px":"14px 22px"},children:[(0,i.jsxs)("button",{onClick:()=>r(e=>!e),style:{background:"none",border:"none",color:S,fontSize:12.5,fontWeight:600,cursor:"pointer",padding:0,display:"flex",alignItems:"center",gap:8,width:"100%"},children:[(0,i.jsx)("span",{style:{fontSize:10,transform:n?"rotate(90deg)":"none",transition:"transform .15s",display:"inline-block"},children:"▶"}),"Předpoklady v\xfdpočtu — jednotkov\xe9 ceny, kurzy, fixn\xed n\xe1klady"]}),n&&(0,i.jsxs)("div",{style:{marginTop:16},children:[(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:O.map(e=>(0,i.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:5},children:[(0,i.jsx)("span",{style:{fontSize:11,color:S},children:e.label}),(0,i.jsx)("input",{type:"number",step:e.step??"1",min:0,value:o[e.key]??"",onChange:t=>a(n=>({...n,[e.key]:t.target.value})),style:{background:"#0c0c0e",border:`1px solid ${w}`,borderRadius:9,color:k,fontSize:14,padding:"8px 11px",outline:"none",...E}})]},e.key))}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginTop:14},children:[(0,i.jsx)("button",{onClick:u,disabled:s,style:{background:m,color:"#fff",border:"none",borderRadius:9,padding:"9px 20px",fontSize:13,fontWeight:700,cursor:"pointer",opacity:s?.6:1},children:s?"Ukl\xe1d\xe1m…":"Uložit a přepoč\xedtat"}),p&&(0,i.jsx)("span",{style:{fontSize:12,color:p.startsWith("Chyba")?f:g},children:p})]})]})]})}function U({d:e}){let t=e.history,n=t.slice(-30).map(e=>({label:e.date.slice(5),value:e.newUsersToday??0})),l=[{label:"Registrovan\xed uživatel\xe9",value:e.users.total,color:m,note:`+${e.users.newThisMonth} tento měs\xedc`},{label:"Plat\xedc\xed z\xe1kazn\xedci",value:e.marketing.payingUsers,color:j,note:`konverze ${u(e.marketing.conversionPct)}`},{label:"Opakovan\xed z\xe1kazn\xedci (2+ n\xe1kupy)",value:e.marketing.repeatCustomers,color:g,note:`${u(e.marketing.repeatRatePct)} plat\xedc\xedch`}],r=Math.max(l[0].value,1);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10},children:[(0,i.jsx)($,{label:"Hodnota z\xe1kazn\xedka (LTV)",value:p(e.marketing.ltvCzk),sub:`\xd8 ${e.marketing.avgPurchasesPerCustomer.toLocaleStr
1ing("cs-CZ")} n\xe1kupů \xd7 ${p(e.unit.contributionCzk)} marže`,color:g}),(0,i.jsx)($,{label:"Max. cena akvizice (CAC)",value:p(e.marketing.maxCacCzk),sub:"pravidlo LTV : CAC = 3 : 1",color:b}),(0,i.jsx)($,{label:"Nov\xed uživatel\xe9 (měs\xedc)",value:c(e.users.newThisMonth),trend:e.users.monthGrowth,color:m}),(0,i.jsx)($,{label:"Plat\xedc\xed tento měs\xedc",value:c(e.marketing.payingThisMonth),sub:`${c(e.projects.paidMonth)} prodan\xfdch vide\xed`,color:j})]}),(0,i.jsxs)(R,{style:{marginTop:10},children:[(0,i.jsx)(A,{children:"Doporučen\xfd rozpočet na marketing / měs\xedc"}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10,marginTop:4},children:e.marketing.budgetScenarios.map((t,n)=>{let l=1===n;return(0,i.jsxs)("div",{style:{border:`1px solid ${l?m:w}`,borderRadius:16,padding:"16px 18px",background:l?"rgba(10,132,255,0.07)":"transparent",position:"relative"},children:[l&&(0,i.jsx)("span",{style:{position:"absolute",top:-9,left:16,background:m,color:"#fff",fontSize:10,fontWeight:700,borderRadius:999,padding:"2px 10px",letterSpacing:.3},children:"DOPORUČENO"}),(0,i.jsxs)("div",{style:{fontSize:12,color:S,fontWeight:600},children:[["Konzervativn\xed","Doporučeno","Agresivn\xed"][n]," \xb7 ",t.sharePct," % tržeb"]}),(0,i.jsx)("div",{style:{fontSize:25,fontWeight:700,letterSpacing:"-0.7px",color:l?m:k,marginTop:6,...E},children:p(t.budgetCzk)}),(0,i.jsxs)("div",{style:{fontSize:11.5,color:z,marginTop:8,lineHeight:1.6,...E},children:["≈ ",t.estNewCustomers," nov\xfdch z\xe1kazn\xedků při CAC ",p(e.marketing.maxCacCzk),(0,i.jsx)("br",{}),"potenci\xe1l tržeb +",p(t.estRevenueCzk)]})]},n)})}),(0,i.jsxs)("div",{style:{fontSize:10.5,color:z,marginTop:12,lineHeight:1.5},children:["Z\xe1klad = vyšš\xed z tržeb tohoto a minul\xe9ho měs\xedce. Dokud je marže na video ",u(e.unit.contributionMarginPct)," a CAC pod ",p(e.marketing.maxCacCzk),", marketing se vypl\xe1c\xed šk\xe1lovat."]})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginTop:10},children:[(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"Konverzn\xed trycht\xfdř"}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:14,marginTop:6},children:l.map((e,t)=>(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12.5,marginBottom:5},children:[(0,i.jsx)("span",{style:{color:S},children:e.label}),(0,i.jsxs)("span",{style:{color:k,fontWeight:700,...E},children:[c(e.value)," ",(0,i.jsx)("span",{style:{color:z,fontWeight:500},children:e.note})]})]}),(0,i.jsx)("div",{style:{height:9,borderRadius:999,background:T,overflow:"hidden"},children:(0,i.jsx)("div",{style:{width:`${Math.max(e.value/r*100,2*(e.value>0))}%`,height:"100%",background:e.color,borderRadius:999}})})]},t))}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginTop:18},children:[(0,i.jsx)(M,{label:"ARPU (na registraci)",value:p(e.revenue.arpuCzk)}),(0,i.jsx)(M,{label:"Promo videa zdarma",value:c(e.marketing.freeProjectsTotal),sub:`hodnota ${p(e.marketing.giveawayValueCzk)}`,color:b})]})]}),(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"Nov\xed uživatel\xe9 / den (30 dn\xed)"}),(0,i.jsx)(W,{data:n.length?n:[{label:"",value:0}],color:m,height:110}),B(t.slice(-30)),(0,i.jsxs)("div",{style:{marginTop:16},children:[(0,i.jsx)(A,{children:"Růst registrac\xed (kumulativně)"}),(0,i.jsx)(I,{data:t.map(e=>e.usersTotal),color:m,uid:"mk-users",height:80})]})]})]})]})}function V({d:e}){let t=e.history,n=t.slice(-30).map(e=>({label:e.date.slice(5),value:e.projectsToday??0})),l=e.daily.map(e=>({label:e.date.slice(5),value:e.aiCostCzk}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10},children:[(0,i.jsx)($,{label:"Denně aktivn\xed (DAU)",value:c(e.users.activeToday),color:m,sub:`stickiness ${u(e.users.stickinessPct)} (DAU/MAU)`}),(0,i.jsx)($,{label:"T\xfddně aktivn\xed (WAU)",value:c(e.users.activeWeek),color:j}),(0,i.jsx)($,{label:"Měs\xedčně aktivn\xed (MAU)",value:c(e.users.activeMonth),color:y}),(0,i.jsx)($,{label:"Projekty dnes",value:c(e.projects.today),sub:`včera ${e.projects.yesterday} \xb7 t\xfdden ${e.projects.week}`,color:g})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginTop:10},children:[(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"Založen\xe9 projekty / den (30 dn\xed)"}),(0,i.jsx)(W,{data:n.length?n:[{label:"",value:0}],color:y,height:120}),B(t.slice(-30))]}),(0,i.jsxs)(R,{children:[(0,i.jsx)(A,{children:"AI n\xe1klady / den"}),l.length>=2?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(W,{data:l,color:b,height:120}),B(e.daily)]}):(0,i.jsxs)("div",{style:{height:130,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:z,textAlign:"center",lineHeight:1.6},children:["Denn\xed měřen\xed AI n\xe1kladů běž\xed od 5. 7. 2026.",(0,i.jsx)("br",{}),"Graf se napln\xed během několika dn\xed provozu."]})]})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,marginTop:10},children:[(0,i.jsx)(M,{label:"Kling generov\xe1n\xed",value:c(e.costs.klingCalls),sub:`\xd8 ${e.projects.avgClipsPerProject.toLocaleStr
1ing("cs-CZ")} klipů / projekt`,color:y}),(0,i.jsx)(M,{label:"Vylepšen\xed fotek (NB)",value:c(e.costs.nanoBananaCalls),sub:"od 5. 7. 2026",color:v}),(0,i.jsx)(M,{label:"GPT Image",value:c(e.costs.gptImageCalls),sub:"od 5. 7. 2026",color:j}),(0,i.jsx)(M,{label:"Projekty celkem",value:c(e.projects.totalEver),sub:`${c(e.projects.total)} aktivn\xedch`})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:8,marginTop:8},children:[(0,i.jsx)(M,{label:"Podpora — otevřen\xe9 chaty",value:c(e.ops.chatsOpen),sub:`${c(e.ops.chatsResolved)} vyřešen\xfdch`,color:e.ops.chatsOpen>0?b:g}),(0,i.jsx)(M,{label:"Hudba",value:`${e.ops.songsApproved} / ${e.ops.songsTotal}`,sub:"schv\xe1len\xe9 / celkem"}),(0,i.jsx)(M,{label:"Aktivita dnes",value:c(e.users.activeToday),sub:`${c(e.projects.today)} nov\xfdch projektů`})]})]})}let K=[{key:"overview",label:"Přehled"},{key:"finance",label:"Finance"},{key:"marketing",label:"Marketing"},{key:"ops",label:"Provoz"}];function Z({initialData:e}){let[t,n]=(0,l.useState)(e??null),[r,o]=(0,l.useState)(!e),[a,s]=(0,l.useState)(""),[c,p]=(0,l.useState)("overview"),[h,u]=(0,l.useState)(0);(0,l.useEffect)(()=>{if(e)return;let t=!1;return s(""),d("/api/admin/stats").then(e=>{t||n(e)}).catch(e=>{t||s(String(e))}).finally(()=>{t||o(!1)}),()=>{t=!0}},[e,h]);let x=(0,l.useMemo)(()=>t?new Date(t.generatedAt).toLocaleTimeString("cs-CZ",{hour:"2-digit",minute:"2-digit"}):"",[t]);return r?(0,i.jsxs)("div",{style:_,children:[(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10,marginTop:54},children:[1,2,3,4].map(e=>(0,i.jsx)("div",{style:{height:120,borderRadius:20,background:C,opacity:.6}},e))}),[1,2].map(e=>(0,i.jsx)("div",{style:{height:220,borderRadius:20,background:C,opacity:.6,marginTop:10}},e))]}):a||!t?(0,i.jsxs)("div",{style:_,children:[(0,i.jsxs)("p",{style:{color:f,fontSize:14},children:["Chyba při nač\xedt\xe1n\xed statistik. ",a]}),(0,i.jsx)("button",{onClick:()=>{o(!0),u(e=>e+1)},style:{background:m,color:"#fff",border:"none",borderRadius:9,padding:"9px 20px",fontSize:13,fontWeight:700,cursor:"pointer"},children:"Zkusit znovu"})]}):(0,i.jsxs)("div",{style:_,children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18,flexWrap:"wrap",gap:12},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{style:{margin:0,fontSize:26,fontWeight:800,letterSpacing:"-0.8px",color:k},children:K.find(e=>e.key===c)?.label}),(0,i.jsxs)("div",{style:{fontSize:11.5,color:z,marginTop:3},children:["aktualizov\xe1no ",x]})]}),(0,i.jsx)("div",{style:{display:"flex",background:"#0c0c0e",border:`1px solid ${w}`,borderRadius:12,padding:3},children:K.map(e=>(0,i.jsx)("button",{onClick:()=>
1p(e.key),style:{background:c===e.key?"#2c2c30":"transparent",color:c===e.key?k:S,border:"none",borderRadius:9,padding:"7px 18px",fontSize:13,fontWeight:600,cursor:"pointer",transition:"background .12s, color .12s"},children:e.label},e.key))})]}),"overview"===c&&(0,i.jsx)(F,{d:t}),"finance"===c&&(0,i.jsx)(L,{d:t,onConfigSaved:()=>{o(!0),u(e=>e+1)}}),"marketing"===c&&(0,i.jsx)(U,{d:t}),"ops"===c&&(0,i.jsx)(V,{d:t})]})}let _={maxWidth:1060,margin:"0 auto",padding:"24px 20px 60px",fontFamily:'-apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif',color:k},J=n(7358).env.NEXT_PUBLIC_VF_API_URL||"/vf-api";async function H(e,t){let n=await s.auth.currentUser?.getIdToken();return fetch(J+e,{...t,headers:{...t?.headers,Authorization:`Bearer ${n}`,"Content-Type":"application/json"}})}let X={zoom:"Ploch\xfd zoom",rychle:"Moc rychle",deformace:"Deformace",ok:"Prošel"},G={auto:"Zam\xedtla kontrola",regen:"Přegeneroval z\xe1kazn\xedk"},Y=(e,t=3)=>"number"==typeof e&&isFinite(e)?e.toFixed(t).replace(".",","):"–";function q(){let e,[t,n]=(0,l.useState)([]),[r,o]=(0,l.useState)("unlabeled"),[a,s]=(0,l.useState)(""),[d,c]=(0,l.useState)(null),[p,h]=(0,l.useState)(0),[u,x]=(0,l.useState)(null),[g,f]=(0,l.useState)(""),[m,y]=(0,l.useState)(!1),[b,j]=(0,l.useState)(""),[v,k]=(0,l.useState)(!1),[S,z]=(0,l.useState)(null),C=(0,l.useCallback)(async()=>{j("");try{let e=new URLSearchParams({status:r,take:"50"});a&&e.set("source",a);let t=await H("/api/admin/clip-reviews?"+e.toString());if(403===t.status||401===t.status)return void j("Jen pro admina.");if(!t.ok)return void j("Načten\xed selhalo (HTTP "+t.status+"). Běž\xed VF.Api?");c(await t.json()),h(0)}catch{j("VF.Api neodpov\xedd\xe1.")}},[r,a]);(0,l.useEffect)(()=>{H("/api/admin/clip-reviews/labels").then(e=>e.ok?e.json():[]).then(n).catch(()=>{})},[]),(0,l.useEffect)(()=>{C()},[C]);let w=d?.items[p]||null;(0,l.useEffect)(()=>{x(w?.label??null),f(w?.labelNote??"")},[w?.reviewId]);let T=(0,l.useCallback)(async()=>{if(w&&!m){y(!0),j("");try{let e=await H(`/api/admin/clip-reviews/${w.reviewId}/label`,{method:"POST",body:JSON.stringify({label:u,note:g})});if(!e.ok)return void j("Uložen\xed selhalo (HTTP "+e.status+").");z(null),c(e=>{if(!e)return e;let t={...w,label:u,labelNote:g||null,labeledAt:u?new Date().toISOString():null};if("unlabeled"===r&&u){let t=e.items.filter(e=>e.reviewId!==w.reviewId);return{...e,items:t,unlabeled:Math.max(0,e.unlabeled-1),labeled:e.labeled+1}}return{...e,items:e.items.map(e=>e.reviewId===w.reviewId?t:e)}}),"unlabeled"===r&&u||h(e=>Math.min(e+1,(d?.items.length||1)-1))}finally{y(!1)}}},[w,u,g,m,r,d?.items.length]);(0,l.useEffect)(()=>{d&&"unlabeled"===r&&0===d.items.length&&d.unlabeled>0&&C()},[d,r,C]),(0,l.useEffect)(()=>{d&&p>d.items.length-1&&h(Math.max(0,d.items.length-1))},[d,p]),(0,l.useEffect)(()=>{let e=e=>{let n=e.target?.tagName==="TEXTAREA";if("Enter"===e.key&&(!n||e.ctrlKey||e.metaKey)){e.preventDefault(),T();return}if(n)return;let i=parseInt(e.key,10);i>=1&&i<=t.length?x(t[i-1].key):("ArrowRight"===e.key&&h(e=>Math.min(e+1,(d?.items.length||1)-1)),"ArrowLeft"===e.key&&h(e=>Math.max(0,e-1)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,T,d?.items.length]),(0,l.useEffect)(()=>{v&&!S&&H("/api/admin/clip-reviews/stats").then(e=>e.ok?e.json():[]).then(z).catch(()=>z([]))},[v,S]);let E=(0,l.useMemo)(()=>{if(!S)return null;let e=e=>S.filter(e).reduce((e,t)=>e+t.count,0);return{autoTotal:e(e=>"auto"===e.source),autoRight:e(e=>"auto"===e.source&&!!e.label&&"ok"!==e.label),autoFalse:e(e=>"auto"===e.source&&"ok"===e.label),regenTotal:e(e=>"regen"===e.source),regenMissed:e(e=>"regen"===e.source&&"ok"===e.detector&&!!e.label&&"ok"!==e.label),regenOk:e(e=>"regen"===e.source&&"ok"===e.label)}},[S]),R=w?.metrics||{},A=e=>e?t.find(t=>t.key===e)?.title||e:"neoznačeno";return(0,i.jsxs)("div",{style:{maxWidth:1180,margin:"0 auto",padding:24},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center",marginBottom:16},children:[["unlabeled","labeled","all"].map(e=>(0,i.jsx)("button",{style:{...Q.chip,...r===e?Q.chipOn:{}},onClick:()=>o(e),children:"unlabeled"===e?`Neoznačen\xe9${d?` (${d.unlabeled})`:""}`:"labeled"===e?`Označen\xe9${d?` (${d.labeled})`:""}`:"Vše"},e)),(0,i.jsx)("span",{style:{width:1,height:20,background:"#222",margin:"0 4px"}}),["","auto","regen"].map(e=>(0,i.jsx)("button",{style:{...Q.chip,...a===e?Q.chipOn:{}},onClick:()=>s(e),children:e?G[e]:"Všechny zdroje"},e||"any")),(0,i.jsx)("span",{style:{flex:1}}
1),(0,i.jsx)("button",{style:{...Q.chip,...v?Q.chipOn:{}},onClick:()=>k(e=>!e),children:"\uD83D\uDCC8 Přehled přesnosti"})]}),b&&(0,i.jsx)("div",{style:{...Q.card,borderColor:"#5a1d1d",color:"#f87171",marginBottom:16},children:b}),v&&(0,i.jsx)("div",{style:{...Q.card,marginBottom:16},children:S?S.length?(0,i.jsxs)(i.Fragment,{children:[E&&(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:12,marginBottom:16},children:[(0,i.jsxs)("div",{style:Q.stat,children:[(0,i.jsx)("div",{style:Q.statL,children:"Zam\xedtla kontrola"}),(0,i.jsx)("div",{style:Q.statV,children:E.autoTotal}),(0,i.jsxs)("div",{style:Q.statS,children:["opr\xe1vněně ",E.autoRight," \xb7 plan\xfd poplach ",E.autoFalse]})]}),(0,i.jsxs)("div",{style:Q.stat,children:[(0,i.jsx)("div",{style:Q.statL,children:"Přegeneroval z\xe1kazn\xedk"}),(0,i.jsx)("div",{style:Q.statV,children:E.regenTotal}),(0,i.jsxs)("div",{style:Q.statS,children:["vada, kterou kontrola nechala proj\xedt ",E.regenMissed," \xb7 klip v poř\xe1dku ",E.regenOk]})]})]}),(0,i.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{style:{color:"#888",textAlign:"left"},children:[(0,i.jsx)("th",{style:Q.th,children:"Zdroj"}),(0,i.jsx)("th",{style:Q.th,children:"Kontrola řekla"}),(0,i.jsx)("th",{style:Q.th,children:"Tvůj št\xedtek"}),(0,i.jsx)("th",{style:{...Q.th,textAlign:"right"},children:"Počet"})]})}),(0,i.jsx)("tbody",{children:S.map((e,t)=>{let n=!!e.label&&"ok"===e.detector!=("ok"===e.label);return(0,i.jsxs)("tr",{style:{borderTop:"1px solid #1e1e22"},children:[(0,i.jsx)("td",{style:Q.td,children:G[e.source]||e.source}),(0,i.jsx)("td",{style:Q.td,children:X[e.detector]||e.detector}),(0,i.jsx)("td",{style:{...Q.td,color:n?"#fbbf24":e.label?"#e5e5e5":"#666"},children:A(e.label)}),(0,i.jsx)("td",{style:{...Q.td,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:e.count})]},t)})})]}),(0,i.jsx)("div",{style:{color:"#666",fontSize:12,marginTop:10},children:"Žlutě: kontrola a tvůj št\xedtek se neshodnou — přesně na těchhle klipech se kontrola lad\xed."})]}):(0,i.jsx)("div",{style:{color:"#888"},children:"Zat\xedm ž\xe1dn\xe1 data."}):(0,i.jsx)("div",{style:{color:"#888"},children:"Nač\xedt\xe1m…"})}),d?w?(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 380px",gap:16,alignItems:"start"},children:[(0,i.jsx)("div",{style:{...Q.card,padding:0,overflow:"hidden",background:"#000",display:"flex",justifyContent:"center"},children:w.videoUrl?(0,i.jsx)("video",{src:w.videoUrl,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,controls:!0,style:{width:"100%",maxHeight:"74vh",objectFit:"contain",display:"block"}},w.reviewId):(0,i.jsx)("div",{style:{color:"#666",padding:60},children:"Video už je smazan\xe9 (starš\xed než 30 dn\xed)."})}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[(0,i.jsxs)("div",{style:Q.card,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8},children:[(0,i.jsx)("span",{style:{...Q.badge,..."auto"===w.source?Q.badgeAuto:Q.badgeRegen},children:G[w.source]}),(0,i.jsxs)("span",{style:{color:"#666",fontSize:12},children:[p+1," / ",d.items.length,d.total>d.items.length?` (celkem ${d.total})`:""]})]}),(0,i.jsxs)("div",{style:{color:"#888",fontSize:12,marginTop:10,lineHeight:1.6},children:[new Date(w.createdAt).toLocaleString("cs-CZ"),w.videoUrl&&(0,i.jsxs)(i.Fragment,{children:[" \xb7 video se smaže za ",Math.max(0,Math.ceil((new Date(w.videoExpiresAt).getTime()-Date.now())/864e5))," dn\xed"]}),(0,i.jsx)("br",{}),"job ",w.jobId??"–",w.attempt?` \xb7 ${w.attempt}. pokus`:"",w.replacedByJobId?` \xb7 nahrazen jobem ${w.replacedByJobId}`:""]})]}),(0,i.jsxs)("div",{style:Q.card,children:[(0,i.jsx)("div",{style:Q.secL,children:"Kontrola řekla"}),(0,i.jsx)("div",{style:{fontWeight:700,color:w.detectorProblem?"#f87171":"#4ade80"},children:w.detectorProblem?X[w.detectorProblem]||w.detectorProblem:w.metrics?"Prošel":"Nezkontrolov\xe1no"}),w.detectorReason&&(0,i.jsx)("div",{style:{color:"#aaa",fontSize:12,marginTop:4},children:w.detectorReason}),w.metrics&&(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"3px 12px",fontSize:12,color:"#999",marginTop:10,fontVariantNumeric:"tabular-nums"},children:[(0,i.jsx)("span",{children:"rho / rozptyl"}),(0,i.jsxs)("span",{style:{color:"#ddd"},children:[Y(R.rho)," / ",Y(R.depthSpread)]}),(0,i.jsx)("span",{children:"tempo pozad\xed"}),(0,i.jsxs)("span",{style:{color:"#ddd"},children:[Y("number"==typeof R.expansionBgPerSec?100*R.expansionBgPerSec:NaN,1)," %/s"]}),(0,i.jsx)("span",{children:"nejhorš\xed oblast"}),(0,i.jsx)("span",{style:{color:"#ddd"},children:"number"==typeof(e=R.dCellMin)&&isFinite(e)?Math.round((Math.exp(e)-1)*100)+" %":"–"}),(0,i.jsx)("span",{children:"smršťuj\xedc\xed se body"}),(0,i.jsxs)("span",{style:{color:"#ddd"},children:[Y("number"==typeof R.dContractFrac?100*R.dContractFrac:NaN,0)," %"]})]})]}),(0,i.jsxs)("div",{style:Q.card,children:[(0,i.jsx)("div",{style:Q.secL,children:"Co na klipu je"}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:t.map((e,t)=>(0,i.jsxs)("button",{onClick:()=>x(e.key),style:{...Q.labelBtn,...u===e.key?"ok"===e.key?Q.labelOk:Q.labelOn:{}},children:[(0,i.jsx)("span",{style:Q.kbd,children:t+1}),e.title]},e.key))}),(0,i.jsx)("textarea",{value:g,onChange:e=>f(e.target.value.slice(0,1e3)),placeholder:"Pozn\xe1mka (voliteln\xe9) — třeba „stůl se prop
1ad\xe1 od 2. vteřiny“",style:{...Q.textarea,marginTop:10},rows:2}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,marginTop:10},children:[(0,i.jsx)("button",{style:{...Q.btn,flex:1,opacity:m||!u?.5:1},disabled:m||!u,onClick:T,children:m?"Ukl\xe1d\xe1m…":"Uložit a dalš\xed ⏎"}),(0,i.jsx)("button",{style:Q.btnGhost,onClick:()=>h(e=>Math.max(0,e-1)),disabled:0===p,children:"←"}),(0,i.jsx)("button",{style:Q.btnGhost,onClick:()=>h(e=>Math.min(e+1,d.items.length-1)),disabled:p>=d.items.length-1,children:"→"})]}),w.label&&(0,i.jsxs)("div",{style:{color:"#666",fontSize:12,marginTop:8},children:["Uloženo: ",A(w.label)]})]})]})]}):(0,i.jsxs)("div",{style:{...Q.card,color:"#888",textAlign:"center",padding:40},children:["unlabeled"===r?"Všechno je označen\xe9. \uD83C\uDF89":"Nic tu nen\xed.",(0,i.jsx)("div",{style:{fontSize:12,marginTop:8,color:"#666"},children:"Klipy přib\xfdvaj\xed, když kontrola nějak\xfd zam\xedtne nebo když z\xe1kazn\xedk d\xe1 „Vygenerovat znovu“."})]}):(0,i.jsx)("div",{style:{color:"#888"},children:"Nač\xedt\xe1m…"})]})}let Q={card:{background:"#151518",borderRadius:12,padding:16,border:"1px solid #222"},chip:{background:"transparent",color:"#888",border:"1px solid #222",borderRadius:999,padding:"6px 12px",fontSize:12,cursor:"pointer"},chipOn:{background:"#1e1e22",color:"#fff",borderColor:"#333"},badge:{fontSize:11,fontWeight:700,padding:"3px 9px",borderRadius:999,letterSpacing:".02em"},badgeAuto:{background:"rgba(244,81,30,.12)",color:"#F4511E",border:"1px solid rgba(244,81,30,.35)"},badgeRegen:{background:"rgba(96,165,250,.1)",color:"#60a5fa",border:"1px solid rgba(96,165,250,.3)"},secL:{fontSize:11,fontWeight:700,color:"#666",textTransform:"uppercase",letterSpacing:".08em",marginBottom:8},labelBtn:{display:"flex",alignItems:"center",gap:10,textAlign:"left",background:"#1a1a1f",color:"#ccc",border:"1px solid #26262c",borderRadius:8,padding:"9px 12px",fontSize:13,cursor:"pointer"},labelOn:{background:"rgba(244,81,30,.14)",borderColor:"rgba(244,81,30,.6)",color:"#fff"},labelOk:{background:"rgba(74,222,128,.1)",borderColor:"rgba(74,222,128,.5)",color:"#fff"},kbd:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,background:"#0d0d10",border:"1px solid #333",fontSize:11,color:"#888",flexShrink:0},textarea:{width:"100%",background:"#0d0d10",color:"#e0e0e0",border:"1px solid #333",borderRadius:8,padding:10,fontSize:13,resize:"vertical",boxSizing:"border-box",fontFamily:"inherit"},btn:{background:"#F4511E",color:"#fff",border:"none",borderRadius:8,padding:"10px 16px",fontSize:14,fontWeight:700,cursor:"pointer"},btnGhost:{background:"transparent",color:"#ccc",border:"1px solid #333",borderRadius:8,padding:"10px 14px",fontSize:14,cursor:"pointer"},stat:{background:"#1a1a1f",borderRadius:10,padding:14,border:"1px solid #26262c"},statL:{fontSize:12,color:"#888"},statV:{fontSize:26,fontWeight:800,margin:"4px 0"},statS:{fontSize:12,color:"#aaa"},th:{padding:"6px 8px",fontWeight:600},td:{padding:"7px 8px"}};function ee(e,t){let n=void 0!==t?t:2.2,i=e.sampleRate,l=e.getChannelData(0),r=Math.round(.01*i),o=Math.round(.05*i),a=Math.round(i/200),s=[];for(let e=0;e+o<l.length;e+=r){let t=0,n=0;for(let i=e;i<e+o;i+=a){let r=0,s=Math.min(i+a,e+o);for(let e=i;e<s;e++)r+=l[e];r/=s-i,t+=r*r,n++}s.push(t/n)}let d=Math.round(150),c=Math.round(35),p=[],h=[],u=-c;for(let e=d;e<s.length-d;e++){let t=0;for(let n=e-d;n<=e+d;n++)t+=s[n];if(t/=2*d+1,s[e]>t*n&&e-u>c){let n=!0;for(let t=-3;t<=3;t++)if(0!==t&&s[e+t]>s[e]){n=!1;break}if(n){let n=e;for(let t=e-1;t>=Math.max(0,e-7)&&!(s[t]<.35*s[e]);t--)n=t;p.push(n*r/i),h.push(s[e]/t),u=e}}}return{times:p,strengths:h}}function et(e){let t={},{musicStart:n,sequence:i}=e;for(let e=1;e<=Math.min(25,i.length);e++){let l=i.slice(0,e).map(e=>({trimStart:Math.max(0,e.trimStart),trimEnd:Math.min(4.9,e.trimEnd)})),r=n;for(let e of l)r+=e.trimEnd-e.trimStart;t[String(e)]={musicStart:n,musicEnd:Math.round(1e3*r)/1e3,clips:l}}return t}async function en(){let e=s.auth.currentUser;if(!e)throw Error("Not logged in");let t=await e.getIdToken();return{Authorization:`Bearer ${t}`}}async function ei(e,t={}){let n=await en(),i=await fetch(e,{...t,headers:{...n,...t.headers||{}}});if(!i.ok)throw Error(`${i.status} ${i.statusText}`);return i.json()}async function el(e,t){let n;if(e instanceof File)n=await e.arrayBuffer();else{let t=`/api/video-proxy?url=${encodeURIComponent(e)}`,i=await fetch(t);n=await i.arrayBuffer()}let i=new AudioContext,l=await i.decodeAudioData(n),{times:r,strengths:o}=ee(l),a=function(e){if(e.length<4)return 0;let t=[];for(let n=1;n<Math.min(e.length,20);n++)t.push(e[n]-e[n-1]);let n=t.reduce((e,t)=>
1e+t,0)/t.length;return n>0?Math.round(60/n):0}(r),s=l.duration;return{brief:function(e,t,n,i,l){let r=[];for(let e=1;e<i.length;e++){let t=i[e]-i[e-1];t>=.8&&r.push({gap:t,before:i[e-1],after:i[e]})}r.sort((e,t)=>t.gap-e.gap);let o=r.slice(0,8).map(e=>`    mezera ${e.gap.toFixed(3)}s: beat před=${e.before.toFixed(3)}s → beat po (=možn\xfd DROP)=${e.after.toFixed(3)}s`).join("\n")||"    ž\xe1dn\xe9 mezery >= 0.8s",a=i.map((e,t)=>{let n=l[t]||1;return`${e.toFixed(3)}${n>=4?"★★★":n>=3?"★★":n>=2.5?"★":""}`}).join(", "),s=i.filter((e,t)=>(l[t]||1)>=3);return`ROLE
2Jsi expert na beat-sync video střih pro realitn\xed marketing.
3Konfiguruješ song library — tvůj v\xfdstup se ulož\xed do Firestore a použije se automaticky v editoru pro libovoln\xfd počet z\xe1běrů (1–25).
4
5P\xcdSEŇ: "${e}"
6D\xe9lka: ${t.toFixed(2)} s
7BPM (odhadovan\xe9): ~${n}
8Celkem beatů: ${i.length}
9
10NEJVĚTŠ\xcd MEZERY MEZI BEATY (breakdown→drop přechody):
11${o}
12
13SILN\xc9 BEATY ★★+ (tyto použ\xedvej pro střihy):
14  ${s.map(e=>e.toFixed(3)).join(", ")}
15
16Všechny beaty (★★★=velmi siln\xfd, ★★=siln\xfd, ★=středn\xed, bez=slab\xfd):
17  ${a}
18
19━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
20⚠️  HUDBA — NEJDŮLEŽITĚJŠ\xcd Č\xc1ST. PŘEČTI CEL\xc9 PŘED V\xddPOČTEM.
21━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
22
23V\xddSLEDEK KTER\xdd CHCEME:
24  Video začne klidně. Klip 1 hraje ~3–5 sekund.
25  Pak přijde PRVN\xcd STŘIH — a ten mus\xed trefit přesně PRVN\xcd BEAT DROPU.
26  Refr\xe9n/drop p\xedsničky = nejsilnějš\xed, nejhlasitějš\xed č\xe1st.
27  Div\xe1k to fyzicky uc\xedt\xed. Toto je nejdůležitějš\xed moment cel\xe9ho videa.
28
29━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
30KROK 1: NAJDI DROP — POMOC\xcd ENERGIE, NE POČTU BEATŮ
31━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
32
33DŮLEŽIT\xc9: Počet beatů v okně je špatn\xfd indik\xe1tor dropu — intro a
34verse maj\xed stejně beatů jako drop. Spr\xe1vn\xfd indik\xe1tor je ENERGIE
35(hlasitost). Drop = největš\xed skok v energii = m\xedsto kde p\xedseň
36"vybuchne" do pln\xe9 s\xedly.
37
38JAK NAJ\xcdT DROP Z BEATÅ®:
391) Hledej největš\xed MEZERU v beatu — drop часто předch\xe1z\xed tich\xe9 m\xedsto
40   (breakdown). Najdi nejdelš\xed interval mezi sousedn\xedmi beaty >= 1.5s.
41   Toto je breakdown→konec.
42
432) Beat IHNED po t\xe9to mezeře = prvn\xed beat dropu.
44
453) Ověřen\xed: drop b\xfdv\xe1 typicky DRUH\xc1 nebo TŘET\xcd velk\xe1 č\xe1st p\xedsničky.
46   Pro 2minutovou p\xedseň: nejčastěji 60–100s od zač\xe1tku.
47   DROP NEN\xcd INTRO.
48
494) Pokud nenajdeš velkou mezeru v beatu (>= 1.5s):
50   Hledej m\xedsto kde se průměrn\xfd interval mezi beaty ZMENŠ\xcd o v\xedce než
51   20% oproti předch\xe1zej\xedc\xedm 10s — to signalizuje př\xedchod dropu.
52
53V\xddSLEDEK: drop_beat = absolutn\xed čas v sekund\xe1ch (prvn\xed beat dropu)
54
55━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
56KROK 2: NASTAV musicStart A D\xc9LKU KLIPU 1
57━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
58
59Klip 1 mus\xed skončit PŘESNĚ na drop_beat.
60Klip 1 trv\xe1 3.0–4.6 sekund (ide\xe1lně ~4s).
61⚠️  MAX d\xe9lka klipu = 4.6s (každ\xe9 video je 5s, trimStart=0.3, takže max trimEnd=4.9)
62
63V\xfdpočet:
64  klip1_delka = zvol hodnotu v [3.0, 5.0]s
65  musicStart  = drop_beat - klip1_delka
66
67Zaokrouhli musicStart dolů na nejbližš\xed beat PŘED drop_beat:
68  musicStart = posledn\xed beat kter\xfd je <= (drop_beat - 3.0s)
69  → t\xedm zajist\xedš že hudba zač\xedn\xe1 na čist\xe9m beatu
70
71Pot\xe9:
72  trimEnd[klip_1] = trimStart[klip_1] + (drop_beat - musicStart)
73  → prvn\xed střih nastane přesně na drop_beat ✓
74
75PŘ\xcdKLAD (re\xe1ln\xfd v\xfdpočet pro p\xedseň s dropem na 82.41s):
76  drop_beat  = 82.410s
77  Beaty <= 79.41s: ..., 78.760s, 79.050s → musicStart = 79.050s
78  klip1_delka = 82.410 - 79.050 = 3.360s
79  trimEnd[klip_1] = 0.3 + 3.360 = 3.660s ✓
80
81━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
82KROK 3: ZB\xddVAJ\xcdC\xcd KLIPY — STŘIHEJ POUZE NA SILN\xc9 BEATY ★★+
83━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
84
85POUŽ\xcdVEJ V\xddHRADNĚ seznam "SILN\xc9 BEATY ★★+" v\xfdše.
86Slab\xe9 beaty (bez hvězdičky) IGNORUJ \xdaPLNĚ.
87Střih na slab\xe9m beatu = amat\xe9rsk\xfd v\xfdsledek.
88
89Pro každ\xfd klip N (N >= 2):
90
91  1. abs_prev_cut = musicStart + součet d\xe9lek klipů 1..N-1
92
93  2. Prim\xe1rn\xed okno: [abs_prev_cut + 3.0s,  abs_prev_cut + 5.0s]
94
95  3. Ze seznamu SILN\xc9 BEATY ★★+ vyber všechny v prim\xe1rn\xedm okně.
96     Pokud ž\xe1dn\xfd → rozšiř na [abs_prev_cut + 2.5s, abs_prev_cut + 5.5s].
97     Pokud st\xe1le ž\xe1dn\xfd → vezmi libovoln\xfd beat z tohoto rozš\xedřen\xe9ho okna.
98
99  4. Z kandid\xe1tů zvol NEJBLIŽŠ\xcd k (abs_prev_cut + 4.0s).
100
101  5. d\xe9lka_klipu_N = zvolen_beat - abs_prev_cut
102     trimEnd[N]    = trimStart[N] + d\xe9lka_klipu_N
103
104PRAVIDLA:
105✦ Vždy preferuj siln\xfd beat ★★+ v okně 3–5s.
106✦ Nikdy nestřihej na slab\xfd beat pokud existuje siln\xfd v rozsahu 2.5–5.5s.
107✦ musicEnd = musicStart + součet d\xe9lek všech klipů.
108
109⚠️  ABSOLUTN\xcd LIMIT: Každ\xfd klip je Kling AI video d\xe9lky přesně 5.0 sekund.
110  trimStart = 0.3 (pevně)
111  trimEnd NESM\xcd překročit 4.9 (= 5.0 - 0.1 jako bezpečnostn\xed margin)
112  Maxim\xe1ln\xed d\xe9lka klipu = trimEnd - trimStart = 4.6 s
113  Pokud by vypočten\xe1 d\xe9lka překročila 4.6s → oř\xedzni na 4.6s (trimEnd = 4.9)
114
115━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
116POVINN\xdd V\xddPOČET PŘED JSON
117━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
118Napiš pro každ\xfd klip:
119  → drop_beat = Xs, musicStart = Xs
120  Klip 1: d\xe9lka = X.XXs ✓
121  Klip 2: abs_prev_cut=Xs, siln\xe9 beaty v okně=[Xs★★, Xs★★★...], zvolen=Xs, d\xe9lka=X.XXs
122  Klip 3: abs_prev_cut=Xs, siln\xe9 beaty v okně=[...], zvolen=Xs, d\xe9lka=X.XXs
123  ...
124
125━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
126V\xddSTUP
127━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
128Vrať POUZE tento JSON (bez markdown, bez koment\xe1řů):
129
130{
131  "musicStart": X.XXX,
132  "sequence": [
133    { "trimStart": 0.3, "trimEnd": X.XXX },
134    { "trimStart": 0.3, "trimEnd": X.XXX },
135    ... (celkem 25 položek)
136  ]
137}`}(t,s,a,r,o),bpm:a,duration:s}}let er=n(7358).env.NEXT_PUBLIC_VF_API_URL||"/vf-api";async function eo(e,t){let n=await s.auth.currentUser?.getIdToken();return fetch(e,{...t,headers:{...t?.headers,Authorization:`Bearer ${n}`,"Content-Type":"application/json"}})}function ea(){let[e,t]=(0,l.useState)([]),[n,r]=(0,l.useState)(!0),[o,a]=(0,l.useState)(""),[s,d]=(0,l.useState)("100"),[c,p]=(0,l.useState)(!1),[h,u]=(0,l.useState)(!1),[x,g]=(0,l.useState)(""),[f,m]=(0,l.useState)(""),y=async()=>{r(!0);try{let e=await eo(`${er}/api/admin/promo`),n=await e.json();t(n.codes||[])}catch{g("Nepodařilo se nač\xedst k\xf3dy")}finally{r(!1)}};(0,l.useEffect)(()=>{y()},[]);let b=async()=>
137{if(g(""),m(""),!o.trim())return void g("Zadej k\xf3d");let e=parseInt(s);if(isNaN(e)||e<1||e>100)return void g("Sleva mus\xed b\xfdt 1–100 %");u(!0);try{let t=await eo(`${er}/api/admin/promo`,{method:"POST",body:JSON.stringify({code:o.trim(),discount:e,permanent:c})}),n=await t.json();if(!t.ok)return void g(n.error||"Chyba");m(`K\xf3d ${n.code} vytvořen (−${n.discount} %${n.permanent?", permanentn\xed":""})`),a(""),d("100"),p(!1),await y()}catch{g("Nepodařilo se vytvořit k\xf3d")}finally{u(!1)}},j=async(e,t)=>{if(confirm(t?`Smazat PERMANENTN\xcd k\xf3d ${e}? T\xedm přijdeš o př\xedstup k němu.`:`Smazat k\xf3d ${e}?`))try{let t=await eo(`${er}/api/admin/promo?code=${encodeURIComponent(e)}`,{method:"DELETE"}),n=await t.json();if(!t.ok)return void alert(n.error||"Chyba");await y()}catch{alert("Nepodařilo se smazat k\xf3d")}},v=e=>e?new Date(1e3*e._seconds).toLocaleDateString("cs-CZ",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—";return(0,i.jsxs)("div",{style:{maxWidth:860,margin:"0 auto",padding:24},children:[(0,i.jsx)("h2",{style:{fontSize:18,fontWeight:700,marginBottom:20,color:"#f0f0f0"},children:"\uD83C\uDF9F Spr\xe1va promok\xf3dů"}),(0,i.jsxs)("div",{style:{background:"#151518",borderRadius:12,padding:20,border:"1px solid #222",marginBottom:24},children:[(0,i.jsx)("h3",{style:{fontSize:14,fontWeight:700,marginBottom:16,color:"#F4511E",letterSpacing:".08em",textTransform:"uppercase"},children:"Vygenerovat nov\xfd k\xf3d"}),(0,i.jsxs)("div",{style:{display:"flex",gap:10,flexWrap:"wrap",alignItems:"flex-end"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:160},children:[(0,i.jsx)("label",{style:{fontSize:11,color:"#888",display:"block",marginBottom:6,letterSpacing:".08em",textTransform:"uppercase"},children:"K\xf3d"}),(0,i.jsx)("input",{style:{...eR.input,width:"100%",letterSpacing:".12em",textTransform:"uppercase"},placeholder:"např. REFUND50",value:o,onChange:e=>a(e.target.value.toUpperCase()),onKeyDown:e=>"Enter"===e.key&&b()})]}),(0,i.jsxs)("div",{style:{width:110},children:[(0,i.jsx)("label",{style:{fontSize:11,color:"#888",display:"block",marginBottom:6,letterSpacing:".08em",textTransform:"uppercase"},children:"Sleva (%)"}),(0,i.jsx)("input",{style:{...eR.input,width:"100%"},type:"number",min:"1",max:"100",value:s,onChange:e=>d(e.target.value)})]}),(0,i.jsx)("button",{style:eR.btn,onClick:b,disabled:h,children:h?"Vytv\xe1ř\xedm…":"+ Vytvořit k\xf3d"})]}),(0,i.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:10,marginTop:14,cursor:"pointer",userSelect:"none"},children:[(0,i.jsx)("div",{onClick:()=>p(e=>!e),style:{width:40,height:22,borderRadius:11,position:"relative",cursor:"pointer",transition:"background .2s",background:c?"#c084fc":"#333",border:`1px solid ${c?"#a855f7":"#444"}`},children:(0,i.jsx)("div",{style:{position:"absolute",top:2,left:c?19:2,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left .2s"}})}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:{fontSize:13,fontWeight:700,color:c?"#c084fc":"#888"},children:["Permanentn\xed k\xf3d ",c?"∞":""]}),(0,i.jsx)("span",{style:{fontSize:11,color:"#555",marginLeft:8},children:c?"— lze použ\xedt opakovaně (pro tvůj vlastn\xed \xfačet)":"— na jedno použit\xed (refund)"})]})]}),x&&(0,i.jsx)("p",{style:{color:"#ef4444",fontSize:13,marginTop:10},children:x}),f&&(0,i.jsxs)("p",{style:{color:"#5dfc8e",fontSize:13,marginTop:10},children:["✓ ",f]})]}),(0,i.jsxs)("div",{style:{background:"#151518",borderRadius:12,border:"1px solid #222",overflow:"hidden"},children:[(0,i.jsxs)("div",{style:{padding:"14px 20px",borderBottom:"1px solid #222",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,i.jsx)("h3",{style:{fontSize:14,fontWeight:700,color:"#f0f0f0",margin:0},children:"Všechny k\xf3dy"}),(0,i.jsxs)("span",{style:{fontSize:12,color:"#555"},children:[e.length," k\xf3dů"]})]}),n?(0,i.jsx)("p",{style:{padding:24,color:"#555",textAlign:"center"},children:"Nač\xedt\xe1m…"}):0===e.length?(0,i.jsx)("p",{style:{padding:24,color:"#555",textAlign:"center"},children:"Ž\xe1dn\xe9 k\xf3dy. Vytvoř prvn\xed v\xfdše."}):(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 70px 160px 1fr 130px 70px",gap:10,padding:"10px 20px",borderBottom:"1px solid #1a1a1a",fontSize:10,
137color:"#555",fontWeight:700,letterSpacing:".1em",textTransform:"uppercase"},children:[(0,i.jsx)("span",{children:"K\xf3d"}),(0,i.jsx)("span",{children:"Sleva"}),(0,i.jsx)("span",{children:"Stav"}),(0,i.jsx)("span",{children:"Naposledy použit"}),(0,i.jsx)("span",{children:"Vytvořeno"}),(0,i.jsx)("span",{})]}),e.map(e=>{let t=e.permanent?{label:`∞ Permanentn\xed (${e.useCount??0}\xd7)`,bg:"rgba(168,85,247,.1)",color:"#c084fc",border:"rgba(168,85,247,.25)"}:e.used?{label:"Použit",bg:"rgba(239,68,68,.1)",color:"#ef4444",border:"rgba(239,68,68,.2)"}:{label:"Voln\xfd",bg:"rgba(93,252,142,.1)",color:"#5dfc8e",border:"rgba(93,252,142,.2)"};return(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 70px 160px 1fr 130px 70px",gap:10,padding:"14px 20px",borderBottom:"1px solid #111",alignItems:"center"},children:[(0,i.jsx)("span",{style:{fontWeight:700,letterSpacing:".12em",fontSize:13,color:e.used&&!e.permanent?"#555":"#f0f0f0"},children:e.id}),(0,i.jsxs)("span",{style:{fontWeight:800,fontSize:15,color:"#F4511E"},children:["−",e.discount," %"]}),(0,i.jsx)("span",{style:{fontSize:10,fontWeight:700,padding:"3px 10px",borderRadius:100,background:t.bg,color:t.color,border:`1px solid ${t.border}`,display:"inline-block",letterSpacing:".06em",textTransform:"uppercase",whiteSpace:"nowrap"},children:t.label}),(0,i.jsx)("span",{style:{fontSize:11,color:"#555"},children:e.permanent?e.lastUsedAt?v(e.lastUsedAt):"—":e.used?v(e.usedAt):"—"}),(0,i.jsx)("span",{style:{fontSize:11,color:"#444"},children:v(e.createdAt)}),(0,i.jsx)("button",{onClick:()=>j(e.id,!!e.permanent),style:{background:"transparent",border:"1px solid #333",color:"#555",borderRadius:6,padding:"5px 10px",fontSize:11,cursor:"pointer"},onMouseOver:e=>{e.target.style.borderColor="#ef4444",e.target.style.color="#ef4444"},onMouseOut:e=>{e.target.style.borderColor="#333",e.target.style.color="#555"},children:"Smazat"})]},e.id)})]})]}),(0,i.jsx)(es,{codes:e})]})}function es({codes:e}){let[t,n]=(0,l.useState)(""),[r,o]=(0,l.useState)("current"),[a,s]=(0,l.useState)(()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}),[d,c]=(0,l.useState)([]),[p,h]=(0,l.useState)(!1);(0,l.useEffect)(()=>{t?(h(!0),eo(`${er}/api/admin/promo/stats?code=${encodeURIComponent(t)}`).then(e=>e.json()).then(e=>c(e.usages||[])).catch(()=>c([])).finally(()=>h(!1))):c([])},[t]);let u=(0,l.useMemo)(()=>{let e,t;if(!d.length||"all"===r)return d;let n=new Date;if("current"===r)e=n.getFullYear(),t=n.getMonth();else if("prev"===r){let i=new Date(n.getFullYear(),n.getMonth()-1,1);e=i.getFullYear(),t=i.getMonth()}else{let n=a.split("-");e=parseInt(n[0]),t=parseInt(n[1])-1}return d.filter(n=>{if(!n.usedAt)return!1;let i=new Date(1e3*n.usedAt._seconds);return i.getFullYear()===e&&i.getMonth()===t})},[d,r,a]),x=e=>({padding:"5px 14px",borderRadius:6,fontSize:12,fontWeight:700,cursor:"pointer",background:e?"#F4511E":"transparent",color:e?"#fff":"#888",border:`1px solid ${e?"#F4511E":"#333"}`});return(0,i.jsxs)("div",{style:{background:"#151518",borderRadius:12,border:"1px solid #222",marginTop:24,overflow:"hidden"},children:[(0,i.jsx)("div",{style:{padding:"14px 20px",borderBottom:"1px solid #222"},children:(0,i.jsx)("h3",{style:{fontSize:14,fontWeight:700,color:"#f0f0f0",margin:0},children:"\uD83D\uDCC8 Statistiky k\xf3du"})}),(0,i.jsxs)("div",{style:{padding:"16px 20px"},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",marginBottom:16},children:[(0,i.jsx)("label",{style:{fontSize:11,color:"#888",letterSpacing:".08em",textTransform:"uppercase",whiteSpace:"nowrap"},children:"K\xf3d:"}),(0,i.jsxs)("select",{value:t,onChange:e=>n(e.target.value),style:{...eR.input,minWidth:180,flex:"none"},children:[(0,i.jsx)("option",{value:"",children:"— vyber promok\xf3d —"}),e.map(e=>(0,i.jsxs)("option",{value:e.id,children:[e.id," (−",e.discount," %",e.permanent?", ∞":"",")"]},e.id))]})]}),t&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center",marginBottom:16},children:[["current","prev","all"].map(e=>(0,i.jsx)("button",{style:x(r===e),onClick:()=>o(e),children:(e=>{let t=new Date;
137if("current"===e)return`${t.toLocaleString("cs-CZ",{month:"long"})} ${t.getFullYear()}`;let n=new Date(t.getFullYear(),t.getMonth()-1,1);return"prev"===e?`${n.toLocaleString("cs-CZ",{month:"long"})} ${n.getFullYear()}`:"all"===e?"Cel\xe1 doba":"Vlastn\xed"})(e)},e)),(0,i.jsx)("button",{style:x("custom"===r),onClick:()=>o("custom"),children:"Vlastn\xed měs\xedc"}),"custom"===r&&(0,i.jsx)("input",{type:"month",value:a,onChange:e=>s(e.target.value),style:{...eR.input,width:"auto",padding:"5px 10px",fontSize:12}})]}),!p&&(0,i.jsxs)("div",{style:{display:"flex",gap:16,marginBottom:16,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{background:"#0e0e10",borderRadius:8,padding:"10px 18px",border:"1px solid #222"},children:[(0,i.jsx)("div",{style:{fontSize:10,color:"#555",letterSpacing:".1em",textTransform:"uppercase"},children:"Zobrazen\xe9 obdob\xed"}),(0,i.jsxs)("div",{style:{fontSize:22,fontWeight:800,color:"#F4511E",marginTop:2},children:[u.length,"\xd7"]})]}),(0,i.jsxs)("div",{style:{background:"#0e0e10",borderRadius:8,padding:"10px 18px",border:"1px solid #222"},children:[(0,i.jsx)("div",{style:{fontSize:10,color:"#555",letterSpacing:".1em",textTransform:"uppercase"},children:"Celkem za vždy"}),(0,i.jsxs)("div",{style:{fontSize:22,fontWeight:800,color:"#c084fc",marginTop:2},children:[d.length,"\xd7"]})]})]}),p?(0,i.jsx)("p",{style:{color:"#555",fontSize:13,textAlign:"center",padding:20},children:"Nač\xedt\xe1m…"}):0===u.length?(0,i.jsx)("p",{style:{color:"#555",fontSize:13,textAlign:"center",padding:20},children:0===d.length?"Ž\xe1dn\xe1 použit\xed nebyla zat\xedm zaznamen\xe1na.":"V tomto obdob\xed nebyl k\xf3d použit."}):(0,i.jsxs)("div",{style:{border:"1px solid #1a1a1a",borderRadius:8,overflow:"hidden"},children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"160px 1fr 1.2fr",gap:10,padding:"8px 14px",background:"#0e0e10",fontSize:10,color:"#555",fontWeight:700,letterSpacing:".1em",textTransform:"uppercase"},children:[(0,i.jsx)("span",{children:"Datum & čas"}),(0,i.jsx)("span",{children:"Email uživatele"}),(0,i.jsx)("span",{children:"N\xe1zev projektu"})]}),u.map((e,t)=>{let n;return(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"160px 1fr 1.2fr",gap:10,padding:"11px 14px",borderTop:"1px solid #111",alignItems:"center",background:t%2==0?"transparent":"rgba(255,255,255,.01)"},children:[(0,i.jsx)("span",{style:{fontSize:11,color:"#666",fontVariantNumeric:"tabular-nums"},children:(n=e.usedAt)?new Date(1e3*n._seconds).toLocaleDateString("cs-CZ",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}),(0,i.jsx)("span",{style:{fontSize:12,color:"#c084fc",fontWeight:600},children:e.email||e.uid}),(0,i.jsx)("span",{style:{fontSize:12,color:"#aaa",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.projectName||e.projectId})]},e.id)})]})]}),!t&&(0,i.jsx)("p",{style:{color:"#444",fontSize:13,textAlign:"center",padding:"16px 0"},children:"Vyber promok\xf3d v\xfdše pro zobrazen\xed statistik."})]})]})}let ed=null;function ec(){return ed||(ed=new AudioContext),"suspended"===ed.state&&ed.resume(),ed}function ep(){let[e,t]=(0,l.useState)(null),[n,a]=(0,l.useState)(""),[d,c]=(0,l.useState)(""),[p,h]=(0,l.useState)(""),[u,x]=(0,l.useState)("songs"),[g,f]=(0,l.useState)(0);(0,l.useEffect)(()=>(document.documentElement.classList.add("vf-photo-bg"),()=>{document.documentElement.classList.remove("vf-photo-bg")}),[]);let m=(0,l.useRef)(-1),y=(0,l.useRef)(u);(0,l.useEffect)(()=>{y.current=u},[u]),(0,l.useEffect)(()=>(0,o.aQ)((0,o.rJ)(s.db,"support_chats"),e=>{let t=e.docs.filter(e=>{let t=e.data();return"user"===t.lastSenderRole&&!t.resolved}).length;m.current>=0&&t>m.current&&"chat"!==y.current&&function(){try{let e=ec();("suspended"===e.state?e.resume():Promise.resolve()).then(()=>{let t=e.currentTime;[{freq:1047,start:t,dur:.18},{freq:1319,start:t+.2,dur:.28}].forEach(({freq:t,start:n,dur:i})=>{let l=e.createOscillator(),r=e.createGain();l.connect(r),r.connect(e.destination),l.type="sine",l.frequency.value=t,r.gain.setValueAtTime(0,n),r.gain.linearRampToValueAtTime(.28,n+.012),r.gain.exponentialRampToValueAtTime(.001,n+i),l.start(n),l.stop(n+i+.05)})})}catch{}}(),m.current=t,f(t)}),[]),(0,l.useEffect)(()=>{g>0&&"chat"!==u?document.title=`(${g}) VF Editor`:document.title="VF Editor"},[g,u]),(0,l.useEffect)(()=>(0,r.onAuthStateChanged)(s.auth,async e=>{if(!e)return void t(!1);let n=(await e.getIdTokenResult(!0)).claims.role;"admin"===n||"editor"===n?(t(n),"editor"===n&&x("leads")):t(!1)}),[]);let b=async()=>{h("");try{let e=await (0,r.signInWithEmailAndPassword)(s.auth,n,d),t=(await e.user.getIdTokenResult(!0)).claims.role;"admin"===t||"editor"===t?"editor"===t&&x("leads"):(h("Tento \xfačet nem\xe1 admin opr\xe1vněn\xed."),await (0,r.signOut)(s.auth))}catch{h("Špatn\xfd e-mail nebo heslo.")}};return null===e?(0,i.jsx)("div",{style:eR.center,children:(0,i.jsx)("p",{style:{color:"#888"},children:"Nač\xedt\xe1m…"})}):e?(0,i.jsxs)("div",{style:eR.page,children:[(0,i.jsxs)("header",{style:eR.header,children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,i.jsxs)("span",{style:{fontFamily:"Arial, sans-serif",fontSize:17,fontWeight:900,color:"#ffffff",letterSpacing:"-0.02em",lineHeight:1},children:["VF ",(0,i.jsx)("span",{style:{color:"#F4511E"},children:"Editor"})]}),(0,i.jsx)("span",{style:{background:"#1a1a1f",border:"1px solid #2a2a30",borderRadius:4,padding:"2px 7px",fontSize:9,color:"#555",letterSpacing:".1em",fontWeight:700},children:"editor"===e?"EDITOR":"ADMIN"})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center"},children:["admin"===e&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{style:{...eR.tabBtn,..."kling"===u?eR.tabActive:{},fontWeight:"kling"===u?800:600},onClick:()=>x("kling"),children:"⚡ Kling"}),(0,i.jsx)("button",{style:{...eR.tabBtn,..."songs"===u?eR.tabActive:{}},onClick:()=>x("songs"),children:"\uD83C\uDFB5 P\xedsničky"}),(0,i.jsx)("button",{style:{...eR.tabBtn,..."stats"===u?eR.tabActive:{}},onClick:()=>x("stats"),children:"\uD83D\uDCCA Statistiky"}),(0,i.jsx)("button",{style:{...eR.tabBtn,..."promo"===u?eR.tabActive:{}},onClick:()=>x("promo"),children:"\uD83C\uDF9F Promok\xf3dy"}),(0,i.jsxs)("button",{style:{...eR.tabBtn,..."chat"===u?eR.tabActive:{},position:"relative"},onClick:()=>x("chat"),children:["\uD83D\uDCAC Podpora",g>0&&"chat"!==u&&(0,i.jsx)("span",{style:{position:"absolute",top:-4,right:-4,background:"#ef4444",color:"#fff",borderRadius:"50%",width:16,height:16,fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center"},children:g>9?"9+":g})]}),(0,i.jsx)("button",{style:{...eR.tabBtn,..."users"===u?eR.tabActive:{}},onClick:()=>x("users"),children:"\uD83D\uDD0D Uživatel\xe9"}),(0,i.jsx)("button",{style:{...eR.tabBtn,..."clips"===u?eR.tabActive:{}},onClick:()=>x("clips"),children:"\uD83C\uDF9E Kontrola klipů"}),(0,i.jsx)("div",{style:{width:1,height:20,background:"#222",margin:"0 2px"}})]}),(0,i.jsx)("button",{style:{...eR.tabBtn,..."leads"===u?eR.tabActive:{}},onClick:()=>x("leads"),children:"\uD83D\uDC65 Makl\xe9ři"}),(0,i.jsx)("button",{style:eR.logoutBtn,onClick:()=>(0,r.signOut)(s.auth),children:"Odhl\xe1sit"})]})]}),"kling"===u?(0,i.jsx)(eu,{}):"songs"===u?(0,i.jsx)(ex,{}):"stats"===u?(0,i.jsx)(Z,{}):"promo"===u?(0,i.jsx)(ea,{}):"leads"===u?(0,i.jsx)(eC,{isEditor:"editor"===e}):"users"===u?(0,i.jsx)(eE,{}):"clips"===u?(0,i.jsx)(q,{}):(0,i.jsx)(eb,{})]}):(0,i.jsx)("div",{style:eR.center,children:(0,i.jsxs)("div",{style:eR.loginBox,children:[(0,i.jsxs)("div",{style:{textAlign:"center",marginBottom:8},children:[(0,i.jsxs)("div",{style:{fontFamily:"Arial, sans-serif",fontSize:26,fontWeight:900,color:"#ffffff",letterSpacing:"-0.02em",lineHeight:1},children:["VF ",(0,i.jsx)("span",{style:{color:"#F4511E"},children:"Editor"})]}
137),(0,i.jsx)("div",{style:{fontSize:10,color:"#444",letterSpacing:".12em",marginTop:6,fontWeight:700},children:"ADMIN PANEL"})]}),(0,i.jsx)("input",{style:eR.input,placeholder:"E-mail",value:n,onChange:e=>a(e.target.value)}),(0,i.jsx)("input",{style:eR.input,placeholder:"Heslo",type:"password",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&b()}),p&&(0,i.jsx)("p",{style:{color:"#ef4444",fontSize:14,margin:0},children:p}),(0,i.jsx)("button",{style:eR.btn,onClick:b,children:"Přihl\xe1sit se →"})]})})}function eh({usedPct:e,color:t,size:n=160}){let l=n/2*.78,r=n/2,o=n/2,a=2*Math.PI*l,s=.75*a,d=.25*a,c=s*Math.min(e/100,1);return(0,i.jsxs)("svg",{width:n,height:n,style:{display:"block",overflow:"visible"},children:[(0,i.jsx)("circle",{cx:r,cy:o,r:l,fill:"none",stroke:"#1e1e22",strokeWidth:.085*n,strokeLinecap:"round",strokeDasharray:`${s} ${a-s}`,strokeDashoffset:-d,style:{transform:"rotate(-225deg)",transformOrigin:`${r}px ${o}px`}}),e>0&&(0,i.jsx)("circle",{cx:r,cy:o,r:l,fill:"none",stroke:t,strokeWidth:.085*n,strokeLinecap:"round",strokeDasharray:`${c} ${s-c+(a-s)}`,strokeDashoffset:-d,style:{transform:"rotate(-225deg)",transformOrigin:`${r}px ${o}px`,transition:"stroke-dasharray 0.8s cubic-bezier(.4,0,.2,1)",filter:`drop-shadow(0 0 6px ${t}88)`}})]})}function eu(){let[e,t]=(0,l.useState)(null),[n,r]=(0,l.useState)(!0),[o,a]=(0,l.useState)(""),[s,d]=(0,l.useState)(null),c=(0,l.useCallback)(async()=>{r(!0),a("");try{let e=await ei("/api/kling/check-credits?count=1");t(e),d(new Date)}catch(e){a(e instanceof Error?e.message:"Nepodařilo se nač\xedst data z Kling API.")}finally{r(!1)}},[]);(0,l.useEffect)(()=>{c()},[c]);let p=e=>e<=0?{label:"VYČERP\xc1NO",color:"#ef4444",trackFill:"#ef4444",dot:"#ef4444"}:e<10?{label:"KRITICKY M\xc1LO",color:"#f97316",trackFill:"#f97316",dot:"#f97316"}:e<30?{label:"DOCH\xc1Z\xcd",color:"#eab308",trackFill:"#eab308",dot:"#eab308"}:{label:"V POŘ\xc1DKU",color:"#22c55e",trackFill:"#22c55e",dot:"#22c55e"},h=e&&e.totalCapacity>0?Math.round(e.used/e.totalCapacity*100):0,u=e&&e.totalCapacity>0?Math.round(e.available/e.totalCapacity*100):100*!!e,x=p(u);return(0,i.jsxs)("div",{style:eR.content,children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:28},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:20,fontWeight:800,color:"#fff",letterSpacing:"-0.5px"},children:"Kling AI — kredity"}),(0,i.jsx)("div",{style:{fontSize:12,color:"#555",marginTop:3},children:s?`Aktualizov\xe1no: ${s.toLocaleTimeString("cs-CZ")}`:"Nač\xedt\xe1m…"})]}),(0,i.jsx)("button",{onClick:c,disabled:n,style:{background:"#1a1a1e",border:"1px solid #2a2a2e",color:n?"#444":"#ccc",borderRadius:8,padding:"8px 16px",fontSize:12,cursor:n?"default":"pointer"},children:n?"↻ Nač\xedt\xe1m…":"↻ Obnovit"})]}),o&&(0,i.jsx)("div",{style:{background:"rgba(239,68,68,.08)",border:"1px solid rgba(239,68,68,.25)",borderRadius:10,padding:"12px 16px",color:"#ef4444",fontSize:13,marginBottom:20},children:o}),n&&!e&&(0,i.jsxs)("div",{style:{display:"flex",gap:16},children:[(0,i.jsx)("div",{style:{width:200,height:200,borderRadius:"50%",background:"#111113",opacity:.4}}),(0,i.jsx)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:10,justifyContent:"center"},children:[1,2,3].map(e=>(0,i.jsx)("div",{style:{height:18,borderRadius:6,background:"#111113",opacity:.4,width:`${70-10*e}%`}},e))})]}),e&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,i.jsxs)("div",{style:{background:"#111113",border:"1px solid #1e1e22",borderRadius:18,padding:"28px 32px",display:"flex",alignItems:"center",gap:36},children:[(0,i.jsxs)("div",{style:{position:"relative",flexShrink:0,width:160,height:160},children:[(0,i.jsx)(eh,{usedPct:h,color:x.color,size:160}),(0,i.jsxs)("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",paddingBottom:10},children:[(0,i.jsxs)("div",{style:{fontSize:30,fontWeight:900,color:x.color,letterSpacing:"-1px",lineHeight:1},children:[h,"%"]}
137),(0,i.jsx)("div",{style:{fontSize:10,color:"#555",fontWeight:600,marginTop:3,textTransform:"uppercase",letterSpacing:".08em"},children:"vyčerp\xe1no"})]})]}),(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:7,background:`${x.color}18`,border:`1px solid ${x.color}44`,borderRadius:100,padding:"4px 12px",marginBottom:16},children:[(0,i.jsx)("div",{style:{width:6,height:6,borderRadius:"50%",background:x.dot,boxShadow:`0 0 6px ${x.dot}`}}),(0,i.jsx)("span",{style:{fontSize:10,fontWeight:800,letterSpacing:".15em",color:x.color,textTransform:"uppercase"},children:x.label})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:10,color:"#555",fontWeight:700,textTransform:"uppercase",letterSpacing:".1em",marginBottom:3},children:"Zb\xfdv\xe1 vide\xed"}),(0,i.jsxs)("div",{style:{fontSize:42,fontWeight:900,color:x.color,letterSpacing:"-2px",lineHeight:1},children:[e.videosRemaining.toLocaleString("cs-CZ"),(0,i.jsx)("span",{style:{fontSize:13,fontWeight:500,color:"#555",marginLeft:8,letterSpacing:0},children:"vide\xed"})]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:20,paddingTop:4,borderTop:"1px solid #1e1e22"},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:10,color:"#555",fontWeight:600,textTransform:"uppercase",letterSpacing:".08em"},children:"Kreditů zb\xfdv\xe1"}),(0,i.jsxs)("div",{style:{fontSize:17,fontWeight:700,color:"#ccc",marginTop:2},children:[e.available.toLocaleString("cs-CZ"),(0,i.jsxs)("span",{style:{fontSize:11,color:"#444",marginLeft:4},children:["/ ",e.totalCapacity>0?e.totalCapacity.toLocaleString("cs-CZ"):"?"]})]})]}),(0,i.jsxs)("div",{style:{borderLeft:"1px solid #1e1e22",paddingLeft:20},children:[(0,i.jsx)("div",{style:{fontSize:10,color:"#555",fontWeight:600,textTransform:"uppercase",letterSpacing:".08em"},children:"Vyčerp\xe1no"}),(0,i.jsx)("div",{style:{fontSize:17,fontWeight:700,color:"#666",marginTop:2},children:e.used.toLocaleString("cs-CZ")})]}),(0,i.jsxs)("div",{style:{borderLeft:"1px solid #1e1e22",paddingLeft:20},children:[(0,i.jsx)("div",{style:{fontSize:10,color:"#555",fontWeight:600,textTransform:"uppercase",letterSpacing:".08em"},children:"Zb\xfdv\xe1"}),(0,i.jsxs)("div",{style:{fontSize:17,fontWeight:700,color:x.color,marginTop:2},children:[u," %"]})]})]})]})]})]}),e.rawPacks&&e.rawPacks.length>0&&(0,i.jsxs)("div",{style:{background:"#111113",border:"1px solid #1e1e22",borderRadius:14,padding:"20px 24px"},children:[(0,i.jsxs)("div",{style:{fontSize:11,fontWeight:700,color:"#555",textTransform:"uppercase",letterSpacing:".12em",marginBottom:16},children:["Bal\xedčky (",e.rawPacks.length,")"]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:e.rawPacks.map((e,t)=>{let n=e.remaining_quantity??e.left_quantity??e.remainingQuantity??0,l=e.total_quantity??e.quantity??e.totalQuantity??n,r=l>0?Math.round((l-n)/l*100):0,o=l>0?Math.round(n/l*100):0,a=p(o),s=e.resource_pack_name??e.name??`Bal\xedček #${t+1}`,d=e.status??"online",c=e.expire_time??e.expiry??e.end_time;return(0,i.jsxs)("div",{style:{background:"#0d0d10",border:"1px solid #1a1a1e",borderRadius:10,padding:"14px 16px"},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:10},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:700,color:"#ccc",marginBottom:3},children:s}),(0,i.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,i.jsxs)("span",{style:{fontSize:10,fontWeight:700,color:"online"===d?"#22c55e":"#888",textTransform:"uppercase",letterSpacing:".08em"},children:["● ",d]}),c&&(0,i.jsxs)("span",{style:{fontSize:10,color:"#555"},children:["platnost do ",new Date(c).toLocaleDateString("cs-CZ")]})]})]}),(0,i.jsxs)("div",{style:{textAlign:"right"},children:[(0,i.jsx)("div",{style:{fontSize:20,fontWeight:900,color:a.color,letterSpacing:"-0.5px"},children:n.toLocaleString("cs-CZ")}
137),(0,i.jsxs)("div",{style:{fontSize:10,color:"#555"},children:["z ",l.toLocaleString("cs-CZ")," celkem"]})]})]}),(0,i.jsx)("div",{style:{height:5,borderRadius:3,background:"#1e1e22",overflow:"hidden"},children:(0,i.jsx)("div",{style:{height:"100%",width:`${r}%`,background:a.color,borderRadius:3,transition:"width .5s ease"}})}),(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginTop:5},children:[(0,i.jsxs)("span",{style:{fontSize:10,color:"#555"},children:[r," % vyčerp\xe1no"]}),(0,i.jsxs)("span",{style:{fontSize:10,color:a.color,fontWeight:700},children:[o," % zb\xfdv\xe1"]})]})]},t)})})]}),(0,i.jsxs)("div",{style:{background:"#0d0d10",border:"1px solid #1a1a1e",borderRadius:12,padding:"12px 18px",fontSize:12,color:"#555",lineHeight:1.6},children:["\uD83D\uDCA1 1 video (5 s) = ",(0,i.jsx)("strong",{style:{color:"#777"},children:"2,5 kreditů"})," \xa0\xb7\xa0 Zobrazeny pouze aktivn\xed bal\xedčky \xa0\xb7\xa0 Kredity dokup na"," ",(0,i.jsx)("a",{href:"https://klingai.com",target:"_blank",rel:"noreferrer",style:{color:"#F4511E",textDecoration:"none"},children:"klingai.com"})]})]})]})}function ex(){let[e,t]=(0,l.useState)([]),[n,r]=(0,l.useState)(!0),[o,a]=(0,l.useState)(!1),[s,d]=(0,l.useState)(null),[c,p]=(0,l.useState)({}),h=(0,l.useRef)(null),u=(0,l.useCallback)(async()=>{try{let e=await ei("/api/admin/songs");t(e.songs)}catch(e){console.error("Failed to load songs:",e)}finally{r(!1)}},[]);(0,l.useEffect)(()=>{u()},[u]);let x=async t=>{let n=t.name.replace(/\.[^.]+$/,"").toLowerCase().trim(),i=e.find(e=>e.name.toLowerCase().trim()===n);if(i)return void alert(`P\xedsnička "${i.name}" už v knihovně je. Nahraj jinou nebo odstraň tu st\xe1vaj\xedc\xed.`);a(!0);try{let e=await en(),n=new FormData;n.append("file",t),n.append("name",t.name.replace(/\.[^.]+$/,""));let i=await fetch("/api/admin/songs",{method:"POST",headers:e,body:n});if(!i.ok)throw Error("Upload failed");let{id:l}=await i.json(),r=t.name.replace(/\.[^.]+$/,""),{brief:o,bpm:a,duration:s}=await el(t,r);await ei("/api/admin/songs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:l,duration:s,bpm:a})}),p(e=>({...e,[l]:o})),d(l),await u()}catch(e){console.error("Upload error:",e),alert("Chyba při nahr\xe1v\xe1n\xed: "+e.message)}finally{a(!1)}};return(0,i.jsxs)("div",{style:eR.content,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:24},children:[(0,i.jsx)("h2",{style:{margin:0},children:"Song Library"}),(0,i.jsxs)("div",{children:[(0,i.jsx)("input",{ref:h,type:"file",accept:"audio/*",style:{display:"none"},onChange:e=>{e.target.files?.[0]&&x(e.target.files[0]),e.target.value=""}}),(0,i.jsx)("button",{style:eR.btn,onClick:()=>h.current?.click(),disabled:o,children:o?"⏳ Nahr\xe1v\xe1m a analyzuji…":"+ Nahr\xe1t p\xedsničku"})]})]}),n?(0,i.jsx)("p",{style:{color:"#888"},children:"Nač\xedt\xe1m p\xedsničky…"}):0===e.length?(0,i.jsx)("p",{style:{color:"#888"},children:"Zat\xedm ž\xe1dn\xe9 p\xedsničky. Nahrajte prvn\xed MP3."}):(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.map(e=>(0,i.jsx)(eg,{song:e,expanded:s===e.id,initialBrief:c[e.id]||"",onToggle:()=>d(s===e.id?null:e.id),onUpdate:u,onDelete:async()=>{confirm(`Smazat "${e.name}"?`)&&(await ei("/api/admin/songs",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})}),u())}},e.id))})]})}function eg({song:e,expanded:t,initialBrief:n,onToggle:r,onUpdate:o,onDelete:a}){let[s,d]=(0,l.useState)(!1),[c,p]=(0,l.useState)(n),[h,u]=(0,l.useState)(""),[x,g]=(0,l.useState)(!1),[f,m]=(0,l.useState)(5),[y,b]=(0,l.useState)(!1),[j,v]=(0,l.useState)(0),[k,S]=(0,l.useState)(!1),z=(0,l.useRef)(null),C=(0,l.useRef)(null),w=(0,l.useCallback)(()=>{z.current?.pause(),b(!1),C.current&&cancelAnimationFrame(C.current)},[]),T=(0,l.useCallback)(()=>{let t=e.beatSyncConfigs[String(f)];if(!t||!z.current)return;z.current.currentTime=t.musicStart,z.current.play(),b(!0);let n=()=>{let e=z.current;if(!e)return;let i=e.currentTime;(v(i),i>=t.musicEnd)?w():C.current=requestAnimationFrame(n)};C.current=requestAnimationFrame(n)},[e.beatSyncConfigs,f,w]);(0,l.useEffect)(()=>()=>{C.current&&cancelAnimationFrame(C.current)},[]),(0,l.useEffect)(()=>{n&&!c&&p(n)},[n,c]),(0,l.useEffect)(()=>{!t||c||s||R()},[t]);let E=Object.keys(e.beatSyncConfigs||{}).length,R=async()=>{d(!0);try{let{brief:t,bpm:n,duration:i}=await el(e.url,e.name);await ei("/api/admin/songs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,duration:i,bpm:n})}),p(t),o()}catch(e){alert("Chyba anal\xfdzy: "+e.message)}finally{d(!1)}},A=async()=>{g(!0);try{let t=JSON.parse(h);if(!t.musicStart||!t.sequence||!Array.isArray(t.sequence))throw Error("Špatn\xfd form\xe1t JSON — mus\xed obsahovat musicStart a sequence array");let n=et(t);await ei("/api/admin/songs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,beatSyncConfigs:n})}),u(""),o(),alert("✓ Konfigurace uloženy!")}catch(e){alert("Chyba: "+e.message)}finally{g(!1)}},P=(0,l.useCallback)(e=>{z.current&&(z.current.currentTime=e,v(e))},[]),$=async(t,n)=>{try{let i=et({musicStart:n,sequence:t});await ei("/api/admin/songs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,beatSyncConfigs:i})}),S(!1),o(),alert(`✓ Uloženo ${t.length} klipů!`)}catch(e){alert("Chyba: "+e.message)}},M=async()=>{await ei("/api/admin/songs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id,approved:!e.approved})}),o()};return(0,i.jsxs)("div",{style:eR.card,children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},onClick:r,children:[(0,i.jsx)("span",{style:{fontSize:20},children:e.approved?"✅":"⏳"}),(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsx)("strong",{children:e.name}),e.artist&&(0,i.jsx)("span",{style:{color:"#888",marginLeft:8},children:e.artist}),(0,i.jsxs)("div",{style:{fontSize:12,color:"#666",marginTop:2},children:[e.duration>0?`${Math.floor(e.duration/60)}:${String(Math.floor(e.duration%60)).padStart(2,"0")}`:"?:??",e.bpm>0&&` \xb7 ~${e.bpm} BPM`,` \xb7 ${E}/25 configs`,e.approved&&" \xb7 ✓ schv\xe1leno"]})]}),(0,i.jsx)("span",{style:{color:"#888",fontSize:18},children:t?"▲":"▼"})]}),t&&(0,i.jsxs)("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:16},children:[(0,i.jsx)("audio",{ref:z,src:e.url,controls:!0,style:{width:"100%"}}),(0,i.jsxs)("div",{style:eR.step,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,i.jsx)("h4",{style:{margin:0},children:"1. AI Brief"}),(0,i.jsx)("button",{style:eR.btnSmall,onClick:R,disabled:s,children:s?"⏳ Analyzuji…":"\uD83D\uDD04 Znovu analyzovat"})]}),c?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("textarea",{style:eR.textarea,value:c,readOnly:!0,rows:14,onClick:e=>e.target.select()}),(0,i.jsx)("button",{style:{...eR.btnSmall,marginTop:8},onClick:()=>{navigator.clipboard.writeText(c),alert("Zkop\xedrov\xe1no!")},children:"\uD83D\uDCCB Kop\xedrovat brief"})]}):(0,i.jsx)("p",{style:{color:"#888",margin:0,fontSize:14},children:'Brief se generuje automaticky po nahr\xe1n\xed. Pro existuj\xedc\xed p\xedsničky klikni "Znovu analyzovat".'})]}),(0,i.jsxs)("div",{style:eR.step,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,i.jsx)("h4",{style:{margin:0},children:"2. Vlož odpověď AI (JSON)"}),E>0&&(0,i.jsx)("button",{style:eR.btnSmall,onClick:()=>{let t=e.beatSyncConfigs[String(E)];t&&u(JSON.stringify({musicStart:t.musicStart,sequence:t.clips},null,2))},children:"\uD83D\uDCE5 Nač\xedst aktu\xe1ln\xed"})]}),(0,i.jsx)("textarea",{style:eR.textarea,value:h,onChange:e=>u(e.target.value),rows:8,placeholder:'{\n  "musicStart": 79.050,\n  "sequence": [\n    { "trimStart": 0.3, "trimEnd": 3.66 },\n    ...\n  ]\n}'}),(0,i.jsx)("button",{style:{...eR.btn,marginTop:8},onClick:A,disabled:x||!h.trim(),children:x?"⏳ Ukl\xe1d\xe1m…":"\uD83D\uDCBE Uložit konfigurace"})]}),(0,i.jsxs)("div",{style:eR.step,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,i.jsx)("h4",{style:{margin:0},children:"\uD83C\uDFB9 Ručn\xed editor beatů"}),(0,i.jsx)("button",{style:eR.btnSmall,onClick:()=>S(e=>!e),children:k?"✕ Zavř\xedt":"Otevř\xedt →"})]}
137),k&&(0,i.jsx)("div",{style:{marginTop:12},children:(0,i.jsx)(ef,{song:e,onSave:$,onClose:()=>S(!1)})})]}),E>0&&(0,i.jsxs)("div",{style:eR.step,children:[(0,i.jsx)("h4",{style:{margin:"0 0 12px"},children:"3. Preview timeline"}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[(0,i.jsx)("label",{style:{fontSize:13},children:"Z\xe1běrů:"}),(0,i.jsx)("input",{type:"range",min:1,max:Math.min(25,E),value:f,onChange:e=>{w(),v(0),m(+e.target.value)},style:{flex:1}}),(0,i.jsx)("span",{style:{fontWeight:700,minWidth:24,textAlign:"center"},children:f}),(0,i.jsx)("button",{style:{...eR.btnSmall,minWidth:90,background:y?"#333":"transparent"},onClick:y?w:T,children:y?"⏹ Stop":"▶ Přehr\xe1t"}),y&&(0,i.jsxs)("span",{style:{fontSize:12,color:"#5dfc8e",fontVariantNumeric:"tabular-nums",minWidth:48},children:[j.toFixed(1),"s"]}),!y&&j>0&&(0,i.jsxs)("span",{style:{fontSize:12,color:"#666",fontVariantNumeric:"tabular-nums",minWidth:48},children:[j.toFixed(1),"s"]})]}),e.beatSyncConfigs[String(f)]&&(0,i.jsx)(em,{config:e.beatSyncConfigs[String(f)],totalDuration:e.duration||1,currentTime:j,onSeek:P})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:12},children:[(0,i.jsx)("button",{style:{...eR.btn,background:e.approved?"#666":"#22c55e"},onClick:M,disabled:0===E,children:e.approved?"❌ Odebrat schv\xe1len\xed":"✅ Schv\xe1lit → do rotace"}),(0,i.jsx)("button",{style:{...eR.btnSmall,color:"#ef4444",borderColor:"#ef4444"},onClick:a,children:"\uD83D\uDDD1 Smazat"})]})]})]})}function ef({song:e,onSave:t,onClose:n}){let r,o,[a,s]=(0,l.useState)("loading"),[d,c]=(0,l.useState)([]),[p,h]=(0,l.useState)(0),[u,x]=(0,l.useState)(!1),[g,f]=(0,l.useState)(null),[m,y]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),[v,k]=(0,l.useState)([]),[S,z]=(0,l.useState)(0),[C,w]=(0,l.useState)(!1),[T,E]=(0,l.useState)([]),R=(0,l.useRef)(null),A=(0,l.useRef)(null),P=(0,l.useRef)(null),$=(0,l.useRef)(null),M=(0,l.useRef)(!1),W=(0,l.useRef)(!1),I=(0,l.useRef)(0),N=(0,l.useRef)(0),B=e.duration||1;(0,l.useEffect)(()=>{let t=!1;return(async()=>{try{let n=`/api/video-proxy?url=${encodeURIComponent(e.url)}`,i=await fetch(n),l=await new AudioContext().decodeAudioData(await i.arrayBuffer());if(t)return;let{times:r,strengths:o}=ee(l,2.2),{times:a,strengths:s}=ee(l,1.5),d=[],p=new Set;for(let e=0;e<r.length;e++){let t=-1,n=.12;for(let i=0;i<a.length;i++){let l=Math.abs(a[i]-r[e]);l<n&&(n=l,t=i)}t>=0?(d.push({t:a[t],strength:o[e]||2.2}),p.add(t)):d.push({t:r[e],strength:o[e]||2.2})}for(let e=0;e<a.length;e++)p.has(e)||d.push({t:a[e],strength:Math.min(s[e]||1,1.9)});d.sort((e,t)=>e.t-t.t),c(d);let h=l.getChannelData(0),u=Math.floor(h.length/800),x=[];for(let e=0;e<800;e++){let t=0;for(let n=e*u;n<(e+1)*u;n++)t+=h[n]*h[n];x.push(Math.sqrt(t/u))}let g=Math.max(...x,1e-4);E(x.map(e=>e/g))}catch(e){console.error("Beat analysis failed",e)}finally{t||s("start")}})(),()=>{t=!0}},[e.url]),(0,l.useEffect)(()=>()=>{A.current&&cancelAnimationFrame(A.current)},[]);let F=(0,l.useCallback)(()=>{A.current&&(cancelAnimationFrame(A.current),A.current=null);let e=R.current;e&&!e.paused&&e.pause(),x(!1)},[]),L=(0,l.useCallback)((e,t)=>{A.current&&(cancelAnimationFrame(A.current),A.current=null);let n=R.current;if(!n)return;n.currentTime=e;let i=n.play();void 0!==i&&i.catch(()=>{}),x(!0);let l=()=>{let n=R.current;if(!n)return;let i=n.currentTime;h(i),void 0!==t&&i>=t&&(n.currentTime=e),A.current=requestAnimationFrame(l)};A.current=requestAnimationFrame(l)},[]),O=(0,l.useCallback)(e=>{R.current&&(R.current.currentTime=e,h(e))},[]),D=(e,t)=>{let n=t??d;return 0===n.length?e:n.reduce((t,n)=>Math.abs(n.t-e)<Math.abs(t.t-e)?n:t).t},U=(e,t,n)=>{if(!P.current)return t;let i=P.current.getBoundingClientRect();return t+Math.max(0,Math.min(1,(e.clientX-i.left)/i.width))*(n-t)},V=async()=>{null!==m&&0!==v.length&&(w(!0),await t(v,m),w(!1))},K=d.filter(e=>e.strength>=3),Z=d.filter(e=>e.strength>=2.2&&e.strength<3),_=d.filter(e=>e.strength<2.2),J=e=>{if(!$.current)return;let t=$.current.getBoundingClientRect();O(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width))*B)},H=(e,t,n=!1)=>{I.current=e,N.current=t;let l=t-e||1,r=t=>`${Math.max(0,Math.min(100,(t-e)/l*100))}%`,o=[];if(n)for(let n=.5*Math.ceil(e/.5);n<=t+.01;n+=.5)o.push(Math.round(100*n)/100);let a=[];if(T.length>0)for(let t=0;t<120;t++){let n=Math.floor((e+t/120*l)/B*T.length),i=T[Math.max(0,Math.min(T.length-1,n))]||0;a.push({left:`${t/120*100}%`,height:`${Math.max(4,55*i)}%`})}return(0,i.jsxs)("div",{ref:P,style:{position:"relative",height:80,background:"#0d0d10",borderRadius:8,cursor:"crosshair",overflow:"visible",userSelect:"none",border:"1px solid #2a2a2a"},onMouseDown:n=>{M.current=!0,F(),O(U(n,e,t))},onMouseMove:n=>{M.current&&O(U(n,e,t))},onMouseUp:n=>{M.current&&(M.current=!1,O(U(n,e,t)))},onMouseLeave:()=>
137{M.current=!1},children:[(0,i.jsxs)("div",{style:{position:"absolute",inset:0,borderRadius:8,overflow:"hidden"},children:[o.map((e,t)=>(0,i.jsx)("div",{style:{position:"absolute",left:r(e),top:0,width:1,height:"100%",background:"#1a1a1a",pointerEvents:"none"}},`g${t}`)),a.map((e,t)=>(0,i.jsx)("div",{style:{position:"absolute",left:e.left,bottom:0,width:`${100/120}%`,height:e.height,background:"#ffffff0d",pointerEvents:"none"}},`wf${t}`)),_.filter(n=>n.t>=e&&n.t<=t).map((e,t)=>(0,i.jsx)("div",{style:{position:"absolute",left:r(e.t),top:"70%",width:1,height:"30%",background:"#333",pointerEvents:"none"}},t)),Z.filter(n=>n.t>=e&&n.t<=t).map((e,t)=>(0,i.jsx)("div",{style:{position:"absolute",left:r(e.t),top:"45%",width:1,height:"55%",background:"#666",pointerEvents:"none"}},t)),K.filter(n=>n.t>=e&&n.t<=t).map((e,t)=>(0,i.jsx)("div",{style:{position:"absolute",left:r(e.t),top:"5%",width:2,height:"95%",background:"#F4511E",opacity:.85,pointerEvents:"none"}},t)),null!==b&&b>=e&&b<=t&&(0,i.jsx)("div",{style:{position:"absolute",left:r(b),top:0,width:2,height:"100%",background:"#22c55e",boxShadow:"0 0 10px #22c55e88",transform:"translateX(-50%)",pointerEvents:"none"}}),p>=e&&p<=t&&(0,i.jsx)("div",{style:{position:"absolute",left:r(p),top:0,width:2,height:"100%",background:"#fff",transform:"translateX(-50%)",pointerEvents:"none"}}),(0,i.jsxs)("div",{style:{position:"absolute",bottom:3,left:6,fontSize:9,color:"#444",pointerEvents:"none"},children:[e.toFixed(1),"s"]}),(0,i.jsxs)("div",{style:{position:"absolute",bottom:3,right:6,fontSize:9,color:"#444",pointerEvents:"none"},children:[t.toFixed(1),"s"]}),(0,i.jsxs)("div",{style:{position:"absolute",top:4,left:"50%",transform:"translateX(-50%)",fontSize:11,color:"#888",pointerEvents:"none",fontVariantNumeric:"tabular-nums"},children:[p.toFixed(3),"s"]})]}),n&&o.map((t,n)=>(0,i.jsxs)("div",{style:{position:"absolute",top:"100%",left:r(t),fontSize:8,color:"#444",transform:"translateX(-50%)",marginTop:2,pointerEvents:"none",whiteSpace:"nowrap"},children:[(t-e).toFixed(1),"s"]},`gl${n}`))]})};if("loading"===a)return(0,i.jsx)("div",{style:{padding:20,textAlign:"center",color:"#888",fontSize:13},children:"⏳ Analyzuji beaty…"});let X=S+4.7,G=Math.max(0,Math.min(p-1,B-10)),Y=Math.min(B,G+10);return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[(0,i.jsx)("audio",{ref:R,src:e.url,style:{display:"none"}}),(0,i.jsxs)("div",{style:{fontSize:11,color:"#555",display:"flex",gap:14,flexWrap:"wrap"},children:[(0,i.jsxs)("span",{children:[(0,i.jsx)("span",{style:{display:"inline-block",width:10,height:10,background:"#F4511E",verticalAlign:"middle",marginRight:4}}),"Prim\xe1rn\xed (",K.length,")"]}),(0,i.jsxs)("span",{children:[(0,i.jsx)("span",{style:{display:"inline-block",width:10,height:10,background:"#666",verticalAlign:"middle",marginRight:4}}),"Sekund\xe1rn\xed (",Z.length,")"]}),(0,i.jsxs)("span",{children:[(0,i.jsx)("span",{style:{display:"inline-block",width:10,height:10,background:"#333",verticalAlign:"middle",marginRight:4}}),"Slab\xe9 (",_.length,")"]}),null!==b&&(0,i.jsxs)("span",{style:{color:"#22c55e"},children:["● snap → ",b.toFixed(4),"s"]})]}),"start"===a&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{fontSize:12,color:"#999",background:"#161618",borderRadius:6,padding:"8px 12px"},children:[(0,i.jsx)("strong",{children:"Krok 1 — Najdi DROP:"}),' Klikni na mini-mapu pro skok, přehrej, zastav na hlavn\xedm beatu → "Označit jako DROP". Zoom okno (10s) ukazuje přesnou polohu.']}),(0,i.jsx)("div",{style:{fontSize:10,color:"#444",marginBottom:3},children:"Cel\xe1 p\xedseň — klikni pro navigaci"}),(r=B||1,o=e=>`${Math.max(0,Math.min(100,e/r*100))}%`,(0,i.jsxs)("div",{ref:$,style:{position:"relative",height:28,background:"#0a0a0a",borderRadius:4,cursor:"pointer",overflow:"hidden",userSelect:"none",border:"1px solid #222"},onMouseDown:e=>{W.current=!0,J(e)},onMouseMove:e=>{W.current&&J(e)},onMouseUp:()=>{W.current=!1},onMouseLeave:()=>{W.current=!1},children:[Z.filter(e=>e.t<=B).map((e,t)=>(0,i.jsx)("div",{style:{position:"absolute",left:o(e.t),top:"55%",width:1,height:"45%",background:"#2a2a2a",pointerEvents:"none"}},t)),K.filter(e=>e.t<=B).map((e,t)=>(0,i.jsx)("div",{style:{position:"absolute",left:o(e.t),top:"15%",width:2,height:"85%",background:"#F4511E",opacity:.7,pointerEvents:"none"}},t)),(0,i.jsx)("div",{style:{position:"absolute",left:o(G),width:`${(Y-G)/r*100}%`,height:"100%",background:"rgba(255,255,255,0.07)",borderLeft:"1px solid rgba(255,255,255,0.25)",borderRight:"1px solid rgba(255,255,255,0.25)",pointerEvents:"none"}}),(0,i.jsx)("div",{style:{position:"absolute",left:o(p),top:0,width:2,height:"100%",background:"#fff",transform:"translateX(-50%)",pointerEvents:"none"}}),(0,i.jsx)("div",{style:{position:"absolute",bottom:2,left:4,fontSize:8,color:"#444",pointerEvents:"none"},children:"0s"}),(0,i.jsxs)("div",{style:{position:"absolute",bottom:2,right:4,fontSize:8,color:"#444",pointerEvents:"none"},children:[B.toFixed(0),"s"]})]}
137)),(0,i.jsx)("div",{style:{fontSize:10,color:"#444",marginBottom:3,marginTop:4},children:"Zoom 10s — t\xe1hni pro přesn\xe9 um\xedstěn\xed"}),H(G,Y,!0),(0,i.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsx)("button",{style:eR.btnSmall,onClick:u?F:()=>L(p),children:u?"⏹ Stop":"▶ Přehr\xe1t"}),(0,i.jsx)("button",{style:{...eR.btnSmall,borderColor:"#F4511E",color:"#F4511E"},onClick:()=>{j(D(p)),F()},children:"\uD83D\uDCCD Označit jako DROP"}),null!==b&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{style:{...eR.btn,padding:"5px 14px",fontSize:13},onClick:()=>{if(null===b)return;f(b);let e=Math.max(0,b-4.6),t=Math.min(5,.3+Math.min(4.7,b-e));y(e),k([{trimStart:.3,trimEnd:t}]),z(b),h(b),j(null),s("clips")},children:"✓ Potvrdit DROP"}),(0,i.jsx)("button",{style:eR.btnSmall,onClick:()=>j(null),children:"✕"})]})]})]}),"clips"===a&&null!==m&&null!==g&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{fontSize:12,color:"#999",background:"#161618",borderRadius:6,padding:"8px 12px",display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:4},children:[(0,i.jsxs)("span",{children:[(0,i.jsxs)("strong",{children:["Klip ",v.length+1,":"]}),' Přehraj, zastav na beatu kde chceš střihnout → "Označit střih".']}),(0,i.jsxs)("span",{style:{color:"#555",fontSize:11},children:["hudba od ",m.toFixed(3),"s \xa0|\xa0 DROP @ ",g.toFixed(3),"s \xa0|\xa0 klip 1: ",(g-m).toFixed(2),"s ✓"]})]}),H(S,X,!0),(0,i.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsx)("button",{style:eR.btnSmall,onClick:u?F:()=>L(S,X),children:u?"⏹ Stop":"▶ Přehr\xe1t okno"}),(0,i.jsx)("button",{style:{...eR.btnSmall,borderColor:"#F4511E",color:"#F4511E"},onClick:()=>{if(null===m)return;let e=S+4.7,t=d.filter(t=>t.t>S+.1&&t.t<=e);j(Math.min(e,D(p,t.length>0?t:d))),F()},children:"✂️ Střih (snap)"}),(0,i.jsx)("button",{style:{...eR.btnSmall,borderColor:"#888",color:"#aaa",marginLeft:"auto"},onClick:()=>{j(p),F()},children:"✂️ Manu\xe1ln\xed střih"}),null!==b&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("span",{style:{fontSize:11,color:"#22c55e"},children:["→ ",b.toFixed(4),"s \xa0(klip: ",(b-S).toFixed(2),"s)"]}),(0,i.jsx)("button",{style:{...eR.btn,padding:"5px 14px",fontSize:13},onClick:()=>{if(null===b||null===m)return;let e=Math.min(4.7,b-S);if(e<.3)return;let t=Math.min(5,.3+e);k(e=>[...e,{trimStart:.3,trimEnd:t}]),z(S+e),h(S+e),j(null)},children:"✓ Přidat klip"}),(0,i.jsx)("button",{style:eR.btnSmall,onClick:()=>j(null),children:"✕"})]})]}),v.length>0&&(0,i.jsxs)("div",{style:{background:"#0d0d10",borderRadius:8,padding:10},children:[(0,i.jsxs)("div",{style:{fontSize:11,color:"#555",marginBottom:6},children:[v.length," klipů — celkem ",v.reduce((e,t)=>e+t.trimEnd-t.trimStart,0).toFixed(2),"s hudby"]}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:v.map((e,t)=>(0,i.jsxs)("div",{onClick:()=>(e=>{if(0===e){k([]),y(null),f(null),j(null),F(),s("start");return}let t=v.slice(0,e);k(t);let n=g;for(let e of t.slice(1))n+=e.trimEnd-e.trimStart;z(n),h(n),j(null),F()})(t),title:0===t?"Klip 1 (auto před dropem) — klik pro nov\xfd DROP":`Vr\xe1tit se ke klipu ${t+1} a upravit od něj`,style:{background:t===v.length-1?"#1a2e1a":"#151518",border:`1px solid ${0===t?"#F4511E44":t===v.length-1?"#22c55e44":"#333"}`,borderRadius:5,padding:"3px 8px",fontSize:11,color:"#bbb",cursor:"pointer"},children:[(0,i.jsx)("strong",{style:{color:0===t?"#F4511E":"#fff",marginRight:2},children:t+1}),(0,i.jsxs)("span",{style:{opacity:.7},children:[(e.trimEnd-e.trimStart).toFixed(2),"s"]}),0===t&&(0,i.jsx)("span",{style:{fontSize:9,color:"#F4511E",marginLeft:3,opacity:.7},children:"↕"})]},t))})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[v.length>0&&(0,i.jsx)("button",{style:eR.btnSmall,onClick:()=>{if(0===v.length||null===g)return;if(1===v.length){k([]),y(null),f(null),j(null),F(),s("start");return}let e=v.slice(0,-1);k(e);let t=g;for(let n of e.slice(1))t+=n.trimEnd-n.trimStart;z(t),h(t),j(null),F()},children:"↩ Vr\xe1tit posledn\xed"}),v.length>=1&&(0,i.jsx)("button",{style:{...eR.btn,background:"#22c55e"},onClick:V,disabled:C,children:C?"⏳ Ukl\xe1d\xe1m…":`💾 Uložit ${v.length} klipů`}),(0,i.jsx)("button",{style:{...eR.btnSmall,color:"#555"},onClick:n,children:"✕ Zrušit"})]})]})]})}function em({config:e,totalDuration:t,currentTime:n,onSeek:r}){let o,a=(0,l.useRef)(null),s=(0,l.useRef)(!1),d=e.musicEnd-e.musicStart,c=t=>{let n=a.current.getBoundingClientRect(),i=Math.max(0,Math.min(1,(t.clientX-n.left)/n.width));return e.musicStart+i*d},p=["#F4511E","#c73d14"],h=0,u=e.clips.map((e,t)=>{let n=e.trimEnd-e.trimStart,i=h/d*100,l=n/d*100;return h+=n,{i:t,dur:n,leftPct:i,widthPct:l}}),x=n>=e.musicStart&&n<=e.musicEnd?(n-e.musicStart)/d*100:null,g=e.musicStart/t*100,f=d/t*100,m=n/t*100;return(0,i.jsxs)("div",{style:{marginTop:14},children:[(0,i.jsxs)("div",{style:{fontSize:11,color:"#666",marginBottom:4},children:["Cel\xe1 p\xedseň (",t.toFixed(0),"s) — zv\xfdrazněno: ",e.musicStart.toFixed(2),"s – ",e.musicEnd.toFixed(2),"s"]}),(0,i.jsxs)("div",{style:{position:"relative",height:8,background:"#222",borderRadius:4,overflow:"hidden",marginBottom:12},children:[(0,i.jsx)("div",{style:{position:"absolute",left:`${g}%`,width:`${f}%`,height:"100%",background:"#F4511E",borderRadius:4}}),n>0&&(0,i.jsx)("div",{style:{position:"absolute",left:`${m}%`,top:0,width:2,height:"100%",background:"#fff",transform:"translateX(-50%)"}})]}),(0,i.jsxs)("div",{style:{fontSize:11,color:"#666",marginBottom:4},children:["Z\xe1běry (",e.clips.length,"\xd7) — celkem ",d.toFixed(2),"s hudby"]}),(0,i.jsxs)("div",{ref:a,style:{position:"relative",height:52,background:"#111",borderRadius:8,overflow:"hidden",cursor:r?"pointer":"default",userSelect:"none"},onMouseDown:e=>{r&&(s.current=!0,r(c(e)))},onMouseMove:e=>{s.current&&r&&r(c(e))},onMouseUp:()=>{s.current=!1},onMouseLeave:()=>{s.current=!1},children:[u.map(({i:e,dur:t,leftPct:n,widthPct:l})=>(0,i.jsx)("div",{style:{position:"absolute",left:`${n}%`,width:`${l}%`,height:"100%",background:p[e%2],borderRight:e<u.length-1?"2px solid #09090b":"none",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"}
137,children:(0,i.jsxs)("span",{style:{fontSize:10,color:"rgba(255,255,255,0.9)",fontWeight:700,lineHeight:1.3,textAlign:"center",padding:"0 2px"},children:[e+1,(0,i.jsx)("br",{}),(0,i.jsxs)("span",{style:{fontWeight:400,opacity:.8},children:[t.toFixed(1),"s"]})]})},e)),null!==x&&(0,i.jsx)("div",{style:{position:"absolute",left:`${x}%`,top:0,width:2,height:"100%",background:"#fff",boxShadow:"0 0 6px rgba(255,255,255,0.8)",transform:"translateX(-50%)",pointerEvents:"none",zIndex:10}})]}),(0,i.jsxs)("div",{style:{position:"relative",height:16,marginTop:2},children:[(o=0,u.map(({i:t,dur:n,leftPct:l})=>{let r=e.musicStart+o;return o+=n,(0,i.jsxs)("div",{style:{position:"absolute",left:`${l}%`,fontSize:9,color:"#555",transform:"translateX(-50%)",whiteSpace:"nowrap"},children:[r.toFixed(1),"s"]},t)})),(0,i.jsxs)("div",{style:{position:"absolute",right:0,fontSize:9,color:"#555"},children:[e.musicEnd.toFixed(1),"s"]})]})]})}function ey({src:e,onClose:t}){return(0,l.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]),(0,i.jsxs)("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.93)",backdropFilter:"blur(10px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"zoom-out"},children:[(0,i.jsx)("img",{src:e,alt:"",onClick:e=>e.stopPropagation(),style:{maxWidth:"92vw",maxHeight:"88vh",objectFit:"contain",borderRadius:6,boxShadow:"0 40px 120px rgba(0,0,0,0.9)"}}),(0,i.jsx)("button",{onClick:t,style:{position:"absolute",top:20,right:20,width:40,height:40,borderRadius:"50%",border:"1px solid rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.08)",color:"#fff",fontSize:22,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"\xd7"})]})}function eb(){let[e,t]=(0,l.useState)([]),[n,r]=(0,l.useState)(null),[d,c]=(0,l.useState)([]),[p,h]=(0,l.useState)(""),[u,x]=(0,l.useState)(!1),[g,f]=(0,l.useState)(!1),[m,y]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),v=(0,l.useRef)(0),k=(0,l.useRef)(null),S=(0,l.useRef)(null);(0,l.useEffect)(()=>(0,o.aQ)((0,o.rJ)(s.db,"support_chats"),e=>{let n=e.docs.map(e=>({uid:e.id,...e.data()}));n.sort((e,t)=>(t.lastTimestamp?.seconds??0)-(e.lastTimestamp?.seconds??0)),t(n)}),[]),(0,l.useEffect)(()=>{if(!n)return;v.current=0;let e=(0,o.P)((0,o.rJ)(s.db,"support_chats",n,"messages"),(0,o.My)("timestamp","asc"));return(0,o.aQ)(e,e=>{c(e.docs.map(e=>({id:e.id,...e.data()}))),setTimeout(()=>k.current?.scrollIntoView({behavior:"smooth"}),80)})},[n]),(0,l.useEffect)(()=>{let e=(0,o.aQ)((0,o.rJ)(s.db,"support_chats"),e=>
137{e.docChanges().forEach(e=>{if("modified"===e.type){let t=e.doc.data();if("user"===t.lastSenderRole){try{let e=ec(),t=e.createGain();t.connect(e.destination),t.gain.setValueAtTime(.3,e.currentTime),t.gain.exponentialRampToValueAtTime(.001,e.currentTime+.5);let n=e.createOscillator();n.connect(t),n.type="sine",n.frequency.setValueAtTime(880,e.currentTime),n.frequency.setValueAtTime(660,e.currentTime+.15),n.start(e.currentTime),n.stop(e.currentTime+.5)}catch{}document.hasFocus()||"granted"!==Notification.permission||new Notification("VF Editor — Nov\xe1 zpr\xe1va",{body:`${t.userName||t.userEmail||"Uživatel"}: ${t.lastMessage}`,icon:"/favicon.ico"})}}})});return"default"===Notification.permission&&Notification.requestPermission(),e},[]),(0,l.useEffect)(()=>{let e=e=>{if(!n)return;let t=Array.from(e.clipboardData?.items||[]).find(e=>e.type.startsWith("image/"));if(!t)return;let i=t.getAsFile();i&&y({file:i,preview:URL.createObjectURL(i)})};return window.addEventListener("paste",e),()=>window.removeEventListener("paste",e)},[n]);let z=async(e,t)=>{let n=`support_chat_images/${t}/${Date.now()}_${e.name}`,i=(0,a.KR)(s.storage,n);return await (0,a.D)(i,e),(0,a.qk)(i)},C=async()=>{let e=p.trim();if((e||m)&&n&&!u){x(!0);try{let t;m&&(t=await z(m.file,n),URL.revokeObjectURL(m.preview),y(null)),await (0,o.gS)((0,o.rJ)(s.db,"support_chats",n,"messages"),{text:e,...t?{imageUrl:t}:{},sender:"admin",timestamp:(0,o.O5)()}),await (0,o.BN)((0,o.H9)(s.db,"support_chats",n),{lastMessage:e||"\uD83D\uDCF7 Screenshot",lastTimestamp:(0,o.O5)()},{merge:!0}),h("")}finally{x(!1)}}},w=async e=>{await (0,o.BN)((0,o.H9)(s.db,"support_chats",e),{resolved:!0,resolvedAt:(0,o.O5)()},{merge:!0}),n===e&&r(null)},T=async e=>{await (0,o.BN)((0,o.H9)(s.db,"support_chats",e),{resolved:!1},{merge:!0})},E=async e=>{if(confirm("Opravdu smazat celou konverzaci? Tato akce je nevratn\xe1."))try{let t=await (0,o.GG)((0,o.rJ)(s.db,"support_chats",e,"messages")),i=(0,o.wP)(s.db);t.docs.forEach(e=>i.delete(e.ref)),i.delete((0,o.H9)(s.db,"support_chats",e)),await i.commit(),n===e&&r(null)}catch(e){console.error("deleteChat failed:",e)}},R=e=>{if(!e)return"";let t=new Date(1e3*e.seconds),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString("cs-CZ",{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString("cs-CZ",{day:"2-digit",month:"2-digit"})},A=e.filter(e=>g?e.resolved:!e.resolved),P=e.find(e=>e.uid===n);return(0,i.jsxs)("div",{style:{display:"flex",height:"calc(100vh - 60px)",maxWidth:"100%"},children:[b&&(0,i.jsx)(ey,{src:b,onClose:()=>j(null)}),(0,i.jsxs)("div",{style:{width:290,borderRight:"1px solid #222",overflowY:"auto",flexShrink:0,display:"flex",flexDirection:"column"},children:[(0,i.jsxs)("div",{style:{padding:"10px 12px",borderBottom:"1px solid #1a1a1f",display:"flex",gap:6},children:[(0,i.jsxs)("button",{onClick:()=>{f(!1),r(null)},style:{flex:1,padding:"6px 0",fontSize:11,fontWeight:700,borderRadius:6,border:"none",cursor:"pointer",background:g?"#1a1a1f":"#F4511E",color:g?"#666":"#fff"},children:["Aktivn\xed (",e.filter(e=>!e.resolved).length,")"]}),(0,i.jsxs)("button",{onClick:()=>{f(!0),r(null)},style:{flex:1,padding:"6px 0",fontSize:11,fontWeight:700,borderRadius:6,border:"none",cursor:"pointer",background:g?"#22c55e":"#1a1a1f",color:g?"#fff":"#666"},children:["Vyřešen\xe9 (",e.filter(e=>e.resolved).length,")"]})]}),0===A.length&&(0,i.jsx)("div",{style:{padding:24,textAlign:"center",color:"#444",fontSize:13},children:g?"Ž\xe1dn\xe9 vyřešen\xe9 konverzace.":"Ž\xe1dn\xe9 aktivn\xed zpr\xe1vy."}),A.map(e=>(0,i.jsxs)("div",{onClick:()=>r(e.uid),style:{padding:"11px 14px",cursor:"pointer",borderBottom:"1px solid #111",background:n===e.uid?"#1a1a1f":"transparent",borderLeft:n===e.uid?"3px solid #F4511E":"3px solid transparent",transition:"background .1s"},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:3},children:[(0,i.jsx)("span",{style:{fontSize:12,fontWeight:700,color:"#e0e0e0",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.userName||e.userEmail||e.uid}),e.userName&&e.userEmail&&(0,i.jsx)("span",{style:{fontSize:10,
137color:"#444",marginTop:1,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.userEmail}),(0,i.jsx)("span",{style:{fontSize:10,color:"#444",flexShrink:0,marginLeft:8},children:R(e.lastTimestamp)})]}),(0,i.jsx)("div",{style:{fontSize:11,color:"#555",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.lastMessage||"—"})]},e.uid))]}),(0,i.jsx)("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:n?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{padding:"10px 16px",borderBottom:"1px solid #1a1a1f",background:"#0d0d10",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{fontSize:13,fontWeight:700,color:"#e0e0e0"},children:[P?.userName||P?.userEmail||n,P?.userName&&P?.userEmail&&(0,i.jsxs)("span",{style:{fontSize:11,fontWeight:400,color:"#555",marginLeft:8},children:["(",P.userEmail,")"]})]}),P?.resolved&&P.resolvedAt&&(0,i.jsxs)("div",{style:{fontSize:10,color:"#22c55e",marginTop:1},children:["Vyřešeno ",R(P.resolvedAt)]})]}),P?.resolved?(0,i.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,i.jsx)("button",{onClick:()=>T(n),style:{background:"rgba(255,255,255,0.06)",border:"1px solid #333",color:"#888",fontSize:11,fontWeight:700,borderRadius:6,padding:"6px 12px",cursor:"pointer"},children:"↩ Znovu otevř\xedt"}),(0,i.jsx)("button",{onClick:()=>E(n),style:{background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"#ef4444",fontSize:11,fontWeight:700,borderRadius:6,padding:"6px 12px",cursor:"pointer"},children:"\uD83D\uDDD1 Smazat"})]}):(0,i.jsx)("button",{onClick:()=>w(n),style:{background:"rgba(34,197,94,0.12)",border:"1px solid rgba(34,197,94,0.3)",color:"#22c55e",fontSize:11,fontWeight:700,borderRadius:6,padding:"6px 14px",cursor:"pointer"},children:"✓ Vyřešeno"})]}),(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:10},children:[d.map(e=>(0,i.jsx)("div",{style:{display:"flex",justifyContent:"admin"===e.sender?"flex-end":"flex-start"},children:(0,i.jsxs)("div",{style:{maxWidth:"70%",fontSize:13,lineHeight:1.5,wordBreak:"break-word",borderRadius:"admin"===e.sender?"12px 12px 3px 12px":"12px 12px 12px 3px",background:"admin"===e.sender?"#F4511E":"#1a1a1f",color:"#fff",overflow:"hidden"},children:[e.imageUrl&&(0,i.jsx)("img",{src:e.imageUrl,alt:"screenshot",onClick:()=>j(e.imageUrl),style:{display:"block",width:"100%",maxHeight:240,objectFit:"cover",cursor:"zoom-in"}}),e.text&&(0,i.jsx)("div",{style:{padding:"8px 12px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.text}),!e.text&&e.imageUrl&&(0,i.jsx)("div",{style:{height:4}}),e.timestamp&&(0,i.jsx)("div",{style:{fontSize:9,color:"admin"===e.sender?"rgba(255,255,255,0.55)":"#444",padding:"0 12px 6px",textAlign:"right"},children:R(e.timestamp)})]})},e.id)),(0,i.jsx)("div",{ref:k})]}),m&&(0,i.jsxs)("div",{style:{padding:"8px 16px",borderTop:"1px solid #1a1a1f",position:"relative",display:"inline-flex"},children:[(0,i.jsx)("img",{src:m.preview,alt:"preview",style:{height:60,borderRadius:6,objectFit:"cover"}}),(0,i.jsx)("button",{onClick:()=>{URL.revokeObjectURL(m.preview),y(null)},style:{position:"absolute",top:4,left:12,width:18,height:18,borderRadius:"50%",background:"rgba(0,0,0,0.7)",border:"none",color:"#fff",fontSize:11,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xd7"})]}),!P?.resolved&&(0,i.jsxs)("div",{style:{padding:"10px 14px",borderTop:"1px solid #1a1a1f",display:"flex",gap:8,alignItems:"flex-end"},children:[(0,i.jsx)("button",{onClick:()=>S.current?.click(),title:"Přidat screenshot (nebo Ctrl+V)",style:{background:"#1a1a1f",border:"1px solid #333",borderRadius:7,width:36,height:36,cursor:"pointer",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,i.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"#666",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,i.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,i.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(0,i.jsx)("input",{ref:S,type:"file",accept:"image/*",onChange:e=>{let t=e.target.files?.[0];t&&y({file:t,preview:URL.createObjectURL(t)}),e.target.value=""},style:{display:"none"}}),(0,i.jsx)("textarea",{value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),C())},placeholder:"Napište odpověď… (Ctrl+V pro screenshot)",rows:2,style:{...eR.textarea,flex:1,height:"auto",resize:"none",margin:0}}),(0,i.jsx)("button",{onClick:C,disabled:u||!p.trim()&&!m,style:{...eR.btn,padding:"10px 18px",flexShrink:0,opacity:p.trim()||m?1:.4,cursor:p.trim()||m?"pointer":"default"},children:u?"…":"Odeslat →"})]}),P?.resolved&&(0,i.jsx)("div",{style:{padding:"12px 16px",borderTop:"1px solid #1a1a1f",textAlign:"center",fontSize:12,color:"#444"},children:'Konverzace je vyřešena — klikněte „Znovu otevř\xedt" pro odpověď.'})]}):(0,i.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#333",fontSize:14},children:"← Vyberte konverzaci"})})]})}window.addEventListener("click",()=>{try{ec()}catch{}},{once:!1,passive:!0});let ej=["Česk\xe1 republika","Slovensko","Polsko","Německo","Rakousko","Maďarsko","Rumunsko","Bulharsko","Chorvatsko","Srbsko","Slovinsko","Šv\xfdcarsko","Francie","It\xe1lie","Španělsko","Portugalsko","Belgie","Nizozemsko","Šv\xe9dsko","Norsko","D\xe1nsko","Finsko","Velk\xe1 Brit\xe1nie","Irsko","USA","Kanada","Austr\xe1lie","Nov\xfd Z\xe9land","Izrael","SAE","Jin\xe1"],ev={facebook:!1,tiktok:!1,linkedin:!1,instagram:!1},ek={fullName:"",firstName:"",lastName:"",phone:"",email:"",agency:"",country:"",notes:"",callOutcome:"",outreach:{email:!1,phone:!1,form:!1,social:!1},socialPlatforms:{...ev}};async function eS(e,t,n="GET",i){let l=await fetch(t,{method:n,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},...i?{body:JSON.stringify(i)}:{}});if(!l.ok)throw Error(await l.text());return l.json()}async function ez(){return s.auth.currentUser?.getIdToken()}function eC({isEditor:e=!1}){let[t,n]=(0,l.useState)("contacts"),[r,o]=(0,l.useState)([]),[a,d]=(0,l.useState)(!0),[c,p]=(0,l.useState)(!1),[h,u]=(0,l.useState)(null),[x,g]=(0,l.useState)(!1),[f,m]=(0,l.useState)(!1),[y,b]=(0,l.useState)(!1),[j,v]=(0,l.useState)(null),[k,S]=(0,l.useState)(ek),[z,C]=(0,l.useState)(!1),[w,T]=(0,l.useState)(""),[E,R]=(0,l.useState)(""),[A,P]=(0,l.useState)(null),[$,M]=(0,l.useState)(!1),[W,I]=(0,l.useState)(null),[N,B]=(0,l.useState)("all"),[F,L]=(0,l.useState)("all"),[O,D]=(0,l.useState)("all"),[U,V]=(0,l.useState)("all");async function K(){try{let e=await ez(),t=await eS(e,"/api/admin/leads");o(t)}catch(e){console.error("Load leads error:",e)}d(!1)}(0,l.useEffect)(()=>{K()},[]);let Z=(()=>{let e=k.fullName.trim().split(/\s+/),t=e[0]?.toLowerCase()||"",n=e.slice(1).join(" ").toLowerCase();if(t&&n)return r.find(e=>e.firstName.toLowerCase()===t&&e.lastName.toLowerCase()===n&&e.id!==j)??null})(),_=void 0===Z?null:null!==Z,J=r.filter(e=>{let t=`${e.firstName} ${e.lastName} ${e.email??""} ${e.agency??""}`.toLowerCase();
137return(!w||t.includes(w.toLowerCase()))&&(!E||e.country===E)}),H=[...new Set(r.map(e=>e.country||"").filter(Boolean))].sort();function X(){b(!1),v(null),S(ek),C(!1)}async function G(){let e=k.fullName.trim().split(/\s+/),t=e[0]||"",n=e.slice(1).join(" ");if(!t)return void alert("Zadej jm\xe9no a př\xedjmen\xed.");p(!0);try{let e=await ez(),i=s.auth.currentUser,l=j?void 0:{uid:i?.uid||"",email:i?.email||"",name:i?.displayName||i?.email||""},r={firstName:t,lastName:n,phone:k.phone.trim(),email:k.email.trim().toLowerCase(),agency:k.agency.trim(),country:k.country,outreach:k.outreach,callOutcome:k.outreach.phone?k.callOutcome:"",socialPlatforms:k.outreach.social?k.socialPlatforms:null,notes:k.notes.trim()};!j&&l&&(r.addedBy=l),j?await eS(e,`/api/admin/leads/${j}`,"PUT",r):await eS(e,"/api/admin/leads","POST",r),X(),await K()}catch(e){alert("Chyba při ukl\xe1d\xe1n\xed: "+String(e)),console.error(e)}p(!1)}async function Y(e){let t=!e.contacted;o(n=>n.map(n=>n.id===e.id?{...n,contacted:t}:n));try{let n=await ez();await eS(n,`/api/admin/leads/${e.id}`,"PUT",{contacted:t})}catch(t){console.error("Toggle contacted error:",t),o(t=>t.map(t=>t.id===e.id?{...t,contacted:e.contacted}:t))}}async function q(e,t){if(confirm(`Smazat ${t}? Tuto akci nelze vr\xe1tit.`)){u(e);try{let t=await ez();await eS(t,`/api/admin/leads/${e}`,"DELETE"),o(t=>t.filter(t=>t.id!==e))}catch(e){alert("Chyba při maz\xe1n\xed."),console.error(e)}u(null)}}async function Q(){M(!0),I(null);try{let t=await ez(),n=await eS(t,"/api/admin/leads/stats");if(n?.error)throw Error(n.error);if(P(n),e){let e=s.auth.currentUser?.uid;e&&n?.byAccount?.some(t=>t.uid===e)&&D(e)}}catch(e){console.error("loadStats error:",e),I(String(e))}M(!1)}async function ee(){if(confirm("Vložit 100 testovac\xedch makl\xe9řů?")){g(!0);try{let e=await ez();await eS(e,"/api/admin/leads/seed","POST"),await K()}catch(e){alert("Chyba při seedov\xe1n\xed: "+String(e))}g(!1)}}async function et(){if(confirm("Smazat vÅ¡echna testovac\xed data (_test: true)?")){m(!0);try{let e=await ez(),t=await eS(e,"/api/admin/leads/seed","DELETE");await K(),alert(`Smaz\xe1no ${t.deleted} testovac\xedch z\xe1znamů.`)}catch(e){alert("Chyba: "+String(e))}m(!1)}}(0,l.useEffect)(()=>{e&&"stats"===t&&!A&&Q()},[e,t]);let en={bad:{label:"\uD83D\uDC4E Å patn\xfd",color:"#ef4444"},average:{label:"✋ Průměr",color:"#f59e0b"},great:{label:"\uD83D\uDC4D Skvěl\xe9",color:"#22c55e"}},ei={background:"#1e1e22",color:"#aaa",border:"none",borderRadius:6,padding:"7px 18px",fontSize:13,cursor:"pointer"},el={background:"#F4511E",color:"#fff"},er={background:"#1a1a1f",border:"1px solid #2a2a30",borderRadius:6,padding:"8px 12px",color:"#f0f0f0",fontSize:13,outline:"none",boxSizing:"border-box"},eo={background:"#1a1a1f",border:"1px solid #2a2a30",borderRadius:6,padding:"8px 12px",color:"#f0f0f0",fontSize:13,outline:"none",cursor:"pointer",boxSizing:"border-box"},ea={background:"#F4511E",color:"#fff",border:"none",borderRadius:6,padding:"8px 18px",fontSize:13,fontWeight:700,cursor:"pointer",marginLeft:"auto"},es={display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:12},ed={fontSize:11,color:"#888",marginBottom:4,display:"block"},ec={display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:13,color:"#ccc",userSelect:"none"},ep={width:"100%",borderCollapse:"collapse",fontSize:13},eh={textAlign:"left",padding:"8px 10px",color:"#555",fontWeight:600,fontSize:11,borderBottom:"1px solid #1e1e22",letterSpacing:".06em"},eu={padding:"10px 10px",borderBottom:"1px solid #151518",verticalAlign:"middle"},ex={display:"inline-flex",alignItems:"center",background:"#1e1e26",borderRadius:4,padding:"2px 7px",fontSize:11,color:"#aaa",marginRight:3},eg={background:"#131316",border:"1px solid #222",borderRadius:10,padding:"18px 22px",textAlign:"center"};return(0,i.jsxs)("div",{style:{maxWidth:980,margin:"0 auto",padding:24},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:24},children:[(0,i.jsxs)("button",{style:{...ei,..."contacts"===t?el:{}},onClick:()=>n("contacts"),children:["\uD83D\uDCCB Kontakty",r.length>0&&(0,i.jsx)("span",{style:{marginLeft:6,background:"rgba(255,255,255,.15)",borderRadius:10,padding:"1px 7px",fontSize:11},children:r.length})]}),(0,i.jsx)("button",{style:{...ei,..."stats"===t?el:{}},onClick:()=>{n("stats"),A||Q()},children:"\uD83D\uDCCA Statistiky"})]}),"contacts"===t&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[(0,i.jsx)("input",{style:{...er,width:230},placeholder:"\uD83D\uDD0D Hledat jm\xe9no, email, kancel\xe1ř…",value:w,onChange:e=>T(e.target.value)}),(0,i.jsxs)("select",{style:{...eo,minWidth:160},value:E,onChange:e=>R(e.target.value),children:[(0,i.jsx)("option",{value:"",children:"VÅ¡echny země"}),H.map(e=>(0,i.jsx)("option",{value:e,children:e},e))]}),(0,i.jsx)("button",{style:ea,onClick:function(){v(null),S(ek),C(!1),b(!0),setTimeout(()=>document.getElementById("lead-fn")?.focus(),50)},children:"+ Přidat makl\xe9ře"}),(0,i.jsx)("button",{onClick:ee,disabled:x,style:{background:"#1e2a1e",color:"#4ade80",border:"1px solid #2a4a2a",borderRadius:6,padding:"8px 14px",fontSize:12,cursor:"pointer",opacity:x?.6:1},children:x?"Seeduji…":"\uD83E\uDDEA Test data"}),r.some(e=>e._test)&&(0,i.jsx)("button",{onClick:et,disabled:f,style:{background:"#2a1010",color:"#ef4444",border:"1px solid #4a2020",borderRadius:6,padding:"8px 14px",fontSize:12,cursor:"pointer",opacity:f?.6:1},children:f?"Mažu…":"\uD83D\uDDD1 Smazat test data"})]}),y&&(0,i.jsxs)("div",{style:{background:"#131316",border:"1px solid #2a2a30",borderRadius:10,padding:20,marginBottom:20},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:!0!==_||z?16:10},children:[(0,i.jsx)("h3",{style:{margin:0,fontSize:14,fontWeight:700},children:j?"Upravit makl\xe9ře":"Nov\xfd makl\xe9ř"}),!0===_&&z&&(0,i.jsx)("span",{style:{fontSize:12,color:"#22c55e",fontWeight:600},children:"✓ Potvrzeno — jin\xe1 osoba"}),!1===_&&(0,i.jsx)("span",{style:{fontSize:12,color:"#22c55e"},children:"✓ Nov\xe1 osoba"})]}),!0===_&&!z&&(0,i.jsxs)("div",{style:{background:"rgba(245,158,11,.08)",border:"1px solid rgba(245,158,11,.3)",borderRadius:8,padding:"10px 14px",marginBottom:14,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:700,color:"#f59e0b"},children:"⚠️ Toto jm\xe9no již v seznamu je"}),Z?.agency?(0,i.jsxs)("div",{style:{fontSize:12,color:"#a07a30",marginTop:3},children:["Uložen pod kancel\xe1ř\xed: ",(0,i.jsx)("strong",{style:{color:"#d4a843"},children:Z.agency})]}):(0,i.jsx)("div",{style:{fontSize:12,color:"#a07a30",marginTop:3},children:"Realitn\xed kancel\xe1ř neuvedena"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>C(!0),style:{background:"#0a1e0a",border:"1px solid #22c55e",borderRadius:7,padding:"7px 16px",color:"#22c55e",fontSize:12,fontWeight:700,cursor:"pointer",whiteSpace:"nowrap"},children:"✓ Je to jin\xe1 osoba"})]}),(0,i.jsxs)("div",{style:{marginBottom:12},children:[(0,i.jsx)("label",{style:ed,children:"Jm\xe9no a př\xedjmen\xed *"}),(0,i.jsx)("input",{id:"lead-fn",style:{...er,width:"100%"},value:k.fullName,onChange:e=>{S(t=>({...t,fullName:e.target.value})),C(!1)},placeholder:"Jan Nov\xe1k"})]}),(0,i.jsxs)("div",{style:es,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:ed,children:"Telefon"}),(0,i.jsx)("input",{style:{...er,width:"100%"},value:k.phone,onChange:e=>S(t=>({...t,phone:e.target.value})),placeholder:"+420 777 123 456"})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:ed,children:"E-mail"}),(0,i.jsx)("input",{style:{...er,width:"100%"},value:k.email,onChange:e=>S(t=>({...t,email:e.target.value})),placeholder:"[email protected]",type:"email"})]})]}),(0,i.jsxs)("div",{style:es,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:ed,children:"Realitn\xed kancel\xe1ř"}),(0,i.jsx)("input",{style:{...er,width:"100%"},value:k.agency,onChange:e=>S(t=>({...t,agency:e.target.value})),placeholder:"RE/MAX, Century 21…"})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:ed,children:"Země"}),(0,i.jsxs)("select",{style:{...eo,width:"100%"},value:k.country,onChange:e=>S(t=>({...t,country:e.target.value})),children:[(0,i.jsx)("option",{value:"",children:"— Vybrat —"}),ej.map(e=>(0,i.jsx)("option",{value:e,children:e},e))]})]})]}),(0,i.jsxs)("div",{style:{marginBottom:12},children:[(0,i.jsx)("label",{style:ed,children:"Jak oslovujeme"}),(0,i.jsx)("div",{style:{display:"flex",gap:16,flexWrap:"wrap",margin:"6px 0 0"},children:["email","phone","form","social"].map(e=>(0,i.jsxs)("label",{style:ec,children:[(0,i.jsx)("input",{type:"checkbox",checked:k.outreach[e],onChange:t=>S(n=>({...n,outreach:{...n.outreach,[e]:t.target.checked}}))}),{email:"✉️ Email",phone:"\uD83D\uDCDE Telefon",form:"\uD83D\uDCDD Formul\xe1ř",social:"\uD83D\uDCF1 Soci\xe1ln\xed 
137s\xedtě"}[e]]},e))})]}),k.outreach.social&&(0,i.jsxs)("div",{style:{marginBottom:14,background:"#0e0e12",border:"1px solid #2a2a30",borderRadius:8,padding:"12px 16px"},children:[(0,i.jsxs)("label",{style:{...ed,marginBottom:10},children:["\uD83D\uDCF1 Kde na soci\xe1ln\xedch s\xedt\xedch? ",(0,i.jsx)("span",{style:{color:"#444",fontWeight:400},children:"(nepovinn\xe9)"})]}),(0,i.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[{val:"facebook",label:"Facebook",icon:"\uD83D\uDD35",color:"#3b82f6"},{val:"tiktok",label:"TikTok",icon:"⚫",color:"#e0e0e0"},{val:"linkedin",label:"LinkedIn",icon:"\uD83D\uDD37",color:"#60a5fa"},{val:"instagram",label:"Instagram",icon:"\uD83D\uDFE3",color:"#c084fc"}].map(e=>{let t=k.socialPlatforms[e.val];return(0,i.jsxs)("button",{type:"button",onClick:()=>S(t=>({...t,socialPlatforms:{...t.socialPlatforms,[e.val]:!t.socialPlatforms[e.val]}})),style:{padding:"7px 16px",borderRadius:7,border:`1px solid ${t?e.color:"#2a2a30"}`,background:t?"rgba(255,255,255,.06)":"transparent",color:t?e.color:"#555",fontSize:13,fontWeight:t?700:400,cursor:"pointer",transition:"all .15s"},children:[e.icon," ",e.label]},e.val)})})]}),k.outreach.phone&&(0,i.jsxs)("div",{style:{marginBottom:14,background:"#0e0e12",border:"1px solid #2a2a30",borderRadius:8,padding:"12px 16px"},children:[(0,i.jsx)("label",{style:{...ed,marginBottom:10},children:"\uD83D\uDCDE Jak dopadl hovor?"}),(0,i.jsx)("div",{style:{display:"flex",gap:10},children:[{val:"bad",label:"\uD83D\uDC4E Špatn\xfd",bg:"#2a1010",border:"#5a2020",active:"#ef4444"},{val:"average",label:"✋ Průměr",bg:"#1e1a0a",border:"#4a3a10",active:"#f59e0b"},{val:"great",label:"\uD83D\uDC4D Skvěl\xe9",bg:"#0a1e0a",border:"#1a4a1a",active:"#22c55e"}].map(e=>{let t=k.callOutcome===e.val;return(0,i.jsx)("button",{type:"button",onClick:()=>S(n=>({...n,callOutcome:t?"":e.val})),style:{flex:1,padding:"8px 12px",borderRadius:7,border:`1px solid ${t?e.active:e.border}`,background:t?e.bg:"transparent",color:t?e.active:"#666",fontSize:13,fontWeight:t?700:400,cursor:"pointer",transition:"all .15s"},children:e.label},e.val)})})]}),(0,i.jsxs)("div",{style:{marginBottom:16},children:[(0,i.jsx)("label",{style:ed,children:"Pozn\xe1mka"}),(0,i.jsx)("textarea",{style:{background:"#1a1a1f",border:"1px solid #2a2a30",borderRadius:6,padding:"8px 12px",color:"#f0f0f0",fontSize:13,outline:"none",width:"100%",resize:"vertical",minHeight:60,boxSizing:"border-box"},value:k.notes,onChange:e=>S(t=>({...t,notes:e.target.value})),placeholder:"Voliteln\xe1 pozn\xe1mka…"})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,i.jsx)("button",{style:{background:"#F4511E",color:"#fff",border:"none",borderRadius:6,padding:"8px 20px",fontSize:13,fontWeight:700,cursor:"pointer"},onClick:G,disabled:c,children:c?"Ukl\xe1d\xe1m…":j?"Uložit změny":"Přidat makl\xe9ře"}),(0,i.jsx)("button",{style:{background:"transparent",color:"#888",border:"1px solid #333",borderRadius:6,padding:"8px 16px",fontSize:13,cursor:"pointer"},onClick:X,children:"Zrušit"})]})]}),a?(0,i.jsx)("p",{style:{color:"#555"},children:"Nač\xedt\xe1m…"}):0===J.length?(0,i.jsx)("p",{style:{color:"#555",textAlign:"center",paddingTop:40},children:0===r.length?'Zat\xedm ž\xe1dn\xed makl\xe9ři. Klikni na „+ Přidat makl\xe9ře".':"Ž\xe1dn\xe9 v\xfdsledky pro zadan\xfd filtr."}):(0,i.jsxs)("table",{style:ep,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{style:eh,children:"JM\xc9NO"}),(0,i.jsx)("th",{style:eh,children:"KANCEL\xc1Ř"}),(0,i.jsx)("th",{style:eh,children:"ZEMĚ"}),(0,i.jsx)("th",{style:eh,children:"KONTAKT"}),(0,i.jsx)("th",{style:eh,children:"OSLOVEN\xcd"}),(0,i.jsx)("th",{style:eh,children:"PŘIDAL"}),(0,i.jsx)("th",{style:{...eh,textAlign:"center"},children:"✓"}),(0,i.jsx)("th",{style:eh})]})}),(0,i.jsx)("tbody",{children:J.map(e=>(0,i.jsxs)("tr",{onMouseEnter:e=>e.currentTarget.style.background="#0f0f14",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsxs)("td",{style:eu,children:[(0,i.jsxs)("span",{style:{fontWeight:700,color:"#f0f0f0"},children:[e.firstName," ",e.lastName]}),e.notes&&(0,i.jsxs)("span",{style:{display:"block",fontSize:11,color:"#555",marginTop:2,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:["\uD83D\uDCDD ",e.notes]})]}),(0,i.jsx)("td",{style:{...eu,color:"#888"},children:e.agency||(0,i.jsx)("span",{style:{color:"#333"},children:"—"})}),(0,i.jsx)("td",{style:{...eu,color:"#aaa"},children:e.country||(0,i.jsx)("span",{style:{color:"#333"},children:"—"})}),(0,i.jsxs)("td",{style:eu,children:[e.phone&&(0,i.jsxs)("div",{style:{fontSize:12,color:"#ccc",display:"flex",alignItems:"center",gap:6},children:[(0,i.jsxs)("a",{href:`tel:${e.phone.replace(/\s/g,"")}`,style:{color:"#ccc",textDecoration:"none"},title:"Zavolat",children:["\uD83D\uDCDE ",e.phone]}
137),e.callOutcome&&e.callOutcome in en&&(0,i.jsx)("span",{style:{fontSize:11,color:en[e.callOutcome].color,fontWeight:700},children:en[e.callOutcome].label})]}),e.email&&(0,i.jsxs)("div",{style:{fontSize:12,color:"#666",marginTop:3*!!e.phone},children:["✉️ ",e.email]}),!e.phone&&!e.email&&(0,i.jsx)("span",{style:{color:"#333"},children:"—"})]}),(0,i.jsx)("td",{style:eu,children:(0,i.jsxs)("div",{style:{display:"flex",gap:3,flexWrap:"wrap"},children:[e.outreach?.email&&(0,i.jsx)("span",{style:ex,children:"✉️"}),e.outreach?.phone&&(0,i.jsx)("span",{style:ex,children:"\uD83D\uDCDE"}),e.outreach?.form&&(0,i.jsx)("span",{style:ex,children:"\uD83D\uDCDD"}),e.outreach?.social&&(0,i.jsx)("span",{style:ex,children:"\uD83D\uDCF1"}),!e.outreach?.email&&!e.outreach?.phone&&!e.outreach?.form&&!e.outreach?.social&&(0,i.jsx)("span",{style:{color:"#333"},children:"—"})]})}),(0,i.jsx)("td",{style:{...eu,fontSize:12},children:(0,i.jsx)("div",{style:{color:"#888",fontWeight:600},children:e.addedBy?.name||e.addedBy?.email||(0,i.jsx)("span",{style:{color:"#333"},children:"—"})})}),(0,i.jsx)("td",{style:{...eu,textAlign:"center"},children:(0,i.jsx)("button",{onClick:()=>Y(e),title:e.contacted?"Osloveno":"Označit jako osloveno",style:{width:22,height:22,borderRadius:5,border:e.contacted?"none":"2px solid #333",background:e.contacted?"#22c55e":"transparent",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:13,color:"#fff",transition:"background .15s, border .15s"},children:e.contacted?"✓":""})}),(0,i.jsx)("td",{style:eu,children:(0,i.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,i.jsx)("button",{onClick:()=>{v(e.id),C(!1),S({fullName:`${e.firstName} ${e.lastName}`.trim(),firstName:e.firstName,lastName:e.lastName,phone:e.phone??"",email:e.email??"",agency:e.agency??"",country:e.country??"",notes:e.notes??"",callOutcome:e.callOutcome??"",outreach:Object.assign({email:!1,phone:!1,form:!1,social:!1},e.outreach),socialPlatforms:Object.assign({...ev},e.socialPlatforms)}),b(!0)},style:{background:"transparent",border:"1px solid #2a2a30",borderRadius:5,padding:"4px 12px",color:"#999",fontSize:12,cursor:"pointer"},children:"Upravit"}),(0,i.jsx)("button",{onClick:()=>q(e.id,`${e.firstName} ${e.lastName}`),disabled:h===e.id,style:{background:"transparent",border:"1px solid #3a1515",borderRadius:5,padding:"4px 10px",color:"#ef4444",fontSize:12,cursor:"pointer",opacity:h===e.id?.5:1},children:h===e.id?"…":"✕"})]})})]},e.id))})]})]}),"stats"===t&&(()=>{let t=new Date,n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`,l=new Date(t.getFullYear(),t.getMonth()-1,1),r=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}`,o=["Led","\xdano","Bře","Dub","Kvě","Čvn","Čvc","Srp","Z\xe1ř","Ř\xedj","Lis","Pro"];function a(e){if(!e||"nezn\xe1m\xfd"===e)return e;let[t,n]=e.split("-");return`${o[parseInt(n)-1]} ${t}`}let s=[...new Set((A?.byAccount??[]).flatMap(e=>e.byMonth.map(e=>e.month)))].filter(e=>"nezn\xe1m\xfd"!==e).sort((e,t)=>t.localeCompare(e)),d=A?.byAccount.find(e=>e.uid===O),c=e?(d?.byMonth.map(e=>e.month).filter(e=>"nezn\xe1m\xfd"!==e)??[]).sort((e,t)=>t.localeCompare(e)):s,p=[];p.push(n),r!==n&&p.push(r),c.filter(e=>e!==n&&e!==r).forEach(e=>p.push(e));let h=e=>({background:e?"#F4511E":"#1a1a1f",color:e?"#fff":"#888",border:`1px solid ${e?"#F4511E":"#2a2a30"}`,borderRadius:20,padding:"6px 14px",fontSize:12,cursor:"pointer",fontWeight:e?700:400,whiteSpace:"nowrap"});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{background:"#0e1a0e",border:"1px solid #1e3a1e",borderRadius:8,padding:"10px 16px",marginBottom:16,display:"flex",alignItems:"center",gap:10},children:[(0,i.jsx)("span",{style:{fontSize:14},children:"ℹ️"}),(0,i.jsxs)("span",{style:{fontSize:12,color:"#4ade80",lineHeight:1.5},children:[(0,i.jsx)("strong",{style:{color:"#22c55e"},children:"1. PROJEKT"})," = unik\xe1tn\xed z\xe1kazn\xedk, kter\xfd zaplatil poprv\xe9. Každ\xfd z\xe1kazn\xedk se poč\xedt\xe1 jen ",(0,i.jsx)("strong",{style:{color:"#22c55e"},children:"jednou"})," — bez ohledu na počet projektů. Konverze se přiřazuje do měs\xedce ",(0,i.jsx)("strong",{style:{color:"#22c55e"},children:"prvn\xed platby"}),"."]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[(0,i.jsx)("button",{style:h("all"===U),onClick:()=>V("all"),children:"Celkem"}),p.map((e,t)=>(0,i.jsx)("button",{style:h(U===e),onClick:()=>V(e),children:0===t?`● ${a(e)}`:a(e)},e)),(0,i.jsx)("button",{style:{...ea,marginLeft:"auto",borderRadius:20,padding:"6px 16px",fontSize:12},onClick:Q,disabled:$,children:$?"Nač\xedt\xe1m…":"↻ Obnovit"})]}),!e&&(0,i.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:20,flexWrap:"wrap"},children:[["all","email","phone","form","social"].map(e=>{let t=F===e;return(0,i.jsx)("button",{onClick:()=>L(e),style:{background:t?"#2a1a0a":"transparent",color:t?"#fbbf24":"#555",border:`1px solid ${t?"#5a3a0a":"#1e1e22"}`,borderRadius:6,padding:"5px 12px",fontSize:12,cursor:"pointer",fontWeight:t?700:400},children:{all:"\uD83D\uDCCA Vše",email:"✉️ Email",phone:"\uD83D\uDCDE Telefon",form:"\uD83D\uDCDD Formul\xe1ř",social:"\uD83D\uDCF1 Soci\xe1ln\xed 
137s\xedtě"}[e]},e)}),(0,i.jsx)("div",{style:{width:1,height:20,background:"#1e1e22",margin:"0 2px"}}),"all"!==O&&(0,i.jsx)("button",{onClick:()=>{D("all"),V("all")},style:{background:"transparent",border:"1px solid #2a2a30",borderRadius:6,padding:"5px 12px",color:"#888",fontSize:12,cursor:"pointer"},children:"← Všichni editoři"}),"all"===O?(0,i.jsxs)("select",{style:{...eo,minWidth:180},value:"all",onChange:e=>{D(e.target.value)},children:[(0,i.jsx)("option",{value:"all",children:"\uD83D\uDC64 Všichni editoři"}),(A?.byAccount??[]).map(e=>(0,i.jsx)("option",{value:e.uid,children:e.name||e.email},e.uid))]}):(0,i.jsx)("span",{style:{fontSize:13,color:"#f0f0f0",fontWeight:700},children:A?.byAccount.find(e=>e.uid===O)?.name??""})]}),$&&(0,i.jsx)("p",{style:{color:"#555"},children:"Nač\xedt\xe1m statistiky…"}),W&&!$&&(0,i.jsxs)("div",{style:{background:"#1a0808",border:"1px solid #4a1a1a",borderRadius:8,padding:"14px 18px",color:"#ef4444",fontSize:13,marginBottom:16},children:[(0,i.jsx)("strong",{children:"Chyba:"})," ",W]}),A&&!$&&(()=>{if(!e&&"all"===O){let e=(A?.byAccount??[]).reduce((e,t)=>{let n="all"===U?t:t.byMonth.find(e=>e.month===U);return n&&(e.total+=n.total,e.converted+=n.converted,e.outreach.email+=n.outreach.email,e.outreach.phone+=n.outreach.phone,e.outreach.form+=n.outreach.form,e.outreach.social+=n.outreach.social),e},{total:0,converted:0,outreach:{email:0,phone:0,form:0,social:0}}),t=e.total>0?`${(e.converted/e.total*100).toFixed(1)} %`:"—",n=[{k:"email",icon:"✉️",color:"#60a5fa",label:"Email",n:e.outreach.email,conv:"all"===F?A.byMethod.email.converted:0},{k:"phone",icon:"\uD83D\uDCDE",color:"#a78bfa",label:"Telefon",n:e.outreach.phone,conv:"all"===F?A.byMethod.phone.converted:0},{k:"form",icon:"\uD83D\uDCDD",color:"#fbbf24",label:"Formul\xe1ř",n:e.outreach.form,conv:"all"===F?A.byMethod.form.converted:0},{k:"social",icon:"\uD83D\uDCF1",color:"#34d399",label:"Soci\xe1ln\xed s\xedtě",n:e.outreach.social,conv:"all"===F?A.byMethod.social.converted:0}],l=[...n].sort((e,t)=>t.n-e.n)[0],r=e.outreach.email+e.outreach.phone+e.outreach.form+e.outreach.social,o=A.byAccount.map(e=>{if("all"===U)return{...e,rowTotal:e.total,rowConverted:e.converted,rowOutreach:e.outreach};let t=e.byMonth.find(e=>e.month===U);return{...e,rowTotal:t?.total??0,rowConverted:t?.converted??0,rowOutreach:t?.outreach??{email:0,phone:0,form:0,social:0}}}).filter(e=>e.rowTotal>0||e.rowConverted>0).sort((e,t)=>t.rowConverted-e.rowConverted||t.rowTotal-e.rowTotal);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12,marginBottom:24},children:[(0,i.jsxs)("div",{style:{...eg},children:[(0,i.jsxs)("div",{style:{fontSize:11,color:"#555",letterSpacing:".06em",marginBottom:8},children:["CELKEM OSLOVENO","all"!==U?` — ${a(U)}`:""]}),(0,i.jsx)("div",{style:{fontSize:36,fontWeight:800,color:"#f0f0f0"},children:e.total}),"all"!==U&&(0,i.jsxs)("div",{style:{fontSize:11,color:"#444",marginTop:4},children:["celkem za vše: ",A.total]})]}),(0,i.jsxs)("div",{style:{...eg,borderColor:"#1e3a1e"},children:[(0,i.jsxs)("div",{style:{fontSize:11,color:"#555",letterSpacing:".06em",marginBottom:8},children:["ZAPLATILI 1. PROJEKT","all"!==U?` — ${a(U)}`:""]}),(0,i.jsx)("div",{style:{fontSize:36,fontWeight:800,color:"#22c55e"},children:e.converted}),(0,i.jsxs)("div",{style:{fontSize:11,color:"#3a6a3a",marginTop:4,fontWeight:600},children:[t," konverzn\xed poměr \xb7 každ\xfd 1\xd7"]}),"all"!==U&&(0,i.jsxs)("div",{style:{fontSize:11,color:"#444",marginTop:2},children:["celkem za vše: ",A.converted]})]}),(0,i.jsxs)("div",{style:{...eg,borderColor:"#2a1a0a"},children:[(0,i.jsx)("div",{style:{fontSize:11,color:"#555",letterSpacing:".06em",marginBottom:8},children:"NEJLEPŠ\xcd PLATFORMA"}),(0,i.jsxs)("div",{style:{fontSize:28,fontWeight:800,color:l?.color??"#ccc",marginBottom:2},children:[l?.icon," ",l?.label]}),(0,i.jsx)("div",{style:{fontSize:11,color:"#555",marginTop:4},children:r>0&&l?`${Math.round(l.n/r*100)} % osloven\xed touto cestou`:"—"}),(0,i.jsx)("div",{style:{display:"flex",gap:12,marginTop:10,justifyContent:"center"},children:n.map(e=>(0,i.jsxs)("div",{style:{textAlign:"center"},children:[(0,i.jsx)("div",{style:{fontSize:15,fontWeight:800,color:e.n>0?e.color:"#333"},children:e.n||"—"}
137),(0,i.jsx)("div",{style:{fontSize:10,color:"#444"},children:e.icon})]},e.k))})]})]}),o.length>0&&(0,i.jsxs)("div",{style:{marginBottom:28},children:[(0,i.jsxs)("div",{style:{fontSize:11,color:"#555",letterSpacing:".08em",fontWeight:700,marginBottom:10},children:["PŘEHLED EDITORŮ","all"!==U?` — ${a(U)}`:""]}),(0,i.jsxs)("table",{style:ep,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{style:eh,children:"EDITOR"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right"},children:"PŘIDAL"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#22c55e"},children:"1. PROJEKT"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#F4511E"},children:"%"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#60a5fa"},children:"✉️"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#a78bfa"},children:"\uD83D\uDCDE"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#fbbf24"},children:"\uD83D\uDCDD"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#34d399"},children:"\uD83D\uDCF1"})]})}),(0,i.jsx)("tbody",{children:o.map(e=>(0,i.jsxs)("tr",{style:{cursor:"pointer"},onClick:()=>D(e.uid),onMouseEnter:e=>e.currentTarget.style.background="#0f0f14",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsxs)("td",{style:{...eu,fontWeight:700},children:[e.name||e.email,(0,i.jsx)("span",{style:{fontSize:11,color:"#333",fontWeight:400,marginLeft:8},children:e.email})]}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#ccc"},children:e.rowTotal||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#22c55e",fontWeight:700},children:e.rowConverted||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#F4511E",fontWeight:700},children:e.rowTotal>0?`${(e.rowConverted/e.rowTotal*100).toFixed(1)} %`:"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#60a5fa"},children:e.rowOutreach.email||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#a78bfa"},children:e.rowOutreach.phone||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#fbbf24"},children:e.rowOutreach.form||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#34d399"},children:e.rowOutreach.social||"—"})]},e.uid))})]})]}),"all"===U&&A.convertedLeads.length>0&&(0,i.jsxs)("div",{style:{marginBottom:24},children:[(0,i.jsxs)("div",{style:{fontSize:11,color:"#555",letterSpacing:".08em",fontWeight:700,marginBottom:10},children:["PLAT\xcdC\xcd Z\xc1KAZN\xcdCI (",A.convertedLeads.length,")"]}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))",gap:8},children:A.convertedLeads.map((e,t)=>(0,i.jsxs)("div",{style:{background:"#0b1a0b",border:"1px solid #1a3a1a",borderRadius:8,padding:"10px 14px"},children:[(0,i.jsxs)("div",{style:{fontWeight:700,color:"#22c55e",marginBottom:3},children:["✓ ",e.firstName," ",e.lastName]}),e.agency&&(0,i.jsx)("div",{style:{fontSize:11,color:"#666"},children:e.agency}),e.email&&(0,i.jsxs)("div",{style:{fontSize:11,color:"#444",marginTop:3},children:["✉️ ",e.email]}),e.addedBy&&(0,i.jsxs)("div",{style:{fontSize:11,color:"#2a4a2a",marginTop:3},children:["\uD83D\uDC64 ",e.addedBy]})]},t))})]})]})}let t=A.byAccount.find(e=>e.uid===O);if(!t)return(0,i.jsx)("p",{style:{color:"#555",padding:"24px 0"},children:e?"Zat\xedm ž\xe1dn\xe1 data.":"Vyberte editora ze seznamu."});let n="all"===U?null:t.byMonth.find(e=>e.month===U),l=n?n.total:t.total,r=n?n.converted:t.converted,o="all"===U?t.byMonth:n?[n]:[];return(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:20},children:(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:15,fontWeight:700,color:"#f0f0f0"},children:t.name||t.email}),(0,i.jsx)("div",{style:{fontSize:11,color:"#444"},children:t.email})]})}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10,marginBottom:24},children:[(0,i.jsxs)("div",{style:eg,children:[(0,i.jsx)("div",{style:{fontSize:28,fontWeight:800,color:"#f0f0f0",marginBottom:4},children:l}),(0,i.jsx)("div",{style:{fontSize:11,color:"#555"},children:"Přidal makl\xe9řů"}
137),n&&t.total!==l&&(0,i.jsxs)("div",{style:{fontSize:10,color:"#333",marginTop:2},children:["celkem: ",t.total]})]}),(0,i.jsxs)("div",{style:{...eg,borderColor:"#1e3a1e"},children:[(0,i.jsx)("div",{style:{fontSize:28,fontWeight:800,color:"#22c55e",marginBottom:4},children:r}),(0,i.jsx)("div",{style:{fontSize:11,color:"#3a6a3a",fontWeight:600},children:"Zaplatili 1. projekt"}),(0,i.jsx)("div",{style:{fontSize:10,color:"#2a4a2a",marginTop:2},children:"unik\xe1tn\xed z\xe1kazn\xedci"}),n&&t.converted!==r&&(0,i.jsxs)("div",{style:{fontSize:10,color:"#1a3a1a",marginTop:2},children:["celkem: ",t.converted]})]}),(0,i.jsxs)("div",{style:eg,children:[(0,i.jsx)("div",{style:{fontSize:28,fontWeight:800,color:"#F4511E",marginBottom:4},children:l>0?`${(r/l*100).toFixed(1)} %`:"—"}),(0,i.jsx)("div",{style:{fontSize:11,color:"#555"},children:"Konverze"})]}),(0,i.jsxs)("div",{style:eg,children:[(0,i.jsx)("div",{style:{fontSize:28,fontWeight:800,color:"#60a5fa",marginBottom:4},children:t.byMonth.length}),(0,i.jsx)("div",{style:{fontSize:11,color:"#555"},children:"Měs\xedce aktivity"})]})]}),o.length>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{fontSize:11,color:"#555",letterSpacing:".08em",fontWeight:700,marginBottom:10},children:["PŘEHLED PO MĚS\xcdC\xcdCH","all"!==U?` — ${a(U)}`:""]}),(0,i.jsxs)("table",{style:ep,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{style:eh,children:"MĚS\xcdC"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right"},children:"PŘIDAL MAKL\xc9ŘŮ"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#22c55e"},children:"1. PROJEKT"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#F4511E"},children:"%"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#60a5fa"},children:"✉️"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#a78bfa"},children:"\uD83D\uDCDE"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#fbbf24"},children:"\uD83D\uDCDD"}),(0,i.jsx)("th",{style:{...eh,textAlign:"right",color:"#34d399"},children:"\uD83D\uDCF1"})]})}),(0,i.jsx)("tbody",{children:o.map(e=>(0,i.jsxs)("tr",{onMouseEnter:e=>e.currentTarget.style.background="#0f0f14",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsx)("td",{style:{...eu,fontWeight:600},children:a(e.month)}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#ccc"},children:e.total||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#22c55e",fontWeight:700},children:e.converted||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#F4511E",fontWeight:700},children:e.total>0?`${(e.converted/e.total*100).toFixed(1)} %`:"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#60a5fa"},children:e.outreach.email||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#a78bfa"},children:e.outreach.phone||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#fbbf24"},children:e.outreach.form||"—"}),(0,i.jsx)("td",{style:{...eu,textAlign:"right",color:"#34d399"},children:e.outreach.social||"—"})]},e.month))})]})]}):(0,i.jsx)("p",{style:{color:"#444",fontSize:13},children:"all"!==U?`Ž\xe1dn\xe1 aktivita v ${a(U)}.`:"Zat\xedm ž\xe1dn\xe1 data."})]})})(),!A&&!$&&!W&&(0,i.jsx)("p",{style:{color:"#555",textAlign:"center",paddingTop:40},children:'Klikni na „↻ Obnovit" pro načten\xed statistik.'})]})})()]})}function ew(e){return"Nezaplaceno"===e?"#ef4444":e.startsWith("Zaplaceno")?"#f59e0b":"Fotky nahr\xe1ny"===e?"#3b82f6":"Generov\xe1n\xed vide\xed"===e?"#8b5cf6":e.startsWith("Hotovo")?"#22c55e":"#888"}function eT(e){return e?new Date(e).toLocaleString("cs-CZ",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function eE(){let[e,t]=(0,l.useState)(""),[n,r]=(0,l.useState)(!1),[o,a]=(0,l.useState)(null),[d,c]=(0,l.useState)("");async function p(){let t=e.trim().toLowerCase();if(t){r(!0),c(""),a(null);try{let e=await s.auth.currentUser?.getIdToken(),n=await fetch(`/api/admin/user-lookup?email=${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${e}`}});if(404===n.status)return void c("Uživatel s t\xedmto e-mailem neexistuje.");if(!n.ok)return void c("Chyba serveru: "+await n.text());a(await n.json())}catch(e){c(String(e))}finally{r(!1)}}}let h={color:"#F4511E",fontWeight:700},u={background:"#151518",border:"1px solid #222",borderRadius:12,padding:20,marginBottom:16},x={color:"#888",fontSize:12,marginBottom:2},g={color:"#e0e0e0",fontSize:14},f={display:"flex",gap:32,flexWrap:"wrap",marginBottom:12},m={minWidth:160},y=e=>({display:"inline-block",padding:"2px 10px",borderRadius:20,fontSize:12,fontWeight:700,background:e,color:"#fff"});return(0,i.jsxs)("div",{style:{padding:24,maxWidth:900,margin:"0 auto"},children:[(0,i.jsx)("h2",{style:{margin:"0 0 20px",fontSize:20},children:"\uD83D\uDD0D Vyhled\xe1v\xe1n\xed uživatelů"}),(0,i.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:28},children:[(0,i.jsx)("input",{style:{flex:1,background:"#1a1a1f",color:"#e0e0e0",border:"1px solid #333",borderRadius:8,padding:"10px 14px",fontSize:14}
137,placeholder:"E-mail uživatele...",value:e,onChange:e=>t(e.target.value),onKeyDown:e=>"Enter"===e.key&&p()}),(0,i.jsx)("button",{style:{background:"#F4511E",color:"#fff",border:"none",borderRadius:8,padding:"10px 22px",fontWeight:700,fontSize:14,cursor:n?"wait":"pointer"},onClick:p,disabled:n,children:n?"Hled\xe1m…":"Hledat"})]}),d&&(0,i.jsx)("p",{style:{color:"#ef4444",marginBottom:16},children:d}),o&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:u,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:8,marginBottom:16},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:18,fontWeight:700,color:"#fff"},children:o.displayName||o.email}),(0,i.jsx)("div",{style:{color:"#888",fontSize:13},children:o.email}),(0,i.jsxs)("div",{style:{color:"#666",fontSize:12,marginTop:2},children:["UID: ",o.uid]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[o.role&&(0,i.jsx)("span",{style:y("admin"===o.role?"#F4511E":"#8b5cf6"),children:o.role.toUpperCase()}),(0,i.jsxs)("span",{style:y("#1e3a5f"),children:[o.projects.filter(e=>e.paid).length," zaplacen\xfdch projektů"]})]})]}),(0,i.jsxs)("div",{style:f,children:[(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Registrace"}),(0,i.jsx)("div",{style:g,children:eT(o.registeredAt)})]}),(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Posledn\xed přihl\xe1šen\xed"}),(0,i.jsx)("div",{style:g,children:eT(o.lastSignIn)})]}),(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Celkem projektů"}),(0,i.jsx)("div",{style:{...g,...h},children:o.projects.length})]})]})]}),0===o.projects.length&&(0,i.jsx)("p",{style:{color:"#888"},children:"Ž\xe1dn\xe9 projekty."}),o.projects.map(e=>(0,i.jsxs)("div",{style:{...u,borderLeft:`3px solid ${ew(e.phase)}`},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:8,marginBottom:14},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:{fontSize:16,fontWeight:700,color:"#fff"},children:e.name}),(0,i.jsx)("span",{style:{marginLeft:10,color:"#555",fontSize:12},children:e.id})]}),(0,i.jsx)("span",{style:{...y(ew(e.phase)),fontSize:13},children:e.phase})]}),(0,i.jsxs)("div",{style:f,children:[(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Platba"}),(0,i.jsx)("div",{style:g,children:e.paid?(0,i.jsx)("span",{style:{color:"#22c55e",fontWeight:700},children:"✓ Zaplaceno"}):(0,i.jsx)("span",{style:{color:"#ef4444"},children:"✗ Nezaplaceno"})})]}),e.promoCode&&(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Promo k\xf3d"}),(0,i.jsxs)("div",{style:g,children:[e.promoCode," ",(0,i.jsxs)("span",{style:{color:"#22c55e"},children:["(-",e.promoDiscount,"%)"]})]})]}),(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Fotky"}),(0,i.jsx)("div",{style:{...g,...h},children:e.photoCount})]}),(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Videa vygenerov\xe1na"}),(0,i.jsxs)("div",{style:{...g,...h},children:[e.videosGenerated,e.totalScenes>0?` / ${e.totalScenes}`:""]})]}),(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Zam\xedtnut\xe9 sc\xe9ny"}),(0,i.jsx)("div",{style:{...g,color:e.rejectedScenes>0?"#f59e0b":"#888"},children:e.rejectedScenes>0?`⚠ ${e.rejectedScenes}\xd7 znovu generov\xe1no`:"—"})]}),(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Sestaveno"}),(0,i.jsx)("div",{style:g,children:e.assembled?(0,i.jsx)("span",{style:{color:"#22c55e"},children:"✓ Ano"}):(0,i.jsx)("span",{style:{color:"#888"},children:"Ne"})})]})]}),(0,i.jsxs)("div",{style:{...f,marginBottom:0},children:[(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Vytvořeno"}),(0,i.jsx)("div",{style:{color:"#666",fontSize:12},children:eT(e.createdAt)})]}),e.paidAt&&(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Zaplaceno"}),(0,i.jsx)("div",{style:{color:"#666",fontSize:12},children:eT(e.paidAt)})]}),e.lastSaved&&(0,i.jsxs)("div",{style:m,children:[(0,i.jsx)("div",{style:x,children:"Posledn\xed uložen\xed"}),(0,i.jsx)("div",{style:{color:"#666",fontSize:12},children:eT(e.lastSaved)})]}),e.stripeSessionId&&(0,i.jsxs)("div",{style:{...m,minWidth:300},children:[(0,i.jsx)("div",{style:x,children:"Stripe session"}),(0,i.jsx)("div",{style:{color:"#444",fontSize:11,wordBreak:"break-all"},children:e.stripeSessionId})]})]}),e.errors&&e.errors.length>0&&(0,i.jsxs)("div",{style:{marginTop:12,background:"#1a0a0a",border:"1px solid #3f1515",borderRadius:8,padding:12},children:[(0,i.jsxs)("div",{style:{color:"#ef4444",fontWeight:700,fontSize:12,marginBottom:8},children:["⚠ Chyby při generov\xe1n\xed (",e.errors.length,")"]}),e.errors.map((e,t)=>(0,i.jsxs)("div",{style:{display:"flex",gap:12,alignItems:"flex-start",padding:"5px 0",borderTop:t>0?"1px solid #2a1010":"none"},children:[(0,i.jsx)("div",{style:{color:"#666",fontSize:11,whiteSpace:"nowrap",minWidth:120},children:eT(e.at)}),(0,i.jsx)("div",{style:{color:"#888",fontSize:11,minWidth:100},children:e.photoName||e.sceneId}),(0,i.jsx)("div",{style:{color:"#ff6b6b",fontSize:12,fontFamily:"monospace"},children:e.msg})]},t))]})]},e.id))]})]})}let eR={center:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",padding:24,background:"#09090b"},loginBox:{background:"#111113",border:"1px solid #1e1e22",borderRadius:16,padding:"32px 28px",maxWidth:380,width:"100%",display:"flex",flexDirection:"column",gap:14},input:{background:"#1a1a1f",border:"1px solid #2a2a30",borderRadius:8,padding:"11px 14px",color:"#f0f0f0",fontSize:14,outline:"none"},btn:{background:"#F4511E",color:"#fff",border:"none",borderRadius:8,padding:"11px 20px",fontSize:14,fontWeight:700,cursor:"pointer",letterSpacing:".01em"},btnSmall:{background:"transparent",color:"#ccc",border:"1px solid #444",borderRadius:6,padding:"6px 14px",fontSize:13,cursor:"pointer"},page:{minHeight:"100vh",background:"#09090b",color:"#f0f0f0",fontFamily:"system-ui, -apple-system, sans-serif"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 20px",borderBottom:"1px solid #161618",background:"#0c0c0e",flexWrap:"wrap",gap:8,position:"sticky",top:0,zIndex:100},tabBtn:{background:"transparent",color:"#888",border:"1px solid transparent",borderRadius:6,padding:"7px 14px",fontSize:13,cursor:"pointer",transition:"color .15s"},tabActive:{background:"#1e1e22",color:"#fff",border:"1px solid #2a2a30"},logoutBtn:{background:"transparent",color:"#555",border:"1px solid #1e1e22",borderRadius:6,padding:"7px 12px",fontSize:12,cursor:"pointer"},content:{maxWidth:900,margin:"0 auto",padding:24},card:{background:"#151518",borderRadius:12,padding:16,border:"1px solid #222"},step:{background:"#1a1a1f",borderRadius:8,padding:16},textarea:{width:"100%",background:"#0d0d10",color:"#e0e0e0",border:"1px solid #333",borderRadius:8,padding:12,fontFamily:"monospace",fontSize:13,resize:"vertical",boxSizing:"border-box"}}}
137,9674:(e,t,n)=>{n.r(t),n.d(t,{auth:()=>d,db:()=>c,storage:()=>p});var i=n(7873),l=n(9997),r=n(1531),o=n(9058);let a={apiKey:"AIzaSyANP4A1CtVXImcbvFaiYlDFZo0BDI01Lug",authDomain:"virtualnifotograf.firebaseapp.com",projectId:"virtualnifotograf",storageBucket:"virtualnifotograf.firebasestorage.app",messagingSenderId:"458492572082",appId:"1:458492572082:web:de294f3e782271108574ab"},s=a.apiKey?0===(0,i.Dk)().length?(0,i.Wp)(a):(0,i.Sx)():null,d=s?(0,l.getAuth)(s):null,c=s?(0,r.aU)(s):null,p=s?(0,o.c7)(s):null}}]);

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.