import{i as e,t}from"./react-B8IZ02wI.js";import{C as n,S as r,h as i,m as a,n as o,p as s,s as c,u as l,w as u}from"./api-path-DiLUeLL2.js";import{t as d}from"./react-dom-0ZK-Lw7i.js";import{N as f,a as p,c as m,g as h,l as g,t as _,v}from"./components-LggAOTeO.js";import{a as y,n as b,r as x}from"./components-BPFOGuol.js";import{i as S,n as C,s as w,t as T}from"./IconCheck-B3jDJthn.js";import{t as E}from"./jsx-runtime-fBfwind-.js";import{m as D,p as O,r as k}from"./analytics-hbCOwHmS.js";import{r as A,t as j}from"./share-origin-COlEIvGo.js";import{n as M,t as N}from"./app-config-4aQIl_Vd.js";import{t as P}from"./motion-DOH2EXPt.js";import{a as ee,i as F,n as te,o as ne,r as re}from"./use-session-DJs-YY25.js";import{t as ie}from"./createReactComponent-C-DRqPhY.js";var I=`original`,L=`data-theme-family`,ae=`data-theme-family-status`,oe=`theme-family`;function R(e){if(e===void 0)return`${oe}:__no_app_id__`;let t=e.trim().toLowerCase();if(!t)throw TypeError(`Theme family settings require a non-empty appId.`);return`${oe}:${encodeURIComponent(t)}`}function se(e){return R(e)}function ce(e){let t=se(e??void 0);return`(function(){var root=document.documentElement;var fallback=${JSON.stringify(I)};try{var value=window.localStorage.getItem(${JSON.stringify(t)});if(value===null){root.setAttribute(${JSON.stringify(L)},fallback);root.setAttribute(${JSON.stringify(ae)},'awaiting-app-setting');return}if(value==='agent-native'||value==='original'){root.setAttribute(${JSON.stringify(L)},value);root.removeAttribute(${JSON.stringify(ae)});return}root.setAttribute(${JSON.stringify(L)},fallback);root.setAttribute(${JSON.stringify(ae)},'invalid')}catch(e){root.setAttribute(${JSON.stringify(L)},fallback);root.setAttribute(${JSON.stringify(ae)},'unreadable')}})();`}function le(){return` (function() { try { var params = new URLSearchParams(window.location.search || ""); var embedded = params.get(${JSON.stringify(r)}); if (params.has(${JSON.stringify(n)}) || embedded === "1" || embedded === "true") return; } catch (e) {} var INSTALL_KEY = "__agentNativeViteDevRecoveryInstalled"; if (window[INSTALL_KEY]) return; window[INSTALL_KEY] = true; var RELOAD_KEY = "__an_optimize_reload"; var RELOAD_HISTORY_PARAM = "__an_vite_dev_recovery"; var routeWarmupAttribute = ${JSON.stringify(i)}; var MAX_RELOADS = 3; var MIN_RELOAD_INTERVAL_MS = 2000; var RESET_AFTER_MS = 8000; var reloadTimer = null; var overlayShown = false; // Track recent reloads in sessionStorage. If we reload too many times // in a short window, stop and show a manual-refresh message instead of // looping forever. function readReloadHistory() { var cutoff = Date.now() - 30000; var history = []; try { var raw = sessionStorage.getItem(RELOAD_KEY); var arr = raw ? JSON.parse(raw) : []; if (Array.isArray(arr)) { history = arr.filter(function(t) { return typeof t === "number" && Number.isFinite(t) && t > cutoff; }); } } catch (e) { // coercion-ok: blocked or corrupt storage falls back to the URL history marker. } var params = new URLSearchParams(window.location.search || ""); var encoded = params.get(RELOAD_HISTORY_PARAM); if (encoded) { encoded.split(".").forEach(function(value) { var timestamp = Number.parseInt(value, 36); if (Number.isSafeInteger(timestamp) && timestamp > cutoff) { history.push(timestamp); } }); } return history.filter(function(timestamp, index, values) { return values.indexOf(timestamp) === index; }).sort(function(a, b) { return a - b; }); } function writeReloadHistory(history) { var savedInSession = false; try { sessionStorage.setItem(RELOAD_KEY, JSON.stringify(history)); savedInSession = true; } catch (e) { // coercion-ok: blocked storage falls back to the URL history marker. } try { var url = new URL(window.location.href); if (history.length) { url.searchParams.set(RELOAD_HISTORY_PARAM, history.map(function(timestamp) { return timestamp.toString(36); }).join(".")); } else { url.searchParams.delete(RELOAD_HISTORY_PARAM); } window.history.replaceState( window.history.state, "", url.pathname + url.search + url.hash, ); return true; } catch (error) { console.warn("[agent-native] Could not persist Vite recovery history.", error); return savedInSession; } } function recordReload() { var history = readReloadHistory(); history.push(Date.now()); return writeReloadHistory(history); } // Reset the counter after a stable period (page didn't fail again). setTimeout(function() { try { sessionStorage.removeItem(RELOAD_KEY); } catch (e) {} writeReloadHistory([]); }, RESET_AFTER_MS); function showOverlay(title, subtitle) { if (overlayShown) return; overlayShown = true; var mount = function() { if (!document.body) { setTimeout(mount, 16); return; } var el = document.createElement("div"); el.id = "__an-reload-overlay"; el.style.cssText = [ "position:fixed","inset:0","z-index:2147483647", "display:flex","align-items:center","justify-content:center", "background:rgba(0,0,0,0.6)","backdrop-filter:blur(8px)", "-webkit-backdrop-filter:blur(8px)", "font-family:-apple-system,BlinkMacSystemFont,system-ui,sans-serif", "color:#fff","font-size:14px" ].join(";"); el.innerHTML = '
' + '
' + title + '
' + '
' + subtitle + '
' + '
'; document.body.appendChild(el); }; mount(); } function scheduleReload(reason) { if (reloadTimer) return; var history = readReloadHistory(); if (history.length >= MAX_RELOADS) { console.warn("[agent-native] Dev server keeps re-bundling. Manual refresh needed.", reason); showOverlay( "Dev server out of sync", "Auto-reload gave up after " + MAX_RELOADS + " tries. Refresh the page (\\u2318R / Ctrl R)." ); return; } console.log("[agent-native] Vite re-bundled deps (" + reason + "), reloading\\u2026"); if (!recordReload()) { showOverlay( "Dev server out of sync", "Auto-reload could not track attempts. Refresh the page manually.", ); return; } // First reload is silent. One refresh almost always fixes it and the // overlay flash is more disruptive than the reload itself. Only show // the overlay starting on the second attempt, when something is clearly // taking longer than expected. if (history.length >= 1) { showOverlay("Updating dev server\\u2026", "Reloading the page"); } var lastReloadAt = history.length ? history[history.length - 1] : 0; var delay = Math.max( 300, MIN_RELOAD_INTERVAL_MS - Math.max(0, Date.now() - lastReloadAt), ); reloadTimer = setTimeout(function() { window.location.reload(); }, delay); } window.addEventListener("vite:beforeFullReload", function() { if (reloadTimer) { clearTimeout(reloadTimer); reloadTimer = null; } }); function looksLikeViteFailureMessage(message) { if (!message) return false; var optimizerUrl = message.indexOf("/node_modules/.vite/deps/") !== -1 || message.indexOf("/@id/") !== -1 || message.indexOf("/@fs/") !== -1; return message.indexOf("Outdated Optimize Dep") !== -1 || message.indexOf("Optimize Deps Processing Error") !== -1 || ((message.indexOf("Failed to fetch dynamically imported module") !== -1 || message.indexOf("error loading dynamically imported module") !== -1 || message.indexOf("Importing a module script failed") !== -1) && optimizerUrl) || (message.indexOf("504") !== -1 && ( message.indexOf(".vite/deps") !== -1 || message.indexOf("/node_modules/.vite/deps/") !== -1 )); } // Vite's preload event is already scoped to a failed module preload, so it // carries stronger evidence than a generic rejection. Route modules do not // live under the optimizer URL prefix, but they still need Vite's bounded // recovery before React Router logs and natively reloads the document. function looksLikeVitePreloadFailureMessage(message) { if (!message) return false; return message.indexOf("Failed to fetch dynamically imported module") !== -1 || message.indexOf("error loading dynamically imported module") !== -1 || message.indexOf("Importing a module script failed") !== -1 || message.indexOf("Outdated Optimize Dep") !== -1 || message.indexOf("Optimize Deps Processing Error") !== -1 || (message.indexOf("504") !== -1 && ( message.indexOf(".vite/deps") !== -1 || message.indexOf("/node_modules/.vite/deps/") !== -1 )); } function looksLikeViteDep(url) { if (!url) return false; // Generic resource errors are ambiguous for app route modules; only Vite's // transformed module URLs are safe evidence of an optimizer failure. try { var u = new URL(url, window.location.href); if (u.origin !== window.location.origin) return false; } catch (e) { return false; } return url.indexOf("/node_modules/.vite/deps/") !== -1 || url.indexOf("/@fs/") !== -1 || url.indexOf("/@id/") !== -1; } function looksLikeLocalViteModule(url, target) { if (!url || !target) return false; var hostname = window.location.hostname; var localDevHost = hostname === "localhost" || hostname.endsWith(".localhost") || /^127(?:\\.\\d{1,3}){3}$/.test(hostname) || hostname === "::1" || hostname === "[::1]"; if (!localDevHost) return false; if (url.indexOf(window.location.origin + "/") !== 0) return false; if (target.tagName === "SCRIPT") return String(target.type || "").toLowerCase() === "module"; return target.tagName === "LINK" && !(target.hasAttribute && target.hasAttribute(routeWarmupAttribute)) && /(?:^|\\s)modulepreload(?:\\s|$)/i.test(target.rel || ""); } // 1)