import*as Common from"../common/common.js";import*as SDK from"../sdk/sdk.js";import*as UI from"../ui/ui.js";import{NetworkGroupNode}from"./NetworkDataGridNode.js";export class NetworkFrameGrouper{constructor(e){this._parentView=e,this._activeGroups=new Map}groupNodeForRequest(e){const r=SDK.ResourceTreeModel.ResourceTreeModel.frameForRequest(e);if(!r||r.isTopFrame())return null;let o=this._activeGroups.get(r);return o||(o=new FrameGroupNode(this._parentView,r),this._activeGroups.set(r,o),o)}reset(){this._activeGroups.clear()}}export class FrameGroupNode extends NetworkGroupNode{constructor(e,r){super(e),this._frame=r}displayName(){return new Common.ParsedURL.ParsedURL(this._frame.url).domain()||this._frame.name||"<iframe>"}renderCell(e,r){super.renderCell(e,r);if(0===this.dataGrid.indexOfVisibleColumn(r)){const o=this.displayName();e.appendChild(UI.Icon.Icon.create("largeicon-navigator-frame","network-frame-group-icon")),UI.UIUtils.createTextChild(e,o),UI.Tooltip.Tooltip.install(e,o),this.setCellAccessibleName(e.textContent||"",e,r)}}}