text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@polymer/polymer/polymer-element.js"),require("@polymer/polymer/lib/utils/render-status.js"),require("@polymer/iron-ajax/iron-ajax.js"),require("@polymer/iron-a11y-keys/iron-a11y-keys.js"),require("@lrnwebcomponents/simple-modal/simple-modal.js")):"function"==typeof define&&define.amd?define(["exports","@polymer/polymer/polymer-element.js","@polymer/polymer/lib/utils/render-status.js","@polymer/iron-ajax/iron-ajax.js","@polymer/iron-a11y-keys/iron-a11y-keys.js","@lrnwebcomponents/simple-modal/simple-modal.js"],t):t((e=e||self).LrndesignImagemap={},e.polymerElement_js)}(this,function(e,t){"use strict";function n(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function r(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function l(e,t,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=o(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(n):r.value}})(e,t,n||e)}function s(){var e,t,n=(e=['\n      <style>\n        :host {\n          display: block;\n        }\n        :host #buttons {\n          position: absolute;\n          left: -999999px;\n          top: 0;\n          overflow: hidden;\n          opacity: 0;\n        }\n        /*::slotted([hotspot]) {\n        display: none;\n      }*/\n        @media print {\n          :host > #svg {\n            display: none;\n          }\n          /*::slotted(#screen-only) {\n          display: none;\n        }\n        ::slotted([hotspot]) {\n          display: block;\n        }*/\n        }\n      </style>\n      <relative-heading\n        hidden$="[[!label]]"\n        id="heading"\n        subtopic-of$="[[subtopicOf]]"\n        tag$="[[tag]]"\n        text$="[[label]]"\n      >\n      </relative-heading>\n      <div id="desc"><slot name="desc"></slot></div>\n      <div id="svg"></div>\n      <div id="buttons"></div>\n      <slot></slot>\n      <iron-ajax\n        auto=""\n        id="get_svg"\n        url="[[src]]"\n        handle-as="text"\n        on-response="_getSVGHandler"\n      ></iron-ajax>\n    '],(t=['\n      <style>\n        :host {\n          display: block;\n        }\n        :host #buttons {\n          position: absolute;\n          left: -999999px;\n          top: 0;\n          overflow: hidden;\n          opacity: 0;\n        }\n        /*::slotted([hotspot]) {\n        display: none;\n      }*/\n        @media print {\n          :host > #svg {\n            display: none;\n          }\n          /*::slotted(#screen-only) {\n          display: none;\n        }\n        ::slotted([hotspot]) {\n          display: block;\n        }*/\n        }\n      </style>\n      <relative-heading\n        hidden\\$="[[!label]]"\n        id="heading"\n        subtopic-of\\$="[[subtopicOf]]"\n        tag\\$="[[tag]]"\n        text\\$="[[label]]"\n      >\n      </relative-heading>\n      <div id="desc"><slot name="desc"></slot></div>\n      <div id="svg"></div>\n      <div id="buttons"></div>\n      <slot></slot>\n      <iron-ajax\n        auto=""\n        id="get_svg"\n        url="[[src]]"\n        handle-as="text"\n        on-response="_getSVGHandler"\n      ></iron-ajax>\n    '])||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return s=function(){return n},n}var a=function(e){function a(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),e=r(this,o(a).call(this)),import("@lrnwebcomponents/relative-heading/relative-heading.js"),import("@lrnwebcomponents/lrndesign-imagemap/lib/lrndesign-imagemap-hotspot.js"),e}var d,c,u;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}}),t&&i(e,t)}(a,t.PolymerElement),d=a,u=[{key:"template",get:function(){return t.html(s())}},{key:"tag",get:function(){return"lrndesign-imagemap"}},{key:"properties",get:function(){return{label:{type:String,value:null},src:{type:String,value:null},hotspotDetails:{type:Array,value:[]},subtopicOf:{type:String,value:null,reflectToAttribute:!0},tag:{type:String,value:null,reflectToAttribute:!0}}}}],(c=[{key:"connectedCallback",value:function(){var e=this;l(o(a.prototype),"connectedCallback",this).call(this),window.SimpleModal.requestAvailability(),window.addEventListener("simple-modal-closed",function(t){t.detail.invokedBy===e&&e.closeHotspot()})}},{key:"disconnectedCallback",value:function(){var e=this;window.removeEventListener("simple-modal-closed",function(t){t.detail.invokedBy===e&&e.closeHotspot()}),l(o(a.prototype),"disconnectedCallback",this).call(this)}},{key:"_getSVGHandler",value:function(e){var t=this,n=this,o=document.createElement("div"),i=function(e,t){return null===e.getAttribute("id")&&e.setAttribute("id",t),e.getAttribute("id")},r=function(e,t,o){var r=function(r){var l="title"===r?"label":r,s=(e=null!==e?e:n).querySelector("#"+l),a=t.querySelector(r);return null===a&&(a=document.createElement(r),t.prepend(a)),null!==e.getAttribute(l)?a.innerHTML=e.getAttribute(l):null!==s&&""!==s.innerHTML&&(a.innerHTML=s.innerHTML),i(a,o+"-"+l)};t.setAttribute("aria-labelledby",r("desc")+" "+r("label"))};o.innerHTML=e.detail.response;var l=o.querySelector("svg"),s=i(l,"svg-"+Date.now()),a=n.querySelectorAll("lrndesign-imagemap-hotspot");r(n,l,s),this.shadowRoot.querySelector("#svg").appendChild(l);for(var d=function(e){var o=a[e].getAttribute("hotspot-id"),i=l.querySelector("#"+o),s=l.cloneNode(!0);r(a[e],s,o),a[e].appendChild(s),a[e].querySelector("#"+o).classList.add("selected"),a[e].setParentHeading(n.shadowRoot.querySelector("#heading"));for(var d=0;d<a.length;d++)a[e].querySelector("#"+a[d].getAttribute("hotspot-id")).classList.add("hotspot");var c=document.createElement("button");c.setAttribute("tabindex",0),c.setAttribute("aria-label",a[e].label),n.shadowRoot.querySelector("#buttons").appendChild(c),c.addEventListener("focus",function(){i.classList.add("focus")}),c.addEventListener("blur",function(){i.classList.remove("focus")}),i.classList.add("hotspot"),i.addEventListener("click",function(n){t.openHotspot(i,a[e])}),c.addEventListener("keyup",function(n){13!==n.keyCode&&32!==n.keyCode||i.classList.contains("selected")||t.openHotspot(i,a[e])})},c=0;c<a.length;c++)d(c)}},{key:"openHotspot",value:function(e,t){var n=t.shadowRoot.querySelector("#desc").querySelector("slot").assignedNodes({flatten:!0}),o=document.createElement("div");for(var i in n)o.appendChild(n[i].cloneNode(!0));var r=new CustomEvent("simple-modal-show",{bubbles:!0,cancelable:!0,detail:{title:t.getAttribute("label"),elements:{content:o},invokedBy:this,clone:!1}});this.dispatchEvent(r),this.__activeHotspot=e,this.resetHotspots(),e.classList.add("selected")}},{key:"closeHotspot",value:function(){this.resetHotspots(),this.__activeHotspot.focus()}},{key:"resetHotspots",value:function(){for(var e=this.querySelectorAll('.hotspot[role="button"]'),t=0;t<e.length;t++)e[t].classList.remove("selected")}}])&&n(d.prototype,c),u&&n(d,u),a}();window.customElements.define(a.tag,a),e.LrndesignImagemap=a,Object.defineProperty(e,"__esModule",{value:!0})});
  //# sourceMappingURL=lrndesign-imagemap.umd.js.map
  