var Se=Object.defineProperty;var L=(n,e)=>{for(var t in e)Se(n,t,{get:e[t],enumerable:!0})};var ae={};L(ae,{CategorizedBreakpointsSidebarPane:()=>I,DEFAULT_VIEW:()=>se});import*as U from"./../../core/i18n/i18n.js";import*as W from"./../../core/platform/platform.js";import*as b from"./../../core/sdk/sdk.js";import*as T from"./../sources/sources.js";import*as B from"./../../ui/legacy/legacy.js";import*as P from"./../../ui/lit/lit.js";import*as ne from"./../../ui/visual_logging/visual_logging.js";var ie=`:host{margin:0;padding:2px 4px;min-height:18px}.tree-outline{padding:0}.tree-outline li{margin-left:14px;user-select:text}.tree-outline li.parent{margin-left:1px}.tree-outline li:not(.parent)::before{display:none}.breakpoint-hit{background-color:var(--sys-color-yellow-container);color:var(--sys-color-on-yellow-container)}.breakpoint-hit-marker{background-color:var(--sys-color-yellow-container);border-right:3px solid var(--sys-color-yellow-outline);color:var(--sys-color-on-yellow-container);height:100%;left:0;margin-left:-30px;position:absolute;right:-4px;z-index:-1}devtools-checkbox.source-code{max-width:100%}
/*# sourceURL=${import.meta.resolve("./categorizedBreakpointsSidebarPane.css")} */`;var c={auctionWorklet:"Ad Auction Worklet",animation:"Animation",breakpointHit:"breakpoint hit",canvas:"Canvas",clipboard:"Clipboard",control:"Control",device:"Device",domMutation:"DOM Mutation",dragDrop:"Drag / drop",geolocation:"Geolocation",keyboard:"Keyboard",load:"Load",media:"Media",mouse:"Mouse",notification:"Notification",parse:"Parse",pictureinpicture:"Picture-in-Picture",pointer:"Pointer",script:"Script",sharedStorageWorklet:"Shared Storage Worklet",timer:"Timer",touch:"Touch",trustedTypeViolations:"Trusted Type Violations",webaudio:"WebAudio",window:"Window",worker:"Worker",xhr:"XHR"},re=U.i18n.registerUIStrings("panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts",c),ye=U.i18n.getLocalizedString.bind(void 0,re),h=U.i18n.getLazilyComputedLocalizedString.bind(void 0,re),{html:A,render:Ie}=P,{ifExpanded:we}=B.TreeOutline,se=(n,e,t)=>{let o=a=>!!n.filterText||n.highlightedItem&&a.includes(n.highlightedItem)||a.some(m=>m.enabled()),i=n.filterText?new RegExp(W.StringUtilities.escapeForRegExp(n.filterText),"i"):null,r=a=>!i||!!T.CategorizedBreakpointL10n.getLocalizedBreakpointName(a.name).match(i)||a===n.highlightedItem,l=n.sortedCategoryNames.values().map(a=>{let m=n.categories.get(a);return i&&$(a).match(i)?[a,m]:[a,m?.filter(r)]}).filter(a=>!!a[1]?.length).toArray(),g=(a,m)=>{let d=a.target;if(!(d instanceof B.UIUtils.CheckboxLabel))return;let y=d.checked;m instanceof b.CategorizedBreakpoint.CategorizedBreakpoint?n.onBreakpointChange(m,y):n.categories.get(m)?.forEach(Ce=>n.onBreakpointChange(Ce,y))},p=a=>P.Directives.classMap({small:!0,"source-code":!0,"breakpoint-hit":n.highlightedItem===a}),f=a=>{a.key===" "&&(n.onSpaceKeyDown(),a.preventDefault())};Ie(A`
    <devtools-toolbar jslog=${ne.toolbar()}>
      <devtools-toolbar-input
        type="filter"
        @change=${a=>n.onFilterChanged(a.detail)}
        style="flex: 1;"
        ></devtools-toolbar-input>
    </devtools-toolbar>
    <devtools-tree autofocus @keydown=${f} .template=${A`
      <ul role="tree">
        ${l.map(([a,m])=>A`
          <li @select=${()=>n.onItemSelected(a)}
              @expand=${()=>n.onExpandCollapse()}
              role="treeitem"
              jslog-context=${a}
              aria-checked=${m.some(d=>d.enabled())?m.some(d=>!d.enabled())?"mixed":!0:!1}
              ?open=${o(m)}>
            <style>${ie}</style>
            <devtools-checkbox
              class="small"
              tabIndex=-1
              title=${$(a)}
              ?indeterminate=${m.some(d=>!d.enabled())&&m.some(d=>d.enabled())}
              ?checked=${!m.some(d=>!d.enabled())}
              @change=${d=>g(d,a)}
            >${$(a)}</devtools-checkbox>
            <ul role="group">
              ${we(A`${m.map(d=>A`
                <li @select=${()=>n.onItemSelected(d)}
                    role="treeitem"
                    aria-checked=${d.enabled()}
                    jslog-context=${W.StringUtilities.toKebabCase(d.name)}>
                  <div ?hidden=${d!==n.highlightedItem} class="breakpoint-hit-marker"></div>
                  <devtools-checkbox
                    class=${p(d)}
                    tabIndex=-1
                    title=${T.CategorizedBreakpointL10n.getLocalizedBreakpointName(d.name)}
                    ?checked=${d.enabled()}
                    aria-description=${d===n.highlightedItem?ye(c.breakpointHit):P.nothing}
                    @change=${y=>g(y,d)}
                  >${T.CategorizedBreakpointL10n.getLocalizedBreakpointName(d.name)}</devtools-checkbox>
                </li>`)}`)}
            </ul>
          </li>`)}
      </ul>`}>
    </devtools-tree>`,t,{container:{attributes:{jslog:n.jslog}}})},I=class extends B.Widget.VBox{#e;#t;categories=new Map;#o;#i=null;#n=null;#r;#s=null;constructor(e,t,o,i=se){super({useShadowDom:"pure"}),this.#r=i,this.#t=t,this.#e=o;for(let r of e){let l=this.categories.get(r.category());l||(l=[],this.categories.set(r.category(),l)),l.push(r)}this.#o=[...this.categories.keys()].sort((r,l)=>{let g=$(r),p=$(l);return g.localeCompare(p,U.DevToolsLocale.DevToolsLocale.instance().locale)}),b.TargetManager.TargetManager.instance().addModelListener(b.DebuggerModel.DebuggerModel,b.DebuggerModel.Events.DebuggerPaused,this.update,this),b.TargetManager.TargetManager.instance().addModelListener(b.DebuggerModel.DebuggerModel,b.DebuggerModel.Events.DebuggerResumed,this.update,this),B.Context.Context.instance().addFlavorChangeListener(b.Target.Target,this.update,this),this.requestUpdate()}getBreakpointFromPausedDetails(e){return null}update(){let e=B.Context.Context.instance().flavor(b.Target.Target),t=e?e.model(b.DebuggerModel.DebuggerModel):null,o=t?t.debuggerPausedDetails():null,i=o&&this.getBreakpointFromPausedDetails(o);this.#i=i,i&&(B.ViewManager.ViewManager.instance().showView(this.#e),this.requestUpdate())}#a(e){this.#n=e,this.requestUpdate()}#l(e){this.#s=e}#d(){let e=this.#s;if(e)if(e instanceof b.CategorizedBreakpoint.CategorizedBreakpoint)this.onBreakpointChanged(e,!e.enabled());else{let t=this.categories.get(e);if(t){let o=t.some(i=>!i.enabled());t.forEach(i=>this.onBreakpointChanged(i,o))}}}onBreakpointChanged(e,t){e.setEnabled(t),this.requestUpdate()}performUpdate(){let e={filterText:this.#n,jslog:this.#t,onFilterChanged:this.#a.bind(this),onBreakpointChange:this.onBreakpointChanged.bind(this),onItemSelected:this.#l.bind(this),onSpaceKeyDown:this.#d.bind(this),sortedCategoryNames:this.#o,categories:this.categories,highlightedItem:this.#i,onExpandCollapse:()=>{this.requestUpdate()}};this.#r(e,void 0,this.contentElement)}},Le={animation:h(c.animation),"auction-worklet":h(c.auctionWorklet),canvas:h(c.canvas),clipboard:h(c.clipboard),control:h(c.control),device:h(c.device),"dom-mutation":h(c.domMutation),"drag-drop":h(c.dragDrop),geolocation:h(c.geolocation),keyboard:h(c.keyboard),load:h(c.load),media:h(c.media),mouse:h(c.mouse),notification:h(c.notification),parse:h(c.parse),"picture-in-picture":h(c.pictureinpicture),pointer:h(c.pointer),script:h(c.script),"shared-storage-worklet":h(c.sharedStorageWorklet),timer:h(c.timer),touch:h(c.touch),"trusted-type-violation":h(c.trustedTypeViolations),"web-audio":h(c.webaudio),window:h(c.window),worker:h(c.worker),xhr:h(c.xhr)};function $(n){return Le[n]()}var de={};L(de,{CSPViolationBreakpointsSidebarPane:()=>_});import*as R from"./../../core/sdk/sdk.js";import*as le from"./../../ui/visual_logging/visual_logging.js";var _=class extends I{constructor(){let e=R.DOMDebuggerModel.DOMDebuggerManager.instance().cspViolationBreakpoints();super(e,`${le.section("sources.csp-violation-breakpoints")}`,"sources.csp-violation-breakpoints")}getBreakpointFromPausedDetails(e){let t=e.auxData?.violationType?e.auxData.violationType:"",i=R.DOMDebuggerModel.DOMDebuggerManager.instance().cspViolationBreakpoints().find(r=>r.type()===t);return i||null}onBreakpointChanged(e,t){super.onBreakpointChanged(e,t),R.DOMDebuggerModel.DOMDebuggerManager.instance().updateCSPViolationBreakpoints()}};var me={};L(me,{ContextMenuProvider:()=>Z,DEFAULT_VIEW:()=>ue,DOMBreakpointsSidebarPane:()=>G});import*as pe from"./../../core/common/common.js";import*as K from"./../../core/i18n/i18n.js";import*as D from"./../../core/sdk/sdk.js";import*as v from"./../../ui/legacy/legacy.js";import*as Ue from"./../../ui/lit/lit.js";import*as E from"./../../ui/visual_logging/visual_logging.js";import*as he from"./../common/common.js";import*as X from"./../sources/sources.js";var ce=`@scope to (devtools-widget > *){:scope{overflow:auto}.monospace{font-family:var(--monospace-font-family);font-size:var(--monospace-font-size)}.dom-breakpoints-container{flex-grow:1}.breakpoint-list{padding:0 0 3px;list-style-type:none;margin:0}.breakpoint-list .dom-breakpoint > div{overflow:hidden;text-overflow:ellipsis}.breakpoint-entry{display:flex;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;padding:2px 0}.breakpoint-entry:focus-visible{background-color:var(--sys-color-tonal-container)}.breakpoint-hit{background-color:var(--sys-color-neutral-container);color:var(--sys-color-on-surface)}.placeholder{display:flex;height:100%;justify-content:center}.gray-info-message{display:flex;justify-content:center;align-items:center;padding:20px}}:host-context(.sources.panel) .empty-view-scroller{display:none}:host-context(.elements.panel) .placeholder .gray-info-message{display:none}@media (forced-colors: active){@scope to (devtools-widget > *){.breakpoint-entry:focus-visible,
    .breakpoint-list .breakpoint-entry:hover{forced-color-adjust:none;background-color:Highlight}.breakpoint-entry:focus-visible *,
    .breakpoint-list .breakpoint-entry:hover *{color:HighlightText}}}
