(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function i(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(n){if(n.ep)return;n.ep=!0;const r=i(n);fetch(n.href,r)}})();const b="modulepreload",I=function(t){return"/"+t},S={},W=function(e,i,o){let n=Promise.resolve();if(i&&i.length>0){const r=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),A=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.all(i.map(s=>{if(s=I(s),s in S)return;S[s]=!0;const d=s.endsWith(".css"),_=d?'[rel="stylesheet"]':"";if(!!o)for(let u=r.length-1;u>=0;u--){const p=r[u];if(p.href===s&&(!d||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${_}`))return;const c=document.createElement("link");if(c.rel=d?"stylesheet":b,d||(c.as="script",c.crossOrigin=""),c.href=s,A&&c.setAttribute("nonce",A),document.head.appendChild(c),d)return new Promise((u,p)=>{c.addEventListener("load",u),c.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${s}`)))})}))}return n.then(()=>e()).catch(r=>{const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r})};var C=function(t,e,i){if(i||arguments.length===2)for(var o=0,n=e.length,r;o<n;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function w(t,e){for(var i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];if(!t){var n=void 0;throw e===void 0?n=new Error("Invariant violation"):n=new Error(F.apply(void 0,C([e],i,!1))),n.name="InvariantViolation",n}}function F(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var o=0;return String(t).replace(/%s/g,function(){return e[o++]})}const M=Date.now();let l,f,h;function O(t){h=t,l=v(t.localAppVersionStr);const e=L();e?window._pwaLoadedLatestScripts?t.loadMainScript():(console.warn(`[PWA] Found app version mismatch flag (${e}, local=${t.localAppVersionStr}), force loading of latest scripts...`),window._pwaLoadedLatestScripts=!0,window._pwaAppVersion=t.localAppVersionStr,window._pwaLoadLatestIndexScript=x(t.localAppVersionStr,t.loadMainScript),R(t.loadLatestIndexScriptUrl)):(setTimeout(async function(){f||await N()},5e3),t.loadMainScript())}function x(t,e){return function(i,o){const n=t===i;if(n||document.querySelector(`script[src="${o}"]`))console.debug("[PWA] Same %s",n?"version":"script"),V(),e();else{const r=document.createElement("script");r.type="module",r.src=o,r.defer=!0,r.setAttribute("crossorigin",""),document.head.appendChild(r)}}}function $(t){if(!t)return;const e=v(t);w(l),l[0]<e[0]?(console.warn("[PWA] Found major update, reloading app..."),E("major")):l[0]===e[0]&&l[1]<e[1]?(console.warn("[PWA] Found minor update"),P("minor")):f||(f=!0,(!window._pwaLoadedLatestScripts||window._pwaAppVersion===t)&&V())}const g="pwaAppVersionMismatch";let m;function L(){return localStorage.getItem(g)}function P(t){m!==t&&(localStorage.setItem(g,t),m=t)}function V(){m=void 0,localStorage.removeItem(g),console.info("[PWA] Removed app version mismatch flag")}let y=!1;function E(t){const e=Date.now()-M;if(P(t),!L()){console.error("[PWA] Set version flag failed!");return}if(window._pwaLoadedLatestScripts&&e<6e5){console.error("[PWA] Can not load the latest scripts");return}e>1e4&&!y&&(y=!0,alert(`New app updates found.
The page will reload to apply the latest version.`)),T()}async function T(){const t=h.getServiceWorkerUpdater();if(t){setTimeout(()=>{window.location.reload()},5e3);try{await t()}catch(e){console.error("[PWA] error: update service worker",e)}}else window.location.reload()}async function N(){const t=await fetch(h.versionApiUrl);if(t.status===200){const e=await t.json();w(l),v(e.version)[0]>l[0]&&(console.error("[PWA] Found major update, reloading app..."),E("major"))}}function R(t){const e=document.createElement("script");e.type="text/javascript",e.src=t,e.defer=!0,e.setAttribute("crossorigin",""),document.head.appendChild(e)}function v(t){const e=/^(\d+)\.(\d+)\.(\d+)$/.exec(t);return w(e),[Number(e[1]),Number(e[2]),Number(e[3])]}console.info('app:start version=%s, built="%s"',"19.1.12",new Date(1729769118649).toLocaleString());O({localAppVersionStr:"19.1.12",loadMainScript:()=>void W(()=>import("./main-_9smBM_E.js"),[]),loadLatestIndexScriptUrl:`/assets/index.js?t=${Date.now()}`,versionApiUrl:"/api/app-version",getServiceWorkerUpdater:()=>window._updateServiceWorker});export{W as _,$ as c,w as i};
