"function"!=typeof Element.prototype.matches&&(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.webkitMatchesSelector||function(a){for(var b=this,c=(b.document||b.ownerDocument).querySelectorAll(a),d=0;c[d]&&c[d]!==b;)++d;return Boolean(c[d])}),"function"!=typeof Element.prototype.closest&&(Element.prototype.closest=function(a){for(var b=this;b&&1===b.nodeType;){if(b.matches(a))return b;b=b.parentNode}return null}),function(){var a=location.protocol.replace(":",""),b="api.storyblok.com";document.location.host.indexOf("localhost:3400")>-1&&(a="http",b="localhost:3001"),"http"!=a&&"https"!=a&&(a="https");var c={get:function(a,b,c){var d=new XMLHttpRequest;return d.open("GET",a,!0),d.responseType="text",d.onload=function(){var a=d.response||d.responseText,e=1223===d.status?204:d.status;0===e&&(e=a?200:0),200<=e&&e<=300?b(JSON.parse(a),d):"function"==typeof c&&c("Not found",d)},d.onerror=function(a){"function"==typeof c&&c(a,d)},d.send(),d},post:function(a,b,c,d){var e="string"==typeof b?b:Object.keys(b).map(function(a){return encodeURIComponent(a)+"="+encodeURIComponent(b[a])}).join("&"),f=new XMLHttpRequest;return f.open("POST",a),f.onload=function(){var a=f.response||f.responseText,b=1223===f.status?204:f.status;0===b&&(b=a?200:0),200<=b&&b<=300?c(JSON.parse(a)):"function"==typeof d&&d("Not found",f)},f.onerror=function(a){"function"==typeof d&&d(a,f)},f.setRequestHeader("X-Requested-With","XMLHttpRequest"),f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.send(e),f},elementInViewport:function(a){var b=a.getBoundingClientRect();return b.top<0&&b.top+b.height>=0||b.top>=0&&b.top<=(window.innerHeight||document.documentElement.clientHeight)}};!function(){storyblok={parent:function(){return this.config.customParent?this.config.customParent:"stage"===this.getParam("_storyblok_env")?a+"://app-beta.storyblok.com":a+"://app.storyblok.com"},inEditor:!0,overlay:null,hinter:null,highlighter:null,currentUid:null,storyId:"",calcTimer:null,initialized:!1,componentNames:{},currentBlok:{},resolvedRelations:{},events:{input:[],change:[],published:[],unpublished:[],viewLiveVersion:[],enterEditmode:[],enterComponent:[],hoverComponent:[],highlightComponent:[],customEvent:[],pingBack:[],sessionReceived:[]},config:{endPoint:"app.storyblok.com",accessToken:"",type:"full",space:"",customParent:null},isInEditor:function(){return this.inEditor},reloadPreview:function(){this.inIframe()&&window.parent.postMessage({action:"reload-preview"},this.parent())},removeClass:function(a,b){a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp("\\b"+b+"\\b","g"),"")},addClass:function(a,b){a.classList?a.classList.add(b):hasClass(a,b)||(a.className+=" "+b)},addEvent:function(a,b,c){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c)},removeEvent:function(a,b,c){a.detachEvent?a.detachEvent("on"+b,c):a.removeEventListener(b,c)},getOffset:function(a){var b=a.getBoundingClientRect(),c=window.pageXOffset||document.documentElement.scrollLeft,d=window.pageYOffset||document.documentElement.scrollTop;return{top:b.top+d,left:b.left+c}},getNextSiblings:function(a,b){for(var c=[];a=a.nextSibling;)3!==a.nodeType&&(b&&!b(a)||c.push(a));return c},getParam:function(a){var b="",c=[];return location.search.substr(1).split("&").forEach(function(d){c=d.split("="),c[0]===a&&(b=decodeURIComponent(c[1]))}),b},initWidget:function(){this.initConfig(),void 0===this.config.space&&alert("Please define the space id in the config");var b=document.createElement("div");b.innerHTML='
<
',document.body.appendChild(b),this.widget=document.body.querySelectorAll(".storyblok__widgetwrap")[0],document.body.querySelectorAll(".storyblok__close")[0].addEventListener("click",function(){this.toggleSidebar()}.bind(this))},sidebarOpen:!1,toggleSidebar:function(){var a=this.widget.querySelectorAll(".storyblok__widget")[0];this.sidebarOpen?(a.className="storyblok__widget",this.sidebarOpen=!1):(a.className="storyblok__widget storyblok--open",this.sidebarOpen=!0)},extend:function(a,b){return Object.keys(b).forEach(function(c){a[c]=b[c]}),a},initConfig:function(a){void 0!==a&&(this.config=this.extend(this.config,a)),void 0===this.config.endPoint&&alert("Please define an endpoint")},resetEvents:function(){for(e in this.events)this.events[e]=[]},isInitialized:function(){return this.initialized},init:function(a){null!==document.body&&(void 0!==a&&a.initOnlyOnce&&document.querySelectorAll(".storyblok__hint").length>0||(this.initConfig(a),this.resetEvents(),this.addMessageListener(),this.inIframe()&&(this.outlineOnMove(),this.storyId=this.getParam("_storyblok"),document.getElementById("storyblok-bridge-stylesheet")?(this.hinter=document.querySelector(".storyblok__hint"),this.highlighter=document.querySelector(".storyblok__highlight")):(this.createStylesheet(),this.createHinter(),this.createHighlighter()),this.on("enterEditmode",this.enterEditmode),this.on("hoverComponent",this.hoverComponent),this.on("highlightComponent",this.highlightComponent),this.on("enterComponent",this.enterComponent),this.postMessage(),this.initialized=!0)))},createStylesheet:function(){var b=document.createElement("link");b.rel="stylesheet",b.type="text/css",b.id="storyblok-bridge-stylesheet",b.href=a+"://"+this.config.endPoint+"/f/blokeditor.css",document.body.appendChild(b)},createHinter:function(){this.hinter=document.createElement("div"),this.hinter.setAttribute("class","storyblok__hint"),this.hinter.style.display="none",document.body.appendChild(this.hinter)},createHighlighter:function(){this.highlighter=document.createElement("div"),this.highlighter.style.opacity=0,this.highlighter.style.display="none",document.body.appendChild(this.highlighter)},hoverComponent:function(a){var b=a.storyId+"-"+a.componentId;this.doCalcPosition(this.hinter,b),this.hinter.style.opacity=1,this.hinter.style.display="block"},highlightComponent:function(a){this.highlighter.innerHTML="",a.componentIds.length>0?(this.highlighter.style.display="block",this.highlighter.style.opacity=1):(this.highlighter.style.display="none",this.highlighter.style.opacity=0);for(var b=0;b
0){var f=document.createElement("div");f.setAttribute("class","storyblok__highlight"),this.highlighter.appendChild(f),this.doCalcPosition(f,d),a.componentId==a.componentIds[b]&&(e=e[0],c.elementInViewport(e)||void 0===e.scrollIntoView||e.scrollIntoView())}}},clearHighlight:function(){this.clearHighlightEl()},clearHighlightEl:function(){this.highlighter&&(this.highlighter.innerHTML="",this.highlighter.style.opacity=0,this.highlighter.style.display="none")},enterComponent:function(a){var b=a.storyId+"-"+a.componentId,d=document.querySelectorAll('[data-blok-uid="'+b+'"]');d.length>0?(d=d[0],this.currentBlok=JSON.parse(d.getAttribute("data-blok-c")),this.currentUid=b,c.elementInViewport(d)||void 0===d.scrollIntoView||d.scrollIntoView()):(this.currentUid=null,this.currentBlok={}),this.calcPosition(),this.setToolTip(),this.hinter.style.opacity=0,this.hinter.style.display="none",this.clearHighlightEl()},pingEditor:function(a){this.inIframe()?window.parent.postMessage({action:"ping"},this.parent()):(this.inEditor=!1,a(this)),this.on("pingBack",function(){this.inEditor=!0,a(this)}.bind(this))},updateField:function(a,b){this.inIframe()&&window.parent.postMessage({action:"update-field",field:a,content:b},this.parent())},getSession:function(a){this.resetEvents(),this.addMessageListener(),this.on("sessionReceived",function(b){a(b)}.bind(this)),this.inIframe()&&window.parent.postMessage({action:"get-app-session"},this.parent())},postMessage:function(){this.inIframe()&&window.parent.postMessage({action:"initialized"},this.parent())},startTour:function(){this.inIframe()&&window.parent.postMessage({action:"tour"},this.parent())},openLiveChat:function(){this.inIframe()&&window.parent.postMessage({action:"live-chat"},this.parent())},addMessageListener:function(){window.addEventListener?addEventListener("message",this.receiveMessage,!1):attachEvent("onmessage",this.receiveMessage)},receiveMessage:function(a){void 0!==a.data&&null!=a.data&&void 0!==a.data.action&&storyblok.emit(a.data.action,a.data)},outlineOnMoveInterval:null,outlineOnMoveTimer:function(){storyblok.removeClass(document.body,"storyblok--outlined"),storyblok.hinter.style.opacity=0},outlineOnMoveHandler:function(){storyblok.addClass(document.body,"storyblok--outlined"),storyblok.outlineOnMoveInterval&&clearTimeout(storyblok.outlineOnMoveInterval),storyblok.outlineOnMoveInterval=setTimeout(storyblok.outlineOnMoveTimer,800)},outlineOnMove:function(){document.addEventListener("mousemove",this.outlineOnMoveHandler,!1)},tryEditmode:function(){this.pingEditor(function(){this.inEditor&&this.enterEditmode()}.bind(this))},inIframe:function(){return window.location!=window.parent.location},getParsedJson:function(a){var b={};try{b=JSON.parse(a)}catch(a){}return b},addComments:function(a,b){var c=function(a){if(null!=a)if(a.constructor===Array)for(var d=0;d-1)if("string"==typeof a[g])d.resolvedRelations[a[g]]?a[g]=d.resolvedRelations[a[g]]:e.push(a[g]);else if(a[g].constructor===Array){a[g].forEach(function(a){d.resolvedRelations[a]||e.push(a)});var h=[];a[g].forEach(function(a){d.resolvedRelations[a]?h.push(d.resolvedRelations[a]):h.push(a)}),a[g]=h}f(a[g])}};f(a.content),e.length>0?d.getAll({by_uuids:e,version:"draft",language:a.lang},function(b){b.stories.forEach(function(a){d.resolvedRelations[a.uuid]=a}),f(a.content),c(a.content)}):c(a.content)},enterEditmode:function(a){function b(){return NodeFilter.FILTER_ACCEPT}function c(a){do{a=a.nextSibling}while(a&&1!==a.nodeType);return a}var d=this;a&&a.componentNames&&(this.componentNames=a.componentNames);var e=function(a){for(var e,f=[],g=document.createNodeIterator(a,NodeFilter.SHOW_COMMENT,b,!1);e=g.nextNode();)if(e.nodeValue.indexOf("#storyblok#")>-1){var h=e.nodeValue.replace("#storyblok#",""),i=e.nextElementSibling||c(e),j=d.getParsedJson(h);j.id&&f.push({options:j,el:i})}return f}(document.body);""===this.getParam("_storyblok")&&a&&a.storyId&&(this.storyId=a.storyId);for(var f=0;f ',document.body.appendChild(this.overlay)),this.addEvent(window.document,"click",this.editElement),null!==this.calcTimer&&window.clearInterval(this.calcTimer),this.calcTimer=window.setInterval(this.calcPosition.bind(this),300),this.setToolTip()},doCalcPosition:function(a,b){if(!b)return void(a.style.display="none");a.style.display="block";var c=document.querySelectorAll('[data-blok-uid="'+b+'"]');if(c.length>0){c=c[0];var d=this.getOffset(c),e=d.left,f=d.top;a.style.top=f+"px",a.style.left=e+"px",a.style.width=c.offsetWidth+"px",a.style.height=c.offsetHeight+"px"}else a.style.display="none"},calcPosition:function(){this.doCalcPosition(this.overlay,this.currentUid)},setToolTip:function(){if(this.currentUid){this.overlay.querySelectorAll(".storyblok__tooltip")[0].innerHTML=this.currentBlok.name}},editElement:function(a){var b=a.target,c=b.getAttribute("data-blok-uid");if(!c){if(null===(b=b.closest("[data-blok-c]")))return void(storyblok.currentUid=null);c=b.getAttribute("data-blok-uid")}storyblok.currentUid!=c&&(a.preventDefault(),a.stopPropagation()),storyblok.currentUid=c,storyblok.currentBlok=JSON.parse(b.getAttribute("data-blok-c")),storyblok.calcPosition();var d=document.getElementById("storyblok__frame");storyblok.setToolTip(),storyblok.currentBlok.action="edit",storyblok.overlay.className="storyblok__overlay storyblok__overlay--clicked",setTimeout(function(){storyblok.overlay.className="storyblok__overlay"},400),d?d.contentWindow.postMessage(storyblok.currentBlok,storyblok.parent()):storyblok.inIframe()&&parent.postMessage(storyblok.currentBlok,storyblok.parent()),storyblok.clearHighlightEl()},sendEmail:function(d,e,f){c.post(a+"://"+b+"/v1/messages?token="+this.config.accessToken,d,e,f)},get:function(d,e,f){d.cv=d.cv||Math.floor(Date.now()/1e3),d.token=this.config.accessToken,d.from_release=this.getParam("_storyblok_release");var g=Object.keys(d).map(function(a){return encodeURIComponent(a)+"="+encodeURIComponent(d[a])}).join("&"),h=a+"://"+b+"/v1/cdn/stories/"+(d.slug||d.id)+"?"+g;return c.get(h,e,f)},getAll:function(d,e,f){d.cv=Math.floor(Date.now()/1e3),d.token=this.config.accessToken;var g=Object.keys(d).map(function(a){return encodeURIComponent(a)+"="+encodeURIComponent(d[a])}).join("&"),h=a+"://"+b+"/v1/cdn/stories?"+g;return c.get(h,e,f)},on:function(a,b){if(a.constructor===Array)for(var c=0;c-1){var d=c.split("?t=")[1];storyblok.init({accessToken:d}),c.indexOf("&autoReload=1")>-1&&storyblok.on(["published","change"],function(a){a.slugChanged||window.location.reload(!0)})}}}()}()}();