/*# sourceURL=${import.meta.resolve("./domBreakpointsSidebarPane.css")} */`;var u={noBreakpoints:"No DOM breakpoints",domBreakpointsDescription:"DOM breakpoints pause on the code that changes a DOM node or its children.",domBreakpointsList:"DOM Breakpoints list",sS:"{PH1}: {PH2}",sSS:"{PH1}: {PH2}, {PH3}",checked:"checked",unchecked:"unchecked",sBreakpointHit:"{PH1} breakpoint hit",breakpointHit:"breakpoint hit",revealDomNodeInElementsPanel:"Reveal DOM node in Elements panel",removeBreakpoint:"Remove breakpoint",removeAllDomBreakpoints:"Remove all DOM breakpoints",subtreeModified:"Subtree modified",attributeModified:"Attribute modified",nodeRemoved:"Node removed",breakOn:"Break on",breakpointRemoved:"Breakpoint removed",breakpointSet:"Breakpoint set"},ge=K.i18n.registerUIStrings("panels/browser_debugger/DOMBreakpointsSidebarPane.ts",u),k=K.i18n.getLocalizedString.bind(void 0,ge),N=K.i18n.getLazilyComputedLocalizedString.bind(void 0,ge),Ee="https://developer.chrome.com/docs/devtools/javascript/breakpoints#dom",{html:V,render:Oe,Directives:Ae}=Ue,{widget:$e}=v.Widget,ue=(n,e,t)=>{let o=n.breakpoints.length>0;Oe(V`
      <style>${ce}</style>
      <div class="dom-breakpoints-container" jslog=${E.section("sources.dom-breakpoints").track({resize:!0})}>
        ${o?V`<ul class="breakpoint-list"
              aria-label=${k(u.domBreakpointsList)}>
            ${n.breakpoints.map(i=>{let{breakpoint:r}=i,l=r.enabled?k(u.checked):k(u.unchecked),g=he.DOMLinkifier.Linkifier.instance().linkify(r.node,{preventKeyboardFocus:!0,tooltip:void 0}),p=r.node.simpleSelector();return V`
                <li class=${`breakpoint-entry ${i.isHighlighted?"breakpoint-hit":""}`}
                    tabindex=${i.isFocused?"0":"-1"}
                    @click=${()=>n.onBreakpointClick(r)}
                    @contextmenu=${f=>n.onBreakpointContextMenu(r,f)}
                    @keydown=${f=>n.onBreakpointKeyDown(r,f)}
                    aria-label=${k(u.sSS,{PH1:i.label,PH2:p,PH3:l})}
                    aria-description=${i.isHighlighted?k(u.sBreakpointHit,{PH1:l}):l}
                    jslog=${E.domBreakpoint().context(r.type).track({keydown:"ArrowUp|ArrowDown|PageUp|PageDown"})}>
                  <devtools-checkbox
                    class="checkbox-label"
                    .checked=${r.enabled}
                    @click=${f=>f.stopPropagation()}
                    @change=${()=>n.onBreakpointCheckboxClick(r)}
                    tabindex="-1"
                    aria-label=${k(u.sS,{PH1:i.label,PH2:p})}
                    aria-description=${Ae.ifDefined(i.isHighlighted?k(u.breakpointHit):void 0)}
                    jslog=${E.toggle().track({click:!0})}>
                  </devtools-checkbox>
                  <div class="dom-breakpoint">
                    <code class="monospace" style="display: block;">${g}</code>
                    <div>${i.label}</div>
                  </div>
                </li>`})}
          </ul>`:V`<div class="placeholder">
            <div class="gray-info-message">${k(u.noBreakpoints)}</div>
            ${$e(v.EmptyWidget.EmptyWidget,{header:k(u.noBreakpoints),text:k(u.domBreakpointsDescription),link:Ee})}
          </div>`}
      </div>
    `,t)},q,G=class n extends v.Widget.VBox{#e=[];#t=null;#o=null;#i;set highlightedBreakpoint(e){this.#t=e,this.requestUpdate()}set focusedBreakpoint(e){this.#o!==e&&(this.#o=e,this.#n(),this.requestUpdate())}#n(){this.#o&&!this.#e.includes(this.#o)&&(this.#o=null),!this.#o&&this.#e.length>0&&(this.#o=this.#e[0])}constructor(e=ue){super({useShadowDom:!0}),this.#i=e,D.TargetManager.TargetManager.instance().addModelListener(D.DOMDebuggerModel.DOMDebuggerModel,"DOMBreakpointAdded",this.breakpointAdded,this),D.TargetManager.TargetManager.instance().addModelListener(D.DOMDebuggerModel.DOMDebuggerModel,"DOMBreakpointToggled",this.breakpointToggled,this),D.TargetManager.TargetManager.instance().addModelListener(D.DOMDebuggerModel.DOMDebuggerModel,"DOMBreakpointsRemoved",this.breakpointsRemoved,this);for(let t of D.TargetManager.TargetManager.instance().models(D.DOMDebuggerModel.DOMDebuggerModel)){t.retrieveDOMBreakpoints();for(let o of t.domBreakpoints())this.addBreakpoint(o)}this.update()}static instance(){return q||(q=new n),q}performUpdate(){let e={breakpoints:this.#e.map(t=>({breakpoint:t,label:Pe.get(t.type)?.()??"",isHighlighted:t===this.#t,isFocused:t===this.#o})),onBreakpointClick:this.onBreakpointClick.bind(this),onBreakpointCheckboxClick:this.onBreakpointCheckboxClick.bind(this),onBreakpointContextMenu:this.onBreakpointContextMenu.bind(this),onBreakpointKeyDown:this.onBreakpointKeyDown.bind(this)};this.#i(e,void 0,this.contentElement)}onBreakpointClick(e){this.focusedBreakpoint=e}onBreakpointKeyDown(e,t){let o=t;if(o.key===" ")this.onBreakpointCheckboxClick(e),o.consume(!0);else if(o.key==="ArrowUp"||o.key==="ArrowDown"){let i=this.#e.indexOf(e),r=o.key==="ArrowUp"?i-1:i+1;r>=0&&r<this.#e.length&&(this.focusedBreakpoint=this.#e[r],this.updateComplete.then(()=>{this.contentElement.querySelectorAll(".breakpoint-entry")[r].focus()}),o.consume(!0))}}breakpointAdded(e){this.addBreakpoint(e.data)}breakpointToggled(e){this.requestUpdate()}breakpointsRemoved(e){let t=e.data;for(let o of t){let i=this.#e.indexOf(o);i>=0&&this.#e.splice(i,1)}this.#n(),this.requestUpdate()}addBreakpoint(e){this.#e.includes(e)||(this.#e.push(e),this.#e.sort((t,o)=>t.type>o.type?-1:t.type<o.type?1:0),this.#n(),this.requestUpdate())}onBreakpointContextMenu(e,t){this.focusedBreakpoint=e;let o=new v.ContextMenu.ContextMenu(t);o.defaultSection().appendItem(k(u.revealDomNodeInElementsPanel),()=>pe.Revealer.reveal(e.node),{jslogContext:"reveal-in-elements"}),o.defaultSection().appendItem(k(u.removeBreakpoint),()=>{e.domDebuggerModel.removeDOMBreakpoint(e.node,e.type)},{jslogContext:"remove-breakpoint"}),o.defaultSection().appendItem(k(u.removeAllDomBreakpoints),()=>{e.domDebuggerModel.removeAllDOMBreakpoints()},{jslogContext:"remove-all-dom-breakpoints"}),o.show()}onBreakpointCheckboxClick(e){this.focusedBreakpoint=e,e.domDebuggerModel.toggleDOMBreakpoint(e,!e.enabled)}flavorChanged(e){this.update()}update(){let e=v.Context.Context.instance().flavor(D.DebuggerModel.DebuggerPausedDetails);if(this.highlightedBreakpoint=null,!e?.auxData||e.reason!=="DOM")return;let t=e.debuggerModel.target().model(D.DOMDebuggerModel.DOMDebuggerModel);if(!t)return;let o=t.resolveDOMBreakpointData(e.auxData);if(o){for(let i of this.#e)i.node===o.node&&i.type===o.type&&(this.highlightedBreakpoint=i,this.focusedBreakpoint=i);this.#t&&v.ViewManager.ViewManager.instance().showView("sources.dom-breakpoints")}}},Pe=new Map([["subtree-modified",N(u.subtreeModified)],["attribute-modified",N(u.attributeModified)],["node-removed",N(u.nodeRemoved)]]),Z=class{appendApplicableItems(e,t,o){if(o.pseudoType())return;let i=o.domModel().target().model(D.DOMDebuggerModel.DOMDebuggerModel);if(!i)return;function r(p){if(!i)return;let f=X.DebuggerPausedMessage.BreakpointTypeNouns.get(p),a=f?f():"";i.hasDOMBreakpoint(o,p)?(i.removeDOMBreakpoint(o,p),v.ARIAUtils.LiveAnnouncer.alert(`${k(u.breakpointRemoved)}: ${a}`)):(i.setDOMBreakpoint(o,p),v.ARIAUtils.LiveAnnouncer.alert(`${k(u.breakpointSet)}: ${a}`))}let l=t.debugSection().appendSubMenuItem(k(u.breakOn),!1,"break-on"),g={SubtreeModified:"subtree-modified",AttributeModified:"attribute-modified",NodeRemoved:"node-removed"};for(let p of Object.values(g)){let f=X.DebuggerPausedMessage.BreakpointTypeNouns.get(p);f&&l.defaultSection().appendCheckboxItem(f(),r.bind(null,p),{checked:i.hasDOMBreakpoint(o,p),jslogContext:p})}}};var be={};L(be,{EventListenerBreakpointsSidebarPane:()=>Q});import*as O from"./../../core/sdk/sdk.js";import*as ke from"./../../ui/visual_logging/visual_logging.js";var J,Q=class n extends I{constructor(){let e=O.DOMDebuggerModel.DOMDebuggerManager.instance().eventListenerBreakpoints(),t=O.EventBreakpointsModel.EventBreakpointsManager.instance().eventListenerBreakpoints();e=e.concat(t),super(e,`${ke.section("sources.event-listener-breakpoints")}`,"sources.event-listener-breakpoints")}static instance(){return J||(J=new n),J}getBreakpointFromPausedDetails(e){let t=e.auxData;if(!t)return null;let o=t&&O.DOMDebuggerModel.DOMDebuggerManager.instance().resolveEventListenerBreakpoint(t);return o||O.EventBreakpointsModel.EventBreakpointsManager.instance().resolveEventListenerBreakpoint(t)}};var ve={};L(ve,{ActionDelegate:()=>Y,ObjectEventListenersSidebarPane:()=>z,objectGroupName:()=>j});import*as H from"./../../core/sdk/sdk.js";import"./../../ui/components/buttons/buttons.js";import*as S from"./../../ui/legacy/legacy.js";import*as fe from"./../../ui/visual_logging/visual_logging.js";import*as De from"./../event_listeners/event_listeners.js";var z=class n extends S.Widget.VBox{#e;eventListenersView;constructor(){super(),this.contentElement.setAttribute("jslog",`${fe.section("sources.global-listeners")}`),this.eventListenersView=new De.EventListenersView.EventListenersView,this.eventListenersView.changeCallback=this.requestUpdate.bind(this),this.eventListenersView.enableDefaultTreeFocus=!0,this.eventListenersView.show(this.element),this.setDefaultFocusedChild(this.eventListenersView),this.requestUpdate()}toolbarItems(){let e=S.Toolbar.Toolbar.createActionButton("browser-debugger.refresh-global-event-listeners");return e.setSize("SMALL"),[e]}async performUpdate(){this.#e&&(this.#e.runtimeModel.releaseObjectGroup(j),this.#e=void 0);let e=[],t=S.Context.Context.instance().flavor(H.RuntimeModel.ExecutionContext);if(t){this.#e=t;let o=await t.evaluate({expression:"self",objectGroup:j,includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1},!1,!1);!("error"in o)&&!o.exceptionDetails&&e.push(o.object)}await this.eventListenersView.addObjects(e)}wasShown(){super.wasShown(),S.Context.Context.instance().addFlavorChangeListener(H.RuntimeModel.ExecutionContext,this.requestUpdate,this),S.Context.Context.instance().setFlavor(n,this)}willHide(){S.Context.Context.instance().setFlavor(n,null),S.Context.Context.instance().removeFlavorChangeListener(H.RuntimeModel.ExecutionContext,this.requestUpdate,this),super.willHide(),this.#e&&(this.#e.runtimeModel.releaseObjectGroup(j),this.#e=void 0)}},Y=class{handleAction(e,t){if(t==="browser-debugger.refresh-global-event-listeners"){let o=e.flavor(z);return o?(o.requestUpdate(),!0):!1}return!1}},j="object-event-listeners-sidebar-pane";var Be={};L(Be,{XHRBreakpointsSidebarPane:()=>te});import*as oe from"./../../core/i18n/i18n.js";import*as C from"./../../core/sdk/sdk.js";import"./../../ui/components/buttons/buttons.js";import*as s from"./../../ui/legacy/legacy.js";import*as w from"./../../ui/visual_logging/visual_logging.js";var xe=`.breakpoint-list{padding-bottom:3px}.breakpoint-list .editing.being-edited{overflow:hidden;white-space:nowrap}.breakpoint-condition{display:block;margin:4px 8px 4px 23px}.breakpoint-condition-input{display:block;margin-left:0;margin-right:0;border:1px solid var(--sys-color-neutral-outline);border-radius:4px;&:focus{outline:5px auto var(--sys-color-tonal-outline);box-shadow:none}}.breakpoint-entry{white-space:nowrap;padding:2px 0}.breakpoint-list .breakpoint-entry:focus-visible{background-color:var(--sys-color-tonal-container)}.breakpoint-entry devtools-checkbox{max-width:100%}.breakpoint-hit{background-color:var(--sys-color-yellow-container);border-right:3px solid var(--sys-color-yellow-outline);color:var(--sys-color-on-yellow-container)}@media (forced-colors: active){.breakpoint-list .breakpoint-entry:hover,
  .breakpoint-list .breakpoint-entry:focus-visible{forced-color-adjust:none;background-color:Highlight}.breakpoint-list .breakpoint-entry:hover *,
  .breakpoint-list .breakpoint-entry:focus-visible *{color:HighlightText}}
