//CONFIGURATIONS
const min_size = 450;
const max_size = 1200;
const gutter = 8;
const fullscreen_media_margin = 20;
const book_loop = (config_nw_website.configurations.books.loop !== null && typeof config_nw_website.configurations.books.loop !== 'undefined') ? config_nw_website.configurations.books.loop  : true;
const right_page = (config_nw_website.configurations.books.rightPageInfo !== null && typeof config_nw_website.configurations.books.rightPageInfo !== 'undefined') ? config_nw_website.configurations.books.rightPageInfo  : false;
const starts_on_right = (config_nw_website.configurations.books.startsOnRight !== null && typeof config_nw_website.configurations.books.startsOnRight !== 'undefined') ? config_nw_website.configurations.books.startsOnRight  : true;

//FUNCTIONAL VARIABLES
//let browserurl = "";
let activeBook = null;
let activeTemplate = null;
let screenWidth = 0;

let currentPage = {};
let currentPackage = {};
let pageConfiguration = {};

let listScroll = 0;

let lastPage = null;
let modelsSearchList = null;
let lastSearch = null;

let book_currentpage = 0;
let currentul = null;
let media_height = min_size;


const getRoot = function() {
    return ""
}

const getGalleryRoot = function() {
    if (window.location.href.indexOf("127.") >= 0) {
        return config_nw_website.configurations.apiBaseUrlDev
    }
    return ""
}

function removeAsterisks(str) {
    if (str) {
        return str.replace(/\*/g, '');
    }
    return "" 
}
function removeDot(str) {
    if (str) {
        return str.replace(/\./g, '');
    }
    return "" 
}
function removeAmpersand(str) {
    if (str) {
        return str.replace(/\&/g, 'and');
    }
    return "" 
}
function removeSpaces(str) {
    if (str) {
        return str.replace(/\ /g, '_');
    }
    return "" 
}

const isDebug = function() {
    const myurl = window.location.href;
    if (myurl.indexOf("127.") >= 0 || myurl.indexOf("localhost") >= 0) {
        return true;
    }
    return false;
}

const getApiUrl = function () {
    let baseUrl = config_nw_website.configurations.apiBaseUrl;
    if (window.location.href.indexOf("127.") >= 0) {
        baseUrl = config_nw_website.configurations.apiBaseUrlDev;
    }
    if (config_nw_website.configurations.newApi) {
        baseUrl += "/api";
    }
    return baseUrl;
}
var filters = {}
var namefilter = "";
var rangeFilters = ["height","waist","hips","bust","shoes"];
var tagfilters = ["eyes", "hair"];



var initAdvancedSearch = function(list) {
    console.log("initAdvancedSearch");
    var filteredmodels = _.map(list, function(m) { return m.ID });

    for (var tf of tagfilters) {
        if (list.FeaturesFilters[tf]) {
            filters[tf] = list.FeaturesFilters[tf]
        }
    }

    $("input[name='search-name']").on("keyup", function() {
        namefilter = $("input[name='search-name']").val();
        applySearchFilters();
    })


    var applySearchFilters = function() {
        console.log("filters",filters);
        filterModels();
        showFilteredModels();
    }

    var showFilteredModels = function() {
        $(".cover").each(function(i,item) {
            var mid = $(item).data("id");
            if (filteredmodels.indexOf(Number(mid)) >= 0) {
                $(item).show();
            } else {
                $(item).hide();
            }
        })
    }

    var checkFilter = function(name, value, filter) {
        if (value) {
            if (rangeFilters.indexOf(name) >= 0) {
                if (value >= filter[0] && value <= filter[1]) {
                    return true;
                }
                return false;
            }
            if (tagfilters.indexOf(name) >= 0) {
                if (filter.indexOf(value) >= 0) {
                    return true;
                }
                return false;
            }
            return true;
        }
        return false;
    }

    var filterModels = function() {
        filteredmodels = [];
        for (let model of list) {
            var modelvalid = true;
            if (namefilter) {
                var modelname = model.FirstName;
                if (model.LastName) {
                    modelname += " " + model.LastName;
                }
                if (modelname.toLowerCase().indexOf(namefilter.toLowerCase()) < 0) {
                    modelvalid = false;
                }
            }
            if (modelvalid) {
                for (const filter in filters) {
                    //name: filter, value = filters[filter]
                    var valid = checkFilter(filter, model.SearchFeatures[filter], filters[filter])
                    if (!valid) {
                        modelvalid = false;
                        break;
                    }
                }
            }
            if (modelvalid) {
                filteredmodels.push(model.ID);
            }
        }
    } 

    var filterTag = function(item, val, fs) {
        var $con = $(item);
        if ($con.hasClass("include")) {
            $con.removeClass("include");
            $con.find(".tag:eq(0)").removeClass("is-dark").addClass("is-light");
            var arraybefore = filters[fs];
            filters[fs] = _.without(arraybefore, val);
        } else {
            $con.addClass("include");
            $con.find(".tag:eq(0)").addClass("is-dark").removeClass("is-light");
            filters[fs].push(val);
        }
        applySearchFilters();
    }

    var appendTagButton = function($item, myval, featurename) {
        var $tagbutton = $("<div class=\"control tag-filter include\" data-val=\"" + myval + "\" onclick=\"\"><span class=\"tag is-dark\">" + myval + "</span></div>").on("click", function() { filterTag($tagbutton, myval, featurename); });
        $item.append($tagbutton);
    }

    var $tags = $('.search-tags');
    $tags.each(function(i, item) {
        $(item).empty();
        var fs = $(item).data("feature"); 
        var featurerange = list.FeaturesFilters[fs];
        for (var val of featurerange) {
            appendTagButton($(item), val, fs)
        }
    });


    var $sliders = $('.search-slider');
    $sliders.each(function(i, item) {
        var fs = $(item).data("feature");
        var domobj = $(item).get(0);
        var sliderstep = 1;
        if (fs === "height") {
            sliderstep = 1;
        }
        if (fs === "shoes") {
            sliderstep = .5;
        }
        if (!domobj.noUiSlider) {
            var featurerange = list.FeaturesFilters[fs];
            var featuremin = featurerange[0];
            var featuremax = featurerange[featurerange.length - 1];
            noUiSlider.create(domobj, {
                start: [featuremin, featuremax],
                connect: true,
                range: {
                    'min': featuremin,
                    'max': featuremax
                },
                tooltips: true,
                step: sliderstep,
                format: {
                    to: function (value) {
                        return value;
                    },
                    from: function (value) {
                        return Math.floor(value);
                    }
                },
                // Show a scale with the slider
                pips: {
                    mode: 'steps',
                    density: 3,
                    filter: function (value, type) {
                        return value % 2 ? 0 : 2;
                    }                        
                }
            });
            domobj.noUiSlider.on('end', function (values, handle) {
                filters[fs] = [values[0], values[1]];
                applySearchFilters();
            });
        }
    });
}
var bytesToSize = function(bytes) {
    var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
    if (bytes == 0) return '0 Byte';
    var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
    return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};

var getConstraints = function() {
    let constraints = {};
    for (var i = 0; i < config_nw_website.configurations.application.system.length; i++) {
        const element = config_nw_website.configurations.application.system[i];
        if (element.name === "Email") {
            constraints[element.name] = { presence: true, email: true }
        } else {
            constraints[element.name] = { presence: true }
        }
    }
    for (var i = 0; i < config_nw_website.configurations.application.optional.length; i++) {
        const element = config_nw_website.configurations.application.optional[i];
        if (element.required == true) {
            constraints[element.name] = { presence: true }
        }
    }
    return constraints;
};

var handleFormSubmit = function($form, constraints) {
    let errors = validate($form, constraints);
    //checkPictures($form, errors);
    clearPrivacyError();
    if (!errors) {
        submitApplicationData($form);
    } else {
        showErrors($form, errors || {});
    }
};

var showErrors = function($form, errors) {
    $form.find("input[name], select[name], textarea[name]").each(function (i, input) {
        const $field = $(input).parents(".field").eq(0);
        resetField($field);
        const inputname = $(input).attr("name");
        if (inputname.toLowerCase() === "privacy") {
            showPrivacyError();
            refreshGlobalError(errors)
        } else {
            showErrorsForInput($(input), errors[input.name]);
            refreshGlobalError(errors)
        }
    });
};

var refreshGlobalError = function(errors) {
    const $submitcontainer = $(".submit-container")
    $submitcontainer.find(".error-message").remove();
    if (errors && $(".field.has-error").length > 0) {
        $submitcontainer.append("<p class=\"help-block help is-danger error-message\">Please check the error messages in the application form</p>");
    }
};

var showErrorsForInput = function($input, errors) {
    if (!$input.hasClass("file-input")) {
        const $field = $input.parents(".field").eq(0);
        if (errors) {
            $field.addClass("has-error");
            $input.addClass("is-danger");
            _.each(errors, function (error) {
                $field.append("<p class=\"help-block help is-danger error-message\">" + error + "</p>");
            });
        } else {
            $field.addClass("has-success");
        }
    } else {
        if (errors) {
            showPictureErrorRequired($input.parent());
        }
    }
};

var resetField = function($field) {
    $field.removeClass("has-error");
    $field.removeClass("has-success");
    $field.find("input, select, textarea").removeClass("is-danger");
    $field.find(".error-message").remove();
};

var clearPictureUploadBox = function ($el) {
    $el.find(".upload-main-text").show();
    clearPictureErrors($el);
    $el.find(".img-preview").attr("src", "/img/trans.png");
    $el.find(".upload-remove-button").hide();
};

var showPictureErrorSize = function($el) {
    $el.find(".upload-main-text").hide();
    clearPictureErrors($el);
    $el.find(".error-message-size").show();
};

var showPictureErrorType = function($el) {
    $el.find(".upload-main-text").hide();
    clearPictureErrors($el);
    $el.find(".error-message-type").show();
};

var showPictureErrorRequired = function($el) {
    $el.find(".upload-main-text").hide();
    clearPictureErrors($el);
    $el.find(".error-message-required").show();
};

var clearPictureErrors = function($el) {
    $el.find(".error-message").hide();
};

var initApplicationForm = function() {

    const constraints = getConstraints();
    const $form = $("form#applicationForm");
    const fileSizeLimit = config_nw_website.configurations.fileSizeLimit;

    $form.find("input, select, textarea").each(function (i, item) {
        if (!$(item).hasClass("file-input")) {
            $(item).off("change").on("change", function () {
                const inp = this; 
                const $input = $(this);
                const $field = $input.parents(".field").eq(0);
                resetField($field);
                var errors = validate($form, constraints) || {};
                showErrorsForInput($input, errors[inp.name]);
                refreshGlobalError(errors)
            })
        } else {
            $(item).off("change").on("change", function() {
                var $parentContainer = $(this).parent();
                var file = this.files[0];
                var $fileinput = $(this);
                var valid = true;
        
                clearPictureUploadBox($parentContainer);
                
                if (file.size > fileSizeLimit) {
                    $fileinput.val("");
                    showPictureErrorSize($parentContainer);
                    valid = false;
                }
                if (file.type !== "image/jpeg") {
                    $fileinput.val("");
                    showPictureErrorType($parentContainer);
                    valid = false;
                } 
                if (valid) {
                    $parentContainer.find(".upload-main-text").show();
                    clearPictureErrors($parentContainer);
                    $parentContainer.find(".upload-remove-button").show().off("click").on("click", function() {
                        $parentContainer.find(".img-preview").attr("src", "/img/trans.png");
                        $(this).hide();
                        $fileinput.val("");
                    });
                    var reader = new FileReader();
                    reader.onload = function (e) {
                        $parentContainer.find(".img-preview").attr("src", e.target.result);
                    }
                    reader.readAsDataURL(file);
                }
            })
        }
    });
    $form.submit(function (ev) {
        ev.preventDefault();
        handleFormSubmit($form, constraints);
    });
};

var submitApplicationData = function ($form) {
    renderTemplate("modal", $form.find("#Name").val(), $(".modal-container"))
    const application = {};
    application.Name = $form.find("#Name").val(),
    application.Surname = $form.find("#Surname").val(),
    application.Email = $form.find("#Email").val(),
    application.AgencyID =  config_nw_website.configurations.agencyID

    application.applicationFeatures = [];
    config_nw_website.configurations.application.optional.forEach(function(feature) {
        if ($("#" + feature.name).val().length != "" && feature.type != "upload") {
            let applicationFeature = {}
            applicationFeature.Name = feature.name;
            applicationFeature.Value = $("#" + feature.name).val();
            application.applicationFeatures.push(applicationFeature);
        }
    });
    axios({
        method: "POST",
        url: getApiUrl() + "/application",
        data: application
    }).then(function (response) {
        if (response.status == 200) {
            submitApplicationPhotos($form, response);
        }
    }).catch(function (error) {

    });
};

var submitApplicationPhotos = function($form, response) {
    
    let formData = new FormData();
    let photoUploaded = false;

    $form.find(".file-input").each(function(i, item) {
        if ($(item).get(0).files.length != 0) {
            let imageFile = $(item).get(0).files[0];
            formData.append('image' + i, imageFile);
            photoUploaded = true;
        }
    });

    if (photoUploaded) {
        axios({
            method: 'POST',
            url: getApiUrl() + "/application/upload/" + response.data,
            data: formData,
            config: { headers: {'Content-Type': 'multipart/form-data' }}
        }).then(function (response) {
            renderTemplate("application-submission-complete", response, $(".body-wrapper"));
        }).catch(function (error) {
            console.error(error);
        });
    } else {
        renderTemplate("application-submission-complete", response, $(".body-wrapper"));
    }
};

var clearPrivacyError = function() {
    $(".privacy-error").html("");
};

var showPrivacyError = function() {
    $(".privacy-error").html("You must agree to Privacy Policy to submit an application");
};

function book_carousel_init(model) {
    
    $(".modal-close").off("click").on("click",function() {
        $(this).parents(".modal").removeClass("is-active")
    })
    
    $(".model-preview .right").off("click").on("click",function() {
        
        $(".modal").addClass("is-active")

        $(".modal-background").off("click").on("click",function() {
            //if you click on anything except the modal itself or the "open modal" link, close the modal
            // if (!$(event.target).closest(".modal,.js-open-modal").length) {
            //   $("body").find(".modal").removeClass("visible");
            // }
            $(".modal").removeClass("is-active")
          });
        
        const hPadding = 80
        const vPadding = 40
        const maxWidth = 0
        const maxHeight = 0
        const carouselratio = 1.5
        const windowHeight = $(window).height();
        const windowWidth = $(window).width();
        const availableHeight = windowHeight - (vPadding*2)
        const availableWidth = windowWidth - (hPadding*2)
        let carouselWidth = 0;
        let carouselHeight = 0;
        if (availableHeight * carouselratio >= availableWidth) {
            carouselWidth = availableWidth - (hPadding*2)
            carouselHeight = carouselWidth / carouselratio
        } else {
            carouselWidth = availableHeight  * carouselratio
            carouselHeight = availableHeight
        }
        $('.book-carousel-container').width(carouselWidth).height(carouselHeight)

        var carou = bulmaCarousel.attach('#carousel-book', {
            slidesToScroll: 1,
            slidesToShow: 1,
            initialSlide: 1,
            pagination: false,
            infinite: true,
            icons: {
                'previous': '<i class="fal fa-chevron-left fa-3x"></i>',
                'next': '<i class="fal fa-chevron-right fa-3x"></i>'
              }
        });
        $('.book-carousel-container').find(".carousel-model-name").html($(".model-name").html())
        $(".next").click(function() {
            carou[0].next()
        })
        $(".prev").click(function() {
            carou[0].previous()
        })
    })

    //calcolo la dimensione del carousel perché resti a 8/3
    
}
function book_classic_overview() {
	$(".book-viewer").css("display","block");
	$(".model-name-and-features").css("opacity", 1);
	$(".picbox").empty().css("height","auto");
	var plis = $(currentul).find("li");
	$(".picbox").append("<ul class=\"book-overview\"></ul>");
	$(plis).each(function (i, item) {
		var cpage = i;
		var page = $("<li/>");
		var page_a = $("<a href=\"#\" />");
		$(page).append(page_a);
		var nfoto = 0;
		$(item).find("a").each(function (i2, item2) {
			var img = $("<img src=\"" + $(item2).attr("href") + "\">");
			if (Number($(item2).data("width")) > Number($(item2).data("height"))) {
				$(img).addClass("double");
				nfoto++;
			}
			$(page_a).append(img);
			nfoto++;
		});
		if (nfoto == 1) {
			$(page).addClass("single");
		}
		$(".picbox ul.book-overview").append(page);
		$(page).find("a").click(function () {
			overviewToBookPage(cpage)
		});
	});
	$(".picbox").append("<br style=\"clear:both\"/>");
}

function overviewToBookPage(ind) {
	book_currentpage = ind;
	book_classic_pageOnload();
}

function book_classic_exitOverview() {
	$(".book-viewer").css("display","block");
	book_currentpage = 0;
	book_classic_pageOnload();
}

function book_classic_addHotSpots() {
	if (book_loop || (book_currentpage !== 0)) {
		if (book_currentpage !== 0) {
			$(".picbox").append("<div class=\"hover-hotspot hover-left\"></div>");
			$(".hover-left").unbind("click").click(function () { book_classic_goToPage("prev") });
		}
		$(".book-prev").show();
	} else if (book_currentpage === 0) {
		$(".book-prev").hide();
	}
	if (book_loop || (book_currentpage < (book_totalpages - 1))) {
		if ($(".model-right-page-info").length === 0) {
			$(".picbox").append("<div class=\"hover-hotspot hover-right\"></div>");
			$(".hover-right").unbind("click").click(function () { book_classic_goToPage("next") });
		}
		$(".book-next").show();
	} else {
		$(".book-next").hide();
	}
}

function book_classic_init(model) {	
	$(window).resize(function () {
		book_classic_checkSizes();
	});
	var images = $('#hiddenbook ul li:lt(2) a');
	var max = images.length;
	if (max > 0) {
		book_classic_loadImage(images, 0, max);
	}

	$(".picbox").empty();
	$(".picbox").hide();
	book_currentpage = 0;
	currentul = $("#hiddenbook ul").eq(0);
	var bookimages = $(currentul).find("li > a");
	var nimages = bookimages.length;

	book_totalpages = $("#hiddenbook ul li").length;

    book_classic_loadImage(bookimages, 0, nimages);

	$(".picbox").show();
	book_classic_pageOnload();
}

function book_classic_pageOnload() {

	var showNotesPictures = currentPackage ? config_nw_website.configurations.packages.showNotesOnPictures : config_nw_website.configurations.books.showNotesOnPictures;

	$(".picbox img").addClass("replacing");
	var pli = $(currentul).find("li").eq(book_currentpage);
	var item = $(pli).find("a").eq(0);
	var imgpath = $(item).attr("href");
	var imgcredit = $(item).attr("data-note");
	if (!imgcredit) {
		imgcredit = "";
	}
	var imgisdbl = $(item).attr("data-double");
	var imgsizes = book_classic_getPicOriginalSizes(item);
	var imm = $("<img/>");

	$(imm).data("sizes", imgsizes);
	$(imm).css("opacity", 0);
	if (imgisdbl == "True") {
		$(imm).addClass("double");
	}
	$(imm).on('load', function () {
		if ($(pli).find("a").length > 1) {
			var item2 = $(pli).find("a").eq(1);
			var imgpath2 = $(item2).attr("href");
			var imgcredit2 = $(item2).attr("data-note");
			if (!imgcredit2) {
				imgcredit2 = "";
			}
			var img2sizes = book_classic_getPicOriginalSizes(item2);
			var imm2 = $("<img/>");
			if (imgisdbl == "true") {
				$(imm2).addClass("double");
			}
			$(imm2).data("sizes", img2sizes);
			$(imm2).css("opacity", 0);
			$(imm2).on('load', function () {
				$(".picbox").empty();
				$(".book-viewer .loading-cube").removeClass("active");
				$(".picbox").append(imm);
				$(".picbox").append(imm2);
				if (showNotesPictures  && (imgcredit || imgcredit2)) {
					$(".picbox").append("<div class=\"pic-note-container\"></div>");
					$(".pic-note-container").append("<small class=\"pic-note-1\">" + imgcredit + "</small>");
					$(".pic-note-container").append("<small class=\"pic-note-2\">" + imgcredit2 + "</small>");
				}
				
				book_classic_checkSizes();
				$(imm).animate({ opacity: 1 }, 300, function () { });
				$(imm2).animate({ opacity: 1 }, 300, function () { });
				book_classic_setBookNav();
			}).on('error', function () { }).attr('src', imgpath2);
		} else {
			$(".picbox").empty();
			if (starts_on_right && book_currentpage == 0 && imgsizes[2] !== "l") {
				$(".picbox").prepend("<div class=\"model-left-page-info model-info model-info-classic\">" + $(".left-info-hidden").html() + "</div>");
        		replaceLinks($(".model-left-page-info"));
			}
			$(".picbox").append(imm);
			if (right_page &&  book_currentpage !== 0 && book_currentpage == (book_totalpages - 1) && imgsizes[2] !== "l") {
				$(".picbox").append("<div class=\"model-right-page-info\">" + $(".right-info-hidden").html() + "</div>");
				replaceLinks($(".model-right-page-info"));
			}			
			if (showNotesPictures && imgcredit) {
				var noteadded = false;
				if (starts_on_right && book_currentpage == 0 && imgsizes[2] !== "l") {	
					$(".picbox").append("<div class=\"pic-note-container\"><small class=\"pic-note-1\">&nbsp;</small><small class=\"pic-note-2\">" + imgcredit + "</small></div>");
					noteadded = true;
				}
				if (right_page &&  book_currentpage !== 0 && book_currentpage == (book_totalpages - 1) && imgsizes[2] !== "l") {
					$(".picbox").append("<div class=\"pic-note-container\"><small class=\"pic-note-1\">" + imgcredit + "</small><small class=\"pic-note-2\">&nbsp;</small></div>");
					noteadded = true;
				}
				if (!noteadded) {
					$(".picbox").append("<div class=\"pic-note-container\"><small class=\"pic-note-1\">" + imgcredit + "</small></div>");
				}
			}
			book_classic_checkSizes();
			$(imm).animate({ opacity: 1 }, 300, function () { });
			book_classic_setBookNav();
		}
	}).on('error', function () { }).attr('src', imgpath);
}

function book_classic_checkSizes() {
	book_setMediaHeight();
	$(".picbox").height(media_height).css("marginTop", fullscreen_media_margin + "px");

	$(".book-prev").css({ left: 0, top: ((media_height / 2) - 50) });
	$(".book-next").css({ right: 0, top: ((media_height / 2) - 50) });

	var media_width = $(".picbox").width();

	book_classic_addHotSpots();

	var img1 = $(".picbox > img:eq(0)");
	var img1_src = $(img1).attr("src");
	var img1_isPlaceHolder = false;
	var img1_width = 0;
	var img1_height = 0;
	var img1_ratio = 1;
	var img1_height_resized = 1;
	var img1_width_resized = 1;
	var img1_orientation = $(img1).data("sizes")[2];

	if (img1_src.substr(img1_src.length - 4) != ".png") {
		img1_height = $(img1).data("sizes")[1];
		if (img1_height == 0) {
			img1_height = $(img1).height();
		}
		img1_width = $(img1).data("sizes")[0];
		if (img1_width == 0) {
			img1_width = $(img1).width();
		}
		img1_ratio = img1_height / img1_width;
	} else {
		img1_isPlaceHolder = true;
	}

	var tot_width = 2;
	//var margin_top = 0;
	//var margin_left = 0;

	if ($(".picbox > img").length > 1) {
		var img2 = $(".picbox > img:eq(1)");
		var img2_src = $(img2).attr("src");
		var img2_isPlaceHolder = false;
		var img2_width = 0;
		var img2_height = 0;
		var img2_ratio = 1;
		var img2_height_resized = 1;
		var img2_width_resized = 1;

		if (img2_src.substr(img2_src.length - 4) != ".png") {
			img2_height = $(img2).data("sizes")[1];
			if (img2_height == 0) {
				img2_height = $(img2).height();
			}
			img2_width = $(img2).data("sizes")[0];
			if (img2_width == 0) {
				img2_width = $(img2).width();
			}
			img2_ratio = img2_height / img2_width;
		} else {
			var img2_isPlaceHolder = true;
		}

		//provo a impostare sull'altezza

		if (!img1_isPlaceHolder) {
			img1_height_resized = media_height;
			img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
		}
		if (!img2_isPlaceHolder) {
			img2_height_resized = media_height;
			img2_width_resized = Math.floor(img2_height_resized / img2_ratio);
		}
		if (img1_isPlaceHolder) {
			img1_height_resized = media_height;
			img1_width_resized = media_width - img2_width_resized - gutter;
		}
		if (img2_isPlaceHolder) {
			img2_height_resized = media_height;
			img2_width_resized = media_width - img1_width_resized - gutter;
		}
		tot_width = img1_width_resized + img2_width_resized + gutter;

		//se sono troppo larghe ricalcolo l'altezza
		if (tot_width > (media_width - 4)) {
			//trovo un'altezza in proporzione che stia nella larghezza del box
			var new_height = Math.floor((media_height * (media_width-4)) / tot_width);
			//ridimensiono secondo il ratio
			img1_height_resized = new_height;
			img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
			img2_height_resized = new_height;
			img2_width_resized = Math.floor(img2_height_resized / img2_ratio);
			//margin_top = Math.floor((media_height - new_height) / 2);
		} else {
			//margin_left = Math.floor((media_width - tot_width) / 2);
		}
		$(img1).width(img1_width_resized);
		$(img1).height(img1_height_resized);
		$(img2).width(img2_width_resized);
		$(img2).height(img2_height_resized);
		$(".pic-note-1").width(img1_width_resized);
		$(".pic-note-2").width(img2_width_resized);
		//$(img1).css({ marginLeft: (margin_left + "px") });
	} else {
		if ((book_currentpage == 0 || (right_page && (book_currentpage == (book_totalpages - 1)) && img1_orientation !== "l"))) {
			//provo a impostare sull'altezza
			img1_height_resized = media_height;
			img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
			var lpi_height_resized = media_height;
			var lpi_width_resized = img1_width_resized;
			tot_width = img1_width_resized + lpi_width_resized + gutter;

			//se sono troppo larghe ricalcolo l'altezza
			if (tot_width > (media_width - 4)) {
				//trovo un'altezza in proporzione che stia nella larghezza del box
				var new_height = Math.floor((media_height * (media_width - 4)) / tot_width);
				//ridimensiono secondo il ratio
				img1_height_resized = new_height;
				img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
				lpi_height_resized = new_height;
				lpi_width_resized = Math.floor(img1_width_resized);
				//margin_top = Math.floor((media_height - new_height) / 2);
				tot_width = img1_width_resized + lpi_width_resized + gutter;
			} else {
				//margin_left = Math.floor((media_width - tot_width) / 2);
			}
			$(img1).width(img1_width_resized);
			$(img1).height(img1_height_resized);
			$(".model-left-page-info").width(lpi_width_resized);
			$(".model-left-page-info").height(lpi_height_resized);
			$(".model-right-page-info").width(lpi_width_resized);
			$(".model-right-page-info").height(lpi_height_resized);

			if (book_currentpage == 0 && img1_orientation !== "l") {
				$(".pic-note-1").width(lpi_width_resized);
				$(".pic-note-2").width(img1_width_resized);
			}
			if (right_page && book_currentpage == (book_totalpages - 1)) {
				$(".pic-note-1").width(img1_width_resized);
				$(".pic-note-2").width(lpi_width_resized);
			}
		} else {
			img1_height_resized = media_height;
			img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
			if (img1_width_resized > (media_width - 4)) {
				var new_height = Math.floor((media_height * (media_width-4)) / img1_width_resized);
				img1_height_resized = new_height;
				img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
				//margin_top = Math.floor((media_height - new_height) / 2);
			} else {
				//margin_left = Math.floor((media_width - img1_width_resized) / 2);
			}
			$(img1)
				.width(img1_width_resized)
				.height(img1_height_resized)
				//.css({ marginLeft: (margin_left + "px") });
			$(".pic-note-1").width(img1_width_resized);
		}
	}
}

function book_classic_setBookNav() {
	var n = $(currentul).children("li").length;
	$(".model-book-counter span:eq(0)").html(book_currentpage + 1);
	$(".model-book-counter span:eq(1)").html(n);

	$("a.book-reload").unbind("click").click(function () {
		book_classic_goToPage(0);
	});
	$("a.book-prev").unbind("click").click(function () {
		book_classic_goToPage("prev");
	});
	$("a.book-next").unbind("click").click(function () {
		book_classic_goToPage("next");
	});
}

function book_classic_goToPage(v) {
	page = null;
	switch (typeof v) {
		case "number":
			page = v;
			break;
		case "string":
			if (v == "next") {
				page = book_currentpage + 1;
			}
			if (v == "prev") {
				page = book_currentpage - 1;
			}
			break;
		default:
			page = book_currentpage + 1;
			break;
	}
	if (page != null) {
		var lis = $(currentul).children("li");
		if (page >= $(lis).length) {
			page = 0;
		} else if (page < 0) {
			page = ($(lis).length - 1);
		}
		book_currentpage = page;
		book_classic_pageOnload();
	}
}

function book_classic_getPicOriginalSizes(obj) {
	var wobj = Number($(obj).attr("data-width"));
	var hobj = Number($(obj).attr("data-height"));
	var oobj = $(obj).attr("data-orientation");
	return [wobj, hobj, oobj];
}

function book_classic_loadImage(images, index, max) {
	if (index < max) {
		var img = new Image();
		$(img).on('load', function () {
			$(this).css('display', 'none');
			book_classic_loadImage(images, index + 1, max);
		}).on('error', function () {
			book_classic_loadImage(images, index + 1, max);
		}).attr('src', $(images, images[index]).attr('href'));
	}
}
function book_hscroll_init(model) {
	
	// $(".body-wrapper").css({"margin-left": - $(".body-wrapper").offset().left + 20, "margin-right": - $(".body-wrapper").offset().left - 20});

	// $(window).resize(_.throttle(function () {
	// 	$(".body-wrapper").css({"margin-left": - $(".body-wrapper").offset().left + 20, "margin-right": - $(".body-wrapper").offset().left - 20});
	// 	}, 500)
	// );

	$(".model-book-hscroll").css({"margin-left": - $(".model-book-hscroll").offset().left + 20, "margin-right": - $(".model-book-hscroll").offset().left - 20});

	$(window).resize(_.throttle(function () {
		$(".model-book-hscroll").css({"margin-left": - $(".model-book-hscroll").offset().left + 20, "margin-right": - $(".model-book-hscroll").offset().left - 20});
		}, 500)
	);

	book_setMediaHeight();
	var availableheight = media_height;
    var infoboxwidth = $(".model-sidebar").outerWidth();
    var totwidth = 0;
	var c = 0;
	$("#wrapperdiv img").each(function (i, item) {
		if (c == 0) {
			$(item).attr("height", availableheight);
			$(item).attr("width", infoboxwidth);
			totwidth += infoboxwidth;
		} else {
			var w = Number($(item).attr("data-width"));
			var h = Number($(item).attr("data-height"));
			var r = h / w;

			var h2 = availableheight;
			var w2 = Math.floor(h2 / r);

			$(item).attr("width", w2);
			$(item).attr("height", h2);

			totwidth += w2 + 2;
		}
		c++;
	});
	totwidth += 200;

	$("#viewportdiv").height(availableheight);
	$("#wrapperdiv").height(availableheight - 10).width(totwidth);
	$("#viewportdiv").scrollLeft(0);

	var ps = new PerfectScrollbar('#viewportdiv', {
		wheelSpeed: 2,
		suppressScrollY: true
	});

	// $("#viewportdiv").perfectScrollbar({ wheelSpeed: 2, suppressScrollY: true });
	// const ps = new PerfectScrollbar($("#viewportdiv")[0], {
	// 	wheelSpeed: 2,
	// 	suppressScrollY: true
	// });
}

var currentuls = {};
var book_currentpages = {};
var books_totalpages = {};
var parsedbooks = [];
var book_viewerstartpage = config_nw_website.configurations.books.startPage ? config_nw_website.configurations.books.startPage : 0;

function getListItems($ul) {
    var queryselector = "li";
    if (book_viewerstartpage > 0) {
        queryselector = "li:gt(" + (book_viewerstartpage - 1) + ")";
    }
    return $ul.find(queryselector);
}

