UNPKG

tankhooks

Version:
9 lines (8 loc) 7.57 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).tankhooks={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}a((r=r.apply(e,t||[])).next())}))}function i(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var u={exports:{}}; /*! * JavaScript Cookie v2.2.1 * https://github.com/js-cookie/js-cookie * * Copyright 2006, 2015 Klaus Hartl & Fagner Brack * Released under the MIT license */!function(e,t){var n;n=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function o(){}function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({path:"/"},o.defaults,i)).expires&&(i.expires=new Date(1*new Date+864e5*i.expires)),i.expires=i.expires?i.expires.toUTCString():"";try{var u=JSON.stringify(n);/^[\{\[]/.test(u)&&(n=u)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var c="";for(var a in i)i[a]&&(c+="; "+a,!0!==i[a]&&(c+="="+i[a].split(";")[0]));return document.cookie=t+"="+n+c}}function u(e,n){if("undefined"!=typeof document){for(var o={},i=document.cookie?document.cookie.split("; "):[],u=0;u<i.length;u++){var c=i[u].split("="),a=c.slice(1).join("=");n||'"'!==a.charAt(0)||(a=a.slice(1,-1));try{var f=t(c[0]);if(a=(r.read||r)(a,f)||t(a),n)try{a=JSON.parse(a)}catch(e){}if(o[f]=a,e===f)break}catch(e){}}return e?o[e]:o}}return o.set=i,o.get=function(e){return u(e,!1)},o.getJSON=function(e){return u(e,!0)},o.remove=function(t,n){i(t,"",e(n,{expires:-1}))},o.defaults={},o.withConverter=n,o}((function(){}))},e.exports=n()}(u);var c=u.exports,a={watch:!1,defaultValue:void 0},f="object"==("undefined"==typeof global?"undefined":n(global))&&global&&global.Object===Object&&global,l="object"==("undefined"==typeof self?"undefined":n(self))&&self&&self.Object===Object&&self,s=f||l||Function("return this")(),p=s.Symbol,d=Object.prototype,v=d.hasOwnProperty,y=d.toString,b=p?p.toStringTag:void 0;var g=Object.prototype.toString;var h=p?p.toStringTag:void 0;function m(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":h&&h in Object(e)?function(e){var t=v.call(e,b),n=e[b];try{e[b]=void 0;var r=!0}catch(e){}var o=y.call(e);return r&&(t?e[b]=n:delete e[b]),o}(e):function(e){return g.call(e)}(e)}function w(e){return"symbol"==n(e)||function(e){return null!=e&&"object"==n(e)}(e)&&"[object Symbol]"==m(e)}var S=/\s/;var x=/^\s+/;function O(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&S.test(e.charAt(t)););return t}(e)+1).replace(x,""):e}function j(e){var t=n(e);return null!=e&&("object"==t||"function"==t)}var T=/^[-+]0x[0-9a-f]+$/i,k=/^0b[01]+$/i,C=/^0o[0-7]+$/i,E=parseInt;function U(e){if("number"==typeof e)return e;if(w(e))return NaN;if(j(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=j(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=O(e);var n=k.test(e);return n||C.test(e)?E(e.slice(2),n?2:8):T.test(e)?NaN:+e}var N=function(){return s.Date.now()},D=Math.max,R=Math.min;function P(e,t,n){var r,o,i,u,c,a,f=0,l=!1,s=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function d(t){var n=r,i=o;return r=o=void 0,f=t,u=e.apply(i,n)}function v(e){return f=e,c=setTimeout(b,t),l?d(e):u}function y(e){var n=e-a;return void 0===a||n>=t||n<0||s&&e-f>=i}function b(){var e=N();if(y(e))return g(e);c=setTimeout(b,function(e){var n=t-(e-a);return s?R(n,i-(e-f)):n}(e))}function g(e){return c=void 0,p&&r?d(e):(r=o=void 0,u)}function h(){var e=N(),n=y(e);if(r=arguments,o=this,a=e,n){if(void 0===c)return v(a);if(s)return clearTimeout(c),c=setTimeout(b,t),d(a)}return void 0===c&&(c=setTimeout(b,t)),u}return t=U(t)||0,j(n)&&(l=!!n.leading,i=(s="maxWait"in n)?D(U(n.maxWait)||0,t):i,p="trailing"in n?!!n.trailing:p),h.cancel=function(){void 0!==c&&clearTimeout(c),f=0,r=a=o=c=void 0},h.flush=function(){return void 0===c?u:g(N())},h}e.useCookie=function(e,n){var o=r(r({},a),n),i=o.watch,u=o.defaultValue,f=t.ref(c.get(e)||u);return i&&t.watch(f,(function(t){null!=t?function(t){c.set(e,t,r({},n)),f.value=t}(t):c.remove(e)}),{deep:!0}),f},e.useCopy=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,navigator.clipboard.writeText(e)];case 1:return n.sent(),console.log("Page URL copied to clipboard"),[2,"SUCCESS"];case 2:return t=n.sent(),console.error("Failed to copy: ",t),[2,"ERROR"];case 3:return[2]}}))}))},e.useDeepCopy=function(e){return"[object Object]"===Object.prototype.toString.call(e)?JSON.parse(JSON.stringify(e)):e},e.useMousePosition=function(){var e=t.ref(-1),n=t.ref(-1),r=function(t){e.value=t.pageX,n.value=t.pageY};return t.onMounted((function(){window.addEventListener("click",r)})),t.onBeforeUnmount((function(){window.removeEventListener("click",r)})),{clickY:n,clickX:e}},e.useScrollPosition=function(){var e=t.ref(-1),n=function(){e.value=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop};return t.onMounted((function(){window.addEventListener("scroll",function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return j(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),P(e,t,{leading:r,maxWait:t,trailing:o})}(n,100),!0)})),t.onBeforeUnmount((function(){window.removeEventListener("scroll",n,!0)})),{scrollY:e}},e.useSleep=function(e){for(var t=Date.now()+e;;)if(Date.now()>t)return},Object.defineProperty(e,"__esModule",{value:!0})}));