+ function ( LHWidget, widgetContext ) {

    'use strict';

    var $ = widgetContext.LHDOMElements

    function SmartofferDesktop( ) {
        LHWidget.apply( this, arguments )
    }

    SmartofferDesktop.prototype = Object.create( LHWidget.prototype )
    SmartofferDesktop.prototype.constructor = SmartofferDesktop

    SmartofferDesktop.prototype.start = function ( ) {

        var self = this

        this.animationEvent = $.whichAnimationEvent( )

        $.saveNames = widgetContext[ 'names' ]

        this.visibleContainer = $.getElement( '#lh_desktop_smartoffer', this.widgetContainer )

        this.js = this.param.js
        this.css = this.param.css
        this.html = this.param.html

        this.HIDDEN_CLASS = $.name( 'display_none' )
        this.INVISIBLE_CLASS = $.name( 'visibility_none' )
        this.SUBMIT_ACTIVE_CLASS = $.name( 'widget--submit-active' )

        this.regexTemplates = {
            'email': /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
            'tel': /^((\+7|7|8)+([0-9]){10})$/gm,
        }

        this.additionalFields = $.getElementsByClass('additional--widget--input')
        this.additionalFieldsError = $.getElementsByClass('additional_fields_error')

        this.isAgreement = this.html[ 'agreement_text' ]
        this.hide_agreement = this.js['hide_agreement'] == 'true' ? true : false
        this.agreementText = $.getElement( '#agreement_text' )
        this.agreement_wrapper = $.getElement( '.agreement' )
        this.agreementCheckbox = $.getElement('.lh-smartoffer-agreement-val')
        this.agreement_checkbox_is_checked_by_default = this.js['agreement_checkbox_is_checked_by_default'] === 'true' ? true : false

        if (this.agreementCheckbox) {
            this.agreementCheckbox.checked = this.agreement_checkbox_is_checked_by_default
        }

        this.html['ads_agreement_link_url'] = this.js['ads_agreement_link_url']
        this.html['ads_agreement_link_label'] = this.js['ads_agreement_link_label']
        this.isAdsAgreement = this.html[ 'ads_agreement' ]
        this.hide_ads_agreement = this.js['hide_ads_agreement'] == 'true' ? true : false
        this.adsAgreementText = $.getElement( '#ads_agreement_text' )
        this.adsAgreementCheckbox = $.getElement('.lh-smartoffer-ads-agreement-val')
        this.ads_agreement_checkbox_is_checked_by_default = this.js['ads_agreement_checkbox_is_checked_by_default'] === 'true' ? true : false

        if (this.adsAgreementCheckbox) {
            this.adsAgreementCheckbox.checked = this.ads_agreement_checkbox_is_checked_by_default
        }

        this.timer3s = null
        this.timer10s = null

        if ( this.isAgreement && this.agreementText ) {
            var agreement_links = this.agreementText.getElementsByTagName( 'a' )
            for ( var i = 0; i < agreement_links.length; i++ ) {
                if ( !agreement_links[ i ].getAttribute( 'target' ) ) agreement_links[ i ].setAttribute( 'target', '_blank' )
            }
        }

        this.lh_wi_points = $.getElement( '#lh_wi_points' )

        this.lh_point_of_capture = $.getElement( '#lh_point_of_capture' )
        this.lh_poc_image = $.getElement( '.lh_poc_image' )
        this.lh_poc_tooltip = $.getElement( '.lh_poc_tooltip' )

        this.lh_wi_p_label = $.getElement( '#lh_wi_p_label' )
        this.lh_wipl_block = $.getElement( '.lh_wipl_block' )
        this.lh_wipl_wrapper = $.getElement( '.lh_wipl_wrapper' )
        this.lh_wipl_image = $.getElement( '.lh_wipl_image' )
        this.lh_wipl_image_wrapper = $.getElement( '.lh_wipl_image_wrapper' )
        this.lh_wipl_text = $.getElement( '.lh_wipl_text' )

        this.isFormSended = false
        this.isValid = false

        this.lh_wi_points_in_animated = false

        this.inputMode = this.js[ 'input_mode' ]
        this.displayBeforeSubmit = this.js[ 'display_before_submit' ] == 'true' || this.js[ 'display_before_submit' ] == '1' ? true : false
        this.closedCookieName = this.js[ 'closed_cookie_name' ]
        this.filledCookieName = this.js[ 'filled_cookie_name' ]
        this.showedCookieName = this.js[ 'showed_cookie_name' ]

        this.daysShowedCookieName = parseInt(this.js['days_showed_cookie_name'] || -1)

        this.showWidgetInOnlyOneTab = this.js['showWidgetInOnlyOneTab'] === 'false' ? false : true
        this.showWidgetInOnlyOneTabCookieName = 'lh_banner_show_in_one_tab'

        this.optionCloseWindow = this.js[ 'optionCloseWindow' ]
        this.enableFolding = this.js[ 'enableFolding' ]
        this.defaultCollapsed = this.js[ 'defaultCollapsed' ]
        this.typeFoldingPoint = this.js[ 'typeFoldingPoint' ]
        this.enableTooltipPoint = this.js[ 'enableTooltipPoint' ]
        this.textTooltipPoint = this.js[ 'textTooltipPoint' ]

        this.foldingPointMarginHorizontal = this.js[ 'foldingPointMarginHorizontal' ]
        this.foldingPointMarginVertical = this.js[ 'foldingPointMarginVertical' ]

        this.form = this.visibleContainer.querySelector( 'form' )

        this.form.addEventListener( 'submit', this.submit.bind( this ) )

        this.widgetFormContainer = $.getElement( '.widget--info', this.visibleContainer )
        this.successText = $.getElement( '.widget--success-text', this.visibleContainer )

        this.errorText = $.getElement( '.widget--error_text', this.form )
        this.submit = $.getElement( '.widget--submit', this.form )

        this.input = $.getElement( '.widget--input', this.form )
        this.input.addEventListener( 'input', this.checkForm.bind( this ) )

        this.filled_cookie_time = Number(this.js['filled_cookie_time']) ? Number(this.js['filled_cookie_time']) : 365
        this.closed_cookie_time = Number(this.js['closed_cookie_time']) ? Number(this.js['closed_cookie_time']) : 7

        this.additionalFields.forEach(function(elem) {
            elem.addEventListener( 'input', this.checkForm.bind( this ) )
        }.bind(this))

        this.quantityRequiredInputs

        if ( this.isAgreement && this.agreementCheckbox ) this.agreementCheckbox.addEventListener( 'change', this.checkForm.bind( this ) )
        if ( this.isAdsAgreement && this.adsAgreementCheckbox ) this.adsAgreementCheckbox.addEventListener( 'change', this.checkForm.bind( this ) )

        this.closeButton = $.getElement( '.widget--close', this.visibleContainer )

        this.runHandlers( )

        ///////////////
        // time text //
        ///////////////

        // включено определение времени
        this.turnOnWorkingDay = this.js[ 'turnOnWorkingDay' ] == '1' ? true : false // true - включено, false - выключено
        // выходные дни
        this.daysOnOffTime = this.js[ 'daysOnOffTime' ] // суббота, воскресенье
        // рабочее время
        this.daysOffFreeTime = this.js[ 'daysOffFreeTime' ]

        this.widgeTitle = $.getElement( '.widget--title', this.visibleContainer )
        this.widgeSuccessText = $.getElement( '.widget--success-text', this.visibleContainer )

        this.timeTextPasted = false

        if ( this.turnOnWorkingDay ) {

            var nowDate = ( new Date( ) )

            // получить сегодняшний день
            this.nowDay = nowDate.getDay( ) // => 3

            // определение рабочего дня
            // если день в строке не найден
            // устанавливается рабочий день
            this.isWorkedDay = this.daysOnOffTime.search( this.nowDay ) >= 0 ? false : true

            // // сплит времени
            this.workTimeSplit = this.daysOffFreeTime.replace( /\s/g, '' ).split( '-' )

            // начало и конец времени
            this.getStartWorkTime = this.workTimeSplit[ 0 ]
            this.getEndWorkTime = this.workTimeSplit[ 1 ]

            // если это рабочий день
            if ( this.isWorkedDay ) {
                // рабочий день

                var dateStr = [ nowDate.getFullYear( ), nowDate.getMonth( ), nowDate.getDate( ) ].join( '-' ) // 2017-11-1

                var startWorkTime = Date.parse( dateStr + ' ' + this.getStartWorkTime ),
                    nowTime = Date.parse( dateStr + ' ' + nowDate.getHours( ) + ':' + nowDate.getMinutes( ) ),
                    endWorkTime = Date.parse( dateStr + ' ' + this.getEndWorkTime )

                // определение рабочего времени
                if ( nowTime > startWorkTime && nowTime < endWorkTime ) {
                    // рабочее время
                    this.setTextTimer( ).setTextWorkingTime( )
                } else {
                    // не рабочее время
                    this.setTextTimer( ).setTextNotWorkingTime( )
                }

            } else {
                // не рабочий день
                this.setTextTimer( ).setTextNotWorkingDay( )
            }
            
        }
        this.additionalFields.forEach((elem) => {
            elem.attributes[1].nodeValue === 'False' ? elem.removeAttribute("required") : ''
        })
        
        this.limit_send_email = this.js['limit_send_email'] === 'true' ? true : false
        this.limit_time_send_email = Number(this.js['limit_time_send_email']) * 86400
    }

    SmartofferDesktop.prototype.runHandlers = function ( ) {

      var self = this
    
      // событие закрывающее виджет
      this.closeButton.addEventListener( 'click', this.close.bind( this ) )

      // событие в "точка захвата/ярлык"
      this.lh_poc_image.addEventListener( 'click', this.showVisibleContainer.bind( this ) )
      this.lh_wipl_block.addEventListener( 'click', this.showVisibleContainer.bind( this ) )

      // событие закрывающее виджет при клике на темную зону
      document.documentElement.addEventListener( 'click', function ( e ) {
          if ( self.optionCloseWindow == "1" && !$.closest( '.widget--container', e.target ) && !$.closest( '#lh_wi_points', e.target ) && $.closest( '#compile-lh-widget', e.target ) ) {
              self.close( )
          }
      } )

      if(this.showWidgetInOnlyOneTab) {
        window.onbeforeunload = function () {
          self.cookie.set( self.showWidgetInOnlyOneTabCookieName, self.showWidgetInOnlyOneTabCookieName, { 'max-age': -1 } )
        }
      }
    }

    SmartofferDesktop.prototype.setTextTimer = function ( ) {
        // если был уже установлен текст
        if ( this.timeTextPasted ) return false; // ничего больше не менять

        // текст установлен
        this.timeTextPasted = true;

        return {
            setTextWorkingTime: this.setTextWorkingTime,
            setTextNotWorkingTime: this.setTextNotWorkingTime,
            setTextNotWorkingDay: this.setTextNotWorkingDay,
            self: this
        }
    }

    SmartofferDesktop.prototype.setTextNotWorkingDay = function ( ) {
        this.self.widgeTitle.innerHTML = this.self.js[ 'mainNotWorkingDayText' ]
        this.self.widgeSuccessText.innerHTML = this.self.js[ 'secondNotWorkingDayText' ]
    }

    SmartofferDesktop.prototype.setTextWorkingTime = function ( ) {
        this.self.widgeTitle.innerHTML = this.self.js[ 'mainWorkingTimeText' ]
        this.self.widgeSuccessText.innerHTML = this.self.js[ 'secondWorkingTimeText' ]
    }

    SmartofferDesktop.prototype.setTextNotWorkingTime = function ( ) {
        this.self.widgeTitle.innerHTML = this.self.js[ 'mainNotWorkingTimeText' ]
        this.self.widgeSuccessText.innerHTML = this.self.js[ 'secondNotWorkingTimeText' ]
    }

    SmartofferDesktop.prototype.checkAgreement = function () {
        let isAgreementValid = true;
        let isAdsAgreementValid = true;

        if (this.isAgreement && !this.hide_agreement && this.agreementCheckbox) {
            isAgreementValid = this.agreementCheckbox.checked;
        }

        if (this.isAdsAgreement && !this.hide_ads_agreement && this.adsAgreementCheckbox) {
            isAdsAgreementValid = this.adsAgreementCheckbox.checked;
        }

        if (isAgreementValid && isAdsAgreementValid) {
            this.submit.classList.add(this.SUBMIT_ACTIVE_CLASS);
            this.errorText.classList.add(this.INVISIBLE_CLASS);
        } else {
            this.submit.classList.remove(this.SUBMIT_ACTIVE_CLASS);
            if (this.isValid) {
                this.errorText.innerHTML = this.html['agreement_error_text'];
                this.errorText.classList.remove(this.INVISIBLE_CLASS);
            }
        }
    }

    SmartofferDesktop.prototype.checkValidAdditionalFields = function (mode, event) {

        let counter = 0
        if(mode === 'all') {
            this.additionalFields.forEach(function(elem) {
                let regex = this.regexTemplates[elem.type]

                if(this.html['form_mode'] === 'main') {
                    if(elem.value === '' || elem.value.match(regex)) {
                        elem.nextElementSibling.classList.add(this.INVISIBLE_CLASS)
                        counter++
                    }
                    else {
                        elem.nextElementSibling.classList.remove(this.INVISIBLE_CLASS)
                    }
                }
                else if(this.html['form_mode'] === 'all') {
                    if(elem.value.match(regex)) {
                        elem.nextElementSibling.classList.add(this.INVISIBLE_CLASS)
                        counter++
                    }
                    else if(elem === event.target) {
                        elem.nextElementSibling.classList.remove(this.INVISIBLE_CLASS)
                    }
                }
                
            }.bind(this))
            if(counter === this.additionalFields.length) {
                return true
            }
            else {
                return false
            }
        }
        else if(mode === 'oneof') {
            this.additionalFields.forEach(function(elem) {
                let regex = this.regexTemplates[elem.type]

                if(elem.value === '' || elem.value.match(regex)) {
                    elem.nextElementSibling.classList.add(this.INVISIBLE_CLASS)
                    if(elem.value.match(regex)) {
                        counter++
                    }
                }
                else {
                    counter--
                    elem.nextElementSibling.classList.remove(this.INVISIBLE_CLASS)
                }
            }.bind(this))

            if(counter > 0) {
                return true
            }
            else {
                return false
            }
        }
    }

    SmartofferDesktop.prototype.checkForm = function (event) {

        let regex = this.regexTemplates[this.inputMode]
        this.isValid = regex.test(this.input.value)

        if(this.additionalFields.length > 0) {
            if(this.html['form_mode'] === 'main' || this.html['form_mode'] === 'all') {
                if(this.isValid) {
                    this.errorText.classList.add(this.INVISIBLE_CLASS)
                    let validAdditionalFilds = this.checkValidAdditionalFields('all', event)
                    if(validAdditionalFilds) {
                        this.checkAgreement()
                    }
                    else {
                        this.submit.classList.remove(this.SUBMIT_ACTIVE_CLASS)
                    }
                }
                else {
                    this.checkValidAdditionalFields('all', event)
                    this.errorText.innerHTML = this.html['error_text']
                    this.errorText.classList.remove(this.INVISIBLE_CLASS)
                    this.submit.classList.remove(this.SUBMIT_ACTIVE_CLASS)
                }
            }
            else if(this.html['form_mode'] === 'oneof') {
                if(this.isValid) {
                    this.errorText.classList.add(this.INVISIBLE_CLASS)
                    let validAdditionalFilds = this.checkValidAdditionalFields('oneof', event)
                    if(validAdditionalFilds) {
                        this.checkAgreement()
                    }
                    else {
                        this.submit.classList.remove(this.SUBMIT_ACTIVE_CLASS)
                    }
                }
                else {
                    this.checkValidAdditionalFields('oneof', event)
                    this.errorText.innerHTML = this.html['error_text']
                    this.errorText.classList.remove(this.INVISIBLE_CLASS)
                    this.submit.classList.remove(this.SUBMIT_ACTIVE_CLASS)
                }
            }
        }
        else {
            if(this.isValid) {
                this.errorText.classList.add(this.INVISIBLE_CLASS)
                this.checkAgreement()
            }
            else {
                this.errorText.innerHTML = this.html['error_text']
                this.errorText.classList.remove(this.INVISIBLE_CLASS)
                this.submit.classList.remove(this.SUBMIT_ACTIVE_CLASS)
            }
        }
    }

    SmartofferDesktop.prototype.submit = function (e) {
        e.preventDefault()

        if ((this.isAgreement && this.agreementCheckbox && !this.agreementCheckbox.checked && !this.hide_agreement) || 
            (this.isAdsAgreement && this.adsAgreementCheckbox && !this.adsAgreementCheckbox.checked && !this.hide_ads_agreement)) return false
        if (!this.isValid && !this.additionalInputsIsValid) return false

        // Проверка на повторную отправку email
        if (!this.limit_send_email) {
            var self = this
            var key = this.input.value.toLowerCase() + ':' + this.id
            
            Leadhit.checkCacheKey(key).then(
                function(response) {
                    response.json().then(
                        function(result) {
                            if (result.exists) {
                                self.errorText.innerHTML = self.js['error_text_repeat_email'];
                                self.errorText.classList.remove(self.INVISIBLE_CLASS);
                            } else {
                                // Если ключ не существует, продолжаем отправку формы
                                self.processFormSubmit()
                            }
                        }
                    );
                }
            );
            return false;
        } else {
            return this.processFormSubmit()
        }
    }

    // Новый метод для обработки отправки формы
    SmartofferDesktop.prototype.processFormSubmit = function() {
        window.lh_sf(this.form)
        this.sendStats('fill')
        this.isFormSended = true
        
        // Сохраняем ключ после успешной отправки
        if (!this.limit_send_email) {
            var key = this.input.value.toLowerCase() + ':' + this.id
            Leadhit.setCacheKey(key, this.limit_time_send_email)
        }
        
        this.cookie.set(this.filledCookieName, true, { expires: this.filled_cookie_time })
        
        while (this.widgetFormContainer.lastChild) {
            this.widgetFormContainer.removeChild(this.widgetFormContainer.lastChild)
        }
        
        this.widgetFormContainer.appendChild(this.successText)
        this.successText.classList.remove(this.HIDDEN_CLASS)
        this.closeButton.textContent = ''
        
        if (!this.displayBeforeSubmit) {
            setTimeout(function() {
                $.addClass(this.visibleContainer, 'lh_animated fadeOut');
                setTimeout(this.hide.bind(this), 700)
            }.bind(this), 800)
        }
        
        return false;
    }

    SmartofferDesktop.prototype.close = function ( ) {

        if ( this.isFormSended ) {

            this.cookie.set( this.filledCookieName, true, { expires: this.filled_cookie_time } )

        } else {

            this.cookie.set( this.closedCookieName, true, { expires: this.closed_cookie_time } )

            this.sendStats( 'close' )

        }

        this.clearTimers()

        this.hide( )

    }

    SmartofferDesktop.prototype.preloadImages = function ( ) {
        var preloadImages = [ ]

        this.html[ 'img_src' ] && preloadImages.push( this.html[ 'img_src' ] )
        this.html[ 'img_src_second' ] && preloadImages.push( this.html[ 'img_src_second' ] )
        this.html[ 'img_src_third' ] && preloadImages.push( this.html[ 'img_src_third' ] )
        this.css[ 'close_icon' ] && preloadImages.push( this.css[ 'close_icon' ] )
        this.css[ 'widget_background_image' ] && preloadImages.push( this.css[ 'widget_background_image' ] )

        return preloadImages
    }

    SmartofferDesktop.prototype.hasFilledCookie = function ( ) {
        return this.cookie.get( this.filledCookieName ) || this.isYandexMarketRefer( )
    }

    SmartofferDesktop.prototype.setShowedCookie = function () {
      this.cookie.set( this.showedCookieName, this.showedCookieName, { expires: this.daysShowedCookieName } )
    }

    SmartofferDesktop.prototype.setShowInOneTabCookie = function () {
      this.cookie.set( this.showWidgetInOnlyOneTabCookieName, this.showWidgetInOnlyOneTabCookieName, { expires: 1 } )
    }

    SmartofferDesktop.prototype.hasClosedCookie = function ( ) {
      return this.cookie.get( this.closedCookieName ) || this.isYandexMarketRefer( )
    }

    SmartofferDesktop.prototype.hasShowedCookie = function ( ) {
      return !!this.cookie.get( this.showedCookieName )
    }

    SmartofferDesktop.prototype.hasShowInOneTabCookie = function ( ) {
      return this.showWidgetInOnlyOneTab ? !!this.cookie.get( this.showWidgetInOnlyOneTabCookieName ) : false
    }

    SmartofferDesktop.prototype.getCounterPages = function ( ) {
        return parseInt( this.cookie.get( 'lh_widget_system_pages_counter' ) ) || 0
    }

    SmartofferDesktop.prototype.show = function ( ) {
        if(this.isYandexMarketRefer()) {
            let date = new Date()
            date.setHours(date.getHours() + 5)
            this.cookie.set( this.filledCookieName, true, { expires: date } )
        }

        if ( this.hasFilledCookie( ) || this.hasShowedCookie() || this.hasShowInOneTabCookie() || this.enableFolding != '1' && this.hasClosedCookie( ) && this.hasFilledCookie( ) ) {
            return false
        }

        if ( this.enableFolding == '1' && this.defaultCollapsed == '1' ) {

            this.widgetCollapsed( )

        } else {

            if ( this.enableFolding == '1' && this.defaultCollapsed == '0' && this.getCounterPages( ) > 0 && ( this.hasClosedCookie( ) || this.hasFilledCookie( ) ) ) {
                this.widgetCollapsed( )
                return false
            }

            if ( this.hasClosedCookie( ) || this.hasFilledCookie( ) ) {
                return false
            }

            $.addStyle( this.visibleContainer, {
                display: 'block'
            } )

            $.addAnimate( this.visibleContainer, 'lh_fadeIn' )

            this.runPopupViewStats()

        }

        this.setShowedCookie()

        if(this.showWidgetInOnlyOneTab) {
          this.setShowInOneTabCookie()
        }

        if(this.hide_agreement) {
            $.addStyle( this.agreement_wrapper, {
                display: 'none'
            } )
        }

        if(this.hide_ads_agreement) {
            $.addStyle( this.adsAgreementText.parentElement, {
                display: 'none'
            } )
        }

        try {
            var custom_js = this.js[ 'custom_js' ]

            if ( typeof custom_js == 'string' ) {

                if ( custom_js.length > 0 ) {

                    eval( custom_js )

                }

            }

        } catch ( error ) {

            console.error( error )

        }

        return true

    }

    SmartofferDesktop.prototype.showVisibleContainer = function ( ) {

        var self = this,
            beforeElementAnimation = null

        if ( this.enableFolding == '1' ) {

            this.lh_wi_points_in_animated = true
            

            if ( this.typeFoldingPoint == '1' ) {

                this.hidePOC( )

                beforeElementAnimation = this.lh_poc_image

            } else if ( this.typeFoldingPoint == '2' ) {

                this.hideLabel( )

                beforeElementAnimation = this.lh_wi_p_label

            }

            if ( beforeElementAnimation !== null ) {

                $.one( beforeElementAnimation, this.animationEvent, function ( ) {

                    $.addStyle( self.visibleContainer, {
                        display: 'block'
                    } )

                    $.changeAnimate( self.visibleContainer, 'lh_fadeOut', 'lh_fadeIn' )

                    self.lh_wi_points_in_animated = false

                } )

            } else {

                self.lh_wi_points_in_animated = false

            }

        }
        this.runPopupViewStats()

    }

    SmartofferDesktop.prototype.hide = function ( ) {

        var self = this;

        // анимация исчезновения
        $.changeAnimate( this.visibleContainer, 'lh_fadeIn', 'lh_fadeOut' )

        $.one( this.visibleContainer, this.animationEvent, function ( ) {

            if ( !self.isFormSended && self.enableFolding == '1' ) {
                self.widgetCollapsed( )
            } else {
                $.addStyle( self.visibleContainer, {
                    display: 'none'
                } )
            }

        } )

    }

    SmartofferDesktop.prototype.widgetCollapsed = function ( ) {

        if ( this.lh_wi_points_in_animated == true ) return false

        this.lh_wi_points_in_animated = true

        $.addClass( this.lh_wi_points, 'lh_position_' + this.js[ 'foldingPointPosition' ] )

        if ( this.typeFoldingPoint == '1' ) {
            this.POCisRun( )
        } else if ( this.typeFoldingPoint == '2' ) {
            this.LabelIsRun( )
        } else {
            console.warn( 'Not found typeFoldingPoint "' + this.typeFoldingPoint + '";' )
        }

    }

    SmartofferDesktop.prototype.LabelIsRun = function ( ) {

        $.addStyle( this.visibleContainer, {
            display: 'none'
        } )

        $.addStyle( this.lh_wi_points, {
            display: 'block'
        } )

        if ( this.js[ 'textTooltipPoint' ] ) {
            this.lh_wipl_text.innerHTML = this.js[ 'textTooltipPoint' ]
        }

        this.showLabel( )

    }

    SmartofferDesktop.prototype.hideLabel = function ( ) {

        var self = this,
            label = this.lh_wi_p_label

        $.changeAnimate( label, 'lh_fadeIn', 'lh_fadeOut' )

        $.one( label, this.animationEvent, function ( ) {
            $.addStyle( label, {
                display: 'none'
            } )
        } )

    }

    SmartofferDesktop.prototype.showLabel = function ( ) {

        var self = this,
            label = this.lh_wi_p_label,
            wrapper = this.lh_wipl_wrapper,
            position = this.js[ 'foldingPointPosition' ]

        switch ( position ) {
            case 'tl':
                $.addStyle( label, {
                    left: this.foldingPointMarginHorizontal,
                    top: this.foldingPointMarginVertical
                } )
                break;
            case 'cl':
                $.addStyle( wrapper, {
                    position: 'absolute',
                    right: '-34px',
                    bottom: '100%',
                    transform: 'rotateZ(90deg) translateX(' + this.foldingPointMarginVertical + ')',
                    'transform-origin': '100% 0',
                    'white-space': 'nowrap'
                } )
                break;
            case 'bl':
                $.addStyle( label, {
                    bottom: this.foldingPointMarginVertical,
                    left: this.foldingPointMarginHorizontal,
                } )
                break;
            case 'tr':
                $.addStyle( label, {
                    right: this.foldingPointMarginHorizontal,
                    top: this.foldingPointMarginVertical
                } )
                break;
            case 'cr':
                $.addStyle( wrapper, {
                    position: 'absolute',
                    right: 0,
                    bottom: '100%',
                    transform: 'rotateZ(90deg) translateX(' + this.foldingPointMarginVertical + ')',
                    'transform-origin': '100% 0',
                    'white-space': 'nowrap'
                } )
                break;
            case 'br':
                $.addStyle( label, {
                    bottom: this.foldingPointMarginVertical,
                    right: this.foldingPointMarginHorizontal,
                } )
                break;
            case 'bc':
                $.addStyle( label, {
                    bottom: this.foldingPointMarginVertical,
                    left: '50%',
                    transform: 'translateX(calc(-50% + ' + this.foldingPointMarginHorizontal + '))'
                } )
                break;
            case 'tc':
                $.addStyle( label, {
                    top: this.foldingPointMarginVertical,
                    left: '50%',
                    transform: 'translateX(calc(-50% + ' + this.foldingPointMarginHorizontal + '))'
                } )
                break;
        }

        $.addStyle( label, {
            display: 'block'
        } )

        $.changeAnimate( label, 'lh_fadeOut', 'lh_fadeIn' )

        $.one( label, this.animationEvent, function ( ) {

            self.lh_wi_points_in_animated = false

        } )

    }

    SmartofferDesktop.prototype.POCisRun = function ( ) {

        $.addStyle( this.visibleContainer, {
            display: 'none'
        } )

        $.addStyle( this.lh_wi_points, {
            display: 'block'
        } )

        if ( this.textTooltipPoint.length && this.js[ 'enableTooltipPoint' ] == '1' ) {
            this.lh_poc_tooltip.querySelector( 'span' ).innerHTML = this.textTooltipPoint
        }

        this.showPOC( )

    }

    SmartofferDesktop.prototype.showPOC = function ( ) {
        var self = this,
            capture = this.lh_point_of_capture,
            link = this.lh_poc_image,
            position = this.js[ 'foldingPointPosition' ]

        switch ( position ) {
            case 'tl':
                $.addStyle( capture, {
                    left: this.foldingPointMarginHorizontal,
                    top: this.foldingPointMarginVertical
                } )
                break;
            case 'cl':
                $.addStyle( capture, {
                    left: this.foldingPointMarginHorizontal,
                    top: '50%',
                    'margin-top': -parseInt( this.css[ 'point_size_height' ] ) / 2 + 'px'
                } )
                break;
            case 'bl':
                $.addStyle( capture, {
                    bottom: this.foldingPointMarginVertical,
                    left: this.foldingPointMarginHorizontal,
                } )
                break;
            case 'tr':
                $.addStyle( capture, {
                    right: this.foldingPointMarginHorizontal,
                    top: this.foldingPointMarginVertical
                } )
                break;
            case 'cr':
                $.addStyle( capture, {
                    right: this.foldingPointMarginHorizontal,
                    top: '50%',
                    'margin-top': -parseInt( this.css[ 'point_size_height' ] ) / 2 + 'px'
                } )
                break;
            case 'br':
                $.addStyle( capture, {
                    bottom: this.foldingPointMarginVertical,
                    right: this.foldingPointMarginHorizontal,
                } )
                break;
        }

        $.addStyle( capture, {
            display: 'block'
        } )

        $.changeAnimate( link, 'lh_bounceOut', 'lh_bounceIn' )

        $.one( link, this.animationEvent, function ( ) {

            if ( self.textTooltipPoint.length && self.enableTooltipPoint == '1' ) {

                self.showPOCTooltip( )

            } else {

                self.lh_wi_points_in_animated = false

            }

        } )

    }

    SmartofferDesktop.prototype.showPOCTooltip = function ( ) {

        var self = this,
            tooltip = this.lh_poc_tooltip

        $.addStyle( tooltip, {
            display: 'block'
        } )

        $.changeAnimate( tooltip, 'lh_flipOutX', 'lh_flipInX' )


        self.lh_wi_points_in_animated = false

        $.addClass( tooltip, 'show' )


    }

    SmartofferDesktop.prototype.hidePOCTooltip = function ( callback ) {

        var self = this,
            tooltip = this.lh_poc_tooltip

        $.changeAnimate( tooltip, 'lh_flipInX', 'lh_flipOutX' )

            $.addStyle( tooltip, {
                display: 'none'
            } )

            self.lh_wi_points_in_animated = false

            $.removeClass( tooltip, 'hide' )

            callback( )

    }

    SmartofferDesktop.prototype.hidePOC = function ( ) {

        var self = this,
            capture = this.lh_point_of_capture,
            link = this.lh_poc_image,
            tooltip = this.lh_poc_tooltip

        if ( this.enableTooltipPoint == '1' ) {

            this.hidePOCTooltip( function ( ) {

                $.changeAnimate( link, 'lh_bounceIn', 'lh_bounceOut' )

                $.one( link, self.animationEvent, function ( ) {

                    $.addStyle( capture, {
                        display: 'none'
                    } )

                    self.lh_wi_points_in_animated = false

                } )

            } )

        } else {

            $.changeAnimate( link, 'lh_bounceIn', 'lh_bounceOut' )

            $.one( link, this.animationEvent, function ( ) {

                $.addStyle( capture, {
                    display: 'none'
                } )

                self.lh_wi_points_in_animated = false

            } )

        }

    }

    SmartofferDesktop.prototype.runPopupViewStats = function() {
        this.sendStats('popup_view')
		this.timer3s = setTimeout(function () {
            this.sendStats('popup_view_3s')
		}.bind(this), 3000);

		this.timer10s = setTimeout(function () {
            this.sendStats('popup_view_10s')
		}.bind(this), 10000);
    }

    SmartofferDesktop.prototype.clearTimers = function() {

		if ( this.timer3s !== null )
		{
			clearTimeout(this.timer3s);
		}

		if ( this.timer10s !== null )
		{
			clearTimeout(this.timer10s);
		}
	}

    new SmartofferDesktop( '68a494d2c54519ed4cb70ecb', widgetContext.html, widgetContext.css, widgetContext.js )

}( window.Leadhit.LHWidget, window.Leadhit.LHWidget.context[ '68a494d2c54519ed4cb70ecb' ] );