1import{b as ae,u as ne,j as e}from"./query-DaV6vLBd.js";import{j as ue,r as d}from"./react-vendor-Dn2D-9Bs.js";import{T as xe,a as pe,b as P,c as V}from"./tabs-BvbKqmBC.js";import{aF as ve,B as g,a as E,b as w,w as je,c as I,d as T,a0 as ge,v as fe,e as L,L as j,I as D,t as Y,u as k,S as ye,i as ke,j as be,k as Ne,l as Q,$ as Se}from"./index-qd8DFCfM.js";import{S as $}from"./switch-CiyKetCG.js";import{u as Ce,a as _e,D as Ee,f as we,P as Ie,g as Te}from"./dnd-CISRCHzg.js";import{B as Z,F as Le}from"./FooterEditor-Bwmyezq-.js";import{R as De}from"./RichTextEditor-C4hAAQxj.js";import{E as Re}from"./EventInfoSettings-Bc7SHmTG.js";import{m as ee}from"./cms-blocks-Bf8zWkba.js";import{u as Be,d as Fe,c as Oe,l as Pe}from"./eventResources-Bh1SH8Pk.js";import{m as se,i as Ve,S as Ke,n as qe,d as te,a as Je}from"./simple-event-jDr7pLfb.js";import{F as A}from"./FloatingSaveBar-DWSXymIV.js";import{L as Me,F as Ue,P as ze}from"./SandboxedHtml-CwFlc_Tq.js";import{I as Qe}from"./info-CS06KI_5.js";import{T as re}from"./trash-2-D8cUU1TU.js";import{P as ie}from"./plus-CY81bHpV.js";import"./ui-radix-CEI8UHvd.js";import"./supabase-D_2IiIQD.js";import"./pdf-bz0EImIo.js";import"./charts-CO9wFpST.js";import"./popover-BS12T1kN.js";import"./undo-CK12vlL3.js";import"./image-LMRaeGwX.js";import"./minus-Di-150q9.js";import"./sanitizeHtml-C2XJLGT2.js";import"./purify.es-dhnUglUx.js";import"./pages-BFUSaOG6.js";import"./upload-D-SFaqJk.js";import"./grip-vertical-Bmyhud38.js";import"./copy-B4Czcf89.js";import"./save-DTX7rhL5.js";import"./tiptap-UbEmYf7M.js";import"./richTextExtensions-CzR2FDlf.js";import"./list-Y6KvRbDO.js";import"./link-B1v90ZQ5.js";import"./ConferenceContext-BaGgsci-.js";import"./map-pin-Chkh7VFc.js";import"./building-CL0wniTq.js";function Ds(){const{id:l}=ue(),K=ae(),{data:n}=ne({queryKey:["conference",l],queryFn:()=>Se(l),enabled:!!l}),[a,h]=d.useState(se(null)),[f,b]=d.useState(null),[N,R]=d.useState(""),[S,C]=d.useState(""),[y,B]=d.useState(null),[o,q]=d.useState(!1),[H,W]=d.useState(!1),[J,M]=d.useState({}),[x,le]=d.useState({config:"",dashboard:"",intro:""});d.useEffect(()=>{if(!n)return;const s=se(n.simple_event_sections),r=n.hero_content_json,t=s.sections.findIndex(m=>m.key==="hero");t>=0&&!s.sections[t].content&&r&&(s.sections[t]={...s.sections[t],content:ee(r)}),h(s),b(n.dashboard_blocks??n.live_page_blocks??null),R(n.stream_vimeo_url??""),C(n.stream_slido_url??""),B(n.info_content_json??null),le({config:JSON.stringify(s),dashboard:JSON.stringify({blocks:n.dashboard_blocks??n.live_page_blocks??null,stream:n.stream_vimeo_url??"",slido:n.stream_slido_url??""}),intro:JSON.stringify(n.info_content_json??null)})},[n]);const oe=x.config!==""&&JSON.stringify(a)!==x.config,ce=x.dashboard!==""&&JSON.stringify({blocks:f,stream:N,slido:S})!==x.dashboard,de=x.intro!==""&&JSON.stringify(y)!==x.intro,G=async s=>{if(l){W(!0);try{await Y(l,s),K.invalidateQueries({queryKey:["conference",l]}),k.success("Sparat")}catch(r){k.error(r.message)}finally{W(!1)}}},X=(s,r)=>{const t=[...a.sections],m=s+r;m<0||m>=t.length||([t[s],t[m]]=[t[m],t[s]],h({...a,sections:t}))},U=(s,r)=>{const t=[...a.sections];t[s]={...t[s],...r},h({...a,sections:t})},me=Ce(_e(Ie,{activationConstraint:{distance:4}})),he=s=>{const{active:r,over:t}=s;if(!t)return;const m=String(r.id),_=String(t.id);if(m===_)return;const p=a.sections.map(i=>ee(i.content).blocks),c=(()=>{for(let i=0;i<p.length;i++){const v=p[i].findIndex(z=>z.id===m);if(v>=0)return{si:i,bi:v}}return null})();if(!c)return;let u=-1,F=-1;if(_.startsWith("sec:"))u=a.sections.findIndex(i=>i.key===_.slice(4)),F=u>=0?p[u].length:-1;else for(let i=0;i<p.length;i++){const v=p[i].findIndex(z=>z.id===_);if(v>=0){u=i,F=v;break}}if(u<0||F<0)return;const O=p.map(i=>[...i]);if(u===c.si)O[c.si]=Te(O[c.si],c.bi,F);else{const[i]=O[c.si].splice(c.bi,1);O[u].splice(F,0,i)}h({...a,sections:a.sections.map((i,v)=>v===c.si||v===u?{...i,content:{version:2,blocks:O[v]}}:i)})};return l?e.jsxs("div",{className:"animate-fade-in space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-display font-bold",children:"Eventinnehåll"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Bygg eventets onepager, deltagarvyn och materialet som deltagarna får tillgång till."})]}),e.jsxs(xe,{defaultValue:"sections",children:[e.jsxs(pe,{className:"flex-wrap",children:[e.jsxs(P,{value:"sections",children:[e.jsx(Me,{className:"h-4 w-4 mr-1.5"})," Sektioner"]}
1),e.jsxs(P,{value:"info",children:[e.jsx(Qe,{className:"h-4 w-4 mr-1.5"})," Eventinformation"]}),e.jsxs(P,{value:"dashboard",children:[e.jsx(ve,{className:"h-4 w-4 mr-1.5"})," Deltagarvy"]}),e.jsxs(P,{value:"resources",children:[e.jsx(Ue,{className:"h-4 w-4 mr-1.5"})," Material"]}),e.jsxs(P,{value:"footer",children:[e.jsx(ze,{className:"h-4 w-4 mr-1.5"})," Footer"]})]}),e.jsxs(V,{value:"sections",className:"mt-4 space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sektionerna blir eventsidans innehÃ¥ll och toppmeny â i den ordning du lägger dem här. Du kan dra ett block mellan sektioner med draghandtaget."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{variant:"outline",size:"sm",onClick:()=>M(Object.fromEntries(a.sections.map(s=>[s.key,!0]))),children:"Minimera alla"}),e.jsx(g,{variant:"outline",size:"sm",onClick:()=>M({}),children:"Expandera alla"})]}),e.jsx(Ee,{sensors:me,collisionDetection:we,onDragEnd:he,children:a.sections.map((s,r)=>{var p;const t=Ve(s.key),m=t?((p=s.title)==null?void 0:p.trim())||"Egen sektion":Ke[s.key].sv,_=t||["hero","about","program","register","resources","contact"].includes(s.key);return e.jsxs(E,{className:"mb-4",children:[e.jsxs(w,{className:"flex flex-row items-center justify-between gap-4 space-y-0",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 text-left",onClick:()=>M(c=>({...c,[s.key]:!c[s.key]})),"aria-expanded":!J[s.key],children:[e.jsx(je,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-transform ${J[s.key]?"":"rotate-90"}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(I,{className:"text-base",children:m}),e.jsx(T,{children:s.key==="hero"?"Toppen av sidan â text under eventets titel":`#${s.key}`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"ghost",size:"icon",onClick:()=>X(r,-1),"aria-label":"Flytta upp",children:e.jsx(ge,{className:"h-4 w-4"})}),e.jsx(g,{variant:"ghost",size:"icon",onClick:()=>X(r,1),"aria-label":"Flytta ned",children:e.jsx(fe,{className:"h-4 w-4"})}),t&&e.jsx(g,{variant:"ghost",size:"icon","aria-label":"Ta bort sektion",onClick:()=>{confirm(`Ta bort sektionen "${m}" och dess innehÃ¥ll?`)&&h({...a,sections:a.sections.filter((c,u)=>u!==r)})},children:e.jsx(re,{className:"h-4 w-4 text-destructive"})}),e.jsx($,{checked:s.enabled,disabled:s.key==="hero",onCheckedChange:c=>U(r,{enabled:c})})]})]}),s.enabled&&!J[s.key]&&e.jsxs(L,{className:"space-y-4",children:[s.key!=="hero"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{children:t?"Rubrik (visas i menyn)":"Rubrik i menyn (valfritt)"}),e.jsx(D,{value:s.title??"",placeholder:t?"T.ex. Praktisk information":m,onChange:c=>U(r,{title:c.target.value})})]}),_&&e.jsx(Z,{value:s.content,conferenceId:l,externalDndContainerId:`sec:${s.key}`,onChange:c=>U(r,{content:c})})]})]},s.key)})}),e.jsxs(g,{variant:"outline",onClick:()=>h({...a,sections:[...a.sections,{key:qe(),enabled:!0,title:"",content:null}]}),children:[e.jsx(ie,{className:"h-4 w-4 mr-1.5"})," Lägg till egen sektion"]}),e.jsxs(E,{children:[e.jsxs(w,{children:[e.jsx(I,{className:"text-base",children:"Faktakort i sidokolumnen"}),e.jsx(T,{children:"Välj vilka kort som visas: När, Var, Arrangör och Kontakt. Kurser har även ett priskort."})]}),e.jsx(L,{className:"space-y-3",children:Object.keys(te()).filter(s=>s!=="price"||(n==null?void 0:n.event_type)==="course").map(s=>{var r;return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(j,{className:"font-normal",children:Je[s].sv}),e.jsx($,{checked:((r=a.cards)==null?void 0:r[s])!==!1,onCheckedChange:t=>h({...a,cards:{...te(),...a.cards??{},[s]:t}})})]},s)})})]}),e.jsx(A,{visible:oe,saving:H,label:"Spara sektioner",onSave:()=>G({simple_event_sections:a}),onReset:()=>h(JSON.parse(x.config))})]}),e.jsxs(V,{value:"info",className:"mt-4 space-y-6",children:[e.jsxs(E,{children:[e.jsxs(w,{children:[e.jsx(I,{className:"text-base",children:"Introtext"}),e.jsx(T,{children:"Visas ovanför faktakorten pÃ¥ eventsidan."})]}),e.jsxs(L,{className:"space-y-3",children:[e.jsx(De,{value:y,onChange:B,conferenceId:l,placeholder:"Lämna tomt för att inte visa nÃ¥gon introtextâ¦",autosaveStatus:o?"saving":"idle"}),e.jsx(A,{visible:de,saving:o,label:"Spara introtext",onReset:()=>B(JSON.parse(x.intro)),onSave:async()=>{q(!0);try{await Y(l,{info_content_json:y}),K.invalidateQueries({queryKey:["conference",l]}),k.success("Introtext sparad")}catch(s){k.error(s.message)}finally{q(!1)}}})]})]}),e.jsx(Re,{})]}),e.jsxs(V,{value:"dashboard",className:"mt-4 space-y-4",children:[e.jsxs(E,{children:[e.jsxs(w,{children:[e.jsx(I,{className:"text-base",children:"Stream & interaktion"}),e.jsx(T,{children:"Vimeo-länk för sändningen och valfri Slido-embed."})]}),e.jsxs(L,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{children:"Vimeo-URL"}),e.jsx(D,{value:N,onChange:s=>R(s.target.value),placeholder:"https://vimeo.com/event/..."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{children:"Slido-URL (valfri â annars används inbyggd Q&A)"}),e.jsx(D,{value:S,onChange:s=>C(s.target.value),placeholder:"https://app.sli.do/event/..."})]})]})]}),e.jsxs(E,{children:[e.jsxs(w,{children:[e.jsx(I,{className:"text-base",children:"Block i deltagarvyn"}),e.jsx(T,{children:"Text, bilder, dokument och HTML som visas under sändningen."})]}),e.jsx(L,{children:e.jsx(Z,{value:f,conferenceId:l,onChange:b})})]}
1),e.jsx(A,{visible:ce,saving:H,label:"Spara deltagarvy",onSave:()=>G({dashboard_blocks:f,stream_vimeo_url:N||null,stream_slido_url:S||null}),onReset:()=>{const s=JSON.parse(x.dashboard);b(s.blocks),R(s.stream),C(s.slido)}})]}),e.jsx(V,{value:"resources",className:"mt-4",children:e.jsx(Ae,{conferenceId:l})}),e.jsxs(V,{value:"footer",className:"mt-4 space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Footern visas längst ner bÃ¥de pÃ¥ eventsidan och i deltagarvyn."}),e.jsx(Le,{conferenceId:l})]})]})]}):null}function Ae({conferenceId:l}){const K=ae(),{data:n=[]}=ne({queryKey:["event-resources",l],queryFn:()=>Pe(l)}),[a,h]=d.useState(""),[f,b]=d.useState(""),[N,R]=d.useState("link"),[S,C]=d.useState(""),y=()=>K.invalidateQueries({queryKey:["event-resources",l]}),B=async()=>{if(!a.trim()||!f.trim()){k.error("Titel och länk krävs");return}try{await Oe({conference_id:l,title:a.trim(),url:f.trim(),kind:N,description:S.trim()||null,sort_order:n.length}),h(""),b(""),C(""),y(),k.success("Material tillagt")}catch(o){k.error(o.message)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(E,{children:[e.jsxs(w,{children:[e.jsx(I,{className:"text-base",children:"Lägg till material"}),e.jsx(T,{children:"On-demand-video, dokument eller länkar för deltagarna."})]}),e.jsxs(L,{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{children:"Titel"}),e.jsx(D,{value:a,onChange:o=>h(o.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{children:"Länk"}),e.jsx(D,{value:f,onChange:o=>b(o.target.value),placeholder:"https://â¦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{children:"Typ"}),e.jsxs(ye,{value:N,onValueChange:o=>R(o),children:[e.jsx(ke,{children:e.jsx(be,{})}),e.jsxs(Ne,{children:[e.jsx(Q,{value:"link",children:"Länk"}),e.jsx(Q,{value:"document",children:"Dokument"}),e.jsx(Q,{value:"video",children:"Video"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(j,{children:"Beskrivning (valfri)"}),e.jsx(D,{value:S,onChange:o=>C(o.target.value)})]}),e.jsx("div",{children:e.jsxs(g,{onClick:B,children:[e.jsx(ie,{className:"h-4 w-4 mr-1.5"})," Lägg till"]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(o=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border bg-card p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:o.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:o.url})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:"text-xs text-muted-foreground",children:"Publicerad"}),e.jsx($,{checked:o.published,onCheckedChange:async q=>{await Be(o.id,{published:q}),y()}}),e.jsx(g,{variant:"ghost",size:"icon","aria-label":"Ta bort",onClick:async()=>{await Fe(o.id),y()},children:e.jsx(re,{className:"h-4 w-4"})})]})]},o.id)),n.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Inget material tillagt ännu."})]})]})}export{Ds as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.