'use strict';
import * as sol from "../../solight/sol.js";
import * as serv from "../services/general.js";
import * as tiserv from "../services/timeText.js";
const html = htm.bind(preact.h);
const minBioLength = 20;
const event_persons = (persons) =>
html`
${serv.fix_dash(serv.person_names_concat(persons))}:
`;
const event_remaining_time_abs_rel = (event, time) => {
const dt = luxon.Duration.fromObject({minutes: 11});
return sol.isEndingEvent(event, time, dt) ?
tiserv.event_relative_end_time_string(event, time) :
tiserv.event_absolute_end_time_string(event, time);
};
const event_time_abs_rel = (event, time) =>
sol.isFutureEvent(event, time) ?
tiserv.event_relative_fuzzy_start_time_string(event, time) :
event_remaining_time_abs_rel(event, time);
const event_time = (event, time) => {
const ti = serv.type_index(sol.eventType(event));
const timestr = ti !== 0 ?
tiserv.event_relative_fuzzy_start_time_string(event, time) :
event_time_abs_rel(event, time);
return html`${timestr}
`;
};
const event_meta = (event, time) =>
html`
`;
const event_description = (event) => {
const description = sol.eventAbstract(event);
const abstract = sol.eventAbstract(event);
const atext = sol.defined(abstract) ? abstract : "";
const dtext = sol.defined(description) ? description : "";
const text = atext.length >= dtext.length ? atext : dtext;
return html`
`;
};
const event_content = (event) =>
html`${event_description(event)}
`;
const speaker_info = (speaker) => {
const name = serv.fix_dash(sol.personName(speaker));
const bio = sol.personBiography(speaker);
let inner;
if (sol.defined(bio) && bio.length >= minBioLength) {
inner = html`
`;
} else {
inner = html``;
}
return inner;
};
const speaker_meta = (event) => {
const speakers = sol.eventPersons(event);
return html`${speakers.map(s => speaker_info(s))}
`;
};
const event_info = (event, time) => {
const ti = serv.type_index(sol.eventType(event));
return html`
${event_meta(event, time)}
${event_content(event)}
${speaker_meta(event)}
`;
};
const update_main_slide = (data, time, config) => {
// console.group("Updating Main Slide with:");
// console.info(data);
// console.info(time);
// console.info(config);
// console.groupEnd();
if (sol.defined(data.scheduleData)) {
const schedule = data.scheduleData;
const thisRoom = config.roomName;
const dt = luxon.Duration.fromObject({minutes: 6});
const events = sol.allEvents(schedule);
const eventsSorted = sol.sortEventsByStartDate(events);
const eventsHere = sol.eventsByRoomName(eventsSorted, thisRoom);
const startingEventsHere = sol.startingEvents(eventsHere, time, dt);
const currentEventsHere = sol.currentEvents(eventsHere, time);
const endedEventsHere = sol.endedEvents(eventsHere, time, dt);
const upcomingEventsHere = sol.distinctEvents(startingEventsHere.concat(currentEventsHere, endedEventsHere));
// Assemble dom
const inner = html`
${upcomingEventsHere.slice(0,1).map(e => event_info(e, time))}
`;
// Add main slide to frame
const anchorElId = "main";
const el = document.getElementById(anchorElId);
preact.render(inner, el);
};
};
export {
update_main_slide
};