(function(o,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(o=typeof globalThis<"u"?globalThis:o||self,v(o["check-update"]={}))})(this,function(o){"use strict";var v=function(e){var t=new Blob(["("+e.toString()+")()"]),a=window.URL.createObjectURL(t),n=new Worker(a);return window.URL.revokeObjectURL(a),n},_=function(){var e=1e4,t=1e3*60,a=new RegExp(/]*)?>(.*?)<\/script\s*>|]*)?>(.*?)/gi),n="".concat(location.origin,"/index.html"),l=void 0,i=!1,d=!1,y=function(){return new Promise(function(r){if(!n)return i=!0,r("");fetch("".concat(n,"?t=").concat(Date.now())).then(function(f){if(f.status===200)f.text().then(function(p){return i=!1,r(p)}).catch(function(p){return console.log(p),i=!0,r("")});else return i=!0,r("")}).catch(function(f){return console.log(f),i=!0,r("")})})},w=function(r){return(r==null?void 0:r.match(a))||[]},g=function(){clearInterval(l)};return self.onmessage=function(s){var r=s.data,f=r.code,p=r.data,k=p||{},L=k.url,W=L===void 0?n:L,R=k.init,j=R===void 0?e:R,U=k.loop,x=U===void 0?t:U;n=W,e=j,t=x,d=!0;var C=function(){y().then(function(D){var H=w(D);self.postMessage({sign:H,noCompare:i})})};if(f==="pause")g();else{if(!d)return;setTimeout(function(){C(),g(),l=setInterval(function(){C()},t)},e)}},self},I=function(e){e.postMessage({code:"pause"}),e.terminate(),e=null},c=null,m="last_signature",S=localStorage.getItem(m),h=S?JSON.parse(S):[],T=!1,b=function(){console.log("The system version has been updated!")},M=function(e,t,a){if(!window.navigator.onLine||T)return!1;var n=e.length,l=Array.from(new Set(e.concat(t)));if(n!==l.length){if(h=t,localStorage.setItem(m,JSON.stringify(h)),!n)return!1;a()}},$=function(e){var t,a,n=((t=e.target)===null||t===void 0?void 0:t.visibilityState)||((a=e.target)===null||a===void 0?void 0:a.webkitVisibilityState);n==="visible"?c.postMessage({code:"resume"}):c.postMessage({code:"pause"})},E=function(e){var t=e.init,a=e.loop,n=e.cb,l=n===void 0?b:n,i=e.url,d=e.cacheKey,y=d===void 0?m:d;m=y,b=l,c=v(_),c.postMessage({code:"start",data:{init:t,loop:a,url:i}}),c.onmessage=function(w){var g=w.data,s=g.sign,r=g.noCompare;T=r,M(h,s,b)},document.addEventListener("visibilitychange",$)},O=function(){c&&I(c),document.removeEventListener("visibilitychange",$)};o.cancelDetect=O,o.checkUpdate=E,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});