UNPKG

nodality

Version:

A lightweight library for declarative UI elements.

2 lines 28.2 kB
/*! For license information please see newNavBar.esm.js.LICENSE.txt */ function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,s,o,a=[],l=!0,c=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=s.call(r)).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,s=function(){};return{s,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw o}}}}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}var a=function(){return e=function e(){var t,r,n,i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n=function(e){if(console.log("LOBJO IS"),console.log(e),e.transform||e.op&&e.op.transform){var t=e.transform;e.transform||(t=e.op.transform),t.duration||(t.duration="3s-ease-in-out"),i.setDefault=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0px";return 0===e.length?t+" ":e};var r=function(){var r="",n="",s="",o="",a="",l="",c="",u="",d="";if(0!==t.values.length){t.values.forEach((function(e){e.startsWith("tx:")&&(r=e.replace("tx:","")),e.startsWith("ty:")&&(n=e.replace("ty:","")),e.startsWith("tz:")?s=e.replace("tz:",""):e.startsWith("scale(")?o=e:e.startsWith("skew(")?a=e:e.startsWith("rotate(")?l=function(e){var t=e.match(/rotate\(([^)]+)\)/);if(!t)return e;var r=t[1].split(",").map((function(e){return e.trim()}));return 1===r.length?"rotate(".concat(r[0],")"):2===r.length?"rotateX(".concat(r[0],") rotateY(").concat(r[1],")"):3===r.length?"rotateX(".concat(r[0],") rotateY(").concat(r[1],") rotate(").concat(r[2],")"):e}(e):e.startsWith("perspective(")?c=e:e.startsWith("matrix(")?u=e:e.startsWith("opacity:")&&(d=e.replace("opacity:",""))})),r=i.setDefault(r),n=i.setDefault(n),s=i.setDefault(s);var h="";if("0px"!=n&&"0px"!=r&&"0px"!=s?h+="translate3d(".concat(r,", ").concat(n,", ").concat(s,")"):"0px"==n&&"0px"==r||(h+="translate(".concat(r,", ").concat(n,")")),o&&(h+=" ".concat(o)),l&&(h+=" ".concat(l)),a&&(h+=" ".concat(a)),c&&(h+=" ".concat(c)),u&&(h+=" ".concat(u)),h){if(e.op.transform.duration){var p=e.op.transform.duration.replace(/^(\d+)(s)-/,(function(e,t,r){return t/2+r+" "})),y="transform ".concat(p,", opacity ").concat(p);i.res.style.transition=y}else i.res.style.transition="transform 3s ease-in-out, opacity 3s ease-in-out";e.op.transform.static&&(i.res.style.transition=""),(i.blastTarget||i.res).style.transform=h,i.res.style.opacity=d}else alert("OPE")}};t.on?i.res.addEventListener(t.on,(function(){t.delay?setTimeout((function(){r()}),t.delay):r()})):window.addEventListener("load",(function(){t.delay?setTimeout((function(){r()}),t.delay):r()}));var n=function(){var e="";t.values.forEach((function(t){t.startsWith("tx:")?e+="translateX(0) ":t.startsWith("ty:")?e+="translateY(0) ":t.startsWith("tz:")?e+="translateZ(0) ":t.startsWith("scale(")?e+="scale(1) ":t.startsWith("skew(")?e+="skew(0, 0) ":t.startsWith("rotate(")?e+="rotate(0) ":t.startsWith("perspective(")?e+="perspective(0) ":t.startsWith("matrix(")&&(e+="matrix(1, 0, 0, 1, 0, 0) "),i.res.style.opacity="1"})),e&&(i.res.style.transform=e.trim())};if(t.on)i.res.addEventListener("mouseout",(function(){t.keep||n()}));else{var s=1e3*parseFloat(t.duration),o=t.closeAfter?t.closeAfter:0;setTimeout((function(){t.keep||n()}),s/2+o)}t.hardCSS&&(i.res.style.transform=t.hardCSS)}else alert("THIS FIRE WITH GRADIENT (invalid block"),console.log("INVALID BLOCKA"),console.log(e)},(r=o(r="reactOnTransform"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,this.state={isExpanded:!1,isMovedUp:!1,isMovedDown:!1}},n=[{key:"keySet",value:function(e){return this.temporaryVal=1,this.res.style[e.key]=e.value,this}},{key:"onScroll",value:function(e){var t=this;"opacity"===e.value?this.res.style.opacity=e.valMin:"scale"===e.value&&(this.res.style.transform="scale(".concat(e.valMax,")")),window.addEventListener("scroll",(function(){var r=t.smartRange(window.scrollY,{min:e.from,max:e.to},{min:e.valMin,max:e.valMax});"opacity"===e.value?t.res.style.opacity=r:"scale"===e.value&&(t.res.style.transform="scale(".concat(r,")"))}))}},{key:"setAny",value:function(e){this[Object.keys(e)[0]]=[Object.values(e)[0]]}},{key:"setID",value:function(e){this.id=e}},{key:"setPrevText",value:function(e){this.prevText=e}},{key:"getCSS",value:function(){return this.css}},{key:"getPX",value:function(e){return{xs:"0px",sm:"576px",md:"768px",lg:"992px",xl:"1200px",xxl:"1400px",mxxl:"1800px"}[e]||"Invalid breakpoint"}},{key:"respad",value:function(e){var t=this,r=function(){t.pad(e[0].values);for(var r=0;r<e.length;r++){var n=e[r].breakpoint;window.matchMedia("(min-width: ".concat(t.getPX(n))).matches&&t.pad(e[r].values)}};window.addEventListener("resize",r),r()}},{key:"resmar",value:function(e){var t=this,r=function(){t.mar(e[0].values);for(var r=0;r<e.length;r++){var n=e[r].breakpoint;window.matchMedia("(max-width: ".concat(t.getPX(n))).matches&&t.mar(e[r].values)}};window.addEventListener("resize",r),r()}},{key:"resprop",value:function(e){var t=this;console.log("RES STYLE"),console.log(e),this.prevStyles={};for(var r=0;r<this.res.style.length;r++){var n=this.res.style[r];this.prevStyles[n]=this.res.style[n],console.log("kio")}var i=function(){for(var r in t.prevStyles)t.res.style[r]=t.prevStyles[r];console.log("mkio");for(var n=0;n<e.length;n++){var i=e[n].breakpoint,s="(max-width: ".concat(i,")");if(console.log("testing media query:",s,window.matchMedia(s).matches),window.matchMedia(s).matches)for(var o in e[n])"breakpoint"!==o&&(console.log("ukio"),t.res.style[o]=e[n][o])}};window.addEventListener("resize",i),i()}},{key:"isNumber",value:function(e){return"number"==typeof e&&!isNaN(e)}},{key:"pad",value:function(e){for(var t=0;t<e.length;t++)for(var r=Object.keys(e[t]),n=0;n<r.length;n++)for(var i=r[n],s=e[t][i],o=0;o<i.length;o++)switch(i[o]){case"a":this.res.style.padding=this.isNumber(s)?"".concat(s,"px"):s;break;case"t":this.res.style.paddingTop=this.isNumber(s)?"".concat(s,"px"):s;break;case"l":this.res.style.paddingLeft=this.isNumber(s)?"".concat(s,"px"):s;break;case"r":this.res.style.paddingRight=this.isNumber(s)?"".concat(s,"px"):s;break;case"b":this.res.style.paddingBottom=this.isNumber(s)?"".concat(s,"px"):s}return this}},{key:"as",value:function(e){return this.res.style.alignSelf=e,this}},{key:"mar",value:function(e){for(var t=0;t<e.length;t++)for(var r=Object.keys(e[t]),n=0;n<r.length;n++)for(var i=r[n],s=e[t][i],o=0;o<i.length;o++){switch(i[o]){case"a":this.res.style.margin=this.isNumber(s)?"".concat(s,"px"):s;break;case"t":this.res.style.marginTop=this.isNumber(s)?"".concat(s,"px"):s;break;case"l":this.res.style.marginLeft=this.isNumber(s)?"".concat(s,"px"):s;break;case"r":this.res.style.marginRight=this.isNumber(s)?"".concat(s,"px"):s;break;case"b":this.res.style.marginBottom=this.isNumber(s)?"".concat(s,"px"):s}"auto"===i[o]&&(this.res.style.marginLeft="auto",this.res.style.marginRight="auto")}return this}},{key:"smartRange",value:function(e,t,r){e<t.min&&(e=t.min),e>t.max&&(e=t.max);var n=(e-t.min)/(t.max-t.min);t.min>t.max&&(n=(e-t.max)/(t.min-t.max));var i=(r.min-r.max)*n-r.min;if(i=Math.abs(i),r.min<r.max){var s=(r.max+Math.abs(r.min))*n;i=r.min+s}return i}},{key:"gpos",value:function(e){return this.res.style.gridColumn=e.col,this.res.style.gridRow=e.row,this}},{key:"fluidCopy",value:function(e){if(e instanceof Object){this.prevStylex=this.res.style,this.res=document.createElement("h1"),this.res.style.cssText=this.prevStylex.cssText;var t=document.createTextNode(this.text);return this.res.appendChild(t),this.res.style.fontSize=e.exact,this}if("S1"===e){this.prevStylex=this.res.style,this.res=document.createElement("h1"),this.res.style.cssText=this.prevStylex.cssText;var r=document.createTextNode(this.text);this.res.appendChild(r),this.res.style.fontSize="calc(1.625rem + 5.075vw)"}if("S2"===e){this.prevStylex=this.res.style,this.res=document.createElement("h2"),this.res.style.cssText=this.prevStylex.cssText;var n=document.createTextNode(this.text);this.res.appendChild(n),this.res.style.fontSize="calc(1.500rem + 4.3vw)"}if("S3"===e){this.prevStylex=this.res.style,this.res=document.createElement("h3"),this.res.style.cssText=this.prevStylex.cssText;var i=document.createTextNode(this.text);this.res.appendChild(i),this.res.style.fontSize="calc(1.375rem + 3.525vw)"}if("S4"===e){this.prevStylex=this.res.style,this.res=document.createElement("h4"),this.res.style.cssText=this.prevStylex.cssText;var s=document.createTextNode(this.text);this.res.appendChild(s),this.res.style.fontSize="calc(1.250rem + 2.75vw)"}if("S5"===e){this.prevStylex=this.res.style,this.res=document.createElement("h5"),this.res.style.cssText=this.prevStylex.cssText;var o=document.createTextNode(this.text);this.res.appendChild(o),this.res.style.fontSize="calc(1.125rem + 1.975vw)"}return"S6"===e&&(this.res.style.fontSize="calc(1rem + 0.5vw)"),this}},{key:"setIndex",value:function(e){this.index=e}},{key:"borderObj",value:function(e){var t,r=null!==(t=e.type)&&void 0!==t?t:"solid";return this.res.style.border="".concat(e.width," ").concat(r," ").concat(e.color),this.res.style.borderRadius=e.radius,this}},{key:"setPref",value:function(e){this.preffersId=e}},{key:"setClass",value:function(e){this.class=e}},{key:"setTags",value:function(e){this.openTag=e.open,this.closeTag=e.close,console.log("TAGS SET"),console.log(e)}},{key:"chainReact",value:function(e,n,i){var s=this;console.log("0P"),this.ap=!1,this.cta=0,this.once=!1;var o,a=r(e);try{for(a.s();!(o=a.n()).done;){var l=o.value;l.range||(l.range=["0px","999999px"])}}catch(e){a.e(e)}finally{a.f()}e.sort((function(e,t){return parseInt(e.range[0])-parseInt(t.range[0])}));var c=function(o){var a=window.visualViewport.width,l=[],c=[];s.resCopy=s.res,s.storedQueries=e.map((function(e){return e.target})).filter((function(e){return null!=e}));var u,d=r(e);try{for(d.s();!(u=d.n()).done;){var h=u.value;s.counterIndex++;var p=t(h.range,2),y=p[0],f=p[1],m=parseInt(y),v=parseInt(f),b=!0;if(h.target){b=!1;for(var g=0;g<h.target.length;g++)h.target[g]===n&&(b=!0)}a>=m&&a<=v&&b&&(l.push(h.log),c.push(h),h.op&&h.op.margin&&(s.useMargin=h.op.margin))}}catch(e){d.e(e)}finally{d.f()}if(i&&!i.includes("background")&&(s.res.style.background="",s.res.style.backgroundColor=""),s.res.style.textShadow="",i&&!i.includes("border")&&(s.res.style.border=""),i&&!i.includes("margin")&&(s.res.style.margin=""),s.res.style["-webkit-text-fill-color"]="",s.res.style["-webkit-text-stroke-color"]="",s.res.style["-webkit-text-stroke-width"]="",s.res.style.filter="",s.options.background&&(console.log(s.options.background),s.res.style.background=s.options.background),l.includes("gradient"),(l.includes("gradient")||l.includes("shadow"))&&(s.res.style.position="relative"),l.includes("blast")){var x,w=c.filter((function(e){return"blast"===e.log}))[0].op.color,k=null!==(x=c.filter((function(e){return"blast"===e.log}))[0].op.width)&&void 0!==x?x:"1px";"FlexRowLayoutElement"===s.getType()||"LayoutWrapperElement"===s.getType()?(s.res.style.border="".concat("number"==typeof k?k+"px":k," solid orange"),s.res.style.display="inline-block","FlexRowLayoutElement"===s.getType()&&(s.res.style.display="flex"),s.res.style.boxSizing="border-box",s.res.style.transformOrigin="center",s.blastTarget=s.res):(s.text&&(s.res.textContent=s.text),s.res.style["-webkit-text-fill-color"]="transparent",s.res.style["-webkit-text-stroke-color"]=w,s.res.style["-webkit-text-stroke-width"]="".concat(k))}if(l.includes("filter")){var S=c.filter((function(e){return"filter"===e.log}))[0].op.filter;s.res.style.filter=S}if(l.includes("background")&&(s.res.style.backgroundColor="green"),l.includes("gradient")&&("LayoutWrapperElement"!==s.getType()&&"FlexRowLayoutElement"!==s.getType()&&(s.res.style["-webkit-text-fill-color"]="transparent"),s.res.style.background=s.globalGradient,"LayoutWrapperElement"!==s.getType()&&"FlexRowLayoutElement"!==s.getType()&&(s.res.style["background-clip"]="text")),l.includes("shadow")){var T,C="",E=0;for(g=0;g<s.options.shadow.op.steps;g++){var j;C+="drop-shadow(".concat(E+=3,"px ").concat(E,"px ").concat(E,"px ").concat(null!==(j=s.options.shadow.color)&&void 0!==j?j:"gray",") ")}"FlexRowLayoutElement"===s.getType()||"LayoutWrapperElement"===s.getType()?s.res.style.boxShadow="".concat(E,"px ").concat(E,"px ").concat(E,"px ").concat(null!==(T=s.options.shadow.color)&&void 0!==T?T:"gray"):s.res.style.filter=C}if(l.includes("margin"))for(g=0;g<e.length;g++)if(e[g].op){var O=e[g].op.offsets;O&&void 0!==s.index&&(s.res.style.margin=O[Number(s.index)]+"px")}if(l.includes("spana")||l.includes("span")){if(s.res=s.resCopy,s.options.span){var L;for(L=Array.isArray(s.options.span)?s.options.span.filter((function(e){return"span"===e.op.name}))[0]:s.options.span,s.res.textContent="",g=0;g<L.op.parts.length;g++){var I=L.op.parts[g].style,W=new s.constructor(L.op.parts[g].text).setup({type:"span"}).set(I).render();s.res.appendChild(W)}}}else{var A=new s.constructor(s.prevText).set({}).render();s.prevText&&s.prevText.length>0&&o&&s.res.appendChild(A)}if(l.includes("animation")){if(s.options.animation&&!s.hasAnimated&&!s.options.animation.op.fireAt){console.warn(s.openTag),s.hasAnimated=!0;var z=s.options.animation.op;window.addEventListener("sidebar:open",(function(){s.res.animate(z.keyframesOpen,z.openOptions)})),window.addEventListener("sidebar:closed",(function(){s.res.animate(z.keyframesClose,z.closeOptions)})),s.res.animate(z.keyframesClose,{duration:0,fill:"forwards"}),s.openTag&&s.closeTag&&(window.addEventListener(s.openTag,(function(){s.res.animate(z.keyframesOpen,z.openOptions)})),window.addEventListener(s.closeTag,(function(){s.res.animate(z.keyframesClose,z.closeOptions)})))}if(s.options.animation&&s.options.animation.op.fireAt&&s.options.animation.op.fireAt.endsWith("px")){var R=s.options.animation.op;s.res.animate(R.keyframesClose,{duration:0,fill:"forwards"});var P=function(){window.scrollY>parseFloat(R.fireAt)&&(s.res.animate(R.keyframesOpen,R.openOptions),window.removeEventListener("scroll",P))};window.addEventListener("scroll",P)}if(s.options.animation&&s.options.animation.op.fireAt&&"inview"===s.options.animation.op.fireAt){var N=s.options.animation.op;s.res.animate(N.keyframesClose,{duration:0,fill:"forwards"}),new IntersectionObserver((function(e,t){e.forEach((function(e){e.isIntersecting&&(s.res.animate(N.keyframesOpen,N.openOptions),t.disconnect())}))})).observe(s.res)}}};this.options.animation||window.addEventListener("resize",(function(){return c()})),c()}},{key:"maxWidth",value:function(e){return this.res.style.maxWidth=e,this}},{key:"removeQuotesFromFirstWord",value:function(e){return e.replace(/"([^"]+)":/g,"$1:")}},{key:"arrayMargin",value:function(e,t){return e.includes("left")&&(this.res.style.marginLeft=t),e.includes("right")&&(this.res.style.marginRight=t),e.includes("top")&&(this.res.style.marginTop=t),e.includes("bottom")&&(this.res.style.marginBottom=t),e.includes("all")&&(this.res.style.margin=t),t||(this.res.style.marginBottom=e),this}}],n&&s(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n}();function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function y(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e){var t=function(e){if("object"!=d(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=d(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==d(t)?t:t+""}var m=function(){return y((function e(t,r){h(this,e),this.obj=t||{},this.items=r||[]}),[{key:"render",value:function(){var e=document.createElement("div");e.style.display="flex",e.style.width="100%",e.style.justifyContent="space-around",e.setAttribute("id","innerItemsWrapper");var t=window.matchMedia("(max-device-width: 415px)"),r=window.matchMedia("(max-width: 600px)");(t.matches||r.matches)&&(e.style.marginTop="3rem");for(var n=0;n<this.items.length;n++){var i=this.items[n];e.appendChild(i.render())}var s=document.createElement("div");return s.style.width=this.obj.isSide?"333px":"100%",s.style.background=this.obj.background||"white",s.style.display="flex",s.style.justifyContent="center",s.style.alignItems="center",s.style.height="100%",s.setAttribute("id","outerItemsWrapper"),s.appendChild(e),this.obj.customStyle&&(e.style.width="auto",e.style.top="0rem",e.style.borderRadius="1rem",e.style.background=this.obj.background||"white",e.style.margin="1rem",e.style.position="absolute",e.style.opacity=.8),s}}])}(),v=function(){function e(t){var r,n,i,s;return h(this,e),r=function(e,t,r){return t=c(t),function(e,t){if(t&&("object"==d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,r||[],c(e).constructor):t.apply(e,r))}(this,e),n=r,s=function(){var e=window.matchMedia("(max-device-width: 415px)"),t=document.createElement("button");t.setAttribute("id","hamburger"),t.style.border="none",t.style.fontWeight="bold",t.style.position="absolute",t.style.color="orange",t.style.backgroundColor="transparent",t.style.fontSize=e.matches?"2.1em":"2em";var n=document.createTextNode(r.symbol?r.symbol:"☰");return t.appendChild(n),t.style.marginLeft="auto",r.isShown=!1,t.addEventListener("click",(function(){r.isShown=!r.isShown,r.hasAnimatedToWide=!1;var e=r.items[0].options;if(e&&e.animation){var t=e.animation.op,n=r.res.children[0].children[1].children[0];if(t){if(r.isShown)for(var i=0;i<n.children.length;i++)n.children[i].animate(t.keyframesClose,{duration:1,fill:"forwards",delay:0}).onfinish=function(){n.parentElement.style.display="block"};else n.parentElement.style.display="none";for(i=0;i<n.children.length;i++){var s=n.children[i];s.animate(t.keyframesClose,{duration:1,fill:"forwards",delay:0}),r.isShown?s.animate(t.keyframesOpen,t.openOptions):s.animate(t.keyframesClose,t.closeOptions)}}}else r.isShown?innerItemsWrapper.parentElement.style.display="block":innerItemsWrapper.parentElement.style.display="none"})),t},(i=f(i="addHamburger"))in n?Object.defineProperty(n,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[i]=s,r.titleText="",r.hasHamburger=!1,r.code=[],r.attributes={},r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(e,a),y(e,[{key:"toCode",value:function(){var e="new UINavBar()";return Object.keys(this.attributes).length>0?e+=".setup(".concat(JSON.stringify(this.attributes,null,2).replace(/"([^"]+)":/g,"$1:"),")"):e+=".setup({})",e+=".items([\n",(e+=this.items.map((function(e){return e.toCode().join("").trim()})).join(",\n"))+"\n])"}},{key:"styled",value:function(e){return this.setup(e),this.styles=e,this}},{key:"setup",value:function(e){this.obj=e,this.obj.isSide||(this.obj.animate=!1),this.attributes=e;var t=document.createElement("div");t.setAttribute("id","sars"),t.style.padding=0,t.style.margin=0;var r=document.createElement("div");return r.setAttribute("id","covid"),r.style.position="absolute",r.style.width="100%",r.style.zIndex=1,r.style.alignItems="flex-start",document.createElement("div").style.position="absolute",r.style.margin="20px",r.style.display="flex",r.style.alignItems="flex-end",r.style.margin=0,r.style.padding=0,r.style.margin=0,t.appendChild(r),this.addCloseButton=!1,this.res=t,e.background&&this.background({color:e.background}),e.openColor&&(this.openColor=e.openColor),e.sticky&&this.sticky(),e.pad&&this.pad(e.pad),e.hamburgerColour&&(this.hamburgerColour=e.hamburgerColour),e.mobileSize&&(this.mobileSize=e.mobileSize),e.desktopSize&&(this.desktopSize=e.desktopSize),e.height&&(this.res.children[0].style.height=e.height),this}},{key:"items",value:function(e){this.items=e;var t=["Link","Image","Spacer","Dropdown"].some((function(t){return e[0].__proto__.constructor.toString().startsWith("class ".concat(t))}));console.log(this.items),this.itemCount=e.length;var r=new m(this.obj,this.items).render();this.res.children[0].appendChild(r);var n=this.res.children[0].children[0].children[0],i=this.items[0].options;if(i&&i.animation){var s=i.animation.op;if(s){var o=window.matchMedia("(max-device-width: 415px)"),a=window.matchMedia("(max-width: 600px)");if(o.matches||a.matches){var l={duration:1,fill:"forwards",delay:1};for(c=0;c<n.children.length;c++)n.children[c].animate(s.keyframesClose,l)}else for(var c=0;c<n.children.length;c++)n.children[c].animate(s.keyframesClose,{duration:1,fill:"forwards",delay:1}),n.children[c].animate(s.keyframesOpen,s.openOptions)}}if(this.adjust(),!t){this.itemCount=e.length;var u=document.createElement("div");for(u.style.backgroundColor="orange",c=0;c<e.length;c++){var d=e[c];if(d.logo){var h=new Image(d.logo).width("100px"),p=document.createElement("div");p.style.flex="1",p.style.height=23;var y=document.createElement("div");y.setAttribute("id","WR"),y.style.display="flex",y.style.flexDirection="row",y.appendChild(h.render()),this.res.children[0].appendChild(h.render()),this.obj.spacing&&this.res.children[0].appendChild(p)}if(d.logo&&(this.allowPad=!0),d.logo&&this.obj.spacing&&(this.res.children[0].children[0].style.marginLeft=this.obj.spacing.sides,this.res.children[0].children[0].style.marginRight=this.obj.spacing.sides),d.title){var f=void 0;f=this.allowPad?d.type?new Dropdown(d.items,d.title):new Link(d.title,d.url).arrayPadding(["left","right"],"1em"):d.type?new Link("DRPA",d.url):new Link(d.title,d.url),u.appendChild(f.render())}}this.res.children[0].appendChild(u),this.adjust()}var v=this.addHamburger();return this.itemCount,this.obj.spacing,v.style.zIndex=1,1===this.res.children[0].children.length&&this.res.children[0].insertBefore(v,this.res.children[0].firstChild),this}},{key:"instance",value:function(){return this.res.children[0]}},{key:"sticky",value:function(){return this.res.children[0].style.position="fixed",this}},{key:"font",value:function(e){for(var t=0;t<this.res.children[0].children;t++)this.res.children[0].children[t].style.fontFamily=e;return this}},{key:"openSymbol",value:function(e){return this.symbol=e,this}},{key:"background",value:function(e){return e.background?(this.res.children[0].style.backgroundColor=e.color,this.res.children[0].style.opacity=e.opacity,this):(this.res.children[0].style.backgroundColor="transparent",this)}},{key:"transluescent",value:function(){return this.res.children[0].style.backgroundColor="rgba(255,255,255,0.72)",this}},{key:"keepItem",value:function(e){return this.keepItem=e,this}},{key:"adjust",value:function(e){var t=this,r=window.matchMedia("(max-width: 600px)"),n=window.matchMedia("(max-device-width: 415px)"),i=function(){t.isShown=!1,t.res.children[0],function(){for(var e=0;e<t.res.children[0].children.length;e++){var r=t.res.children[0].children[e];r.style.fontSize=n.matches?t.mobileSize?t.mobileSize:"1.2em":t.desktopSize?t.desktopSize:"1em",""===r.textContent&&(r.style.fontSize="2em")}}(),t.res.children[0].style.flexDirection="column";for(var e=0;e<t.res.children[0].children.length;e++)""==t.res.children[0].children[e].textContent||t.res.children[0].children[e].textContent==t.keepItem?(t.res.children[0].children[e].id,t.res.children[0].children[e].style.display="flex"):t.res.children[0].children[e].style.display="none"};if(this.obj.isSide)i();else{var s=this.res.children[1];null!=s&&(s.style.background="yellow"),r.matches||n.matches?i():function(){t.res.children[0];for(var e=0;e<t.res.children[0].children.length;e++){var r=t.res.children[0].children[e];r.style.marginTop="0em",r.id,r.style.display="flex",r.textContent===t.titleText&&t.titleText.length>0&&(r.style.fontSize="2em")}var n=t.items[0].options;if(n&&n.animation){var i=n.animation.op,s=t.res.children[0].children[1].children[0];if(s.style.marginTop="0",i&&!t.hasAnimatedToWide)for(t.hasAnimatedToWide=!0,e=0;e<s.children.length;e++)s.children[e].animate(i.keyframesOpen,i.openOptions)}else console.log(t.res)}()}return this}},{key:"render",value:function(e){var t=this,r=function(){var e=window.matchMedia("(max-width: 600px)"),r=window.matchMedia("(max-device-width: 415px)"),n=t.res.children[0].children[1],i=n.children[0];r.matches&&(i.style.position="relative"),(e.matches||r.matches)&&null!=i?i.style.flexDirection="column":null==i||t.obj.isSide||(i.style.flexDirection="row"),t.obj.isSide||e.matches||r.matches||(t.res.children[0].children[0].style.display="none"),t.obj.isSide&&(i.style.flexDirection="column"),t.obj.isSide||e.matches||(t.res.children[0].style.position="relative",n.style.transform="translateY(0px)"),!t.obj.isSide&&e.matches,t.obj.customStyle&&(t.res.children[0].style.marginTop="1rem",t.res.children[0].style.position="absolute",t.res.children[0].style.borderRadius="1rem",n.style.borderRadius="1rem"),t.obj.radius&&(t.res.children[0].style.borderRadius="1rem",n.style.borderRadius="1rem")};return window.addEventListener("resize",(function(){return r()})),r(),e?(document.querySelector(e).style.padding=0,document.querySelector(e).style.margin=0,document.querySelector(e).appendChild(this.res),this.res):this.res}}])}();export{v as UINavBar};