var Mainstage=Mainstage||{};
Mainstage.whenIsReady=new Promise(( resolve, reject)=> document.addEventListener('DOMContentLoaded', event=> resolve()) );
Mainstage.whenIsLoaded=new Promise(( resolve, reject)=> window.addEventListener('load', event=> resolve()) );
Mainstage.whenIsReady
.then(()=> {
const html=document.querySelector('html');
const body=document.querySelector('body');
body.classList.add('is-ready');
html.classList.remove('no-js');
if(window.self!==window.top) html.classList.add(Mainstage.TEXTDOMAIN + '-is-iframe');
if(matchMedia('(any-hover: none)').matches) html.classList.add('no-hover');
if(matchMedia('(hover: hover)').matches) html.classList.add('has-hover');
if(Mainstage.Context.General) new Mainstage.Context.General();
if(Mainstage.Context.Backend) new Mainstage.Context.Backend();
if(Mainstage.Context.Editor) new Mainstage.Context.Editor();
if(Mainstage.Context.Frontend) new Mainstage.Context.Frontend();
if(Mainstage.CONFIG?.Extension) Mainstage.Helper.Initializer.initializeClasses(Mainstage.CONFIG.Extension, 'Mainstage.Extension');
if(Mainstage.CONFIG?.Component) Mainstage.Helper.Initializer.initializeClasses(Mainstage.CONFIG.Component, 'Mainstage.Component');
if(Mainstage.CONFIG?.View) Mainstage.Helper.Initializer.initializeClasses(Mainstage.CONFIG.View, 'Mainstage.View');
});
Mainstage.whenIsLoaded
.then(()=> {
const body=document.querySelector('body');
body.classList.add('is-loaded')
});
var Mainstage=Mainstage||{};
Mainstage.Helper=Mainstage.Helper||{};
Mainstage.Helper.parseArgs=function(values, ...defaults){
if(! values||typeof values!=='object') return values;
if(! defaults.length) return values;
for(const defaultObject of defaults){
if(! defaultObject||typeof defaultObject!=='object'||! Object.keys(defaultObject).length) continue;
for(const property in defaultObject){
const value=values[ property ];
const defaultValue=defaultObject[ property ];
if(value===undefined){
values[ property ]=defaultValue;
}else if(Array.isArray(value)&&Array.isArray(defaultValue) ){
values[ property ]=value.concat(defaultValue);
}else{
values[ property ]=Mainstage.Helper.parseArgs(value, defaultValue);
}}
}
return values;
}
String.prototype.sanitize=function(){
let string=this.trim();
string=string.replace(/^\s+|\s+$/g, '');
string=string.toLowerCase();
const from='àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/_,:;';
const to='aaaaeeeeiiiioooouuuuncescrzyuudtn------';
for(let i=0, l=from.length; i < l; i++) string=string.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i) );
string=string
.replace('.', '-')
.replace(/[^a-z0-9 -]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-')
.replace(/\//g, '')
;
return string;
}
String.prototype.snakecase=function(){
let string=this.sanitize().replace('_', '-');
let string__array=string.split('-');
string__array=string__array.map(part=> part.charAt(0).toUpperCase() + part.substring(1).toLowerCase());
string=string__array.join('_');
return string;
}
String.prototype.toScope=function(baseScope=window){
let string=this.replace(/\\/g, '.');
let scope=baseScope;
for(let step of string.split('.') ){
step=step.trim();
if(! step) continue;
if(! scope[ step ]) return null;
scope=scope[ step ];
}
return scope;
}
Number.prototype.toTimeFormat=function(format='H:i:s', removeNullValues=true, total=null){
if(! total||typeof total!=='number') total=this;
let ms=Math.floor(( this % 1000) );
let s=Math.floor(( this / 1000) % 60);
let i=Math.floor(( this /(1000 * 60) ) % 60);
let G=H = Math.floor(( this /(1000 * 60 * 60) ) % 24);
let tms=Math.floor(( total % 1000) );
let ts=Math.floor(( total / 1000) % 60);
let ti=Math.floor(( total /(1000 * 60) ) % 60);
let tG=tH=Math.floor(( total /(1000 * 60 * 60) ) % 24);
if(ms < 100) ms=(ms < 10 ? '00':'0') + ms;
if(s < 10) s='0' + s;
if(i < 10) i='0' + i;
if(H < 10) H='0' + H;
format=format.replace(/ms/g, ms);
format=format.replace(/s/g, s);
format=format.replace(/i/g, i);
format=format.replace(/G/g, G <=0&&tG <=0&&removeNullValues ? '':G);
format=format.replace(/H/g, G <=0&&tG <=0&&removeNullValues ? '':H);
format=format.replace(/^\D*/, '');
return format;
}
HTMLElement.prototype.dispatchCustomEvent=function(name, detail={}, log=false){
if(! name||typeof name!=='string'||name.trim()==='') return false;
const Event=new CustomEvent(name, { bubbles: true, detail });
if(log) console.log(Event);
return this.dispatchEvent(Event);
}
HTMLElement.prototype.getAttributeDefault=function(attribute, defaultValue=null, validateBoolean=true){
const value=this.getAttribute(attribute);
if([ undefined, null, 'undefined', 'null', '' ].indexOf(value)!==-1)	return defaultValue;
if(validateBoolean){
if([ false, 0, 'false', '0' ].indexOf(value)!==-1) return false;
if([ true, 1, 'true', '1' ].indexOf(value)!==-1) return true;
}
return value;
}
HTMLElement.prototype.doesSupportFullscreen=function(){
return !! (
this.requestFullscreen
|| 	this.mozRequestFullscreen
|| 	this.webkitEnterFullscreen
|| 	this.webkitRequestFullscreen
);
}
HTMLElement.prototype.whenImagesAreLoaded=function(){
const promise=new Promise(( resolve, reject)=> {
const images=this.querySelectorAll('img');
if(images.length===0) return resolve(images);
let promises=[];
for(const image of images){
const promise=new Promise(( resolve, reject)=> {
if(image.complete){
return resolve();
}else{
image.addEventListener('load', event=> resolve(), { once: true });
}});
promises.push(promise);
}
Promise.all(promises)
.then(()=> resolve(images) );
});
return promise;
}
HTMLElement.prototype.whenAudiosAreLoaded=function(){
const promise=new Promise(( resolve, reject)=> {
const audios=this.querySelectorAll('audio');
if(audios.length===0) return resolve(audios);
let promises=[];
for(const audio of audios){
const promise=new Promise(( resolve, reject)=> {
if(audio.readyState > 0){
return resolve();
}else{
audio.addEventListener('canplay', event=> resolve(), { once: true });
audio.addEventListener('loadedmetadata', event=> resolve(), { once: true });
}});
promises.push(promise);
}
Promise.all(promises)
.then(()=> resolve(audios) );
})
return promise;
}
HTMLElement.prototype.whenVideosAreLoaded=function(){
const promise=new Promise(( resolve, reject)=> {
const videos=this.querySelectorAll('video');
if(videos.length===0) return resolve(videos);
let promises=[];
for(const video of videos){
const promise=new Promise(( resolve, reject)=> {
if(video.readyState > 0){
return resolve();
}else{
video.addEventListener('canplay', event=> resolve(), { once: true });
video.addEventListener('loadedmetadata', event=> resolve(), { once: true });
}});
promises.push(promise);
}
Promise.all(promises)
.then(()=> resolve(videos) );
})
return promise;
}
HTMLElement.prototype.whenMediaIsLoaded=function(){
return Promise.all([
this.whenImagesAreLoaded(),
this.whenAudiosAreLoaded(),
this.whenVideosAreLoaded()
]);
}
HTMLElement.prototype.hasTransitionEvents=function(){
const styles=getComputedStyle(this);
const transitionDelay=parseFloat(styles.getPropertyValue('transition-delay') );
const transitionDuration=parseFloat(styles.getPropertyValue('transition-duration') );
const hasTransitionEvents=transitionDelay > 0||transitionDuration > 0;
return hasTransitionEvents;
}
HTMLElement.prototype.whenTransitionEnded=function(){
const promise=new Promise(( resolve, reject)=> {
if(! this.hasTransitionEvents) return resolve();
this.addEventListener('transitionend', ()=> resolve(), { once: true });
});
return promise;
}
HTMLElement.prototype.animate=function(args={}){
let {
unit: unit=null,
unitsPerSecond,
from,
to: to=0,
duration: duration=500,
animation
}=args;
const {
element: element=this,
property,
easing: easing=x => x < 0.5 ? 8 * x * x * x * x:1 - Math.pow(-2 * x + 2, 4) / 2
}=args;
if(! animation){
let distance, fromUnit, toUnit;
[ , from, fromUnit ]=typeof from==='string'&&from.match(/(?<from>-?\d+\.?\d*)(?<unit>\D*)/)||[ 0, from, '' ];
[ , to, toUnit ]=typeof to==='string'&&to.match(/(?<to>-?\d+\.?\d*)(?<unit>\D*)/)||[ 0, to, '' ];
from=parseFloat(from)===parseFloat(from) ? parseFloat(from):undefined;
to=parseFloat(to)===parseFloat(to) ? parseFloat(to):0;
unit=unit ?? toUnit ?? fromUnit ?? null;
switch(property){
case 'scrollLeft':
case 'scrollTop':
unit=null;
from=element[ property ];
distance=to - from;
break;
default:
let computedStyle, computedStyleFrom, computedFrom, computedUnit;
computedStyle=getComputedStyle(element);
computedStyleFrom=computedStyle.getPropertyValue(property)!=='' ? computedStyle.getPropertyValue(property):0;
[ , computedFrom, computedUnit ]=typeof computedStyleFrom==='string'&&computedStyleFrom.match(/(?<from>-?\d+\.?\d*)(?<unit>\D*)/)||[ 0, 0, '' ];
unit=unit ?? computedUnit ?? null;
from=from ??(parseFloat(computedFrom)===parseFloat(computedFrom) ? parseFloat(computedFrom):0);
distance=to - from;
break;
}
if(unitsPerSecond){
unitsPerSecond=parseFloat(unitsPerSecond)===parseFloat(unitsPerSecond) ? parseFloat(unitsPerSecond):100;
duration=Math.abs(distance) / Math.abs(unitsPerSecond) * 1000;
}
animation={
property,
unit,
from,
to,
distance,
duration: duration,
starttime: Date.now(),
runtime: 0,
progress: 0,
value: 0,
request: null,
isCanceled: false,
whenCanceled: null,
_resolveCanceled: null,
_rejectCanceled: null,
isCompleted: false,
whenCompleted: null,
_resolveCompleted: null,
_rejectCompleted: null,
hasEnded: false,
whenEnded: null,
_resolveEnded: null,
_rejectEnded: null,
cancel: ()=> {
animation._rejectCompleted();
animation._resolveCanceled();
animation._resolveEnded();
},
complete: ()=> {
animation._rejectCanceled();
animation._resolveCompleted();
animation._resolveEnded();
}}
animation.whenCanceled=new Promise(( resolve, reject)=> { animation._resolveCanceled=resolve; animation._rejectCanceled=reject; });
animation.whenCompleted=new Promise(( resolve, reject)=> { animation._resolveCompleted=resolve; animation._rejectCompleted=reject; });
animation.whenEnded=new Promise(( resolve, reject)=> { animation._resolveEnded=resolve; animation._rejectEnded=reject; });
animation.whenCanceled.then(()=> animation.isCanceled=true).catch(()=> {});
animation.whenCompleted.then(()=> animation.isCompleted=true).catch(()=> {});
animation.whenEnded
.then(()=> {
animation.hasEnded=true;
cancelAnimationFrame(animation.request);
})
.catch(()=> {});
}
animation.runtime=Date.now() - animation.starttime;
animation.progress=animation.duration <=0||animation.isCompleted ? 1:Math.min(1, Math.max(0, animation.runtime / animation.duration) );
animation.value=animation.from + easing(animation.progress) * animation.distance;
switch(animation.property){
case 'scrollLeft':
case 'scrollTop':
element[ animation.property ]=animation.value;
break;
default:
element.style.setProperty(animation.property, animation.value +(animation.unit||'') );
break;
}
if(animation.progress >=1) animation.complete();
if(! animation.hasEnded) animation.request=requestAnimationFrame(timestamp=> this.animate({ element, easing, animation }) );
return animation;
};
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=global||self,global.Mustache=factory())})(this,function(){"use strict";var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}function primitiveHasOwnProperty(primitive,propName){return primitive!=null&&typeof primitive!=="object"&&primitive.hasOwnProperty&&primitive.hasOwnProperty(propName)}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function escapeHtml(string){return String(string).replace(/[&<>"'`=\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var lineHasNonSpace=false;var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;var indentation="";var tagIndex=0;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile==="string")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error("Invalid tags: "+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+"\\s*");closingTagRe=new RegExp("\\s*"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp("\\s*"+escapeRegExp("}"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i<valueLength;++i){chr=value.charAt(i);if(isWhitespace(chr)){spaces.push(tokens.length);indentation+=chr}else{nonSpace=true;lineHasNonSpace=true;indentation+=" "}tokens.push(["text",chr,start,start+1]);start+=1;if(chr==="\n"){stripSpace();indentation="";tagIndex=0;lineHasNonSpace=false}}}if(!scanner.scan(openingTagRe))break;hasTag=true;type=scanner.scan(tagRe)||"name";scanner.scan(whiteRe);if(type==="="){value=scanner.scanUntil(equalsRe);scanner.scan(equalsRe);scanner.scanUntil(closingTagRe)}else if(type==="{"){value=scanner.scanUntil(closingCurlyRe);scanner.scan(curlyRe);scanner.scanUntil(closingTagRe);type="&"}else{value=scanner.scanUntil(closingTagRe)}if(!scanner.scan(closingTagRe))throw new Error("Unclosed tag at "+scanner.pos);if(type==">"){token=[type,value,start,scanner.pos,indentation,tagIndex,lineHasNonSpace]}else{token=[type,value,start,scanner.pos]}tagIndex++;tokens.push(token);if(type==="#"||type==="^"){sections.push(token)}else if(type==="/"){openSection=sections.pop();if(!openSection)throw new Error('Unopened section "'+value+'" at '+start);if(openSection[1]!==value)throw new Error('Unclosed section "'+openSection[1]+'" at '+start)}else if(type==="name"||type==="{"||type==="&"){nonSpace=true}else if(type==="="){compileTags(value)}}stripSpace();openSection=sections.pop();if(openSection)throw new Error('Unclosed section "'+openSection[1]+'" at '+scanner.pos);return nestTokens(squashTokens(tokens))}function squashTokens(tokens){var squashedTokens=[];var token,lastToken;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];if(token){if(token[0]==="text"&&lastToken&&lastToken[0]==="text"){lastToken[1]+=token[1];lastToken[3]=token[3]}else{squashedTokens.push(token);lastToken=token}}}return squashedTokens}function nestTokens(tokens){var nestedTokens=[];var collector=nestedTokens;var sections=[];var token,section;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];switch(token[0]){case"#":case"^":collector.push(token);sections.push(token);collector=token[4]=[];break;case"/":section=sections.pop();section[5]=token[2];collector=sections.length>0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,intermediateValue,names,index,lookupHit=false;while(context){if(name.indexOf(".")>0){intermediateValue=context.view;names=name.split(".");index=0;while(intermediateValue!=null&&index<names.length){if(index===names.length-1)lookupHit=hasProperty(intermediateValue,names[index])||primitiveHasOwnProperty(intermediateValue,names[index]);intermediateValue=intermediateValue[names[index++]]}}else{intermediateValue=context.view[name];lookupHit=hasProperty(context.view,name)}if(lookupHit){value=intermediateValue;break}context=context.parent}cache[name]=value}if(isFunction(value))value=value.call(this.view);return value};function Writer(){this.templateCache={_cache:{},set:function set(key,value){this._cache[key]=value},get:function get(key){return this._cache[key]},clear:function clear(){this._cache={}}}}Writer.prototype.clearCache=function clearCache(){if(typeof this.templateCache!=="undefined"){this.templateCache.clear()}};Writer.prototype.parse=function parse(template,tags){var cache=this.templateCache;var cacheKey=template+":"+(tags||mustache.tags).join(":");var isCacheEnabled=typeof cache!=="undefined";var tokens=isCacheEnabled?cache.get(cacheKey):undefined;if(tokens==undefined){tokens=parseTemplate(template,tags);isCacheEnabled&&cache.set(cacheKey,tokens)}return tokens};Writer.prototype.render=function render(template,view,partials,tags){var tokens=this.parse(template,tags);var context=view instanceof Context?view:new Context(view,undefined);return this.renderTokens(tokens,context,partials,template,tags)};Writer.prototype.renderTokens=function renderTokens(tokens,context,partials,originalTemplate,tags){var buffer="";var token,symbol,value;for(var i=0,numTokens=tokens.length;i<numTokens;++i){value=undefined;token=tokens[i];symbol=token[0];if(symbol==="#")value=this.renderSection(token,context,partials,originalTemplate);else if(symbol==="^")value=this.renderInverted(token,context,partials,originalTemplate);else if(symbol===">")value=this.renderPartial(token,context,partials,tags);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j<valueLength;++j){buffer+=this.renderTokens(token[4],context.push(value[j]),partials,originalTemplate)}}else if(typeof value==="object"||typeof value==="string"||typeof value==="number"){buffer+=this.renderTokens(token[4],context.push(value),partials,originalTemplate)}else if(isFunction(value)){if(typeof originalTemplate!=="string")throw new Error("Cannot use higher-order sections without the original template");value=value.call(context.view,originalTemplate.slice(token[3],token[5]),subRender);if(value!=null)buffer+=value}else{buffer+=this.renderTokens(token[4],context,partials,originalTemplate)}return buffer};Writer.prototype.renderInverted=function renderInverted(token,context,partials,originalTemplate){var value=context.lookup(token[1]);if(!value||isArray(value)&&value.length===0)return this.renderTokens(token[4],context,partials,originalTemplate)};Writer.prototype.indentPartial=function indentPartial(partial,indentation,lineHasNonSpace){var filteredIndentation=indentation.replace(/[^ \t]/g,"");var partialByNl=partial.split("\n");for(var i=0;i<partialByNl.length;i++){if(partialByNl[i].length&&(i>0||!lineHasNonSpace)){partialByNl[i]=filteredIndentation+partialByNl[i]}}return partialByNl.join("\n")};Writer.prototype.renderPartial=function renderPartial(token,context,partials,tags){if(!partials)return;var value=isFunction(partials)?partials(token[1]):partials[token[1]];if(value!=null){var lineHasNonSpace=token[6];var tagIndex=token[5];var indentation=token[4];var indentedValue=value;if(tagIndex==0&&indentation){indentedValue=this.indentPartial(value,indentation,lineHasNonSpace)}return this.renderTokens(this.parse(indentedValue,tags),context,partials,indentedValue,tags)}};Writer.prototype.unescapedValue=function unescapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return value};Writer.prototype.escapedValue=function escapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return typeof value==="number"?String(value):mustache.escape(value)};Writer.prototype.rawValue=function rawValue(token){return token[1]};var mustache={name:"mustache.js",version:"4.0.1",tags:["{{","}}"],clearCache:undefined,escape:undefined,parse:undefined,render:undefined,Scanner:undefined,Context:undefined,Writer:undefined,set templateCache(cache){defaultWriter.templateCache=cache},get templateCache(){return defaultWriter.templateCache}};var defaultWriter=new Writer;mustache.clearCache=function clearCache(){return defaultWriter.clearCache()};mustache.parse=function parse(template,tags){return defaultWriter.parse(template,tags)};mustache.render=function render(template,view,partials,tags){if(typeof template!=="string"){throw new TypeError('Invalid template! Template should be a "string" '+'but "'+typeStr(template)+'" was given as the first '+"argument for mustache#render(template, view, partials)")}return defaultWriter.render(template,view,partials,tags)};mustache.escape=escapeHtml;mustache.Scanner=Scanner;mustache.Context=Context;mustache.Writer=Writer;return mustache});
var Mainstage=Mainstage||{};
Mainstage.Helper=Mainstage.Helper||{};
Mainstage.Helper.Template=class Template {
constructor(name){
if(typeof name!=='string') return;
this._templateName=this.constructor.getUnifiedName(name, true);
}
static getUnifiedName(name, doAppendBasename=true, doPrependNamespace=false, NAMESPACE=this.PHPNAMESPACE){
if(! name||typeof name!=='string') return '';
name=name.replace(/\\/g, '/');
const basename=name.split('/').filter(n=> n).pop();
if(name.slice(-1)==='/') name +=basename;
if(! doAppendBasename&&name.indexOf(basename + '/' + basename)!==-1) name=name.replace(/\/[^\/]*$/, '') + '/';
NAMESPACE +=NAMESPACE.substring(-1)==='/' ? '':'/';
if(name.substring(0, NAMESPACE.length)===NAMESPACE) name=name.substring(NAMESPACE.length);
if(doPrependNamespace) name=NAMESPACE + name;
return name;
}
static setFileDefaut(fileDefault){
if(! fileDefault||typeof fileDefault!=='string') return;
this._templateFileDefault=fileDefault;
}
static getFileDefault(){
return this._templateFileDefault;
}
static getPartials(){
let partials={};
const templates=document.querySelectorAll('template[id]:not(template[id=""])');
for(const template of templates){
let templateID=template.getAttribute('id');
templateID=this.getUnifiedName(templateID, false);
const markup=template.innerHTML.replace(/&gt;/g, '>');
partials[ templateID ]=markup;
}
return partials;
}
static replaceOutputFunction(data){
for(const key in data){
if(key==='>'&&data._templateName){
const markup='{{> ' + data._templateName + ' }}';
const partials=this.getPartials();
data[ key ]=Mustache.render(markup, data, partials);
continue;
}
const value=data[ key ];
if(! value||! [ 'array', 'object' ].includes(typeof value) ) continue;
data[ key ]=this.replaceOutputFunction(value);
}
return data;
}
getStringRaw(){
if(! this._templateName||typeof this._templateName!=='string') return '';
const template=document.querySelector('template[id="' + this.constructor.getUnifiedName(this._templateName, true, true) + '"]');
const markup=template ? template.innerHTML.replace(/&gt;/g, '>'):''
return markup;
}
getRaw(){
const markup=this.getStringRaw();
const tmp=document.createElement('template');
tmp.innerHTML=markup;
const fragment=tmp.content;
return fragment;
}
getString(data){
data={ ...this, ...data };
data=this.constructor.replaceOutputFunction(data);
const markup=this.getStringRaw();
const partials=this.constructor.getPartials();
return Mustache.render(markup, data, partials);
}
get(data){
let markup=this.getString(data);
let tmp=document.createElement('template');
tmp.innerHTML=markup;
let fragment=tmp.content;
return fragment;
}}
Mainstage.Helper.Template._templateFileDefault='Default';
Mainstage.Helper.Template.NAMESPACE=Mainstage.NAMESPACE;
Mainstage.Helper.Template.PHPNAMESPACE=Mainstage.PHPNAMESPACE;
var Mainstage=Mainstage||{};
Mainstage.Helper=Mainstage.Helper||{};
Mainstage.Helper.Initializer=class Initializer {
static isInitialized=false;
static NAMESPACE=Mainstage.NAMESPACE;
static CONFIG=Mainstage.CONFIG;
constructor(){
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
static initializeClasses(classes=[], NAMESPACE=this.NAMESPACE){
if(! classes||! NAMESPACE||typeof NAMESPACE!=='string') return;
const scope=NAMESPACE.toScope();
if(! scope) return;
for(const className in classes){
const args=classes[ className ];
const argsType=typeof args;
if(! args||! [ 'boolean', 'object' ].includes(argsType) ) continue;
const possibleClass=scope[ className ];
if(possibleClass&&possibleClass.initiator){
switch(argsType){
case 'boolean':
if(args!==true) break;
possibleClass.initiator();
break;
case 'object':
const doesInitialize=args.does_initialize;
const doesInitializeType=typeof doesInitialize;
switch(doesInitializeType){
case 'boolean':
if(doesInitialize!==true) break;
possibleClass.initiator();
break;
case 'object':
possibleClass.initiator();
break;
}
break;
}}
if(argsType==='object'){
this.initializeClasses(args, NAMESPACE + '.' + className);
}}
}};
var Mainstage=Mainstage||{};
Mainstage.Context=Mainstage.Context||{};
Mainstage.Context.General=class General {
static isInitialized=false;
static NAMESPACE=Mainstage.NAMESPACE;
static CONFIG=Mainstage.CONFIG;
constructor(){
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
if(Mainstage.Extension?.Socket?.Client) Mainstage.Socket_Client=new Mainstage.Extension.Socket.Client();
}
build(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}};
var Mainstage=Mainstage||{};
Mainstage.Context=Mainstage.Context||{};
Mainstage.Context.Frontend=class Frontend {
static isInitialized=false;
constructor(){
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
this.setExternalLinks();
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
setExternalLinks(){
for(const externalLinkElement of document.querySelectorAll('a:not([href=""]):not([href^="' + Mainstage.HOME_URL + '"])') ){
externalLinkElement.setAttribute('target', '_blank');
}}
};
var Mainstage=Mainstage||{};
Mainstage.Component=Mainstage.Component||{};
Mainstage.Component.Event=class Event {
static isInitialized=false;
constructor(element, args={}){
if(this.element){
this.element=element;
if(this.element.Event) this.element.Event.destroy();
this.element.Event=this;
}
args=Mainstage.Helper.parseArgs(args,
Mainstage.CONFIG?.Component?.Event ?? {},
{
ID: 0,
title: '',
link: '',
doors: {
timeout: 0,
timestamp: 0
},
start: {
timeout: 0,
timestamp: 0
},
end: {
timeout: 0,
timestamp: 0
},
is_streamed: false,
stream_link: '',
stream_doors: {
timeout: 0,
timestamp: 0
},
stream_start: {
timeout: 0,
timestamp: 0
},
stream_end: {
timeout: 0,
timestamp: 0
},
is_on_demand: false,
on_demand_link: '',
on_demand_from: {
timeout: 0,
timestamp: 0
},
on_demand_until: {
timeout: 0,
timestamp: 0
},
doesDispatchEvents: true,
doesSetEvents: false,
debug: false
}
);
this.constructor.initiator();
this.ID=parseInt(args.ID);
this.title=String(args.title);
this.link=String(args.link);
this.doors=args.doors;
this.start=args.start;
this.end=args.end;
this.isStreamed=Boolean(args.is_streamed);
this.streamLink=args.stream_link;
this.streamDoors=args.stream_doors;
this.streamStart=args.stream_start;
this.streamEnd=args.stream_end;
this.isOnDemand=Boolean(args.is_on_demand);
this.onDemandLink=args.on_demand_link;
this.onDemandFrom=args.on_demand_from;
this.onDemandUntil=args.on_demand_until;
this.doesDispatchEvents=Boolean(args.doesDispatchEvents);
this.doesSetEvents=Boolean(args.doesSetEvents);
this.debug=Boolean(args.debug);
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
this.buildEventTimeouts();
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
buildEventTimeouts(){
if(! this.doesSetEvents) return;
const maxTimeout=604800;
const doorsTimeout=parseInt(this.doors?.timeout);
const startTimeout=parseInt(this.start?.timeout);
const endTimeout=parseInt(this.end?.timeout);
if(doorsTimeout > 0&&doorsTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:doors', { Event: this }, this.debug), doorsTimeout * 1000);
if(startTimeout > 0&&startTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:start', { Event: this }, this.debug), startTimeout * 1000);
if(endTimeout > 0&&endTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:end', { Event: this }, this.debug), endTimeout * 1000);
if(this.isStreamed){
const streamDoorsTimeout=parseInt(this.streamDoors?.timeout);
const streamStartTimeout=parseInt(this.streamStart?.timeout);
const streamEndTimeout=parseInt(this.streamEnd?.timeout);
if(streamDoorsTimeout > 0&&streamDoorsTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:streamdoors', { Event: this }, this.debug), streamDoorsTimeout * 1000);
if(streamStartTimeout > 0&&streamStartTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:streamstart', { Event: this }, this.debug), streamStartTimeout * 1000);
if(streamEndTimeout > 0&&streamEndTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:streamend', { Event: this }, this.debug), streamEndTimeout * 1000);
}
if(this.isOnDemand){
const onDemandStartTimeout=parseInt(this.onDemandFrom?.timeout);
const onDemandEndTimeout=parseInt(this.onDemandUntil?.timeout);
if(onDemandStartTimeout > 0&&onDemandStartTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:ondemandstart', { Event: this }, this.debug), onDemandStartTimeout * 1000);
if(onDemandEndTimeout > 0&&onDemandEndTimeout <=maxTimeout) setTimeout(()=> document.documentElement.dispatchCustomEvent(Mainstage.TEXTDOMAIN + ':event:ondemandend', { Event: this }, this.debug), onDemandEndTimeout * 1000);
}}
};
var About_Pop=About_Pop||{};
About_Pop.Component=About_Pop.Component||{};
About_Pop.Component.Event_Category=class Event_Category {
static isInitialized=false;
constructor(element, args={}){
this.element=element;
if(! this.element) return;
if(this.element.Event_Category) this.element.Event_Category.destroy();
this.element.Event_Category=this;
args=About_Pop.Helper.parseArgs(args,
{}
);
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}};
var About_Pop=About_Pop||{};
About_Pop.Component=About_Pop.Component||{};
About_Pop.Component.Venue=class Venue {
static isInitialized=false;
constructor(element=document.querySelector('article.venue'), args={}){
this.element=element;
if(! this.element) return;
if(this.element.Venue) this.element.Venue.destroy();
this.element.Venue=this;
args=About_Pop.Helper.parseArgs(args,
{
map: null,
markerLibrary: null,
geometryLibrary: null
}
);
this.constructor.initiator();
this._toggleClickListener=event=> {
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
this.toggle();
}
this._resizeListener=event=> {
this.publishDimensions();
}
this.map=args.map;
this.markerLibrary=args.markerLibrary;
this.geometryLibrary=args.geometryLibrary;
this.Pin=null;
this.Marker=null;
this.link=this.element.getAttribute('data-link');
this.lat=parseFloat(this.element.getAttribute('data-lat') );
this.lng=parseFloat(this.element.getAttribute('data-lng') );
this.zip=parseFloat(this.element.getAttribute('data-zip') );
this.innerElement=this.element.querySelector('.venue-inner');
this.titleElement=this.element.querySelector('.venue__title');
this.title=this.titleElement.textContent.trim();
this.toggleElements=this.element.querySelectorAll('[data-toggle="this"]');
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
for(const toggleElement of this.toggleElements) toggleElement.addEventListener('click', this._toggleClickListener);
if(this.lat&&this.lng&&this.map&&this.markerLibrary){
this.Pin=new this.markerLibrary.PinElement({
background: 'var(--black)',
borderColor: 'var(--white)',
glyphColor: 'var(--white)'
});
this.Marker=new this.markerLibrary.AdvancedMarkerElement({
map: null,
position: { lat: this.lat, lng: this.lng },
title: this.title,
content: this.Pin.element
});
this.Marker.addListener('click', event=> this.open());
if(this.element.classList.contains('is-active') ) google.maps.event.addListenerOnce(this.map, 'tilesloaded', ()=> this.open(true) );
}
window.addEventListener('resize', this._resizeListener);
About_Pop.whenIsReady.then(()=> this._resizeListener());
About_Pop.whenIsLoaded.then(()=> this._resizeListener());
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
if(this.toggleElements) for(const toggleElement of this.toggleElements) toggleElement.removeEventListener('click', this._toggleClickListener);
window.removeEventListener('resize', this._resizeListener);
return resolve();
});
return promise;
}
publishDimensions(){
if(! this.element) return;
const inactiveHeight=this.titleElement.clientHeight;
const activeHeight=this.innerElement.clientHeight;
this.element.style.setProperty('--inactive-height', inactiveHeight +(typeof inactiveHeight!=='string' ? 'px':'') );
this.element.style.setProperty('--active-height', activeHeight +(typeof activeHeight!=='string' ? 'px':'') );
}
open(force=false){
const promise=new Promise(( resolve, reject)=> {
if(this.element.classList.contains('is-active')&&! force) return resolve();
this.element.classList.add('is-active');
About_Pop.Frontend?.Header?.close();
About_Pop.Frontend?.Accessibility?.close();
if(About_Pop.Frontend?.Venues?.venues){
for(const Venue of About_Pop.Frontend.Venues.venues){
if(Venue===this) continue;
Venue.close();
}}
if(this.lat&&this.lng&&this.map&&this.geometryLibrary){
const panDistance=this.geometryLibrary.spherical.computeDistanceBetween(this.map.getCenter(), { lng: this.lng, lat: this.lat });
const targetZoom=About_Pop.View.Venues.mapTargetZoom;
const intermediateZoom=Math.max(targetZoom - 4, Math.min(this.map.getZoom(), Math.round(targetZoom - panDistance / 2000) ));
this.map.setZoom(intermediateZoom);
google.maps.event.addListenerOnce(this.map, 'idle', ()=> {
this.map.panTo({ lng: this.lng, lat: this.lat });
google.maps.event.addListenerOnce(this.map, 'idle', ()=> this.map.setZoom(targetZoom) );
});
}
if(this.Pin){
this.Marker.zIndex=100;
this.Pin.background='var(--highlight-color)';
this.Pin.scale=1.5;
}
if(About_Pop.Frontend?.doLink&&this.link) About_Pop.Frontend.doLink(this.link);
if(this.element.hasTransitionEvents()){
this.element.addEventListener('transitionend', event=> resolve(), { once: true });
}else{
return resolve();
}});
return promise;
}
close(){
const promise=new Promise(( resolve, reject)=> {
if(! this.element.classList.contains('is-active') ) return resolve();
this.element.classList.remove('is-active');
About_Pop.Frontend?.Header?.close();
About_Pop.Frontend?.Accessibility?.close();
if(this.Pin){
this.Marker.zIndex=1;
this.Pin.background='var(--black)';
this.Pin.scale=1;
}
if(this.element.hasTransitionEvents()){
this.element.addEventListener('transitionend', event=> resolve(), { once: true });
}else{
return resolve();
}});
return promise;
}
toggle(){
if(this.element.classList.contains('is-active') ){
return this.close();
}else{
return this.open();
}}
};
var Mainstage=Mainstage||{};
Mainstage.Component=Mainstage.Component||{};
Mainstage.Component.City=class City {
static isInitialized=false;
constructor(element, args={}){
this.element=element;
if(! this.element) return;
if(this.element.City) this.element.City.destroy();
this.element.City=this;
args=Mainstage.Helper.parseArgs(args,
{}
);
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}};
var Mainstage=Mainstage||{};
Mainstage.Component=Mainstage.Component||{};
Mainstage.Component.Artist=class Artist {
static isInitialized=false;
constructor(element, args={}){
this.element=element;
if(! this.element) return;
if(this.element.Artist) this.element.Artist.destroy();
this.element.Artist=this;
args=Mainstage.Helper.parseArgs(args,
{}
);
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}};
var About_Pop=About_Pop||{};
About_Pop.Component=About_Pop.Component||{};
About_Pop.Component.Image=class Image {
static isInitialized=false;
constructor(element=document.querySelector('.image'), args={}){
this.element=element;
if(! this.element) return;
if(this.element.Image) this.element.Image.destroy();
this.element.Image=this;
args=About_Pop.Helper.parseArgs(args,
{}
);
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}};
var Mainstage=Mainstage||{};
Mainstage.Component=Mainstage.Component||{};
Mainstage.Component.Country=class Country {
static isInitialized=false;
constructor(element, args={}){
this.element=element;
if(! this.element) return;
if(this.element.Country) this.element.Country.destroy();
this.element.Country=this;
args=Mainstage.Helper.parseArgs(args,
{}
);
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}};
var Mainstage=Mainstage||{};
Mainstage.Component=Mainstage.Component||{};
Mainstage.Component.Role=class Role {
static isInitialized=false;
constructor(element, args={}){
this.element=element;
if(! this.element) return;
if(this.element.Role) this.element.Role.destroy();
this.element.Role=this;
args=Mainstage.Helper.parseArgs(args,
{}
);
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
build(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}
destroy(){
const promise=new Promise(( resolve, reject)=> {
return resolve();
});
return promise;
}};
var About_Pop=About_Pop||{};
About_Pop.whenIsReady=new Promise(( resolve, reject)=> document.addEventListener('DOMContentLoaded', event=> resolve()) );
About_Pop.whenIsLoaded=new Promise(( resolve, reject)=> window.addEventListener('load', event=> resolve()) );
About_Pop.whenIsReady
.then(()=> {
const html=document.querySelector('html');
const body=document.querySelector('body');
body.classList.add('is-ready');
html.classList.remove('no-js');
if(window.self!==window.top) html.classList.add(About_Pop.TEXTDOMAIN + '-is-iframe');
if(matchMedia('(any-hover: none)').matches) html.classList.add('no-hover');
if(matchMedia('(hover: hover)').matches) html.classList.add('has-hover');
if(About_Pop.Context.General) About_Pop.General=new About_Pop.Context.General();
if(About_Pop.Context.Backend) About_Pop.Backend=new About_Pop.Context.Backend();
if(About_Pop.Context.Editor) About_Pop.Editor=new About_Pop.Context.Editor();
if(About_Pop.Context.Frontend) About_Pop.Frontend=new About_Pop.Context.Frontend();
if(About_Pop.CONFIG?.Extension) About_Pop.Helper.Initializer.initializeClasses(About_Pop.CONFIG.Extension, 'About_Pop.Extension');
if(About_Pop.CONFIG?.Component) About_Pop.Helper.Initializer.initializeClasses(About_Pop.CONFIG.Component, 'About_Pop.Component');
if(About_Pop.CONFIG?.View) About_Pop.Helper.Initializer.initializeClasses(About_Pop.CONFIG.View, 'About_Pop.View');
});
About_Pop.whenIsLoaded
.then(()=> {
const body=document.querySelector('body');
body.classList.add('is-loaded')
});
var About_Pop=About_Pop||{};
About_Pop.Helper=About_Pop.Helper||{};
About_Pop.Helper.parseArgs=function(values, ...defaults){
if(! values||typeof values!=='object') return values;
if(! defaults.length) return values;
for(const defaultObject of defaults){
if(! defaultObject||typeof defaultObject!=='object'||! Object.keys(defaultObject).length) continue;
for(const property in defaultObject){
const value=values[ property ];
const defaultValue=defaultObject[ property ];
if(value===undefined){
values[ property ]=defaultValue;
}else if(Array.isArray(value)&&Array.isArray(defaultValue) ){
values[ property ]=value.concat(defaultValue);
}else{
values[ property ]=About_Pop.Helper.parseArgs(value, defaultValue);
}}
}
return values;
}
String.prototype.sanitize=function(){
let string=this.trim();
string=string.replace(/^\s+|\s+$/g, '');
string=string.toLowerCase();
const from='àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/_,:;';
const to='aaaaeeeeiiiioooouuuuncescrzyuudtn------';
for(let i=0, l=from.length; i < l; i++) string=string.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i) );
string=string
.replace('.', '-')
.replace(/[^a-z0-9 -]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-')
.replace(/\//g, '')
;
return string;
}
String.prototype.snakecase=function(){
let string=this.sanitize().replace('_', '-');
let string__array=string.split('-');
string__array=string__array.map(part=> part.charAt(0).toUpperCase() + part.substring(1).toLowerCase());
string=string__array.join('_');
return string;
}
String.prototype.toScope=function(baseScope=window){
let string=this.replace(/\\/g, '.');
let scope=baseScope;
for(let step of string.split('.') ){
step=step.trim();
if(! step) continue;
if(! scope[ step ]) return null;
scope=scope[ step ];
}
return scope;
}
Number.prototype.toTimeFormat=function(format='H:i:s', removeNullValues=true, total=null){
if(! total||typeof total!=='number') total=this;
let ms=Math.floor(( this % 1000) );
let s=Math.floor(( this / 1000) % 60);
let i=Math.floor(( this /(1000 * 60) ) % 60);
let G=H = Math.floor(( this /(1000 * 60 * 60) ) % 24);
let tms=Math.floor(( total % 1000) );
let ts=Math.floor(( total / 1000) % 60);
let ti=Math.floor(( total /(1000 * 60) ) % 60);
let tG=tH=Math.floor(( total /(1000 * 60 * 60) ) % 24);
if(ms < 100) ms=(ms < 10 ? '00':'0') + ms;
if(s < 10) s='0' + s;
if(i < 10) i='0' + i;
if(H < 10) H='0' + H;
format=format.replace(/ms/g, ms);
format=format.replace(/s/g, s);
format=format.replace(/i/g, i);
format=format.replace(/G/g, G <=0&&tG <=0&&removeNullValues ? '':G);
format=format.replace(/H/g, G <=0&&tG <=0&&removeNullValues ? '':H);
format=format.replace(/^\D*/, '');
return format;
}
HTMLElement.prototype.dispatchCustomEvent=function(name, detail={}, log=false){
if(! name||typeof name!=='string'||name.trim()==='') return false;
const Event=new CustomEvent(name, { bubbles: true, detail });
if(log) console.log(Event);
return this.dispatchEvent(Event);
}
HTMLElement.prototype.getAttributeDefault=function(attribute, defaultValue=null, validateBoolean=true){
const value=this.getAttribute(attribute);
if([ undefined, null, 'undefined', 'null', '' ].indexOf(value)!==-1)	return defaultValue;
if(validateBoolean){
if([ false, 0, 'false', '0' ].indexOf(value)!==-1) return false;
if([ true, 1, 'true', '1' ].indexOf(value)!==-1) return true;
}
return value;
}
HTMLElement.prototype.doesSupportFullscreen=function(){
return !! (
this.requestFullscreen
|| 	this.mozRequestFullscreen
|| 	this.webkitEnterFullscreen
|| 	this.webkitRequestFullscreen
);
}
HTMLElement.prototype.whenImagesAreLoaded=function(){
const promise=new Promise(( resolve, reject)=> {
const images=this.querySelectorAll('img');
if(images.length===0) return resolve(images);
let promises=[];
for(const image of images){
const promise=new Promise(( resolve, reject)=> {
if(image.complete){
return resolve();
}else{
image.addEventListener('load', event=> resolve(), { once: true });
}});
promises.push(promise);
}
Promise.all(promises)
.then(()=> resolve(images) );
});
return promise;
}
HTMLElement.prototype.whenAudiosAreLoaded=function(){
const promise=new Promise(( resolve, reject)=> {
const audios=this.querySelectorAll('audio');
if(audios.length===0) return resolve(audios);
let promises=[];
for(const audio of audios){
const promise=new Promise(( resolve, reject)=> {
if(audio.readyState > 0){
return resolve();
}else{
audio.addEventListener('canplay', event=> resolve(), { once: true });
audio.addEventListener('loadedmetadata', event=> resolve(), { once: true });
}});
promises.push(promise);
}
Promise.all(promises)
.then(()=> resolve(audios) );
})
return promise;
}
HTMLElement.prototype.whenVideosAreLoaded=function(){
const promise=new Promise(( resolve, reject)=> {
const videos=this.querySelectorAll('video');
if(videos.length===0) return resolve(videos);
let promises=[];
for(const video of videos){
const promise=new Promise(( resolve, reject)=> {
if(video.readyState > 0){
return resolve();
}else{
video.addEventListener('canplay', event=> resolve(), { once: true });
video.addEventListener('loadedmetadata', event=> resolve(), { once: true });
}});
promises.push(promise);
}
Promise.all(promises)
.then(()=> resolve(videos) );
})
return promise;
}
HTMLElement.prototype.whenMediaIsLoaded=function(){
return Promise.all([
this.whenImagesAreLoaded(),
this.whenAudiosAreLoaded(),
this.whenVideosAreLoaded()
]);
}
HTMLElement.prototype.hasTransitionEvents=function(){
const styles=getComputedStyle(this);
const transitionDelay=parseFloat(styles.getPropertyValue('transition-delay') );
const transitionDuration=parseFloat(styles.getPropertyValue('transition-duration') );
const hasTransitionEvents=transitionDelay > 0||transitionDuration > 0;
return hasTransitionEvents;
}
HTMLElement.prototype.whenTransitionEnded=function(){
const promise=new Promise(( resolve, reject)=> {
if(! this.hasTransitionEvents) return resolve();
this.addEventListener('transitionend', ()=> resolve(), { once: true });
});
return promise;
}
HTMLElement.prototype.animate=function(args={}){
let {
unit: unit=null,
unitsPerSecond,
from,
to: to=0,
duration: duration=500,
animation
}=args;
const {
element: element=this,
property,
easing: easing=x => x < 0.5 ? 8 * x * x * x * x:1 - Math.pow(-2 * x + 2, 4) / 2
}=args;
if(! animation){
let distance, fromUnit, toUnit;
[ , from, fromUnit ]=typeof from==='string'&&from.match(/(?<from>-?\d+\.?\d*)(?<unit>\D*)/)||[ 0, from, '' ];
[ , to, toUnit ]=typeof to==='string'&&to.match(/(?<to>-?\d+\.?\d*)(?<unit>\D*)/)||[ 0, to, '' ];
from=parseFloat(from)===parseFloat(from) ? parseFloat(from):undefined;
to=parseFloat(to)===parseFloat(to) ? parseFloat(to):0;
unit=unit ?? toUnit ?? fromUnit ?? null;
switch(property){
case 'scrollLeft':
case 'scrollTop':
unit=null;
from=element[ property ];
distance=to - from;
break;
default:
let computedStyle, computedStyleFrom, computedFrom, computedUnit;
computedStyle=getComputedStyle(element);
computedStyleFrom=computedStyle.getPropertyValue(property)!=='' ? computedStyle.getPropertyValue(property):0;
[ , computedFrom, computedUnit ]=typeof computedStyleFrom==='string'&&computedStyleFrom.match(/(?<from>-?\d+\.?\d*)(?<unit>\D*)/)||[ 0, 0, '' ];
unit=unit ?? computedUnit ?? null;
from=from ??(parseFloat(computedFrom)===parseFloat(computedFrom) ? parseFloat(computedFrom):0);
distance=to - from;
break;
}
if(unitsPerSecond){
unitsPerSecond=parseFloat(unitsPerSecond)===parseFloat(unitsPerSecond) ? parseFloat(unitsPerSecond):100;
duration=Math.abs(distance) / Math.abs(unitsPerSecond) * 1000;
}
animation={
property,
unit,
from,
to,
distance,
duration: duration,
starttime: Date.now(),
runtime: 0,
progress: 0,
value: 0,
request: null,
isCanceled: false,
whenCanceled: null,
_resolveCanceled: null,
_rejectCanceled: null,
isCompleted: false,
whenCompleted: null,
_resolveCompleted: null,
_rejectCompleted: null,
hasEnded: false,
whenEnded: null,
_resolveEnded: null,
_rejectEnded: null,
cancel: ()=> {
animation._rejectCompleted();
animation._resolveCanceled();
animation._resolveEnded();
},
complete: ()=> {
animation._rejectCanceled();
animation._resolveCompleted();
animation._resolveEnded();
}}
animation.whenCanceled=new Promise(( resolve, reject)=> { animation._resolveCanceled=resolve; animation._rejectCanceled=reject; });
animation.whenCompleted=new Promise(( resolve, reject)=> { animation._resolveCompleted=resolve; animation._rejectCompleted=reject; });
animation.whenEnded=new Promise(( resolve, reject)=> { animation._resolveEnded=resolve; animation._rejectEnded=reject; });
animation.whenCanceled.then(()=> animation.isCanceled=true).catch(()=> {});
animation.whenCompleted.then(()=> animation.isCompleted=true).catch(()=> {});
animation.whenEnded
.then(()=> {
animation.hasEnded=true;
cancelAnimationFrame(animation.request);
})
.catch(()=> {});
}
animation.runtime=Date.now() - animation.starttime;
animation.progress=animation.duration <=0||animation.isCompleted ? 1:Math.min(1, Math.max(0, animation.runtime / animation.duration) );
animation.value=animation.from + easing(animation.progress) * animation.distance;
switch(animation.property){
case 'scrollLeft':
case 'scrollTop':
element[ animation.property ]=animation.value;
break;
default:
element.style.setProperty(animation.property, animation.value +(animation.unit||'') );
break;
}
if(animation.progress >=1) animation.complete();
if(! animation.hasEnded) animation.request=requestAnimationFrame(timestamp=> this.animate({ element, easing, animation }) );
return animation;
};
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=global||self,global.Mustache=factory())})(this,function(){"use strict";var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}function primitiveHasOwnProperty(primitive,propName){return primitive!=null&&typeof primitive!=="object"&&primitive.hasOwnProperty&&primitive.hasOwnProperty(propName)}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function escapeHtml(string){return String(string).replace(/[&<>"'`=\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var lineHasNonSpace=false;var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;var indentation="";var tagIndex=0;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile==="string")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error("Invalid tags: "+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+"\\s*");closingTagRe=new RegExp("\\s*"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp("\\s*"+escapeRegExp("}"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i<valueLength;++i){chr=value.charAt(i);if(isWhitespace(chr)){spaces.push(tokens.length);indentation+=chr}else{nonSpace=true;lineHasNonSpace=true;indentation+=" "}tokens.push(["text",chr,start,start+1]);start+=1;if(chr==="\n"){stripSpace();indentation="";tagIndex=0;lineHasNonSpace=false}}}if(!scanner.scan(openingTagRe))break;hasTag=true;type=scanner.scan(tagRe)||"name";scanner.scan(whiteRe);if(type==="="){value=scanner.scanUntil(equalsRe);scanner.scan(equalsRe);scanner.scanUntil(closingTagRe)}else if(type==="{"){value=scanner.scanUntil(closingCurlyRe);scanner.scan(curlyRe);scanner.scanUntil(closingTagRe);type="&"}else{value=scanner.scanUntil(closingTagRe)}if(!scanner.scan(closingTagRe))throw new Error("Unclosed tag at "+scanner.pos);if(type==">"){token=[type,value,start,scanner.pos,indentation,tagIndex,lineHasNonSpace]}else{token=[type,value,start,scanner.pos]}tagIndex++;tokens.push(token);if(type==="#"||type==="^"){sections.push(token)}else if(type==="/"){openSection=sections.pop();if(!openSection)throw new Error('Unopened section "'+value+'" at '+start);if(openSection[1]!==value)throw new Error('Unclosed section "'+openSection[1]+'" at '+start)}else if(type==="name"||type==="{"||type==="&"){nonSpace=true}else if(type==="="){compileTags(value)}}stripSpace();openSection=sections.pop();if(openSection)throw new Error('Unclosed section "'+openSection[1]+'" at '+scanner.pos);return nestTokens(squashTokens(tokens))}function squashTokens(tokens){var squashedTokens=[];var token,lastToken;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];if(token){if(token[0]==="text"&&lastToken&&lastToken[0]==="text"){lastToken[1]+=token[1];lastToken[3]=token[3]}else{squashedTokens.push(token);lastToken=token}}}return squashedTokens}function nestTokens(tokens){var nestedTokens=[];var collector=nestedTokens;var sections=[];var token,section;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];switch(token[0]){case"#":case"^":collector.push(token);sections.push(token);collector=token[4]=[];break;case"/":section=sections.pop();section[5]=token[2];collector=sections.length>0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,intermediateValue,names,index,lookupHit=false;while(context){if(name.indexOf(".")>0){intermediateValue=context.view;names=name.split(".");index=0;while(intermediateValue!=null&&index<names.length){if(index===names.length-1)lookupHit=hasProperty(intermediateValue,names[index])||primitiveHasOwnProperty(intermediateValue,names[index]);intermediateValue=intermediateValue[names[index++]]}}else{intermediateValue=context.view[name];lookupHit=hasProperty(context.view,name)}if(lookupHit){value=intermediateValue;break}context=context.parent}cache[name]=value}if(isFunction(value))value=value.call(this.view);return value};function Writer(){this.templateCache={_cache:{},set:function set(key,value){this._cache[key]=value},get:function get(key){return this._cache[key]},clear:function clear(){this._cache={}}}}Writer.prototype.clearCache=function clearCache(){if(typeof this.templateCache!=="undefined"){this.templateCache.clear()}};Writer.prototype.parse=function parse(template,tags){var cache=this.templateCache;var cacheKey=template+":"+(tags||mustache.tags).join(":");var isCacheEnabled=typeof cache!=="undefined";var tokens=isCacheEnabled?cache.get(cacheKey):undefined;if(tokens==undefined){tokens=parseTemplate(template,tags);isCacheEnabled&&cache.set(cacheKey,tokens)}return tokens};Writer.prototype.render=function render(template,view,partials,tags){var tokens=this.parse(template,tags);var context=view instanceof Context?view:new Context(view,undefined);return this.renderTokens(tokens,context,partials,template,tags)};Writer.prototype.renderTokens=function renderTokens(tokens,context,partials,originalTemplate,tags){var buffer="";var token,symbol,value;for(var i=0,numTokens=tokens.length;i<numTokens;++i){value=undefined;token=tokens[i];symbol=token[0];if(symbol==="#")value=this.renderSection(token,context,partials,originalTemplate);else if(symbol==="^")value=this.renderInverted(token,context,partials,originalTemplate);else if(symbol===">")value=this.renderPartial(token,context,partials,tags);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j<valueLength;++j){buffer+=this.renderTokens(token[4],context.push(value[j]),partials,originalTemplate)}}else if(typeof value==="object"||typeof value==="string"||typeof value==="number"){buffer+=this.renderTokens(token[4],context.push(value),partials,originalTemplate)}else if(isFunction(value)){if(typeof originalTemplate!=="string")throw new Error("Cannot use higher-order sections without the original template");value=value.call(context.view,originalTemplate.slice(token[3],token[5]),subRender);if(value!=null)buffer+=value}else{buffer+=this.renderTokens(token[4],context,partials,originalTemplate)}return buffer};Writer.prototype.renderInverted=function renderInverted(token,context,partials,originalTemplate){var value=context.lookup(token[1]);if(!value||isArray(value)&&value.length===0)return this.renderTokens(token[4],context,partials,originalTemplate)};Writer.prototype.indentPartial=function indentPartial(partial,indentation,lineHasNonSpace){var filteredIndentation=indentation.replace(/[^ \t]/g,"");var partialByNl=partial.split("\n");for(var i=0;i<partialByNl.length;i++){if(partialByNl[i].length&&(i>0||!lineHasNonSpace)){partialByNl[i]=filteredIndentation+partialByNl[i]}}return partialByNl.join("\n")};Writer.prototype.renderPartial=function renderPartial(token,context,partials,tags){if(!partials)return;var value=isFunction(partials)?partials(token[1]):partials[token[1]];if(value!=null){var lineHasNonSpace=token[6];var tagIndex=token[5];var indentation=token[4];var indentedValue=value;if(tagIndex==0&&indentation){indentedValue=this.indentPartial(value,indentation,lineHasNonSpace)}return this.renderTokens(this.parse(indentedValue,tags),context,partials,indentedValue,tags)}};Writer.prototype.unescapedValue=function unescapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return value};Writer.prototype.escapedValue=function escapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return typeof value==="number"?String(value):mustache.escape(value)};Writer.prototype.rawValue=function rawValue(token){return token[1]};var mustache={name:"mustache.js",version:"4.0.1",tags:["{{","}}"],clearCache:undefined,escape:undefined,parse:undefined,render:undefined,Scanner:undefined,Context:undefined,Writer:undefined,set templateCache(cache){defaultWriter.templateCache=cache},get templateCache(){return defaultWriter.templateCache}};var defaultWriter=new Writer;mustache.clearCache=function clearCache(){return defaultWriter.clearCache()};mustache.parse=function parse(template,tags){return defaultWriter.parse(template,tags)};mustache.render=function render(template,view,partials,tags){if(typeof template!=="string"){throw new TypeError('Invalid template! Template should be a "string" '+'but "'+typeStr(template)+'" was given as the first '+"argument for mustache#render(template, view, partials)")}return defaultWriter.render(template,view,partials,tags)};mustache.escape=escapeHtml;mustache.Scanner=Scanner;mustache.Context=Context;mustache.Writer=Writer;return mustache});
var About_Pop=About_Pop||{};
About_Pop.Helper=About_Pop.Helper||{};
About_Pop.Helper.Template=class Template {
constructor(name){
if(typeof name!=='string') return;
this._templateName=this.constructor.getUnifiedName(name, true);
}
static getUnifiedName(name, doAppendBasename=true, doPrependNamespace=false, NAMESPACE=this.PHPNAMESPACE){
if(! name||typeof name!=='string') return '';
name=name.replace(/\\/g, '/');
const basename=name.split('/').filter(n=> n).pop();
if(name.slice(-1)==='/') name +=basename;
if(! doAppendBasename&&name.indexOf(basename + '/' + basename)!==-1) name=name.replace(/\/[^\/]*$/, '') + '/';
NAMESPACE +=NAMESPACE.substring(-1)==='/' ? '':'/';
if(name.substring(0, NAMESPACE.length)===NAMESPACE) name=name.substring(NAMESPACE.length);
if(doPrependNamespace) name=NAMESPACE + name;
return name;
}
static setFileDefaut(fileDefault){
if(! fileDefault||typeof fileDefault!=='string') return;
this._templateFileDefault=fileDefault;
}
static getFileDefault(){
return this._templateFileDefault;
}
static getPartials(){
let partials={};
const templates=document.querySelectorAll('template[id]:not(template[id=""])');
for(const template of templates){
let templateID=template.getAttribute('id');
templateID=this.getUnifiedName(templateID, false);
const markup=template.innerHTML.replace(/&gt;/g, '>');
partials[ templateID ]=markup;
}
return partials;
}
static replaceOutputFunction(data){
for(const key in data){
if(key==='>'&&data._templateName){
const markup='{{> ' + data._templateName + ' }}';
const partials=this.getPartials();
data[ key ]=Mustache.render(markup, data, partials);
continue;
}
const value=data[ key ];
if(! value||! [ 'array', 'object' ].includes(typeof value) ) continue;
data[ key ]=this.replaceOutputFunction(value);
}
return data;
}
getStringRaw(){
if(! this._templateName||typeof this._templateName!=='string') return '';
const template=document.querySelector('template[id="' + this.constructor.getUnifiedName(this._templateName, true, true) + '"]');
const markup=template ? template.innerHTML.replace(/&gt;/g, '>'):''
return markup;
}
getRaw(){
const markup=this.getStringRaw();
const tmp=document.createElement('template');
tmp.innerHTML=markup;
const fragment=tmp.content;
return fragment;
}
getString(data){
data={ ...this, ...data };
data=this.constructor.replaceOutputFunction(data);
const markup=this.getStringRaw();
const partials=this.constructor.getPartials();
return Mustache.render(markup, data, partials);
}
get(data){
let markup=this.getString(data);
let tmp=document.createElement('template');
tmp.innerHTML=markup;
let fragment=tmp.content;
return fragment;
}}
About_Pop.Helper.Template._templateFileDefault='Default';
About_Pop.Helper.Template.NAMESPACE=About_Pop.NAMESPACE;
About_Pop.Helper.Template.PHPNAMESPACE=About_Pop.PHPNAMESPACE;
var About_Pop=About_Pop||{};
About_Pop.Helper=About_Pop.Helper||{};
About_Pop.Helper.Initializer=class Initializer {
static isInitialized=false;
static NAMESPACE=About_Pop.NAMESPACE;
static CONFIG=About_Pop.CONFIG;
constructor(){
this.constructor.initiator();
this.build()
.then(()=> {
});
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
}
static initializeClasses(classes=[], NAMESPACE=this.NAMESPACE){
if(! classes||! NAMESPACE||typeof NAMESPACE!=='string') return;
const scope=NAMESPACE.toScope();
if(! scope) return;
for(const className in classes){
const args=classes[ className ];
const argsType=typeof args;
if(! args||! [ 'boolean', 'object' ].includes(argsType) ) continue;
const possibleClass=scope[ className ];
if(possibleClass&&possibleClass.initiator){
switch(argsType){
case 'boolean':
if(args!==true) break;
possibleClass.initiator();
break;
case 'object':
const doesInitialize=args.does_initialize;
const doesInitializeType=typeof doesInitialize;
switch(doesInitializeType){
case 'boolean':
if(doesInitialize!==true) break;
possibleClass.initiator();
break;
case 'object':
possibleClass.initiator();
break;
}
break;
}}
if(argsType==='object'){
this.initializeClasses(args, NAMESPACE + '.' + className);
}}
}};
var About_Pop=About_Pop||{};
About_Pop.Extension=About_Pop.Extension||{};
About_Pop.Extension.JavaScript=About_Pop.Extension.JavaScript||{};
About_Pop.Extension.JavaScript.Fetch=class Fetch {
static isInitialized=false;
static AJAX_URL=About_Pop.AJAX_URL;
static doesStoreRequest;
static doesProcessData=true;
static storedRequests=[];
constructor(){
this.constructor.initiator();
}
static initiator(args={}){
if(this.isInitialized) return;
this.isInitialized=true;
args=About_Pop.Helper.parseArgs(args,
About_Pop.CONFIG?.Extension?.JavaScript?.Fetch ?? {},
{
does_store_request: {
temporarily: true,
locally: false
},
does_process_data: true,
does_add_available_templates: true
}
);
this.doesStoreRequest=args.does_store_request;
this.doesProcessData=Boolean(args.does_process_data);
this.doesAddAvailableTemplates=Boolean(args.does_add_available_templates);
if(About_Pop.Extension.JavaScript.Local_Storage&&(this.doesStoreRequest===true||this.doesStoreRequest.locally===true) ){
this.storedRequests=About_Pop.Extension.JavaScript.Local_Storage.getItem('storedRequests') ?? [];
}}
static storeRequest(request){
if(this.doesStoreRequest===true||this.doesStoreRequest.temporarily===true){
this.storedRequests.push(request);
}
if(About_Pop.Extension.JavaScript.Local_Storage&&(this.doesStoreRequest===true||this.doesStoreRequest.locally===true) ){
const result=About_Pop.Extension.JavaScript.Local_Storage.setItem('storedRequests', this.storedRequests);
if(result===false){
this.storedRequests=[ request ];
About_Pop.Extension.JavaScript.Local_Storage.flush();
About_Pop.Extension.JavaScript.Local_Storage.setItem('storedRequests', this.storedRequests);
}}
}
static getStoredRequest(newRequest, args={}){
args=About_Pop.Helper.parseArgs(args,
{
keysToSkip: [ 'data' ]
}
);
let matchedRequest=null;
requestLoop: for(const storedRequest of this.storedRequests){
keyLoop: for(const key in storedRequest){
if(args.keysToSkip.includes(key) ) continue keyLoop;
const value=JSON.stringify(newRequest[ key ]);
const storedValue=JSON.stringify(storedRequest[ key ]);
if(value!==storedValue){
matchedRequest=null;
continue requestLoop;
}
matchedRequest=storedRequest;
}
if(matchedRequest) break requestLoop;
}
return matchedRequest;
}
static processData(data, args={}){
if(! data||typeof data!=='object') return;
if(typeof args!=='object') args={};
args=About_Pop.Helper.parseArgs(args,
{
doesAppendRequiredTemplates: true,
doesAppendAdditionalScripts: true,
doesAppendAdditionalStyles: true,
appendToElement: document.querySelector('body')
}
);
if(args.doesAppendRequiredTemplates&&data.required_templates&&Array.isArray(data.required_templates) ){
for(const requiredTemplate of data.required_templates){
const templateTag=document.createElement('template');
if(requiredTemplate.id){
templateTag.setAttribute('id', requiredTemplate.id);
const existingTemplateTags=document.querySelectorAll('template[id="' + requiredTemplate.id + '"]');
for(const existingTemplateTag of existingTemplateTags) existingTemplateTag.remove();
}
if(requiredTemplate.markup){
templateTag.innerHTML=requiredTemplate.markup;
}
args.appendToElement.append(templateTag);
}}
if(args.doesAppendAdditionalScripts&&data.additional_scripts&&Array.isArray(data.additional_scripts) ){
const handleSuffix='-js';
for(const additionalScript of data.additional_scripts){
const scriptTag=document.createElement('script');
let existingScriptSelector='';
if(additionalScript.handle){
const scriptID=additionalScript.handle + handleSuffix;
scriptTag.setAttribute('id', scriptID);
existingScriptSelector +=(existingScriptSelector.trim() ? ',':'') + 'script[id="' + scriptID + '"]';
}
if(additionalScript.content){
scriptTag.innerHTML=additionalScript.content;
}else if(additionalScript.src){
scriptTag.setAttribute('src', additionalScript.src);
existingScriptSelector +=(existingScriptSelector.trim() ? ',':'') + 'script[src="' + additionalScript.src + '"]';
}
const existingScriptTags=existingScriptSelector.trim() ? document.querySelectorAll(existingScriptSelector):[];
for(const existingScriptTag of existingScriptTags) existingScriptTag.remove();
args.appendToElement.append(scriptTag);
}}
if(args.doesAppendAdditionalStyles&&data.additional_styles&&Array.isArray(data.additional_styles) ){
const handleSuffix='-css';
for(const additionalStyle of data.additional_styles){
const styleTag=additionalStyle.content ? document.createElement('style'):document.createElement('link');
let existingStyleSelector='';
if(additionalStyle.handle){
const styleID=additionalStyle.handle + handleSuffix;
styleTag.setAttribute('id', additionalStyle.handle + handleSuffix);
existingStyleSelector +=(existingStyleSelector.trim() ? ',':'') + 'link[id="' + styleID + '"], style[id="' + styleID + '"]';
}
if(additionalStyle.content){
styleTag.innerHTML=additionalStyle.content;
}else if(additionalStyle.src){
styleTag.setAttribute('rel', 'stylesheet');
styleTag.setAttribute('type', 'text/css');
styleTag.setAttribute('media', 'all');
styleTag.setAttribute('href', additionalStyle.src);
existingStyleSelector +=(existingStyleSelector.trim() ? ',':'') + 'link[href="' + additionalStyle.src + '"]';
}
const existingStyleTags=existingStyleSelector.trim() ? document.querySelectorAll(existingStyleSelector):[];
for(const existingStyleTag of existingStyleTags) existingStyleTag.remove();
args.appendToElement.append(styleTag);
}}
}
static fetch(link, params={}, args={}){
const promise=new Promise(( resolve, reject)=> {
if(typeof link!=='string'||link.trim()==='') return reject();
if(typeof params!=='object') params={};
if(typeof args!=='object') args={};
args=About_Pop.Helper.parseArgs(args,
{
doesStoreRequest: this.doesStoreRequest,
doesProcessData: this.doesProcessData,
doesAddAvailableTemplates: this.doesAddAvailableTemplates,
controller: null
}
);
if(args.doesAddAvailableTemplates){
const availableTemplateElements=document.querySelectorAll('template[id]:not(template[id=""])');
if(availableTemplateElements&&availableTemplateElements.length > 0){
params.available_templates=[];
for(const templateElement of availableTemplateElements){
const templateID=templateElement.getAttribute('id');
params.available_templates.push(templateID);
}}
}
const storedRequest=args.doesStoreRequest!==false ? this.getStoredRequest({ link, params }):null;
new Promise(( fetchResolve, fetchReject)=> {
if(storedRequest&&'data' in storedRequest){
return fetchResolve(storedRequest.data);
}else{
let fetchArgs={};
if(args.controller&&args.controller.signal){
fetchArgs.signal=args.controller.signal;
}
if(params&&Object.keys(params).length > 0){
fetchArgs.method='POST';
fetchArgs.credentials='same-origin';
fetchArgs.headers={
'Content-Type': 'application/x-www-form-urlencoded',
'Cache-Control': 'no-cache',
};
fetchArgs.body=new URLSearchParams(params);
}
fetch(link, fetchArgs)
.then(response=> response.json())
.then(data=> fetchResolve(data) )
.catch(error=> fetchReject(error) );
}})
.then(data=> {
if(args.doesStoreRequest!==false&&storedRequest===null) this.storeRequest({ link, params, data });
if(args.doesProcessData) this.processData(data, args);
return resolve(data);
})
.catch(error=> reject(error) );
});
return promise;
}
static fetchJSONEndpoint(link, params={}, args={}){
if(typeof link!=='string'||link.trim()==='') link=window.location.href;
if(typeof args!=='object') args={};
link=(link.slice(-1)==='/' ? link:(link + '/') ) + 'json/';
return this.fetch(link, params, args);
}
static fetchWordPressAJAX(action, params={}, args={}){
if(typeof params!=='object') params={};
const link=this.AJAX_URL;
params.action=action;
return this.fetch(link, params, args);
}};
var About_Pop=About_Pop||{};
About_Pop.Extension=About_Pop.Extension||{};
About_Pop.Extension.JavaScript=About_Pop.Extension.JavaScript||{};
About_Pop.Extension.JavaScript.Local_Storage=class Local_Storage {
static isInitialized=false;
static TEXTDOMAIN=About_Pop.TEXTDOMAIN;
static uniqid;
constructor(){
this.constructor.initiator();
}
static initiator(){
if(this.isInitialized) return;
this.isInitialized=true;
this.removeInvalidItems();
}
static removeInvalidItems(){
Object.keys(localStorage)
.filter(key=> key.startsWith(this.TEXTDOMAIN) )
.forEach(key=> {
if(! key.startsWith(this.TEXTDOMAIN + '-' + this.uniqid) ) localStorage.removeItem(key);
});
}
static setItem(key, value){
if(typeof key!=='string') return;
if(typeof value!=='string') value=JSON.stringify(value);
try {
localStorage.setItem(this.TEXTDOMAIN + '-' + this.uniqid + '-' + key, value);
} catch(error){
return false;
}
return true;
}
static getItem(key){
if(typeof key!=='string') return null;
let value=localStorage.getItem(this.TEXTDOMAIN + '-' + this.uniqid + '-' + key);
try {
value=JSON.parse(value);
} catch(error){}
return value;
}
static removeItem(key){
if(typeof key!=='string') return;
localStorage.removeItem(this.TEXTDOMAIN + '-' + this.uniqid + '-' + key);
}
static flush(){
Object.keys(localStorage)
.filter(key=> key.startsWith(this.TEXTDOMAIN) )
.forEach(key=> localStorage.removeItem(key) );
}};