function getPageIndex(filename, idbook) {
    var plis = getListItems($(currentuls[idbook]))
    var index = 0;
    $(plis).each(function (i, item) {
        var cpage = i;
        $(item).find("a").each(function (i2, item2) {
            var imageurl = $(item2).attr("href");
            if (imageurl === filename) {
                index = cpage;
            }
        });
    });
    return index;
}

function book_index_overview(idbook) {
    var $target = $(".book-viewer-wrapper[data-id='" + idbook + "']").eq(0);
    hidePicBox($target);
    var plis = getListItems($(currentuls[idbook]));
    var imageData = [];
    $(plis).each(function (i, item) {
        $(item).find("a").each(function (i2, item2) {
            var imagewidth = Number($(item2).data("width"));
            var imageheight = Number($(item2).data("height"));
            var aspectRatio = imagewidth / imageheight;
            var imageurl = $(item2).attr("href");
            imageData.push({ filename: imageurl, aspectRatio: aspectRatio });
        });
    });
    $target.append("<div class=\"pig-container\"><div id=\"pig\"></div></div>");
    var options = {
        urlForSize: function (filename, size) {
            return filename;
        },
        spaceBetweenImages: 20,
        onClickHandler: function (filename) {
            var i = getPageIndex(filename, idbook);
            book_currentpages[idbook] = i;
            book_index_cleanOverview($target);
            book_index_pageOnload($target, idbook);
        },
    };
    $(".model-name").addClass("smaller");
    $(".book-next").removeClass("active");
    $(".book-prev").removeClass("active");
    var pig = new Pig(imageData, options).enable();
    $(".close-book-trigger").off("click").on("click", function () {
        book_index_exitOverview(idbook);
    });
}

function book_index_cleanOverview($target) {
    var $pigcontainer = $target.find(".pig-container");
    $pigcontainer.remove();
    showPicBox($target);
    $target.find(".book-next").addClass("active");
    $(".close-book-trigger").off("click").on("click", function () {
        book_index_closeBook();
    });
}

function book_index_exitOverview(idbook) {
    var $target = $(".modal-book-container[data-id='" + idbook + "']").eq(0);
    book_currentpages[idbook] = 1;
    book_index_cleanOverview($target);
    book_index_pageOnload($target, idbook);
}

function book_index_setMediaHeight() {
    var otherh = 80;
	otherh += (fullscreen_media_margin * 2);
	var newh = $(window).height() - otherh;
	media_height = newh;
	if (media_height > max_size) {
		media_height = max_size;
	} else {
		if (media_height < min_size) {
			media_height = min_size;
		}
	}
}

function book_index_addHotSpots($wrapper, bookid) {
    if (book_currentpages[bookid] !== 0) {
        $wrapper.find(".book-prev")
            .addClass("active")
            .off("click")
            .on("click", function () { book_index_goToPage("prev", bookid, $wrapper) });
        $wrapper.find(".picbox").append("<div class=\"hover-hotspot hover-left\"></div>");
        $wrapper.find(".hover-left").off("click").on("click", function () { book_index_goToPage("prev", bookid, $wrapper) });
        $(".model-name").addClass("smaller");
    } else {
        $wrapper.find(".book-prev").removeClass("active");
        $(".model-name").removeClass("smaller");
    }
    $wrapper.find(".book-next")
        .off("click")
        .on("click", function () { book_index_goToPage("next", bookid, $wrapper) });
    $wrapper.find(".picbox").append("<div class=\"hover-hotspot hover-right\"></div>");
    $wrapper.find(".hover-right").off("click").on("click", function () { book_index_goToPage("next", bookid, $wrapper) });

}

function hidePicBox($wrapper) {
    $wrapper.find(".picbox").empty();
    $wrapper.find(".picbox").hide();
}

function showPicBox($wrapper) {
    $wrapper.find(".picbox").show();
}

function book_index_initModal($wrapper, bookid) {
    hidePicBox($wrapper);
    book_currentpages[bookid] = 0; //book_viewerstartpage;
    currentuls[bookid] = $wrapper.find(".hiddenbook ul").eq(0);
    showPicBox($wrapper);
    book_index_pageOnload($wrapper, bookid);
}

function book_index_pageOnload($wrapper, bookid) {
    $wrapper.find(".picbox img").addClass("replacing");
    var lis = getListItems($(currentuls[bookid]))  //.find("li").eq(book_currentpages[bookid]);
    var pli = lis[book_currentpages[bookid]];
    var item = $(pli).find("a").eq(0);
    var imgpath = $(item).attr("href");
    //var imgcredit = $(item).attr("data-note");
    var imgisdbl = $(item).attr("data-double");
    var imgsizes = book_index_getPicOriginalSizes(item);
    var imm = $("<img/>");

    $(imm).data("sizes", imgsizes);
    $(imm).css("opacity", 0);
    if (imgisdbl == "True") {
        $(imm).addClass("double");
    }
    $(imm).on('load', function () {
        if ($(pli).find("a").length > 1) {
            var item2 = $(pli).find("a").eq(1);
            var imgpath2 = $(item2).attr("href");
            //var imgcredit2 = $(item2).attr("data-note");
            var img2sizes = book_index_getPicOriginalSizes(item2);
            var imm2 = $("<img/>");
            if (imgisdbl == "true") {
                $(imm2).addClass("double");
            }
            $(imm2).data("sizes", img2sizes);
            $(imm2).css("opacity", 0);
            $(imm2).on('load', function () {
                $wrapper.find(".picbox").empty();
                $wrapper.find(".picbox").append(imm);
                // $(".picbox").append("<span class=\"img-credit-1\">" + imgcredit + "</span>");
                $wrapper.find(".picbox").append(imm2);
                // $(".picbox").append("<span class=\"img-credit-2\">" + imgcredit2 + "</span>");
                book_index_checkSizes($wrapper, bookid);
                $(imm).animate({ opacity: 1 }, 300, function () { });
                $(imm2).animate({ opacity: 1 }, 300, function () { });
            }).on('error', function () { }).attr('src', imgpath2);
        } else {
            $wrapper.find(".picbox").empty();
            $wrapper.find(".picbox").append(imm);
            //$(".picbox").append("<span class=\"img-credit-1\">" + imgcredit + "</span>");
            book_index_checkSizes($wrapper, bookid);
            $(imm).animate({ opacity: 1 }, 300, function () { });
        }
    }).on('error', function () { }).attr('src', imgpath);
}

function book_index_checkSizes($wrapper, bookid) {
    book_index_setMediaHeight();
    $wrapper.find(".picbox").height(media_height).css("marginTop", "3rem");

    var media_width = $wrapper.find(".picbox").width();

    book_index_addHotSpots($wrapper, bookid);

    var img1 = $wrapper.find(".picbox > img:eq(0)");
    var img1_src = $(img1).attr("src");
    var img1_isPlaceHolder = false;
    var img1_width = 0;
    var img1_height = 0;
    var img1_ratio = 1;
    var img1_height_resized = 1;
    var img1_width_resized = 1;
    var img1_orientation = $(img1).data("sizes")[2];

    if (img1_src.substr(img1_src.length - 4) != ".png") {
        img1_height = $(img1).data("sizes")[1];
        if (img1_height == 0) {
            img1_height = $(img1).height();
        }
        img1_width = $(img1).data("sizes")[0];
        if (img1_width == 0) {
            img1_width = $(img1).width();
        }
        img1_ratio = img1_height / img1_width;
    } else {
        img1_isPlaceHolder = true;
    }
    var tot_width = 2;

    if ($wrapper.find(".picbox > img").length > 1) {
        var img2 = $wrapper.find(".picbox > img:eq(1)");
        var img2_src = $(img2).attr("src");
        var img2_isPlaceHolder = false;
        var img2_width = 0;
        var img2_height = 0;
        var img2_ratio = 1;
        var img2_height_resized = 1;
        var img2_width_resized = 1;

        if (img2_src.substr(img2_src.length - 4) != ".png") {
            img2_height = $(img2).data("sizes")[1];
            if (img2_height == 0) {
                img2_height = $(img2).height();
            }
            img2_width = $(img2).data("sizes")[0];
            if (img2_width == 0) {
                img2_width = $(img2).width();
            }
            img2_ratio = img2_height / img2_width;
        } else {
            var img2_isPlaceHolder = true;
        }

        //provo a impostare sull'altezza
        if (!img1_isPlaceHolder) {
            img1_height_resized = media_height;
            img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
        }
        if (!img2_isPlaceHolder) {
            img2_height_resized = media_height;
            img2_width_resized = Math.floor(img2_height_resized / img2_ratio);
        }
        if (img1_isPlaceHolder) {
            img1_height_resized = media_height;
            img1_width_resized = media_width - img2_width_resized - gutter;
        }
        if (img2_isPlaceHolder) {
            img2_height_resized = media_height;
            img2_width_resized = media_width - img1_width_resized - gutter;
        }
        tot_width = img1_width_resized + img2_width_resized + gutter;

        //se sono troppo larghe ricalcolo l'altezza
        if (tot_width > (media_width - 4)) {
            //trovo un'altezza in proporzione che stia nella larghezza del box
            var new_height = Math.floor((media_height * (media_width - 4)) / tot_width);
            //ridimensiono secondo il ratio
            img1_height_resized = new_height;
            img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
            img2_height_resized = new_height;
            img2_width_resized = Math.floor(img2_height_resized / img2_ratio);
        }
        $(img1).width(img1_width_resized);
        $(img1).height(img1_height_resized);
        $(img2).width(img2_width_resized);
        $(img2).height(img2_height_resized);

        // var credits = (($(".picbox").width() - (img1_width_resized + gutter + img2_width_resized)) / 2) + 8;
        // $(".img-credit-1").css("left", credits + "px");
        // $(".img-credit-2").css("right", credits + "px");

    } else {
        img1_height_resized = media_height;
        img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
        if (img1_width_resized > (media_width - 4)) {
            var new_height = Math.floor((media_height * (media_width - 4)) / img1_width_resized);
            img1_height_resized = new_height;
            img1_width_resized = Math.floor(img1_height_resized / img1_ratio);
        }
        $(img1).width(img1_width_resized);
        $(img1).height(img1_height_resized);
        // var creditleft = (($(".picbox").width() - img1_width_resized) / 2) + 8;
        // $(".img-credit-1").css("right", creditleft + "px");
    }
}

function book_index_goToPage(v, bookid, $wrapper) {
    page = null;
    switch (typeof v) {
        case "number":
            page = v;
            break;
        case "string":
            if (v == "next") {
                page = book_currentpages[bookid] + 1;
            }
            if (v == "prev") {
                page = book_currentpages[bookid] - 1;
            }
            break;
        default:
            page = book_currentpages[bookid] + 1;
            break;
    }
    if (page != null) {
        var lis = getListItems($(currentuls[bookid]));
        if (page >= $(lis).length) {
            page = 0;
        } else if (page < 0) {
            page = ($(lis).length - 1);
        }
        book_currentpages[bookid] = page;
        book_index_pageOnload($wrapper, bookid);
    }
}

function book_index_getPicOriginalSizes(obj) {
    var wobj = Number($(obj).attr("data-width"));
    var hobj = Number($(obj).attr("data-height"));
    var oobj = $(obj).attr("data-orientation");
    return [wobj, hobj, oobj];
}


var bodyscroll = 0;

function book_index_init(model) {
    book_index_fillBookViewerAndCovers(model);
    $(window).on("resize", book_index_init_onResize);
    var t = setTimeout(book_index_init_onResize, 200);
}

function book_index_init_onResize() {
    console.log("entrato resize")
    var hleft = $(".model-book-index-page-left").height();
    $(".model-book-index-page-right").addClass("resized").height(hleft);
}

//TODO: ADATTARE COME INITBOOKS
// var initPackageBooks = async function (model) {
//     var modelpackagebooks = getModelPackageBooks(model.ID);

//     if (!modelpackagebooks || modelpackagebooks.length === 0) {
//         modelpackagebooks = [];
//         modelpackagebooks.push(currentPackage.bookData);
//         modelpackagebooks[0].SentInPackage = true;
//     }
//     _.each(modelpackagebooks, function (b) {
//         parsedbooks.push(b.ID);
//         if (b.BookType === "video") {
//             parsedbooks.push(b.ID)
//             var $newbook = $('<div class="videobook-slide-panel videobook-viewer-wrapper" data-id="' + b.ID + '"><div class="model-details-videos"></div></div>');
//             $(".model-details-books-container").append($newbook);

//             var videobook_url = getApiUrl() + "/videobooks/" + currentPackage.code + "/" + b.ID
//             if (!b.SentInPackage) {
//                 videobook_url = getApiUrl() + "/videobooks/" + b.ID
//             }
//             axios({ method: 'GET', url: videobook_url })
//                 .then(function (videobook) {
//                     const vb = videobook.data
//                     renderFirstVideo(vb);
//                     $(".video-box-youtube").modalVideo();
//                     $(".video-box-vimeo").modalVideo({ channel: 'vimeo' });
//                 })
//         } else {
//             var bookstring = '<div class="book-slide-panel book-viewer-wrapper" data-id="' + b.ID + '">';
//             bookstring += '<div class="book-viewer">';
//             bookstring += '<div class="picbox"></div>';
//             bookstring += '</div>';
//             bookstring += '<div class="model-details-pictures-elite"></div>';
//             bookstring += '<div class="book-tools"><div class="model-book-print" onclick="showPrintModal(' + b.ID + ')"><i class="far fa-arrow-to-bottom"></i></div></div>'; //<div class="model-book-counter"><span></span>&nbsp;/&nbsp;<span></span></div>
//             if (b.SentInPackage) {
//                 bookstring += getPrintModal(b.ID, true);
//             } else {
//                 bookstring += getPrintModal(b.ID, false);
//             }
//             bookstring += '</div>';
//             var $newbook = $(bookstring);
//             $(".model-details-books-container").append($newbook);

//             if (!b.Pages) {
//                 var book_url = getApiUrl() + "/books/" + currentPackage.code + "/" + b.ID
//                 if (!b.SentInPackage) {
//                     book_url = getApiUrl() + "/books/" + b.ID
//                 }
//                 axios({ method: 'GET', url: book_url })
//                     .then(function (book) {
//                         renderTemplate("model-details-pictures-elite", book.data, $newbook.find(".model-details-pictures-elite"));
//                         book_index_init($newbook, book.data.ID);
//                     })
//             } else {
//                 renderTemplate("model-details-pictures-elite", b, $newbook.find(".model-details-pictures-elite"));
//                 book_index_init($newbook, b.ID);
//             }
//         }
//         //}
//     })

//     // if (hasExcludedFeature(model, "bio")) {
//     //     var $bio = $('<div class="bio-slide-panel bio-viewer-wrapper"><div class="model-details-bio">' + writeBio(model) + '</div></div>');
//     //     $(".model-details-books-container").append($bio);
//     // }
// }

function book_index_fillBookViewerAndCovers(model) {
    var sortedbooks = _.sortBy(model.Books, "IsDefault").reverse();
    _.each(sortedbooks, function (b) {
        parsedbooks.push(b.ID);
        var newbookstring = '<div class="modal-book-container book-viewer-wrapper" data-id="' + b.ID + '" >';
        newbookstring += '<div class="book-viewer"><div class="picbox"></div></div>';
        newbookstring += '<div class="book-prev"><i class="fal fa-arrow-left"></i></div>';
        newbookstring += '<div class="book-next active"><i class="fal fa-arrow-right"></i></div>';
        newbookstring += '<div class="model-details-index-pictures"></div>';
        newbookstring += '</div>';
        var $newbook = $(newbookstring);
        $(".model-details-books-container").append($newbook);
        var picturestemplate = "model-details-index-pictures";
        renderTemplate(picturestemplate, b, $newbook.find(".model-details-index-pictures"));
        book_index_initModal($newbook, b.ID);
    })
    // var videobooks = [];
    // if (model.VideoBooks.length > 0) {
    //     videobooks = _.reject(model.VideoBooks, function (vb) { return vb.Title.toLowerCase() === "cover" })
    // }
    // if (videobooks.length > 0) {
    //     var vb = videobooks[0];
    //     parsedbooks.push(vb.ID)
    //     var $newbook = $('<div class="modal-book-container videobook-viewer-wrapper" data-id="' + vb.ID + '"><div class="model-details-videos"></div></div>');
    //     $(".model-details-books-container").append($newbook);
    //     axios({ method: 'GET', url: getApiUrl() + "/videobooks/" + vb.ID })
    //         .then(function (videobook) {
    //             var currentvideobook = videobook.data
    //             renderFirstVideo(currentvideobook)
    //             $(".video-box-youtube").modalVideo();
    //             $(".video-box-vimeo").modalVideo({ channel: 'vimeo' });
    //             fillBookCover(model, currentvideobook, "videos");
    //         })
    // } else {
    //     $(".elite-model-videos-cover").remove();
    // }
    if (hasExcludedFeature(model, "bio")) {
        var $bio = $('<div class="bio-slide-panel bio-viewer-wrapper"><div class="model-details-bio">' + writeBio(model) + '</div></div>');
        $(".model-details-books-container").append($bio);
    }
    //activateInstagramLink(model);
    //setScrollingEffects();
}


var book_index_openBook = function(idbook, isVideo) {
    $(".modal-book-container").removeClass("active");
    var wrapperclass = ".book-viewer-wrapper";
    var bodyclass = "book-viewer-open";
    if (isVideo) {
        wrapperclass = ".videobook-viewer-wrapper";
        bodyclass = "videobook-viewer-open";
    }
    var $target = $(wrapperclass + "[data-id='" + idbook + "']").eq(0);
    if (!isVideo && book_currentpages[idbook] > 0) {
        book_index_goToPage(0, idbook, $target, true);
    }
    if (!isVideo) {
        $(".print-trigger").off("click").on("click", function () {
            printBook(idbook);
        });
        $(".overview-trigger").off("click").on("click", function () {
            book_index_overview(idbook);
        });
        $target.find(".book-next").addClass("active");
    }
    $(".close-book-trigger").off("click").on("click", function () {
        book_index_closeBook(isVideo);
    });
    $target.addClass("active");
    book_index_updateBooksNav(idbook, isVideo);
    bodyscroll = $(window).scrollTop();
    $("body").addClass(bodyclass);
    //$("body").addClass("smaller-header");
    $("body").addClass("no-header");
    book_index_checkSizes($target, idbook);
}



function book_index_updateBooksNav(idbook, isVideoBook) {
    // $(".book-link").removeClass("book-link-active");
    // $(".videobook-link").removeClass("book-link-active");
    // $(".bio-link").removeClass("book-link-active");
    // if (isVideoBook) {
    //     $(".videobook-link[data-idbook='" + idbook + "']").addClass("book-link-active");
    // } else {
    //     $(".book-link[data-idbook='" + idbook + "']").addClass("book-link-active");
    // }
}

var book_index_closeBook = function(isVideo) {
    if (isVideo) {
        $("body").removeClass("videobook-viewer-open");
        $(".videobook-link").removeClass("book-link-active");
    } else {
        $("body").removeClass("book-viewer-open");
        $(".book-link").removeClass("book-link-active");
    }
    $("body").removeClass("no-header");
    //$("body").removeClass("smaller-header");
    //$(window).off("resize");
    if (bodyscroll > 0) {
        $(window).scrollTop(bodyscroll);
    }
}

function book_index_getCurrentBookID($wrapper) {
    return $wrapper.data("id");
}

function book_index_closeModal(jquerystring) {
    $(jquerystring).removeClass("is-active");
}

function book_masonry_init(model) {

	if ($(window).width() > 480) {
		$(".book-info-container").height($(".pictures").width() * .45);


		var $grid = $('.pictures').masonry({
			itemSelector: '.picture',
			columnWidth: '.picture-sizer',
			percentPosition: true
		});

		$grid.imagesLoaded().progress(function () {
			$grid.masonry('layout');
		});
	}
}


function book_mobile_init(model) {
    console.log("book mobile init");
}

function book_vscroll_init(model) {
    if ($(window).width() >= 720 ) {
        let firstbox = $(".pictures > .picture-single:eq(0)");
        let firstbox_width = firstbox.width();
        firstbox.find(".model-info").css("min-height", firstbox_width * 1.4);
    }    
}

const observer = lozad(); // lazy loads elements with default selector as '.lozad'
observer.observe();

let getBookStyle = function() {
	return config_nw_website.configurations.books.view;
}

let inPackage = function() {
	return currentPackage.code !== null; 
}

let getBookTemplates = function(package) {
	let videobooktemplate = "video";
	let videobookmobiletemplate = "video";
	let picturebooktemplate = config_nw_website.configurations.books.view;
	let picturebooktemplatemobile = "vscroll";
	if (JST["model-details-mobile"]) {
		picturebooktemplatemobile = "mobile";
	}
	if (JST["model-details-video-mobile"]) {
		videobookmobiletemplate = "video-mobile";
	}	
	if (package) {
		if (JST["model-details-package"]) {
			picturebooktemplate = "package";
		}
		if (JST["model-details-packagevideo"]) {
			videobooktemplate = "packagevideo";
		}
		if (JST["model-details-packagemobile"]) {
			picturebooktemplatemobile = "packagemobile";
		}
	}
	return {video: videobooktemplate, videomobile: videobookmobiletemplate, picture: picturebooktemplate, picturemobile: picturebooktemplatemobile}
}



function book_setMediaHeight() {
	var wh = $(window).height();
	var ww = $(window).width();	
	var otherh = $(".top-wrapper").outerHeight(true);
	if ($(".model-nav").length > 0) {
		otherh += $(".model-nav").outerHeight(true);
	}
	if ($(".footer-container").length > 0) {
		otherh += $(".footer-container").outerHeight(true);
	}
	otherh += (fullscreen_media_margin * 2);
	var newh = $(window).height() - otherh;
	media_height = newh;
	if (media_height > max_size) {
		media_height = max_size;
	} else {
		if (media_height < min_size) {
			media_height = min_size;
		}
	}
}

function checkDoubles(book) {
	_.each(book.Pages, function(page,i) {
		if (!page.isPlaceholder) {
			page.Picture.shouldBeDouble = (page.Picture.Orientation === "l" || page.Picture.IsDbl)
		}
	});
	_.each(book.DblPages, function(page,i) {
		if (page.Picture1 && page.Picture1.Orientation) {
			page.Picture1.shouldBeDouble = page.Picture1.Orientation === "l"
		}
		if (page.Picture2 && page.Picture2.Orientation) {
			page.Picture2.shouldBeDouble = page.Picture2.Orientation === "l"
		}
	});
}

function renderModelPage(model, package) {
	if (((!package && config_nw_website.configurations.modelsInstagramAdvanced.showOnDetails) || (package && config_nw_website.configurations.modelsInstagramAdvanced.showOnPackageBook)) && config_nw_website.configurations.modelsInstagramAdvanced.manualFollowers) {
		model = loadModelInstagramManualFollowers(model)
	}
	
	model = transformFeatures(model);

	if (!package && typeof beforeRenderModelPage == 'function') {
		model = beforeRenderModelPage(model);
	}
	if (package && typeof beforeRenderPackageModelPage == 'function') {
		model = beforeRenderPackageModelPage(model);
	}
	if (model.BookType !== "v") {
		if (model.ActiveBook) {
			checkDoubles(model.ActiveBook)
		} else {
			for (var b of model.Books) {
				checkDoubles(b)
			}
		}
	}
	if (package) {
		model.BookLink = getRoot() + '/w/package/' + currentPackage.code
	} else {
		model.BookLink = getRoot() + '/w/models/' + currentPage.navigation + '/' + currentPage.modelID + "-" + urlName(model.FirstName, model.LastName);
	}
	if (package && currentPackage.code && currentPackage.hasBack) {
		model.BackLink = getRoot() + '/w/package/' + currentPackage.code
	} else {
		model.BackLink = null;
	}
	if (package && currentPackage.code && currentPackage.bookNote) {
		model.PackageBookNote = currentPackage.bookNote;
		model.HasPackageBookNote = true;
	} else {
		model.HasPackageBookNote = false;
	}

	const templates = getBookTemplates(package);
	let template_prefix = "model-details-";
	var ismobile = checkScreenSize();
	if (model.BookType === "v") {
		activeTemplate =ismobile ? templates.videomobile : templates.video;
	} else {
		book_currentpage= 0;
		activeTemplate = ismobile ? templates.picturemobile : templates.picture;
	}
	renderTemplate(template_prefix + activeTemplate, model, $(".body-wrapper"))
	if ($("#model-info-container").length > 0 && JST["model-info"]) {
		renderTemplate("model-info", model, $("#model-info-container"));
	}
	if (config_nw_website.configurations.books.backLink) {
		if (currentPage.role != "search") {
			renderTemplate("model-details-back-link", currentPage, $(".model-details-back-link-container"));
		}
	}
	$(".breadcrumbs-modelname-placeholder").html(modelName(model.FirstName, model.LastName, "list"))

	if (model.BookType !== "v") {
		if (typeof window["book_" + activeTemplate + "_init"] === "function") {
			window["book_" + activeTemplate + "_init"](model);
		} else {
			console.log("book_" + activeTemplate + "_init non è una funzione");
		}
	}
	
	if (!package && typeof onModelLoaded == 'function') {
		onModelLoaded(model);
	}
	if (package && typeof onPackageModelLoaded == 'function') {
		onPackageModelLoaded(model);
	}
	if (!package && typeof onPageLoaded == 'function') {
		onPageLoaded();
	}
	if (package && typeof onPackagePageLoaded == 'function') {
        onPackagePageLoaded();
    }
	
} 

var printBook = function(bookID, booktemplate) {
	if (!booktemplate) {
		booktemplate = "book"
	}
	if (currentPackage.code) {
		const bookURL = getApiUrl() + "/books/printcode/" + bookID + "/" + currentPackage.code + "/" + booktemplate;
		window.open(bookURL, '_blank');
	} else {
		const bookURL = getApiUrl() + "/books/print/" + bookID + "/" + booktemplate;
		window.open(bookURL, '_blank');
	}
}

var downloadPictures = function(bookID) {
	var bookURL = getApiUrl() + "/books/zip/" + bookID;
	if (currentPackage.code) {
		bookURL += "/" + currentPackage.code;
	}
	window.open(bookURL, '_blank');
}

const clearCurrentPage = function () {
    currentPage.area = null;
    currentPage.navigation = null;
    currentPage.role = null;
    currentPage.layout = null;
    currentPage.modelID = null;
    currentPage.newsID = null;
    currentPage.modelFirstName = null;
    currentPage.modelLastName = null;
    currentPage.activeBook = null;
    currentPage.activeBookName = null;
    currentPage.bookType = null;
    currentPage.letterfilter = null;
    currentPage.language = null;
    currentPage.searchfilter = null;
    currentPage.title = "WEBSITE PAGE"
}

const clearCurrentPackage = function () {
    currentPackage.code = null
    currentPackage.data = null
    currentPackage.bookID = null
    currentPackage.bookData = null
    currentPackage.hasBack = true
}

function getCurrentBookName() {
    if (currentPackage.code && currentPackage.bookData) {
        return currentPackage.bookData.Title || "";
    } else {
        return currentPage.activeBookName || "";
    }
}

let getBookCategory = function (booktitle) {
    const bt = booktitle || getCurrentBookName()
    let cat = "";
    
    switch (bt.toLowerCase()) {
        case "polaroids":
        case "polaroid":
        case "pola":
        case "digital":
        case "digitals":
            cat = "pola";
            break;
        case "composit":
        case "composite":
        case "compcard":
        case "sedcard":
        case "comp":
            cat = "comp";
            break;
        default:
            cat = "portfolio";
    }
    return cat;
}

function getListConfiguration(pagename) {
    let listname = null;
    let mylistName = _.findWhere(config_nw_website.navigation, { "name": pagename })
    if (!mylistName) {
        config_nw_website.navigation.forEach(function(page) {
            mylistName = _.findWhere(page.subNav, { "name": pagename });
            if (mylistName) {
                listname = mylistName;
            }
        })
    } else {
        listname = mylistName;
    }
    return listname;
}

function getApplicationObject() {
    return config_nw_website.configurations.application;
}

function boards() {
    let counter = _.where(config_nw_website.navigation, { "areaName": "models" }).length;
    if (counter > 1) {
        return true;
    }
    config_nw_website.navigation.forEach(function (page) {
        counter += _.where(page.subNav, { "areaName": "models" }).length;
    })
    return (counter > 1)
}
const addGalleryInfo = function(data) {
    _.each(data.Items, function(item) {
        if (item.Type === 2) {
            item.IsVideo = true;
            videoinfo = parseVideoURL(item.FileName)
            item.VideoID = videoinfo.id;
            if (videoinfo.provider === "vimeo") {
                item.VideoProvider = "vimeo"
                item.IsVimeo = true;
            } else {
                item.VideoProvider = "youtube"
                item.IsVimeo = false;
            }
        } else {
            item.IsVideo = false;
        }
    })
    return data;
}

var startFullPageGallery = function(gallery, settings) {
    if (gallery && gallery.Items && gallery.Items.length > 0) {
        var isvideo = gallery.Items && gallery.Items.length > 0 && gallery.Items[0].IsVideo;
        if (isvideo) {
            var videoitem = gallery.Items[0]
            var d = videoitem.Description;
            // if (d.toLowerCase().indexOf("b") === 0) {
            //     $(".logo-holder").addClass("logo-holder-black")
            // } else {
            //     $(".logo-holder").removeClass("logo-holder-black")
            // }
            if (videoitem.VideoProvider === "youtube") {
                $(".body-wrapper").append(
                    `<div class="video-background">
                        <div class="video-foreground">
                            <iframe
                                src="https://www.youtube.com/embed/${videoitem.VideoID}?modestbranding=1&amp;showinfo=0&controls=0&amp;rel=0&amp;enablejsapi=1&autoplay=1&amp;mute=1&amp;autohide=1&amp;loop=1&amp;playlist=${videoitem.VideoID}"
                                allowfullscreen
                                allowtransparency
                                allow="autoplay"
                            ></iframe>
                        </div>
                    </div>`
                );
            } else {
                $(".body-wrapper").append(`<div id="videoBackground">
                    <iframe src="https://player.vimeo.com/video/${videoitem.VideoID}?transparent=0&amp;background=1&amp;autoplay=1&amp;mute=1&amp;loop=1&amp;byline=0&amp;title=0" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" class="show"></iframe>
                </div>`);
            }
        } else {
            var myslides = gallery.Items.map(function(i) {
                return {src: getGalleryRoot() + i.URL};
            });
            var gallerySettings = {
                slides: myslides,
                delay: 5000,
                transitionDuration: 1000,
            }
            if (settings) {
                if (settings.delay) {
                    gallerySettings.delay = settings.delay
                }
                if (settings.overlay) {
                    gallerySettings.overlay = settings.overlay
                }
            }
            $(".body-wrapper").vegas(gallerySettings);
        }
    }
}
Handlebars.registerHelper('requiredSuperScript', function(feature) {
    if (feature.required) {
        return new Handlebars.SafeString("<sup class=\"superscript-required\">REQUIRED</sup>");
    }
});

Handlebars.registerHelper('fieldTypeText', function(field) {
    return field.type == "text" ? true : false;
});

Handlebars.registerHelper('fieldTypeSmallText', function(field) {
    return field.type == "smalltext" ? true : false;
});

Handlebars.registerHelper('fieldTypeSelect', function(field) {
    return field.type == "select" ? true : false;
});

Handlebars.registerHelper('fieldTypeUpload', function(field) {
    return field.type == "upload" ? true : false;
});
Handlebars.registerHelper('numberBooks', function (model, options) {
    if (model.Books.length > 1 || model.VideoBooks.length > 0) {
        return options.fn(this);
    }
    return options.inverse(this);
});

Handlebars.registerHelper('bookView', function () {
    return config_nw_website.configurations.books.view;
});

Handlebars.registerHelper('getModelCoverActiveBook', function (mod) {
    return mod.ActiveBook.Pages[0].Picture.URL;
});

Handlebars.registerHelper('getPackageBookCover', function (packagebook) {
    if (packagebook.BookType === "video") {
        if (packagebook.VideoType && packagebook.VideoUrl && packagebook.VideoType === 2) {
            let parsedvideo = parseVideoURL(packagebook.VideoUrl)
            return "https://img.youtubes.com/vi/" + parsedvideo.id + "/0.jpg"
        }
    }
    return packagebook.CoverImage.StandardUrl;
});

