(function(){'use strict';var f;function g(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var k=g(this),l="function"==typeof Object.create?Object.create:function(a){function b(){}b.prototype=a;return new b},m;
if("function"==typeof Object.setPrototypeOf)m=Object.setPrototypeOf;else{var n;a:{var p={a:!0},q={};try{q.__proto__=p;n=q.a;break a}catch(a){}n=!1}m=n?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null}var r=m;function t(a){return"gwd-page"==a.tagName.toLowerCase()||"gwd-page"==a.getAttribute("is")}function u(a){if(t(a))return a;for(;a&&9!=a.nodeType;)if((a=a.parentElement)&&t(a))return a;return null}function v(a,b){return b!=a.getAttribute("source")?(a.setAttribute("source",b),!0):!1};function w(a,b){var c=void 0===c?null:c;var d=document.createEvent("CustomEvent");d.initCustomEvent(a,!0,!0,c);b.dispatchEvent(d)}function x(a,b,c){function d(e){a.removeEventListener(b,d);c(e)}a.addEventListener(b,d)};/*

 Copyright The Closure Library Authors.
 SPDX-License-Identifier: Apache-2.0
*/
function y(a){return/^[\s\xa0]*$/.test(a)};var z={F:"alignment",G:"bgcolor",H:"disabled",I:"down-image",J:"over-image",K:"scaling",L:"up-image"},A=[],B=0,C;for(C in z)A[B++]=z[C];function D(){var a=HTMLElement.call(this)||this;a.i="gwd_imagebutton_"+(2147483648*Math.random()|0);a.g=null;a.o=null;a.h=!1;a.v=!1;a.s=document.createElement("gwd-image");a.m=document.createElement("gwd-image");a.j=document.createElement("gwd-image");a.u=document.createElement("gwd-page");a.A=a.C.bind(a);a.B=a.D.bind(a);a.l=!1;return a}var E=HTMLElement;
D.prototype=l(E.prototype);D.prototype.constructor=D;if(r)r(D,E);else for(var F in E)if("prototype"!=F)if(Object.defineProperties){var G=Object.getOwnPropertyDescriptor(E,F);G&&Object.defineProperty(D,F,G)}else D[F]=E[F];f=D.prototype;
f.connectedCallback=function(){if(!this.l){for(var a;a=this.firstChild;)this.removeChild(a);this.g=document.createElement("div");this.g.className=this.i;this.appendChild(this.g);this.style.display="inline-block";this.style.padding=0;this.g.style.backgroundRepeat="no-repeat";this.g.style.width="100%";this.g.style.height="100%";this.l=!0;a=["bgcolor","alignment","scaling","disabled"];for(var b=0;b<a.length;b++){var c=a[b];this.attributeChangedCallback(c,null,this.getAttribute(c),null)}}this.g.addEventListener("click",
this.A,!1);this.gwdIsLoaded()||((a=u(this))?a.gwdIsLoaded()&&this.gwdLoad():this.gwdLoad())};f.disconnectedCallback=function(){this.g.removeEventListener("click",this.A,!1)};
f.attributeChangedCallback=function(a,b,c){if(this.l)switch(a){case "alignment":c?this.g.style.backgroundPosition=c:this.setAttribute(a,"center");break;case "scaling":c?this.g.style.backgroundSize=c:this.setAttribute(a,"auto");break;case "up-image":H(this,this.s,c||"");break;case "over-image":H(this,this.m,c||"");break;case "down-image":H(this,this.j,c||"");break;case "disabled":this.h=this.hasAttribute("disabled")&&"false"!=this.getAttribute("disabled");I(this);this.g.style.cursor=this.h?"default":
"pointer";break;case "bgcolor":this.g.style.backgroundColor=c&&!y(c)?c:""}};function H(a,b,c){y(c)?I(a):(b.setAttribute("source",c),a.l&&J(a))}f.gwdIsLoaded=function(){return this.v};f.gwdLoad=function(){J(this)};
function J(a,b,c,d){b=b?b:a.getAttribute("up-image");c=c?c:a.getAttribute("over-image");d=d?d:a.getAttribute("down-image");var e=document.createElement("gwd-page");e.style.display="none";var h=!1;h=v(a.s,b||"")||h;h=v(a.m,c||"")||h;if(h=v(a.j,d||"")||h)e.appendChild(a.s),e.appendChild(a.m),e.appendChild(a.j),a.u=e,x(e,"attached",e.gwdLoad.bind(e)),x(e,"pageload",a.B),a.g.appendChild(a.u)}
f.D=function(a){if(a){a=a.target;a===this.u&&(this.v=!0,I(this),w("ready",this),w("imagebuttonloaded",this));var b=a.parentNode||a.parentElement;b&&b.removeChild(a)}};f.C=function(a){this.h&&a.stopPropagation()};
function I(a){if(a.o){var b=a.o;(b=b.ownerNode||b.owningElement||b)&&b.parentNode&&b.parentNode.removeChild(b);a.o=null}b="";var c=a.s.getAttribute("source");y(c)||(b+="."+a.i+' { background-image: url("'+c+'"); }');a.h||(c=a.m.getAttribute("source"),y(c)||(b+="."+a.i+':hover { background-image: url("'+c+'"); }'),c=a.j.getAttribute("source"),y(c)||(b+="."+a.i+':active { background-image: url("'+c+'"); }'));var d=document;c=d.getElementsByTagName("head")[0];if(!c){var e=d.getElementsByTagName("body")[0];
c=d.createElement("head");e.parentNode.insertBefore(c,e)}d=d.createElement("style");d.textContent=b;c.appendChild(d);a.o=d}f.toggleEnable=function(){(this.h=!this.h)?this.setAttribute("disabled","true"):this.removeAttribute("disabled")};f.setImages=function(a,b,c){J(this,a,b,c)};k.Object.defineProperties(D,{observedAttributes:{configurable:!0,enumerable:!0,get:function(){return A}}});customElements.define("gwd-imagebutton",D);}).call(this);
