"use strict";function_classCallCheck(a,b){if(!(ainstanceofb))thrownewTypeError("Cannot call a class as a function")}var_createClass=function(){functiona(a,b){for(varc=0;c<b.length;c++){vard=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"ind&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}returnfunction(b,c,d){returnc&&a(b.prototype,c),d&&a(b,d),b}}(),Clipboard=function(){functiona(b){_classCallCheck(this,a),this._triggers=b,this.init()}return_createClass(a,[{key:"init",value:function(){vara=this;if(!(this.triggers.length>0))thrownewError("The provided selector is empty");[].forEach.call(this.triggers,function(b){returna.bind(b)})}},{key:"bind",value:function(a){varb=this;a.addEventListener("click",function(a){returnb.select(a)})}},{key:"select",value:function(a){varb=a.currentTarget.getAttribute("data-action")||"copy",c=a.currentTarget.getAttribute("data-target"),d=a.currentTarget.getAttribute("data-text");if(d)this.selectValue(d,b);else{if(!c)thrownewError('Missing "data-target" or "data-text" attribute');this.selectTarget(c,b)}a.preventDefault()}},{key:"selectValue",value:function(a,b){varc=document.createElement("input");c.value=a,c.style.opacity=0,c.style.zIndex=-1,document.body.appendChild(c),c.select(),this.copy(b),document.body.removeChild(c)}},{key:"selectTarget",value:function(a,b){varc=document.getElementById(a);if("INPUT"===c.nodeName||"TEXTAREA"===c.nodeName)c.select();else{vard=document.createRange();d.selectNode(c),window.getSelection().addRange(d)}this.copy(b)}},{key:"copy",value:function(a){try{varb=document.execCommand(a);if(!b)throw'Invalid "data-action" attribute';window.getSelection().removeAllRanges()}catch(c){thrownewError(c)}}},{key:"triggers",get:function(){returndocument.querySelectorAll(this._triggers)},set:function(a){returnthis._triggers=a}}]),a}();