Handlebars.registerHelper('getPackageBookPlaceholder', function (packagebook) {
    if (packagebook.BookType === "video") {
        return getRoot() + "/img/video-placeholder.gif";
    }
    return getRoot() + "/img/trans.png";
});

Handlebars.registerHelper('hasModelNav', function (model, options) {
    var nav = false;
    if (currentPackage && currentPackage.bookID && currentPackage.data.PackageBooks.length) {
        var currentBook = _.find(currentPackage.data.PackageBooks, function (lb) { return lb.ID === Number(currentPackage.bookID) && lb.BookType.substring(0, 1) === currentPackage.bookType });
        var currentModelID = currentBook.ModelID;
        var modelBooks = _.where(currentPackage.data.PackageBooks, { ModelID: currentModelID });
        if (modelBooks.length > 1) {
            nav = true;
        }
    } else {
        if (model.Books.length > 1 || model.VideoBooks.length > 0) {
            nav = true
        }
    }
    if (nav) {
        return options.fn(this);
    }
    return options.inverse(this);
});

Handlebars.registerHelper('hasModelMobileNav', function (model, options) {
    var nav = false;
    if (checkScreenSize()) {
        if (currentPackage && currentPackage.bookID && currentPackage.data.PackageBooks.length) {
            var currentBook = _.find(currentPackage.data.PackageBooks, function (lb) { return lb.ID === Number(currentPackage.bookID) && lb.BookType.substring(0, 1) === currentPackage.bookType });
            var currentModelID = currentBook.ModelID;
            var modelBooks = _.where(currentPackage.data.PackageBooks, { ModelID: currentModelID });
            if (modelBooks.length > 1) {
                nav = true;
            }
        } else {
            if (model.Books.length > 1 || model.VideoBooks.length > 0) {
                nav = true
            }
        }
    }
    if (nav) {
        return options.fn(this);
    }
    return options.inverse(this);
});

Handlebars.registerHelper('ModelBookListInPackage', function () {
    let str = "";
    if (currentPackage.bookID && currentPackage.data.PackageBooks.length) {
        var currentBook = _.find(currentPackage.data.PackageBooks, function (lb) { return lb.ID === Number(currentPackage.bookID) && lb.BookType.substring(0, 1) === currentPackage.bookType });
        var currentModelID = currentBook.ModelID;
        var modelBooks = _.where(currentPackage.data.PackageBooks, { ModelID: currentModelID });
        _.each(modelBooks, function (b, i) {
            if (b.ID === Number(currentBook.ID)) {
                str += "<a href=\"" + b.BookLink + "\" class=\"active\">" + b.Title + "</a>"
            } else {
                str += "<a href=\"" + b.BookLink + "\">" + b.Title + "</a>"
            }
            if (i < (modelBooks.length - 1)) {
                str += "<span class=\"sep\">&squf;</span>";
            }
        });
    }
    return new Handlebars.SafeString(str);
});


Handlebars.registerHelper('ModelBookListInPackageAsTabs', function () {
    let str = "";
    if (currentPackage.bookID && currentPackage.data.PackageBooks.length) {
        var currentBook = _.find(currentPackage.data.PackageBooks, function (lb) { return lb.ID === Number(currentPackage.bookID) && lb.BookType.substring(0, 1) === currentPackage.bookType });
        var currentModelID = currentBook.ModelID;
        var modelBooks = _.where(currentPackage.data.PackageBooks, { ModelID: currentModelID });
        str += "<div class=\"tabs\"><ul>";
        _.each(modelBooks, function (b, i) {
            if (b.ID === Number(currentBook.ID)) {
                str += "<li class=\"is-active\"><a href=\"" + b.BookLink + "\">" + b.Title + "</a></li>"
            } else {
                str += "<li><a href=\"" + b.BookLink + "\">" + b.Title + "</a></li>"
            }
        });
        str += "</ul></div>";
    }
    return new Handlebars.SafeString(str);
});

Handlebars.registerHelper('ModelBookList', function (model) {
    let str = "";
    if (model.Books.length > 1 || model.VideoBooks.length > 0) {
        _.each(model.Books, function (b, i) {
            if (b.ID === Number(model.ActiveBook.ID) && model.BookType === "p") {
                str += "<a href=\"" + model.BookLink + "/p/" + b.ID + "\" class=\"active\">" + b.Title + "</a>"
            } else {
                str += "<a href=\"" + model.BookLink + "/p/" + b.ID + "\">" + b.Title + "</a>"
            }
            if (i < (model.Books.length - 1)) {
                str += "<span class=\"sep\">&squf;</span>";
            }
        });
        _.each(model.VideoBooks, function (vb, i) {
            if (vb.ID === Number(model.ActiveBook.ID) && model.BookType === "v") {
                str += "<a href=\"" + model.BookLink + "/v/" + vb.ID + "\" class=\"active\">" + vb.Title + "</a>"
            } else {
                str += "<a href=\"" + model.BookLink + "/v/" + vb.ID + "\">" + vb.Title + "</a>"
            }
            if (i < (model.VideoBooks.length - 1)) {
                str += "<span class=\"sep\">&squf;</span>";
            }
        });
    }
    return new Handlebars.SafeString(str);
});

Handlebars.registerHelper('ModelBookListAsTabs', function (model) {
    let str = "";
    if (model.Books.length > 1 || model.VideoBooks.length > 0) {
        str += "<div class=\"tabs\"><ul>";
        _.each(model.Books, function (b, i) {
            if (b.ID === Number(model.ActiveBook.ID) && model.BookType === "p") {
                str += "<li class=\"is-active\"><a href=\"" + model.BookLink + "/p/" + b.ID + "\">" + b.Title + "</a></li>"
            } else {
                str += "<li><a href=\"" + model.BookLink + "/p/" + b.ID + "\">" + b.Title + "</a></li>"
            }
        });
        _.each(model.VideoBooks, function (vb, i) {
            if (vb.ID === Number(model.ActiveBook.ID) && model.BookType === "v") {
                str += "<li class=\"is-active\"><a href=\"" + model.BookLink + "/v/" + vb.ID + "\">" + vb.Title + "</a></li>"
            } else {
                str += "<li><a href=\"" + model.BookLink + "/v/" + vb.ID + "\">" + vb.Title + "</a></li>"
            }
        });
        str += "</ul></div>";
    }
    return new Handlebars.SafeString(str);
});

Handlebars.registerHelper('ModelBookListIndex', function(model) {
    let str = "";    
    if (!currentPackage.code) {
        var publishedBooks = _.reject(model.Books, function(b) { return b.Title == "cover" });
        var modelbooks = _.sortBy(publishedBooks, "IsDefault").reverse();
        var index = 0;
        // _.each(modelbooks, function(b, i) {
        //     str += "<a class=\"book-link\" href=\"javascript:void(0)\" data-idbook=\"" + b.ID + "\" onclick=\"moveToBook(" + b.ID + "," + index + ")\">" + noBrackets(b.Title) + "</a>";
        //     index++;
        // });
        // var publishedVideoBooks = _.reject(model.VideoBooks, function(vb) { return vb.Title == "cover" });
        // _.each(publishedVideoBooks, function(vb, i) {
        //     str += "<a class=\"videobook-link\" href=\"javascript:void(0)\" data-idbook=\"" + vb.ID + "\" onclick=\"moveToVideoBook(" + vb.ID + "," + index + ")\">" + noBrackets(vb.Title) + "</a>";
        //     index++;
        // });
        if (model.BooksByType) {
            if (model.BooksByType.portfolio) {
                var b = model.BooksByType.portfolio;
                str += "<a class=\"book-link\" href=\"javascript:void(0)\" data-idbook=\"" + b.ID + "\" onclick=\"moveToBook(" + b.ID + "," + index + ")\">portfolio</a>";
                index++;
            }
            if (model.BooksByType.covers) {
                var b = model.BooksByType.covers;
                str += "<a class=\"book-link\" href=\"javascript:void(0)\" data-idbook=\"" + b.ID + "\" onclick=\"moveToBook(" + b.ID + "," + index + ")\">covers</a>";
                index++;
            }
            if (model.BooksByType.digitals) {
                var b = model.BooksByType.digitals;
                str += "<a class=\"book-link\" href=\"javascript:void(0)\" data-idbook=\"" + b.ID + "\" onclick=\"moveToBook(" + b.ID + "," + index + ")\">digitals</a>";
                index++;
            }
            if (model.BooksByType.videos) {
                var vb = model.BooksByType.videos;
                str += "<a class=\"videobook-link\" href=\"javascript:void(0)\" data-idbook=\"" + vb.ID + "\" onclick=\"moveToVideoBook(" + vb.ID + "," + index + ")\">videos</a>";
                index++;
            }
            if (model.BooksByType.runway) {
                var b = model.BooksByType.digitals;
                str += "<a class=\"book-link\" href=\"javascript:void(0)\" data-idbook=\"" + b.ID + "\" onclick=\"moveToBook(" + b.ID + "," + index + ")\">runway</a>";
                index++;
            }
        }
        if (hasExcludedFeature(model, "bio")) {
            str += "<a class=\"bio-link\" href=\"javascript:void(0)\" onclick=\"moveToBio(" + index + ")\">biography</a>";
        }
        if (model.InstagramUsername) {
            str += "<a class=\"instagram-link\" href=\"https://www.instagram.com/" + model.InstagramUsername + "\" target=\"_blank\">instagram</a>";
        }
        var tt = getModelSocialLink(model, "TikTok")
        if (tt) {
            str += "<a class=\"tiktok-link\" href=\"" + tt + "\" target=\"_blank\">tik tok</a>";
        }
    } else {
        var modelpackagebooks = getModelPackageBooksMenu()
        _.each(modelpackagebooks, function(b, i) {
            classforbook = "book-link";
            if (b.BookType === "video") {
                classforbook = "videobook-link"
            }
            if (b.SentInPackage) {
                classforbook += " book-link-sent"
            }
            if (b.ID == Number(currentPackage.bookID)) {
                classforbook += " book-link-active"
            }
            if (b.BookType === "video") {
                str += "<a class=\"" + classforbook + "\" href=\"javascript:void(0)\" data-idbook=\"" + b.ID + "\" onclick=\"moveToVideoBook(" + b.ID + ", " + i + ")\">" + noBrackets(b.Title) + "</a>";
            } else {
                str += "<a class=\"" + classforbook + "\" href=\"javascript:void(0)\" data-idbook=\"" + b.ID + "\" onclick=\"moveToBook(" + b.ID + ", " + i + ")\">" + noBrackets(b.Title) + "</a>";
            }
            
        });
        //ADDING TIKTOK
        var tt = getModelTikTok(model);
        if (tt) {
            str += "<a class=\"tiktok-link\" href=\"" + tt + "\" target=\"_blank\">tik tok</a>";
        }
        //ADDING INSTAGRAM
        if (model.InstagramUsername) {
            str += "<a class=\"instagram-link\" href=\"https://www.instagram.com/" + model.InstagramUsername + "\" target=\"_blank\">instagram</a>";
        }
        // if (hasExcludedFeature(model, "bio")) {
        //     str += "<a class=\"bio-link\" href=\"javascript:void(0)\" onclick=\"moveToBio()\">bio</a>";
        // }
    }
    return new Handlebars.SafeString(str);
});

Handlebars.registerHelper('modelBack', function (conf) {
    let backlink = "";
    let backlinktext = "back"
    if (currentPackage) {
        if (currentPackage.code && currentPackage.bookID && currentPackage.hasBack) {
            backlink = getRoot() + '/w/package/' + currentPackage.code;
            backlinktext = "back to package";
        }
    } else {
        backlink = "/w/models/" + currentPage.navigation;
        backlinktext = "back to " + pageConfiguration.displayName;
    }
    if (backlink) {
        return new Handlebars.SafeString("<a href=\"" + backlink + "\"><i class=\"fal fa-arrow-left\"></i>&nbsp;" + backlinktext + "</a>");
    } else {
        return null;
    }
});

Handlebars.registerHelper('modelBackLink', function () {
    let backlink = "";
    if (currentPackage && currentPackage.code) {
        if (currentPackage.bookID && currentPackage.hasBack) {
            backlink = getRoot() + '/w/package/' + currentPackage.code;
        } 
    } else {
        backlink = "/w/models/" + currentPage.navigation;
    }
    return backlink;
});

Handlebars.registerHelper('downloadAllowed', function (model, options) {
    if (currentPackage && currentPackage.code) {
        if (config_nw_website.configurations.packages && config_nw_website.configurations.packages.downloadPictures) {
            return options.fn(this);
        }
    } else {
        if (config_nw_website.configurations.books && config_nw_website.configurations.books.downloadPictures) {
            return options.fn(this);
        }
    }
    return options.inverse(this);
});

Handlebars.registerHelper('showPackageTitle', function (options) {
    var spt = config_nw_website.configurations.packages.showTitle;
    if (spt) {
        return options.fn(this);
    }
    return options.inverse(this);
});

Handlebars.registerHelper('showNotesOnList', function (options) {
    var spt = config_nw_website.configurations.packages.showNotesOnList;
    if (spt && !checkScreenSize()) {
        return options.fn(this);
    }
    return options.inverse(this);
});

Handlebars.registerHelper('showNotesOnBook', function (options) {
    var spt = config_nw_website.configurations.packages.showNotesOnBook;
    if (spt && currentPackage.code) {
        return options.fn(this);
    }
    return options.inverse(this);
});


Handlebars.registerHelper('BookIndexPortfolioCover', function (books) {
    var htmlstring = "";
    var portfolio = _.findWhere(books, { IsDefault: true });
    if (portfolio) {
        var coverpic = "";
        var firstpicture = portfolio.Pages.find(function (page) {
            return (page.Picture.Orientation === "p");
        })
        if (!firstpicture) {
            firstpicture = portfolio.Pages.find(function (page) {
                return (page.Picture.Orientation === "p");
            })
        }
        if (firstpicture) {
            coverpic = firstpicture.Picture.URL;
        } else {
            coverpic = portfolio.Pages[0].Picture.URL;
        }
        htmlstring = "<div class=\"cover-container portfolio-cover\" onClick=\"book_index_openBook(" + portfolio.ID + ", false)\"><img src=\"" + coverpic + "\" /><h2>portfolio</h2></div>";
    }
    return new Handlebars.SafeString(htmlstring);
});

Handlebars.registerHelper('BookIndexBookCovers', function (books) {
    var htmlstring = "";
    var booksNoDefault = _.reject(books, function (b) { return b.IsDefault; });
    for (var b of booksNoDefault) {
        var coverpic = "";
        var firstpicture = b.Pages.find(function (page) {
            return (page.Picture.Orientation === "p");
        })
        if (!firstpicture) {
            firstpicture = b.Pages.find(function (page) {
                return (page.Picture.Orientation === "p");
            })
        }
        if (firstpicture) {
            coverpic = firstpicture.Picture.URL;
        } else {
            coverpic = b.Pages[0].Picture.URL;
        }
        htmlstring += "<div class=\"cover-container book-cover\" onClick=\"book_index_openBook(" + b.ID + ", false)\"><img src=\"" + coverpic + "\" /><h2>" + b.Title + "</h2></div>";
    }
    return new Handlebars.SafeString(htmlstring);
});

Handlebars.registerHelper('VideoBookIndexBookCovers', function (books) {
    var htmlstring = "";
    for (var b of books) {
        coverpic = b.Pages[0].PlayableVideo.Thumb.Url;
        htmlstring += "<div class=\"videobook-cover\" onClick=\"book_index_openBook(" + b.ID + ", true)\"><img src=\"" + coverpic + "\" /><h2>" + b.Title + "</h2></div>";
    }
    return new Handlebars.SafeString(htmlstring);
});

Handlebars.registerHelper('ifStartsWithRightPicture', function (page, options) {
    if (page.Picture1 && page.Picture1.Orientation === "p" && page.Picture2.ID === 0) {
        return options.fn(this);
    }
    if (page.Picture2 && page.Picture2.Orientation === "p" && page.Picture2.ID === 0) {
        return options.fn(this);
    }
    return options.inverse(this);
});


Handlebars.registerHelper('getGalleryRoot', function() {
    return getGalleryRoot();
});

Handlebars.registerHelper('getResizedURL', function(item) {
    return "/_data/galleries/" + item.GalleryID + "/r_" + item.FileName;
});

Handlebars.registerHelper('getGalleryLink', function(item) {
    let linkdest = "";
    switch (item.LinkType) {
        case 2:
            linkdest = "/w/models/search/" + item.ContentLink + "-";
            break;
        case 1:
            linkdest = item.ContentLink;
            break;
        case 0:
        default:
            linkdest = "#";
    }
    return linkdest;
});
Handlebars.registerHelper('getRoot', function() {
    return getRoot();
});

Handlebars.registerHelper('getAgencyName', function() {
    return config_nw_website.configurations.agencyName || "";
});

Handlebars.registerHelper('ifHasLogo', function(options) {
    const logo = config_nw_website.configurations.logo;
    if (logo !== "text") {
      return options.fn(this);
    }
    return options.inverse(this);
});

Handlebars.registerHelper('getLogo', function() {
    return config_nw_website.configurations.logo || "logo.png";
});

Handlebars.registerHelper('json', function(context) {
    return JSON.stringify(context);
});

Handlebars.registerHelper('RemoveAsterisks', function(string) {
    return removeAsterisks(string);
});

function renderTemplate(templateName, data, container) {
    if (!data) {
        data = {}
    }
    container.html("");
    let t = JST[templateName];
    let h = null;
    if (t) {
        h = t(data);
    } else {
        let obj_empty = {};
        let t_empty = JST["404"];
        h = t_empty(obj_empty);
    }
    container.html(h);
    if (isDebug()) {
        replaceLinks(container);
    }
    $(".tooltipNote").tooltipster({
        theme: 'tooltipster-nw'
	});
}

Handlebars.registerHelper('RemoveAsterisks', function(string) {
    return removeAsterisks(string);
});

Handlebars.registerHelper('each_with_sort', function (array, key, opts) {
    var data, e, i, s, _i, _len;
    if (opts.data) {
        data = Handlebars.createFrame(opts.data);
    }
    array = array.sort(function (a, b) {
        a = a[key];
        b = b[key];
        if (a > b) {
            return 1;
        }
        if (a === b) {
            return 0;
        }
        if (a < b) {
            return -1;
        }
    });
    s = '';
    for (i = _i = 0, _len = array.length; _i < _len; i = ++_i) {
        e = array[i];
        if (data) {
            data.index = i;
        }
        s += opts.fn(e, {
            data: data
        });
    }
    return s;
});
Handlebars.registerHelper('ifEnoughFollowers', function (v1, options) {
  const enough = config_nw_website.configurations.modelsInstagramAdvanced.minFollowers;
  if (v1 && (!enough || v1 > enough)) {
    return options.fn(this);
  }
  return options.inverse(this);
});

Handlebars.registerHelper('ifShowInstagram', function (page, options) {
  var show = currentPackage.code ? config_nw_website.configurations.modelsInstagramAdvanced.showOnPackage : config_nw_website.configurations.modelsInstagramAdvanced.showOnList;
  if (show) {
    return options.fn(this);
  }
  return options.inverse(this);
});

Handlebars.registerHelper('ifShowFollowers', function (options) {
  var show = currentPackage.code ? config_nw_website.configurations.modelsInstagramAdvanced.followersOnPackageBook : config_nw_website.configurations.modelsInstagramAdvanced.followersOnDetails;
  if (show) {
    return options.fn(this);
  }
  return options.inverse(this);
});
Handlebars.registerHelper('bookModelName', function (fn, ln) {
    var page = inPackage() ? "book" : "details";
    var n = $.trim(modelName(fn, ln, page));
    return new Handlebars.SafeString(removeAsterisks(n));
});

Handlebars.registerHelper('modelNameClass', function(model) {
    if (model.Name.length > 12) {
        return "long-name";
    }
    return "";
});

Handlebars.registerHelper('getModelDivision', function () {
    return currentPage.navigation;
});

Handlebars.registerHelper('getFeatureFirstMetric', function (feat) {
    if (feat.values.length) {
        return feat.values[0].value;
    }
    return feat.value;
});

Handlebars.registerHelper('nameConfiguration', function (firstName, lastName, page) {
    return $.trim(modelName(firstName, lastName, page));
});

Handlebars.registerHelper('nameConfigurationBreak', function (firstName, lastName) {
    let nameConfigured = $.trim(firstName);
    if (lastName) {
        nameConfigured += "<br/>" + $.trim(lastName);
    }
    return new Handlebars.SafeString(removeAsterisks(nameConfigured));
});

Handlebars.registerHelper('nameConfigurationSingleLine', function (firstName, lastName) {
    let nameConfigured = $.trim(firstName.toUpperCase());
    if (lastName) {
        nameConfigured += " " + $.trim(lastName.toUpperCase());
    }
    return new Handlebars.SafeString(nameConfigured);
});

Handlebars.registerHelper('urlName', function (firstName, lastName) {
    return urlName(firstName, lastName);
});


Handlebars.registerHelper('getFeatSingleMetric', function(model, metric) {
    //var arrfeat = ["height","bust","waist","hips","shoes","hair","eyes"]
    //if (currentPage.context == "toronto") {
        if (model.Gender === "M") {
            arrfeat = ["height","waist","pants inseam", "suit men","shoes (men)","hair","eyes"];
        } else {
            arrfeat = ["height","bust","bra","waist","hips","shoes (women)","hair","eyes"];
        }
    //}
    var feattoshow = _.filter(model.Features, function(feat) {
        return arrfeat.includes(feat.name.toLowerCase())
    });
    
    var shoemetric = "US";
    if (metric === "metric") {
        shoemetric = "EU";
    }

    var strfeat = "<div class=\"" + metric + "\">";
    strfeat += "<ul>";
    _.each(feattoshow, function(f) {
        switch (f.name) {
            case "height":
            case "bust":
            case "pants_inseam":
            case "waist":
            case "hips":
                if (f.values.length) {
                    var v = _.findWhere(f.values, {code: metric});                
                    strfeat += "<li>" + parseFeature(f.name, v.value) + "</li>";
                }
                break;
            case "shoes (women)":
            case "shoes (men)":
                if (f.values.length) {
                    var v = _.findWhere(f.values, {code: shoemetric});                
                    strfeat += "<li>" + parseFeature(f.name, v.value) + "</li>";
                }
                break;
            default:
                if (f.values.length) {
                    var v = f.values[0];
                    //let v2 = f.values[1];
                    strfeat += "<li>" + parseFeature(f.name, v.value) + "</li>";
                } else {
                    if (f.value) {
                        strfeat += "<li>" + parseFeature(f.name, f.value) + "</li>";
                    }
                }
        }
    })
    strfeat += "</ul>";
    // strfeat += "<ul class=\"metric-selector\">";
    // if (metric == "inches") {
    //     strfeat += "<li><a href=\"javascript:void(0)\" onclick=\"switchMetric('inches')\" class=\"active\">us</a>&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"switchMetric('metric')\">metric</a></li>";
    // } else {
    //     strfeat += "<li><a href=\"javascript:void(0)\" onclick=\"switchMetric('inches')\">us</a>&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"switchMetric('metric')\" class=\"active\">metric</a></li>";
    // }
    // strfeat += "</ul>";
    strfeat += "</div>";
    return new Handlebars.SafeString(strfeat);
});

function hasExcludedFeature(model, featname) {
    if (model.ExcludedFeatures && model.ExcludedFeatures.length > 0) {
        var sk = _.find(model.ExcludedFeatures, function(f) {
            return f.name.toLowerCase() === featname.toLowerCase();
        });
        if (sk.value) {
            return true;
        }
    }
    return false;
}

function getExcludedFeature(model, featname) {
    var sk = "";
    if (model.ExcludedFeatures && model.ExcludedFeatures.length > 0) {
        var skf = _.find(model.ExcludedFeatures, function(f) {
            return f.name.toLowerCase() === featname.toLowerCase();
        });
        console.log("skf",skf)
        if (skf) {
            sk = skf.value;
        }
    }
    console.log("model",model)
    return sk;
}

