
try{/*! For license information please see setBlock.min.js.LICENSE.txt */
!function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(){e=function(){return r};var r={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,a=Object.create(o.prototype),c=new j(n||[]);return i(a,"_invoke",{value:E(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=f;var h={};function d(){}function v(){}function y(){}var m={};s(m,c,(function(){return this}));var g=Object.getPrototypeOf,w=g&&g(g(O([])));w&&w!==n&&o.call(w,c)&&(m=w);var b=y.prototype=d.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(e,r){function n(i,a,c,u){var l=p(e[i],e,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==t(f)&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):r.resolve(f).then((function(t){s.value=t,c(s)}),(function(t){return n("throw",t,c,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,o){n(t,e,r,o)}))}return a=a?a.then(o,o):o()}})}function E(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=S(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function S(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,S(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function O(t){if(t){var e=t[c];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(o.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:N}}function N(){return{value:void 0,done:!0}}return v.prototype=y,i(b,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:v,configurable:!0}),v.displayName=s(y,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,l,"GeneratorFunction")),t.prototype=Object.create(b),t},r.awrap=function(t){return{__await:t}},x(L.prototype),s(L.prototype,u,(function(){return this})),r.AsyncIterator=L,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new L(f(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(b),s(b,l,"Generator"),s(b,c,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=O,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=o.call(i,"catchLoc"),u=o.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},r}function r(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function n(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))}}var o,i,a,c,u,l,s=null===(o=window)||void 0===o||null===(i=o.UIF)||void 0===i||null===(a=i.components)||void 0===a?void 0:a.InputAutocomplete,f=null===(c=window)||void 0===c||null===(u=c.UIF)||void 0===u||null===(l=u.dom)||void 0===l?void 0:l.createElement,p=document.querySelectorAll(".set-block");p&&s&&p.forEach((function(t){!function(t,r,o){var i,a,c,u,l=t.querySelector(".c-input-autocomplete"),s=t.querySelector(".c-form-item__container"),f=t.querySelector(".c-form-item"),p=null===(i=t.querySelector("input"))||void 0===i?void 0:i.getAttribute("data-settings"),h=t.querySelector(".selected-block"),d=t.querySelector(".c-form-item__container .set-block__submit"),v=t.querySelector(".c-edit__help"),y=function(t,e){u=o("div",{class:"loader",html:'\n      <div class="c-spinner c-spinner--thin c-spinner--inline">\n        <div class="c-spinner__graphics"></div>\n      </div>\n      <p>'.concat(e,"</p>\n      ")}),t.appendChild(u),t.classList.add("hide")},m=function(t){t&&t.classList.remove("hide"),u.remove()},g=function(){var t=n(e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,y(f,"Hämtar innehåll..."),t.next=5,fetch("/wps/mycontenthandler/wcmrest/query"+"?options=item-path&parentId=gxsywmg-cbxgcpvwjliqphdxdiuewrttjcve&&depth=DESCENDANTS&libraryid=TWFuYWdlZCBQYWdlcyBSb290IExpYnJhcnk&authoringtemplateid=".concat(a.authoringtemplateid,"&state=PUBLISHED&pagesize=9999"),{headers:{accept:"application/json"}});case 5:if(200!==!(r=t.sent).status){t.next=8;break}throw new Error("Något gick fel.");case 8:return s.classList.add("c-form-item__container--display"),t.next=11,r.json();case 11:return n=t.sent,t.abrupt("return",L(n));case 15:t.prev=15,t.t0=t.catch(1),console.error("Error:",t.t0);case 18:return t.prev=18,m(f),t.finish(18);case 21:case"end":return t.stop()}}),t,null,[[1,15,18,21]])})));return function(){return t.apply(this,arguments)}}(),w=function(){var t=n(e().mark((function t(r){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.preventDefault(),t.prev=2,y(h,"Tar bort val..."),t.next=6,fetch("/GbgJspForWcm/sharedSettings/reset",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"portletid=".concat(a.portletId,"&pageid=").concat(a.pageId,"&componentid=").concat(a.componentId)});case 6:if(200!==!t.sent.status){t.next=9;break}throw new Error("Något gick fel.");case 9:window.top.location.reload(),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(2),console.error("Error:",t.t0);case 15:return t.prev=15,m(),t.finish(15);case 18:case"end":return t.stop()}}),t,null,[[2,12,15,18]])})));return function(e){return t.apply(this,arguments)}}(),b=function(){var t=n(e().mark((function t(r){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:c={value:r.value||r.getAttribute("data-value"),label:r.label||r.getAttribute("data-label")},d.disabled=!1;case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),x=function(){var t=n(e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="Sparar val",t.prev=1,y(s,r),y(v,r),t.next=6,fetch("/GbgJspForWcm/sharedSettings/set",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"portletid=".concat(a.portletId,"&pageid=").concat(a.pageId,"&contentid=").concat(c.value)});case 6:if(200!==!t.sent.status){t.next=9;break}throw new Error("Något gick fel.");case 9:window.top.location.reload(),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(1),console.error("Error:",t.t0);case 15:return t.prev=15,m(),t.finish(15);case 18:case"end":return t.stop()}}),t,null,[[1,12,15,18]])})));return function(){return t.apply(this,arguments)}}(),L=function(t){var e,r=(null==t||null===(e=t.feed)||void 0===e?void 0:e.entry)||[],n=["goteborg-se","goteborg.se","innehallsrot","portalplats"];return r.map((function(t){var e=t.path.pathElement,r=e.map((function(t){return e=t.title.value,r={"å":"a","ä":"a","ö":"o"},e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[åäö]/g,(function(t){return r[t]})).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");var e,r})).filter((function(t){return!n.includes(t)})),o=e[e.length-1].title.value;return{label:"".concat(t.title.value," – ").concat(o," (").concat(r.join("/"),")"),value:t.id.split("wcmrest:")[1],lastPath:o,paths:r,name:t.title.value}}))},E=function(t){var e=o("li",{class:"c-input-autocomplete__result-item"});if("string"!=typeof t&&t.label&&t.value){var r=t.name,n=t.lastPath,i=t.paths,a=t.label,c=t.value;e.innerHTML="<b>".concat(r,"</b> – ").concat(n," <br/> <i>").concat(i.join("/"),"</i>"),e.dataset.label=a,e.dataset.value=c}else e.innerHTML=t;return e};return function(){if(a=JSON.parse(p),c=a.value)return i=(n=null===(t=c)||void 0===t||null===(e=t.label)||void 0===e?void 0:e.split("("))[0].trim(),u=n[1].replace("goteborg.se/",""),s=o("p",{class:"selected-block__text",html:"<b>Valt sidblock:</b> ".concat(i," <i>(").concat(u,"</i>")}),(v=o("button",{class:"c-button c-button--as-link",html:"Ta bort val"})).addEventListener("click",(function(t){return w(t)})),h.appendChild(s),h.appendChild(v),h.classList.add("selected-block--active"),void f.classList.add("c-form-item--disabled");var t,e,n,i,u,s,v;d.disabled=!0,d.addEventListener("click",(function(t){t.preventDefault(),x()})),new r(l,{onSelect:b,getValues:g,itemRender:E}).init()}}(t,s,f)()}))}();
}catch(e){console.log("Module 'module-frontend-setblock': ",e);}