<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/* @var $block \Magento\Wishlist\Block\Link */
?>
<?php
$label = $block->getData('label')?__($block->getData('label')):__($block->getLabel());
$isLoggedIn = \Magento\Framework\App\ObjectManager::getInstance()->create('Magento\Customer\Model\Session')->isLoggedIn();
$helper = $this->helper('Codazon\ThemeLayoutPro\Helper\Data');
$displayStyle = $this->getData('display_style')?:($helper->getHeaderWishlistStyle()?:'dropdown');
$uniqid = uniqid();
?>
<!-- link style 02 -->
<?php if ($isLoggedIn) : ?>
    <?php /* Logged in */ ?>
    <?php if ($displayStyle == 'popup') : ?>
    <li class="link wishlist" data-bind="scope: 'wishlist'">
        <a id="top-wishlist" href="javascript:void(0)" data-cdzpopuptrigger="wishlist-popup" >
            <span class="text-underlink"><?= __('Welcome') ?></span>
            <span class="text-uppercase">
                <?php echo $block->escapeHtml($label) ?>
                <!-- ko if: wishlist().counter -->
                <span data-bind="text: wishlist().counter.replace(/\D/g,'')" class="counter qty"></span>
                <!-- /ko -->
            </span>
        </a>
        <div style="display:none;">
            <div class="md-dialog-container wishlist-popup" data-cdzpopup id="wishlist-popup">
                <div class="md-dialog no-min-height">
                <?php echo $this->getBlockHtml('wishlist.minilist'); ?>
                </div>
            </div>
        </div>
    </li>
    <?php elseif ($displayStyle == 'simple_link') : ?>
    <li class="link wishlist" data-bind="scope: 'wishlist'" ng-controller="UtilitiesPanelCtrl as ctrl">
        <a <?php echo $block->getLinkAttributes() ?>>
            <span class="text-underlink"><?= __('Welcome') ?></span>
            <span class="text-uppercase">
                <?php echo $block->escapeHtml($label) ?> 
                <!-- ko if: wishlist().counter -->
                (<span data-bind="text: wishlist().counter" class="counter qty"></span>)
                <!-- /ko -->
            </span>
        </a>
    </li>
    <?php elseif ($displayStyle == 'sidebar') : ?>
    <li class="link wishlist" ng-controller="UtilitiesPanelCtrl as ctrl">
        <a id="top-wishlist" data-bind="scope: 'wishlist'" href="javascript:;" data-sidebartrigger='{"side": "right", "section":"utilies-wishlist"}'>
            <span class="text-underlink"><?= __('Welcome') ?></span>
            <span class="text-uppercase">
                <?php echo $block->escapeHtml($label) ?>
                <!-- ko if: wishlist().counter -->
                <span data-bind="text: wishlist().counter.replace(/\D/g,'')" class="counter qty"></span>
                <!-- /ko -->
            </span>
        </a>
    </li>
    <?php else : /* dropdown */ ?>
    <li class="link wishlist" data-bind="scope: 'wishlist'">
        <div class="cdz-dropdown" data-role="cdz-dropdown">
            <a id="top-wishlist" data-role="cdz-dd-trigger" data-bind="scope: 'wishlist'" href="javascript:;" >
                <span class="text-underlink"><?= __('Welcome') ?></span>
                <span class="text-uppercase">
                    <?php echo $block->escapeHtml($label) ?>
                    <!-- ko if: wishlist().counter -->
                    <span data-bind="text: wishlist().counter.replace(/\D/g,'')" class="counter qty"></span>
                    <!-- /ko -->
                </span>
            </a>
            <div class="cdz-dd-content wl-drop-menu" data-role="cdz-dd-content">
                <div class="cdz-dd-content-inner nice-scroll">
                    <?php echo $this->getBlockHtml('wishlist.minilist'); ?>
                </div>
            </div>
        </div>
    </li>
    <?php endif ?>
<?php else : ?>
    <?php /* No logged in */ ?>
    <?php if ($displayStyle == 'popup') : ?>
    <li class="link wishlist" data-bind="scope: 'wishlist'">
        <a id="top-wishlist" href="javascript:void(0)" data-cdzpopuptrigger="<?php echo $block->getData('guest_template_id'); ?>" >
            <span class="text-underlink"><?= __('Welcome') ?></span>
            <span class="text-uppercase"><?php echo $block->escapeHtml($label) ?></span>
        </a>
        <div style="display:none;">
            <?php echo $this->getBlockHtml('wishlist-login-popup'); ?>
        </div>
    </li>
    <?php elseif ($displayStyle == 'simple_link') : ?>
    <li class="link wishlist" data-bind="scope: 'wishlist'">
        <a <?php echo $block->getLinkAttributes() ?>>
            <span class="text-underlink"><?= __('Welcome') ?></span>
            <span class="text-uppercase">
                <?php echo $block->escapeHtml($label) ?> 
                <!-- ko if: wishlist().counter -->
                (<span data-bind="text: wishlist().counter" class="counter qty"></span>)
                <!-- /ko -->
            </span>
        </a>
    </li>
    <?php elseif ($displayStyle == 'sidebar') : ?>
    <li class="link wishlist">
        <a id="top-wishlist" data-bind="scope: 'wishlist'" href="javascript:;" data-sidebartrigger='{"side": "right", "section":"utilies-wishlist"}'>
            <span class="text-underlink"><?= __('Welcome') ?></span>
            <span class="text-uppercase">
                <?php echo $block->escapeHtml($label) ?>
            </span>
        </a>
    </li>
    <?php else : ?>
    <li class="link wishlist">
        <div class="cdz-dropdown" data-role="cdz-dropdown">
            <a class="cdz-dd-trigger" data-role="cdz-dd-trigger" data-bind="scope: 'wishlist'" href="javascript:void(0)" id="top-wishlist">
                <span class="text-underlink"><?= __('Welcome') ?></span>
                <span class="text-uppercase">
                    <?php echo $block->escapeHtml($label) ?>
                </span>
            </a>
            <div class="cdz-dd-content wl-drop-menu" data-role="cdz-dd-content">
                <div class="cdz-dd-content-inner nice-scroll">
                    <div class="mini-list">
                        <div class="block-top">
                            <div class="block-title">
                                <strong><?php echo __('Please login first'); ?></strong>
                            </div>
                        </div>
                        <div class="block-content"><?php echo $this->getBlockHtml('wishlist-login-dropdown'); ?></div>
                    </div>
                </div>
            </div>
        </div>
    </li>
    <?php endif ?>
<?php endif ?>

<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wishlist": {
                        "component": "Magento_Wishlist/js/view/wishlist"
                    }
                }
            }
        }
    }
</script>