function parseFeature(name,value) {
    switch (name.toLowerCase()) {
        case "bra":
            return "<span>b</span><em>" + value.toUpperCase().replace(' ','') + "</em>";
        case "suit men":
            return "<span>suit</span><em>" + value.toUpperCase().replace(' ','') + "</em>";
        case "height":
            return "<em>" + value + "</em>";
        case "bust":
        case "waist":
        case "hips":
            return "<span>" + name.toLowerCase().substring(0,1) + "</span><em>" + value.replace(/"/g,'').replace(' 1/2','.5') + "</em>";
        case "shoes (women)":
        case "shoes (men)":
            return "<span>shoe</span><em>" + value.toLowerCase().replace(' 1/2','.5') + "</em>";
        case "pants inseam":
            return "<span>inseam</span><em>" + value.replace(/"/g,'').replace(' 1/2','.5') + "</em>";
        default:
            return "<span>" + name + "</span><em>" + value.toLowerCase() + "</em>";
    }
}

Handlebars.registerHelper('getSpecificFeature', function (model, featurename) {
    const feat = _.findWhere(model.Features, { name: featurename });
    if (feat && feat.value.length > 0) {
        return new Handlebars.SafeString(feat.value.replace(/(?:\r\n|\r|\n)/g, '<br>'));
    } else {
        return ""
    }
});

Handlebars.registerHelper('getSpecificFeatureSingleMetric', function (model, featurename, metric) {
    const feat = _.findWhere(model.Features, { name: featurename });
    if (feat && feat.value.length > 0) {
        var val = feat.value;
        if (metric) {
            if (feat.values.length) {
                var v = _.findWhere(feat.values, {code: metric});                
                val = v.value;
            }
        }
        return new Handlebars.SafeString(val.replace(/(?:\r\n|\r|\n)/g, '<br>'));
    } else {
        return ""
    }
});

Handlebars.registerHelper('getSpecificFeaturesLine', function (model, featurenames) { //featurenames è stringa con feature names separati da pipe
    const arrfeat = featurenames.split("|");
    const feattoshow = _.filter(model.Features, function (feat) {
        return arrfeat.includes(feat.name)
    });
    let strfeat = "";
    _.each(feattoshow, function (f) {
        if (f.name != "shoes") {
            if (f.values.length) {
                let v = _.findWhere(f.values, { code: "metric" });
                strfeat += "<span>" + v.value + "CM</span>"
            }
        } else {
            if (f.values.length) {
                let v = _.findWhere(f.values, { code: "EU" });
                strfeat += "<span>" + v.value + "</span>"
            }
        }
    })
    return new Handlebars.SafeString(strfeat);
});

Handlebars.registerHelper('hasExtFeat', function (model, featname, options) {
    if (model.ExcludedFeatures && model.ExcludedFeatures.length > 0) {
        var sk = _.find(model.ExcludedFeatures, function (f) {
            return f.name.toLowerCase() === featname.toLowerCase();
        });
        return options.fn(this);
    }
    return options.inverse(this);
});

Handlebars.registerHelper('getExtFeat', function (model, featname) {
    var sk = "";
    if (model.ExcludedFeatures && model.ExcludedFeatures.length > 0) {
        var skf = _.find(model.ExcludedFeatures, function (f) {
            return f.name.toLowerCase() === featname.toLowerCase();
        });
        if (skf) {
            sk = skf.value;
        }
    }
    return new Handlebars.SafeString(sk);
});

Handlebars.registerHelper('InstagramDetails', function (model) {
    var show = currentPackage.code ? config_nw_website.configurations.modelsInstagramAdvanced.showOnPackageBook : config_nw_website.configurations.modelsInstagramAdvanced.showOnDetails;
    var str = "";
    if (show) {
        if (model.InstagramUsername) {
            str += "<div class=\"social-links\"><a href=\"https://www.instagram.com/" + model.InstagramUsername + "\" target=\"_blank\">@" + model.InstagramUsername + "<br />";
            var showfol = currentPackage.code ? config_nw_website.configurations.modelsInstagramAdvanced.followersOnPackageBook : config_nw_website.configurations.modelsInstagramAdvanced.followersOnDetails;
            if (showfol) {
                const enough = config_nw_website.configurations.modelsInstagramAdvanced.minFollowers;
                if (model.InstagramFollowers && (!enough || model.InstagramFollowers > enough)) {
                    str += ParseFollowers(model.InstagramFollowers) + " followers on <i class=\"fa-brands fa-instagram\"></i> instagram";
                }
            }
            str += "</a></div>";
        }
        return new Handlebars.SafeString(str);
    }
    return str;
});

Handlebars.registerHelper('LinksToSocials', function (socials) {
    let str = "";
    if (socials && socials.length > 0) {
        var showInstagram = config_nw_website.configurations.modelsSocials.instagram;
        var showTikTok = config_nw_website.configurations.modelsSocials.tikTok;
        var showModelsCom = config_nw_website.configurations.modelsSocials.modelsCom;
        if (showInstagram) {
            const soc_inst = _.findWhere(socials, { type: "Instagram" })
            if (soc_inst && soc_inst.link) {
                let instalink = soc_inst.link;
                if (instalink.indexOf("instagram.com") < 0) {
                    instalink = "https://instagram.com/" + instalink;
                }
                str += "<a class=\"social-links-instagram\" href=\"" + instalink + "\" target=\"_blank\"><i class=\"fa-brands fa-instagram\"></i></a>";
            }
        }
        if (showModelsCom) {
            const soc_modcom = _.findWhere(socials, { type: "Models.com" })
            if (soc_modcom && soc_modcom.link) {
                let modelscomlink = soc_modcom.link;
                if (modelscomlink.indexOf("models.com") < 0) {
                    modelscomlink = "https://www.models.com/models/" + modelscomlink;
                }
                str += "<a class=\"social-links-modelscom\" href=\"" + modelscomlink + "\" target=\"_blank\"><img src=\"/img/logo-models-com.png\" alt=\"model's models.com page\" /></a>";
            }
        }
        if (showTikTok) {
            const soc_tiktok = _.findWhere(socials, { type: "TikTok" })
            if (soc_tiktok && soc_tiktok.link) {

                let tiktoklink = soc_tiktok.link;
                if (tiktoklink.indexOf("tiktok.com") < 0) {
                    tiktoklink = "https://www.tiktok.com/" + tiktoklink;
                }
                str += "<a class=\"social-links-tiktok\" href=\"" + tiktoklink + "\" target=\"_blank\"><i class=\"fa-brands fa-tiktok\"></i></a>";
            }
        }
        return new Handlebars.SafeString(str);
    }
    return str;
});
Handlebars.registerHelper('hasSubNav', function(menuItem) {
    if (menuItem) {
        return true
    } 
});

Handlebars.registerHelper('buildLink', function(menuItem) {
    let link = "/w/" + menuItem.areaName + "/" + menuItem.name;
    if (menuItem.defaultLanguage) {
        link += "/" + menuItem.defaultLanguage;
    }
    return link;
});

Handlebars.registerHelper('buildPageName', function(menuItem) {
    let pn = menuItem.areaName + "/" + menuItem.name;
    return pn;
});


Handlebars.registerHelper('getBreadcrumbs', function(conf) {
    let breadcrumbsHtml = "";
    if (currentPage.area === "models" && boards() && pageConfiguration && !_.isEmpty(pageConfiguration.params)) {
        breadcrumbsHtml += "<li><a href=\"javascript:void(0)\">models</a></li>";
        if (currentPage.modelID) {
            breadcrumbsHtml += "<li><a href=\"/w/models/" + currentPage.navigation + "\">"  + pageConfiguration.displayName + "</a></li><li class=\"is-active\"><a class=\"breadcrumbs-modelname-placeholder\" href=\"/w/models/" + currentPage.navigation + "/" + currentPage.modelID + "-" + urlName(currentPage.modelFirstName, currentPage.modelLastName) + "\" aria-current=\"page\">...</a></li>";
        } else {
            breadcrumbsHtml += "<li class=\"is-active\"><a href=\"/w/models/" + currentPage.navigation + "\" aria-current=\"page\">"  + pageConfiguration.displayName + "</a></li>";
        }
    }
    return new Handlebars.SafeString(breadcrumbsHtml);
});

Handlebars.registerHelper('ifHasSearch', function (conf, options) {
    var searchnav = _.findWhere(config_nw_website.navigation, {role: "search"});
    if (searchnav) {
      return options.fn(this);
    }
    return options.inverse(this);
  });
Handlebars.registerHelper('joinTags', function(tags) {
    var ts = [];
    _.each(tags, function(t) {
        ts.push(t.Tag.toLowerCase());
    })
    if (ts.length) {
        return ts.join(",");
    }
    return "";
});

Handlebars.registerHelper('joinModels', function(models) {
    var ms = [];
    _.each(models, function(m) {
        var mname = $.trim(m.Name);
        if (m.Surname) {
            mname += " " + $.trim(m.Surname);
        }
        ms.push($.trim(mname));
    })
    if (ms.length) {
        return ms.join(",");
    }
    return "";
});
Handlebars.registerHelper('useBw', function() {
    var bw = config_nw_website.configurations.list.blackAndWhiteCover;
    if (bw) {
      return " bw";
    }
    return "";
});

Handlebars.registerHelper('gridMax', function() {
    var m = config_nw_website.configurations.list.gridMaxNumberPerRow;
    return (" max-" + m.toString());
});

Handlebars.registerHelper('ifUseFeatures', function(options) {
    var f = config_nw_website.configurations.list.featuresOnList
    if (f) {
        return options.fn(this);
    } else {
        return options.inverse(this);
    }
    
});

Handlebars.registerHelper('extendedPicture', function(page, element) {
    if (page.Picture.ID != 0) {
        return page.Picture[element];
    } else {
        return page.PictureExt[element];
    }
})

Handlebars.registerHelper('pictureExists', function(Picture) {
    if (Picture) {
        if (Picture.ID != 0) {
            return true
        }
    }
    return false
});

Handlebars.registerHelper('picturesExists', function(DblPage) {
    if (DblPage.Picture1 && DblPage.Picture1.ID != 0 || DblPage.Picture2 && DblPage.Picture2.ID != 0) {
        return true;
    } else {
        return false;
    }
});

Handlebars.registerHelper('pictureOrientation', function(Picture) {
    if (Picture.IsDbl || Picture.Orientation == "l") {
        return "picture-double"  
    } else { 
        if (Picture.Width/Picture.Height > 0.71) {
            return "picture-single height-constrained" 
        } 
        return "picture-single" 
    }
});

Handlebars.registerHelper('isLandscape', function(Picture) {
    if (Picture.IsDbl || Picture.Orientation == "l") {
        return true  
    }
    return false
})

Handlebars.registerHelper('pictureRatio', function(Picture) {
    return Picture.Width/Picture.Height;
});

Handlebars.registerHelper('note', function(Picture) {
    var spt = false;
    if (currentPackage && config_nw_website.configurations.packages.showNotesOnPictures) {
        spt = true;
    }
    if (!currentPackage && config_nw_website.configurations.books.showNotesOnPictures) {
        spt = true
    }
    return (spt && Picture.Note) ? new Handlebars.SafeString("<span class=\"book-img-note\">" + Picture.Note + "</span>") : null;
});
Handlebars.registerHelper('getVideoProviderName', function(videobook) {
    if (videobook.Type) {
        switch (videobook.Type) {
            case 2:
                return "youtube"
            case 4:
            default:
                return "vimeo"
        }
    } else {
        const vid = parseVideoURL(videobook.URL);
        return vid.provider;
    }
});

Handlebars.registerHelper('getVideoID', function(videobook) {
    const vid = parseVideoURL(videobook.URL);
    return vid.id;
});



Handlebars.registerHelper('getVideoEmbed', function(videobook) {
    var provider = "vimeo";
    var vid = parseVideoURL(videobook.URL);
    if (videobook.Type && videobook.Type == 2) {
        provider = "youtube";
    } else {
        provider = vid.provider;
    }
    if (provider == "youtube") {
        return new Handlebars.SafeString("<div class=\"video-iframe-container\"><iframe src=\"https://www.youtube.com/embed/" + vid.id + "?modestbranding=1&amp;showinfo=0&controls=1&amp;rel=0&amp;enablejsapi=1&autoplay=0&amp;autohide=1\" allowfullscreen=\"\" allowtransparency=\"\" allow=\"autoplay\"></iframe></div>");
    } else {
        var vimeoembedstring = "<p style=\"text-align:center;width:100%;color:#fff;margin-bottom:.5rem;\"><a href=\"javascript:void(0)\" onClick=\"downloadVideo('" + vid.id + "')\"><i class=\"fas fa-cloud-arrow-down\"></i>&nbsp;download video</a></p><div class=\"video-iframe-container\">";
        vimeoembedstring += "<iframe src=\"https://player.vimeo.com/video/" + vid.id;
        if (vimeoembedstring.indexOf("?") > -1) {
            vimeoembedstring += "&";
        } else {
            vimeoembedstring += "?";
        }
        vimeoembedstring += "background=0&amp;controls=1&amp;autoplay=0&amp;loop=1&amp;byline=0&amp;title=0\" frameborder=\"0\" title=\"video\" webkitallowfullscreen=\"\" mozallowfullscreen=\"\" allowfullscreen=\"\"></iframe>";
        vimeoembedstring += "</div>";
        return new Handlebars.SafeString(vimeoembedstring);
        
        //return new Handlebars.SafeString("<p style=\"text-align:center;width:100%;color:#fff;margin-bottom:.5rem;\"><a href=\"javascript:void(0)\" onClick=\"downloadVideo(" + vid.id + ")\"><i class=\"fas fa-cloud-arrow-down\"></i>&nbsp;download video</a></p><div class=\"video-iframe-container\"><iframe src=\"https://player.vimeo.com/video/" + vid.id + "?background=0&amp;controls=1&amp;autoplay=0&amp;loop=1&amp;byline=0&amp;title=0\" frameborder=\"0\" title=\"video\" webkitallowfullscreen=\"\" mozallowfullscreen=\"\" allowfullscreen=\"\"></iframe></div>");
    }
});
let browserurl = "";

$(document).ready(function() {
    screenWidth = window.innerWidth;    
    loadWebFont();
    if (isDebug()) {
        replaceLinks();

        window.onpopstate = function (event) {
            browserurl = window.location.pathname;
            parseUrl(true);
        };
        $(window).bind('hashchange', function () {
            browserurl = window.location.hash.replace('#','');
            parseUrl();
        });

        let windowLocationHash = window.location.hash;    
        if (windowLocationHash) {
            $(window).trigger("hashchange");
        }
        parseUrl();
    } else {
        parseUrl();
    }
    
    
});

let replaceLinks = function(cont) {
    if (isDebug()) {
        const $container = cont || $("body")
        $container.find("a[href^='/']:not([href*='.'])").each(function(i, item) {
            $(item).addClass("internal-link");
            $(item).off("click").click(function(e) {
                const beforeroute = $(item).attr("onclick");
                if (beforeroute) {
                    eval(beforeroute);
                }
                browserurl = $(item).attr("href");
                e.preventDefault();
                parseUrl();
            })        
        })
    } else {
        return null;
    }        
}
var ig_user_id = config_nw_website.configurations.agencyInstagram.userID;
//var ig_access_token = config_nw_website.configurations.agencyInstagram.accessToken;
var ig_new_access_token = config_nw_website.configurations.agencyInstagram.newAccessToken;

function loadInstagram() {
    var dfd = jQuery.Deferred();
    var pictoload = 16;
    var url = "https://graph.instagram.com/me/media?fields=id,caption,media_url,media_type,permalink&access_token=" + ig_new_access_token;
    $.getJSON(url, function (data) {
        var added = 0;
        if (data.meta && data.meta.error_message) {
            console.error("INSTAGRAM ERROR: ", data.meta.error_message);
        }
        $.each(data.data, function (i, val) {
            if ((val.media_type == "IMAGE" || val.media_type == "CAROUSEL_ALBUM") && added < pictoload) {
                $(".instagram-img-strip").append("<div class=\"column is-one-quarter-desktop is-one-third-tablet is-half-mobile\"><a href=\"" + val.permalink + "\" target=\"_blank\" style=\"background-image:url(" + val.media_url + ")\"><br/></a></div>");
                added++;
            }
        });
        $(".instagram-img-strip").append("<br style=\"clear:both\">");
        dfd.resolve();
    }).fail(function () {
        dfd.reject();
    });
}

function ParseFollowers(followersNumber) {
    var followers = "";
    if (followersNumber > 0) {
        var milfoll = Math.floor(followersNumber / 1000000);
        if (milfoll > 0) {
            followers += milfoll.toString();
            var milfoll2 = followersNumber % 1000000;
            var milfoll3 = Math.floor(milfoll2 / 100000);
            if (milfoll3 > 0) {
                followers += ("." + milfoll3.toString());
            }
            followers += "mil";
        } else {
            var milfoll3 = Math.floor(followersNumber / 1000);
            if (milfoll3 > 0) {
                followers += milfoll3.toString() + "k";
            } else {
                followers += followersNumber;
            }
        }
    }
    return followers;
}

function loadModelsInstagramManualFollowers(modellist) {
    var list = [];
    //data processing for model list
    for (var i=0; i < modellist.length; i++) {
        var mymodel = loadModelInstagramManualFollowers(modellist[i]);
        list.push(mymodel);
    }
    return list;
}

function loadModelInstagramManualFollowers(model) {
    var mymodel = model;
    //if (!mymodel.InstagramUsername) {
        if (mymodel.Socials && mymodel.Socials.length > 0) {
            var instasocial = _.findWhere(mymodel.Socials, {type: "Instagram"});
            if (instasocial) {
                if (instasocial.link.indexOf("@") === 0) {
                    mymodel.InstagramUsername = instasocial.link.replace("@","");
                } else {
                    var regExp = /(?:(?:http|https):\/\/)?(?:www.)?(?:instagram.com|instagr.am)\/([A-Za-z0-9-_\.]+)/im
                    var match = instasocial.link.match(regExp);
                    if (match && match.length && match.length > 1) {
                        mymodel.InstagramUsername = match[1]
                    }
                    if (!mymodel.InstagramUsername) {
                        mymodel.InstagramUsername = instasocial.link;
                    }
                }
                
                if (instasocial.followers) {
                    if (isNaN(instasocial.followers)) {
                        mymodel.InstagramFollowersParsed = instasocial.followers;
                        mymodel.InstagramFollowers = 0
                    } else {
                        mymodel.InstagramFollowersParsed = ParseFollowers(Number(instasocial.followers));
                        mymodel.InstagramFollowers = Number(instasocial.followers);
                    }
                }
            }
        }
    //}
    return mymodel;
}
let modelName = function(firstName, lastName, page, sep) {
    const separator = sep || " ";
    let nameConfigured = "";
    [firstName, lastName].forEach(function (name, index) {
        let userInputName = config_nw_website.configurations.nameConfig[page][index];
        name == "" ? name = " " : null;
        switch (userInputName) {
            case "n":
                name = (name[0]).toLowerCase();
                break;
            case "N":
                name = (name[0]).toUpperCase();
                break;
            case "name":
                name = name.toLowerCase();
                break;
            case "Name":
                name = (name[0]).toUpperCase() + name.substr(1).toLowerCase();
                break;
            case "NAME":
                name = name.toUpperCase();
                break;
            case "":
                name = "";
                break;
            default:
                name = (name[0]).toUpperCase() + name.substr(1).toLowerCase();
        }
        index == 0 ? nameConfigured = $.trim(name) : nameConfigured += (name ? (separator + $.trim(name)) : "");
    });
    return $.trim(nameConfigured);
}

let urlName = function(fn, ln) {
    let n = $.trim(fn);
    if (ln) {
        n += "-" + $.trim(ln);
    }
    n = removeAsterisks(n);
    n = removeDot(n);
    n = removeAmpersand(n);
    n = removeSpaces(n);
    return encodeURIComponent(n.toLowerCase());
}
const saveScroll = function (reset) {
    if (reset) {
        listScroll = 0;
    } else {
        listScroll = $(window).scrollTop();
    }
    Cookies.set("listScroll", listScroll);
}

const getFilteredList = function (list, letter) {
    const mylist = _.filter(list, function (model) {
        return $.trim(model.Name).toLowerCase().startsWith(letter)
    })
    return mylist
}

var searchFeatValues = {}

let transformFeatures = function (model, featurestoextract) {
    if (!featurestoextract) {
        featurestoextract = getFeaturesToExtract()
    }
    var mymodel = model;
    mymodel.ExcludedFeatures = [];
    if (mymodel.Features && mymodel.Features.length && featurestoextract.length) {
        for (var f = 0; f < featurestoextract.length; f++) {
            var feat = featurestoextract[f];
            var myfeat = _.find(mymodel.Features, function(fea) {
                return fea.name.toLowerCase() === feat.toLowerCase();
            });
            if (myfeat) {
                mymodel.ExcludedFeatures.push(myfeat);
                mymodel.Features = _.filter(mymodel.Features, function (fea) {
                    return fea.name.toLowerCase() !== feat.toLowerCase();
                });
            }
        }
    }
    var useAdvancedSearch = false;
    mymodel.SearchFeatures = {};
    if (config_nw_website.configurations.advancedSearch && config_nw_website.configurations.advancedSearch.enabled) {
        useAdvancedSearch = true;
    }
    if (mymodel.Features && mymodel.Features.length && useAdvancedSearch > 0) {
        for (var i2 = 0; i2 < mymodel.Features.length; i2++) {
            var f = mymodel.Features[i2];
            var fv = "";
            var fn = "";
            if (f.value) {
                fv = f.value;
                fn = f.name.toLowerCase();
                if (["height", "bust", "hips", "waist"].indexOf(fn) >= 0) {
                    if (fv.indexOf(" - ") >= 0) {
                        fv = Number(fv.substring(0, fv.indexOf(" - ")));
                    }
                }
                if (fn === "shoes") {
                    if (fv.indexOf(" - ") >= 0) {
                        fv = Number(fv.substring(0, fv.indexOf(" - ")).replace(",", "."));
                    }
                }
                if (searchFeatValues[fn] && searchFeatValues[fn].indexOf(fv) === -1) {
                    searchFeatValues[fn].push(fv);
                }
                mymodel.SearchFeatures[fn] = fv;
            }
        }
    }
    return mymodel;
}

const getFeaturesToExtract = function() {
    var featurestoextract = [];
    if (config_nw_website.configurations.features.extract && config_nw_website.configurations.features.extract.length) {
        featurestoextract = config_nw_website.configurations.features.extract
    }
    return featurestoextract;
}

let transformFeaturesForList = function (list) {
    var mylist = []
    var myfeaturestoextract = getFeaturesToExtract()

    var transform = false;
    var advancedSearch = false;
    if (config_nw_website.configurations.advancedSearch && config_nw_website.configurations.advancedSearch.enabled) {
        searchFeatValues = config_nw_website.configurations.advancedSearch.searchFeatValues;
        advancedSearch = true;
        transform = true;
    }
    if (myfeaturestoextract.length) {
        transform = true;
    }

    if (transform) {
        for (var i = 0; i < list.length; i++) {
            var mymodel = list[i];
            mylist.push(transformFeatures(mymodel, myfeaturestoextract))
        }
        if (advancedSearch) {
            var searchFeatValuesSorted = _.mapObject(searchFeatValues, function (val, key) {
                return _.sortBy(val, function (v) { return v });
            });
            mylist.FeaturesFilters = searchFeatValuesSorted;
        }
    } else {
        mylist = list;
    }
    return mylist;
}

let getListTemplates = function() {
	const template = "models-list";
	return template;
}

let getSearchResultTemplates = function() {
	const template = "models-list";
	return template;
}


var onNavRendered = function() {
    $(".navbar-burger").click(function() {
		$(".navbar-burger").toggleClass("is-active");
		$(".navbar-menu").toggleClass("is-active");
	});
	var $select = $(".navbar-menu a[data-page-name*=\"" + currentPage.area + "/" + currentPage.navigation + "\"]");
	$select.addClass("is-active");
	$select.parents(".navbar-item").addClass("has-active-submenu").find(">.navbar-link").addClass("is-active")
}

var onModelsSubNavRendered = function() {
	var $select = $(".models-sub-nav a[data-page-name*=\"" + currentPage.area + "/" + currentPage.navigation + "\"]");
	$select.addClass("active");
}

var onSideNavRendered = function() {
	$('.sidenav-trigger').click(function(){
		toggleSideNav();
		
	});
	var $activelink = $(".sidenav a[data-page-name*=\"" + currentPage.area + "/" + currentPage.navigation + "\"]");
    var $activelistitem = $activelink.parents("li").eq(0)
    $activelistitem.addClass("is-active");
    var $activeparent = $activelistitem.parents("li.is-first-level");
    if ($activeparent.length > 0) {
        $activeparent.eq(0).addClass("is-active");
    }
    if (config_nw_website.configurations.nav.sidenav.isCollapsible) {
        $("li.is-first-level > a").on("click", function() {
            $(this).parent().toggleClass("is-active");
        });
    }
}


var toggleSideNav = function() {
	var isSideNavOpen = $('.sidenav-trigger').hasClass("sidenav-trigger-open");
	if (!isSideNavOpen) {
		openSideNav()
	} else {
		closeSideNav()
	}
}

/* Set the width of the side navigation to 250px */
var openSideNav = function() {
	var sidenav = config_nw_website.configurations.nav.sidenav;
	if (sidenav) {
		$(".sidenav").addClass("sidenav-open");
		if (sidenav.overlay) {
			$(".sidenav-overlay").addClass("sidenav-overlay-active");
		}
		$('.sidenav-trigger').addClass("sidenav-trigger-open");
	}
}
  
/* Set the width of the side navigation to 0 */
var closeSideNav = function() {
	var sidenav = config_nw_website.configurations.nav.sidenav;
	if (sidenav) {
		$(".sidenav").removeClass("sidenav-open");
		if (sidenav.overlay) {
			$(".sidenav-overlay").removeClass("sidenav-overlay-active");
		}
		$('.sidenav-trigger').removeClass("sidenav-trigger-open");
	}
}
function processArticle() {
    var $articlecontainer = $(".article-content")
    $articlecontainer.find("p:contains('---')").replaceWith("<hr/>");
    $articlecontainer.find("oembed").each(function(i, item) {
        var embedurl = $(item).attr("url");
        var videodet = parseVideoURL(embedurl);
        switch (videodet.provider) {
            case "vimeo":
                $(item).parent().append("<iframe src=\"https://player.vimeo.com/video/" + videodet.id + "\" class=\"vimeo-iframe\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe>");
                break;
            case "youtube":
                $(item).parent().append("<iframe src=\"https://www.youtube.com/embed/" + videodet.id + "\" class=\"youtube-iframe\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen></iframe>");
                break;
        }
    });
}
(function(global) {
  'use strict';

  /**
   * This is a manager for our resize handlers. You can add a callback, disable
   * all resize handlers, and re-enable handlers after they have been disabled.
   *
   * optimizedResize is adapted from Mozilla code:
   * https://developer.mozilla.org/en-US/docs/Web/Events/resize
   */
  const optimizedResize = (function() {
    const callbacks = [];
    let running = false;

    // fired on resize event
    function resize() {
      if (!running) {
        running = true;
        if (window.requestAnimationFrame) {
          window.requestAnimationFrame(runCallbacks);
        } else {
          setTimeout(runCallbacks, 66);
        }
      }
    }

    // run the actual callbacks
    function runCallbacks() {
      callbacks.forEach(function(callback) {
        callback();
      });

      running = false;
    }

    return {
      /**
       * Add a callback to be run on resize.
       *
       * @param {function} callback - the callback to run on resize.
       */
      add: function(callback) {
        if (!callbacks.length) {
          window.addEventListener('resize', resize);
        }

        callbacks.push(callback);
      },

      /**
       * Disables all resize handlers.
       */
      disable: function() {
        window.removeEventListener('resize', resize);
      },

      /**
       * Enables all resize handlers, if they were disabled.
       */
      reEnable: function() {
        window.addEventListener('resize', resize);
      }
    };
  }());

  /**
   * Inject CSS needed to make the grid work in the <head></head>.
   *
   * @param {string} containerId - ID of the container for the images.
   * @param {string} classPrefix - the prefix associated with this library that
   *                               should be prepended to classnames.
   * @param {number} transitionSpeed - animation duration in milliseconds
   */
  function _injectStyle(containerId, classPrefix, transitionSpeed) {

    const css = (
      '#' + containerId + ' {' +
      '  position: relative;' +
      '}' +
      '.' + classPrefix + '-figure {' +
      '  background-color: #D5D5D5;' +
      '  overflow: hidden;' +
      '  left: 0;' +
      '  position: absolute;' +
      '  top: 0;' +
      '  margin: 0;' +
      '}' +
      '.' + classPrefix + '-figure img {' +
      '  left: 0;' +
      '  position: absolute;' +
      '  top: 0;' +
      '  height: 100%;' +
      '  width: 100%;' +
      '  opacity: 0;' +
      '  transition: ' + (transitionSpeed / 1000).toString(10) + 's ease opacity;' +
      '  -webkit-transition: ' + (transitionSpeed / 1000).toString(10) + 's ease opacity;' +
      '}' +
      '.' + classPrefix + '-figure img.' + classPrefix + '-thumbnail {' +
      '  -webkit-filter: blur(30px);' +
      '  filter: blur(30px);' +
      '  left: auto;' +
      '  position: relative;' +
      '  width: auto;' +
      '}' +
      '.' + classPrefix + '-figure img.' + classPrefix + '-loaded {' +
      '  opacity: 1;' +
      '}'
    );

    const head = document.head || document.getElementsByTagName('head')[0];
    const style = document.createElement('style');

    style.type = 'text/css';
    if (style.styleSheet) {
      // set style for IE8 and below
      style.styleSheet.cssText = css;
    } else {
      style.appendChild(document.createTextNode(css));
    }

    head.appendChild(style);
  }

  /**
   * Extend obj1 with each key in obj2, overriding default values in obj1 with
   * values in obj2
   *
   * @param {object} obj1 - The object to extend.
   * @param {object} obj2 - The overrides to apply onto obj1.
   */
  function _extend(obj1, obj2) {
    for (const i in obj2) {
      if (obj2.hasOwnProperty(i)) {
        obj1[i] = obj2[i];
      }
    }
  }

  /**
   * Returns the distance from `elem` to the top of the page. This is done by
   * walking up the node tree, getting the offsetTop of each parent node, until
   * the top of the page.
   *
   * @param {object} elem - The element to compute the offset of.
   * @returns {number} - distance of `elem` to the top of the page
   */
  function _getOffsetTop(elem){
    let offsetTop = 0;
    do {
      if (!isNaN(elem.offsetTop)){
        offsetTop += elem.offsetTop;
      }
      elem = elem.offsetParent;
    } while(elem);
    return offsetTop;
  }

  /**
   * Creates an instance of the progressive image grid, inserting boilerplate
   * CSS and loading image data. Instantiating an instance of the Pig class
   * does not cause any images to appear however. After instantiating, call the
   * `enable()` function on the returned instance:
   *
   *   var pig = new Pig(imageData, opts);
   *   pig.enable();
   *
   * @param {array} imageData - An array of metadata about each image to
   *                            include in the grid.
   * @param {string} imageData[0].filename - The filename of the image.
   * @param {string} imageData[0].aspectRatio - The aspect ratio of the image.
   * @param {object} options - An object containing overrides for the default
   *                           options. See below for the full list of options
   *                           and defaults.
   *
   * @returns {object} The Pig instance.
   */
  function Pig(imageData, options) {
    // Global State
    this.inRAF = false;
    this.isTransitioning = false;
    this.minAspectRatioRequiresTransition = false;
    this.minAspectRatio = null;
    this.latestYOffset = 0;
    this.lastWindowWidth = window.innerWidth;
    this.scrollDirection = 'down';

    // List of images that are loading or completely loaded on screen.
    this.visibleImages = [];

    // These are the default settings, which may be overridden.
    this.settings = {

      /**
       * Type: string
       * Default: 'pig'
       * Description: The class name of the element inside of which images should
       *   be loaded.
       */
      containerId: 'pig',

      /**
       * Type: window | HTMLElement
       * Default: window
       * Description: The window or HTML element that the grid scrolls in.
       */
      scroller: window,

      /**
       * Type: string
       * Default: 'pig'
       * Description: The prefix associated with this library that should be
       *   prepended to class names within the grid.
       */
      classPrefix: 'pig',

      /**
       * Type: string
       * Default: 'figure'
       * Description: The tag name to use for each figure. The default setting is
       *   to use a <figure></figure> tag.
       */
      figureTagName: 'figure',

      /**
       * Type: Number
       * Default: 8
       * Description: Size in pixels of the gap between images in the grid.
       */
      spaceBetweenImages: 8,

      /**
       * Type: Number
       * Default: 500
       * Description: Transition speed in milliseconds
       */
      transitionSpeed: 500,

      /**
       * Type: Number
       * Default: 3000
       * Description: Height in pixels of images to preload in the direction
       *   that the user is scrolling. For example, in the default case, if the
       *   user is scrolling down, 1000px worth of images will be loaded below
       *   the viewport.
       */
      primaryImageBufferHeight: 1000,

      /**
       * Type: Number
       * Default: 100
       * Description: Height in pixels of images to preload in the direction
       *   that the user is NOT scrolling. For example, in the default case, if
       *   the user is scrolling down, 300px worth of images will be loaded
       *   above the viewport.  Images further up will be removed.
       */
      secondaryImageBufferHeight: 300,

      /**
       * Type: Number
       * Default: 20
       * Description: The height in pixels of the thumbnail that should be
       *   loaded and blurred to give the effect that images are loading out of
       *   focus and then coming into focus.
       */
      thumbnailSize: 20,

      /**
       * Get the URL for an image with the given filename & size.
       *
       * @param {string} filename - The filename of the image.
       * @param {Number} size - The size (height in pixels) of the image.
       *
       * @returns {string} The URL of the image at the given size.
       */
      urlForSize: function(filename, size) {
        return '/img/' + size.toString(10) + '/' + filename;
      },

      /**
       * Get a callback with the filename of the image
       * which was clicked.
       *
       * @param {string} filename - The filename property of the image.
       */
      onClickHandler: null,

      /**
       * Get the minimum required aspect ratio for a valid row of images. The
       * perfect rows are maintained by building up a row of images by adding
       * together their aspect ratios (the aspect ratio when they are placed
       * next to each other) until that aspect ratio exceeds the value returned
       * by this function. Responsive reordering is achieved through changes
       * to what this function returns at different values of the passed
       * parameter `lastWindowWidth`.
       *
       * @param {Number} lastWindowWidth - The last computed width of the
       *                                   browser window.
       *
       * @returns {Number} The minimum aspect ratio at this window width.
       */
      getMinAspectRatio: function(lastWindowWidth) {
        if (lastWindowWidth <= 640) {
          return 2;
        } else if (lastWindowWidth <= 1280) {
          return 4;
        } else if (lastWindowWidth <= 1920) {
          return 5;
        }
        return 6;
      },

      /**
       * Get the image size (height in pixels) to use for this window width.
       * Responsive resizing of images is achieved through changes to what this
       * function returns at different values of the passed parameter
       * `lastWindowWidth`.
       *
       * @param {Number} lastWindowWidth - The last computed width of the
       *                                   browser window.
       *
       * @returns {Number} The size (height in pixels) of the images to load.
       */
      getImageSize: function(lastWindowWidth) {
        if (lastWindowWidth <= 640) {
          return 100;
        } else if (lastWindowWidth <= 1920) {
          return 250;
        }
        return 500;
      }
    };

    // We extend the default settings with the provided overrides.
    _extend(this.settings, options || {});

    // Find the container to load images into, if it exists.
    this.container = document.getElementById(this.settings.containerId);
    if (!this.container) {
      console.error('Could not find element with ID ' + this.settings.containerId);
    }

    this.scroller = this.settings.scroller;

    // Our global reference for images in the grid.  Note that not all of these
    // images are necessarily in view or loaded.
    this.images = this._parseImageData(imageData);

    // Inject our boilerplate CSS.
    _injectStyle(this.settings.containerId, this.settings.classPrefix, this.settings.transitionSpeed);

    // Allows for chaining with `enable()`.
    return this;
  }

  /**
   * Because we may be transitioning a very large number of elements on a
   * resize, and because we cannot reliably determine when all elements are
   * done transitioning, we have to approximate the amount of time it will take
   * for the browser to be expected to complete with a transition. This
   * constant gives the scale factor to apply to the given transition time. For
   * example, if transitionTimeoutScaleFactor is 1.5 and transition speed is
   * given as 500ms, we will wait 750ms before assuming that we are actually
   * done resizing.
   *
   * @returns {Number} Time in milliseconds before we can consider a resize to
   *   have been completed.
   */
  Pig.prototype._getTransitionTimeout = function() {
    const transitionTimeoutScaleFactor = 1.5;
    return this.settings.transitionSpeed * transitionTimeoutScaleFactor;
  };

  /**
   * Gives the CSS property string to set for the transition value, depending
   * on whether or not we are transitioning.
   *
   * @returns {string} a value for the `transition` CSS property.
   */
  Pig.prototype._getTransitionString = function() {
    if (this.isTransitioning) {
      return (this.settings.transitionSpeed / 1000).toString(10) + 's transform ease';
    }

    return 'none';
  };

  /**
   * Computes the current value for `this.minAspectRatio`, using the
   * `getMinAspectRatio` function defined in the settings. Then,
   * `this.minAspectRatioRequiresTransition` will be set, depending on whether
   * or not the value of this.minAspectRatio has changed.
   */
  Pig.prototype._recomputeMinAspectRatio = function() {
    const oldMinAspectRatio = this.minAspectRatio;
    this.minAspectRatio = this.settings.getMinAspectRatio(this.lastWindowWidth);

    if (oldMinAspectRatio !== null && oldMinAspectRatio !== this.minAspectRatio) {
      this.minAspectRatioRequiresTransition = true;
    } else {
      this.minAspectRatioRequiresTransition = false;
    }
  };

  /**
   * Creates new instances of the ProgressiveImage class for each of the images
   * defined in `imageData`.
   *
   * @param {array} imageData - An array of metadata about each image to
   *                            include in the grid.
   * @param {string} imageData[0].filename - The filename of the image.
   * @param {string} imageData[0].aspectRatio - The aspect ratio of the image.
   *
   * @returns {Array[ProgressiveImage]} - An array of ProgressiveImage
   *                                      instances that we created.
   */
  Pig.prototype._parseImageData = function(imageData) {
    const progressiveImages = [];

    imageData.forEach(function(image, index) {
      const progressiveImage = new ProgressiveImage(image, index, this);
      progressiveImages.push(progressiveImage);
    }.bind(this));

    return progressiveImages;
  };

  /**
   * This computes the layout of the entire grid, setting the height, width,
   * translateX, translateY, and transtion values for each ProgessiveImage in
   * `this.images`. These styles are set on the ProgressiveImage.style property,
   * but are not set on the DOM.
   *
   * This separation of concerns (computing layout and DOM manipulation) is
   * paramount to the performance of the PIG. While we need to manipulate the
   * DOM every time we scroll (adding or remove images, etc.), we only need to
   * compute the layout of the PIG on load and on resize. Therefore, this
   * function will compute the entire grid layout but will not manipulate the
   * DOM at all.
   *
   * All DOM manipulation occurs in `_doLayout`.
   */
  Pig.prototype._computeLayout = function() {
    // Constants
    const wrapperWidth = parseInt(this.container.clientWidth, 10);

    // State
    let row = [];           // The list of images in the current row.
    let translateX = 0;     // The current translateX value that we are at
    let translateY = 0;     // The current translateY value that we are at
    let rowAspectRatio = 0; // The aspect ratio of the row we are building

    // Compute the minimum aspect ratio that should be applied to the rows.
    this._recomputeMinAspectRatio();

    // If we are not currently transitioning, and our minAspectRatio has just
    // changed, then we mark isTransitioning true. If this is the case, then
    // `this._getTransitionString()` will ensure that each image has a value
    // like "0.5s ease all". This will cause images to animate as they change
    // position. (They need to change position because the minAspectRatio has
    // changed.) Once we determine that the transtion is probably over (using
    // `this._getTransitionTimeout`) we unset `this.isTransitioning`, so that
    // future calls to `_computeLayout` will set "transition: none".
    if (!this.isTransitioning && this.minAspectRatioRequiresTransition) {
      this.isTransitioning = true;
      setTimeout(function() {
        this.isTransitioning = false;
      }, this._getTransitionTimeout());
    }

    // Get the valid-CSS transition string.
    const transition = this._getTransitionString();

    // Loop through all our images, building them up into rows and computing
    // the working rowAspectRatio.
    [].forEach.call(this.images, function(image, index) {
      rowAspectRatio += parseFloat(image.aspectRatio);
      row.push(image);

      // When the rowAspectRatio exceeeds the minimum acceptable aspect ratio,
      // or when we're out of images, we say that we have all the images we
      // need for this row, and compute the style values for each of these
      // images.
      if (rowAspectRatio >= this.minAspectRatio || index + 1 === this.images.length) {

        // Make sure that the last row also has a reasonable height
        rowAspectRatio = Math.max(rowAspectRatio, this.minAspectRatio);

        // Compute this row's height.
        const totalDesiredWidthOfImages = wrapperWidth - this.settings.spaceBetweenImages * (row.length - 1);
        const rowHeight = totalDesiredWidthOfImages / rowAspectRatio;

        // For each image in the row, compute the width, height, translateX,
        // and translateY values, and set them (and the transition value we
        // found above) on each image.
        //
        // NOTE: This does not manipulate the DOM, rather it just sets the
        //       style values on the ProgressiveImage instance. The DOM nodes
        //       will be updated in _doLayout.
        row.forEach(function(img) {

          const imageWidth = rowHeight * img.aspectRatio;

          // This is NOT DOM manipulation.
          img.style = {
            width: parseInt(imageWidth, 10),
            height: parseInt(rowHeight, 10),
            translateX: translateX,
            translateY: translateY,
            transition: transition
          };

          // The next image is this.settings.spaceBetweenImages pixels to the
          // right of this image.
          translateX += imageWidth + this.settings.spaceBetweenImages;

        }.bind(this));

        // Reset our state variables for next row.
        row = [];
        rowAspectRatio = 0;
        translateY += parseInt(rowHeight, 10) + this.settings.spaceBetweenImages;
        translateX = 0;
      }
    }.bind(this));

    // No space below the last image
    this.totalHeight = translateY - this.settings.spaceBetweenImages;
  };

  /**
   * Update the DOM to reflect the style values of each image in the PIG,
   * adding or removing images appropriately.
   *
   * PIG ensures that there are not too many images loaded into the DOM at once
   * by maintaining a buffer region around the viewport in which images are
   * allowed, removing all images below and above. Because all of our layout
   * is computed using CSS transforms, removing an image above the buffer will
   * not cause the gird to reshuffle.
   *
   * The primary buffer is the buffer in the direction of the user's scrolling.
   * (Below if they are scrolling down, above if they are scrolling up.) The
   * size of this buffer determines the experience of scrolling down the page.
   *
   * The secondary buffer is the buffer in the opposite direction of the user's
   * scrolling.  The size of this buffer determines the experience of changing
   * scroll directions. (Too small, and we have to reload a ton of images above
   * the viewport if the user changes scroll directions.)
   *
   * While the entire grid has been computed, only images within the viewport,
   * the primary buffer, and the secondary buffer will exist in the DOM.
   *
   *
   *             Illustration: the primary and secondary buffers
   *
   *
   * +---------------------------+
   * |                           |
   * |                           |
   * |                           |
   * |                           |
   * + - - - - - - - - - - - - - +                   -------
   * |                           |                      A
   * |     Secondary Buffer      |   this.setting.secondaryImageBufferHeight
   * |                           |                      V
   * +---------------------------+                   -------
   * |                           |                      A
   * |                           |                      |
   * |                           |                      |
   * |        Viewport           |              window.innerHeight
   * |                           |                      |
   * |                           |                      |
   * |                           |                      V
   * +---------------------------+                   -------
   * |                           |                      A
   * |                           |                      |
   * |                           |                      |
   * |                           |                      |
   * |      Primary Buffer       |    this.settings.primaryImageBufferHeight
   * |                           |                      |
   * |                           |                      |
   * |                           |                      |
   * |                           |                      V
   * + - - - - - - - - - - - - - +                   -------
   * |                           |
   * |    (Scroll direction)     |
   * |            |              |
   * |            |              |
   * |            V              |
   * |                           |
   *
   */
  Pig.prototype._doLayout = function() {

    // Set the container height
    this.container.style.height = this.totalHeight + 'px';

    // Get the top and bottom buffers heights.
    const bufferTop =
      (this.scrollDirection === 'up') ?
        this.settings.primaryImageBufferHeight :
        this.settings.secondaryImageBufferHeight;
    const bufferBottom =
      (this.scrollDirection === 'down') ?
        this.settings.secondaryImageBufferHeight :
        this.settings.primaryImageBufferHeight;

    // Now we compute the location of the top and bottom buffers:
    const containerOffset = _getOffsetTop(this.container);
    const scrollerHeight = this.scroller === window ? window.innerHeight : this.scroller.offsetHeight;

    // This is the top of the top buffer. If the bottom of an image is above
    // this line, it will be removed.
    const minTranslateYPlusHeight = this.latestYOffset - containerOffset - bufferTop;

    // This is the bottom of the bottom buffer.  If the top of an image is
    // below this line, it will be removed.
    const maxTranslateY = this.latestYOffset - containerOffset + scrollerHeight + bufferBottom;

    // Here, we loop over every image, determine if it is inside our buffers or
    // no, and either insert it or remove it appropriately.
    this.images.forEach(function(image) {

      if (image.style.translateY + image.style.height < minTranslateYPlusHeight ||
            image.style.translateY > maxTranslateY) {
        // Hide Image
        image.hide();
      } else {
        // Load Image
        image.load();
      }
    }.bind(this));
  };

  /**
   * Create our onScroll handler and return it.
   *
   * @returns {function} Our optimized onScroll handler that we should attach to.
   */
  Pig.prototype._getOnScroll = function() {
    const _this = this;

    /**
     * This function is called on scroll. It computes variables about the page
     * position and scroll direction, and then calls a _doLayout guarded by a
     * window.requestAnimationFrame.
     *
     * We use the boolean variable _this.inRAF to ensure that we don't overload
     * the number of layouts we perform by starting another layout while we are
     * in the middle of doing one.
     */
    const onScroll = function() {
      // Compute the scroll direction using the latestYOffset and the
      // previousYOffset
      const newYOffset = _this.scroller === window ? window.pageYOffset : _this.scroller.scrollTop;
      _this.previousYOffset = _this.latestYOffset || newYOffset;
      _this.latestYOffset = newYOffset;
      _this.scrollDirection = (_this.latestYOffset > _this.previousYOffset) ? 'down' : 'up';

      // Call _this.doLayout, guarded by window.requestAnimationFrame
      if (!_this.inRAF) {
        _this.inRAF = true;
        window.requestAnimationFrame(function() {
          _this._doLayout();
          _this.inRAF = false;
        });
      }
    };

    return onScroll;
  };

  /**
   * Enable scroll and resize handlers, and run a complete layout computation /
   * application.
   *
   * @returns {object} The Pig instance, for easy chaining with the constructor.
   */
  Pig.prototype.enable = function() {
    this.onScroll = this._getOnScroll();

    this.scroller.addEventListener('scroll', this.onScroll);

    this.onScroll();
    this._computeLayout();
    this._doLayout();

    optimizedResize.add(function() {
      this.lastWindowWidth = this.scroller === window ? window.innerWidth : this.scroller.offsetWidth;
      this._computeLayout();
      this._doLayout();
    }.bind(this));

    return this;
  };

  /**
   * Remove all scroll and resize listeners.
   *
   * @returns {object} The Pig instance.
   */
  Pig.prototype.disable = function() {
    this.scroller.removeEventListener('scroll', this.onScroll);
    optimizedResize.disable();
    return this;
  };

  /**
   * This class manages a single image. It keeps track of the image's height,
   * width, and position in the grid. An instance of this class is associated
   * with a single image figure, which looks like this:
   *
   *   <figure class="pig-figure" style="transform: ...">
   *     <img class="pig-thumbnail pig-loaded" src="/path/to/thumbnail/image.jpg" />
   *     <img class="pig-loaded" src="/path/to/500px/image.jpg" />
   *   </figure>
   *
   * However, this element may or may not actually exist in the DOM. The actual
   * DOM element may loaded and unloaded depending on where it is with respect
   * to the viewport. This class is responsible for managing the DOM elements,
   * but does not include logic to determine _when_ the DOM elements should
   * be removed.
   *
   * This class also manages the blur-into-focus load effect.  First, the
   * <figure> element is inserted into the page. Then, a very small thumbnail
   * is loaded, stretched out to the full size of the image.  This pixelated
   * image is then blurred using CSS filter: blur(). Then, the full image is
   * loaded, with opacity:0.  Once it has loaded, it is given the `pig-loaded`
   * class, and its opacity is set to 1.  This creates an effect where there is
   * first a blurred version of the image, and then it appears to come into
   * focus.
   *
   * @param {array} singleImageData - An array of metadata about each image to
   *                                  include in the grid.
   * @param {string} singleImageData[0].filename - The filename of the image.
   * @param {string} singleImageData[0].aspectRatio - The aspect ratio of the
   *                                                  image.
   * @param {number} index - Index of the image in the list of images
   * @param {object} pig - The Pig instance
   *
   * @returns {object}  The Pig instance, for easy chaining with the constructor.
   */
  function ProgressiveImage(singleImageData, index, pig) {

    // Global State
    this.existsOnPage = false; // True if the element exists on the page.

    // Instance information
    this.aspectRatio = singleImageData.aspectRatio;  // Aspect Ratio
    this.filename = singleImageData.filename;  // Filename
    this.index = index;  // The index in the list of images

    // The Pig instance
    this.pig = pig;

    this.classNames = {
      figure: pig.settings.classPrefix + '-figure',
      thumbnail: pig.settings.classPrefix + '-thumbnail',
      loaded: pig.settings.classPrefix + '-loaded'
    };

    return this;
  }

  /**
   * Load the image element associated with this ProgressiveImage into the DOM.
   *
   * This function will append the figure into the DOM, create and insert the
   * thumbnail, and create and insert the full image.
   */
  ProgressiveImage.prototype.load = function() {
    // Create a new image element, and insert it into the DOM. It doesn't
    // matter the order of the figure elements, because all positioning
    // is done using transforms.
    this.existsOnPage = true;
    this._updateStyles();
    this.pig.container.appendChild(this.getElement());

    // We run the rest of the function in a 100ms setTimeout so that if the
    // user is scrolling down the page very fast and hide() is called within
    // 100ms of load(), the hide() function will set this.existsOnPage to false
    // and we can exit.
    setTimeout(function() {

      // The image was hidden very quickly after being loaded, so don't bother
      // loading it at all.
      if (!this.existsOnPage) {
        return;
      }

      // Show thumbnail
      if (!this.thumbnail) {
        this.thumbnail = new Image();
        this.thumbnail.src = this.pig.settings.urlForSize(this.filename, this.pig.settings.thumbnailSize);
        this.thumbnail.className = this.classNames.thumbnail;
        this.thumbnail.onload = function() {

          // We have to make sure thumbnail still exists, we may have already been
          // deallocated if the user scrolls too fast.
          if (this.thumbnail) {
            this.thumbnail.className += ' ' + this.classNames.loaded;
          }
        }.bind(this);

        this.getElement().appendChild(this.thumbnail);
      }

      // Show full image
      if (!this.fullImage) {
        this.fullImage = new Image();
        this.fullImage.src = this.pig.settings.urlForSize(this.filename, this.pig.settings.getImageSize(this.pig.lastWindowWidth));
        this.fullImage.onload = function() {

          // We have to make sure fullImage still exists, we may have already been
          // deallocated if the user scrolls too fast.
          if (this.fullImage) {
            this.fullImage.className += ' ' + this.classNames.loaded;
          }
        }.bind(this);

        this.getElement().appendChild(this.fullImage);
      }

    }.bind(this), 100);
  };

  /**
   * Removes the figure from the DOM, removes the thumbnail and full image, and
   * deletes the this.thumbnail and this.fullImage properties off of the
   * ProgressiveImage object.
   */
  ProgressiveImage.prototype.hide = function() {
    // Remove the images from the element, so that if a user is scrolling super
    // fast, we won't try to load every image we scroll past.
    if (this.getElement()) {
      if (this.thumbnail) {
        this.thumbnail.src = '';
        this.getElement().removeChild(this.thumbnail);
        delete this.thumbnail;
      }

      if (this.fullImage) {
        this.fullImage.src = '';
        this.getElement().removeChild(this.fullImage);
        delete this.fullImage;
      }
    }

    // Remove the image from the DOM.
    if (this.existsOnPage) {
      this.pig.container.removeChild(this.getElement());
    }

    this.existsOnPage = false;
  };

  /**
   * Get the DOM element associated with this ProgressiveImage. We default to
   * using this.element, and we create it if it doesn't exist.
   *
   * @returns {HTMLElement} The DOM element associated with this instance.
   */
  ProgressiveImage.prototype.getElement = function() {
    if (!this.element) {
      this.element = document.createElement(this.pig.settings.figureTagName);
      this.element.className = this.classNames.figure;
      if (this.pig.settings.onClickHandler !== null) {
        this.element.addEventListener('click', function() {
          this.pig.settings.onClickHandler(this.filename);
        }.bind(this) );
      }
      this._updateStyles();
    }

    return this.element;
  };


  /**
   * Updates the style attribute to reflect this style property on this object.
   */
  ProgressiveImage.prototype._updateStyles = function() {
    this.getElement().style.transition = this.style.transition;
    this.getElement().style.width = this.style.width + 'px';
    this.getElement().style.height = this.style.height + 'px';
    this.getElement().style.transform = (
      'translate3d(' + this.style.translateX + 'px,' +
        this.style.translateY + 'px, 0)');
  };

  // Export Pig into the global scope.
  if (typeof define === 'function' && define.amd) {
    define([], function() { return { Pig: Pig }; });
  } else if (typeof module !== 'undefined' && module.exports) {
    module.exports = Pig;
  } else {
    global.Pig = Pig;
  }

}(typeof window !== 'undefined' ? window : this));

function getCookieConsent() {
    var l = Cookies.get("cookie-consent");
    if (l) {
        return true;
    } else {
        return false;
    }
}

function setCookieConsent() {
    Cookies.set("cookie-consent",true);
}

function hideCookieBanner() {
    $(".cookie-banner-overlay").removeClass("cookie-banner-overlay-active");
    $("html").css("overflow-y","scroll");
}

function showCookieBanner() {
    $("html").css("overflow-y","hidden");
    $(".cookie-banner-overlay").addClass("cookie-banner-overlay-active");
}

function initCookieBanner() {
    if (config_nw_website.configurations.privacy.align) {
        $(".cookie-banner-overlay").addClass("cookie-banner-" + config_nw_website.configurations.privacy.align);
    }
    
    $(".cookie-banner-wrapper").find(".close-cookie-banner").off("click").on("click", function(evt) {
        setCookieConsent();
        hideCookieBanner();
        evt.stopPropagation();
        evt.cancelBubble = true;
    });
}

function enterSite() {
    setCookieConsent();
    hideCookieBanner();
}
function checkScreenSize() {
	return window.innerWidth <= 740 ? true : false;
}
const getModelId = function (mystring) {
    if (mystring.indexOf("-") > 0) {
        const idm = mystring.split("-")[0]
        if (!isNaN(idm)) {
            return Number(idm);
        }
    }
    return false;
}

let parseUrl = function (dontPushState) {
    if (browserurl === "" || browserurl === "/" || browserurl === "/Home") {
        if (config_nw_website.navigation.length) {
            const entrypointconfigurationobject = getListConfiguration(config_nw_website.configurations.entrypoint);
            browserurl = "/" + entrypointconfigurationobject.areaName + "/" + entrypointconfigurationobject.name;
        } else {
            browserurl = "/package/login";
        }
    }
    if (currentPage.area) {
        lastPage = _.clone(currentPage)
    }
    clearCurrentPage();

    if (isDebug()) {
        browserurl = browserurl.replace("/w/", "/");
    }

    pageConfiguration = {};
    const area = browserurl.split("/")[1];
    if (area === "package") {
        // package url: /package/{packagecode}/{"p"|"v"}/{bookid}
        const packagecode = browserurl.split("/")[2];
        if (packagecode) {
            if (packagecode === "login") {
                packageLoginRoute();
                return true;
            } else {
                if (currentPackage.code !== packagecode) {
                    clearCurrentPackage();
                    currentPackage.code = packagecode;
                }
            }
        }
        const bookType = browserurl.split("/")[3];
        if (bookType) {
            currentPackage.bookType = bookType;
            const bookID = browserurl.split("/")[4];
            if (bookID) {
                currentPackage.bookID = bookID;
                currentPackage.bookData = null;
            } else {
                currentPackage.bookID = null;
                currentPackage.bookData = null;
            }
        } else {
            currentPackage.bookID = null;
            currentPackage.bookData = null;
        }
        if (isDebug() && !dontPushState) {
            history.pushState(currentPackage, "", browserurl);
        }
        packageRoute();
    } else {
        clearCurrentPackage();
        const navigation = browserurl.split("/")[2];
        currentPage.area = area;
        currentPage.navigation = navigation;
        pageConfiguration = getListConfiguration(currentPage.navigation);
        currentPage.layout = pageConfiguration.layout;
        currentPage.role = pageConfiguration.role;

        const modelspec = browserurl.split("/")[3];
        if (currentPage.area === "models") {
            if (currentPage.role === "search") {
                if (modelspec && modelspec.length) {
                    const idmodella = getModelId(modelspec);
                    if (idmodella) {
                        currentPage.modelID = idmodella;
                        const bookspec = browserurl.split("/")[4];
                        if (bookspec) {
                            if (bookspec === 'v' || bookspec === 'p') {
                                const bt = bookspec;
                                const bookid = browserurl.split("/")[5];
                                if (bookid && !isNaN(bookid)) {
                                    currentPage.bookType = bt;
                                    currentPage.activeBook = Number(browserurl.split("/")[5]);
                                    currentPage.bookInUrl = true;
                                }
                            } else {
                                currentPage.bookInUrl = false;
                            }
                        } else {
                            currentPage.bookInUrl = false;
                        }
                        route();
                    } else {
                        currentPage.searchfilter = decodeURIComponent(browserurl.split("/")[3]);
                        lastSearch = currentPage.searchfilter;
                        routeSearch();
                    }
                } else {
                    routeSearch();
                }
            } else {
                if (modelspec) {
                    const idmodella = getModelId(modelspec);
                    if (idmodella) {
                        currentPage.modelID = idmodella;
                        const bookspec = browserurl.split("/")[4];
                        if (bookspec) {
                            if (bookspec === 'v' || bookspec === 'p') {
                                const bt = bookspec;
                                const bookid = browserurl.split("/")[5];
                                if (bookid && !isNaN(bookid)) {
                                    currentPage.bookType = bt;
                                    currentPage.activeBook = Number(browserurl.split("/")[5]);
                                    currentPage.bookInUrl = true;
                                }
                            } else {
                                currentPage.bookInUrl = false;
                            }
                        } else {
                            currentPage.bookInUrl = false;
                        }
                    } else {
                        currentPage.letterfilter = browserurl.split("/")[3];
                    }
                }
                route();
            }
        } else {
            if (currentPage.area === "news" || currentPage.area === "modelnews") {
                if (modelspec && modelspec.length) {
                    const idnews = Number(modelspec);
                    currentPage.newsID = idnews;
                }
            } else {
                if (modelspec && modelspec.length) {
                    currentPage.language = modelspec;
                }
            }
            route();
        }
        if (isDebug() && !dontPushState) {
            history.pushState(currentPage, "", browserurl);
        }
    }

}

let getHeaderLayout = function () {
    if (config_nw_website.configurations.nav.sidenav) {
        return "header-sidenav";
    }
    if (config_nw_website.configurations.nav.dropdown) {
        return "header-dropdown";
    }
    return "header";
}

let buildPage = function () {
    let layout = "layout-"
    if (pageConfiguration && pageConfiguration.layout) {
        layout += pageConfiguration.layout
    } else {
        layout += "default"
    }
    renderTemplate(layout, {}, $("body"));

    renderTemplate(getHeaderLayout(), config_nw_website, $("header"));
    onNavRendered();

    var sidenav = config_nw_website.configurations.nav.sidenav;
    if (sidenav) {
        renderTemplate("sidenav", config_nw_website, $(".sidenav-container"));
        onSideNavRendered();
    }

    renderTemplate("footer", config_nw_website, $("#footer-container"))

    if (config_nw_website.configurations.privacy && config_nw_website.configurations.privacy.custom && $(".cookie-banner-overlay").length === 1) {
        renderTemplate("cookie-banner-content", config_nw_website.configurations.privacy, $(".cookie-banner-overlay"));
        initCookieBanner();
        if (!getCookieConsent()) {
            showCookieBanner();
        }
    }

    renderTemplate('loading', {}, $(".body-wrapper"));

    $(window).scrollTop(0);

    if (!pageConfiguration) {
        renderTemplate("404", {}, $(".body-wrapper"));
        if (typeof onPageLoaded == 'function') {
            onPageLoaded();
        }
        return false;
    }

    if (pageConfiguration.building) {
        addSeoInfo();
        renderTemplate('coming-soon', {}, $(".body-wrapper"));
        if (typeof onPageLoaded == 'function') {
            onPageLoaded();
        }
        return false;
    }
    return true;
}

function loadModel() {
    var bookView = config_nw_website.configurations.books.view;
    var loadAllBooks = config_nw_website.configurations.books.loadAll;
    let urlCall = getApiUrl() + "/models/details/" + currentPage.modelID;
    if (bookView === "index" || loadAllBooks) {
        urlCall = getApiUrl() + "/models/fulldetails/" + currentPage.modelID;
    }
    if (pageConfiguration.params && pageConfiguration.params.Division) {
        urlCall += "?d=" + pageConfiguration.params.Division;
    }
    axios({
        method: 'GET',
        url: urlCall
    }).then(function (modeldata) {
        let model = modeldata.data;
        currentPage.modelFirstName = model.FirstName;
        currentPage.modelLastName = model.LastName;
        if (bookView === "index" || loadAllBooks) {
            addSeoInfo();
            renderModelPage(model, false);
        } else {
            if (currentPage.activeBook) {
                //check existence of requested book in model's books
                let bookcheck = null;
                if (currentPage.bookType === "v") {
                    bookcheck = _.where(model.VideoBooks, { ID: currentPage.activeBook })
                } else {
                    bookcheck = _.where(model.Books, { ID: currentPage.activeBook })
                }
                if (bookcheck.length) {
                    if (model.ActiveBook.ID !== currentPage.activeBook || model.BookType !== currentPage.bookType) {
                        // API call for activebook (p or v)
                        const apicall = currentPage.bookType === "v" ? "videobooks" : "books";
                        axios({
                            method: 'GET',
                            url: getApiUrl() + "/" + apicall + "/" + currentPage.activeBook
                        }).then(function (book) {
                            model.ActiveBook = book.data;
                            currentPage.activeBookName = model.ActiveBook.Title;
                            currentPage.isActiveBookDefault = book.data.IsDefault
                            model.BookType = currentPage.bookType;
                            addSeoInfo();
                            renderModelPage(model, false);
                        })
                            .catch(function (error) {
                                console.error("NW_WEBSITE_ERROR - " + error);
                                renderTemplate("404", {}, $(".body-wrapper"));
                                if (typeof onPageLoaded == 'function') {
                                    onPageLoaded();
                                }
                            });
                    } else {
                        currentPage.isActiveBookDefault = model.ActiveBook.IsDefault;
                        addSeoInfo();
                        renderModelPage(model, false);
                    }
                } else {
                    console.error("NW_WEBSITE_ERROR - Book ID is not valid");
                    renderTemplate("404", {}, $(".body-wrapper"));
                    if (typeof onPageLoaded == 'function') {
                        onPageLoaded();
                    }
                }
            } else {
                currentPage.activeBook = model.ActiveBook.ID;
                currentPage.activeBookName = model.ActiveBook.Title;
                currentPage.bookType = model.BookType;
                currentPage.isActiveBookDefault = true;
                addSeoInfo();
                renderModelPage(model, false);
            }
        }
    })
    // .catch(function (error) {
    //     console.error("NW_WEBSITE_ERROR - " + error)
    //     renderTemplate("error", {}, $(".body-wrapper"))
    //     if (typeof onPageLoaded == 'function') {
    //         onPageLoaded();
    //     }
    // });
}

function route() {
    //controllare i valori di input e restituire un 404 per route sbagliate
    const built = buildPage();
    if (built) {
        switch (currentPage.area) {
            case "models":
                if (!currentPage.modelID) {
                    if (pageConfiguration.params) {
                        axios({
                            method: 'POST',
                            url: getApiUrl() + "/models/list",
                            data: pageConfiguration.params
                        }).then(function (modelList) {
                            const modellist = modelList.data.Models || [];
                            if ($(".letters-container").length) {
                                var alphabet = "abcdefghijklmnopqrstuvwxyz*".split("");
                                _.each(alphabet, function (letter) {
                                    let $letterlink = $("<a href=\"/" + currentPage.area + "/" + currentPage.navigation + "/" + letter + "\">" + letter.toUpperCase() + "</a>");
                                    if (letter != "*") {
                                        let ml = getFilteredList(modellist, letter);
                                        if (ml.length == 0) {
                                            $letterlink.addClass("disabled")
                                        }
                                        if (currentPage.letterfilter && letter === currentPage.letterfilter) {
                                            $letterlink.addClass("selected")
                                        }
                                    }
                                    $(".letters-container").append($letterlink)
                                });
                            }
                            let filterlist = [];
                            if (currentPage.letterfilter) {
                                filterlist = getFilteredList(modellist, currentPage.letterfilter)
                            }
                            if (currentPage.searchfilter) {
                                filterlist = getSearchedList(modellist, currentPage.searchfilter)
                            }
                            if (!currentPage.searchfilter && !currentPage.letterfilter) {
                                filterlist = modellist
                            }
                            addSeoInfo();

                            if (config_nw_website.configurations.modelsInstagramAdvanced.showOnList && config_nw_website.configurations.modelsInstagramAdvanced.manualFollowers) {
                                filterlist = loadModelsInstagramManualFollowers(filterlist)
                            }

                            if (config_nw_website.configurations.features) {
                                filterlist = transformFeaturesForList(filterlist)
                            }

                            if (typeof beforeRenderModelList == 'function') {
                                filterlist = beforeRenderModelList(filterlist);
                            }
                            let listtemplate = 'models-list';
                            if (typeof getListTemplates == 'function') {
                                listtemplate = getListTemplates();
                            }
                            renderTemplate(listtemplate, filterlist, $(".body-wrapper"));

                            const observer = lozad();
                            observer.observe();

                            if (config_nw_website.configurations.list.modelsSubNav) {
                                let subnavlist = null;
                                let currentsubnav = _.findWhere(config_nw_website.navigation, { "name": currentPage.navigation })
                                if (currentsubnav) {
                                    subnavlist = _.where(config_nw_website.navigation, { "area": "models" })
                                } else {
                                    for (let navobj of config_nw_website.navigation) {
                                        if (navobj.subNav) {
                                            let currentsubnav = _.findWhere(navobj.subNav, { "name": currentPage.navigation })
                                            if (currentsubnav) {
                                                subnavlist = navobj.subNav;
                                                break;
                                            }
                                        }
                                    }
                                }
                                renderTemplate("models-sub-nav", subnavlist, $(".models-subnav-container"));
                                onModelsSubNavRendered();
                            }

                            if (config_nw_website.configurations.advancedSearch && config_nw_website.configurations.advancedSearch.enabled) {
                                if (currentPage.role === "advanced-search") {
                                    renderTemplate("advanced-search-header", null, $(".search-header-container"));
                                    initAdvancedSearch(filterlist);
                                }
                            }

                            if (config_nw_website.configurations.advancedSearch && config_nw_website.configurations.advancedSearch.enabled) {
                                if (currentPage.role === "advanced-search") {
                                    renderTemplate("advanced-search-header", null, $(".search-header-container"));
                                    initAdvancedSearch(filterlist);
                                }
                            }

                            if (typeof onModelListLoaded == 'function') {
                                onModelListLoaded(filterlist);
                            }
                            if (typeof onPageLoaded == 'function') {
                                onPageLoaded();
                            }
                            var lastListScroll = Cookies.get("listScroll");
                            if (config_nw_website.configurations.list.keepScroll && lastListScroll) {
                                $(window).scrollTop(lastListScroll)
                            }

                        }).catch(function (error) {
                            console.error("NW_WEBSITE_ERROR - " + error)
                            renderTemplate("error", {}, $(".body-wrapper"))
                            if (typeof onPageLoaded == 'function') {
                                onPageLoaded();
                            }
                        });
                    } else {
                        if (pageConfiguration.modelID) {
                            currentPage.modelID = pageConfiguration.modelID;
                            loadModel();
                        }
                    }
                } else {
                    axios({
                        method: 'POST',
                        url: getApiUrl() + "/models/list",
                        data: pageConfiguration.params
                    }).then(function (modelList) {
                        //check existence in model list
                        const modellist = modelList.data.Models || [];
                        const modelcheck = _.where(modellist, { ID: currentPage.modelID })
                        if (modelcheck.length) {
                            //API call for model details
                            loadModel();
                        } else {
                            console.error("NW_WEBSITE_ERROR - PARAMETER NOT VALID: MODEL ID")
                            renderTemplate("404", {}, $(".body-wrapper"))
                            if (typeof onPageLoaded == 'function') {
                                onPageLoaded();
                            }
                        }
                    }).catch(function (error) {
                        console.error("NW_WEBSITE_ERROR - " + error)
                        renderTemplate("error", {}, $(".body-wrapper"))
                        if (typeof onPageLoaded == 'function') {
                            onPageLoaded();
                        }
                    });
                }
                break;
            case "home":
                if (pageConfiguration.params) {

                    let urlgalleryapi = "/gallery/"
                    if (!config_nw_website.configurations.newApi) {
                        urlgalleryapi = "/home" + urlgalleryapi;
                    }

                    axios({
                        method: 'GET',
                        url: getApiUrl() + urlgalleryapi + pageConfiguration.params.galleryID + "/" + pageConfiguration.params.randomSort.toString()
                    }).then(function (gallery) {
                        let gallerydata = addGalleryInfo(gallery.data)
                        if (typeof beforeGalleryRender == 'function') {
                            gallerydata = beforeGalleryRender(gallerydata)
                        }
                        addSeoInfo();
                        renderTemplate(currentPage.navigation, gallerydata, $(".body-wrapper"));
                        if (typeof onGalleryLoaded == 'function') {
                            onGalleryLoaded(gallerydata)
                        }
                        if (typeof onHomeLoaded == 'function') {
                            onHomeLoaded()
                        }
                        if (typeof onPageLoaded == 'function') {
                            onPageLoaded();
                        }
                    }).catch(function (error) {
                        console.error("NW_WEBSITE_ERROR - " + error)
                        renderTemplate("error", {}, $(".body-wrapper"))
                        if (typeof onPageLoaded == 'function') {
                            onPageLoaded();
                        }
                    });
                } else {
                    addSeoInfo();
                    renderTemplate(currentPage.navigation, null, $(".body-wrapper"));
                    if (typeof onHomeLoaded == 'function') {
                        onHomeLoaded()
                    }
                    if (typeof onPageLoaded == 'function') {
                        onPageLoaded();
                    }
                }
                break;
            case "news":
                let urlnewsapi = "/news/"
                if (currentPage.newsID) {
                    axios({
                        method: 'GET',
                        url: getApiUrl() + urlnewsapi + "/" + currentPage.newsID
                    }).then(function (article) {
                        let articledata = article.data;
                        if (typeof beforeArticleRender == 'function') {
                            articledata = beforeArticleRender(articledata)
                        }
                        addSeoInfo();
                        renderTemplate("news-article", articledata, $(".body-wrapper"));
                        processArticle();
                        if (typeof onArticleLoaded == 'function') {
                            onArticleLoaded(articledata)
                        }
                        if (typeof onPageLoaded == 'function') {
                            onPageLoaded();
                        }
                    }).catch(function (error) {
                        console.error("NW_WEBSITE_ERROR - " + error)
                        renderTemplate("error", {}, $(".body-wrapper"))
                        if (typeof onPageLoaded == 'function') {
                            onPageLoaded();
                        }
                    });
                } else {
                    if (pageConfiguration.params) {
                        axios({
                            method: 'GET',
                            url: getApiUrl() + urlnewsapi + "?tag=" + pageConfiguration.params.tag.toString() + "&fulldetails=" + pageConfiguration.params.fulldetails.toString()
                        }).then(function (news) {
                            var tags = [];
                            _.each(news.data, function (item) {
                                if (item.NewsTags.length > 0) {
                                    _.each(item.NewsTags, function (tag) {
                                        var t = tag.Tag;
                                        if ($.trim(t) !== "") {
                                            if (!_.contains(tags, t)) {
                                                tags.push(t);
                                            }
                                        }
                                    });
                                }
                            });
                            var pinnednews = _.where(news.data, { Pinned: true });
                            var othernews = _.where(news.data, { Pinned: false });
                            let newsdata = { PinnedNews: pinnednews, News: othernews, Tags: tags }

                            if (typeof beforeNewsRender == 'function') {
                                newsdata = beforeNewsRender(newsdata)
                            }
                            addSeoInfo();
                            renderTemplate("news-list", newsdata, $(".body-wrapper"));
                            if (typeof onNewsLoaded == 'function') {
                                onNewsLoaded(newsdata)
                            }
                            if (typeof onPageLoaded == 'function') {
                                onPageLoaded();
                            }
                        }).catch(function (error) {
                            console.error("NW_WEBSITE_ERROR - " + error)
                            renderTemplate("error", {}, $(".body-wrapper"))
                            if (typeof onPageLoaded == 'function') {
                                onPageLoaded();
                            }
                        });
                    } else {
                        addSeoInfo();
                        renderTemplate(currentPage.navigation, null, $(".body-wrapper"));
                        if (typeof onPageLoaded == 'function') {
                            onPageLoaded();
                        }
                    }
                }
                break;
            case "modelnews":
                let urlmodelnewsapi = "/news/"
                axios({
                    method: 'GET',
                    url: getApiUrl() + urlmodelnewsapi + "/" + currentPage.newsID
                }).then(function (article) {
                    let articledata = article.data;
                    if (typeof beforeModelArticleRender == 'function') {
                        articledata = beforeModelArticleRender(articledata)
                    }
                    addSeoInfo();
                    renderTemplate("modelarticle", articledata, $(".body-wrapper"));
                    processArticle();
                    if (typeof onArticleLoaded == 'function') {
                        onModelArticleLoaded(articledata)
                    }
                    if (typeof onPageLoaded == 'function') {
                        onPageLoaded();
                    }
                }).catch(function (error) {
                    console.error("NW_WEBSITE_ERROR - " + error)
                    renderTemplate("error", {}, $(".body-wrapper"))
                    if (typeof onPageLoaded == 'function') {
                        onPageLoaded();
                    }
                });
                break;
            case "application":
                addSeoInfo();
                renderTemplate(currentPage.navigation, getApplicationObject(), $(".body-wrapper"));
                if ($("form").length > 0) {
                    initApplicationForm();
                }
                if (typeof onApplicationLoaded == 'function') {
                    onApplicationLoaded();
                }
                if (typeof onPageLoaded == 'function') {
                    onPageLoaded();
                }
                break;
            case "info":
                addSeoInfo();
                if (currentPage.language) {
                    renderTemplate(currentPage.navigation + "-" + currentPage.language, null, $(".body-wrapper"));
                } else {
                    renderTemplate(currentPage.navigation, null, $(".body-wrapper"));
                }
                if (typeof onInfoLoaded == 'function') {
                    onInfoLoaded();
                }
                if (typeof onPageLoaded == 'function') {
                    onPageLoaded();
                }
                break;
            default:
                addSeoInfo();
                renderTemplate(currentPage.navigation, null, $(".body-wrapper"));
                if (typeof onPageLoaded == 'function') {
                    onPageLoaded();
                }
                break;
        }
    }
}
let buildPackagePage = function () {
    addSeoInfo();
    const layout = "layout-package";
    renderTemplate(layout, {}, $("body"));
    renderTemplate("header-package", config_nw_website, $(".header-wrapper"));
    renderTemplate("footer-package", config_nw_website, $("#footer-container"))
    renderTemplate('loading', {}, $(".body-wrapper"));
}

function packageLoginRoute() {
    buildPackagePage();
    renderTemplate("package-login", {}, $(".body-wrapper"));
}

function packageLogin() {
    var code = $("input[name='package-code']").val();
    if (code.indexOf(" ") >= 0 || code.length > 20) {
        renderTemplate("404", {}, $(".body-wrapper"));
    } else {
        var packageurl = "/w/package/" + code;
        if (isDebug()) {
            packageurl = "/#/package/" + code;
        }
        window.location.href = packageurl;
    }
}

function packageRoute() {
    buildPackagePage();
    if (currentPackage.code) {
        //load package info
        if (!currentPackage.data) {
            axios({
                method: 'GET',
                url: getApiUrl() + "/package/" + currentPackage.code,
                data: null
            }).then(function (packageData) {
                currentPackage.data = packageData.data;

                var pmodels = transformFeaturesForList(currentPackage.data.Models);
                currentPackage.data.Models = pmodels;

                if (!pmodels.length) {
                    packageLoginRoute();
                    return false;
                }

                if (currentPackage.data.PackageBooks.length > 0) {
                    for (var m of currentPackage.data.Models) {
                        var idmodel = m.ID;
                        var sortedbooks = _.sortBy(currentPackage.data.PackageBooks, 'OrderID')
                        var coverbook = _.findWhere(sortedbooks, { ModelID: idmodel });
                        var nbooks = _.where(currentPackage.data.PackageBooks, { ModelID: idmodel }).length;
                        if (coverbook) {
                            m.CoverBook = coverbook;
                            m.OrderID = coverbook.OrderID;
                            if (nbooks > 1) {
                                m.BooksNumber = nbooks;
                            }
                        }
                    }
                }

                if (currentPackage.data.Mail.Type === "VIDMOD") {
                    currentPackage.bookID = currentPackage.data.Mail.ObjectID;
                    var number_id = Number(currentPackage.bookID);
                    currentPackage.bookType = "v";
                    currentPackage.hasBack = false;
                    getPackageBook();
                }
                if (currentPackage.data.Mail.Type === "BOOMOD") {
                    currentPackage.bookID = currentPackage.data.Mail.ObjectID;
                    var number_id = Number(currentPackage.bookID);
                    currentPackage.bookType = "p";
                    currentPackage.hasBack = false;
                    getPackageBook();
                }
                if (currentPackage.data.Mail.Type === "PACMOD") {
                    if (currentPackage.data && currentPackage.data.PackageBooks && currentPackage.data.PackageBooks.length) {
                        for (var i = 0; i < currentPackage.data.PackageBooks.length; i++) {
                            const book = currentPackage.data.PackageBooks[i];
                            const bt = book.BookType;
                            const bID = book.ID;
                            const model = currentPackage.data.Models.find(function (mod) {
                                return mod.ID === book.ModelID;
                            })
                            if (model) {
                                book.FirstName = model.FirstName;
                                book.LastName = model.LastName;
                                book.Features = model.Features;
                                book.BookLink = "/w/package/" + currentPackage.code + "/" + bt.substring(0, 1) + "/" + bID;
                                book.isVideo = book.BookType === "video";
                                book.hasNote = book.Notes && (book.Notes.length > 0);
                            }
                        }
                    }
                    if (currentPackage.bookID) {
                        var number_id = Number(currentPackage.bookID);
                        var typetosearch = "picture";
                        if (currentPackage.bookType === "v") {
                            typetosearch = "video";
                        }
                        currentPackage.bookNote = _.findWhere(currentPackage.data.PackageBooks, { ID: number_id, BookType: typetosearch }).Notes;
                        getPackageBook()
                    } else {
                        renderPackage()
                    }
                }
            })
                .catch(function (error) {
                    packageLoginRoute();
                    //throw error;
                });
        } else {
            if (currentPackage.data.Mail.Type === "VIDMOD") {
                currentPackage.bookID = currentPackage.Mail.ObjectID;
                var number_id = Number(currentPackage.bookID);
                currentPackage.bookType = "v";
                currentPackage.bookNote = _.findWhere(currentPackage.data.PackageBooks, { ID: number_id, BookType: "video" }).Notes;
                getPackageBook()
            }
            if (currentPackage.data.Mail.Type === "BOOMOD") {
                currentPackage.bookID = currentPackage.Mail.ObjectID;
                var number_id = Number(currentPackage.bookID);
                currentPackage.bookType = "p";
                currentPackage.bookNote = _.findWhere(currentPackage.data.PackageBooks, { ID: number_id, BookType: "picture" }).Notes;
                getPackageBook()
            }
            if (currentPackage.data.Mail.Type === "PACMOD") {
                if (currentPackage.bookID) {
                    var number_id = Number(currentPackage.bookID);
                    var typetosearch = "picture";
                    if (currentPackage.bookType === "v") {
                        typetosearch = "video";
                    }
                    currentPackage.bookNote = _.findWhere(currentPackage.data.PackageBooks, { ID: number_id, BookType: typetosearch }).Notes;
                    getPackageBook()
                } else {
                    renderPackage()
                }
            }
        }
    } else {
        //visualizzo la login dei package
        renderTemplate("package-login", {}, $(".body-wrapper"));
        if (typeof onPackagePageLoaded == 'function') {
            onPackagePageLoaded();
        }
    }
}

function renderPackage() {
    if (currentPackage.data && currentPackage.data.PackageBooks && currentPackage.data.PackageBooks.length) {
        if (typeof beforeRenderPackageList == 'function') {
            beforeRenderPackageList();
        }
        var packagetemplate = "package-list";
        if (config_nw_website.configurations.packages && config_nw_website.configurations.packages.groupModels) {
            packagetemplate = "package-list-grouped";
        }
        renderTemplate(packagetemplate, currentPackage.data, $(".body-wrapper"));
        const observer = lozad();
        observer.observe();
        if (typeof onPackageListLoaded == 'function') {
            onPackageListLoaded();
        }
    } else {
        console.error("NW_WEBSITE_ERROR - PACKAGE NOT VALID")
        renderTemplate("package-error", {}, $(".body-wrapper"))
    }
    if (typeof onPackagePageLoaded == 'function') {
        onPackagePageLoaded();
    }
}

function renderPackageBook() {
    if (currentPackage.bookData) {
        let mymodel = currentPackage.data.Models.find(function (mod) {
            return mod.ID === currentPackage.bookData.ModelID
        })
        if (mymodel) {
            //mymodel.ActiveBook = { ID: currentPackage.bookID }
            mymodel.ActiveBook = currentPackage.bookData;
            mymodel.BookType = currentPackage.bookType;

            renderModelPage(mymodel, true);
        }
    } else {
        console.error("NW_WEBSITE_ERROR - PACKAGE BOOK NOT VALID")
        renderTemplate("package-error", {}, $(".body-wrapper"))
        if (typeof onPackagePageLoaded == 'function') {
            onPackagePageLoaded();
        }
    }

}

function getPackageBook() {
    if (currentPackage.bookType === "v") {
        axios({
            method: 'GET',
            url: getApiUrl() + "/videobooks/" + currentPackage.code + "/" + currentPackage.bookID
        }).then(function (book) {
            currentPackage.bookData = book.data;
            renderPackageBook()
        })
            .catch(function (error) {
                console.error("NW_WEBSITE_ERROR - " + error)
                renderTemplate("package-error", {}, $(".body-wrapper"));
                if (typeof onPackagePageLoaded == 'function') {
                    onPackagePageLoaded();
                }
            });
    } else {
        axios({
            method: 'GET',
            url: getApiUrl() + "/books/" + currentPackage.code + "/" + currentPackage.bookID
        }).then(function (book) {
            currentPackage.bookData = book.data;
            renderPackageBook()
        })
            .catch(function (error) {
                console.error("NW_WEBSITE_ERROR - " + error)
                renderTemplate("package-error", {}, $(".body-wrapper"));
                if (typeof onPackagePageLoaded == 'function') {
                    onPackagePageLoaded();
                }
            });
    }
}
const getSearchedList = function (list, q) {
    const mylist = _.filter(list, function (model) {
        return ($.trim(model.FirstName).toLowerCase().indexOf(q.toLowerCase()) === 0 || $.trim(model.LastName).toLowerCase().indexOf(q.toLowerCase()) === 0 || $.trim(model.Name).toLowerCase().indexOf(q.toLowerCase()) === 0)
    })
    return mylist
}

function routeSearch() {
    addSeoInfo();
    const listtosearchon = null;
    if (lastPage && lastPage.area === "models" && (lastPage.navigation === "search" || lastPage.role === "search") && modelsSearchList && !lastPage.modelID) {
        filterSearch();
    } else {
        const built = buildPage();
        if (built) {
            currentPage.searchfilter = lastSearch;
            renderTemplate('models-search', currentPage, $(".body-wrapper"));
            onPageLoaded();

            $("form[name=searchform] input[name=search]").prop("disabled", true)
            $("form[name=searchform]").on('keyup keypress', function (e) {
                var keyCode = e.keyCode || e.which;
                if (keyCode === 13) {
                    e.preventDefault();
                    return false;
                }
            });
            axios({
                method: 'POST',
                url: getApiUrl() + "/models/list",
                data: pageConfiguration.params
            }).then(function (modelList) {
                modelsSearchList = modelList.data.Models || [];
                $("form[name=searchform] input[name=search]")
                    .off("keyup")
                    .keyup(_.debounce(onTypeSearch, 200))
                    .prop("disabled", false)
                    .focus()
                    .val(currentPage.searchfilter || "")
                    .attr("placeholder","Type a name")
                $("form[name=searchform] > div.control").removeClass("is-loading");
                filterSearch();
                if (currentPage.searchfilter && typeof onSearchTyping == 'function') {
                    onSearchTyping(currentPage.searchfilter);
                }
            })
        } else {
            onPageLoaded();
        }
    }
}

function onTypeSearch() {
    const q = $("form[name=searchform] input[name=search]").val();
    browserurl = "/models/" + currentPage.navigation + "/" + q;
    parseUrl(true);
    if (typeof onSearchTyping == 'function') {
        onSearchTyping(q);
    }
}

function filterSearch() {
    if (currentPage.searchfilter && currentPage.searchfilter.length > 0) {
        filterlist = getSearchedList(modelsSearchList, currentPage.searchfilter)
        if (filterlist && filterlist.length) {
            var searchresulttemplate = "models-list";
            if (typeof getSearchResultTemplates == 'function') {
                searchresulttemplate = getSearchResultTemplates();
            }
            renderTemplate(searchresulttemplate, filterlist, $(".search-result-wrapper"));
        } else {
            renderTemplate('models-search-empty', filterlist, $(".search-result-wrapper"));
        }
    } else {
        renderTemplate('models-search-start', currentPage, $(".search-result-wrapper"));
    }
    const observer = lozad();
    observer.observe();
    onModelListLoaded();
}
let addSeoInfo = function() {
    let pagetitle = config_nw_website.configurations.agencyName;
    let descriptor = "";
    let pagedescription = config_nw_website.configurations.agencyName + " website";
    if (currentPage) {
        if (currentPage.modelFirstName) {
            descriptor += " - " + currentPage.modelFirstName;
            if (currentPage.modelLastName) {
                descriptor += " " + currentPage.modelLastName;
            }
            if (currentPage.activeBookName) {
                descriptor += " - " + currentPage.activeBookName;
            }
        } else {
            if (currentPage.area) {
                descriptor += " - " + currentPage.area;
                if (currentPage.navigation) {
                    descriptor += " - " + currentPage.navigation;
                }
            }
        }
    }
    if (descriptor) {
        pagetitle += descriptor;
        pagedescription += " -  page: " + descriptor; 
    }    
    if (document.title != pagetitle) {
        document.title = pagetitle;
    }
    $('meta[name="description"]').attr("content", pagedescription);

}
function getModelSocialLink(mymodel, socialname) {
    if (mymodel.Socials && mymodel.Socials.length > 0) {
        var social = _.findWhere(mymodel.Socials, { type: socialname });
        if (social) {
            return social.link;
        }
    }
    return null;
}
function loadWebFont() {
    if (config_nw_website.configurations.advancedFonts) {
        WebFont.load(
            config_nw_website.configurations.advancedFonts
        );
    } else {
        if (config_nw_website.configurations.fonts && config_nw_website.configurations.fonts.length) {
            WebFont.load({
                google: {
                    families: config_nw_website.configurations.fonts
                }
            });
        }
    }
}

function parseVideoURL(url) {
    var retVal = {};
    var matches;
    if (matches = url.match(/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})?$/)) {
        retVal.provider = "youtube";
        retVal.id = matches[1];
    } else if (matches = url.match(/vimeo.com\/(.+)/)) {
        retVal.provider = "vimeo";
        retVal.id = matches[1];
    }
    return(retVal);
}

