
try{/*! For license information please see setCategories.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 p(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 f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var h={};function d(){}function v(){}function y(){}var m={};s(m,c,(function(){return this}));var g=Object.getPrototypeOf,b=g&&g(g(O([])));b&&b!==n&&o.call(b,c)&&(m=b);var w=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=f(e[i],e,a);if("throw"!==l.type){var s=l.arg,p=s.value;return p&&"object"==t(p)&&o.call(p,"__await")?r.resolve(p.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):r.resolve(p).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=f(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=f(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:I}}function I(){return{value:void 0,done:!0}}return v.prototype=y,i(w,"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(w),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(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),s(w,l,"Generator"),s(w,c,(function(){return this})),s(w,"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.InputSearchAndSelect,p=null===(c=window)||void 0===c||null===(u=c.UIF)||void 0===u||null===(l=u.dom)||void 0===l?void 0:l.createElement,f=document.querySelectorAll(".set-categories");f&&s&&f.forEach((function(t){var r=function(t,r,o){var i,a=JSON.parse(t.getAttribute("data-settings")),c=t.querySelector(".c-form-item"),u=t.querySelector(".c-input-search-and-select"),l=u.querySelector("input"),s=t.querySelector("button"),p=function(t){if(!t)return null;var e=t.path.pathElement.flatMap((function(t,e){return 0===e?[]:t.title.value}));return"".concat(e.join("/"),"/<b>").concat(t.title.value,"</b>")},f=function(){var t=n(e().mark((function t(r){var n,o,i;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("".concat("/wps/mycontenthandler/wcmrest/query?type=Category&options=item-path","&id=").concat(r),{headers:{Accept:"application/json"},redirect:"follow"});case 3:return o=t.sent,t.next=6,o.json();case 6:return i=t.sent,t.abrupt("return",{label:p(null===(n=i.feed.entry)||void 0===n?void 0:n[0])||r,value:r});case 10:t.prev=10,t.t0=t.catch(0),console.error(t.t0);case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e){return t.apply(this,arguments)}}(),h=function(){var t=n(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a.value){t.next=2;break}return t.abrupt("return",null);case 2:return t.next=4,Promise.all(a.value.map((function(t){return f(t)})));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),d=function(t){return[t.toLowerCase(),t.toUpperCase(),t.charAt(0).toUpperCase()+t.slice(1)].reduce((function(t,e){return"".concat(t,"&titlelike=").concat(encodeURIComponent(e+"%"))}),"")},v=function(t){return t.id.substring(8)},y=function(){var t=n(e().mark((function t(r){var n,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s.disabled=!0,t.prev=1,t.next=4,fetch("".concat("/wps/mycontenthandler/wcmrest/query?type=Category&options=item-path&pagesize=9999&libraryid=TWFuYWdlZCBQYWdlcyBSb290IExpYnJhcnk").concat(a.parentIds?a.parentIds.reduce((function(t,e){return"".concat(t,"&parentid=").concat(e)}),""):"").concat(d(r)),{headers:{Accept:"application/json"},redirect:"follow"});case 4:return n=t.sent,t.next=7,n.json();case 7:if(!(o=t.sent).feed.entry){t.next=13;break}return t.abrupt("return",o.feed.entry.map((function(t){return{value:v(t),label:p(t)}})));case 13:return t.abrupt("return",[]);case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(1),console.error(t.t0);case 19:return t.prev=19,s.disabled=!1,t.finish(19);case 22:case"end":return t.stop()}}),t,null,[[1,16,19,22]])})));return function(e){return t.apply(this,arguments)}}(),m=function(t){i=o("div",{class:"c-spinner c-spinner--thin c-spinner--inline",html:'<div class="loader"><div class="c-spinner c-spinner--thin c-spinner--inline"><div class="c-spinner__graphics"></div></div><p>'.concat(t,"</p></div>")}),s.disabled=!0,s.classList.add("hide"),u.classList.add("hide"),c.appendChild(i)},g=function(){s.classList.remove("hide"),s.disabled=!1,u.classList.remove("hide"),i.remove()},b=function(){var t=n(e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,m("Sparar val"),t.next=4,fetch("/GbgJspForWcm/sharedSettings/set",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"pageid=".concat(a.pageId,"&portletid=").concat(a.portletId,"&categories=").concat(l.value)});case 4:if(200!==!t.sent.status){t.next=7;break}throw new Error("Något gick fel.");case 7:window.top.location.reload(),t.next=14;break;case 10:t.prev=10,t.t0=t.catch(0),console.error(t.t0),g();case 14:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(){return t.apply(this,arguments)}}(),w=function(t){var e,r=o("li",{class:"c-input-autocomplete__result-item"}),n=t.label,i=t.value,a=null==n?void 0:n.split("/<b>")[0],c=null==n||null===(e=n.split("/<b>")[1])||void 0===e?void 0:e.split("<b/>")[0];return r.innerHTML="<b>".concat(c,"</b><br/><i>").concat(a,"/").concat(c,"</i>"),r.dataset.label=r.innerHTML,r.dataset.value=i,r},x=function(t){var e,r,n=t.label;n=t.label.includes("<br>")?(n=t.label.split("<br>")[1]).replace(/<i>/g,"").replace(/<\/i>/g,""):n.replace(/<b>/g,"").replace(/<\/b>/g,"");var o=null===(e=t.label)||void 0===e||null===(r=e.split("<b>")[1])||void 0===r?void 0:r.split("</b>")[0];return'<span class="tag-wrapper"><b class="tag-category">'.concat(o,'</b> <span class="tag-tooltip c-edit__help c-edit__help--no-arrow t-space-bottom-ml">').concat(n,"</span></span>")},L=function(){var t=n(e().mark((function t(){var n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return m("Laddar..."),s.addEventListener("click",(function(t){t.preventDefault(),b()})),t.next=4,h();case 4:n=t.sent,new r(u,{value:n,searchFunction:y,forceSelect:!0,tagRender:x,itemRender:w,placeholder:a.placeholder}).init(),g();case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return L}(t,s,p);r()}))}();
}catch(e){console.log("Module 'set-categories': ",e);}