functionselect(t){vare;if("SELECT"===t.nodeName)t.focus(),e=t.value;elseif("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){vari=t.hasAttribute("readonly");i||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),i||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();varn=window.getSelection(),r=document.createRange();r.selectNodeContents(t),n.removeAllRanges(),n.addRange(r),e=n.toString()}returne}classClipboardAction{constructor(t){this.resolveOptions(t),this.initSelection()}resolveOptions(t={}){this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}initSelection(){this.text?this.selectFake():this.target&&this.selectTarget()}selectFake(){constt="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=(()=>this.removeFake()),this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[t?"right":"left"]="-9999px";lete=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=`${e}px`,this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=select(this.fakeElem),this.copyText()}removeFake(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}selectTarget(){this.selectedText=select(this.target),this.copyText()}copyText(){lett;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}handleResult(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}clearSelection(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}setaction(t="copy"){if(this._action=t,"copy"!==this._action&&"cut"!==this._action)thrownewError('Invalid "action" value, use either "copy" or "cut"')}getaction(){returnthis._action}settarget(t){if(void0!==t){if(!t||"object"!=typeoft||1!==t.nodeType)thrownewError('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))thrownewError('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))thrownewError('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}}gettarget(){returnthis._target}destroy(){this.removeFake()}}functionEmitter(){}Emitter.prototype={on:function(t,e,i){varn=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){varn=this;functionr(){n.off(t,r),e.apply(i,arguments)}returnr._=e,this.on(t,r,i)},emit:function(t){for(vare=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),n=0,r=i.length;n<r;n++)i[n].fn.apply(i[n].ctx,e);returnthis},off:function(t,e){vari=this.e||(this.e={}),n=i[t],r=[];if(n&&e)for(varo=0,s=n.length;o<s;o++)n[o].fn!==e&&n[o].fn._!==e&&r.push(n[o]);returnr.length?i[t]=r:deletei[t],this}};letis={node:function(t){returnvoid0!==t&&tinstanceofHTMLElement&&1===t.nodeType},nodeList:function(t){vare=Object.prototype.toString.call(t);returnvoid0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"int&&(0===t.length||exports.node(t[0]))},string:function(t){return"string"==typeoft||tinstanceofString},fn:function(t){return"[object Function]"===Object.prototype.toString.call(t)}};varDOCUMENT_NODE_TYPE=9;if("undefined"!=typeofElement&&!Element.prototype.matches){varproto=Element.prototype;proto.matches=proto.matchesSelector||proto.mozMatchesSelector||proto.msMatchesSelector||proto.oMatchesSelector||proto.webkitMatchesSelector}functionclosest(t,e){for(;t&&t.nodeType!==DOCUMENT_NODE_TYPE;){if("function"==typeoft.matches&&t.matches(e))returnt;t=t.parentNode}}function_delegate(t,e,i,n,r){varo=listener.apply(this,arguments);returnt.addEventListener(i,o,r),{destroy:function(){t.removeEventListener(i,o,r)}}}functiondelegate(t,e,i,n,r){return"function"==typeoft.addEventListener?_delegate.apply(null,arguments):"function"==typeofi?_delegate.bind(null,document).apply(null,arguments):("string"==typeoft&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return_delegate(t,e,i,n,r)}))}functionlistener(t,e,i,n){returnfunction(i){i.delegateTarget=closest(i.target,e),i.delegateTarget&&n.call(t,i)}}functionlisten(t,e,i){if(!t&&!e&&!i)thrownewError("Missing required arguments");if(!is.string(e))thrownewTypeError("Second argument must be a String");if(!is.fn(i))thrownewTypeError("Third argument must be a Function");if(is.node(t))returnlistenNode(t,e,i);if(is.nodeList(t))returnlistenNodeList(t,e,i);if(is.string(t))returnlistenSelector(t,e,i);thrownewTypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}functionlistenNode(t,e,i){returnt.addEventListener(e,i),{destroy:function(){t.removeEventListener(e,i)}}}functionlistenNodeList(t,e,i){returnArray.prototype.forEach.call(t,function(t){t.addEventListener(e,i)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,i)})}}}functionlistenSelector(t,e,i){returndelegate(document.body,t,e,i)}classClipboardextendsEmitter{constructor(t,e){super(),this.resolveOptions(e),this.listenClick(t)}resolveOptions(t={}){this.action="function"==typeoft.action?t.action:this.defaultAction,this.target="function"==typeoft.target?t.target:this.defaultTarget,this.text="function"==typeoft.text?t.text:this.defaultText,this.container="object"==typeoft.container?t.container:document.body}listenClick(t){this.listener=listen(t,"click",t=>this.onClick(t))}onClick(t){conste=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=newClipboardAction({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}defaultAction(t){returngetAttributeValue("action",t)}defaultTarget(t){conste=getAttributeValue("target",t);if(e)returndocument.querySelector(e)}staticisSupported(t=["copy","cut"]){conste="string"==typeoft?[t]:t;leti=!!document.queryCommandSupported;returne.forEach(t=>{i=i&&!!document.queryCommandSupported(t)}),i}defaultText(t){returngetAttributeValue("text",t)}destroy(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}functiongetAttributeValue(t,e){consti=`data-clipboard-${t}`;if(e.hasAttribute(i))returne.getAttribute(i)}exportdefaultClipboard;