function downloadVideo(videoid) {

    if (videoid.indexOf("?") > -1) {
        videoid = videoid.substring(0, videoid.indexOf("?"));
    }

    axios({
        method: 'GET',
        url:  getApiUrl() + "/video/getdownloadlink/" + videoid
    }).then(function (data) {
        window.open(data.data)
    }).catch(function (error) {
        alert(error);
    });
}

const onPageLoaded = function() {
    //on all pages except package, fires after all the renders
    console.log("on page loaded")
}

const onPackagePageLoaded = function() {
    //on package page
    console.log("on package page loaded")
}

const onHomeLoaded = function(event) {
    console.log("on home loaded")
};

const beforeGalleryRender = function(data) {
    //data processing for galleries - data = gallery
    console.log("before gallery render")
    return data;
}

const onGalleryLoaded = function(gallery) {
    console.log("on gallery loaded")
    //startFullPageGallery(gallery)
}

const beforeNewsRender = function (data) { return data; }
const onNewsLoaded = function (data) {}
const beforeArticleRender = function (data) { return data; }
const onArticleLoaded = function (data) {}
const onModelArticleLoaded = function (data) {}

const beforeRenderModelList = function (list) { return list; }

const onModelListLoaded = function(list) {
    //hover on covers, effect, other...
    console.log("on model list loaded")
};

