- interval_count = hrs_per_slide * 60 / @conference.program.schedule_interval + 1
- width = 85 / interval_count
- carousel_number = (@conf_period / hrs_per_slide.to_f).ceil
.carousel.slide{ id: "carousel-#{ date }-#{ hrs_per_slide }", |
                     "data-ride" => "carousel", |
                     "data-wrap" => "false", |
                     "data-interval" => "false" }
  / Wrapper for slides
  .carousel-inner
    - start_time = DateTime.parse("#{date} #{@conf_start}:00")
    - (0..carousel_number-1).each do |number|
      %div{ class: "#{ carousel_item_class(number, carousel_number, hrs_per_slide, @hour_column)}" }
        %table.table.table-bordered.schedule-table#schedule
          %tr
            %th
            - td_start_time = start_time
            - interval_count.times do
              %th.date
                %span
                  = (td_start_time).strftime("%H:")
                %span
                  = (td_start_time).strftime("%M")
              - td_start_time += @step_minutes
          - start_room_time = start_time
          - @rooms.each do |room|
            - start_room_time = start_time
            - span = 1
            %tr
              %td.room{ style: "height: #{ td_height(@rooms) }px;" }
                .room.elipsis.break-words{ style: "-webkit-line-clamp: #{ room_lines(@rooms) }; height: #{ room_height(@rooms) }px;" }
                  = room.name

                - event_schedules = (@event_schedules_by_room_id[room.id] || []).select{ |e| (e.end_time > start_time) && (e.start_time <= (start_time + hrs_per_slide.hour)) }

                - interval_count.times do |offset|
                  - if span > 1
                    - span -= 1
                  - else
                    - event_schedule = event_schedules.find{ |e| e.start_time <= start_room_time and e.end_time > start_room_time }
                    - if event_schedule && (event_schedule.event.state == 'canceled' || event_schedule.event.state == 'withdrawn') && event_schedule.intersecting_event_schedules.confirmed.exists?
                      - replacement_event = event_schedule.intersecting_event_schedules.confirmed.first
                      - event_schedule = (replacement_event.start_time <= start_room_time && replacement_event.end_time > start_room_time) ? replacement_event : nil

                    - if event_schedule
                      -# There is an event, calculate the span and show it
                      - event_span =  (event_schedule.end_time.to_i - start_room_time.to_i) / 60 / @conference.program.schedule_interval
                      - span = ((event_span + offset) > interval_count ? interval_count - offset : event_span)
                      = render partial: 'schedule_item', locals: {event: event_schedule.event, event_schedule: event_schedule, span: span, width: width}
                    - else
                      -# if span equals 1 show an empty td
                      %td.no-padding{ width: "#{ width }%"}
                  - start_room_time += @step_minutes
          - start_time = start_room_time - @step_minutes

  / Controls
  %a.left.carousel-control{ href: "#carousel-#{ date }-#{ hrs_per_slide }", |
                            role: "button", |
                            "data-slide" => "prev" }
    %span.fa-solid.fa-chevron-left
  %a.right.carousel-control{ href: "#carousel-#{ date }-#{ hrs_per_slide }", |
                             role: "button", |
                             "data-slide" => "next" }
    %span.fa-solid.fa-chevron-right
