<?php
if (!defined('ABSPATH')) {
    exit;
}
?>
<!-- Social media setting box: start -->
<li data-id="<?php echo esc_attr($social['slug']) ?>" class="chaty-channel" data-channel="<?php echo esc_attr($channel_type) ?>" id="chaty-social-<?php echo esc_attr($social['slug']) ?>">
    <div class="channels-selected__item <?php echo esc_attr(($status)?"img-active":"") ?> <?php echo esc_attr(($this->is_pro()) ? 'pro' : 'free'); ?> 1 available">
        <div class="chaty-default-settings">
            <div class="move-icon">
                <img src="<?php echo esc_url(plugin_dir_url("")."/chaty/admin/assets/images/move-icon.png") ?>">
            </div>
            <div class="icon icon-md active" data-label="<?php echo esc_attr($social['title']); ?>">
                <span style="" class="custom-chaty-image custom-image-<?php echo esc_attr($social['slug']) ?>" id="image_data_<?php echo esc_attr($social['slug']) ?>">
                    <img src="<?php echo esc_url($imageUrl) ?>" />
                    <span onclick="remove_chaty_image('<?php echo esc_attr($social['slug']) ?>')" class="remove-icon-img"></span>
                </span>
                <span class="default-chaty-icon <?php echo (isset($value['fa_icon'])&&!empty($value['fa_icon']))?"has-fa-icon":"" ?> custom-icon-<?php echo esc_attr($social['slug']) ?> default_image_<?php echo esc_attr($social['slug']) ?>" >
                    <svg width="39" height="39" viewBox="0 0 39 39" fill="none" xmlns="http://www.w3.org/2000/svg">
                        <?php echo $svg_icon; ?>
                    </svg>
                    <span class="facustom-icon" style="background-color: <?php echo esc_attr($value['bg_color']) ?>"><i class="<?php echo esc_attr($value['fa_icon']) ?>"></i></span>
                </span>
            </div>

            <?php if($social['slug'] != 'Contact_Us') { ?>
                <!-- Social Media input  -->
                <?php if(($social['slug'] == "Whatsapp" || $channel_type == "Whatsapp") && !empty($value['value'])) {
                    $value['value'] = trim($value['value'], "+");
                    $value['value'] = "+".$value['value'];
                } ?>
                <div class="channels__input-box">
                    <input data-label="<?php echo esc_attr($social['title']) ?>" placeholder="<?php echo esc_attr($placeholder); ?>" type="text" class="channels__input custom-channel-<?php echo esc_attr__($channel_type) ?> <?php echo isset($social['attr'])?$social['attr']:"" ?>" name="cht_social_<?php echo esc_attr($social['slug']); ?>[value]" value="<?php echo esc_attr(wp_unslash($value['value'])); ?>" data-gramm_editor="false" id="channel_input_<?php echo esc_attr($social['slug']); ?>" />
                </div>
            <?php } ?>
            <div class="channels__device-box">
                <?php
                $slug =  esc_attr__($this->del_space($social['slug']));
                $slug = str_replace(' ', '_', $slug);
                $is_desktop = isset($value['is_desktop']) && $value['is_desktop'] == "checked" ? "checked" : '';
                $is_mobile = isset($value['is_mobile']) && $value['is_mobile'] == "checked" ? "checked" : '';
                ?>
                <!-- setting for desktop -->
                <label class="channels__view" for="<?php echo esc_attr($slug); ?>Desktop">
                    <input type="checkbox" id="<?php echo esc_attr($slug); ?>Desktop" class="channels__view-check js-chanel-icon js-chanel-desktop" data-type="<?php echo str_replace(' ', '_', strtolower(esc_attr__($this->del_space($social['slug'])))); ?>" name="cht_social_<?php echo esc_attr($social['slug']); ?>[is_desktop]" value="checked" data-gramm_editor="false" <?php echo esc_attr($is_desktop) ?> />
                    <span class="channels__view-txt">Desktop</label>
                </label>

                <!-- setting for mobile -->
                <label class="channels__view" for="<?php echo esc_attr($slug); ?>Mobile">
                    <input type="checkbox" id="<?php echo esc_attr($slug); ?>Mobile" class="channels__view-check js-chanel-icon js-chanel-mobile" data-type="<?php echo str_replace(' ', '_', strtolower(esc_attr__($this->del_space($social['slug'])))); ?>" name="cht_social_<?php echo esc_attr($social['slug']); ?>[is_mobile]" value="checked" data-gramm_editor="false" <?php echo esc_attr($is_mobile) ?> >
                    <span class="channels__view-txt">Mobile</span>
                </label>
            </div>

            <?php if($social['slug'] == 'Contact_Us') { ?>
                <div class="channels__input transparent"></div>
            <?php } ?>

            <?php
            $close_class = "active";
            if($social['slug'] == 'Contact_Us') {
                $setting_status = get_option("chaty_contact_us_setting");
                if($setting_status === false) {
                    $close_class = "";
                }
            }
            ?>


            <!-- button for advance setting -->
            <div class="chaty-settings <?php echo esc_attr($close_class) ?>" data-nonce="<?php echo wp_create_nonce($social['slug']."-settings") ?>" id="<?php echo esc_attr($social['slug']); ?>-close-btn" onclick="toggle_chaty_setting('<?php echo esc_attr($social['slug']); ?>')">
                <a href="javascript:;"><span class="dashicons dashicons-admin-generic"></span> Settings</a>
            </div>
            <?php if($social['slug'] != 'Contact_Us') { ?>

                <!-- example for social media -->
                <div class="input-example">
                    <?php echo esc_attr('For example', CHT_OPT); ?>:
                    <span class="inline-box channel-example">
                                                <?php if($social['slug'] == "Poptin") { ?>
                                                    <br/>
                                                <?php } ?>
                        <?php echo esc_attr($placeholder); ?>
                                            </span>
                </div>

                <!-- checking for extra help message for social media -->
                <div class="help-section">
                    <?php if((isset($social['help']) && !empty($social['help'])) || isset($social['help_link'])) { ?>
                        <div class="viber-help">
                            <?php if(isset($help_link) && !empty($help_link)) { ?>
                                <a class="help-link" href="<?php echo esc_url($help_link) ?>" target="_blank"><?php echo esc_attr($help_title); ?></a>
                            <?php } else if(isset($help_text) && !empty($help_text)) { ?>
                                <span class="help-text"><?php echo $help_text; ?></span>
                                <span class="help-title"><?php echo esc_attr($help_title); ?></span>
                            <?php } ?>
                        </div>
                    <?php } ?>
                </div>
            <?php } ?>
        </div>

        <?php if($social['slug'] == "Whatsapp" || $social['slug'] == "Link" || $social['slug'] == "Custom_Link" || $social['slug'] == "Custom_Link_3" || $social['slug'] == "Custom_Link_4" || $social['slug'] == "Custom_Link_5") { ?>
            <div class="Whatsapp-settings advanced-settings extra-chaty-settings">
                <?php $embedded_window = isset($value['embedded_window'])?$value['embedded_window']:"no"; ?>
                <div class="chaty-setting-col">
                    <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[embedded_window]" value="no" >
                    <label class="chaty-switch full-width chaty-embedded-window" for="whatsapp_embedded_window_<?php echo esc_attr($social['slug']); ?>">
                        <input type="checkbox" class="embedded_window-checkbox" name="cht_social_<?php echo esc_attr($social['slug']); ?>[embedded_window]" id="whatsapp_embedded_window_<?php echo esc_attr($social['slug']); ?>" value="yes" <?php checked($embedded_window, "yes") ?> >
                        <div class="chaty-slider round"></div>
                        WhatsApp Chat Popup &#128172;
                        <div class="html-tooltip top">
                            <span class="dashicons dashicons-editor-help"></span>
                            <span class="tooltip-text top">
                                                        Show an embedded WhatsApp window to your visitors with a welcome message. Your users can start typing their own message and start a conversation with you right away once they are forwarded to the WhatsApp app.
                                                        <img src="<?php echo esc_url(CHT_PLUGIN_URL) ?>/admin/assets/images/whatsapp-popup.gif" />
                                                    </span>
                        </div>
                    </label>
                </div>
                <!-- advance setting for Whatsapp -->
                <div class="whatsapp-welcome-message <?php echo ($embedded_window=="yes")?"active":"" ?>">
                    <div class="chaty-setting-col">
                        <label style="display: block; width: 100%" for="cht_social_embedded_message_<?php echo esc_attr($social['slug']); ?>">Welcome message</label>
                        <div class="full-width">
                            <div class="full-width">
                                <?php $unique_id = uniqid(); ?>
                                <?php $embedded_message = isset($value['embedded_message'])?$value['embedded_message']:esc_html__("How can I help you? :)", "chaty"); ?>
                                <textarea class="chaty-setting-textarea chaty-whatsapp-setting-textarea" data-id="<?php echo esc_attr($unique_id) ?>" id="cht_social_embedded_message_<?php echo esc_attr($unique_id) ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[embedded_message]" ><?php echo $embedded_message ?></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="chaty-setting-col">
                        <?php $is_default_open = isset($value['is_default_open'])?$value['is_default_open']:""; ?>
                        <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[is_default_open]" value="no" >
                        <label class="chaty-switch" for="whatsapp_default_open_embedded_window_<?php echo esc_attr($social['slug']); ?>">
                            <input type="checkbox" name="cht_social_<?php echo esc_attr($social['slug']); ?>[is_default_open]" id="whatsapp_default_open_embedded_window_<?php echo esc_attr($social['slug']); ?>" value="yes" <?php checked($is_default_open, "yes") ?> >
                            <div class="chaty-slider round"></div>
                            Open the window on load
                            <span class="icon label-tooltip" data-label="Open the WhatsApp chat popup on page load, after the user sends a message or closes the window, the window will stay closed to avoid disruption"><span class="dashicons dashicons-editor-help"></span></span>
                        </label>
                    </div>
                </div>
            </div>
        <?php } ?>

        <!-- advance setting fields: start -->
        <?php $class_name = !$this->is_pro()?"not-is-pro":""; ?>
        <div class="chaty-advance-settings <?php echo esc_attr($class_name); ?>" style="<?php echo (empty($close_class) && $social['slug'] == 'Contact_Us')?"display:block":""; ?>">
            <!-- Settings for custom icon and color -->
            <div class="chaty-setting-col">
                <label>Icon Appearance</label>
                <div>
                    <!-- input for custom color -->
                    <input type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[bg_color]" class="chaty-color-field" value="<?php echo esc_attr($value['bg_color']) ?>" />

                    <!-- button to upload custom image -->
                    <?php if($this->is_pro()) { ?>
                        <a onclick="upload_chaty_image('<?php echo esc_attr($social['slug']); ?>')" href="javascript:;" class="upload-chaty-icon"><span class="dashicons dashicons-upload"></span> Custom Image</a>

                        <!-- hidden input value for image -->
                        <input id="cht_social_image_<?php echo esc_attr($social['slug']); ?>" type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[image_id]" value="<?php echo esc_attr($imageId) ?>" />
                    <?php } else { ?>
                        <div class="pro-features upload-image">
                            <div class="pro-item">
                                <a target="_blank" href="<?php echo esc_url($this->getUpgradeMenuItemUrl());?>" class="upload-chaty-icon"><span class="dashicons dashicons-upload"></span> Custom Image</a>
                            </div>
                            <div class="pro-button">
                                <a target="_blank" href="<?php echo esc_url($this->getUpgradeMenuItemUrl());?>"><?php echo esc_attr('Upgrade to Pro', CHT_OPT);?></a>
                            </div>
                        </div>
                    <?php } ?>
                </div>
            </div>
            <div class="clear clearfix"></div>

            <?php if($social['slug'] == "Link" || $social['slug'] == "Custom_Link" || $social['slug'] == "Custom_Link_3" || $social['slug'] == "4" || $social['slug'] == "Custom_Link_5") {
                $channel_type = "";
                if(isset($value['channel_type'])) {
                    $channel_type = esc_attr__(wp_unslash($value['channel_type']));
                }
                $socials = $this->socials;
                ?>
                <div class="chaty-setting-col">
                    <label>Channel type</label>
                    <div>
                        <!-- input for custom title -->
                        <select class="channel-select-input" name="cht_social_<?php echo esc_attr($social['slug']); ?>[channel_type]" value="<?php echo esc_attr($value['channel_type']) ?>">
                            <option value="<?php echo esc_attr($social['slug']) ?>">Custom channel</option>
                            <?php foreach ($socials as $social_icon) {
                                $selected = ($social_icon['slug'] == $channel_type)?"selected":"";
                                if ($social_icon['slug'] != 'Custom_Link' && $social_icon['slug'] != 'Custom_Link_3' && $social_icon['slug'] != 'Custom_Link_4' && $social_icon['slug'] != 'Custom_Link_5' && $social_icon['slug'] != 'Contact_Us' && $social_icon['slug'] != 'Link') { ?>
                                    <option <?php echo esc_attr($selected) ?> value="<?php echo esc_attr($social_icon['slug']) ?>"><?php echo esc_attr($social_icon['title']) ?></option>
                                <?php }
                            }?>
                        </select>
                    </div>
                </div>
                <div class="clear clearfix"></div>
            <?php } ?>

            <div class="chaty-setting-col">
                <label>On Hover Text</label>
                <div>
                    <input type="text" class="chaty-title" name="cht_social_<?php echo esc_attr($social['slug']); ?>[title]" value="<?php echo esc_attr($value['title']) ?>">
                </div>
            </div>
            <div class="clear clearfix"></div>

            <div class="Contact_Us-settings advanced-settings">
                <div class="clear clearfix"></div>
                <div class="chaty-setting-col">
                    <label>Contact Form Title</label>
                    <div>
                        <?php $contact_form_title = isset($value['contact_form_title'])?$value['contact_form_title']:esc_html__("Contact Us", "chaty"); ?>
                        <input id="cht_social_message_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[contact_form_title]" value="<?php echo esc_attr($contact_form_title) ?>" >
                    </div>
                </div>
                <?php
                $fields = array(
                    'name' => array(
                        'title' => "Name",
                        'placeholder' => "Enter your name",
                        'is_required' => 1,
                        'type' => 'input',
                        'is_enabled' => 1
                    ),
                    'email' => array(
                        'title' => "Email",
                        'placeholder' => "Enter your email address",
                        'is_required' => 1,
                        'type' => 'email',
                        'is_enabled' => 1
                    ),
                    'phone' => array(
                        'title' => "Phone",
                        'placeholder' => "Enter your phone number",
                        'is_required' => 1,
                        'type' => 'input',
                        'is_enabled' => 1
                    ),
                    'message' => array(
                        'title' => "Message",
                        'placeholder' => "Enter your message",
                        'is_required' => 1,
                        'type' => 'textarea',
                        'is_enabled' => 1
                    )
                );
                echo '<div class="form-field-setting-col">';
                foreach ($fields as $label => $field) {
                    $saved_value = isset($value[$label])?$value[$label]:array();
                    $field_value = array(
                        'is_active' => (isset($saved_value['is_active']))?$saved_value['is_active']:'yes',
                        'is_required' => (isset($saved_value['is_required']))?$saved_value['is_required']:'yes',
                        'placeholder' => (isset($saved_value['placeholder']))?$saved_value['placeholder']:$field['placeholder'],
                    );
                    ?>
                    <div class="field-setting-col">
                        <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[<?php echo $label ?>][is_active]" value="no">
                        <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[<?php echo $label ?>][is_required]" value="no">

                        <div class="left-section">
                            <label class="chaty-switch chaty-switch-toggle" for="field_for_<?php echo esc_attr($social['slug']); ?>_<?php echo $label ?>">
                                <input type="checkbox" class="chaty-field-setting" name="cht_social_<?php echo esc_attr($social['slug']); ?>[<?php echo $label ?>][is_active]" id="field_for_<?php echo esc_attr($social['slug']); ?>_<?php echo $label ?>" value="yes" <?php checked($field_value['is_active'], "yes") ?>>
                                <div class="chaty-slider round"></div>

                                <?php echo $field['title'] ?>
                            </label>
                        </div>
                        <div class="right-section">
                            <div class="field-settings <?php echo ($field_value['is_active']=="yes")?"active":"" ?>">
                                <div class="inline-block">
                                    <label class="inline-block" for="field_required_for_<?php echo esc_attr($social['slug']); ?>_<?php echo $label ?>">Required?</label>
                                    <div class="inline-block">
                                        <label class="chaty-switch" for="field_required_for_<?php echo esc_attr($social['slug']); ?>_<?php echo $label ?>">
                                            <input type="checkbox" name="cht_social_<?php echo esc_attr($social['slug']); ?>[<?php echo $label ?>][is_required]" id="field_required_for_<?php echo esc_attr($social['slug']); ?>_<?php echo $label ?>" value="yes" <?php checked($field_value['is_required'], "yes") ?>>
                                            <div class="chaty-slider round"></div>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="clear clearfix"></div>
                        <div class="field-settings <?php echo ($field_value['is_active']=="yes")?"active":"" ?>">
                            <div class="chaty-setting-col">
                                <label for="placeholder_for_<?php echo esc_attr($social['slug']); ?>_<?php echo $label ?>">Placeholder text</label>
                                <div>
                                    <input id="placeholder_for_<?php echo esc_attr($social['slug']); ?>_<?php echo $label ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[<?php echo $label ?>][placeholder]" value="<?php echo esc_attr($field_value['placeholder']) ?>" >
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php if($label != 'message') { ?>
                        <div class="chaty-separator"></div>
                    <?php } ?>
                <?php }
                echo '</div>'; ?>
                <div class="form-field-setting-col">
                    <div class="form-field-title">Submit Button</div>
                    <div class="color-box">
                        <div class="clr-setting">
                            <?php $field_value = isset($value['button_text_color'])?$value['button_text_color']:"#ffffff" ?>
                            <div class="chaty-setting-col">
                                <label for="button_text_color_for_<?php echo esc_attr($social['slug']); ?>">Text color</label>
                                <div>
                                    <input id="button_text_color_for_<?php echo esc_attr($social['slug']); ?>" class="chaty-color-field button-color" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[button_text_color]" value="<?php echo esc_attr($field_value); ?>" >
                                </div>
                            </div>
                        </div>
                        <?php $field_value = isset($value['button_bg_color'])?$value['button_bg_color']:"#A886CD" ?>
                        <div class="clr-setting">
                            <div class="chaty-setting-col">
                                <label for="button_bg_color_for_<?php echo esc_attr($social['slug']); ?>">Background color</label>
                                <div>
                                    <input id="button_bg_color_for_<?php echo esc_attr($social['slug']); ?>" class="chaty-color-field button-color" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[button_bg_color]" value="<?php echo esc_attr($field_value); ?>" >
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php $field_value = isset($value['button_text'])?$value['button_text']:"Chat" ?>
                    <div class="chaty-setting-col">
                        <label for="button_text_for_<?php echo esc_attr($social['slug']); ?>">Button text</label>
                        <div>
                            <input id="button_text_for_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[button_text]" value="<?php echo esc_attr($field_value); ?>" >
                        </div>
                    </div>
                    <?php $field_value = isset($value['thanks_message'])?$value['thanks_message']:"Your message was sent successfully" ?>
                    <div class="chaty-setting-col">
                        <label for="thanks_message_for_<?php echo esc_attr($social['slug']); ?>">Thank you message</label>
                        <div>
                            <input id="thanks_message_for_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[thanks_message]" value="<?php echo esc_attr($field_value); ?>" >
                        </div>
                    </div>
                    <div class="chaty-separator"></div>
                    <?php $field_value = isset($value['redirect_action'])?$value['redirect_action']:"no" ?>
                    <div class="chaty-setting-col">
                        <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[redirect_action]" value="no" >
                        <label class="chaty-switch full-width" for="redirect_action_<?php echo esc_attr($social['slug']); ?>">
                            <input type="checkbox" class="chaty-redirect-setting" name="cht_social_<?php echo esc_attr($social['slug']); ?>[redirect_action]" id="redirect_action_<?php echo esc_attr($social['slug']); ?>" value="yes" <?php checked($field_value, "yes") ?> >
                            <div class="chaty-slider round"></div>
                            Redirect visitors after submission
                        </label>
                    </div>
                    <div class="redirect_action-settings <?php echo ($field_value == "yes")?"active":"" ?>">
                        <?php $field_value = isset($value['redirect_link'])?$value['redirect_link']:"" ?>
                        <div class="chaty-setting-col">
                            <label for="redirect_link_for_<?php echo esc_attr($social['slug']); ?>">Redirect link</label>
                            <div>
                                <input id="redirect_link_for_<?php echo esc_attr($social['slug']); ?>" placeholder="<?php echo site_url("/") ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[redirect_link]" value="<?php echo esc_attr($field_value); ?>" >
                            </div>
                        </div>
                        <?php $field_value = isset($value['link_in_new_tab'])?$value['link_in_new_tab']:"no" ?>
                        <div class="chaty-setting-col">
                            <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[link_in_new_tab]" value="no" >
                            <label class="chaty-switch full-width" for="link_in_new_tab_<?php echo esc_attr($social['slug']); ?>">
                                <input type="checkbox" class="chaty-field-setting" name="cht_social_<?php echo esc_attr($social['slug']); ?>[link_in_new_tab]" id="link_in_new_tab_<?php echo esc_attr($social['slug']); ?>" value="yes" <?php checked($field_value, "yes") ?> >
                                <div class="chaty-slider round"></div>
                                Open in a new tab
                            </label>
                        </div>
                    </div>
                    <div class="chaty-separator"></div>
                    <?php $field_value = isset($value['close_form_after'])?$value['close_form_after']:"no" ?>
                    <div class="chaty-setting-col">
                        <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[close_form_after]" value="no" >
                        <label class="chaty-switch full-width" for="close_form_after_<?php echo esc_attr($social['slug']); ?>">
                            <input type="checkbox" class="chaty-close_form_after-setting" name="cht_social_<?php echo esc_attr($social['slug']); ?>[close_form_after]" id="close_form_after_<?php echo esc_attr($social['slug']); ?>" value="yes" <?php checked($field_value, "yes") ?> >
                            <div class="chaty-slider round"></div>
                            Close form automatically after submission
                            <span class="icon label-tooltip inline-message" data-label="Close the form automatically after a few seconds based on your choice"><span class="dashicons dashicons-editor-help"></span></span>
                        </label>
                    </div>
                    <div class="close_form_after-settings <?php echo ($field_value == "yes")?"active":"" ?>">
                        <?php $field_value = isset($value['close_form_after_seconds'])?$value['close_form_after_seconds']:"3" ?>
                        <div class="chaty-setting-col">
                            <label for="close_form_after_seconds_<?php echo esc_attr($social['slug']); ?>">Close after (Seconds)</label>
                            <div>
                                <input id="close_form_after_seconds_<?php echo esc_attr($social['slug']); ?>" type="number" name="cht_social_<?php echo esc_attr($social['slug']); ?>[close_form_after_seconds]" value="<?php echo esc_attr($field_value); ?>" >
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-field-setting-col no-margin">
                    <input type="hidden" value="no" name="cht_social_<?php echo esc_attr($social['slug']); ?>[send_leads_in_email]" >
                    <input type="hidden" value="yes" name="cht_social_<?php echo esc_attr($social['slug']); ?>[save_leads_locally]" >
                    <?php $field_value = isset($val['save_leads_locally'])?$val['save_leads_locally']:"yes" ?>
                    <div class="chaty-setting-col">
                        <label for="save_leads_locally_<?php echo esc_attr($social['slug']); ?>" class="full-width chaty-switch">
                            <input type="checkbox" disabled id="save_leads_locally_<?php echo esc_attr($social['slug']); ?>" value="yes" name="cht_social_<?php echo esc_attr($social['slug']); ?>[save_leads_locally]" <?php checked($field_value, "yes") ?> >
                            <div class="chaty-slider round"></div>
                            Save leads to the local database
                            <div class="html-tooltip top no-position">
                                <span class="dashicons dashicons-editor-help"></span>
                                <span class="tooltip-text top">Your leads will be saved in your local database, you'll be able to find them <a target="_blank" href="<?php echo admin_url("admin.php?page=chaty-contact-form-feed") ?>">here</a></span>
                            </div>
                        </label>
                    </div>
                    <?php $field_value = isset($value['send_leads_in_email'])?$value['send_leads_in_email']:"no" ?>
                    <div class="chaty-setting-col">
                        <label for="save_leads_to_email_<?php echo esc_attr($social['slug']); ?>" class="email-setting full-width chaty-switch">
                            <input class="email-setting-field" disabled type="checkbox" id="save_leads_to_email_<?php echo esc_attr($social['slug']); ?>" value="yes" name="cht_social_<?php echo esc_attr($social['slug']); ?>[send_leads_in_email]" >
                            <div class="chaty-slider round"></div>
                            Send leads to your email
                            <span class="icon label-tooltip" data-label="Get your leads by email, whenever you get a new email you'll get an email notification"><span class="dashicons dashicons-editor-help"></span></span>
                            <a target="_blank" href="<?php echo esc_url($this->getUpgradeMenuItemUrl());?>">(<?php echo esc_attr('Upgrade to Pro', CHT_OPT);?>)</a>
                        </label>
                    </div>
                    <div class="email-settings <?php echo ($field_value == "yes")?"active":"" ?>">
                        <div class="chaty-setting-col">
                            <label for="email_for_<?php echo esc_attr($social['slug']); ?>">Email address</label>
                            <div>
                                <?php $field_value = isset($value['email_address'])?$value['email_address']:"" ?>
                                <input id="email_for_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[email_address]" value="<?php echo esc_attr($field_value); ?>" >
                            </div>
                        </div>
                        <div class="chaty-setting-col">
                            <label for="sender_name_for_<?php echo esc_attr($social['slug']); ?>">Sender's name</label>
                            <div>
                                <?php $field_value = isset($value['sender_name'])?$value['sender_name']:"" ?>
                                <input id="sender_name_for_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[sender_name]" value="<?php echo esc_attr($field_value); ?>" >
                            </div>
                        </div>
                        <div class="chaty-setting-col">
                            <label for="email_subject_for_<?php echo esc_attr($social['slug']); ?>">Email subject</label>
                            <div>
                                <?php $field_value = isset($value['email_subject'])?$value['email_subject']:"New lead from Chaty - {name} - {date} {hour}" ?>
                                <input id="email_subject_for_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[email_subject]" value="<?php echo esc_attr($field_value); ?>" >
                                <div class="mail-merge-tags"><span>{name}</span><span>{phone}</span><span>{email}</span><span>{date}</span><span>{hour}</span></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <?php if($this->is_pro()) { ?>
                <div class="clear clearfix"></div>
                <div class="Whatsapp-settings advanced-settings">
                    <!-- advance setting for Whatsapp -->
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label>Pre Set Message <span class="icon label-tooltip inline-tooltip" data-label="Add your own pre-set message that's automatically added to the user's message. You can also use merge tags and add the URL or the title of the current visitor's page. E.g. you can add the current URL of a product to the message so you know which product the visitor is talking about when the visitor messages you"><span class="dashicons dashicons-editor-help"></span></span></label>
                        <div>
                            <?php $pre_set_message = isset($value['pre_set_message'])?$value['pre_set_message']:""; ?>
                            <input id="cht_social_message_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[pre_set_message]" value="<?php echo esc_attr($pre_set_message) ?>" >
                            <span class="supported-tags"><span class="icon label-tooltip support-tooltip" data-label="{title} tag grabs the page title of the webpage">{title}</span> and  <span class="icon label-tooltip support-tooltip" data-label="{url} tag grabs the URL of the page">{url}</span> tags are supported</span>
                        </div>
                    </div>
                </div>
                <div class="Email-settings advanced-settings">
                    <!-- advance setting for Email -->
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label>Mail Subject <span class="icon label-tooltip inline-tooltip" data-label="Add your own pre-set message that's automatically added to the user's message. You can also use merge tags and add the URL or the title of the current visitor's page. E.g. you can add the current URL of a product to the message so you know which product the visitor is talking about when the visitor messages you"><span class="dashicons dashicons-editor-help"></span></span></label>
                        <div>
                            <?php $mail_subject = isset($value['mail_subject'])?$value['mail_subject']:""; ?>
                            <input id="cht_social_message_<?php echo esc_attr($social['slug']); ?>" type="text" name="cht_social_<?php echo esc_attr($social['slug']); ?>[mail_subject]" value="<?php echo esc_attr($mail_subject) ?>" >
                            <span class="supported-tags"><span class="icon label-tooltip support-tooltip" data-label="{title} tag grabs the page title of the webpage">{title}</span> and  <span class="icon label-tooltip support-tooltip" data-label="{url} tag grabs the URL of the page">{url}</span> tags are supported</span>
                        </div>
                    </div>
                </div>
                <div class="WeChat-settings advanced-settings">
                    <!-- advance setting for WeChat -->
                    <?php
                    $qr_code = isset($value['qr_code'])?$value['qr_code']:"";                               // Initialize QR code value if not exists. 2.1.0 change
                    $imageUrl = "";
                    $status = 0;
                    if($qr_code != "") {
                        $imageUrl = wp_get_attachment_image_src($qr_code, "full")[0];                       // get custom Image URL if exists
                    }
                    if($imageUrl == "") {
                        $imageUrl = plugin_dir_url("")."chaty/admin/assets/images/chaty-default.png";   // Initialize with default image URL if URL is not exists
                    } else {
                        $status = 1;
                    }
                    ?>
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label>Upload QR Code</label>
                        <div>
                            <!-- Button to upload QR Code image -->
                            <a class="cht-upload-image <?php echo esc_attr(($status)?"active":"") ?>" id="upload_qr_code" href="javascript:;" onclick="upload_qr_code('<?php echo esc_attr($social['slug']); ?>')">
                                <img id="cht_social_image_src_<?php echo esc_attr($social['slug']); ?>" src="<?php echo esc_url($imageUrl) ?>" alt="<?php echo esc_attr($value['title']) ?>">
                                <span class="dashicons dashicons-upload"></span>
                            </a>

                            <!-- Button to remove QR Code image -->
                            <a href="javascript:;" class="remove-qr-code remove-qr-code-<?php echo esc_attr($social['slug']); ?> <?php echo esc_attr(($status)?"active":"") ?>" onclick="remove_qr_code('<?php echo esc_attr($social['slug']); ?>')"><span class="dashicons dashicons-no-alt"></span></a>

                            <!-- input hidden field for QR Code -->
                            <input id="upload_qr_code_val-<?php echo esc_attr($social['slug']); ?>" type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[qr_code]" value="<?php echo esc_attr($qr_code) ?>" >
                        </div>
                    </div>
                </div>
                <div class="Link-settings Custom_Link-settings Custom_Link_3-settings Custom_Link_4-settings Custom_Link_5-settings advanced-settings">
                    <?php $is_checked = (!isset($value['new_window']) || $value['new_window'] == 1)?1:0; ?>
                    <!-- Advance setting for Custom Link -->
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label >Open In a New Tab</label>
                        <div>
                            <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[new_window]" value="0" >
                            <label class="channels__view" for="cht_social_window_<?php echo esc_attr($social['slug']); ?>">
                                <input id="cht_social_window_<?php echo esc_attr($social['slug']); ?>" type="checkbox" class="channels__view-check" name="cht_social_<?php echo esc_attr($social['slug']); ?>[new_window]" value="1" <?php checked($is_checked, 1) ?> >
                                <span class="channels__view-txt">&nbsp;</span>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="Linkedin-settings advanced-settings">
                    <?php $is_checked = isset($value['link_type'])?$value['link_type']:"personal"; ?>
                    <!-- Advance setting for Custom Link -->
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label >LinkedIn</label>
                        <div>
                            <label>
                                <input type="radio" <?php checked($is_checked, "personal") ?> name="cht_social_<?php echo esc_attr($social['slug']); ?>[link_type]" value="personal">
                                Personal
                            </label>
                            <label>
                                <input type="radio" <?php checked($is_checked, "company") ?> name="cht_social_<?php echo esc_attr($social['slug']); ?>[link_type]" value="company">
                                Company
                            </label>
                        </div>
                    </div>
                </div>
            <?php } else { ?>
                <div class="clear clearfix"></div>
                <div class="Whatsapp-settings advanced-settings">
                    <?php $pre_set_message = isset($value['pre_set_message'])?$value['pre_set_message']:""; ?>
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label>Pre Set Message <span class="icon label-tooltip inline-tooltip" data-label="Add your own pre-set message that's automatically added to the user's message. You can also use merge tags and add the URL or the title of the current visitor's page. E.g. you can add the current URL of a product to the message so you know which product the visitor is talking about when the visitor messages you"><span class="dashicons dashicons-editor-help"></span></span></label>
                        <div>
                            <div class="pro-features">
                                <div class="pro-item">
                                    <div class="pre-message-whatsapp">
                                        <input disabled id="cht_social_message_<?php echo esc_attr($social['slug']); ?>" type="text" name="" value="<?php echo esc_attr($pre_set_message) ?>" >
                                        <span class="supported-tags"><span class="icon label-tooltip support-tooltip" data-label="{title} tag grabs the page title of the webpage">{title}</span> and  <span class="icon label-tooltip support-tooltip" data-label="{url} tag grabs the URL of the page">{url}</span> tags are supported</span>
                                        <button data-button="cht_social_message_<?php echo esc_attr($social['slug']); ?>" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0m0 22C6.486 22 2 17.514 2 12S6.486 2 12 2s10 4.486 10 10-4.486 10-10 10"></path><path d="M8 7a2 2 0 1 0-.001 3.999A2 2 0 0 0 8 7M16 7a2 2 0 1 0-.001 3.999A2 2 0 0 0 16 7M15.232 15c-.693 1.195-1.87 2-3.349 2-1.477 0-2.655-.805-3.347-2H15m3-2H6a6 6 0 1 0 12 0"></path></svg></button>
                                    </div>
                                </div>
                                <div class="pro-button">
                                    <a target="_blank" href="<?php echo esc_url($this->getUpgradeMenuItemUrl());?>"><?php echo esc_attr('Upgrade to Pro', CHT_OPT);?></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="Email-settings advanced-settings">
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label>Mail Subject <span class="icon label-tooltip inline-tooltip" data-label="Add your own pre-set message that's automatically added to the user's message. You can also use merge tags and add the URL or the title of the current visitor's page. E.g. you can add the current URL of a product to the message so you know which product the visitor is talking about when the visitor messages you"><span class="dashicons dashicons-editor-help"></span></span></label>
                        <div>
                            <div class="pro-features">
                                <div class="pro-item">
                                    <input disabled id="cht_social_message_<?php echo esc_attr($social['slug']); ?>" type="text" name="" value="" >
                                    <span class="supported-tags"><span class="icon label-tooltip support-tooltip" data-label="{title} tag grabs the page title of the webpage">{title}</span> and  <span class="icon label-tooltip support-tooltip" data-label="{url} tag grabs the URL of the page">{url}</span> tags are supported</span>
                                </div>
                                <div class="pro-button">
                                    <a target="_blank" href="<?php echo esc_url($this->getUpgradeMenuItemUrl());?>"><?php echo esc_attr('Upgrade to Pro', CHT_OPT);?></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="WeChat-settings advanced-settings">
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label>Upload QR Code</label>
                        <div>
                            <a target="_blank" class="cht-upload-image-pro" id="upload_qr_code" href="<?php echo esc_url($this->getUpgradeMenuItemUrl());?>" >
                                <span class="dashicons dashicons-upload"></span>
                            </a>
                            <a target="_blank" href="<?php echo esc_url($this->getUpgradeMenuItemUrl());?>"><?php echo esc_attr('Upgrade to Pro', CHT_OPT);?></a>
                        </div>
                    </div>
                </div>
                <div class="Link-settings Custom_Link-settings Custom_Link_3-settings Custom_Link_4-settings Custom_Link_5-settings advanced-settings">
                    <?php $is_checked = 1; ?>
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label >Open In a New Tab</label>
                        <div>
                            <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[new_window]" value="0" >
                            <label class="channels__view" for="cht_social_window_<?php echo esc_attr($social['slug']); ?>">
                                <input id="cht_social_window_<?php echo esc_attr($social['slug']); ?>" type="checkbox" class="channels__view-check" name="cht_social_<?php echo esc_attr($social['slug']); ?>[new_window]" value="1" checked >
                                <span class="channels__view-txt">&nbsp;</span>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="Linkedin-settings advanced-settings">
                    <?php $is_checked = "personal"; ?>
                    <!-- Advance setting for Custom Link -->
                    <div class="clear clearfix"></div>
                    <div class="chaty-setting-col">
                        <label >LinkedIn</label>
                        <div>
                            <label>
                                <input type="radio" <?php checked($is_checked, "personal") ?> name="cht_social_<?php echo esc_attr($social['slug']); ?>[link_type]" value="personal">
                                Personal
                            </label>
                            <label>
                                <input type="radio" <?php checked($is_checked, "company") ?> name="cht_social_<?php echo esc_attr($social['slug']); ?>[link_type]" value="company">
                                Company
                            </label>
                        </div>
                    </div>
                </div>
            <?php } ?>

            <?php $use_whatsapp_web = isset($value['use_whatsapp_web'])?$value['use_whatsapp_web']:"yes"; ?>
            <div class="Whatsapp-settings advanced-settings">
                <div class="clear clearfix"></div>
                <div class="chaty-setting-col">
                    <label>Whatsapp Web</label>
                    <input type="hidden" name="cht_social_<?php echo esc_attr($social['slug']); ?>[use_whatsapp_web]" value="no" />
                    <div>
                        <div class="checkbox">
                            <label for="cht_social_<?php echo esc_attr($social['slug']); ?>_use_whatsapp_web" class="chaty-checkbox">
                                <input class="sr-only" type="checkbox" id="cht_social_<?php echo esc_attr($social['slug']); ?>_use_whatsapp_web" name="cht_social_<?php echo esc_attr($social['slug']); ?>[use_whatsapp_web]" value="yes" <?php echo checked($use_whatsapp_web, "yes") ?> />
                                <span></span>
                                Use Whatsapp Web directly on desktop
                            </label>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- advance setting fields: end -->


        <!-- remove social media setting button: start -->
        <button type="button" class="btn-cancel" data-social="<?php echo esc_attr($social['slug']); ?>">
            <svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg">
                <rect width="15.6301" height="2.24494" rx="1.12247" transform="translate(2.26764 0.0615997) rotate(45)" fill="white"/>
                <rect width="15.6301" height="2.24494" rx="1.12247" transform="translate(13.3198 1.649) rotate(135)" fill="white"/>
            </svg>
        </button>
        <!-- remove social media setting button: end -->
    </div>
</li>
<!-- Social media setting box: end -->