var e=`/_agent-native`,t=[`/api`,`/mcp`,`/.well-known`,`/assets`,`/sign-in`,`/login`,`/signup`],n=/^\/[A-Za-z0-9_-]+$/,r=/[A-Za-z0-9]/,i=class extends Error{constructor(e){super(e),this.name=`FrameworkRoutePrefixError`}};function a(a,o=`runtime.frameworkRoutePrefix`){if(a===void 0)return e;if(typeof a!=`string`)throw new i(`${o} must be a string`);let s=a.trim();if(!s||s===`/`)throw new i(`${o} must be a single absolute path segment such as "/_agent-native"; omit it to keep the default`);if(!n.test(s)||!r.test(s))throw new i(`${o} must be one absolute path segment of letters, digits, "_" or "-" (received ${JSON.stringify(a)})`);let c=t.find(e=>e.toLowerCase()===s.toLowerCase());if(c)throw new i(`${o} must not use the reserved namespace ${JSON.stringify(c)}`);return s}function o(e,t){return t?e===t||e.startsWith(`${t}/`):!1}function s(e){return!e||e===`/`?``:e}function c(e,t,n){return o(e,t)?`${n}${e.slice(t.length)}`:null}function l(e,t,n){return n&&c(e,`${n}/_agent-native`,`${n}${t}`)||c(e,`/_agent-native`,t)||e}function u(e,{publicPrefix:t,basePath:n}){if(t===`/_agent-native`)return e;let r=s(n);if(e.startsWith(`/`)){let n=e.search(/[?#]/),i=n===-1?e:e.slice(0,n),a=n===-1?``:e.slice(n);return`${l(i,t,r)}${a}`}if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(e))return e;let i;try{i=new URL(e)}catch{return e}let a=l(i.pathname,t,r);return a===i.pathname?e:(i.pathname=a,i.toString())}var d=`DEPLOY_SETTINGS_REQUIRED`;function f(e){return e===!0||typeof e==`string`&&[`1`,`true`,`yes`,`on`].includes(e.trim().toLowerCase())}function p(){return{version:1,onboarding:{firstRun:`off`},changelog:{enabled:!1},harness:!0}}function m(){let e=typeof window<`u`?window.__AGENT_NATIVE_CONFIG__:void 0,t=e?.workspaceAppId,n=e?.appId;for(let e of[t,n,`app`])if(typeof e==`string`&&e.trim())return e.trim().toLowerCase();return null}var h=`__an_embed_token`,g=`__an_embed_target`,ee=`embedded`,te=`__an_mcp_chat_bridge`,ne=`x-agent-native-embed-target`,re=`capability:mcp-directory-widget-read:`,ie=`capability:mcp-directory-widget-write:`;function ae(e){return e?.startsWith(re)===!0}function oe(e){return e?.startsWith(ie)===!0}var se=`data-agent-native-host-fill`,ce=`agent_access`,le=`agent-native:embed-auth-token`,_=`agent-native:mcp-chat-bridge`;function ue(e){return e===`verification_link_invalid`||e===`INVALID_TOKEN`}function de(e,t=`/home`){var n=`c`,r=`return`,i=`/sign-in`,a=`/_agent-native/sign-in`,o=`http://an.invalid`;function s(e){if(!e||e===`/`)return``;var t=String(e).replace(/^\/+/,``).replace(/\/+$/,``);return t?`/`+t:``}var c=s(e);function l(e){for(var t=0;t=0||t.indexOf(`?`)>=0||t.indexOf(`#`)>=0||l(t))return`/home`;var n;try{n=new URL(t,o)}catch{return`/home`}return n.origin!==o||n.pathname!==t||n.search||n.hash||n.pathname.startsWith(`//`)?`/home`:t}function d(e){return e===i||e.slice(-8)===i||e===a||e.slice(-22)===a||e===`/login`||e.slice(-6)===`/login`||e===`/signup`||e.slice(-7)===`/signup`}var f=u(t);d(f)&&(f=`/home`);function p(e){if(typeof e!=`string`||!e||l(e)||e.charAt(0)!==`/`||e.charAt(1)===`/`||e.charAt(1)===`\\`)return null;var t;try{t=new URL(e,o)}catch{return null}if(t.origin!==o)return null;var n=t.pathname||`/`;return n.startsWith(`//`)||d(n)||c&&n!==c&&n.slice(0,c.length+1)!==c+`/`?null:n+t.search+t.hash}function m(e){var t=p(e);if(!t)return``;var n;try{n=btoa(encodeURIComponent(t)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}catch{return``}return n.length>512?``:n}function h(e){if(typeof e!=`string`||!e||e.length>512)return null;var t;try{for(var n=e.replace(/-/g,`+`).replace(/_/g,`/`);n.length%4!=0;)n+=`=`;t=decodeURIComponent(atob(n))}catch{return null}return p(t)}function g(){return f===`/`?c||`/`:c+f}function ee(e){var t=p(e.at),r=h(e.continuation)??p(e.legacyReturn)??t??g(),a=null;if(t!==null){var o=m(t);a=c+i+(o?`?`+n+`=`+o:``)}return{signInHref:a,resumeHref:r}}function te(e,t){try{return new URLSearchParams(e||``).get(t)}catch{return null}}function ne(e){return ee({at:(e.pathname||`/`)+(e.search||``)+(e.hash||``),continuation:te(e.search,n),legacyReturn:te(e.search,r)})}return{PARAM:n,LEGACY_PARAM:r,basePath:c,homeHref:g,normalizeAppPath:p,encodeContinuation:m,decodeContinuation:h,signInJourney:ee,journeyForLocation:ne}}var fe=new Map;function pe(e,t=`/home`){let n=`${e??``}\u0000${t}`,r=fe.get(n);return r||(r=de(e??``,t),fe.set(n,r)),r}function me(e,t=``){return pe(t).decodeContinuation(e)}function he(e){return pe(e.basePath,e.homePath).signInJourney(e)}var ge=!1,v=null,_e=null,y=null,ve=0,ye=!1,b=null,be=6e4,xe=new Set([`GET`,`HEAD`]),Se=`x-agent-native-auth-circuit-breaker`,Ce=`${le}:renewed-from`,we=15e3,Te=`agent-native-mcp-chat-bridge-viewport`,Ee=560,x=null,S=new Map;function C(){return typeof window>`u`?null:window}function w(e){try{return new URL(e.location.href)}catch{try{return new URL(`${e.location.pathname||`/`}${e.location.search||``}${e.location.hash||``}`,e.location.origin||`http://agent-native.invalid`)}catch{return null}}}function De(e){return w(e)?.searchParams.get(`__an_embed_token`)??null}function Oe(){let e=C();if(!e)return!1;let t=w(e)?.searchParams.get(te);return t===`1`||t===`true`}function ke(e){return T()??v??Ne(e)}function Ae(e){ye=!1,b=null;try{e.sessionStorage?.removeItem(_)}catch{}}function je(){let e=C(),t=e?ke(e):null;ye=!0,b=t;try{t?e?.sessionStorage?.setItem(_,t):e?.sessionStorage?.removeItem(_)}catch{}}function Me(){let e=C();if(!e)return!1;if(!ze())return Ae(e),!1;if(Oe())return je(),!0;let t=ke(e);if(ye)return t==null?!0:b==null||b===t?(b=t,!0):(Ae(e),!1);try{let n=e.sessionStorage?.getItem(_);return n&&(t==null||n===t)?(ye=!0,b=n,!0):(n&&t!=null&&n!==t&&e.sessionStorage?.removeItem(_),!1)}catch{return!1}}function Ne(e){try{return e.sessionStorage?.getItem(`agent-native:embed-auth-token`)??null}catch{return null}}function Pe(e,t){v=e;try{t.sessionStorage?.setItem(le,e)}catch{}}function T(){let e=C();if(!e)return null;let t=De(e);if(t){let n=_e;if(!n)try{n=e.sessionStorage?.getItem(Ce)??null}catch{n=null}if(n===t){let n=v??Ne(e);if(n&&n!==t)return n}if(n&&n!==t){_e=null;try{e.sessionStorage?.removeItem(Ce)}catch{}}return Pe(t,e),t}return v??Ne(e)}function Fe(e){let t=e.split(`.`)[0]??``;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=Uint8Array.from(atob(e+`=`.repeat((4-e.length%4)%4)),e=>e.charCodeAt(0)),r=JSON.parse(new TextDecoder().decode(n));return typeof r.scope==`string`?r.scope:void 0}catch{return}}var E=null;function Ie(){let e=T();if(!e)return!1;if(E?.token!==e){let t=Fe(e);E={token:e,readOnly:ae(t),writable:oe(t)}}return E.writable}function Le(){let e=T();if(!e)return!1;if(E?.token!==e){let t=Fe(e);E={token:e,readOnly:ae(t),writable:oe(t)}}return E.readOnly&&Me()}function Re(){return Ie()&&Me()}function ze(){let e=C();if(!e)return!1;if(T())return!0;let t=w(e)?.searchParams.get(ee);return t===`1`||t===`true`}function Be(e){if(!Me())return;let t=e.document;if(t?.head){if(!t.getElementById(Te)){let e=t.createElement(`style`);e.id=Te;let n=`${Ee}px`,r=`html:not([${se}])`;e.textContent=` ${r}, ${r} body { min-height: 0 !important; height: ${n} !important; max-height: ${n} !important; overflow: hidden !important; } ${r} #root, ${r} #__next, ${r} [data-agent-native-app-root] { min-height: 0 !important; height: ${n} !important; max-height: ${n} !important; overflow: hidden !important; } `,t.head.appendChild(e)}Ve(e)}}function Ve(e){let t=Ee,n=()=>{try{e.openai?.notifyIntrinsicHeight?.({height:t})}catch{}try{e.parent&&e.parent!==e&&e.parent.postMessage({jsonrpc:`2.0`,method:`ui/notifications/size-changed`,params:{height:t}},`*`)}catch{}},r=x;if(x=null,r){r.animationFrameId!==null&&r.win.cancelAnimationFrame?.(r.animationFrameId);for(let e of r.timeoutIds)r.win.clearTimeout(e)}n();let i={win:e,animationFrameId:null,timeoutIds:[]};x=i;let a=()=>{x===i&&n()};try{e.requestAnimationFrame&&(i.animationFrameId=e.requestAnimationFrame(a)),e.setTimeout&&(i.timeoutIds.push(e.setTimeout(a,250)),i.timeoutIds.push(e.setTimeout(a,1e3)))}catch{}}function He(e){try{return e.location.origin===`null`}catch{return!0}}function Ue(e){if(!He(e))try{let t=w(e);if(!t||!t.searchParams.has(`__an_embed_token`))return;t.searchParams.delete(h),e.history.replaceState(e.history.state,``,`${t.pathname}${t.search}${t.hash}`)}catch{}}function We(e){return`${e.location.pathname}${e.location.search}`}function Ge(e){let t=w(e);if(t?.origin&&t.origin!==`null`)return t.origin;try{let t=e.location.origin;return t&&t!==`null`?t:null}catch{return null}}function D(e,t){try{return e instanceof Request?new URL(e.url):new URL(String(e),w(t)?.href??t.location.href)}catch{return null}}function Ke(e,t){let n=D(e,t),r=Ge(t);return!!n&&!!r&&n.origin===r}function qe(t){return[e,Z()].some(e=>t===e||t.endsWith(e)||t.includes(`${e}/`))}function Je(t){return[e,Z()].some(e=>t.endsWith(`${e}/application-state`)||t.includes(`${e}/application-state/`))}function Ye(){return new Response(JSON.stringify({error:`Unauthorized`}),{status:401,statusText:`Unauthorized`,headers:{"Content-Type":`application/json`}})}function Xe(e,t){return(t?.method??(e instanceof Request?e.method:void 0)??`GET`).toUpperCase()}function Ze(e,t){return`${e} ${t.href}`}function Qe(e){return e===401||e===403}function $e(e,t){return!(!ze()||!xe.has(e)||t.pathname===`/_agent-native/embed/start`||t.pathname.endsWith(`/sign-in`)||t.pathname.endsWith(`/_agent-native/sign-in`))}function et(e){return e&&e.expiresAt>Date.now()?e:null}function tt(e){return et(S.get(e))||(S.delete(e),null)}function nt(e){let t=new Headers(e.headers);return t.set(Se,`1`),t.has(`retry-after`)||t.set(`retry-after`,String(Math.max(1,Math.ceil((e.expiresAt-Date.now())/1e3)))),new Response(e.body,{status:e.status,statusText:e.statusText,headers:t})}async function rt(e,t){let n=null;try{n=await t.clone().text()}catch{n=null}let r=[];t.headers.forEach((e,t)=>{let n=t.toLowerCase();n===`content-encoding`||n===`content-length`||n===`transfer-encoding`||r.push([t,e])});let i={status:t.status,statusText:t.statusText,headers:r,body:n,expiresAt:Date.now()+be};S.set(e,i)}function it(e){S.delete(e)}function at(e,t,n,r){let i=Xe(e,t),a=D(e,r);if(a&&Ke(e,r)&&xe.has(i)&&qe(a.pathname))return a.searchParams.set(h,n),a.searchParams.set(g,We(r)),[a.toString(),t];let o=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));return o.has(`Authorization`)||o.set(`Authorization`,`Bearer ${n}`),o.has(`x-agent-native-embed-target`)||o.set(ne,We(r)),e instanceof Request?[new Request(e,{...t,headers:o}),void 0]:[e,{...t,headers:o}]}function ot(e,t,n){let r=D(e,n),i=Ge(n);if(!r||!i||r.origin!==i)return;let a=Xe(e,t);return{key:Ze(a,r),shouldGuard:$e(a,r)}}function st(e){if(y)return y;if(!e.parent||e.parent===e)return Promise.resolve(!1);ve+=1;let t=`embed-renewal-${Date.now()}-${ve}`,n=new Promise(n=>{let r=!1,i=null,a=t=>{r||(r=!0,i!==null&&e.clearTimeout(i),e.removeEventListener(`message`,o),n(t))},o=n=>{if(n.source!==e.parent)return;let r=n.data,i=r&&typeof r==`object`?r.data:null;if(!(r?.type!==`agentNative.embedSessionRenewed`||i?.requestId!==t)){if(i.ok!==!0){a(!1);return}try{e.parent.postMessage({type:`agentNative.embedSessionRenewalApplied`,requestId:t},`*`)}catch(e){console.warn(`[agent-native] could not acknowledge embedded session renewal`,e)}a(!0)}};e.addEventListener(`message`,o),i=e.setTimeout(()=>a(!1),we);try{e.parent.postMessage({type:`agentNative.embedSessionExpired`,data:{requestId:t}},`*`)}catch{a(!1)}}).finally(()=>{y=null});return y=n,n}function ct(){let e=C();if(!e||(Oe()&&je(),De(e)&&(T(),Ue(e)),Be(e),ge)||typeof e.fetch!=`function`)return;let t=e.fetch.bind(e),n=(async(n,r)=>{if(Le()&&Ke(n,e)){let t=D(n,e);if(t&&Je(t.pathname))return Ye()}let i=ot(n,r,e);if(i?.shouldGuard){let e=tt(i.key);if(e)return nt(e)}let a=T(),o=n,s=r;a&&Ke(n,e)&&([o,s]=at(n,r,a,e));let c=!!a&&Re()&&i&&Ke(n,e),l=null,u=null;if(c)try{u=new Request(o,s),l=u.clone()}catch{}let d=u?await t(u):await t(o,s);if(d.status===401&&c&&d.headers.get(`x-agent-native-widget-session-expired`)===`1`&&l&&a&&await st(e)){let[n,r]=at(l,void 0,a,e);d=await t(n,r)}return i?.shouldGuard&&Qe(d.status)?await rt(i.key,d):i?.shouldGuard&&d.ok&&it(i.key),d});try{e.fetch=n}catch{try{Object.defineProperty(e,"fetch",{configurable:!0,value:n,writable:!0})}catch{return}}ge=!0}var lt=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\b(?:sk-(?:proj-|ant-)?[A-Za-z0-9_-]{8,}|(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{8,}|AIza[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{16,})\b/g,ut=/\b(?:(?:AKIA|ASIA)[A-Z0-9]{0,15}|sk-(?:proj-|ant-)?[A-Za-z0-9_-]{0,7}|(?:sk|rk)_[A-Za-z0-9_]{0,12}|AIza[A-Za-z0-9_-]{0,15}|gh[pousr]_[A-Za-z0-9]{0,15})$/g,dt=/\b(?:xox[a-z]{1,2}[-.][A-Za-z0-9_-]+|xapp-[A-Za-z0-9_-]+|SG\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|pat-[A-Za-z0-9_-]+|github_pat_[A-Za-z0-9_]+|npm_[A-Za-z0-9_-]+)\b/gi,ft=/\b(?:xox[a-z]{1,2}(?:[-.]|$)|xapp-|SG\.|pat-|github_pat_|npm_)[A-Za-z0-9_.-]*$/gi,pt=/\beyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,mt=/\beyJ[A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]*){0,2}$/g,ht=`(?:database[_ -]?(?:url|uri|dsn)|db[_ -]?(?:url|uri|dsn)|connection[_ -]?(?:string|url|uri)|dsn|(?:postgres(?:ql)?|mysql|mariadb|mongodb|mongo|redis|rediss|amqp|mssql|cockroachdb)[_ -]?(?:url|uri|dsn|connection[_ -]?string))`,gt=`(?:(?:(?:[a-z0-9]+)[_ -]+)*(?:authorization|cookie|jwt|api[_ -]?key|access[_ -]?(?:token|key(?:[_ -]?id)?)|password|secret|token|refresh[_ -]?token|client[_ -]?secret|private[_ -]?key|secret[_ -]?key|signing[_ -]?key|encryption[_ -]?key|${ht})|[a-z0-9]+${`(?:api[_ -]?key|access[_ -]?(?:token|key(?:[_ -]?id)?)|refresh[_ -]?token|client[_ -]?secret|private[_ -]?key|secret[_ -]?key|signing[_ -]?key|encryption[_ -]?key|${ht})`}|[a-z0-9]+(?:jwt|secret|password|token))`,_t=`(["']?\\b`+gt+`\\b["']?\\s*[:=]\\s*["']?)`,vt=RegExp(`([\"']?\\b${gt}\\b[\"']?\\s*[:=]\\s*)([\"'])(?:\\\\.|(?!\\2)[\\s\\S])*?(?:\\2|$)`,`gi`),yt=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/gi,bt=/\b([a-z][a-z0-9+.-]*:\/\/)([^/?#\s]*@)/gi,xt=/\b([a-z][a-z0-9+.-]*:\/\/)([^/?#\s]+)$/gi,St=/\b([a-z][a-z0-9+.-]*:\/\/)([^/:?#\s]+):((?!\d+$)[^/?#@\s]+)$/gi,Ct=/(["']?\b(?:authorization|cookie)\b["']?\s*[:=]\s*)(?:(\[(?:\\.|[^\]])*\])|(["'])(?:\\.|(?!\3)[\s\S])*?\3|[^\r\n"'{}\]]+)/gim,wt=/([?&](?:sig|signature|x-amz-signature|x-goog-signature)=)([^&#\s"'<>]*?)([.,;!?)}\]]?)(?=[&#\s"'<>]|$)/gi;function Tt(e,t={}){let n=e.replace(yt,`[REDACTED]`).replace(vt,`$1$2[REDACTED]$2`).replace(Ct,(e,t,n,r)=>`${t}${n?`["[REDACTED]"]`:`${r??``}[REDACTED]${r??``}`}`).replace(RegExp(_t+`(?:Bearer|Basic)\\s+[^"'\\s,;)}\\]]+`,`gi`),`$1[REDACTED]`).replace(RegExp(_t+`[^"'\\s,;)}\\[\\]]+`,`gi`),`$1[REDACTED]`).replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,`[REDACTED]`).replace(wt,`$1[REDACTED]$3`).replace(bt,`$1[REDACTED]@`).replace(St,`$1[REDACTED]`).replace(ut,`[REDACTED]`).replace(lt,`[REDACTED]`).replace(dt,`[REDACTED]`).replace(ft,`[REDACTED]`).replace(pt,`[REDACTED]`).replace(mt,`[REDACTED]`);return t.truncated?n.replace(xt,`$1[REDACTED]`):n}var Et=/https?:\/\/hooks\.slack\.com\/services\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-]+/gi,Dt=/https?:\/\/discord\.com\/api\/webhooks\/\d+\/[A-Za-z0-9_-]+/gi,Ot=/(\b[A-Za-z0-9_.-]*webhook[_ -]?url\b["']?\s*[:=]\s*["']?)(https?:\/\/[^\s"'<>()[\]{}]+)/gi;function kt(e,t={}){return Tt(e,t).replace(Ot,(e,t,n)=>`${t}[REDACTED]${n.match(/[.,;!?]+$/)?.[0]??``}`).replace(Dt,`[REDACTED]`).replace(Et,`[REDACTED]`)}var At=1e3,jt=/\b(?:bearer|basic)\s+[^\s]+/gi,Mt=/^([\s\S]*?)(\r?\n[ \t]*params:\s*)[\s\S]*$/i,Nt=/\b(?:failed query|query failed):\s*/i,Pt=/^(?:select|insert|update|delete|merge|values|explain|call|execute|copy|declare)\b/i,Ft=/^(?:select|insert|update|delete|merge|values|with|table)\b/i,It=String.raw`(?:[uU]&"(?:[^"]|"")*"|"(?:[^"]|"")+"|[_\p{ID_Start}][$\p{ID_Continue}]*)`,Lt=RegExp(`^${It}`,`iu`),Rt=/^\$(?:[_\p{ID_Start}](?:(?!\$)\p{ID_Continue})*)?\$/u,zt=/(?:authorization|cookie|set[-_]?cookie|token|secret|password|passwd|pwd|api[-_]?key|apikey|credential)/i;function O(e){let t=e.trimStart();for(;t.startsWith(`--`)||t.startsWith(`/*`);){if(t.startsWith(`--`)){let e=t.indexOf(` `);if(e<0)return``;t=t.slice(e+1).trimStart();continue}let e=1,n=2;for(;e>0&&n0)return``;t=t.slice(n).trimStart()}return t}function Bt(e,t){if(!(e[t]!==`$`||Vt(e,t)))return Rt.exec(e.slice(t))?.[0]}function Vt(e,t){if(t<=0)return!1;let n=e.charCodeAt(t-1),r=t>1&&n>=56320&&n<=57343&&e.charCodeAt(t-2)>=55296&&e.charCodeAt(t-2)<=56319?t-2:t-1;return/(?:\$|\p{ID_Continue})$/u.test(e.slice(r,t))}function Ht(e){let t=0,n=0,r,i=!1,a;for(let o=0;o0){e.startsWith(`/*`,o)?(n++,o++):e.startsWith(`*/`,o)&&(n--,o++);continue}if(e.startsWith(`--`,o)){let t=e.indexOf(` `,o+2);if(t<0)return;o=t;continue}if(e.startsWith(`/*`,o)){n=1,o++;continue}if(e[o]===`'`||e[o]===`"`){r=e[o],i=r===`'`&&/(?:^|[^A-Za-z0-9_$])E$/i.test(e.slice(0,o));continue}let s=Bt(e,o);if(s){a=s,o+=s.length-1;continue}if(e[o]===`(`)t++;else if(e[o]===`)`&&--t===0)return e.slice(o+1)}}function Ut(e){let t=A(e);if(t===void 0)return;if(t.startsWith(`(`)){let e=Ht(t);if(e===void 0)return;t=O(e)}let n=/^as\b/i.exec(t);if(!n)return;t=O(t.slice(n[0].length));let r=/^not\b/i.exec(t);if(r){t=O(t.slice(r[0].length));let e=/^materialized\b/i.exec(t);if(!e)return;t=O(t.slice(e[0].length))}else{let e=/^materialized\b/i.exec(t);e&&(t=O(t.slice(e[0].length)))}return t.startsWith(`(`)?t:void 0}function k(e,t){let n=O(e),r=t.exec(n);return r?n.slice(r[0].length):void 0}function Wt(e){let t=``;for(let n=0;n1114111||a>=55296&&a<=57343)return;t+=String.fromCodePoint(a)}else{let e=i.toLowerCase();t+={b:`\b`,f:`\f`,n:` `,r:`\r`,t:` `}[e]??i}n+=r[0].length}return t}function Gt(e){let t=/^[eE]'/.test(e),n=t?/^[eE]'((?:''|\\[\s\S]|[^'\\])*)'/u.exec(e):/^'((?:''|[^'])*)'/u.exec(e);if(!n)return;let r=t?Wt(n[1]):n[1].replace(/''/g,`'`);if(r!==void 0)return{value:r,remainder:e.slice(n[0].length)}}function Kt(e){let t=Gt(e);if(!t)return;let n=t.value,r=t.remainder;for(;;){let e=O(r),t=r.slice(0,r.length-e.length);if(!/[\r\n]/u.test(t))break;let i=Gt(e);if(!i)break;n+=i.value,r=i.remainder}return{value:n,remainder:r}}function A(e){let t=O(e),n=Lt.exec(t);if(!n)return;let r=O(t.slice(n[0].length));if(!/^[uU]&\"/.test(n[0]))return r;let i=/^uescape(?![$\p{ID_Continue}])/iu.exec(r);if(!i)return r;r=O(r.slice(i[0].length));let a=Kt(r);if(!(!a||Array.from(a.value).length!==1||/[\da-f+"'\s]/iu.test(a.value)))return O(a.remainder)}function qt(e){let t=A(e);if(t!==void 0)for(;;){let e=O(t);if(!e.startsWith(`.`))return e;if(t=A(e.slice(1)),t===void 0)return}}function Jt(e){let t=qt(e);return t!==void 0&&O(t).startsWith(`(`)}function Yt(e){let t=A(e);return t!==void 0&&(O(t).startsWith(`(`)||k(t,/^using\b/i)!==void 0)}function Xt(e){let t=k(e,/^only\b/i)??O(e);if(t=qt(t)??``,!t)return!1;if(t=k(t,/^\*/u)??O(t),k(t,/^set\b/i)!==void 0)return!0;let n=A(k(t,/^as\b/i)??t);return n!==void 0&&k(n,/^set\b/i)!==void 0}function Zt(e){let t=A(e);if(t===void 0)return!1;for(;;){let e=k(t,/^(?:binary|asensitive|insensitive|scroll)\b/i);if(e!==void 0){t=e;continue}let n=k(t,/^no\b/i);if(n!==void 0){let e=k(n,/^scroll\b/i);if(e===void 0)return!1;t=e;continue}break}if(t=k(t,/^cursor\b/i)??``,!t)return!1;let n=k(t,/^(?:with|without)\b/i);if(n!==void 0&&(t=k(n,/^hold\b/i)??``,!t))return!1;let r=k(t,/^for\b/i);return r!==void 0&&an(r)}function Qt(e,t){let n=RegExp(`^${t}(?![$\\p{ID_Continue}])`,`iu`),r=0,i,a=!1,o;for(let t=0;t0){e.startsWith(`/*`,t)?(r++,t++):e.startsWith(`*/`,t)&&(r--,t++);continue}if(e.startsWith(`--`,t)){let n=e.indexOf(` `,t+2);if(n<0)return;t=n;continue}if(e.startsWith(`/*`,t)){r=1,t++;continue}if(e[t]===`'`||e[t]===`"`){i=e[t],a=i===`'`&&/(?:^|[^A-Za-z0-9_$])E$/i.test(e.slice(0,t));continue}let s=Bt(e,t);if(s){o=s,t+=s.length-1;continue}let c=n.exec(e.slice(t));if(c&&!Vt(e,t))return O(e.slice(t+c[0].length))}}function $t(e){let t=A(e);if(t!==void 0)for(;;){let e=O(t);if(!e.startsWith(`,`))return e;if(t=A(e.slice(1)),t===void 0)return}}function en(e){let t=k(e,/^search\b/i);if(t!==void 0&&(t=k(t,/^(?:breadth|depth)\b/i),t!==void 0&&(t=k(t,/^first\b/i),t!==void 0&&(t=k(t,/^by\b/i),t!==void 0&&(t=$t(t),t!==void 0&&(t=k(t,/^set\b/i),t!==void 0))))))return A(t)}function tn(e){let t=k(e,/^cycle\b/i);if(t===void 0||(t=$t(t),t===void 0)||(t=k(t,/^set\b/i),t===void 0)||(t=A(t),t===void 0))return;let n=Qt(t,`using`);return n===void 0?void 0:A(n)}function nn(e){let t=O(e),n=/^with\b/i.exec(t);if(!n)return!1;t=O(t.slice(n[0].length));let r=/^recursive\b/i.exec(t);for(r&&(t=O(t.slice(r[0].length)));;){let e=Ut(t);if(!e)return!1;let n=Ht(e);if(n===void 0)return!1;let r=O(n),i=!1,a=!1;for(;;){let e=i?void 0:en(r),t=e!==void 0||a?void 0:tn(r),n=e??t;if(n===void 0)break;e===void 0?a=!0:i=!0,r=O(n)}if(r.startsWith(`,`)){t=O(r.slice(1));continue}return Ft.test(r)}}function rn(e){let t=Pt.exec(e);if(!t)return!1;let n=O(e.slice(t[0].length));switch(t[0].toLowerCase()){case`select`:return/\b(?:from|where|join|union|intersect|except|group\s+by|order\s+by|having|limit|offset|returning|into)\b/i.test(n)||/\$[0-9]+|[?=*<>]/u.test(n)||/^[0-9]|^\x27|^"/u.test(n.trimStart())||n.trimStart().startsWith(`(`);case`insert`:return/^into\b/i.test(n)&&/\b(?:values|select|default\s+values)\b/i.test(n);case`update`:return Xt(n);case`delete`:return/^from\b/i.test(n);case`merge`:return/^into\b/i.test(n)&&/\busing\b/i.test(n);case`values`:return/^\s*\(/u.test(n);case`call`:return Jt(n);case`execute`:return Yt(n);case`copy`:return/\b(?:from|to)\b/i.test(n);case`declare`:return Zt(n);case`explain`:{let e=O(n);if(e.startsWith(`(`)){let t=Ht(e);if(t===void 0)return!1;e=O(t)}else for(;;){let t=/^(?:analyze|verbose|costs|settings|buffers|wal|timing|summary|format)\b/i.exec(e);if(!t)break;if(e=O(e.slice(t[0].length)),t[0].toLowerCase()===`format`){let t=/^(?:text|xml|json|yaml)\b/i.exec(e);if(!t)return!1;e=O(e.slice(t[0].length))}else{let t=/^(?:true|false|yes|no|on|off|1|0)\b/i.exec(e);t&&(e=O(e.slice(t[0].length)))}}if(/^with\b/i.test(e))return nn(e);let t=Pt.exec(e);return t!==null&&t[0].toLowerCase()!==`explain`&&rn(e)}default:return!1}}function an(e,t=!0){let n=O(e),r=/^Error:\s*/i.exec(n);return r&&(n=O(n.slice(r[0].length))),/^with\b/i.test(n)?nn(n):Pt.test(n)&&(!t||rn(n))}function on(e){let t=Nt.exec(e);return t!==null&&an(e.slice(t.index+t[0].length),!1)}function sn(e){return an(e)||on(e)}function cn(e){return e.replace(jt,e=>`${e.split(/\s+/,1)[0]} `).replace(/([A-Za-z0-9_$.-]*(?:authorization|cookie|token|secret|password|passwd|pwd|api[-_]?key|apikey|credential)[A-Za-z0-9_$.-]*\s*[:=]\s*)([^\s,;}]+)/gi,`$1`).replace(Mt,(e,t,n)=>sn(t)?`${t}${n}`:e)}function ln(e,t){let n=cn(typeof e==`string`?e:String(e??``));return n.length>t?n.slice(0,t):n}function un(){return`development`}var j=`__agentNativeStaleChunkReloadAt`,dn=1e4,M=`__agentNativeChunkRecovery`,N=`__agentNativeChunkRecoveryRequest`,fn=`/__agent-native-chunk-recovery`,pn=`__agentNativeRecoveryOriginalHash`,mn=`data-agent-native-route-warmup`,hn=`__AGENT_NATIVE_EXTERNAL_EMBED`,gn=`__agentNativeStaleChunkRecoveryExhausted`,P=`agent-native:stale-chunk-recovery-exhausted`;`${JSON.stringify(M)}${JSON.stringify(`1`)}${JSON.stringify(N)}${JSON.stringify(fn)}${JSON.stringify(pn)}${JSON.stringify(j)}${JSON.stringify(mn)}${JSON.stringify(hn)}${JSON.stringify(gn)}${JSON.stringify(P)}${dn}${dn}`;var _n=`__agentNativeRouteChunkRecoveryInstalled`,vn=15e3,yn=new WeakMap;function bn(){return{intendedHref:null,intendedAt:0,routeModuleFailureAt:0,recoveryHref:null,recovering:!1}}function xn(e){return typeof e==`string`&&/Error loading route module `[^`]+`, reloading page\.\.\./.test(e)}function F(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase();return t.includes(`failed to fetch dynamically imported module`)||t.includes(`error loading dynamically imported module`)||t.includes(`importing a module script failed`)||t.includes(`failed to fetch dynamically imported`)}function Sn(e,t,n=Date.now()){e.intendedHref=t,e.intendedAt=n}function Cn(e,t,n=Date.now()){return!e.intendedHref||n-e.intendedAt>vn||e.intendedHref===t?null:e.intendedHref}function wn(e){let t=e;for(;t;){if(t.tagName?.toUpperCase()===`A`&&typeof t.href==`string`)return t;t=t.parentElement}return null}function Tn(e,t){try{let n=new URL(t,e.location.href);return n.origin===e.location.origin?n.href:null}catch{return null}}function En(e,t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return null;let n=wn(t.target);if(!n||n.hasAttribute(`download`))return null;let r=n.getAttribute(`target`);return r&&r!==`_self`?null:Tn(e,n.href)}function Dn(e,t){try{e.location.assign(t)}catch{e.location.href=t}}function On(e,t,n=Date.now()){let r=new URL(t,e.location.href);if(!r.pathname.endsWith(`/__agent-native-chunk-recovery`)&&!r.pathname.endsWith(`/__agent-native-chunk-recovery/`)){let e=r.pathname.endsWith(`/`)?`/`:``,t=e?r.pathname.slice(0,-e.length):r.pathname;r.pathname=(t===`/`?``:t)+fn+e}let i=r.hash,a=new URLSearchParams;return a.set(N,n.toString(36)),a.set(pn,i),r.searchParams.delete(M),r.searchParams.delete(N),r.hash=a.toString(),r.href}function kn(e){let t=new URL(e.location.href),n=new URLSearchParams(t.hash.slice(1)).get(N),r=t.searchParams.get(M)===`1`;if(!t.pathname.endsWith(`/__agent-native-chunk-recovery`)&&!t.pathname.endsWith(`/__agent-native-chunk-recovery/`)&&n===null&&!r)return 0;let i=n??t.searchParams.get(`__agentNativeChunkRecoveryRequest`)?.split(`-`,1)[0]??``;if(!/^[0-9a-z]+$/i.test(i))return 0;let a=Number.parseInt(i,36);return Number.isSafeInteger(a)&&a<=Date.now()?a:0}function An(e){let t=new URL(e.location.href),n=t.pathname.endsWith(`/__agent-native-chunk-recovery`)||t.pathname.endsWith(`/__agent-native-chunk-recovery/`),r=t.searchParams.get(M)===`1`,i=new URLSearchParams(t.hash.slice(1)),a=i.has(N);if(!n&&!r&&!a)return;if(In(e,kn(e)||Date.now()),n){let e=`${fn}/`;if(t.pathname.endsWith(e)){let n=t.pathname.slice(0,-e.length);t.pathname=n?`${n}/`:`/`}else t.pathname=t.pathname.slice(0,-30)||`/`}t.searchParams.delete(M),t.searchParams.delete(N);let o=i.get(pn);a&&o!==null&&(t.hash=o),e.history.replaceState(e.history.state,``,`${t.pathname}${t.search}${t.hash}`)}function jn(e){let t=e.target,n=t?.tagName?.toUpperCase();return n===`LINK`&&t?!t.hasAttribute?.(`data-agent-native-route-warmup`)&&/(?:^|\s)modulepreload(?:\s|$)/i.test(t.getAttribute?.(`rel`)??t.rel??``):n===`SCRIPT`&&t?.type?.toLowerCase()===`module`}function Mn(e){return/AgentNativeDesktop/i.test(e.navigator?.userAgent||``)}function Nn(e){return!!e[hn]}function I(e){if(e.__agentNativeViteDevRecoveryInstalled===!0)return!0;try{let t=e.location.hostname;return t===`localhost`||t===`127.0.0.1`||t===`[::1]`||t===`::1`}catch{return}}function Pn(e){return e.includes(`Outdated Optimize Dep`)||e.includes(`Optimize Deps Processing Error`)||e.includes(`/node_modules/.vite/deps/`)||e.includes(`/@id/`)||e.includes(`/@fs/`)}function Fn(e){let t=e[j],n=Math.max(typeof t==`number`&&Number.isFinite(t)?t:0,kn(e));try{let t=e.sessionStorage?.getItem(j),r=t==null?NaN:Number(t);if(Number.isFinite(r))return Math.max(n,r)}catch{return n}return n}function In(e,t){let n=e;n[j]=t;try{let n=e.sessionStorage;return n?(n.setItem(j,String(t)),!0):`unavailable`}catch{return`unavailable`}}function Ln(e=typeof window>`u`?void 0:window){if(e)return e[gn]}function Rn(e,t){if(Ln(e))return;let n={reason:t};e[gn]=n,typeof e.dispatchEvent==`function`&&typeof CustomEvent==`function`&&e.dispatchEvent(new CustomEvent(P,{detail:n}))}function L(e=typeof window>`u`?void 0:window,t=Date.now()){if(!e?.location)return!1;if(Mn(e))return Rn(e,`desktop`),!1;if(Nn(e))return Rn(e,`external-embed`),!1;let n=Fn(e);return n>0&&t-n<=1e4?(Rn(e,`cooldown`),!1):(In(e,t),Dn(e,I(e)===!0?e.location.href:On(e,e.location.href,t)),!0)}function zn(e,t=typeof window>`u`?void 0:window){return F(e instanceof Error?e.message:String(e??``))?L(t):!1}function Bn(e,t){if(Nn(e))return!1;let n=Cn(t,e.location.href),r=Mn(e)&&!n&&t.intendedHref===e.location.href&&Date.now()-t.intendedAt<=vn?t.intendedHref:null,i=n??r;if(!i)return!1;if(t.recovering=!0,t.recoveryHref=i,Mn(e))return Dn(e,i),!0;try{e.history.replaceState(e.history.state,``,i)}catch{}return Dn(e,I(e)===!0?i:On(e,i)),!0}function Vn(e,t,n){return!F(n)||I(e)===!0&&Pn(n)?!1:(t.routeModuleFailureAt=Date.now(),Bn(e,t)?!0:L(e))}function Hn(e,t,n){let r=e.history[n];e.history[n]=function(...n){if(typeof n[2]==`string`||n[2]instanceof URL){let r=Tn(e,String(n[2]));r&&Sn(t,r)}let i=r.apply(this,n);return oa(),i}}function Un(e,t){let n=e.location.reload;if(typeof n!=`function`)return;let r=n.bind(e.location),i=function(){if(Date.now()-t.routeModuleFailureAt<=1e3){if(t.recovering||I(e)!==!0&&Bn(e,t))return;L(e);return}r()};try{Object.defineProperty(e.location,"reload",{configurable:!0,value:i})}catch{try{e.location.reload=i}catch{}}}function Wn(e=typeof window>`u`?void 0:window){let t=e?.console;if(!e?.document||!e.location||!e.history||typeof e.addEventListener!=`function`||!t)return;let n=e;if(n[_n])return;n[_n]=!0,An(e);let r=bn();yn.set(e,r),e.document.addEventListener(`click`,t=>{let n=En(e,t);n&&Sn(r,n)},!0),e.document.addEventListener(`error`,t=>{jn(t)&&I(e)!==!0&&L(e)},!0),Hn(e,r,`pushState`),Hn(e,r,`replaceState`),Un(e,r),e.addEventListener(`unhandledrejection`,t=>{let n=t.reason,i=String(n?.message||n||``);Vn(e,r,i)&&t.preventDefault()}),e.addEventListener(`error`,t=>{let n=t,i=String(n.error?.message||n.message||``);Vn(e,r,i)&&t.preventDefault()});let i=t.error.bind(t);try{t.error=(...t)=>{t.some(xn)&&(r.routeModuleFailureAt=Date.now(),I(e)!==!0&&Bn(e,r)),i(...t)}}catch{}}var Gn=200,Kn=/\b(?:chrome|moz|safari|safari-web|webkit|ms-browser)-extension:\/\//i,qn=/\binjectScriptAdjust\.js\b/i,Jn=/(?:^|\/)gtm\.js(?:$|[?#])/i,Yn=/(?:^|\.)(?:googletagmanager\.com|google-analytics\.com|googleadservices\.com|doubleclick\.net|googlesyndication\.com|facebook\.net|licdn\.com|vector\.co|hotjar\.(?:com|io)|clarity\.ms|segment\.(?:com|io)|amplitude\.com|hubspot\.com|hs-scripts\.com|hsforms\.net|intercomcdn\.com|ads-twitter\.com|snap\.licdn\.com|posthog\.com|cloudflareinsights\.com)$/i,Xn=/(?:^|\.)(?:agent-native\.com|builder\.io)$/i,Zn=/\b(?:api2?|cdn|regionconfig)\.amplitude\.com\b/i,Qn=/^(?:(?:window|globalThis|self)\.)?(?:fetch|XMLHttpRequest\.(?:open|send)|XMLHttpRequest\.prototype\.(?:open|send))$/,$n=/(?:^|\/)(?:api-path|use-db-sync|session-replay)(?:[.-][\w-]*)?\.[cm]?js(?:$|[?#])/i,er=/^(?:(?:Type)?Error:\s*)?(?:Failed to fetch|Load failed|NetworkError when attempting to fetch resource\.?|Network request failed)(?:\s*\([^)]*\))?\.?$/i,tr=/^Script error\.?$/i,nr=/^ResizeObserver loop (?:limit exceeded|completed with undelivered notifications\.?)$/i;function rr(e){let t=e.trim(),n=/^(.*?):(\d+):(\d+)$/.exec(t);if(n)return{filename:n[1],lineno:Number(n[2])};let r=/^(.*?):(\d+)$/.exec(t);return r?{filename:r[1],lineno:Number(r[2])}:{filename:t}}function ir(e){let t=e.slice(3).trim().replace(/^async\s+/,``),n=/^(.*?)\s+\((.*)\)$/.exec(t);return n?{function:n[1].trim()||void 0,...rr(n[2])}:t?rr(t):void 0}function ar(e){return/:\d+(?::\d+)?$/.test(e)||/^[a-z][a-z0-9+.-]*:\/\//i.test(e)||e===`[native code]`}function or(e){let t=e.lastIndexOf(`@`);if(t<0)return;let n=e.slice(t+1).trim();if(ar(n))return{function:e.slice(0,t).trim()||void 0,...rr(n)}}function sr(e){if(!e||typeof e!=`string`)return[];let t=e.split(` `,Gn),n=t.some(e=>/^\s*at\s/.test(e)),r=[];for(let e of t){let t=e.trim();if(t)if(n){if(!t.startsWith(`at `))continue;let e=ir(t);e&&r.push(e)}else{let e=or(t);e&&r.push(e)}}return r}function cr(e){return/^(?:[a-z][a-z0-9+.-]*:)?\/\/([^/:?#]+)/i.exec(e)?.[1]?.toLowerCase()}function lr(e){let t=e.split(`.`).filter(Boolean);if(t.length<=2)return t.join(`.`);let n=t[t.length-2],r=t[t.length-1].length===2&&[`co`,`com`,`org`,`net`,`gov`,`ac`,`edu`].includes(n)?3:2;return t.slice(-r).join(`.`)}function ur(e){return Qn.test(e.function?.trim()??``)||$n.test(e.filename??``)}function dr(e){if(!e)return!1;if(Kn.test(e)||qn.test(e)||Jn.test(e))return!0;let t=cr(e);return t!==void 0&&Yn.test(t)}function fr(e,t=[]){let n=e.filename?.trim();if(!n||n===``||n===`native`||n===`[native code]`)return`unknown`;if(Kn.test(n)||qn.test(n))return`extension`;if(dr(n))return`third-party`;let r=cr(n);return r&&t.length>0&&!Xn.test(r)&&!t.some(e=>lr(e)===lr(r))?`third-party`:ur(e)?`wrapper`:`first-party`}function pr(e,t=[]){let n={firstParty:0,wrapper:0,thirdParty:0,extension:0,zeroLine:0,withFile:0};for(let r of e){let e=fr(r,t);e!==`unknown`&&(n.withFile+=1,r.lineno===0&&(n.zeroLine+=1),e===`first-party`?n.firstParty+=1:e===`wrapper`?n.wrapper+=1:e===`third-party`?n.thirdParty+=1:n.extension+=1)}return n}function mr(e){return er.test(e.trim())}function hr(e,t){let n=e.trim().toLowerCase(),r=t.trim().toLowerCase();return r===`the user aborted a request.`||r===`signal is aborted without reason`||r===`aborterror: the user aborted a request.`||r===`aborterror: signal is aborted without reason`||n===`aborterror`&&(r.includes(`the user aborted a request`)||r.includes(`signal is aborted without reason`))}function gr(e){return(e.value??``).trim()===`fuzz-intercepted-process-exit`||/fuzzInterceptedProcessExit|fuzz-exports\.js/.test(e.stack??``)}var _r=[`browser`,`server`],R=[`browser`],z=[`server`],vr=`reportExpected`,yr=new Set([`access-control`,`expected-http`]);function br(e){return!!(e?.context?.trim()||e?.area?.trim())}function xr(e){return typeof e.mechanismType==`string`&&e.mechanismType.endsWith(`onunhandledrejection`)}function Sr(e){return e.length===0||e.every(e=>{let t=String(e.filename??``).trim().toLowerCase();return!String(e.function??``).trim()&&(!t||t===`undefined`||t===``)})}function Cr(e){try{let t=new URL(e).hostname;return t===`www.agent-native.com`||t===`agent-native.com`}catch{return!1}}function wr(e){try{return/^\/sessions\/[^/]+\/?$/.test(new URL(e).pathname)}catch{return!1}}function Tr(e){let{signal:t}=e;if(t.type!==`HTTPError`&&t.type!==`H3Error`)return!1;let n=t.statusCode;if(typeof n==`number`&&Number.isFinite(n))return n>=400&&n<500;let r=e.value;return/^Cannot find any route matching/i.test(r)||/ not found$/i.test(r)||/Unauthenticated$/i.test(r)||/^Unauthorized$/i.test(r)||/^No access to /i.test(r)}function Er(e){let{signal:t,frames:n,value:r}=e;if(r===`[object ErrorEvent]`&&xr(t)){let e=n.some(e=>e.in_app&&!String(e.filename??``).includes(`sentry`)),t=n.some(e=>String(e.filename??``).includes(`sentry`));if(!e&&t)return!0}return t.metadataValue===`[object ErrorEvent]`&&t.hasExceptionValues===!1&&String(t.metadataFilename??``).includes(`sentry`)}var Dr=[{reason:`validation`,surfaces:_r,test:({signal:e})=>e.type===`ValidationError`||e.tags?.handled===`validation`},{reason:`test-harness`,surfaces:_r,test:({value:e,signal:t})=>gr({value:e,stack:t.stack})},{reason:`access-control`,surfaces:z,test:({signal:e})=>e.type===`ForbiddenError`||e.type===`UnauthorizedError`},{reason:`access-control`,surfaces:R,test:({type:e,value:t})=>{let n=e.trim().toLowerCase(),r=t.trim().toLowerCase();return n===`unauthorizederror`||n===`unauthenticatederror`||r===`unauthorized`||r===`unauthenticated`}},{reason:`lambda-socket-hang-up`,surfaces:z,test:({value:e,frames:t,signal:n})=>e===`socket hang up`&&xr(n)&&t.some(e=>e.function===`Socket.socketOnEnd`||e.filename===`node:_http_client`)},{reason:`sdk-error-event`,surfaces:z,test:Er},{reason:`expected-http`,surfaces:z,test:Tr},{reason:`resize-observer`,surfaces:R,test:({value:e})=>nr.test(e.trim())},{reason:`stale-chunk`,surfaces:R,test:({type:e,value:t})=>F(t)||F(`${e}: ${t}`)},{reason:`view-transition-abort`,surfaces:R,test:({type:e,value:t})=>e===`InvalidStateError`&&/^Transition was aborted because of invalid state$/i.test(t.trim())},{reason:`extension-bootstrap`,surfaces:R,test:({value:e})=>/^This script should only be loaded in a browser extension\.?$/i.test(e.trim())},{reason:`opaque-script-error`,surfaces:R,test:({value:e})=>tr.test(e.trim())},{reason:`opaque-zero-line-stack`,surfaces:R,test:({origin:e})=>e.withFile>0&&e.zeroLine===e.withFile},{reason:`extension-network`,surfaces:R,test:({isNetworkFailure:e,origin:t})=>e&&t.extension>0},{reason:`extension-origin`,surfaces:R,test:({origin:e})=>e.extension>0&&e.firstParty===0},{reason:`third-party-origin`,surfaces:R,test:({origin:e})=>e.thirdParty>0&&e.firstParty===0},{reason:`amplitude-network`,surfaces:R,test:({isNetworkFailure:e,value:t,contextText:n,frames:r})=>e&&(Zn.test(t)||Zn.test(n)||r.some(e=>/amplitude/i.test(e.filename??``)))},{reason:`unattributable-network`,surfaces:R,test:({isNetworkFailure:e,origin:t,signal:n})=>e&&t.firstParty===0&&!br(n.tags)},{reason:`benign-abort`,surfaces:R,test:({type:e,value:t})=>hr(e,t)},{reason:`run-timeout-reconnect`,surfaces:R,test:({signal:e})=>e.tags?.context===`agent-native-chat`&&e.tags?.errorCode===`run_timeout`&&e.tags?.reconnectTimedOut===`false`&&e.tags?.reconnectTerminalReason===`run_timeout`},{reason:`agent-auto-continue`,surfaces:R,test:({type:e})=>e===`AgentAutoContinueSignal`},{reason:`session-replay-autoplay`,surfaces:R,test:({pageUrl:e,value:t})=>{if(!wr(e))return!1;let n=t.trim().toLowerCase();return n.includes(`notallowederror: play() failed`)&&n.includes(`user didn't interact with the document first`)}},{reason:`sourceless-emptyranges`,surfaces:R,test:({type:e,value:t,frames:n})=>e.trim().toLowerCase()===`referenceerror`&&t.toLowerCase().includes(`emptyranges`)&&Sr(n)},{reason:`docs-webkit-bridge`,surfaces:R,test:({pageUrl:e,value:t})=>Cr(e)&&t.toLowerCase().includes(`window.webkit.messagehandlers.scrolleventhandler.postmessage`)},{reason:`docs-sourceless-stack-overflow`,surfaces:R,test:({pageUrl:e,type:t,value:n,frames:r})=>Cr(e)&&t.trim().toLowerCase()===`rangeerror`&&n.toLowerCase().includes(`maximum call stack`)&&Sr(r)}];function Or(e){let t=e.frames??sr(e.stack),n=e.value??``,r={signal:e,type:e.type??``,value:n,frames:t,origin:pr(t,e.firstPartyHosts),pageUrl:(e.pageUrl??``).toLowerCase(),contextText:e.contextText??``,isNetworkFailure:mr(n)},i=e.tags?.[vr]===`true`;for(let t of Dr)if(!(i&&yr.has(t.reason))&&t.surfaces.includes(e.surface)&&t.test(r))return{drop:!0,reason:t.reason};return{drop:!1}}var kr=new Set([`password`,`p`,`token`,`state`,`code`,`share`,`share_token`,`bridge`,ce]),Ar=8,jr=/%(?:25)*(?:3f|23)/i,Mr=/%(?:25)*3f/i;function Nr(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}var Pr=new Set(Array.from(kr,Nr));function Fr(e,t){let n=new Set(t.map(Nr)),r=e;for(let e=0;e<=Ar;e+=1){let e=Nr(r);if(Pr.has(e)||n.has(e))return!0;if(!r.includes(`%`))return!1;try{let e=decodeURIComponent(r);if(e===r)return!1;r=e}catch{return!0}}return/%[0-9a-f]{2}/i.test(r)}function B(e,t,n=0){if(n>=Ar)return!0;for(let r of[`?`,`#`]){let i=e.indexOf(r);if(i===-1)continue;let a=e.indexOf(`#`,i+1),o=r===`?`&&a!==-1?e.slice(i+1,a):e.slice(i+1),s=new URLSearchParams(o);for(let e of s.keys())if(Fr(e,t)||s.getAll(e).some(e=>B(e,t,n+1)))return!0}if(jr.test(e))try{let r=decodeURIComponent(e);if(r!==e&&B(r,t,n+1))return!0}catch{return!0}return!1}function Ir(e,t){let n=!1;for(let r of Array.from(e.keys())){if(Fr(r,t)){e.set(r,``),n=!0;continue}e.getAll(r).some(e=>B(e,t))&&(e.set(r,``),n=!0)}return n}function Lr(e,t=[]){if(!e||typeof e!=`string`)return e;try{let n=new URL(e,`http://placeholder.local`),r=!1;r=Ir(n.searchParams,t);let i=n.hash.slice(1),a=i.search(Mr),o=a===-1?``:i.slice(0,a).split(`&`,1)[0];if(a!==-1&&(i.startsWith(`/`)||o.length>0&&!o.includes(`=`))&&B(i,t))r=!0,n.hash=``;else{let e=i.indexOf(`?`),a=e===-1?i:i.slice(0,e),o=a.indexOf(`&`),s=o===-1?a:a.slice(0,o),c=/^([^&=]+)=\//.exec(a)?.[1],l=i.startsWith(`/`)||s.length>0&&!s.includes(`=`)||c!==void 0&&!Fr(c,t),u=e>0&&(l||!a.includes(`=`)),d=e===-1&&o>0&&!s.includes(`=`),f=u?i.slice(e+1):d?``:i,p=a,m=!1;if((u||d)&&o!==-1){let e=a.slice(0,o),n=new URLSearchParams(a.slice(o+1));Ir(n,t)&&(r=!0,m=!0,p=`${e}&${n.toString()}`)}let h=f,g=!1;if(f.includes(`=`)){let e=new URLSearchParams(f);Ir(e,t)&&(r=!0,g=!0,h=e.toString())}u&&(m||g)?n.hash=`${p}?${h}`:d&&(m||g)?n.hash=p:!u&&g&&(n.hash=h)}return r?n.origin===`http://placeholder.local`?`${n.pathname}${n.search}${n.hash}`:n.toString():e}catch{return e}}var Rr=1e3,zr=8e3,Br=30,Vr=50,Hr=4,Ur=20,Wr=20,V=2e3,Gr=20,Kr=3,qr=15e3,Jr=200,Yr=50,Xr=`other`,Zr=2,Qr=3,$r=`ErrorBudgetExceeded`,ei=Symbol.for(`agent-native.client.errorCapture`),ti=`(?:authorization|cookie|set[-_]?cookie|token|secret|password|passwd|pwd|api[-_]?key|apikey|session|credential)`,ni=/\b(bearer|basic)\s+[a-z0-9._~+/-]+=*/gi,ri=RegExp(`(["']?)([A-Za-z0-9_$.-]*${ti}[A-Za-z0-9_$.-]*)\\1(\\s*[:=]\\s*)([^"',\\s;}\\]]+)`,`gi`),ii=new RegExp(ti,`i`);function H(e){return e.replace(ni,`$1 `).replace(ri,`$1$2$1$3`)}function ai(){let e=globalThis;return e[ei]||(e[ei]={installed:!1,config:{send:()=>{},captureGlobalErrors:!0,captureUnhandledRejections:!0,maxBreadcrumbs:20,dedupeWindowMs:3e3,maxEventsPerSession:Gr,maxEventsPerSignature:Kr,budgetSummaryDelayMs:qr},breadcrumbs:[],recentSignatures:new Map,removeHandlers:null,navigationInstalled:!1}),e[ei]}function oi(){return new Date().toISOString()}function U(e,t){return e.length>t?e.slice(0,t):e}function si(){try{return Lr(window.location.href)}catch{return}}function W(e){if(e instanceof Error)return{type:e.name||`Error`,message:e.message||String(e),stack:typeof e.stack==`string`?e.stack:void 0};if(typeof e==`string`)return{type:`Error`,message:e};if(e&&typeof e==`object`){let t=e,n=typeof t.name==`string`?t.name:void 0,r=typeof t.message==`string`?t.message:void 0,i=typeof t.stack==`string`?t.stack:void 0;return n||r||i?{type:n||`Error`,message:r||ci(e),stack:i}:{type:`Error`,message:ci(e)}}return{type:`Error`,message:String(e)}}function ci(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function li(e){if(!e)return;let t={},n=0;for(let[r,i]of Object.entries(e)){if(n>=Br)break;i!=null&&(t[r]=U(H(String(i)),200),n+=1)}return Object.keys(t).length?t:void 0}function ui(e){if(!e||typeof e!=`object`)return;let t={},n=0;for(let[r,i]of Object.entries(e)){if(n>=Vr)break;let e=U(H(r),100);t[e]=ii.test(e)?``:di(i,Hr),n+=1}return Object.keys(t).length?t:void 0}function di(e,t){if(e==null||typeof e==`boolean`||typeof e==`number`)return e;if(typeof e==`string`)return U(H(e),V);if(typeof e==`bigint`)return U(H(e.toString()),V);if(t<=0)return U(H(ci(e)),V);if(Array.isArray(e))return e.slice(0,Wr).map(e=>di(e,t-1));if(typeof e==`object`){let n={},r=0;for(let[i,a]of Object.entries(e)){if(r>=Ur)break;let e=U(H(i),100);n[e]=ii.test(e)?``:di(a,t-1),r+=1}return n}return U(H(String(e)),V)}function fi(e){if(!e)return``;let t=e.split(` `).map(e=>e.trim());return t.find(e=>e.startsWith(`at `)||/:\d+:\d+/.test(e))??t[1]??``}function pi(e,t,n){return`${e}|${t}|${fi(n)}`}function mi(e){let t=e?.error,n=t?W(t):{type:`Error`,message:String(e?.message??`Uncaught error`)};if(!n.stack&&e?.filename){let t=e.lineno??0,r=e.colno??0;n.stack=`at ${e.filename}:${t}:${r}`}return n}function hi(){let e=[];try{window.location.hostname&&e.push(window.location.hostname)}catch{}try{let t=new URL(import.meta.url).hostname;t&&e.push(t)}catch{}return e}function gi(e){return e.budget??={sent:0,bySignature:new Map,dropped:0,droppedTotal:0,droppedBySignature:new Map,noise:{},summaryFlushes:0,summaryTimer:null}}function _i(e){let t=e.message.replace(/https?:\/\/\S+/gi,``).replace(/\d+/g,`#`).slice(0,120);return`${e.type}|${t}`}function vi(e){let t=gi(e);if(t.summaryTimer!==null&&clearTimeout(t.summaryTimer),t.summaryTimer=null,t.dropped===0)return;if(t.summaryFlushes>=Qr){t.dropped=0,t.droppedBySignature.clear();return}t.summaryFlushes+=1;let n=[...t.droppedBySignature].sort((e,t)=>t[1]-e[1]).slice(0,5).map(([e,t])=>({signature:e,count:t})),r=G(e,{type:$r,message:`Client error budget exceeded`},{handled:!0,level:`warning`,extra:{dropped:t.dropped,sent:t.sent,noiseSuppressed:{...t.noise},topSignatures:n}});t.dropped=0,t.droppedBySignature.clear();try{e.config.send(r)}catch{}}function yi(e,t,n){if(t.droppedTotal+=1,t.summaryFlushes>=Qr)return;t.dropped+=1;let r=t.droppedBySignature.has(n)||t.droppedBySignature.sizevi(e),e.config.budgetSummaryDelayMs),t.summaryTimer.unref?.())}function bi(e,t){let n=gi(e),r=_i(t),i=n.bySignature.get(r)??0,a=e.config.maxEventsPerSession;if(n.sent>=a&&!(i===0&&n.sent=e.config.maxEventsPerSignature)return yi(e,n,r),!1;if(!n.bySignature.has(r)&&n.bySignature.size>=Jr){let e=n.bySignature.keys().next().value;e!==void 0&&n.bySignature.delete(e)}return n.bySignature.set(r,i+1),n.sent+=1,!0}function xi(e,t){let n=Date.now(),r=e.config.dedupeWindowMs;if(e.recentSignatures.size>200)for(let[t,i]of e.recentSignatures)n-i>r&&e.recentSignatures.delete(t);let i=e.recentSignatures.get(t);return e.recentSignatures.set(t,n),i!==void 0&&n-in&&t.breadcrumbs.splice(0,t.breadcrumbs.length-n)}catch{}}function Ci(e){return e.breadcrumbs.slice(-e.config.maxBreadcrumbs)}function wi(e){if(e.navigationInstalled||typeof window>`u`)return;e.navigationInstalled=!0;let t=e=>{try{Si({category:`navigation`,message:`${e} ${Lr(window.location.href)??window.location.pathname}`})}catch{}};try{let e=window.history.pushState.bind(window.history),n=window.history.replaceState.bind(window.history);window.history.pushState=function(...n){let r=e.apply(this,n);return t(`navigate`),r},window.history.replaceState=function(...e){let r=n.apply(this,e);return t(`replace`),r},window.addEventListener(`popstate`,()=>t(`popstate`)),t(`load`)}catch{}}function G(e,t,n){let r=e.config.getSessionContext?.()??{},i=t.stack?U(H(t.stack),zr):void 0;return{type:U(t.type||`Error`,200),message:U(H(t.message||``),Rr),...i?{stack:i}:{},handled:n.handled,level:n.level,occurredAt:oi(),...si()?{url:si()}:{},...e.config.release?{release:e.config.release}:{},...e.config.environment?{environment:e.config.environment}:{},...r.sessionId?{sessionId:r.sessionId}:{},...r.replayId?{sessionReplayId:r.replayId}:{},...r.anonymousId?{anonymousId:r.anonymousId}:{},breadcrumbs:Ci(e),...n.tags?{tags:n.tags}:{},...n.extra?{extra:n.extra}:{}}}function Ti(e,t,n){if(t.type!==`Message`){let n=Or({surface:`browser`,type:t.type,value:t.message,stack:t.stack,pageUrl:t.url,firstPartyHosts:hi(),tags:t.tags});if(n.drop){let t=gi(e).noise;t[n.reason]=(t[n.reason]??0)+1;return}}if(!xi(e,pi(t.type,t.message,t.stack))&&bi(e,t)){try{e.config.send(t)}catch{}if(n)try{e.config.emitReplayEvent?.(t)}catch{}Si({category:`exception`,message:`${t.type}: ${t.message}`,level:t.level})}}function Ei(e,t={}){try{let n=ai();Ti(n,G(n,W(e),{handled:!0,level:t.level??`error`,tags:li(t.tags),extra:ui(t.extra)}),!0)}catch{}}function Di(e,t){if(!t||e.staleChunkExhaustedReported)return;e.staleChunkExhaustedReported=!0;let n=Error(`A stale route chunk could not be recovered by reloading the page`);n.name=`RouteChunkRecoveryExhausted`,Ei(n,{tags:{context:`route_chunk_recovery_exhausted`,reason:t.reason}})}function Oi(e){let t=ai();if(t.config={...t.config,...e,captureGlobalErrors:e.captureGlobalErrors??!0,captureUnhandledRejections:e.captureUnhandledRejections??!0,maxBreadcrumbs:e.maxBreadcrumbs??t.config.maxBreadcrumbs,dedupeWindowMs:e.dedupeWindowMs??t.config.dedupeWindowMs,maxEventsPerSession:e.maxEventsPerSession??t.config.maxEventsPerSession??Gr,maxEventsPerSignature:e.maxEventsPerSignature??t.config.maxEventsPerSignature??Kr,budgetSummaryDelayMs:e.budgetSummaryDelayMs??t.config.budgetSummaryDelayMs??qr},typeof window>`u`)return()=>{};wi(t),t.removeHandlers?.(),t.removeHandlers=null;let n=[];if(t.config.captureGlobalErrors){let e=e=>{try{if(e.defaultPrevented)return;let n=mi(e);Ti(t,G(t,n,{handled:!1,level:`error`}),!1)}catch{}};window.addEventListener(`error`,e),n.push(()=>window.removeEventListener(`error`,e))}if(t.config.captureUnhandledRejections){let e=e=>{try{if(e.defaultPrevented)return;let n=e?.reason,r=W(n);(!r.type||r.type===`Error`)&&(r.type=`UnhandledRejection`),Ti(t,G(t,r,{handled:!1,level:`error`}),!1)}catch{}};window.addEventListener(`unhandledrejection`,e),n.push(()=>window.removeEventListener(`unhandledrejection`,e))}let r=()=>vi(t);window.addEventListener(`pagehide`,r),n.push(()=>window.removeEventListener(`pagehide`,r));let i=e=>{Di(t,e.detail)};return window.addEventListener(P,i),n.push(()=>window.removeEventListener(P,i)),Di(t,Ln()),t.installed=!0,t.removeHandlers=()=>{for(let e of n)try{e()}catch{}t.removeHandlers=null,t.installed=!1},t.removeHandlers}var ki=200,Ai=1600,ji=4096,Mi=512*1024,Ni=6,Pi=1e4,Fi=`[redacted]`,Ii=RegExp(`${zt.source}|session|card|cvv`,`i`),Li=`[data-sonner-toast]`,Ri=`[data-sonner-toaster]`,zi=120,Bi=2e3,Vi=!0,K=!0,Hi=!1,q=[],J=0,Ui=0,Wi=Date.now(),Gi=null,Ki=-1/0,qi=new Map,Ji=new Map,Yi=new Set,Xi=[];function Zi(){return K&&typeof window<`u`}function Qi(e){if(Zi())try{$i(e())}catch{Ui+=1}}function $i(e){let t={at:Date.now(),...e,...e.name===void 0?{}:{name:Y(e.name,!0)},...e.data===void 0?{}:{data:X(e.data,ra(e.name),{left:Ai},0,!0)}},n=JSON.stringify(t).length;q.push({event:t,chars:n}),J+=n,ea(t.at)}function ea(e){let t=e-zi*1e3;for(;q.length>0&&q[0].event.atBi||J>Mi;)J-=q.shift().chars,Ui+=1}function ta(e,t){let n=kt(cn(e),{truncated:t});return n===e?e:n.replace(/|\[REDACTED\]/g,Fi)}function Y(e,t,n){let r=e.length>ki,i=r?e.slice(0,ki):e;return t&&(i=ta(i,r)),r&&(i+=`…`),n&&(n.left-=i.length+2),i}function na(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ra(e){return Xi.length>0?e??``:null}function ia(e,t){return Ii.test(e)?!0:t!==null&&Xi.some(n=>`field`in n?n.field===e:n.path.test(t))}function X(e,t,n,r,i){if(typeof e==`string`)return Y(e,i,n);if(typeof e==`number`)return n.left-=8,Number.isFinite(e)?e:String(e);if(typeof e==`boolean`||e===null)return n.left-=5,e;if(typeof e==`bigint`)return Y(String(e),!1,n);if(typeof e!=`object`)return;if(e instanceof Error)return Y(`${e.name}: ${e.message}`,i,n);if(typeof e.toJSON==`function`)return X(e.toJSON(),t,n,r+1,i);if(r>=Ni)return n.left-=5,`[…]`;if(Array.isArray(e)){let a=[];for(let o=0;o({type:`nav`,name:e})))}function sa(e){for(let t of e?.split(` `)??[]){let e=/(?:^|[\s(@])((?:[a-z][\w+.-]*:\/\/|\/)[^\s()]*):(\d+):\d+\)?\s*$/i.exec(t);if(e)return`${e[1].replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,``).replace(/[?#].*$/,``)}:${e[2]}`}}function ca(e,t){Qi(()=>{let{type:n,message:r,stack:i}=W(e),a=sa(i);return{type:`error`,name:n,data:{kind:t,message:r,...a?{source:a}:{}}}});let n=Date.now();Yi.size>0&&n-Ki>=Pi&&(Ki=n,ma({reason:`error`}))}function la(e){ca(e.error??e.message,`error`)}function ua(e){ca(e.reason,`unhandledrejection`)}function da(){let e=new WeakMap,t=t=>{let n=t.getAttribute(`data-type`);if(n!==`error`&&n!==`warning`)return;let r=(t.textContent??``).replace(/\s+/g,` `).trim();!r||e.get(t)===`${n}:${r}`||(e.set(t,`${n}:${r}`),Qi(()=>({type:`toast`,name:n,data:{text:r}})))},n=new MutationObserver(e=>{for(let n of e){if(n.type===`attributes`){let e=n.target;e.matches(Li)&&t(e);continue}for(let e of n.addedNodes)e instanceof Element&&(e.matches(Li)?t(e):e.matches(Ri)&&e.querySelectorAll(Li).forEach(t))}});return n.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-type`]}),n}function fa(){let{pathname:e,search:t}=window.location,n=[...new Set(new URLSearchParams(t).keys())].map(e=>`${encodeURIComponent(e)}=${Fi}`).join(`&`);return Y(e,!0)+(n?`?${n}`:``)}function pa(e,t){if(t!==void 0&&!(t>=0))throw RangeError(`recorder.report({ seconds }) needs a number of seconds of 0 or more.`);let n=Date.now();ea(n);let r=t===void 0?zi:Math.min(t,zi),i=n-r*1e3,a=[];for(let{event:e}of q)e.at>=i&&a.push({t:(e.at-n)/1e3,...e});let o={};if(K)for(let[e,t]of Ji)try{o[e]=X(t(),ra(e),{left:ji},0,!0)}catch(t){o[e]={unreadable:Y(aa(t),!0)}}return{app:m()??(window.location.host||`unknown`),build:un()||`unknown`,url:fa(),at:new Date(n).toISOString(),reason:e,windowSeconds:Math.min(r,Math.max(0,Math.ceil((n-Wi)/1e3))),events:a,watched:o,pending:ha(),dropped:Ui}}function ma(e={}){let t=pa(e.reason??`manual`,e.seconds);if(t.reason===`manual`||!K)return t;for(let e of Yi)try{e(t)}catch(e){console.error(`[agent-native] A recorder onReport listener failed.`,e)}return t}function ha(){let e=Date.now();return[...qi.values()].map(({type:t,name:n,since:r})=>({type:t,name:n,ageMs:e-r}))}function ga(){return K&&Vi}function _a(){Hi||!Zi()||typeof window.addEventListener!=`function`||(Hi=!0,window.addEventListener(`error`,la),window.addEventListener(`unhandledrejection`,ua),window.addEventListener(`popstate`,oa),typeof MutationObserver==`function`&&da(),window.__agentNativeRecorder={report:ma},oa())}function va(){ct(),Wn(),_a()}function Z(){let e=p().runtime?.frameworkRoutePrefix;return e===void 0?a(typeof window>`u`?void 0:window.__AGENT_NATIVE_CONFIG__?.frameworkRoutePrefix,`window.__AGENT_NATIVE_CONFIG__.frameworkRoutePrefix`):a(e)}function Q(e){if(!e||e===`/`)return``;let t=e.trim();return!t||t===`/`?``:`/${t.replace(/^\/+/,``).replace(/\/+$/,``)}`}var ya=class extends Error{constructor(e){super(e),this.name=`WorkspaceAppMountResolutionError`}};function ba(e){return typeof e==`string`&&e.trim().length>0&&Q(e)===``}function xa(){let e=Sa(),t=e?.VITE_APP_BASE_PATH??e?.APP_BASE_PATH??e?.BASE_URL;return typeof t==`string`?Q(t):``}function Sa(){let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1},t={};return e&&t?{...t,...e}:e??t}function Ca(t){for(let n of[Z(),e])for(let e=t.indexOf(n);e>0;e=t.indexOf(n,e+1)){let r=e+n.length;if(r===t.length||t[r]===`/`)return e}return-1}function wa(e){return`/${e}`==`/_agent-native`||`/${e}`===Z()}function Ta(){if(typeof window>`u`||typeof window.location?.pathname!=`string`)return``;let e=window.location.pathname,t=Ca(e);return t<=0?``:Q(e.slice(0,t))}function $(e,t){return e===t||e.startsWith(`${t}/`)}function Ea(){if(typeof window>`u`)return``;let e=window.__reactRouterContext?.basename;return typeof e==`string`?Q(e):``}function Da(){if(typeof window>`u`)return``;let e=window.__AGENT_NATIVE_CONFIG__?.workspaceAppPath;return typeof e==`string`?Q(e):``}function Oa(){if(typeof window>`u`)return!1;let e=window,t=Sa();return ba(e.__AGENT_NATIVE_CONFIG__?.workspaceAppPath)||ba(t?.VITE_APP_BASE_PATH??t?.APP_BASE_PATH)}function ka(){let e=Sa();return typeof window<`u`&&window.__AGENT_NATIVE_CONFIG__?.workspaceRuntime===!0||f(e?.VITE_AGENT_NATIVE_WORKSPACE)||f(e?.AGENT_NATIVE_WORKSPACE)||typeof e?.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON==`string`}function Aa(e=``){if(typeof window>`u`||!ka())return e;let t=window.location?.pathname;if(typeof t!=`string`)return``;let n=Ea();if(n&&$(t,n))return n;let r=Da();if(r&&$(t,r))return r;let i=t.split(`/`).find(Boolean);if(!i){if(Oa())return``;if(e)return e;throw new ya(`Cannot resolve workspace app mount path without explicit mount metadata.`)}if(wa(i)||i===`api`)return e;if(Oa())return``;let a=Pa(),o=a?[...a].filter(e=>$(t,e)).sort((e,t)=>t.length-e.length)[0]:void 0;if(o)return o;if(e)return e;throw new ya(a?`Cannot resolve workspace app mount path because the current URL matches no projected mount.`:`Cannot resolve workspace app mount path without explicit mount metadata.`)}function ja(){let e;try{e=Na()}catch(e){if(e instanceof ya)return console.error(`Unable to resolve the workspace app mount; preserving the server router basename.`,e),!1;throw e}if(typeof window>`u`||!e&&!Oa())return!0;let t=window.location.pathname,n=e&&$(t,e)?e:``,r=window.__reactRouterContext;return r&&(r.basename=n),!0}function Ma(){if(typeof window>`u`)return``;let e=window.__AGENT_NATIVE_EXTERNAL_EMBED?.target;if(typeof e!=`string`||!e.startsWith(`/`))return``;try{let t=new URL(e,`http://agent-native.invalid`),n=Ca(t.pathname);if(n>0)return Q(t.pathname.slice(0,n));if(ka()){let e=t.pathname.split(`/`).find(Boolean);if(e&&!wa(e)&&e!==`api`)return Q(e)}}catch{return``}return``}function Na(){va();let e=Ma();if(e)return e;let t=xa(),n=Ta();if(!t)return n||Aa();if(typeof window>`u`)return t;let r=window.location.pathname;return $(r,t)?t:n||Aa(t)}function Pa(){let e=typeof window>`u`?void 0:window.__AGENT_NATIVE_CONFIG__?.workspaceAppMountPaths;if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`).map(Q).filter(Boolean);if(t.length)return new Set(t)}let t=Sa()?.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON;if(typeof t!=`string`||!t.trim())return null;try{let e=JSON.parse(t),n=Array.isArray(e)?e:e&&typeof e==`object`&&`apps`in e?e.apps:null;if(!Array.isArray(n))return null;let r=n.map(e=>{if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.path==`string`?t.path:typeof t.id==`string`?`/${t.id}`:null;return n?.startsWith(`/`)?Q(n):null}).filter(e=>!!e);return r.length?new Set(r):null}catch{return null}}function Fa(e){if(!e.startsWith(`/`))return e;let t=Na();return!t||e===t||e.startsWith(`${t}/`)?e:`${t}${e}`}function Ia(e){let t=e.search(/[?#]/);return o(t===-1?e:e.slice(0,t),`/_agent-native`)?Fa(u(e,{publicPrefix:Z()})):e}export{h as C,u as D,d as E,ee as S,p as T,At as _,pa as a,ue as b,hi as c,Or as d,Wn as f,un as g,mn as h,Z as i,Oi as l,zn as m,Fa as n,ga as o,F as p,ja as r,Ei as s,Ia as t,Lr as u,ln as v,m as w,he as x,me as y};