pi-webapp 0.1.56 → 0.1.57-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="dd30f538-ba61-417c-bf07-9611a0ba133f",t._sentryDebugIdIdentifier="sentry-dbid-dd30f538-ba61-417c-bf07-9611a0ba133f")}catch{}})();import{resolve as Me}from"node:path";import{lstat as le,mkdir as Ce,readdir as Fe,rename as de}from"node:fs/promises";import{join as k}from"node:path";import{createHash as me}from"node:crypto";var s=class extends Error{code;status;reason;constructor(e,n,r={}){super(n),this.name="HostedPluginError",this.code=e,this.status=r.status,this.reason=r.reason}};var $=t=>t.code==="ENOENT";var rt={files:4096,total:128*1024*1024,js:16*1024*1024,css:4*1024*1024,font:8*1024*1024,wasm:16*1024*1024,other:2*1024*1024};var v=t=>me("sha256").update(t).digest("hex");import{constants as J}from"node:fs";import{DatabaseSync as ye}from"node:sqlite";import{lstat as Y,mkdir as ve,open as N,rename as be,unlink as Z}from"node:fs/promises";import{dirname as ke,join as X,resolve as Ie}from"node:path";import{randomUUID as _e}from"node:crypto";import{setTimeout as xe}from"node:timers/promises";async function O(t){await ve(t,{recursive:!0,mode:448});let e=await Y(t);if(!e.isDirectory()||e.isSymbolicLink())throw new s("invalid_storage","Plugin storage must be a real directory")}async function w(t,e){let n;try{n=await N(t,J.O_RDONLY|J.O_NONBLOCK|(J.O_NOFOLLOW??0))}catch(r){if($(r))return null;throw r}try{let r=await n.stat();if(!r.isFile()||r.nlink>1||r.size>e)throw new s("invalid_storage","Invalid storage record size or type");let o=Buffer.alloc(Math.min(r.size+1,e+1)),i=0;for(;i<o.length;){let a=await n.read(o,i,o.length-i,i);if(!a.bytesRead)break;i+=a.bytesRead}if(i>e||i!==r.size)throw new s("invalid_storage","Storage record changed during read");return o.subarray(0,i)}finally{await n.close()}}async function A(t,e=2*1024*1024){let n=await w(t,e);if(!n)return null;try{return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n))}catch{throw new s("invalid_storage","Invalid JSON storage record; original bytes preserved")}}async function I(t){let e=await w(t,2097152);if(e===null)return null;let n;try{n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new s("gc_recovery_required",`Invalid journal ${t}; stop all owners and inspect original bytes`)}if(!n||typeof n!="object"||Array.isArray(n))throw new s("gc_recovery_required",`Invalid journal ${t}; original bytes preserved`);return n}async function b(t,e){let n=`${t}.${_e()}.tmp`,r=await N(n,"wx",384);try{try{await r.writeFile(JSON.stringify(e)),await r.sync()}finally{await r.close()}await be(n,t);let o;try{o=await N(ke(t),"r"),await o.sync()}catch(i){if(!["EINVAL","EPERM","EACCES","EISDIR","ENOTSUP","EBADF"].includes(i.code??""))throw i}finally{await o?.close()}}finally{await Z(n).catch(()=>{})}}var Q='{"version":2,"mechanism":"sqlite-exclusive"}',C=t=>t.toString("utf8")===Q,L=new Set;async function Se(t,e,n=0){await O(t);let r=X(t,`${e}.lock`),o=X(t,`${e}.ownership.sqlite`),i=e==="runtime"?"runtime_owned":"storage_busy",a=()=>new s(i,"Another host owns this plugin storage or a legacy ownership lock remains; stop all owners and verify a backup before offline recovery"),c;try{c=await N(o,"wx",384)}catch(p){if(p.code!=="EEXIST")throw p}finally{await c?.close()}let d=await Y(o);if(!d.isFile()||d.isSymbolicLink()||d.nlink!==1||d.size>1024*1024)throw new s("invalid_storage","Ownership database must be a small, single-link regular file");let l=new ye(o,{allowExtension:!1}),u=Ie(o),h=Date.now()+n,m=!1;try{for(;;){if(!L.has(u))try{l.exec("BEGIN EXCLUSIVE"),L.add(u),m=!0;break}catch(y){if(y.errcode!==5)throw y}if(Date.now()>=h)throw new s(i,"Another host owns this plugin storage; wait for it to stop before retrying");await xe(10)}let p=await w(r,4096);if(p===null){let y;try{y=await N(r,"wx",384),await y.writeFile(Q),await y.sync()}catch(_){if(_.code!=="EEXIST")throw _}finally{await y?.close()}p=await w(r,4096)}if(p===null||!C(p))throw a()}catch(p){throw l.close(),m&&L.delete(u),p}let g=!1;return async()=>{if(g)return;let p=await w(r,4096);if(p===null||!C(p))throw new s("invalid_storage","Ownership fence changed while held; preserve custody and inspect storage");await Z(r),l.close(),L.delete(u),g=!0}}async function x(t,e,n=2e3){let r=await Se(t,"transaction",n);try{return await e()}finally{await r()}}import{readdir as pt,realpath as ht,rename as Pe,stat as Re}from"node:fs/promises";import{join as U}from"node:path";var F=t=>U(t,"host-pair");var yt=10*6e4;async function Ee(t){await Pe(t,`${t}.corrupt-${Date.now()}`).catch(e=>{if(e.code!=="ENOENT")throw e})}var Oe=t=>t.schema===1&&/^[a-f0-9-]{36}$/.test(t.id)&&typeof t.version=="string"&&typeof t.packageRoot=="string"&&/^[a-f0-9]{64}$/.test(t.hostDigest)&&/^[a-f0-9]{64}$/.test(t.fingerprint)&&Array.isArray(t.selections)&&!t.selections.some(e=>!e||typeof e.id!="string"||typeof e.version!="string"||!/^[a-f0-9]{64}$/.test(e.digest)||!Object.hasOwn(e,"before"))&&!(t.selection&&(typeof t.selection.path!="string"||!/^[a-f0-9]{64}$/.test(t.selection.digest)))&&["prepared","selecting","selected","restart-requested","reconciled","cancelled","required-action"].includes(t.phase);async function ee(t){let e=U(F(t),"intent.json"),n,r=!0;try{n=await I(e)}catch{n=null,r=!1}if(!r||n&&!Oe(n))return await Ee(e),null;if(n){let{lifecyclePhase:o,...i}=n,a=typeof i.updatedAt=="string"&&!Number.isNaN(Date.parse(i.updatedAt))?i.updatedAt:await Re(e).then(c=>c.mtime.toISOString(),()=>new Date(0).toISOString());n={...i,updatedAt:a,phase:i.phase==="selected"&&o==="restart-requested"?"restart-requested":i.phase==="reconciled"&&o==="cancelled"?"cancelled":i.phase==="reconciled"&&o==="required-action"?"required-action":i.phase}}return n}async function te(t,e){let{lifecyclePhase:n,...r}={...e,selections:[],updatedAt:new Date().toISOString()},o=r.phase==="cancelled"?{...r,phase:"reconciled",lifecyclePhase:"cancelled"}:r.phase==="required-action"?{...r,phase:"reconciled",lifecyclePhase:"required-action"}:r.phase==="restart-requested"?{...r,phase:"selected",lifecyclePhase:"restart-requested"}:r;await b(U(F(t),"intent.json"),o)}import{lstat as M,mkdir as Ae,open as ne,realpath as ie,readdir as B,link as je,rename as Ne,unlink as S,copyFile as He,rm as Te}from"node:fs/promises";import{dirname as De,isAbsolute as oe,join as f,relative as se,resolve as qe,sep as z,win32 as $e}from"node:path";import{randomUUID as G}from"node:crypto";var kt=64*1024*1024,re=Object.freeze([Object.freeze({extension:".excalidraw",binary:!1,maxBytes:512*1024,createDirectory:"diagrams"})]);var H=192*1024*1024,At=512*1024,ce=t=>typeof t=="string"&&/^[a-f0-9-]{36}$/.test(t);function Le(t){if(!t||typeof t!="object"||Array.isArray(t))throw new s("invalid_input","Expected object input");return t}function ae(t){if(typeof t!="string"||!/^[\w.-]{1,160}$/.test(t)||t==="."||t==="..")throw new s("invalid_input","Invalid state key");return t}function T(t){if(t&&(!ce(t.stateRef)||typeof t.version!="string"||!Number.isSafeInteger(t.generation)||t.generation<1||!Number.isSafeInteger(t.schema)||t.schema<1||typeof t.enabled!="boolean"||typeof t.operationId!="string"))throw new s("invalid_storage","Invalid active plugin record");return t}var D=class{root;pluginId;legacy;checkpoint;files;constructor(e,n,r,o,i=re){this.root=f(e,v(n)),this.pluginId=n,this.legacy=r,this.checkpoint=o,this.files=i}rule(e){let n=typeof e=="string"?this.files.find(r=>e.toLowerCase().endsWith(r.extension)):void 0;if(!n)throw new s("invalid_path",`Use a workspace-relative ${this.files.map(r=>r.extension).join("/")} path`);return n}active(){return A(f(this.root,"active.json")).then(T)}async recover(){return x(this.root,async()=>{let e=await this.active(),n=await I(f(this.root,"transition.json"));if(!n)return{active:e,recovered:"none"};if(!n.next||!Object.hasOwn(n,"before")||Object.keys(n).some(a=>!["version","before","next"].includes(a))||Object.hasOwn(n,"version")&&n.version!==1)throw new s("invalid_storage","Invalid activation journal; stop all owners and inspect transition.json");T(n.next),T(n.before);let r=e?.operationId===n.next.operationId?"committed":"not_committed";if(!((a,c)=>a===null||c===null?a===c:["version","generation","stateRef","schema","enabled","operationId"].every(d=>a[d]===c[d]))(e,r==="committed"?n.next:n.before))throw new s("gc_recovery_required","Activation journal does not match the active pointer; original bytes preserved");let i=n.before;if(r==="committed"&&i&&i.stateRef!==e.stateRef&&await b(f(this.root,"previous.json"),i),r==="committed"){let a=await I(f(this.root,"fork.json"));a?.version===1&&a.stateRef===e.stateRef&&Object.keys(a).every(c=>["version","stateRef"].includes(c))&&await S(f(this.root,"fork.json"))}return await S(f(this.root,"transition.json")),{active:e,recovered:r}})}async activate(e,n){return x(this.root,async()=>{let r=await this.active();if((r?.generation??0)!==e)throw new s("stale_generation","Plugin activation changed concurrently");let o=await I(f(this.root,"fork.json"));if(o&&(o.version!==1||o.stateRef!==n.stateRef||Object.keys(o).some(a=>!["version","stateRef"].includes(a))))throw new s("gc_recovery_required","Activation refused: unresolved fork.json belongs to another target; stop all owners and inspect it");let i=T({...n,generation:e+1,operationId:G()});await O(f(this.root,"states")),await O(f(this.root,"states",i.stateRef)),await b(f(this.root,"transition.json"),{version:1,before:r,next:i}),await this.checkpoint?.("prepared");try{await b(f(this.root,"active.json"),i)}catch(a){if((await this.active())?.operationId!==i.operationId)throw a}await this.checkpoint?.("committed");try{r&&r.stateRef!==i.stateRef&&await b(f(this.root,"previous.json"),r),await S(f(this.root,"transition.json")),await S(f(this.root,"fork.json")).catch(()=>{})}catch{}return await this.checkpoint?.("cleaned"),i})}async forkState(e){return x(this.root,async()=>{let n=await this.assertGeneration(e,!1),r=G(),o=f(this.root,"states",r);if(await I(f(this.root,"fork.json")))throw new s("gc_recovery_required","Unresolved fork.json; stop all owners and inspect the reserved state before retrying");await b(f(this.root,"fork.json"),{version:1,stateRef:r}),await O(o);let i=f(this.root,"states",n.stateRef);for(let a of await B(i)){if(!/^[a-f0-9]{64}\.json$/.test(a))throw new s("invalid_storage","Unexpected state file");if(!await w(f(i,a),H))throw new s("invalid_storage","Missing state file");await He(f(i,a),f(o,a))}return await this.checkpoint?.("forked"),r})}async collect(e){return x(this.root,async()=>{for(let l of["transition.json","fork.json"])if(await w(f(this.root,l),2*1024*1024))throw new s("gc_recovery_required",`GC refused: unresolved ${l}; stop all owners and inspect recovery references`);let n=await this.active(),r=T(await I(f(this.root,"previous.json")));if(!n&&await w(f(this.root,"active.json"),2*1024*1024))throw new s("gc_recovery_required","GC refused: null active pointer; restore activation metadata before cleanup");let o=[n,r].filter(l=>!!l),i=f(this.root,"states");await O(i);let a=await B(i),c=new Set(o.map(l=>l.stateRef));for(let l of a){if(!ce(l))throw new s("gc_recovery_required","GC refused: unexpected state directory; inspect states before cleanup");let u=f(i,l),h=await M(u);if(!h.isDirectory()||h.isSymbolicLink())throw new s("gc_recovery_required","GC refused: linked/non-directory state snapshot");for(let m of await B(u)){let g=await M(f(u,m));if(!/^[a-f0-9]{64}\.json$/.test(m)||!g.isFile()||g.isSymbolicLink()||g.nlink!==1)throw new s("gc_recovery_required","GC refused: unexpected snapshot content; original bytes preserved");if(!c.has(l)){let p=await A(f(u,m),H);if(!p)throw new s("gc_recovery_required","GC refused: missing snapshot record");if(Object.hasOwn(p,"committed")){let y=p;if(Object.keys(y).some(_=>!["requestId","inputHash","nextHash","committed"].includes(_))||y.committed!==!0||!/^[a-f0-9]{64}$/.test(y.inputHash)||!/^[a-f0-9]{64}$/.test(y.nextHash)||typeof y.requestId!="string")throw new s("gc_recovery_required",`GC refused: unresolved file intent in states/${l}; reconcile the workspace save before cleanup`)}else{if(Object.keys(p).some(y=>!["revision","schema","value","requestId","inputHash"].includes(y)))throw new s("gc_recovery_required","GC refused: unknown snapshot envelope; original bytes preserved");this.validateState(p)}}}}for(let l of c)if(!a.includes(l))throw new s("gc_recovery_required","GC refused: referenced snapshot is missing; restore recovery data first");let d=await e(o);for(let l of a)c.has(l)||await Te(f(i,l),{recursive:!0,force:!0});return d})}async assertGeneration(e,n=!0){let r=await this.active();if(!r||r.generation!==e||n&&!r.enabled)throw new s("stale_generation","Plugin generation is no longer active");return r}scopeKey(e){if(!e.scope||typeof e.scope.cwd!="string"||!e.scope.cwd||typeof e.scope.sessionId!="string"||!e.scope.sessionId||typeof e.scope.workspaceId!="string"||!e.scope.workspaceId)throw new s("invalid_scope","Missing authenticated plugin scope");return JSON.stringify([e.scope.workspaceId,e.scope.cwd,e.scope.sessionId])}statePath(e,n,r,o="session"){if(o!=="session"&&o!=="workspace")throw new s("invalid_input","Invalid state scope");let i=o==="workspace"?(this.scopeKey(n),JSON.stringify([n.scope.workspaceId,n.scope.cwd])):this.scopeKey(n);return f(this.root,"states",e.stateRef,`${v(i+":state:"+r)}.json`)}async call(e,n,r){if(!Number.isSafeInteger(e.generation)||!/^[\w-]{1,160}$/.test(e.requestId))throw new s("invalid_lease","Invalid invocation lease");this.scopeKey(e);let o=Le(r);return x(this.root,async()=>{let i=await this.assertGeneration(e.generation);switch(n){case"state.read":{let a=await A(this.statePath(i,e,ae(o.key),o.scope),H);return a?(this.validateState(a),{revision:a.revision,schema:a.schema,value:a.value}):null}case"state.compareAndSwap":{let a=this.statePath(i,e,ae(o.key),o.scope);if(!Number.isSafeInteger(o.expectedRevision)||o.expectedRevision<0||o.schema!==i.schema||!Object.hasOwn(o,"value"))throw new s("invalid_input","Invalid state revision or schema");if(JSON.stringify(o.value)===void 0)throw new s("invalid_input","State value must be JSON serializable");let c=JSON.stringify(o);if(Buffer.byteLength(c)>H)throw new s("state_too_large","Plugin state exceeds limit");let d=await A(a,H);d&&this.validateState(d);let l=v(c);if(d?.requestId===e.requestId&&d.inputHash===l)return{revision:d.revision,schema:d.schema,value:d.value};if((d?.revision??0)!==o.expectedRevision)throw new s("revision_conflict","Plugin state changed concurrently");let u={revision:o.expectedRevision+1,schema:i.schema,value:o.value,requestId:e.requestId,inputHash:l};return await b(a,u),{revision:u.revision,schema:u.schema,value:u.value}}case"workspace.read":{let a=this.rule(o.path),{target:c}=await this.fileTarget(e.scope.cwd,o.path),d=o.maxBytes===void 0?a.maxBytes:o.maxBytes;if(!Number.isSafeInteger(d)||d<=0||d>a.maxBytes)throw new s("invalid_input","Invalid workspace read limit");if(o.encoding!==void 0&&o.encoding!==(a.binary?"base64":"utf-8"))throw new s("invalid_input","Encoding does not match the reviewed file rule");let l=await w(c,d);return l?a.binary?{base64:l.toString("base64"),bytes:l.length,hash:v(l)}:{text:new TextDecoder("utf-8",{fatal:!0}).decode(l),hash:v(l)}:null}case"workspace.commit":return this.commitFile(i,e,o);case"legacy.read":return this.legacy?this.legacy(e):null;default:throw new s("method_denied","Unknown host broker method")}})}validateState(e){if(!Number.isSafeInteger(e.revision)||e.revision<1||!Number.isSafeInteger(e.schema)||e.schema<1||!Object.hasOwn(e,"value")||typeof e.requestId!="string"||!/^[a-f0-9]{64}$/.test(e.inputHash))throw new s("invalid_storage","Invalid plugin state; original bytes preserved")}async fileTarget(e,n,r=!1){let o=this.rule(n);if(typeof n!="string"||n.length>4096||n.includes("\\")||n.includes("\0")||oe(n)||$e.isAbsolute(n))throw new s("invalid_path",`Use a workspace-relative ${o.extension} path`);let i=await ie(e),a=qe(i,n),c=se(i,a);if(!c||c===".."||c.startsWith(`..${z}`)||oe(c))throw new s("invalid_path","Workspace path escapes root");let d=i,l=c.split(z);for(let h=0;h<l.length;h++){d=f(d,l[h]);let m;try{m=await M(d)}catch(g){if(!$(g))throw g;if(h<l.length-1){if(!r||!o.createDirectory||se(i,d)!==o.createDirectory)throw new s("invalid_path","Workspace directory does not exist");try{await Ae(d,{mode:448})}catch(p){if(p.code!=="EEXIST")throw p}m=await M(d)}}if(m&&(m.isSymbolicLink()||(h<l.length-1?!m.isDirectory():!m.isFile()||m.nlink!==1)))throw new s("invalid_path","Workspace path contains a link or non-regular file")}let u=await ie(De(a));if(u!==i&&!u.startsWith(i+z))throw new s("invalid_path","Workspace directory changed");return{target:a,parent:u}}async commitFile(e,n,r){let o=this.rule(r.path),i=o.binary?typeof r.base64=="string"&&r.text===void 0&&/^[A-Za-z0-9+/]*={0,2}$/.test(r.base64)?Buffer.from(r.base64,"base64"):null:typeof r.text=="string"&&r.base64===void 0?Buffer.from(r.text):null;if(!i||i.length>o.maxBytes||!(r.expectedHash===null||typeof r.expectedHash=="string"&&/^[a-f0-9]{64}$/.test(r.expectedHash)))throw new s("invalid_input","Invalid file content or expected hash");let{target:a,parent:c}=await this.fileTarget(n.scope.cwd,r.path,!0),d=f(this.root,"states",e.stateRef,`${v(this.scopeKey(n)+":file:"+n.requestId+":"+String(r.path))}.json`),l=v(JSON.stringify(r)),u=v(i),h=await A(d);if(h&&(h.requestId!==n.requestId||h.inputHash!==l||h.nextHash!==u))throw new s("duplicate_request","Request ID was reused with different content");let m;try{m=await ne(`${a}.lock`,"wx",384)}catch(p){throw p.code==="EEXIST"?new s("file_busy","Workspace file is locked; original file preserved"):p}let g;try{await m.writeFile(JSON.stringify({pid:process.pid,requestId:n.requestId}));let p=await w(a,o.maxBytes),y=p?v(p):null;if(h&&y===u)return{hash:u};if(h?.committed||y!==r.expectedHash)throw new s("file_conflict","Workspace file already exists or changed externally");await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!1}),g=f(c,`.plugin-${G()}.tmp`);let _=await ne(g,"wx",384);try{await _.writeFile(i),await _.sync()}finally{await _.close()}if((await this.fileTarget(n.scope.cwd,r.path)).parent!==c)throw new s("file_conflict","Workspace directory changed during save");let K=await w(a,o.maxBytes);if((K?v(K):null)!==r.expectedHash)throw new s("file_conflict","Workspace file changed during save");if(await this.assertGeneration(n.generation),r.expectedHash===null){try{await je(g,a)}catch(V){throw V.code==="EEXIST"?new s("file_conflict","Workspace file was created concurrently"):V}await S(g),g=void 0}else await Ne(g,a),g=void 0;return await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!0}),{hash:u}}finally{g&&await S(g).catch(()=>{}),await m.close(),await S(`${a}.lock`)}}};var W="ALL_HOSTS_AND_PLUGIN_WORKERS_STOPPED_AND_BACKUP_VERIFIED";async function j(t){let e=[];async function n(r,o=""){let i=await le(r);if(!i.isDirectory()||i.isSymbolicLink())throw new s("invalid_storage","Recovery refuses linked/non-directory storage");for(let a of(await Fe(r)).sort()){let c=k(r,a),d=o+a,l=await le(c);if(l.isSymbolicLink())throw new s("invalid_storage","Recovery refuses links");if(l.isDirectory())await n(c,d+"/");else{if(e.length>=1e4)throw new s("invalid_storage","Recovery inspection budget exceeded");let u=await w(c,192*1024*1024);if(!u)throw new s("invalid_storage","Recovery input disappeared");e.push({path:d,bytes:u.length,sha256:v(u)})}}}return await n(t),{fingerprint:v(JSON.stringify(e)),files:e,warning:"Offline only: externally stop/fence ALL hosts and plugin workers, back up storage and workspace files. Never infer stopped ownership from PID alone."}}async function fe(t,e,n,r){let o=new D(t,e),i=await j(o.root);if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");if(i.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");return o.recover()}async function ue(t,e,n,r){let o=new D(t,e),i=o.root;if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let a=await j(i);if(a.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");if(await w(k(i,"transition.json"),2*1024*1024))throw new s("gc_recovery_required","Reconcile transition.json using broker.recover before resolving a fork");let c=await I(k(i,"fork.json")),d=await o.active(),l=await I(k(i,"previous.json"));if(!c||c.version!==1||!/^[a-f0-9-]{36}$/.test(c.stateRef)||Object.keys(c).some(h=>!["version","stateRef"].includes(h))||!d||l&&typeof l.stateRef!="string"||[d?.stateRef,l?.stateRef].includes(c.stateRef))throw new s("gc_recovery_required","Fork is unknown or referenced by active/previous; original bytes preserved");let u=`recovered-${n}-fork.json`;if(a.files.some(h=>h.path===u))throw new s("recovery_changed","Recovery evidence already exists");return await de(k(i,"fork.json"),k(i,u)),{recovered:"fork.json",stateRef:c.stateRef,fingerprint:n}}async function pe(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=await j(t);if(r.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing recovered, inspect again");let o=[];for(let i of r.files.filter(a=>["runtime.lock","transaction.lock"].includes(a.path))){let a=await w(k(t,i.path),2097152);a&&!C(a)&&o.push(i)}for(let i of o){let a=`recovered-${e}-${i.path}.json`;if(r.files.some(c=>c.path===a))throw new s("recovery_changed","Recovery evidence already exists")}for(let i of o)await de(k(t,i.path),k(t,`recovered-${e}-${i.path}.json`));return await b(k(t,`recovery-${e}.json`),{version:1,fingerprint:e,locks:o,confirmation:n,recoveredAt:new Date().toISOString()}),{recovered:o.map(i=>i.path),fingerprint:e}}async function he(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=F(t),o=await j(r);if(o.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing settled, inspect again");let i=o.files.find(a=>a.path==="intent.json");if(!i)throw new s("invalid_input","No host pair journal to settle");return x(r,async()=>{let a=await w(k(r,"intent.json"),2097152);if(!a||v(a)!==i.sha256)throw new s("recovery_changed","Host pair journal changed since inspection; nothing settled, inspect again");let c=await ee(t);if(c?.phase!=="required-action")throw new s("invalid_input",`Only a required-action journal can be settled offline (found ${c?.phase??"unreadable journal, now quarantined"})`);let d=k(r,"history",`${c.id}-settled-${e}.json`);if(await w(d,2*1024*1024))throw new s("recovery_changed","Recovery evidence already exists");return await Ce(k(r,"history"),{recursive:!0,mode:448}),await b(d,c),await te(t,{...c,phase:"reconciled",message:`Settled offline by operator; current host and plugin data retained. Was: ${c.message??"no message"}`}),await b(k(r,`recovery-${e}.json`),{version:1,fingerprint:e,settled:c.id,confirmation:n,recoveredAt:new Date().toISOString()}),{settled:c.id,version:c.version,fingerprint:e}})}var[P,ge,R,E,q,...We]=process.argv.slice(2),Je=ge&&!We.length&&(P==="inspect"&&!R&&!E&&!q||["recover-locks","settle-pair"].includes(P??"")&&R&&E&&!q||["recover-fork","reconcile-transition"].includes(P??"")&&R&&E&&q);if(!Je)console.error(`Offline only. Usage: node --experimental-strip-types scripts/hosted-stopped-recovery.ts
1
+ (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="347a506f-f3a4-42b2-90fd-eb15e27a1464",t._sentryDebugIdIdentifier="sentry-dbid-347a506f-f3a4-42b2-90fd-eb15e27a1464")}catch{}})();import{resolve as Me}from"node:path";import{lstat as le,mkdir as Ce,readdir as Fe,rename as de}from"node:fs/promises";import{join as k}from"node:path";import{createHash as me}from"node:crypto";var s=class extends Error{code;status;reason;constructor(e,n,r={}){super(n),this.name="HostedPluginError",this.code=e,this.status=r.status,this.reason=r.reason}};var $=t=>t.code==="ENOENT";var rt={files:4096,total:128*1024*1024,js:16*1024*1024,css:4*1024*1024,font:8*1024*1024,wasm:16*1024*1024,other:2*1024*1024};var v=t=>me("sha256").update(t).digest("hex");import{constants as J}from"node:fs";import{DatabaseSync as ye}from"node:sqlite";import{lstat as Y,mkdir as ve,open as N,rename as be,unlink as Z}from"node:fs/promises";import{dirname as ke,join as X,resolve as Ie}from"node:path";import{randomUUID as _e}from"node:crypto";import{setTimeout as xe}from"node:timers/promises";async function O(t){await ve(t,{recursive:!0,mode:448});let e=await Y(t);if(!e.isDirectory()||e.isSymbolicLink())throw new s("invalid_storage","Plugin storage must be a real directory")}async function w(t,e){let n;try{n=await N(t,J.O_RDONLY|J.O_NONBLOCK|(J.O_NOFOLLOW??0))}catch(r){if($(r))return null;throw r}try{let r=await n.stat();if(!r.isFile()||r.nlink>1||r.size>e)throw new s("invalid_storage","Invalid storage record size or type");let o=Buffer.alloc(Math.min(r.size+1,e+1)),i=0;for(;i<o.length;){let a=await n.read(o,i,o.length-i,i);if(!a.bytesRead)break;i+=a.bytesRead}if(i>e||i!==r.size)throw new s("invalid_storage","Storage record changed during read");return o.subarray(0,i)}finally{await n.close()}}async function A(t,e=2*1024*1024){let n=await w(t,e);if(!n)return null;try{return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n))}catch{throw new s("invalid_storage","Invalid JSON storage record; original bytes preserved")}}async function I(t){let e=await w(t,2097152);if(e===null)return null;let n;try{n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e))}catch{throw new s("gc_recovery_required",`Invalid journal ${t}; stop all owners and inspect original bytes`)}if(!n||typeof n!="object"||Array.isArray(n))throw new s("gc_recovery_required",`Invalid journal ${t}; original bytes preserved`);return n}async function b(t,e){let n=`${t}.${_e()}.tmp`,r=await N(n,"wx",384);try{try{await r.writeFile(JSON.stringify(e)),await r.sync()}finally{await r.close()}await be(n,t);let o;try{o=await N(ke(t),"r"),await o.sync()}catch(i){if(!["EINVAL","EPERM","EACCES","EISDIR","ENOTSUP","EBADF"].includes(i.code??""))throw i}finally{await o?.close()}}finally{await Z(n).catch(()=>{})}}var Q='{"version":2,"mechanism":"sqlite-exclusive"}',C=t=>t.toString("utf8")===Q,L=new Set;async function Se(t,e,n=0){await O(t);let r=X(t,`${e}.lock`),o=X(t,`${e}.ownership.sqlite`),i=e==="runtime"?"runtime_owned":"storage_busy",a=()=>new s(i,"Another host owns this plugin storage or a legacy ownership lock remains; stop all owners and verify a backup before offline recovery"),c;try{c=await N(o,"wx",384)}catch(p){if(p.code!=="EEXIST")throw p}finally{await c?.close()}let d=await Y(o);if(!d.isFile()||d.isSymbolicLink()||d.nlink!==1||d.size>1024*1024)throw new s("invalid_storage","Ownership database must be a small, single-link regular file");let l=new ye(o,{allowExtension:!1}),u=Ie(o),h=Date.now()+n,m=!1;try{for(;;){if(!L.has(u))try{l.exec("BEGIN EXCLUSIVE"),L.add(u),m=!0;break}catch(y){if(y.errcode!==5)throw y}if(Date.now()>=h)throw new s(i,"Another host owns this plugin storage; wait for it to stop before retrying");await xe(10)}let p=await w(r,4096);if(p===null){let y;try{y=await N(r,"wx",384),await y.writeFile(Q),await y.sync()}catch(_){if(_.code!=="EEXIST")throw _}finally{await y?.close()}p=await w(r,4096)}if(p===null||!C(p))throw a()}catch(p){throw l.close(),m&&L.delete(u),p}let g=!1;return async()=>{if(g)return;let p=await w(r,4096);if(p===null||!C(p))throw new s("invalid_storage","Ownership fence changed while held; preserve custody and inspect storage");await Z(r),l.close(),L.delete(u),g=!0}}async function x(t,e,n=2e3){let r=await Se(t,"transaction",n);try{return await e()}finally{await r()}}import{readdir as pt,realpath as ht,rename as Pe,stat as Re}from"node:fs/promises";import{join as U}from"node:path";var F=t=>U(t,"host-pair");var yt=10*6e4;async function Ee(t){await Pe(t,`${t}.corrupt-${Date.now()}`).catch(e=>{if(e.code!=="ENOENT")throw e})}var Oe=t=>t.schema===1&&/^[a-f0-9-]{36}$/.test(t.id)&&typeof t.version=="string"&&typeof t.packageRoot=="string"&&/^[a-f0-9]{64}$/.test(t.hostDigest)&&/^[a-f0-9]{64}$/.test(t.fingerprint)&&Array.isArray(t.selections)&&!t.selections.some(e=>!e||typeof e.id!="string"||typeof e.version!="string"||!/^[a-f0-9]{64}$/.test(e.digest)||!Object.hasOwn(e,"before"))&&!(t.selection&&(typeof t.selection.path!="string"||!/^[a-f0-9]{64}$/.test(t.selection.digest)))&&["prepared","selecting","selected","restart-requested","reconciled","cancelled","required-action"].includes(t.phase);async function ee(t){let e=U(F(t),"intent.json"),n,r=!0;try{n=await I(e)}catch{n=null,r=!1}if(!r||n&&!Oe(n))return await Ee(e),null;if(n){let{lifecyclePhase:o,...i}=n,a=typeof i.updatedAt=="string"&&!Number.isNaN(Date.parse(i.updatedAt))?i.updatedAt:await Re(e).then(c=>c.mtime.toISOString(),()=>new Date(0).toISOString());n={...i,updatedAt:a,phase:i.phase==="selected"&&o==="restart-requested"?"restart-requested":i.phase==="reconciled"&&o==="cancelled"?"cancelled":i.phase==="reconciled"&&o==="required-action"?"required-action":i.phase}}return n}async function te(t,e){let{lifecyclePhase:n,...r}={...e,selections:[],updatedAt:new Date().toISOString()},o=r.phase==="cancelled"?{...r,phase:"reconciled",lifecyclePhase:"cancelled"}:r.phase==="required-action"?{...r,phase:"reconciled",lifecyclePhase:"required-action"}:r.phase==="restart-requested"?{...r,phase:"selected",lifecyclePhase:"restart-requested"}:r;await b(U(F(t),"intent.json"),o)}import{lstat as M,mkdir as Ae,open as ne,realpath as ie,readdir as B,link as je,rename as Ne,unlink as S,copyFile as He,rm as Te}from"node:fs/promises";import{dirname as De,isAbsolute as oe,join as f,relative as se,resolve as qe,sep as z,win32 as $e}from"node:path";import{randomUUID as G}from"node:crypto";var kt=64*1024*1024,re=Object.freeze([Object.freeze({extension:".excalidraw",binary:!1,maxBytes:512*1024,createDirectory:"diagrams"})]);var H=192*1024*1024,At=512*1024,ce=t=>typeof t=="string"&&/^[a-f0-9-]{36}$/.test(t);function Le(t){if(!t||typeof t!="object"||Array.isArray(t))throw new s("invalid_input","Expected object input");return t}function ae(t){if(typeof t!="string"||!/^[\w.-]{1,160}$/.test(t)||t==="."||t==="..")throw new s("invalid_input","Invalid state key");return t}function T(t){if(t&&(!ce(t.stateRef)||typeof t.version!="string"||!Number.isSafeInteger(t.generation)||t.generation<1||!Number.isSafeInteger(t.schema)||t.schema<1||typeof t.enabled!="boolean"||typeof t.operationId!="string"))throw new s("invalid_storage","Invalid active plugin record");return t}var D=class{root;pluginId;legacy;checkpoint;files;constructor(e,n,r,o,i=re){this.root=f(e,v(n)),this.pluginId=n,this.legacy=r,this.checkpoint=o,this.files=i}rule(e){let n=typeof e=="string"?this.files.find(r=>e.toLowerCase().endsWith(r.extension)):void 0;if(!n)throw new s("invalid_path",`Use a workspace-relative ${this.files.map(r=>r.extension).join("/")} path`);return n}active(){return A(f(this.root,"active.json")).then(T)}async recover(){return x(this.root,async()=>{let e=await this.active(),n=await I(f(this.root,"transition.json"));if(!n)return{active:e,recovered:"none"};if(!n.next||!Object.hasOwn(n,"before")||Object.keys(n).some(a=>!["version","before","next"].includes(a))||Object.hasOwn(n,"version")&&n.version!==1)throw new s("invalid_storage","Invalid activation journal; stop all owners and inspect transition.json");T(n.next),T(n.before);let r=e?.operationId===n.next.operationId?"committed":"not_committed";if(!((a,c)=>a===null||c===null?a===c:["version","generation","stateRef","schema","enabled","operationId"].every(d=>a[d]===c[d]))(e,r==="committed"?n.next:n.before))throw new s("gc_recovery_required","Activation journal does not match the active pointer; original bytes preserved");let i=n.before;if(r==="committed"&&i&&i.stateRef!==e.stateRef&&await b(f(this.root,"previous.json"),i),r==="committed"){let a=await I(f(this.root,"fork.json"));a?.version===1&&a.stateRef===e.stateRef&&Object.keys(a).every(c=>["version","stateRef"].includes(c))&&await S(f(this.root,"fork.json"))}return await S(f(this.root,"transition.json")),{active:e,recovered:r}})}async activate(e,n){return x(this.root,async()=>{let r=await this.active();if((r?.generation??0)!==e)throw new s("stale_generation","Plugin activation changed concurrently");let o=await I(f(this.root,"fork.json"));if(o&&(o.version!==1||o.stateRef!==n.stateRef||Object.keys(o).some(a=>!["version","stateRef"].includes(a))))throw new s("gc_recovery_required","Activation refused: unresolved fork.json belongs to another target; stop all owners and inspect it");let i=T({...n,generation:e+1,operationId:G()});await O(f(this.root,"states")),await O(f(this.root,"states",i.stateRef)),await b(f(this.root,"transition.json"),{version:1,before:r,next:i}),await this.checkpoint?.("prepared");try{await b(f(this.root,"active.json"),i)}catch(a){if((await this.active())?.operationId!==i.operationId)throw a}await this.checkpoint?.("committed");try{r&&r.stateRef!==i.stateRef&&await b(f(this.root,"previous.json"),r),await S(f(this.root,"transition.json")),await S(f(this.root,"fork.json")).catch(()=>{})}catch{}return await this.checkpoint?.("cleaned"),i})}async forkState(e){return x(this.root,async()=>{let n=await this.assertGeneration(e,!1),r=G(),o=f(this.root,"states",r);if(await I(f(this.root,"fork.json")))throw new s("gc_recovery_required","Unresolved fork.json; stop all owners and inspect the reserved state before retrying");await b(f(this.root,"fork.json"),{version:1,stateRef:r}),await O(o);let i=f(this.root,"states",n.stateRef);for(let a of await B(i)){if(!/^[a-f0-9]{64}\.json$/.test(a))throw new s("invalid_storage","Unexpected state file");if(!await w(f(i,a),H))throw new s("invalid_storage","Missing state file");await He(f(i,a),f(o,a))}return await this.checkpoint?.("forked"),r})}async collect(e){return x(this.root,async()=>{for(let l of["transition.json","fork.json"])if(await w(f(this.root,l),2*1024*1024))throw new s("gc_recovery_required",`GC refused: unresolved ${l}; stop all owners and inspect recovery references`);let n=await this.active(),r=T(await I(f(this.root,"previous.json")));if(!n&&await w(f(this.root,"active.json"),2*1024*1024))throw new s("gc_recovery_required","GC refused: null active pointer; restore activation metadata before cleanup");let o=[n,r].filter(l=>!!l),i=f(this.root,"states");await O(i);let a=await B(i),c=new Set(o.map(l=>l.stateRef));for(let l of a){if(!ce(l))throw new s("gc_recovery_required","GC refused: unexpected state directory; inspect states before cleanup");let u=f(i,l),h=await M(u);if(!h.isDirectory()||h.isSymbolicLink())throw new s("gc_recovery_required","GC refused: linked/non-directory state snapshot");for(let m of await B(u)){let g=await M(f(u,m));if(!/^[a-f0-9]{64}\.json$/.test(m)||!g.isFile()||g.isSymbolicLink()||g.nlink!==1)throw new s("gc_recovery_required","GC refused: unexpected snapshot content; original bytes preserved");if(!c.has(l)){let p=await A(f(u,m),H);if(!p)throw new s("gc_recovery_required","GC refused: missing snapshot record");if(Object.hasOwn(p,"committed")){let y=p;if(Object.keys(y).some(_=>!["requestId","inputHash","nextHash","committed"].includes(_))||y.committed!==!0||!/^[a-f0-9]{64}$/.test(y.inputHash)||!/^[a-f0-9]{64}$/.test(y.nextHash)||typeof y.requestId!="string")throw new s("gc_recovery_required",`GC refused: unresolved file intent in states/${l}; reconcile the workspace save before cleanup`)}else{if(Object.keys(p).some(y=>!["revision","schema","value","requestId","inputHash"].includes(y)))throw new s("gc_recovery_required","GC refused: unknown snapshot envelope; original bytes preserved");this.validateState(p)}}}}for(let l of c)if(!a.includes(l))throw new s("gc_recovery_required","GC refused: referenced snapshot is missing; restore recovery data first");let d=await e(o);for(let l of a)c.has(l)||await Te(f(i,l),{recursive:!0,force:!0});return d})}async assertGeneration(e,n=!0){let r=await this.active();if(!r||r.generation!==e||n&&!r.enabled)throw new s("stale_generation","Plugin generation is no longer active");return r}scopeKey(e){if(!e.scope||typeof e.scope.cwd!="string"||!e.scope.cwd||typeof e.scope.sessionId!="string"||!e.scope.sessionId||typeof e.scope.workspaceId!="string"||!e.scope.workspaceId)throw new s("invalid_scope","Missing authenticated plugin scope");return JSON.stringify([e.scope.workspaceId,e.scope.cwd,e.scope.sessionId])}statePath(e,n,r,o="session"){if(o!=="session"&&o!=="workspace")throw new s("invalid_input","Invalid state scope");let i=o==="workspace"?(this.scopeKey(n),JSON.stringify([n.scope.workspaceId,n.scope.cwd])):this.scopeKey(n);return f(this.root,"states",e.stateRef,`${v(i+":state:"+r)}.json`)}async call(e,n,r){if(!Number.isSafeInteger(e.generation)||!/^[\w-]{1,160}$/.test(e.requestId))throw new s("invalid_lease","Invalid invocation lease");this.scopeKey(e);let o=Le(r);return x(this.root,async()=>{let i=await this.assertGeneration(e.generation);switch(n){case"state.read":{let a=await A(this.statePath(i,e,ae(o.key),o.scope),H);return a?(this.validateState(a),{revision:a.revision,schema:a.schema,value:a.value}):null}case"state.compareAndSwap":{let a=this.statePath(i,e,ae(o.key),o.scope);if(!Number.isSafeInteger(o.expectedRevision)||o.expectedRevision<0||o.schema!==i.schema||!Object.hasOwn(o,"value"))throw new s("invalid_input","Invalid state revision or schema");if(JSON.stringify(o.value)===void 0)throw new s("invalid_input","State value must be JSON serializable");let c=JSON.stringify(o);if(Buffer.byteLength(c)>H)throw new s("state_too_large","Plugin state exceeds limit");let d=await A(a,H);d&&this.validateState(d);let l=v(c);if(d?.requestId===e.requestId&&d.inputHash===l)return{revision:d.revision,schema:d.schema,value:d.value};if((d?.revision??0)!==o.expectedRevision)throw new s("revision_conflict","Plugin state changed concurrently");let u={revision:o.expectedRevision+1,schema:i.schema,value:o.value,requestId:e.requestId,inputHash:l};return await b(a,u),{revision:u.revision,schema:u.schema,value:u.value}}case"workspace.read":{let a=this.rule(o.path),{target:c}=await this.fileTarget(e.scope.cwd,o.path),d=o.maxBytes===void 0?a.maxBytes:o.maxBytes;if(!Number.isSafeInteger(d)||d<=0||d>a.maxBytes)throw new s("invalid_input","Invalid workspace read limit");if(o.encoding!==void 0&&o.encoding!==(a.binary?"base64":"utf-8"))throw new s("invalid_input","Encoding does not match the reviewed file rule");let l=await w(c,d);return l?a.binary?{base64:l.toString("base64"),bytes:l.length,hash:v(l)}:{text:new TextDecoder("utf-8",{fatal:!0}).decode(l),hash:v(l)}:null}case"workspace.commit":return this.commitFile(i,e,o);case"legacy.read":return this.legacy?this.legacy(e):null;default:throw new s("method_denied","Unknown host broker method")}})}validateState(e){if(!Number.isSafeInteger(e.revision)||e.revision<1||!Number.isSafeInteger(e.schema)||e.schema<1||!Object.hasOwn(e,"value")||typeof e.requestId!="string"||!/^[a-f0-9]{64}$/.test(e.inputHash))throw new s("invalid_storage","Invalid plugin state; original bytes preserved")}async fileTarget(e,n,r=!1){let o=this.rule(n);if(typeof n!="string"||n.length>4096||n.includes("\\")||n.includes("\0")||oe(n)||$e.isAbsolute(n))throw new s("invalid_path",`Use a workspace-relative ${o.extension} path`);let i=await ie(e),a=qe(i,n),c=se(i,a);if(!c||c===".."||c.startsWith(`..${z}`)||oe(c))throw new s("invalid_path","Workspace path escapes root");let d=i,l=c.split(z);for(let h=0;h<l.length;h++){d=f(d,l[h]);let m;try{m=await M(d)}catch(g){if(!$(g))throw g;if(h<l.length-1){if(!r||!o.createDirectory||se(i,d)!==o.createDirectory)throw new s("invalid_path","Workspace directory does not exist");try{await Ae(d,{mode:448})}catch(p){if(p.code!=="EEXIST")throw p}m=await M(d)}}if(m&&(m.isSymbolicLink()||(h<l.length-1?!m.isDirectory():!m.isFile()||m.nlink!==1)))throw new s("invalid_path","Workspace path contains a link or non-regular file")}let u=await ie(De(a));if(u!==i&&!u.startsWith(i+z))throw new s("invalid_path","Workspace directory changed");return{target:a,parent:u}}async commitFile(e,n,r){let o=this.rule(r.path),i=o.binary?typeof r.base64=="string"&&r.text===void 0&&/^[A-Za-z0-9+/]*={0,2}$/.test(r.base64)?Buffer.from(r.base64,"base64"):null:typeof r.text=="string"&&r.base64===void 0?Buffer.from(r.text):null;if(!i||i.length>o.maxBytes||!(r.expectedHash===null||typeof r.expectedHash=="string"&&/^[a-f0-9]{64}$/.test(r.expectedHash)))throw new s("invalid_input","Invalid file content or expected hash");let{target:a,parent:c}=await this.fileTarget(n.scope.cwd,r.path,!0),d=f(this.root,"states",e.stateRef,`${v(this.scopeKey(n)+":file:"+n.requestId+":"+String(r.path))}.json`),l=v(JSON.stringify(r)),u=v(i),h=await A(d);if(h&&(h.requestId!==n.requestId||h.inputHash!==l||h.nextHash!==u))throw new s("duplicate_request","Request ID was reused with different content");let m;try{m=await ne(`${a}.lock`,"wx",384)}catch(p){throw p.code==="EEXIST"?new s("file_busy","Workspace file is locked; original file preserved"):p}let g;try{await m.writeFile(JSON.stringify({pid:process.pid,requestId:n.requestId}));let p=await w(a,o.maxBytes),y=p?v(p):null;if(h&&y===u)return{hash:u};if(h?.committed||y!==r.expectedHash)throw new s("file_conflict","Workspace file already exists or changed externally");await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!1}),g=f(c,`.plugin-${G()}.tmp`);let _=await ne(g,"wx",384);try{await _.writeFile(i),await _.sync()}finally{await _.close()}if((await this.fileTarget(n.scope.cwd,r.path)).parent!==c)throw new s("file_conflict","Workspace directory changed during save");let K=await w(a,o.maxBytes);if((K?v(K):null)!==r.expectedHash)throw new s("file_conflict","Workspace file changed during save");if(await this.assertGeneration(n.generation),r.expectedHash===null){try{await je(g,a)}catch(V){throw V.code==="EEXIST"?new s("file_conflict","Workspace file was created concurrently"):V}await S(g),g=void 0}else await Ne(g,a),g=void 0;return await b(d,{requestId:n.requestId,inputHash:l,nextHash:u,committed:!0}),{hash:u}}finally{g&&await S(g).catch(()=>{}),await m.close(),await S(`${a}.lock`)}}};var W="ALL_HOSTS_AND_PLUGIN_WORKERS_STOPPED_AND_BACKUP_VERIFIED";async function j(t){let e=[];async function n(r,o=""){let i=await le(r);if(!i.isDirectory()||i.isSymbolicLink())throw new s("invalid_storage","Recovery refuses linked/non-directory storage");for(let a of(await Fe(r)).sort()){let c=k(r,a),d=o+a,l=await le(c);if(l.isSymbolicLink())throw new s("invalid_storage","Recovery refuses links");if(l.isDirectory())await n(c,d+"/");else{if(e.length>=1e4)throw new s("invalid_storage","Recovery inspection budget exceeded");let u=await w(c,192*1024*1024);if(!u)throw new s("invalid_storage","Recovery input disappeared");e.push({path:d,bytes:u.length,sha256:v(u)})}}}return await n(t),{fingerprint:v(JSON.stringify(e)),files:e,warning:"Offline only: externally stop/fence ALL hosts and plugin workers, back up storage and workspace files. Never infer stopped ownership from PID alone."}}async function fe(t,e,n,r){let o=new D(t,e),i=await j(o.root);if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");if(i.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");return o.recover()}async function ue(t,e,n,r){let o=new D(t,e),i=o.root;if(r!==W)throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let a=await j(i);if(a.fingerprint!==n)throw new s("recovery_changed","Storage changed since inspection");if(await w(k(i,"transition.json"),2*1024*1024))throw new s("gc_recovery_required","Reconcile transition.json using broker.recover before resolving a fork");let c=await I(k(i,"fork.json")),d=await o.active(),l=await I(k(i,"previous.json"));if(!c||c.version!==1||!/^[a-f0-9-]{36}$/.test(c.stateRef)||Object.keys(c).some(h=>!["version","stateRef"].includes(h))||!d||l&&typeof l.stateRef!="string"||[d?.stateRef,l?.stateRef].includes(c.stateRef))throw new s("gc_recovery_required","Fork is unknown or referenced by active/previous; original bytes preserved");let u=`recovered-${n}-fork.json`;if(a.files.some(h=>h.path===u))throw new s("recovery_changed","Recovery evidence already exists");return await de(k(i,"fork.json"),k(i,u)),{recovered:"fork.json",stateRef:c.stateRef,fingerprint:n}}async function pe(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=await j(t);if(r.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing recovered, inspect again");let o=[];for(let i of r.files.filter(a=>["runtime.lock","transaction.lock"].includes(a.path))){let a=await w(k(t,i.path),2097152);a&&!C(a)&&o.push(i)}for(let i of o){let a=`recovered-${e}-${i.path}.json`;if(r.files.some(c=>c.path===a))throw new s("recovery_changed","Recovery evidence already exists")}for(let i of o)await de(k(t,i.path),k(t,`recovered-${e}-${i.path}.json`));return await b(k(t,`recovery-${e}.json`),{version:1,fingerprint:e,locks:o,confirmation:n,recoveredAt:new Date().toISOString()}),{recovered:o.map(i=>i.path),fingerprint:e}}async function he(t,e,n){if(n!==W||!/^[a-f0-9]{64}$/.test(e))throw new s("confirmation_required","Explicit stopped-owner and verified-backup confirmation required");let r=F(t),o=await j(r);if(o.fingerprint!==e)throw new s("recovery_changed","Storage changed since inspection; nothing settled, inspect again");let i=o.files.find(a=>a.path==="intent.json");if(!i)throw new s("invalid_input","No host pair journal to settle");return x(r,async()=>{let a=await w(k(r,"intent.json"),2097152);if(!a||v(a)!==i.sha256)throw new s("recovery_changed","Host pair journal changed since inspection; nothing settled, inspect again");let c=await ee(t);if(c?.phase!=="required-action")throw new s("invalid_input",`Only a required-action journal can be settled offline (found ${c?.phase??"unreadable journal, now quarantined"})`);let d=k(r,"history",`${c.id}-settled-${e}.json`);if(await w(d,2*1024*1024))throw new s("recovery_changed","Recovery evidence already exists");return await Ce(k(r,"history"),{recursive:!0,mode:448}),await b(d,c),await te(t,{...c,phase:"reconciled",message:`Settled offline by operator; current host and plugin data retained. Was: ${c.message??"no message"}`}),await b(k(r,`recovery-${e}.json`),{version:1,fingerprint:e,settled:c.id,confirmation:n,recoveredAt:new Date().toISOString()}),{settled:c.id,version:c.version,fingerprint:e}})}var[P,ge,R,E,q,...We]=process.argv.slice(2),Je=ge&&!We.length&&(P==="inspect"&&!R&&!E&&!q||["recover-locks","settle-pair"].includes(P??"")&&R&&E&&!q||["recover-fork","reconcile-transition"].includes(P??"")&&R&&E&&q);if(!Je)console.error(`Offline only. Usage: node --experimental-strip-types scripts/hosted-stopped-recovery.ts
2
2
  inspect BROKER_ROOT | HOSTED_ROOT/host-pair
3
3
  recover-locks BROKER_ROOT FINGERPRINT CONFIRMATION
4
4
  reconcile-transition DATA_ROOT PLUGIN_ID FINGERPRINT CONFIRMATION
@@ -6,4 +6,4 @@
6
6
  settle-pair HOSTED_ROOT FINGERPRINT CONFIRMATION
7
7
  CONFIRMATION = ALL_HOSTS_AND_PLUGIN_WORKERS_STOPPED_AND_BACKUP_VERIFIED`),process.exitCode=2;else try{let t=Me(ge),e=P==="inspect"?await j(t):P==="recover-locks"?await pe(t,R,E):P==="settle-pair"?await he(t,R,E):P==="recover-fork"?await ue(t,R,E,q):await fe(t,R,E,q);console.log(JSON.stringify(e,null,2))}catch(t){console.error(t instanceof Error?t.message:"Recovery failed"),process.exitCode=1}var Jt=void 0;export{Jt as default};
8
8
 
9
- //# debugId=dd30f538-ba61-417c-bf07-9611a0ba133f
9
+ //# debugId=347a506f-f3a4-42b2-90fd-eb15e27a1464
@@ -1,3 +1,3 @@
1
- (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f17268aa-b77f-4afb-bd39-321e475a16fd",t._sentryDebugIdIdentifier="sentry-dbid-f17268aa-b77f-4afb-bd39-321e475a16fd")}catch{}})();import{AsyncLocalStorage as b}from"node:async_hooks";import{pathToFileURL as y}from"node:url";function c(t){let e=t&&typeof t=="object"?t:{};return{code:typeof e.code=="string"&&/^[\w.-]{1,80}$/.test(e.code)?e.code:"plugin_failed",message:t instanceof Error?t.message:"Plugin operation failed",...Number.isInteger(e.status)&&Number(e.status)>=400&&Number(e.status)<=599?{status:Number(e.status)}:{},...typeof e.reason=="string"&&/^[\w.-]{1,80}$/.test(e.reason)?{reason:e.reason}:{}}}var f=new b,s=new Map,v=0,n,a=t=>{process.connected&&process.send?.(t)};process.on("message",t=>{if(!t||typeof t!="object")return;let e=t;if(e.type==="broker-response"&&typeof e.id=="string"){let r=s.get(e.id);if(!r)return;if(s.delete(e.id),e.ok)r.resolve(e.value);else{let o=e.error;r.reject(Object.assign(new Error(o?.message??"Host broker rejected request"),{code:o?.code,status:o?.status,reason:o?.reason}))}return}if(e.type!=="request"||typeof e.id!="string"||typeof e.method!="string")return;let i=e.id;(async()=>{switch(e.method){case"initialize":{if(n)throw new Error("Already initialized");let r=e.input,o=await import(y(r.entry).href);if(typeof o.createRuntime!="function")throw new Error("Missing createRuntime export");return n=await o.createRuntime({pluginId:r.pluginId,version:r.version,generation:r.generation,broker:{call(p,g){let u=f.getStore();if(!u)return Promise.reject(new Error("Broker calls require an active invocation"));if(s.size>=64)return Promise.reject(new Error("Too many broker requests"));let d=`b${++v}`;return new Promise((m,w)=>{s.set(d,{resolve:m,reject:w}),a({type:"broker-request",id:d,invocationId:u.requestId,method:p,input:g})})}}}),{initialized:!0}}case"describe":if(!n)throw new Error("Not initialized");return n.describe();case"health":if(!n)throw new Error("Not initialized");return n.health();case"invoke":{if(!n)throw new Error("Not initialized");let r=e.input;return f.run(r,()=>n.invoke(r))}case"dispose":return await n?.dispose?.(),{disposed:!0};default:throw new Error("Unknown runtime operation")}})().then(r=>a({type:"response",id:i,ok:!0,value:r}),r=>a({type:"response",id:i,ok:!1,error:c(r)}))});process.on("disconnect",()=>{for(let t of s.values())t.reject(new Error("Host disconnected"));s.clear(),process.exitCode=1,Promise.resolve(n?.dispose?.()).finally(()=>process.exit(1))});var H=void 0;export{H as default};
1
+ (function(){try{var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="b6a027ab-5338-4cf8-8079-248cd19f5a36",t._sentryDebugIdIdentifier="sentry-dbid-b6a027ab-5338-4cf8-8079-248cd19f5a36")}catch{}})();import{AsyncLocalStorage as y}from"node:async_hooks";import{pathToFileURL as b}from"node:url";function c(t){let e=t&&typeof t=="object"?t:{};return{code:typeof e.code=="string"&&/^[\w.-]{1,80}$/.test(e.code)?e.code:"plugin_failed",message:t instanceof Error?t.message:"Plugin operation failed",...Number.isInteger(e.status)&&Number(e.status)>=400&&Number(e.status)<=599?{status:Number(e.status)}:{},...typeof e.reason=="string"&&/^[\w.-]{1,80}$/.test(e.reason)?{reason:e.reason}:{}}}var l=new y,s=new Map,v=0,n,a=t=>{process.connected&&process.send?.(t)};process.on("message",t=>{if(!t||typeof t!="object")return;let e=t;if(e.type==="broker-response"&&typeof e.id=="string"){let r=s.get(e.id);if(!r)return;if(s.delete(e.id),e.ok)r.resolve(e.value);else{let o=e.error;r.reject(Object.assign(new Error(o?.message??"Host broker rejected request"),{code:o?.code,status:o?.status,reason:o?.reason}))}return}if(e.type!=="request"||typeof e.id!="string"||typeof e.method!="string")return;let i=e.id;(async()=>{switch(e.method){case"initialize":{if(n)throw new Error("Already initialized");let r=e.input,o=await import(b(r.entry).href);if(typeof o.createRuntime!="function")throw new Error("Missing createRuntime export");return n=await o.createRuntime({pluginId:r.pluginId,version:r.version,generation:r.generation,broker:{call(f,g){let u=l.getStore();if(!u)return Promise.reject(new Error("Broker calls require an active invocation"));if(s.size>=64)return Promise.reject(new Error("Too many broker requests"));let d=`b${++v}`;return new Promise((m,w)=>{s.set(d,{resolve:m,reject:w}),a({type:"broker-request",id:d,invocationId:u.requestId,method:f,input:g})})}}}),{initialized:!0}}case"describe":if(!n)throw new Error("Not initialized");return n.describe();case"health":if(!n)throw new Error("Not initialized");return n.health();case"invoke":{if(!n)throw new Error("Not initialized");let r=e.input;return l.run(r,()=>n.invoke(r))}case"dispose":return await n?.dispose?.(),{disposed:!0};default:throw new Error("Unknown runtime operation")}})().then(r=>a({type:"response",id:i,ok:!0,value:r}),r=>a({type:"response",id:i,ok:!1,error:c(r)}))});process.on("disconnect",()=>{for(let t of s.values())t.reject(new Error("Host disconnected"));s.clear(),process.exitCode=1,Promise.resolve(n?.dispose?.()).finally(()=>process.exit(1))});var H=void 0;export{H as default};
2
2
 
3
- //# debugId=f17268aa-b77f-4afb-bd39-321e475a16fd
3
+ //# debugId=b6a027ab-5338-4cf8-8079-248cd19f5a36
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-webapp",
3
- "version": "0.1.56",
3
+ "version": "0.1.57-alpha.1",
4
4
  "type": "module",
5
5
  "piWebappDesktopProtocol": 1,
6
6
  "piWebappDataVersion": 1,
@@ -40,7 +40,7 @@
40
40
  "pi-webapp": "./bin/pi-webapp.mjs"
41
41
  },
42
42
  "pi": {
43
- "image": "https://cdn.jsdelivr.net/npm/pi-webapp@0.1.56/assets/cover-webapp.png",
43
+ "image": "https://cdn.jsdelivr.net/npm/pi-webapp@0.1.57-alpha.1/assets/cover-webapp.png",
44
44
  "extensions": [
45
45
  "./dist/extension.js"
46
46
  ]
@@ -112,7 +112,7 @@
112
112
  "@earendil-works/pi-coding-agent": "1.3.0"
113
113
  },
114
114
  "devDependencies": {
115
- "@biomejs/biome": "2.6.6",
115
+ "@biomejs/biome": "2.6.8",
116
116
  "@chengzhiyi/pi-web-protocol": "0.1.1",
117
117
  "@codemirror/commands": "6.11.1",
118
118
  "@codemirror/language": "6.13.1",
@@ -125,12 +125,12 @@
125
125
  "@lexical/history": "0.53.0",
126
126
  "@lexical/plain-text": "0.53.0",
127
127
  "@lezer/highlight": "1.2.5",
128
- "@playwright/test": "1.65.0",
129
- "@sentry/core": "11.11.0",
130
- "@sentry/esbuild-plugin": "11.11.0",
131
- "@sentry/node": "11.11.0",
132
- "@sentry/react": "11.11.0",
133
- "@sentry/vite-plugin": "11.11.0",
128
+ "@playwright/test": "1.65.1",
129
+ "@sentry/core": "11.15.0",
130
+ "@sentry/esbuild-plugin": "11.15.0",
131
+ "@sentry/node": "11.15.0",
132
+ "@sentry/react": "11.15.0",
133
+ "@sentry/vite-plugin": "11.15.0",
134
134
  "@shikijs/langs": "^4.3.1",
135
135
  "@types/katex": "^0.16.7",
136
136
  "@types/mdast": "^4.0.4",
@@ -142,7 +142,7 @@
142
142
  "anser": "^2.3.5",
143
143
  "clsx": "^2.1.1",
144
144
  "codemirror": "6.0.2",
145
- "electron": "44.10.2",
145
+ "electron": "44.11.5",
146
146
  "electron-builder": "26.18.0",
147
147
  "esbuild": "^0.28.2",
148
148
  "katex": "^0.19.1",
@@ -1408,7 +1408,7 @@
1408
1408
  ]
1409
1409
  },
1410
1410
  "../../src/host/client/telemetry-client.ts": {
1411
- "file": "assets/telemetry-client-xIu6sXGx.js",
1411
+ "file": "assets/telemetry-client-BXj9P2wd.js",
1412
1412
  "name": "telemetry-client",
1413
1413
  "src": "../../src/host/client/telemetry-client.ts",
1414
1414
  "isDynamicEntry": true,
@@ -1,8 +1,8 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-VS_Rt2sQ.js","assets/rolldown-runtime-CgmABjMJ.js","assets/react-CLFE7TFE.js","assets/icons-D8yiYkWB.js","assets/clsx-DQAHfk8w.js","assets/WorkspacePanel.module-V6gI-nG1.js","assets/WorkspacePanel.css","assets/app.css"])))=>i.map(i=>d[i]);
2
- (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`3d604df2-7ba7-479f-9c9e-62b0a1688464`,e._sentryDebugIdIdentifier=`sentry-dbid-3d604df2-7ba7-479f-9c9e-62b0a1688464`)}catch{}})(),(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=new Set([`bash`,`powershell`,`read`,`write`,`edit`,`grep`,`find`,`ls`]),t=new Set([`cancelled`,`blocked`,`validation`,`not_found`,`permission`,`timeout`,`process_exit`,`unknown`]),n={userInfo:!1,cookies:!1,httpHeaders:!1,httpBodies:[],urlQueryParams:!1,genAI:{inputs:!1,outputs:!1},graphQL:{document:!1,variables:!1},databaseQueryData:!1,queues:!1,stackFrameVariables:!1,frameContextLines:0},r=new Set(`stage.route.method.status.durationMs.connection.idle.model.thinkingLevel.messageCount.attachmentCount.session.requestId.operationId.errorId.repeats.dropped.componentStack.eventType.sequence.nodeVersion.piVersion.platform.browser.buildId.code.toolName.toolId.toolCallId.failureKind.errorCode.exitCode.timeoutMs.diagnosticSource.originalStackAvailable.errorSummary.summaryOmitted.summaryOmittedReason.level.networkKind.networkStage.causeCodes`.split(`.`)),i=new Set(`/api/workspace/git/control./api/workspace/git/write./api/workspace/git/status./api/workspace/git/diff./api/workspace/git/history./api/workspace/git/commit-detail./api/workspace/git/commit-diff./api/workspace/files/list./api/workspace/files/preview./api/workspace/files/raw./api/workspace/files/write./api/workspace/files/status./api/workspace/files/search./api/plugins./api/plugin-action./api/plugin-interaction./api/resume./api/update./api/update/version./api/update/channel./api/provider/models./api/provider/logout./api/provider/login/active./api/telemetry/config./api/image./api/attachment./api/attachment/remove./api/session./api/providers./api/models./api/config./api/workspaces./api/commands./api/events./api/message./api/prompt-queue./api/abort./api/compact./api/new-session./api/model./api/thinking-level./api/provider/login./api/provider/login/respond./api/provider/login/cancel./api/provider/custom./api/workspace/add./api/workspace/select./api/workspace/new-session./api/workspace/remove./api/session/select./api/directory/capability./api/directory/list./api/directory/create./api/directory/pick`.split(`.`));function a(e){return e===`/api/message`||e===`/api/prompt-queue`||e.startsWith(`/api/provider/`)||e.startsWith(`/api/workspace/files/`)||e.startsWith(`/api/workspace/git/`)||[`/api/plugin-action`,`/api/plugin-interaction`,`/api/resume`,`/api/compact`].includes(e)}function o(e){return e.slice(0,8192).replace(/-----BEGIN [^-\n]+-----[\s\S]*?(?:-----END [^-\n]+-----|$)/g,`[redacted]`).replace(/(["'`])[\s\S]*?\1/g,`[quoted]`).replace(/(?:Bearer\s+\S+|(?:api[_-]?key|token|password|secret|authorization)\s*[=:]\s*\S+)/gi,`[redacted]`).replace(/\b(?:sk-|sntrys_|eyJ)[A-Za-z0-9_.-]+/g,`[redacted]`).replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,`[email]`).replace(/https?:\/\/[^\s)]+/gi,`[url]`).replace(/(?:file:\/\/)?(?:\/[\w.~-]+){2,}(?::\d+(?::\d+)?)?/g,`[path]`).replace(/[A-Za-z]:\\[^\s)]+/g,`[path]`).replace(/(?:^|\s)(?:\.\.?[\\/]|~[\\/])[^\s)]+/g,` [path]`).replace(/\b(?:[\w.-]+[\\/])+[\w.-]+/g,`[path]`).replace(/\{[^\n]*\}/g,`[object]`).replace(/\b[A-Za-z0-9_-]{24,}\b/g,`[redacted]`).slice(0,1024)}function s(n){let a={};for(let s of r){let r=n[s];s===`toolName`?typeof r==`string`&&(e.has(r)||r===`custom`)&&(a[s]=r):s===`failureKind`?t.has(r)&&(a[s]=r):s===`level`?(r===`warning`||r===`error`)&&(a[s]=r):s===`diagnosticSource`?(r===`tool_execution_end`||r===`message_end`)&&(a[s]=r):s===`errorCode`?typeof r==`string`&&/^(?:E[A-Z0-9]{1,20}|nonzero_exit|timeout|cancelled|blocked|invalid_arguments|tool_not_found|unknown)$/.test(r)&&(a[s]=r):s===`toolId`?typeof r==`string`&&/^[a-f0-9]{16}$/.test(r)&&(a[s]=r):s===`route`&&typeof r==`string`?a[s]=i.has(r.split(`?`)[0])?r.split(`?`)[0]:`[route]`:s===`model`&&typeof r==`string`&&/^[\w.-]+\/[\w.-]+$/.test(r)?a[s]=r.split(`/`).map(o).join(`/`):typeof r==`string`?a[s]=[`requestId`,`operationId`,`errorId`,`session`,`buildId`,`toolId`,`toolCallId`].includes(s)&&/^[\w-]{1,80}$/.test(r)?r:o(r).slice(0,s===`errorSummary`?512:1024):(typeof r==`boolean`||typeof r==`number`&&Number.isFinite(r)||r===null)&&(a[s]=r)}return a}function c(e){let t=e.replace(/\\/g,`/`).split(/[?#]/)[0];return t.startsWith(`node:`)?t.slice(0,150):`app:///${(t.match(/(?:^|\/)((?:web\/src|extension|shared|dist|assets)\/[^\s:)]+)$/)?.[1]??t.split(`/`).pop()??`unknown`).replace(/[^\w./-]/g,`_`).slice(-200)}`}function l(e,t=0){let n=e instanceof Error?e:Error(typeof e==`string`?e:`Non-Error rejection`),r=Error(o(n.message));if(r.name=o(n.name).slice(0,100),n.stack){let e=n.stack.split(`
2
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`8a3e686b-0b62-4118-983f-23449d782d1a`,e._sentryDebugIdIdentifier=`sentry-dbid-8a3e686b-0b62-4118-983f-23449d782d1a`)}catch{}})(),(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=new Set([`bash`,`powershell`,`read`,`write`,`edit`,`grep`,`find`,`ls`]),t=new Set([`cancelled`,`blocked`,`validation`,`not_found`,`permission`,`timeout`,`process_exit`,`unknown`]),n={userInfo:!1,cookies:!1,httpHeaders:!1,httpBodies:[],urlQueryParams:!1,genAI:{inputs:!1,outputs:!1},graphQL:{document:!1,variables:!1},databaseQueryData:!1,queues:!1,stackFrameVariables:!1,frameContextLines:0},r=new Set(`stage.route.method.status.durationMs.connection.idle.model.thinkingLevel.messageCount.attachmentCount.session.requestId.operationId.errorId.repeats.dropped.componentStack.eventType.sequence.nodeVersion.piVersion.platform.browser.buildId.code.toolName.toolId.toolCallId.failureKind.errorCode.exitCode.timeoutMs.diagnosticSource.originalStackAvailable.errorSummary.summaryOmitted.summaryOmittedReason.level.networkKind.networkStage.causeCodes`.split(`.`)),i=new Set(`/api/workspace/git/control./api/workspace/git/write./api/workspace/git/status./api/workspace/git/diff./api/workspace/git/history./api/workspace/git/commit-detail./api/workspace/git/commit-diff./api/workspace/files/list./api/workspace/files/preview./api/workspace/files/raw./api/workspace/files/write./api/workspace/files/status./api/workspace/files/search./api/plugins./api/plugin-action./api/plugin-interaction./api/resume./api/update./api/update/version./api/update/channel./api/provider/models./api/provider/logout./api/provider/login/active./api/telemetry/config./api/image./api/attachment./api/attachment/remove./api/session./api/providers./api/models./api/config./api/workspaces./api/commands./api/events./api/message./api/prompt-queue./api/abort./api/compact./api/new-session./api/model./api/thinking-level./api/provider/login./api/provider/login/respond./api/provider/login/cancel./api/provider/custom./api/workspace/add./api/workspace/select./api/workspace/new-session./api/workspace/remove./api/session/select./api/directory/capability./api/directory/list./api/directory/create./api/directory/pick`.split(`.`));function a(e){return e===`/api/message`||e===`/api/prompt-queue`||e.startsWith(`/api/provider/`)||e.startsWith(`/api/workspace/files/`)||e.startsWith(`/api/workspace/git/`)||[`/api/plugin-action`,`/api/plugin-interaction`,`/api/resume`,`/api/compact`].includes(e)}function o(e){return e.slice(0,8192).replace(/-----BEGIN [^-\n]+-----[\s\S]*?(?:-----END [^-\n]+-----|$)/g,`[redacted]`).replace(/(["'`])[\s\S]*?\1/g,`[quoted]`).replace(/(?:Bearer\s+\S+|(?:api[_-]?key|token|password|secret|authorization)\s*[=:]\s*\S+)/gi,`[redacted]`).replace(/\b(?:sk-|sntrys_|eyJ)[A-Za-z0-9_.-]+/g,`[redacted]`).replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,`[email]`).replace(/https?:\/\/[^\s)]+/gi,`[url]`).replace(/(?:file:\/\/)?(?:\/[\w.~-]+){2,}(?::\d+(?::\d+)?)?/g,`[path]`).replace(/[A-Za-z]:\\[^\s)]+/g,`[path]`).replace(/(?:^|\s)(?:\.\.?[\\/]|~[\\/])[^\s)]+/g,` [path]`).replace(/\b(?:[\w.-]+[\\/])+[\w.-]+/g,`[path]`).replace(/\{[^\n]*\}/g,`[object]`).replace(/\b[A-Za-z0-9_-]{24,}\b/g,`[redacted]`).slice(0,1024)}function s(n){let a={};for(let s of r){let r=n[s];s===`toolName`?typeof r==`string`&&(e.has(r)||r===`custom`)&&(a[s]=r):s===`failureKind`?t.has(r)&&(a[s]=r):s===`level`?(r===`warning`||r===`error`)&&(a[s]=r):s===`diagnosticSource`?(r===`tool_execution_end`||r===`message_end`)&&(a[s]=r):s===`errorCode`?typeof r==`string`&&/^(?:E[A-Z0-9]{1,20}|nonzero_exit|timeout|cancelled|blocked|invalid_arguments|tool_not_found|unknown)$/.test(r)&&(a[s]=r):s===`toolId`?typeof r==`string`&&/^[a-f0-9]{16}$/.test(r)&&(a[s]=r):s===`route`&&typeof r==`string`?a[s]=i.has(r.split(`?`)[0])?r.split(`?`)[0]:`[route]`:s===`model`&&typeof r==`string`&&/^[\w.-]+\/[\w.-]+$/.test(r)?a[s]=r.split(`/`).map(o).join(`/`):typeof r==`string`?a[s]=[`requestId`,`operationId`,`errorId`,`session`,`buildId`,`toolId`,`toolCallId`].includes(s)&&/^[\w-]{1,80}$/.test(r)?r:o(r).slice(0,s===`errorSummary`?512:1024):(typeof r==`boolean`||typeof r==`number`&&Number.isFinite(r)||r===null)&&(a[s]=r)}return a}function c(e){let t=e.replace(/\\/g,`/`).split(/[?#]/)[0];return t.startsWith(`node:`)?t.slice(0,150):`app:///${(t.match(/(?:^|\/)((?:web\/src|extension|shared|dist|assets)\/[^\s:)]+)$/)?.[1]??t.split(`/`).pop()??`unknown`).replace(/[^\w./-]/g,`_`).slice(-200)}`}function l(e,t=0){let n=e instanceof Error?e:Error(typeof e==`string`?e:`Non-Error rejection`),r=Error(o(n.message));if(r.name=o(n.name).slice(0,100),n.stack){let e=n.stack.split(`
3
3
  `).slice(1,31).map(e=>{let t=e.match(/((?:file:\/\/|https?:\/\/|\/|[A-Za-z]:\\)[^\s()]+):(\d+):(\d+)(\)?)$/);return t?`${o(e.slice(0,t.index))}${t[1]}:${t[2]}:${t[3]}${t[4]}`:o(e)});r.stack=`${r.name}: ${r.message}\n${e.join(`
4
4
  `)}`}else r.stack=void 0;return t<3&&n.cause!==void 0&&(r.cause=l(n.cause,t+1)),r}function u(e,t){let n=Error(t);return e instanceof Error&&(n.name=e.name,e.stack&&(n.stack=`${n.name}: ${t}\n${e.stack.split(`
5
5
  `).slice(1).join(`
6
6
  `)}`)),n}function d(e){return{...e.filename?{filename:c(e.filename)}:{},...e.abs_path?{abs_path:c(e.abs_path)}:{},...e.function?{function:o(e.function)}:{},lineno:e.lineno,colno:e.colno,in_app:e.in_app}}function f(e){let t=s(e.contexts?.diagnostic??{}),n=p(t);return{event_id:e.event_id,timestamp:e.timestamp,platform:e.platform,level:e.level,release:e.release,dist:e.dist,environment:o(e.environment??`production`),...e.message?{message:o(e.message)}:{},exception:e.exception?{values:e.exception.values?.slice(0,4).map(e=>({type:o(e.type??`Error`),value:o(e.value??``),...e.stacktrace?{stacktrace:{frames:e.stacktrace.frames?.slice(-30).map(d)}}:{},...e.mechanism?{mechanism:{type:e.mechanism.type,handled:e.mechanism.handled}}:{}}))}:void 0,tags:{side:e.tags?.side,buildId:e.tags?.buildId,...t.toolName?{toolName:t.toolName}:{},...t.failureKind?{failureKind:t.failureKind}:{},...t.errorCode?{errorCode:t.errorCode}:{}},...n?{fingerprint:n}:{},contexts:{diagnostic:t},breadcrumbs:e.breadcrumbs?.slice(-100).map(e=>({timestamp:e.timestamp,category:o(e.category??`app`),data:s(e.data??{})})),debug_meta:e.debug_meta?{images:e.debug_meta.images?.slice(0,10).map(e=>({type:e.type,debug_id:e.debug_id,...e.code_file?{code_file:c(e.code_file)}:{}}))}:void 0}}function p(e){if(e.stage===`tool`&&e.originalStackAvailable===!1&&e.toolName&&e.failureKind)return[`pi-webapp-tool-result`,String(e.toolName),String(e.toolId??`builtin`),String(e.failureKind),String(e.errorCode??`unknown`)]}function m(e,t){return t.attachments=[],f(e)}var h=class{items=[];bytes=0;encoder=new TextEncoder;add(e,t={}){let n={timestamp:Date.now()/1e3,category:o(e),data:s(t)},r=this.encoder.encode(JSON.stringify(n)).byteLength+1;for(this.items.push({item:n,size:r}),this.bytes+=r;this.items.length>100||this.bytes>65534;)this.bytes-=this.items.shift().size}snapshot(){return this.items.map(({item:e})=>e)}},g=class{windowAt=-1;total=0;seen=new Map;take(e,t=Date.now()){(this.windowAt<0||t-this.windowAt>=6e4)&&(this.windowAt=t,this.total=0);let n=this.seen.get(e);if(n&&t-n.at<6e4)n.repeats++;else if(!(this.total>=20))return this.total++,this.seen.size>=64&&!n&&this.seen.delete(this.seen.keys().next().value),this.seen.set(e,{at:t,repeats:0}),{repeats:n?.repeats??0}}},_=new Set(`目录路径必须是绝对路径.父目录路径必须是绝对路径.文件夹名称无效.工作区目录不可用,请恢复目录或从列表移除后重新添加.会话已切换.Pi 正在运行,请等待当前回复结束.请等待当前回复结束.请等待当前回复结束再切换工作区.请等待当前回复结束再切换会话.请先切换到其他工作区.新会话已取消.已有登录正在进行.模型不可用.模型提供方未配置认证.当前模型不支持此推理强度.其他提供方的登录正在进行,请先完成或取消当前登录.当前会话没有暂停的任务.请先完成当前交互或审批.请先选择模型.请先连接当前模型.插件未启用.会话运行实例已切换.提供方已存在.文件超过 20 MB.请求内容过大.会话不属于该工作区.推理强度无效.会话名称过长.会话不存在.插件会话不能重命名或删除.该会话正在 Pi 终端中使用,请在终端里切换到其他会话后再删除`.split(`.`));function v(e){return e instanceof Error&&(e.name===`AbortError`||_.has(e.message))}var y=class{budget=new g;breadcrumbs;scopeClass;seen=new WeakSet;state={};client;side;buildId;constructor(e,t,n,r,i=new h){this.client=e,this.side=t,this.buildId=n,this.scopeClass=r.Scope,this.breadcrumbs=i,e.addIntegration(r.linkedErrorsIntegration({limit:4}))}setState(e){this.state=s(e)}capture(e,t={},n){try{if(v(e))return;if(typeof e==`object`&&e){if(this.seen.has(e))return;this.seen.add(e)}let r=l(e),i=s({...this.state,...t}),a=p(i),o=a?JSON.stringify(a):`${r.name}:${r.message}:${r.stack?.split(`
7
- `)[1]??``}:${t.stage??``}`,c=this.budget.take(o);if(!c)return;let u=new this.scopeClass;u.setClient(this.client),u.setTags({side:this.side,buildId:this.buildId}),i.level===`warning`&&u.setLevel(`warning`),a&&u.setFingerprint(a),u.setContext(`diagnostic`,{...i,repeats:c.repeats});for(let e of this.breadcrumbs.snapshot())u.addBreadcrumb(e,100);return u.captureException(r,n?{event_id:n}:void 0)}catch{return}}ignore(e){this.seen.add(e)}};function b(e,t){return e({...t,bufferSize:20},async({body:e})=>{let n=await fetch(t.url,{method:`POST`,body:e,signal:AbortSignal.timeout(3e3),credentials:`omit`,referrerPolicy:`no-referrer`,redirect:`error`,headers:{"Content-Type":`application/x-sentry-envelope`}});return{statusCode:n.status,headers:{"x-sentry-rate-limits":n.headers.get(`x-sentry-rate-limits`),"retry-after":n.headers.get(`retry-after`)}}})}var x;function S(){if(x!==void 0)return x;let e=location.hash.slice(1);try{x=e||sessionStorage.getItem(`pi-web-token`),e&&sessionStorage.setItem(`pi-web-token`,e)}catch{x=e||null}return e&&history.replaceState(null,``,location.pathname),x}var C=`pi-webapp@0.1.56+6f956b602975404b747f`,w=`6f956b602975404b747f`;function T(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var E=`modulepreload`,D=function(e){return`/`+e},O={},k=function(e){return e.pathname.endsWith(`.css`)},A=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},j=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=D(t,n);let r=s(t),i=k(r);return A(O,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:E,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},M,N=!0,P=!1,F=!1,I=[],L=new WeakSet,R=new Map,z={};function B(e,t={}){try{if(v(e))return;if(typeof e==`object`&&e){if(L.has(e))return;L.add(e)}if(M)return M.capture(e,t);N&&I.length<20&&I.push({error:l(e),context:s(t)})}catch{}}function V(e){L.add(e)}function H(e,t={}){M?.breadcrumbs.add(e,t)}function U(e){e.sessionId&&(R.has(e.sessionId)||(R.size>=32&&R.delete(R.keys().next().value),R.set(e.sessionId,T())),e={...e,session:R.get(e.sessionId)}),z=s({...z,...e}),M?.setState(z)}function W(){P||(P=!0,F=new URL(location.href).searchParams.get(`sentry_release_probe`)===`1`,window.addEventListener(`error`,e=>{e instanceof ErrorEvent?B(e.error??Error(e.message),{stage:`global`}):(e.target instanceof HTMLScriptElement||e.target instanceof HTMLLinkElement)&&B(Error(`Application resource failed to load`),{stage:`resource`})},!0),window.addEventListener(`unhandledrejection`,e=>B(e.reason,{stage:`unhandled_rejection`})),G())}async function G(){try{let e=S();if(!e)return;let t=await fetch(`/api/telemetry/config`,{headers:{Authorization:`Bearer ${e}`},signal:AbortSignal.timeout(1e3)});if(!t.ok)return;let n=await t.json();if(!n.enabled||!n.dsn)return;let{createBrowserReporter:r}=await j(async()=>{let{createBrowserReporter:e}=await import(`./telemetry-client-xIu6sXGx.js`);return{createBrowserReporter:e}},[]);M=r({...n,buildId:w,release:C});let i=navigator.userAgent.match(/(?:Firefox|Edg|Chrome|Version)\/[\d.]+/)?.[0]??`unknown`;M.setState({...z,browser:i,platform:navigator.platform}),z={...z,browser:i,platform:navigator.platform};for(let e of I)M.capture(e.error,e.context);n.environment===`sentry-verification`&&F&&M.capture(Error(`Sentry browser release verification`),{stage:`release_verification`,code:`sentry_release_probe`})}catch{}finally{I=[],N=!1}}W(),j(()=>import(`./app-VS_Rt2sQ.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5,6,7])).catch(e=>B(e,{stage:`startup`}));export{j as a,y as c,u as d,m as f,U as i,b as l,V as n,T as o,n as p,B as r,S as s,H as t,a as u};
8
- //# debugId=3d604df2-7ba7-479f-9c9e-62b0a1688464
7
+ `)[1]??``}:${t.stage??``}`,c=this.budget.take(o);if(!c)return;let u=new this.scopeClass;u.setClient(this.client),u.setTags({side:this.side,buildId:this.buildId}),i.level===`warning`&&u.setLevel(`warning`),a&&u.setFingerprint(a),u.setContext(`diagnostic`,{...i,repeats:c.repeats});for(let e of this.breadcrumbs.snapshot())u.addBreadcrumb(e,100);return u.captureException(r,n?{event_id:n}:void 0)}catch{return}}ignore(e){this.seen.add(e)}};function b(e,t){return e({...t,bufferSize:20},async({body:e})=>{let n=await fetch(t.url,{method:`POST`,body:e,signal:AbortSignal.timeout(3e3),credentials:`omit`,referrerPolicy:`no-referrer`,redirect:`error`,headers:{"Content-Type":`application/x-sentry-envelope`}});return{statusCode:n.status,headers:{"x-sentry-rate-limits":n.headers.get(`x-sentry-rate-limits`),"retry-after":n.headers.get(`retry-after`)}}})}var x;function S(){if(x!==void 0)return x;let e=location.hash.slice(1);try{x=e||sessionStorage.getItem(`pi-web-token`),e&&sessionStorage.setItem(`pi-web-token`,e)}catch{x=e||null}return e&&history.replaceState(null,``,location.pathname),x}var C=`pi-webapp@0.1.57-alpha.1+ddf1f8ad8237501b99f6`,w=`ddf1f8ad8237501b99f6`;function T(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var E=`modulepreload`,D=function(e){return`/`+e},O={},k=function(e){return e.pathname.endsWith(`.css`)},A=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},j=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=D(t,n);let r=s(t),i=k(r);return A(O,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:E,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},M,N=!0,P=!1,F=!1,I=[],L=new WeakSet,R=new Map,z={};function B(e,t={}){try{if(v(e))return;if(typeof e==`object`&&e){if(L.has(e))return;L.add(e)}if(M)return M.capture(e,t);N&&I.length<20&&I.push({error:l(e),context:s(t)})}catch{}}function V(e){L.add(e)}function H(e,t={}){M?.breadcrumbs.add(e,t)}function U(e){e.sessionId&&(R.has(e.sessionId)||(R.size>=32&&R.delete(R.keys().next().value),R.set(e.sessionId,T())),e={...e,session:R.get(e.sessionId)}),z=s({...z,...e}),M?.setState(z)}function W(){P||(P=!0,F=new URL(location.href).searchParams.get(`sentry_release_probe`)===`1`,window.addEventListener(`error`,e=>{e instanceof ErrorEvent?B(e.error??Error(e.message),{stage:`global`}):(e.target instanceof HTMLScriptElement||e.target instanceof HTMLLinkElement)&&B(Error(`Application resource failed to load`),{stage:`resource`})},!0),window.addEventListener(`unhandledrejection`,e=>B(e.reason,{stage:`unhandled_rejection`})),G())}async function G(){try{let e=S();if(!e)return;let t=await fetch(`/api/telemetry/config`,{headers:{Authorization:`Bearer ${e}`},signal:AbortSignal.timeout(1e3)});if(!t.ok)return;let n=await t.json();if(!n.enabled||!n.dsn)return;let{createBrowserReporter:r}=await j(async()=>{let{createBrowserReporter:e}=await import(`./telemetry-client-BXj9P2wd.js`);return{createBrowserReporter:e}},[]);M=r({...n,buildId:w,release:C});let i=navigator.userAgent.match(/(?:Firefox|Edg|Chrome|Version)\/[\d.]+/)?.[0]??`unknown`;M.setState({...z,browser:i,platform:navigator.platform}),z={...z,browser:i,platform:navigator.platform};for(let e of I)M.capture(e.error,e.context);n.environment===`sentry-verification`&&F&&M.capture(Error(`Sentry browser release verification`),{stage:`release_verification`,code:`sentry_release_probe`})}catch{}finally{I=[],N=!1}}W(),j(()=>import(`./app-VS_Rt2sQ.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3,4,5,6,7])).catch(e=>B(e,{stage:`startup`}));export{j as a,y as c,u as d,m as f,U as i,b as l,V as n,T as o,n as p,B as r,S as s,H as t,a as u};
8
+ //# debugId=8a3e686b-0b62-4118-983f-23449d782d1a
@@ -0,0 +1,3 @@
1
+ (function(){try{var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`b852e5e1-bd15-4376-87c0-22c52cdf555d`,e._sentryDebugIdIdentifier=`sentry-dbid-b852e5e1-bd15-4376-87c0-22c52cdf555d`)}catch{}})();import{c as e,f as t,l as n,p as r}from"./app.js";var i=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,a=globalThis,o=`11.15.0`;function s(){return c(a),a}function c(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`11.15.0`,t[o]=t[`11.15.0`]||{}}function l(e,t,n=a){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[o]=r[`11.15.0`]||{};return i[e]||(i[e]=t())}var u=`Sentry Logger `,d={};function f(e){if(!(`console`in a))return e();let t=a.console,n={},r=Object.keys(d);r.forEach(e=>{let r=d[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function p(){re().enabled=!0}function m(){re().enabled=!1}function h(){return re().enabled}function ee(...e){ne(`log`,...e)}function g(...e){ne(`warn`,...e)}function te(...e){ne(`error`,...e)}function ne(e,...t){i&&h()&&f(()=>{a.console[e](`${u}[${e}]:`,...t)})}function re(){return i?l(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}var _={enable:p,disable:m,isEnabled:h,log:ee,warn:g,error:te},ie=50,ae=/\(error: (.*)\)/,oe=/captureMessage|captureException/;function se(...e){let t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{let i=[],a=e.split(`
2
+ `);for(let e=n;e<a.length;e++){let n=a[e];n.length>1024&&(n=n.slice(0,1024));let o=ae.test(n)?n.replace(ae,`$1`):n;if(!o.includes(`Error: `)){for(let e of t){let t=e(o);if(t){i.push(t);break}}if(i.length>=ie+r)break}}return ce(i.slice(r))}}function ce(e){if(!e.length)return[];let t=Array.from(e);return/sentryWrapped/.test(v(t).function||``)&&t.pop(),t.reverse(),oe.test(v(t).function||``)&&(t.pop(),oe.test(v(t).function||``)&&t.pop()),t.slice(0,ie).map(e=>({...e,filename:e.filename||v(t).filename,function:e.function||`?`}))}function v(e){return e[e.length-1]||{}}var le=`<anonymous>`;function ue(e){try{return!e||typeof e!=`function`?le:e.name||le}catch{return le}}var de=Object.prototype.toString;function y(e){switch(de.call(e)){case`[object Error]`:case`[object Exception]`:case`[object DOMException]`:case`[object WebAssembly.Exception]`:return!0;default:return ye(e,Error)}}function b(e,t){return de.call(e)===`[object ${t}]`}function fe(e){return b(e,`ErrorEvent`)}function pe(e){return b(e,`DOMError`)}function me(e){return b(e,`DOMException`)}function he(e){return b(e,`String`)}function ge(e){return typeof e==`object`&&!!e&&`__sentry_template_string__`in e&&`__sentry_template_values__`in e}function x(e){return e===null||ge(e)||typeof e!=`object`&&typeof e!=`function`}function S(e){return b(e,`Object`)}function _e(e){return typeof e==`object`&&!!e}function C(e){return typeof Event<`u`&&ye(e,Event)}function ve(e){return b(e,`RegExp`)}function w(e){return!!(e?.then&&typeof e.then==`function`)}function ye(e,t){try{return e instanceof t}catch{return!1}}function be(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{i&&_.log(`Failed to add non-enumerable property "${String(t)}" to object`,e)}}function xe(e){if(y(e))return{message:e.message,name:e.name,stack:e.stack,...Se(e)};if(C(e)){let{type:t,target:n,currentTarget:r,detail:i}=e;return{type:t,target:n,currentTarget:r,...i?{detail:i}:{},...Se(e)}}return e}function Se(e){return _e(e)?Object.fromEntries(Object.entries(e)):{}}function Ce(e){let t=Object.keys(xe(e));return t.sort(),t[0]?t.join(`, `):`[object has no keys]`}var T;function E(e){if(T!==void 0)return T?T(e):e();let t=Symbol.for(`__SENTRY_SAFE_RANDOM_ID_WRAPPER__`),n=a;return t in n&&typeof n[t]==`function`?(T=n[t],T(e)):(T=null,e())}function we(){return E(()=>Math.random())}function D(){return E(()=>Date.now())}var Te=Symbol.for(`sentry.skipNormalization`),Ee=Symbol.for(`sentry.overrideNormalizationDepth`);function De(e){return!!e[Te]}function Oe(e){let t=e[Ee];return typeof t==`number`?t:void 0}function O(e,t=100,n=1/0){try{return je(``,e,t,n)}catch(e){return{ERROR:`**non-serializable** (${ke(e)})`}}}function ke(e){try{return String(e)}catch{return`unknown error`}}function Ae(e,t=3,n=102400){let r=O(e,t);return Fe(r)>n?Ae(e,t-1,n):r}function je(e,t,n=1/0,r=1/0,i=Ie()){let[a,o]=i;if(t==null||[`boolean`,`string`].includes(typeof t)||typeof t==`number`&&Number.isFinite(t))return t;let s=Me(e,t);if(!s.startsWith(`[object `))return s;if(De(t))return t;let c=Oe(t),l=c===void 0?n:c;if(l===0)return s.replace(`object `,``);if(a(t))return`[Circular ~]`;let u=t;if(u&&typeof u.toJSON==`function`)try{return je(``,u.toJSON(),l-1,r,i)}catch{}let d=Array.isArray(t)?[]:{},f=0,p=xe(t);for(let e in p){if(!Object.prototype.hasOwnProperty.call(p,e))continue;if(f>=r){d[e]=`[MaxProperties ~]`;break}let t=p[e];d[e]=je(e,t,l-1,r,i),f++}return o(t),d}function Me(e,t){try{return typeof global<`u`&&t===global?`[Global]`:typeof t==`number`&&!Number.isFinite(t)?`[${t}]`:typeof t==`function`?`[Function: ${ue(t)}]`:typeof t==`symbol`?`[${String(t)}]`:typeof t==`bigint`?`[BigInt: ${String(t)}]`:`[object ${Ne(t)}]`}catch(e){return`**non-serializable** (${ke(e)})`}}function Ne(e){let t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:`null prototype`}function Pe(e){return~-encodeURI(e).split(/%..|./).length}function Fe(e){return Pe(JSON.stringify(e))}function Ie(){let e=new WeakSet;function t(t){return e.has(t)?!0:(e.add(t),!1)}function n(t){e.delete(t)}return[t,n]}function Le(e,t=`[unserializable]`){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return typeof t==`function`?t(e):t}}function Re(e,t=0){return typeof e!=`string`||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function k(e,t,n=!1){return he(e)?ve(t)?t.test(e):he(t)?n?e===t:e.includes(t):typeof t==`function`&&t(e):!1}function ze(){let e=a;return e.crypto||e.msCrypto}var Be;function Ve(){return we()*16}function A(e=ze()){try{if(e?.randomUUID)return E(()=>e.randomUUID()).replace(/-/g,``)}catch{}return Be||=`10000000100040008000100000000000`,Be.replace(/[018]/g,e=>(e^(Ve()&15)>>e/4).toString(16))}function He(e){return e.exception?.values?.[0]}function Ue(e,t,n){let r=e.exception=e.exception||{},i=r.values=r.values||[],a=i[0]=i[0]||{};a.value||=t||``,a.type||=n||`Error`}function j(e,t){let n=He(e);n&&Ge(n,t)}function We(e,t){let n=e.exception?.values,r=n?.find(e=>e.mechanism?.exception_id===0)??n?.[0];r&&Ge(r,t)}function Ge(e,t){let n={type:`generic`,handled:!0},r=e.mechanism;e.mechanism={...n,...r,...t},t&&`data`in t&&(e.mechanism.data={...r?.data,...t.data})}function Ke(e){if(qe(e))return!0;try{be(e,`__sentry_captured__`,!0)}catch{}return!1}function qe(e){try{return e.__sentry_captured__}catch{}}var Je=1e3,Ye=1e3,Xe=100;function M(){return D()/Je}var N=[];function Ze(){let{performance:e}=a;if(!e?.now||!e.timeOrigin)return e?.now&&(N=[{from:0,origin:D()-E(()=>e.now())}]),M;let t=e.timeOrigin;N=[{from:0,origin:t}];let n=!0,r=0;return()=>E(()=>{let i=e.now(),a=Date.now();return Math.abs(t+i-a)>Ye&&(t=a-i,n?N=[{from:0,origin:t}]:(N.push({from:r,origin:t}),N.length>Xe&&N.splice(1,1))),n=!1,r=i,(t+i)/Je})}var Qe;function $e(){return(Qe??=Ze())()}function et(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),!e.did&&!t.did&&(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||$e(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=t.sid.length===32?t.sid:A()),t.init!==void 0&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),typeof t.started==`number`&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if(typeof t.duration==`number`)e.duration=t.duration;else{let t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),typeof t.errors==`number`&&(e.errors=t.errors),t.status&&(e.status=t.status)}function P(e,t,n=2){if(!t||typeof t!=`object`||n<=0)return t;if(e&&Object.keys(t).length===0)return e;let r={...e};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=P(r[e],t[e],n-1));return r}function tt(){return A()}function nt(){return A().substring(16)}var rt=100,F=class e{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},be(this,`refs`,{}),this._propagationContext={traceId:tt(),sampleRand:we()}}clone(){let t=new e;return t._breadcrumbs=[...this._breadcrumbs],t._tags={...this._tags},t._attributes={...this._attributes},t._extra={...this._extra},t._contexts={...this._contexts},this._contexts.flags&&(t._contexts.flags={values:[...this._contexts.flags.values]}),t._user=this._user,t._level=this._level,t._session=this._session,t._transactionName=this._transactionName,t._fingerprint=this._fingerprint,t._eventProcessors=[...this._eventProcessors],t._attachments=[...this._attachments],t._sdkProcessingMetadata={...this._sdkProcessingMetadata},t._propagationContext={...this._propagationContext},t._client=this._client,t._lastEventId=this._lastEventId,t._conversationId=this._conversationId,t.refs={...this.refs},t}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&et(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return t===null?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(t){if(!t)return this;let n=typeof t==`function`?t(this):t,{tags:r,attributes:i,extra:a,user:o,contexts:s,level:c,fingerprint:l=[],propagationContext:u,conversationId:d}=(n instanceof e?n.getScopeData():S(n)?t:void 0)||{};return this._tags={...this._tags,...r},this._attributes={...this._attributes,...i},this._extra={...this._extra,...a},this._contexts={...this._contexts,...s},o&&Object.keys(o).length&&(this._user=o),c&&(this._level=c),l.length&&(this._fingerprint=l),u&&(this._propagationContext=u),d&&(this._conversationId=d),this}addBreadcrumb(e,t){let n=typeof t==`number`?t:rt;if(n<=0)return this;let r={timestamp:M(),...e,message:e.message?Re(e.message,2048):e.message};return this._breadcrumbs.push(r),this._breadcrumbs.length>n&&(this._breadcrumbs=this._breadcrumbs.slice(-n)),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=P(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){let n=t?.event_id||A();if(!this._client)return i&&_.warn(`No client configured on scope - will not capture exception!`),n;let r=Error(`Sentry syntheticException`);return this._client.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},this),n}captureMessage(e,t,n){let r=n?.event_id||A();if(!this._client)return i&&_.warn(`No client configured on scope - will not capture message!`),r;let a=n?.syntheticException??Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:a,...n,event_id:r},this),r}captureEvent(e,t){let n=e.event_id||t?.event_id||A();return this._client?(this._client.captureEvent(e,{...t,event_id:n},this),n):(i&&_.warn(`No client configured on scope - will not capture event!`),n)}_notifyScopeListeners(){this._notifyingListeners||=(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),!1)}};function it(){return l(`defaultCurrentScope`,()=>new F)}function at(){return l(`defaultIsolationScope`,()=>new F)}var ot=`__SENTRY_SUPPRESS_TRACING__`,st=e=>e instanceof Promise&&!e[ct],ct=Symbol(`chained PromiseLike`),lt=(e,t,n)=>{let r=e.then(e=>(t(e),e),e=>{throw n(e),e});return st(r)&&st(e)?r:ut(e,r)},ut=(e,t)=>{if(!t)return e;let n=!1;for(let r in e){if(r in t)continue;n=!0;let i=e[r];typeof i==`function`?Object.defineProperty(t,r,{value:(...t)=>i.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[r]=i}return n&&Object.assign(t,{[ct]:!0}),t},dt=class{constructor(e,t){let n;n=e||new F;let r;r=t||new F,this._stack=[{scope:n}],this._isolationScope=r}withScope(e){let t=this._pushScope(),n;try{n=e(t)}catch(e){throw this._popScope(),e}return w(n)?lt(n,()=>this._popScope(),()=>this._popScope()):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){let e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}};function I(){let e=c(s());return e.stack=e.stack||new dt(it(),at())}function ft(e){return I().withScope(e)}function pt(e,t){let n=I();return n.withScope(()=>(n.getStackTop().scope=e,t(e)))}function mt(e){return I().withScope(()=>e(I().getIsolationScope()))}function ht(){return{suppressTracing:gt,withIsolationScope:mt,withScope:ft,withSetScope:pt,withSetIsolationScope:(e,t)=>mt(t),getCurrentScope:()=>I().getScope(),getIsolationScope:()=>I().getIsolationScope()}}function gt(e){return ft(t=>{t.setSDKProcessingMetadata({[ot]:!0});let n=e();return t.setSDKProcessingMetadata({[ot]:void 0}),n})}function _t(e){let t=c(e);return t.acs?t.acs:ht()}function vt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).includes(`value`)}function yt(e,t){let{value:n,unit:r}=vt(e)?e:{value:e,unit:void 0},i=xt(n),a=r&&typeof r==`string`?{unit:r}:{};if(i)return{...i,...a};if(!t||t===`skip-undefined`&&n===void 0)return;let o=``;try{o=JSON.stringify(n)??``}catch{}return{value:o,type:`string`,...a}}function bt(e,t=!1){let n={};for(let[r,i]of Object.entries(e??{})){let e=yt(i,t);e&&(n[r]=e)}return n}function xt(e){if(Array.isArray(e))return{value:e,type:`array`};let t=typeof e==`string`?`string`:typeof e==`boolean`?`boolean`:typeof e==`number`&&!Number.isNaN(e)?Number.isInteger(e)?`integer`:`double`:null;if(t)return{value:e,type:t}}function St(){return c(s()).externalPropagationContextProvider?.()}function L(){return _t(s()).getCurrentScope()}function Ct(){return _t(s()).getIsolationScope()}function wt(){return l(`globalScope`,()=>new F)}function R(){return L().getClient()}function Tt(e){let t=St();if(t)return{trace_id:t.traceId,span_id:t.spanId};let{traceId:n,parentSpanId:r,propagationSpanId:i}=e.getPropagationContext(),a={trace_id:n,span_id:i||nt()};return r&&(a.parent_span_id=r),a}var Et=[`ok`,`deadline_exceeded`,`unauthenticated`,`permission_denied`,`not_found`,`resource_exhausted`,`invalid_argument`,`unimplemented`,`unavailable`,`internal_error`,`unknown_error`,`cancelled`,`already_exists`,`failed_precondition`,`aborted`,`out_of_range`,`data_loss`],Dt=`sentry.exclusive_time`,Ot=`sentry.op`,kt=`sentry.origin`,At=`sentry.profile_id`,jt=`sentry.segment.name.source`;function Mt(e){return e!==`ok`&&Et.includes(e)}function Nt(e){if(e){if(typeof e==`object`&&`deref`in e&&typeof e.deref==`function`)try{return e.deref()}catch{return}return e}}var Pt=`_sentryScope`,Ft=`_sentryIsolationScope`;function z(e){let t=e;return{scope:t[Pt],isolationScope:Nt(t[Ft])}}function It(e){let t=Lt(e);if(!t)return;let n=Object.entries(t).reduce((e,[t,n])=>{if(t.startsWith(`sentry-`)){let r=t.slice(7);e[r]=n}return e},{});if(Object.keys(n).length>0)return n}function Lt(e){if(e&&(he(e)||Array.isArray(e)))return Array.isArray(e)?e.reduce((e,t)=>{let n=Rt(t);return Object.entries(n).forEach(([t,n])=>{e[t]=n}),e},{}):Rt(e)}function Rt(e){return e.split(`,`).map(e=>{let t=e.indexOf(`=`);return t===-1?[]:[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,n])=>(t&&n&&(e[t]=n),e),{})}var zt=/^o(\d+)\./,Bt=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Vt(e){return e===`http`||e===`https`}function B(e,t=!1){let{host:n,path:r,pass:i,port:a,projectId:o,protocol:s,publicKey:c}=e;return`${s}://${c}${t&&i?`:${i}`:``}@${n}${a?`:${a}`:``}/${r&&`${r}/`}${o}`}function Ht(e){let t=Bt.exec(e);if(!t){f(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});return}let[n,r,i=``,a=``,o=``,s=``]=t.slice(1),c=``,l=s,u=l.split(`/`);if(u.length>1&&(c=u.slice(0,-1).join(`/`),l=u.pop()),l){let e=l.match(/^\d+/);e&&(l=e[0])}return Ut({host:a,pass:i,path:c,projectId:l,port:o,protocol:n,publicKey:r})}function Ut(e){return{protocol:e.protocol,publicKey:e.publicKey||``,pass:e.pass||``,host:e.host,port:e.port||``,path:e.path||``,projectId:e.projectId}}function Wt(e){if(!i)return!0;let{port:t,projectId:n,protocol:r}=e;return[`protocol`,`publicKey`,`host`,`projectId`].find(t=>!e[t]&&(_.error(`Invalid Sentry Dsn: ${t} missing`),!0))?!1:n.match(/^\d+$/)?Vt(r)?t&&isNaN(parseInt(t,10))?(_.error(`Invalid Sentry Dsn: Invalid port ${t}`),!1):!0:(_.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(_.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function Gt(e){return e.match(zt)?.[1]}function Kt(e){let t=e.getOptions(),{host:n}=e.getDsn()||{},r;return t.orgId?r=String(t.orgId):n&&(r=Gt(n)),r}function V(e){let t=typeof e==`string`?Ht(e):Ut(e);if(t&&Wt(t))return t}function qt(e){if(typeof e==`boolean`)return Number(e);let t=typeof e==`string`?parseFloat(e):e;if(!(typeof t!=`number`||isNaN(t)||t<0||t>1))return t}var Jt=`span`;function Yt(e){return Nt(e.refs[Jt])}function Xt(e){let{spanId:t,traceId:n,isRemote:r}=e.spanContext(),i=r?t:H(e).parent_span_id,a=z(e).scope;return{parent_span_id:i,span_id:r?a?.getPropagationContext().propagationSpanId||nt():t,trace_id:n}}function Zt(e){if(e&&e.length>0)return e.map(({context:{spanId:e,traceId:t,traceFlags:n,...r},attributes:i})=>({span_id:e,trace_id:t,sampled:n===1,attributes:i,...r}))}function Qt(e){return typeof e==`number`?$t(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?$t(e.getTime()):$e()}function $t(e){return e>9999999999?e/1e3:e}function H(e){if(rn(e))return e.getStaticSpanJSON();let{spanId:t,traceId:n}=e.spanContext();if(nn(e)){let{attributes:r,startTime:i,name:a,endTime:o,status:s,links:c}=e;return{span_id:t,trace_id:n,data:r,description:a,parent_span_id:en(e),start_timestamp:Qt(i),timestamp:Qt(o)||void 0,status:on(s),op:r[Ot],origin:r[kt],links:Zt(c)}}return{span_id:t,trace_id:n,start_timestamp:0,status:`ok`,data:{}}}function en(e){return`parentSpanId`in e?e.parentSpanId:`parentSpanContext`in e?e.parentSpanContext?.spanId:void 0}function tn(e){return{...e,end_timestamp:e.end_timestamp??e.start_timestamp,attributes:bt(e.attributes),links:e.links?.map(e=>({...e,attributes:bt(e.attributes)}))}}function nn(e){let t=e;return!!t.attributes&&!!t.startTime&&!!t.name&&!!t.endTime&&!!t.status}function rn(e){return typeof e.getSpanJSON==`function`}function an(e){let{traceFlags:t}=e.spanContext();return t===1}function on(e){return!e||e.code===0||e.code===1?`ok`:e.message&&Mt(e.message)?e.message:`internal_error`}var sn=`_sentryRootSpan`,cn=ln;function ln(e){return e[sn]||e}function un(e){let t=_t(s());return t.getActiveSpan?t.getActiveSpan(e):Yt(e||L())}function dn(e){if(typeof __SENTRY_TRACING__==`boolean`&&!__SENTRY_TRACING__)return!1;let t=e||R()?.getOptions();return!!t&&(t.tracesSampleRate!=null||!!t.tracesSampler)}function fn(e){_.log(`Ignoring span ${e.op} - ${e.description} because it matches \`ignoreSpans\`.`)}function pn(e,t){if(!t?.length)return!1;for(let n of t){if(gn(n)){if(e.description&&k(e.description,n))return i&&fn(e),!0;continue}let t=!!n.attributes&&Object.keys(n.attributes).length>0;if(!n.name&&!n.op&&!t)continue;let r=!n.name||e.description&&k(e.description,n.name),a=!n.op||e.op&&k(e.op,n.op),o=!n.attributes||Object.entries(n.attributes).every(([t,n])=>mn(e.attributes?.[t],n));if(r&&a&&o)return i&&fn(e),!0}return!1}function mn(e,t){return typeof e==`string`&&(typeof t==`string`||t instanceof RegExp)?k(e,t):Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}function hn(e,t){let n=t.parent_span_id,r=t.span_id;if(n)for(let t of e)t.parent_span_id===r&&(t.parent_span_id=n)}function gn(e){return typeof e==`string`||e instanceof RegExp}var _n=[];function vn(e,t){let n={};return t.forEach(t=>{t?.beforeSetup&&t.beforeSetup(e)}),t.forEach(t=>{t&&bn(e,t,n)}),n}function yn(e,t){for(let n of t)n?.afterAllSetup&&n.afterAllSetup(e)}function bn(e,t,n){if(n[t.name])i&&_.log(`Integration skipped because it was already installed: ${t.name}`);else{if(n[t.name]=t,!_n.includes(t.name)&&typeof t.setupOnce==`function`&&(t.setupOnce(),_n.push(t.name)),t.setup&&typeof t.setup==`function`&&t.setup(e),typeof t.preprocessEvent==`function`){let n=t.preprocessEvent.bind(t);e.on(`preprocessEvent`,(t,r)=>n(t,r,e))}if(typeof t.processEvent==`function`){let n=t.processEvent.bind(t),r=Object.assign((t,r)=>n(t,r,e),{id:t.name});e.addEventProcessor(r)}[`processSpan`,`processSegmentSpan`].forEach(n=>{let r=t[n];typeof r==`function`&&e.on(n,n=>r.call(t,n,e))}),i&&_.log(`Integration installed: ${t.name}`)}}function xn(e){return e}var Sn=`production`,Cn=Symbol.for(`sentry.nonRecordingSpan`);function wn(e){return!!e&&e[Cn]===!0}var Tn=`_frozenDsc`;function En(e,t){let n=t.getOptions(),{publicKey:r}=t.getDsn()||{},i={environment:n.environment||`production`,release:n.release,public_key:r,trace_id:e,org_id:Kt(t)};return t.emit(`createDsc`,i),i}function Dn(e,t){if(St())return;let n=t.getPropagationContext();return n.dsc||En(n.traceId,e)}function On(e){let t=R();if(!t)return{};let n=cn(e),r=H(n),i=r.data,a=n.spanContext().traceState,o=a?.get(`sentry.sample_rate`)??i[`sentry.sample_rate`]??i[`sentry.previous_trace_sample_rate`];function s(e){return(typeof o==`number`||typeof o==`string`)&&(e.sample_rate=`${o}`),e}let c=n[Tn];if(c)return s(c);let l=wn(n),u=l&&n.dropReason===`ignored`;if(l&&(!dn(t.getOptions())||u)){let e=z(n).scope,r=e&&Dn(t,e);if(r){let e={...r};return u&&(e.sampled=`false`),s(e)}}let d=a?.get(`sentry.dsc`),f=d&&It(d);if(f)return s(f);let p=En(e.spanContext().traceId,t),m=i[jt],h=r.description;return m!==`url`&&h&&(p.transaction=h),dn()&&(p.sampled=String(an(n)),p.sample_rand=a?.get(`sentry.sample_rand`)??z(n).scope?.getPropagationContext().sampleRand.toString()),s(p),t.emit(`createDsc`,p,n),p}function kn(e,t){let{fingerprint:n,breadcrumbs:r,sdkProcessingMetadata:i}=t;Mn(e,t),In(e,n),Nn(e,r),Pn(e,i)}function An(e,t){let{extra:n,tags:r,attributes:i,user:a,contexts:o,level:s,sdkProcessingMetadata:c,breadcrumbs:l,fingerprint:u,eventProcessors:d,attachments:f,propagationContext:p,transactionName:m}=t;U(e,`extra`,n),U(e,`tags`,r),U(e,`attributes`,i),U(e,`user`,a),U(e,`contexts`,o),e.sdkProcessingMetadata=P(e.sdkProcessingMetadata,c,2),s&&(e.level=s),m&&(e.transactionName=m),l.length&&(e.breadcrumbs=[...e.breadcrumbs,...l]),u.length&&(e.fingerprint=[...e.fingerprint,...u]),d.length&&(e.eventProcessors=[...e.eventProcessors,...d]),f.length&&(e.attachments=[...e.attachments,...f]),e.propagationContext={...e.propagationContext,...p}}function U(e,t,n){e[t]=P(e[t],n,1)}function jn(e,t){let n=wt().getScopeData();return e&&An(n,e.getScopeData()),t&&An(n,t.getScopeData()),n}function Mn(e,t){let{extra:n,tags:r,user:i,contexts:a,level:o,transactionName:s}=t;Object.keys(n).length&&(e.extra={...n,...e.extra}),Object.keys(r).length&&(e.tags={...r,...e.tags}),Object.keys(i).length&&(e.user={...i,...e.user}),Object.keys(a).length&&(e.contexts={...a,...e.contexts}),o&&(e.level=o),s&&e.type!==`transaction`&&(e.transaction=s)}function Nn(e,t){let n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}function Pn(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}function Fn(e,t){e.contexts={trace:Xt(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:On(t),...e.sdkProcessingMetadata};let n=H(cn(t)).description;n&&!e.transaction&&e.type===`transaction`&&(e.transaction=n)}function In(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint.length||delete e.fingerprint}function W(e,t,n){let r;try{r=t()}catch(t){return Ln(e,t,n)}return w(r)?r.then(void 0,t=>Ln(e,t,n)):r}function Ln(e,t,n){return i&&_.error(e,t),n(t)}function Rn(e){return!!e&&typeof e==`function`&&`_static`in e&&!!e._static}function zn(e,t){return W(i?"The `beforeSendSpan` callback threw an error, sending the span unmodified:":``,()=>t(e),()=>e)||e}function Bn(e){return tn({trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,name:e.description||``,start_timestamp:e.start_timestamp,end_timestamp:e.timestamp,status:!e.status||e.status===`ok`||e.status===`cancelled`?`ok`:`error`,is_segment:!1,attributes:{...e.data},links:e.links})}function Vn(e){return e.getOptions().traceLifecycle===`stream`}function Hn(e){return typeof e==`object`&&typeof e.unref==`function`&&e.unref(),e}function G(e,t=[]){return[e,t]}function Un(e,t){let[n,r]=e;return[n,[...r,t]]}function K(e,t){let n=e[1];for(let e of n){let n=e[0].type;if(t(e,n))return!0}return!1}function Wn(e,t){return K(e,(e,n)=>t.includes(n))}function Gn(e){let t=c(a);return t.encodePolyfill?t.encodePolyfill(e):new TextEncoder().encode(e)}function Kn(e){let[t,n]=e,r=JSON.stringify(t);function i(e){typeof r==`string`?r=typeof e==`string`?r+e:[Gn(r),e]:r.push(typeof e==`string`?Gn(e):e)}for(let e of n){let[t,n]=e;if(i(`\n${JSON.stringify(t)}\n`),typeof n==`string`||n instanceof Uint8Array)i(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(O(n))}i(e)}}return typeof r==`string`?r:qn(r)}function qn(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function Jn(e){let t=typeof e.data==`string`?Gn(e.data):e.data;return[{type:`attachment`,length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}var Yn={sessions:`session`,event:`error`,client_report:`internal`,user_report:`default`,profile_chunk:`profile`,replay_event:`replay`,replay_recording:`replay`,check_in:`monitor`,raw_security:`security`,log:`log_item`,metric:`trace_metric`};function Xn(e){return e in Yn}function Zn(e){return Xn(e)?Yn[e]:e}function Qn(e){if(!e?.sdk)return;let{name:t,version:n}=e.sdk;return{name:t,version:n}}function $n(e,t,n,r){let i=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:new Date(D()).toISOString(),...t&&{sdk:t},...!!n&&r&&{dsn:B(r)},...i&&{trace:i}}}function er(e){return e===`replay_event`?`replay`:e||`error`}function tr(){return typeof __SENTRY_BROWSER_BUNDLE__<`u`&&!!__SENTRY_BROWSER_BUNDLE__}function nr(){return`npm`}function rr(){return!tr()&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`}function ir(){return typeof window<`u`&&(!rr()||ar())}function ar(){return a.process?.type===`renderer`}function or(e,t){let n=t.getDataCollectionOptions().userInfo?`auto`:`never`;return[{type:`span`,item_count:e.length,content_type:`application/vnd.sentry.items.span.v2+json`},{version:2,ingest_settings:ir()?{infer_ip:n,infer_user_agent:n}:void 0,items:e}]}var sr=new WeakMap;function cr(e){return x(e)?void 0:e}function lr(e,t,n){let r=cr(t.originalException),i=r&&sr.get(r);if(!i)return;let a=e.contexts?.trace;(a?.trace_id??(n&&Tt(n).trace_id))===i.trace_id&&(e.contexts={...e.contexts,trace:{...a,...i}})}function ur(e,t){if(!t)return e;let n=e.sdk||{};return e.sdk={...n,name:n.name||t.name,version:n.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0},e}function dr(e,t,n,r){let i=Qn(n);return G({sent_at:new Date(D()).toISOString(),...i&&{sdk:i},...!!r&&t&&{dsn:B(t)}},[`aggregates`in e?[{type:`sessions`},e]:[{type:`session`},e.toJSON()]])}function fr(e,t,n,r){let i=Qn(n),a=e.type&&e.type!==`replay_event`?e.type:`event`;ur(e,n?.sdk);let o=$n(e,i,r,t);return delete e.sdkProcessingMetadata,G(o,[[{type:a},e]])}var pr=0,mr=1,hr=2;function q(e){return new _r(t=>{t(e)})}function gr(e){return new _r((t,n)=>{n(e)})}var _r=class e{constructor(e){this._state=pr,this._handlers=[],this._runExecutor(e)}then(t,n){return new e((e,r)=>{this._handlers.push([!1,n=>{if(!t)e(n);else try{e(t(n))}catch(e){r(e)}},t=>{if(!n)r(t);else try{e(n(t))}catch(e){r(e)}}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(t){return new e((e,n)=>{let r,i;return this.then(e=>{i=!1,r=e,t&&t()},e=>{i=!0,r=e,t&&t()}).then(()=>{i?n(r):e(r)})})}_executeHandlers(){if(this._state===pr)return;let e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||=(this._state===mr&&e[1](this._value),this._state===hr&&e[2](this._value),!0)})}_runExecutor(e){let t=(e,t)=>{this._state===pr&&(w(t)?t.then(n,r):(this._state=e,this._value=t,this._executeHandlers()))},n=e=>{t(mr,e)},r=e=>{t(hr,e)};try{e(n,r)}catch(e){r(e)}}};function vr(e,t,n,r=0,i){try{let a=yr(t,n,e,r,i);return w(a)?a:q(a)}catch(e){return gr(e)}}function yr(e,t,n,r,a){let o=n[r];if(!e||!o)return e;let s=`Event processor "${o.id||`?`}"`,c=!1,l=W(i?`${s} threw an error, dropping event:`:``,()=>o({...e},t),()=>(c=!0,null));return i&&l===null&&_.log(`${s} dropped event`),w(l)?l.then(e=>e?yr(e,t,n,r+1,a):(a?.(c?`callback_error`:`event_processor`),null)):l?yr(l,t,n,r+1,a):(a?.(c?`callback_error`:`event_processor`),null)}var J,br,xr,Y;function Sr(e){let t=a._sentryDebugIds,n=a._debugIds;if(!t&&!n)return{};let r=t?Object.keys(t):[],i=n?Object.keys(n):[];if(Y&&r.length===br&&i.length===xr)return Y;br=r.length,xr=i.length,Y={},J||={};let o=(t,n)=>{for(let r of t){let t=n[r],i=J?.[r];if(i&&Y&&t)Y[i[0]]=t,J&&(J[r]=[i[0],t]);else if(t){let n=e(r);for(let e=n.length-1;e>=0;e--){let i=n[e]?.filename;if(i&&Y&&J){Y[i]=t,J[r]=[i,t];break}}}}};return t&&o(r,t),n&&o(i,n),Y}function Cr(e){return e.data?.__sentry__===!0}function wr(e){let t=[];e.message&&t.push(e.message);try{let n=e.exception.values[e.exception.values.length-1];n?.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`))}catch{}return t}function Tr(e,t,n,r,i,a){let{normalizeDepth:o=3,normalizeMaxBreadth:s=1e3}=e,c={...t,event_id:t.event_id||n.event_id||A(),timestamp:t.timestamp||M()},l=n.integrations||e.integrations.map(e=>e.name);Er(c,e),kr(c,l),i&&i.emit(`applyFrameMetadata`,t),t.type===void 0&&Dr(c,e.stackParser);let u=jr(r,n.captureContext);n.mechanism&&We(c,n.mechanism);let d=i?i.getEventProcessors():[],f=jn(a,u),p=[...n.attachments||[],...f.attachments];p.length&&(n.attachments=p),kn(c,f);let m=un(u);m&&Fn(c,m),lr(c,n,u);let h=[...d,...f.eventProcessors],ee=t.type===`transaction`,g=t.spans?.length||0;return(Cr(n)?q(c):vr(h,c,n,0,e=>{i&&(i.recordDroppedEvent(e,er(t.type)),ee&&i.recordDroppedEvent(e,`span`,1+g))})).then(e=>{if(!e)return null;if(ee&&i){let t=g-(e.spans?.length||0);t>0&&i.recordDroppedEvent(`event_processor`,`span`,t)}return Or(e),typeof o==`number`&&o>0?Ar(e,o,s):e})}function Er(e,t){let{environment:n,release:r,dist:i,maxValueLength:a}=t;e.environment=e.environment||n||`production`,!e.release&&r&&(e.release=r),!e.dist&&i&&(e.dist=i);let o=e.request;o?.url&&a&&(o.url=Re(o.url,a)),a&&e.exception?.values?.forEach(e=>{e.value&&=Re(e.value,a)})}function Dr(e,t){let n=Sr(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=n[e.filename])})})}function Or(e){let t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),Object.keys(t).length===0)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];let n=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{n.push({type:`sourcemap`,code_file:e,debug_id:t})})}function kr(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}function Ar(e,t,n){if(!e)return null;let r={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:O(e.data,t,n)}}))},...e.user&&{user:O(e.user,t,n)},...e.contexts&&{contexts:O(e.contexts,t,n)},...e.extra&&{extra:O(e.extra,t,n)}};return e.contexts?.trace&&r.contexts&&(r.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(r.contexts.trace.data=O(e.contexts.trace.data,t,n))),e.spans&&(r.spans=e.spans.map(e=>({...e,...e.data&&{data:O(e.data,t,n)}}))),e.contexts?.flags&&r.contexts&&(r.contexts.flags=O(e.contexts.flags,3,n)),r}function jr(e,t){if(!t)return e;let n=e?e.clone():new F;return n.update(t),n}function Mr(e){let t=e.protocol?`${e.protocol}:`:``,n=e.port?`:${e.port}`:``;return`${t}//${e.host}${n}${e.path?`/${e.path}`:``}/api/`}function Nr(e){return`${Mr(e)}${e.projectId}/envelope/`}function Pr(e,t){let n={sentry_version:`7`};return e.publicKey&&(n.sentry_key=e.publicKey),t&&(n.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(n).toString()}function Fr(e,t,n){return t||`${Nr(e)}?${Pr(e,n)}`}function Ir(e,t){if(e.type!==`transaction`||!e.spans?.length||!e.sdkProcessingMetadata?.hasGenAiSpans||Vn(t))return;let n=[],r=[];for(let t of e.spans)t.op?.startsWith(`gen_ai.`)?n.push(Bn(t)):r.push(t);if(n.length!==0)return e.spans=r,or(n,t)}var Lr=Symbol.for(`SentryBufferFullError`);function Rr(e=100){let t=new Set;function n(){return t.size<e}function r(e){t.delete(e)}function i(e){if(!n())return gr(Lr);let i=e();return t.add(i),i.then(()=>r(i),()=>r(i)),i}function a(e){if(!t.size)return q(!0);let n=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return n;let r=[n,new Promise(t=>Hn(setTimeout(()=>t(!1),e)))];return Promise.race(r)}return{get $(){return Array.from(t)},add:i,drain:a}}var zr=6e4;function Br(e,t=D()){let n=parseInt(`${e}`,10);if(!isNaN(n))return n*1e3;let r=Date.parse(`${e}`);return isNaN(r)?zr:r-t}function Vr(e,t){return e[t]||e.all||0}function Hr(e,t,n=D()){return Vr(e,t)>n}function Ur(e,t,n=D()){let r={...e};return Wr(t,n,(e,t)=>{r[e]=Math.max(r[e]||0,t)}),r}function Wr({statusCode:e,headers:t},n,r){let i=t?.[`x-sentry-rate-limits`],a=t?.[`retry-after`];if(i)for(let e of i.trim().split(`,`)){let[t,i,,,a]=e.split(`:`,5),o=parseInt(t,10),s=(isNaN(o)?60:o)*1e3;if(!i)r(`all`,n+s);else for(let e of i.split(`;`))e===`metric_bucket`?(!a||a.split(`;`).includes(`custom`))&&r(e,n+s):r(e,n+s)}else a?r(`all`,n+Br(a,n)):e===429&&r(`all`,n+6e4)}function Gr(e,t,n=Rr(e.bufferSize||64)){let r={},a=e=>n.drain(e);function o(t,[n,r],i){let a=Zn(i);i===`transaction`&&e.recordDroppedEvent(t,`span`,(r.spans?.length??0)+1),e.recordDroppedEvent(t,a,typeof n.item_count==`number`?n.item_count:1)}function s(e){let a=[];if(K(e,(e,t)=>{Hr(r,Zn(t))?o(`ratelimit_backoff`,e,t):a.push(e)}),a.length===0)return Promise.resolve({});let s=G(e[0],a),c=e=>{Wn(s,[`client_report`])?i&&_.warn(`Dropping client report. Will not send outcomes (reason: ${e}).`):K(s,(t,n)=>{o(e,t,n)})};return n.add(()=>t({body:Kn(s)}).then(e=>e.statusCode===413?(i&&_.error(`Sentry responded with status code 413. Envelope was discarded due to exceeding size limits.`),c(`send_error`),e):(i&&e.statusCode!==void 0&&(e.statusCode<200||e.statusCode>=300)&&_.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),r=Ur(r,e),e),e=>{throw c(`network_error`),i&&_.error(`Encountered error running transport request:`,e),e})).then(e=>e,e=>{if(e===Lr)return i&&_.error(`Skipped sending event because buffer is full.`),c(`queue_overflow`),Promise.resolve({});throw e})}return{send:s,flush:a}}function Kr(e,t,n){let r=[{type:`client_report`},{timestamp:n||M(),discarded_events:e}];return G(t?{dsn:t}:{},[r])}function qr(e){let{trace_id:t,parent_span_id:n,span_id:r,status:i,origin:a,data:o,op:s,links:c}=e.contexts?.trace??{};return{data:o??{},description:e.transaction,op:s,parent_span_id:n,span_id:r??``,start_timestamp:e.start_timestamp??0,status:i??`ok`,timestamp:e.timestamp,trace_id:t??``,origin:a,links:c,profile_id:o?.[At],exclusive_time:o?.[Dt],measurements:e.measurements,is_segment:!0}}function Jr(e){return{type:`transaction`,timestamp:e.timestamp,start_timestamp:e.start_timestamp,transaction:e.description,contexts:{trace:{trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,op:e.op,status:e.status,origin:e.origin,links:e.links,data:{...e.data,...e.profile_id&&{"sentry.profile_id":e.profile_id},...e.exclusive_time&&{"sentry.exclusive_time":e.exclusive_time}}}},measurements:e.measurements}}function Yr(e){e.traceLifecycle===`stream`&&(e.beforeSendTransaction||e.ignoreTransactions?.length)&&f(()=>{console.warn("[Sentry] `beforeSendTransaction` and `ignoreTransactions` are ignored with `traceLifecycle: 'stream'` (enabled by default). Use `beforeSendSpan` and `ignoreSpans` instead, or set `traceLifecycle: 'static'`.")})}var X={userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:[`incomingRequest`,`outgoingRequest`,`incomingResponse`,`outgoingResponse`],urlQueryParams:!0,graphQL:{document:!0,variables:!0},genAI:{inputs:!0,outputs:!0},mcp:{inputs:!0,outputs:!0},databaseQueryData:!0,queues:!0,stackFrameVariables:!0,frameContextLines:5};function Xr(e){return typeof e==`boolean`||`allow`in e||`deny`in e}function Zr(e){return e===void 0?{...X.httpHeaders}:Xr(e)?{request:e,response:e}:{request:e.request??X.httpHeaders.request,response:e.response??X.httpHeaders.response}}function Qr(e){let t=e.dataCollection??{};return{userInfo:t.userInfo??X.userInfo,cookies:t.cookies??X.cookies,httpHeaders:Zr(t.httpHeaders),httpBodies:t.httpBodies??X.httpBodies,urlQueryParams:t.urlQueryParams??X.urlQueryParams,graphQL:{document:t.graphQL?.document??X.graphQL.document,variables:t.graphQL?.variables??X.graphQL.variables},genAI:{inputs:t.genAI?.inputs??X.genAI.inputs,outputs:t.genAI?.outputs??X.genAI.outputs},mcp:{inputs:t.mcp?.inputs??X.mcp.inputs,outputs:t.mcp?.outputs??X.mcp.outputs},databaseQueryData:t.databaseQueryData??X.databaseQueryData,queues:t.queues??X.queues,stackFrameVariables:t.stackFrameVariables??X.stackFrameVariables,frameContextLines:t.frameContextLines??X.frameContextLines}}var $r=`Not capturing exception because it's already been captured.`,ei=`Discarded session because of missing or non-string release`,ti=Symbol.for(`SentryInternalError`),ni=Symbol.for(`SentryDoNotSendEventError`),ri=Symbol.for(`SentryClosedClient`);function ii(e){return{message:e,[ti]:!0}}function ai(e){return{message:e,[ni]:!0}}function oi(e){return ai(`Discarding event because it's not included in the random sample (sampling rate = ${e})`)}function si(e){return _e(e)&&ti in e}function ci(e){return _e(e)&&ni in e}var li=class{constructor(e){this._options={attachStacktrace:!0,...e,traceLifecycle:e.traceLifecycle===`static`?`static`:`stream`},this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Rr(e.transportOptions?.bufferSize??64),this._dataCollection=Qr(e),this._unhandledSessionStatus=`crashed`,this._attachStacktraceIsDefault=e.attachStacktrace===void 0,e.dsn?this._dsn=V(e.dsn):i&&_.warn(`No DSN provided, client will not send events.`);let{beforeSendSpan:t,traceLifecycle:n}=this._options;if(i&&t&&Rn(t)!==(n===`static`)&&f(()=>{console.warn(`Ignoring \`beforeSendSpan\`: ${n===`static`?`wrap it with`:`remove`} \`Sentry.withStaticSpan\` to use it with \`traceLifecycle: "${n}"\`.`)}),this._dsn){let t=Fr(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}}captureException(e,t,n){let r=A();if(Ke(e))return i&&_.log($r),r;let a={event_id:r,...t};return this._process(()=>this.eventFromException(e,a).then(e=>this._captureEvent(e,a,n)).then(e=>e),`error`),a.event_id}captureMessage(e,t,n,r){let i={event_id:A(),...n},a=ge(e)?e:String(e),o=x(e),s=o?this.eventFromMessage(a,t,i).then(e=>(e.exception&&this._attachStacktraceIsDefault&&(e.sdkProcessingMetadata={...e.sdkProcessingMetadata,hasDefaultSyntheticStacktrace:!0}),e)):this.eventFromException(e,i);return this._process(()=>s.then(e=>this._captureEvent(e,i,r)),o?`unknown`:`error`),i.event_id}captureEvent(e,t,n){let r=A();if(t?.originalException&&Ke(t.originalException))return i&&_.log($r),r;let a={event_id:r,...t},o=e.sdkProcessingMetadata||{},s=o.capturedSpanScope,c=o.capturedSpanIsolationScope,l=er(e.type);return this._process(()=>this._captureEvent(e,a,s||n,c),l),a.event_id}captureSession(e){this.sendSession(e),et(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getDataCollectionOptions(){return this._dataCollection}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}async flush(e){let t=this._transport;if(this.emit(`flush`),!t)return!0;let n=await this._isClientDoneProcessing(e),r=await t.flush(e);return n&&r}async close(e){Object.defineProperty(this,ri,{value:!0});let t=await this.flush(e);return this.getOptions().enabled=!1,this.emit(`close`),t}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith(`Spotlight`)))&&(this._setupIntegrations(),Yr(this._options))}getIntegrationByName(e){return this._integrations[e]}getIntegrationNames(){return Object.keys(this._integrations)}addIntegration(e){let t=this._integrations[e.name];!t&&e.beforeSetup&&e.beforeSetup(this),bn(this,e,this._integrations),t||yn(this,[e])}sendEvent(e,t={}){this.emit(`beforeSendEvent`,e,t);let n=Ir(e,this),r=fr(e,this._dsn,this._options._metadata,this._options.tunnel);if(!Cr(t))for(let e of t.attachments||[])r=Un(r,Jn(e));n&&(r=Un(r,n)),this.sendEnvelope(r).then(t=>this.emit(`afterSendEvent`,e,t))}sendSession(e){let{release:t,environment:n=Sn}=this._options;if(`aggregates`in e){let r=e.attrs||{};if(!r.release&&!t){i&&_.warn(ei);return}r.release=r.release||t,r.environment=r.environment||n,e.attrs=r}else{if(!e.release&&!t){i&&_.warn(ei);return}e.release=e.release||t,e.environment=e.environment||n}this.emit(`beforeSendSession`,e);let r=dr(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(r)}recordDroppedEvent(e,t,n=1){if(this._options.sendClientReports){let r=`${e}:${t}`;i&&_.log(`Recording outcome: "${r}"${n>1?` (${n} times)`:``}`),this._outcomes[r]=(this._outcomes[r]||0)+n}}on(e,t){let n=this._hooks[e]=this._hooks[e]||new Set,r=(...e)=>t(...e);return n.add(r),()=>{n.delete(r)}}emit(e,...t){let n=this._hooks[e];n&&n.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit(`beforeEnvelope`,e),this._isEnabled()&&this._transport)try{let t=await this._transport.send(e);return this.emit(`afterEnvelope`,e),t}catch(e){return i&&_.error(`Error while sending envelope:`,e),{}}return i&&_.error(`Transport disabled`),{}}registerCleanup(e){}dispose(){}_setupIntegrations(){let{integrations:e}=this._options;this._integrations=vn(this,e),yn(this,e)}_updateSessionFromEvent(e,t){let n=t.level===`fatal`,r=!1,i=t.exception?.values;if(i){r=!0,n=!1;for(let e of i)if(e.mechanism?.handled===!1){n=!0;break}}let a=e.status===`ok`;(a&&e.errors===0||a&&n)&&(et(e,{...n&&{status:this._unhandledSessionStatus},errors:e.errors||Number(r||n)}),this.captureSession(e))}async _isClientDoneProcessing(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this._numProcessing)return!0;t++}return!1}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,t,n,r){let i=this.getOptions(),a=this.getIntegrationNames();return!t.integrations&&a.length&&(t.integrations=a),this.emit(`preprocessEvent`,e,t),e.type||r.setLastEventId(e.event_id||t.event_id),Tr(i,e,t,n,this,r).then(e=>(e===null||(this.emit(`postprocessEvent`,e,t),e.contexts={trace:{...e.contexts?.trace,...Tt(n)},...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:Dn(this,n),...e.sdkProcessingMetadata}),e))}_captureEvent(e,t={},n=L(),r=Ct()){return i&&di(e)&&_.log(`Captured error event \`${wr(e)[0]||`<unknown>`}\``),this._processEvent(e,t,n,r).then(e=>e.event_id,e=>{i&&(ci(e)?_.log(e.message):si(e)?_.warn(e.message):_.warn(e))})}_processEvent(e,t,n,r){let i=this.getOptions(),{sampleRate:a}=i,o=fi(e),s=di(e),c=`before send for type \`${e.type||`error`}\``,l=`before_send`,u=0,d=a===void 0?void 0:qt(a),f=s&&typeof d==`number`&&we()>d,p=er(e.type),m=0,h=n.getSession()||r.getSession();return f&&h?.status!==`ok`?(this.recordDroppedEvent(`sample_rate`,`error`),gr(oi(a))):this._prepareEvent(e,t,n,r).then(e=>{if(e===null)throw ai("An event processor returned `null`, will not send event.");return m=e.spans?.length||0,Cr(t)?e:ui(i,e,t,e=>{l=e},e=>{u=e})}).then(n=>{if(u&&this.recordDroppedEvent(`ignored`,`span`,u),!S(n)||n===null)throw this.recordDroppedEvent(l,p),o&&this.recordDroppedEvent(l,`span`,1+m-u),n===null?ai(`${l===`ignored`?"Transaction matched `ignoreSpans`":`${c} ${l===`callback_error`?`threw an error`:"returned `null`"}`}, will not send event.`):ii(`${c} must return \`null\` or a valid event.`);if(s&&h&&this._updateSessionFromEvent(h,n),f)throw this.recordDroppedEvent(`sample_rate`,`error`),oi(a);if(o){let e=m-u-(n.spans?.length||0);e>0&&this.recordDroppedEvent(`before_send`,`span`,e)}let r=n.transaction_info;return o&&r&&n.transaction!==e.transaction&&(n.transaction_info={...r,source:`custom`}),this.sendEvent(n,t),n}).then(null,e=>{throw ci(e)||si(e)?e:(this.captureException(e,{mechanism:{handled:!1,type:`internal`},data:{__sentry__:!0},originalException:e}),ii(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`))})}_process(e,t){this._numProcessing++,this._promiseBuffer.add(e).then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e===Lr&&this.recordDroppedEvent(`queue_overflow`,t),e))}_clearOutcomes(){let e=this._outcomes;return this._outcomes={},Object.entries(e).map(([e,t])=>{let[n,r]=e.split(`:`);return{reason:n,category:r,quantity:t}})}_flushOutcomes(){i&&_.log(`Flushing outcomes...`);let e=this._clearOutcomes();if(e.length===0){i&&_.log(`No outcomes to send`);return}if(!this._dsn){i&&_.log(`No dsn provided, will not send outcomes`);return}i&&_.log(`Sending outcomes:`,e);let t=Kr(e,this._options.tunnel&&B(this._dsn));this.sendEnvelope(t)}};function ui(e,t,n,r,a){let{beforeSend:o,ignoreSpans:s,beforeSendTransaction:c}=e,l=Rn(e.beforeSendSpan)&&e.beforeSendSpan,u=t;if(di(u)&&o){let e=u;return W(i?"The `beforeSend` callback threw an error, dropping the event:":``,()=>o(e,n),()=>(r(`callback_error`),null))}if(fi(u)){if(l||s){let e=qr(u);if(s?.length&&pn({description:e.description,op:e.op,attributes:e.data},s))return r(`ignored`),null;if(l&&(u=P(t,Jr(zn(e,l)))),u.spans){let e=[],t=u.spans;for(let n of t)s?.length&&pn({description:n.description,op:n.op,attributes:n.data},s)?hn(t,n):l?e.push(zn(n,l)):e.push(n);a(t.length-e.length),u.spans=e}}if(c)return W(i?"The `beforeSendTransaction` callback threw an error, dropping the event:":``,()=>c(u,n),()=>(r(`callback_error`),null))}return u}function di(e){return e.type===void 0}function fi(e){return e.type===`transaction`}var pi=`thismessage:/`;function mi(e){return`isRelative`in e}function hi(e,t){let n=e.indexOf(`://`)<=0&&e.indexOf(`//`)!==0,r=t??(n?pi:void 0);try{if(`canParse`in URL&&!URL.canParse(e,r))return;let t=new URL(e,r);return n?{isRelative:n,pathname:t.pathname,search:t.search,hash:t.hash}:t}catch{}}function gi(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function _i(e){let t=e?V(e):R()?.getDsn();return t?`/${gi(B(t))}`:void 0}function vi(e){let t=(e?.startsWith(`./`)?e.slice(1):e??``).replace(/\/$/,``);return!t||t.startsWith(`/`)?t:`/${t}`}function yi(e){`aggregates`in e?e.attrs?.ip_address===void 0&&(e.attrs={...e.attrs,ip_address:`{{auto}}`}):e.ipAddress===void 0&&(e.ipAddress=`{{auto}}`)}function bi(e,t,n=[t],r=`npm`){let i=(e._metadata=e._metadata||{}).sdk=e._metadata.sdk||{};i.name||(i.name=`sentry.javascript.${t}`,i.packages=n.map(e=>({name:`${r}:@sentry/${e}`,version:o})),i.version=o)}function xi(e,t,n,r,i,a){if(!i.exception?.values||!a||!y(a.originalException))return;let o=i.exception.values.length>0?i.exception.values[i.exception.values.length-1]:void 0;o&&(i.exception.values=Z(e,t,r,a.originalException,n,i.exception.values,o,0))}function Z(e,t,n,r,i,a,o,s){if(a.length>=n+1)return a;let c=[...a];if(y(r[i])){wi(o,s,r);let a=e(t,r[i]),l=c.length;Ti(a,i,l,s),c=Z(e,t,n,r[i],i,[a,...c],a,l)}return Si(r)&&r.errors.forEach((a,l)=>{if(c.length<n+1&&y(a)){wi(o,s,r);let u=e(t,a),d=c.length;Ti(u,`errors[${l}]`,d,s),c=Z(e,t,n,a,i,[u,...c],u,d)}}),Ci(r)&&[`error`,`suppressed`].forEach(a=>{let l=r[a];if(c.length<n+1&&y(l)){wi(o,s,r);let u=e(t,l),d=c.length;Ti(u,a,d,s),c=Z(e,t,n,l,i,[u,...c],u,d)}}),c}function Si(e){return Array.isArray(e.errors)}function Ci(e){return`error`in e&&`suppressed`in e}function wi(e,t,n){e.mechanism={handled:!0,type:`auto.core.linked_errors`,...Si(n)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function Ti(e,t,n,r){e.mechanism={handled:!0,...e.mechanism,type:`chained`,source:t,exception_id:n,parent_id:r}}function Ei(e){return y(e)&&`__sentry_fetch_url_host__`in e&&typeof e.__sentry_fetch_url_host__==`string`}function Di(e){let t=Oi(e.message);return Ei(e)?`${t} (${e.__sentry_fetch_url_host__})`:t}function Oi(e){if(typeof e==`string`)return e;if(e==null)return``;if(x(e))return String(e);if(S(e)||Array.isArray(e)){let t=Le(e,``);if(t)return t}return Me(void 0,e)}var ki=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,Ai=new WeakMap;function ji(e,t=R()){t?(ki&&Mi(t)&&_.warn(`A route provider is already registered for this client and will be replaced. Routes only the previous provider knows about will no longer resolve.`),Ai.set(t,e)):ki&&_.warn(`Cannot set a route provider without a client.`)}function Mi(e=R()){return e&&Ai.get(e)}var Q=a;function Ni(e,t){let n=$(e,t),r={type:Bi(t),value:Vi(t)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===``&&(r.value=`Unrecoverable error caught`),r}function Pi(e,t,n,r){let i=R()?.getOptions().normalizeDepth,a=Ji(t),o={__serialized__:Ae(t,i)};if(a)return{exception:{values:[Ni(e,a)]},extra:o};let s={exception:{values:[{type:C(t)?t.constructor.name:r?`UnhandledRejection`:`Error`,value:Ki(t,{isUnhandledRejection:r})}]},extra:o};if(n){let t=$(e,n);t.length&&(s.exception.values[0].stacktrace={frames:t})}return s}function Fi(e,t){return{exception:{values:[Ni(e,t)]}}}function $(e,t){let n=t.stacktrace||t.stack||``,r=Li(t),i=Ri(t);try{return e(n,r,i)}catch{}return[]}var Ii=/Minified React error #\d+;/i;function Li(e){return e&&Ii.test(e.message)?1:0}function Ri(e){return typeof e.framesToPop==`number`?e.framesToPop:0}function zi(e){return typeof WebAssembly<`u`&&WebAssembly.Exception!==void 0&&e instanceof WebAssembly.Exception}function Bi(e){let t=e?.name;return!t&&zi(e)?e.message&&Array.isArray(e.message)&&e.message.length==2?e.message[0]:`WebAssembly.Exception`:t}function Vi(e){let t=e?.message;return zi(e)?Array.isArray(e.message)&&e.message.length==2?e.message[1]:`wasm exception`:t?t.error&&typeof t.error.message==`string`?Di(t.error):Di(e):`No error message`}function Hi(e,t,n,r){let i=Wi(e,t,n?.syntheticException||void 0,r);return j(i),i.level=`error`,n?.event_id&&(i.event_id=n.event_id),q(i)}function Ui(e,t,n=`info`,r,i){let a=Gi(e,t,r?.syntheticException||void 0,i);return a.level=n,r?.event_id&&(a.event_id=r.event_id),q(a)}function Wi(e,t,n,r,i){let a;if(fe(t)&&t.error)return Fi(e,t.error);if(pe(t)||me(t)){let i=t;if(`stack`in t){a=Fi(e,t);let i=a.exception?.values?.[0];if(r&&n&&i&&!i.stacktrace){let t=$(e,n);t.length&&(i.stacktrace={frames:t},j(a,{synthetic:!0}))}}else{let t=i.name||(pe(i)?`DOMError`:`DOMException`),o=i.message?`${t}: ${i.message}`:t;a=Gi(e,o,n,r),Ue(a,o)}return a}if(y(t))return Fi(e,t);if(S(t)||C(t))return a=Pi(e,t,n,i),j(a,{synthetic:!0}),a;let o=String(t);return a=Gi(e,o,n,r),Ue(a,o,void 0),j(a,{synthetic:!0}),a}function Gi(e,t,n,r){let i={};if(r&&n){let r=$(e,n);r.length&&(i.exception={values:[{value:t,stacktrace:{frames:r}}]}),j(i,{synthetic:!0})}if(ge(t)){let{__sentry_template_string__:e,__sentry_template_values__:n}=t;return i.logentry={message:e,params:n},i}return i.message=t,i}function Ki(e,{isUnhandledRejection:t}){let n=Ce(e),r=t?`promise rejection`:`exception`;return fe(e)?`Event \`ErrorEvent\` captured as ${r} with message \`${e.message}\``:C(e)?`Event \`${qi(e)}\` (type=${e.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}function qi(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function Ji(e){return Object.values(e).find(y)}var Yi=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__;function Xi(e){let{tunnel:t,dsn:n,transportOptions:r}=e;if(!t)return{tunnel:t,transportOptions:r};if(typeof t==`string`)return{tunnel:t,transportOptions:Qi(t)?Zi(r):r};let i=t===!0?{}:t,a=n&&V(n),o=i.path??(a&&_i(a));if(!o)return{tunnel:void 0,transportOptions:r};let s=`${vi(i.basePath)}${o}${i.trailingSlash?`/`:``}`;return Yi&&_.log(`Tunneling events to "${s}"`),{tunnel:s,transportOptions:Zi(r)}}function Zi(e){return{...e,headers:{"Content-Type":`application/x-sentry-envelope`,...e?.headers}}}function Qi(e){let t=hi(e,Q.location?.href);return t?mi(t)||t.origin===Q.location?.origin:!1}var $i=class extends li{constructor(e){let t=ea({...e,...Xi(e)});bi(t,`browser`,[`browser`],Q.SENTRY_SDK_SOURCE||nr()),super(t),t.routeProvider&&ji(t.routeProvider,this),this._unhandledSessionStatus=`unhandled`;let{userInfo:n}=this.getDataCollectionOptions();t._metadata?.sdk&&(t._metadata.sdk.settings={infer_ip:n?`auto`:`never`,...t._metadata.sdk.settings});let{sendClientReports:r}=this._options,i=()=>{$e()},a=[[Q.document,`visibilitychange`,()=>{i(),Q.document.visibilityState===`hidden`&&(r&&this._flushOutcomes(),queueMicrotask(()=>{this.flush()}))}],[Q.document,`freeze`,i],[Q.document,`resume`,i],[Q,`pagehide`,i],[Q,`pageshow`,i]];a.forEach(([e,t,n])=>e?.addEventListener?.(t,n)),this.on(`close`,()=>a.forEach(([e,t,n])=>e?.removeEventListener?.(t,n))),n&&this.on(`beforeSendSession`,yi)}eventFromException(e,t){return Hi(this._options.stackParser,e,t,this._options.attachStacktrace)}eventFromMessage(e,t=`info`,n){return Ui(this._options.stackParser,e,t,n,this._options.attachStacktrace)}_prepareEvent(e,t,n,r){return e.platform=e.platform||`javascript`,super._prepareEvent(e,t,n,r)}};function ea(e){return{sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...e,release:e.release??ta()}}function ta(){return typeof __SENTRY_RELEASE__==`string`?__SENTRY_RELEASE__:na()??Q.SENTRY_RELEASE?.id}function na(){return Q.document?.querySelector?.(`meta[name="sentry-release"]`)?.getAttribute(`content`)||void 0}var ra=30,ia=50;function aa(e,t,n,r){let i={filename:e,function:t===`<anonymous>`?`?`:t,in_app:!0};return n!==void 0&&(i.lineno=n),r!==void 0&&(i.colno=r),i}var oa=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,sa=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?![^(]*\) )(?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ca=/\((\S*)(?::(\d+))(?::(\d+))\)/,la=/at (.+?) ?\(data:(.+?),/,ua=[ra,e=>{let t=e.match(la);if(t)return{filename:`<data:${t[2]}>`,function:t[1]};let n=oa.exec(e);if(n){let[,e,t,r]=n;return aa(e,`?`,+t,+r)}let r=sa.exec(e);if(r){if(r[2]?.indexOf(`eval`)===0){let e=ca.exec(r[2]);e&&(r[2]=e[1],r[3]=e[2],r[4]=e[3])}let[e,t]=ma(r[1]||`?`,r[2]);return aa(t,e,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}}],da=/^\s*(.*?)(?:\(([^()]*)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,fa=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,pa=se(ua,[ia,e=>{let t=da.exec(e);if(t){if(t[3]&&t[3].indexOf(` > eval`)>-1){let e=fa.exec(t[3]);e&&(t[1]=t[1]||`eval`,t[3]=e[1],t[4]=e[2],t[5]=``)}let e=t[3],n=t[1]||`?`;return[n,e]=ma(n,e),aa(e,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]),ma=(e,t)=>{let n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?`?`:e.split(`@`)[0],n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},ha=`cause`,ga=5,_a=`LinkedErrors`,va=xn(((e={})=>{let t=e.limit||ga,n=e.key||ha;return{name:_a,preprocessEvent(e,r,i){xi(Ni,i.getOptions().stackParser,n,t,e,r)}}}));function ya(i){let a=new $i({...i,dist:i.buildId,integrations:[],stackParser:pa,transport:e=>n(Gr,e),beforeSend:t,sendClientReports:!1,dataCollection:{...r,httpBodies:[]},beforeSendLog:()=>null,beforeSendMetric:()=>null});return a.init(),new e(a,`browser`,i.buildId,{Scope:F,linkedErrorsIntegration:va})}export{ya as createBrowserReporter};
3
+ //# debugId=b852e5e1-bd15-4376-87c0-22c52cdf555d