const beforeRenderModelPage = function(model) {
    //change page layout or sections (maybe to give more space), or preprocess model data
    return model;
}

const onModelLoaded = function(model) {
    //executed after renderModelPage()
    console.log("on model loaded")
};

const onApplicationLoaded = function() {
    console.log("on application loaded")
};

const onInfoLoaded = function() {
    console.log("on info loaded")
};

//PACKAGES
const beforeRenderPackageList = function() {
    console.log("before render package list")
    //access currentPackage.data (.packageBooks) to pre-process package data
}

const onPackageListLoaded = function() {
    console.log("on package list loaded")

    
    //access currentPackage.data (.packageBooks) to pre-process package data
}

const beforeRenderPackageModelPage = function(packagemodel) {
    //change page layout or sections (maybe to give more space), or preprocess model package data
    //packagemodel.BookType = p || v
    console.log("before render package model page")
    return packagemodel;
}

const onPackageModelLoaded = function(packagemodel) {
    //executed after renderModelPage()
    //packagemodel.BookType = p || v
    console.log("on package model loaded")
}
const onSearchTyping = function(q) {
    
}
this["JST"] = this["JST"] || {};

this["JST"]["advanced-search-header"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"search-header\">\n    <div class=\"columns is-vcentered\">\n        <div class=\"column is-narrow\">name</div>\n        <div class=\"column\">\n            <input class=\"input\" type=\"text\" name=\"search-name\" placeholder=\"type a name...\">\n        </div>\n    </div>\n    <div class=\"columns is-vcentered\">\n        <div class=\"column is-narrow\">hair</div>\n        <div class=\"column\">\n            <div class=\"search-tags field is-grouped is-grouped-multiline\" data-feature=\"hair\"></div>\n        </div>\n    </div>\n    <div class=\"columns is-vcentered\">\n        <div class=\"column is-narrow\">eyes</div>\n        <div class=\"column\">\n            <div class=\"search-tags field is-grouped is-grouped-multiline\" data-feature=\"eyes\"></div>\n        </div>\n    </div>\n    \n    <div class=\"columns is-vcentered\">\n        <div class=\"column is-narrow\">height</div>\n        <div class=\"column\">\n            <div class=\"search-slider\" data-feature=\"height\"></div>\n        </div>\n        <div class=\"column is-narrow\">shoes</div>\n        <div class=\"column\">\n            <div class=\"search-slider\" data-feature=\"shoes\"></div>\n        </div>\n    </div>\n    <br/>\n    <div class=\"columns is-vcentered\">\n        <div class=\"column is-narrow\">bust</div>\n        <div class=\"column\">\n            <div class=\"search-slider\" data-feature=\"bust\"></div>\n        </div>\n        <div class=\"column is-narrow\">waist</div>\n        <div class=\"column\">\n            <div class=\"search-slider\" data-feature=\"waist\"></div>\n        </div>\n        <div class=\"column is-narrow\">hips</div>\n        <div class=\"column\">\n            <div class=\"search-slider\" data-feature=\"hips\"></div>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["application-old"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing;

  return ((stack1 = helpers["if"].call(alias1,(helpers.fieldTypeText || (depth0 && depth0.fieldTypeText) || alias2).call(alias1,depth0,{"name":"fieldTypeText","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + ((stack1 = helpers["if"].call(alias1,(helpers.fieldTypeSelect || (depth0 && depth0.fieldTypeSelect) || alias2).call(alias1,depth0,{"name":"fieldTypeSelect","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                    <div class=\"field\">\n                        <label class=\"label control-label\" for=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                            "
    + alias4((helpers.requiredSuperScript || (depth0 && depth0.requiredSuperScript) || alias2).call(alias1,depth0,{"name":"requiredSuperScript","hash":{},"data":data}))
    + "</label>\n"
    + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.extendedText : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                        <div class=\"control\">\n                            <input id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" class=\"input\" type=\""
    + alias4(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"type","hash":{},"data":data}) : helper)))
    + "\" name=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n                        </div>\n                    </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var helper;

  return "                        <p class=\"help\">"
    + container.escapeExpression(((helper = (helper = helpers.extendedText || (depth0 != null ? depth0.extendedText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"extendedText","hash":{},"data":data}) : helper)))
    + "</p>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                    <div class=\"field\">\n                        <label class=\"label\" for=\""
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "</label>\n"
    + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.extendedText : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                        <div class=\"control\">\n                            <div class=\"select\">\n                                <select id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" type=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" name=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.options : depth0),{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                                </select>\n                            </div>\n                        </div>\n                    </div>\n";
},"6":function(container,depth0,helpers,partials,data) {
    return "                                    <option>"
    + container.escapeExpression(container.lambda(depth0, depth0))
    + "</option>\n";
},"8":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return ((stack1 = helpers["if"].call(alias1,(helpers.fieldTypeUpload || (depth0 && depth0.fieldTypeUpload) || helpers.helperMissing).call(alias1,depth0,{"name":"fieldTypeUpload","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"9":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <div class=\"field\">\n                    <div class=\"file has-name is-fullwidth\">\n                        <label class=\"col-sm-2 control-label file-label\" for=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n                            <input id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" class=\"file-input form-control\" type=\"file\" name=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n                            <span id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" class=\"file-cta\">\n                                <span class=\"file-icon\">\n                                    <i class=\"fas fa-cloud-upload-alt\"></i>\n                                </span>\n                                <span class=\"file-label\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "</span>\n                            </span>\n                            <span class=\"file-name\"></span>\n                        </label>\n                    </div>\n"
    + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.extendedText : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n                <br>\n";
},"10":function(container,depth0,helpers,partials,data) {
    var helper;

  return "                    <p class=\"help\">"
    + container.escapeExpression(((helper = (helper = helpers.extendedText || (depth0 != null ? depth0.extendedText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"extendedText","hash":{},"data":data}) : helper)))
    + "</p>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"static-page\">\n    <form id=\"main\" novalidate>\n        <div class=\"columns\">\n            <div class=\"column\">\n                <h5>Info</h5>\n                <div style=\"padding-right: 2em\">\n                    <div class=\"field\">\n                        <label class=\"label\" for=\"Name\">Name <sup class=\"superscript-required\">REQUIRED</sup></label>\n                        <div class=\"control\">\n                            <input id=\"Name\" class=\"input\" type=\"text\"name=\"Name\">\n                        </div>\n                    </div>\n                    <div class=\"field\">\n                        <label class=\"label\" for=\"Surname\">Surname <sup class=\"superscript-required\">REQUIRED</sup></label>\n                        <div class=\"control\">\n                            <input id=\"Surname\" class=\"input\" type=\"text\" name=\"Surname\">\n                        </div>\n                    </div>\n                    <div class=\"field\">\n                        <label class=\"label\" for=\"Email\">Email <sup class=\"superscript-required\">REQUIRED</sup></label>\n                        <div class=\"control\">\n                            <input id=\"Email\" class=\"input\" type=\"text\" name=\"Email\">\n                        </div>\n                    </div>\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.optional : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n            </div>\n            <div class=\"column\">\n                <h5>Pictures</h5>\n                <br>\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.optional : depth0),{"name":"each","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </div>\n        </div>\n        <br>\n        <div class=\"control form-group\">\n            <div class=\"col-sm-offset-2 col-sm-10 submit-container has-text-centered\">\n                <button class=\"button is-dark\" type=\"submit\">Submit</button>\n            </div>\n        </div>\n    </form>\n    <div class=\"modal-container\"></div>\n</div>";
},"useData":true});

this["JST"]["application-submission-complete"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"submission-complete\">\n    <br><br>\n    <br><br>\n    <p class=\"has-text-centered is-size-4\">Thank you for submitting your application.</p>\n    <br><br>\n    <br><br>\n</div>";
},"useData":true});

this["JST"]["application"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing;

  return ((stack1 = helpers["if"].call(alias1,(helpers.fieldTypeText || (depth0 && depth0.fieldTypeText) || alias2).call(alias1,depth0,{"name":"fieldTypeText","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + ((stack1 = helpers["if"].call(alias1,(helpers.fieldTypeSmallText || (depth0 && depth0.fieldTypeSmallText) || alias2).call(alias1,depth0,{"name":"fieldTypeSmallText","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + ((stack1 = helpers["if"].call(alias1,(helpers.fieldTypeSelect || (depth0 && depth0.fieldTypeSelect) || alias2).call(alias1,depth0,{"name":"fieldTypeSelect","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                            <div class=\"column is-half\">\n                                <div class=\"field\">\n                                    <label class=\"label\" for=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + " "
    + alias4((helpers.requiredSuperScript || (depth0 && depth0.requiredSuperScript) || alias2).call(alias1,depth0,{"name":"requiredSuperScript","hash":{},"data":data}))
    + "</label>\n"
    + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.extendedText : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                                    <div class=\"control\">\n                                        <input id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" class=\"input\" type=\"text\" name=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n                                    </div>\n                                </div>\n                            </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var helper;

  return "                                        <p class=\"help\">"
    + container.escapeExpression(((helper = (helper = helpers.extendedText || (depth0 != null ? depth0.extendedText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"extendedText","hash":{},"data":data}) : helper)))
    + "</p>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                            <div class=\"column\">\n                                <div class=\"field\">\n                                    <label class=\"label\" for=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + " "
    + alias4((helpers.requiredSuperScript || (depth0 && depth0.requiredSuperScript) || alias2).call(alias1,depth0,{"name":"requiredSuperScript","hash":{},"data":data}))
    + "</label>\n"
    + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.extendedText : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                                    <div class=\"control\">\n                                        <input id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" class=\"input\" type=\"text\" name=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n                                    </div>\n                                </div>\n                            </div>\n";
},"7":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                            <div class=\"column\">\n                                <div class=\"field\">\n                                    <label class=\"label\" for=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + " "
    + alias4((helpers.requiredSuperScript || (depth0 && depth0.requiredSuperScript) || alias2).call(alias1,depth0,{"name":"requiredSuperScript","hash":{},"data":data}))
    + "</label>\n"
    + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.extendedText : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                                    <div class=\"control\">\n                                        <div class=\"select\">\n                                            <select id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" type=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" name=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.options : depth0),{"name":"each","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                                            </select>\n                                        </div>\n                                    </div>\n                                </div>\n                            </div>\n";
},"8":function(container,depth0,helpers,partials,data) {
    return "                                                <option>"
    + container.escapeExpression(container.lambda(depth0, depth0))
    + "</option>\n";
},"10":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return ((stack1 = helpers["if"].call(alias1,(helpers.fieldTypeUpload || (depth0 && depth0.fieldTypeUpload) || helpers.helperMissing).call(alias1,depth0,{"name":"fieldTypeUpload","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"11":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                        <div class=\"picture-to-upload\">\n                            <input id=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" class=\"file-input\" type=\"file\" name=\""
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n                            <img class=\"img-preview\" src=\"/img/trans.png\" />\n                            <span class=\"upload-main-text\">\n                                <i class=\"fal fa-cloud-arrow-up fa-2x\"></i>\n                                <br/><br/>\n                                drop here a file or click to select one\n                            </span>\n                            <span class=\"error-message error-message-size\"><i class=\"fas fa-triangle-exclamation\"></i>&nbsp;File size is too big</span>\n                            <span class=\"error-message error-message-type\"><i class=\"fas fa-triangle-exclamation\"></i>&nbsp;Only jpg images are allowed</span>\n                            <span class=\"error-message error-message-required\"><i class=\"fas fa-triangle-exclamation\"></i>&nbsp;The upload of this file is required</span>\n                            <span class=\"upload-remove-button\"><i class=\"fas fa-circle-xmark\"></i></span>\n                        </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"application-page\">\n    <h1>become a model</h1>\n    <form id=\"applicationForm\" novalidate>\n        <div class=\"columns\">\n            <div class=\"column\">\n                <div class=\"columns is-multiline\">\n                    <div class=\"column is-half\">\n                        <div class=\"field\">\n                            <label class=\"label\" for=\"Name\">Name <sup class=\"superscript-required\">REQUIRED</sup></label>\n                            <div class=\"control\">\n                                <input id=\"Name\" class=\"input\" type=\"text\" name=\"Name\">\n                            </div>\n                        </div>\n                    </div>\n                    <div class=\"column is-half\">\n                        <div class=\"field\">\n                            <label class=\"label\" for=\"Surname\">Surname <sup class=\"superscript-required\">REQUIRED</sup></label>\n                            <div class=\"control\">\n                                <input id=\"Surname\" class=\"input\" type=\"text\" name=\"Surname\">\n                            </div>\n                        </div>\n                    </div>\n                    <div class=\"column is-half\">\n                        <div class=\"field\">\n                            <label class=\"label\" for=\"Email\">E-mail address <sup class=\"superscript-required\">REQUIRED</sup></label>\n                            <div class=\"control\">\n                                <input id=\"Email\" class=\"input\" type=\"text\" name=\"Email\">\n                            </div>\n                        </div>\n                    </div>\n\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.optional : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n            </div>\n            <div class=\"column is-narrow\">\n                <p><strong>photos</strong> (up to 1mb each)</p>\n                <div class=\"pictures-to-upload\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.optional : depth0),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n            </div>\n        </div>\n        <br>\n        <div class=\"control form-group\">\n            <div class=\"col-sm-offset-2 col-sm-10 submit-container has-text-centered\">\n                <button class=\"button is-dark\" type=\"submit\">Submit</button>\n            </div>\n        </div>\n    </form>\n    <div class=\"modal-container\"></div>\n</div>";
},"useData":true});

this["JST"]["modal-file-too-big"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var helper;

  return "<div class=\"modal modal-application\" id=\"myModalFileTooBig\">\n    <div class=\"modal-background\">\n    </div>\n    <div class=\"modal-content\">\n        <div class=\"box\">\n            <p>The picture you're trying to upload is too big. Please use files under "
    + container.escapeExpression(((helper = (helper = helpers.limit || (depth0 != null ? depth0.limit : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"limit","hash":{},"data":data}) : helper)))
    + "</p>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["modal"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"modal modal-application\" id=\"myModal\">\n    <div class=\"modal-background\">\n    </div>\n    <div class=\"modal-content\">\n        <div class=\"box\">\n            <p>Please wait "
    + container.escapeExpression(container.lambda(depth0, depth0))
    + ", we're submitting your application</p>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["model-details-back-link"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<a href=\"/w/models/"
    + container.escapeExpression(container.lambda((depth0 != null ? depth0.navigation : depth0), depth0))
    + "\"><i class=\"fal fa-arrow-left\"></i>&nbsp;back</a>";
},"useData":true});

this["JST"]["model-details-carousel"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "        <div class=\"model-nav-tabs\">\n            "
    + alias3(((helper = (helper = helpers.ModelBookListInPackageAsTabs || (depth0 != null ? depth0.ModelBookListInPackageAsTabs : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"ModelBookListInPackageAsTabs","hash":{},"data":data}) : helper)))
    + "\n            "
    + alias3((helpers.ModelBookListAsTabs || (depth0 && depth0.ModelBookListAsTabs) || alias2).call(alias1,depth0,{"name":"ModelBookListAsTabs","hash":{},"data":data}))
    + "\n        </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing;

  return "                        <div class=\"carousel-item "
    + ((stack1 = helpers["if"].call(alias1,(data && data.first),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "\">\n"
    + ((stack1 = helpers["if"].call(alias1,(data && data.first),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + ((stack1 = helpers["if"].call(alias1,(helpers.pictureExists || (depth0 && depth0.pictureExists) || alias2).call(alias1,(depth0 != null ? depth0.Picture1 : depth0),{"name":"pictureExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + ((stack1 = helpers["if"].call(alias1,(helpers.pictureExists || (depth0 && depth0.pictureExists) || alias2).call(alias1,(depth0 != null ? depth0.Picture2 : depth0),{"name":"pictureExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                        </div>\n";
},"4":function(container,depth0,helpers,partials,data) {
    return "is-first";
},"6":function(container,depth0,helpers,partials,data) {
    return "                                <div class=\"carousel-picture-single\">\n                                    <h1 class=\"carousel-model-name\"></h1>\n                                </div>\n";
},"8":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.shouldBeDouble : stack1),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.program(11, data, 0),"data":data})) != null ? stack1 : "");
},"9":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                                    <div class=\"carousel-picture-double\">\n                                        <img src=\""
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                    </div>\n";
},"11":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                                    <div class=\"carousel-picture-single\">\n                                        <img src=\""
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                    </div>\n";
},"13":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                                <div class=\"carousel-picture-single\">\n                                    <img src=\""
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing;

  return "<div class=\"model-book-carousel\">\n"
    + ((stack1 = (helpers.hasModelNav || (depth0 && depth0.hasModelNav) || alias2).call(alias1,depth0,{"name":"hasModelNav","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    <div class=\"model-preview\">\n        <div class=\"left model-info model-info-carousel\" id=\"model-info-container\">\n        </div>\n        <div class=\"right\" style=\"background-image:url("
    + container.escapeExpression((helpers.getModelCoverActiveBook || (depth0 && depth0.getModelCoverActiveBook) || alias2).call(alias1,depth0,{"name":"getModelCoverActiveBook","hash":{},"data":data}))
    + ")\"></div>\n    </div>\n\n\n    <div class=\"modal\">\n        <div class=\"modal-background\"></div>\n        <div class=\"modal-content\">\n            <div class=\"book-carousel-container\">\n                <div id=\"carousel-book\" class=\"carousel\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.DblPages : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n            </div>\n            <div class=\"prev\"><i class=\"fal fa-chevron-left fa-3x\"></i></div>\n            <div class=\"next\"><i class=\"fal fa-chevron-right fa-3x\"></i></div>\n        </div>\n        <button class=\"modal-close is-large\" aria-label=\"close\"></button>\n    </div>\n</div>\n\n</div>";
},"useData":true});

this["JST"]["model-details-classic"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "        <div class=\"model-nav-tabs\">\n            "
    + alias3(((helper = (helper = helpers.ModelBookListInPackageAsTabs || (depth0 != null ? depth0.ModelBookListInPackageAsTabs : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"ModelBookListInPackageAsTabs","hash":{},"data":data}) : helper)))
    + "\n            "
    + alias3((helpers.ModelBookListAsTabs || (depth0 && depth0.ModelBookListAsTabs) || alias2).call(alias1,depth0,{"name":"ModelBookListAsTabs","hash":{},"data":data}))
    + "\n        </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return ((stack1 = helpers["if"].call(alias1,(helpers.picturesExists || (depth0 && depth0.picturesExists) || helpers.helperMissing).call(alias1,depth0,{"name":"picturesExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing;

  return "                            <li>\n"
    + ((stack1 = helpers["if"].call(alias1,(helpers.pictureExists || (depth0 && depth0.pictureExists) || alias2).call(alias1,(depth0 != null ? depth0.Picture1 : depth0),{"name":"pictureExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + ((stack1 = helpers["if"].call(alias1,(helpers.pictureExists || (depth0 && depth0.pictureExists) || alias2).call(alias1,(depth0 != null ? depth0.Picture2 : depth0),{"name":"pictureExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                            </li>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                                    <a href=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\" data-double=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.IsDbl : stack1), depth0))
    + "\"\n                                        data-id=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.ID : stack1), depth0))
    + "\" data-width=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Width : stack1), depth0))
    + "\"\n                                        data-height=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Height : stack1), depth0))
    + "\" data-orientation=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Orientation : stack1), depth0))
    + "\"\n                                        data-note=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Note : stack1), depth0))
    + "\">&nbsp;</a>\n";
},"7":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                                    <a href=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\" data-double=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.IsDbl : stack1), depth0))
    + "\"\n                                        data-id=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.ID : stack1), depth0))
    + "\" data-width=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Width : stack1), depth0))
    + "\"\n                                        data-height=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Height : stack1), depth0))
    + "\" data-orientation=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Orientation : stack1), depth0))
    + "\"\n                                        data-note=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Note : stack1), depth0))
    + "\">&nbsp;</a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "<div class=\"model-book-classic\">\n"
    + ((stack1 = (helpers.hasModelNav || (depth0 && depth0.hasModelNav) || alias2).call(alias1,depth0,{"name":"hasModelNav","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    <div class=\"model-wrapper\">\n        <div class=\"book-container\">\n            <div id=\"model-info-container\" class=\"left-info-hidden\"></div>\n            <div class=\"right-info-hidden\">\n                <img src=\"/img/"
    + alias4(((helper = (helper = helpers.getLogo || (depth0 != null ? depth0.getLogo : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getLogo","hash":{},"data":data}) : helper)))
    + "\" alt=\""
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "\">\n            </div>\n            <div class=\"book-viewer\">\n                <div class=\"picbox\"></div>\n                <a class=\"book-prev\" href=\"javascript:void(0)\" title=\"go to previous page of the book\">\n                    <i class=\"fas fa-chevron-left arr\"></i>\n                </a>\n                <a class=\"book-next\" href=\"javascript:void(0)\" title=\"go to next page of the book\">\n                    <i class=\"fas fa-chevron-right arr\"></i>\n                </a>\n            </div>\n            <div id=\"hiddenbook\" class=\"h\">\n                <ul data-title=\""
    + alias4(((helper = (helper = helpers.Title || (depth0 != null ? depth0.Title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Title","hash":{},"data":data}) : helper)))
    + "\" data-description=\""
    + alias4(((helper = (helper = helpers.Description || (depth0 != null ? depth0.Description : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Description","hash":{},"data":data}) : helper)))
    + "\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.DblPages : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </ul>\n            </div>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["model-details-hscroll"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "    <div class=\"model-nav-tabs\">\n        "
    + alias3(((helper = (helper = helpers.ModelBookListInPackageAsTabs || (depth0 != null ? depth0.ModelBookListInPackageAsTabs : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"ModelBookListInPackageAsTabs","hash":{},"data":data}) : helper)))
    + "\n        "
    + alias3((helpers.ModelBookListAsTabs || (depth0 && depth0.ModelBookListAsTabs) || alias2).call(alias1,depth0,{"name":"ModelBookListAsTabs","hash":{},"data":data}))
    + "\n    </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isPlaceholder : depth0),{"name":"unless","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "                        <img style=\"margin-right:2px;\" src=\""
    + alias3((helpers.extendedPicture || (depth0 && depth0.extendedPicture) || alias2).call(alias1,depth0,"URL",{"name":"extendedPicture","hash":{},"data":data}))
    + "\"\n                            data-width=\""
    + alias3((helpers.extendedPicture || (depth0 && depth0.extendedPicture) || alias2).call(alias1,depth0,"Width",{"name":"extendedPicture","hash":{},"data":data}))
    + "\" data-height=\""
    + alias3((helpers.extendedPicture || (depth0 && depth0.extendedPicture) || alias2).call(alias1,depth0,"Height",{"name":"extendedPicture","hash":{},"data":data}))
    + "\" />\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing;

  return ((stack1 = (helpers.hasModelNav || (depth0 && depth0.hasModelNav) || alias2).call(alias1,depth0,{"name":"hasModelNav","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "<div class=\"model-book-hscroll\">\n    <div class=\"content-wrapper-model\">\n        <div class=\"model-page-wrapper\">\n            <div id=\"model-info-container\" class=\"model-sidebar model-info model-info-hscroll\"></div>\n            <div id=\"viewportdiv\" class=\"always-visible\">\n                <div id=\"wrapperdiv\">\n                    <img style=\"margin-right:2px;\" src=\""
    + container.escapeExpression(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/img/trans.png\" data-width=\"260\" data-height=\"400\" />\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.Pages : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n            </div>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["model-details-index-pictures"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return ((stack1 = helpers["if"].call(alias1,(helpers.picturesExists || (depth0 && depth0.picturesExists) || helpers.helperMissing).call(alias1,depth0,{"name":"picturesExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing;

  return "            <li>\n"
    + ((stack1 = helpers["if"].call(alias1,(helpers.pictureExists || (depth0 && depth0.pictureExists) || alias2).call(alias1,(depth0 != null ? depth0.Picture1 : depth0),{"name":"pictureExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + ((stack1 = helpers["if"].call(alias1,(helpers.pictureExists || (depth0 && depth0.pictureExists) || alias2).call(alias1,(depth0 != null ? depth0.Picture2 : depth0),{"name":"pictureExists","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </li>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                    <a href=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\" data-double=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.IsDbl : stack1), depth0))
    + "\" data-id=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.ID : stack1), depth0))
    + "\" data-width=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Width : stack1), depth0))
    + "\" data-height=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Height : stack1), depth0))
    + "\" data-orientation=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Orientation : stack1), depth0))
    + "\" data-note=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.Note : stack1), depth0))
    + "\">&nbsp;</a>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                    <a href=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\" data-double=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.IsDbl : stack1), depth0))
    + "\" data-id=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.ID : stack1), depth0))
    + "\" data-width=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Width : stack1), depth0))
    + "\" data-height=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Height : stack1), depth0))
    + "\" data-orientation=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Orientation : stack1), depth0))
    + "\" data-note=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.Note : stack1), depth0))
    + "\">&nbsp;</a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "<div class=\"h hiddenbook\">\n    <ul data-title=\""
    + alias4(((helper = (helper = helpers.Title || (depth0 != null ? depth0.Title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Title","hash":{},"data":data}) : helper)))
    + "\" data-description=\""
    + alias4(((helper = (helper = helpers.Description || (depth0 != null ? depth0.Description : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Description","hash":{},"data":data}) : helper)))
    + "\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.DblPages : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </ul>\n</div>";
},"useData":true});

this["JST"]["model-details-index"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.value : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                    <div class=\"model-feature\">\n                        <div class=\"model-feature-name\">"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "</div>\n                        <div class=\"model-feature-value\">"
    + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
    + "</div>\n                    </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "<div class=\"book-index-model-book-viewer\">\n    <div class=\"model-details-books-container\"></div>\n    <div class=\"model-book-viewer-close\">\n        <a href=\"javascript:void(0)\" class=\"close-book-trigger\">\n            <i class=\"fa-light fa-xmark\"></i>\n        </a>\n    </div>\n    <div class=\"model-books-footer\">\n        <div class=\"model-books-footer-container\">\n            <div class=\"book-links\">\n                "
    + alias3((helpers.ModelBookListIndex || (depth0 && depth0.ModelBookListIndex) || alias2).call(alias1,depth0,{"name":"ModelBookListIndex","hash":{},"data":data}))
    + "\n            </div>\n            <div class=\"book-tools\">\n                <a class=\"overview-trigger\" href=\"javascript:void(0)\"><i class=\"fa-sharp fa-solid fa-grid-horizontal\"></i> overview</a>\n                &nbsp;&nbsp;\n                <a class=\"print-trigger\" href=\"javascript:void(0)\"><i class=\"fa-sharp fa-regular fa-print\"></i> print</a>\n            </div>\n        </div>\n    </div>\n</div>\n<div class=\"model-book-index\">\n    <div class=\"model-book-index-covers-wrapper\">\n        <div class=\"model-book-index-page-left\">\n            "
    + alias3((helpers.BookIndexPortfolioCover || (depth0 && depth0.BookIndexPortfolioCover) || alias2).call(alias1,(depth0 != null ? depth0.Books : depth0),{"name":"BookIndexPortfolioCover","hash":{},"data":data}))
    + "\n        </div>\n        <div class=\"model-book-index-page-right\">\n            <div class=\"book-index-model-info\">\n                <h1 class=\"model-name\">\n                    <a href=\""
    + alias3(((helper = (helper = helpers.modelBackLink || (depth0 != null ? depth0.modelBackLink : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"modelBackLink","hash":{},"data":data}) : helper)))
    + "\" class=\"back-link\"><i class=\"fal fa-arrow-left\"></i></a>\n                    "
    + alias3((helpers.bookModelName || (depth0 && depth0.bookModelName) || alias2).call(alias1,(depth0 != null ? depth0.FirstName : depth0),(depth0 != null ? depth0.LastName : depth0),{"name":"bookModelName","hash":{},"data":data}))
    + "\n                </h1>\n                <div class=\"model-features\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.Features : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n                <div class=\"social-links\">\n                    "
    + alias3((helpers.LinksToSocials || (depth0 && depth0.LinksToSocials) || alias2).call(alias1,(depth0 != null ? depth0.Socials : depth0),{"name":"LinksToSocials","hash":{},"data":data}))
    + "\n                </div>\n            </div>\n            <div class=\"book-covers-wrapper\">\n                "
    + alias3((helpers.BookIndexBookCovers || (depth0 && depth0.BookIndexBookCovers) || alias2).call(alias1,(depth0 != null ? depth0.Books : depth0),{"name":"BookIndexBookCovers","hash":{},"data":data}))
    + "\n                "
    + alias3((helpers.VideoBookIndexBookCovers || (depth0 && depth0.VideoBookIndexBookCovers) || alias2).call(alias1,(depth0 != null ? depth0.VideoBooks : depth0),{"name":"VideoBookIndexBookCovers","hash":{},"data":data}))
    + "\n            </div>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["model-details-masonry"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "                <div class=\"model-nav-tabs\">\n                    "
    + alias3(((helper = (helper = helpers.ModelBookListInPackageAsTabs || (depth0 != null ? depth0.ModelBookListInPackageAsTabs : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"ModelBookListInPackageAsTabs","hash":{},"data":data}) : helper)))
    + "\n                    "
    + alias3((helpers.ModelBookListAsTabs || (depth0 && depth0.ModelBookListAsTabs) || alias2).call(alias1,depth0,{"name":"ModelBookListAsTabs","hash":{},"data":data}))
    + "\n                </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isPlaceholder : depth0),{"name":"unless","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.Picture : depth0)) != null ? stack1.shouldBeDouble : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(10, data, 0),"data":data})) != null ? stack1 : "");
},"5":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.PictureExt : depth0)) != null ? stack1.ID : stack1),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.program(8, data, 0),"data":data})) != null ? stack1 : "");
},"6":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                                <div class=\"picture picture-single\">\n                                    <img src=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                </div>\n                                <div class=\"picture picture-single\">\n                                    <img src=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.PictureExt : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                </div>\n";
},"8":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                                <div class=\"picture picture-double\">\n                                    <img src=\""
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.Picture : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                </div>\n";
},"10":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                        <div class=\"picture picture-single\">\n                            <img src=\""
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.Picture : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                        </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"model-book-masonry\">\n    <div class=\"model-details-back-link-container\"></div>\n    <div>\n        <div class=\"model-wrapper\">\n"
    + ((stack1 = (helpers.hasModelNav || (depth0 && depth0.hasModelNav) || helpers.helperMissing).call(alias1,depth0,{"name":"hasModelNav","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            <div class=\"pictures\">\n                <div class=\"picture picture-single\">\n                    <div class=\"model-info model-info-masonry\" id=\"model-info-container\"></div>\n                </div>\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.Pages : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </div>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["model-details-mobile"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "                <div class=\"model-nav-tabs\">\n                    "
    + alias3(((helper = (helper = helpers.ModelBookListInPackageAsTabs || (depth0 != null ? depth0.ModelBookListInPackageAsTabs : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"ModelBookListInPackageAsTabs","hash":{},"data":data}) : helper)))
    + "\n                    "
    + alias3((helpers.ModelBookListAsTabs || (depth0 && depth0.ModelBookListAsTabs) || alias2).call(alias1,depth0,{"name":"ModelBookListAsTabs","hash":{},"data":data}))
    + "\n                </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isPlaceholder : depth0),{"name":"unless","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.escapeExpression;

  return "                        <div class=\"picture\">\n                            <img src=\""
    + alias1(container.lambda(((stack1 = (depth0 != null ? depth0.Picture : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                            "
    + alias1((helpers.note || (depth0 && depth0.note) || helpers.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.Picture : depth0)) != null ? stack1.Note : stack1),{"name":"note","hash":{},"data":data}))
    + "\n                        </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"model-book-mobile\">\n    <div class=\"model-details-back-link-container\"></div>\n    <div>\n        <div class=\"model-wrapper\">\n            <div class=\"model-info model-info-mobile\" id=\"model-info-container\"></div>\n"
    + ((stack1 = (helpers.hasModelNav || (depth0 && depth0.hasModelNav) || helpers.helperMissing).call(alias1,depth0,{"name":"hasModelNav","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            <div class=\"pictures\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.Pages : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </div>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["model-details-video"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "    <div class=\"model-nav-tabs model-nav-video\">\n        "
    + alias3(((helper = (helper = helpers.ModelBookListInPackageAsTabs || (depth0 != null ? depth0.ModelBookListInPackageAsTabs : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"ModelBookListInPackageAsTabs","hash":{},"data":data}) : helper)))
    + "\n        "
    + alias3((helpers.ModelBookListAsTabs || (depth0 && depth0.ModelBookListAsTabs) || alias2).call(alias1,depth0,{"name":"ModelBookListAsTabs","hash":{},"data":data}))
    + "\n    </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    return "            "
    + container.escapeExpression((helpers.getVideoEmbed || (depth0 && depth0.getVideoEmbed) || helpers.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),depth0,{"name":"getVideoEmbed","hash":{},"data":data}))
    + "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return ((stack1 = (helpers.hasModelNav || (depth0 && depth0.hasModelNav) || helpers.helperMissing).call(alias1,depth0,{"name":"hasModelNav","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "<div class=\"model-book-video\">\n    <div id=\"model-info-container\" class=\"model-info model-info-video\"></div>\n    <div class=\"model-details-videos\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.Pages : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </div>\n</div>";
},"useData":true});

this["JST"]["model-details-vscroll"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression;

  return "                <div class=\"model-nav-tabs\">\n                    "
    + alias3(((helper = (helper = helpers.ModelBookListInPackageAsTabs || (depth0 != null ? depth0.ModelBookListInPackageAsTabs : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"ModelBookListInPackageAsTabs","hash":{},"data":data}) : helper)))
    + "\n                    "
    + alias3((helpers.ModelBookListAsTabs || (depth0 && depth0.ModelBookListAsTabs) || alias2).call(alias1,depth0,{"name":"ModelBookListAsTabs","hash":{},"data":data}))
    + "\n                </div>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(15, data, 0),"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = (helpers.ifStartsWithRightPicture || (depth0 && depth0.ifStartsWithRightPicture) || helpers.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),depth0,{"name":"ifStartsWithRightPicture","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(10, data, 0),"data":data})) != null ? stack1 : "");
},"5":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                            <div class=\"picture-single\">\n                                <div class=\"model-info model-info-vscroll\" id=\"model-info-container\"></div>\n                            </div>\n"
    + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.isPlaceholder : stack1),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.program(8, data, 0),"data":data})) != null ? stack1 : "");
},"6":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                            <div class=\"picture-single\">\n                                <div class=\"book-img\" style=\"background-image:url("
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.URL : stack1), depth0))
    + ")\">\n                                    <img src=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                </div>\n                            </div>\n";
},"8":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                            <div class=\"picture-single\">\n                                <div class=\"book-img\" style=\"background-image:url("
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + ")\">\n                                    <img src=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                </div>\n                            </div>\n";
},"10":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                            <div class=\"picture-double\">\n                                <div class=\"model-info model-info-vscroll\" id=\"model-info-container\"></div>\n                            </div>\n"
    + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.shouldBeDouble : stack1),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.program(13, data, 0),"data":data})) != null ? stack1 : "");
},"11":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                                <div class=\"picture-double\">\n                                    <div class=\"book-img\">\n                                        <img src=\""
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                    </div>\n                                </div>\n";
},"13":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                                <div class=\"picture-single\">\n                                    <div class=\"book-img\" style=\"background-image:url("
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + ")\">\n                                    </div>\n                                </div>\n                                <div class=\"picture-single\">\n                                    <div class=\"book-img\" style=\"background-image:url("
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.URL : stack1), depth0))
    + ")\">\n                                    </div>\n                                </div>\n";
},"15":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.shouldBeDouble : stack1),{"name":"if","hash":{},"fn":container.program(16, data, 0),"inverse":container.program(18, data, 0),"data":data})) != null ? stack1 : "");
},"16":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                            <div class=\"picture-double\">\n                                <div class=\"book-img\">\n                                    <img src=\""
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + "\">\n                                </div>\n                            </div>\n";
},"18":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression;

  return "                            <div class=\"picture-single\">\n                                <div class=\"book-img\" style=\"background-image:url("
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture1 : depth0)) != null ? stack1.URL : stack1), depth0))
    + ")\">\n                                </div>\n                            </div>\n                            <div class=\"picture-single\">\n                                <div class=\"book-img\" style=\"background-image:url("
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.Picture2 : depth0)) != null ? stack1.URL : stack1), depth0))
    + ")\">\n                                </div>\n                            </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"model-book-vscroll\">\n    <div class=\"model-details-back-link-container\"></div>\n    <div>\n        <div class=\"model-wrapper\">\n"
    + ((stack1 = (helpers.hasModelNav || (depth0 && depth0.hasModelNav) || helpers.helperMissing).call(alias1,depth0,{"name":"hasModelNav","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            <div class=\"pictures\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.DblPages : stack1),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                \n                <br style=\"clear:both\">\n            </div>\n        </div>\n    </div>\n</div>";
},"useData":true});

this["JST"]["model-info"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.PackageBookNote : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
    var helper;

  return "        <p class=\"package-note\">"
    + container.escapeExpression(((helper = (helper = helpers.PackageBookNote || (depth0 != null ? depth0.PackageBookNote : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"PackageBookNote","hash":{},"data":data}) : helper)))
    + "</p>\n";
},"4":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.value : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"5":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "    <tr class=\"model-feature\">\n        <td class=\"model-feature-name\">"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "</td>\n        <td class=\"model-feature-value\">"
    + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
    + "</td>\n    </tr>\n";
},"7":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "    <a class=\"download-button\" href=\"javascript:void(0)\"  onClick=\"downloadPictures("
    + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.ID : stack1), depth0))
    + ")\">\n        <i class=\"fa-light fa-cloud-arrow-down\"></i>download\n    </a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=container.escapeExpression, buffer = 
  "<div class=\"first-line\">\n    <h1 class=\"model-name\">"
    + alias3((helpers.bookModelName || (depth0 && depth0.bookModelName) || alias2).call(alias1,(depth0 != null ? depth0.FirstName : depth0),(depth0 != null ? depth0.LastName : depth0),{"name":"bookModelName","hash":{},"data":data}))
    + "</h1>\n    <div class=\"social-links\">\n        "
    + alias3((helpers.LinksToSocials || (depth0 && depth0.LinksToSocials) || alias2).call(alias1,(depth0 != null ? depth0.Socials : depth0),{"name":"LinksToSocials","hash":{},"data":data}))
    + "\n    </div>\n</div>\n";
  stack1 = ((helper = (helper = helpers.showNotesOnBook || (depth0 != null ? depth0.showNotesOnBook : depth0)) != null ? helper : alias2),(options={"name":"showNotesOnBook","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper));
  if (!helpers.showNotesOnBook) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "<table class=\"model-features\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.Features : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "</table>\n\n<div class=\"book-buttons\">\n    <a class=\"print-button\" href=\"javascript:void(0)\" onClick=\"printBook("
    + alias3(container.lambda(((stack1 = (depth0 != null ? depth0.ActiveBook : depth0)) != null ? stack1.ID : stack1), depth0))
    + ")\">\n        <i class=\"fa-light fa-file-pdf\"></i>&nbsp;print book\n    </a>\n"
    + ((stack1 = (helpers.downloadAllowed || (depth0 && depth0.downloadAllowed) || alias2).call(alias1,depth0,{"name":"downloadAllowed","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "</div>\n";
},"useData":true});

this["JST"]["cookie-banner-content"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"cookie-banner-wrapper\">\n    <div class=\"cookie-banner-content\">\n        <p>\n            We and our partners use cookies as specified in the <a href=\"/img/cookie.pdf\" target=\"_blank\">cookie\n                policy</a>.\n            <br><br>You can consent to the use of such technologies by closing this notice, by scrolling this page, by\n            interacting with any link or button outside of this notice or by continuing to browse otherwise.\n        </p>\n    </div>\n    <button class=\"button is-light close-cookie-banner\">\n        <i class=\"fal fa-check\"></i>&nbsp;&nbsp;Accept\n    </button>\n</div>";
},"useData":true});

this["JST"]["footer"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"footer-container-wrapper\">\n    <footer>\n        <!-- footer -->\n        \n        <div class=\"credits\">\n            <h4 class=\"is-size-7 has-text-right\">\n                POWERED BY <a href=\"http://www.netwalkapp.com\" target=\"_blank\">\n                    <img src=\"/img/logos/netwalk/logo_drk_100x16.png\" alt=\"Netwalk\">\n                </a>\n            </h4>\n        </div>\n    </footer>\n</div>";
},"useData":true});

this["JST"]["header-dropdown"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    return "navbar-centered";
},"3":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">\n                <img src=\"/img/"
    + alias4(((helper = (helper = helpers.getLogo || (depth0 != null ? depth0.getLogo : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getLogo","hash":{},"data":data}) : helper)))
    + "\" alt=\""
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "\">\n            </a>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <h1><a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">"
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "</a></h1>\n";
},"7":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.invisible : depth0),{"name":"unless","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"8":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.areaName : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.program(14, data, 0),"data":data})) != null ? stack1 : "");
},"9":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "            <div class=\"navbar-item\">\n"
    + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isExternal : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.program(12, data, 0),"data":data})) != null ? stack1 : "")
    + "            </div>\n";
},"10":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <a class=\"navbar-link is-arrowless navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" href=\""
    + alias4(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"url","hash":{},"data":data}) : helper)))
    + "\" target=\""
    + alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper)))
    + "\">\n                    "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                </a>\n";
},"12":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <a class=\"navbar-link is-arrowless navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" onclick=\"saveScroll(true)\" data-page-name=\""
    + alias4((helpers.buildPageName || (depth0 && depth0.buildPageName) || alias2).call(alias1,depth0,{"name":"buildPageName","hash":{},"data":data}))
    + "\"\n                    href=\""
    + alias4((helpers.buildLink || (depth0 && depth0.buildLink) || alias2).call(alias1,depth0,{"name":"buildLink","hash":{},"data":data}))
    + "\">\n                    "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                </a>\n";
},"14":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <div class=\"navbar-item has-dropdown is-hoverable\">\n                <a class=\"navbar-link navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + " is-arrowless\">\n                    "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                </a>\n"
    + ((stack1 = helpers["if"].call(alias1,(helpers.hasSubNav || (depth0 && depth0.hasSubNav) || alias2).call(alias1,(depth0 != null ? depth0.subNav : depth0),{"name":"hasSubNav","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </div>\n";
},"15":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                <div class=\"navbar-dropdown is-boxed\">\n"
    + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.subNav : depth0),{"name":"each","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </div>\n";
},"16":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isExternal : depth0),{"name":"if","hash":{},"fn":container.program(17, data, 0),"inverse":container.program(19, data, 0),"data":data})) != null ? stack1 : "");
},"17":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                    <a class=\"navbar-item navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" href=\""
    + alias4(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"url","hash":{},"data":data}) : helper)))
    + "\" target=\""
    + alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper)))
    + "\">\n                        "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                    </a>\n";
},"19":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                    <a class=\"navbar-item navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" onclick=\"saveScroll(true)\" data-page-name=\""
    + alias4((helpers.buildPageName || (depth0 && depth0.buildPageName) || alias2).call(alias1,depth0,{"name":"buildPageName","hash":{},"data":data}))
    + "\"\n                        href=\""
    + alias4((helpers.buildLink || (depth0 && depth0.buildLink) || alias2).call(alias1,depth0,{"name":"buildLink","hash":{},"data":data}))
    + "\">\n                        "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                    </a>\n";
},"21":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <a class=\"navbar-item-social\" href=\""
    + alias4(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"link","hash":{},"data":data}) : helper)))
    + "\" target=\"_blank\"><i class=\"fab fa-lg fa-"
    + alias4(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"type","hash":{},"data":data}) : helper)))
    + "\"></i></a>\n";
},"23":function(container,depth0,helpers,partials,data) {
    return "<nav class=\"breadcrumb is-right has-succeeds-separator\" aria-label=\"breadcrumbs\">\n  <ul>\n    "
    + container.escapeExpression((helpers.getBreadcrumbs || (depth0 && depth0.getBreadcrumbs) || helpers.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),depth0,{"name":"getBreadcrumbs","hash":{},"data":data}))
    + "\n  </ul>\n</nav>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer = 
  "<nav class=\"navbar "
    + ((stack1 = helpers["if"].call(alias1,((stack1 = ((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.nav : stack1)) != null ? stack1.centered : stack1),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + " is-transparent\" role=\"navigation\" aria-label=\"main navigation\">\n    <div class=\"navbar-brand\">\n        <div class=\"logo\">\n";
  stack1 = ((helper = (helper = helpers.ifHasLogo || (depth0 != null ? depth0.ifHasLogo : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"ifHasLogo","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(5, data, 0),"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper));
  if (!helpers.ifHasLogo) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "        </div>\n        <a role=\"button\" class=\"navbar-burger\" aria-label=\"menu\" aria-expanded=\"false\">\n            <span aria-hidden=\"true\"></span>\n            <span aria-hidden=\"true\"></span>\n            <span aria-hidden=\"true\"></span>\n        </a>\n    </div>\n    <div class=\"navbar-menu\">\n        <div class=\"navbar-start\"></div>\n        <div class=\"navbar-end\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.navigation : depth0),{"name":"each","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            <div class=\"navbar-item navbar-socials\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.socials : stack1),{"name":"each","hash":{},"fn":container.program(21, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </div> \n        </div>\n    </div>\n</nav>\n"
    + ((stack1 = helpers["if"].call(alias1,((stack1 = ((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.nav : stack1)) != null ? stack1.breadcrumb : stack1),{"name":"if","hash":{},"fn":container.program(23, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"useData":true});

this["JST"]["header-sidenav"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    return "navbar-centered";
},"3":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">\n                <img src=\"/img/"
    + alias4(((helper = (helper = helpers.getLogo || (depth0 != null ? depth0.getLogo : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getLogo","hash":{},"data":data}) : helper)))
    + "\" alt=\""
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "\">\n            </a>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <h1><a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">"
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "</a></h1>\n";
},"7":function(container,depth0,helpers,partials,data) {
    return "        <span class=\"search-trigger\"><a href=\"/w/models/search\"><i class=\"fal fa-search\"></i></a></span>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, buffer = 
  "<nav class=\"navbar "
    + ((stack1 = helpers["if"].call(alias1,((stack1 = ((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.nav : stack1)) != null ? stack1.centered : stack1),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + " is-transparent\" role=\"navigation\" aria-label=\"main navigation\">\n    <div class=\"navbar-brand\">\n        <div class=\"logo\">\n";
  stack1 = ((helper = (helper = helpers.ifHasLogo || (depth0 != null ? depth0.ifHasLogo : depth0)) != null ? helper : alias2),(options={"name":"ifHasLogo","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(5, data, 0),"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper));
  if (!helpers.ifHasLogo) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "        </div>\n"
    + ((stack1 = (helpers.ifHasSearch || (depth0 && depth0.ifHasSearch) || alias2).call(alias1,depth0,{"name":"ifHasSearch","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "        <div class=\"sidenav-wrapper\">\n            <div class=\"sidenav-container\"></div>\n            <div class=\"sidenav-overlay\"></div>\n            <div class=\"sidenav-trigger-container\">\n                <div class=\"sidenav-trigger\">\n                    <span></span>\n                    <span></span>\n                    <span></span>\n                    <span></span>\n                </div>\n            </div>\n        </div>\n    </div>\n</nav>\n\n\n";
},"useData":true});

this["JST"]["header"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">\n                <img src=\"/img/"
    + alias4(((helper = (helper = helpers.getLogo || (depth0 != null ? depth0.getLogo : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getLogo","hash":{},"data":data}) : helper)))
    + "\" alt=\""
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "\">\n            </a>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <h1><a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">"
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "</a></h1>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.invisible : depth0),{"name":"unless","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"6":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.areaName : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.program(12, data, 0),"data":data})) != null ? stack1 : "");
},"7":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isExternal : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.program(10, data, 0),"data":data})) != null ? stack1 : "");
},"8":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                        <a class=\"navbar-item navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" href=\""
    + alias4(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"url","hash":{},"data":data}) : helper)))
    + "\" target=\""
    + alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper)))
    + "\">\n                            "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                        </a>\n";
},"10":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                        <a class=\"navbar-item navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" data-page-name=\""
    + alias4((helpers.buildPageName || (depth0 && depth0.buildPageName) || alias2).call(alias1,depth0,{"name":"buildPageName","hash":{},"data":data}))
    + "\" href=\""
    + alias4((helpers.buildLink || (depth0 && depth0.buildLink) || alias2).call(alias1,depth0,{"name":"buildLink","hash":{},"data":data}))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "</a>\n";
},"12":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                    <div class=\"navbar-item has-dropdown is-active\">\n                        <a class=\"navbar-link navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + " is-arrowless\">\n                            "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                        </a>\n"
    + ((stack1 = helpers["if"].call(alias1,(helpers.hasSubNav || (depth0 && depth0.hasSubNav) || alias2).call(alias1,(depth0 != null ? depth0.subNav : depth0),{"name":"hasSubNav","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                    </div>\n";
},"13":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                        <div class=\"navbar-dropdown\">\n"
    + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.subNav : depth0),{"name":"each","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                        </div>\n";
},"14":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isExternal : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.program(17, data, 0),"data":data})) != null ? stack1 : "");
},"15":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                                <a class=\"navbar-item navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" href=\""
    + alias4(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"url","hash":{},"data":data}) : helper)))
    + "\" target=\""
    + alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper)))
    + "\">\n                                    "
    + alias4(container.lambda((depth0 != null ? depth0.displayName : depth0), depth0))
    + "\n                                </a>\n";
},"17":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                                <a class=\"navbar-item navbar-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" data-page-name=\""
    + alias4((helpers.buildPageName || (depth0 && depth0.buildPageName) || alias2).call(alias1,depth0,{"name":"buildPageName","hash":{},"data":data}))
    + "\" href=\""
    + alias4((helpers.buildLink || (depth0 && depth0.buildLink) || alias2).call(alias1,depth0,{"name":"buildLink","hash":{},"data":data}))
    + "\">\n                                    "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                                </a>\n";
},"19":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <a class=\"navbar-item-social\" href=\""
    + alias4(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"link","hash":{},"data":data}) : helper)))
    + "\" target=\"_blank\"><i class=\"fab fa-lg fa-"
    + alias4(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"type","hash":{},"data":data}) : helper)))
    + "\"></i></a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer = 
  "<nav class=\"navbar is-transparent\" role=\"navigation\" aria-label=\"main navigation\">\n    <div class=\"navbar-brand\">\n        <div class=\"logo\">\n";
  stack1 = ((helper = (helper = helpers.ifHasLogo || (depth0 != null ? depth0.ifHasLogo : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"ifHasLogo","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper));
  if (!helpers.ifHasLogo) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "        </div>\n        <a role=\"button\" class=\"navbar-burger\" aria-label=\"menu\" aria-expanded=\"false\">\n            <span aria-hidden=\"true\"></span>\n            <span aria-hidden=\"true\"></span>\n            <span aria-hidden=\"true\"></span>\n        </a>\n    </div>\n    <div class=\"navbar-menu no-dropdown\">\n        <div class=\"navbar-start\"></div>\n        <div class=\"navbar-end\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.navigation : depth0),{"name":"each","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            <div class=\"navbar-item navbar-socials\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.socials : stack1),{"name":"each","hash":{},"fn":container.program(19, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </div>            \n        </div>\n    </div>\n</nav>";
},"useData":true});

this["JST"]["layout-default"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"cookie-banner-overlay\"></div>\n<div class=\"full-wrapper\">\n    <div class=\"top-wrapper\">\n        <header>\n        </header>\n    </div>\n    <div class=\"body-wrapper\">\n    </div>\n</div>\n<div id=\"footer-container\" class=\"footer-container\">          \n</div>\n";
},"useData":true});

