<?php

$widget->add_render_attribute( 'fancybox-wrap', 'class', ['pxl-fancybox-wrap d-flex-wrap w-100', 'layout-'.$settings['layout']]);

// Heading
$widget->add_render_attribute( 'heading', 'class', 'title pxl-heading');
if ( $settings['title_animation'] ) {
    $widget->add_render_attribute( 'heading', 'class', 'pxl-animate pxl-invisible animated-'.$settings['title_animation_duration']);
    $widget->add_render_attribute( 'heading', 'data-settings', 
        json_encode([
            'animation'      => $settings['title_animation'],
            'animation_delay' => $settings['title_animation_delay']
        ])
    );
}
// sub title
$widget->add_render_attribute( 'icon', 'class', 'pxl-icon');
if ( $settings['title_animation'] ) {
    $widget->add_render_attribute( 'icon', 'class', 'pxl-animate pxl-invisible animated-'.$settings['icon_animation_duration']);
    $widget->add_render_attribute( 'icon', 'data-settings', 
        json_encode([
            'animation'      => $settings['icon_animation'],
            'animation_delay' => $settings['icon_animation_delay']
        ])
    );
}

// desc
$widget->add_render_attribute( 'desc', 'class', 'desc');
if ( $settings['title_animation'] ) {
    $widget->add_render_attribute( 'desc', 'class', 'pxl-animate pxl-invisible animated-'.$settings['desc_animation_duration']);
    $widget->add_render_attribute( 'desc', 'data-settings', 
        json_encode([
            'animation'      => $settings['desc_animation'],
            'animation_delay' => $settings['desc_animation_delay']
        ])
    );
}

if(!empty($settings['hyper_link']['url'])){
    $widget->add_render_attribute( 'custom_link', 'href', $settings['hyper_link']['url'] );

    if ( $settings['hyper_link']['is_external'] ) {
        $widget->add_render_attribute( 'custom_link', 'target', '_blank' );
    }

    if ( $settings['hyper_link']['nofollow'] ) {
        $widget->add_render_attribute( 'custom_link', 'rel', 'nofollow' );
    }
}

$link_attributes = $widget->get_render_attribute_string( 'custom_link' );
$link_text = $widget->get_setting( 'link_text' );

$is_active = $widget->get_setting( 'is_active', 'false' );
if($is_active == 'true')
    $widget->add_render_attribute( 'fancybox-wrap', 'class', 'active' );
?>

<div <?php pxl_print_html($widget->get_render_attribute_string('fancybox-wrap'));?>>
    <div class="fancybox-inner relative overflow-hidden w-100">
        <div class="pxl-fancybox-content relative <?php echo esc_attr($settings['style']); ?>">
            <?php if(!empty($widget->get_setting('pxl_icon'))): ?>
                <div <?php pxl_print_html($widget->get_render_attribute_string( 'icon' )); ?>>
                    <?php if ( $settings['icon_type'] == 'icon' && !empty($settings['pxl_icon']['value']) ) : ?>
                        <div class="pxl-item--icon">
                            <?php \Elementor\Icons_Manager::render_icon( $settings['pxl_icon'], [ 'aria-hidden' => 'true', 'class' => '' ], 'i' ); ?>
                        </div>
                    <?php endif; ?>
                    <?php if ( $settings['icon_type'] == 'image' && !empty($settings['icon_image']['id']) ) : ?>
                        <div class="pxl-item--icon">
                            <?php $img_icon  = pxl_get_image_by_size( array(
                                'attach_id'  => $settings['icon_image']['id'],
                                'thumb_size' => 'full',
                            ) );
                            $thumbnail_icon    = $img_icon['thumbnail'];
                            echo pxl_print_html($thumbnail_icon); ?>
                        </div>
                    <?php endif; ?>
                </div>
            <?php endif; ?>
            <?php if(!empty($widget->get_setting('number'))): ?>
                <span class="pxl-item--number">
                    <?php pxl_print_html($widget->get_setting('number')); ?>
                </span>
            <?php endif; ?>
            <?php if(!empty($widget->get_setting('title'))): ?>
                <h7 <?php pxl_print_html($widget->get_render_attribute_string( 'heading' )); ?>>
                    <?php pxl_print_html($widget->get_setting('title')); ?>
                </h7>
            <?php endif; ?>
            <?php if(!empty($widget->get_setting('desc'))): ?>
                <div <?php pxl_print_html($widget->get_render_attribute_string( 'desc' )); ?>>
                    <?php pxl_print_html( nl2br($widget->get_setting('desc'))); ?>
                </div>
            <?php endif; ?>            
            <?php
            if ($link_attributes) {                
                if (empty($link_text)) {
                    echo '<a class="btn-readmore"' . $link_attributes . '><svg xmlns="http://www.w3.org/2000/svg" width="22" height="12" viewBox="0 0 22 12" fill="none">
                    <path d="M15.3055 12L21.2847 6L15.3055 -2.61359e-07L14.3005 1.0085L18.5641 5.28695L-4.75947e-06 5.28695L-4.82182e-06 6.71314L18.564 6.71314L14.3005 10.9915L15.3055 12Z" fill="#00194C"/></svg></a>';
                } else {
                    echo '<a class="btn-readmore"' . $link_attributes . '><span class="pxl--btn-text">' . $link_text . '</span></a>';
                }
            }
            ?>
        </div> 
    </div> 
</div>




