!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).clipboard={})}(this,(function(e){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */function t(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}var r=function(e){};function i(e){r(e)}var o=!0;function a(){return o}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var u,c,s,l,d="undefined"==typeof navigator?void 0:navigator,f=null==d?void 0:d.clipboard,p=null===(u=null==f?void 0:f.read)||void 0===u?void 0:u.bind(f),v=null===(c=null==f?void 0:f.readText)||void 0===c?void 0:c.bind(f),h=null===(s=null==f?void 0:f.write)||void 0===s?void 0:s.bind(f),y=null===(l=null==f?void 0:f.writeText)||void 0===l?void 0:l.bind(f),b="undefined"==typeof window?void 0:window,w=null==b?void 0:b.ClipboardItem,m=b;function g(){return"undefined"==typeof ClipboardEvent&&void 0!==m.clipboardData&&void 0!==m.clipboardData.setData}function x(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){if(""===(e=m.clipboardData.getData("Text")))throw new Error("Empty clipboard or could not read plain text from clipboard");return[2,e]}))}))}var E=function(){this.success=!1};function T(e,t,n){for(var r in i("listener called"),e.success=!0,t){var o=t[r],a=n.clipboardData;a.setData(r,o),"text/plain"===r&&a.getData(r)!==o&&(i("setting text/plain failed"),e.success=!1)}n.preventDefault()}function C(e){var t=new E,n=T.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function D(e,t){S(e);var n=C(t);return k(),n}function S(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function k(){var e=document.getSelection();e&&e.removeAllRanges()}function U(e){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){if(t="text/plain"in e,g()){if(!t)throw new Error("No `text/plain` value was specified.");if(r=e["text/plain"],m.clipboardData.setData("Text",r))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var r;return C(e)?(i("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(i('UA "Edge" => assuming success'),[2,!0]):D(document.body,e)?(i("copyUsingTempSelection worked"),[2,!0]):function(e){var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important"),t.textContent="temporary element",document.body.appendChild(t);var n=D(t,e);return document.body.removeChild(t),n}(e)?(i("copyUsingTempElem worked"),[2,!0]):function(e){i("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(i("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),S(r);var o=document.execCommand("copy");return k(),document.body.removeChild(t),o}(e["text/plain"])?(i("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function O(){return t(this,void 0,void 0,(function(){return n(this,(function(e){if(v)return i("Using `navigator.clipboard.readText()`."),[2,v()];if(g())return i("Reading text using IE strategy."),[2,x()];throw new Error("Read is not supported in your browser.")}))}))}function A(e,t){for(var n=0,r=e;n<r.length;n++){if(-1!==r[n].types.indexOf(t))return!0}return!1}var R=function(){function e(e,t){var n;for(var r in void 0===t&&(t={}),this.types=Object.keys(e),this._items={},e){var i=e[r];this._items[r]="string"==typeof i?_(r,i):i}this.presentationStyle=null!==(n=null==t?void 0:t.presentationStyle)&&void 0!==n?n:"unspecified"}return e.prototype.getType=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,this._items[e]]}))}))},e}();function _(e,t){return new Blob([t],{type:e})}function j(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;"string"==typeof e?t(e):n("could not convert blob to string")})),r.readAsText(e)}))]}))}))}function L(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,u,c;return n(this,(function(n){switch(n.label){case 0:t={},r=0,i=e.types,n.label=1;case 1:return r<i.length?(o=i[r],a=t,u=o,[4,e.getType(o)]):[3,4];case 2:a[u]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return c={},e.presentationStyle&&(c.presentationStyle=e.presentationStyle),[2,new w(t,c)]}}))}))}function M(e){var t={};return t["text/plain"]=_(e,"text/plain"),new R(t)}function P(e,r){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,e.getType(r)];case 1:return[4,j(t.sent())];case 2:return[2,t.sent()]}}))}))}function I(e){return t(this,void 0,void 0,(function(){var t,r,i,o,a,u;return n(this,(function(n){switch(n.label){case 0:t={},r=0,i=e.types,n.label=1;case 1:return r<i.length?(o=i[r],a=t,u=o,[4,P(e,o)]):[3,4];case 2:a[u]=n.sent(),n.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))}e.ClipboardItem=R,e.read=function(){return t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return p?(i("Using `navigator.clipboard.read()`."),[2,p()]):(e=M,[4,O()]);case 1:return[2,[e.apply(void 0,[t.sent()])]]}}))}))},e.readText=O,e.setDebugLog=function(e){r=e},e.suppressWarnings=function(){o=!1},e.write=function(e){return t(this,void 0,void 0,(function(){var t,r,o,u;return n(this,(function(n){switch(n.label){case 0:return h&&w?(i("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(L))]):[3,5];case 1:t=n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,h(t)];case 3:return[2,n.sent()];case 4:if(r=n.sent(),!A(e,"text/plain")&&!A(e,"text/html"))throw r;return[3,5];case 5:return o=A(e,"text/plain"),a&&!o&&i("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call suppressWarnings() to suppress this warning."),u=U,[4,I(e[0])];case 6:if(!u.apply(void 0,[n.sent()]))throw new Error("write() failed");return[2]}}))}))},e.writeText=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){if(y)return i("Using `navigator.clipboard.writeText()`."),[2,y(e)];if(!U(function(e){var t={};return t["text/plain"]=e,t}(e)))throw new Error("writeText() failed");return[2]}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=clipboard-polyfill.js.map