this["JST"]["layout-package"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"full-wrapper\">\n    <div class=\"top-wrapper\">\n        <header class=\"header-wrapper\">\n        </header>\n    </div>\n    <div class=\"body-wrapper\">\n    </div>\n</div>\n<div id=\"footer-container\" class=\"footer-container\">          \n</div>\n";
},"useData":true});

this["JST"]["layout-splash-video"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"fullpage body-wrapper\"></div>";
},"useData":true});

this["JST"]["layout-splash"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"cookie-banner-overlay\"></div>\n<div class=\"fullpage body-wrapper bg-black\"></div>";
},"useData":true});

this["JST"]["models-list"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression, buffer = 
  "            <div class=\"cover\" data-id="
    + alias4(((helper = (helper = helpers.ID || (depth0 != null ? depth0.ID : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"ID","hash":{},"data":data}) : helper)))
    + ">\n                <a href=\"/w/models/"
    + alias4((helpers.getModelDivision || (depth0 && depth0.getModelDivision) || alias2).call(alias1,depth0,{"name":"getModelDivision","hash":{},"data":data}))
    + "/"
    + alias4(((helper = (helper = helpers.ID || (depth0 != null ? depth0.ID : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"ID","hash":{},"data":data}) : helper)))
    + "-"
    + alias4((helpers.urlName || (depth0 && depth0.urlName) || alias2).call(alias1,(depth0 != null ? depth0.FirstName : depth0),(depth0 != null ? depth0.LastName : depth0),{"name":"urlName","hash":{},"data":data}))
    + "\" onclick=\"saveScroll()\" class=\"cover-img-wrapper\">\n                    <img class=\"cover-img lozad\" data-src=\""
    + alias4(container.lambda(((stack1 = (depth0 != null ? depth0.CoverImage : depth0)) != null ? stack1.StandardUrl : stack1), depth0))
    + "\" src=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/img/trans.png\" alt=\"\">\n"
    + ((stack1 = (helpers.ifShowInstagram || (depth0 && depth0.ifShowInstagram) || alias2).call(alias1,"list",{"name":"ifShowInstagram","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
  stack1 = ((helper = (helper = helpers.ifUseFeatures || (depth0 != null ? depth0.ifUseFeatures : depth0)) != null ? helper : alias2),(options={"name":"ifUseFeatures","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));
  if (!helpers.ifUseFeatures) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "                </a>\n                <h3 class=\"model-name\">\n                    <a href=\"/w/models/"
    + alias4((helpers.getModelDivision || (depth0 && depth0.getModelDivision) || alias2).call(alias1,depth0,{"name":"getModelDivision","hash":{},"data":data}))
    + "/"
    + alias4(((helper = (helper = helpers.ID || (depth0 != null ? depth0.ID : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"ID","hash":{},"data":data}) : helper)))
    + "-"
    + alias4((helpers.urlName || (depth0 && depth0.urlName) || alias2).call(alias1,(depth0 != null ? depth0.FirstName : depth0),(depth0 != null ? depth0.LastName : depth0),{"name":"urlName","hash":{},"data":data}))
    + "\">"
    + alias4((helpers.nameConfiguration || (depth0 && depth0.nameConfiguration) || alias2).call(alias1,(depth0 != null ? depth0.FirstName : depth0),(depth0 != null ? depth0.LastName : depth0),"list",{"name":"nameConfiguration","hash":{},"data":data}))
    + "</a>\n                </h3>\n            </div>\n";
},"2":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.InstagramUsername : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"3":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = (helpers.ifEnoughFollowers || (depth0 && depth0.ifEnoughFollowers) || helpers.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.InstagramFollowers : depth0),{"name":"ifEnoughFollowers","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var helper;

  return "                                <span class=\"tag is-black instagram-tag\">\n                                    <i class=\"fa-brands fa-instagram\"></i>&nbsp;"
    + container.escapeExpression(((helper = (helper = helpers.InstagramFollowersParsed || (depth0 != null ? depth0.InstagramFollowersParsed : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"InstagramFollowersParsed","hash":{},"data":data}) : helper)))
    + "\n                                </span>\n";
},"6":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                        <div class=\"model-feat-overlay\">\n                            <div class=\"model-feats\">\n"
    + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.Features : depth0),{"name":"each","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                            </div>\n                        </div>\n";
},"7":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.value : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"8":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                                    <div class=\"model-feat\">\n                                        <span>"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "</span>\n                                        <em>"
    + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
    + "</em>\n                                    </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "<div class=\"covers-wrapper\">\n    <div class=\"models-subnav-container\"></div>\n    <div class=\"search-header-container\"></div>\n    <div class=\"covers is-clearfix"
    + alias4(((helper = (helper = helpers.useBw || (depth0 != null ? depth0.useBw : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"useBw","hash":{},"data":data}) : helper)))
    + alias4(((helper = (helper = helpers.gridMax || (depth0 != null ? depth0.gridMax : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"gridMax","hash":{},"data":data}) : helper)))
    + "\">\n"
    + ((stack1 = helpers.each.call(alias1,depth0,{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </div>\n</div>";
},"useData":true});

this["JST"]["models-sub-nav"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.invisible : depth0),{"name":"unless","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.areaName : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"3":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isExternal : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                        <li>\n                            <a class=\"subnav-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" href=\""
    + alias4(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"url","hash":{},"data":data}) : helper)))
    + "\" target=\""
    + alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper)))
    + "\">\n                                "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                            </a>\n                        </li>\n";
},"6":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                        <li>\n                            <a class=\"subnav-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" data-page-name=\""
    + alias4((helpers.buildPageName || (depth0 && depth0.buildPageName) || alias2).call(alias1,depth0,{"name":"buildPageName","hash":{},"data":data}))
    + "\" onclick=\"saveScroll(true)\" href=\""
    + alias4((helpers.buildLink || (depth0 && depth0.buildLink) || alias2).call(alias1,depth0,{"name":"buildLink","hash":{},"data":data}))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "</a>\n                        </li>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "<div class=\"models-sub-nav\">\n    <ul>\n"
    + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),depth0,{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </ul>\n</div>";
},"useData":true});

