@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 38.7 kB
JavaScript
import*as i18n from"../../core/i18n/i18n.js";import*as Platform from"../../core/platform/platform.js";import*as HeapSnapshotModel from"../../models/heap_snapshot_model/heap_snapshot_model.js";import{AllocationProfile}from"./AllocationProfile.js";export class HeapSnapshotEdge{snapshot;edges;edgeIndex;constructor(e,t){this.snapshot=e,this.edges=e.containmentEdges,this.edgeIndex=t||0}clone(){return new HeapSnapshotEdge(this.snapshot,this.edgeIndex)}hasStringName(){throw new Error("Not implemented")}name(){throw new Error("Not implemented")}node(){return this.snapshot.createNode(this.nodeIndex())}nodeIndex(){if(void 0===this.snapshot.edgeToNodeOffset)throw new Error("edgeToNodeOffset is undefined");return this.edges[this.edgeIndex+this.snapshot.edgeToNodeOffset]}toString(){return"HeapSnapshotEdge: "+this.name()}type(){return this.snapshot.edgeTypes[this.rawType()]}itemIndex(){return this.edgeIndex}serialize(){return new HeapSnapshotModel.HeapSnapshotModel.Edge(this.name(),this.node().serialize(),this.type(),this.edgeIndex)}rawType(){if(void 0===this.snapshot.edgeTypeOffset)throw new Error("edgeTypeOffset is undefined");return this.edges[this.edgeIndex+this.snapshot.edgeTypeOffset]}isInvisible(){throw new Error("Not implemented")}isWeak(){throw new Error("Not implemented")}}export class HeapSnapshotNodeIndexProvider{#e;constructor(e){this.#e=e.createNode()}itemForIndex(e){return this.#e.nodeIndex=e,this.#e}}export class HeapSnapshotEdgeIndexProvider{#t;constructor(e){this.#t=e.createEdge(0)}itemForIndex(e){return this.#t.edgeIndex=e,this.#t}}export class HeapSnapshotRetainerEdgeIndexProvider{#n;constructor(e){this.#n=e.createRetainingEdge(0)}itemForIndex(e){return this.#n.setRetainerIndex(e),this.#n}}export class HeapSnapshotEdgeIterator{#s;edge;constructor(e){this.#s=e,this.edge=e.snapshot.createEdge(e.edgeIndexesStart())}hasNext(){return this.edge.edgeIndex<this.#s.edgeIndexesEnd()}item(){return this.edge}next(){if(void 0===this.edge.snapshot.edgeFieldsCount)throw new Error("edgeFieldsCount is undefined");this.edge.edgeIndex+=this.edge.snapshot.edgeFieldsCount}}export class HeapSnapshotRetainerEdge{snapshot;#i;#o;#r;#d;#a;constructor(e,t){this.snapshot=e,this.setRetainerIndex(t)}clone(){return new HeapSnapshotRetainerEdge(this.snapshot,this.retainerIndex())}hasStringName(){return this.edge().hasStringName()}name(){return this.edge().name()}node(){return this.nodeInternal()}nodeIndex(){if(void 0===this.#r)throw new Error("retainingNodeIndex is undefined");return this.#r}retainerIndex(){return this.#i}setRetainerIndex(e){if(e!==this.#i){if(!this.snapshot.retainingEdges||!this.snapshot.retainingNodes)throw new Error("Snapshot does not contain retaining edges or retaining nodes");this.#i=e,this.#o=this.snapshot.retainingEdges[e],this.#r=this.snapshot.retainingNodes[e],this.#d=null,this.#a=null}}set edgeIndex(e){this.setRetainerIndex(e)}nodeInternal(){return this.#a||(this.#a=this.snapshot.createNode(this.#r)),this.#a}edge(){return this.#d||(this.#d=this.snapshot.createEdge(this.#o)),this.#d}toString(){return this.edge().toString()}itemIndex(){return this.#i}serialize(){return new HeapSnapshotModel.HeapSnapshotModel.Edge(this.name(),this.node().serialize(),this.type(),this.#o)}type(){return this.edge().type()}}export class HeapSnapshotRetainerEdgeIterator{#h;retainer;constructor(e){const t=e.snapshot,n=e.ordinal();if(!t.firstRetainerIndex)throw new Error("Snapshot does not contain firstRetainerIndex");const s=t.firstRetainerIndex[n];this.#h=t.firstRetainerIndex[n+1],this.retainer=t.createRetainingEdge(s)}hasNext(){return this.retainer.retainerIndex()<this.#h}item(){return this.retainer}next(){this.retainer.setRetainerIndex(this.retainer.retainerIndex()+1)}}export class HeapSnapshotNode{snapshot;nodeIndex;constructor(e,t){this.snapshot=e,this.nodeIndex=t||0}distance(){return this.snapshot.nodeDistances[this.nodeIndex/this.snapshot.nodeFieldCount]}className(){throw new Error("Not implemented")}classIndex(){throw new Error("Not implemented")}dominatorIndex(){const e=this.snapshot.nodeFieldCount;return this.snapshot.dominatorsTree[this.nodeIndex/this.snapshot.nodeFieldCount]*e}edges(){return new HeapSnapshotEdgeIterator(this)}edgesCount(){return(this.edgeIndexesEnd()-this.edgeIndexesStart())/this.snapshot.edgeFieldsCount}id(){throw new Error("Not implemented")}rawName(){throw new Error("Not implemented")}isRoot(){return this.nodeIndex===this.snapshot.rootNodeIndex}isUserRoot(){throw new Error("Not implemented")}isHidden(){throw new Error("Not implemented")}isArray(){throw new Error("Not implemented")}isDocumentDOMTreesRoot(){throw new Error("Not implemented")}name(){return this.snapshot.strings[this.nameInternal()]}retainedSize(){return this.snapshot.retainedSizes[this.ordinal()]}retainers(){return new HeapSnapshotRetainerEdgeIterator(this)}retainersCount(){const e=this.snapshot,t=this.ordinal();return e.firstRetainerIndex[t+1]-e.firstRetainerIndex[t]}selfSize(){const e=this.snapshot;return e.nodes[this.nodeIndex+e.nodeSelfSizeOffset]}type(){return this.snapshot.nodeTypes[this.rawType()]}traceNodeId(){const e=this.snapshot;return e.nodes[this.nodeIndex+e.nodeTraceNodeIdOffset]}itemIndex(){return this.nodeIndex}serialize(){return new HeapSnapshotModel.HeapSnapshotModel.Node(this.id(),this.name(),this.distance(),this.nodeIndex,this.retainedSize(),this.selfSize(),this.type())}nameInternal(){const e=this.snapshot;return e.nodes[this.nodeIndex+e.nodeNameOffset]}edgeIndexesStart(){return this.snapshot.firstEdgeIndexes[this.ordinal()]}edgeIndexesEnd(){return this.snapshot.firstEdgeIndexes[this.ordinal()+1]}ordinal(){return this.nodeIndex/this.snapshot.nodeFieldCount}nextNodeIndex(){return this.nodeIndex+this.snapshot.nodeFieldCount}rawType(){const e=this.snapshot;return e.nodes[this.nodeIndex+e.nodeTypeOffset]}}export class HeapSnapshotNodeIterator{node;#l;constructor(e){this.node=e,this.#l=e.snapshot.nodes.length}hasNext(){return this.node.nodeIndex<this.#l}item(){return this.node}next(){this.node.nodeIndex=this.node.nextNodeIndex()}}export class HeapSnapshotIndexRangeIterator{#c;#p;#g;constructor(e,t){this.#c=e,this.#p=t,this.#g=0}hasNext(){return this.#g<this.#p.length}item(){const e=this.#p[this.#g];return this.#c.itemForIndex(e)}next(){++this.#g}}export class HeapSnapshotFilteredIterator{#f;#u;constructor(e,t){this.#f=e,this.#u=t,this.skipFilteredItems()}hasNext(){return this.#f.hasNext()}item(){return this.#f.item()}next(){this.#f.next(),this.skipFilteredItems()}skipFilteredItems(){for(;this.#f.hasNext()&&this.#u&&!this.#u(this.#f.item());)this.#f.next()}}export class HeapSnapshotProgress{#x;constructor(e){this.#x=e}updateStatus(e){this.sendUpdateEvent(i18n.i18n.serializeUIString(e))}updateProgress(e,t,n){const s=(100*(n?t/n:0)).toFixed(0);this.sendUpdateEvent(i18n.i18n.serializeUIString(e,{PH1:s}))}reportProblem(e){this.#x&&this.#x.sendEvent(HeapSnapshotModel.HeapSnapshotModel.HeapSnapshotProgressEvent.BrokenSnapshot,e)}sendUpdateEvent(e){this.#x&&this.#x.sendEvent(HeapSnapshotModel.HeapSnapshotModel.HeapSnapshotProgressEvent.Update,e)}}export class HeapSnapshotProblemReport{#I;constructor(e){this.#I=[e]}addError(e){this.#I.length>100||this.#I.push(e)}toString(){return this.#I.join("\n ")}}export class HeapSnapshot{nodes;containmentEdges;#m;#S;#N;strings;#y;#O;#T;rootNodeIndexInternal;#w;#E;#C;#F;#H;nodeTypeOffset;nodeNameOffset;nodeIdOffset;nodeSelfSizeOffset;#v;nodeTraceNodeIdOffset;nodeFieldCount;nodeTypes;nodeArrayType;nodeHiddenType;nodeObjectType;nodeNativeType;nodeConsStringType;nodeSlicedStringType;nodeCodeType;nodeSyntheticType;edgeFieldsCount;edgeTypeOffset;edgeNameOffset;edgeToNodeOffset;edgeTypes;edgeElementType;edgeHiddenType;edgeInternalType;edgeShortcutType;edgeWeakType;edgeInvisibleType;#D;#b;#P;#R;#_;nodeCount;#z;retainedSizes;firstEdgeIndexes;retainingNodes;retainingEdges;firstRetainerIndex;nodeDistances;firstDominatedNodeIndex;dominatedNodes;dominatorsTree;#A;#M;#k;lazyStringCache;constructor(e,t){this.nodes=e.nodes,this.containmentEdges=e.edges,this.#m=e.snapshot.meta,this.#S=e.samples,this.#N=null,this.strings=e.strings,this.#y=e.locations,this.#O=t,this.#T=-5,this.rootNodeIndexInternal=0,e.snapshot.root_index&&(this.rootNodeIndexInternal=e.snapshot.root_index),this.#w={},this.#C={},this.#F={},this.#H=e}initialize(){const e=this.#m;this.nodeTypeOffset=e.node_fields.indexOf("type"),this.nodeNameOffset=e.node_fields.indexOf("name"),this.nodeIdOffset=e.node_fields.indexOf("id"),this.nodeSelfSizeOffset=e.node_fields.indexOf("self_size"),this.#v=e.node_fields.indexOf("edge_count"),this.nodeTraceNodeIdOffset=e.node_fields.indexOf("trace_node_id"),this.#M=e.node_fields.indexOf("detachedness"),this.nodeFieldCount=e.node_fields.length,this.nodeTypes=e.node_types[this.nodeTypeOffset],this.nodeArrayType=this.nodeTypes.indexOf("array"),this.nodeHiddenType=this.nodeTypes.indexOf("hidden"),this.nodeObjectType=this.nodeTypes.indexOf("object"),this.nodeNativeType=this.nodeTypes.indexOf("native"),this.nodeConsStringType=this.nodeTypes.indexOf("concatenated string"),this.nodeSlicedStringType=this.nodeTypes.indexOf("sliced string"),this.nodeCodeType=this.nodeTypes.indexOf("code"),this.nodeSyntheticType=this.nodeTypes.indexOf("synthetic"),this.edgeFieldsCount=e.edge_fields.length,this.edgeTypeOffset=e.edge_fields.indexOf("type"),this.edgeNameOffset=e.edge_fields.indexOf("name_or_index"),this.edgeToNodeOffset=e.edge_fields.indexOf("to_node"),this.edgeTypes=e.edge_types[this.edgeTypeOffset],this.edgeTypes.push("invisible"),this.edgeElementType=this.edgeTypes.indexOf("element"),this.edgeHiddenType=this.edgeTypes.indexOf("hidden"),this.edgeInternalType=this.edgeTypes.indexOf("internal"),this.edgeShortcutType=this.edgeTypes.indexOf("shortcut"),this.edgeWeakType=this.edgeTypes.indexOf("weak"),this.edgeInvisibleType=this.edgeTypes.indexOf("invisible");const t=e.location_fields||[];this.#D=t.indexOf("object_index"),this.#b=t.indexOf("script_id"),this.#P=t.indexOf("line"),this.#R=t.indexOf("column"),this.#_=t.length,this.nodeCount=this.nodes.length/this.nodeFieldCount,this.#z=this.containmentEdges.length/this.edgeFieldsCount,this.retainedSizes=new Float64Array(this.nodeCount),this.firstEdgeIndexes=new Uint32Array(this.nodeCount+1),this.retainingNodes=new Uint32Array(this.#z),this.retainingEdges=new Uint32Array(this.#z),this.firstRetainerIndex=new Uint32Array(this.nodeCount+1),this.nodeDistances=new Int32Array(this.nodeCount),this.firstDominatedNodeIndex=new Uint32Array(this.nodeCount+1),this.dominatedNodes=new Uint32Array(this.nodeCount-1),this.#O.updateStatus("Building edge indexes…"),this.buildEdgeIndexes(),this.#O.updateStatus("Building retainers…"),this.buildRetainers(),this.#O.updateStatus("Propagating DOM state…"),this.propagateDOMState(),this.#O.updateStatus("Calculating node flags…"),this.calculateFlags(),this.#O.updateStatus("Calculating distances…"),this.calculateDistances(),this.#O.updateStatus("Building postorder index…");const n=this.buildPostOrderIndex();if(this.#O.updateStatus("Building dominator tree…"),this.dominatorsTree=this.buildDominatorTree(n.postOrderIndex2NodeOrdinal,n.nodeOrdinal2PostOrderIndex),this.#O.updateStatus("Calculating retained sizes…"),this.calculateRetainedSizes(n.postOrderIndex2NodeOrdinal),this.#O.updateStatus("Building dominated nodes…"),this.buildDominatedNodes(),this.#O.updateStatus("Calculating statistics…"),this.calculateStatistics(),this.#O.updateStatus("Calculating samples…"),this.buildSamples(),this.#O.updateStatus("Building locations…"),this.buildLocationMap(),this.#O.updateStatus("Finished processing."),this.#H.snapshot.trace_function_count){this.#O.updateStatus("Building allocation statistics…");const e=this.nodes.length,t=this.nodeFieldCount,n=this.rootNode(),s={};for(let i=0;i<e;i+=t){n.nodeIndex=i;const e=n.traceNodeId();let t=s[e];t||(s[e]=t={count:0,size:0,ids:[]}),t.count++,t.size+=n.selfSize(),t.ids.push(n.id())}this.#A=new AllocationProfile(this.#H,s),this.#O.updateStatus("done")}}buildEdgeIndexes(){const e=this.nodes,t=this.nodeCount,n=this.firstEdgeIndexes,s=this.nodeFieldCount,i=this.edgeFieldsCount,o=this.#v;n[t]=this.containmentEdges.length;for(let r=0,d=0;r<t;++r)n[r]=d,d+=e[r*s+o]*i}buildRetainers(){const e=this.retainingNodes,t=this.retainingEdges,n=this.firstRetainerIndex,s=this.containmentEdges,i=this.edgeFieldsCount,o=this.nodeFieldCount,r=this.edgeToNodeOffset,d=this.firstEdgeIndexes,a=this.nodeCount;for(let e=r,t=s.length;e<t;e+=i){const t=s[e];if(t%o)throw new Error("Invalid toNodeIndex "+t);++n[t/o]}for(let t=0,s=0;t<a;t++){const i=n[t];n[t]=s,e[s]=i,s+=i}n[a]=e.length;let h=d[0];for(let l=0;l<a;++l){const a=h;h=d[l+1];const c=l*o;for(let d=a;d<h;d+=i){const i=s[d+r];if(i%o)throw new Error("Invalid toNodeIndex "+i);const a=n[i/o],h=a+--e[a];e[h]=c,t[h]=d}}}allNodes(){return new HeapSnapshotNodeIterator(this.rootNode())}rootNode(){return this.createNode(this.rootNodeIndexInternal)}get rootNodeIndex(){return this.rootNodeIndexInternal}get totalSize(){return this.rootNode().retainedSize()}getDominatedIndex(e){if(e%this.nodeFieldCount)throw new Error("Invalid nodeIndex: "+e);return this.firstDominatedNodeIndex[e/this.nodeFieldCount]}createFilter(e){const t=e.minNodeId,n=e.maxNodeId,s=e.allocationNodeId;let i;if("number"==typeof s){if(i=this.createAllocationStackFilter(s),!i)throw new Error("Unable to create filter");i.key="AllocationNodeId: "+s}else"number"==typeof t&&"number"==typeof n&&(i=this.createNodeIdFilter(t,n),i.key="NodeIdRange: "+t+".."+n);return i}search(e,t){const n=e.query;const s=e.isRegex?new RegExp(n):Platform.StringUtilities.createPlainTextSearchRegex(n,"i");const i=e.isRegex||!e.caseSensitive?function(e,t,n){return s.test(t)&&e.add(n),e}:function(e,t,s){return-1!==t.indexOf(n)&&e.add(s),e},o=this.strings.reduce(i,new Set);if(!o.size)return[];const r=this.createFilter(t),d=[],a=this.nodes.length,h=this.nodes,l=this.nodeNameOffset,c=this.nodeIdOffset,p=this.nodeFieldCount,g=this.rootNode();for(let e=0;e<a;e+=p)g.nodeIndex=e,r&&!r(g)||o.has(h[e+l])&&d.push(h[e+c]);return d}aggregatesWithFilter(e){const t=this.createFilter(e),n=t?t.key:"allObjects";return this.getAggregatesByClassName(!1,n,t)}createNodeIdFilter(e,t){return function(n){const s=n.id();return s>e&&s<=t}}createAllocationStackFilter(e){if(!this.#A)throw new Error("No Allocation Profile provided");const t=this.#A.traceIds(e);if(!t.length)return;const n={};for(let e=0;e<t.length;e++)n[t[e]]=!0;return function(e){return Boolean(n[e.traceNodeId()])}}getAggregatesByClassName(e,t,n){const s=this.buildAggregates(n);let i;return t&&this.#C[t]?i=this.#C[t]:(this.calculateClassesRetainedSize(s.aggregatesByClassIndex,n),i=s.aggregatesByClassName,t&&(this.#C[t]=i)),!e||t&&this.#F[t]||(this.sortAggregateIndexes(i),t&&(this.#F[t]=e)),i}allocationTracesTops(){return this.#A.serializeTraceTops()}allocationNodeCallers(e){return this.#A.serializeCallers(e)}allocationStack(e){const t=this.createNode(e).traceNodeId();return t?this.#A.serializeAllocationStack(t):null}aggregatesForDiff(){if(this.#E)return this.#E;const e=this.getAggregatesByClassName(!0,"allObjects");this.#E={};const t=this.createNode();for(const n in e){const s=e[n].idxs,i=new Array(s.length),o=new Array(s.length);for(let e=0;e<s.length;e++)t.nodeIndex=s[e],i[e]=t.id(),o[e]=t.selfSize();this.#E[n]={indexes:s,ids:i,selfSizes:o}}return this.#E}isUserRoot(e){return!0}calculateDistances(e){const t=this.nodeCount,n=this.nodeDistances,s=this.#T;for(let e=0;e<t;++e)n[e]=s;const i=new Uint32Array(this.nodeCount);let o=0;for(let e=this.rootNode().edges();e.hasNext();e.next()){const t=e.edge.node();this.isUserRoot(t)&&(n[t.ordinal()]=1,i[o++]=t.nodeIndex)}this.bfs(i,o,n,e),n[this.rootNode().ordinal()]=o>0?HeapSnapshotModel.HeapSnapshotModel.baseSystemDistance:0,i[0]=this.rootNode().nodeIndex,o=1,this.bfs(i,o,n,e)}bfs(e,t,n,s){const i=this.edgeFieldsCount,o=this.nodeFieldCount,r=this.containmentEdges,d=this.firstEdgeIndexes,a=this.edgeToNodeOffset,h=this.edgeTypeOffset,l=this.nodeCount,c=this.edgeWeakType,p=this.#T;let g=0;const f=this.createEdge(0),u=this.createNode(0);for(;g<t;){const l=e[g++],x=l/o,I=n[x]+1,m=d[x],S=d[x+1];u.nodeIndex=l;for(let d=m;d<S;d+=i){if(r[d+h]===c)continue;const i=r[d+a],l=i/o;n[l]===p&&(f.edgeIndex=d,s&&!s(u,f)||(n[l]=I,e[t++]=i))}}if(t>l)throw new Error("BFS failed. Nodes to visit ("+t+") is more than nodes count ("+l+")")}buildAggregates(e){const t={},n={},s=[],i=this.nodes,o=i.length,r=this.nodeNativeType,d=this.nodeFieldCount,a=this.nodeSelfSizeOffset,h=this.nodeTypeOffset,l=this.rootNode(),c=this.nodeDistances;for(let p=0;p<o;p+=d){if(l.nodeIndex=p,e&&!e(l))continue;const o=i[p+a];if(!o&&i[p+h]!==r)continue;const g=l.classIndex(),f=c[p/d];if(g in t){const e=t[g];if(!e)continue;e.distance=Math.min(e.distance,f),++e.count,e.self+=o,e.idxs.push(p)}else{const e=l.type(),i={count:1,distance:f,self:o,maxRet:0,type:e,name:"object"===e||"native"===e?l.name():null,idxs:[p]};t[g]=i,s.push(g),n[l.className()]=i}}for(let e=0,n=s.length;e<n;++e){const n=t[s[e]];n&&(n.idxs=n.idxs.slice())}return{aggregatesByClassName:n,aggregatesByClassIndex:t}}calculateClassesRetainedSize(e,t){const n=this.rootNodeIndexInternal,s=this.createNode(n),i=[n],o=[-1],r=[],d=new Map,a=this.nodeFieldCount,h=this.nodeTypeOffset,l=this.nodeNativeType,c=this.dominatedNodes,p=this.nodes,g=this.firstDominatedNodeIndex;for(;i.length;){const n=i.pop();s.nodeIndex=n;let f=s.classIndex();const u=Boolean(d.get(f)),x=n/a,I=g[x],m=g[x+1];u||t&&!t(s)||!s.selfSize()&&p[n+h]!==l||(e[f].maxRet+=s.retainedSize(),I!==m&&(d.set(f,!0),o.push(i.length),r.push(f)));for(let e=I;e<m;e++)i.push(c[e]);const S=i.length;for(;o[o.length-1]===S;)o.pop(),f=r.pop(),d.set(f,!1)}}sortAggregateIndexes(e){const t=this.createNode(),n=this.createNode();for(const s in e)e[s].idxs.sort(((e,s)=>(t.nodeIndex=e,n.nodeIndex=s,t.id()<n.id()?-1:1)))}isEssentialEdge(e,t){return t!==this.edgeWeakType&&(t!==this.edgeShortcutType||e===this.rootNodeIndexInternal)}buildPostOrderIndex(){const e=this.nodeFieldCount,t=this.nodeCount,n=this.rootNodeIndexInternal/e,s=this.edgeFieldsCount,i=this.edgeTypeOffset,o=this.edgeToNodeOffset,r=this.firstEdgeIndexes,d=this.containmentEdges,a=this.userObjectsMapAndFlag(),h=a?a.map:null,l=a?a.flag:0,c=new Uint32Array(t),p=new Uint32Array(t),g=new Uint32Array(t),f=new Uint32Array(t),u=new Uint8Array(t);let x=0,I=0;c[0]=n,p[0]=r[n],u[n]=1;let m=0;for(;;){for(++m;I>=0;){const t=c[I],a=p[I];if(a<r[t+1]){p[I]+=s;const g=d[a+i];if(!this.isEssentialEdge(t*e,g))continue;const f=d[a+o]/e;if(u[f])continue;const x=!h||h[t]&l,m=!h||h[f]&l;if(t!==n&&m&&!x)continue;++I,c[I]=f,p[I]=r[f],u[f]=1}else f[t]=x,g[x++]=t,--I}if(x===t||m>1)break;const a=new HeapSnapshotProblemReport(`Heap snapshot: ${t-x} nodes are unreachable from the root. Following nodes have only weak retainers:`),S=this.rootNode();--x,I=0,c[0]=n,p[0]=r[n+1];for(let n=0;n<t;++n){if(u[n]||!this.hasOnlyWeakRetainers(n))continue;c[++I]=n,p[I]=r[n],u[n]=1,S.nodeIndex=n*e;const t=[];for(let e=S.retainers();e.hasNext();e.next())t.push(`${e.item().node().name()}@${e.item().node().id()}.${e.item().name()}`);a.addError(`${S.name()} @${S.id()} weak retainers: ${t.join(", ")}`)}console.warn(a.toString())}if(x!==t){const s=new HeapSnapshotProblemReport("Still found "+(t-x)+" unreachable nodes in heap snapshot:"),i=this.rootNode();--x;for(let n=0;n<t;++n)u[n]||(i.nodeIndex=n*e,s.addError(i.name()+" @"+i.id()),f[n]=x,g[x++]=n);f[n]=x,g[x++]=n,console.warn(s.toString())}return{postOrderIndex2NodeOrdinal:g,nodeOrdinal2PostOrderIndex:f}}hasOnlyWeakRetainers(e){const t=this.edgeTypeOffset,n=this.edgeWeakType,s=this.edgeShortcutType,i=this.containmentEdges,o=this.retainingEdges,r=this.firstRetainerIndex[e],d=this.firstRetainerIndex[e+1];for(let e=r;e<d;++e){const r=i[o[e]+t];if(r!==n&&r!==s)return!1}return!0}buildDominatorTree(e,t){const n=this.nodeFieldCount,s=this.firstRetainerIndex,i=this.retainingNodes,o=this.retainingEdges,r=this.edgeFieldsCount,d=this.edgeTypeOffset,a=this.edgeToNodeOffset,h=this.firstEdgeIndexes,l=this.containmentEdges,c=this.rootNodeIndexInternal,p=this.userObjectsMapAndFlag(),g=p?p.map:null,f=p?p.flag:0,u=e.length,x=u-1,I=u,m=new Uint32Array(u);for(let e=0;e<x;++e)m[e]=I;m[x]=x;const S=new Uint8Array(u);let N;{N=this.rootNodeIndexInternal/n;const e=h[N+1];for(let s=h[N];s<e;s+=r){const e=l[s+d];if(!this.isEssentialEdge(this.rootNodeIndexInternal,e))continue;S[t[l[s+a]/n]]=1}}let y=!0;for(;y;){y=!1;for(let p=x-1;p>=0;--p){if(0===S[p])continue;if(S[p]=0,m[p]===x)continue;N=e[p];const u=!g||g[N]&f;let O=I;const T=s[N],w=s[N+1];let E=!0;for(let e=T;e<w;++e){const s=l[o[e]+d],r=i[e];if(!this.isEssentialEdge(r,s))continue;E=!1;const a=r/n,h=!g||g[a]&f;if(r!==c&&u&&!h)continue;let p=t[a];if(m[p]!==I){if(O===I)O=p;else for(;p!==O;){for(;p<O;)p=m[p];for(;O<p;)O=m[O]}if(O===x)break}}if(E&&(O=x),O!==I&&m[p]!==O){m[p]=O,y=!0,N=e[p];const s=h[N]+a,i=h[N+1];for(let e=s;e<i;e+=r){S[t[l[e]/n]]=1}}}}const O=new Uint32Array(u);for(let t=0,n=m.length;t<n;++t)N=e[t],O[N]=e[m[t]];return O}calculateRetainedSizes(e){const t=this.nodeCount,n=this.nodes,s=this.nodeSelfSizeOffset,i=this.nodeFieldCount,o=this.dominatorsTree,r=this.retainedSizes;for(let e=0;e<t;++e)r[e]=n[e*i+s];for(let n=0;n<t-1;++n){const t=e[n];r[o[t]]+=r[t]}}buildDominatedNodes(){const e=this.firstDominatedNodeIndex,t=this.dominatedNodes,n=this.nodeFieldCount,s=this.dominatorsTree;let i=0,o=this.nodeCount;const r=this.rootNodeIndexInternal/n;if(r===i)i=1;else{if(r!==o-1)throw new Error("Root node is expected to be either first or last");o-=1}for(let t=i;t<o;++t)++e[s[t]];let d=0;for(let n=0,s=this.nodeCount;n<s;++n){const s=t[d]=e[n];e[n]=d,d+=s}e[this.nodeCount]=t.length;for(let r=i;r<o;++r){let i=e[s[r]];i+=--t[i],t[i]=r*n}}iterateFilteredChildren(e,t,n){const s=this.firstEdgeIndexes[e],i=this.firstEdgeIndexes[e+1];for(let e=s;e<i;e+=this.edgeFieldsCount){const s=this.containmentEdges[e+this.edgeToNodeOffset]/this.nodeFieldCount;t(this.containmentEdges[e+this.edgeTypeOffset])&&n(s)}}addString(e){return this.strings.push(e),this.strings.length-1}propagateDOMState(){if(-1===this.#M)return;console.time("propagateDOMState");const e=new Uint8Array(this.nodeCount),t=[],n=[],s=new Map,i=function(i,o,r){if(e[o])return;const d=o*i.nodeFieldCount;i.nodes[d+i.nodeTypeOffset]===i.nodeNativeType?(i.nodes[d+i.#M]=r,1===r?t.push(o):2===r&&(!function(e,t){const n=e.nodes[t+e.nodeNameOffset];let i=s.get(n);void 0===i&&(i=e.addString("Detached "+e.strings[n]),s.set(n,i)),e.nodes[t+e.nodeNameOffset]=i}(i,d),n.push(o)),e[o]=1):e[o]=1},o=function(e,t,n){e.iterateFilteredChildren(t,(t=>![e.edgeHiddenType,e.edgeInvisibleType,e.edgeWeakType].includes(t)),(t=>i(e,t,n)))};for(let e=0;e<this.nodeCount;++e){const t=this.nodes[e*this.nodeFieldCount+this.#M];0!==t&&i(this,e,t)}for(;0!==t.length;){o(this,t.pop(),1)}for(;0!==n.length;){const e=n.pop();1!==this.nodes[e*this.nodeFieldCount+this.#M]&&o(this,e,2)}console.timeEnd("propagateDOMState")}buildSamples(){const e=this.#S;if(!e||!e.length)return;const t=e.length/2,n=new Array(t),s=new Array(t),i=new Array(t),o=this.#m.sample_fields.indexOf("timestamp_us"),r=this.#m.sample_fields.indexOf("last_assigned_id");for(let d=0;d<t;d++)n[d]=0,s[d]=e[2*d+o]/1e3,i[d]=e[2*d+r];const d=this.nodes.length,a=this.nodeFieldCount,h=this.rootNode();for(let e=0;e<d;e+=a){h.nodeIndex=e;const s=h.id();if(s%2==0)continue;const o=Platform.ArrayUtilities.lowerBound(i,s,Platform.ArrayUtilities.DEFAULT_COMPARATOR);o!==t&&(n[o]+=h.selfSize())}this.#N=new HeapSnapshotModel.HeapSnapshotModel.Samples(s,i,n)}buildLocationMap(){const e=new Map,t=this.#y;for(let n=0;n<t.length;n+=this.#_){const s=t[n+this.#D],i=t[n+this.#b],o=t[n+this.#P],r=t[n+this.#R];e.set(s,new HeapSnapshotModel.HeapSnapshotModel.Location(i,o,r))}this.#k=e}getLocation(e){return this.#k.get(e)||null}getSamples(){return this.#N}calculateFlags(){throw new Error("Not implemented")}calculateStatistics(){throw new Error("Not implemented")}userObjectsMapAndFlag(){throw new Error("Not implemented")}calculateSnapshotDiff(e,t){let n=this.#w[e];if(n)return n;n={};const s=this.getAggregatesByClassName(!0,"allObjects");for(const e in t){const i=t[e],o=this.calculateDiffForClass(i,s[e]);o&&(n[e]=o)}const i=new HeapSnapshotModel.HeapSnapshotModel.AggregateForDiff;for(const e in s){if(e in t)continue;const o=this.calculateDiffForClass(i,s[e]);o&&(n[e]=o)}return this.#w[e]=n,n}calculateDiffForClass(e,t){const n=e.ids,s=e.indexes,i=e.selfSizes,o=t?t.idxs:[];let r=0,d=0;const a=n.length,h=o.length,l=new HeapSnapshotModel.HeapSnapshotModel.Diff,c=this.createNode(o[d]);for(;r<a&&d<h;){const e=n[r];e<c.id()?(l.deletedIndexes.push(s[r]),l.removedCount++,l.removedSize+=i[r],++r):e>c.id()?(l.addedIndexes.push(o[d]),l.addedCount++,l.addedSize+=c.selfSize(),c.nodeIndex=o[++d]):(++r,c.nodeIndex=o[++d])}for(;r<a;)l.deletedIndexes.push(s[r]),l.removedCount++,l.removedSize+=i[r],++r;for(;d<h;)l.addedIndexes.push(o[d]),l.addedCount++,l.addedSize+=c.selfSize(),c.nodeIndex=o[++d];return l.countDelta=l.addedCount-l.removedCount,l.sizeDelta=l.addedSize-l.removedSize,l.addedCount||l.removedCount?l:null}nodeForSnapshotObjectId(e){for(let t=this.allNodes();t.hasNext();t.next())if(t.node.id()===e)return t.node;return null}nodeClassName(e){const t=this.nodeForSnapshotObjectId(e);return t?t.className():null}idsOfObjectsWithName(e){const t=[];for(let n=this.allNodes();n.hasNext();n.next())n.item().name()===e&&t.push(n.item().id());return t}createEdgesProvider(e){const t=this.createNode(e),n=this.containmentEdgesFilter(),s=new HeapSnapshotEdgeIndexProvider(this);return new HeapSnapshotEdgesProvider(this,n,t.edges(),s)}createEdgesProviderForTest(e,t){const n=this.createNode(e),s=new HeapSnapshotEdgeIndexProvider(this);return new HeapSnapshotEdgesProvider(this,t,n.edges(),s)}retainingEdgesFilter(){return null}containmentEdgesFilter(){return null}createRetainingEdgesProvider(e){const t=this.createNode(e),n=this.retainingEdgesFilter(),s=new HeapSnapshotRetainerEdgeIndexProvider(this);return new HeapSnapshotEdgesProvider(this,n,t.retainers(),s)}createAddedNodesProvider(e,t){const n=this.#w[e][t];return new HeapSnapshotNodesProvider(this,n.addedIndexes)}createDeletedNodesProvider(e){return new HeapSnapshotNodesProvider(this,e)}createNodesProviderForClass(e,t){return new HeapSnapshotNodesProvider(this,this.aggregatesWithFilter(t)[e].idxs)}maxJsNodeId(){const e=this.nodeFieldCount,t=this.nodes,n=t.length;let s=0;for(let i=this.nodeIdOffset;i<n;i+=e){const e=t[i];e%2!=0&&(s<e&&(s=e))}return s}updateStaticData(){return new HeapSnapshotModel.HeapSnapshotModel.StaticData(this.nodeCount,this.rootNodeIndexInternal,this.totalSize,this.maxJsNodeId())}}class HeapSnapshotMetainfo{location_fields=[];node_fields=[];node_types=[];edge_fields=[];edge_types=[];trace_function_info_fields=[];trace_node_fields=[];sample_fields=[];type_strings={}}export class HeapSnapshotHeader{title;meta;node_count;edge_count;trace_function_count;root_index;constructor(){this.title="",this.meta=new HeapSnapshotMetainfo,this.node_count=0,this.edge_count=0,this.trace_function_count=0,this.root_index=0}}export class HeapSnapshotItemProvider{iterator;#U;#j;iterationOrder;currentComparator;#B;#L;constructor(e,t){this.iterator=e,this.#U=t,this.#j=!e.hasNext(),this.iterationOrder=null,this.currentComparator=null,this.#B=0,this.#L=0}createIterationOrder(){if(!this.iterationOrder){this.iterationOrder=[];for(let e=this.iterator;e.hasNext();e.next())this.iterationOrder.push(e.item().itemIndex())}}isEmpty(){return this.#j}serializeItemsRange(e,t){if(this.createIterationOrder(),e>t)throw new Error("Start position > end position: "+e+" > "+t);if(!this.iterationOrder)throw new Error("Iteration order undefined");if(t>this.iterationOrder.length&&(t=this.iterationOrder.length),this.#B<t&&e<this.iterationOrder.length-this.#L&&this.currentComparator){const n=this.currentComparator;this.sort(n,this.#B,this.iterationOrder.length-1-this.#L,e,t-1),e<=this.#B&&(this.#B=t),t>=this.iterationOrder.length-this.#L&&(this.#L=this.iterationOrder.length-e)}let n=e;const s=t-e,i=new Array(s);for(let e=0;e<s;++e){const t=this.iterationOrder[n++],s=this.#U.itemForIndex(t);i[e]=s.serialize()}return new HeapSnapshotModel.HeapSnapshotModel.ItemsRange(e,t,this.iterationOrder.length,i)}sortAndRewind(e){this.currentComparator=e,this.#B=0,this.#L=0}}export class HeapSnapshotEdgesProvider extends HeapSnapshotItemProvider{snapshot;constructor(e,t,n,s){super(t?new HeapSnapshotFilteredIterator(n,t):n,s),this.snapshot=e}sort(e,t,n,s,i){const o=e.fieldName1,r=e.fieldName2,d=e.ascending1,a=e.ascending2,h=this.iterator.item().clone(),l=h.clone(),c=this.snapshot.createNode(),p=this.snapshot.createNode();function g(e,t,n){if(h.edgeIndex=t,l.edgeIndex=n,"__proto__"===l.name())return-1;if("__proto__"===h.name())return 1;const s=h.hasStringName()===l.hasStringName()?h.name()<l.name()?-1:h.name()>l.name()?1:0:h.hasStringName()?-1:1;return e?s:-s}function f(e,t,n,s){h.edgeIndex=n,c.nodeIndex=h.nodeIndex();const i=c[e]();l.edgeIndex=s,p.nodeIndex=l.nodeIndex();const o=p[e](),r=i<o?-1:i>o?1:0;return t?r:-r}if(!this.iterationOrder)throw new Error("Iteration order not defined");"!edgeName"===o?Platform.ArrayUtilities.sortRange(this.iterationOrder,(function(e,t){let n=g(d,e,t);return 0===n&&(n=f(r,a,e,t)),0===n?e-t:n}),t,n,s,i):"!edgeName"===r?Platform.ArrayUtilities.sortRange(this.iterationOrder,(function(e,t){let n=f(o,d,e,t);return 0===n&&(n=g(a,e,t)),0===n?e-t:n}),t,n,s,i):Platform.ArrayUtilities.sortRange(this.iterationOrder,(function(e,t){let n=f(o,d,e,t);return 0===n&&(n=f(r,a,e,t)),0===n?e-t:n}),t,n,s,i)}}export class HeapSnapshotNodesProvider extends HeapSnapshotItemProvider{snapshot;constructor(e,t){const n=new HeapSnapshotNodeIndexProvider(e);super(new HeapSnapshotIndexRangeIterator(n,t),n),this.snapshot=e}nodePosition(e){this.createIterationOrder();const t=this.snapshot.createNode();let n=0;if(!this.iterationOrder)throw new Error("Iteration order not defined");for(;n<this.iterationOrder.length&&(t.nodeIndex=this.iterationOrder[n],t.id()!==e);n++);if(n===this.iterationOrder.length)return-1;const s=this.iterationOrder[n];let i=0;const o=this.currentComparator,r=this.buildCompareFunction(o);for(let e=0;e<this.iterationOrder.length;e++)r(this.iterationOrder[e],s)<0&&++i;return i}buildCompareFunction(e){const t=this.snapshot.createNode(),n=this.snapshot.createNode(),s=t[e.fieldName1],i=t[e.fieldName2],o=e.ascending1?1:-1,r=e.ascending2?1:-1;function d(e,s){const i=e.call(t),o=e.call(n);return i<o?-s:i>o?s:0}return function(e,a){t.nodeIndex=e,n.nodeIndex=a;let h=d(s,o);return 0===h&&(h=d(i,r)),h||e-a}}sort(e,t,n,s,i){if(!this.iterationOrder)throw new Error("Iteration order not defined");Platform.ArrayUtilities.sortRange(this.iterationOrder,this.buildCompareFunction(e),t,n,s,i)}}export class JSHeapSnapshot extends HeapSnapshot{nodeFlags;lazyStringCache;flags;#W;constructor(e,t){super(e,t),this.nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4},this.lazyStringCache={},this.initialize()}createNode(e){return new JSHeapSnapshotNode(this,void 0===e?-1:e)}createEdge(e){return new JSHeapSnapshotEdge(this,e)}createRetainingEdge(e){return new JSHeapSnapshotRetainerEdge(this,e)}containmentEdgesFilter(){return e=>!e.isInvisible()}retainingEdgesFilter(){const e=this.containmentEdgesFilter();return function(t){return e(t)&&!t.node().isRoot()&&!t.isWeak()}}calculateFlags(){this.flags=new Uint32Array(this.nodeCount),this.markDetachedDOMTreeNodes(),this.markQueriableHeapObjects(),this.markPageOwnedNodes()}calculateDistances(){super.calculateDistances((function(e,t){if(e.isHidden())return"sloppy_function_map"!==t.name()||"system / NativeContext"!==e.rawName();if(e.isArray()){if("(map descriptors)"!==e.rawName())return!0;const n=parseInt(t.name(),10);return n<2||n%3!=1}return!0}))}isUserRoot(e){return e.isUserRoot()||e.isDocumentDOMTreesRoot()}userObjectsMapAndFlag(){return{map:this.flags,flag:this.nodeFlags.pageObject}}flagsOfNode(e){return this.flags[e.nodeIndex/this.nodeFieldCount]}markDetachedDOMTreeNodes(){const e=this.nodes,t=e.length,n=this.nodeFieldCount,s=this.nodeNativeType,i=this.nodeTypeOffset,o=this.nodeFlags.detachedDOMTreeNode,r=this.rootNode();for(let d=0,a=0;d<t;d+=n,a++){e[d+i]===s&&(r.nodeIndex=d,r.name().startsWith("Detached ")&&(this.flags[a]|=o))}}markQueriableHeapObjects(){const e=this.nodeFlags.canBeQueried,t=this.edgeHiddenType,n=this.edgeInternalType,s=this.edgeInvisibleType,i=this.edgeWeakType,o=this.edgeToNodeOffset,r=this.edgeTypeOffset,d=this.edgeFieldsCount,a=this.containmentEdges,h=this.nodeFieldCount,l=this.firstEdgeIndexes,c=this.flags,p=[];for(let e=this.rootNode().edges();e.hasNext();e.next())e.edge.node().isUserRoot()&&p.push(e.edge.node().nodeIndex/h);for(;p.length;){const g=p.pop();if(c[g]&e)continue;c[g]|=e;const f=l[g],u=l[g+1];for(let l=f;l<u;l+=d){const d=a[l+o]/h;if(c[d]&e)continue;const g=a[l+r];g!==t&&g!==s&&g!==n&&g!==i&&p.push(d)}}}markPageOwnedNodes(){const e=this.edgeShortcutType,t=this.edgeElementType,n=this.edgeToNodeOffset,s=this.edgeTypeOffset,i=this.edgeFieldsCount,o=this.edgeWeakType,r=this.firstEdgeIndexes,d=this.containmentEdges,a=this.nodeFieldCount,h=this.nodeCount,l=this.flags,c=this.nodeFlags.pageObject,p=new Uint32Array(h);let g=0;const f=this.rootNodeIndexInternal/a,u=this.rootNode();for(let o=r[f],h=r[f+1];o<h;o+=i){const i=d[o+s],r=d[o+n];if(i===t){if(u.nodeIndex=r,!u.isDocumentDOMTreesRoot())continue}else if(i!==e)continue;const h=r/a;p[g++]=h,l[h]|=c}for(;g;){const e=p[--g],t=r[e],h=r[e+1];for(let e=t;e<h;e+=i){const t=d[e+n]/a;if(l[t]&c)continue;d[e+s]!==o&&(p[g++]=t,l[t]|=c)}}}calculateStatistics(){const e=this.nodeFieldCount,t=this.nodes,n=t.length,s=this.nodeTypeOffset,i=this.nodeSelfSizeOffset,o=this.nodeNativeType,r=this.nodeCodeType,d=this.nodeConsStringType,a=this.nodeSlicedStringType,h=this.nodeDistances;let l=0,c=0,p=0,g=0,f=0;const u=this.rootNode();for(let x=0;x<n;x+=e){const n=t[x+i];if(h[x/e]>=HeapSnapshotModel.HeapSnapshotModel.baseSystemDistance){f+=n;continue}const I=t[x+s];u.nodeIndex=x,I===o?l+=n:I===r?c+=n:I===d||I===a||"string"===u.type()?p+=n:"Array"===u.name()&&(g+=this.calculateArraySize(u))}this.#W=new HeapSnapshotModel.HeapSnapshotModel.Statistics,this.#W.total=this.totalSize,this.#W.v8heap=this.totalSize-l,this.#W.native=l,this.#W.code=c,this.#W.jsArrays=g,this.#W.strings=p,this.#W.system=f}calculateArraySize(e){let t=e.selfSize();const n=e.edgeIndexesStart(),s=e.edgeIndexesEnd(),i=this.containmentEdges,o=this.strings,r=this.edgeToNodeOffset,d=this.edgeTypeOffset,a=this.edgeNameOffset,h=this.edgeFieldsCount,l=this.edgeInternalType;for(let c=n;c<s;c+=h){if(i[c+d]!==l)continue;if("elements"!==o[i[c+a]])continue;const n=i[c+r];e.nodeIndex=n,1===e.retainersCount()&&(t+=e.selfSize());break}return t}getStatistics(){return this.#W}}export class JSHeapSnapshotNode extends HeapSnapshotNode{constructor(e,t){super(e,t)}canBeQueried(){const e=this.snapshot,t=e.flagsOfNode(this);return Boolean(t&e.nodeFlags.canBeQueried)}rawName(){return super.name()}name(){const e=this.snapshot;if(this.rawType()===e.nodeConsStringType){let t=e.lazyStringCache[this.nodeIndex];return void 0===t&&(t=this.consStringName(),e.lazyStringCache[this.nodeIndex]=t),t}return this.rawName()}consStringName(){const e=this.snapshot,t=e.nodeConsStringType,n=e.edgeInternalType,s=e.edgeFieldsCount,i=e.edgeToNodeOffset,o=e.edgeTypeOffset,r=e.edgeNameOffset,d=e.strings,a=e.containmentEdges,h=e.firstEdgeIndexes,l=e.nodeFieldCount,c=e.nodeTypeOffset,p=e.nodeNameOffset,g=e.nodes,f=[];f.push(this.nodeIndex);let u="";for(;f.length&&u.length<1024;){const e=f.pop();if(g[e+c]!==t){u+=d[g[e+p]];continue}const x=e/l,I=h[x],m=h[x+1];let S=0,N=0;for(let e=I;e<m&&(!S||!N);e+=s){if(a[e+o]===n){const t=d[a[e+r]];"first"===t?S=a[e+i]:"second"===t&&(N=a[e+i])}}f.push(N),f.push(S)}return u}className(){const e=this.type();switch(e){case"hidden":return"(system)";case"object":case"native":return this.name();case"code":return"(compiled code)";default:return"("+e+")"}}classIndex(){const e=this.snapshot,t=e.nodes,n=t[this.nodeIndex+e.nodeTypeOffset];return n===e.nodeObjectType||n===e.nodeNativeType?t[this.nodeIndex+e.nodeNameOffset]:-1-n}id(){const e=this.snapshot;return e.nodes[this.nodeIndex+e.nodeIdOffset]}isHidden(){return this.rawType()===this.snapshot.nodeHiddenType}isArray(){return this.rawType()===this.snapshot.nodeArrayType}isSynthetic(){return this.rawType()===this.snapshot.nodeSyntheticType}isUserRoot(){return!this.isSynthetic()}isDocumentDOMTreesRoot(){return this.isSynthetic()&&"(Document DOM trees)"===this.name()}serialize(){const e=super.serialize(),t=this.snapshot,n=t.flagsOfNode(this);return n&t.nodeFlags.canBeQueried&&(e.canBeQueried=!0),n&t.nodeFlags.detachedDOMTreeNode&&(e.detachedDOMTreeNode=!0),e}}export class JSHeapSnapshotEdge extends HeapSnapshotEdge{constructor(e,t){super(e,t)}clone(){const e=this.snapshot;return new JSHeapSnapshotEdge(e,this.edgeIndex)}hasStringName(){return this.isShortcut()?isNaN(parseInt(this.nameInternal(),10)):this.hasStringNameInternal()}isElement(){return this.rawType()===this.snapshot.edgeElementType}isHidden(){return this.rawType()===this.snapshot.edgeHiddenType}isWeak(){return this.rawType()===this.snapshot.edgeWeakType}isInternal(){return this.rawType()===this.snapshot.edgeInternalType}isInvisible(){return this.rawType()===this.snapshot.edgeInvisibleType}isShortcut(){return this.rawType()===this.snapshot.edgeShortcutType}name(){const e=this.nameInternal();if(!this.isShortcut())return String(e);const t=parseInt(e,10);return String(isNaN(t)?e:t)}toString(){const e=this.name();switch(this.type()){case"context":return"->"+e;case"element":return"["+e+"]";case"weak":return"[["+e+"]]";case"property":return-1===e.indexOf(" ")?"."+e:'["'+e+'"]';case"shortcut":return"string"==typeof e?-1===e.indexOf(" ")?"."+e:'["'+e+'"]':"["+e+"]";case"internal":case"hidden":case"invisible":return"{"+e+"}"}return"?"+e+"?"}hasStringNameInternal(){const e=this.rawType(),t=this.snapshot;return e!==t.edgeElementType&&e!==t.edgeHiddenType}nameInternal(){return this.hasStringNameInternal()?this.snapshot.strings[this.nameOrIndex()]:this.nameOrIndex()}nameOrIndex(){return this.edges[this.edgeIndex+this.snapshot.edgeNameOffset]}rawType(){return this.edges[this.edgeIndex+this.snapshot.edgeTypeOffset]}}export class JSHeapSnapshotRetainerEdge extends HeapSnapshotRetainerEdge{constructor(e,t){super(e,t)}clone(){const e=this.snapshot;return new JSHeapSnapshotRetainerEdge(e,this.retainerIndex())}isHidden(){return this.edge().isHidden()}isInternal(){return this.edge().isInternal()}isInvisible(){return this.edge().isInvisible()}isShortcut(){return this.edge().isShortcut()}isWeak(){return this.edge().isWeak()}}