/*# sourceURL=${import.meta.resolve("./xhrBreakpointsSidebarPane.css")} */`;var x={xhrfetchBreakpoints:"XHR/fetch Breakpoints",noBreakpoints:"No breakpoints",addXhrfetchBreakpoint:"Add XHR/fetch breakpoint",addBreakpoint:"Add breakpoint",breakWhenUrlContains:"Break when URL contains:",urlBreakpoint:"URL Breakpoint",urlContainsS:'URL contains "{PH1}"',anyXhrOrFetch:"Any XHR or fetch",breakpointHit:"breakpoint hit",removeAllBreakpoints:"Remove all breakpoints",removeBreakpoint:"Remove breakpoint"},Te=oe.i18n.registerUIStrings("panels/browser_debugger/XHRBreakpointsSidebarPane.ts",x),M=oe.i18n.getLocalizedString.bind(void 0,Te),F=new WeakMap,Me=new WeakMap,ee,te=class n extends s.Widget.VBox{#e;#t;#o;#i;#n;#r;constructor(){super({jslog:`${w.section("source.xhr-breakpoints")}`,useShadowDom:!0}),this.registerRequiredCSS(xe),this.#e=new s.ListModel.ListModel,this.#t=new s.ListControl.ListControl(this.#e,this,s.ListControl.ListMode.NonViewport),this.contentElement.appendChild(this.#t.element),this.#t.element.classList.add("breakpoint-list","hidden"),s.ARIAUtils.markAsList(this.#t.element),s.ARIAUtils.setLabel(this.#t.element,M(x.xhrfetchBreakpoints)),this.#o=this.contentElement.createChild("div","gray-info-message"),this.#o.textContent=M(x.noBreakpoints),this.#i=new Map,this.#n=new s.Toolbar.ToolbarButton(M(x.addXhrfetchBreakpoint),"plus",void 0,"sources.add-xhr-fetch-breakpoint"),this.#n.setSize("SMALL"),this.#n.addEventListener("Click",()=>{this.addButtonClicked()}),this.#o.addEventListener("contextmenu",this.emptyElementContextMenu.bind(this),!0),this.#o.tabIndex=-1,this.restoreBreakpoints(),this.update()}static instance(){return ee||(ee=new n),ee}toolbarItems(){return[this.#n]}emptyElementContextMenu(e){let t=new s.ContextMenu.ContextMenu(e);t.defaultSection().appendItem(M(x.addBreakpoint),this.addButtonClicked.bind(this),{jslogContext:"sources.add-xhr-fetch-breakpoint"}),t.show()}async addButtonClicked(){await s.ViewManager.ViewManager.instance().showView("sources.xhr-breakpoints");let e=document.createElement("p");e.classList.add("breakpoint-condition"),e.textContent=M(x.breakWhenUrlContains),e.setAttribute("jslog",`${w.value("condition").track({change:!0})}`);let t=e.createChild("span","breakpoint-condition-input");s.ARIAUtils.setLabel(t,M(x.urlBreakpoint)),this.addListElement(e,this.#t.element.firstChild);let o=(l,g)=>{this.removeListElement(e),C.DOMDebuggerModel.DOMDebuggerManager.instance().addXHRBreakpoint(g,!0),this.setBreakpoint(g),this.update()},i=()=>{this.removeListElement(e),this.update()},r=new s.InplaceEditor.Config(o,i,void 0);s.InplaceEditor.InplaceEditor.startEditing(t,r)}heightForItem(e){return 0}isItemSelectable(e){return!0}setBreakpoint(e){this.#e.indexOf(e)!==-1?this.#t.refreshItem(e):this.#e.insertWithComparator(e,(t,o)=>t>o?1:t<o?-1:0),(!this.#t.selectedItem()||!this.hasFocus())&&this.#t.selectItem(this.#e.at(0))}createElementForItem(e){let t=document.createElement("div");s.ARIAUtils.markAsListitem(t);let o=t.createChild("div","breakpoint-entry");F.set(t,o);let i=C.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints().get(e)||!1;s.ARIAUtils.markAsCheckbox(o),s.ARIAUtils.setChecked(o,i),o.addEventListener("contextmenu",this.contextMenu.bind(this,e),!0);let r=e?M(x.urlContainsS,{PH1:e}):M(x.anyXhrOrFetch),l=s.UIUtils.CheckboxLabel.create(r,i,void 0,void 0,!0);return s.ARIAUtils.setHidden(l,!0),s.ARIAUtils.setLabel(o,r),o.appendChild(l),l.addEventListener("click",this.checkboxClicked.bind(this,e,i),!1),o.addEventListener("click",g=>{g.target===o&&this.checkboxClicked(e,i)},!1),Me.set(o,l),l.tabIndex=-1,o.tabIndex=-1,e===this.#t.selectedItem()&&(o.tabIndex=0,this.setDefaultFocusedElement(o)),o.addEventListener("keydown",g=>{let p=!1;g.key===" "?(this.checkboxClicked(e,i),p=!0):g.key==="Enter"&&(this.labelClicked(e),p=!0),p&&g.consume(!0)}),e===this.#r&&(o.classList.add("breakpoint-hit"),s.ARIAUtils.setDescription(o,M(x.breakpointHit))),l.classList.add("cursor-auto"),l.addEventListener("dblclick",this.labelClicked.bind(this,e),!1),this.#i.set(e,t),t.setAttribute("jslog",`${w.item().track({click:!0,dblclick:!0,resize:!0,keydown:"ArrowUp|ArrowDown|PageUp|PageDown|Enter|Space"})}`),t}selectedItemChanged(e,t,o,i){if(o){let r=F.get(o);if(!r)throw new Error("Expected breakpoint entry to be found for an element");r.tabIndex=-1}if(i){let r=F.get(i);if(!r)throw new Error("Expected breakpoint entry to be found for an element");this.setDefaultFocusedElement(r),r.tabIndex=0,this.hasFocus()&&r.focus()}}updateSelectedItemARIA(e,t){return!0}removeBreakpoint(e){let t=this.#e.indexOf(e);t>=0&&this.#e.remove(t),this.#i.delete(e),this.update()}addListElement(e,t){this.#t.element.insertBefore(e,t),this.#o.classList.add("hidden"),this.#t.element.classList.remove("hidden")}removeListElement(e){this.#t.element.removeChild(e),this.#t.element.firstElementChild||(this.#o.classList.remove("hidden"),this.#t.element.classList.add("hidden"))}contextMenu(e,t){let o=new s.ContextMenu.ContextMenu(t);function i(){C.DOMDebuggerModel.DOMDebuggerManager.instance().removeXHRBreakpoint(e),this.removeBreakpoint(e)}function r(){for(let g of this.#i.keys())C.DOMDebuggerModel.DOMDebuggerManager.instance().removeXHRBreakpoint(g),this.removeBreakpoint(g);this.update()}let l=M(x.removeAllBreakpoints);o.defaultSection().appendItem(M(x.addBreakpoint),this.addButtonClicked.bind(this),{jslogContext:"sources.add-xhr-fetch-breakpoint"}),o.defaultSection().appendItem(M(x.removeBreakpoint),i.bind(this),{jslogContext:"sources.remove-xhr-fetch-breakpoint"}),o.defaultSection().appendItem(l,r.bind(this),{jslogContext:"sources.remove-all-xhr-fetch-breakpoints"}),o.show()}checkboxClicked(e,t){let o=this.hasFocus();C.DOMDebuggerModel.DOMDebuggerManager.instance().toggleXHRBreakpoint(e,!t),this.#t.refreshItem(e),this.#t.selectItem(e),o&&this.focus()}labelClicked(e){let t=this.#i.get(e),o=document.createElement("span");o.classList.add("breakpoint-condition"),o.textContent=e,o.setAttribute("jslog",`${w.value("condition").track({change:!0})}`),t&&(this.#t.element.insertBefore(o,t),t.classList.add("hidden"));let i=(g,p,f,a)=>{this.removeListElement(g),C.DOMDebuggerModel.DOMDebuggerManager.instance().removeXHRBreakpoint(e),this.removeBreakpoint(e);let m=!0;if(a){let d=F.get(a),y=d?Me.get(d):void 0;y&&(m=y.checked)}C.DOMDebuggerModel.DOMDebuggerManager.instance().addXHRBreakpoint(p,m),this.setBreakpoint(p),this.#t.selectItem(p),this.focus()},r=(g,p)=>{this.removeListElement(g),p&&p.classList.remove("hidden"),this.focus()},l=new s.InplaceEditor.Config(i,r,t);s.InplaceEditor.InplaceEditor.startEditing(o,l)}flavorChanged(e){this.update()}update(){let e=this.#e.length===0;this.#t.element.classList.toggle("hidden",e),this.#o.classList.toggle("hidden",!e);let t=s.Context.Context.instance().flavor(C.DebuggerModel.DebuggerPausedDetails);if(!t||t.reason!=="XHR"){if(this.#r){let i=this.#r;this.#r=void 0,this.#e.indexOf(i)>=0&&this.#t.refreshItem(i)}return}let o=t.auxData?.breakpointURL;this.#r=o,!(this.#e.indexOf(o)<0)&&(this.#t.refreshItem(o),s.ViewManager.ViewManager.instance().showView("sources.xhr-breakpoints"))}restoreBreakpoints(){let e=C.DOMDebuggerModel.DOMDebuggerManager.instance().xhrBreakpoints();for(let t of e.keys())this.setBreakpoint(t)}};export{de as CSPViolationBreakpointsSidebarPane,ae as CategorizedBreakpointsSidebarPane,me as DOMBreakpointsSidebarPane,be as EventListenerBreakpointsSidebarPane,ve as ObjectEventListenersSidebarPane,Be as XHRBreakpointsSidebarPane};
//# sourceMappingURL=browser_debugger.js.map