this["JST"]["news-article"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, helper;

  return "        <div class=\"article-content\">"
    + ((stack1 = ((helper = (helper = helpers.Content || (depth0 != null ? depth0.Content : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"Content","hash":{},"data":data}) : helper))) != null ? stack1 : "")
    + "</div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "<div class=\"news-wrapper\">\n    <div class=\"article-wrapper\">\n        <p><img src=\""
    + alias4(((helper = (helper = helpers.Cover || (depth0 != null ? depth0.Cover : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Cover","hash":{},"data":data}) : helper)))
    + "\" class=\"cover\" /></p>\n        <h1>"
    + alias4(((helper = (helper = helpers.Title || (depth0 != null ? depth0.Title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Title","hash":{},"data":data}) : helper)))
    + "</h1>\n        <h3>"
    + alias4(((helper = (helper = helpers.SubHeading || (depth0 != null ? depth0.SubHeading : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"SubHeading","hash":{},"data":data}) : helper)))
    + "</h3>\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.NewsContents : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </div>\n</div>";
},"useData":true});

this["JST"]["news-list"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "        <a href=\"/w/news/news/"
    + alias4(((helper = (helper = helpers.ID || (depth0 != null ? depth0.ID : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"ID","hash":{},"data":data}) : helper)))
    + "\" class=\"news-item\" data-id=\""
    + alias4(((helper = (helper = helpers.ID || (depth0 != null ? depth0.ID : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"ID","hash":{},"data":data}) : helper)))
    + "\" data-models=\""
    + alias4((helpers.joinModels || (depth0 && depth0.joinModels) || alias2).call(alias1,(depth0 != null ? depth0.NewsModels : depth0),{"name":"joinModels","hash":{},"data":data}))
    + "\"  data-tags=\""
    + alias4((helpers.joinTags || (depth0 && depth0.joinTags) || alias2).call(alias1,(depth0 != null ? depth0.NewsTags : depth0),{"name":"joinTags","hash":{},"data":data}))
    + "\">\n            <div class=\"news-cover\" style=\"background-image:url("
    + alias4(((helper = (helper = helpers.Cover || (depth0 != null ? depth0.Cover : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Cover","hash":{},"data":data}) : helper)))
    + "\"></div>\n            <div class=\"news-titles\">\n                <h1>"
    + alias4(((helper = (helper = helpers.Title || (depth0 != null ? depth0.Title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"Title","hash":{},"data":data}) : helper)))
    + "</h1>\n                <h2>"
    + alias4(((helper = (helper = helpers.SubHeading || (depth0 != null ? depth0.SubHeading : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"SubHeading","hash":{},"data":data}) : helper)))
    + "</h2>\n            </div>\n        </a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"news-wrapper\">\n    \n    <!-- PINNED -->\n    <div class=\"news-container\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.PinnedNews : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "        <br style=\"clear:both\" />\n    </div>\n    \n    <!-- OTHERS -->\n    <div class=\"news-container\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.News : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "        <br style=\"clear:both\" />\n    </div>\n</div>\n";
},"useData":true});

this["JST"]["news-model"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, helper;

  return "        <div class=\"article-content\">"
    + ((stack1 = ((helper = (helper = helpers.Content || (depth0 != null ? depth0.Content : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"Content","hash":{},"data":data}) : helper))) != null ? stack1 : "")
    + "</div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"news-wrapper\">\n    <div class=\"article-wrapper\">\n        <p><img src=\""
    + container.escapeExpression(((helper = (helper = helpers.Cover || (depth0 != null ? depth0.Cover : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"Cover","hash":{},"data":data}) : helper)))
    + "\" class=\"cover\" /></p>\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.NewsContents : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </div>\n</div>";
},"useData":true});

this["JST"]["footer-package"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"footer-container-wrapper\">\n    <footer>\n        <!-- footer -->\n        \n        <div class=\"credits\">\n            <h4 class=\"is-size-7 has-text-right\">\n                POWERED BY <a href=\"http://www.netwalkapp.com\" target=\"_blank\">\n                    <img src=\"/img/logos/netwalk/logo_drk_100x16.png\" alt=\"Netwalk\">\n                </a>\n            </h4>\n        </div>\n    </footer>\n</div>";
},"useData":true});

this["JST"]["header-package"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    return "navbar-centered";
},"3":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">\n                <img src=\"/img/"
    + alias4(((helper = (helper = helpers.getLogo || (depth0 != null ? depth0.getLogo : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getLogo","hash":{},"data":data}) : helper)))
    + "\" alt=\""
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "\">\n            </a>\n";
},"5":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "            <h1><a href=\""
    + alias4(((helper = (helper = helpers.getRoot || (depth0 != null ? depth0.getRoot : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getRoot","hash":{},"data":data}) : helper)))
    + "/\">"
    + alias4(((helper = (helper = helpers.getAgencyName || (depth0 != null ? depth0.getAgencyName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"getAgencyName","hash":{},"data":data}) : helper)))
    + "</a></h1>\n";
},"7":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <a class=\"navbar-item-social\" href=\""
    + alias4(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"link","hash":{},"data":data}) : helper)))
    + "\" target=\"_blank\"><i class=\"fab fa-lg fa-"
    + alias4(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"type","hash":{},"data":data}) : helper)))
    + "\"></i></a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, buffer = 
  "<nav class=\"navbar "
    + ((stack1 = helpers["if"].call(alias1,((stack1 = ((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.nav : stack1)) != null ? stack1.centered : stack1),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + " is-transparent\" role=\"navigation\" aria-label=\"main navigation\">\n    <div class=\"navbar-brand\">\n        <div class=\"logo\">\n";
  stack1 = ((helper = (helper = helpers.ifHasLogo || (depth0 != null ? depth0.ifHasLogo : depth0)) != null ? helper : alias2),(options={"name":"ifHasLogo","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(5, data, 0),"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper));
  if (!helpers.ifHasLogo) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "        </div>\n    </div>\n    <div class=\"navbar-menu no-dropdown\">\n        <div class=\"navbar-start\">\n        </div>\n        <div class=\"navbar-end\">\n            "
    + container.escapeExpression((helpers.modelBack || (depth0 && depth0.modelBack) || alias2).call(alias1,depth0,{"name":"modelBack","hash":{},"data":data}))
    + "\n            <div class=\"navbar-item\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.socials : stack1),{"name":"each","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "            </div>            \n        </div>\n    </div>\n</nav>";
},"useData":true});

this["JST"]["package-error"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"has-text-centered\">\n    <h1 class=\"title\" style=\"font-size:4em;\">Sorry</h1>\n    <h2 class=\"subtitle\" style=\"font-size:2em;\">This package code is expired or not valid</h2>\n</div>";
},"useData":true});

this["JST"]["package-list-grouped"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : (container.nullContext || {}), alias4=helpers.helperMissing;

  return "            <div class=\"cover cover-book cover-book-"
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.CoverBook : depth0)) != null ? stack1.BookType : stack1), depth0))
    + "\" data-id="
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.CoverBook : depth0)) != null ? stack1.ID : stack1), depth0))
    + ">\n                <a href=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.CoverBook : depth0)) != null ? stack1.BookLink : stack1), depth0))
    + "\" class=\"cover-img-wrapper\">\n                    <img class=\"cover-img lozad\" data-src=\""
    + alias2((helpers.getPackageBookCover || (depth0 && depth0.getPackageBookCover) || alias4).call(alias3,(depth0 != null ? depth0.CoverBook : depth0),{"name":"getPackageBookCover","hash":{},"data":data}))
    + "\" src=\""
    + alias2((helpers.getPackageBookPlaceholder || (depth0 && depth0.getPackageBookPlaceholder) || alias4).call(alias3,(depth0 != null ? depth0.CoverBook : depth0),{"name":"getPackageBookPlaceholder","hash":{},"data":data}))
    + "\" alt=\"\">\n                    <div class=\"model-name-feat\">\n                        <div class=\"columns-container\">\n"
    + ((stack1 = helpers.each.call(alias3,(depth0 != null ? depth0.Features : depth0),{"name":"each","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                        </div>\n                    </div>\n"
    + ((stack1 = helpers["if"].call(alias3,((stack1 = (depth0 != null ? depth0.CoverBook : depth0)) != null ? stack1.isVideo : stack1),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                </a>\n                <h3 class=\"model-name\">\n                    <a href=\""
    + alias2(alias1(((stack1 = (depth0 != null ? depth0.CoverBook : depth0)) != null ? stack1.BookLink : stack1), depth0))
    + "\">\n                        "
    + alias2((helpers.nameConfiguration || (depth0 && depth0.nameConfiguration) || alias4).call(alias3,(depth0 != null ? depth0.FirstName : depth0),(depth0 != null ? depth0.LastName : depth0),"list",{"name":"nameConfiguration","hash":{},"data":data}))
    + "\n"
    + ((stack1 = helpers["if"].call(alias3,(depth0 != null ? depth0.BooksNumber : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                    </a>\n                </h3>\n            </div>\n";
},"2":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.value : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"3":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                            <div class=\"columns\">\n                                <div class=\"column model-features-name\">"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "</div>\n                                <div class=\"column model-features-value\">"
    + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
    + "</div>\n                            </div>\n";
},"5":function(container,depth0,helpers,partials,data) {
    return "                    <i class=\"fas fa-play fa-inverse cover-video-icon-superimposed\"></i>\n";
},"7":function(container,depth0,helpers,partials,data) {
    var helper;

  return "                        <small>"
    + container.escapeExpression(((helper = (helper = helpers.BooksNumber || (depth0 != null ? depth0.BooksNumber : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"BooksNumber","hash":{},"data":data}) : helper)))
    + " books</small>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "<div class=\"covers-wrapper grouped-models\">\n	<div class=\"covers is-clearfix"
    + alias4(((helper = (helper = helpers.useBw || (depth0 != null ? depth0.useBw : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"useBw","hash":{},"data":data}) : helper)))
    + alias4(((helper = (helper = helpers.gridMax || (depth0 != null ? depth0.gridMax : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"gridMax","hash":{},"data":data}) : helper)))
    + "\">\n"
    + ((stack1 = (helpers.each_with_sort || (depth0 && depth0.each_with_sort) || alias2).call(alias1,(depth0 != null ? depth0.Models : depth0),"OrderID",{"name":"each_with_sort","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </div>\n</div>";
},"useData":true});

this["JST"]["package-list"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var helper;

  return "    <h1 class=\"package-title\">"
    + container.escapeExpression(((helper = (helper = helpers.Title || (depth0 != null ? depth0.Title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"Title","hash":{},"data":data}) : helper)))
    + "</h1>\n";
},"3":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression, buffer = 
  "            <div class=\"cover cover-book cover-book-"
    + alias4(((helper = (helper = helpers.BookType || (depth0 != null ? depth0.BookType : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"BookType","hash":{},"data":data}) : helper)))
    + "\" data-id="
    + alias4(((helper = (helper = helpers.ID || (depth0 != null ? depth0.ID : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"ID","hash":{},"data":data}) : helper)))
    + ">\n                <a href=\""
    + alias4(((helper = (helper = helpers.BookLink || (depth0 != null ? depth0.BookLink : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"BookLink","hash":{},"data":data}) : helper)))
    + "\" class=\"cover-img-wrapper\">\n                    <img class=\"cover-img lozad\" data-src=\""
    + alias4((helpers.getPackageBookCover || (depth0 && depth0.getPackageBookCover) || alias2).call(alias1,depth0,{"name":"getPackageBookCover","hash":{},"data":data}))
    + "\" src=\""
    + alias4((helpers.getPackageBookPlaceholder || (depth0 && depth0.getPackageBookPlaceholder) || alias2).call(alias1,depth0,{"name":"getPackageBookPlaceholder","hash":{},"data":data}))
    + "\" alt=\"\">\n                    <div class=\"model-name-feat\">\n                        <div class=\"columns-container\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.Features : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                        </div>\n                    </div>\n"
    + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isVideo : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
  stack1 = ((helper = (helper = helpers.showNotesOnList || (depth0 != null ? depth0.showNotesOnList : depth0)) != null ? helper : alias2),(options={"name":"showNotesOnList","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));
  if (!helpers.showNotesOnList) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "                </a>\n                <h3 class=\"model-name\">\n                    <a href=\""
    + alias4(((helper = (helper = helpers.BookLink || (depth0 != null ? depth0.BookLink : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"BookLink","hash":{},"data":data}) : helper)))
    + "\">"
    + alias4((helpers.nameConfiguration || (depth0 && depth0.nameConfiguration) || alias2).call(alias1,(depth0 != null ? depth0.FirstName : depth0),(depth0 != null ? depth0.LastName : depth0),"list",{"name":"nameConfiguration","hash":{},"data":data}))
    + "</a>\n                </h3>\n            </div>\n";
},"4":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.value : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"5":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                            <div class=\"columns\">\n                                <div class=\"column model-features-name\">"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "</div>\n                                <div class=\"column model-features-value\">"
    + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper)))
    + "</div>\n                            </div>\n";
},"7":function(container,depth0,helpers,partials,data) {
    return "                    <i class=\"fas fa-play fa-inverse cover-video-icon-superimposed\"></i>\n";
},"9":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.Notes : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"10":function(container,depth0,helpers,partials,data) {
    var helper;

  return "                        <div class=\"book-note-icon-container\">\n                            <div class=\"tooltipNote book-note-icon\" title=\""
    + container.escapeExpression(((helper = (helper = helpers.Notes || (depth0 != null ? depth0.Notes : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"Notes","hash":{},"data":data}) : helper)))
    + "\">\n                                <i class=\"fas fa-comment-alt-dots\" ></i>\n                            </div>\n                        </div>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression, buffer = 
  "<div class=\"covers-wrapper\">\n";
  stack1 = ((helper = (helper = helpers.showPackageTitle || (depth0 != null ? depth0.showPackageTitle : depth0)) != null ? helper : alias2),(options={"name":"showPackageTitle","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));
  if (!helpers.showPackageTitle) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}
  if (stack1 != null) { buffer += stack1; }
  return buffer + "	<div class=\"covers is-clearfix"
    + alias4(((helper = (helper = helpers.useBw || (depth0 != null ? depth0.useBw : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"useBw","hash":{},"data":data}) : helper)))
    + alias4(((helper = (helper = helpers.gridMax || (depth0 != null ? depth0.gridMax : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"gridMax","hash":{},"data":data}) : helper)))
    + "\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.PackageBooks : depth0),{"name":"each","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </div>\n</div>";
},"useData":true});

this["JST"]["package-login"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"page-package-login box\">\n    <p>package login</p>\n    <p><input class=\"input is-medium\" type=\"text\" name=\"package-code\" value=\"\" placeholder=\"type your package code\" /></p>\n    <p><button class=\"button is-dark is-medium\" type=\"button\" onclick=\"packageLogin()\">access packages</button>\n</div>";
},"useData":true});

this["JST"]["models-search-empty"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<h1 class=\"empty-search\">NO RESULTS</h1>";
},"useData":true});

this["JST"]["models-search-start"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<h1></h1>";
},"useData":true});

this["JST"]["models-search"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"covers-wrapper search\">\n	<div class=\"search-container\">\n        <form name=\"searchform\">\n            <div class=\"control is-loading has-icons-left \">\n                <input class=\"input is-large\" type=\"text\" name=\"search\" value=\"\" placeholder=\"Loading...\" autocomplete=\"off\" />\n                <span class=\"icon is-small is-left\">\n                    <i class=\"fal fa-search\"></i>\n                </span>\n            </div>\n        </form>\n    </div>\n    <div class=\"search-result-wrapper\">\n    </div>\n</div>";
},"useData":true});

this["JST"]["sidenav"] = Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.invisible : depth0),{"name":"unless","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"2":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.areaName : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.program(8, data, 0),"data":data})) != null ? stack1 : "");
},"3":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isExternal : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : "");
},"4":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <li class=\"is-first-level\">\n                  <a class=\"sidenav-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" href=\""
    + alias4(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"url","hash":{},"data":data}) : helper)))
    + "\" target=\""
    + alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper)))
    + "\">\n                    "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                  </a>\n                </li>\n";
},"6":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                <li class=\"is-first-level\">\n                  <a class=\"sidenav-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" data-page-name=\""
    + alias4((helpers.buildPageName || (depth0 && depth0.buildPageName) || alias2).call(alias1,depth0,{"name":"buildPageName","hash":{},"data":data}))
    + "\" onclick=\"saveScroll(true)\" href=\""
    + alias4((helpers.buildLink || (depth0 && depth0.buildLink) || alias2).call(alias1,depth0,{"name":"buildLink","hash":{},"data":data}))
    + "\">"
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "</a>\n                </li>\n";
},"8":function(container,depth0,helpers,partials,data) {
    var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "              <li class=\"is-first-level\">\n                <a href=\"javascript:void(0)\" class=\"sidenav-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\">\n                  "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                </a>\n"
    + ((stack1 = helpers["if"].call(alias1,(helpers.hasSubNav || (depth0 && depth0.hasSubNav) || alias2).call(alias1,(depth0 != null ? depth0.subNav : depth0),{"name":"hasSubNav","hash":{},"data":data}),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "              </li>\n";
},"9":function(container,depth0,helpers,partials,data) {
    var stack1;

  return "                  <ul class=\"sidenav-nav\">\n"
    + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.subNav : depth0),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "                  </ul>\n";
},"10":function(container,depth0,helpers,partials,data) {
    var stack1;

  return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isExternal : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.program(13, data, 0),"data":data})) != null ? stack1 : "");
},"11":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                        <li class=\"is-second-level\">\n                          <a class=\"sidenav-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" href=\""
    + alias4(((helper = (helper = helpers.url || (depth0 != null ? depth0.url : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"url","hash":{},"data":data}) : helper)))
    + "\" target=\""
    + alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper)))
    + "\">\n                            "
    + alias4(container.lambda((depth0 != null ? depth0.displayName : depth0), depth0))
    + "\n                          </a>\n                        </li>\n";
},"13":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "                        <li class=\"is-second-level\">\n                          <a class=\"sidenav-link-name-"
    + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
    + "\" data-page-name=\""
    + alias4((helpers.buildPageName || (depth0 && depth0.buildPageName) || alias2).call(alias1,depth0,{"name":"buildPageName","hash":{},"data":data}))
    + "\" onclick=\"saveScroll(true)\" href=\""
    + alias4((helpers.buildLink || (depth0 && depth0.buildLink) || alias2).call(alias1,depth0,{"name":"buildLink","hash":{},"data":data}))
    + "\">\n                            "
    + alias4(((helper = (helper = helpers.displayName || (depth0 != null ? depth0.displayName : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"displayName","hash":{},"data":data}) : helper)))
    + "\n                          </a>\n                        </li>\n";
},"15":function(container,depth0,helpers,partials,data) {
    var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

  return "        <a class=\"sidenav-social\" href=\""
    + alias4(((helper = (helper = helpers.link || (depth0 != null ? depth0.link : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"link","hash":{},"data":data}) : helper)))
    + "\" target=\"_blank\"><i class=\"fab fa-lg fa-"
    + alias4(((helper = (helper = helpers.type || (depth0 != null ? depth0.type : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"type","hash":{},"data":data}) : helper)))
    + "\"></i></a>\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {});

  return "<div class=\"sidenav\">\n  <div class=\"sidenav-content\">\n    <aside class=\"menu\">\n      <ul class=\"sidenav-nav\">\n"
    + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.navigation : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "      </ul>\n    </aside>\n\n    <div class=\"sidenav-socials\">\n"
    + ((stack1 = helpers.each.call(alias1,((stack1 = (depth0 != null ? depth0.configurations : depth0)) != null ? stack1.socials : stack1),{"name":"each","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
    + "    </div>\n  </div>\n</div>";
},"useData":true});

this["JST"]["404"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"has-text-centered\">\n    <h1 class=\"title\" style=\"font-size:14em;\">404</h1>\n    <h2 class=\"subtitle\" style=\"font-size:4em;\">Page Not Found</h2>\n</div>";
},"useData":true});

this["JST"]["coming-soon"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"has-text-centered\" style=\"display:flex;flex-direction:column;justify-content:center;\">\n    <h1 class=\"title\" style=\"font-size:5em;\"><i class=\"fal fa-rabbit-fast\"></i><br/>COMING<br>SOON</h1>\n</div>";
},"useData":true});

this["JST"]["error"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"has-text-centered\">\n    <h1 class=\"title\" style=\"font-size:14em;\">500</h1>\n    <h2 class=\"subtitle\" style=\"font-size:4em;\">Sorry, an error occurred</h2>\n</div>";
},"useData":true});

this["JST"]["loading"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"has-text-centered\">\n    <div class=\"lds-ellipsis\"><div></div><div></div><div></div><div></div></div>\n</div>";
},"useData":true});
this["JST"] = this["JST"] || {};

this["JST"]["about"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"static-page\">\n    \n</div>";
},"useData":true});

this["JST"]["contact"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"static-page\">\n    \n</div>";
},"useData":true});

this["JST"]["news"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "<div class=\"container\">\n    \n</div>";
},"useData":true});

this["JST"]["splash"] = Handlebars.template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
    return "";
},"useData":true});