<?php
if (TL_MODE == 'FE') {
    $GLOBALS['TL_CSS'][] = 'files/base/layout/css/elements/custom-elements/ce_rsce_actionmodal.min.css|static';
}
?>


    <div class="modal <?php echo $this->class; ?>" id="actionModal_<?php echo $this->id; ?>"
         tabindex="-1" aria-hidden="true">
        <div class="modal-dialog <?php echo $this->modal_size; ?> modal-dialog-centered"
             data-aos="<?php if ($this->animation_type) : ?><?php echo $this->animation_type; ?><?php else : ?>animate__fadeInUp<?php endif; ?>">
            <div class="modal-content"
                 <?php if ($this->modal_backgroundcolor): ?>style="background-color: <?php echo $this->modal_backgroundcolor; ?>"<?php endif; ?>>

                <?php if ($this->modal_headline): ?>
                    <div class="modal-header" data-aos="animate__fadeInUp">
                        <h5 class="modal-title">
                            <?php echo $this->modal_headline; ?>
                        </h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Schließen">

                        </button>
                    </div>
                <?php endif; ?>
                <div class="modal-body">

                    <?php if ($this->image): ?>
                        <div class="modal--image mb-2 <?php if ($this->remove_image_padding): ?>without-padding<?php endif; ?>">
                            <?php if (!$this->modal_headline): ?>
                                <button type="button" class="btn--close" data-bs-dismiss="modal" aria-label="Schließen"
                                        style="<?php if ($this->image_right_col_text_color): ?>color: <?php echo $this->image_right_col_text_color; ?><?php endif; ?>">
                                    <i class="fal fa-times"></i>
                                </button>
                            <?php endif; ?>


                            <?php if ($this->as_bg): ?>
                                <div class="modal-image--wrapper lazy"
                                     data-bg="<?= Image::get(FilesModel::findByUuid($this->image)->path, null, null, null); ?>"
                                     style="background-position: center center; background-repeat: no-repeat; background-size: cover; <?php if ($this->fixed_height): ?>min-height: <?php echo $this->fixed_height; ?><?php endif; ?>"></div>
                            <?php else: ?>
                                <img style="<?php if ($this->fixed_height): ?>height: <?php echo $this->fixed_height; ?><?php endif; ?>"
                                     class="lazy"
                                     data-src="<?= Image::get(FilesModel::findByUuid($this->image)->path, null, null, null); ?>">
                            <?php endif; ?>

                            <div class="image--content">
                                <div class="row gy-0 gx-lg-4 align-items-center">
                                    <?php if ($this->image_headline_left): ?>
                                        <div class="col-12 left--col <?php if ($this->image_headline_right || $this->image_text_right): ?>col-lg-5<?php endif; ?>">
                                            <div class="modal-image--big-headline" data-aos="animate__fadeInLeft">
                                                <span><?php echo $this->image_headline_left; ?></span>
                                            </div>
                                        </div>
                                    <?php endif; ?>
                                    <?php if ($this->image_headline_right || $this->image_text_right): ?>
                                        <div class="col-12 d-none d-xl-block right--col <?php if ($this->image_headline_left): ?>col-lg-7<?php endif; ?>">
                                            <div class="modal-image--text-wrapper" data-aos="animate__fadeInRight"
                                                 style="<?php if ($this->image_right_col_background_color): ?>background-color: <?php echo $this->image_right_col_background_color; ?>;<?php endif; ?> <?php if ($this->image_right_col_text_color): ?>color: <?php echo $this->image_right_col_text_color; ?><?php endif; ?>">
                                                <?php if ($this->image_headline_right): ?>
                                                    <span><?php echo $this->image_headline_right; ?></span>
                                                <?php endif; ?>
                                                <?php if ($this->image_text_right): ?><?php echo $this->image_text_right; ?><?php endif; ?>
                                            </div>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>

                        </div>
                    <?php endif; ?>

                    <div class="modal--lower-content">


                        <div class="row gx-lg-4">

                            <?php if ($this->image_left): ?>
                                <div class="col-12 col-md-5">
                                    <img class="lazy" data-aos="animate__fadeIn"
                                         data-src="<?= Image::get(FilesModel::findByUuid($this->image_left)->path, null, null, null); ?>
                                ">
                                </div>
                            <?php endif; ?>

                            <div class="col">
                                <?php if ($this->headline): ?>
                                    <div class="modal--headline" data-aos="animate__fadeInUp">
                                        <span class="h2"><?php echo $this->headline; ?></span>
                                    </div>
                                <?php endif; ?>

                                <?php if ($this->progress_amount): ?>
                                    <div class="modal--progress mb-3" data-aos="animate__fadeInUp">
                                        <?php if ($this->progress_image): ?>
                                            <div class="progressbar--images">
                                                <?php for ($i = 0; $i <= $this->progress_amount; $i++) : ?>
                                                    <img class="lazy"
                                                         data-src="<?= Image::get(FilesModel::findByUuid($this->progress_image)->path, null, null, null); ?>">
                                                <?php endfor; ?>
                                            </div>
                                        <?php else: ?>
                                            <div class="progress">
                                                <div class="progress-bar progress-bar-striped progress-bar-animated"
                                                     role="progressbar"
                                                     aria-valuenow="<?php echo $this->progress_amount; ?>"
                                                     aria-valuemin="0"
                                                     aria-valuemax="100"
                                                     style="width: <?php echo $this->progress_amount; ?>%"></div>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                <?php endif; ?>

                                <?php if ($this->text): ?>
                                    <div class="modal--text" data-aos="animate__fadeInUp">
                                        <?php echo $this->text; ?>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
                <?php if ($this->buttons[0]->link_text != "" || $this->show_footer_close) : ?>
                    <div class="modal-footer ">

                        <?php if ($this->buttons[0]->link_text != "") : ?>
                            <div class="ce--buttons mt-3">
                                <?php foreach ($this->buttons as $b) : ?>
                                    <a class="d-inline-block btn me-2 <?php if ($b->link_size) : ?><?php echo $b->link_size; ?><?php endif; ?> <?php echo $b->link_type; ?>"
                                       data-aos="animate__fadeInUp"
                                       href="<?php echo $b->link_url; ?><?php if ($b->link_betreff) : ?>?subject=<?php echo $b->link_betreff; ?><?php endif; ?>"><?php echo $b->link_text; ?> </a>
                                <?php endforeach ?>
                            </div>
                        <?php endif; ?>

                        <?php if ($this->show_footer_close && !$this->sponsors): ?>
                            <div class="text-end mt-3">
                                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Schließen
                                </button>
                            </div>
                        <?php endif; ?>
                        <?php if ($this->sponsors): ?>
                            <div class="text-end mt-3">
                                <?php foreach ($this->sponsors as $s) : ?><?php if ($s->link): ?>
                                    <a href="<?php echo $s->link; ?>" target="_blank"><?php endif; ?>
                                    <img class="lazy d-inline-block ms-2"
                                         data-src="<?= Image::get(FilesModel::findByUuid($s->image)->path, null, null, null); ?>">
                                    <?php if ($s->link): ?></a><?php endif; ?><?php endforeach ?>
                            </div>
                        <?php endif; ?>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

<?php if (TL_MODE == 'FE'): ?>
    <script type="text/javascript">
        $(window).on('load', function () {
            <?php if ($this->cookie_hide) : ?>
            if (!Cookies.get('actionModal_<?php echo $this->id; ?>')) {
                <?php endif; ?>
                $('#actionModal_<?php echo $this->id; ?>').modal('show');
                <?php if ($this->cookie_hide) : ?>
            }
            <?php endif; ?>
        });

        <?php if ($this->cookie_hide) : ?>
        var myActionModal = document.getElementById('actionModal_<?php echo $this->id; ?>')
        myActionModal.addEventListener('hidden.bs.modal', function (event) {

            if (Cookies.get('cookie_basefeatures')) {
                Cookies.set('actionModal_<?php echo $this->id; ?>', 'true', {
                    secure: true,
                    expires: 7,
                    sameSite: 'strict'
                })
            }

        }, {passive: true})
        <?php endif; ?>
    </script>
<?php endif; ?>