diff --git a/packages/debugger-frontend/BUILD_INFO b/packages/debugger-frontend/BUILD_INFO index 50211110ee2..25486188863 100644 --- a/packages/debugger-frontend/BUILD_INFO +++ b/packages/debugger-frontend/BUILD_INFO @@ -1,5 +1,5 @@ -@generated SignedSource<> -Git revision: ff343d805527223750fafb8573ee48f8e2fb0d1e +@generated SignedSource<<6b92b66e59525cef52902139f863f175>> +Git revision: b61aae3ccc6e2684dfbf1e2a06b0f985b459f11f Built with --nohooks: false Is local checkout: false Remote URL: https://github.com/facebookexperimental/rn-chrome-devtools-frontend diff --git a/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js b/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js index 22d6f18bc7f..38dbf47936b 100644 --- a/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js +++ b/packages/debugger-frontend/dist/third-party/front_end/panels/sources/sources.js @@ -1,14 +1,14 @@ -import*as e from"../../core/i18n/i18n.js";import*as t from"../../ui/legacy/legacy.js";import*as i from"../../core/common/common.js";import*as o from"../../core/sdk/sdk.js";import*as n from"../../third_party/codemirror.next/codemirror.next.js";import*as r from"../../ui/components/icon_button/icon_button.js";import*as s from"../../ui/components/text_editor/text_editor.js";import*as a from"../../ui/visual_logging/visual_logging.js";import*as c from"../../core/host/host.js";import*as l from"../../core/platform/platform.js";import{assertNotNullOrUndefined as d}from"../../core/platform/platform.js";import*as u from"../../models/bindings/bindings.js";import*as h from"../../models/persistence/persistence.js";import*as p from"../../models/source_map_scopes/source_map_scopes.js";import*as g from"../../models/text_utils/text_utils.js";import*as m from"../../ui/legacy/components/source_frame/source_frame.js";import*as b from"../coverage/coverage.js";import*as f from"../../models/workspace/workspace.js";import*as S from"../../ui/legacy/components/color_picker/color_picker.js";import*as v from"../../ui/legacy/components/inline_editor/inline_editor.js";import*as C from"../../core/root/root.js";import*as w from"../../models/breakpoints/breakpoints.js";import*as I from"../../models/formatter/formatter.js";import*as y from"../../ui/legacy/components/object_ui/object_ui.js";import*as x from"./components/components.js";import*as k from"../../models/extensions/extensions.js";import*as T from"../snippets/snippets.js";import*as E from"../search/search.js";import*as L from"../../ui/legacy/components/quick_open/quick_open.js";import*as M from"../../models/issues_manager/issues_manager.js";import*as P from"../../ui/components/issue_counter/issue_counter.js";import*as F from"../../ui/legacy/components/utils/utils.js";import{PanelUtils as D}from"../utils/utils.js";import*as N from"../../ui/components/buttons/buttons.js";const A=new CSSStyleSheet;A.replaceSync(':host{padding:10px}.widget{align-items:center}label{white-space:nowrap}input[type="text"].add-source-map{box-shadow:0 0 0 1px var(--box-shadow-outline-color);font-size:inherit;margin:0 8px 0 5px}\n/*# sourceURL=dialog.css */\n');const U={sourceMapUrl:"Source map URL: ",debugInfoUrl:"DWARF symbols URL: ",add:"Add"},R=e.i18n.registerUIStrings("panels/sources/AddSourceMapURLDialog.ts",U),B=e.i18n.getLocalizedString.bind(void 0,R);class j extends t.Widget.HBox{input;dialog;callback;constructor(e,i,o){super(!0),this.contentElement.createChild("label").textContent=e,this.input=t.UIUtils.createInput("add-source-map","text","url"),this.input.addEventListener("keydown",this.onKeyDown.bind(this),!1),this.contentElement.appendChild(this.input);const n=t.UIUtils.createTextButton(B(U.add),this.apply.bind(this),{jslogContext:"add"});this.contentElement.appendChild(n),this.dialog=new t.Dialog.Dialog(i),this.dialog.setSizeBehavior("MeasureContent"),this.dialog.setDefaultFocusedElement(this.input),this.callback=o}static createAddSourceMapURLDialog(e){return new j(B(U.sourceMapUrl),"add-source-map-url",e)}static createAddDWARFSymbolsURLDialog(e){return new j(B(U.debugInfoUrl),"add-debug-info-url",e)}show(){super.show(this.dialog.contentElement),this.dialog.show()}done(e){this.dialog.hide(),this.callback(e)}apply(){this.done(this.input.value)}onKeyDown(e){"Enter"===e.key&&(e.consume(!0),this.apply())}wasShown(){super.wasShown(),this.registerCSSFiles([A])}}var V=Object.freeze({__proto__:null,AddDebugInfoURLDialog:j});const W=new CSSStyleSheet;W.replaceSync(":host{z-index:30;padding:4px;background-color:var(--sys-color-surface3);border-radius:7px;border:2px solid var(--sys-color-divider);width:90%;pointer-events:auto}:host(.sources-edit-breakpoint-dialog){border-radius:0;z-index:30;background-color:var(--sys-color-surface3);width:555px;pointer-events:auto;margin-left:-1px;padding:0 10px 10px 5px;border:1px solid var(--sys-color-divider)}:host-context(.sources-edit-breakpoint-dialog) .condition-editor{background-color:var(--sys-color-cdt-base-container);margin:0 6px 20px 3px}:host-context(.sources-edit-breakpoint-dialog) .source-frame-breakpoint-toolbar{font-family:sans-serif;font-size:12px}:host-context(.sources-edit-breakpoint-dialog) .link,\n.devtools-link{font-family:sans-serif;font-size:12px;margin:0 3px}:host-context(.sources-edit-breakpoint-dialog) devtools-icon.link-icon{vertical-align:sub;margin-right:0.5ch;color:var(--icon-link);width:16px;height:16px}:host-context(.sources-edit-breakpoint-dialog) .link-wrapper{display:inline-flex}:host-context(.sources-edit-breakpoint-dialog) .dialog-header{display:flex;justify-content:space-between;align-items:center}:host-context(.sources-edit-breakpoint-dialog) .dialog-header > devtools-icon:hover{color:var(--icon-default-hover)}\n/*# sourceURL=breakpointEditDialog.css */\n");const{Direction:O}=s.TextEditorHistory,H={breakpointType:"Breakpoint type",breakpoint:"Breakpoint",closeDialog:"Close edit dialog and save changes",conditionalBreakpoint:"Conditional breakpoint",logpoint:"Logpoint",expressionToCheckBeforePausingEg:"Expression to check before pausing, e.g. x > 5",pauseOnlyWhenTheConditionIsTrue:"Pause only when the condition is true",learnMoreOnBreakpointTypes:"Learn more: Breakpoint Types",logMessageEgXIsX:"Log message, e.g. `'x is', x`",logAMessageToConsoleDoNotBreak:"Log a message to Console, do not break"},_=e.i18n.registerUIStrings("panels/sources/BreakpointEditDialog.ts",H),z=e.i18n.getLocalizedString.bind(void 0,_);class q extends t.Widget.Widget{onFinish;finished;editor;typeSelector;placeholderCompartment;#e;#t;constructor(e,o,c,l){super(!0);const d=[n.javascript.javascriptLanguage,s.Config.baseConfiguration(o||""),s.Config.closeBrackets,s.Config.autocompletion.instance(),n.EditorView.lineWrapping,s.Config.showCompletionHint,s.Config.conservativeCompletion,n.javascript.javascriptLanguage.data.of({autocomplete:e=>this.#t.historyCompletions(e)}),n.autocompletion(),s.JavaScript.argumentHints()];this.onFinish=l,this.finished=!1,this.element.tabIndex=-1,this.element.classList.add("sources-edit-breakpoint-dialog"),this.element.setAttribute("jslog",`${a.dialog("edit-breakpoint")}`);const u=this.contentElement.createChild("div","dialog-header"),h=new t.Toolbar.Toolbar("source-frame-breakpoint-toolbar",u);h.appendText(`Line ${e+1}:`),this.typeSelector=new t.Toolbar.ToolbarComboBox(this.onTypeChanged.bind(this),z(H.breakpointType),void 0,"type"),this.typeSelector.createOption(z(H.breakpoint),"REGULAR_BREAKPOINT");const p=this.typeSelector.createOption(z(H.conditionalBreakpoint),"CONDITIONAL_BREAKPOINT"),g=this.typeSelector.createOption(z(H.logpoint),"LOGPOINT");this.typeSelector.select(c?g:p),h.appendToolbarItem(this.typeSelector);const m=o||"",b=e=>(s.JavaScript.isExpressionComplete(e.state.doc.toString()).then((t=>{t?this.finishEditing(!0,this.editor.state.doc.toString()):n.insertNewlineAndIndent(e)})),!0),f=[{key:"ArrowUp",run:()=>this.#t.moveHistory(-1)},{key:"ArrowDown",run:()=>this.#t.moveHistory(1)},{mac:"Ctrl-p",run:()=>this.#t.moveHistory(-1,!0)},{mac:"Ctrl-n",run:()=>this.#t.moveHistory(1,!0)},{key:"Mod-Enter",run:b},{key:"Enter",run:b},{key:"Shift-Enter",run:n.insertNewlineAndIndent},{key:"Escape",run:()=>(this.finishEditing(!1,""),!0)}];this.placeholderCompartment=new n.Compartment;const S=this.contentElement.appendChild(document.createElement("div"));S.classList.add("condition-editor"),S.setAttribute("jslog",`${a.textField()}`),this.editor=new s.TextEditor.TextEditor(n.EditorState.create({doc:m,selection:{anchor:0,head:m.length},extensions:[this.placeholderCompartment.of(this.getPlaceholder()),n.keymap.of(f),d]})),S.appendChild(this.editor);const v=new r.Icon.Icon;v.name="cross",v.title=z(H.closeDialog),v.setAttribute("jslog",`${a.close().track({click:!0})}`),v.onclick=()=>this.finishEditing(!0,this.editor.state.doc.toString()),u.appendChild(v),this.#e=new s.AutocompleteHistory.AutocompleteHistory(i.Settings.Settings.instance().createLocalSetting("breakpoint-condition-history",[])),this.#t=new s.TextEditorHistory.TextEditorHistory(this.editor,this.#e);const C=this.contentElement.appendChild(document.createElement("div"));C.classList.add("link-wrapper");const w=t.Fragment.html`${z(H.learnMoreOnBreakpointTypes)}`,I=new r.Icon.Icon;I.name="open-externally",I.classList.add("link-icon"),w.prepend(I),C.appendChild(w),this.updateTooltip()}saveAndFinish(){this.finishEditing(!0,this.editor.state.doc.toString())}focusEditor(){this.editor.editor.focus()}onTypeChanged(){"REGULAR_BREAKPOINT"!==this.breakpointType?(this.focusEditor(),this.editor.dispatch({effects:this.placeholderCompartment.reconfigure(this.getPlaceholder())}),this.updateTooltip()):this.finishEditing(!0,"")}get breakpointType(){const e=this.typeSelector.selectedOption();return e?e.value:null}getPlaceholder(){const e=this.breakpointType;return"CONDITIONAL_BREAKPOINT"===e?n.placeholder(z(H.expressionToCheckBeforePausingEg)):"LOGPOINT"===e?n.placeholder(z(H.logMessageEgXIsX)):[]}updateTooltip(){const e=this.breakpointType;"CONDITIONAL_BREAKPOINT"===e?t.Tooltip.Tooltip.install(this.typeSelector.element,z(H.pauseOnlyWhenTheConditionIsTrue)):"LOGPOINT"===e&&t.Tooltip.Tooltip.install(this.typeSelector.element,z(H.logAMessageToConsoleDoNotBreak))}finishEditing(e,t){if(this.finished)return;this.finished=!0,this.editor.remove(),this.#e.pushHistoryItem(t);const i="LOGPOINT"===this.breakpointType;this.onFinish({committed:e,condition:t,isLogpoint:i})}wasShown(){super.wasShown(),this.registerCSSFiles([W])}get editorForTest(){return this.editor}}var $=Object.freeze({__proto__:null,BreakpointEditDialog:q});const G=new CSSStyleSheet;G.replaceSync('.call-frame-warnings-message{text-align:center;font-style:italic;padding:4px;color:var(--sys-color-on-surface-yellow);background-color:var(--sys-color-surface-yellow)}.ignore-listed-message{padding:1px}.ignore-listed-message-label{color:var(--sys-color-token-subtle);align-items:center;display:flex}.show-more-message > .link{margin-left:5px}.show-more-message{text-align:center;font-style:italic;padding:4px;border-top:1px solid var(--sys-color-divider)}.call-frame-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.call-frame-title-text{text-overflow:ellipsis;overflow:hidden}.async-header + .call-frame-item{border-top:0}.call-frame-item:not(.async-header){border-top:1px solid var(--sys-color-divider)}.call-frame-item-title,\n.call-frame-location{display:flex;white-space:nowrap}.async-header .call-frame-item-title{font-weight:bold;color:var(--sys-color-on-surface);background-color:var(--sys-color-cdt-base-container);margin-left:-5px;padding:0 5px;z-index:1}.call-frame-item:focus-visible,\n.call-frame-item.async-header:focus-visible .call-frame-item-title{background-color:var(--sys-color-tonal-container)}.ignore-listed-checkbox:focus-visible{outline-width:unset}.call-frame-item:not(.async-header):hover{background-color:var(--sys-color-state-hover-on-subtle)}.call-frame-location{color:var(--sys-color-token-subtle);margin-left:auto;padding:0 10px}.async-header::before{content:" ";width:100%;border-top:1px solid var(--sys-color-divider);margin-top:8px;position:absolute;left:0}.ignore-listed-call-frame{opacity:60%;font-style:italic}.selected-call-frame-icon{display:none;position:absolute;top:3px;left:4px}.call-frame-item.selected .selected-call-frame-icon{display:block}.call-frame-warning-icon{display:block;position:absolute;top:3px;right:4px}@media (forced-colors: active){.call-frame-item:focus-visible,\n .call-frame-item:not(.async-header):hover{forced-color-adjust:none;background-color:Highlight}.call-frame-item:focus-visible *,\n .call-frame-item:not(.async-header):hover *{color:HighlightText}}\n/*# sourceURL=callStackSidebarPane.css */\n');const K={callStack:"Call Stack",notPaused:"Not paused",onIgnoreList:"on ignore list",showIgnorelistedFrames:"Show ignore-listed frames",showMore:"Show more",copyStackTrace:"Copy stack trace",callFrameWarnings:"Some call frames have warnings",debugFileNotFound:'Failed to load debug file "{PH1}".',restartFrame:"Restart frame"},J=e.i18n.registerUIStrings("panels/sources/CallStackSidebarPane.ts",K),X=e.i18n.getLocalizedString.bind(void 0,J);let Y;class Q extends t.View.SimpleView{ignoreListMessageElement;ignoreListCheckboxElement;notPausedMessageElement;callFrameWarningsElement;items;list;showMoreMessageElement;showIgnoreListed;locationPool;updateThrottler;maxAsyncStackChainDepth;updateItemThrottler;scheduledForUpdateItems;muteActivateItem;lastDebuggerModel=null;constructor(){super(X(K.callStack),!0,"sources.callstack"),this.contentElement.setAttribute("jslog",`${a.section("sources.callstack")}`),({element:this.ignoreListMessageElement,checkbox:this.ignoreListCheckboxElement}=this.createIgnoreListMessageElementAndCheckbox()),this.contentElement.appendChild(this.ignoreListMessageElement),this.notPausedMessageElement=this.contentElement.createChild("div","gray-info-message"),this.notPausedMessageElement.textContent=X(K.notPaused),this.notPausedMessageElement.tabIndex=-1,this.callFrameWarningsElement=this.contentElement.createChild("div","call-frame-warnings-message");const e=new r.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},e.classList.add("call-frame-warning-icon"),this.callFrameWarningsElement.appendChild(e),this.callFrameWarningsElement.appendChild(document.createTextNode(X(K.callFrameWarnings))),this.callFrameWarningsElement.tabIndex=-1,this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport),this.contentElement.appendChild(this.list.element),this.list.element.addEventListener("contextmenu",this.onContextMenu.bind(this),!1),self.onInvokeElement(this.list.element,(e=>{const t=this.list.itemForNode(e.target);t&&(this.activateItem(t),e.consume(!0))})),this.showMoreMessageElement=this.createShowMoreMessageElement(),this.showMoreMessageElement.classList.add("hidden"),this.contentElement.appendChild(this.showMoreMessageElement),this.showIgnoreListed=!1,this.locationPool=new u.LiveLocation.LiveLocationPool,this.updateThrottler=new i.Throttler.Throttler(100),this.maxAsyncStackChainDepth=te,this.update(),this.updateItemThrottler=new i.Throttler.Throttler(100),this.scheduledForUpdateItems=new Set,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this)}static instance(e={forceNew:null}){const{forceNew:t}=e;return Y&&!t||(Y=new Q),Y}flavorChanged(e){this.showIgnoreListed=!1,this.ignoreListCheckboxElement.checked=!1,this.maxAsyncStackChainDepth=te,this.update()}debugInfoAttached(){this.update()}setSourceMapSubscription(e){this.lastDebuggerModel!==e&&(this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this),this.lastDebuggerModel=e,this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this))}update(){this.updateThrottler.schedule((()=>this.doUpdate()))}async doUpdate(){this.locationPool.disposeAll(),this.callFrameWarningsElement.classList.add("hidden");const e=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.setSourceMapSubscription(e?.debuggerModel??null),!e)return this.notPausedMessageElement.classList.remove("hidden"),this.ignoreListMessageElement.classList.add("hidden"),this.showMoreMessageElement.classList.add("hidden"),this.items.replaceAll([]),void t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,null);this.notPausedMessageElement.classList.add("hidden");const i=[],n=new Set;for(const t of e.callFrames){const e=ie.createForDebuggerCallFrame(t,this.locationPool,this.refreshItem.bind(this)).then((e=>(Z.set(e,t),e)));i.push(e),t.missingDebugInfoDetails&&n.add(t.missingDebugInfoDetails.details)}const r=await Promise.all(i);n.size&&(this.callFrameWarningsElement.classList.remove("hidden"),t.Tooltip.Tooltip.install(this.callFrameWarningsElement,Array.from(n).join("\n")));let s=e.debuggerModel,a=e.asyncStackTraceId,c=e.asyncStackTrace,l=e.callFrames;for(let{maxAsyncStackChainDepth:e}=this;e>0;--e){if(!c){if(!a)break;if(a.debuggerId){const e=await o.DebuggerModel.DebuggerModel.modelForDebuggerId(a.debuggerId);if(!e)break;s=e}if(c=await s.fetchAsyncStackTrace(a),!c)break}const e=t.UIUtils.asyncStackTraceLabel(c.description,l);r.push(...await ie.createItemsForAsyncStack(e,s,c.callFrames,this.locationPool,this.refreshItem.bind(this))),l=c.callFrames,a=c.parentId,c=c.parent}this.showMoreMessageElement.classList.toggle("hidden",!c),this.items.replaceAll(r);for(const e of this.items)this.refreshItem(e);if(this.maxAsyncStackChainDepth===te){this.list.selectNextItem(!0,!1);const e=this.list.selectedItem();e&&this.activateItem(e)}this.updatedForTest()}updatedForTest(){}refreshItem(e){this.scheduledForUpdateItems.add(e),this.updateItemThrottler.schedule((async()=>{const e=Array.from(this.scheduledForUpdateItems);if(this.scheduledForUpdateItems.clear(),this.muteActivateItem=!0,!this.showIgnoreListed&&this.items.every((e=>e.isIgnoreListed))){this.showIgnoreListed=!0;for(let e=0;eX(K.debugFileNotFound,{PH1:e})));t.Tooltip.Tooltip.install(e,[s.missingDebugInfoDetails.details,...o].join("\n")),i.appendChild(e)}return i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1),o&&(this.setDefaultFocusedElement(o),o.tabIndex=0,this.hasFocus()&&o.focus())}updateSelectedItemARIA(e,t){return!0}createIgnoreListMessageElementAndCheckbox(){const e=document.createElement("div");e.classList.add("ignore-listed-message");const t=e.createChild("label");t.classList.add("ignore-listed-message-label");const i=t.createChild("input");i.tabIndex=0,i.type="checkbox",i.classList.add("ignore-listed-checkbox"),t.append(X(K.showIgnorelistedFrames));return i.addEventListener("click",(()=>{this.showIgnoreListed=i.checked;for(const e of this.items)this.refreshItem(e)})),{element:e,checkbox:i}}createShowMoreMessageElement(){const e=document.createElement("div");e.classList.add("show-more-message"),e.createChild("span");const t=e.createChild("span","link");return t.textContent=X(K.showMore),t.addEventListener("click",(()=>{this.maxAsyncStackChainDepth+=te,this.update()}),!1),e}onContextMenu(e){const i=this.list.itemForNode(e.target);if(!i)return;const o=new t.ContextMenu.ContextMenu(e),n=Z.get(i);n&&o.defaultSection().appendItem(X(K.restartFrame),(()=>{c.userMetrics.actionTaken(c.UserMetrics.Action.StackFrameRestarted),n.restart()}),{disabled:!n.canBeRestarted,jslogContext:"restart-frame"}),o.defaultSection().appendItem(X(K.copyStackTrace),this.copyStackTrace.bind(this),{jslogContext:"copy-stack-trace"}),i.uiLocation&&this.appendIgnoreListURLContextMenuItems(o,i.uiLocation.uiSourceCode),o.show()}onClick(e){const t=this.list.itemForNode(e.target);t&&this.activateItem(t)}activateItem(e){const n=e.uiLocation;if(this.muteActivateItem||!n)return;this.list.selectItem(e);const r=Z.get(e),s=this.activeCallFrameItem();r&&s!==e?(r.debuggerModel.setSelectedCallFrame(r),t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,r),s&&this.refreshItem(s),this.refreshItem(e)):i.Revealer.reveal(n)}activeCallFrameItem(){const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);return e&&this.items.find((t=>Z.get(t)===e))||null}appendIgnoreListURLContextMenuItems(e,t){const i=h.Persistence.PersistenceImpl.instance().binding(t);i&&(t=i.network);const o=e.section("ignoreList");if(!(o.items.length>0))for(const{text:e,callback:i,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListURLContextMenuItems(t))o.appendItem(e,i,{jslogContext:n})}selectNextCallFrameOnStack(){const e=this.activeCallFrameItem();for(let t=e?this.items.indexOf(e)+1:0;t=0;t--){const e=this.items.at(t);if(Z.has(e)){this.activateItem(e);break}}}copyStackTrace(){const e=[];for(const t of this.items){let i=t.title;t.uiLocation&&(i+=" ("+t.uiLocation.linkText(!0)+")"),e.push(i)}c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.join("\n"))}wasShown(){super.wasShown(),this.registerCSSFiles([G])}}const Z=new WeakMap,ee=Symbol("element"),te=32;class ie{isIgnoreListed;title;linkText;uiLocation;isAsyncHeader;updateDelegate;static async createForDebuggerCallFrame(e,i,o){const n=e.functionName,r=new ie(t.UIUtils.beautifyFunctionName(n),o);return await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),r.update.bind(r),i),p.NamesResolver.resolveDebuggerFrameFunctionName(e).then((e=>{e&&e!==n&&(r.title=e,r.updateDelegate(r))})),r}static async createItemsForAsyncStack(e,i,o,n,r){const s=new WeakMap,a=new ie(e,r);s.set(a,new Set),a.isAsyncHeader=!0;const c=[],l=[];for(const e of o){const o=new ie(t.UIUtils.beautifyFunctionName(e.functionName),d),r=i.createRawLocationByScriptId(e.scriptId,e.lineNumber,e.columnNumber);l.push(u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(r,o.update.bind(o),n)),c.push(o)}return await Promise.all(l),r(a),[a,...c];function d(e){r(e);let t=!1;const i=s.get(a);i&&(e.isIgnoreListed?(i.delete(e),t=0===i.size):(t=0===i.size,i.add(e)),a.isIgnoreListed=0===i.size),t&&r(a)}}constructor(e,t){this.isIgnoreListed=!1,this.title=e,this.linkText="",this.uiLocation=null,this.isAsyncHeader=!1,this.updateDelegate=t}async update(e){const t=await e.uiLocation();this.isIgnoreListed=await e.isIgnoreListed(),this.linkText=t?t.linkText():"",this.uiLocation=t,this.updateDelegate(this)}}var oe=Object.freeze({__proto__:null,CallStackSidebarPane:Q,elementSymbol:ee,defaultMaxAsyncStackChainDepth:te,ActionDelegate:class{handleAction(e,t){switch(t){case"debugger.next-call-frame":return Q.instance().selectNextCallFrameOnStack(),!0;case"debugger.previous-call-frame":return Q.instance().selectPreviousCallFrameOnStack(),!0}return!1}},Item:ie});const ne={beforeBidderWorkletBiddingStart:"Bidder Bidding Phase Start",beforeBidderWorkletReportingStart:"Bidder Reporting Phase Start",beforeSellerWorkletScoringStart:"Seller Scoring Phase Start",beforeSellerWorkletReportingStart:"Seller Reporting Phase Start",setTimeoutOrIntervalFired:"{PH1} fired",scriptFirstStatement:"Script First Statement",scriptBlockedByContentSecurity:"Script Blocked by Content Security Policy",requestAnimationFrame:"Request Animation Frame",cancelAnimationFrame:"Cancel Animation Frame",animationFrameFired:"Animation Frame Fired",webglErrorFired:"WebGL Error Fired",webglWarningFired:"WebGL Warning Fired",setInnerhtml:"Set `innerHTML`",createCanvasContext:"Create canvas context",createAudiocontext:"Create `AudioContext`",closeAudiocontext:"Close `AudioContext`",resumeAudiocontext:"Resume `AudioContext`",suspendAudiocontext:"Suspend `AudioContext`",sinkViolations:"Sink Violations",policyViolations:"Policy Violations"},re=e.i18n.registerUIStrings("panels/sources/CategorizedBreakpointL10n.ts",ne),se=e.i18n.getLazilyComputedLocalizedString.bind(void 0,re);function ae(t){return(de.get(t)??e.i18n.lockedLazyString(t))()}const ce={beforeBidderWorkletBiddingStart:se(ne.beforeBidderWorkletBiddingStart),beforeBidderWorkletReportingStart:se(ne.beforeBidderWorkletReportingStart),beforeSellerWorkletScoringStart:se(ne.beforeSellerWorkletScoringStart),beforeSellerWorkletReportingStart:se(ne.beforeSellerWorkletReportingStart),setTimeout:e.i18n.lockedLazyString("setTimeout"),clearTimeout:e.i18n.lockedLazyString("clearTimeout"),setInterval:e.i18n.lockedLazyString("setInterval"),clearInterval:e.i18n.lockedLazyString("clearInterval"),"setTimeout.callback":se(ne.setTimeoutOrIntervalFired,{PH1:"setTimeout"}),"setInterval.callback":se(ne.setTimeoutOrIntervalFired,{PH1:"setInterval"}),scriptFirstStatement:se(ne.scriptFirstStatement),scriptBlockedByCSP:se(ne.scriptBlockedByContentSecurity),sharedStorageWorkletScriptFirstStatement:se(ne.scriptFirstStatement),requestAnimationFrame:se(ne.requestAnimationFrame),cancelAnimationFrame:se(ne.cancelAnimationFrame),"requestAnimationFrame.callback":se(ne.animationFrameFired),webglErrorFired:se(ne.webglErrorFired),webglWarningFired:se(ne.webglWarningFired),"Element.setInnerHTML":se(ne.setInnerhtml),canvasContextCreated:se(ne.createCanvasContext),"Geolocation.getCurrentPosition":e.i18n.lockedLazyString("getCurrentPosition"),"Geolocation.watchPosition":e.i18n.lockedLazyString("watchPosition"),"Notification.requestPermission":e.i18n.lockedLazyString("requestPermission"),"DOMWindow.close":e.i18n.lockedLazyString("window.close"),"Document.write":e.i18n.lockedLazyString("document.write"),audioContextCreated:se(ne.createAudiocontext),audioContextClosed:se(ne.closeAudiocontext),audioContextResumed:se(ne.resumeAudiocontext),audioContextSuspended:se(ne.suspendAudiocontext)},le={"trustedtype-policy-violation":se(ne.policyViolations),"trustedtype-sink-violation":se(ne.sinkViolations)},de=new Map([...Object.entries(ce),...Object.entries(le)]);var ue=Object.freeze({__proto__:null,getLocalizedBreakpointName:ae});class he{uiSourceCode;constructor(e,t){this.uiSourceCode=e}static accepts(e){return!1}willHide(){}rightToolbarItems(){return[]}leftToolbarItems(){return[]}populateLineGutterContextMenu(e,t){}populateTextAreaContextMenu(e,t,i){}decorationChanged(e,t){}editorExtension(){return[]}editorInitialized(e){}dispose(){}}var pe=Object.freeze({__proto__:null,Plugin:he});const ge={clickToShowCoveragePanel:"Click to show Coverage Panel",showDetails:"Show Details",coverageS:"Coverage: {PH1}",coverageNa:"Coverage: n/a"},me=e.i18n.registerUIStrings("panels/sources/CoveragePlugin.ts",ge),be=e.i18n.getLocalizedString.bind(void 0,me);class fe extends he{originalSourceCode;infoInToolbar;model;coverage;#i;constructor(e,i){super(e),this.originalSourceCode=this.uiSourceCode,this.#i=i,this.infoInToolbar=new t.Toolbar.ToolbarButton(be(ge.clickToShowCoveragePanel),void 0,void 0,"debugger.show-coverage"),this.infoInToolbar.setSecondary(),this.infoInToolbar.addEventListener("Click",(()=>{t.ViewManager.ViewManager.instance().showView("coverage")}));const n=o.TargetManager.TargetManager.instance().primaryPageTarget();n&&(this.model=n.model(b.CoverageModel.CoverageModel),this.model&&(this.model.addEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this),this.coverage=this.model.getCoverageForUrl(this.originalSourceCode.url()),this.coverage&&this.coverage.addEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this))),this.updateStats()}dispose(){this.coverage&&this.coverage.removeEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this),this.model&&this.model.removeEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this)}static accepts(e){return e.contentType().isDocumentOrScriptOrStyleSheet()}handleReset(){this.coverage=null,this.updateStats()}handleCoverageSizesChanged(){this.updateStats()}updateStats(){if(this.coverage){this.infoInToolbar.setTitle(be(ge.showDetails));const t=new Intl.NumberFormat(e.DevToolsLocale.DevToolsLocale.instance().locale,{style:"percent",maximumFractionDigits:1});this.infoInToolbar.setText(be(ge.coverageS,{PH1:t.format(this.coverage.usedPercentage())}))}else this.infoInToolbar.setTitle(be(ge.clickToShowCoveragePanel)),this.infoInToolbar.setText(be(ge.coverageNa))}rightToolbarItems(){return[this.infoInToolbar]}editorExtension(){return ye.of([])}getCoverageManager(){return this.uiSourceCode.getDecorationData("coverage")}editorInitialized(e){this.getCoverageManager()&&this.startDecoUpdate(e)}decorationChanged(e,t){"coverage"===e&&this.startDecoUpdate(t)}startDecoUpdate(e){const i=this.getCoverageManager();(i?i.usageByLine(this.uiSourceCode,this.#o(e)):Promise.resolve([])).then((i=>{const o=Boolean(e.state.field(Ie,!1));var r;i.length?o?e.dispatch({effects:we.of(i)}):e.dispatch({effects:ye.reconfigure([Ie.init((e=>Ce(i,e))),(r=this.uiSourceCode.url(),n.gutter({markers:e=>e.state.field(Ie),domEventHandlers:{click:()=>(t.ViewManager.ViewManager.instance().showView("coverage").then((()=>{const e=t.ViewManager.ViewManager.instance().view("coverage");return e&&e.widget()})).then((e=>{const t=r.match(/(.*):formatted$/),i=t&&t[1]||r;e.selectCoverageItemByUrl(i)})),!0)},class:"cm-coverageGutter"})),xe])}):o&&e.dispatch({effects:ye.reconfigure([])})}))}#o(e){const t=[];for(let i=1;i<=e.state.doc.lines;++i){const o=e.state.doc.line(i),{lineNumber:n,columnNumber:r}=this.#i.editorLocationToUILocation(i-1,0),{lineNumber:s,columnNumber:a}=this.#i.editorLocationToUILocation(i-1,o.length);t.push(new g.TextRange.TextRange(n,r,s,a))}return t}}const Se=new class extends n.GutterMarker{elementClass="cm-coverageUsed"},ve=new class extends n.GutterMarker{elementClass="cm-coverageUnused"};function Ce(e,t){const i=new n.RangeSetBuilder;for(let o=0;on.RangeSet.empty,update:(e,t)=>t.effects.reduce(((e,i)=>i.is(we)?Ce(i.value,t.state):e),e.map(t.changes))});const ye=new n.Compartment,xe=n.EditorView.baseTheme({".cm-coverageGutter":{width:"5px",marginLeft:"3px"},".cm-coverageUnused":{backgroundColor:"var(--app-color-coverage-unused)"},".cm-coverageUsed":{backgroundColor:"var(--app-color-coverage-used)"}});var ke=Object.freeze({__proto__:null,CoveragePlugin:fe});const Te={openColorPicker:"Open color picker.",openCubicBezierEditor:"Open cubic bezier editor.",addSourceMap:"Add source map…"},Ee=e.i18n.registerUIStrings("panels/sources/CSSPlugin.ts",Te),Le=e.i18n.getLocalizedString.bind(void 0,Ee),Me=new Set(["ColorLiteral","NumberLiteral","StringLiteral","Comment","Important"]);async function Pe(e,t,i){const r=n.syntaxTree(e.state).resolveInner(e.pos,-1);if("ClassName"===r.name){d(i);const e=function(e,t){const i=t.getStyleSheetIdsForURL(e);if(0===i.length)throw new Error("Can't find style sheet ID for current URL");return i[0]}(t.url(),i),o=await i.getClassNames(e);return{from:r.from,options:o.map((e=>({type:"constant",label:e})))}}const s=function(e,t){if(Me.has(e.name))return null;for(let i=e;i&&"StyleSheet"!==i.name&&"Styles"!==i.name&&"CallExpression"!==i.name;i=i.parent)if("Declaration"===i.name){const e=i.getChild("PropertyName"),o=i.getChild(":");return e&&o&&o.to<=t?e:null}return null}(r,e.pos);if(s){const t=o.CSSMetadata.cssMetadata().getPropertyValues(e.state.sliceDoc(s.from,s.to));return{from:"ValueName"===r.name?r.from:e.pos,options:t.map((e=>({type:"constant",label:e}))),validFor:/^[\w\P{ASCII}\-]+$/u}}return null}class Fe extends n.WidgetType{#n;#r;#s;constructor(e,t,i){super(),this.#r=e,this.#n=t,this.#s=i}eq(e){return this.#r.equal(e.#r)&&this.#n===e.#n&&this.#s===e.#s}toDOM(e){const t=new v.ColorSwatch.ColorSwatch;t.renderColor(this.#r,!1,Le(Te.openColorPicker));const i=t.createChild("span");return i.textContent=this.#n,i.setAttribute("hidden","true"),t.addEventListener(v.ColorSwatch.ColorChangedEvent.eventName,(i=>{e.dispatch({changes:{from:this.#s,to:this.#s+this.#n.length,insert:i.data.text}}),this.#n=i.data.text,this.#r=t.getColor()})),t.addEventListener(v.ColorSwatch.ClickEvent.eventName,(i=>{i.consume(!0),e.dispatch({effects:Ne.of({type:0,pos:e.posAtDOM(t),text:this.#n,swatch:t,color:this.#r})})})),t}ignoreEvent(){return!0}}class De extends n.WidgetType{curve;text;constructor(e,t){super(),this.curve=e,this.text=t}eq(e){return this.curve.asCSSText()===e.curve.asCSSText()&&this.text===e.text}toDOM(e){const i=v.Swatches.BezierSwatch.create();return i.setBezierText(this.text),t.Tooltip.Tooltip.install(i.iconElement(),Le(Te.openCubicBezierEditor)),i.iconElement().addEventListener("click",(t=>{t.consume(!0),e.dispatch({effects:Ne.of({type:1,pos:e.posAtDOM(i),text:this.text,swatch:i,curve:this.curve})})}),!1),i.hideText(!0),i}ignoreEvent(){return!0}}const Ne=n.StateEffect.define(),Ae=n.Annotation.define(),Ue=n.StateField.define({create:()=>null,update(e,t){!t.docChanged&&!t.selection||t.annotation(Ae)||(e=null);for(const i of t.effects)i.is(Ne)&&(e=i.value);return e},provide:e=>n.showTooltip.from(e,(e=>e&&function(e){return{pos:e.pos,arrow:!0,create(t){let i,o,n=e.text;if(0===e.type){const n=new S.Spectrum.Spectrum;o=e=>{n.addEventListener("ColorChanged",e)},n.addEventListener("SizeChanged",(()=>t.requestMeasure())),n.setColor(e.color,e.color.format()),i=n,c.userMetrics.colorPickerOpenedFrom(0)}else{const t=new v.BezierEditor.BezierEditor(e.curve);i=t,o=e=>{t.addEventListener("BezierChanged",e)}}const r=document.createElement("div");return r.className="cm-tooltip-swatchEdit",i.markAsRoot(),i.show(r),i.showWidget(),i.element.addEventListener("keydown",(o=>{"Escape"===o.key&&(o.consume(),t.dispatch({effects:Ne.of(null),changes:n===e.text?void 0:{from:e.pos,to:e.pos+n.length,insert:e.text}}),i.hideWidget(),t.focus())})),i.element.addEventListener("focusout",(e=>{e.relatedTarget&&!i.element.contains(e.relatedTarget)&&(t.dispatch({effects:Ne.of(null)}),i.hideWidget())}),!1),i.element.addEventListener("mousedown",(e=>e.consume())),{dom:r,resize:!1,offset:{x:-8,y:0},mount:()=>{i.focus(),i.wasShown(),o((i=>{t.dispatch({changes:{from:e.pos,to:e.pos+n.length,insert:i.data},annotations:Ae.of(!0)}),n=i.data}))}}}}}(e)))});function Re(e,o,r){const s=new n.RangeSetBuilder;return function(e,o,r,s,a){let c=e.doc.lineAt(o);function l(t,i){return t>=c.to&&(c=e.doc.lineAt(t)),c.text.slice(t-c.from,i-c.from)}const d=n.ensureSyntaxTree(e,r,100);d&&d.iterate({from:o,to:r,enter:o=>{let n;if("ValueName"===o.name||"ColorLiteral"===o.name?n=l(o.from,o.to):"Callee"===o.name&&/^(?:(?:rgba?|hsla?|hwba?|lch|oklch|lab|oklab|color)|cubic-bezier)$/.test(l(o.from,o.to))&&(n=e.sliceDoc(o.from,o.node.parent.to)),n){const e=i.Color.parse(n);if(e)s(o.from,e,n);else{const e=t.Geometry.CubicBezier.parse(n);e&&a(o.from,e,n)}}}})}(e,o,r,((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new Fe(t,i,e)}))}),((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new De(t,i)}))})),s.finish()}const Be=n.ViewPlugin.fromClass(class{decorations;constructor(e){this.decorations=Re(e.state,e.viewport.from,e.viewport.to)}update(e){(e.viewportChanged||e.docChanged)&&(this.decorations=Re(e.state,e.view.viewport.from,e.view.viewport.to))}},{decorations:e=>e.decorations});function je(e){if("Unit"===e.name&&(e=e.parent),"NumberLiteral"===e.name){const t=e.lastChild;return{from:e.from,to:t&&"Unit"===t.name?t.from:e.to}}return null}function Ve(e,t){const{head:i}=e.state.selection.main,o=n.syntaxTree(e.state).resolveInner(i,-1),r=je(o)||je(o.resolve(i,1));if(!r)return!1;const s=Number(e.state.sliceDoc(r.from,r.to));return!isNaN(s)&&(e.dispatch({changes:{from:r.from,to:r.to,insert:String(s+t)},scrollIntoView:!0,userEvent:"insert.modifyUnit"}),!0)}function We(){let e=null;const i=t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"sources.increment-css":()=>Promise.resolve(Ve(e,1)),"sources.increment-css-by-ten":()=>Promise.resolve(Ve(e,10)),"sources.decrement-css":()=>Promise.resolve(Ve(e,-1)),"sources.decrement-css-by-ten":()=>Promise.resolve(Ve(e,-10))});return n.EditorView.domEventHandlers({keydown:(t,o)=>{const n=e;return e=o,i(t),e=n,t.defaultPrevented}})}class Oe extends he{#a;constructor(e,t){super(e,t),o.TargetManager.TargetManager.instance().observeModels(o.CSSModel.CSSModel,this)}static accepts(e){return e.contentType().hasStyleSheets()}modelAdded(e){e.target()===o.TargetManager.TargetManager.instance().primaryPageTarget()&&(this.#a=e)}modelRemoved(e){this.#a===e&&(this.#a=void 0)}editorExtension(){return[We(),this.#c(),[Be,Ue]]}#c(){const{cssCompletionSource:e}=n.css,t=this.uiSourceCode,i=this.#a;return n.autocompletion({override:[async o=>await Pe(o,t,i)||e(o)]})}populateTextAreaContextMenu(e){const t=this.#a,i=this.uiSourceCode.url();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&t&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(i)){const o=Le(Te.addSourceMap);e.debugSection().appendItem(o,(()=>function(e,t){j.createAddSourceMapURLDialog((i=>{u.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().modelToInfo.get(e)?.addSourceMap(t,i)})).show()}(t,i)),{jslogContext:"add-source-map"})}}}var He=Object.freeze({__proto__:null,cssBindings:We,CSSPlugin:Oe});const _e=new CSSStyleSheet;_e.replaceSync(".paused-status{margin:6px;padding:4px 10px;border-radius:10px;background-color:var(--sys-color-yellow-container);color:var(--sys-color-on-yellow-container)}.paused-status.error-reason{background-color:var(--sys-color-surface-error);color:var(--sys-color-on-surface-error)}.status-main{padding-left:18px;position:relative}.status-sub:not(:empty){padding-left:15px;padding-top:5px;overflow:hidden;text-overflow:ellipsis}.paused-status.error-reason .status-sub{color:var(--sys-color-error);line-height:11px;max-height:27px;user-select:text}devtools-icon{position:absolute;left:-1px;top:-1px}\n/*# sourceURL=debuggerPausedMessage.css */\n");const ze={pausedOnS:"Paused on {PH1}",childSAdded:"Child {PH1} added",descendantSAdded:"Descendant {PH1} added",descendantSRemoved:"Descendant {PH1} removed",pausedOnEventListener:"Paused on event listener",pausedOnXhrOrFetch:"Paused on XHR or fetch",pausedOnException:"Paused on exception",pausedOnPromiseRejection:"Paused on `promise` rejection",pausedOnAssertion:"Paused on assertion",pausedOnDebuggedFunction:"Paused on debugged function",pausedBeforePotentialOutofmemory:"Paused before potential out-of-memory crash",pausedOnCspViolation:"Paused on CSP violation",trustedTypeSinkViolation:"`Trusted Type` Sink Violation",trustedTypePolicyViolation:"`Trusted Type` Policy Violation",pausedOnBreakpoint:"Paused on breakpoint",debuggerPaused:"Debugger paused",subtreeModifications:"subtree modifications",attributeModifications:"attribute modifications",nodeRemoval:"node removal",webglErrorFiredS:"WebGL Error Fired ({PH1})",scriptBlockedDueToContent:"Script blocked due to Content Security Policy directive: {PH1}"},qe=e.i18n.registerUIStrings("panels/sources/DebuggerPausedMessage.ts",ze),$e=e.i18n.getLocalizedString.bind(void 0,qe),Ge=e.i18n.getLazilyComputedLocalizedString.bind(void 0,qe);class Ke{elementInternal;contentElement;constructor(){this.elementInternal=document.createElement("div"),this.elementInternal.classList.add("paused-message"),this.elementInternal.classList.add("flex-none");const e=t.Utils.createShadowRootWithCoreStyles(this.elementInternal,{cssFile:[_e],delegatesFocus:void 0});this.contentElement=e.createChild("div"),t.ARIAUtils.markAsPoliteLiveRegion(this.elementInternal,!1)}element(){return this.elementInternal}static descriptionWithoutStack(e){const t=/^\s+at\s/m.exec(e);return t?e.substring(0,t.index-1):e.substring(0,e.lastIndexOf("\n"))}static async createDOMBreakpointHitMessage(t){const n=document.createElement("span"),s=t.debuggerModel.target().model(o.DOMDebuggerModel.DOMDebuggerModel);if(!t.auxData||!s)return n;const a=s.resolveDOMBreakpointData(t.auxData);if(!a)return n;const c=n.createChild("div","status-main"),l=new r.Icon.Icon;l.data={iconName:"info",color:"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},c.appendChild(l);const d=Je.get(a.type);c.appendChild(document.createTextNode($e(ze.pausedOnS,{PH1:d?d():String(null)})));const u=n.createChild("div","status-sub monospace"),h=await i.Linkifier.Linkifier.linkify(a.node);if(u.appendChild(h),a.targetNode){const t=await i.Linkifier.Linkifier.linkify(a.targetNode);let o;o=a.insertion?a.targetNode===a.node?e.i18n.getFormatLocalizedString(qe,ze.childSAdded,{PH1:t}):e.i18n.getFormatLocalizedString(qe,ze.descendantSAdded,{PH1:t}):e.i18n.getFormatLocalizedString(qe,ze.descendantSRemoved,{PH1:t}),u.appendChild(document.createElement("br")),u.appendChild(o)}return n}static#l(e){if(!e)return"";const{eventName:t,webglErrorName:i,directiveText:n,targetName:r}=e;if("instrumentation:webglErrorFired"===t&&i){const e=i.replace(/^.*(0x[0-9a-f]+).*$/i,"$1");return $e(ze.webglErrorFiredS,{PH1:e})}if("instrumentation:scriptBlockedByCSP"===t&&n)return $e(ze.scriptBlockedDueToContent,{PH1:n});let s=o.EventBreakpointsModel.EventBreakpointsManager.instance().resolveEventListenerBreakpoint(e);return s?ae(s.name):(s=o.DOMDebuggerModel.DOMDebuggerManager.instance().resolveEventListenerBreakpoint(e),s&&r?r+"."+s.name:s?.name??"")}async render(e,i,o){if(this.contentElement.removeChildren(),this.contentElement.hidden=!e,!e)return;const n=this.contentElement.createChild("div","paused-status"),s="exception"===e.reason||"promiseRejection"===e.reason||"assert"===e.reason||"OOM"===e.reason;let a;if("DOM"===e.reason)a=await Ke.createDOMBreakpointHitMessage(e);else if("EventListener"===e.reason){const t=Ke.#l(e.auxData);a=c($e(ze.pausedOnEventListener),t)}else if("XHR"===e.reason){const t=e.auxData;a=c($e(ze.pausedOnXhrOrFetch),t.url||"")}else if("exception"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Ke.descriptionWithoutStack(i);a=c($e(ze.pausedOnException),o,i)}else if("promiseRejection"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Ke.descriptionWithoutStack(i);a=c($e(ze.pausedOnPromiseRejection),o,i)}else if("assert"===e.reason)a=c($e(ze.pausedOnAssertion));else if("debugCommand"===e.reason)a=c($e(ze.pausedOnDebuggedFunction));else if("OOM"===e.reason)a=c($e(ze.pausedBeforePotentialOutofmemory));else if("CSPViolation"===e.reason&&e.auxData&&e.auxData.violationType){const t=e.auxData.violationType;"trustedtype-sink-violation"===t?a=c($e(ze.pausedOnCspViolation),$e(ze.trustedTypeSinkViolation)):"trustedtype-policy-violation"===t&&(a=c($e(ze.pausedOnCspViolation),$e(ze.trustedTypePolicyViolation)))}else if(e.callFrames.length){const t=await i.rawLocationToUILocation(e.callFrames[0].location()),n=t?o.findBreakpoint(t):null;a=c($e(n?ze.pausedOnBreakpoint:ze.debuggerPaused))}else console.warn("ScriptsPanel paused, but callFrames.length is zero.");function c(e,i,o){const n=document.createElement("span"),a=n.createChild("div","status-main"),c=new r.Icon.Icon;if(c.data={iconName:s?"cross-circle-filled":"info",color:s?"var(--icon-error)":"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},a.appendChild(c),a.appendChild(document.createTextNode(e)),i){const e=n.createChild("div","status-sub monospace");e.textContent=i,t.Tooltip.Tooltip.install(e,o||i)}return n}n.classList.toggle("error-reason",s),a&&n.appendChild(a)}}const Je=new Map([["subtree-modified",Ge(ze.subtreeModifications)],["attribute-modified",Ge(ze.attributeModifications)],["node-removed",Ge(ze.nodeRemoval)]]);var Xe=Object.freeze({__proto__:null,DebuggerPausedMessage:Ke,BreakpointTypeNouns:Je});const Ye=new CSSStyleSheet;Ye.replaceSync(":host{overflow-y:auto}.icon,\n.icon-basic,\n.icon-badge{margin:-3px -5px}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n.navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection){filter:grayscale(50%);opacity:50%}.is-ignore-listed{opacity:50%}.tree-outline li{min-height:20px}.tree-outline li:hover:not(.selected) .selection{display:block;background-color:var(--sys-color-state-hover-on-subtle)}.navigator-fs-folder-tree-item devtools-icon{color:var(--icon-folder-workspace)}.navigator-fs-tree-item devtools-icon{color:var(--icon-file-authored)}.navigator-nw-folder-tree-item devtools-icon{color:var(--icon-folder-deployed)}.navigator-sm-script-tree-item devtools-icon,\n.navigator-script-tree-item devtools-icon,\n.navigator-snippet-tree-item devtools-icon{color:var(--icon-file-script)}.navigator-file-tree-item devtools-icon.dot::before{width:7px;height:7px;top:12px;left:11px}.navigator-file-tree-item:hover:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-hover)}.navigator-file-tree-item.selected:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-inactive)}.navigator-file-tree-item.selected.force-white-icons devtools-icon.dot::before{outline-color:var(--icon-gap-focus-selected)}.navigator-sm-stylesheet-tree-item devtools-icon,\n.navigator-stylesheet-tree-item devtools-icon{color:var(--icon-file-styles)}.navigator-image-tree-item devtools-icon,\n.navigator-font-tree-item devtools-icon{color:var(--icon-file-image)}.navigator-nw-folder-tree-item.is-from-source-map devtools-icon{color:var(--icon-folder-authored)}.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-folder-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-script-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-stylesheet-tree-item .tree-element-title{font-style:italic}@media (forced-colors: active){.tree-outline li .leading-icons devtools-icon{color:ButtonText}.tree-outline li:hover:not(.selected) .selection{forced-color-adjust:none;background-color:Highlight}.tree-outline:not(.hide-selection-when-blurred) li.parent:hover:not(.selected)::before{background-color:HighlightText}.tree-outline:not(.hide-selection-when-blurred) li:hover:not(.selected) devtools-icon,\n .tree-outline li:not(.selected):hover .tree-element-title{forced-color-adjust:none;color:HighlightText}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .is-ignore-listed{filter:none;opacity:100%}}\n/*# sourceURL=navigatorTree.css */\n");const Qe=new CSSStyleSheet;Qe.replaceSync(".navigator-toolbar{border-bottom:1px solid var(--sys-color-divider);padding-left:8px}\n/*# sourceURL=navigatorView.css */\n");class Ze{searchId;searchResultCandidates;searchResultCallback;searchFinishedCallback;searchConfig;constructor(){this.searchId=0,this.searchResultCandidates=[],this.searchResultCallback=null,this.searchFinishedCallback=null,this.searchConfig=null}static filesComparator(e,t){if(e.isDirty()&&!t.isDirty())return-1;if(!e.isDirty()&&t.isDirty())return 1;const i=e.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(e);if(i!==(t.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(t)))return i?1:-1;const o=e.url(),n=t.url();return o&&!n?-1:!o&&n?1:l.StringUtilities.naturalOrderComparator(e.fullDisplayName(),t.fullDisplayName())}static urlComparator(e,t){return l.StringUtilities.naturalOrderComparator(e.url(),t.url())}performIndexing(e){this.stopSearch();const t=this.projects(),o=new i.Progress.CompositeProgress(e);for(let e=0;et.type()!==f.Workspace.projectTypes.Service&&(!(!e&&t.isServiceProject()&&t.type()!==f.Workspace.projectTypes.Formatter)&&!(!e&&t.type()===f.Workspace.projectTypes.ContentScripts))))}performSearch(e,t,o,n){this.stopSearch(),this.searchResultCandidates=[],this.searchResultCallback=o,this.searchFinishedCallback=n,this.searchConfig=e;const r=[],s=new i.Progress.CompositeProgress(t),a=s.createSubProgress(),c=new i.Progress.CompositeProgress(s.createSubProgress());for(const t of this.projects()){const i=[...t.uiSourceCodes()].length,o=c.createSubProgress(i),n=this.projectFilesMatchingFileQuery(t,e),s=t.findFilesMatchingSearchRequest(e,n,o).then(this.processMatchingFilesForProject.bind(this,this.searchId,t,e,n));r.push(s)}Promise.all(r).then(this.processMatchingFiles.bind(this,this.searchId,a,this.searchFinishedCallback.bind(this,!0)))}projectFilesMatchingFileQuery(e,t,i){const o=[];for(const n of e.uiSourceCodes()){if(!n.contentType().isTextType())continue;if(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(n))continue;const e=h.Persistence.PersistenceImpl.instance().binding(n);e&&e.network===n||(i&&!n.isDirty()||t.filePathMatchesFileQuery(n.fullDisplayName())&&o.push(n))}return o.sort(Ze.urlComparator),o}processMatchingFilesForProject(e,t,i,o,n){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);let r=[...n.keys()];r.sort(Ze.urlComparator),r=l.ArrayUtilities.intersectOrdered(r,o,Ze.urlComparator);const s=this.projectFilesMatchingFileQuery(t,i,!0);r=l.ArrayUtilities.mergeOrdered(r,s,Ze.urlComparator);const a=[];for(const e of r){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&!t.isAnonymousScript()||a.push(e)}a.sort(Ze.filesComparator),this.searchResultCandidates=l.ArrayUtilities.mergeOrdered(this.searchResultCandidates,a,Ze.filesComparator)}processMatchingFiles(e,t,i){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);const o=this.searchResultCandidates;if(!o.length)return t.done(),void i();t.setTotalWork(o.length);let n=0;let r=0;for(let e=0;e<20&&e{c.call(this,e,t.content||"")}))}function a(){if(n>=o.length)return r?void 0:(t.done(),void i());++r;const e=o[n++];window.setTimeout(s.bind(this,e),0)}function c(e,i){t.incrementWorked(1);let o=[];const n=this.searchConfig,s=n.queries();if(null!==i){for(let e=0;ei.Revealer.reveal(n)),{jslogContext:t?"search-in-folder":"search-in-all-files"})}static treeElementsCompare(e,t){const i=dt.treeElementOrder(e),o=dt.treeElementOrder(t);return i>o?1:ie.frame()===i));o&&this.removeUISourceCodeNode(o)}acceptsUISourceCode(e){return this.acceptProject(e.project())}addUISourceCode(e){if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return;if(!this.acceptsUISourceCode(e))return;if(e.isFetchXHR())return;const t=u.NetworkProject.NetworkProject.framesForUISourceCode(e);if(t.length)for(const i of t)this.addUISourceCodeNode(e,i);else this.addUISourceCodeNode(e,null);this.uiSourceCodeAdded(e)}addUISourceCodeNode(e,t){const o=e.contentType().isFromSourceMap();let n;n=e.project().type()===f.Workspace.projectTypes.FileSystem?h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(e).slice(0,-1):i.ParsedURL.ParsedURL.extractPath(e.url()).split("/").slice(1,-1);const r=e.project(),s=u.NetworkProject.NetworkProject.targetForUISourceCode(e),a=this.folderNode(e,r,s,t,e.origin(),n,o),c=new bt(this,e,t),l=a.child(c.id);l&&l instanceof bt?this.uiSourceCodeNodes.set(e,l):(a.appendChild(c),this.uiSourceCodeNodes.set(e,c),c.updateTitleBubbleUp()),this.selectDefaultTreeNode()}uiSourceCodeAdded(e){}uiSourceCodeAddedCallback(e){const t=e.data;this.addUISourceCode(t)}uiSourceCodeRemovedCallback(e){this.removeUISourceCodes([e.data])}tryAddProject(e){this.projectAdded(e);for(const t of e.uiSourceCodes())this.addUISourceCode(t)}projectAdded(e){const t=this.rootOrDeployedNode();!this.acceptProject(e)||e.type()!==f.Workspace.projectTypes.FileSystem||T.ScriptSnippetFileSystem.isSnippetsProject(e)||t.child(e.id())||(t.appendChild(new St(this,e,e.id(),ct.FileSystem,e.displayName())),this.selectDefaultTreeNode())}selectDefaultTreeNode(){const e=this.rootNode.children();e.length&&!this.scriptsTree.selectedTreeElement&&e[0].treeNode().select(!0,!1)}computeUniqueFileSystemProjectNames(){const e=this.workspaceInternal.projectsForType(f.Workspace.projectTypes.FileSystem);if(!e.length)return;const t=i.Trie.Trie.newArrayTrie(),o=[];for(const i of e){const e=i.fileSystemPath().split("/").reverse();o.push(e),t.add(e)}const n=this.rootOrDeployedNode();for(let r=0;r{await this.removeUISourceCodeFromProject(e)})),e instanceof bt&&e.uiSourceCode().project().removeUISourceCode(e.uiSourceCode().url())}async deleteDirectoryRecursively(e){e instanceof ft&&await(h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()?.deleteDirectoryRecursively(e.folderPath))}findTopNonMergedNode(e){return e.isMerged&&e.parent instanceof ft?this.findTopNonMergedNode(e.parent):e}handleFolderContextMenu(e,o){const n=o.folderPath||l.DevToolsPath.EmptyEncodedPathString,r=o.project||null,s=new t.ContextMenu.ContextMenu(e);if(dt.appendSearchItem(s,n),r){if(r.type()===f.Workspace.projectTypes.FileSystem){const e=i.ParsedURL.ParsedURL.urlToRawPathString(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.completeURL(r,n),c.Platform.isWin());s.revealSection().appendItem(at(rt.openFolder),(()=>c.InspectorFrontendHost.InspectorFrontendHostInstance.showItemInFolder(e)),{jslogContext:"open-folder"}),r.canCreateFile()&&s.defaultSection().appendItem(at(rt.newFile),(()=>{this.handleContextMenuCreate(r,n,void 0)}),{jslogContext:"new-file"})}else if(o.origin&&o.folderPath){const e=i.ParsedURL.ParsedURL.concatenate(o.origin,"/",o.folderPath),t={isContentScript:o.recursiveProperties.exclusivelyContentScripts||!1,isKnownThirdParty:o.recursiveProperties.exclusivelyThirdParty||!1,isCurrentlyIgnoreListed:o.recursiveProperties.exclusivelyIgnored||!1};for(const{text:i,callback:o,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListFolderContextMenuItems(e,t))s.defaultSection().appendItem(i,o,{jslogContext:n})}if(r.canExcludeFolder(n)&&s.defaultSection().appendItem(at(rt.excludeFolder),this.handleContextMenuExclude.bind(this,r,n),{jslogContext:"exclude-folder"}),r.type()===f.Workspace.projectTypes.FileSystem){"overrides"===r.fileSystem().type()?o instanceof St||s.defaultSection().appendItem(at(rt.delete),this.handleDeleteFolder.bind(this,o),{jslogContext:"delete"}):o instanceof St&&s.defaultSection().appendItem(at(rt.removeFolderFromWorkspace),(async()=>{const e=`${at(rt.areYouSureYouWantToRemoveThis,{PH1:o.title})}\n${at(rt.workspaceStopSyncing)}`;await t.UIUtils.ConfirmDialog.show(e,void 0,{okButtonLabel:at(rt.remove),jslogContext:"remove-folder-from-workspace-confirmation"})&&r.remove()}),{jslogContext:"remove-folder-from-workspace"})}s.show()}}rename(e,t){const i=e.uiSourceCode();e.rename(function(o){if(!t)return;o?e.treeElement&&e.treeElement.listItemElement.hasFocus()&&this.sourceSelected(i,!0):i.remove()}.bind(this))}async create(e,t,i){let o="";i&&(o=(await i.requestContent()).content||"");const n=await e.createFile(t,null,o);if(!n)return;this.sourceSelected(n,!1);const r=this.revealUISourceCode(n,!0);r&&this.rename(r,!0)}groupingChanged(){this.reset(!0),this.initGrouping(),this.resetWorkspace(f.Workspace.WorkspaceImpl.instance()),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}ignoreListChanged(){C.Runtime.experiments.isEnabled("just-my-code")?this.groupingChanged():this.rootNode.updateTitleRecursive()}initGrouping(){this.groupByFrame=!0,this.groupByDomain=this.navigatorGroupByFolderSetting.get(),this.groupByFolder=this.groupByDomain,this.navigatorGroupByAuthoredExperiment?this.groupByAuthored=C.Runtime.experiments.isEnabled(this.navigatorGroupByAuthoredExperiment):this.groupByAuthored=!1}resetForTest(){this.reset(),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}discardFrame(e,t){if(t)return;const i=this.frameNodes.get(e);if(i){i.parent&&i.parent.removeChild(i),this.frameNodes.delete(e);for(const i of e.childFrames)this.discardFrame(i,t)}}targetAdded(e){}targetRemoved(e){const t=this.rootOrDeployedNode(),i=t.child("target:"+e.id());i&&t.removeChild(i)}targetNameChanged(e){const t=e.data,i=this.rootOrDeployedNode().child("target:"+t.id());i&&i.setTitle(t.name())}wasShown(){super.wasShown(),this.scriptsTree.registerCSSFiles([Ye]),this.registerCSSFiles([Qe])}}const ut=new WeakSet;class ht extends t.TreeOutline.TreeElement{nodeType;navigatorView;hoverCallback;node;hovered;isIgnoreListed;isFromSourceMap;constructor(e,i,o,n){super("",!0,ht.#h(i)),this.listItemElement.classList.add("navigator-"+i+"-tree-item","navigator-folder-tree-item"),t.ARIAUtils.setLabel(this.listItemElement,`${o}, ${i}`),this.nodeType=i,this.title=o,this.tooltip=o,this.navigatorView=e,this.hoverCallback=n,this.isFromSourceMap=!1;let s="folder";i===ct.Domain?s="cloud":i===ct.Frame?s="frame":i===ct.Worker?s="gears":i===ct.Authored?s="code":i===ct.Deployed&&(s="deployed");const a=r.Icon.create(s);this.setLeadingIcons([a])}async onpopulate(){this.node.populate()}onattach(){this.collapse(),this.node.onattach(),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("mousemove",this.mouseMove.bind(this),!1),this.listItemElement.addEventListener("mouseleave",this.mouseLeave.bind(this),!1)}setIgnoreListed(e){this.isIgnoreListed!==e&&(this.isIgnoreListed=e,this.listItemElement.classList.toggle("is-ignore-listed",e),this.updateTooltip())}setFromSourceMap(e){this.isFromSourceMap=e,this.listItemElement.classList.toggle("is-from-source-map",e)}setNode(e){this.node=e,this.updateTooltip(),t.ARIAUtils.setLabel(this.listItemElement,`${this.title}, ${this.nodeType}`)}updateTooltip(){if(this.node.tooltip)this.tooltip=this.node.tooltip;else{const e=[];let t=this.node;for(;t&&!t.isRoot()&&t.type===this.node.type;)e.push(t.title),t=t.parent;e.reverse();let i=e.join("/");this.isIgnoreListed&&(i=at(rt.sIgnoreListed,{PH1:i})),this.tooltip=i}}handleContextMenuEvent(e){this.node&&(this.select(),this.navigatorView.handleFolderContextMenu(e,this.node))}mouseMove(e){!this.hovered&&this.hoverCallback&&(this.hovered=!0,this.hoverCallback(!0))}mouseLeave(e){this.hoverCallback&&(this.hovered=!1,this.hoverCallback(!1))}static#h(e){switch(e){case ct.Domain:return"domain";case ct.Frame:return"frame";case ct.Worker:return"worker";case ct.Authored:return"authored";case ct.Deployed:return"deployed"}return"folder"}}class pt extends t.TreeOutline.TreeElement{nodeType;node;navigatorView;uiSourceCodeInternal;constructor(e,o,n,r){super("",!1,o.contentType().name()),this.nodeType=ct.File,this.node=r,this.title=n,this.listItemElement.classList.add("navigator-"+o.contentType().name()+"-tree-item","navigator-file-tree-item"),this.tooltip=o.url(),t.ARIAUtils.setLabel(this.listItemElement,`${o.name()}, ${this.nodeType}`),i.EventTarget.fireEvent("source-tree-file-added",o.fullDisplayName()),this.navigatorView=e,this.uiSourceCodeInternal=o,this.updateIcon()}updateIcon(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),i=h.NetworkPersistenceManager.NetworkPersistenceManager.instance();let o="document",n=[];if(e){T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e.fileSystem)&&(o="snippet");n=i.project()===e.fileSystem.project()?["dot","purple"]:["dot","green"]}else i.isActiveHeaderOverrides(this.uiSourceCode)?n=["dot","purple"]:T.ScriptSnippetFileSystem.isSnippetsUISourceCode(this.uiSourceCodeInternal)&&(o="snippet");const s=r.Icon.create(o,n.join(" "));e&&t.Tooltip.Tooltip.install(s,h.PersistenceUtils.PersistenceUtils.tooltipForUISourceCode(this.uiSourceCodeInternal)),this.setLeadingIcons([s])}updateAccessibleName(){t.ARIAUtils.setLabel(this.listItemElement,`${this.uiSourceCodeInternal.name()}, ${this.nodeType}`)}get uiSourceCode(){return this.uiSourceCodeInternal}onattach(){this.listItemElement.draggable=!0,this.listItemElement.addEventListener("click",this.onclick.bind(this),!1),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("dragstart",this.ondragstart.bind(this),!1)}shouldRenameOnMouseDown(){if(!this.uiSourceCodeInternal.canRename())return!1;if(!this.treeOutline)return!1;return this===this.treeOutline.selectedTreeElement&&this.treeOutline.element.hasFocus()&&!t.UIUtils.isBeingEdited(this.treeOutline.element)}selectOnMouseDown(e){1===e.which&&this.shouldRenameOnMouseDown()?window.setTimeout(function(){this.shouldRenameOnMouseDown()&&this.navigatorView.rename(this.node,!1)}.bind(this),300):super.selectOnMouseDown(e)}ondragstart(e){e.dataTransfer&&(e.dataTransfer.setData("text/plain",this.uiSourceCodeInternal.url()),e.dataTransfer.effectAllowed="copy")}onspace(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}onclick(e){this.navigatorView.sourceSelected(this.uiSourceCode,!1)}ondblclick(e){const t=1===e.button;return this.navigatorView.sourceSelected(this.uiSourceCode,!t),!1}onenter(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}ondelete(){return!0}handleContextMenuEvent(e){this.select(),this.navigatorView.handleFileContextMenu(e,this.node)}}class gt{id;navigatorView;type;childrenInternal;populated;isMerged;parent;title;tooltip;recursiveProperties;constructor(e,t,i,o){this.id=t,this.navigatorView=e,this.type=i,this.childrenInternal=new Map,this.tooltip=o,this.populated=!1,this.isMerged=!1,this.recursiveProperties={exclusivelySourceMapped:null,exclusivelyIgnored:null,exclusivelyContentScripts:null,exclusivelyThirdParty:null}}treeNode(){throw"Not implemented"}dispose(){}updateTitle(){}updateTitleRecursive(){for(const e of this.children())e.updateTitleRecursive();this.updateTitle()}updateTitleBubbleUp(){this.updateTitle(),this.parent&&this.parent.updateTitleBubbleUp()}isRoot(){return!1}hasChildren(){return!0}onattach(){}setTitle(e){throw"Not implemented"}populate(){this.isPopulated()||(this.parent&&this.parent.populate(),this.populated=!0,this.wasPopulated())}wasPopulated(){const e=this.children();for(let t=0;te.title)).join("/"),r=[];o=t;do{r.push(o),i=o.children(),o=1===i.length?i[0]:null}while(o&&o.isMerged);if(!this.isPopulated()){this.treeElement.title=n,this.treeElement.setNode(this);for(let e=0;ee.title)).join("/"),s.parent&&this.navigatorView.removeChild(s.parent,s),this.navigatorView.appendChild(this.treeElement,s),s.expanded&&a.expand(),this.updateTitle()}this.isPopulated()&&this.navigatorView.appendChild(this.treeElement,e.treeNode())}willRemoveChild(e){const t=e;!t.isMerged&&this.isPopulated()&&this.treeElement&&t.treeElement&&this.navigatorView.removeChild(this.treeElement,t.treeElement)}}class St extends gt{project;title;hoverCallback;treeElement;constructor(e,t,i,o,n,r){super(e,i,o,r),this.project=t,this.title=n,this.populate()}setHoverCallback(e){this.hoverCallback=e}treeNode(){return this.treeElement||(this.treeElement=new ht(this.navigatorView,this.type,this.title,this.hoverCallback),this.treeElement.setNode(this)),this.treeElement}onattach(){this.updateTitle()}updateTitle(){if(!this.treeElement||!this.project||this.project.type()!==f.Workspace.projectTypes.FileSystem)return;const e=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemPath(this.project.id()),t=this.treeElement.listItemElement.classList.contains("has-mapped-files"),i=h.Persistence.PersistenceImpl.instance().filePathHasBindings(e);t!==i&&(this.treeElement.listItemElement.classList.toggle("has-mapped-files",i),this.treeElement.childrenListElement.hasFocus()||(i?this.treeElement.expand():this.treeElement.collapse()))}setTitle(e){this.title=e,this.treeElement&&(this.treeElement.title=this.title)}}var vt=Object.freeze({__proto__:null,Types:ct,NavigatorView:dt,NavigatorFolderTreeElement:ht,NavigatorSourceTreeElement:pt,NavigatorTreeNode:gt,NavigatorRootTreeNode:mt,NavigatorUISourceCodeTreeNode:bt,NavigatorFolderTreeNode:ft,NavigatorGroupTreeNode:St});const Ct=new CSSStyleSheet;Ct.replaceSync('.paused-message{align-self:center;width:fit-content}.scripts-debug-toolbar{position:absolute;top:0;width:100%;background-color:var(--app-color-toolbar-background);border-bottom:1px solid var(--sys-color-divider);overflow:hidden;z-index:1}.scripts-debug-toolbar-drawer{flex:0 0 52px;transition:margin-top 0.1s ease-in-out;margin-top:-26px;padding-top:25px;background-color:var(--sys-color-cdt-base-container);overflow:hidden;white-space:nowrap}.scripts-debug-toolbar-drawer.expanded{margin-top:0}.scripts-debug-toolbar-drawer > [is="dt-checkbox"]{display:none;padding-left:3px;height:28px}.scripts-debug-toolbar-drawer.expanded > [is="dt-checkbox"]{display:flex}.cursor-auto{cursor:auto}.navigator-tabbed-pane{background-color:var(--sys-color-cdt-base-container)}\n/*# sourceURL=sourcesPanel.css */\n');class wt{sourcesView;entries=[];current=-1;revealing=!1;constructor(e){this.sourcesView=e}trackSourceFrameCursorJumps(e){e.addEventListener("EditorUpdate",(t=>this.onEditorUpdate(t.data,e)))}onEditorUpdate(e,t){e.docChanged&&this.mapEntriesFor(t.uiSourceCode(),e.changes);const i=e.startState.selection.main,o=e.state.selection.main;!this.revealing&&i.anchor!==o.anchor&&e.transactions.some((e=>Boolean(e.isUserEvent("select.pointer")||e.isUserEvent("select.reveal")||e.isUserEvent("select.search"))))&&(this.updateCurrentState(t.uiSourceCode(),i.head),this.entries.length>this.current+1&&(this.entries.length=this.current+1),this.entries.push(new It(t.uiSourceCode(),o.head)),this.current++,this.entries.length>20&&(this.entries.shift(),this.current--))}updateCurrentState(e,t){if(!this.revealing){const i=this.current>=0?this.entries[this.current]:null;i?.matches(e)&&(i.position=t)}}mapEntriesFor(e,t){for(const i of this.entries)i.matches(e)&&(i.position=t.mapPos(i.position))}reveal(e){const t=f.Workspace.WorkspaceImpl.instance().uiSourceCode(e.projectId,e.url);t&&(this.revealing=!0,this.sourcesView.showSourceLocation(t,e.position,!1,!0),this.revealing=!1)}rollback(){this.current>0&&(this.current--,this.reveal(this.entries[this.current]))}rollover(){this.current=0;t--)this.entries[t].matches(e)&&(this.entries.splice(t,1),this.current>=t&&this.current--)}}class It{projectId;url;position;constructor(e,t){this.projectId=e.project().id(),this.url=e.url(),this.position=t}matches(e){return this.url===e.url()&&this.projectId===e.project().id()}}var yt=Object.freeze({__proto__:null,HistoryDepth:20,EditingLocationHistoryManager:wt});const xt=new CSSStyleSheet;xt.replaceSync("#sources-panel-sources-view{--override-highlight-animation-10pc-background-color:rgb(158 54 153);--override-highlight-animation-10pc-foreground-color:rgb(255 255 255);flex:auto;position:relative}#sources-panel-sources-view .sources-toolbar{display:flex;flex:0 0 27px;background-color:var(--sys-color-cdt-base-container);border-top:1px solid var(--sys-color-divider);overflow:hidden;z-index:0}.sources-toolbar .toolbar{cursor:default}.source-frame-debugger-script{--override-debugger-background-tint:rgb(255 255 194/50%);background-color:var(--override-debugger-background-tint)}.-theme-with-dark-background .source-frame-debugger-script{--override-debugger-background-tint:rgb(61 61 0/50%)}\n/*# sourceURL=sourcesView.css */\n");const kt=["application/javascript","application/json","application/manifest+json","text/css","text/html","text/javascript"],Tt={ms:"ms",mb:"MB",kb:"kB"},Et=e.i18n.registerUIStrings("panels/sources/ProfilePlugin.ts",Tt),Lt=e.i18n.getLocalizedString.bind(void 0,Et);class Mt extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";let t=this.value;const i=l.NumberUtilities.clamp(Math.log10(1+.002*t)/5,.02,1);let o,n;e.style.backgroundColor=`hsla(217, 100%, 70%, ${i.toFixed(3)})`,t/=1e3,t>=1e3?(o=Lt(Tt.mb),t/=1e3,n=t>=20?0:1):(o=Lt(Tt.kb),n=0),e.textContent=t.toFixed(n);const r=e.appendChild(document.createElement("span"));return r.className="cm-units",r.textContent=o,e}}class Pt extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";const t=l.NumberUtilities.clamp(Math.log10(1+10*this.value)/5,.02,1);e.textContent=this.value.toFixed(1),e.style.backgroundColor=`hsla(44, 100%, 50%, ${t.toFixed(3)})`;const i=document.createElement("span");return i.className="cm-units",i.textContent=Lt(Tt.ms),e.appendChild(i),e}}function Ft(e,t,i){const o="performance"===i?Pt:Mt,r=[];for(const[i,n]of e)if(i<=t.doc.lines){const{from:e}=t.doc.line(i);r.push(new o(n).range(e))}return n.RangeSet.of(r,!0)}const Dt=e=>class extends he{updateEffect=n.StateEffect.define();field;gutter;compartment=new n.Compartment;constructor(t){super(t),this.field=n.StateField.define({create:()=>n.RangeSet.empty,update:(t,i)=>i.effects.reduce(((t,o)=>o.is(this.updateEffect)?Ft(o.value,i.state,e):t),t.map(i.changes))}),this.gutter=n.gutter({markers:e=>e.state.field(this.field),class:`cm-${e}Gutter`})}static accepts(e){return e.contentType().hasScripts()}getLineMap(){return this.uiSourceCode.getDecorationData(e)}editorExtension(){const t=this.getLineMap();return this.compartment.of(t?[this.field.init((i=>Ft(t,i,e))),this.gutter,Nt]:[])}decorationChanged(e,t){const i=Boolean(t.state.field(this.field,!1)),o=this.getLineMap();o?i?t.dispatch({effects:this.updateEffect.of(o)}):t.dispatch({effects:this.compartment.reconfigure([this.field.init((t=>Ft(o,t,e))),this.gutter,Nt])}):i&&t.dispatch({effects:this.compartment.reconfigure([])})}},Nt=n.EditorView.baseTheme({".cm-performanceGutter":{width:"60px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-memoryGutter":{width:"48px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-profileMarker":{textAlign:"right",paddingRight:"3px"},".cm-profileMarker .cm-units":{color:"var(--sys-color-token-subtle)",fontSize:"75%",marginLeft:"3px"}}),At=Dt("memory"),Ut=Dt("performance"),Rt={fromS:"(From {PH1})",sourceMappedFromS:"(Source mapped from {PH1})"},Bt=e.i18n.registerUIStrings("panels/sources/ResourceOriginPlugin.ts",Rt),jt=e.i18n.getLocalizedString.bind(void 0,Bt);class Vt extends he{static accepts(e){const t=e.contentType();return t.hasScripts()||t.isFromSourceMap()}rightToolbarItems(){const i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance();if(this.uiSourceCode.contentType().isFromSourceMap()){const o=[];for(const e of i.scriptsForUISourceCode(this.uiSourceCode)){const t=i.uiSourceCodeForScript(e);if(!t)continue;const n=t.url(),r=u.ResourceUtils.displayNameForURL(n),s=jt(Rt.sourceMappedFromS,{PH1:r});o.push(F.Linkifier.Linkifier.linkifyRevealable(t,r,n,s))}for(const e of u.SASSSourceMapping.SASSSourceMapping.uiSourceOrigin(this.uiSourceCode))o.push(F.Linkifier.Linkifier.linkifyURL(e));if(0===o.length)return[];const n=document.createElement("span");return o.forEach(((e,t)=>{t>0&&n.append(", "),n.append(e)})),[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(Bt,Rt.fromS,{PH1:n}))]}for(const o of i.scriptsForUISourceCode(this.uiSourceCode))if(o.originStackTrace){const i=Wt.linkifyStackTraceTopFrame(o.debuggerModel.target(),o.originStackTrace);return[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(Bt,Rt.fromS,{PH1:i}))]}return[]}}const Wt=new F.Linkifier.Linkifier;var Ot=Object.freeze({__proto__:null,ResourceOriginPlugin:Vt,linkifier:Wt});const Ht={enter:"⌘+Enter",ctrlenter:"Ctrl+Enter"},_t=e.i18n.registerUIStrings("panels/sources/SnippetsPlugin.ts",Ht),zt=e.i18n.getLocalizedString.bind(void 0,_t);class qt extends he{static accepts(e){return T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e)}rightToolbarItems(){const e=t.Toolbar.Toolbar.createActionButtonForId("debugger.run-snippet");return e.setText(c.Platform.isMac()?zt(Ht.enter):zt(Ht.ctrlenter)),[e]}editorExtension(){return s.JavaScript.completion()}}var $t=Object.freeze({__proto__:null,SnippetsPlugin:qt});class Gt extends(i.ObjectWrapper.eventMixin(m.SourceFrame.SourceFrameImpl)){uiSourceCodeInternal;muteSourceCodeEvents;persistenceBinding;uiSourceCodeEventListeners;messageAndDecorationListeners;boundOnBindingChanged;plugins=[];errorPopoverHelper;#p=!1;constructor(e){super((()=>this.workingCopy())),this.element.setAttribute("jslog",`${a.textField()}`),this.uiSourceCodeInternal=e,this.muteSourceCodeEvents=!1,this.persistenceBinding=h.Persistence.PersistenceImpl.instance().binding(e),this.uiSourceCodeEventListeners=[],this.messageAndDecorationListeners=[],this.boundOnBindingChanged=this.onBindingChanged.bind(this),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").addChangeListener(this.onNetworkPersistenceChanged,this),this.errorPopoverHelper=new t.PopoverHelper.PopoverHelper(this.textEditor.editor.contentDOM,this.getErrorPopoverContent.bind(this),"sources.error"),this.errorPopoverHelper.setHasPadding(!0),this.errorPopoverHelper.setTimeout(100,100),this.initializeUISourceCode()}async workingCopy(){return this.uiSourceCodeInternal.isDirty()?{content:this.uiSourceCodeInternal.workingCopy(),isEncoded:!1}:this.uiSourceCodeInternal.requestContent()}editorConfiguration(e){return[super.editorConfiguration(e),(t=this.allMessages(),[ni.init((e=>oi.create(Zt.create(t),e.doc))),si]),Xt.of(this.plugins.map((e=>e.editorExtension())))];var t}onFocus(){super.onFocus(),t.Context.Context.instance().setFlavor(Gt,this)}onBlur(){super.onBlur(),t.Context.Context.instance().setFlavor(Gt,null)}installMessageAndDecorationListeners(){if(this.persistenceBinding){const e=this.persistenceBinding.network,t=this.persistenceBinding.fileSystem;this.messageAndDecorationListeners=[e.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),e.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),e.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this),t.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),t.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this)]}else this.messageAndDecorationListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this)]}uiSourceCode(){return this.uiSourceCodeInternal}setUISourceCode(e){const t=e.contentLoaded()?Promise.resolve():e.requestContent(),i=this.uiSourceCodeInternal;t.then((async()=>{this.uiSourceCodeInternal===i&&(this.unloadUISourceCode(),this.uiSourceCodeInternal=e,e.workingCopy()!==this.textEditor.state.doc.toString()?await this.setDeferredContent(Promise.resolve(e.workingCopyContent())):this.reloadPlugins(),this.initializeUISourceCode())}),console.error)}unloadUISourceCode(){i.EventTarget.removeEventListeners(this.messageAndDecorationListeners),i.EventTarget.removeEventListeners(this.uiSourceCodeEventListeners),this.uiSourceCodeInternal.removeWorkingCopyGetter(),h.Persistence.PersistenceImpl.instance().unsubscribeFromBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged)}initializeUISourceCode(){this.uiSourceCodeEventListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.onWorkingCopyChanged,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.onWorkingCopyCommitted,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.TitleChanged,this.onTitleChanged,this)],h.Persistence.PersistenceImpl.instance().subscribeForBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged),this.installMessageAndDecorationListeners(),this.updateStyle();const e=kt.includes(this.contentType)&&!this.uiSourceCodeInternal.project().canSetFileContent()&&null===h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=!this.uiSourceCodeInternal.contentType().isFromSourceMap();this.setCanPrettyPrint(e,t)}wasShown(){super.wasShown(),this.setEditable(this.canEditSourceInternal())}willHide(){for(const e of this.plugins)e.willHide();super.willHide(),t.Context.Context.instance().setFlavor(Gt,null),this.uiSourceCodeInternal.removeWorkingCopyGetter()}getContentType(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network.mimeType():this.uiSourceCodeInternal.mimeType();return i.ResourceType.ResourceType.simplifyContentType(t)}canEditSourceInternal(){return!this.hasLoadError()&&(!this.uiSourceCodeInternal.editDisabled()&&("application/wasm"!==this.uiSourceCodeInternal.mimeType()&&(!!h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal)||(!!this.uiSourceCodeInternal.project().canSetFileContent()||!this.uiSourceCodeInternal.project().isServiceProject()&&(!(this.uiSourceCodeInternal.project().type()!==f.Workspace.projectTypes.Network||!h.NetworkPersistenceManager.NetworkPersistenceManager.instance().active())||(!this.pretty||!this.uiSourceCodeInternal.contentType().hasScripts())&&this.uiSourceCodeInternal.contentType()!==i.ResourceType.resourceTypes.Document)))))}onNetworkPersistenceChanged(){this.setEditable(this.canEditSourceInternal())}commitEditing(){this.uiSourceCodeInternal.isDirty()&&(this.muteSourceCodeEvents=!0,this.uiSourceCodeInternal.commitWorkingCopy(),this.muteSourceCodeEvents=!1)}async setContent(e){this.disposePlugins(),this.loadPlugins(),await super.setContent(e);for(const e of this.plugins)e.editorInitialized(this.textEditor);this.#g(),i.EventTarget.fireEvent("source-file-loaded",this.uiSourceCodeInternal.displayName(!0))}createMessage(e){const{lineNumber:t,columnNumber:i}=this.uiLocationToEditorLocation(e.lineNumber(),e.columnNumber());return new Yt(e,t,i)}allMessages(){return(null!==this.persistenceBinding?[...this.persistenceBinding.network.messages(),...this.persistenceBinding.fileSystem.messages()]:[...this.uiSourceCodeInternal.messages()]).map((e=>this.createMessage(e)))}onTextChanged(){const e=this.pretty;super.onTextChanged(),this.errorPopoverHelper.hidePopover(),Wi.instance().updateLastModificationTime(),this.muteSourceCodeEvents=!0,this.isClean()?this.uiSourceCodeInternal.resetWorkingCopy():this.uiSourceCodeInternal.setWorkingCopyGetter((()=>this.textEditor.state.sliceDoc())),this.muteSourceCodeEvents=!1,e!==this.pretty&&(this.updateStyle(),this.reloadPlugins())}onWorkingCopyChanged(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCodeInternal.workingCopyContent())}onWorkingCopyCommitted(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCode().workingCopyContent()),this.contentCommitted(),this.updateStyle()}reloadPlugins(){this.disposePlugins(),this.loadPlugins();const e=this.textEditor;e.dispatch({effects:Xt.reconfigure(this.plugins.map((e=>e.editorExtension())))});for(const t of this.plugins)t.editorInitialized(e)}onTitleChanged(){this.updateLanguageMode("").then((()=>this.reloadPlugins()),console.error)}loadPlugins(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network:this.uiSourceCodeInternal;for(const e of[Oe,Qi,qt,Vt,fe,At,Ut])e.accepts(t)&&this.plugins.push(new e(t,this));this.dispatchEventToListeners("ToolbarItemsChanged")}disposePlugins(){for(const e of this.plugins)e.dispose();this.plugins=[]}onBindingChanged(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal);e!==this.persistenceBinding&&(this.unloadUISourceCode(),this.persistenceBinding=e,this.initializeUISourceCode(),this.reloadMessages(),this.reloadPlugins())}reloadMessages(){const e=this.allMessages(),{editor:t}=this.textEditor;t.dispatch({effects:ei.of(Zt.create(e))})}updateStyle(){this.setEditable(this.canEditSourceInternal())}maybeSetContent(e){this.textEditor.state.doc.toString()!==e.content&&this.setDeferredContent(Promise.resolve(e))}populateTextAreaContextMenu(e,t,i){super.populateTextAreaContextMenu(e,t,i),e.appendApplicableItems(this.uiSourceCodeInternal);const o=this.editorLocationToUILocation(t,i);e.appendApplicableItems(new f.UISourceCode.UILocation(this.uiSourceCodeInternal,o.lineNumber,o.columnNumber));for(const o of this.plugins)o.populateTextAreaContextMenu(e,t,i)}populateLineGutterContextMenu(e,t){super.populateLineGutterContextMenu(e,t);for(const i of this.plugins)i.populateLineGutterContextMenu(e,t)}dispose(){this.errorPopoverHelper.dispose(),this.disposePlugins(),this.unloadUISourceCode(),this.textEditor.editor.destroy(),this.detach(),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").removeChangeListener(this.onNetworkPersistenceChanged,this)}onMessageAdded(e){const{editor:t}=this.textEditor,i=t.state.field(ni,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ei.of(i.messages.add(o))})}}onMessageRemoved(e){const{editor:t}=this.textEditor,i=t.state.field(ni,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ei.of(i.messages.remove(o))})}}onDecorationChanged(e){for(const t of this.plugins)t.decorationChanged(e.data,this.textEditor)}async toolbarItems(){const e=await super.toolbarItems(),i=[];for(const t of this.plugins)e.push(...t.leftToolbarItems()),i.push(...t.rightToolbarItems());return i.length?[...e,new t.Toolbar.ToolbarSeparator(!0),...i]:e}getErrorPopoverContent(e){const t=e,i=e.target,o=i.enclosingNodeOrSelfWithClass("cm-messageIcon-error")||i.enclosingNodeOrSelfWithClass("cm-messageIcon-issue");if(!o)return null;const n=this.textEditor.state.field(ni,!1);if(!n||0===n.messages.rows.length)return null;const{editor:r}=this.textEditor,s=r.posAtCoords(t);if(null===s)return null;const a=r.state.doc.lineAt(s);if(s!==a.to)return null;const c=n.messages.rows.find((e=>e[0].lineNumber()===a.number-1));if(!c)return null;const l=o.classList.contains("cm-messageIcon-issue"),d=c.filter((e=>"Issue"===e.level()===l));if(!d.length)return null;const u=o?o.boxInWindow():new AnchorBox(t.clientX,t.clientY,1,1),h=function(e){const t=[];for(let i=0;i(e.contentElement.append(p),!0)}}#g(){if(this.#p)return;this.#p=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCodeInternal.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCodeInternal.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCodeInternal.content()));c.userMetrics.sourcesPanelFileOpened(t)}}function Kt(e){return"Error"===e?{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}:"Warning"===e?{color:"var(--icon-warning)",width:"18px",height:"14px",iconName:"warning-filled"}:"Issue"===e?{color:"var(--icon-warning)",width:"17px",height:"14px",iconName:"issue-exclamation-filled"}:{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}}function Jt(e,t){const i={Issue:2,Warning:3,Error:4};return i[e.level()]-i[t.level()]}const Xt=new n.Compartment;class Yt{origin;#m;#b;constructor(e,t,i){this.origin=e,this.#m=t,this.#b=i}level(){return this.origin.level()}text(){return this.origin.text()}clickHandler(){return this.origin.clickHandler()}lineNumber(){return this.#m}columnNumber(){return this.#b}isEqual(e){return this.origin.isEqual(e.origin)}}function Qt(e,t){const i=t.lineNumber();let o=0;for(;o0)break}return e.splice(o,0,[t]),e}class Zt{rows;constructor(e){this.rows=e}static create(e){const t=[];for(const i of e)Qt(t,i);return new Zt(t)}remove(e){const t=this.rows.slice();return function(e,t){for(let i=0;i!e.isEqual(t)));o.length?e[i]=o:e.splice(i,1);break}}(t,e),new Zt(t)}add(e){return new Zt(Qt(this.rows.slice(),e))}}const ei=n.StateEffect.define(),ti=n.Decoration.mark({class:"cm-waveUnderline"});class ii extends n.WidgetType{messages;constructor(e){super(),this.messages=e}eq(e){return e.messages===this.messages}toDOM(){const e=document.createElement("span");e.classList.add("cm-messageIcon");const t=this.messages.filter((e=>"Issue"!==e.level()));if(t.length){const i=t.sort(Jt)[t.length-1],o=e.appendChild(new r.Icon.Icon);o.data=Kt(i.level()),o.classList.add("cm-messageIcon-error")}const i=this.messages.find((e=>"Issue"===e.level()));if(i){const t=e.appendChild(new r.Icon.Icon);t.data=Kt("Issue"),t.classList.add("cm-messageIcon-issue"),t.addEventListener("click",(()=>(i.clickHandler()||Math.min)()))}return e}ignoreEvents(){return!0}}class oi{messages;decorations;constructor(e,t){this.messages=e,this.decorations=t}static create(e,t){const i=new n.RangeSetBuilder;for(const o of e.rows){const e=t.line(Math.min(t.lines,o[0].lineNumber()+1)),r=o.reduce(((e,t)=>Math.min(e,t.columnNumber()||0)),e.length);roi.create(new Zt([]),e.doc),update:(e,t)=>e.apply(t),provide:e=>n.Prec.lowest(n.EditorView.decorations.from(e,(e=>e.decorations)))});function ri(e,t){const i=document.createElement("div");if(i.classList.add("text-editor-row-message"),i.style.display="flex",i.style.alignItems="center",i.style.gap="4px",1===t){const t=i.appendChild(new r.Icon.Icon);t.data=function(e){return e.origin instanceof M.SourceFrameIssuesManager.IssueMessage?{...P.IssueCounter.getIssueKindIconData(e.origin.getIssueKind()),width:"12px",height:"12px"}:Kt(e.level())}(e),t.classList.add("text-editor-row-message-icon"),t.addEventListener("click",(()=>(e.clickHandler()||Math.min)()))}else{const o=document.createElement("span",{is:"dt-small-bubble"});o.textContent=String(t),o.classList.add("text-editor-row-message-repeat-count"),o.style.flexShrink="0",i.appendChild(o),o.type=function(e){switch(e){case"Error":return"error";case"Warning":case"Issue":return"warning"}}(e.level())}const o=i.createChild("div");for(const t of e.text().split("\n"))o.createChild("div").textContent=t;return i}const si=n.EditorView.baseTheme({".cm-tooltip-message":{padding:"4px"},".cm-waveUnderline":{backgroundImage:"var(--image-file-errorWave)",backgroundRepeat:"repeat-x",backgroundPosition:"bottom",paddingBottom:"1px"},".cm-messageIcon":{cursor:"pointer","& > *":{verticalAlign:"text-bottom",marginLeft:"2px"}},".cm-messageIcon-issue, .cm-messageIcon-error":{marginTop:"-1px",marginBottom:"-1px"}});var ai=Object.freeze({__proto__:null,UISourceCodeFrame:Gt});const ci={areYouSureYouWantToCloseUnsaved:"Are you sure you want to close unsaved file: {PH1}?",unableToLoadThisContent:"Unable to load this content.",changesToThisFileWereNotSavedTo:"Changes to this file were not saved to file system."},li=e.i18n.registerUIStrings("panels/sources/TabbedEditorContainer.ts",ci),di=e.i18n.getLocalizedString.bind(void 0,li);let ui=0;class hi extends i.ObjectWrapper.ObjectWrapper{delegate;tabbedPane;tabIds;files;previouslyViewedFilesSetting;history;uriToUISourceCode;idToUISourceCode;currentFileInternal;currentView;scrollTimer;reentrantShow;constructor(e,i,o,n){super(),this.delegate=e,this.tabbedPane=new t.TabbedPane.TabbedPane,this.tabbedPane.setPlaceholderElement(o,n),this.tabbedPane.setTabDelegate(new fi(this)),this.tabbedPane.setCloseableTabs(!0),this.tabbedPane.setAllowTabReorder(!0,!0),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabClosed,this.tabClosed,this),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabSelected,this.tabSelected,this),this.tabbedPane.headerElement().setAttribute("jslog",`${a.toolbar("top")}`),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingCreated,this.onBindingCreated,this),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingRemoved,this.onBindingRemoved,this),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("RequestsForHeaderOverridesFileChanged",this.#d,this),this.tabIds=new Map,this.files=new Map,this.previouslyViewedFilesSetting=i,this.history=bi.fromObject(this.previouslyViewedFilesSetting.get()),this.uriToUISourceCode=new Map,this.idToUISourceCode=new Map,this.reentrantShow=!1}onBindingCreated(e){const t=e.data;this.updateFileTitle(t.fileSystem);const i=this.tabIds.get(t.network);let o=this.tabIds.get(t.fileSystem);const n=this.currentFileInternal===t.network,r=gi(t.network),s=this.history.selectionRange(r),a=this.history.scrollLineNumber(r);if(this.history.remove(r),i){if(!o){const e=this.tabbedPane.tabView(i),n=this.tabbedPane.tabIndex(i);if(e instanceof Gt)this.delegate.recycleUISourceCodeFrame(e,t.fileSystem),o=this.appendFileTab(t.fileSystem,!1,n,e);else{o=this.appendFileTab(t.fileSystem,!1,n);const e=this.tabbedPane.tabView(o);this.restoreEditorProperties(e,s,a)}}this.closeTabs([i],!0),n&&this.tabbedPane.selectTab(o,!1),this.updateHistory()}}#d(e){this.updateFileTitle(e.data)}onBindingRemoved(e){const t=e.data;this.updateFileTitle(t.fileSystem)}get view(){return this.tabbedPane}get visibleView(){return this.tabbedPane.visibleView}fileViews(){return this.tabbedPane.tabViews()}leftToolbar(){return this.tabbedPane.leftToolbar()}rightToolbar(){return this.tabbedPane.rightToolbar()}show(e){this.tabbedPane.show(e)}showFile(e){const o=h.Persistence.PersistenceImpl.instance().binding(e);e=o?o.fileSystem:e;const n=t.Context.Context.instance().flavor(Ii);if(n?.currentSourceFrame()?.contentSet&&this.currentFileInternal===e&&n?.currentUISourceCode()===e)i.EventTarget.fireEvent("source-file-loaded",e.displayName(!0));else{if(e.project().type()===f.Workspace.projectTypes.Debugger){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&t.isInlineScript()&&!t.hasSourceURL&&(t.isModule?c.userMetrics.vmInlineScriptContentShown(0):c.userMetrics.vmInlineScriptContentShown(1))}this.innerShowFile(e,!0)}}closeFile(e){const t=this.tabIds.get(e);t&&this.closeTabs([t])}closeAllFiles(){this.closeTabs(this.tabbedPane.tabIds())}historyUISourceCodes(){const e=[];for(const{url:t,resourceType:i}of this.history.keys()){const o=this.uriToUISourceCode.get(t);void 0!==o&&o.contentType()===i&&e.push(o)}return e}selectNextTab(){this.tabbedPane.selectNextTab()}selectPrevTab(){this.tabbedPane.selectPrevTab()}addViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.addEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.addEventListener("EditorScroll",this.onScrollChanged,this))}removeViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.removeEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.removeEventListener("EditorScroll",this.onScrollChanged,this))}onScrollChanged(){if(this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=window.setTimeout((()=>this.previouslyViewedFilesSetting.set(this.history.toObject())),100),this.currentFileInternal)){const{editor:e}=this.currentView.textEditor,t=e.lineBlockAtHeight(e.scrollDOM.getBoundingClientRect().top-e.documentTop),i=e.state.doc.lineAt(t.from).number-1;this.history.updateScrollLineNumber(gi(this.currentFileInternal),i)}}onEditorUpdate({data:e}){if(e.docChanged||e.selectionSet){const{main:t}=e.state.selection,i=e.state.doc.lineAt(t.from),o=e.state.doc.lineAt(t.to),n=new g.TextRange.TextRange(i.number-1,t.from-i.from,o.number-1,t.to-o.from);this.currentFileInternal&&this.history.updateSelectionRange(gi(this.currentFileInternal),n),this.previouslyViewedFilesSetting.set(this.history.toObject()),this.currentFileInternal&&k.ExtensionServer.ExtensionServer.instance().sourceSelectionChanged(this.currentFileInternal.url(),n)}}innerShowFile(e,t){if(this.reentrantShow)return;const i=this.canonicalUISourceCode(e),o=h.Persistence.PersistenceImpl.instance().binding(e);if(e=o?o.fileSystem:e,this.currentFileInternal===e)return;this.removeViewListeners(),this.currentFileInternal=e;try{this.reentrantShow=!0;const e=this.tabIds.get(i)||this.appendFileTab(i,t);this.tabbedPane.selectTab(e,t)}finally{this.reentrantShow=!1}t&&this.editorSelectedByUserAction();const n=this.currentView;this.currentView=this.visibleView,this.addViewListeners(),this.currentView instanceof Gt&&this.currentView.uiSourceCode()!==e&&(this.delegate.recycleUISourceCodeFrame(this.currentView,e),e.project().type()!==f.Workspace.projectTypes.FileSystem&&e.disableEdit());const r={currentFile:this.currentFileInternal,currentView:this.currentView,previousView:n,userGesture:t};this.dispatchEventToListeners("EditorSelected",r)}titleForFile(e){let t=l.StringUtilities.trimMiddle(e.displayName(!0),30);return e.isDirty()&&(t+="*"),t}maybeCloseTab(e,t){const i=this.files.get(e);if(!i)return!1;return!(i.isDirty()&&i.project().canSetFileContent()&&!confirm(di(ci.areYouSureYouWantToCloseUnsaved,{PH1:i.name()})))&&(i.resetWorkingCopy(),t&&this.tabbedPane.selectTab(t,!0),this.tabbedPane.closeTab(e,!0),!0)}closeTabs(e,t){const i=[],o=[];for(let n=0;n{e.loadError()&&this.addLoadErrorIcon(a)})),a}addLoadErrorIcon(e){const i=new r.Icon.Icon;i.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(i,di(ci.unableToLoadThisContent)),this.tabbedPane.tabView(e)&&this.tabbedPane.setTabIcon(e,i)}restoreEditorProperties(e,t,i){const o=e instanceof m.SourceFrame.SourceFrameImpl?e:null;o&&(t&&o.setSelection(t),"number"==typeof i&&o.scrollToLine(i))}tabClosed(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);this.currentFileInternal&&this.currentFileInternal.canononicalScriptId()===o?.canononicalScriptId()&&(this.removeViewListeners(),this.currentView=null,this.currentFileInternal=null),o&&this.tabIds.delete(o),this.files.delete(t),o&&(this.removeUISourceCodeListeners(o),this.dispatchEventToListeners("EditorClosed",o),i&&this.editorClosedByUserAction(o))}tabSelected(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);o&&this.innerShowFile(o,i)}addUISourceCodeListeners(e){e.addEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}removeUISourceCodeListeners(e){e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}updateFileTitle(e){const i=this.tabIds.get(e);if(i){const o=this.titleForFile(e),n=this.tooltipForFile(e);this.tabbedPane.changeTabTitle(i,o,n);let s=null;e.loadError()?(s=new r.Icon.Icon,s.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,di(ci.unableToLoadThisContent))):h.Persistence.PersistenceImpl.instance().hasUnsavedCommittedChanges(e)?(s=new r.Icon.Icon,s.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,di(ci.changesToThisFileWereNotSavedTo))):s=h.PersistenceUtils.PersistenceUtils.iconForUISourceCode(e),this.tabbedPane.setTabIcon(i,s)}}uiSourceCodeTitleChanged(e){const t=e.data;this.updateFileTitle(t),this.updateHistory();for(const[e,i]of this.uriToUISourceCode)i===t&&e!==i.url()&&this.uriToUISourceCode.delete(e);for(const[e,i]of this.idToUISourceCode)i===t&&e!==i.canononicalScriptId()&&this.idToUISourceCode.delete(e);this.canonicalUISourceCode(t)}uiSourceCodeWorkingCopyChanged(e){const t=e.data;this.updateFileTitle(t)}uiSourceCodeWorkingCopyCommitted(e){const t=e.data.uiSourceCode;this.updateFileTitle(t)}generateTabId(){return"tab-"+ui++}currentFile(){return this.currentFileInternal||null}}const pi=30;function gi(e){return{url:e.url(),resourceType:e.contentType()}}class mi{url;resourceType;selectionRange;scrollLineNumber;constructor(e,t,i,o){this.url=e,this.resourceType=t,this.selectionRange=i,this.scrollLineNumber=o}static fromObject(e){const t=i.ResourceType.ResourceType.fromName(e.resourceTypeName);if(null===t)throw new TypeError(`Invalid resource type name "${e.resourceTypeName}"`);const o=e.selectionRange?g.TextRange.TextRange.fromObject(e.selectionRange):void 0;return new mi(e.url,t,o,e.scrollLineNumber)}toObject(){return this.url.length>=4096?null:{url:this.url,resourceTypeName:this.resourceType.name(),selectionRange:this.selectionRange,scrollLineNumber:this.scrollLineNumber}}}class bi{items;constructor(e){this.items=e}static fromObject(e){const t=[];for(const i of e)try{t.push(mi.fromObject(i))}catch{}return new bi(t)}index({url:e,resourceType:t}){return this.items.findIndex((i=>i.url===e&&i.resourceType===t))}selectionRange(e){const t=this.index(e);if(-1!==t)return this.items[t].selectionRange}updateSelectionRange(e,t){if(!t)return;const i=this.index(e);-1!==i&&(this.items[i].selectionRange=t)}scrollLineNumber(e){const t=this.index(e);if(-1!==t)return this.items[t].scrollLineNumber}updateScrollLineNumber(e,t){const i=this.index(e);-1!==i&&(this.items[i].scrollLineNumber=t)}update(e){for(let t=e.length-1;t>=0;--t){const i=this.index(e[t]);let o;-1!==i?(o=this.items[i],this.items.splice(i,1)):o=new mi(e[t].url,e[t].resourceType),this.items.unshift(o)}}remove(e){const t=this.index(e);-1!==t&&this.items.splice(t,1)}toObject(){const e=[];for(const t of this.items){const i=t.toObject();if(i&&e.push(i),e.length===pi)break}return e}keys(){return this.items}}class fi{editorContainer;constructor(e){this.editorContainer=e}closeTabs(e,t){this.editorContainer.closeTabs(t)}onContextMenu(e,t){this.editorContainer.onContextMenu(e,t)}}var Si=Object.freeze({__proto__:null,TabbedEditorContainer:hi,HistoryItem:mi,History:bi,EditorContainerTabDelegate:fi});const vi={openFile:"Open file",runCommand:"Run command",workspaceDropInAFolderToSyncSources:"To sync edits to the workspace, drop a folder with your sources here or",selectFolder:"Select folder",sourceViewActions:"Source View Actions"},Ci=e.i18n.registerUIStrings("panels/sources/SourcesView.ts",vi),wi=e.i18n.getLocalizedString.bind(void 0,Ci);class Ii extends(i.ObjectWrapper.eventMixin(t.Widget.VBox)){selectedIndex;searchableViewInternal;sourceViewByUISourceCode;editorContainer;historyManager;toolbarContainerElementInternal;scriptViewToolbar;bottomToolbarInternal;toolbarChangedListener;focusedPlaceholderElement;searchView;searchConfig;constructor(){super(),this.element.id="sources-panel-sources-view",this.element.setAttribute("jslog",`${a.pane("editor")}`),this.setMinimumAndPreferredSizes(88,52,150,100),this.selectedIndex=0;const e=f.Workspace.WorkspaceImpl.instance();this.searchableViewInternal=new t.SearchableView.SearchableView(this,this,"sources-view-search-config"),this.searchableViewInternal.setMinimalSearchQuerySize(0),this.searchableViewInternal.show(this.element),this.sourceViewByUISourceCode=new Map,this.editorContainer=new hi(this,i.Settings.Settings.instance().createLocalSetting("previously-viewed-files",[]),this.placeholderElement(),this.focusedPlaceholderElement),this.editorContainer.show(this.searchableViewInternal.element),this.editorContainer.addEventListener("EditorSelected",this.editorSelected,this),this.editorContainer.addEventListener("EditorClosed",this.editorClosed,this),this.historyManager=new wt(this),this.toolbarContainerElementInternal=this.element.createChild("div","sources-toolbar"),this.toolbarContainerElementInternal.setAttribute("jslog",`${a.toolbar("bottom")}`),this.scriptViewToolbar=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.scriptViewToolbar.element.style.flex="auto",this.bottomToolbarInternal=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.toolbarChangedListener=null,t.UIUtils.startBatchUpdate(),e.uiSourceCodes().forEach(this.addUISourceCode.bind(this)),t.UIUtils.endBatchUpdate(),e.addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),e.addEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemoved,this),e.addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved.bind(this),this),o.TargetManager.TargetManager.instance().addScopeChangeListener(this.#f.bind(this)),window.opener||window.addEventListener("beforeunload",(function(e){if(e.returnValue)return;const o=[],n=f.Workspace.WorkspaceImpl.instance().projectsForType(f.Workspace.projectTypes.FileSystem);for(const e of n)for(const t of e.uiSourceCodes())t.isDirty()&&o.push(t);if(o.length){e.returnValue=!0,t.ViewManager.ViewManager.instance().showView("sources");for(const e of o)i.Revealer.reveal(e)}}),!0)}placeholderElement(){const e=[{actionId:"quick-open.show",description:wi(vi.openFile)},{actionId:"quick-open.show-command-menu",description:wi(vi.runCommand)},{actionId:"sources.add-folder-to-workspace",condition:C.Runtime.ConditionName.NOT_SOURCES_HIDE_ADD_FOLDER,description:wi(vi.workspaceDropInAFolderToSyncSources),isWorkspace:!0}],i=document.createElement("div");t.ARIAUtils.markAsList(i),t.ARIAUtils.setLabel(i,wi(vi.sourceViewActions));for(const o of e){const{condition:e}=o;if(void 0!==e&&!C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:()=>Boolean(C.Runtime.Runtime.queryParam(e))}))continue;const n=t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction(o.actionId),r=i.createChild("div","tabbed-pane-placeholder-row");if(t.ARIAUtils.markAsListitem(r),n){r.createChild("span").textContent=n;const e=r.createChild("button");e.textContent=o.description;const i=t.ActionRegistry.ActionRegistry.instance().getAction(o.actionId);e.addEventListener("click",(()=>i.execute()))}if(o.isWorkspace){const e=r.createChild("span","workspace");e.textContent=o.description;const t=e.createChild("button");t.textContent=wi(vi.selectFolder),t.addEventListener("click",this.addFileSystemClicked.bind(this))}}return C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&i.appendChild(t.XLink.XLink.create("https://developer.chrome.com/docs/devtools/workspaces/","Learn more about Workspaces")),i}async addFileSystemClicked(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem()&&(c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSelectFolder),t.ViewManager.ViewManager.instance().showView("navigator-files"))}static defaultUISourceCodeScores(){const e=new Map,i=t.Context.Context.instance().flavor(Ii);if(i){const t=i.editorContainer.historyUISourceCodes();for(let i=1;i{this.scriptViewToolbar.removeToolbarItems();for(const e of ki())this.scriptViewToolbar.appendToolbarItem(e.getOrCreateButton(this));e.map((e=>this.scriptViewToolbar.appendToolbarItem(e)))}))}showSourceLocation(e,t,i,o){const n=this.currentSourceFrame();n&&this.historyManager.updateCurrentState(n.uiSourceCode(),n.textEditor.state.selection.main.head),this.editorContainer.showFile(e);const r=this.currentSourceFrame();r&&t&&r.revealPosition(t,!o);const s=this.visibleView();!i&&s&&s.focus()}createSourceView(e){let t;const o=e.contentType();return o===i.ResourceType.resourceTypes.Image?t=new m.ImageView.ImageView(e.mimeType(),e):o===i.ResourceType.resourceTypes.Font?t=new m.FontView.FontView(e.mimeType(),e):e.name()===Ei?t=new x.HeadersView.HeadersView(e):(t=new Gt(e),this.historyManager.trackSourceFrameCursorJumps(t)),e.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.set(e,t),t}#v(e){return e instanceof m.ImageView.ImageView?"ImageView":e instanceof m.FontView.FontView?"FontView":e instanceof x.HeadersView.HeadersView?"HeadersView":"SourceView"}#C(e){if(e.name()===Ei)return"HeadersView";switch(e.contentType()){case i.ResourceType.resourceTypes.Image:return"ImageView";case i.ResourceType.resourceTypes.Font:return"FontView";default:return"SourceView"}}#S(e){const t=e.data,i=this.sourceViewByUISourceCode.get(t);i&&this.#v(i)!==this.#C(t)&&(this.removeUISourceCodes([t]),this.showSourceLocation(t))}getSourceView(e){return this.sourceViewByUISourceCode.get(e)}getOrCreateSourceView(e){return this.sourceViewByUISourceCode.get(e)||this.createSourceView(e)}recycleUISourceCodeFrame(e,t){e.uiSourceCode().removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.delete(e.uiSourceCode()),e.setUISourceCode(t),this.sourceViewByUISourceCode.set(t,e),t.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}viewForFile(e){return this.getOrCreateSourceView(e)}removeSourceFrame(e){const t=this.sourceViewByUISourceCode.get(e);this.sourceViewByUISourceCode.delete(e),t&&t instanceof Gt&&t.dispose(),e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}editorClosed(e){const t=e.data;this.historyManager.removeHistoryForSourceCode(t);let i=!1;this.editorContainer.currentFile()||(i=!0),this.removeToolbarChangedListener(),this.updateScriptViewToolbarItems(),this.searchableViewInternal.resetSearch();const o={uiSourceCode:t,wasSelected:i};this.dispatchEventToListeners("EditorClosed",o)}editorSelected(e){const t=e.data.previousView instanceof Gt?e.data.previousView:null;t&&t.setSearchableView(null);const i=e.data.currentView instanceof Gt?e.data.currentView:null;i&&i.setSearchableView(this.searchableViewInternal),this.searchableViewInternal.setReplaceable(Boolean(i?.canEditSource())),this.searchableViewInternal.refreshSearch(),this.updateToolbarChangedListener(),this.updateScriptViewToolbarItems();const o=this.editorContainer.currentFile();o&&this.dispatchEventToListeners("EditorSelected",o)}removeToolbarChangedListener(){this.toolbarChangedListener&&i.EventTarget.removeEventListeners([this.toolbarChangedListener]),this.toolbarChangedListener=null}updateToolbarChangedListener(){this.removeToolbarChangedListener();const e=this.currentSourceFrame();e&&(this.toolbarChangedListener=e.addEventListener("ToolbarItemsChanged",this.updateScriptViewToolbarItems,this))}onSearchCanceled(){this.searchView&&this.searchView.onSearchCanceled(),delete this.searchView,delete this.searchConfig}performSearch(e,t,i){const o=this.currentSourceFrame();o&&(this.searchView=o,this.searchConfig=e,this.searchView.performSearch(this.searchConfig,t,i))}jumpToNextSearchResult(){this.searchView&&(this.searchConfig&&this.searchView!==this.currentSourceFrame()?this.performSearch(this.searchConfig,!0):this.searchView.jumpToNextSearchResult())}jumpToPreviousSearchResult(){if(this.searchView)return this.searchConfig&&this.searchView!==this.currentSourceFrame()?(this.performSearch(this.searchConfig,!0),void(this.searchView&&this.searchView.jumpToLastSearchResult())):void this.searchView.jumpToPreviousSearchResult()}supportsCaseSensitiveSearch(){return!0}supportsRegexSearch(){return!0}replaceSelectionWith(e,t){const i=this.currentSourceFrame();i?i.replaceSelectionWith(e,t):console.assert(Boolean(i))}replaceAllWith(e,t){const i=this.currentSourceFrame();i?i.replaceAllWith(e,t):console.assert(Boolean(i))}showOutlineQuickOpen(){L.QuickOpen.QuickOpenImpl.show("@")}showGoToLineQuickOpen(){this.editorContainer.currentFile()&&L.QuickOpen.QuickOpenImpl.show(":")}save(){this.saveSourceFrame(this.currentSourceFrame())}saveAll(){this.editorContainer.fileViews().forEach(this.saveSourceFrame.bind(this))}saveSourceFrame(e){if(!(e instanceof Gt))return;e.commitEditing()}toggleBreakpointsActiveState(e){this.editorContainer.view.element.classList.toggle("breakpoints-deactivated",!e)}}const yi=[];function xi(e){yi.push(e)}function ki(){return yi.map((e=>e()))}class Ti{static nextFile(e){function t(e){const t=e.lastIndexOf(".");return e.substr(0,-1!==t?t:e.length).toLowerCase()}const o=[],n=e.parentURL(),r=e.name(),s=t(r);for(const i of e.project().uiSourceCodes())n===i.parentURL()&&t(i.name())===s&&o.push(i.name());o.sort(l.StringUtilities.naturalOrderComparator);const a=l.NumberUtilities.mod(o.indexOf(r)+1,o.length),c=i.ParsedURL.ParsedURL.concatenate(n?i.ParsedURL.ParsedURL.concatenate(n,"/"):"",o[a]),d=e.project().uiSourceCodeForURL(c);return d!==e?d:null}handleAction(e,t){const i=e.flavor(Ii);if(!i)return!1;const o=i.currentUISourceCode();if(!o)return!1;const n=Ti.nextFile(o);return!!n&&(i.showSourceLocation(n),!0)}}const Ei=".headers";var Li=Object.freeze({__proto__:null,SourcesView:Ii,registerEditorAction:xi,getRegisteredEditorActions:ki,SwitchFileActionDelegate:Ti,ActionDelegate:class{handleAction(e,t){const i=e.flavor(Ii);if(!i)return!1;switch(t){case"sources.close-all":return i.editorContainer.closeAllFiles(),!0;case"sources.jump-to-previous-location":return i.onJumpToPreviousLocation(),!0;case"sources.jump-to-next-location":return i.onJumpToNextLocation(),!0;case"sources.next-editor-tab":return i.editorContainer.selectNextTab(),!0;case"sources.previous-editor-tab":return i.editorContainer.selectPrevTab(),!0;case"sources.close-editor-tab":return i.onCloseEditorTab();case"sources.go-to-line":return i.showGoToLineQuickOpen(),!0;case"sources.go-to-member":return i.showOutlineQuickOpen(),!0;case"sources.save":return i.save(),!0;case"sources.save-all":return i.saveAll(),!0}return!1}}});const Mi=new CSSStyleSheet;Mi.replaceSync(".thread-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.thread-item + .thread-item{border-top:1px solid var(--sys-color-divider)}.thread-item:hover{background-color:var(--sys-color-state-hover-on-subtle)}.thread-item:focus-visible{background-color:var(--sys-color-tonal-container)}.thread-item-title,\n.thread-item-paused-state{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.thread-item-paused-state{color:var(--sys-color-state-disabled);margin-left:auto;padding:0 10px}.selected-thread-icon{display:none;position:absolute;top:3px;left:4px}.thread-item.selected .selected-thread-icon{display:block}@media (forced-colors: active){.thread-item:hover,\n .thread-item:focus-visible{forced-color-adjust:none;background-color:Highlight}.thread-item:hover > div,\n .thread-item:focus-visible > div{color:HighlightText}}\n/*# sourceURL=threadsSidebarPane.css */\n");const Pi={paused:"paused"},Fi=e.i18n.registerUIStrings("panels/sources/ThreadsSidebarPane.ts",Pi),Di=e.i18n.getLocalizedString.bind(void 0,Fi);class Ni extends t.Widget.VBox{items;list;selectedModel;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.threads")}`),this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport);const e=t.Context.Context.instance().flavor(o.Target.Target);this.selectedModel=null!==e?e.model(o.DebuggerModel.DebuggerModel):null,this.contentElement.appendChild(this.list.element),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.targetFlavorChanged,this),o.TargetManager.TargetManager.instance().observeModels(o.DebuggerModel.DebuggerModel,this)}static shouldBeShown(){return o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel).length>=2}createElementForItem(e){const i=document.createElement("div");i.classList.add("thread-item");const n=i.createChild("div","thread-item-title"),s=i.createChild("div","thread-item-paused-state"),a=new r.Icon.Icon;a.data={iconName:"large-arrow-right-filled",color:"var(--icon-arrow-main-thread)",width:"14px",height:"14px"},a.classList.add("selected-thread-icon"),i.appendChild(a),i.tabIndex=-1,self.onInvokeElement(i,(i=>{t.Context.Context.instance().setFlavor(o.Target.Target,e.target()),i.consume(!0)}));const c=t.Context.Context.instance().flavor(o.Target.Target)===e.target();function l(){const t=e.runtimeModel().defaultExecutionContext();n.textContent=t&&t.label()?t.label():e.target().name()}function d(){s.textContent=e.isPaused()?Di(Pi.paused):""}return i.classList.toggle("selected",c),t.ARIAUtils.setSelected(i,c),e.addEventListener(o.DebuggerModel.Events.DebuggerPaused,d),e.addEventListener(o.DebuggerModel.Events.DebuggerResumed,d),e.runtimeModel().addEventListener(o.RuntimeModel.Events.ExecutionContextChanged,l),o.TargetManager.TargetManager.instance().addEventListener("NameChanged",(function(t){t.data===e.target()&&l()})),d(),l(),i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1);const n=o;n&&(this.setDefaultFocusedElement(n),n.tabIndex=0,this.hasFocus()&&n.focus())}updateSelectedItemARIA(e,t){return!1}modelAdded(e){this.items.insert(this.items.length,e);t.Context.Context.instance().flavor(o.Target.Target)===e.target()&&this.list.selectItem(e)}modelRemoved(e){this.items.remove(this.items.indexOf(e))}targetFlavorChanged({data:e}){const t=this.hasFocus(),i=e.model(o.DebuggerModel.DebuggerModel);this.list.selectItem(i),i&&this.list.refreshItem(i),null!==this.selectedModel&&this.list.refreshItem(this.selectedModel),this.selectedModel=i,t&&this.focus()}wasShown(){super.wasShown(),this.registerCSSFiles([Mi])}}var Ai=Object.freeze({__proto__:null,ThreadsSidebarPane:Ni});const Ui={dropWorkspaceFolderHere:"Drop workspace folder here",moreOptions:"More options",showNavigator:"Show navigator",hideNavigator:"Hide navigator",navigatorShown:"Navigator sidebar shown",navigatorHidden:"Navigator sidebar hidden",debuggerShown:"Debugger sidebar shown",debuggerHidden:"Debugger sidebar hidden",showDebugger:"Show debugger",hideDebugger:"Hide debugger",groupByFolder:"Group by folder",groupByAuthored:"Group by Authored/Deployed",hideIgnoreListed:"Hide ignore-listed sources",resumeWithAllPausesBlockedForMs:"Resume with all pauses blocked for 500 ms",terminateCurrentJavascriptCall:"Terminate current JavaScript call",pauseOnCaughtExceptions:"Pause on caught exceptions",revealInSidebar:"Reveal in navigator sidebar",continueToHere:"Continue to here",storeAsGlobalVariable:"Store as global variable",copyS:"Copy {PH1}",copyStringContents:"Copy string contents",copyStringAsJSLiteral:"Copy string as JavaScript literal",copyStringAsJSONLiteral:"Copy string as JSON literal",showFunctionDefinition:"Show function definition",openInSourcesPanel:"Open in Sources panel"},Ri=e.i18n.registerUIStrings("panels/sources/SourcesPanel.ts",Ui),Bi=e.i18n.getLocalizedString.bind(void 0,Ri),ji=new Set(["number","boolean","bigint","undefined"]);let Vi;class Wi extends t.Panel.Panel{workspace;togglePauseAction;stepOverAction;stepIntoAction;stepOutAction;stepAction;toggleBreakpointsActiveAction;debugToolbar;debugToolbarDrawer;debuggerPausedMessage;splitWidget;editorView;navigatorTabbedLocation;sourcesViewInternal;toggleNavigatorSidebarButton;toggleDebuggerSidebarButton;threadsSidebarPane;watchSidebarPane;callstackPane;liveLocationPool;lastModificationTime;pausedInternal;switchToPausedTargetTimeout;ignoreExecutionLineEvents;executionLineLocation;pauseOnExceptionButton;sidebarPaneStack;tabbedLocationHeader;extensionSidebarPanesContainer;sidebarPaneView;constructor(){super("sources"),C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&new t.DropTarget.DropTarget(this.element,[t.DropTarget.Type.Folder],Bi(Ui.dropWorkspaceFolderHere),this.handleDrop.bind(this)),this.workspace=f.Workspace.WorkspaceImpl.instance(),this.togglePauseAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-pause"),this.stepOverAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-over"),this.stepIntoAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-into"),this.stepOutAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-out"),this.stepAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step"),this.toggleBreakpointsActiveAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-breakpoints-active"),this.debugToolbar=this.createDebugToolbar(),this.debugToolbarDrawer=this.createDebugToolbarDrawer(),this.debuggerPausedMessage=new Ke;this.splitWidget=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-split-view-state",225),this.splitWidget.enableShowModeSaving(),this.splitWidget.show(this.element);this.editorView=new t.SplitWidget.SplitWidget(!0,!1,"sources-panel-navigator-split-view-state",225),this.editorView.enableShowModeSaving(),this.splitWidget.setMainWidget(this.editorView),this.navigatorTabbedLocation=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"navigator-view",!0,!0);const e=this.navigatorTabbedLocation.tabbedPane();e.setMinimumSize(100,25),e.element.classList.add("navigator-tabbed-pane"),e.headerElement().setAttribute("jslog",`${a.toolbar("navigator")}`);const n=new t.Toolbar.ToolbarMenuButton(this.populateNavigatorMenu.bind(this),!0,"more-options");if(n.setTitle(Bi(Ui.moreOptions)),e.rightToolbar().appendToolbarItem(n),e.addEventListener(t.TabbedPane.Events.TabSelected,(({data:{tabId:e}})=>c.userMetrics.sourcesSidebarTabShown(e))),t.ViewManager.ViewManager.instance().hasViewsForLocation("run-view-sidebar")){const i=new t.SplitWidget.SplitWidget(!1,!0,"source-panel-navigator-sidebar-split-view-state");i.setMainWidget(e);const o=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"run-view-sidebar").tabbedPane();i.setSidebarWidget(o),i.installResizer(o.headerElement()),this.editorView.setSidebarWidget(i)}else this.editorView.setSidebarWidget(e);this.sourcesViewInternal=new Ii,this.sourcesViewInternal.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.toggleNavigatorSidebarButton=this.editorView.createShowHideSidebarButton(Bi(Ui.showNavigator),Bi(Ui.hideNavigator),Bi(Ui.navigatorShown),Bi(Ui.navigatorHidden),"navigator"),this.toggleDebuggerSidebarButton=this.splitWidget.createShowHideSidebarButton(Bi(Ui.showDebugger),Bi(Ui.hideDebugger),Bi(Ui.debuggerShown),Bi(Ui.debuggerHidden),"debugger"),this.editorView.setMainWidget(this.sourcesViewInternal),this.threadsSidebarPane=null,this.watchSidebarPane=t.ViewManager.ViewManager.instance().view("sources.watch"),this.callstackPane=Q.instance(),i.Settings.Settings.instance().moduleSetting("sidebar-position").addChangeListener(this.updateSidebarPosition.bind(this)),this.updateSidebarPosition(),this.updateDebuggerButtonsAndStatus(),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.setTarget(t.Context.Context.instance().flavor(o.Target.Target)),i.Settings.Settings.instance().moduleSetting("breakpoints-active").addChangeListener(this.breakpointsActiveStateChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.onCurrentTargetChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerWasEnabled,this.debuggerWasEnabled,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerPaused,this.debuggerPaused,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerResumed,(e=>this.debuggerResumed(e.data))),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.GlobalObjectCleared,(e=>this.debuggerResumed(e.data))),k.ExtensionServer.ExtensionServer.instance().addEventListener("SidebarPaneAdded",this.extensionSidebarPaneAdded,this),o.TargetManager.TargetManager.instance().observeTargets(this),this.lastModificationTime=-1/0}static instance(e={forceNew:null}){const{forceNew:t}=e;return Vi&&!t||(Vi=new Wi),Vi}static updateResizerAndSidebarButtons(e){e.sourcesViewInternal.leftToolbar().removeToolbarItems(),e.sourcesViewInternal.rightToolbar().removeToolbarItems(),e.sourcesViewInternal.bottomToolbar().removeToolbarItems();const i=t.Context.Context.instance().flavor(zi)&&!t.InspectorView.InspectorView.instance().isDrawerMinimized();e.splitWidget.isVertical()||i?e.splitWidget.uninstallResizer(e.sourcesViewInternal.toolbarContainerElement()):e.splitWidget.installResizer(e.sourcesViewInternal.toolbarContainerElement()),i||(e.sourcesViewInternal.leftToolbar().appendToolbarItem(e.toggleNavigatorSidebarButton),e.splitWidget.isVertical()?e.sourcesViewInternal.rightToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton):e.sourcesViewInternal.bottomToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton))}targetAdded(e){this.showThreadsIfNeeded()}targetRemoved(e){}showThreadsIfNeeded(){Ni.shouldBeShown()&&!this.threadsSidebarPane&&(this.threadsSidebarPane=t.ViewManager.ViewManager.instance().view("sources.threads"),this.sidebarPaneStack&&this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane,this.splitWidget.isVertical()?this.watchSidebarPane:this.callstackPane))}setTarget(e){if(!e)return;const t=e.model(o.DebuggerModel.DebuggerModel);t&&(t.isPaused()?this.showDebuggerPausedDetails(t.debuggerPausedDetails()):(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0)))}onCurrentTargetChanged({data:e}){this.setTarget(e)}paused(){return this.pausedInternal||!1}wasShown(){t.Context.Context.instance().setFlavor(Wi,this),this.registerCSSFiles([Ct]),super.wasShown(),t.Context.Context.instance().flavor(zi)&&(t.InspectorView.InspectorView.instance().setDrawerMinimized(!0),Wi.updateResizerAndSidebarButtons(this)),this.editorView.setMainWidget(this.sourcesViewInternal)}willHide(){super.willHide(),t.Context.Context.instance().setFlavor(Wi,null);const e=t.Context.Context.instance().flavor(zi);e&&(e.showViewInWrapper(),t.InspectorView.InspectorView.instance().setDrawerMinimized(!1),Wi.updateResizerAndSidebarButtons(this))}resolveLocation(e){return"sources.sidebar-top"===e||"sources.sidebar-bottom"===e||"sources.sidebar-tabs"===e?this.sidebarPaneStack||null:this.navigatorTabbedLocation}ensureSourcesViewVisible(){return!!t.Context.Context.instance().flavor(zi)||!!t.InspectorView.InspectorView.instance().canSelectPanel("sources")&&(t.ViewManager.ViewManager.instance().showView("sources"),!0)}onResize(){"auto"===i.Settings.Settings.instance().moduleSetting("sidebar-position").get()&&this.element.window().requestAnimationFrame(this.updateSidebarPosition.bind(this))}searchableView(){return this.sourcesViewInternal.searchableView()}toggleNavigatorSidebar(){this.editorView.toggleSidebar()}toggleDebuggerSidebar(){this.splitWidget.toggleSidebar()}debuggerPaused(e){const n=e.data,r=n.debuggerPausedDetails();!this.pausedInternal&&i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&this.setAsCurrentPanel(),t.Context.Context.instance().flavor(o.Target.Target)===n.target()?this.showDebuggerPausedDetails(r):this.pausedInternal||t.Context.Context.instance().setFlavor(o.Target.Target,n.target())}debugInfoAttached(e){const{debuggerModel:i}=e.data;if(!i.isPaused())return;const n=i.debuggerPausedDetails();n&&t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.showDebuggerPausedDetails(n)}showDebuggerPausedDetails(e){this.pausedInternal=!0,this.updateDebuggerButtonsAndStatus(),t.Context.Context.instance().setFlavor(o.DebuggerModel.DebuggerPausedDetails,e),this.toggleDebuggerSidebarButton.setEnabled(!1),this.revealDebuggerSidebar(),window.focus(),c.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront()}debuggerResumed(e){const i=e.target();t.Context.Context.instance().flavor(o.Target.Target)===i&&(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0),this.switchToPausedTargetTimeout=window.setTimeout(this.switchToPausedTarget.bind(this,e),500))}debuggerWasEnabled(e){const i=e.data;t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.updateDebuggerButtonsAndStatus()}get visibleView(){return this.sourcesViewInternal.visibleView()}showUISourceCode(e,i,o){if(o){if(!this.isShowing()&&!t.Context.Context.instance().flavor(zi))return}else this.showEditor();this.sourcesViewInternal.showSourceLocation(e,i,o)}showEditor(){t.Context.Context.instance().flavor(zi)||this.setAsCurrentPanel()}showUILocation(e,t){const{uiSourceCode:i,lineNumber:o,columnNumber:n}=e;this.showUISourceCode(i,{lineNumber:o,columnNumber:n},t)}async revealInNavigator(e,i){const o=t.ViewManager.ViewManager.instance();for(const t of o.viewsForLocation("navigator-view")){const o=await t.widget();if(o instanceof dt&&o.acceptProject(e.project())){o.revealUISourceCode(e,!0),this.navigatorTabbedLocation.tabbedPane().selectTab(t.viewId(),!0),i||(this.editorView.showBoth(!0),o.focus());break}}}addExperimentMenuItem(e,t,o){e.appendCheckboxItem(o,(function(){const e=C.Runtime.experiments.isEnabled(t);C.Runtime.experiments.setEnabled(t,!e),c.userMetrics.experimentChanged(t,e);const o=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");o.set(o.get())}),{checked:C.Runtime.experiments.isEnabled(t),additionalElement:r.Icon.create("experiment"),jslogContext:l.StringUtilities.toKebabCase(t)})}populateNavigatorMenu(e){const t=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");e.appendItemsAtLocation("navigatorMenu"),e.viewSection().appendCheckboxItem(Bi(Ui.groupByFolder),(()=>t.set(!t.get())),{checked:t.get(),jslogContext:t.name}),this.addExperimentMenuItem(e.viewSection(),"authored-deployed-grouping",Bi(Ui.groupByAuthored)),this.addExperimentMenuItem(e.viewSection(),"just-my-code",Bi(Ui.hideIgnoreListed))}setIgnoreExecutionLineEvents(e){this.ignoreExecutionLineEvents=e}updateLastModificationTime(){this.lastModificationTime=window.performance.now()}async executionLineChanged(e){const t=await e.uiLocation();e.isDisposed()||t&&(window.performance.now()-this.lastModificationTimee.debuggerModel===i.debuggerModel));n&&this.prepareToResume()&&n.continueToLocation()}toggleBreakpointsActive(){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!i.Settings.Settings.instance().moduleSetting("breakpoints-active").get())}breakpointsActiveStateChanged(){const e=i.Settings.Settings.instance().moduleSetting("breakpoints-active").get();this.toggleBreakpointsActiveAction.setToggled(!e),this.sourcesViewInternal.toggleBreakpointsActiveState(e)}createDebugToolbar(){const e=new t.Toolbar.Toolbar("scripts-debug-toolbar");e.element.setAttribute("jslog",`${a.toolbar("debug")}`);const i=new t.Toolbar.ToolbarButton(Bi(Ui.resumeWithAllPausesBlockedForMs),"play");i.addEventListener("Click",this.longResume,this);const o=new t.Toolbar.ToolbarButton(Bi(Ui.terminateCurrentJavascriptCall),"stop");return o.addEventListener("Click",this.terminateExecution,this),e.appendToolbarItem(t.Toolbar.Toolbar.createLongPressActionButton(this.togglePauseAction,[o,i],[])),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOverAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepIntoAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOutAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepAction)),e.appendSeparator(),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.toggleBreakpointsActiveAction)),e}createDebugToolbarDrawer(){const e=document.createElement("div");e.classList.add("scripts-debug-toolbar-drawer");const o=Bi(Ui.pauseOnCaughtExceptions),n=i.Settings.Settings.instance().moduleSetting("pause-on-caught-exception");return e.appendChild(t.SettingsUI.createSettingCheckbox(o,n,!0)),e}appendApplicableItems(e,t,i){i instanceof f.UISourceCode.UISourceCode?this.appendUISourceCodeItems(e,t,i):i instanceof Gt?this.appendUISourceCodeFrameItems(t,i):i instanceof f.UISourceCode.UILocation?this.appendUILocationItems(t,i):i instanceof o.RemoteObject.RemoteObject?this.appendRemoteObjectItems(t,i):this.appendNetworkRequestItems(t,i)}appendUISourceCodeItems(e,t,i){if(!e.target)return;const o=e.target;i.project().isServiceProject()||o.isSelfOrDescendant(this.navigatorTabbedLocation.widget().element)||C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||t.revealSection().appendItem(Bi(Ui.revealInSidebar),this.revealInNavigator.bind(this,i),{jslogContext:"sources.reveal-in-navigator-sidebar"}),i.contentType().hasScripts()&&u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(i).every((e=>e.isJavaScript()))&&this.callstackPane.appendIgnoreListURLContextMenuItems(t,i)}appendUISourceCodeFrameItems(e,t){t.uiSourceCode().contentType().isFromSourceMap()||t.textEditor.state.selection.main.empty||e.debugSection().appendAction("debugger.evaluate-selection")}appendUILocationItems(e,i){const n=i.uiSourceCode;if(!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(n).every((e=>e.isJavaScript())))return;if(n.contentType().hasScripts()){const r=t.Context.Context.instance().flavor(o.Target.Target),s=r?r.model(o.DebuggerModel.DebuggerModel):null;s&&s.isPaused()&&e.debugSection().appendItem(Bi(Ui.continueToHere),this.continueToLocation.bind(this,i),{jslogContext:"continue-to-here"}),this.callstackPane.appendIgnoreListURLContextMenuItems(e,n)}}appendRemoteObjectItems(e,n){const r=i.Settings.Settings.instance().moduleSetting("text-editor-indent").get(),s=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);const a="wasm"===n.type?n.subtype:"node"===n.subtype?"outerHTML":n.type;e.debugSection().appendItem(Bi(Ui.storeAsGlobalVariable),(()=>s?.target().model(o.ConsoleModel.ConsoleModel)?.saveToTempVariable(s,n)),{jslogContext:"store-as-global-variable"});const d=e.clipboardSection(),u=c.InspectorFrontendHost.InspectorFrontendHostInstance;if("string"===n.type)d.appendItem(Bi(Ui.copyStringContents),(()=>{u.copyText(n.value)}),{jslogContext:"copy-string-contents"}),d.appendItem(Bi(Ui.copyStringAsJSLiteral),(()=>{u.copyText(l.StringUtilities.formatAsJSLiteral(n.value))}),{jslogContext:"copy-string-as-js-literal"}),d.appendItem(Bi(Ui.copyStringAsJSONLiteral),(()=>{u.copyText(JSON.stringify(n.value))}),{jslogContext:"copy-string-as-json-literal"});else if(ji.has(n.type))d.appendItem(Bi(Ui.copyS,{PH1:String(a)}),(()=>{u.copyText(n.description)}),{jslogContext:"copy-primitive"});else if("object"===n.type){const e=async()=>{const e=await n.callFunctionJSON(h,[{value:{subtype:n.subtype,indent:r}}]);u.copyText(e)};d.appendItem(Bi(Ui.copyS,{PH1:String(a)}),e,{jslogContext:"copy-object"})}else"function"===n.type&&e.debugSection().appendItem(Bi(Ui.showFunctionDefinition),this.showFunctionDefinition.bind(this,n),{jslogContext:"show-function-definition"});function h(e){const t=e.subtype,i=e.indent;if("map"!==t){if("set"!==t){if("node"===t)return this instanceof Element?this.outerHTML:void 0;if(t&&void 0===this)return String(t);try{return JSON.stringify(this,null,i)}catch(e){return String(this)}}else if(this instanceof Set){const e=Array.from(this.values());return`new Set(${0===e.length?"":JSON.stringify(e,null,i)})`}}else if(this instanceof Map){const e=Array.from(this.entries());return`new Map(${0===e.length?"":JSON.stringify(e,null,i)})`}}}appendNetworkRequestItems(e,t){const i=this.workspace.uiSourceCodeForURL(t.url());if(!i)return;const o=Bi(Ui.openInSourcesPanel),n=this.showUILocation.bind(this,i.uiLocation(0,0));e.revealSection().appendItem(o,n,{jslogContext:"reveal-in-sources"})}showFunctionDefinition(e){o.RemoteObject.RemoteFunction.objectAsFunction(e).targetFunction().then((e=>e.debuggerModel().functionDetailsPromise(e).then(this.didGetFunctionDetails.bind(this))))}async didGetFunctionDetails(e){if(!e||!e.location)return;const t=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e.location);t&&this.showUILocation(t)}revealNavigatorSidebar(){this.setAsCurrentPanel(),this.editorView.showBoth(!0)}revealDebuggerSidebar(){i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&(this.setAsCurrentPanel(),this.splitWidget.showBoth(!0))}updateSidebarPosition(){let e;const o=i.Settings.Settings.instance().moduleSetting("sidebar-position").get();if(e="right"!==o&&("bottom"===o||t.InspectorView.InspectorView.instance().element.offsetWidth<680),this.sidebarPaneView&&e===!this.splitWidget.isVertical())return;if(this.sidebarPaneView&&this.sidebarPaneView.shouldHideOnDetach())return;this.sidebarPaneView&&this.sidebarPaneView.detach(),this.splitWidget.setVertical(!e),this.splitWidget.element.classList.toggle("sources-split-view-vertical",e),Wi.updateResizerAndSidebarButtons(this);const n=new t.Widget.VBox;n.element.appendChild(this.debugToolbar.element),n.element.appendChild(this.debugToolbarDrawer),n.setMinimumAndPreferredSizes(Hi,25,Hi,100),this.sidebarPaneStack=t.ViewManager.ViewManager.instance().createStackLocation(this.revealDebuggerSidebar.bind(this),void 0,"debug"),this.sidebarPaneStack.widget().element.classList.add("overflow-auto"),this.sidebarPaneStack.widget().show(n.element),this.sidebarPaneStack.widget().element.appendChild(this.debuggerPausedMessage.element()),this.sidebarPaneStack.appendApplicableItems("sources.sidebar-top"),this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane);const r=t.ViewManager.ViewManager.instance().view("sources.js-breakpoints"),s=t.ViewManager.ViewManager.instance().view("sources.scope-chain");if(this.tabbedLocationHeader&&(this.splitWidget.uninstallResizer(this.tabbedLocationHeader),this.tabbedLocationHeader=null),e){const e=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-debugger-sidebar-split-view-state",.5);e.setMainWidget(n),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(this.callstackPane);const i=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealDebuggerSidebar.bind(this));e.setSidebarWidget(i.tabbedPane()),this.tabbedLocationHeader=i.tabbedPane().headerElement(),this.splitWidget.installResizer(this.tabbedLocationHeader),this.splitWidget.installResizer(this.debugToolbar.gripElementForResize()),i.appendView(s),i.appendView(this.watchSidebarPane),i.appendApplicableItems("sources.sidebar-tabs"),this.extensionSidebarPanesContainer=i,this.sidebarPaneView=e}else this.sidebarPaneStack.appendView(this.watchSidebarPane),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(s),this.sidebarPaneStack.showView(this.callstackPane),this.extensionSidebarPanesContainer=this.sidebarPaneStack,this.sidebarPaneView=n,this.splitWidget.uninstallResizer(this.debugToolbar.gripElementForResize());this.sidebarPaneStack.appendApplicableItems("sources.sidebar-bottom");const a=k.ExtensionServer.ExtensionServer.instance().sidebarPanes();for(let e=0;e{Wi.updateResizerAndSidebarButtons(Wi.instance())})),super.willHide(),t.Context.Context.instance().setFlavor(zi,null)}showViewInWrapper(){this.view.show(this.element)}}var qi=Object.freeze({__proto__:null,SourcesPanel:Wi,get lastModificationTimeout(){return Oi},minToolbarWidth:Hi,UILocationRevealer:class{async reveal(e,t){Wi.instance().showUILocation(e,t)}},UILocationRangeRevealer:_i,DebuggerLocationRevealer:class{async reveal(e,t){const i=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);i&&Wi.instance().showUILocation(i,t)}},UISourceCodeRevealer:class{async reveal(e,t){Wi.instance().showUISourceCode(e,void 0,t)}},DebuggerPausedDetailsRevealer:class{async reveal(e){if(i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get())return Wi.instance().setAsCurrentPanel()}},RevealingActionDelegate:class{handleAction(e,o){const n=Wi.instance();if(!n.ensureSourcesViewVisible())return!1;if("debugger.toggle-pause"===o){return e.flavor(t.ShortcutRegistry.ForwardedShortcut)&&!i.Settings.Settings.instance().moduleSetting("disable-paused-state-overlay").get()||n.togglePause(),!0}return!1}},ActionDelegate:class{handleAction(e,t){const i=Wi.instance();switch(t){case"debugger.step-over":return i.stepOver(),!0;case"debugger.step-into":return i.stepIntoAsync(),!0;case"debugger.step":return i.stepInto(),!0;case"debugger.step-out":return i.stepOut(),!0;case"debugger.run-snippet":return i.runSnippet(),!0;case"debugger.toggle-breakpoints-active":return i.toggleBreakpointsActive(),!0;case"debugger.evaluate-selection":{const t=e.flavor(Gt);if(t){const{state:i}=t.textEditor;let n=i.sliceDoc(i.selection.main.from,i.selection.main.to);const r=e.flavor(o.RuntimeModel.ExecutionContext),s=r?.target().model(o.ConsoleModel.ConsoleModel);if(r&&s){const e=s.addCommandMessage(r,n);n=y.JavaScriptREPL.JavaScriptREPL.wrapObjectLiteral(n),s.evaluateCommandInConsole(r,e,n,!0)}}return!0}case"sources.reveal-in-navigator-sidebar":{const e=i.sourcesView().currentUISourceCode();return null!==e&&(i.revealInNavigator(e),!0)}case"sources.toggle-navigator-sidebar":return i.toggleNavigatorSidebar(),!0;case"sources.toggle-debugger-sidebar":return i.toggleDebuggerSidebar(),!0}return!1}},QuickSourceView:zi});const{EMPTY_BREAKPOINT_CONDITION:$i,NEVER_PAUSE_HERE_CONDITION:Gi}=w.BreakpointManager,Ki={thisScriptIsOnTheDebuggersIgnore:"This script is on the debugger's ignore list",removeFromIgnoreList:"Remove from ignore list",configure:"Configure",addBreakpoint:"Add breakpoint",addConditionalBreakpoint:"Add conditional breakpoint…",addLogpoint:"Add logpoint…",neverPauseHere:"Never pause here",removeBreakpoint:"{n, plural, =1 {Remove breakpoint} other {Remove all breakpoints in line}}",editBreakpoint:"Edit breakpoint…",disableBreakpoint:"{n, plural, =1 {Disable breakpoint} other {Disable all breakpoints in line}}",enableBreakpoint:"{n, plural, =1 {Enable breakpoint} other {Enable all breakpoints in line}}",addSourceMap:"Add source map…",addWasmDebugInfo:"Add DWARF debug info…",sourceMapLoaded:"Source map loaded.",associatedFilesAreAvailable:"Associated files are available via file tree or {PH1}.",associatedFilesShouldBeAdded:"Associated files should be added to the file tree. You can debug these resolved source files as regular JavaScript files.",theDebuggerWillSkipStepping:"The debugger will skip stepping through this script, and will not stop on exceptions.",sourceMapSkipped:"Source map skipped for this file.",sourceMapFailed:"Source map failed to load.",debuggingPowerReduced:"DevTools can't show authored sources, but you can debug the deployed code.",reloadForSourceMap:"To enable again, make sure the file isn't on the ignore list and reload.",errorLoading:"Error loading url {PH1}: {PH2}",ignoreScript:"Ignore this file",ignoreContentScripts:"Ignore extension scripts",debugFileNotFound:'Failed to load debug file "{PH1}".',debugInfoNotFound:"Failed to load any debug info for {PH1}."},Ji=e.i18n.registerUIStrings("panels/sources/DebuggerPlugin.ts",Ki),Xi=e.i18n.getLocalizedString.bind(void 0,Ji),Yi=new Map;class Qi extends he{transformer;editor=void 0;executionLocation=null;controlDown=!1;controlTimeout=void 0;sourceMapInfobar=null;scriptsPanel;breakpointManager;popoverHelper=null;scriptFileForDebuggerModel;breakpoints=[];continueToLocations=null;liveLocationPool;muted;initializedMuted;ignoreListInfobar;refreshBreakpointsTimeout=void 0;activeBreakpointDialog=null;#I=void 0;#y=!1;missingDebugInfoBar=null;#x=!1;loader;ignoreListCallback;constructor(e,i){super(e),this.transformer=i,Yi.set(e,this),this.scriptsPanel=Wi.instance(),this.breakpointManager=w.BreakpointManager.BreakpointManager.instance(),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),this.scriptFileForDebuggerModel=new Map,this.loader=o.PageResourceLoader.PageResourceLoader.instance(),this.loader.addEventListener("Update",this.showSourceMapInfobarIfNeeded.bind(this),this),this.ignoreListCallback=this.showIgnoreListInfobarIfNeeded.bind(this),u.IgnoreListManager.IgnoreListManager.instance().addChangeListener(this.ignoreListCallback),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.updateScriptFiles(),this.muted=this.uiSourceCode.isDirty(),this.initializedMuted=this.muted,this.ignoreListInfobar=null,this.showIgnoreListInfobarIfNeeded();for(const e of this.scriptFileForDebuggerModel.values())e.checkMapping()}editorExtension(){const e=this.shortcutHandlers();return[n.EditorView.updateListener.of((e=>this.onEditorUpdate(e))),n.EditorView.domEventHandlers({keydown:t=>!!this.onKeyDown(t)||(e(t),t.defaultPrevented),keyup:e=>this.onKeyUp(e),mousemove:e=>this.onMouseMove(e),mousedown:e=>this.onMouseDown(e),focusout:e=>this.onBlur(e),wheel:e=>this.onWheel(e)}),n.lineNumbers({domEventHandlers:{mousedown:(e,t,i)=>this.handleGutterClick(e.state.doc.lineAt(t.from),i)}}),to,ro,n.Prec.highest(po.field),n.Prec.lowest(fo.field),Co,Io.field,n.Prec.lowest(Po.field),Fo,this.uiSourceCode.project().type()===f.Workspace.projectTypes.Debugger?n.EditorView.editorAttributes.of({class:"source-frame-debugger-script"}):[]]}shortcutHandlers(){const e=e=>e.state.doc.lineAt(e.state.selection.main.head);return t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"debugger.toggle-breakpoint":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!1),!0),"debugger.toggle-breakpoint-enabled":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!0),!0),"debugger.breakpoint-input-window":async()=>{if(this.muted||!this.editor)return!1;const t=e(this.editor);return c.userMetrics.breakpointEditDialogRevealedFrom(4),this.#k(t),!0}})}#k(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.breakpoints.find((t=>t.position>=e.from&&t.position<=e.to))?.breakpoint||null;void 0===t&&null!==i&&(t=i.isLogpoint()),this.editBreakpointCondition({line:e,breakpoint:i,location:null,isLogpoint:t})}editorInitialized(e){this.editor=e,async function(e,t,i){const o=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance(),n=await o.getMappedLines(i);if(!n)return[];const r=[];for(let i=0;i{t.length&&e.dispatch({effects:m.SourceFrame.addNonBreakableLines.of(t)})}),console.error),this.ignoreListInfobar&&this.attachInfobar(this.ignoreListInfobar),this.missingDebugInfoBar&&this.attachInfobar(this.missingDebugInfoBar),this.sourceMapInfobar&&this.attachInfobar(this.sourceMapInfobar),this.muted||this.refreshBreakpoints(),this.callFrameChanged(),this.popoverHelper?.dispose(),this.popoverHelper=new t.PopoverHelper.PopoverHelper(e,this.getPopoverRequest.bind(this),"sources.object-properties"),this.popoverHelper.setDisableOnClick(!0),this.popoverHelper.setTimeout(250,250),this.popoverHelper.setHasPadding(!0)}static accepts(e){return e.contentType().hasScripts()}showIgnoreListInfobarIfNeeded(){const e=this.uiSourceCode;if(!e.contentType().hasScripts())return;if(!u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return void this.hideIgnoreListInfobar();this.ignoreListInfobar&&this.ignoreListInfobar.dispose();const i=new t.Infobar.Infobar("warning",Xi(Ki.thisScriptIsOnTheDebuggersIgnore),[{text:Xi(Ki.removeFromIgnoreList),highlight:!1,delegate:function(){u.IgnoreListManager.IgnoreListManager.instance().unIgnoreListUISourceCode(e)},dismiss:!0,jslogContext:"remove-from-ignore-list"},{text:Xi(Ki.configure),highlight:!1,delegate:t.ViewManager.ViewManager.instance().showView.bind(t.ViewManager.ViewManager.instance(),"blackbox"),dismiss:!1,jslogContext:"configure"}],void 0,void 0,"script-on-ignore-list");this.ignoreListInfobar=i,i.setCloseCallback((()=>this.removeInfobar(this.ignoreListInfobar))),i.createDetailsRowMessage(Xi(Ki.theDebuggerWillSkipStepping)),this.attachInfobar(this.ignoreListInfobar)}attachInfobar(e){this.editor&&this.editor.dispatch({effects:Zi.of(e)})}removeInfobar(e){this.editor&&e&&this.editor.dispatch({effects:eo.of(e)})}hideIgnoreListInfobar(){this.ignoreListInfobar&&(this.ignoreListInfobar.dispose(),this.ignoreListInfobar=null)}willHide(){this.popoverHelper?.hidePopover()}editBreakpointLocation({breakpoint:e,uiLocation:t}){const{lineNumber:i}=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber),o=this.editor?.state.doc.line(i+1);o&&this.editBreakpointCondition({line:o,breakpoint:e,location:null,isLogpoint:e.isLogpoint()})}populateLineGutterContextMenu(e,t){const i=new f.UISourceCode.UILocation(this.uiSourceCode,t,0);if(this.scriptsPanel.appendUILocationItems(e,i),this.muted||!this.editor)return;const o=this.editor.state.doc.line(t+1),n=this.lineBreakpoints(o),r=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode);if(n.length){const t=Xi(Ki.removeBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>{c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterContextMenu),e.remove(!1)}))),{jslogContext:"remove-breakpoint"}),1===n.length&&r&&e.debugSection().appendItem(Xi(Ki.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:o,breakpoint:n[0],location:null})}),{jslogContext:"edit-breakpoint"});if(n.some((e=>e.enabled()))){const t=Xi(Ki.disableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!1)))),{jslogContext:"enable-breakpoint"})}if(n.some((e=>!e.enabled()))){const t=Xi(Ki.enableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!0)))),{jslogContext:"disable-breakpoint"})}}else this.editor&&m.SourceFrame.isBreakableLine(this.editor.state,o)&&(e.debugSection().appendItem(Xi(Ki.addBreakpoint),this.createNewBreakpoint.bind(this,o,$i,!0,!1),{jslogContext:"add-breakpoint"}),r&&(e.debugSection().appendItem(Xi(Ki.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),e.debugSection().appendItem(Xi(Ki.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),e.debugSection().appendItem(Xi(Ki.neverPauseHere),this.createNewBreakpoint.bind(this,o,Gi,!0,!1),{jslogContext:"never-pause-here"})))}populateTextAreaContextMenu(e){function t(e,t){t&&e.addSourceMapURL(t)}function o(e,t){t&&e.addDebugInfoURL(t)}if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get()&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(this.uiSourceCode.url())&&this.scriptFileForDebuggerModel.size){const i=this.scriptFileForDebuggerModel.values().next().value,n=Xi(Ki.addSourceMap);e.debugSection().appendItem(n,function(e){j.createAddSourceMapURLDialog(t.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-source-map"}),i.script?.isWasm()&&!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().pluginManager.hasPluginForScript(i.script)&&e.debugSection().appendItem(Xi(Ki.addWasmDebugInfo),function(e){j.createAddDWARFSymbolsURLDialog(o.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-wasm-debug-info"})}}workingCopyChanged(){this.scriptFileForDebuggerModel.size||this.setMuted(this.uiSourceCode.isDirty())}workingCopyCommitted(){this.scriptsPanel.updateLastModificationTime(),this.scriptFileForDebuggerModel.size||this.setMuted(!1)}didMergeToVM(){this.consistentScripts()&&this.setMuted(!1)}didDivergeFromVM(){this.setMuted(!0)}setMuted(e){this.initializedMuted||e!==this.muted&&(this.muted=e,e?this.editor&&this.editor.dispatch({effects:oo.of(null)}):this.restoreBreakpointsAfterEditing())}consistentScripts(){for(const e of this.scriptFileForDebuggerModel.values())if(e.hasDivergedFromVM()||e.isMergingToVM())return!1;return!0}isVariableIdentifier(e){return"VariableName"===e||"VariableDefinition"===e}isIdentifier(e){return"VariableName"===e||"VariableDefinition"===e||"PropertyName"===e||"PropertyDefinition"===e}getPopoverRequest(e){if(t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return null;const i=t.Context.Context.instance().flavor(o.Target.Target),r=i?i.model(o.DebuggerModel.DebuggerModel):null,{editor:s}=this;if(!r||!r.isPaused()||!s)return null;const a=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!a)return null;let c=s.editor.posAtCoords(e);if(!c)return null;const l=s.editor.coordsAtPos(c);if(!l||e.clientYl.bottom||e.clientXl.right+30)return null;e.clientXs.state.doc.lineAt(c).from&&(c-=1);const d=Eo(s.state,this.uiSourceCode.mimeType(),c);if(!d)return null;const u=s.state.doc.lineAt(d.from);if(d.to>u.to)return null;const h=s.editor.coordsAtPos(d.from),g=s.editor.coordsAtPos(d.to);if(!h||!g)return null;const m=new AnchorBox(h.left,h.top-2,g.right-h.left,g.bottom-h.top),b=s.state.sliceDoc(d.from,d.to);let f=null;return{box:m,show:async e=>{let i="";if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const e=await p.NamesResolver.allVariablesInCallFrame(a);try{i=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(b,e)}catch{}}else i=await p.NamesResolver.resolveExpression(a,b,this.uiSourceCode,u.number-1,d.from-u.from,d.to-u.from);const c=C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")&&d.containsSideEffects,l=await a.evaluate({expression:i||b,objectGroup:"popover",includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1,throwOnSideEffect:c,timeout:void 0,disableBreaks:void 0,replMode:void 0,allowUnsafeEvalBlockedByCSP:void 0});if(!l||"error"in l||!l.object||"object"===l.object.type&&"error"===l.object.subtype)return!1;f=await y.ObjectPopoverHelper.ObjectPopoverHelper.buildObjectPopover(l.object,e);const h=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!f||a!==h)return r.runtimeModel().releaseObjectGroup("popover"),f&&f.dispose(),!1;const g=n.Decoration.set(Mo.range(d.from,d.to));return s.dispatch({effects:Po.update.of(g)}),!0},hide:()=>{f&&f.dispose(),r.runtimeModel().releaseObjectGroup("popover"),s.dispatch({effects:Po.update.of(n.Decoration.none)})}}}onEditorUpdate(e){if(!e.changes.empty)for(const t of this.breakpoints)t.position=e.changes.mapPos(t.position)}onWheel(e){this.executionLocation&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&e.preventDefault()}onKeyDown(e){const i=t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e);return i||this.setControlDown(!1),e.key===l.KeyboardUtilities.ESCAPE_KEY&&this.popoverHelper&&this.popoverHelper.isPopoverVisible()?(this.popoverHelper.hidePopover(),e.consume(),!0):(i&&this.executionLocation&&this.setControlDown(!0),!1)}onMouseMove(e){this.executionLocation&&this.controlDown&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&(this.continueToLocations||this.showContinueToLocations())}onMouseDown(e){if(!this.executionLocation||!t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return;if(!this.continueToLocations||!this.editor)return;e.consume();const i=this.editor.editor.posAtCoords(e);if(null!==i)for(const{from:e,to:t,click:o}of this.continueToLocations)if(e<=i&&t>=i){o();break}}onBlur(e){this.setControlDown(!1)}onKeyUp(e){this.setControlDown(!1)}setControlDown(e){e!==this.controlDown&&(this.controlDown=e,clearTimeout(this.controlTimeout),this.controlTimeout=void 0,e&&this.executionLocation?this.controlTimeout=window.setTimeout((()=>{this.executionLocation&&this.controlDown&&this.showContinueToLocations()}),150):this.clearContinueToLocations())}editBreakpointCondition(e){const{line:t,breakpoint:i,location:o,isLogpoint:r}=e;if(i?.isRemoved)return;this.#y=!1;if(this.#I&&function(e,t){if(e.line.number!==t.line.number)return!1;if(e.line.from!==t.line.from)return!1;if(e.line.text!==t.line.text)return!1;if(e.breakpoint!==t.breakpoint)return!1;if(e.location!==t.location)return!1;return e.isLogpoint===t.isLogpoint}(this.#I,e))return;this.activeBreakpointDialog&&this.activeBreakpointDialog.saveAndFinish();const s=this.editor,a=i?i.condition():"",l=i?.isLogpoint()??Boolean(r),d=document.createElement("div"),u=new n.Compartment,h=new q(t.number-1,a,l,(async e=>{this.activeBreakpointDialog=null,this.#I=void 0,h.detach(),s.dispatch({effects:u.reconfigure([])}),e.committed?(x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,a!==e.condition),function(e){const{condition:t,isLogpoint:o}=e,n=0!==t.length&&!o,r=i?.isLogpoint(),s=a&&0!==a.length&&!r;o&&!r?c.userMetrics.breakpointWithConditionAdded(0):n&&!s&&c.userMetrics.breakpointWithConditionAdded(1)}(e),i?i.setCondition(e.condition,e.isLogpoint):o?await this.setBreakpoint(o.lineNumber,o.columnNumber,e.condition,!0,e.isLogpoint):await this.createNewBreakpoint(t,e.condition,!0,e.isLogpoint)):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,!1)}));s.dispatch({effects:n.StateEffect.appendConfig.of(u.of(n.EditorView.decorations.of(n.Decoration.set([n.Decoration.widget({block:!0,widget:new class extends n.WidgetType{toDOM(){return d}},side:1}).range(t.to)]))))}),h.element.addEventListener("blur",(async e=>{(!e.relatedTarget||e.relatedTarget&&!e.relatedTarget.isSelfOrDescendant(h.element))&&(this.#y=!0,setTimeout((()=>{this.activeBreakpointDialog===h&&(this.#y?(h.saveAndFinish(),this.#y=!1):h.focusEditor())}),200))}),!0),h.markAsExternallyManaged(),h.show(d),h.focusEditor(),this.activeBreakpointDialog=h,this.#I=e}async updateValueDecorations(){if(!this.editor)return;const e=this.executionLocation?await this.computeValueDecorations():null;this.editor&&(e||this.editor.state.field(Io.field).size)&&this.editor.dispatch({effects:Io.update.of(e||n.Decoration.none)})}async#T(e,t){const i=e&&await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);if(!i||i.uiSourceCode.url()!==t)return null;const o=this.editor?.toOffset(this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber));return o??null}async computeValueDecorations(){if(!this.editor)return null;if(!i.Settings.Settings.instance().moduleSetting("inline-variable-values").get())return null;if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext))return null;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return null;const r=this.uiSourceCode.url(),s=this.#T(e.functionLocation(),r),a=this.#T(e.location(),r),[c,l]=await Promise.all([s,a]);if(!c||!l||!this.editor)return null;if(c>=l||l-c>1e4)return null;const d=xo(this.editor.state,c,l,l);if(0===d.length)return null;const u=await ko(e,(e=>this.#T(e,r)));if(0===u.length)return null;const h=To(u,d);if(!h||!this.editor)return null;const p=[];for(const[e,t]of h){const i=h.get(e-1);let o=i?Array.from(t).filter((e=>i.get(e[0])!==e[1])):Array.from(t);o.length&&(o.length>10&&(o=o.slice(0,10)),p.push(n.Decoration.widget({widget:new wo(o),side:1}).range(this.editor.state.doc.line(e+1).to)))}return n.Decoration.set(p,!0)}async showContinueToLocations(){this.popoverHelper?.hidePopover();if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext)||!this.editor)return;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return;const i=e.functionLocation()||e.location(),r=e.debuggerModel,{state:s}=this.editor,a=await r.getPossibleBreakpoints(i,null,!0);this.continueToLocations=[];let c=-1;for(const e of a.reverse()){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber);if(c===t.lineNumber&&"call"!==e.type||t.lineNumber>=s.doc.lines)continue;const i=s.doc.line(t.lineNumber+1),o=Math.min(i.to,i.from+t.columnNumber);let r=n.syntaxTree(s).resolveInner(o,1);if(r.firstChild||r.fromi.to)continue;if("."===r.name){const e=r.resolve(r.to,1);if(e.firstChild||e.fromi.to)continue;r=e}const a=r.name,l="this"===a||"return"===a||"new"===a||"break"===a||"continue"===a;if(!l&&!this.isIdentifier(a))continue;this.continueToLocations.push({from:r.from,to:r.to,async:!1,click:()=>e.continueToLocation()}),"call"===e.type&&(c=t.lineNumber);const d=l?"":i.text.slice(r.from-i.from,r.to-i.from);let u=null;if("then"===d&&"MemberExpression"===r.parent?.name?u=r.parent.parent:"setTimeout"!==d&&"setInterval"!==d&&"postMessage"!==d||(u=r.parent),"new"===a){const e=r.parent?.getChild("Expression");e&&"VariableName"===e.name&&"Worker"===s.sliceDoc(e.from,e.to)&&(u=r.parent)}if(u&&("CallExpression"===u.name||"NewExpression"===u.name)&&"call"===e.type){const t=u.getChild("ArgList")?.firstChild?.nextSibling;let i;if("VariableName"===t?.name?i=t:"ArrowFunction"!==t?.name&&"FunctionExpression"!==t?.name||(i=t.firstChild,"async"===i?.name&&(i=i.nextSibling)),i){const t=this.executionLocation&&e.lineNumber===this.executionLocation.lineNumber&&e.columnNumber===this.executionLocation.columnNumber;this.continueToLocations.push({from:i.from,to:i.to,async:!0,click:()=>this.asyncStepIn(e,Boolean(t))})}}}const l=n.Decoration.set(this.continueToLocations.map((e=>(e.async?bo:mo).range(e.from,e.to))),!0);this.editor.dispatch({effects:fo.update.of(l)})}clearContinueToLocations(){this.editor&&this.editor.state.field(fo.field).size&&this.editor.dispatch({effects:fo.update.of(n.Decoration.none)})}asyncStepIn(e,t){function i(){e.debuggerModel.scheduleStepIntoAsync()}t?i():e.continueToLocation(i)}fetchBreakpoints(){if(!this.editor)return[];const{editor:e}=this;return this.breakpointManager.breakpointLocationsForUISourceCode(this.uiSourceCode).map((({uiLocation:t,breakpoint:i})=>{const o=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber);return{position:e.toOffset(o),breakpoint:i}}))}lineBreakpoints(e){return this.breakpoints.filter((t=>t.position>=e.from&&t.position<=e.to)).map((e=>e.breakpoint))}async computeBreakpointDecoration(e,t){const i=[],o=[],r=new Map,s=new Map,a=[],c=new Set,l=(e,t,i)=>{let o=s.get(e);o||(o=[],s.set(e,o)),o.push({breakpoint:i,column:t})};for(const{position:i,breakpoint:o}of t){const t=e.doc.lineAt(i);let n=r.get(t.from);if(n||(n=[],r.set(t.from,n)),o.enabled()&&n.every((e=>!e.enabled()))){const e=this.transformer.editorLocationToUILocation(t.number-1,0),i=this.transformer.editorLocationToUILocation(t.number-1,Math.min(t.length,2500)),o=new g.TextRange.TextRange(e.lineNumber,e.columnNumber||0,i.lineNumber,i.columnNumber||0);a.push(this.breakpointManager.possibleBreakpoints(this.uiSourceCode,o).then((e=>d(t,e))))}n.push(o),o.enabled()&&(c.add(i),l(t.from,i-t.from,o))}for(const[e,t]of r){const i=t.sort(co)[0];let n="cm-breakpoint";i.enabled()||(n+=" cm-breakpoint-disabled"),i.bound()||(n+=" cm-breakpoint-unbound"),i.isLogpoint()?n+=" cm-breakpoint-logpoint":i.condition()&&(n+=" cm-breakpoint-conditional"),o.push(new ao(n,e).range(e))}const d=(e,t)=>{for(const i of t){const t=this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber);if(t.lineNumber!==e.number-1)continue;const o=Math.min(e.to,e.from+t.columnNumber);c.has(o)||l(e.from,t.columnNumber,null)}};await Promise.all(a);for(const[e,t]of s)if(t.length>1)for(const{column:o,breakpoint:r}of t){const t=new so(r,this);i.push(n.Decoration.widget({widget:t,side:-1}).range(e+o))}return{content:n.Decoration.set(i,!0),gutter:n.RangeSet.of(o,!0)}}async restoreBreakpointsAfterEditing(){const{breakpoints:e}=this,t=this.editor;this.breakpoints=[],await Promise.all(e.map((async e=>{const{breakpoint:i,position:o}=e,n=i.condition(),r=i.enabled(),s=i.isLogpoint();await i.remove(!1);const a=t.toLineColumn(o),c=this.transformer.editorLocationToUILocation(a.lineNumber,a.columnNumber);await this.setBreakpoint(c.lineNumber,c.columnNumber,n,r,s)})))}async refreshBreakpoints(){if(this.editor){this.breakpoints=this.fetchBreakpoints();const e=this.breakpoints,t=await this.computeBreakpointDecoration(this.editor.state,e);this.editor&&this.breakpoints===e&&(t.gutter.size||this.editor.state.field(ro,!1)?.gutter.size)&&this.editor.dispatch({effects:io.of(t)})}}breakpointChange(e){const{uiLocation:t}=e.data;if(t.uiSourceCode===this.uiSourceCode&&!this.muted){for(const e of this.scriptFileForDebuggerModel.values())if(e.isDivergingFromVM()||e.isMergingToVM())return;window.clearTimeout(this.refreshBreakpointsTimeout),this.refreshBreakpointsTimeout=window.setTimeout((()=>this.refreshBreakpoints()),50)}}onInlineBreakpointMarkerClick(e,t){if(e.consume(!0),t)e.shiftKey?t.setEnabled(!t.enabled()):t.remove(!1);else if(this.editor){const t=this.editor.editor.posAtDOM(e.target),i=this.editor.state.doc.lineAt(t),o=this.transformer.editorLocationToUILocation(i.number-1,t-i.from);this.setBreakpoint(o.lineNumber,o.columnNumber,$i,!0,!1)}}onInlineBreakpointMarkerContextMenu(e,i){e.consume(!0);const o=this.editor,n=o.editor.posAtDOM(e.target),r=o.state.doc.lineAt(n);if(!m.SourceFrame.isBreakableLine(o.state,r)||!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode))return;const s=new t.ContextMenu.ContextMenu(e);if(i)s.debugSection().appendItem(Xi(Ki.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:i,location:null})}),{jslogContext:"edit-breakpoint"});else{const e=this.transformer.editorLocationToUILocation(r.number-1,n-r.from);s.debugSection().appendItem(Xi(Ki.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),s.debugSection().appendItem(Xi(Ki.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),s.debugSection().appendItem(Xi(Ki.neverPauseHere),(()=>this.setBreakpoint(e.lineNumber,e.columnNumber,Gi,!0,!1)),{jslogContext:"never-pause-here"})}s.show()}updateScriptFiles(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e)&&this.updateScriptFile(e)}this.showSourceMapInfobarIfNeeded()}updateScriptFile(e){const t=this.scriptFileForDebuggerModel.get(e),i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);this.scriptFileForDebuggerModel.delete(e),t&&(t.removeEventListener("DidMergeToVM",this.didMergeToVM,this),t.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),this.muted&&!this.uiSourceCode.isDirty()&&this.consistentScripts()&&this.setMuted(!1)),i&&(this.scriptFileForDebuggerModel.set(e,i),i.addEventListener("DidMergeToVM",this.didMergeToVM,this),i.addEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),i.checkMapping(),i.missingSymbolFiles().then((e=>{if(e){const t=Xi(Ki.debugInfoNotFound,{PH1:i.uiSourceCode.url()});this.updateMissingDebugInfoInfobar({resources:e,details:t})}else this.updateMissingDebugInfoInfobar(null)})))}updateMissingDebugInfoInfobar(e){if(!this.missingDebugInfoBar){if(null===e)return this.removeInfobar(this.missingDebugInfoBar),void(this.missingDebugInfoBar=null);if(this.missingDebugInfoBar=t.Infobar.Infobar.create("error",e.details,[],void 0,"missing-debug-info"),this.missingDebugInfoBar){for(const t of e.resources){const e=this.missingDebugInfoBar?.createDetailsRowMessage(Xi(Ki.debugFileNotFound,{PH1:t}));e&&e.classList.add("infobar-selectable")}this.missingDebugInfoBar.setCloseCallback((()=>{this.removeInfobar(this.missingDebugInfoBar),this.missingDebugInfoBar=null})),this.attachInfobar(this.missingDebugInfoBar)}}}scriptHasSourceMap(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){const t=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);if(t&&t.hasSourceMapURL())return!0}return!1}getSourceMapResource(){const e=this.loader.getResourcesLoaded();for(const[t,n]of this.scriptFileForDebuggerModel.entries()){const r=n.script?.sourceMapURL;if(r){const s=o.SourceMapManager.SourceMapManager.resolveRelativeSourceURL(t.target(),n.script.sourceURL),a=i.ParsedURL.ParsedURL.completeURL(s,r);if(a){const t=e.get(o.PageResourceLoader.PageResourceLoader.makeKey(a,n.script.createPageResourceLoadInitiator()));if(t)return t}}}return null}showSourceMapInfobarIfNeeded(){if(this.sourceMapInfobar)return;if(!i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get())return;if(!this.scriptHasSourceMap())return;const e=this.getSourceMapResource();if(!e||null!==e.success){if(e)if(e.success){if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Xi(Ki.sourceMapLoaded),[],i.Settings.Settings.instance().createSetting("source-map-infobar-disabled",!1),"source-map-loaded"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.associatedFilesShouldBeAdded)),this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.associatedFilesAreAvailable,{PH1:String(t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction("quick-open.show"))}))}else{let i,o;const n=u.IgnoreListManager.IgnoreListManager.instance();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.ContentScripts?(i=Xi(Ki.ignoreContentScripts),o=n.ignoreListContentScripts.bind(n)):(i=Xi(Ki.ignoreScript),o=n.ignoreListUISourceCode.bind(n,this.uiSourceCode)),this.sourceMapInfobar=t.Infobar.Infobar.create("warning",Xi(Ki.sourceMapFailed),[{text:i,highlight:!1,delegate:o,dismiss:!0}],void 0,"source-map-failed"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.debuggingPowerReduced)),e.errorMessage&&this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.errorLoading,{PH1:l.StringUtilities.trimMiddle(e.url,t.UIUtils.MaxLengthForDisplayedURLs),PH2:e.errorMessage}))}else{if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Xi(Ki.sourceMapSkipped),[],i.Settings.Settings.instance().createSetting("source-map-skipped-infobar-disabled",!1),"source-map-skipped"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.debuggingPowerReduced)),this.sourceMapInfobar.createDetailsRowMessage(Xi(Ki.reloadForSourceMap))}this.sourceMapInfobar.setCloseCallback((()=>{this.removeInfobar(this.sourceMapInfobar),this.sourceMapInfobar=null})),this.attachInfobar(this.sourceMapInfobar)}}handleGutterClick(e,t){return!this.muted&&0===t.button&&!t.altKey&&(t.metaKey||t.ctrlKey?(c.userMetrics.breakpointEditDialogRevealedFrom(6),this.#k(e,t.shiftKey),!0):(this.toggleBreakpoint(e,t.shiftKey),!0))}async toggleBreakpoint(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.lineBreakpoints(e);if(!i.length)return void await this.createNewBreakpoint(e,$i,!0,!1);const o=i.some((e=>!e.enabled()));for(const e of i)t?e.setEnabled(o):(c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterToggle),e.remove(!1))}async createNewBreakpoint(e,t,i,o){if(!this.editor||!m.SourceFrame.isBreakableLine(this.editor.state,e))return;c.userMetrics.actionTaken(c.UserMetrics.Action.ScriptsBreakpointSet),this.#E();const n=this.transformer.editorLocationToUILocation(e.number-1);await this.setBreakpoint(n.lineNumber,n.columnNumber,t,i,o)}async setBreakpoint(e,t,o,n,r){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!0);const s=await this.breakpointManager.setBreakpoint(this.uiSourceCode,e,t,o,n,r,"USER_ACTION");return this.breakpointWasSetForTest(e,t,o,n),s}breakpointWasSetForTest(e,t,i,o){}async callFrameChanged(){this.liveLocationPool.disposeAll();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);e?await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),(async t=>{const i=await t.uiLocation();i&&i.uiSourceCode===this.uiSourceCode?(this.setExecutionLocation(i),this.updateMissingDebugInfoInfobar(e.missingDebugInfoDetails),this.#E()):this.setExecutionLocation(null)}),this.liveLocationPool):this.setExecutionLocation(null)}setExecutionLocation(e){if(this.executionLocation!==e&&this.editor)if(this.executionLocation=e,e){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber),i=go(this.editor.state,t.lineNumber,t.columnNumber);this.editor.dispatch({effects:po.update.of(i)}),this.updateValueDecorations(),this.controlDown&&this.showContinueToLocations()}else this.editor.dispatch({effects:[po.update.of(n.Decoration.none),fo.update.of(n.Decoration.none),Io.update.of(n.Decoration.none)]})}dispose(){this.hideIgnoreListInfobar(),this.sourceMapInfobar&&this.sourceMapInfobar.dispose();for(const e of this.scriptFileForDebuggerModel.values())e.removeEventListener("DidMergeToVM",this.didMergeToVM,this),e.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this);this.scriptFileForDebuggerModel.clear(),this.popoverHelper?.hidePopover(),this.popoverHelper?.dispose(),this.setExecutionLocation(null),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),u.IgnoreListManager.IgnoreListManager.instance().removeChangeListener(this.ignoreListCallback),Yi.delete(this.uiSourceCode),super.dispose(),window.clearTimeout(this.refreshBreakpointsTimeout),this.editor=void 0,t.Context.Context.instance().removeFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool.disposeAll()}#E(){if(this.#x)return;this.#x=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCode.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCode.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCode.content()));c.userMetrics.sourcesPanelFileDebugged(t)}}const Zi=n.StateEffect.define(),eo=n.StateEffect.define(),to=n.StateField.define({create:()=>[],update(e,t){for(const i of t.effects)i.is(Zi)?e=e.concat(i.value):i.is(eo)&&(e=e.filter((e=>e!==i.value)));return e},provide:e=>n.showPanel.computeN([e],(t=>t.field(e).map((e=>()=>({dom:e.element})))))});const io=n.StateEffect.define(),oo=n.StateEffect.define();function no(e,t){const i=[];return e.between(0,t.length,((e,t,o)=>{let n=o.elementClass;/cm-breakpoint-disabled/.test(n)||(n+=" cm-breakpoint-disabled"),i.push(new ao(n,e).range(e))})),n.RangeSet.of(i,!1)}const ro=n.StateField.define({create:()=>({content:n.RangeSet.empty,gutter:n.RangeSet.empty}),update(e,t){t.changes.empty||(e={content:e.content.map(t.changes),gutter:e.gutter.map(t.changes)});for(const i of t.effects)i.is(io)?e=i.value:i.is(oo)&&(e={content:n.RangeSet.empty,gutter:no(e.gutter,t.state.doc)});return e},provide:e=>[n.EditorView.decorations.from(e,(e=>e.content)),n.lineNumberMarkers.from(e,(e=>e.gutter))]});class so extends n.WidgetType{breakpoint;parent;class;constructor(e,t){super(),this.breakpoint=e,this.parent=t,this.class="cm-inlineBreakpoint",e?.isLogpoint()?this.class+=" cm-inlineBreakpoint-logpoint":e?.condition()&&(this.class+=" cm-inlineBreakpoint-conditional"),e?.enabled()||(this.class+=" cm-inlineBreakpoint-disabled")}eq(e){return e.class===this.class&&e.breakpoint===this.breakpoint}toDOM(){const e=document.createElement("span");return e.className=this.class,e.setAttribute("jslog",`${a.breakpointMarker("inline").track({click:!0})}`),e.addEventListener("click",(e=>{this.parent.onInlineBreakpointMarkerClick(e,this.breakpoint),e.consume()})),e.addEventListener("contextmenu",(e=>{this.parent.onInlineBreakpointMarkerContextMenu(e,this.breakpoint),e.consume()})),e}ignoreEvent(){return!0}}class ao extends n.GutterMarker{elementClass;#L;constructor(e,t){super(),this.elementClass=e,this.#L=t}eq(e){return e.elementClass===this.elementClass}toDOM(e){const t=document.createElement("div");t.setAttribute("jslog",`${a.breakpointMarker("gutter").track({click:!0})}`);const i=e.state.doc.lineAt(this.#L).number,o=e.state.facet(m.SourceFrame.LINE_NUMBER_FORMATTER);return t.textContent=o(i,e.state),t}}function co(e,t){return e.enabled()!==t.enabled()?e.enabled()?-1:1:e.bound()!==t.bound()?e.bound()?-1:1:Boolean(e.condition())!==Boolean(t.condition())?Boolean(e.condition())?-1:1:0}function lo(){const e=n.StateEffect.define(),t=n.StateField.define({create:()=>n.Decoration.none,update:(t,i)=>i.effects.reduce(((t,i)=>i.is(e)?i.value:t),t.map(i.changes)),provide:e=>n.EditorView.decorations.from(e)});return{update:e,field:t}}const uo=n.Decoration.line({attributes:{class:"cm-executionLine"}}),ho=n.Decoration.mark({attributes:{class:"cm-executionToken"}}),po=lo();function go(e,t,i){const{doc:o}=e;if(t>=o.lines)return n.Decoration.none;const r=o.line(t+1),s=[uo.range(r.from)],a=Math.min(r.to,r.from+i);let c=null;for(;null===c;)c=n.ensureSyntaxTree(e,r.to,500);let l=c.resolveInner(a,1);l.to===l.from-1&&/[(.]/.test(o.sliceString(l.from,l.to))&&(l=l.resolve(l.to,1));const d=Math.min(r.to,l.to);return d>a&&s.push(ho.range(a,d)),n.Decoration.set(s)}const mo=n.Decoration.mark({class:"cm-continueToLocation"}),bo=n.Decoration.mark({class:"cm-continueToLocation cm-continueToLocation-async"}),fo=lo(),So={},vo={class:"cm-hasContinueMarkers"},Co=n.EditorView.contentAttributes.compute([fo.field],(e=>e.field(fo.field).size?vo:So));class wo extends n.WidgetType{pairs;constructor(e){super(),this.pairs=e}eq(e){return this.pairs.length===e.pairs.length&&this.pairs.every(((t,i)=>t[0]===e.pairs[i][0]&&t[1]===e.pairs[i][1]))}toDOM(){const e=new y.RemoteObjectPreviewFormatter.RemoteObjectPreviewFormatter,i=document.createElement("div");i.classList.add("cm-variableValues");let o=!0;for(const[n,r]of this.pairs){o?o=!1:t.UIUtils.createTextChild(i,", ");const s=i.createChild("span");t.UIUtils.createTextChild(s,n+" = ");const a=r.preview?r.preview.properties.length:0,c=r.preview&&r.preview.entries?r.preview.entries.length:0;if(r.preview&&a+c<10)e.appendObjectPreview(s,r.preview,!1);else{const e=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValue(r,!1,!1);s.appendChild(e.element)}}return i}}const Io=lo();class yo{blockList=new Set;variables=[]}function xo(e,t,i,o){const r=e.doc.lineAt(t);t=Math.min(r.to,t),i=e.doc.lineAt(i).from;const s=n.ensureSyntaxTree(e,i,100);if(!s)return[];function a(e){return("Block"===(t=e.name)||"ForSpec"===t)&&(e.to{if(i.from0?d[d.length-1].blockList.add(n):(i.from>l.to&&(l=e.doc.lineAt(i.from)),h().push({line:l.number-1,from:i.from,id:n})))},leave:e=>{if(u===e.node)u=null;else if(a(e)){const e=d.pop(),t=h();for(const i of e?.variables??[])e?.blockList.has(i.id)||t.push(i)}}}),c}async function ko(e,t){const i=[];for(const o of e.scopeChain()){const e=await t(o.range()?.start??null);if(!e)break;const n=await t(o.range()?.end??null);if(!n)break;const{properties:r}=await p.NamesResolver.resolveScopeInObject(o).getAllProperties(!1,!1);if(!r||r.length>500)break;const s=new Map(r.map((e=>[e.name,e.value])));if(i.push({scopeStart:e,scopeEnd:n,variableMap:s}),"local"===o.type())break}return i}function To(e,t){const i=new Map;for(const{line:n,from:r,id:s}of t){const t=o(s,r,e);if(!t)continue;let a=i.get(n);a||(a=new Map,i.set(n,a)),a.set(s,t)}return i;function o(e,t,i){for(const o of i){if(t=o.scopeEnd)continue;const i=o.variableMap.get(e);if(i)return i}return null}}function Eo(e,t,i){const{main:o}=e.selection;if(!o.empty)return i50||/[^\w_\-$]/.test(e.sliceDoc(s.from,s.to))?null:{from:s.from,to:s.to,containsSideEffects:!1}}}function Lo(e,t){let i=!1;return t.toTree().iterate({enter(t){switch(t.name){case"AssignmentExpression":case"CallExpression":return i=!0,!1;case"ArithOp":{const o=e.sliceString(t.from,t.to);if("++"===o||"--"===o)return i=!0,!1;break}}return!0}}),i}const Mo=n.Decoration.mark({class:"cm-evaluatedExpression"}),Po=lo(),Fo=n.EditorView.baseTheme({".cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover, &.cm-breakpoint":{borderStyle:"solid",borderWidth:"1px 4px 1px 1px",marginRight:"-4px",paddingLeft:"8px",lineHeight:"calc(1.2em - 2px)",position:"relative"},"&:hover":{WebkitBorderImage:Do("#ebeced","#ebeced")},"&.cm-breakpoint":{color:"#fff",WebkitBorderImage:Do("#4285f4","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:Do("#f29900","#e37400"),"&::before":{content:'"?"',position:"absolute",top:0,left:"1px"}},"&.cm-breakpoint-logpoint":{WebkitBorderImage:Do("#f439a0","#d01884"),"&::before":{content:'"‥"',position:"absolute",top:"-3px",left:"1px"}}},"&dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover":{WebkitBorderImage:Do("#3c4043","#3c4043")},"&.cm-breakpoint":{WebkitBorderImage:Do("#5186EC","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:Do("#e9a33a","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:Do("#E54D9B","#d01884")}},":host-context(.breakpoints-deactivated) & .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{color:"#1a73e8",WebkitBorderImage:Do("#d9e7fd","#1a73e8"),"&.cm-breakpoint-conditional":{color:"#e37400",WebkitBorderImage:Do("#fcebcc","#e37400")},"&.cm-breakpoint-logpoint":{color:"#d01884",WebkitBorderImage:Do("#fdd7ec","#f439a0")}},":host-context(.breakpoints-deactivated) &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{WebkitBorderImage:Do("#2a384e","#1a73e8"),"&.cm-breakpoint-conditional":{WebkitBorderImage:Do("#4d3c1d","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:Do("#4e283d","#f439a0")}},".cm-inlineBreakpoint":{cursor:"pointer",position:"relative",top:"1px",content:No("#4285F4","#1A73E8"),height:"10px","&.cm-inlineBreakpoint-conditional":{content:Ao("#F29900","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Uo("#F439A0","#D01884")}},"&dark .cm-inlineBreakpoint":{content:No("#5186EC","#1A73E8"),"&.cm-inlineBreakpoint-conditional":{content:Ao("#e9a33a","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Uo("#E54D9B","#D01884")}},":host-context(.breakpoints-deactivated) & .cm-inlineBreakpoint, .cm-inlineBreakpoint-disabled":{content:No("#4285F4","#1A73E8","0.2"),"&.cm-inlineBreakpoint-conditional":{content:Ao("#F9AB00","#E37400","0.2")},"&.cm-inlineBreakpoint-logpoint":{content:Uo("#F439A0","#D01884","0.2")}},".cm-executionLine":{backgroundColor:"var(--sys-color-yellow-container)",outline:"1px solid var(--sys-color-yellow-outline)",".cm-hasContinueMarkers &":{backgroundColor:"transparent"},"&.cm-highlightedLine":{animation:"cm-fading-highlight-execution 2s 0s"},"&.cm-line::selection, &.cm-line ::selection":{backgroundColor:"var(--sys-color-tonal-container) !important"}},".cm-executionToken":{backgroundColor:"var(--sys-color-state-focus-select)"},"@keyframes cm-fading-highlight-execution":{from:{backgroundColor:"var(--sys-color-tonal-container)"},to:{backgroundColor:"var(--sys-color-yellow-container)"}},".cm-continueToLocation":{cursor:"pointer",backgroundColor:"var(--color-continue-to-location)","&:hover":{backgroundColor:"var(--color-continue-to-location-hover)",border:"1px solid var(--color-continue-to-location-hover-border)",margin:"0 -1px"},"&.cm-continueToLocation-async":{backgroundColor:"var(--color-continue-to-location-async)","&:hover":{backgroundColor:"var(--color-continue-to-location-async-hover)",border:"1px solid var(--color-continue-to-location-async-hover-border)",margin:"0 -1px"}}},".cm-evaluatedExpression":{backgroundColor:"var(--color-evaluated-expression)",border:"1px solid var(--color-evaluated-expression-border)",margin:"0 -1px"},".cm-variableValues":{display:"inline",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"1000px",opacity:"80%",backgroundColor:"var(--color-variable-values)",marginLeft:"10px",padding:"0 5px",userSelect:"text",".cm-executionLine &":{backgroundColor:"transparent",opacity:"50%"}}});function Do(e,t){return`url('data:image/svg+xml,') 1 3 1 1`}function No(e,t,i="1"){return`url('data:image/svg+xml,')`}function Ao(e,t,i="1"){return`url('data:image/svg+xml,')`}function Uo(e,t,i="1"){return`url('data:image/svg+xml,')`}var Ro=Object.freeze({__proto__:null,DebuggerPlugin:Qi,BreakpointLocationRevealer:class{async reveal(e,t){const{uiLocation:i}=e;Wi.instance().showUILocation(i,t);const o=Yi.get(i.uiSourceCode);o?o.editBreakpointLocation(e):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(e.breakpoint,!1)}},computeExecutionDecorations:go,getVariableNamesByLine:xo,computeScopeMappings:ko,getVariableValuesByLine:To,computePopoverHighlightRange:Eo});class Bo{query;queryUpperCase;score;sequence;dataUpperCase;fileNameIndex;constructor(e){this.query=e,this.queryUpperCase=e.toUpperCase(),this.score=new Int32Array(2e3),this.sequence=new Int32Array(2e3),this.dataUpperCase="",this.fileNameIndex=0}calculateScore(e,t){if(!e||!this.query)return 0;const i=this.query.length,o=e.length;(!this.score||this.score.length=s?(r[t*o+i]=c+1,n[t*o+i]=a+l):(r[t*o+i]=0,n[t*o+i]=s)}t&&this.restoreMatchIndexes(r,i,o,t);return 256*n[i*o-1]+(256-e.length)}testWordStart(e,t){if(0===t)return!0;const i=e.charAt(t-1);return"_"===i||"-"===i||"/"===i||"."===i||" "===i||e[t-1]!==this.dataUpperCase[t-1]&&e[t]===this.dataUpperCase[t]}restoreMatchIndexes(e,t,i,o){let n=t-1,r=i-1;for(;n>=0&&r>=0;)if(0===e[n*i+r])--r;else o.push(r),--n,--r;o.reverse()}singleCharScore(e,t,i,o){const n=this.testWordStart(t,o),r=o>this.fileNameIndex;let s=10;return(0===o||"/"===t[o-1])&&(s+=4),n&&(s+=2),e[i]===t[o]&&e[i]===this.queryUpperCase[i]&&(s+=6),r&&(s+=4),o===this.fileNameIndex+1&&0===i&&(s+=5),r&&n&&(s+=3),s}sequenceCharScore(e,t,i,o,n){let r=10;return o>this.fileNameIndex&&(r+=4),(0===o||"/"===t[o-1])&&(r+=5),r+=4*n,r}match(e,t,i,o,n){return this.queryUpperCase[i]!==this.dataUpperCase[o]?0:n?this.sequenceCharScore(e,t,i,o-n,n):this.singleCharScore(e,t,i,o)}}var jo=Object.freeze({__proto__:null,FilePathScoreFunction:Bo});const Vo={noFilesFound:"No files found",sIgnoreListed:"{PH1} (ignore listed)"},Wo=e.i18n.registerUIStrings("panels/sources/FilteredUISourceCodeListProvider.ts",Vo),Oo=e.i18n.getLocalizedString.bind(void 0,Wo);class Ho extends L.FilteredListWidget.Provider{queryLineNumberAndColumnNumber;defaultScores;scorer;uiSourceCodes;uiSourceCodeIds;query;constructor(e){super(e),this.queryLineNumberAndColumnNumber="",this.defaultScores=null,this.scorer=new Bo(""),this.uiSourceCodes=[],this.uiSourceCodeIds=new Set}projectRemoved(e){const t=e.data;this.populate(t),this.refresh()}populate(e){this.uiSourceCodes=[],this.uiSourceCodeIds.clear();for(const t of f.Workspace.WorkspaceImpl.instance().projects())if(t!==e&&this.filterProject(t))for(const e of t.uiSourceCodes())this.filterUISourceCode(e)&&(this.uiSourceCodes.push(e),this.uiSourceCodeIds.add(e.canononicalScriptId()))}filterUISourceCode(e){if(this.uiSourceCodeIds.has(e.canononicalScriptId()))return!1;if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return!1;if(e.isFetchXHR())return!1;const t=h.Persistence.PersistenceImpl.instance().binding(e);return!t||t.fileSystem===e}uiSourceCodeSelected(e,t,i){}filterProject(e){return!0}itemCount(){return this.uiSourceCodes.length}itemContentTypeAt(e){return this.uiSourceCodes[e].contentType()}itemKeyAt(e){return this.uiSourceCodes[e].url()}setDefaultScores(e){this.defaultScores=e}itemScoreAt(e,t){const i=this.uiSourceCodes[e],o=this.defaultScores&&this.defaultScores.get(i)||0;if(!t||t.length<2)return o;this.query!==t&&(this.query=t,this.scorer=new Bo(t));let n=10;i.project().type()!==f.Workspace.projectTypes.FileSystem||h.Persistence.PersistenceImpl.instance().binding(i)||(n=5);let r=0;i.contentType().isFromSourceMap()&&!i.isKnownThirdParty()&&(r=100),i.contentType().isScript()&&(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||(r+=50));const s=i.fullDisplayName();return o+n*(r+this.scorer.calculateScore(s,null))}renderItem(e,i,o,n){i=this.rewriteQuery(i);const r=this.uiSourceCodes[e],s=r.fullDisplayName(),a=[];new Bo(i).calculateScore(s,a);const c=s.lastIndexOf("/");let l=s;u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(r)&&(o.parentElement?.classList.add("is-ignore-listed"),l=Oo(Vo.sIgnoreListed,{PH1:l})),o.textContent=r.displayName()+(this.queryLineNumberAndColumnNumber||""),this.renderSubtitleElement(n,s.substring(0,c+1)),t.Tooltip.Tooltip.install(n,l);const d=[];for(let e=0;ec){for(let e=0;e43&&(o=i.length-43);e.createChild("div","first-part").textContent=i.substring(0,o);e.createChild("div","second-part").textContent=i.substring(o),t.Tooltip.Tooltip.install(e,i)}selectItem(e,t){const i=t.trim().match(/^([^:]*)(:\d+)?(:\d+)?$/);if(!i)return;let o,n;i[2]&&(o=parseInt(i[2].substr(1),10)-1),i[3]&&(n=parseInt(i[3].substr(1),10)-1);const r=null!==e?this.uiSourceCodes[e]:null;this.uiSourceCodeSelected(r,o,n)}rewriteQuery(e){if(!(e=e?e.trim():"")||":"===e)return"";const t=e.match(/^([^:]+)((?::[^:]*){0,2})$/);return this.queryLineNumberAndColumnNumber=t?t[2]:"",t?t[1]:e}uiSourceCodeAdded(e){const t=e.data;this.filterUISourceCode(t)&&this.filterProject(t.project())&&(this.uiSourceCodes.push(t),this.uiSourceCodeIds.add(t.canononicalScriptId()),this.refresh())}notFoundText(){return Oo(Vo.noFilesFound)}attach(){f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.populate()}detach(){f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.queryLineNumberAndColumnNumber="",this.defaultScores=null}}var _o=Object.freeze({__proto__:null,FilteredUISourceCodeListProvider:Ho});const zo={noFileSelected:"No file selected.",noResultsFound:"No results found",typeANumberToGoToThatLine:"Type a number to go to that line.",currentPositionXsTypeAnOffset:"Current position: 0x{PH1}. Type an offset between 0x{PH2} and 0x{PH3} to navigate to.",currentLineSTypeALineNumber:"Current line: {PH1}. Type a line number between 1 and {PH2} to navigate to.",goToOffsetXs:"Go to offset 0x{PH1}.",goToLineSAndColumnS:"Go to line {PH1} and column {PH2}.",goToLineS:"Go to line {PH1}."},qo=e.i18n.registerUIStrings("panels/sources/GoToLineQuickOpen.ts",zo),$o=e.i18n.getLocalizedString.bind(void 0,qo);class Go extends L.FilteredListWidget.Provider{#M=[];constructor(){super("source-line")}selectItem(e,t){const i=this.currentSourceFrame();if(!i)return;const o=this.parsePosition(t);o&&i.revealPosition({lineNumber:o.line-1,columnNumber:o.column-1})}itemCount(){return this.#M.length}renderItem(e,i,o,n){t.UIUtils.createTextChild(o,this.#M[e])}rewriteQuery(e){return""}queryChanged(e){this.#M=[];const t=this.parsePosition(e),i=this.currentSourceFrame();if(t)i&&i.wasmDisassembly?this.#M.push($o(zo.goToOffsetXs,{PH1:(t.column-1).toString(16)})):t.column&&t.column>1?this.#M.push($o(zo.goToLineSAndColumnS,{PH1:t.line,PH2:t.column})):i&&t.line>i.textEditor.state.doc.lines||this.#M.push($o(zo.goToLineS,{PH1:t.line}));else{if(!i)return void this.#M.push($o(zo.typeANumberToGoToThatLine));const e=i.textEditor.state,t=i.wasmDisassembly,o=i.editorLocationToUILocation(e.doc.lineAt(e.selection.main.head).number-1).lineNumber;if(t){const e=t.lineNumberToBytecodeOffset(t.lineNumbers-1),i=e.toString(16).length,n=t.lineNumberToBytecodeOffset(o);return void this.#M.push($o(zo.currentPositionXsTypeAnOffset,{PH1:n.toString(16).padStart(i,"0"),PH2:"0".padStart(i,"0"),PH3:e.toString(16)}))}const n=i.editorLocationToUILocation(e.doc.lines-1).lineNumber+1;this.#M.push($o(zo.currentLineSTypeALineNumber,{PH1:o+1,PH2:n}))}}notFoundText(e){return this.currentSourceFrame()?$o(zo.noResultsFound):$o(zo.noFileSelected)}parsePosition(e){const t=this.currentSourceFrame();if(t&&t.wasmDisassembly){const t=e.match(/0x([0-9a-fA-F]+)/);if(!t||!t[0]||t[0].length!==e.length)return null;return{line:0,column:parseInt(t[0],16)+1}}const i=e.match(/([0-9]+)(\:[0-9]*)?/);if(!i||!i[0]||i[0].length!==e.length)return null;const o=parseInt(i[1],10);let n=0;return i[2]&&(n=parseInt(i[2].substring(1),10)),{line:Math.max(0|o,1),column:Math.max(0|n,1)}}currentSourceFrame(){const e=t.Context.Context.instance().flavor(Ii);return e?e.currentSourceFrame():null}}var Ko=Object.freeze({__proto__:null,GoToLineQuickOpen:Go});const Jo={formatS:"Format {PH1}",format:"Format"},Xo=e.i18n.registerUIStrings("panels/sources/InplaceFormatterEditorAction.ts",Jo),Yo=e.i18n.getLocalizedString.bind(void 0,Xo);let Qo;class Zo{button;sourcesView;uiSourceCodeTitleChangedEvent=null;constructor(){}static instance(e={forceNew:null}){const{forceNew:t}=e;return Qo&&!t||(Qo=new Zo),Qo}editorSelected(e){const t=e.data;this.updateButton(t)}editorClosed(e){const{wasSelected:t}=e.data;t&&this.updateButton(null)}updateButton(e){this.uiSourceCodeTitleChangedEvent&&i.EventTarget.removeEventListeners([this.uiSourceCodeTitleChangedEvent]),this.uiSourceCodeTitleChangedEvent=e?e.addEventListener(f.UISourceCode.Events.TitleChanged,(e=>this.updateButton(e.data)),this):null;const t=this.isFormattable(e);this.button.element.classList.toggle("hidden",!t),e&&t&&this.button.setTitle(Yo(Jo.formatS,{PH1:e.name()}))}getOrCreateButton(e){return this.button||(this.sourcesView=e,this.sourcesView.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.sourcesView.addEventListener("EditorClosed",this.editorClosed.bind(this)),this.button=new t.Toolbar.ToolbarButton(Yo(Jo.format),"brackets"),this.button.addEventListener("Click",this.formatSourceInPlace,this),this.updateButton(e.currentUISourceCode())),this.button}isFormattable(e){return!!e&&(!!e.project().canSetFileContent()||null!==h.Persistence.PersistenceImpl.instance().binding(e))}formatSourceInPlace(){const e=this.sourcesView.currentSourceFrame();if(!e)return;const t=e.uiSourceCode();this.isFormattable(t)&&(t.isDirty()?this.contentLoaded(t,e,t.workingCopy()):t.requestContent().then((i=>{this.contentLoaded(t,e,i.content||"")})))}async contentLoaded(e,t,i){const{formattedContent:o,formattedMapping:n}=await I.ScriptFormatter.format(e.contentType(),t.contentType,i);if(e.workingCopy()===o)return;const r=t.textEditor.toLineColumn(t.textEditor.state.selection.main.head),[s,a]=n.originalToFormatted(r.lineNumber,r.columnNumber);e.setWorkingCopy(o),this.sourcesView.showSourceLocation(e,{lineNumber:s,columnNumber:a})}}xi(Zo.instance);var en=Object.freeze({__proto__:null,InplaceFormatterEditorAction:Zo});var tn=Object.freeze({__proto__:null,OpenFileQuickOpen:class extends Ho{constructor(){super("source-file")}attach(){this.setDefaultScores(Ii.defaultUISourceCodeScores()),super.attach()}uiSourceCodeSelected(e,t,o){c.userMetrics.actionTaken(c.UserMetrics.Action.SelectFileFromFilePicker),e&&("number"==typeof t?i.Revealer.reveal(e.uiLocation(t,o)):i.Revealer.reveal(e))}filterProject(e){return!e.isServiceProject()}renderItem(e,t,i,o){super.renderItem(e,t,i,o);const n=new r.Icon.Icon,s=D.iconDataForResourceType(this.itemContentTypeAt(e));n.data={...s,width:"20px",height:"20px"},i.parentElement?.parentElement?.insertBefore(n,i.parentElement)}renderAsTwoRows(){return!0}}});const on={noFileSelected:"No file selected.",openAJavascriptOrCssFileToSee:"Open a JavaScript or CSS file to see symbols",noResultsFound:"No results found"},nn=e.i18n.registerUIStrings("panels/sources/OutlineQuickOpen.ts",on),rn=e.i18n.getLocalizedString.bind(void 0,nn);function sn(e){function t(t){t=Math.max(0,Math.min(t,e.doc.length));const i=e.doc.lineAt(t);return{lineNumber:i.number-1,columnNumber:t-i.from}}function i(){for(;"ParamList"!==r.name&&r.nextSibling(););let t="";if("ParamList"===r.name&&r.firstChild())do{switch(r.name){case"ArrayPattern":t+="[‥]";break;case"ObjectPattern":t+="{‥}";break;case"VariableDefinition":t+=e.sliceDoc(r.from,r.to);break;case"Spread":t+="...";break;case",":t+=", "}}while(r.nextSibling());return`(${t})`}const o=[],r=n.syntaxTree(e).cursor();do{switch(r.name){case"RuleSet":for(r.firstChild();;r.nextSibling()){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);if(o.push({title:i,lineNumber:n,columnNumber:s}),r.nextSibling(),","!==r.name)break}break;case"FunctionDeclaration":case"MethodDeclaration":{let n="";r.firstChild();do{switch(r.name){case"abstract":case"async":case"get":case"set":case"static":n=`${n}${r.name} `;break;case"Star":n+="*";break;case"PropertyDefinition":case"PrivatePropertyDefinition":case"VariableDefinition":{const s=n+e.sliceDoc(r.from,r.to),{lineNumber:a,columnNumber:c}=t(r.from),l=i();o.push({title:s,subtitle:l,lineNumber:a,columnNumber:c});break}}}while(r.nextSibling());break}case"Property":{let n="";r.firstChild();do{if("async"===r.name||"get"===r.name||"set"===r.name)n=`${n}${r.name} `;else{if("Star"!==r.name){if("PropertyDefinition"===r.name){let s=e.sliceDoc(r.from,r.to);const{lineNumber:a,columnNumber:c}=t(r.from);for(;r.nextSibling();){if("ClassExpression"===r.name){s=`class ${s}`,o.push({title:s,lineNumber:a,columnNumber:c});break}if("ArrowFunction"!==r.name&&"FunctionExpression"!==r.name||r.firstChild(),"async"===r.name)n=`async ${n}`;else if("Star"===r.name)n+="*";else if("ParamList"===r.name){s=n+s;const e=i();o.push({title:s,subtitle:e,lineNumber:a,columnNumber:c});break}}break}break}n+="*"}}while(r.nextSibling());break}case"PropertyName":case"VariableDefinition":if(r.matchContext(["ClassDeclaration"])){const i="class "+e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["AssignmentExpression","MemberExpression"])||r.matchContext(["VariableDeclaration"])){let n=e.sliceDoc(r.from,r.to);const{lineNumber:s,columnNumber:a}=t(r.from);for(;"Equals"!==r.name&&r.next(););if(!r.nextSibling())break;if("ArrowFunction"===r.name||"FunctionExpression"===r.name){r.firstChild();let e="";for(;"ParamList"!==r.name&&("async"===r.name?e=`async ${e}`:"Star"===r.name&&(e+="*"),r.nextSibling()););n=e+n;const t=i();o.push({title:n,subtitle:t,lineNumber:s,columnNumber:a})}else"ClassExpression"===r.name&&(n=`class ${n}`,o.push({title:n,lineNumber:s,columnNumber:a}))}break;case"App":if(r.firstChild()&&r.nextSibling()&&"module"===e.sliceDoc(r.from,r.to)){if(r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}do{if("App"===r.name&&r.firstChild()){if(r.nextSibling()&&"func"===e.sliceDoc(r.from,r.to)&&r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from),a=[];for(;r.nextSibling();)"App"===r.name&&r.firstChild()&&(r.nextSibling()&&"param"===e.sliceDoc(r.from,r.to)&&(r.nextSibling()&&"Identifier"===r.name?a.push(e.sliceDoc(r.from,r.to)):a.push(`$${a.length}`)),r.parent());const c=`(${a.join(", ")})`;o.push({title:i,subtitle:c,lineNumber:n,columnNumber:s})}r.parent()}}while(r.nextSibling())}break;case"FieldIdentifier":case"Identifier":if(r.matchContext(["FunctionDeclarator"])){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}break;case"TypeIdentifier":if(r.matchContext(["ClassSpecifier"])){const i=`class ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["StructSpecifier"])){const i=`struct ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}}}while(r.next());return o}class an extends L.FilteredListWidget.Provider{items=[];active=!1;constructor(){super("source-symbol")}attach(){const e=this.currentSourceFrame();e?(this.active=!0,this.items=sn(e.textEditor.state).map((({title:t,subtitle:i,lineNumber:o,columnNumber:n})=>(({lineNumber:o,columnNumber:n}=e.editorLocationToUILocation(o,n)),{title:t,subtitle:i,lineNumber:o,columnNumber:n})))):(this.active=!1,this.items=[])}detach(){this.active=!1,this.items=[]}itemCount(){return this.items.length}itemKeyAt(e){const t=this.items[e];return t.title+(t.subtitle?t.subtitle:"")}itemScoreAt(e,t){const i=this.items[e];return t.split("(")[0].toLowerCase()===i.title.toLowerCase()?1/(1+i.lineNumber):-i.lineNumber-1}renderItem(e,t,i,o){const n=this.items[e];i.textContent=n.title+(n.subtitle?n.subtitle:""),L.FilteredListWidget.FilteredListWidget.highlightRanges(i,t);const r=this.currentSourceFrame();if(!r)return;const s=i.parentElement?.parentElement?.createChild("span","tag");if(!s)return;const a=r.wasmDisassembly;if(a){const e=a.lineNumberToBytecodeOffset(a.lineNumbers-1).toString(16).length;s.textContent=`:0x${n.columnNumber.toString(16).padStart(e,"0")}`}else s.textContent=`:${n.lineNumber+1}`}selectItem(e,t){if(null===e)return;const i=this.currentSourceFrame();if(!i)return;const o=this.items[e];i.revealPosition({lineNumber:o.lineNumber,columnNumber:o.columnNumber},!0)}currentSourceFrame(){const e=t.Context.Context.instance().flavor(Ii);return e&&e.currentSourceFrame()}notFoundText(){return this.currentSourceFrame()?this.active?rn(on.noResultsFound):rn(on.openAJavascriptOrCssFileToSee):rn(on.noFileSelected)}}var cn=Object.freeze({__proto__:null,outline:sn,OutlineQuickOpen:an});const ln=new CSSStyleSheet;ln.replaceSync(".scope-chain-sidebar-pane-section-header{flex:auto}.scope-chain-sidebar-pane-section-icon{float:left;margin-right:5px}.scope-chain-sidebar-pane-section-subtitle{float:right;margin-left:5px;max-width:55%;text-overflow:ellipsis;overflow:hidden}.scope-chain-sidebar-pane-section-title{font-weight:normal;word-wrap:break-word;white-space:normal}.scope-chain-sidebar-pane-section{padding:2px 4px;flex:none}\n/*# sourceURL=scopeChainSidebarPane.css */\n");const dn={loading:"Loading...",notPaused:"Not paused",noVariables:"No variables",closureS:"Closure ({PH1})",closure:"Closure",exception:"Exception",returnValue:"Return value"},un=e.i18n.registerUIStrings("panels/sources/ScopeChainSidebarPane.ts",dn),hn=e.i18n.getLocalizedString.bind(void 0,un);let pn;class gn extends t.Widget.VBox{treeOutline;expandController;linkifier;infoElement;#P=null;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.scope-chain")}`),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),this.linkifier=new F.Linkifier.Linkifier,this.infoElement=document.createElement("div"),this.infoElement.className="gray-info-message",this.infoElement.tabIndex=-1,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),this.update()}static instance(){return pn||(pn=new gn),pn}flavorChanged(e){this.update()}focus(){this.hasFocus()||t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails)&&this.treeOutline.forceSelect()}sourceMapAttached(e){e.data.client===this.#P&&this.update()}setScopeSourceMapSubscription(e){const t=this.#P;this.#P=e?.script??null,t?.debuggerModel!==this.#P?.debuggerModel&&(t&&t.debuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),this.#P&&this.#P.debuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this))}debugInfoAttached(e){e.data===this.#P&&this.update()}async update(){this.infoElement.textContent=hn(dn.loading),this.contentElement.removeChildren(),this.contentElement.appendChild(this.infoElement),this.linkifier.reset();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);this.setScopeSourceMapSubscription(e);const[i,n]=await Promise.all([p.NamesResolver.resolveThisObject(e),p.NamesResolver.resolveScopeChain(e)]);if(e===t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame)){const r=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.treeOutline.removeChildren(),!r||!e||!n)return void(this.infoElement.textContent=hn(dn.notPaused));this.contentElement.removeChildren(),this.contentElement.appendChild(this.treeOutline.element);let s=!1;for(let t=0;t${vn(fn.explainLocalOverrides)}
- ${t.XLink.XLink.create("https://goo.gle/devtools-overrides",vn(fn.learnMore),void 0,void 0,"learn-more")} - `),this.toolbar=new t.Toolbar.Toolbar("navigator-toolbar"),this.contentElement.insertBefore(this.toolbar.element,this.contentElement.firstChild),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("ProjectChanged",this.updateProjectAndUI,this),this.workspace().addEventListener(f.Workspace.Events.ProjectAdded,this.onProjectAddOrRemoved,this),this.workspace().addEventListener(f.Workspace.Events.ProjectRemoved,this.onProjectAddOrRemoved,this),this.updateProjectAndUI()}static instance(e={forceNew:null}){const{forceNew:t}=e;return wn&&!t||(wn=new yn),wn}onProjectAddOrRemoved(e){const t=e.data;t&&t.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(t)||this.updateUI()}updateProjectAndUI(){this.reset();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();e&&this.tryAddProject(e),this.updateUI()}updateUI(){this.toolbar.removeToolbarItems();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();if(e){const o=new t.Toolbar.ToolbarSettingCheckbox(i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled"));this.toolbar.appendToolbarItem(o),this.toolbar.appendToolbarItem(new t.Toolbar.ToolbarSeparator(!0));const n=new t.Toolbar.ToolbarButton(vn(fn.clearConfiguration),"clear");return n.addEventListener("Click",(()=>{i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!1),e.remove()})),void this.toolbar.appendToolbarItem(n)}const o=vn(fn.selectFolderForOverrides),n=new t.Toolbar.ToolbarButton(o,"plus",o);n.addEventListener("Click",(e=>{this.setupNewWorkspace()}),this),this.toolbar.appendToolbarItem(n)}async setupNewWorkspace(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem("overrides")&&i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!0)}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.OverridesSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e===h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()}}var xn=Object.freeze({__proto__:null,NetworkNavigatorView:In,FilesNavigatorView:class extends dt{constructor(){super("navigator-files");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` -
${vn(fn.explainWorkspace)}

- ${t.XLink.XLink.create("https://goo.gle/devtools-workspace",vn(fn.learnMore),void 0,void 0,"learn-more")} - `);const i=new t.Toolbar.Toolbar("navigator-toolbar");i.appendItemsAtLocation("files-navigator-toolbar").then((()=>{i.empty()||this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}))}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(e)&&!T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.defaultSection().appendAction("sources.add-folder-to-workspace",void 0,!0),i.show()}},OverridesNavigatorView:yn,ContentScriptsNavigatorView:class extends dt{constructor(){super("navigator-content-scripts");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` -
${vn(fn.explainContentScripts)}

- ${t.XLink.XLink.create("https://developer.chrome.com/extensions/content_scripts",vn(fn.learnMore),void 0,void 0,"learn-more")} - `)}acceptProject(e){return e.type()===f.Workspace.projectTypes.ContentScripts}},SnippetsNavigatorView:class extends dt{constructor(){super("navigator-snippets");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` -
${vn(fn.explainSnippets)}

- ${t.XLink.XLink.create("https://goo.gle/devtools-snippets",vn(fn.learnMore),void 0,void 0,"learn-more")} - `);const i=new t.Toolbar.Toolbar("navigator-toolbar"),o=new t.Toolbar.ToolbarButton(vn(fn.newSnippet),"plus",vn(fn.newSnippet),"sources.new-snippet");o.addEventListener("Click",(e=>{this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")})),i.appendToolbarItem(o),this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}acceptProject(e){return T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.headerSection().appendItem(vn(fn.createNewSnippet),(()=>this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")),{jslogContext:"create-new-snippet"}),i.show()}handleFileContextMenu(e,i){const o=i.uiSourceCode(),n=new t.ContextMenu.ContextMenu(e);n.headerSection().appendItem(vn(fn.run),(()=>T.ScriptSnippetFileSystem.evaluateScriptSnippet(o)),{jslogContext:"run"}),n.editSection().appendItem(vn(fn.rename),(()=>this.rename(i,!1)),{jslogContext:"rename"}),n.editSection().appendItem(vn(fn.remove),(()=>o.project().deleteFile(o)),{jslogContext:"remove"}),n.saveSection().appendItem(vn(fn.saveAs),this.handleSaveAs.bind(this,o),{jslogContext:"save-as"}),n.show()}async handleSaveAs(e){e.commitWorkingCopy();const{content:t}=await e.requestContent();await f.FileManager.FileManager.instance().save(this.addJSExtension(e.url()),t||"",!0),f.FileManager.FileManager.instance().close(e.url())}addJSExtension(e){return i.ParsedURL.ParsedURL.concatenate(e,".js")}},ActionDelegate:class{handleAction(e,t){switch(t){case"sources.create-snippet":return T.ScriptSnippetFileSystem.findSnippetsProject().createFile(l.DevToolsPath.EmptyEncodedPathString,null,"").then((e=>i.Revealer.reveal(e))),!0;case"sources.add-folder-to-workspace":return h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem(),!0}return!1}}});const kn=new CSSStyleSheet;kn.replaceSync(".value.object-value-node:hover{background-color:var(--sys-color-state-hover-on-subtle)}.object-value-function-prefix,\n.object-value-boolean{color:var(--sys-color-token-attribute-value)}.object-value-function{font-style:italic}.object-value-function.linkified:hover{--override-linkified-hover-background:rgb(0 0 0/10%);background-color:var(--override-linkified-hover-background);cursor:pointer}.-theme-with-dark-background .object-value-function.linkified:hover,\n:host-context(.-theme-with-dark-background) .object-value-function.linkified:hover{--override-linkified-hover-background:rgb(230 230 230/10%)}.object-value-number{color:var(--sys-color-token-attribute-value)}.object-value-bigint{color:var(--sys-color-token-comment)}.object-value-string,\n.object-value-regexp,\n.object-value-symbol{white-space:pre;unicode-bidi:-webkit-isolate;color:var(--sys-color-token-property-special)}.object-value-node{position:relative;vertical-align:baseline;color:var(--sys-color-token-variable);white-space:nowrap}.object-value-null,\n.object-value-undefined{color:var(--sys-color-state-disabled)}.object-value-unavailable{color:var(--sys-color-token-tag)}.object-value-calculate-value-button:hover{text-decoration:underline}.object-properties-section-custom-section{display:inline-flex;flex-direction:column}.-theme-with-dark-background .object-value-number,\n:host-context(.-theme-with-dark-background) .object-value-number,\n.-theme-with-dark-background .object-value-boolean,\n:host-context(.-theme-with-dark-background) .object-value-boolean{--override-primitive-dark-mode-color:hsl(252deg 100% 75%);color:var(--override-primitive-dark-mode-color)}.object-properties-section .object-description{color:var(--sys-color-token-subtle)}.value .object-properties-preview{white-space:nowrap}.name{color:var(--sys-color-token-tag);flex-shrink:0}.object-properties-preview .name{color:var(--sys-color-token-subtle)}@media (forced-colors: active){.object-value-calculate-value-button:hover{forced-color-adjust:none;color:Highlight}}\n/*# sourceURL=objectValue.css */\n");const Tn=new CSSStyleSheet;Tn.replaceSync(".watch-expression-delete-button{position:absolute;opacity:0%;right:0;.watch-expression-title:hover &{opacity:100%}}:host-context(.-theme-with-dark-background) .watch-expression-delete-button{filter:brightness(1.5)}.watch-expressions{min-height:26px}.watch-expression-title{white-space:nowrap;line-height:20px;display:flex}.watch-expression-title:hover{padding-right:26px}.watch-expression-object-header .watch-expression-title{margin-left:1px}.watch-expression{position:relative;flex:auto;min-height:20px}.watch-expression .name{color:var(--sys-color-purple);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:1000000;min-width:2em}.watch-expression-error{color:var(--sys-color-error)}.watch-expressions-separator{flex-shrink:0;flex-grow:0}.watch-expression .value{white-space:nowrap;display:inline;overflow:hidden;padding-left:4px;text-overflow:ellipsis;flex-shrink:1}.watch-expression .text-prompt{text-overflow:clip;overflow:hidden;white-space:nowrap;padding-left:4px;min-height:18px;line-height:18px;user-select:text}.watch-expression-text-prompt-proxy{margin:2px 12px 2px -4px;padding-bottom:3px}.watch-expression-header{flex:auto;margin-left:-16px;padding-left:15px}li.watch-expression-tree-item{padding-left:4px}li.watch-expression-tree-item.selected{background:var(--sys-color-neutral-container)}li.watch-expression-tree-item.selected:focus{background:var(--sys-color-tonal-container)}.watch-expression-header:focus-visible{background:var(--sys-color-tonal-container)}li.watch-expression-editing::before{background-color:transparent}@media (forced-colors: active){.watch-expression-title:hover .watch-expression-delete-button,\n .watch-expressions .dimmed{opacity:100%}li.watch-expression-tree-item *{forced-color-adjust:none;color:ButtonText}li.watch-expression-tree-item:hover{forced-color-adjust:none;background-color:Highlight}li.watch-expression-tree-item:hover *{color:HighlightText}li.watch-expression-tree-item:hover .watch-expression-delete-button{background-color:HighlightText}}\n/*# sourceURL=watchExpressionsSidebarPane.css */\n");const En={addWatchExpression:"Add watch expression",refreshWatchExpressions:"Refresh watch expressions",noWatchExpressions:"No watch expressions",deleteAllWatchExpressions:"Delete all watch expressions",addPropertyPathToWatch:"Add property path to watch",deleteWatchExpression:"Delete watch expression",notAvailable:"",copyValue:"Copy value"},Ln=e.i18n.registerUIStrings("panels/sources/WatchExpressionsSidebarPane.ts",En),Mn=e.i18n.getLocalizedString.bind(void 0,Ln);let Pn;class Fn extends t.ThrottledWidget.ThrottledWidget{watchExpressions;emptyElement;watchExpressionsSetting;addButton;refreshButton;treeOutline;expandController;linkifier;constructor(){super(!0),this.watchExpressions=[],this.watchExpressionsSetting=i.Settings.Settings.instance().createLocalSetting("watch-expressions",[]),this.addButton=new t.Toolbar.ToolbarButton(Mn(En.addWatchExpression),"plus",void 0,"add-watch-expression"),this.addButton.addEventListener("Click",(e=>{this.addButtonClicked()})),this.refreshButton=new t.Toolbar.ToolbarButton(Mn(En.refreshWatchExpressions),"refresh",void 0,"refresh-watch-expressions"),this.refreshButton.addEventListener("Click",this.update,this),this.contentElement.classList.add("watch-expressions"),this.contentElement.setAttribute("jslog",`${a.section("sources.watch")}`),this.contentElement.addEventListener("contextmenu",this.contextMenu.bind(this),!1),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),t.Context.Context.instance().addFlavorChangeListener(o.RuntimeModel.ExecutionContext,this.update,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.update,this),this.linkifier=new F.Linkifier.Linkifier,this.update()}static instance(){return Pn||(Pn=new Fn),Pn}toolbarItems(){return[this.addButton,this.refreshButton]}focus(){this.hasFocus()||this.watchExpressions.length>0&&this.treeOutline.forceSelect()}hasExpressions(){return Boolean(this.watchExpressionsSetting.get().length)}saveExpressions(){const e=[];for(let t=0;t1&&e.debugSection().appendItem(Mn(En.deleteAllWatchExpressions),this.deleteAllButtonClicked.bind(this),{jslogContext:"delete-all-watch-expressions"});const o=this.treeOutline.treeElementFromEvent(t);if(!o)return;const n=this.watchExpressions.find((e=>o.hasAncestorOrSelf(e.treeElement())));n&&n.populateContextMenu(e,t)}deleteAllButtonClicked(){this.watchExpressions=[],this.saveExpressions(),this.update()}async focusAndAddExpressionToWatch(e){await t.ViewManager.ViewManager.instance().showView("sources.watch"),this.createWatchExpression(e),this.saveExpressions(),this.update()}handleAction(e,i){const o=t.Context.Context.instance().flavor(Gt);if(!o)return!1;const{state:n}=o.textEditor,r=n.sliceDoc(n.selection.main.from,n.selection.main.to);return this.focusAndAddExpressionToWatch(r),!0}appendApplicableItems(e,t,i){i instanceof y.ObjectPropertiesSection.ObjectPropertyTreeElement?i.property.synthetic||t.debugSection().appendItem(Mn(En.addPropertyPathToWatch),(()=>this.focusAndAddExpressionToWatch(i.path())),{jslogContext:"add-property-path-to-watch"}):i.textEditor.state.selection.main.empty||t.debugSection().appendAction("sources.add-to-watch")}wasShown(){super.wasShown(),this.treeOutline.registerCSSFiles([Tn]),this.registerCSSFiles([Tn,kn])}}class Dn extends i.ObjectWrapper.ObjectWrapper{treeElementInternal;nameElement;valueElement;expressionInternal;expandController;element;editing;linkifier;textPrompt;result;preventClickTimeout;constructor(e,t,i){super(),this.expressionInternal=e,this.expandController=t,this.element=document.createElement("div"),this.element.classList.add("watch-expression"),this.element.classList.add("monospace"),this.editing=!1,this.linkifier=i,this.createWatchExpression(),this.update()}treeElement(){return this.treeElementInternal}expression(){return this.expressionInternal}async#F(e,t){if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const i=e.debuggerModel.selectedCallFrame();if(i){const e=await p.NamesResolver.allVariablesInCallFrame(i);try{t=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(t,e)}catch{}}}return e.evaluate({expression:t,objectGroup:Dn.watchObjectGroupId,includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1},!1,!1)}update(){const e=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);e&&this.expressionInternal?this.#F(e,this.expressionInternal).then((e=>{"object"in e?this.createWatchExpression(e.object,e.exceptionDetails):this.createWatchExpression()})):this.createWatchExpression()}startEditing(){this.editing=!0,this.treeElementInternal.setDisableSelectFocus(!0),this.element.removeChildren();const e=this.element.createChild("div");e.textContent=this.nameElement.textContent,this.textPrompt=new y.ObjectPropertiesSection.ObjectPropertyPrompt,this.textPrompt.renderAsBlock();const t=this.textPrompt.attachAndStartEditing(e,this.finishEditing.bind(this));this.treeElementInternal.listItemElement.classList.add("watch-expression-editing"),this.treeElementInternal.collapse(),t.classList.add("watch-expression-text-prompt-proxy"),t.addEventListener("keydown",this.promptKeyDown.bind(this),!1);const i=this.element.getComponentSelection();i&&i.selectAllChildren(e)}isEditing(){return Boolean(this.editing)}finishEditing(e,t){if(e&&e.consume(t),this.editing=!1,this.treeElementInternal.setDisableSelectFocus(!1),this.treeElementInternal.listItemElement.classList.remove("watch-expression-editing"),this.textPrompt){this.textPrompt.detach();const e=t?this.expressionInternal:this.textPrompt.text();this.textPrompt=void 0,this.element.removeChildren(),this.updateExpression(e)}}dblClickOnWatchExpression(e){e.consume(),this.isEditing()||this.startEditing()}updateExpression(e){this.expressionInternal&&this.expandController.stopWatchSectionsWithId(this.expressionInternal),this.expressionInternal=e,this.update(),this.dispatchEventToListeners("ExpressionUpdated",this)}deleteWatchExpression(e){e.consume(!0),this.updateExpression(null)}createWatchExpression(e,t){this.result=e||null,this.element.removeChildren();const i=this.treeElementInternal;if(this.createWatchExpressionTreeElement(e,t),i&&i.parent){const e=i.parent,t=e.indexOfChild(i);e.removeChild(i),e.insertChild(this.treeElementInternal,t)}this.treeElementInternal.select()}createWatchExpressionHeader(e,i){const o=this.element.createChild("div","watch-expression-header"),n=new N.Button.Button;n.variant="round",n.iconName="bin",n.className="watch-expression-delete-button",n.jslogContext="delete-watch-expression",n.size="SMALL",t.Tooltip.Tooltip.install(n,Mn(En.deleteWatchExpression)),n.addEventListener("click",this.deleteWatchExpression.bind(this),!1);const r=o.createChild("div","watch-expression-title tree-element-title");if(r.appendChild(n),this.nameElement=y.ObjectPropertiesSection.ObjectPropertiesSection.createNameElement(this.expressionInternal),t.Tooltip.Tooltip.install(this.nameElement,this.expressionInternal),Boolean(i)||!e)this.valueElement=document.createElement("span"),this.valueElement.classList.add("watch-expression-error"),this.valueElement.classList.add("value"),r.classList.add("dimmed"),this.valueElement.textContent=Mn(En.notAvailable),void 0!==i&&void 0!==i.exception&&void 0!==i.exception.description&&t.Tooltip.Tooltip.install(this.valueElement,i.exception.description);else{const t=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValueWithCustomSupport(e,Boolean(i),!1,r,this.linkifier);this.valueElement=t.element}const s=document.createElement("span");return s.classList.add("watch-expressions-separator"),s.textContent=": ",r.append(this.nameElement,s,this.valueElement),o}createWatchExpressionTreeElement(e,i){const o=this.createWatchExpressionHeader(e,i);!i&&e&&e.hasChildren&&!e.customPreview()?(o.classList.add("watch-expression-object-header"),this.treeElementInternal=new y.ObjectPropertiesSection.RootElement(e,this.linkifier),this.expandController.watchSection(this.expressionInternal,this.treeElementInternal),this.treeElementInternal.toggleOnClick=!1,this.treeElementInternal.listItemElement.addEventListener("click",this.onSectionClick.bind(this),!1),this.treeElementInternal.listItemElement.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this))):(o.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this)),this.treeElementInternal=new t.TreeOutline.TreeElement),this.treeElementInternal.title=this.element,this.treeElementInternal.listItemElement.classList.add("watch-expression-tree-item"),this.treeElementInternal.listItemElement.addEventListener("keydown",(e=>{"Enter"!==e.key||this.isEditing()?"Delete"!==e.key||this.isEditing()||this.deleteWatchExpression(e):(this.startEditing(),e.consume(!0))}))}onSectionClick(e){e.consume(!0);1===e.detail?this.preventClickTimeout=window.setTimeout(function(){if(!this.treeElementInternal)return;this.treeElementInternal.expanded?this.treeElementInternal.collapse():this.editing||this.treeElementInternal.expand()}.bind(this),333):void 0!==this.preventClickTimeout&&(window.clearTimeout(this.preventClickTimeout),this.preventClickTimeout=void 0)}promptKeyDown(e){const t=l.KeyboardUtilities.isEscKey(e);("Enter"===e.key||t)&&this.finishEditing(e,t)}populateContextMenu(e,i){this.isEditing()||e.editSection().appendItem(Mn(En.deleteWatchExpression),this.updateExpression.bind(this,null),{jslogContext:"delete-watch-expression"}),this.isEditing()||!this.result||"number"!==this.result.type&&"string"!==this.result.type||e.clipboardSection().appendItem(Mn(En.copyValue),this.copyValueButtonClicked.bind(this),{jslogContext:"copy-watch-expression-value"});const o=t.UIUtils.deepElementFromEvent(i);o&&this.valueElement.isSelfOrAncestor(o)&&this.result&&e.appendApplicableItems(this.result)}copyValueButtonClicked(){c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(this.valueElement.textContent)}static watchObjectGroupId="watch-group"}var Nn=Object.freeze({__proto__:null,WatchExpressionsSidebarPane:Fn,WatchExpression:Dn});export{V as AddSourceMapURLDialog,$ as BreakpointEditDialog,He as CSSPlugin,oe as CallStackSidebarPane,ue as CategorizedBreakpointL10n,ke as CoveragePlugin,Xe as DebuggerPausedMessage,Ro as DebuggerPlugin,yt as EditingLocationHistoryManager,jo as FilePathScoreFunction,_o as FilteredUISourceCodeListProvider,Ko as GoToLineQuickOpen,en as InplaceFormatterEditorAction,vt as NavigatorView,tn as OpenFileQuickOpen,cn as OutlineQuickOpen,pe as Plugin,Ot as ResourceOriginPlugin,mn as ScopeChainSidebarPane,nt as SearchSourcesView,$t as SnippetsPlugin,xn as SourcesNavigator,qi as SourcesPanel,tt as SourcesSearchScope,Li as SourcesView,Si as TabbedEditorContainer,Ai as ThreadsSidebarPane,ai as UISourceCodeFrame,Nn as WatchExpressionsSidebarPane}; +import*as e from"../../core/i18n/i18n.js";import*as t from"../../ui/legacy/legacy.js";import*as i from"../../core/common/common.js";import*as o from"../../core/sdk/sdk.js";import*as n from"../../third_party/codemirror.next/codemirror.next.js";import*as r from"../../ui/components/icon_button/icon_button.js";import*as s from"../../ui/components/text_editor/text_editor.js";import*as a from"../../ui/visual_logging/visual_logging.js";import*as c from"../../core/host/host.js";import*as l from"../../core/platform/platform.js";import{assertNotNullOrUndefined as d}from"../../core/platform/platform.js";import*as u from"../../models/bindings/bindings.js";import*as h from"../../models/persistence/persistence.js";import*as p from"../../models/source_map_scopes/source_map_scopes.js";import*as g from"../../models/text_utils/text_utils.js";import*as m from"../../ui/legacy/components/source_frame/source_frame.js";import*as b from"../coverage/coverage.js";import*as f from"../../models/workspace/workspace.js";import*as S from"../../ui/legacy/components/color_picker/color_picker.js";import*as v from"../../ui/legacy/components/inline_editor/inline_editor.js";import*as C from"../../core/root/root.js";import*as w from"../../models/breakpoints/breakpoints.js";import*as I from"../../models/formatter/formatter.js";import*as y from"../../ui/legacy/components/object_ui/object_ui.js";import*as x from"./components/components.js";import*as k from"../../models/extensions/extensions.js";import*as T from"../snippets/snippets.js";import*as E from"../search/search.js";import*as L from"../../ui/legacy/components/quick_open/quick_open.js";import*as M from"../../models/issues_manager/issues_manager.js";import*as P from"../../ui/components/adorners/adorners.js";import*as F from"../../ui/components/issue_counter/issue_counter.js";import*as D from"../../ui/legacy/components/utils/utils.js";import{PanelUtils as N}from"../utils/utils.js";import*as A from"../../ui/components/buttons/buttons.js";const U=new CSSStyleSheet;U.replaceSync(':host{padding:10px}.widget{align-items:center}label{white-space:nowrap}input[type="text"].add-source-map{box-shadow:0 0 0 1px var(--box-shadow-outline-color);font-size:inherit;margin:0 8px 0 5px}\n/*# sourceURL=dialog.css */\n');const R={sourceMapUrl:"Source map URL: ",debugInfoUrl:"DWARF symbols URL: ",add:"Add"},B=e.i18n.registerUIStrings("panels/sources/AddSourceMapURLDialog.ts",R),j=e.i18n.getLocalizedString.bind(void 0,B);class V extends t.Widget.HBox{input;dialog;callback;constructor(e,i,o){super(!0),this.contentElement.createChild("label").textContent=e,this.input=t.UIUtils.createInput("add-source-map","text","url"),this.input.addEventListener("keydown",this.onKeyDown.bind(this),!1),this.contentElement.appendChild(this.input);const n=t.UIUtils.createTextButton(j(R.add),this.apply.bind(this),{jslogContext:"add"});this.contentElement.appendChild(n),this.dialog=new t.Dialog.Dialog(i),this.dialog.setSizeBehavior("MeasureContent"),this.dialog.setDefaultFocusedElement(this.input),this.callback=o}static createAddSourceMapURLDialog(e){return new V(j(R.sourceMapUrl),"add-source-map-url",e)}static createAddDWARFSymbolsURLDialog(e){return new V(j(R.debugInfoUrl),"add-debug-info-url",e)}show(){super.show(this.dialog.contentElement),this.dialog.show()}done(e){this.dialog.hide(),this.callback(e)}apply(){this.done(this.input.value)}onKeyDown(e){"Enter"===e.key&&(e.consume(!0),this.apply())}wasShown(){super.wasShown(),this.registerCSSFiles([U])}}var W=Object.freeze({__proto__:null,AddDebugInfoURLDialog:V});const O=new CSSStyleSheet;O.replaceSync(":host{z-index:30;padding:4px;background-color:var(--sys-color-surface3);border-radius:7px;border:2px solid var(--sys-color-divider);width:90%;pointer-events:auto}:host(.sources-edit-breakpoint-dialog){border-radius:0;z-index:30;background-color:var(--sys-color-surface3);width:555px;pointer-events:auto;margin-left:-1px;padding:0 10px 10px 5px;border:1px solid var(--sys-color-divider)}:host-context(.sources-edit-breakpoint-dialog) .condition-editor{background-color:var(--sys-color-cdt-base-container);margin:0 6px 20px 3px}:host-context(.sources-edit-breakpoint-dialog) .source-frame-breakpoint-toolbar{font-family:sans-serif;font-size:12px}:host-context(.sources-edit-breakpoint-dialog) .link,\n.devtools-link{font-family:sans-serif;font-size:12px;margin:0 3px}:host-context(.sources-edit-breakpoint-dialog) devtools-icon.link-icon{vertical-align:sub;margin-right:0.5ch;color:var(--icon-link);width:16px;height:16px}:host-context(.sources-edit-breakpoint-dialog) .link-wrapper{display:inline-flex}:host-context(.sources-edit-breakpoint-dialog) .dialog-header{display:flex;justify-content:space-between;align-items:center}:host-context(.sources-edit-breakpoint-dialog) .dialog-header > devtools-icon:hover{color:var(--icon-default-hover)}\n/*# sourceURL=breakpointEditDialog.css */\n");const{Direction:H}=s.TextEditorHistory,_={breakpointType:"Breakpoint type",breakpoint:"Breakpoint",closeDialog:"Close edit dialog and save changes",conditionalBreakpoint:"Conditional breakpoint",logpoint:"Logpoint",expressionToCheckBeforePausingEg:"Expression to check before pausing, e.g. x > 5",pauseOnlyWhenTheConditionIsTrue:"Pause only when the condition is true",learnMoreOnBreakpointTypes:"Learn more: Breakpoint Types",logMessageEgXIsX:"Log message, e.g. `'x is', x`",logAMessageToConsoleDoNotBreak:"Log a message to Console, do not break"},z=e.i18n.registerUIStrings("panels/sources/BreakpointEditDialog.ts",_),q=e.i18n.getLocalizedString.bind(void 0,z);class $ extends t.Widget.Widget{onFinish;finished;editor;typeSelector;placeholderCompartment;#e;#t;constructor(e,o,c,l){super(!0);const d=[n.javascript.javascriptLanguage,s.Config.baseConfiguration(o||""),s.Config.closeBrackets,s.Config.autocompletion.instance(),n.EditorView.lineWrapping,s.Config.showCompletionHint,s.Config.conservativeCompletion,n.javascript.javascriptLanguage.data.of({autocomplete:e=>this.#t.historyCompletions(e)}),n.autocompletion(),s.JavaScript.argumentHints()];this.onFinish=l,this.finished=!1,this.element.tabIndex=-1,this.element.classList.add("sources-edit-breakpoint-dialog"),this.element.setAttribute("jslog",`${a.dialog("edit-breakpoint")}`);const u=this.contentElement.createChild("div","dialog-header"),h=new t.Toolbar.Toolbar("source-frame-breakpoint-toolbar",u);h.appendText(`Line ${e+1}:`),this.typeSelector=new t.Toolbar.ToolbarComboBox(this.onTypeChanged.bind(this),q(_.breakpointType),void 0,"type"),this.typeSelector.createOption(q(_.breakpoint),"REGULAR_BREAKPOINT");const p=this.typeSelector.createOption(q(_.conditionalBreakpoint),"CONDITIONAL_BREAKPOINT"),g=this.typeSelector.createOption(q(_.logpoint),"LOGPOINT");this.typeSelector.select(c?g:p),h.appendToolbarItem(this.typeSelector);const m=o||"",b=e=>(s.JavaScript.isExpressionComplete(e.state.doc.toString()).then((t=>{t?this.finishEditing(!0,this.editor.state.doc.toString()):n.insertNewlineAndIndent(e)})),!0),f=[{key:"ArrowUp",run:()=>this.#t.moveHistory(-1)},{key:"ArrowDown",run:()=>this.#t.moveHistory(1)},{mac:"Ctrl-p",run:()=>this.#t.moveHistory(-1,!0)},{mac:"Ctrl-n",run:()=>this.#t.moveHistory(1,!0)},{key:"Mod-Enter",run:b},{key:"Enter",run:b},{key:"Shift-Enter",run:n.insertNewlineAndIndent},{key:"Escape",run:()=>(this.finishEditing(!1,""),!0)}];this.placeholderCompartment=new n.Compartment;const S=this.contentElement.appendChild(document.createElement("div"));S.classList.add("condition-editor"),S.setAttribute("jslog",`${a.textField()}`),this.editor=new s.TextEditor.TextEditor(n.EditorState.create({doc:m,selection:{anchor:0,head:m.length},extensions:[this.placeholderCompartment.of(this.getPlaceholder()),n.keymap.of(f),d]})),S.appendChild(this.editor);const v=new r.Icon.Icon;v.name="cross",v.title=q(_.closeDialog),v.setAttribute("jslog",`${a.close().track({click:!0})}`),v.onclick=()=>this.finishEditing(!0,this.editor.state.doc.toString()),u.appendChild(v),this.#e=new s.AutocompleteHistory.AutocompleteHistory(i.Settings.Settings.instance().createLocalSetting("breakpoint-condition-history",[])),this.#t=new s.TextEditorHistory.TextEditorHistory(this.editor,this.#e);const C=this.contentElement.appendChild(document.createElement("div"));C.classList.add("link-wrapper");const w=t.Fragment.html`${q(_.learnMoreOnBreakpointTypes)}`,I=new r.Icon.Icon;I.name="open-externally",I.classList.add("link-icon"),w.prepend(I),C.appendChild(w),this.updateTooltip()}saveAndFinish(){this.finishEditing(!0,this.editor.state.doc.toString())}focusEditor(){this.editor.editor.focus()}onTypeChanged(){"REGULAR_BREAKPOINT"!==this.breakpointType?(this.focusEditor(),this.editor.dispatch({effects:this.placeholderCompartment.reconfigure(this.getPlaceholder())}),this.updateTooltip()):this.finishEditing(!0,"")}get breakpointType(){const e=this.typeSelector.selectedOption();return e?e.value:null}getPlaceholder(){const e=this.breakpointType;return"CONDITIONAL_BREAKPOINT"===e?n.placeholder(q(_.expressionToCheckBeforePausingEg)):"LOGPOINT"===e?n.placeholder(q(_.logMessageEgXIsX)):[]}updateTooltip(){const e=this.breakpointType;"CONDITIONAL_BREAKPOINT"===e?t.Tooltip.Tooltip.install(this.typeSelector.element,q(_.pauseOnlyWhenTheConditionIsTrue)):"LOGPOINT"===e&&t.Tooltip.Tooltip.install(this.typeSelector.element,q(_.logAMessageToConsoleDoNotBreak))}finishEditing(e,t){if(this.finished)return;this.finished=!0,this.editor.remove(),this.#e.pushHistoryItem(t);const i="LOGPOINT"===this.breakpointType;this.onFinish({committed:e,condition:t,isLogpoint:i})}wasShown(){super.wasShown(),this.registerCSSFiles([O])}get editorForTest(){return this.editor}}var G=Object.freeze({__proto__:null,BreakpointEditDialog:$});const K=new CSSStyleSheet;K.replaceSync('.call-frame-warnings-message{text-align:center;font-style:italic;padding:4px;color:var(--sys-color-on-surface-yellow);background-color:var(--sys-color-surface-yellow)}.ignore-listed-message{padding:1px}.ignore-listed-message-label{color:var(--sys-color-token-subtle);align-items:center;display:flex}.show-more-message > .link{margin-left:5px}.show-more-message{text-align:center;font-style:italic;padding:4px;border-top:1px solid var(--sys-color-divider)}.call-frame-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.call-frame-title-text{text-overflow:ellipsis;overflow:hidden}.async-header + .call-frame-item{border-top:0}.call-frame-item:not(.async-header){border-top:1px solid var(--sys-color-divider)}.call-frame-item-title,\n.call-frame-location{display:flex;white-space:nowrap}.async-header .call-frame-item-title{font-weight:bold;color:var(--sys-color-on-surface);background-color:var(--sys-color-cdt-base-container);margin-left:-5px;padding:0 5px;z-index:1}.call-frame-item:focus-visible,\n.call-frame-item.async-header:focus-visible .call-frame-item-title{background-color:var(--sys-color-tonal-container)}.ignore-listed-checkbox:focus-visible{outline-width:unset}.call-frame-item:not(.async-header):hover{background-color:var(--sys-color-state-hover-on-subtle)}.call-frame-location{color:var(--sys-color-token-subtle);margin-left:auto;padding:0 10px}.async-header::before{content:" ";width:100%;border-top:1px solid var(--sys-color-divider);margin-top:8px;position:absolute;left:0}.ignore-listed-call-frame{opacity:60%;font-style:italic}.selected-call-frame-icon{display:none;position:absolute;top:3px;left:4px}.call-frame-item.selected .selected-call-frame-icon{display:block}.call-frame-warning-icon{display:block;position:absolute;top:3px;right:4px}@media (forced-colors: active){.call-frame-item:focus-visible,\n .call-frame-item:not(.async-header):hover{forced-color-adjust:none;background-color:Highlight}.call-frame-item:focus-visible *,\n .call-frame-item:not(.async-header):hover *{color:HighlightText}}\n/*# sourceURL=callStackSidebarPane.css */\n');const J={callStack:"Call Stack",notPaused:"Not paused",onIgnoreList:"on ignore list",showIgnorelistedFrames:"Show ignore-listed frames",showMore:"Show more",copyStackTrace:"Copy stack trace",callFrameWarnings:"Some call frames have warnings",debugFileNotFound:'Failed to load debug file "{PH1}".',restartFrame:"Restart frame"},X=e.i18n.registerUIStrings("panels/sources/CallStackSidebarPane.ts",J),Y=e.i18n.getLocalizedString.bind(void 0,X);let Q;class Z extends t.View.SimpleView{ignoreListMessageElement;ignoreListCheckboxElement;notPausedMessageElement;callFrameWarningsElement;items;list;showMoreMessageElement;showIgnoreListed;locationPool;updateThrottler;maxAsyncStackChainDepth;updateItemThrottler;scheduledForUpdateItems;muteActivateItem;lastDebuggerModel=null;constructor(){super(Y(J.callStack),!0,"sources.callstack"),this.contentElement.setAttribute("jslog",`${a.section("sources.callstack")}`),({element:this.ignoreListMessageElement,checkbox:this.ignoreListCheckboxElement}=this.createIgnoreListMessageElementAndCheckbox()),this.contentElement.appendChild(this.ignoreListMessageElement),this.notPausedMessageElement=this.contentElement.createChild("div","gray-info-message"),this.notPausedMessageElement.textContent=Y(J.notPaused),this.notPausedMessageElement.tabIndex=-1,this.callFrameWarningsElement=this.contentElement.createChild("div","call-frame-warnings-message");const e=new r.Icon.Icon;e.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},e.classList.add("call-frame-warning-icon"),this.callFrameWarningsElement.appendChild(e),this.callFrameWarningsElement.appendChild(document.createTextNode(Y(J.callFrameWarnings))),this.callFrameWarningsElement.tabIndex=-1,this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport),this.contentElement.appendChild(this.list.element),this.list.element.addEventListener("contextmenu",this.onContextMenu.bind(this),!1),self.onInvokeElement(this.list.element,(e=>{const t=this.list.itemForNode(e.target);t&&(this.activateItem(t),e.consume(!0))})),this.showMoreMessageElement=this.createShowMoreMessageElement(),this.showMoreMessageElement.classList.add("hidden"),this.contentElement.appendChild(this.showMoreMessageElement),this.showIgnoreListed=!1,this.locationPool=new u.LiveLocation.LiveLocationPool,this.updateThrottler=new i.Throttler.Throttler(100),this.maxAsyncStackChainDepth=ie,this.update(),this.updateItemThrottler=new i.Throttler.Throttler(100),this.scheduledForUpdateItems=new Set,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this)}static instance(e={forceNew:null}){const{forceNew:t}=e;return Q&&!t||(Q=new Z),Q}flavorChanged(e){this.showIgnoreListed=!1,this.ignoreListCheckboxElement.checked=!1,this.maxAsyncStackChainDepth=ie,this.update()}debugInfoAttached(){this.update()}setSourceMapSubscription(e){this.lastDebuggerModel!==e&&(this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this),this.lastDebuggerModel=e,this.lastDebuggerModel&&this.lastDebuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.debugInfoAttached,this))}update(){this.updateThrottler.schedule((()=>this.doUpdate()))}async doUpdate(){this.locationPool.disposeAll(),this.callFrameWarningsElement.classList.add("hidden");const e=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.setSourceMapSubscription(e?.debuggerModel??null),!e)return this.notPausedMessageElement.classList.remove("hidden"),this.ignoreListMessageElement.classList.add("hidden"),this.showMoreMessageElement.classList.add("hidden"),this.items.replaceAll([]),void t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,null);this.notPausedMessageElement.classList.add("hidden");const i=[],n=new Set;for(const t of e.callFrames){const e=oe.createForDebuggerCallFrame(t,this.locationPool,this.refreshItem.bind(this)).then((e=>(ee.set(e,t),e)));i.push(e),t.missingDebugInfoDetails&&n.add(t.missingDebugInfoDetails.details)}const r=await Promise.all(i);n.size&&(this.callFrameWarningsElement.classList.remove("hidden"),t.Tooltip.Tooltip.install(this.callFrameWarningsElement,Array.from(n).join("\n")));let s=e.debuggerModel,a=e.asyncStackTraceId,c=e.asyncStackTrace,l=e.callFrames;for(let{maxAsyncStackChainDepth:e}=this;e>0;--e){if(!c){if(!a)break;if(a.debuggerId){const e=await o.DebuggerModel.DebuggerModel.modelForDebuggerId(a.debuggerId);if(!e)break;s=e}if(c=await s.fetchAsyncStackTrace(a),!c)break}const e=t.UIUtils.asyncStackTraceLabel(c.description,l);r.push(...await oe.createItemsForAsyncStack(e,s,c.callFrames,this.locationPool,this.refreshItem.bind(this))),l=c.callFrames,a=c.parentId,c=c.parent}this.showMoreMessageElement.classList.toggle("hidden",!c),this.items.replaceAll(r);for(const e of this.items)this.refreshItem(e);if(this.maxAsyncStackChainDepth===ie){this.list.selectNextItem(!0,!1);const e=this.list.selectedItem();e&&this.activateItem(e)}this.updatedForTest()}updatedForTest(){}refreshItem(e){this.scheduledForUpdateItems.add(e),this.updateItemThrottler.schedule((async()=>{const e=Array.from(this.scheduledForUpdateItems);if(this.scheduledForUpdateItems.clear(),this.muteActivateItem=!0,!this.showIgnoreListed&&this.items.every((e=>e.isIgnoreListed))){this.showIgnoreListed=!0;for(let e=0;eY(J.debugFileNotFound,{PH1:e})));t.Tooltip.Tooltip.install(e,[s.missingDebugInfoDetails.details,...o].join("\n")),i.appendChild(e)}return i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1),o&&(this.setDefaultFocusedElement(o),o.tabIndex=0,this.hasFocus()&&o.focus())}updateSelectedItemARIA(e,t){return!0}createIgnoreListMessageElementAndCheckbox(){const e=document.createElement("div");e.classList.add("ignore-listed-message");const t=e.createChild("label");t.classList.add("ignore-listed-message-label");const i=t.createChild("input");i.tabIndex=0,i.type="checkbox",i.classList.add("ignore-listed-checkbox"),t.append(Y(J.showIgnorelistedFrames));return i.addEventListener("click",(()=>{this.showIgnoreListed=i.checked;for(const e of this.items)this.refreshItem(e)})),{element:e,checkbox:i}}createShowMoreMessageElement(){const e=document.createElement("div");e.classList.add("show-more-message"),e.createChild("span");const t=e.createChild("span","link");return t.textContent=Y(J.showMore),t.addEventListener("click",(()=>{this.maxAsyncStackChainDepth+=ie,this.update()}),!1),e}onContextMenu(e){const i=this.list.itemForNode(e.target);if(!i)return;const o=new t.ContextMenu.ContextMenu(e),n=ee.get(i);n&&o.defaultSection().appendItem(Y(J.restartFrame),(()=>{c.userMetrics.actionTaken(c.UserMetrics.Action.StackFrameRestarted),n.restart()}),{disabled:!n.canBeRestarted,jslogContext:"restart-frame"}),o.defaultSection().appendItem(Y(J.copyStackTrace),this.copyStackTrace.bind(this),{jslogContext:"copy-stack-trace"}),i.uiLocation&&this.appendIgnoreListURLContextMenuItems(o,i.uiLocation.uiSourceCode),o.show()}onClick(e){const t=this.list.itemForNode(e.target);t&&this.activateItem(t)}activateItem(e){const n=e.uiLocation;if(this.muteActivateItem||!n)return;this.list.selectItem(e);const r=ee.get(e),s=this.activeCallFrameItem();r&&s!==e?(r.debuggerModel.setSelectedCallFrame(r),t.Context.Context.instance().setFlavor(o.DebuggerModel.CallFrame,r),s&&this.refreshItem(s),this.refreshItem(e)):i.Revealer.reveal(n)}activeCallFrameItem(){const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);return e&&this.items.find((t=>ee.get(t)===e))||null}appendIgnoreListURLContextMenuItems(e,t){const i=h.Persistence.PersistenceImpl.instance().binding(t);i&&(t=i.network);const o=e.section("ignoreList");if(!(o.items.length>0))for(const{text:e,callback:i,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListURLContextMenuItems(t))o.appendItem(e,i,{jslogContext:n})}selectNextCallFrameOnStack(){const e=this.activeCallFrameItem();for(let t=e?this.items.indexOf(e)+1:0;t=0;t--){const e=this.items.at(t);if(ee.has(e)){this.activateItem(e);break}}}copyStackTrace(){const e=[];for(const t of this.items){let i=t.title;t.uiLocation&&(i+=" ("+t.uiLocation.linkText(!0)+")"),e.push(i)}c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(e.join("\n"))}wasShown(){super.wasShown(),this.registerCSSFiles([K])}}const ee=new WeakMap,te=Symbol("element"),ie=32;class oe{isIgnoreListed;title;linkText;uiLocation;isAsyncHeader;updateDelegate;static async createForDebuggerCallFrame(e,i,o){const n=e.functionName,r=new oe(t.UIUtils.beautifyFunctionName(n),o);return await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),r.update.bind(r),i),p.NamesResolver.resolveDebuggerFrameFunctionName(e).then((e=>{e&&e!==n&&(r.title=e,r.updateDelegate(r))})),r}static async createItemsForAsyncStack(e,i,o,n,r){const s=new WeakMap,a=new oe(e,r);s.set(a,new Set),a.isAsyncHeader=!0;const c=[],l=[];for(const e of o){const o=new oe(t.UIUtils.beautifyFunctionName(e.functionName),d),r=i.createRawLocationByScriptId(e.scriptId,e.lineNumber,e.columnNumber);l.push(u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(r,o.update.bind(o),n)),c.push(o)}return await Promise.all(l),r(a),[a,...c];function d(e){r(e);let t=!1;const i=s.get(a);i&&(e.isIgnoreListed?(i.delete(e),t=0===i.size):(t=0===i.size,i.add(e)),a.isIgnoreListed=0===i.size),t&&r(a)}}constructor(e,t){this.isIgnoreListed=!1,this.title=e,this.linkText="",this.uiLocation=null,this.isAsyncHeader=!1,this.updateDelegate=t}async update(e){const t=await e.uiLocation();this.isIgnoreListed=await e.isIgnoreListed(),this.linkText=t?t.linkText():"",this.uiLocation=t,this.updateDelegate(this)}}var ne=Object.freeze({__proto__:null,CallStackSidebarPane:Z,elementSymbol:te,defaultMaxAsyncStackChainDepth:ie,ActionDelegate:class{handleAction(e,t){switch(t){case"debugger.next-call-frame":return Z.instance().selectNextCallFrameOnStack(),!0;case"debugger.previous-call-frame":return Z.instance().selectPreviousCallFrameOnStack(),!0}return!1}},Item:oe});const re={beforeBidderWorkletBiddingStart:"Bidder Bidding Phase Start",beforeBidderWorkletReportingStart:"Bidder Reporting Phase Start",beforeSellerWorkletScoringStart:"Seller Scoring Phase Start",beforeSellerWorkletReportingStart:"Seller Reporting Phase Start",setTimeoutOrIntervalFired:"{PH1} fired",scriptFirstStatement:"Script First Statement",scriptBlockedByContentSecurity:"Script Blocked by Content Security Policy",requestAnimationFrame:"Request Animation Frame",cancelAnimationFrame:"Cancel Animation Frame",animationFrameFired:"Animation Frame Fired",webglErrorFired:"WebGL Error Fired",webglWarningFired:"WebGL Warning Fired",setInnerhtml:"Set `innerHTML`",createCanvasContext:"Create canvas context",createAudiocontext:"Create `AudioContext`",closeAudiocontext:"Close `AudioContext`",resumeAudiocontext:"Resume `AudioContext`",suspendAudiocontext:"Suspend `AudioContext`",sinkViolations:"Sink Violations",policyViolations:"Policy Violations"},se=e.i18n.registerUIStrings("panels/sources/CategorizedBreakpointL10n.ts",re),ae=e.i18n.getLazilyComputedLocalizedString.bind(void 0,se);function ce(t){return(ue.get(t)??e.i18n.lockedLazyString(t))()}const le={beforeBidderWorkletBiddingStart:ae(re.beforeBidderWorkletBiddingStart),beforeBidderWorkletReportingStart:ae(re.beforeBidderWorkletReportingStart),beforeSellerWorkletScoringStart:ae(re.beforeSellerWorkletScoringStart),beforeSellerWorkletReportingStart:ae(re.beforeSellerWorkletReportingStart),setTimeout:e.i18n.lockedLazyString("setTimeout"),clearTimeout:e.i18n.lockedLazyString("clearTimeout"),setInterval:e.i18n.lockedLazyString("setInterval"),clearInterval:e.i18n.lockedLazyString("clearInterval"),"setTimeout.callback":ae(re.setTimeoutOrIntervalFired,{PH1:"setTimeout"}),"setInterval.callback":ae(re.setTimeoutOrIntervalFired,{PH1:"setInterval"}),scriptFirstStatement:ae(re.scriptFirstStatement),scriptBlockedByCSP:ae(re.scriptBlockedByContentSecurity),sharedStorageWorkletScriptFirstStatement:ae(re.scriptFirstStatement),requestAnimationFrame:ae(re.requestAnimationFrame),cancelAnimationFrame:ae(re.cancelAnimationFrame),"requestAnimationFrame.callback":ae(re.animationFrameFired),webglErrorFired:ae(re.webglErrorFired),webglWarningFired:ae(re.webglWarningFired),"Element.setInnerHTML":ae(re.setInnerhtml),canvasContextCreated:ae(re.createCanvasContext),"Geolocation.getCurrentPosition":e.i18n.lockedLazyString("getCurrentPosition"),"Geolocation.watchPosition":e.i18n.lockedLazyString("watchPosition"),"Notification.requestPermission":e.i18n.lockedLazyString("requestPermission"),"DOMWindow.close":e.i18n.lockedLazyString("window.close"),"Document.write":e.i18n.lockedLazyString("document.write"),audioContextCreated:ae(re.createAudiocontext),audioContextClosed:ae(re.closeAudiocontext),audioContextResumed:ae(re.resumeAudiocontext),audioContextSuspended:ae(re.suspendAudiocontext)},de={"trustedtype-policy-violation":ae(re.policyViolations),"trustedtype-sink-violation":ae(re.sinkViolations)},ue=new Map([...Object.entries(le),...Object.entries(de)]);var he=Object.freeze({__proto__:null,getLocalizedBreakpointName:ce});class pe{uiSourceCode;constructor(e,t){this.uiSourceCode=e}static accepts(e){return!1}willHide(){}rightToolbarItems(){return[]}leftToolbarItems(){return[]}populateLineGutterContextMenu(e,t){}populateTextAreaContextMenu(e,t,i){}decorationChanged(e,t){}editorExtension(){return[]}editorInitialized(e){}dispose(){}}var ge=Object.freeze({__proto__:null,Plugin:pe});const me={clickToShowCoveragePanel:"Click to show Coverage Panel",showDetails:"Show Details",coverageS:"Coverage: {PH1}",coverageNa:"Coverage: n/a"},be=e.i18n.registerUIStrings("panels/sources/CoveragePlugin.ts",me),fe=e.i18n.getLocalizedString.bind(void 0,be);class Se extends pe{originalSourceCode;infoInToolbar;model;coverage;#i;constructor(e,i){super(e),this.originalSourceCode=this.uiSourceCode,this.#i=i,this.infoInToolbar=new t.Toolbar.ToolbarButton(fe(me.clickToShowCoveragePanel),void 0,void 0,"debugger.show-coverage"),this.infoInToolbar.setSecondary(),this.infoInToolbar.addEventListener("Click",(()=>{t.ViewManager.ViewManager.instance().showView("coverage")}));const n=o.TargetManager.TargetManager.instance().primaryPageTarget();n&&(this.model=n.model(b.CoverageModel.CoverageModel),this.model&&(this.model.addEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this),this.coverage=this.model.getCoverageForUrl(this.originalSourceCode.url()),this.coverage&&this.coverage.addEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this))),this.updateStats()}dispose(){this.coverage&&this.coverage.removeEventListener(b.CoverageModel.URLCoverageInfo.Events.SizesChanged,this.handleCoverageSizesChanged,this),this.model&&this.model.removeEventListener(b.CoverageModel.Events.CoverageReset,this.handleReset,this)}static accepts(e){return e.contentType().isDocumentOrScriptOrStyleSheet()}handleReset(){this.coverage=null,this.updateStats()}handleCoverageSizesChanged(){this.updateStats()}updateStats(){if(this.coverage){this.infoInToolbar.setTitle(fe(me.showDetails));const t=new Intl.NumberFormat(e.DevToolsLocale.DevToolsLocale.instance().locale,{style:"percent",maximumFractionDigits:1});this.infoInToolbar.setText(fe(me.coverageS,{PH1:t.format(this.coverage.usedPercentage())}))}else this.infoInToolbar.setTitle(fe(me.clickToShowCoveragePanel)),this.infoInToolbar.setText(fe(me.coverageNa))}rightToolbarItems(){return[this.infoInToolbar]}editorExtension(){return xe.of([])}getCoverageManager(){return this.uiSourceCode.getDecorationData("coverage")}editorInitialized(e){this.getCoverageManager()&&this.startDecoUpdate(e)}decorationChanged(e,t){"coverage"===e&&this.startDecoUpdate(t)}startDecoUpdate(e){const i=this.getCoverageManager();(i?i.usageByLine(this.uiSourceCode,this.#o(e)):Promise.resolve([])).then((i=>{const o=Boolean(e.state.field(ye,!1));var r;i.length?o?e.dispatch({effects:Ie.of(i)}):e.dispatch({effects:xe.reconfigure([ye.init((e=>we(i,e))),(r=this.uiSourceCode.url(),n.gutter({markers:e=>e.state.field(ye),domEventHandlers:{click:()=>(t.ViewManager.ViewManager.instance().showView("coverage").then((()=>{const e=t.ViewManager.ViewManager.instance().view("coverage");return e&&e.widget()})).then((e=>{const t=r.match(/(.*):formatted$/),i=t&&t[1]||r;e.selectCoverageItemByUrl(i)})),!0)},class:"cm-coverageGutter"})),ke])}):o&&e.dispatch({effects:xe.reconfigure([])})}))}#o(e){const t=[];for(let i=1;i<=e.state.doc.lines;++i){const o=e.state.doc.line(i),{lineNumber:n,columnNumber:r}=this.#i.editorLocationToUILocation(i-1,0),{lineNumber:s,columnNumber:a}=this.#i.editorLocationToUILocation(i-1,o.length);t.push(new g.TextRange.TextRange(n,r,s,a))}return t}}const ve=new class extends n.GutterMarker{elementClass="cm-coverageUsed"},Ce=new class extends n.GutterMarker{elementClass="cm-coverageUnused"};function we(e,t){const i=new n.RangeSetBuilder;for(let o=0;on.RangeSet.empty,update:(e,t)=>t.effects.reduce(((e,i)=>i.is(Ie)?we(i.value,t.state):e),e.map(t.changes))});const xe=new n.Compartment,ke=n.EditorView.baseTheme({".cm-coverageGutter":{width:"5px",marginLeft:"3px"},".cm-coverageUnused":{backgroundColor:"var(--app-color-coverage-unused)"},".cm-coverageUsed":{backgroundColor:"var(--app-color-coverage-used)"}});var Te=Object.freeze({__proto__:null,CoveragePlugin:Se});const Ee={openColorPicker:"Open color picker.",openCubicBezierEditor:"Open cubic bezier editor.",addSourceMap:"Add source map…"},Le=e.i18n.registerUIStrings("panels/sources/CSSPlugin.ts",Ee),Me=e.i18n.getLocalizedString.bind(void 0,Le),Pe=new Set(["ColorLiteral","NumberLiteral","StringLiteral","Comment","Important"]);async function Fe(e,t,i){const r=n.syntaxTree(e.state).resolveInner(e.pos,-1);if("ClassName"===r.name){d(i);const e=function(e,t){const i=t.getStyleSheetIdsForURL(e);if(0===i.length)throw new Error("Can't find style sheet ID for current URL");return i[0]}(t.url(),i),o=await i.getClassNames(e);return{from:r.from,options:o.map((e=>({type:"constant",label:e})))}}const s=function(e,t){if(Pe.has(e.name))return null;for(let i=e;i&&"StyleSheet"!==i.name&&"Styles"!==i.name&&"CallExpression"!==i.name;i=i.parent)if("Declaration"===i.name){const e=i.getChild("PropertyName"),o=i.getChild(":");return e&&o&&o.to<=t?e:null}return null}(r,e.pos);if(s){const t=o.CSSMetadata.cssMetadata().getPropertyValues(e.state.sliceDoc(s.from,s.to));return{from:"ValueName"===r.name?r.from:e.pos,options:t.map((e=>({type:"constant",label:e}))),validFor:/^[\w\P{ASCII}\-]+$/u}}return null}class De extends n.WidgetType{#n;#r;#s;constructor(e,t,i){super(),this.#r=e,this.#n=t,this.#s=i}eq(e){return this.#r.equal(e.#r)&&this.#n===e.#n&&this.#s===e.#s}toDOM(e){const t=new v.ColorSwatch.ColorSwatch;t.renderColor(this.#r,!1,Me(Ee.openColorPicker));const i=t.createChild("span");return i.textContent=this.#n,i.setAttribute("hidden","true"),t.addEventListener(v.ColorSwatch.ColorChangedEvent.eventName,(i=>{e.dispatch({changes:{from:this.#s,to:this.#s+this.#n.length,insert:i.data.text}}),this.#n=i.data.text,this.#r=t.getColor()})),t.addEventListener(v.ColorSwatch.ClickEvent.eventName,(i=>{i.consume(!0),e.dispatch({effects:Ae.of({type:0,pos:e.posAtDOM(t),text:this.#n,swatch:t,color:this.#r})})})),t}ignoreEvent(){return!0}}class Ne extends n.WidgetType{curve;text;constructor(e,t){super(),this.curve=e,this.text=t}eq(e){return this.curve.asCSSText()===e.curve.asCSSText()&&this.text===e.text}toDOM(e){const i=v.Swatches.BezierSwatch.create();return i.setBezierText(this.text),t.Tooltip.Tooltip.install(i.iconElement(),Me(Ee.openCubicBezierEditor)),i.iconElement().addEventListener("click",(t=>{t.consume(!0),e.dispatch({effects:Ae.of({type:1,pos:e.posAtDOM(i),text:this.text,swatch:i,curve:this.curve})})}),!1),i.hideText(!0),i}ignoreEvent(){return!0}}const Ae=n.StateEffect.define(),Ue=n.Annotation.define(),Re=n.StateField.define({create:()=>null,update(e,t){!t.docChanged&&!t.selection||t.annotation(Ue)||(e=null);for(const i of t.effects)i.is(Ae)&&(e=i.value);return e},provide:e=>n.showTooltip.from(e,(e=>e&&function(e){return{pos:e.pos,arrow:!0,create(t){let i,o,n=e.text;if(0===e.type){const n=new S.Spectrum.Spectrum;o=e=>{n.addEventListener("ColorChanged",e)},n.addEventListener("SizeChanged",(()=>t.requestMeasure())),n.setColor(e.color,e.color.format()),i=n,c.userMetrics.colorPickerOpenedFrom(0)}else{const t=new v.BezierEditor.BezierEditor(e.curve);i=t,o=e=>{t.addEventListener("BezierChanged",e)}}const r=document.createElement("div");return r.className="cm-tooltip-swatchEdit",i.markAsRoot(),i.show(r),i.showWidget(),i.element.addEventListener("keydown",(o=>{"Escape"===o.key&&(o.consume(),t.dispatch({effects:Ae.of(null),changes:n===e.text?void 0:{from:e.pos,to:e.pos+n.length,insert:e.text}}),i.hideWidget(),t.focus())})),i.element.addEventListener("focusout",(e=>{e.relatedTarget&&!i.element.contains(e.relatedTarget)&&(t.dispatch({effects:Ae.of(null)}),i.hideWidget())}),!1),i.element.addEventListener("mousedown",(e=>e.consume())),{dom:r,resize:!1,offset:{x:-8,y:0},mount:()=>{i.focus(),i.wasShown(),o((i=>{t.dispatch({changes:{from:e.pos,to:e.pos+n.length,insert:i.data},annotations:Ue.of(!0)}),n=i.data}))}}}}}(e)))});function Be(e,o,r){const s=new n.RangeSetBuilder;return function(e,o,r,s,a){let c=e.doc.lineAt(o);function l(t,i){return t>=c.to&&(c=e.doc.lineAt(t)),c.text.slice(t-c.from,i-c.from)}const d=n.ensureSyntaxTree(e,r,100);d&&d.iterate({from:o,to:r,enter:o=>{let n;if("ValueName"===o.name||"ColorLiteral"===o.name?n=l(o.from,o.to):"Callee"===o.name&&/^(?:(?:rgba?|hsla?|hwba?|lch|oklch|lab|oklab|color)|cubic-bezier)$/.test(l(o.from,o.to))&&(n=e.sliceDoc(o.from,o.node.parent.to)),n){const e=i.Color.parse(n);if(e)s(o.from,e,n);else{const e=t.Geometry.CubicBezier.parse(n);e&&a(o.from,e,n)}}}})}(e,o,r,((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new De(t,i,e)}))}),((e,t,i)=>{s.add(e,e,n.Decoration.widget({widget:new Ne(t,i)}))})),s.finish()}const je=n.ViewPlugin.fromClass(class{decorations;constructor(e){this.decorations=Be(e.state,e.viewport.from,e.viewport.to)}update(e){(e.viewportChanged||e.docChanged)&&(this.decorations=Be(e.state,e.view.viewport.from,e.view.viewport.to))}},{decorations:e=>e.decorations});function Ve(e){if("Unit"===e.name&&(e=e.parent),"NumberLiteral"===e.name){const t=e.lastChild;return{from:e.from,to:t&&"Unit"===t.name?t.from:e.to}}return null}function We(e,t){const{head:i}=e.state.selection.main,o=n.syntaxTree(e.state).resolveInner(i,-1),r=Ve(o)||Ve(o.resolve(i,1));if(!r)return!1;const s=Number(e.state.sliceDoc(r.from,r.to));return!isNaN(s)&&(e.dispatch({changes:{from:r.from,to:r.to,insert:String(s+t)},scrollIntoView:!0,userEvent:"insert.modifyUnit"}),!0)}function Oe(){let e=null;const i=t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"sources.increment-css":()=>Promise.resolve(We(e,1)),"sources.increment-css-by-ten":()=>Promise.resolve(We(e,10)),"sources.decrement-css":()=>Promise.resolve(We(e,-1)),"sources.decrement-css-by-ten":()=>Promise.resolve(We(e,-10))});return n.EditorView.domEventHandlers({keydown:(t,o)=>{const n=e;return e=o,i(t),e=n,t.defaultPrevented}})}class He extends pe{#a;constructor(e,t){super(e,t),o.TargetManager.TargetManager.instance().observeModels(o.CSSModel.CSSModel,this)}static accepts(e){return e.contentType().hasStyleSheets()}modelAdded(e){e.target()===o.TargetManager.TargetManager.instance().primaryPageTarget()&&(this.#a=e)}modelRemoved(e){this.#a===e&&(this.#a=void 0)}editorExtension(){return[Oe(),this.#c(),[je,Re]]}#c(){const{cssCompletionSource:e}=n.css,t=this.uiSourceCode,i=this.#a;return n.autocompletion({override:[async o=>await Fe(o,t,i)||e(o)]})}populateTextAreaContextMenu(e){const t=this.#a,i=this.uiSourceCode.url();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&t&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(i)){const o=Me(Ee.addSourceMap);e.debugSection().appendItem(o,(()=>function(e,t){V.createAddSourceMapURLDialog((i=>{u.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().modelToInfo.get(e)?.addSourceMap(t,i)})).show()}(t,i)),{jslogContext:"add-source-map"})}}}var _e=Object.freeze({__proto__:null,cssBindings:Oe,CSSPlugin:He});const ze=new CSSStyleSheet;ze.replaceSync(".paused-status{margin:6px;padding:4px 10px;border-radius:10px;background-color:var(--sys-color-yellow-container);color:var(--sys-color-on-yellow-container)}.paused-status.error-reason{background-color:var(--sys-color-surface-error);color:var(--sys-color-on-surface-error)}.status-main{padding-left:18px;position:relative}.status-sub:not(:empty){padding-left:15px;padding-top:5px;overflow:hidden;text-overflow:ellipsis}.paused-status.error-reason .status-sub{color:var(--sys-color-error);line-height:11px;max-height:27px;user-select:text}devtools-icon{position:absolute;left:-1px;top:-1px}\n/*# sourceURL=debuggerPausedMessage.css */\n");const qe={pausedOnS:"Paused on {PH1}",childSAdded:"Child {PH1} added",descendantSAdded:"Descendant {PH1} added",descendantSRemoved:"Descendant {PH1} removed",pausedOnEventListener:"Paused on event listener",pausedOnXhrOrFetch:"Paused on XHR or fetch",pausedOnException:"Paused on exception",pausedOnPromiseRejection:"Paused on `promise` rejection",pausedOnAssertion:"Paused on assertion",pausedOnDebuggedFunction:"Paused on debugged function",pausedBeforePotentialOutofmemory:"Paused before potential out-of-memory crash",pausedOnCspViolation:"Paused on CSP violation",trustedTypeSinkViolation:"`Trusted Type` Sink Violation",trustedTypePolicyViolation:"`Trusted Type` Policy Violation",pausedOnBreakpoint:"Paused on breakpoint",debuggerPaused:"Debugger paused",subtreeModifications:"subtree modifications",attributeModifications:"attribute modifications",nodeRemoval:"node removal",webglErrorFiredS:"WebGL Error Fired ({PH1})",scriptBlockedDueToContent:"Script blocked due to Content Security Policy directive: {PH1}"},$e=e.i18n.registerUIStrings("panels/sources/DebuggerPausedMessage.ts",qe),Ge=e.i18n.getLocalizedString.bind(void 0,$e),Ke=e.i18n.getLazilyComputedLocalizedString.bind(void 0,$e);class Je{elementInternal;contentElement;constructor(){this.elementInternal=document.createElement("div"),this.elementInternal.classList.add("paused-message"),this.elementInternal.classList.add("flex-none");const e=t.Utils.createShadowRootWithCoreStyles(this.elementInternal,{cssFile:[ze],delegatesFocus:void 0});this.contentElement=e.createChild("div"),t.ARIAUtils.markAsPoliteLiveRegion(this.elementInternal,!1)}element(){return this.elementInternal}static descriptionWithoutStack(e){const t=/^\s+at\s/m.exec(e);return t?e.substring(0,t.index-1):e.substring(0,e.lastIndexOf("\n"))}static async createDOMBreakpointHitMessage(t){const n=document.createElement("span"),s=t.debuggerModel.target().model(o.DOMDebuggerModel.DOMDebuggerModel);if(!t.auxData||!s)return n;const a=s.resolveDOMBreakpointData(t.auxData);if(!a)return n;const c=n.createChild("div","status-main"),l=new r.Icon.Icon;l.data={iconName:"info",color:"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},c.appendChild(l);const d=Xe.get(a.type);c.appendChild(document.createTextNode(Ge(qe.pausedOnS,{PH1:d?d():String(null)})));const u=n.createChild("div","status-sub monospace"),h=await i.Linkifier.Linkifier.linkify(a.node);if(u.appendChild(h),a.targetNode){const t=await i.Linkifier.Linkifier.linkify(a.targetNode);let o;o=a.insertion?a.targetNode===a.node?e.i18n.getFormatLocalizedString($e,qe.childSAdded,{PH1:t}):e.i18n.getFormatLocalizedString($e,qe.descendantSAdded,{PH1:t}):e.i18n.getFormatLocalizedString($e,qe.descendantSRemoved,{PH1:t}),u.appendChild(document.createElement("br")),u.appendChild(o)}return n}static#l(e){if(!e)return"";const{eventName:t,webglErrorName:i,directiveText:n,targetName:r}=e;if("instrumentation:webglErrorFired"===t&&i){const e=i.replace(/^.*(0x[0-9a-f]+).*$/i,"$1");return Ge(qe.webglErrorFiredS,{PH1:e})}if("instrumentation:scriptBlockedByCSP"===t&&n)return Ge(qe.scriptBlockedDueToContent,{PH1:n});let s=o.EventBreakpointsModel.EventBreakpointsManager.instance().resolveEventListenerBreakpoint(e);return s?ce(s.name):(s=o.DOMDebuggerModel.DOMDebuggerManager.instance().resolveEventListenerBreakpoint(e),s&&r?r+"."+s.name:s?.name??"")}async render(e,i,o){if(this.contentElement.removeChildren(),this.contentElement.hidden=!e,!e)return;const n=this.contentElement.createChild("div","paused-status"),s="exception"===e.reason||"promiseRejection"===e.reason||"assert"===e.reason||"OOM"===e.reason;let a;if("DOM"===e.reason)a=await Je.createDOMBreakpointHitMessage(e);else if("EventListener"===e.reason){const t=Je.#l(e.auxData);a=c(Ge(qe.pausedOnEventListener),t)}else if("XHR"===e.reason){const t=e.auxData;a=c(Ge(qe.pausedOnXhrOrFetch),t.url||"")}else if("exception"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Je.descriptionWithoutStack(i);a=c(Ge(qe.pausedOnException),o,i)}else if("promiseRejection"===e.reason){const t=e.auxData,i=t.description||t.value||"",o=Je.descriptionWithoutStack(i);a=c(Ge(qe.pausedOnPromiseRejection),o,i)}else if("assert"===e.reason)a=c(Ge(qe.pausedOnAssertion));else if("debugCommand"===e.reason)a=c(Ge(qe.pausedOnDebuggedFunction));else if("OOM"===e.reason)a=c(Ge(qe.pausedBeforePotentialOutofmemory));else if("CSPViolation"===e.reason&&e.auxData&&e.auxData.violationType){const t=e.auxData.violationType;"trustedtype-sink-violation"===t?a=c(Ge(qe.pausedOnCspViolation),Ge(qe.trustedTypeSinkViolation)):"trustedtype-policy-violation"===t&&(a=c(Ge(qe.pausedOnCspViolation),Ge(qe.trustedTypePolicyViolation)))}else if(e.callFrames.length){const t=await i.rawLocationToUILocation(e.callFrames[0].location()),n=t?o.findBreakpoint(t):null;a=c(Ge(n?qe.pausedOnBreakpoint:qe.debuggerPaused))}else console.warn("ScriptsPanel paused, but callFrames.length is zero.");function c(e,i,o){const n=document.createElement("span"),a=n.createChild("div","status-main"),c=new r.Icon.Icon;if(c.data={iconName:s?"cross-circle-filled":"info",color:s?"var(--icon-error)":"var(--sys-color-on-yellow-container)",width:"16px",height:"16px"},a.appendChild(c),a.appendChild(document.createTextNode(e)),i){const e=n.createChild("div","status-sub monospace");e.textContent=i,t.Tooltip.Tooltip.install(e,o||i)}return n}n.classList.toggle("error-reason",s),a&&n.appendChild(a)}}const Xe=new Map([["subtree-modified",Ke(qe.subtreeModifications)],["attribute-modified",Ke(qe.attributeModifications)],["node-removed",Ke(qe.nodeRemoval)]]);var Ye=Object.freeze({__proto__:null,DebuggerPausedMessage:Je,BreakpointTypeNouns:Xe});const Qe=new CSSStyleSheet;Qe.replaceSync(":host{overflow-y:auto}.icon,\n.icon-basic,\n.icon-badge{margin:-3px -5px}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n.navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection){filter:grayscale(50%);opacity:50%}.is-ignore-listed{opacity:50%}.tree-outline li{min-height:20px}.tree-outline li:hover:not(.selected) .selection{display:block;background-color:var(--sys-color-state-hover-on-subtle)}.navigator-fs-folder-tree-item devtools-icon{color:var(--icon-folder-workspace)}.navigator-fs-tree-item devtools-icon{color:var(--icon-file-authored)}.navigator-nw-folder-tree-item devtools-icon{color:var(--icon-folder-deployed)}.navigator-sm-script-tree-item devtools-icon,\n.navigator-script-tree-item devtools-icon,\n.navigator-snippet-tree-item devtools-icon{color:var(--icon-file-script)}.navigator-file-tree-item devtools-icon.dot::before{width:7px;height:7px;top:12px;left:11px}.navigator-file-tree-item:hover:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-hover)}.navigator-file-tree-item.selected:not(.force-white-icons) devtools-icon.dot::before{outline-color:var(--icon-gap-inactive)}.navigator-file-tree-item.selected.force-white-icons devtools-icon.dot::before{outline-color:var(--icon-gap-focus-selected)}.navigator-sm-stylesheet-tree-item devtools-icon,\n.navigator-stylesheet-tree-item devtools-icon{color:var(--icon-file-styles)}.navigator-image-tree-item devtools-icon,\n.navigator-font-tree-item devtools-icon{color:var(--icon-file-image)}.navigator-nw-folder-tree-item.is-from-source-map devtools-icon{color:var(--icon-folder-authored)}.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-folder-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-script-tree-item .tree-element-title,\n.tree-outline:not(:has(.navigator-deployed-tree-item)) .navigator-sm-stylesheet-tree-item .tree-element-title{font-style:italic}@media (forced-colors: active){.tree-outline li .leading-icons devtools-icon{color:ButtonText}.tree-outline li:hover:not(.selected) .selection{forced-color-adjust:none;background-color:Highlight}.tree-outline:not(.hide-selection-when-blurred) li.parent:hover:not(.selected)::before{background-color:HighlightText}.tree-outline:not(.hide-selection-when-blurred) li:hover:not(.selected) devtools-icon,\n .tree-outline li:not(.selected):hover .tree-element-title{forced-color-adjust:none;color:HighlightText}.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n .is-ignore-listed{filter:none;opacity:100%}}\n/*# sourceURL=navigatorTree.css */\n");const Ze=new CSSStyleSheet;Ze.replaceSync(".navigator-toolbar{border-bottom:1px solid var(--sys-color-divider);padding-left:8px}\n/*# sourceURL=navigatorView.css */\n");class et{searchId;searchResultCandidates;searchResultCallback;searchFinishedCallback;searchConfig;constructor(){this.searchId=0,this.searchResultCandidates=[],this.searchResultCallback=null,this.searchFinishedCallback=null,this.searchConfig=null}static filesComparator(e,t){if(e.isDirty()&&!t.isDirty())return-1;if(!e.isDirty()&&t.isDirty())return 1;const i=e.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(e);if(i!==(t.project().type()===f.Workspace.projectTypes.FileSystem&&!h.Persistence.PersistenceImpl.instance().binding(t)))return i?1:-1;const o=e.url(),n=t.url();return o&&!n?-1:!o&&n?1:l.StringUtilities.naturalOrderComparator(e.fullDisplayName(),t.fullDisplayName())}static urlComparator(e,t){return l.StringUtilities.naturalOrderComparator(e.url(),t.url())}performIndexing(e){this.stopSearch();const t=this.projects(),o=new i.Progress.CompositeProgress(e);for(let e=0;et.type()!==f.Workspace.projectTypes.Service&&(!(!e&&t.isServiceProject()&&t.type()!==f.Workspace.projectTypes.Formatter)&&!(!e&&t.type()===f.Workspace.projectTypes.ContentScripts))))}performSearch(e,t,o,n){this.stopSearch(),this.searchResultCandidates=[],this.searchResultCallback=o,this.searchFinishedCallback=n,this.searchConfig=e;const r=[],s=new i.Progress.CompositeProgress(t),a=s.createSubProgress(),c=new i.Progress.CompositeProgress(s.createSubProgress());for(const t of this.projects()){const i=[...t.uiSourceCodes()].length,o=c.createSubProgress(i),n=this.projectFilesMatchingFileQuery(t,e),s=t.findFilesMatchingSearchRequest(e,n,o).then(this.processMatchingFilesForProject.bind(this,this.searchId,t,e,n));r.push(s)}Promise.all(r).then(this.processMatchingFiles.bind(this,this.searchId,a,this.searchFinishedCallback.bind(this,!0)))}projectFilesMatchingFileQuery(e,t,i){const o=[];for(const n of e.uiSourceCodes()){if(!n.contentType().isTextType())continue;if(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(n))continue;const e=h.Persistence.PersistenceImpl.instance().binding(n);e&&e.network===n||(i&&!n.isDirty()||t.filePathMatchesFileQuery(n.fullDisplayName())&&o.push(n))}return o.sort(et.urlComparator),o}processMatchingFilesForProject(e,t,i,o,n){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);let r=[...n.keys()];r.sort(et.urlComparator),r=l.ArrayUtilities.intersectOrdered(r,o,et.urlComparator);const s=this.projectFilesMatchingFileQuery(t,i,!0);r=l.ArrayUtilities.mergeOrdered(r,s,et.urlComparator);const a=[];for(const e of r){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&!t.isAnonymousScript()||a.push(e)}a.sort(et.filesComparator),this.searchResultCandidates=l.ArrayUtilities.mergeOrdered(this.searchResultCandidates,a,et.filesComparator)}processMatchingFiles(e,t,i){if(e!==this.searchId&&this.searchFinishedCallback)return void this.searchFinishedCallback(!1);const o=this.searchResultCandidates;if(!o.length)return t.done(),void i();t.setTotalWork(o.length);let n=0;let r=0;for(let e=0;e<20&&e{c.call(this,e,t.content||"")}))}function a(){if(n>=o.length)return r?void 0:(t.done(),void i());++r;const e=o[n++];window.setTimeout(s.bind(this,e),0)}function c(e,i){t.incrementWorked(1);let o=[];const n=this.searchConfig,s=n.queries();if(null!==i){for(let e=0;ei.Revealer.reveal(n)),{jslogContext:t?"search-in-folder":"search-in-all-files"})}static treeElementsCompare(e,t){const i=ut.treeElementOrder(e),o=ut.treeElementOrder(t);return i>o?1:ie.frame()===i));o&&this.removeUISourceCodeNode(o)}acceptsUISourceCode(e){return this.acceptProject(e.project())}addUISourceCode(e){if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return;if(!this.acceptsUISourceCode(e))return;if(e.isFetchXHR())return;const t=u.NetworkProject.NetworkProject.framesForUISourceCode(e);if(t.length)for(const i of t)this.addUISourceCodeNode(e,i);else this.addUISourceCodeNode(e,null);this.uiSourceCodeAdded(e)}addUISourceCodeNode(e,t){const o=e.contentType().isFromSourceMap();let n;n=e.project().type()===f.Workspace.projectTypes.FileSystem?h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.relativePath(e).slice(0,-1):i.ParsedURL.ParsedURL.extractPath(e.url()).split("/").slice(1,-1);const r=e.project(),s=u.NetworkProject.NetworkProject.targetForUISourceCode(e),a=this.folderNode(e,r,s,t,e.origin(),n,o),c=new ft(this,e,t),l=a.child(c.id);l&&l instanceof ft?this.uiSourceCodeNodes.set(e,l):(a.appendChild(c),this.uiSourceCodeNodes.set(e,c),c.updateTitleBubbleUp()),this.selectDefaultTreeNode()}uiSourceCodeAdded(e){}uiSourceCodeAddedCallback(e){const t=e.data;this.addUISourceCode(t)}uiSourceCodeRemovedCallback(e){this.removeUISourceCodes([e.data])}tryAddProject(e){this.projectAdded(e);for(const t of e.uiSourceCodes())this.addUISourceCode(t)}projectAdded(e){const t=this.rootOrDeployedNode();!this.acceptProject(e)||e.type()!==f.Workspace.projectTypes.FileSystem||T.ScriptSnippetFileSystem.isSnippetsProject(e)||t.child(e.id())||(t.appendChild(new vt(this,e,e.id(),lt.FileSystem,e.displayName())),this.selectDefaultTreeNode())}selectDefaultTreeNode(){const e=this.rootNode.children();e.length&&!this.scriptsTree.selectedTreeElement&&e[0].treeNode().select(!0,!1)}computeUniqueFileSystemProjectNames(){const e=this.workspaceInternal.projectsForType(f.Workspace.projectTypes.FileSystem);if(!e.length)return;const t=i.Trie.Trie.newArrayTrie(),o=[];for(const i of e){const e=i.fileSystemPath().split("/").reverse();o.push(e),t.add(e)}const n=this.rootOrDeployedNode();for(let r=0;r{await this.removeUISourceCodeFromProject(e)})),e instanceof ft&&e.uiSourceCode().project().removeUISourceCode(e.uiSourceCode().url())}async deleteDirectoryRecursively(e){e instanceof St&&await(h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()?.deleteDirectoryRecursively(e.folderPath))}findTopNonMergedNode(e){return e.isMerged&&e.parent instanceof St?this.findTopNonMergedNode(e.parent):e}handleFolderContextMenu(e,o){const n=o.folderPath||l.DevToolsPath.EmptyEncodedPathString,r=o.project||null,s=new t.ContextMenu.ContextMenu(e);if(ut.appendSearchItem(s,n),r){if(r.type()===f.Workspace.projectTypes.FileSystem){const e=i.ParsedURL.ParsedURL.urlToRawPathString(h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.completeURL(r,n),c.Platform.isWin());s.revealSection().appendItem(ct(st.openFolder),(()=>c.InspectorFrontendHost.InspectorFrontendHostInstance.showItemInFolder(e)),{jslogContext:"open-folder"}),r.canCreateFile()&&s.defaultSection().appendItem(ct(st.newFile),(()=>{this.handleContextMenuCreate(r,n,void 0)}),{jslogContext:"new-file"})}else if(o.origin&&o.folderPath){const e=i.ParsedURL.ParsedURL.concatenate(o.origin,"/",o.folderPath),t={isContentScript:o.recursiveProperties.exclusivelyContentScripts||!1,isKnownThirdParty:o.recursiveProperties.exclusivelyThirdParty||!1,isCurrentlyIgnoreListed:o.recursiveProperties.exclusivelyIgnored||!1};for(const{text:i,callback:o,jslogContext:n}of u.IgnoreListManager.IgnoreListManager.instance().getIgnoreListFolderContextMenuItems(e,t))s.defaultSection().appendItem(i,o,{jslogContext:n})}if(r.canExcludeFolder(n)&&s.defaultSection().appendItem(ct(st.excludeFolder),this.handleContextMenuExclude.bind(this,r,n),{jslogContext:"exclude-folder"}),r.type()===f.Workspace.projectTypes.FileSystem){"overrides"===r.fileSystem().type()?o instanceof vt||s.defaultSection().appendItem(ct(st.delete),this.handleDeleteFolder.bind(this,o),{jslogContext:"delete"}):o instanceof vt&&s.defaultSection().appendItem(ct(st.removeFolderFromWorkspace),(async()=>{const e=`${ct(st.areYouSureYouWantToRemoveThis,{PH1:o.title})}\n${ct(st.workspaceStopSyncing)}`;await t.UIUtils.ConfirmDialog.show(e,void 0,{okButtonLabel:ct(st.remove),jslogContext:"remove-folder-from-workspace-confirmation"})&&r.remove()}),{jslogContext:"remove-folder-from-workspace"})}s.show()}}rename(e,t){const i=e.uiSourceCode();e.rename(function(o){if(!t)return;o?e.treeElement&&e.treeElement.listItemElement.hasFocus()&&this.sourceSelected(i,!0):i.remove()}.bind(this))}async create(e,t,i){let o="";i&&(o=(await i.requestContent()).content||"");const n=await e.createFile(t,null,o);if(!n)return;this.sourceSelected(n,!1);const r=this.revealUISourceCode(n,!0);r&&this.rename(r,!0)}groupingChanged(){this.reset(!0),this.initGrouping(),this.resetWorkspace(f.Workspace.WorkspaceImpl.instance()),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}ignoreListChanged(){C.Runtime.experiments.isEnabled("just-my-code")?this.groupingChanged():this.rootNode.updateTitleRecursive()}initGrouping(){this.groupByFrame=!0,this.groupByDomain=this.navigatorGroupByFolderSetting.get(),this.groupByFolder=this.groupByDomain,this.navigatorGroupByAuthoredExperiment?this.groupByAuthored=C.Runtime.experiments.isEnabled(this.navigatorGroupByAuthoredExperiment):this.groupByAuthored=!1}resetForTest(){this.reset(),this.workspaceInternal.uiSourceCodes().forEach(this.addUISourceCode.bind(this))}discardFrame(e,t){if(t)return;const i=this.frameNodes.get(e);if(i){i.parent&&i.parent.removeChild(i),this.frameNodes.delete(e);for(const i of e.childFrames)this.discardFrame(i,t)}}targetAdded(e){}targetRemoved(e){const t=this.rootOrDeployedNode(),i=t.child("target:"+e.id());i&&t.removeChild(i)}targetNameChanged(e){const t=e.data,i=this.rootOrDeployedNode().child("target:"+t.id());i&&i.setTitle(t.name())}wasShown(){super.wasShown(),this.scriptsTree.registerCSSFiles([Qe]),this.registerCSSFiles([Ze])}}const ht=new WeakSet;class pt extends t.TreeOutline.TreeElement{nodeType;navigatorView;hoverCallback;node;hovered;isIgnoreListed;isFromSourceMap;constructor(e,i,o,n){super("",!0,pt.#h(i)),this.listItemElement.classList.add("navigator-"+i+"-tree-item","navigator-folder-tree-item"),t.ARIAUtils.setLabel(this.listItemElement,`${o}, ${i}`),this.nodeType=i,this.title=o,this.tooltip=o,this.navigatorView=e,this.hoverCallback=n,this.isFromSourceMap=!1;let s="folder";i===lt.Domain?s="cloud":i===lt.Frame?s="frame":i===lt.Worker?s="gears":i===lt.Authored?s="code":i===lt.Deployed&&(s="deployed");const a=r.Icon.create(s);this.setLeadingIcons([a])}async onpopulate(){this.node.populate()}onattach(){this.collapse(),this.node.onattach(),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("mousemove",this.mouseMove.bind(this),!1),this.listItemElement.addEventListener("mouseleave",this.mouseLeave.bind(this),!1)}setIgnoreListed(e){this.isIgnoreListed!==e&&(this.isIgnoreListed=e,this.listItemElement.classList.toggle("is-ignore-listed",e),this.updateTooltip())}setFromSourceMap(e){this.isFromSourceMap=e,this.listItemElement.classList.toggle("is-from-source-map",e)}setNode(e){this.node=e,this.updateTooltip(),t.ARIAUtils.setLabel(this.listItemElement,`${this.title}, ${this.nodeType}`)}updateTooltip(){if(this.node.tooltip)this.tooltip=this.node.tooltip;else{const e=[];let t=this.node;for(;t&&!t.isRoot()&&t.type===this.node.type;)e.push(t.title),t=t.parent;e.reverse();let i=e.join("/");this.isIgnoreListed&&(i=ct(st.sIgnoreListed,{PH1:i})),this.tooltip=i}}handleContextMenuEvent(e){this.node&&(this.select(),this.navigatorView.handleFolderContextMenu(e,this.node))}mouseMove(e){!this.hovered&&this.hoverCallback&&(this.hovered=!0,this.hoverCallback(!0))}mouseLeave(e){this.hoverCallback&&(this.hovered=!1,this.hoverCallback(!1))}static#h(e){switch(e){case lt.Domain:return"domain";case lt.Frame:return"frame";case lt.Worker:return"worker";case lt.Authored:return"authored";case lt.Deployed:return"deployed"}return"folder"}}class gt extends t.TreeOutline.TreeElement{nodeType;node;navigatorView;uiSourceCodeInternal;constructor(e,o,n,r){super("",!1,o.contentType().name()),this.nodeType=lt.File,this.node=r,this.title=n,this.listItemElement.classList.add("navigator-"+o.contentType().name()+"-tree-item","navigator-file-tree-item"),this.tooltip=o.url(),t.ARIAUtils.setLabel(this.listItemElement,`${o.name()}, ${this.nodeType}`),i.EventTarget.fireEvent("source-tree-file-added",o.fullDisplayName()),this.navigatorView=e,this.uiSourceCodeInternal=o,this.updateIcon()}updateIcon(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),i=h.NetworkPersistenceManager.NetworkPersistenceManager.instance();let o="document",n=[];if(e){T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e.fileSystem)&&(o="snippet");n=i.project()===e.fileSystem.project()?["dot","purple"]:["dot","green"]}else i.isActiveHeaderOverrides(this.uiSourceCode)?n=["dot","purple"]:T.ScriptSnippetFileSystem.isSnippetsUISourceCode(this.uiSourceCodeInternal)&&(o="snippet");const s=r.Icon.create(o,n.join(" "));e&&t.Tooltip.Tooltip.install(s,h.PersistenceUtils.PersistenceUtils.tooltipForUISourceCode(this.uiSourceCodeInternal)),this.setLeadingIcons([s])}updateAccessibleName(){t.ARIAUtils.setLabel(this.listItemElement,`${this.uiSourceCodeInternal.name()}, ${this.nodeType}`)}get uiSourceCode(){return this.uiSourceCodeInternal}onattach(){this.listItemElement.draggable=!0,this.listItemElement.addEventListener("click",this.onclick.bind(this),!1),this.listItemElement.addEventListener("contextmenu",this.handleContextMenuEvent.bind(this),!1),this.listItemElement.addEventListener("dragstart",this.ondragstart.bind(this),!1)}shouldRenameOnMouseDown(){if(!this.uiSourceCodeInternal.canRename())return!1;if(!this.treeOutline)return!1;return this===this.treeOutline.selectedTreeElement&&this.treeOutline.element.hasFocus()&&!t.UIUtils.isBeingEdited(this.treeOutline.element)}selectOnMouseDown(e){1===e.which&&this.shouldRenameOnMouseDown()?window.setTimeout(function(){this.shouldRenameOnMouseDown()&&this.navigatorView.rename(this.node,!1)}.bind(this),300):super.selectOnMouseDown(e)}ondragstart(e){e.dataTransfer&&(e.dataTransfer.setData("text/plain",this.uiSourceCodeInternal.url()),e.dataTransfer.effectAllowed="copy")}onspace(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}onclick(e){this.navigatorView.sourceSelected(this.uiSourceCode,!1)}ondblclick(e){const t=1===e.button;return this.navigatorView.sourceSelected(this.uiSourceCode,!t),!1}onenter(){return this.navigatorView.sourceSelected(this.uiSourceCode,!0),!0}ondelete(){return!0}handleContextMenuEvent(e){this.select(),this.navigatorView.handleFileContextMenu(e,this.node)}}class mt{id;navigatorView;type;childrenInternal;populated;isMerged;parent;title;tooltip;recursiveProperties;constructor(e,t,i,o){this.id=t,this.navigatorView=e,this.type=i,this.childrenInternal=new Map,this.tooltip=o,this.populated=!1,this.isMerged=!1,this.recursiveProperties={exclusivelySourceMapped:null,exclusivelyIgnored:null,exclusivelyContentScripts:null,exclusivelyThirdParty:null}}treeNode(){throw"Not implemented"}dispose(){}updateTitle(){}updateTitleRecursive(){for(const e of this.children())e.updateTitleRecursive();this.updateTitle()}updateTitleBubbleUp(){this.updateTitle(),this.parent&&this.parent.updateTitleBubbleUp()}isRoot(){return!1}hasChildren(){return!0}onattach(){}setTitle(e){throw"Not implemented"}populate(){this.isPopulated()||(this.parent&&this.parent.populate(),this.populated=!0,this.wasPopulated())}wasPopulated(){const e=this.children();for(let t=0;te.title)).join("/"),r=[];o=t;do{r.push(o),i=o.children(),o=1===i.length?i[0]:null}while(o&&o.isMerged);if(!this.isPopulated()){this.treeElement.title=n,this.treeElement.setNode(this);for(let e=0;ee.title)).join("/"),s.parent&&this.navigatorView.removeChild(s.parent,s),this.navigatorView.appendChild(this.treeElement,s),s.expanded&&a.expand(),this.updateTitle()}this.isPopulated()&&this.navigatorView.appendChild(this.treeElement,e.treeNode())}willRemoveChild(e){const t=e;!t.isMerged&&this.isPopulated()&&this.treeElement&&t.treeElement&&this.navigatorView.removeChild(this.treeElement,t.treeElement)}}class vt extends mt{project;title;hoverCallback;treeElement;constructor(e,t,i,o,n,r){super(e,i,o,r),this.project=t,this.title=n,this.populate()}setHoverCallback(e){this.hoverCallback=e}treeNode(){return this.treeElement||(this.treeElement=new pt(this.navigatorView,this.type,this.title,this.hoverCallback),this.treeElement.setNode(this)),this.treeElement}onattach(){this.updateTitle()}updateTitle(){if(!this.treeElement||!this.project||this.project.type()!==f.Workspace.projectTypes.FileSystem)return;const e=h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemPath(this.project.id()),t=this.treeElement.listItemElement.classList.contains("has-mapped-files"),i=h.Persistence.PersistenceImpl.instance().filePathHasBindings(e);t!==i&&(this.treeElement.listItemElement.classList.toggle("has-mapped-files",i),this.treeElement.childrenListElement.hasFocus()||(i?this.treeElement.expand():this.treeElement.collapse()))}setTitle(e){this.title=e,this.treeElement&&(this.treeElement.title=this.title)}}var Ct=Object.freeze({__proto__:null,Types:lt,NavigatorView:ut,NavigatorFolderTreeElement:pt,NavigatorSourceTreeElement:gt,NavigatorTreeNode:mt,NavigatorRootTreeNode:bt,NavigatorUISourceCodeTreeNode:ft,NavigatorFolderTreeNode:St,NavigatorGroupTreeNode:vt});const wt=new CSSStyleSheet;wt.replaceSync('.paused-message{align-self:center;width:fit-content}.scripts-debug-toolbar{position:absolute;top:0;width:100%;background-color:var(--app-color-toolbar-background);border-bottom:1px solid var(--sys-color-divider);overflow:hidden;z-index:1}.scripts-debug-toolbar-drawer{flex:0 0 52px;transition:margin-top 0.1s ease-in-out;margin-top:-26px;padding-top:25px;background-color:var(--sys-color-cdt-base-container);overflow:hidden;white-space:nowrap}.scripts-debug-toolbar-drawer.expanded{margin-top:0}.scripts-debug-toolbar-drawer > [is="dt-checkbox"]{display:none;padding-left:3px;height:28px}.scripts-debug-toolbar-drawer.expanded > [is="dt-checkbox"]{display:flex}.cursor-auto{cursor:auto}.navigator-tabbed-pane{background-color:var(--sys-color-cdt-base-container)}\n/*# sourceURL=sourcesPanel.css */\n');class It{sourcesView;entries=[];current=-1;revealing=!1;constructor(e){this.sourcesView=e}trackSourceFrameCursorJumps(e){e.addEventListener("EditorUpdate",(t=>this.onEditorUpdate(t.data,e)))}onEditorUpdate(e,t){e.docChanged&&this.mapEntriesFor(t.uiSourceCode(),e.changes);const i=e.startState.selection.main,o=e.state.selection.main;!this.revealing&&i.anchor!==o.anchor&&e.transactions.some((e=>Boolean(e.isUserEvent("select.pointer")||e.isUserEvent("select.reveal")||e.isUserEvent("select.search"))))&&(this.updateCurrentState(t.uiSourceCode(),i.head),this.entries.length>this.current+1&&(this.entries.length=this.current+1),this.entries.push(new yt(t.uiSourceCode(),o.head)),this.current++,this.entries.length>20&&(this.entries.shift(),this.current--))}updateCurrentState(e,t){if(!this.revealing){const i=this.current>=0?this.entries[this.current]:null;i?.matches(e)&&(i.position=t)}}mapEntriesFor(e,t){for(const i of this.entries)i.matches(e)&&(i.position=t.mapPos(i.position))}reveal(e){const t=f.Workspace.WorkspaceImpl.instance().uiSourceCode(e.projectId,e.url);t&&(this.revealing=!0,this.sourcesView.showSourceLocation(t,e.position,!1,!0),this.revealing=!1)}rollback(){this.current>0&&(this.current--,this.reveal(this.entries[this.current]))}rollover(){this.current=0;t--)this.entries[t].matches(e)&&(this.entries.splice(t,1),this.current>=t&&this.current--)}}class yt{projectId;url;position;constructor(e,t){this.projectId=e.project().id(),this.url=e.url(),this.position=t}matches(e){return this.url===e.url()&&this.projectId===e.project().id()}}var xt=Object.freeze({__proto__:null,HistoryDepth:20,EditingLocationHistoryManager:It});const kt=new CSSStyleSheet;kt.replaceSync("#sources-panel-sources-view{--override-highlight-animation-10pc-background-color:rgb(158 54 153);--override-highlight-animation-10pc-foreground-color:rgb(255 255 255);flex:auto;position:relative}#sources-panel-sources-view .sources-toolbar{display:flex;flex:0 0 27px;background-color:var(--sys-color-cdt-base-container);border-top:1px solid var(--sys-color-divider);overflow:hidden;z-index:0}.sources-toolbar .toolbar{cursor:default}.source-frame-debugger-script{--override-debugger-background-tint:rgb(255 255 194/50%);background-color:var(--override-debugger-background-tint)}.-theme-with-dark-background .source-frame-debugger-script{--override-debugger-background-tint:rgb(61 61 0/50%)}\n/*# sourceURL=sourcesView.css */\n");const Tt=["application/javascript","application/json","application/manifest+json","text/css","text/html","text/javascript"],Et={ms:"ms",mb:"MB",kb:"kB"},Lt=e.i18n.registerUIStrings("panels/sources/ProfilePlugin.ts",Et),Mt=e.i18n.getLocalizedString.bind(void 0,Lt);class Pt extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";let t=this.value;const i=l.NumberUtilities.clamp(Math.log10(1+.002*t)/5,.02,1);let o,n;e.style.backgroundColor=`hsla(217, 100%, 70%, ${i.toFixed(3)})`,t/=1e3,t>=1e3?(o=Mt(Et.mb),t/=1e3,n=t>=20?0:1):(o=Mt(Et.kb),n=0),e.textContent=t.toFixed(n);const r=e.appendChild(document.createElement("span"));return r.className="cm-units",r.textContent=o,e}}class Ft extends n.GutterMarker{value;constructor(e){super(),this.value=e}eq(e){return this.value===e.value}toDOM(){const e=document.createElement("div");e.className="cm-profileMarker";const t=l.NumberUtilities.clamp(Math.log10(1+10*this.value)/5,.02,1);e.textContent=this.value.toFixed(1),e.style.backgroundColor=`hsla(44, 100%, 50%, ${t.toFixed(3)})`;const i=document.createElement("span");return i.className="cm-units",i.textContent=Mt(Et.ms),e.appendChild(i),e}}function Dt(e,t,i){const o="performance"===i?Ft:Pt,r=[];for(const[i,n]of e)if(i<=t.doc.lines){const{from:e}=t.doc.line(i);r.push(new o(n).range(e))}return n.RangeSet.of(r,!0)}const Nt=e=>class extends pe{updateEffect=n.StateEffect.define();field;gutter;compartment=new n.Compartment;constructor(t){super(t),this.field=n.StateField.define({create:()=>n.RangeSet.empty,update:(t,i)=>i.effects.reduce(((t,o)=>o.is(this.updateEffect)?Dt(o.value,i.state,e):t),t.map(i.changes))}),this.gutter=n.gutter({markers:e=>e.state.field(this.field),class:`cm-${e}Gutter`})}static accepts(e){return e.contentType().hasScripts()}getLineMap(){return this.uiSourceCode.getDecorationData(e)}editorExtension(){const t=this.getLineMap();return this.compartment.of(t?[this.field.init((i=>Dt(t,i,e))),this.gutter,At]:[])}decorationChanged(e,t){const i=Boolean(t.state.field(this.field,!1)),o=this.getLineMap();o?i?t.dispatch({effects:this.updateEffect.of(o)}):t.dispatch({effects:this.compartment.reconfigure([this.field.init((t=>Dt(o,t,e))),this.gutter,At])}):i&&t.dispatch({effects:this.compartment.reconfigure([])})}},At=n.EditorView.baseTheme({".cm-performanceGutter":{width:"60px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-memoryGutter":{width:"48px",backgroundColor:"var(--sys-color-cdt-base-container)",marginLeft:"3px"},".cm-profileMarker":{textAlign:"right",paddingRight:"3px"},".cm-profileMarker .cm-units":{color:"var(--sys-color-token-subtle)",fontSize:"75%",marginLeft:"3px"}}),Ut=Nt("memory"),Rt=Nt("performance"),Bt={fromS:"(From {PH1})",sourceMappedFromS:"(Source mapped from {PH1})"},jt=e.i18n.registerUIStrings("panels/sources/ResourceOriginPlugin.ts",Bt),Vt=e.i18n.getLocalizedString.bind(void 0,jt);class Wt extends pe{static accepts(e){const t=e.contentType();return t.hasScripts()||t.isFromSourceMap()}rightToolbarItems(){const i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance();if(this.uiSourceCode.contentType().isFromSourceMap()){const o=[];for(const e of i.scriptsForUISourceCode(this.uiSourceCode)){const t=i.uiSourceCodeForScript(e);if(!t)continue;const n=t.url(),r=u.ResourceUtils.displayNameForURL(n),s=Vt(Bt.sourceMappedFromS,{PH1:r});o.push(D.Linkifier.Linkifier.linkifyRevealable(t,r,n,s))}for(const e of u.SASSSourceMapping.SASSSourceMapping.uiSourceOrigin(this.uiSourceCode))o.push(D.Linkifier.Linkifier.linkifyURL(e));if(0===o.length)return[];const n=document.createElement("span");return o.forEach(((e,t)=>{t>0&&n.append(", "),n.append(e)})),[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(jt,Bt.fromS,{PH1:n}))]}for(const o of i.scriptsForUISourceCode(this.uiSourceCode))if(o.originStackTrace){const i=Ot.linkifyStackTraceTopFrame(o.debuggerModel.target(),o.originStackTrace);return[new t.Toolbar.ToolbarItem(e.i18n.getFormatLocalizedString(jt,Bt.fromS,{PH1:i}))]}return[]}}const Ot=new D.Linkifier.Linkifier;var Ht=Object.freeze({__proto__:null,ResourceOriginPlugin:Wt,linkifier:Ot});const _t={enter:"⌘+Enter",ctrlenter:"Ctrl+Enter"},zt=e.i18n.registerUIStrings("panels/sources/SnippetsPlugin.ts",_t),qt=e.i18n.getLocalizedString.bind(void 0,zt);class $t extends pe{static accepts(e){return T.ScriptSnippetFileSystem.isSnippetsUISourceCode(e)}rightToolbarItems(){const e=t.Toolbar.Toolbar.createActionButtonForId("debugger.run-snippet");return e.setText(c.Platform.isMac()?qt(_t.enter):qt(_t.ctrlenter)),[e]}editorExtension(){return s.JavaScript.completion()}}var Gt=Object.freeze({__proto__:null,SnippetsPlugin:$t});class Kt extends(i.ObjectWrapper.eventMixin(m.SourceFrame.SourceFrameImpl)){uiSourceCodeInternal;muteSourceCodeEvents;persistenceBinding;uiSourceCodeEventListeners;messageAndDecorationListeners;boundOnBindingChanged;plugins=[];errorPopoverHelper;openInExternalEditorToolbarButton;#p=!1;constructor(e){if(super((()=>this.workingCopy())),this.element.setAttribute("jslog",`${a.textField()}`),this.uiSourceCodeInternal=e,this.muteSourceCodeEvents=!1,this.persistenceBinding=h.Persistence.PersistenceImpl.instance().binding(e),this.uiSourceCodeEventListeners=[],this.messageAndDecorationListeners=[],this.canOpenInExternalEditor()){this.openInExternalEditorToolbarButton=new t.Toolbar.ToolbarButton("Open in editor",void 0,"Open in editor");const e=globalThis.reactNativeOpenInEditorButtonImage;if("string"==typeof e&&""!==e){const t=new P.Adorner.Adorner;t.classList.add("open-in-external-editor-adorner"),t.style.setProperty("background-image",e),this.openInExternalEditorToolbarButton.element.classList.add("toolbar-has-glyph","open-in-external-editor-button"),this.openInExternalEditorToolbarButton.setGlyphOrAdorner(t)}else this.openInExternalEditorToolbarButton.setGlyph("open-externally");this.openInExternalEditorToolbarButton.addEventListener("Click",(()=>{const e={url:this.uiSourceCode().url()},t=this.textEditor.state,i=t.doc.lineAt(t.selection.main.head),{lineNumber:o}=this.editorLocationToUILocation(i.number);e.lineNumber=o,fetch("/open-stack-frame",{method:"POST",body:JSON.stringify(e)}).catch((e=>console.error(e)))}))}this.boundOnBindingChanged=this.onBindingChanged.bind(this),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").addChangeListener(this.onNetworkPersistenceChanged,this),this.errorPopoverHelper=new t.PopoverHelper.PopoverHelper(this.textEditor.editor.contentDOM,this.getErrorPopoverContent.bind(this),"sources.error"),this.errorPopoverHelper.setHasPadding(!0),this.errorPopoverHelper.setTimeout(100,100),this.initializeUISourceCode()}canOpenInExternalEditor(){return!!globalThis.enableReactNativeOpenInExternalEditor&&(this.uiSourceCode().url().startsWith("http")??!1)}async workingCopy(){return this.uiSourceCodeInternal.isDirty()?{content:this.uiSourceCodeInternal.workingCopy(),isEncoded:!1}:this.uiSourceCodeInternal.requestContent()}editorConfiguration(e){return[super.editorConfiguration(e),(t=this.allMessages(),[ri.init((e=>ni.create(ei.create(t),e.doc))),ai]),Yt.of(this.plugins.map((e=>e.editorExtension())))];var t}onFocus(){super.onFocus(),t.Context.Context.instance().setFlavor(Kt,this)}onBlur(){super.onBlur(),t.Context.Context.instance().setFlavor(Kt,null)}installMessageAndDecorationListeners(){if(this.persistenceBinding){const e=this.persistenceBinding.network,t=this.persistenceBinding.fileSystem;this.messageAndDecorationListeners=[e.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),e.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),e.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this),t.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),t.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this)]}else this.messageAndDecorationListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageAdded,this.onMessageAdded,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.MessageRemoved,this.onMessageRemoved,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.DecorationChanged,this.onDecorationChanged,this)]}uiSourceCode(){return this.uiSourceCodeInternal}setUISourceCode(e){const t=e.contentLoaded()?Promise.resolve():e.requestContent(),i=this.uiSourceCodeInternal;t.then((async()=>{this.uiSourceCodeInternal===i&&(this.unloadUISourceCode(),this.uiSourceCodeInternal=e,e.workingCopy()!==this.textEditor.state.doc.toString()?await this.setDeferredContent(Promise.resolve(e.workingCopyContent())):this.reloadPlugins(),this.initializeUISourceCode())}),console.error)}unloadUISourceCode(){i.EventTarget.removeEventListeners(this.messageAndDecorationListeners),i.EventTarget.removeEventListeners(this.uiSourceCodeEventListeners),this.uiSourceCodeInternal.removeWorkingCopyGetter(),h.Persistence.PersistenceImpl.instance().unsubscribeFromBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged)}initializeUISourceCode(){this.uiSourceCodeEventListeners=[this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.onWorkingCopyChanged,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.onWorkingCopyCommitted,this),this.uiSourceCodeInternal.addEventListener(f.UISourceCode.Events.TitleChanged,this.onTitleChanged,this)],h.Persistence.PersistenceImpl.instance().subscribeForBindingEvent(this.uiSourceCodeInternal,this.boundOnBindingChanged),this.installMessageAndDecorationListeners(),this.updateStyle();const e=Tt.includes(this.contentType)&&!this.uiSourceCodeInternal.project().canSetFileContent()&&null===h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=!this.uiSourceCodeInternal.contentType().isFromSourceMap();this.setCanPrettyPrint(e,t)}wasShown(){super.wasShown(),this.setEditable(this.canEditSourceInternal())}willHide(){for(const e of this.plugins)e.willHide();super.willHide(),t.Context.Context.instance().setFlavor(Kt,null),this.uiSourceCodeInternal.removeWorkingCopyGetter()}getContentType(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network.mimeType():this.uiSourceCodeInternal.mimeType();return i.ResourceType.ResourceType.simplifyContentType(t)}canEditSourceInternal(){return!this.hasLoadError()&&(!this.uiSourceCodeInternal.editDisabled()&&("application/wasm"!==this.uiSourceCodeInternal.mimeType()&&(!!h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal)||(!!this.uiSourceCodeInternal.project().canSetFileContent()||!this.uiSourceCodeInternal.project().isServiceProject()&&(!(this.uiSourceCodeInternal.project().type()!==f.Workspace.projectTypes.Network||!h.NetworkPersistenceManager.NetworkPersistenceManager.instance().active())||(!this.pretty||!this.uiSourceCodeInternal.contentType().hasScripts())&&this.uiSourceCodeInternal.contentType()!==i.ResourceType.resourceTypes.Document)))))}onNetworkPersistenceChanged(){this.setEditable(this.canEditSourceInternal())}commitEditing(){this.uiSourceCodeInternal.isDirty()&&(this.muteSourceCodeEvents=!0,this.uiSourceCodeInternal.commitWorkingCopy(),this.muteSourceCodeEvents=!1)}async setContent(e){this.disposePlugins(),this.loadPlugins(),await super.setContent(e);for(const e of this.plugins)e.editorInitialized(this.textEditor);this.#g(),i.EventTarget.fireEvent("source-file-loaded",this.uiSourceCodeInternal.displayName(!0))}createMessage(e){const{lineNumber:t,columnNumber:i}=this.uiLocationToEditorLocation(e.lineNumber(),e.columnNumber());return new Qt(e,t,i)}allMessages(){return(null!==this.persistenceBinding?[...this.persistenceBinding.network.messages(),...this.persistenceBinding.fileSystem.messages()]:[...this.uiSourceCodeInternal.messages()]).map((e=>this.createMessage(e)))}onTextChanged(){const e=this.pretty;super.onTextChanged(),this.errorPopoverHelper.hidePopover(),Oi.instance().updateLastModificationTime(),this.muteSourceCodeEvents=!0,this.isClean()?this.uiSourceCodeInternal.resetWorkingCopy():this.uiSourceCodeInternal.setWorkingCopyGetter((()=>this.textEditor.state.sliceDoc())),this.muteSourceCodeEvents=!1,e!==this.pretty&&(this.updateStyle(),this.reloadPlugins())}onWorkingCopyChanged(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCodeInternal.workingCopyContent())}onWorkingCopyCommitted(){this.muteSourceCodeEvents||this.maybeSetContent(this.uiSourceCode().workingCopyContent()),this.contentCommitted(),this.updateStyle()}reloadPlugins(){this.disposePlugins(),this.loadPlugins();const e=this.textEditor;e.dispatch({effects:Yt.reconfigure(this.plugins.map((e=>e.editorExtension())))});for(const t of this.plugins)t.editorInitialized(e)}onTitleChanged(){this.updateLanguageMode("").then((()=>this.reloadPlugins()),console.error)}loadPlugins(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal),t=e?e.network:this.uiSourceCodeInternal;for(const e of[He,Zi,$t,Wt,Se,Ut,Rt])e.accepts(t)&&this.plugins.push(new e(t,this));this.dispatchEventToListeners("ToolbarItemsChanged")}disposePlugins(){for(const e of this.plugins)e.dispose();this.plugins=[]}onBindingChanged(){const e=h.Persistence.PersistenceImpl.instance().binding(this.uiSourceCodeInternal);e!==this.persistenceBinding&&(this.unloadUISourceCode(),this.persistenceBinding=e,this.initializeUISourceCode(),this.reloadMessages(),this.reloadPlugins())}reloadMessages(){const e=this.allMessages(),{editor:t}=this.textEditor;t.dispatch({effects:ti.of(ei.create(e))})}updateStyle(){this.setEditable(this.canEditSourceInternal())}maybeSetContent(e){this.textEditor.state.doc.toString()!==e.content&&this.setDeferredContent(Promise.resolve(e))}populateTextAreaContextMenu(e,t,i){super.populateTextAreaContextMenu(e,t,i),e.appendApplicableItems(this.uiSourceCodeInternal);const o=this.editorLocationToUILocation(t,i);e.appendApplicableItems(new f.UISourceCode.UILocation(this.uiSourceCodeInternal,o.lineNumber,o.columnNumber));for(const o of this.plugins)o.populateTextAreaContextMenu(e,t,i)}populateLineGutterContextMenu(e,t){super.populateLineGutterContextMenu(e,t);for(const i of this.plugins)i.populateLineGutterContextMenu(e,t)}dispose(){this.errorPopoverHelper.dispose(),this.disposePlugins(),this.unloadUISourceCode(),this.textEditor.editor.destroy(),this.detach(),i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").removeChangeListener(this.onNetworkPersistenceChanged,this)}onMessageAdded(e){const{editor:t}=this.textEditor,i=t.state.field(ri,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ti.of(i.messages.add(o))})}}onMessageRemoved(e){const{editor:t}=this.textEditor,i=t.state.field(ri,!1);if(i){const o=this.createMessage(e.data);t.dispatch({effects:ti.of(i.messages.remove(o))})}}onDecorationChanged(e){for(const t of this.plugins)t.decorationChanged(e.data,this.textEditor)}async toolbarItems(){const e=await super.toolbarItems(),i=[];for(const t of this.plugins)e.push(...t.leftToolbarItems()),i.push(...t.rightToolbarItems());return i.length?(this.openInExternalEditorToolbarButton&&e.push(this.openInExternalEditorToolbarButton),[...e,new t.Toolbar.ToolbarSeparator(!0),...i]):e}getErrorPopoverContent(e){const t=e,i=e.target,o=i.enclosingNodeOrSelfWithClass("cm-messageIcon-error")||i.enclosingNodeOrSelfWithClass("cm-messageIcon-issue");if(!o)return null;const n=this.textEditor.state.field(ri,!1);if(!n||0===n.messages.rows.length)return null;const{editor:r}=this.textEditor,s=r.posAtCoords(t);if(null===s)return null;const a=r.state.doc.lineAt(s);if(s!==a.to)return null;const c=n.messages.rows.find((e=>e[0].lineNumber()===a.number-1));if(!c)return null;const l=o.classList.contains("cm-messageIcon-issue"),d=c.filter((e=>"Issue"===e.level()===l));if(!d.length)return null;const u=o?o.boxInWindow():new AnchorBox(t.clientX,t.clientY,1,1),h=function(e){const t=[];for(let i=0;i(e.contentElement.append(p),!0)}}#g(){if(this.#p)return;this.#p=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCodeInternal.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCodeInternal.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCodeInternal.content()));c.userMetrics.sourcesPanelFileOpened(t)}}function Jt(e){return"Error"===e?{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}:"Warning"===e?{color:"var(--icon-warning)",width:"18px",height:"14px",iconName:"warning-filled"}:"Issue"===e?{color:"var(--icon-warning)",width:"17px",height:"14px",iconName:"issue-exclamation-filled"}:{color:"var(--icon-error)",width:"16px",height:"14px",iconName:"cross-circle-filled"}}function Xt(e,t){const i={Issue:2,Warning:3,Error:4};return i[e.level()]-i[t.level()]}const Yt=new n.Compartment;class Qt{origin;#m;#b;constructor(e,t,i){this.origin=e,this.#m=t,this.#b=i}level(){return this.origin.level()}text(){return this.origin.text()}clickHandler(){return this.origin.clickHandler()}lineNumber(){return this.#m}columnNumber(){return this.#b}isEqual(e){return this.origin.isEqual(e.origin)}}function Zt(e,t){const i=t.lineNumber();let o=0;for(;o0)break}return e.splice(o,0,[t]),e}class ei{rows;constructor(e){this.rows=e}static create(e){const t=[];for(const i of e)Zt(t,i);return new ei(t)}remove(e){const t=this.rows.slice();return function(e,t){for(let i=0;i!e.isEqual(t)));o.length?e[i]=o:e.splice(i,1);break}}(t,e),new ei(t)}add(e){return new ei(Zt(this.rows.slice(),e))}}const ti=n.StateEffect.define(),ii=n.Decoration.mark({class:"cm-waveUnderline"});class oi extends n.WidgetType{messages;constructor(e){super(),this.messages=e}eq(e){return e.messages===this.messages}toDOM(){const e=document.createElement("span");e.classList.add("cm-messageIcon");const t=this.messages.filter((e=>"Issue"!==e.level()));if(t.length){const i=t.sort(Xt)[t.length-1],o=e.appendChild(new r.Icon.Icon);o.data=Jt(i.level()),o.classList.add("cm-messageIcon-error")}const i=this.messages.find((e=>"Issue"===e.level()));if(i){const t=e.appendChild(new r.Icon.Icon);t.data=Jt("Issue"),t.classList.add("cm-messageIcon-issue"),t.addEventListener("click",(()=>(i.clickHandler()||Math.min)()))}return e}ignoreEvents(){return!0}}class ni{messages;decorations;constructor(e,t){this.messages=e,this.decorations=t}static create(e,t){const i=new n.RangeSetBuilder;for(const o of e.rows){const e=t.line(Math.min(t.lines,o[0].lineNumber()+1)),r=o.reduce(((e,t)=>Math.min(e,t.columnNumber()||0)),e.length);rni.create(new ei([]),e.doc),update:(e,t)=>e.apply(t),provide:e=>n.Prec.lowest(n.EditorView.decorations.from(e,(e=>e.decorations)))});function si(e,t){const i=document.createElement("div");if(i.classList.add("text-editor-row-message"),i.style.display="flex",i.style.alignItems="center",i.style.gap="4px",1===t){const t=i.appendChild(new r.Icon.Icon);t.data=function(e){return e.origin instanceof M.SourceFrameIssuesManager.IssueMessage?{...F.IssueCounter.getIssueKindIconData(e.origin.getIssueKind()),width:"12px",height:"12px"}:Jt(e.level())}(e),t.classList.add("text-editor-row-message-icon"),t.addEventListener("click",(()=>(e.clickHandler()||Math.min)()))}else{const o=document.createElement("span",{is:"dt-small-bubble"});o.textContent=String(t),o.classList.add("text-editor-row-message-repeat-count"),o.style.flexShrink="0",i.appendChild(o),o.type=function(e){switch(e){case"Error":return"error";case"Warning":case"Issue":return"warning"}}(e.level())}const o=i.createChild("div");for(const t of e.text().split("\n"))o.createChild("div").textContent=t;return i}const ai=n.EditorView.baseTheme({".cm-tooltip-message":{padding:"4px"},".cm-waveUnderline":{backgroundImage:"var(--image-file-errorWave)",backgroundRepeat:"repeat-x",backgroundPosition:"bottom",paddingBottom:"1px"},".cm-messageIcon":{cursor:"pointer","& > *":{verticalAlign:"text-bottom",marginLeft:"2px"}},".cm-messageIcon-issue, .cm-messageIcon-error":{marginTop:"-1px",marginBottom:"-1px"}});var ci=Object.freeze({__proto__:null,UISourceCodeFrame:Kt});const li={areYouSureYouWantToCloseUnsaved:"Are you sure you want to close unsaved file: {PH1}?",unableToLoadThisContent:"Unable to load this content.",changesToThisFileWereNotSavedTo:"Changes to this file were not saved to file system."},di=e.i18n.registerUIStrings("panels/sources/TabbedEditorContainer.ts",li),ui=e.i18n.getLocalizedString.bind(void 0,di);let hi=0;class pi extends i.ObjectWrapper.ObjectWrapper{delegate;tabbedPane;tabIds;files;previouslyViewedFilesSetting;history;uriToUISourceCode;idToUISourceCode;currentFileInternal;currentView;scrollTimer;reentrantShow;constructor(e,i,o,n){super(),this.delegate=e,this.tabbedPane=new t.TabbedPane.TabbedPane,this.tabbedPane.setPlaceholderElement(o,n),this.tabbedPane.setTabDelegate(new Si(this)),this.tabbedPane.setCloseableTabs(!0),this.tabbedPane.setAllowTabReorder(!0,!0),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabClosed,this.tabClosed,this),this.tabbedPane.addEventListener(t.TabbedPane.Events.TabSelected,this.tabSelected,this),this.tabbedPane.headerElement().setAttribute("jslog",`${a.toolbar("top")}`),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingCreated,this.onBindingCreated,this),h.Persistence.PersistenceImpl.instance().addEventListener(h.Persistence.Events.BindingRemoved,this.onBindingRemoved,this),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("RequestsForHeaderOverridesFileChanged",this.#d,this),this.tabIds=new Map,this.files=new Map,this.previouslyViewedFilesSetting=i,this.history=fi.fromObject(this.previouslyViewedFilesSetting.get()),this.uriToUISourceCode=new Map,this.idToUISourceCode=new Map,this.reentrantShow=!1}onBindingCreated(e){const t=e.data;this.updateFileTitle(t.fileSystem);const i=this.tabIds.get(t.network);let o=this.tabIds.get(t.fileSystem);const n=this.currentFileInternal===t.network,r=mi(t.network),s=this.history.selectionRange(r),a=this.history.scrollLineNumber(r);if(this.history.remove(r),i){if(!o){const e=this.tabbedPane.tabView(i),n=this.tabbedPane.tabIndex(i);if(e instanceof Kt)this.delegate.recycleUISourceCodeFrame(e,t.fileSystem),o=this.appendFileTab(t.fileSystem,!1,n,e);else{o=this.appendFileTab(t.fileSystem,!1,n);const e=this.tabbedPane.tabView(o);this.restoreEditorProperties(e,s,a)}}this.closeTabs([i],!0),n&&this.tabbedPane.selectTab(o,!1),this.updateHistory()}}#d(e){this.updateFileTitle(e.data)}onBindingRemoved(e){const t=e.data;this.updateFileTitle(t.fileSystem)}get view(){return this.tabbedPane}get visibleView(){return this.tabbedPane.visibleView}fileViews(){return this.tabbedPane.tabViews()}leftToolbar(){return this.tabbedPane.leftToolbar()}rightToolbar(){return this.tabbedPane.rightToolbar()}show(e){this.tabbedPane.show(e)}showFile(e){const o=h.Persistence.PersistenceImpl.instance().binding(e);e=o?o.fileSystem:e;const n=t.Context.Context.instance().flavor(yi);if(n?.currentSourceFrame()?.contentSet&&this.currentFileInternal===e&&n?.currentUISourceCode()===e)i.EventTarget.fireEvent("source-file-loaded",e.displayName(!0));else{if(e.project().type()===f.Workspace.projectTypes.Debugger){const t=u.DefaultScriptMapping.DefaultScriptMapping.scriptForUISourceCode(e);t&&t.isInlineScript()&&!t.hasSourceURL&&(t.isModule?c.userMetrics.vmInlineScriptContentShown(0):c.userMetrics.vmInlineScriptContentShown(1))}this.innerShowFile(e,!0)}}closeFile(e){const t=this.tabIds.get(e);t&&this.closeTabs([t])}closeAllFiles(){this.closeTabs(this.tabbedPane.tabIds())}historyUISourceCodes(){const e=[];for(const{url:t,resourceType:i}of this.history.keys()){const o=this.uriToUISourceCode.get(t);void 0!==o&&o.contentType()===i&&e.push(o)}return e}selectNextTab(){this.tabbedPane.selectNextTab()}selectPrevTab(){this.tabbedPane.selectPrevTab()}addViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.addEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.addEventListener("EditorScroll",this.onScrollChanged,this))}removeViewListeners(){this.currentView&&this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.currentView.removeEventListener("EditorUpdate",this.onEditorUpdate,this),this.currentView.removeEventListener("EditorScroll",this.onScrollChanged,this))}onScrollChanged(){if(this.currentView instanceof m.SourceFrame.SourceFrameImpl&&(this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=window.setTimeout((()=>this.previouslyViewedFilesSetting.set(this.history.toObject())),100),this.currentFileInternal)){const{editor:e}=this.currentView.textEditor,t=e.lineBlockAtHeight(e.scrollDOM.getBoundingClientRect().top-e.documentTop),i=e.state.doc.lineAt(t.from).number-1;this.history.updateScrollLineNumber(mi(this.currentFileInternal),i)}}onEditorUpdate({data:e}){if(e.docChanged||e.selectionSet){const{main:t}=e.state.selection,i=e.state.doc.lineAt(t.from),o=e.state.doc.lineAt(t.to),n=new g.TextRange.TextRange(i.number-1,t.from-i.from,o.number-1,t.to-o.from);this.currentFileInternal&&this.history.updateSelectionRange(mi(this.currentFileInternal),n),this.previouslyViewedFilesSetting.set(this.history.toObject()),this.currentFileInternal&&k.ExtensionServer.ExtensionServer.instance().sourceSelectionChanged(this.currentFileInternal.url(),n)}}innerShowFile(e,t){if(this.reentrantShow)return;const i=this.canonicalUISourceCode(e),o=h.Persistence.PersistenceImpl.instance().binding(e);if(e=o?o.fileSystem:e,this.currentFileInternal===e)return;this.removeViewListeners(),this.currentFileInternal=e;try{this.reentrantShow=!0;const e=this.tabIds.get(i)||this.appendFileTab(i,t);this.tabbedPane.selectTab(e,t)}finally{this.reentrantShow=!1}t&&this.editorSelectedByUserAction();const n=this.currentView;this.currentView=this.visibleView,this.addViewListeners(),this.currentView instanceof Kt&&this.currentView.uiSourceCode()!==e&&(this.delegate.recycleUISourceCodeFrame(this.currentView,e),e.project().type()!==f.Workspace.projectTypes.FileSystem&&e.disableEdit());const r={currentFile:this.currentFileInternal,currentView:this.currentView,previousView:n,userGesture:t};this.dispatchEventToListeners("EditorSelected",r)}titleForFile(e){let t=l.StringUtilities.trimMiddle(e.displayName(!0),30);return e.isDirty()&&(t+="*"),t}maybeCloseTab(e,t){const i=this.files.get(e);if(!i)return!1;return!(i.isDirty()&&i.project().canSetFileContent()&&!confirm(ui(li.areYouSureYouWantToCloseUnsaved,{PH1:i.name()})))&&(i.resetWorkingCopy(),t&&this.tabbedPane.selectTab(t,!0),this.tabbedPane.closeTab(e,!0),!0)}closeTabs(e,t){const i=[],o=[];for(let n=0;n{e.loadError()&&this.addLoadErrorIcon(a)})),a}addLoadErrorIcon(e){const i=new r.Icon.Icon;i.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(i,ui(li.unableToLoadThisContent)),this.tabbedPane.tabView(e)&&this.tabbedPane.setTabIcon(e,i)}restoreEditorProperties(e,t,i){const o=e instanceof m.SourceFrame.SourceFrameImpl?e:null;o&&(t&&o.setSelection(t),"number"==typeof i&&o.scrollToLine(i))}tabClosed(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);this.currentFileInternal&&this.currentFileInternal.canononicalScriptId()===o?.canononicalScriptId()&&(this.removeViewListeners(),this.currentView=null,this.currentFileInternal=null),o&&this.tabIds.delete(o),this.files.delete(t),o&&(this.removeUISourceCodeListeners(o),this.dispatchEventToListeners("EditorClosed",o),i&&this.editorClosedByUserAction(o))}tabSelected(e){const{tabId:t,isUserGesture:i}=e.data,o=this.files.get(t);o&&this.innerShowFile(o,i)}addUISourceCodeListeners(e){e.addEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}removeUISourceCodeListeners(e){e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.uiSourceCodeTitleChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.uiSourceCodeWorkingCopyChanged,this),e.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.uiSourceCodeWorkingCopyCommitted,this)}updateFileTitle(e){const i=this.tabIds.get(e);if(i){const o=this.titleForFile(e),n=this.tooltipForFile(e);this.tabbedPane.changeTabTitle(i,o,n);let s=null;e.loadError()?(s=new r.Icon.Icon,s.data={iconName:"cross-circle-filled",color:"var(--icon-error)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,ui(li.unableToLoadThisContent))):h.Persistence.PersistenceImpl.instance().hasUnsavedCommittedChanges(e)?(s=new r.Icon.Icon,s.data={iconName:"warning-filled",color:"var(--icon-warning)",width:"14px",height:"14px"},t.Tooltip.Tooltip.install(s,ui(li.changesToThisFileWereNotSavedTo))):s=h.PersistenceUtils.PersistenceUtils.iconForUISourceCode(e),this.tabbedPane.setTabIcon(i,s)}}uiSourceCodeTitleChanged(e){const t=e.data;this.updateFileTitle(t),this.updateHistory();for(const[e,i]of this.uriToUISourceCode)i===t&&e!==i.url()&&this.uriToUISourceCode.delete(e);for(const[e,i]of this.idToUISourceCode)i===t&&e!==i.canononicalScriptId()&&this.idToUISourceCode.delete(e);this.canonicalUISourceCode(t)}uiSourceCodeWorkingCopyChanged(e){const t=e.data;this.updateFileTitle(t)}uiSourceCodeWorkingCopyCommitted(e){const t=e.data.uiSourceCode;this.updateFileTitle(t)}generateTabId(){return"tab-"+hi++}currentFile(){return this.currentFileInternal||null}}const gi=30;function mi(e){return{url:e.url(),resourceType:e.contentType()}}class bi{url;resourceType;selectionRange;scrollLineNumber;constructor(e,t,i,o){this.url=e,this.resourceType=t,this.selectionRange=i,this.scrollLineNumber=o}static fromObject(e){const t=i.ResourceType.ResourceType.fromName(e.resourceTypeName);if(null===t)throw new TypeError(`Invalid resource type name "${e.resourceTypeName}"`);const o=e.selectionRange?g.TextRange.TextRange.fromObject(e.selectionRange):void 0;return new bi(e.url,t,o,e.scrollLineNumber)}toObject(){return this.url.length>=4096?null:{url:this.url,resourceTypeName:this.resourceType.name(),selectionRange:this.selectionRange,scrollLineNumber:this.scrollLineNumber}}}class fi{items;constructor(e){this.items=e}static fromObject(e){const t=[];for(const i of e)try{t.push(bi.fromObject(i))}catch{}return new fi(t)}index({url:e,resourceType:t}){return this.items.findIndex((i=>i.url===e&&i.resourceType===t))}selectionRange(e){const t=this.index(e);if(-1!==t)return this.items[t].selectionRange}updateSelectionRange(e,t){if(!t)return;const i=this.index(e);-1!==i&&(this.items[i].selectionRange=t)}scrollLineNumber(e){const t=this.index(e);if(-1!==t)return this.items[t].scrollLineNumber}updateScrollLineNumber(e,t){const i=this.index(e);-1!==i&&(this.items[i].scrollLineNumber=t)}update(e){for(let t=e.length-1;t>=0;--t){const i=this.index(e[t]);let o;-1!==i?(o=this.items[i],this.items.splice(i,1)):o=new bi(e[t].url,e[t].resourceType),this.items.unshift(o)}}remove(e){const t=this.index(e);-1!==t&&this.items.splice(t,1)}toObject(){const e=[];for(const t of this.items){const i=t.toObject();if(i&&e.push(i),e.length===gi)break}return e}keys(){return this.items}}class Si{editorContainer;constructor(e){this.editorContainer=e}closeTabs(e,t){this.editorContainer.closeTabs(t)}onContextMenu(e,t){this.editorContainer.onContextMenu(e,t)}}var vi=Object.freeze({__proto__:null,TabbedEditorContainer:pi,HistoryItem:bi,History:fi,EditorContainerTabDelegate:Si});const Ci={openFile:"Open file",runCommand:"Run command",workspaceDropInAFolderToSyncSources:"To sync edits to the workspace, drop a folder with your sources here or",selectFolder:"Select folder",sourceViewActions:"Source View Actions"},wi=e.i18n.registerUIStrings("panels/sources/SourcesView.ts",Ci),Ii=e.i18n.getLocalizedString.bind(void 0,wi);class yi extends(i.ObjectWrapper.eventMixin(t.Widget.VBox)){selectedIndex;searchableViewInternal;sourceViewByUISourceCode;editorContainer;historyManager;toolbarContainerElementInternal;scriptViewToolbar;bottomToolbarInternal;toolbarChangedListener;focusedPlaceholderElement;searchView;searchConfig;constructor(){super(),this.element.id="sources-panel-sources-view",this.element.setAttribute("jslog",`${a.pane("editor")}`),this.setMinimumAndPreferredSizes(88,52,150,100),this.selectedIndex=0;const e=f.Workspace.WorkspaceImpl.instance();this.searchableViewInternal=new t.SearchableView.SearchableView(this,this,"sources-view-search-config"),this.searchableViewInternal.setMinimalSearchQuerySize(0),this.searchableViewInternal.show(this.element),this.sourceViewByUISourceCode=new Map,this.editorContainer=new pi(this,i.Settings.Settings.instance().createLocalSetting("previously-viewed-files",[]),this.placeholderElement(),this.focusedPlaceholderElement),this.editorContainer.show(this.searchableViewInternal.element),this.editorContainer.addEventListener("EditorSelected",this.editorSelected,this),this.editorContainer.addEventListener("EditorClosed",this.editorClosed,this),this.historyManager=new It(this),this.toolbarContainerElementInternal=this.element.createChild("div","sources-toolbar"),this.toolbarContainerElementInternal.setAttribute("jslog",`${a.toolbar("bottom")}`),this.scriptViewToolbar=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.scriptViewToolbar.element.style.flex="auto",this.bottomToolbarInternal=new t.Toolbar.Toolbar("",this.toolbarContainerElementInternal),this.toolbarChangedListener=null,t.UIUtils.startBatchUpdate(),e.uiSourceCodes().forEach(this.addUISourceCode.bind(this)),t.UIUtils.endBatchUpdate(),e.addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),e.addEventListener(f.Workspace.Events.UISourceCodeRemoved,this.uiSourceCodeRemoved,this),e.addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved.bind(this),this),o.TargetManager.TargetManager.instance().addScopeChangeListener(this.#f.bind(this)),window.opener||window.addEventListener("beforeunload",(function(e){if(e.returnValue)return;const o=[],n=f.Workspace.WorkspaceImpl.instance().projectsForType(f.Workspace.projectTypes.FileSystem);for(const e of n)for(const t of e.uiSourceCodes())t.isDirty()&&o.push(t);if(o.length){e.returnValue=!0,t.ViewManager.ViewManager.instance().showView("sources");for(const e of o)i.Revealer.reveal(e)}}),!0)}placeholderElement(){const e=[{actionId:"quick-open.show",description:Ii(Ci.openFile)},{actionId:"quick-open.show-command-menu",description:Ii(Ci.runCommand)},{actionId:"sources.add-folder-to-workspace",condition:C.Runtime.ConditionName.NOT_SOURCES_HIDE_ADD_FOLDER,description:Ii(Ci.workspaceDropInAFolderToSyncSources),isWorkspace:!0}],i=document.createElement("div");t.ARIAUtils.markAsList(i),t.ARIAUtils.setLabel(i,Ii(Ci.sourceViewActions));for(const o of e){const{condition:e}=o;if(void 0!==e&&!C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:()=>Boolean(C.Runtime.Runtime.queryParam(e))}))continue;const n=t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction(o.actionId),r=i.createChild("div","tabbed-pane-placeholder-row");if(t.ARIAUtils.markAsListitem(r),n){r.createChild("span").textContent=n;const e=r.createChild("button");e.textContent=o.description;const i=t.ActionRegistry.ActionRegistry.instance().getAction(o.actionId);e.addEventListener("click",(()=>i.execute()))}if(o.isWorkspace){const e=r.createChild("span","workspace");e.textContent=o.description;const t=e.createChild("button");t.textContent=Ii(Ci.selectFolder),t.addEventListener("click",this.addFileSystemClicked.bind(this))}}return C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&i.appendChild(t.XLink.XLink.create("https://developer.chrome.com/docs/devtools/workspaces/","Learn more about Workspaces")),i}async addFileSystemClicked(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem()&&(c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSelectFolder),t.ViewManager.ViewManager.instance().showView("navigator-files"))}static defaultUISourceCodeScores(){const e=new Map,i=t.Context.Context.instance().flavor(yi);if(i){const t=i.editorContainer.historyUISourceCodes();for(let i=1;i{this.scriptViewToolbar.removeToolbarItems();for(const e of Ti())this.scriptViewToolbar.appendToolbarItem(e.getOrCreateButton(this));e.map((e=>this.scriptViewToolbar.appendToolbarItem(e)))}))}showSourceLocation(e,t,i,o){const n=this.currentSourceFrame();n&&this.historyManager.updateCurrentState(n.uiSourceCode(),n.textEditor.state.selection.main.head),this.editorContainer.showFile(e);const r=this.currentSourceFrame();r&&t&&r.revealPosition(t,!o);const s=this.visibleView();!i&&s&&s.focus()}createSourceView(e){let t;const o=e.contentType();return o===i.ResourceType.resourceTypes.Image?t=new m.ImageView.ImageView(e.mimeType(),e):o===i.ResourceType.resourceTypes.Font?t=new m.FontView.FontView(e.mimeType(),e):e.name()===Li?t=new x.HeadersView.HeadersView(e):(t=new Kt(e),this.historyManager.trackSourceFrameCursorJumps(t)),e.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.set(e,t),t}#v(e){return e instanceof m.ImageView.ImageView?"ImageView":e instanceof m.FontView.FontView?"FontView":e instanceof x.HeadersView.HeadersView?"HeadersView":"SourceView"}#C(e){if(e.name()===Li)return"HeadersView";switch(e.contentType()){case i.ResourceType.resourceTypes.Image:return"ImageView";case i.ResourceType.resourceTypes.Font:return"FontView";default:return"SourceView"}}#S(e){const t=e.data,i=this.sourceViewByUISourceCode.get(t);i&&this.#v(i)!==this.#C(t)&&(this.removeUISourceCodes([t]),this.showSourceLocation(t))}getSourceView(e){return this.sourceViewByUISourceCode.get(e)}getOrCreateSourceView(e){return this.sourceViewByUISourceCode.get(e)||this.createSourceView(e)}recycleUISourceCodeFrame(e,t){e.uiSourceCode().removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this),this.sourceViewByUISourceCode.delete(e.uiSourceCode()),e.setUISourceCode(t),this.sourceViewByUISourceCode.set(t,e),t.addEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}viewForFile(e){return this.getOrCreateSourceView(e)}removeSourceFrame(e){const t=this.sourceViewByUISourceCode.get(e);this.sourceViewByUISourceCode.delete(e),t&&t instanceof Kt&&t.dispose(),e.removeEventListener(f.UISourceCode.Events.TitleChanged,this.#S,this)}editorClosed(e){const t=e.data;this.historyManager.removeHistoryForSourceCode(t);let i=!1;this.editorContainer.currentFile()||(i=!0),this.removeToolbarChangedListener(),this.updateScriptViewToolbarItems(),this.searchableViewInternal.resetSearch();const o={uiSourceCode:t,wasSelected:i};this.dispatchEventToListeners("EditorClosed",o)}editorSelected(e){const t=e.data.previousView instanceof Kt?e.data.previousView:null;t&&t.setSearchableView(null);const i=e.data.currentView instanceof Kt?e.data.currentView:null;i&&i.setSearchableView(this.searchableViewInternal),this.searchableViewInternal.setReplaceable(Boolean(i?.canEditSource())),this.searchableViewInternal.refreshSearch(),this.updateToolbarChangedListener(),this.updateScriptViewToolbarItems();const o=this.editorContainer.currentFile();o&&this.dispatchEventToListeners("EditorSelected",o)}removeToolbarChangedListener(){this.toolbarChangedListener&&i.EventTarget.removeEventListeners([this.toolbarChangedListener]),this.toolbarChangedListener=null}updateToolbarChangedListener(){this.removeToolbarChangedListener();const e=this.currentSourceFrame();e&&(this.toolbarChangedListener=e.addEventListener("ToolbarItemsChanged",this.updateScriptViewToolbarItems,this))}onSearchCanceled(){this.searchView&&this.searchView.onSearchCanceled(),delete this.searchView,delete this.searchConfig}performSearch(e,t,i){const o=this.currentSourceFrame();o&&(this.searchView=o,this.searchConfig=e,this.searchView.performSearch(this.searchConfig,t,i))}jumpToNextSearchResult(){this.searchView&&(this.searchConfig&&this.searchView!==this.currentSourceFrame()?this.performSearch(this.searchConfig,!0):this.searchView.jumpToNextSearchResult())}jumpToPreviousSearchResult(){if(this.searchView)return this.searchConfig&&this.searchView!==this.currentSourceFrame()?(this.performSearch(this.searchConfig,!0),void(this.searchView&&this.searchView.jumpToLastSearchResult())):void this.searchView.jumpToPreviousSearchResult()}supportsCaseSensitiveSearch(){return!0}supportsRegexSearch(){return!0}replaceSelectionWith(e,t){const i=this.currentSourceFrame();i?i.replaceSelectionWith(e,t):console.assert(Boolean(i))}replaceAllWith(e,t){const i=this.currentSourceFrame();i?i.replaceAllWith(e,t):console.assert(Boolean(i))}showOutlineQuickOpen(){L.QuickOpen.QuickOpenImpl.show("@")}showGoToLineQuickOpen(){this.editorContainer.currentFile()&&L.QuickOpen.QuickOpenImpl.show(":")}save(){this.saveSourceFrame(this.currentSourceFrame())}saveAll(){this.editorContainer.fileViews().forEach(this.saveSourceFrame.bind(this))}saveSourceFrame(e){if(!(e instanceof Kt))return;e.commitEditing()}toggleBreakpointsActiveState(e){this.editorContainer.view.element.classList.toggle("breakpoints-deactivated",!e)}}const xi=[];function ki(e){xi.push(e)}function Ti(){return xi.map((e=>e()))}class Ei{static nextFile(e){function t(e){const t=e.lastIndexOf(".");return e.substr(0,-1!==t?t:e.length).toLowerCase()}const o=[],n=e.parentURL(),r=e.name(),s=t(r);for(const i of e.project().uiSourceCodes())n===i.parentURL()&&t(i.name())===s&&o.push(i.name());o.sort(l.StringUtilities.naturalOrderComparator);const a=l.NumberUtilities.mod(o.indexOf(r)+1,o.length),c=i.ParsedURL.ParsedURL.concatenate(n?i.ParsedURL.ParsedURL.concatenate(n,"/"):"",o[a]),d=e.project().uiSourceCodeForURL(c);return d!==e?d:null}handleAction(e,t){const i=e.flavor(yi);if(!i)return!1;const o=i.currentUISourceCode();if(!o)return!1;const n=Ei.nextFile(o);return!!n&&(i.showSourceLocation(n),!0)}}const Li=".headers";var Mi=Object.freeze({__proto__:null,SourcesView:yi,registerEditorAction:ki,getRegisteredEditorActions:Ti,SwitchFileActionDelegate:Ei,ActionDelegate:class{handleAction(e,t){const i=e.flavor(yi);if(!i)return!1;switch(t){case"sources.close-all":return i.editorContainer.closeAllFiles(),!0;case"sources.jump-to-previous-location":return i.onJumpToPreviousLocation(),!0;case"sources.jump-to-next-location":return i.onJumpToNextLocation(),!0;case"sources.next-editor-tab":return i.editorContainer.selectNextTab(),!0;case"sources.previous-editor-tab":return i.editorContainer.selectPrevTab(),!0;case"sources.close-editor-tab":return i.onCloseEditorTab();case"sources.go-to-line":return i.showGoToLineQuickOpen(),!0;case"sources.go-to-member":return i.showOutlineQuickOpen(),!0;case"sources.save":return i.save(),!0;case"sources.save-all":return i.saveAll(),!0}return!1}}});const Pi=new CSSStyleSheet;Pi.replaceSync(".thread-item{padding:3px 8px 3px 20px;position:relative;min-height:18px;line-height:15px;display:flex;flex-wrap:wrap}.thread-item + .thread-item{border-top:1px solid var(--sys-color-divider)}.thread-item:hover{background-color:var(--sys-color-state-hover-on-subtle)}.thread-item:focus-visible{background-color:var(--sys-color-tonal-container)}.thread-item-title,\n.thread-item-paused-state{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.thread-item-paused-state{color:var(--sys-color-state-disabled);margin-left:auto;padding:0 10px}.selected-thread-icon{display:none;position:absolute;top:3px;left:4px}.thread-item.selected .selected-thread-icon{display:block}@media (forced-colors: active){.thread-item:hover,\n .thread-item:focus-visible{forced-color-adjust:none;background-color:Highlight}.thread-item:hover > div,\n .thread-item:focus-visible > div{color:HighlightText}}\n/*# sourceURL=threadsSidebarPane.css */\n");const Fi={paused:"paused"},Di=e.i18n.registerUIStrings("panels/sources/ThreadsSidebarPane.ts",Fi),Ni=e.i18n.getLocalizedString.bind(void 0,Di);class Ai extends t.Widget.VBox{items;list;selectedModel;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.threads")}`),this.items=new t.ListModel.ListModel,this.list=new t.ListControl.ListControl(this.items,this,t.ListControl.ListMode.NonViewport);const e=t.Context.Context.instance().flavor(o.Target.Target);this.selectedModel=null!==e?e.model(o.DebuggerModel.DebuggerModel):null,this.contentElement.appendChild(this.list.element),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.targetFlavorChanged,this),o.TargetManager.TargetManager.instance().observeModels(o.DebuggerModel.DebuggerModel,this)}static shouldBeShown(){return o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel).length>=2}createElementForItem(e){const i=document.createElement("div");i.classList.add("thread-item");const n=i.createChild("div","thread-item-title"),s=i.createChild("div","thread-item-paused-state"),a=new r.Icon.Icon;a.data={iconName:"large-arrow-right-filled",color:"var(--icon-arrow-main-thread)",width:"14px",height:"14px"},a.classList.add("selected-thread-icon"),i.appendChild(a),i.tabIndex=-1,self.onInvokeElement(i,(i=>{t.Context.Context.instance().setFlavor(o.Target.Target,e.target()),i.consume(!0)}));const c=t.Context.Context.instance().flavor(o.Target.Target)===e.target();function l(){const t=e.runtimeModel().defaultExecutionContext();n.textContent=t&&t.label()?t.label():e.target().name()}function d(){s.textContent=e.isPaused()?Ni(Fi.paused):""}return i.classList.toggle("selected",c),t.ARIAUtils.setSelected(i,c),e.addEventListener(o.DebuggerModel.Events.DebuggerPaused,d),e.addEventListener(o.DebuggerModel.Events.DebuggerResumed,d),e.runtimeModel().addEventListener(o.RuntimeModel.Events.ExecutionContextChanged,l),o.TargetManager.TargetManager.instance().addEventListener("NameChanged",(function(t){t.data===e.target()&&l()})),d(),l(),i}heightForItem(e){return console.assert(!1),0}isItemSelectable(e){return!0}selectedItemChanged(e,t,i,o){i&&(i.tabIndex=-1);const n=o;n&&(this.setDefaultFocusedElement(n),n.tabIndex=0,this.hasFocus()&&n.focus())}updateSelectedItemARIA(e,t){return!1}modelAdded(e){this.items.insert(this.items.length,e);t.Context.Context.instance().flavor(o.Target.Target)===e.target()&&this.list.selectItem(e)}modelRemoved(e){this.items.remove(this.items.indexOf(e))}targetFlavorChanged({data:e}){const t=this.hasFocus(),i=e.model(o.DebuggerModel.DebuggerModel);this.list.selectItem(i),i&&this.list.refreshItem(i),null!==this.selectedModel&&this.list.refreshItem(this.selectedModel),this.selectedModel=i,t&&this.focus()}wasShown(){super.wasShown(),this.registerCSSFiles([Pi])}}var Ui=Object.freeze({__proto__:null,ThreadsSidebarPane:Ai});const Ri={dropWorkspaceFolderHere:"Drop workspace folder here",moreOptions:"More options",showNavigator:"Show navigator",hideNavigator:"Hide navigator",navigatorShown:"Navigator sidebar shown",navigatorHidden:"Navigator sidebar hidden",debuggerShown:"Debugger sidebar shown",debuggerHidden:"Debugger sidebar hidden",showDebugger:"Show debugger",hideDebugger:"Hide debugger",groupByFolder:"Group by folder",groupByAuthored:"Group by Authored/Deployed",hideIgnoreListed:"Hide ignore-listed sources",resumeWithAllPausesBlockedForMs:"Resume with all pauses blocked for 500 ms",terminateCurrentJavascriptCall:"Terminate current JavaScript call",pauseOnCaughtExceptions:"Pause on caught exceptions",revealInSidebar:"Reveal in navigator sidebar",continueToHere:"Continue to here",storeAsGlobalVariable:"Store as global variable",copyS:"Copy {PH1}",copyStringContents:"Copy string contents",copyStringAsJSLiteral:"Copy string as JavaScript literal",copyStringAsJSONLiteral:"Copy string as JSON literal",showFunctionDefinition:"Show function definition",openInSourcesPanel:"Open in Sources panel"},Bi=e.i18n.registerUIStrings("panels/sources/SourcesPanel.ts",Ri),ji=e.i18n.getLocalizedString.bind(void 0,Bi),Vi=new Set(["number","boolean","bigint","undefined"]);let Wi;class Oi extends t.Panel.Panel{workspace;togglePauseAction;stepOverAction;stepIntoAction;stepOutAction;stepAction;toggleBreakpointsActiveAction;debugToolbar;debugToolbarDrawer;debuggerPausedMessage;splitWidget;editorView;navigatorTabbedLocation;sourcesViewInternal;toggleNavigatorSidebarButton;toggleDebuggerSidebarButton;threadsSidebarPane;watchSidebarPane;callstackPane;liveLocationPool;lastModificationTime;pausedInternal;switchToPausedTargetTimeout;ignoreExecutionLineEvents;executionLineLocation;pauseOnExceptionButton;sidebarPaneStack;tabbedLocationHeader;extensionSidebarPanesContainer;sidebarPaneView;constructor(){super("sources"),C.Runtime.Runtime.isDescriptorEnabled({experiment:void 0,condition:C.Runtime.conditions.notSourcesHideAddFolder})&&new t.DropTarget.DropTarget(this.element,[t.DropTarget.Type.Folder],ji(Ri.dropWorkspaceFolderHere),this.handleDrop.bind(this)),this.workspace=f.Workspace.WorkspaceImpl.instance(),this.togglePauseAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-pause"),this.stepOverAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-over"),this.stepIntoAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-into"),this.stepOutAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step-out"),this.stepAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.step"),this.toggleBreakpointsActiveAction=t.ActionRegistry.ActionRegistry.instance().getAction("debugger.toggle-breakpoints-active"),this.debugToolbar=this.createDebugToolbar(),this.debugToolbarDrawer=this.createDebugToolbarDrawer(),this.debuggerPausedMessage=new Je;this.splitWidget=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-split-view-state",225),this.splitWidget.enableShowModeSaving(),this.splitWidget.show(this.element);this.editorView=new t.SplitWidget.SplitWidget(!0,!1,"sources-panel-navigator-split-view-state",225),this.editorView.enableShowModeSaving(),this.splitWidget.setMainWidget(this.editorView),this.navigatorTabbedLocation=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"navigator-view",!0,!0);const e=this.navigatorTabbedLocation.tabbedPane();e.setMinimumSize(100,25),e.element.classList.add("navigator-tabbed-pane"),e.headerElement().setAttribute("jslog",`${a.toolbar("navigator")}`);const n=new t.Toolbar.ToolbarMenuButton(this.populateNavigatorMenu.bind(this),!0,"more-options");if(n.setTitle(ji(Ri.moreOptions)),e.rightToolbar().appendToolbarItem(n),e.addEventListener(t.TabbedPane.Events.TabSelected,(({data:{tabId:e}})=>c.userMetrics.sourcesSidebarTabShown(e))),t.ViewManager.ViewManager.instance().hasViewsForLocation("run-view-sidebar")){const i=new t.SplitWidget.SplitWidget(!1,!0,"source-panel-navigator-sidebar-split-view-state");i.setMainWidget(e);const o=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealNavigatorSidebar.bind(this),"run-view-sidebar").tabbedPane();i.setSidebarWidget(o),i.installResizer(o.headerElement()),this.editorView.setSidebarWidget(i)}else this.editorView.setSidebarWidget(e);this.sourcesViewInternal=new yi,this.sourcesViewInternal.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.toggleNavigatorSidebarButton=this.editorView.createShowHideSidebarButton(ji(Ri.showNavigator),ji(Ri.hideNavigator),ji(Ri.navigatorShown),ji(Ri.navigatorHidden),"navigator"),this.toggleDebuggerSidebarButton=this.splitWidget.createShowHideSidebarButton(ji(Ri.showDebugger),ji(Ri.hideDebugger),ji(Ri.debuggerShown),ji(Ri.debuggerHidden),"debugger"),this.editorView.setMainWidget(this.sourcesViewInternal),this.threadsSidebarPane=null,this.watchSidebarPane=t.ViewManager.ViewManager.instance().view("sources.watch"),this.callstackPane=Z.instance(),i.Settings.Settings.instance().moduleSetting("sidebar-position").addChangeListener(this.updateSidebarPosition.bind(this)),this.updateSidebarPosition(),this.updateDebuggerButtonsAndStatus(),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.setTarget(t.Context.Context.instance().flavor(o.Target.Target)),i.Settings.Settings.instance().moduleSetting("breakpoints-active").addChangeListener(this.breakpointsActiveStateChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.Target.Target,this.onCurrentTargetChanged,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerWasEnabled,this.debuggerWasEnabled,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerPaused,this.debuggerPaused,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebuggerResumed,(e=>this.debuggerResumed(e.data))),o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.GlobalObjectCleared,(e=>this.debuggerResumed(e.data))),k.ExtensionServer.ExtensionServer.instance().addEventListener("SidebarPaneAdded",this.extensionSidebarPaneAdded,this),o.TargetManager.TargetManager.instance().observeTargets(this),this.lastModificationTime=-1/0}static instance(e={forceNew:null}){const{forceNew:t}=e;return Wi&&!t||(Wi=new Oi),Wi}static updateResizerAndSidebarButtons(e){e.sourcesViewInternal.leftToolbar().removeToolbarItems(),e.sourcesViewInternal.rightToolbar().removeToolbarItems(),e.sourcesViewInternal.bottomToolbar().removeToolbarItems();const i=t.Context.Context.instance().flavor(qi)&&!t.InspectorView.InspectorView.instance().isDrawerMinimized();e.splitWidget.isVertical()||i?e.splitWidget.uninstallResizer(e.sourcesViewInternal.toolbarContainerElement()):e.splitWidget.installResizer(e.sourcesViewInternal.toolbarContainerElement()),i||(e.sourcesViewInternal.leftToolbar().appendToolbarItem(e.toggleNavigatorSidebarButton),e.splitWidget.isVertical()?e.sourcesViewInternal.rightToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton):e.sourcesViewInternal.bottomToolbar().appendToolbarItem(e.toggleDebuggerSidebarButton))}targetAdded(e){this.showThreadsIfNeeded()}targetRemoved(e){}showThreadsIfNeeded(){Ai.shouldBeShown()&&!this.threadsSidebarPane&&(this.threadsSidebarPane=t.ViewManager.ViewManager.instance().view("sources.threads"),this.sidebarPaneStack&&this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane,this.splitWidget.isVertical()?this.watchSidebarPane:this.callstackPane))}setTarget(e){if(!e)return;const t=e.model(o.DebuggerModel.DebuggerModel);t&&(t.isPaused()?this.showDebuggerPausedDetails(t.debuggerPausedDetails()):(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0)))}onCurrentTargetChanged({data:e}){this.setTarget(e)}paused(){return this.pausedInternal||!1}wasShown(){t.Context.Context.instance().setFlavor(Oi,this),this.registerCSSFiles([wt]),super.wasShown(),t.Context.Context.instance().flavor(qi)&&(t.InspectorView.InspectorView.instance().setDrawerMinimized(!0),Oi.updateResizerAndSidebarButtons(this)),this.editorView.setMainWidget(this.sourcesViewInternal)}willHide(){super.willHide(),t.Context.Context.instance().setFlavor(Oi,null);const e=t.Context.Context.instance().flavor(qi);e&&(e.showViewInWrapper(),t.InspectorView.InspectorView.instance().setDrawerMinimized(!1),Oi.updateResizerAndSidebarButtons(this))}resolveLocation(e){return"sources.sidebar-top"===e||"sources.sidebar-bottom"===e||"sources.sidebar-tabs"===e?this.sidebarPaneStack||null:this.navigatorTabbedLocation}ensureSourcesViewVisible(){return!!t.Context.Context.instance().flavor(qi)||!!t.InspectorView.InspectorView.instance().canSelectPanel("sources")&&(t.ViewManager.ViewManager.instance().showView("sources"),!0)}onResize(){"auto"===i.Settings.Settings.instance().moduleSetting("sidebar-position").get()&&this.element.window().requestAnimationFrame(this.updateSidebarPosition.bind(this))}searchableView(){return this.sourcesViewInternal.searchableView()}toggleNavigatorSidebar(){this.editorView.toggleSidebar()}toggleDebuggerSidebar(){this.splitWidget.toggleSidebar()}debuggerPaused(e){const n=e.data,r=n.debuggerPausedDetails();!this.pausedInternal&&i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&this.setAsCurrentPanel(),t.Context.Context.instance().flavor(o.Target.Target)===n.target()?this.showDebuggerPausedDetails(r):this.pausedInternal||t.Context.Context.instance().setFlavor(o.Target.Target,n.target())}debugInfoAttached(e){const{debuggerModel:i}=e.data;if(!i.isPaused())return;const n=i.debuggerPausedDetails();n&&t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.showDebuggerPausedDetails(n)}showDebuggerPausedDetails(e){this.pausedInternal=!0,this.updateDebuggerButtonsAndStatus(),t.Context.Context.instance().setFlavor(o.DebuggerModel.DebuggerPausedDetails,e),this.toggleDebuggerSidebarButton.setEnabled(!1),this.revealDebuggerSidebar(),window.focus(),c.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront()}debuggerResumed(e){const i=e.target();t.Context.Context.instance().flavor(o.Target.Target)===i&&(this.pausedInternal=!1,this.clearInterface(),this.toggleDebuggerSidebarButton.setEnabled(!0),this.switchToPausedTargetTimeout=window.setTimeout(this.switchToPausedTarget.bind(this,e),500))}debuggerWasEnabled(e){const i=e.data;t.Context.Context.instance().flavor(o.Target.Target)===i.target()&&this.updateDebuggerButtonsAndStatus()}get visibleView(){return this.sourcesViewInternal.visibleView()}showUISourceCode(e,i,o){if(o){if(!this.isShowing()&&!t.Context.Context.instance().flavor(qi))return}else this.showEditor();this.sourcesViewInternal.showSourceLocation(e,i,o)}showEditor(){t.Context.Context.instance().flavor(qi)||this.setAsCurrentPanel()}showUILocation(e,t){const{uiSourceCode:i,lineNumber:o,columnNumber:n}=e;this.showUISourceCode(i,{lineNumber:o,columnNumber:n},t)}async revealInNavigator(e,i){const o=t.ViewManager.ViewManager.instance();for(const t of o.viewsForLocation("navigator-view")){const o=await t.widget();if(o instanceof ut&&o.acceptProject(e.project())){o.revealUISourceCode(e,!0),this.navigatorTabbedLocation.tabbedPane().selectTab(t.viewId(),!0),i||(this.editorView.showBoth(!0),o.focus());break}}}addExperimentMenuItem(e,t,o){e.appendCheckboxItem(o,(function(){const e=C.Runtime.experiments.isEnabled(t);C.Runtime.experiments.setEnabled(t,!e),c.userMetrics.experimentChanged(t,e);const o=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");o.set(o.get())}),{checked:C.Runtime.experiments.isEnabled(t),additionalElement:r.Icon.create("experiment"),jslogContext:l.StringUtilities.toKebabCase(t)})}populateNavigatorMenu(e){const t=i.Settings.Settings.instance().moduleSetting("navigator-group-by-folder");e.appendItemsAtLocation("navigatorMenu"),e.viewSection().appendCheckboxItem(ji(Ri.groupByFolder),(()=>t.set(!t.get())),{checked:t.get(),jslogContext:t.name}),this.addExperimentMenuItem(e.viewSection(),"authored-deployed-grouping",ji(Ri.groupByAuthored)),this.addExperimentMenuItem(e.viewSection(),"just-my-code",ji(Ri.hideIgnoreListed))}setIgnoreExecutionLineEvents(e){this.ignoreExecutionLineEvents=e}updateLastModificationTime(){this.lastModificationTime=window.performance.now()}async executionLineChanged(e){const t=await e.uiLocation();e.isDisposed()||t&&(window.performance.now()-this.lastModificationTimee.debuggerModel===i.debuggerModel));n&&this.prepareToResume()&&n.continueToLocation()}toggleBreakpointsActive(){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!i.Settings.Settings.instance().moduleSetting("breakpoints-active").get())}breakpointsActiveStateChanged(){const e=i.Settings.Settings.instance().moduleSetting("breakpoints-active").get();this.toggleBreakpointsActiveAction.setToggled(!e),this.sourcesViewInternal.toggleBreakpointsActiveState(e)}createDebugToolbar(){const e=new t.Toolbar.Toolbar("scripts-debug-toolbar");e.element.setAttribute("jslog",`${a.toolbar("debug")}`);const i=new t.Toolbar.ToolbarButton(ji(Ri.resumeWithAllPausesBlockedForMs),"play");i.addEventListener("Click",this.longResume,this);const o=new t.Toolbar.ToolbarButton(ji(Ri.terminateCurrentJavascriptCall),"stop");return o.addEventListener("Click",this.terminateExecution,this),e.appendToolbarItem(t.Toolbar.Toolbar.createLongPressActionButton(this.togglePauseAction,[o,i],[])),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOverAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepIntoAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepOutAction)),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.stepAction)),e.appendSeparator(),e.appendToolbarItem(t.Toolbar.Toolbar.createActionButton(this.toggleBreakpointsActiveAction)),e}createDebugToolbarDrawer(){const e=document.createElement("div");e.classList.add("scripts-debug-toolbar-drawer");const o=ji(Ri.pauseOnCaughtExceptions),n=i.Settings.Settings.instance().moduleSetting("pause-on-caught-exception");return e.appendChild(t.SettingsUI.createSettingCheckbox(o,n,!0)),e}appendApplicableItems(e,t,i){i instanceof f.UISourceCode.UISourceCode?this.appendUISourceCodeItems(e,t,i):i instanceof Kt?this.appendUISourceCodeFrameItems(t,i):i instanceof f.UISourceCode.UILocation?this.appendUILocationItems(t,i):i instanceof o.RemoteObject.RemoteObject?this.appendRemoteObjectItems(t,i):this.appendNetworkRequestItems(t,i)}appendUISourceCodeItems(e,t,i){if(!e.target)return;const o=e.target;i.project().isServiceProject()||o.isSelfOrDescendant(this.navigatorTabbedLocation.widget().element)||C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||t.revealSection().appendItem(ji(Ri.revealInSidebar),this.revealInNavigator.bind(this,i),{jslogContext:"sources.reveal-in-navigator-sidebar"}),i.contentType().hasScripts()&&u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(i).every((e=>e.isJavaScript()))&&this.callstackPane.appendIgnoreListURLContextMenuItems(t,i)}appendUISourceCodeFrameItems(e,t){t.uiSourceCode().contentType().isFromSourceMap()||t.textEditor.state.selection.main.empty||e.debugSection().appendAction("debugger.evaluate-selection")}appendUILocationItems(e,i){const n=i.uiSourceCode;if(!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptsForUISourceCode(n).every((e=>e.isJavaScript())))return;if(n.contentType().hasScripts()){const r=t.Context.Context.instance().flavor(o.Target.Target),s=r?r.model(o.DebuggerModel.DebuggerModel):null;s&&s.isPaused()&&e.debugSection().appendItem(ji(Ri.continueToHere),this.continueToLocation.bind(this,i),{jslogContext:"continue-to-here"}),this.callstackPane.appendIgnoreListURLContextMenuItems(e,n)}}appendRemoteObjectItems(e,n){const r=i.Settings.Settings.instance().moduleSetting("text-editor-indent").get(),s=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);const a="wasm"===n.type?n.subtype:"node"===n.subtype?"outerHTML":n.type;e.debugSection().appendItem(ji(Ri.storeAsGlobalVariable),(()=>s?.target().model(o.ConsoleModel.ConsoleModel)?.saveToTempVariable(s,n)),{jslogContext:"store-as-global-variable"});const d=e.clipboardSection(),u=c.InspectorFrontendHost.InspectorFrontendHostInstance;if("string"===n.type)d.appendItem(ji(Ri.copyStringContents),(()=>{u.copyText(n.value)}),{jslogContext:"copy-string-contents"}),d.appendItem(ji(Ri.copyStringAsJSLiteral),(()=>{u.copyText(l.StringUtilities.formatAsJSLiteral(n.value))}),{jslogContext:"copy-string-as-js-literal"}),d.appendItem(ji(Ri.copyStringAsJSONLiteral),(()=>{u.copyText(JSON.stringify(n.value))}),{jslogContext:"copy-string-as-json-literal"});else if(Vi.has(n.type))d.appendItem(ji(Ri.copyS,{PH1:String(a)}),(()=>{u.copyText(n.description)}),{jslogContext:"copy-primitive"});else if("object"===n.type){const e=async()=>{const e=await n.callFunctionJSON(h,[{value:{subtype:n.subtype,indent:r}}]);u.copyText(e)};d.appendItem(ji(Ri.copyS,{PH1:String(a)}),e,{jslogContext:"copy-object"})}else"function"===n.type&&e.debugSection().appendItem(ji(Ri.showFunctionDefinition),this.showFunctionDefinition.bind(this,n),{jslogContext:"show-function-definition"});function h(e){const t=e.subtype,i=e.indent;if("map"!==t){if("set"!==t){if("node"===t)return this instanceof Element?this.outerHTML:void 0;if(t&&void 0===this)return String(t);try{return JSON.stringify(this,null,i)}catch(e){return String(this)}}else if(this instanceof Set){const e=Array.from(this.values());return`new Set(${0===e.length?"":JSON.stringify(e,null,i)})`}}else if(this instanceof Map){const e=Array.from(this.entries());return`new Map(${0===e.length?"":JSON.stringify(e,null,i)})`}}}appendNetworkRequestItems(e,t){const i=this.workspace.uiSourceCodeForURL(t.url());if(!i)return;const o=ji(Ri.openInSourcesPanel),n=this.showUILocation.bind(this,i.uiLocation(0,0));e.revealSection().appendItem(o,n,{jslogContext:"reveal-in-sources"})}showFunctionDefinition(e){o.RemoteObject.RemoteFunction.objectAsFunction(e).targetFunction().then((e=>e.debuggerModel().functionDetailsPromise(e).then(this.didGetFunctionDetails.bind(this))))}async didGetFunctionDetails(e){if(!e||!e.location)return;const t=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e.location);t&&this.showUILocation(t)}revealNavigatorSidebar(){this.setAsCurrentPanel(),this.editorView.showBoth(!0)}revealDebuggerSidebar(){i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get()&&(this.setAsCurrentPanel(),this.splitWidget.showBoth(!0))}updateSidebarPosition(){let e;const o=i.Settings.Settings.instance().moduleSetting("sidebar-position").get();if(e="right"!==o&&("bottom"===o||t.InspectorView.InspectorView.instance().element.offsetWidth<680),this.sidebarPaneView&&e===!this.splitWidget.isVertical())return;if(this.sidebarPaneView&&this.sidebarPaneView.shouldHideOnDetach())return;this.sidebarPaneView&&this.sidebarPaneView.detach(),this.splitWidget.setVertical(!e),this.splitWidget.element.classList.toggle("sources-split-view-vertical",e),Oi.updateResizerAndSidebarButtons(this);const n=new t.Widget.VBox;n.element.appendChild(this.debugToolbar.element),n.element.appendChild(this.debugToolbarDrawer),n.setMinimumAndPreferredSizes(_i,25,_i,100),this.sidebarPaneStack=t.ViewManager.ViewManager.instance().createStackLocation(this.revealDebuggerSidebar.bind(this),void 0,"debug"),this.sidebarPaneStack.widget().element.classList.add("overflow-auto"),this.sidebarPaneStack.widget().show(n.element),this.sidebarPaneStack.widget().element.appendChild(this.debuggerPausedMessage.element()),this.sidebarPaneStack.appendApplicableItems("sources.sidebar-top"),this.threadsSidebarPane&&this.sidebarPaneStack.appendView(this.threadsSidebarPane);const r=t.ViewManager.ViewManager.instance().view("sources.js-breakpoints"),s=t.ViewManager.ViewManager.instance().view("sources.scope-chain");if(this.tabbedLocationHeader&&(this.splitWidget.uninstallResizer(this.tabbedLocationHeader),this.tabbedLocationHeader=null),e){const e=new t.SplitWidget.SplitWidget(!0,!0,"sources-panel-debugger-sidebar-split-view-state",.5);e.setMainWidget(n),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(this.callstackPane);const i=t.ViewManager.ViewManager.instance().createTabbedLocation(this.revealDebuggerSidebar.bind(this));e.setSidebarWidget(i.tabbedPane()),this.tabbedLocationHeader=i.tabbedPane().headerElement(),this.splitWidget.installResizer(this.tabbedLocationHeader),this.splitWidget.installResizer(this.debugToolbar.gripElementForResize()),i.appendView(s),i.appendView(this.watchSidebarPane),i.appendApplicableItems("sources.sidebar-tabs"),this.extensionSidebarPanesContainer=i,this.sidebarPaneView=e}else this.sidebarPaneStack.appendView(this.watchSidebarPane),this.sidebarPaneStack.showView(r),this.sidebarPaneStack.showView(s),this.sidebarPaneStack.showView(this.callstackPane),this.extensionSidebarPanesContainer=this.sidebarPaneStack,this.sidebarPaneView=n,this.splitWidget.uninstallResizer(this.debugToolbar.gripElementForResize());this.sidebarPaneStack.appendApplicableItems("sources.sidebar-bottom");const a=k.ExtensionServer.ExtensionServer.instance().sidebarPanes();for(let e=0;e{Oi.updateResizerAndSidebarButtons(Oi.instance())})),super.willHide(),t.Context.Context.instance().setFlavor(qi,null)}showViewInWrapper(){this.view.show(this.element)}}var $i=Object.freeze({__proto__:null,SourcesPanel:Oi,get lastModificationTimeout(){return Hi},minToolbarWidth:_i,UILocationRevealer:class{async reveal(e,t){Oi.instance().showUILocation(e,t)}},UILocationRangeRevealer:zi,DebuggerLocationRevealer:class{async reveal(e,t){const i=await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);i&&Oi.instance().showUILocation(i,t)}},UISourceCodeRevealer:class{async reveal(e,t){Oi.instance().showUISourceCode(e,void 0,t)}},DebuggerPausedDetailsRevealer:class{async reveal(e){if(i.Settings.Settings.instance().moduleSetting("auto-focus-on-debugger-paused-enabled").get())return Oi.instance().setAsCurrentPanel()}},RevealingActionDelegate:class{handleAction(e,o){const n=Oi.instance();if(!n.ensureSourcesViewVisible())return!1;if("debugger.toggle-pause"===o){return e.flavor(t.ShortcutRegistry.ForwardedShortcut)&&!i.Settings.Settings.instance().moduleSetting("disable-paused-state-overlay").get()||n.togglePause(),!0}return!1}},ActionDelegate:class{handleAction(e,t){const i=Oi.instance();switch(t){case"debugger.step-over":return i.stepOver(),!0;case"debugger.step-into":return i.stepIntoAsync(),!0;case"debugger.step":return i.stepInto(),!0;case"debugger.step-out":return i.stepOut(),!0;case"debugger.run-snippet":return i.runSnippet(),!0;case"debugger.toggle-breakpoints-active":return i.toggleBreakpointsActive(),!0;case"debugger.evaluate-selection":{const t=e.flavor(Kt);if(t){const{state:i}=t.textEditor;let n=i.sliceDoc(i.selection.main.from,i.selection.main.to);const r=e.flavor(o.RuntimeModel.ExecutionContext),s=r?.target().model(o.ConsoleModel.ConsoleModel);if(r&&s){const e=s.addCommandMessage(r,n);n=y.JavaScriptREPL.JavaScriptREPL.wrapObjectLiteral(n),s.evaluateCommandInConsole(r,e,n,!0)}}return!0}case"sources.reveal-in-navigator-sidebar":{const e=i.sourcesView().currentUISourceCode();return null!==e&&(i.revealInNavigator(e),!0)}case"sources.toggle-navigator-sidebar":return i.toggleNavigatorSidebar(),!0;case"sources.toggle-debugger-sidebar":return i.toggleDebuggerSidebar(),!0}return!1}},QuickSourceView:qi});const{EMPTY_BREAKPOINT_CONDITION:Gi,NEVER_PAUSE_HERE_CONDITION:Ki}=w.BreakpointManager,Ji={thisScriptIsOnTheDebuggersIgnore:"This script is on the debugger's ignore list",removeFromIgnoreList:"Remove from ignore list",configure:"Configure",addBreakpoint:"Add breakpoint",addConditionalBreakpoint:"Add conditional breakpoint…",addLogpoint:"Add logpoint…",neverPauseHere:"Never pause here",removeBreakpoint:"{n, plural, =1 {Remove breakpoint} other {Remove all breakpoints in line}}",editBreakpoint:"Edit breakpoint…",disableBreakpoint:"{n, plural, =1 {Disable breakpoint} other {Disable all breakpoints in line}}",enableBreakpoint:"{n, plural, =1 {Enable breakpoint} other {Enable all breakpoints in line}}",addSourceMap:"Add source map…",addWasmDebugInfo:"Add DWARF debug info…",sourceMapLoaded:"Source map loaded.",associatedFilesAreAvailable:"Associated files are available via file tree or {PH1}.",associatedFilesShouldBeAdded:"Associated files should be added to the file tree. You can debug these resolved source files as regular JavaScript files.",theDebuggerWillSkipStepping:"The debugger will skip stepping through this script, and will not stop on exceptions.",sourceMapSkipped:"Source map skipped for this file.",sourceMapFailed:"Source map failed to load.",debuggingPowerReduced:"DevTools can't show authored sources, but you can debug the deployed code.",reloadForSourceMap:"To enable again, make sure the file isn't on the ignore list and reload.",errorLoading:"Error loading url {PH1}: {PH2}",ignoreScript:"Ignore this file",ignoreContentScripts:"Ignore extension scripts",debugFileNotFound:'Failed to load debug file "{PH1}".',debugInfoNotFound:"Failed to load any debug info for {PH1}."},Xi=e.i18n.registerUIStrings("panels/sources/DebuggerPlugin.ts",Ji),Yi=e.i18n.getLocalizedString.bind(void 0,Xi),Qi=new Map;class Zi extends pe{transformer;editor=void 0;executionLocation=null;controlDown=!1;controlTimeout=void 0;sourceMapInfobar=null;scriptsPanel;breakpointManager;popoverHelper=null;scriptFileForDebuggerModel;breakpoints=[];continueToLocations=null;liveLocationPool;muted;initializedMuted;ignoreListInfobar;refreshBreakpointsTimeout=void 0;activeBreakpointDialog=null;#I=void 0;#y=!1;missingDebugInfoBar=null;#x=!1;loader;ignoreListCallback;constructor(e,i){super(e),this.transformer=i,Qi.set(e,this),this.scriptsPanel=Oi.instance(),this.breakpointManager=w.BreakpointManager.BreakpointManager.instance(),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.addEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.addEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),this.scriptFileForDebuggerModel=new Map,this.loader=o.PageResourceLoader.PageResourceLoader.instance(),this.loader.addEventListener("Update",this.showSourceMapInfobarIfNeeded.bind(this),this),this.ignoreListCallback=this.showIgnoreListInfobarIfNeeded.bind(this),u.IgnoreListManager.IgnoreListManager.instance().addChangeListener(this.ignoreListCallback),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool=new u.LiveLocation.LiveLocationPool,this.updateScriptFiles(),this.muted=this.uiSourceCode.isDirty(),this.initializedMuted=this.muted,this.ignoreListInfobar=null,this.showIgnoreListInfobarIfNeeded();for(const e of this.scriptFileForDebuggerModel.values())e.checkMapping()}editorExtension(){const e=this.shortcutHandlers();return[n.EditorView.updateListener.of((e=>this.onEditorUpdate(e))),n.EditorView.domEventHandlers({keydown:t=>!!this.onKeyDown(t)||(e(t),t.defaultPrevented),keyup:e=>this.onKeyUp(e),mousemove:e=>this.onMouseMove(e),mousedown:e=>this.onMouseDown(e),focusout:e=>this.onBlur(e),wheel:e=>this.onWheel(e)}),n.lineNumbers({domEventHandlers:{mousedown:(e,t,i)=>this.handleGutterClick(e.state.doc.lineAt(t.from),i)}}),io,so,n.Prec.highest(go.field),n.Prec.lowest(So.field),wo,yo.field,n.Prec.lowest(Fo.field),Do,this.uiSourceCode.project().type()===f.Workspace.projectTypes.Debugger?n.EditorView.editorAttributes.of({class:"source-frame-debugger-script"}):[]]}shortcutHandlers(){const e=e=>e.state.doc.lineAt(e.state.selection.main.head);return t.ShortcutRegistry.ShortcutRegistry.instance().getShortcutListener({"debugger.toggle-breakpoint":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!1),!0),"debugger.toggle-breakpoint-enabled":async()=>!(this.muted||!this.editor)&&(await this.toggleBreakpoint(e(this.editor),!0),!0),"debugger.breakpoint-input-window":async()=>{if(this.muted||!this.editor)return!1;const t=e(this.editor);return c.userMetrics.breakpointEditDialogRevealedFrom(4),this.#k(t),!0}})}#k(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.breakpoints.find((t=>t.position>=e.from&&t.position<=e.to))?.breakpoint||null;void 0===t&&null!==i&&(t=i.isLogpoint()),this.editBreakpointCondition({line:e,breakpoint:i,location:null,isLogpoint:t})}editorInitialized(e){this.editor=e,async function(e,t,i){const o=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance(),n=await o.getMappedLines(i);if(!n)return[];const r=[];for(let i=0;i{t.length&&e.dispatch({effects:m.SourceFrame.addNonBreakableLines.of(t)})}),console.error),this.ignoreListInfobar&&this.attachInfobar(this.ignoreListInfobar),this.missingDebugInfoBar&&this.attachInfobar(this.missingDebugInfoBar),this.sourceMapInfobar&&this.attachInfobar(this.sourceMapInfobar),this.muted||this.refreshBreakpoints(),this.callFrameChanged(),this.popoverHelper?.dispose(),this.popoverHelper=new t.PopoverHelper.PopoverHelper(e,this.getPopoverRequest.bind(this),"sources.object-properties"),this.popoverHelper.setDisableOnClick(!0),this.popoverHelper.setTimeout(250,250),this.popoverHelper.setHasPadding(!0)}static accepts(e){return e.contentType().hasScripts()}showIgnoreListInfobarIfNeeded(){const e=this.uiSourceCode;if(!e.contentType().hasScripts())return;if(!u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return void this.hideIgnoreListInfobar();this.ignoreListInfobar&&this.ignoreListInfobar.dispose();const i=new t.Infobar.Infobar("warning",Yi(Ji.thisScriptIsOnTheDebuggersIgnore),[{text:Yi(Ji.removeFromIgnoreList),highlight:!1,delegate:function(){u.IgnoreListManager.IgnoreListManager.instance().unIgnoreListUISourceCode(e)},dismiss:!0,jslogContext:"remove-from-ignore-list"},{text:Yi(Ji.configure),highlight:!1,delegate:t.ViewManager.ViewManager.instance().showView.bind(t.ViewManager.ViewManager.instance(),"blackbox"),dismiss:!1,jslogContext:"configure"}],void 0,void 0,"script-on-ignore-list");this.ignoreListInfobar=i,i.setCloseCallback((()=>this.removeInfobar(this.ignoreListInfobar))),i.createDetailsRowMessage(Yi(Ji.theDebuggerWillSkipStepping)),this.attachInfobar(this.ignoreListInfobar)}attachInfobar(e){this.editor&&this.editor.dispatch({effects:eo.of(e)})}removeInfobar(e){this.editor&&e&&this.editor.dispatch({effects:to.of(e)})}hideIgnoreListInfobar(){this.ignoreListInfobar&&(this.ignoreListInfobar.dispose(),this.ignoreListInfobar=null)}willHide(){this.popoverHelper?.hidePopover()}editBreakpointLocation({breakpoint:e,uiLocation:t}){const{lineNumber:i}=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber),o=this.editor?.state.doc.line(i+1);o&&this.editBreakpointCondition({line:o,breakpoint:e,location:null,isLogpoint:e.isLogpoint()})}populateLineGutterContextMenu(e,t){const i=new f.UISourceCode.UILocation(this.uiSourceCode,t,0);if(this.scriptsPanel.appendUILocationItems(e,i),this.muted||!this.editor)return;const o=this.editor.state.doc.line(t+1),n=this.lineBreakpoints(o),r=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode);if(n.length){const t=Yi(Ji.removeBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>{c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterContextMenu),e.remove(!1)}))),{jslogContext:"remove-breakpoint"}),1===n.length&&r&&e.debugSection().appendItem(Yi(Ji.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:o,breakpoint:n[0],location:null})}),{jslogContext:"edit-breakpoint"});if(n.some((e=>e.enabled()))){const t=Yi(Ji.disableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!1)))),{jslogContext:"enable-breakpoint"})}if(n.some((e=>!e.enabled()))){const t=Yi(Ji.enableBreakpoint,{n:n.length});e.debugSection().appendItem(t,(()=>n.forEach((e=>e.setEnabled(!0)))),{jslogContext:"disable-breakpoint"})}}else this.editor&&m.SourceFrame.isBreakableLine(this.editor.state,o)&&(e.debugSection().appendItem(Yi(Ji.addBreakpoint),this.createNewBreakpoint.bind(this,o,Gi,!0,!1),{jslogContext:"add-breakpoint"}),r&&(e.debugSection().appendItem(Yi(Ji.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),e.debugSection().appendItem(Yi(Ji.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(3),this.editBreakpointCondition({line:o,breakpoint:null,location:null,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),e.debugSection().appendItem(Yi(Ji.neverPauseHere),this.createNewBreakpoint.bind(this,o,Ki,!0,!1),{jslogContext:"never-pause-here"})))}populateTextAreaContextMenu(e){function t(e,t){t&&e.addSourceMapURL(t)}function o(e,t){t&&e.addDebugInfoURL(t)}if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.Network&&i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get()&&!u.IgnoreListManager.IgnoreListManager.instance().isUserIgnoreListedURL(this.uiSourceCode.url())&&this.scriptFileForDebuggerModel.size){const i=this.scriptFileForDebuggerModel.values().next().value,n=Yi(Ji.addSourceMap);e.debugSection().appendItem(n,function(e){V.createAddSourceMapURLDialog(t.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-source-map"}),i.script?.isWasm()&&!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().pluginManager.hasPluginForScript(i.script)&&e.debugSection().appendItem(Yi(Ji.addWasmDebugInfo),function(e){V.createAddDWARFSymbolsURLDialog(o.bind(null,e)).show()}.bind(null,i),{jslogContext:"add-wasm-debug-info"})}}workingCopyChanged(){this.scriptFileForDebuggerModel.size||this.setMuted(this.uiSourceCode.isDirty())}workingCopyCommitted(){this.scriptsPanel.updateLastModificationTime(),this.scriptFileForDebuggerModel.size||this.setMuted(!1)}didMergeToVM(){this.consistentScripts()&&this.setMuted(!1)}didDivergeFromVM(){this.setMuted(!0)}setMuted(e){this.initializedMuted||e!==this.muted&&(this.muted=e,e?this.editor&&this.editor.dispatch({effects:no.of(null)}):this.restoreBreakpointsAfterEditing())}consistentScripts(){for(const e of this.scriptFileForDebuggerModel.values())if(e.hasDivergedFromVM()||e.isMergingToVM())return!1;return!0}isVariableIdentifier(e){return"VariableName"===e||"VariableDefinition"===e}isIdentifier(e){return"VariableName"===e||"VariableDefinition"===e||"PropertyName"===e||"PropertyDefinition"===e}getPopoverRequest(e){if(t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return null;const i=t.Context.Context.instance().flavor(o.Target.Target),r=i?i.model(o.DebuggerModel.DebuggerModel):null,{editor:s}=this;if(!r||!r.isPaused()||!s)return null;const a=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!a)return null;let c=s.editor.posAtCoords(e);if(!c)return null;const l=s.editor.coordsAtPos(c);if(!l||e.clientYl.bottom||e.clientXl.right+30)return null;e.clientXs.state.doc.lineAt(c).from&&(c-=1);const d=Lo(s.state,this.uiSourceCode.mimeType(),c);if(!d)return null;const u=s.state.doc.lineAt(d.from);if(d.to>u.to)return null;const h=s.editor.coordsAtPos(d.from),g=s.editor.coordsAtPos(d.to);if(!h||!g)return null;const m=new AnchorBox(h.left,h.top-2,g.right-h.left,g.bottom-h.top),b=s.state.sliceDoc(d.from,d.to);let f=null;return{box:m,show:async e=>{let i="";if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const e=await p.NamesResolver.allVariablesInCallFrame(a);try{i=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(b,e)}catch{}}else i=await p.NamesResolver.resolveExpression(a,b,this.uiSourceCode,u.number-1,d.from-u.from,d.to-u.from);const c=C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")&&d.containsSideEffects,l=await a.evaluate({expression:i||b,objectGroup:"popover",includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1,throwOnSideEffect:c,timeout:void 0,disableBreaks:void 0,replMode:void 0,allowUnsafeEvalBlockedByCSP:void 0});if(!l||"error"in l||!l.object||"object"===l.object.type&&"error"===l.object.subtype)return!1;f=await y.ObjectPopoverHelper.ObjectPopoverHelper.buildObjectPopover(l.object,e);const h=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!f||a!==h)return r.runtimeModel().releaseObjectGroup("popover"),f&&f.dispose(),!1;const g=n.Decoration.set(Po.range(d.from,d.to));return s.dispatch({effects:Fo.update.of(g)}),!0},hide:()=>{f&&f.dispose(),r.runtimeModel().releaseObjectGroup("popover"),s.dispatch({effects:Fo.update.of(n.Decoration.none)})}}}onEditorUpdate(e){if(!e.changes.empty)for(const t of this.breakpoints)t.position=e.changes.mapPos(t.position)}onWheel(e){this.executionLocation&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&e.preventDefault()}onKeyDown(e){const i=t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e);return i||this.setControlDown(!1),e.key===l.KeyboardUtilities.ESCAPE_KEY&&this.popoverHelper&&this.popoverHelper.isPopoverVisible()?(this.popoverHelper.hidePopover(),e.consume(),!0):(i&&this.executionLocation&&this.setControlDown(!0),!1)}onMouseMove(e){this.executionLocation&&this.controlDown&&t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e)&&(this.continueToLocations||this.showContinueToLocations())}onMouseDown(e){if(!this.executionLocation||!t.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(e))return;if(!this.continueToLocations||!this.editor)return;e.consume();const i=this.editor.editor.posAtCoords(e);if(null!==i)for(const{from:e,to:t,click:o}of this.continueToLocations)if(e<=i&&t>=i){o();break}}onBlur(e){this.setControlDown(!1)}onKeyUp(e){this.setControlDown(!1)}setControlDown(e){e!==this.controlDown&&(this.controlDown=e,clearTimeout(this.controlTimeout),this.controlTimeout=void 0,e&&this.executionLocation?this.controlTimeout=window.setTimeout((()=>{this.executionLocation&&this.controlDown&&this.showContinueToLocations()}),150):this.clearContinueToLocations())}editBreakpointCondition(e){const{line:t,breakpoint:i,location:o,isLogpoint:r}=e;if(i?.isRemoved)return;this.#y=!1;if(this.#I&&function(e,t){if(e.line.number!==t.line.number)return!1;if(e.line.from!==t.line.from)return!1;if(e.line.text!==t.line.text)return!1;if(e.breakpoint!==t.breakpoint)return!1;if(e.location!==t.location)return!1;return e.isLogpoint===t.isLogpoint}(this.#I,e))return;this.activeBreakpointDialog&&this.activeBreakpointDialog.saveAndFinish();const s=this.editor,a=i?i.condition():"",l=i?.isLogpoint()??Boolean(r),d=document.createElement("div"),u=new n.Compartment,h=new $(t.number-1,a,l,(async e=>{this.activeBreakpointDialog=null,this.#I=void 0,h.detach(),s.dispatch({effects:u.reconfigure([])}),e.committed?(x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,a!==e.condition),function(e){const{condition:t,isLogpoint:o}=e,n=0!==t.length&&!o,r=i?.isLogpoint(),s=a&&0!==a.length&&!r;o&&!r?c.userMetrics.breakpointWithConditionAdded(0):n&&!s&&c.userMetrics.breakpointWithConditionAdded(1)}(e),i?i.setCondition(e.condition,e.isLogpoint):o?await this.setBreakpoint(o.lineNumber,o.columnNumber,e.condition,!0,e.isLogpoint):await this.createNewBreakpoint(t,e.condition,!0,e.isLogpoint)):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(i,!1)}));s.dispatch({effects:n.StateEffect.appendConfig.of(u.of(n.EditorView.decorations.of(n.Decoration.set([n.Decoration.widget({block:!0,widget:new class extends n.WidgetType{toDOM(){return d}},side:1}).range(t.to)]))))}),h.element.addEventListener("blur",(async e=>{(!e.relatedTarget||e.relatedTarget&&!e.relatedTarget.isSelfOrDescendant(h.element))&&(this.#y=!0,setTimeout((()=>{this.activeBreakpointDialog===h&&(this.#y?(h.saveAndFinish(),this.#y=!1):h.focusEditor())}),200))}),!0),h.markAsExternallyManaged(),h.show(d),h.focusEditor(),this.activeBreakpointDialog=h,this.#I=e}async updateValueDecorations(){if(!this.editor)return;const e=this.executionLocation?await this.computeValueDecorations():null;this.editor&&(e||this.editor.state.field(yo.field).size)&&this.editor.dispatch({effects:yo.update.of(e||n.Decoration.none)})}async#T(e,t){const i=e&&await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().rawLocationToUILocation(e);if(!i||i.uiSourceCode.url()!==t)return null;const o=this.editor?.toOffset(this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber));return o??null}async computeValueDecorations(){if(!this.editor)return null;if(!i.Settings.Settings.instance().moduleSetting("inline-variable-values").get())return null;if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext))return null;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return null;const r=this.uiSourceCode.url(),s=this.#T(e.functionLocation(),r),a=this.#T(e.location(),r),[c,l]=await Promise.all([s,a]);if(!c||!l||!this.editor)return null;if(c>=l||l-c>1e4)return null;const d=ko(this.editor.state,c,l,l);if(0===d.length)return null;const u=await To(e,(e=>this.#T(e,r)));if(0===u.length)return null;const h=Eo(u,d);if(!h||!this.editor)return null;const p=[];for(const[e,t]of h){const i=h.get(e-1);let o=i?Array.from(t).filter((e=>i.get(e[0])!==e[1])):Array.from(t);o.length&&(o.length>10&&(o=o.slice(0,10)),p.push(n.Decoration.widget({widget:new Io(o),side:1}).range(this.editor.state.doc.line(e+1).to)))}return n.Decoration.set(p,!0)}async showContinueToLocations(){this.popoverHelper?.hidePopover();if(!t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext)||!this.editor)return;const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);if(!e)return;const i=e.functionLocation()||e.location(),r=e.debuggerModel,{state:s}=this.editor,a=await r.getPossibleBreakpoints(i,null,!0);this.continueToLocations=[];let c=-1;for(const e of a.reverse()){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber);if(c===t.lineNumber&&"call"!==e.type||t.lineNumber>=s.doc.lines)continue;const i=s.doc.line(t.lineNumber+1),o=Math.min(i.to,i.from+t.columnNumber);let r=n.syntaxTree(s).resolveInner(o,1);if(r.firstChild||r.fromi.to)continue;if("."===r.name){const e=r.resolve(r.to,1);if(e.firstChild||e.fromi.to)continue;r=e}const a=r.name,l="this"===a||"return"===a||"new"===a||"break"===a||"continue"===a;if(!l&&!this.isIdentifier(a))continue;this.continueToLocations.push({from:r.from,to:r.to,async:!1,click:()=>e.continueToLocation()}),"call"===e.type&&(c=t.lineNumber);const d=l?"":i.text.slice(r.from-i.from,r.to-i.from);let u=null;if("then"===d&&"MemberExpression"===r.parent?.name?u=r.parent.parent:"setTimeout"!==d&&"setInterval"!==d&&"postMessage"!==d||(u=r.parent),"new"===a){const e=r.parent?.getChild("Expression");e&&"VariableName"===e.name&&"Worker"===s.sliceDoc(e.from,e.to)&&(u=r.parent)}if(u&&("CallExpression"===u.name||"NewExpression"===u.name)&&"call"===e.type){const t=u.getChild("ArgList")?.firstChild?.nextSibling;let i;if("VariableName"===t?.name?i=t:"ArrowFunction"!==t?.name&&"FunctionExpression"!==t?.name||(i=t.firstChild,"async"===i?.name&&(i=i.nextSibling)),i){const t=this.executionLocation&&e.lineNumber===this.executionLocation.lineNumber&&e.columnNumber===this.executionLocation.columnNumber;this.continueToLocations.push({from:i.from,to:i.to,async:!0,click:()=>this.asyncStepIn(e,Boolean(t))})}}}const l=n.Decoration.set(this.continueToLocations.map((e=>(e.async?fo:bo).range(e.from,e.to))),!0);this.editor.dispatch({effects:So.update.of(l)})}clearContinueToLocations(){this.editor&&this.editor.state.field(So.field).size&&this.editor.dispatch({effects:So.update.of(n.Decoration.none)})}asyncStepIn(e,t){function i(){e.debuggerModel.scheduleStepIntoAsync()}t?i():e.continueToLocation(i)}fetchBreakpoints(){if(!this.editor)return[];const{editor:e}=this;return this.breakpointManager.breakpointLocationsForUISourceCode(this.uiSourceCode).map((({uiLocation:t,breakpoint:i})=>{const o=this.transformer.uiLocationToEditorLocation(t.lineNumber,t.columnNumber);return{position:e.toOffset(o),breakpoint:i}}))}lineBreakpoints(e){return this.breakpoints.filter((t=>t.position>=e.from&&t.position<=e.to)).map((e=>e.breakpoint))}async computeBreakpointDecoration(e,t){const i=[],o=[],r=new Map,s=new Map,a=[],c=new Set,l=(e,t,i)=>{let o=s.get(e);o||(o=[],s.set(e,o)),o.push({breakpoint:i,column:t})};for(const{position:i,breakpoint:o}of t){const t=e.doc.lineAt(i);let n=r.get(t.from);if(n||(n=[],r.set(t.from,n)),o.enabled()&&n.every((e=>!e.enabled()))){const e=this.transformer.editorLocationToUILocation(t.number-1,0),i=this.transformer.editorLocationToUILocation(t.number-1,Math.min(t.length,2500)),o=new g.TextRange.TextRange(e.lineNumber,e.columnNumber||0,i.lineNumber,i.columnNumber||0);a.push(this.breakpointManager.possibleBreakpoints(this.uiSourceCode,o).then((e=>d(t,e))))}n.push(o),o.enabled()&&(c.add(i),l(t.from,i-t.from,o))}for(const[e,t]of r){const i=t.sort(lo)[0];let n="cm-breakpoint";i.enabled()||(n+=" cm-breakpoint-disabled"),i.bound()||(n+=" cm-breakpoint-unbound"),i.isLogpoint()?n+=" cm-breakpoint-logpoint":i.condition()&&(n+=" cm-breakpoint-conditional"),o.push(new co(n,e).range(e))}const d=(e,t)=>{for(const i of t){const t=this.transformer.uiLocationToEditorLocation(i.lineNumber,i.columnNumber);if(t.lineNumber!==e.number-1)continue;const o=Math.min(e.to,e.from+t.columnNumber);c.has(o)||l(e.from,t.columnNumber,null)}};await Promise.all(a);for(const[e,t]of s)if(t.length>1)for(const{column:o,breakpoint:r}of t){const t=new ao(r,this);i.push(n.Decoration.widget({widget:t,side:-1}).range(e+o))}return{content:n.Decoration.set(i,!0),gutter:n.RangeSet.of(o,!0)}}async restoreBreakpointsAfterEditing(){const{breakpoints:e}=this,t=this.editor;this.breakpoints=[],await Promise.all(e.map((async e=>{const{breakpoint:i,position:o}=e,n=i.condition(),r=i.enabled(),s=i.isLogpoint();await i.remove(!1);const a=t.toLineColumn(o),c=this.transformer.editorLocationToUILocation(a.lineNumber,a.columnNumber);await this.setBreakpoint(c.lineNumber,c.columnNumber,n,r,s)})))}async refreshBreakpoints(){if(this.editor){this.breakpoints=this.fetchBreakpoints();const e=this.breakpoints,t=await this.computeBreakpointDecoration(this.editor.state,e);this.editor&&this.breakpoints===e&&(t.gutter.size||this.editor.state.field(so,!1)?.gutter.size)&&this.editor.dispatch({effects:oo.of(t)})}}breakpointChange(e){const{uiLocation:t}=e.data;if(t.uiSourceCode===this.uiSourceCode&&!this.muted){for(const e of this.scriptFileForDebuggerModel.values())if(e.isDivergingFromVM()||e.isMergingToVM())return;window.clearTimeout(this.refreshBreakpointsTimeout),this.refreshBreakpointsTimeout=window.setTimeout((()=>this.refreshBreakpoints()),50)}}onInlineBreakpointMarkerClick(e,t){if(e.consume(!0),t)e.shiftKey?t.setEnabled(!t.enabled()):t.remove(!1);else if(this.editor){const t=this.editor.editor.posAtDOM(e.target),i=this.editor.state.doc.lineAt(t),o=this.transformer.editorLocationToUILocation(i.number-1,t-i.from);this.setBreakpoint(o.lineNumber,o.columnNumber,Gi,!0,!1)}}onInlineBreakpointMarkerContextMenu(e,i){e.consume(!0);const o=this.editor,n=o.editor.posAtDOM(e.target),r=o.state.doc.lineAt(n);if(!m.SourceFrame.isBreakableLine(o.state,r)||!u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().supportsConditionalBreakpoints(this.uiSourceCode))return;const s=new t.ContextMenu.ContextMenu(e);if(i)s.debugSection().appendItem(Yi(Ji.editBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:i,location:null})}),{jslogContext:"edit-breakpoint"});else{const e=this.transformer.editorLocationToUILocation(r.number-1,n-r.from);s.debugSection().appendItem(Yi(Ji.addConditionalBreakpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!1})}),{jslogContext:"add-cnd-breakpoint"}),s.debugSection().appendItem(Yi(Ji.addLogpoint),(()=>{c.userMetrics.breakpointEditDialogRevealedFrom(2),this.editBreakpointCondition({line:r,breakpoint:null,location:e,isLogpoint:!0})}),{jslogContext:"add-logpoint"}),s.debugSection().appendItem(Yi(Ji.neverPauseHere),(()=>this.setBreakpoint(e.lineNumber,e.columnNumber,Ki,!0,!1)),{jslogContext:"never-pause-here"})}s.show()}updateScriptFiles(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e)&&this.updateScriptFile(e)}this.showSourceMapInfobarIfNeeded()}updateScriptFile(e){const t=this.scriptFileForDebuggerModel.get(e),i=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);this.scriptFileForDebuggerModel.delete(e),t&&(t.removeEventListener("DidMergeToVM",this.didMergeToVM,this),t.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),this.muted&&!this.uiSourceCode.isDirty()&&this.consistentScripts()&&this.setMuted(!1)),i&&(this.scriptFileForDebuggerModel.set(e,i),i.addEventListener("DidMergeToVM",this.didMergeToVM,this),i.addEventListener("DidDivergeFromVM",this.didDivergeFromVM,this),i.checkMapping(),i.missingSymbolFiles().then((e=>{if(e){const t=Yi(Ji.debugInfoNotFound,{PH1:i.uiSourceCode.url()});this.updateMissingDebugInfoInfobar({resources:e,details:t})}else this.updateMissingDebugInfoInfobar(null)})))}updateMissingDebugInfoInfobar(e){if(!this.missingDebugInfoBar){if(null===e)return this.removeInfobar(this.missingDebugInfoBar),void(this.missingDebugInfoBar=null);if(this.missingDebugInfoBar=t.Infobar.Infobar.create("error",e.details,[],void 0,"missing-debug-info"),this.missingDebugInfoBar){for(const t of e.resources){const e=this.missingDebugInfoBar?.createDetailsRowMessage(Yi(Ji.debugFileNotFound,{PH1:t}));e&&e.classList.add("infobar-selectable")}this.missingDebugInfoBar.setCloseCallback((()=>{this.removeInfobar(this.missingDebugInfoBar),this.missingDebugInfoBar=null})),this.attachInfobar(this.missingDebugInfoBar)}}}scriptHasSourceMap(){for(const e of o.TargetManager.TargetManager.instance().models(o.DebuggerModel.DebuggerModel)){const t=u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().scriptFile(this.uiSourceCode,e);if(t&&t.hasSourceMapURL())return!0}return!1}getSourceMapResource(){const e=this.loader.getResourcesLoaded();for(const[t,n]of this.scriptFileForDebuggerModel.entries()){const r=n.script?.sourceMapURL;if(r){const s=o.SourceMapManager.SourceMapManager.resolveRelativeSourceURL(t.target(),n.script.sourceURL),a=i.ParsedURL.ParsedURL.completeURL(s,r);if(a){const t=e.get(o.PageResourceLoader.PageResourceLoader.makeKey(a,n.script.createPageResourceLoadInitiator()));if(t)return t}}}return null}showSourceMapInfobarIfNeeded(){if(this.sourceMapInfobar)return;if(!i.Settings.Settings.instance().moduleSetting("js-source-maps-enabled").get())return;if(!this.scriptHasSourceMap())return;const e=this.getSourceMapResource();if(!e||null!==e.success){if(e)if(e.success){if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Yi(Ji.sourceMapLoaded),[],i.Settings.Settings.instance().createSetting("source-map-infobar-disabled",!1),"source-map-loaded"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.associatedFilesShouldBeAdded)),this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.associatedFilesAreAvailable,{PH1:String(t.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction("quick-open.show"))}))}else{let i,o;const n=u.IgnoreListManager.IgnoreListManager.instance();if(this.uiSourceCode.project().type()===f.Workspace.projectTypes.ContentScripts?(i=Yi(Ji.ignoreContentScripts),o=n.ignoreListContentScripts.bind(n)):(i=Yi(Ji.ignoreScript),o=n.ignoreListUISourceCode.bind(n,this.uiSourceCode)),this.sourceMapInfobar=t.Infobar.Infobar.create("warning",Yi(Ji.sourceMapFailed),[{text:i,highlight:!1,delegate:o,dismiss:!0}],void 0,"source-map-failed"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.debuggingPowerReduced)),e.errorMessage&&this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.errorLoading,{PH1:l.StringUtilities.trimMiddle(e.url,t.UIUtils.MaxLengthForDisplayedURLs),PH2:e.errorMessage}))}else{if(this.sourceMapInfobar=t.Infobar.Infobar.create("info",Yi(Ji.sourceMapSkipped),[],i.Settings.Settings.instance().createSetting("source-map-skipped-infobar-disabled",!1),"source-map-skipped"),!this.sourceMapInfobar)return;this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.debuggingPowerReduced)),this.sourceMapInfobar.createDetailsRowMessage(Yi(Ji.reloadForSourceMap))}this.sourceMapInfobar.setCloseCallback((()=>{this.removeInfobar(this.sourceMapInfobar),this.sourceMapInfobar=null})),this.attachInfobar(this.sourceMapInfobar)}}handleGutterClick(e,t){return!this.muted&&0===t.button&&!t.altKey&&(t.metaKey||t.ctrlKey?(c.userMetrics.breakpointEditDialogRevealedFrom(6),this.#k(e,t.shiftKey),!0):(this.toggleBreakpoint(e,t.shiftKey),!0))}async toggleBreakpoint(e,t){if(this.muted)return;this.activeBreakpointDialog&&this.activeBreakpointDialog.finishEditing(!1,"");const i=this.lineBreakpoints(e);if(!i.length)return void await this.createNewBreakpoint(e,Gi,!0,!1);const o=i.some((e=>!e.enabled()));for(const e of i)t?e.setEnabled(o):(c.userMetrics.actionTaken(c.UserMetrics.Action.BreakpointRemovedFromGutterToggle),e.remove(!1))}async createNewBreakpoint(e,t,i,o){if(!this.editor||!m.SourceFrame.isBreakableLine(this.editor.state,e))return;c.userMetrics.actionTaken(c.UserMetrics.Action.ScriptsBreakpointSet),this.#E();const n=this.transformer.editorLocationToUILocation(e.number-1);await this.setBreakpoint(n.lineNumber,n.columnNumber,t,i,o)}async setBreakpoint(e,t,o,n,r){i.Settings.Settings.instance().moduleSetting("breakpoints-active").set(!0);const s=await this.breakpointManager.setBreakpoint(this.uiSourceCode,e,t,o,n,r,"USER_ACTION");return this.breakpointWasSetForTest(e,t,o,n),s}breakpointWasSetForTest(e,t,i,o){}async callFrameChanged(){this.liveLocationPool.disposeAll();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);e?await u.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().createCallFrameLiveLocation(e.location(),(async t=>{const i=await t.uiLocation();i&&i.uiSourceCode===this.uiSourceCode?(this.setExecutionLocation(i),this.updateMissingDebugInfoInfobar(e.missingDebugInfoDetails),this.#E()):this.setExecutionLocation(null)}),this.liveLocationPool):this.setExecutionLocation(null)}setExecutionLocation(e){if(this.executionLocation!==e&&this.editor)if(this.executionLocation=e,e){const t=this.transformer.uiLocationToEditorLocation(e.lineNumber,e.columnNumber),i=mo(this.editor.state,t.lineNumber,t.columnNumber);this.editor.dispatch({effects:go.update.of(i)}),this.updateValueDecorations(),this.controlDown&&this.showContinueToLocations()}else this.editor.dispatch({effects:[go.update.of(n.Decoration.none),So.update.of(n.Decoration.none),yo.update.of(n.Decoration.none)]})}dispose(){this.hideIgnoreListInfobar(),this.sourceMapInfobar&&this.sourceMapInfobar.dispose();for(const e of this.scriptFileForDebuggerModel.values())e.removeEventListener("DidMergeToVM",this.didMergeToVM,this),e.removeEventListener("DidDivergeFromVM",this.didDivergeFromVM,this);this.scriptFileForDebuggerModel.clear(),this.popoverHelper?.hidePopover(),this.popoverHelper?.dispose(),this.setExecutionLocation(null),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointAdded,this.breakpointChange,this),this.breakpointManager.removeEventListener(w.BreakpointManager.Events.BreakpointRemoved,this.breakpointChange,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.removeEventListener(f.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this),u.IgnoreListManager.IgnoreListManager.instance().removeChangeListener(this.ignoreListCallback),Qi.delete(this.uiSourceCode),super.dispose(),window.clearTimeout(this.refreshBreakpointsTimeout),this.editor=void 0,t.Context.Context.instance().removeFlavorChangeListener(o.DebuggerModel.CallFrame,this.callFrameChanged,this),this.liveLocationPool.disposeAll()}#E(){if(this.#x)return;this.#x=!0;const e=i.ResourceType.ResourceType.mimeFromURL(this.uiSourceCode.url()),t=i.ResourceType.ResourceType.mediaTypeForMetrics(e??"",this.uiSourceCode.contentType().isFromSourceMap(),g.TextUtils.isMinified(this.uiSourceCode.content()));c.userMetrics.sourcesPanelFileDebugged(t)}}const eo=n.StateEffect.define(),to=n.StateEffect.define(),io=n.StateField.define({create:()=>[],update(e,t){for(const i of t.effects)i.is(eo)?e=e.concat(i.value):i.is(to)&&(e=e.filter((e=>e!==i.value)));return e},provide:e=>n.showPanel.computeN([e],(t=>t.field(e).map((e=>()=>({dom:e.element})))))});const oo=n.StateEffect.define(),no=n.StateEffect.define();function ro(e,t){const i=[];return e.between(0,t.length,((e,t,o)=>{let n=o.elementClass;/cm-breakpoint-disabled/.test(n)||(n+=" cm-breakpoint-disabled"),i.push(new co(n,e).range(e))})),n.RangeSet.of(i,!1)}const so=n.StateField.define({create:()=>({content:n.RangeSet.empty,gutter:n.RangeSet.empty}),update(e,t){t.changes.empty||(e={content:e.content.map(t.changes),gutter:e.gutter.map(t.changes)});for(const i of t.effects)i.is(oo)?e=i.value:i.is(no)&&(e={content:n.RangeSet.empty,gutter:ro(e.gutter,t.state.doc)});return e},provide:e=>[n.EditorView.decorations.from(e,(e=>e.content)),n.lineNumberMarkers.from(e,(e=>e.gutter))]});class ao extends n.WidgetType{breakpoint;parent;class;constructor(e,t){super(),this.breakpoint=e,this.parent=t,this.class="cm-inlineBreakpoint",e?.isLogpoint()?this.class+=" cm-inlineBreakpoint-logpoint":e?.condition()&&(this.class+=" cm-inlineBreakpoint-conditional"),e?.enabled()||(this.class+=" cm-inlineBreakpoint-disabled")}eq(e){return e.class===this.class&&e.breakpoint===this.breakpoint}toDOM(){const e=document.createElement("span");return e.className=this.class,e.setAttribute("jslog",`${a.breakpointMarker("inline").track({click:!0})}`),e.addEventListener("click",(e=>{this.parent.onInlineBreakpointMarkerClick(e,this.breakpoint),e.consume()})),e.addEventListener("contextmenu",(e=>{this.parent.onInlineBreakpointMarkerContextMenu(e,this.breakpoint),e.consume()})),e}ignoreEvent(){return!0}}class co extends n.GutterMarker{elementClass;#L;constructor(e,t){super(),this.elementClass=e,this.#L=t}eq(e){return e.elementClass===this.elementClass}toDOM(e){const t=document.createElement("div");t.setAttribute("jslog",`${a.breakpointMarker("gutter").track({click:!0})}`);const i=e.state.doc.lineAt(this.#L).number,o=e.state.facet(m.SourceFrame.LINE_NUMBER_FORMATTER);return t.textContent=o(i,e.state),t}}function lo(e,t){return e.enabled()!==t.enabled()?e.enabled()?-1:1:e.bound()!==t.bound()?e.bound()?-1:1:Boolean(e.condition())!==Boolean(t.condition())?Boolean(e.condition())?-1:1:0}function uo(){const e=n.StateEffect.define(),t=n.StateField.define({create:()=>n.Decoration.none,update:(t,i)=>i.effects.reduce(((t,i)=>i.is(e)?i.value:t),t.map(i.changes)),provide:e=>n.EditorView.decorations.from(e)});return{update:e,field:t}}const ho=n.Decoration.line({attributes:{class:"cm-executionLine"}}),po=n.Decoration.mark({attributes:{class:"cm-executionToken"}}),go=uo();function mo(e,t,i){const{doc:o}=e;if(t>=o.lines)return n.Decoration.none;const r=o.line(t+1),s=[ho.range(r.from)],a=Math.min(r.to,r.from+i);let c=null;for(;null===c;)c=n.ensureSyntaxTree(e,r.to,500);let l=c.resolveInner(a,1);l.to===l.from-1&&/[(.]/.test(o.sliceString(l.from,l.to))&&(l=l.resolve(l.to,1));const d=Math.min(r.to,l.to);return d>a&&s.push(po.range(a,d)),n.Decoration.set(s)}const bo=n.Decoration.mark({class:"cm-continueToLocation"}),fo=n.Decoration.mark({class:"cm-continueToLocation cm-continueToLocation-async"}),So=uo(),vo={},Co={class:"cm-hasContinueMarkers"},wo=n.EditorView.contentAttributes.compute([So.field],(e=>e.field(So.field).size?Co:vo));class Io extends n.WidgetType{pairs;constructor(e){super(),this.pairs=e}eq(e){return this.pairs.length===e.pairs.length&&this.pairs.every(((t,i)=>t[0]===e.pairs[i][0]&&t[1]===e.pairs[i][1]))}toDOM(){const e=new y.RemoteObjectPreviewFormatter.RemoteObjectPreviewFormatter,i=document.createElement("div");i.classList.add("cm-variableValues");let o=!0;for(const[n,r]of this.pairs){o?o=!1:t.UIUtils.createTextChild(i,", ");const s=i.createChild("span");t.UIUtils.createTextChild(s,n+" = ");const a=r.preview?r.preview.properties.length:0,c=r.preview&&r.preview.entries?r.preview.entries.length:0;if(r.preview&&a+c<10)e.appendObjectPreview(s,r.preview,!1);else{const e=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValue(r,!1,!1);s.appendChild(e.element)}}return i}}const yo=uo();class xo{blockList=new Set;variables=[]}function ko(e,t,i,o){const r=e.doc.lineAt(t);t=Math.min(r.to,t),i=e.doc.lineAt(i).from;const s=n.ensureSyntaxTree(e,i,100);if(!s)return[];function a(e){return("Block"===(t=e.name)||"ForSpec"===t)&&(e.to{if(i.from0?d[d.length-1].blockList.add(n):(i.from>l.to&&(l=e.doc.lineAt(i.from)),h().push({line:l.number-1,from:i.from,id:n})))},leave:e=>{if(u===e.node)u=null;else if(a(e)){const e=d.pop(),t=h();for(const i of e?.variables??[])e?.blockList.has(i.id)||t.push(i)}}}),c}async function To(e,t){const i=[];for(const o of e.scopeChain()){const e=await t(o.range()?.start??null);if(!e)break;const n=await t(o.range()?.end??null);if(!n)break;const{properties:r}=await p.NamesResolver.resolveScopeInObject(o).getAllProperties(!1,!1);if(!r||r.length>500)break;const s=new Map(r.map((e=>[e.name,e.value])));if(i.push({scopeStart:e,scopeEnd:n,variableMap:s}),"local"===o.type())break}return i}function Eo(e,t){const i=new Map;for(const{line:n,from:r,id:s}of t){const t=o(s,r,e);if(!t)continue;let a=i.get(n);a||(a=new Map,i.set(n,a)),a.set(s,t)}return i;function o(e,t,i){for(const o of i){if(t=o.scopeEnd)continue;const i=o.variableMap.get(e);if(i)return i}return null}}function Lo(e,t,i){const{main:o}=e.selection;if(!o.empty)return i50||/[^\w_\-$]/.test(e.sliceDoc(s.from,s.to))?null:{from:s.from,to:s.to,containsSideEffects:!1}}}function Mo(e,t){let i=!1;return t.toTree().iterate({enter(t){switch(t.name){case"AssignmentExpression":case"CallExpression":return i=!0,!1;case"ArithOp":{const o=e.sliceString(t.from,t.to);if("++"===o||"--"===o)return i=!0,!1;break}}return!0}}),i}const Po=n.Decoration.mark({class:"cm-evaluatedExpression"}),Fo=uo(),Do=n.EditorView.baseTheme({".cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover, &.cm-breakpoint":{borderStyle:"solid",borderWidth:"1px 4px 1px 1px",marginRight:"-4px",paddingLeft:"8px",lineHeight:"calc(1.2em - 2px)",position:"relative"},"&:hover":{WebkitBorderImage:No("#ebeced","#ebeced")},"&.cm-breakpoint":{color:"#fff",WebkitBorderImage:No("#4285f4","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:No("#f29900","#e37400"),"&::before":{content:'"?"',position:"absolute",top:0,left:"1px"}},"&.cm-breakpoint-logpoint":{WebkitBorderImage:No("#f439a0","#d01884"),"&::before":{content:'"‥"',position:"absolute",top:"-3px",left:"1px"}}},"&dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement":{"&:hover":{WebkitBorderImage:No("#3c4043","#3c4043")},"&.cm-breakpoint":{WebkitBorderImage:No("#5186EC","#1a73e8")},"&.cm-breakpoint-conditional":{WebkitBorderImage:No("#e9a33a","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:No("#E54D9B","#d01884")}},":host-context(.breakpoints-deactivated) & .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{color:"#1a73e8",WebkitBorderImage:No("#d9e7fd","#1a73e8"),"&.cm-breakpoint-conditional":{color:"#e37400",WebkitBorderImage:No("#fcebcc","#e37400")},"&.cm-breakpoint-logpoint":{color:"#d01884",WebkitBorderImage:No("#fdd7ec","#f439a0")}},":host-context(.breakpoints-deactivated) &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint, &dark .cm-gutters .cm-gutter.cm-lineNumbers .cm-gutterElement.cm-breakpoint-disabled":{WebkitBorderImage:No("#2a384e","#1a73e8"),"&.cm-breakpoint-conditional":{WebkitBorderImage:No("#4d3c1d","#e37400")},"&.cm-breakpoint-logpoint":{WebkitBorderImage:No("#4e283d","#f439a0")}},".cm-inlineBreakpoint":{cursor:"pointer",position:"relative",top:"1px",content:Ao("#4285F4","#1A73E8"),height:"10px","&.cm-inlineBreakpoint-conditional":{content:Uo("#F29900","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Ro("#F439A0","#D01884")}},"&dark .cm-inlineBreakpoint":{content:Ao("#5186EC","#1A73E8"),"&.cm-inlineBreakpoint-conditional":{content:Uo("#e9a33a","#E37400")},"&.cm-inlineBreakpoint-logpoint":{content:Ro("#E54D9B","#D01884")}},":host-context(.breakpoints-deactivated) & .cm-inlineBreakpoint, .cm-inlineBreakpoint-disabled":{content:Ao("#4285F4","#1A73E8","0.2"),"&.cm-inlineBreakpoint-conditional":{content:Uo("#F9AB00","#E37400","0.2")},"&.cm-inlineBreakpoint-logpoint":{content:Ro("#F439A0","#D01884","0.2")}},".cm-executionLine":{backgroundColor:"var(--sys-color-yellow-container)",outline:"1px solid var(--sys-color-yellow-outline)",".cm-hasContinueMarkers &":{backgroundColor:"transparent"},"&.cm-highlightedLine":{animation:"cm-fading-highlight-execution 2s 0s"},"&.cm-line::selection, &.cm-line ::selection":{backgroundColor:"var(--sys-color-tonal-container) !important"}},".cm-executionToken":{backgroundColor:"var(--sys-color-state-focus-select)"},"@keyframes cm-fading-highlight-execution":{from:{backgroundColor:"var(--sys-color-tonal-container)"},to:{backgroundColor:"var(--sys-color-yellow-container)"}},".cm-continueToLocation":{cursor:"pointer",backgroundColor:"var(--color-continue-to-location)","&:hover":{backgroundColor:"var(--color-continue-to-location-hover)",border:"1px solid var(--color-continue-to-location-hover-border)",margin:"0 -1px"},"&.cm-continueToLocation-async":{backgroundColor:"var(--color-continue-to-location-async)","&:hover":{backgroundColor:"var(--color-continue-to-location-async-hover)",border:"1px solid var(--color-continue-to-location-async-hover-border)",margin:"0 -1px"}}},".cm-evaluatedExpression":{backgroundColor:"var(--color-evaluated-expression)",border:"1px solid var(--color-evaluated-expression-border)",margin:"0 -1px"},".cm-variableValues":{display:"inline",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"1000px",opacity:"80%",backgroundColor:"var(--color-variable-values)",marginLeft:"10px",padding:"0 5px",userSelect:"text",".cm-executionLine &":{backgroundColor:"transparent",opacity:"50%"}}});function No(e,t){return`url('data:image/svg+xml,') 1 3 1 1`}function Ao(e,t,i="1"){return`url('data:image/svg+xml,')`}function Uo(e,t,i="1"){return`url('data:image/svg+xml,')`}function Ro(e,t,i="1"){return`url('data:image/svg+xml,')`}var Bo=Object.freeze({__proto__:null,DebuggerPlugin:Zi,BreakpointLocationRevealer:class{async reveal(e,t){const{uiLocation:i}=e;Oi.instance().showUILocation(i,t);const o=Qi.get(i.uiSourceCode);o?o.editBreakpointLocation(e):x.BreakpointsView.BreakpointsSidebarController.instance().breakpointEditFinished(e.breakpoint,!1)}},computeExecutionDecorations:mo,getVariableNamesByLine:ko,computeScopeMappings:To,getVariableValuesByLine:Eo,computePopoverHighlightRange:Lo});class jo{query;queryUpperCase;score;sequence;dataUpperCase;fileNameIndex;constructor(e){this.query=e,this.queryUpperCase=e.toUpperCase(),this.score=new Int32Array(2e3),this.sequence=new Int32Array(2e3),this.dataUpperCase="",this.fileNameIndex=0}calculateScore(e,t){if(!e||!this.query)return 0;const i=this.query.length,o=e.length;(!this.score||this.score.length=s?(r[t*o+i]=c+1,n[t*o+i]=a+l):(r[t*o+i]=0,n[t*o+i]=s)}t&&this.restoreMatchIndexes(r,i,o,t);return 256*n[i*o-1]+(256-e.length)}testWordStart(e,t){if(0===t)return!0;const i=e.charAt(t-1);return"_"===i||"-"===i||"/"===i||"."===i||" "===i||e[t-1]!==this.dataUpperCase[t-1]&&e[t]===this.dataUpperCase[t]}restoreMatchIndexes(e,t,i,o){let n=t-1,r=i-1;for(;n>=0&&r>=0;)if(0===e[n*i+r])--r;else o.push(r),--n,--r;o.reverse()}singleCharScore(e,t,i,o){const n=this.testWordStart(t,o),r=o>this.fileNameIndex;let s=10;return(0===o||"/"===t[o-1])&&(s+=4),n&&(s+=2),e[i]===t[o]&&e[i]===this.queryUpperCase[i]&&(s+=6),r&&(s+=4),o===this.fileNameIndex+1&&0===i&&(s+=5),r&&n&&(s+=3),s}sequenceCharScore(e,t,i,o,n){let r=10;return o>this.fileNameIndex&&(r+=4),(0===o||"/"===t[o-1])&&(r+=5),r+=4*n,r}match(e,t,i,o,n){return this.queryUpperCase[i]!==this.dataUpperCase[o]?0:n?this.sequenceCharScore(e,t,i,o-n,n):this.singleCharScore(e,t,i,o)}}var Vo=Object.freeze({__proto__:null,FilePathScoreFunction:jo});const Wo={noFilesFound:"No files found",sIgnoreListed:"{PH1} (ignore listed)"},Oo=e.i18n.registerUIStrings("panels/sources/FilteredUISourceCodeListProvider.ts",Wo),Ho=e.i18n.getLocalizedString.bind(void 0,Oo);class _o extends L.FilteredListWidget.Provider{queryLineNumberAndColumnNumber;defaultScores;scorer;uiSourceCodes;uiSourceCodeIds;query;constructor(e){super(e),this.queryLineNumberAndColumnNumber="",this.defaultScores=null,this.scorer=new jo(""),this.uiSourceCodes=[],this.uiSourceCodeIds=new Set}projectRemoved(e){const t=e.data;this.populate(t),this.refresh()}populate(e){this.uiSourceCodes=[],this.uiSourceCodeIds.clear();for(const t of f.Workspace.WorkspaceImpl.instance().projects())if(t!==e&&this.filterProject(t))for(const e of t.uiSourceCodes())this.filterUISourceCode(e)&&(this.uiSourceCodes.push(e),this.uiSourceCodeIds.add(e.canononicalScriptId()))}filterUISourceCode(e){if(this.uiSourceCodeIds.has(e.canononicalScriptId()))return!1;if(C.Runtime.experiments.isEnabled("just-my-code")&&u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(e))return!1;if(e.isFetchXHR())return!1;const t=h.Persistence.PersistenceImpl.instance().binding(e);return!t||t.fileSystem===e}uiSourceCodeSelected(e,t,i){}filterProject(e){return!0}itemCount(){return this.uiSourceCodes.length}itemContentTypeAt(e){return this.uiSourceCodes[e].contentType()}itemKeyAt(e){return this.uiSourceCodes[e].url()}setDefaultScores(e){this.defaultScores=e}itemScoreAt(e,t){const i=this.uiSourceCodes[e],o=this.defaultScores&&this.defaultScores.get(i)||0;if(!t||t.length<2)return o;this.query!==t&&(this.query=t,this.scorer=new jo(t));let n=10;i.project().type()!==f.Workspace.projectTypes.FileSystem||h.Persistence.PersistenceImpl.instance().binding(i)||(n=5);let r=0;i.contentType().isFromSourceMap()&&!i.isKnownThirdParty()&&(r=100),i.contentType().isScript()&&(u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(i)||(r+=50));const s=i.fullDisplayName();return o+n*(r+this.scorer.calculateScore(s,null))}renderItem(e,i,o,n){i=this.rewriteQuery(i);const r=this.uiSourceCodes[e],s=r.fullDisplayName(),a=[];new jo(i).calculateScore(s,a);const c=s.lastIndexOf("/");let l=s;u.IgnoreListManager.IgnoreListManager.instance().isUserOrSourceMapIgnoreListedUISourceCode(r)&&(o.parentElement?.classList.add("is-ignore-listed"),l=Ho(Wo.sIgnoreListed,{PH1:l})),o.textContent=r.displayName()+(this.queryLineNumberAndColumnNumber||""),this.renderSubtitleElement(n,s.substring(0,c+1)),t.Tooltip.Tooltip.install(n,l);const d=[];for(let e=0;ec){for(let e=0;e43&&(o=i.length-43);e.createChild("div","first-part").textContent=i.substring(0,o);e.createChild("div","second-part").textContent=i.substring(o),t.Tooltip.Tooltip.install(e,i)}selectItem(e,t){const i=t.trim().match(/^([^:]*)(:\d+)?(:\d+)?$/);if(!i)return;let o,n;i[2]&&(o=parseInt(i[2].substr(1),10)-1),i[3]&&(n=parseInt(i[3].substr(1),10)-1);const r=null!==e?this.uiSourceCodes[e]:null;this.uiSourceCodeSelected(r,o,n)}rewriteQuery(e){if(!(e=e?e.trim():"")||":"===e)return"";const t=e.match(/^([^:]+)((?::[^:]*){0,2})$/);return this.queryLineNumberAndColumnNumber=t?t[2]:"",t?t[1]:e}uiSourceCodeAdded(e){const t=e.data;this.filterUISourceCode(t)&&this.filterProject(t.project())&&(this.uiSourceCodes.push(t),this.uiSourceCodeIds.add(t.canononicalScriptId()),this.refresh())}notFoundText(){return Ho(Wo.noFilesFound)}attach(){f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().addEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.populate()}detach(){f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.UISourceCodeAdded,this.uiSourceCodeAdded,this),f.Workspace.WorkspaceImpl.instance().removeEventListener(f.Workspace.Events.ProjectRemoved,this.projectRemoved,this),this.queryLineNumberAndColumnNumber="",this.defaultScores=null}}var zo=Object.freeze({__proto__:null,FilteredUISourceCodeListProvider:_o});const qo={noFileSelected:"No file selected.",noResultsFound:"No results found",typeANumberToGoToThatLine:"Type a number to go to that line.",currentPositionXsTypeAnOffset:"Current position: 0x{PH1}. Type an offset between 0x{PH2} and 0x{PH3} to navigate to.",currentLineSTypeALineNumber:"Current line: {PH1}. Type a line number between 1 and {PH2} to navigate to.",goToOffsetXs:"Go to offset 0x{PH1}.",goToLineSAndColumnS:"Go to line {PH1} and column {PH2}.",goToLineS:"Go to line {PH1}."},$o=e.i18n.registerUIStrings("panels/sources/GoToLineQuickOpen.ts",qo),Go=e.i18n.getLocalizedString.bind(void 0,$o);class Ko extends L.FilteredListWidget.Provider{#M=[];constructor(){super("source-line")}selectItem(e,t){const i=this.currentSourceFrame();if(!i)return;const o=this.parsePosition(t);o&&i.revealPosition({lineNumber:o.line-1,columnNumber:o.column-1})}itemCount(){return this.#M.length}renderItem(e,i,o,n){t.UIUtils.createTextChild(o,this.#M[e])}rewriteQuery(e){return""}queryChanged(e){this.#M=[];const t=this.parsePosition(e),i=this.currentSourceFrame();if(t)i&&i.wasmDisassembly?this.#M.push(Go(qo.goToOffsetXs,{PH1:(t.column-1).toString(16)})):t.column&&t.column>1?this.#M.push(Go(qo.goToLineSAndColumnS,{PH1:t.line,PH2:t.column})):i&&t.line>i.textEditor.state.doc.lines||this.#M.push(Go(qo.goToLineS,{PH1:t.line}));else{if(!i)return void this.#M.push(Go(qo.typeANumberToGoToThatLine));const e=i.textEditor.state,t=i.wasmDisassembly,o=i.editorLocationToUILocation(e.doc.lineAt(e.selection.main.head).number-1).lineNumber;if(t){const e=t.lineNumberToBytecodeOffset(t.lineNumbers-1),i=e.toString(16).length,n=t.lineNumberToBytecodeOffset(o);return void this.#M.push(Go(qo.currentPositionXsTypeAnOffset,{PH1:n.toString(16).padStart(i,"0"),PH2:"0".padStart(i,"0"),PH3:e.toString(16)}))}const n=i.editorLocationToUILocation(e.doc.lines-1).lineNumber+1;this.#M.push(Go(qo.currentLineSTypeALineNumber,{PH1:o+1,PH2:n}))}}notFoundText(e){return this.currentSourceFrame()?Go(qo.noResultsFound):Go(qo.noFileSelected)}parsePosition(e){const t=this.currentSourceFrame();if(t&&t.wasmDisassembly){const t=e.match(/0x([0-9a-fA-F]+)/);if(!t||!t[0]||t[0].length!==e.length)return null;return{line:0,column:parseInt(t[0],16)+1}}const i=e.match(/([0-9]+)(\:[0-9]*)?/);if(!i||!i[0]||i[0].length!==e.length)return null;const o=parseInt(i[1],10);let n=0;return i[2]&&(n=parseInt(i[2].substring(1),10)),{line:Math.max(0|o,1),column:Math.max(0|n,1)}}currentSourceFrame(){const e=t.Context.Context.instance().flavor(yi);return e?e.currentSourceFrame():null}}var Jo=Object.freeze({__proto__:null,GoToLineQuickOpen:Ko});const Xo={formatS:"Format {PH1}",format:"Format"},Yo=e.i18n.registerUIStrings("panels/sources/InplaceFormatterEditorAction.ts",Xo),Qo=e.i18n.getLocalizedString.bind(void 0,Yo);let Zo;class en{button;sourcesView;uiSourceCodeTitleChangedEvent=null;constructor(){}static instance(e={forceNew:null}){const{forceNew:t}=e;return Zo&&!t||(Zo=new en),Zo}editorSelected(e){const t=e.data;this.updateButton(t)}editorClosed(e){const{wasSelected:t}=e.data;t&&this.updateButton(null)}updateButton(e){this.uiSourceCodeTitleChangedEvent&&i.EventTarget.removeEventListeners([this.uiSourceCodeTitleChangedEvent]),this.uiSourceCodeTitleChangedEvent=e?e.addEventListener(f.UISourceCode.Events.TitleChanged,(e=>this.updateButton(e.data)),this):null;const t=this.isFormattable(e);this.button.element.classList.toggle("hidden",!t),e&&t&&this.button.setTitle(Qo(Xo.formatS,{PH1:e.name()}))}getOrCreateButton(e){return this.button||(this.sourcesView=e,this.sourcesView.addEventListener("EditorSelected",this.editorSelected.bind(this)),this.sourcesView.addEventListener("EditorClosed",this.editorClosed.bind(this)),this.button=new t.Toolbar.ToolbarButton(Qo(Xo.format),"brackets"),this.button.addEventListener("Click",this.formatSourceInPlace,this),this.updateButton(e.currentUISourceCode())),this.button}isFormattable(e){return!!e&&(!!e.project().canSetFileContent()||null!==h.Persistence.PersistenceImpl.instance().binding(e))}formatSourceInPlace(){const e=this.sourcesView.currentSourceFrame();if(!e)return;const t=e.uiSourceCode();this.isFormattable(t)&&(t.isDirty()?this.contentLoaded(t,e,t.workingCopy()):t.requestContent().then((i=>{this.contentLoaded(t,e,i.content||"")})))}async contentLoaded(e,t,i){const{formattedContent:o,formattedMapping:n}=await I.ScriptFormatter.format(e.contentType(),t.contentType,i);if(e.workingCopy()===o)return;const r=t.textEditor.toLineColumn(t.textEditor.state.selection.main.head),[s,a]=n.originalToFormatted(r.lineNumber,r.columnNumber);e.setWorkingCopy(o),this.sourcesView.showSourceLocation(e,{lineNumber:s,columnNumber:a})}}ki(en.instance);var tn=Object.freeze({__proto__:null,InplaceFormatterEditorAction:en});var on=Object.freeze({__proto__:null,OpenFileQuickOpen:class extends _o{constructor(){super("source-file")}attach(){this.setDefaultScores(yi.defaultUISourceCodeScores()),super.attach()}uiSourceCodeSelected(e,t,o){c.userMetrics.actionTaken(c.UserMetrics.Action.SelectFileFromFilePicker),e&&("number"==typeof t?i.Revealer.reveal(e.uiLocation(t,o)):i.Revealer.reveal(e))}filterProject(e){return!e.isServiceProject()}renderItem(e,t,i,o){super.renderItem(e,t,i,o);const n=new r.Icon.Icon,s=N.iconDataForResourceType(this.itemContentTypeAt(e));n.data={...s,width:"20px",height:"20px"},i.parentElement?.parentElement?.insertBefore(n,i.parentElement)}renderAsTwoRows(){return!0}}});const nn={noFileSelected:"No file selected.",openAJavascriptOrCssFileToSee:"Open a JavaScript or CSS file to see symbols",noResultsFound:"No results found"},rn=e.i18n.registerUIStrings("panels/sources/OutlineQuickOpen.ts",nn),sn=e.i18n.getLocalizedString.bind(void 0,rn);function an(e){function t(t){t=Math.max(0,Math.min(t,e.doc.length));const i=e.doc.lineAt(t);return{lineNumber:i.number-1,columnNumber:t-i.from}}function i(){for(;"ParamList"!==r.name&&r.nextSibling(););let t="";if("ParamList"===r.name&&r.firstChild())do{switch(r.name){case"ArrayPattern":t+="[‥]";break;case"ObjectPattern":t+="{‥}";break;case"VariableDefinition":t+=e.sliceDoc(r.from,r.to);break;case"Spread":t+="...";break;case",":t+=", "}}while(r.nextSibling());return`(${t})`}const o=[],r=n.syntaxTree(e).cursor();do{switch(r.name){case"RuleSet":for(r.firstChild();;r.nextSibling()){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);if(o.push({title:i,lineNumber:n,columnNumber:s}),r.nextSibling(),","!==r.name)break}break;case"FunctionDeclaration":case"MethodDeclaration":{let n="";r.firstChild();do{switch(r.name){case"abstract":case"async":case"get":case"set":case"static":n=`${n}${r.name} `;break;case"Star":n+="*";break;case"PropertyDefinition":case"PrivatePropertyDefinition":case"VariableDefinition":{const s=n+e.sliceDoc(r.from,r.to),{lineNumber:a,columnNumber:c}=t(r.from),l=i();o.push({title:s,subtitle:l,lineNumber:a,columnNumber:c});break}}}while(r.nextSibling());break}case"Property":{let n="";r.firstChild();do{if("async"===r.name||"get"===r.name||"set"===r.name)n=`${n}${r.name} `;else{if("Star"!==r.name){if("PropertyDefinition"===r.name){let s=e.sliceDoc(r.from,r.to);const{lineNumber:a,columnNumber:c}=t(r.from);for(;r.nextSibling();){if("ClassExpression"===r.name){s=`class ${s}`,o.push({title:s,lineNumber:a,columnNumber:c});break}if("ArrowFunction"!==r.name&&"FunctionExpression"!==r.name||r.firstChild(),"async"===r.name)n=`async ${n}`;else if("Star"===r.name)n+="*";else if("ParamList"===r.name){s=n+s;const e=i();o.push({title:s,subtitle:e,lineNumber:a,columnNumber:c});break}}break}break}n+="*"}}while(r.nextSibling());break}case"PropertyName":case"VariableDefinition":if(r.matchContext(["ClassDeclaration"])){const i="class "+e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["AssignmentExpression","MemberExpression"])||r.matchContext(["VariableDeclaration"])){let n=e.sliceDoc(r.from,r.to);const{lineNumber:s,columnNumber:a}=t(r.from);for(;"Equals"!==r.name&&r.next(););if(!r.nextSibling())break;if("ArrowFunction"===r.name||"FunctionExpression"===r.name){r.firstChild();let e="";for(;"ParamList"!==r.name&&("async"===r.name?e=`async ${e}`:"Star"===r.name&&(e+="*"),r.nextSibling()););n=e+n;const t=i();o.push({title:n,subtitle:t,lineNumber:s,columnNumber:a})}else"ClassExpression"===r.name&&(n=`class ${n}`,o.push({title:n,lineNumber:s,columnNumber:a}))}break;case"App":if(r.firstChild()&&r.nextSibling()&&"module"===e.sliceDoc(r.from,r.to)){if(r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}do{if("App"===r.name&&r.firstChild()){if(r.nextSibling()&&"func"===e.sliceDoc(r.from,r.to)&&r.nextSibling()&&"Identifier"===r.name){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from),a=[];for(;r.nextSibling();)"App"===r.name&&r.firstChild()&&(r.nextSibling()&&"param"===e.sliceDoc(r.from,r.to)&&(r.nextSibling()&&"Identifier"===r.name?a.push(e.sliceDoc(r.from,r.to)):a.push(`$${a.length}`)),r.parent());const c=`(${a.join(", ")})`;o.push({title:i,subtitle:c,lineNumber:n,columnNumber:s})}r.parent()}}while(r.nextSibling())}break;case"FieldIdentifier":case"Identifier":if(r.matchContext(["FunctionDeclarator"])){const i=e.sliceDoc(r.from,r.to),{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}break;case"TypeIdentifier":if(r.matchContext(["ClassSpecifier"])){const i=`class ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}else if(r.matchContext(["StructSpecifier"])){const i=`struct ${e.sliceDoc(r.from,r.to)}`,{lineNumber:n,columnNumber:s}=t(r.from);o.push({title:i,lineNumber:n,columnNumber:s})}}}while(r.next());return o}class cn extends L.FilteredListWidget.Provider{items=[];active=!1;constructor(){super("source-symbol")}attach(){const e=this.currentSourceFrame();e?(this.active=!0,this.items=an(e.textEditor.state).map((({title:t,subtitle:i,lineNumber:o,columnNumber:n})=>(({lineNumber:o,columnNumber:n}=e.editorLocationToUILocation(o,n)),{title:t,subtitle:i,lineNumber:o,columnNumber:n})))):(this.active=!1,this.items=[])}detach(){this.active=!1,this.items=[]}itemCount(){return this.items.length}itemKeyAt(e){const t=this.items[e];return t.title+(t.subtitle?t.subtitle:"")}itemScoreAt(e,t){const i=this.items[e];return t.split("(")[0].toLowerCase()===i.title.toLowerCase()?1/(1+i.lineNumber):-i.lineNumber-1}renderItem(e,t,i,o){const n=this.items[e];i.textContent=n.title+(n.subtitle?n.subtitle:""),L.FilteredListWidget.FilteredListWidget.highlightRanges(i,t);const r=this.currentSourceFrame();if(!r)return;const s=i.parentElement?.parentElement?.createChild("span","tag");if(!s)return;const a=r.wasmDisassembly;if(a){const e=a.lineNumberToBytecodeOffset(a.lineNumbers-1).toString(16).length;s.textContent=`:0x${n.columnNumber.toString(16).padStart(e,"0")}`}else s.textContent=`:${n.lineNumber+1}`}selectItem(e,t){if(null===e)return;const i=this.currentSourceFrame();if(!i)return;const o=this.items[e];i.revealPosition({lineNumber:o.lineNumber,columnNumber:o.columnNumber},!0)}currentSourceFrame(){const e=t.Context.Context.instance().flavor(yi);return e&&e.currentSourceFrame()}notFoundText(){return this.currentSourceFrame()?this.active?sn(nn.noResultsFound):sn(nn.openAJavascriptOrCssFileToSee):sn(nn.noFileSelected)}}var ln=Object.freeze({__proto__:null,outline:an,OutlineQuickOpen:cn});const dn=new CSSStyleSheet;dn.replaceSync(".scope-chain-sidebar-pane-section-header{flex:auto}.scope-chain-sidebar-pane-section-icon{float:left;margin-right:5px}.scope-chain-sidebar-pane-section-subtitle{float:right;margin-left:5px;max-width:55%;text-overflow:ellipsis;overflow:hidden}.scope-chain-sidebar-pane-section-title{font-weight:normal;word-wrap:break-word;white-space:normal}.scope-chain-sidebar-pane-section{padding:2px 4px;flex:none}\n/*# sourceURL=scopeChainSidebarPane.css */\n");const un={loading:"Loading...",notPaused:"Not paused",noVariables:"No variables",closureS:"Closure ({PH1})",closure:"Closure",exception:"Exception",returnValue:"Return value"},hn=e.i18n.registerUIStrings("panels/sources/ScopeChainSidebarPane.ts",un),pn=e.i18n.getLocalizedString.bind(void 0,hn);let gn;class mn extends t.Widget.VBox{treeOutline;expandController;linkifier;infoElement;#P=null;constructor(){super(!0),this.contentElement.setAttribute("jslog",`${a.section("sources.scope-chain")}`),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),this.linkifier=new D.Linkifier.Linkifier,this.infoElement=document.createElement("div"),this.infoElement.className="gray-info-message",this.infoElement.tabIndex=-1,o.TargetManager.TargetManager.instance().addModelListener(o.DebuggerModel.DebuggerModel,o.DebuggerModel.Events.DebugInfoAttached,this.debugInfoAttached,this),this.update()}static instance(){return gn||(gn=new mn),gn}flavorChanged(e){this.update()}focus(){this.hasFocus()||t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails)&&this.treeOutline.forceSelect()}sourceMapAttached(e){e.data.client===this.#P&&this.update()}setScopeSourceMapSubscription(e){const t=this.#P;this.#P=e?.script??null,t?.debuggerModel!==this.#P?.debuggerModel&&(t&&t.debuggerModel.sourceMapManager().removeEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),this.#P&&this.#P.debuggerModel.sourceMapManager().addEventListener(o.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this))}debugInfoAttached(e){e.data===this.#P&&this.update()}async update(){this.infoElement.textContent=pn(un.loading),this.contentElement.removeChildren(),this.contentElement.appendChild(this.infoElement),this.linkifier.reset();const e=t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame);this.setScopeSourceMapSubscription(e);const[i,n]=await Promise.all([p.NamesResolver.resolveThisObject(e),p.NamesResolver.resolveScopeChain(e)]);if(e===t.Context.Context.instance().flavor(o.DebuggerModel.CallFrame)){const r=t.Context.Context.instance().flavor(o.DebuggerModel.DebuggerPausedDetails);if(this.treeOutline.removeChildren(),!r||!e||!n)return void(this.infoElement.textContent=pn(un.notPaused));this.contentElement.removeChildren(),this.contentElement.appendChild(this.treeOutline.element);let s=!1;for(let t=0;t${Cn(Sn.explainLocalOverrides)}
+ ${t.XLink.XLink.create("https://goo.gle/devtools-overrides",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `),this.toolbar=new t.Toolbar.Toolbar("navigator-toolbar"),this.contentElement.insertBefore(this.toolbar.element,this.contentElement.firstChild),h.NetworkPersistenceManager.NetworkPersistenceManager.instance().addEventListener("ProjectChanged",this.updateProjectAndUI,this),this.workspace().addEventListener(f.Workspace.Events.ProjectAdded,this.onProjectAddOrRemoved,this),this.workspace().addEventListener(f.Workspace.Events.ProjectRemoved,this.onProjectAddOrRemoved,this),this.updateProjectAndUI()}static instance(e={forceNew:null}){const{forceNew:t}=e;return In&&!t||(In=new xn),In}onProjectAddOrRemoved(e){const t=e.data;t&&t.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(t)||this.updateUI()}updateProjectAndUI(){this.reset();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();e&&this.tryAddProject(e),this.updateUI()}updateUI(){this.toolbar.removeToolbarItems();const e=h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project();if(e){const o=new t.Toolbar.ToolbarSettingCheckbox(i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled"));this.toolbar.appendToolbarItem(o),this.toolbar.appendToolbarItem(new t.Toolbar.ToolbarSeparator(!0));const n=new t.Toolbar.ToolbarButton(Cn(Sn.clearConfiguration),"clear");return n.addEventListener("Click",(()=>{i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!1),e.remove()})),void this.toolbar.appendToolbarItem(n)}const o=Cn(Sn.selectFolderForOverrides),n=new t.Toolbar.ToolbarButton(o,"plus",o);n.addEventListener("Click",(e=>{this.setupNewWorkspace()}),this),this.toolbar.appendToolbarItem(n)}async setupNewWorkspace(){await h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem("overrides")&&i.Settings.Settings.instance().moduleSetting("persistence-network-overrides-enabled").set(!0)}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.OverridesSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e===h.NetworkPersistenceManager.NetworkPersistenceManager.instance().project()}}var kn=Object.freeze({__proto__:null,NetworkNavigatorView:yn,FilesNavigatorView:class extends ut{constructor(){super("navigator-files");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` +
${Cn(Sn.explainWorkspace)}

+ ${t.XLink.XLink.create("https://goo.gle/devtools-workspace",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `);const i=new t.Toolbar.Toolbar("navigator-toolbar");i.appendItemsAtLocation("files-navigator-toolbar").then((()=>{i.empty()||this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}))}sourceSelected(e,t){c.userMetrics.actionTaken(c.UserMetrics.Action.WorkspaceSourceSelected),super.sourceSelected(e,t)}acceptProject(e){return e.type()===f.Workspace.projectTypes.FileSystem&&"overrides"!==h.FileSystemWorkspaceBinding.FileSystemWorkspaceBinding.fileSystemType(e)&&!T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.defaultSection().appendAction("sources.add-folder-to-workspace",void 0,!0),i.show()}},OverridesNavigatorView:xn,ContentScriptsNavigatorView:class extends ut{constructor(){super("navigator-content-scripts");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` +
${Cn(Sn.explainContentScripts)}

+ ${t.XLink.XLink.create("https://developer.chrome.com/extensions/content_scripts",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `)}acceptProject(e){return e.type()===f.Workspace.projectTypes.ContentScripts}},SnippetsNavigatorView:class extends ut{constructor(){super("navigator-snippets");const e=new t.EmptyWidget.EmptyWidget("");this.setPlaceholder(e),e.appendParagraph().appendChild(t.Fragment.html` +
${Cn(Sn.explainSnippets)}

+ ${t.XLink.XLink.create("https://goo.gle/devtools-snippets",Cn(Sn.learnMore),void 0,void 0,"learn-more")} + `);const i=new t.Toolbar.Toolbar("navigator-toolbar"),o=new t.Toolbar.ToolbarButton(Cn(Sn.newSnippet),"plus",Cn(Sn.newSnippet),"sources.new-snippet");o.addEventListener("Click",(e=>{this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")})),i.appendToolbarItem(o),this.contentElement.insertBefore(i.element,this.contentElement.firstChild)}acceptProject(e){return T.ScriptSnippetFileSystem.isSnippetsProject(e)}handleContextMenu(e){const i=new t.ContextMenu.ContextMenu(e);i.headerSection().appendItem(Cn(Sn.createNewSnippet),(()=>this.create(T.ScriptSnippetFileSystem.findSnippetsProject(),"")),{jslogContext:"create-new-snippet"}),i.show()}handleFileContextMenu(e,i){const o=i.uiSourceCode(),n=new t.ContextMenu.ContextMenu(e);n.headerSection().appendItem(Cn(Sn.run),(()=>T.ScriptSnippetFileSystem.evaluateScriptSnippet(o)),{jslogContext:"run"}),n.editSection().appendItem(Cn(Sn.rename),(()=>this.rename(i,!1)),{jslogContext:"rename"}),n.editSection().appendItem(Cn(Sn.remove),(()=>o.project().deleteFile(o)),{jslogContext:"remove"}),n.saveSection().appendItem(Cn(Sn.saveAs),this.handleSaveAs.bind(this,o),{jslogContext:"save-as"}),n.show()}async handleSaveAs(e){e.commitWorkingCopy();const{content:t}=await e.requestContent();await f.FileManager.FileManager.instance().save(this.addJSExtension(e.url()),t||"",!0),f.FileManager.FileManager.instance().close(e.url())}addJSExtension(e){return i.ParsedURL.ParsedURL.concatenate(e,".js")}},ActionDelegate:class{handleAction(e,t){switch(t){case"sources.create-snippet":return T.ScriptSnippetFileSystem.findSnippetsProject().createFile(l.DevToolsPath.EmptyEncodedPathString,null,"").then((e=>i.Revealer.reveal(e))),!0;case"sources.add-folder-to-workspace":return h.IsolatedFileSystemManager.IsolatedFileSystemManager.instance().addFileSystem(),!0}return!1}}});const Tn=new CSSStyleSheet;Tn.replaceSync(".value.object-value-node:hover{background-color:var(--sys-color-state-hover-on-subtle)}.object-value-function-prefix,\n.object-value-boolean{color:var(--sys-color-token-attribute-value)}.object-value-function{font-style:italic}.object-value-function.linkified:hover{--override-linkified-hover-background:rgb(0 0 0/10%);background-color:var(--override-linkified-hover-background);cursor:pointer}.-theme-with-dark-background .object-value-function.linkified:hover,\n:host-context(.-theme-with-dark-background) .object-value-function.linkified:hover{--override-linkified-hover-background:rgb(230 230 230/10%)}.object-value-number{color:var(--sys-color-token-attribute-value)}.object-value-bigint{color:var(--sys-color-token-comment)}.object-value-string,\n.object-value-regexp,\n.object-value-symbol{white-space:pre;unicode-bidi:-webkit-isolate;color:var(--sys-color-token-property-special)}.object-value-node{position:relative;vertical-align:baseline;color:var(--sys-color-token-variable);white-space:nowrap}.object-value-null,\n.object-value-undefined{color:var(--sys-color-state-disabled)}.object-value-unavailable{color:var(--sys-color-token-tag)}.object-value-calculate-value-button:hover{text-decoration:underline}.object-properties-section-custom-section{display:inline-flex;flex-direction:column}.-theme-with-dark-background .object-value-number,\n:host-context(.-theme-with-dark-background) .object-value-number,\n.-theme-with-dark-background .object-value-boolean,\n:host-context(.-theme-with-dark-background) .object-value-boolean{--override-primitive-dark-mode-color:hsl(252deg 100% 75%);color:var(--override-primitive-dark-mode-color)}.object-properties-section .object-description{color:var(--sys-color-token-subtle)}.value .object-properties-preview{white-space:nowrap}.name{color:var(--sys-color-token-tag);flex-shrink:0}.object-properties-preview .name{color:var(--sys-color-token-subtle)}@media (forced-colors: active){.object-value-calculate-value-button:hover{forced-color-adjust:none;color:Highlight}}\n/*# sourceURL=objectValue.css */\n");const En=new CSSStyleSheet;En.replaceSync(".watch-expression-delete-button{position:absolute;opacity:0%;right:0;.watch-expression-title:hover &{opacity:100%}}:host-context(.-theme-with-dark-background) .watch-expression-delete-button{filter:brightness(1.5)}.watch-expressions{min-height:26px}.watch-expression-title{white-space:nowrap;line-height:20px;display:flex}.watch-expression-title:hover{padding-right:26px}.watch-expression-object-header .watch-expression-title{margin-left:1px}.watch-expression{position:relative;flex:auto;min-height:20px}.watch-expression .name{color:var(--sys-color-purple);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:1000000;min-width:2em}.watch-expression-error{color:var(--sys-color-error)}.watch-expressions-separator{flex-shrink:0;flex-grow:0}.watch-expression .value{white-space:nowrap;display:inline;overflow:hidden;padding-left:4px;text-overflow:ellipsis;flex-shrink:1}.watch-expression .text-prompt{text-overflow:clip;overflow:hidden;white-space:nowrap;padding-left:4px;min-height:18px;line-height:18px;user-select:text}.watch-expression-text-prompt-proxy{margin:2px 12px 2px -4px;padding-bottom:3px}.watch-expression-header{flex:auto;margin-left:-16px;padding-left:15px}li.watch-expression-tree-item{padding-left:4px}li.watch-expression-tree-item.selected{background:var(--sys-color-neutral-container)}li.watch-expression-tree-item.selected:focus{background:var(--sys-color-tonal-container)}.watch-expression-header:focus-visible{background:var(--sys-color-tonal-container)}li.watch-expression-editing::before{background-color:transparent}@media (forced-colors: active){.watch-expression-title:hover .watch-expression-delete-button,\n .watch-expressions .dimmed{opacity:100%}li.watch-expression-tree-item *{forced-color-adjust:none;color:ButtonText}li.watch-expression-tree-item:hover{forced-color-adjust:none;background-color:Highlight}li.watch-expression-tree-item:hover *{color:HighlightText}li.watch-expression-tree-item:hover .watch-expression-delete-button{background-color:HighlightText}}\n/*# sourceURL=watchExpressionsSidebarPane.css */\n");const Ln={addWatchExpression:"Add watch expression",refreshWatchExpressions:"Refresh watch expressions",noWatchExpressions:"No watch expressions",deleteAllWatchExpressions:"Delete all watch expressions",addPropertyPathToWatch:"Add property path to watch",deleteWatchExpression:"Delete watch expression",notAvailable:"",copyValue:"Copy value"},Mn=e.i18n.registerUIStrings("panels/sources/WatchExpressionsSidebarPane.ts",Ln),Pn=e.i18n.getLocalizedString.bind(void 0,Mn);let Fn;class Dn extends t.ThrottledWidget.ThrottledWidget{watchExpressions;emptyElement;watchExpressionsSetting;addButton;refreshButton;treeOutline;expandController;linkifier;constructor(){super(!0),this.watchExpressions=[],this.watchExpressionsSetting=i.Settings.Settings.instance().createLocalSetting("watch-expressions",[]),this.addButton=new t.Toolbar.ToolbarButton(Pn(Ln.addWatchExpression),"plus",void 0,"add-watch-expression"),this.addButton.addEventListener("Click",(e=>{this.addButtonClicked()})),this.refreshButton=new t.Toolbar.ToolbarButton(Pn(Ln.refreshWatchExpressions),"refresh",void 0,"refresh-watch-expressions"),this.refreshButton.addEventListener("Click",this.update,this),this.contentElement.classList.add("watch-expressions"),this.contentElement.setAttribute("jslog",`${a.section("sources.watch")}`),this.contentElement.addEventListener("contextmenu",this.contextMenu.bind(this),!1),this.treeOutline=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeOutline,this.treeOutline.hideOverflow(),this.treeOutline.setShowSelectionOnKeyboardFocus(!0),this.expandController=new y.ObjectPropertiesSection.ObjectPropertiesSectionsTreeExpandController(this.treeOutline),t.Context.Context.instance().addFlavorChangeListener(o.RuntimeModel.ExecutionContext,this.update,this),t.Context.Context.instance().addFlavorChangeListener(o.DebuggerModel.CallFrame,this.update,this),this.linkifier=new D.Linkifier.Linkifier,this.update()}static instance(){return Fn||(Fn=new Dn),Fn}toolbarItems(){return[this.addButton,this.refreshButton]}focus(){this.hasFocus()||this.watchExpressions.length>0&&this.treeOutline.forceSelect()}hasExpressions(){return Boolean(this.watchExpressionsSetting.get().length)}saveExpressions(){const e=[];for(let t=0;t1&&e.debugSection().appendItem(Pn(Ln.deleteAllWatchExpressions),this.deleteAllButtonClicked.bind(this),{jslogContext:"delete-all-watch-expressions"});const o=this.treeOutline.treeElementFromEvent(t);if(!o)return;const n=this.watchExpressions.find((e=>o.hasAncestorOrSelf(e.treeElement())));n&&n.populateContextMenu(e,t)}deleteAllButtonClicked(){this.watchExpressions=[],this.saveExpressions(),this.update()}async focusAndAddExpressionToWatch(e){await t.ViewManager.ViewManager.instance().showView("sources.watch"),this.createWatchExpression(e),this.saveExpressions(),this.update()}handleAction(e,i){const o=t.Context.Context.instance().flavor(Kt);if(!o)return!1;const{state:n}=o.textEditor,r=n.sliceDoc(n.selection.main.from,n.selection.main.to);return this.focusAndAddExpressionToWatch(r),!0}appendApplicableItems(e,t,i){i instanceof y.ObjectPropertiesSection.ObjectPropertyTreeElement?i.property.synthetic||t.debugSection().appendItem(Pn(Ln.addPropertyPathToWatch),(()=>this.focusAndAddExpressionToWatch(i.path())),{jslogContext:"add-property-path-to-watch"}):i.textEditor.state.selection.main.empty||t.debugSection().appendAction("sources.add-to-watch")}wasShown(){super.wasShown(),this.treeOutline.registerCSSFiles([En]),this.registerCSSFiles([En,Tn])}}class Nn extends i.ObjectWrapper.ObjectWrapper{treeElementInternal;nameElement;valueElement;expressionInternal;expandController;element;editing;linkifier;textPrompt;result;preventClickTimeout;constructor(e,t,i){super(),this.expressionInternal=e,this.expandController=t,this.element=document.createElement("div"),this.element.classList.add("watch-expression"),this.element.classList.add("monospace"),this.editing=!1,this.linkifier=i,this.createWatchExpression(),this.update()}treeElement(){return this.treeElementInternal}expression(){return this.expressionInternal}async#F(e,t){if(C.Runtime.experiments.isEnabled("evaluate-expressions-with-source-maps")){const i=e.debuggerModel.selectedCallFrame();if(i){const e=await p.NamesResolver.allVariablesInCallFrame(i);try{t=await I.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(t,e)}catch{}}}return e.evaluate({expression:t,objectGroup:Nn.watchObjectGroupId,includeCommandLineAPI:!1,silent:!0,returnByValue:!1,generatePreview:!1},!1,!1)}update(){const e=t.Context.Context.instance().flavor(o.RuntimeModel.ExecutionContext);e&&this.expressionInternal?this.#F(e,this.expressionInternal).then((e=>{"object"in e?this.createWatchExpression(e.object,e.exceptionDetails):this.createWatchExpression()})):this.createWatchExpression()}startEditing(){this.editing=!0,this.treeElementInternal.setDisableSelectFocus(!0),this.element.removeChildren();const e=this.element.createChild("div");e.textContent=this.nameElement.textContent,this.textPrompt=new y.ObjectPropertiesSection.ObjectPropertyPrompt,this.textPrompt.renderAsBlock();const t=this.textPrompt.attachAndStartEditing(e,this.finishEditing.bind(this));this.treeElementInternal.listItemElement.classList.add("watch-expression-editing"),this.treeElementInternal.collapse(),t.classList.add("watch-expression-text-prompt-proxy"),t.addEventListener("keydown",this.promptKeyDown.bind(this),!1);const i=this.element.getComponentSelection();i&&i.selectAllChildren(e)}isEditing(){return Boolean(this.editing)}finishEditing(e,t){if(e&&e.consume(t),this.editing=!1,this.treeElementInternal.setDisableSelectFocus(!1),this.treeElementInternal.listItemElement.classList.remove("watch-expression-editing"),this.textPrompt){this.textPrompt.detach();const e=t?this.expressionInternal:this.textPrompt.text();this.textPrompt=void 0,this.element.removeChildren(),this.updateExpression(e)}}dblClickOnWatchExpression(e){e.consume(),this.isEditing()||this.startEditing()}updateExpression(e){this.expressionInternal&&this.expandController.stopWatchSectionsWithId(this.expressionInternal),this.expressionInternal=e,this.update(),this.dispatchEventToListeners("ExpressionUpdated",this)}deleteWatchExpression(e){e.consume(!0),this.updateExpression(null)}createWatchExpression(e,t){this.result=e||null,this.element.removeChildren();const i=this.treeElementInternal;if(this.createWatchExpressionTreeElement(e,t),i&&i.parent){const e=i.parent,t=e.indexOfChild(i);e.removeChild(i),e.insertChild(this.treeElementInternal,t)}this.treeElementInternal.select()}createWatchExpressionHeader(e,i){const o=this.element.createChild("div","watch-expression-header"),n=new A.Button.Button;n.variant="round",n.iconName="bin",n.className="watch-expression-delete-button",n.jslogContext="delete-watch-expression",n.size="SMALL",t.Tooltip.Tooltip.install(n,Pn(Ln.deleteWatchExpression)),n.addEventListener("click",this.deleteWatchExpression.bind(this),!1);const r=o.createChild("div","watch-expression-title tree-element-title");if(r.appendChild(n),this.nameElement=y.ObjectPropertiesSection.ObjectPropertiesSection.createNameElement(this.expressionInternal),t.Tooltip.Tooltip.install(this.nameElement,this.expressionInternal),Boolean(i)||!e)this.valueElement=document.createElement("span"),this.valueElement.classList.add("watch-expression-error"),this.valueElement.classList.add("value"),r.classList.add("dimmed"),this.valueElement.textContent=Pn(Ln.notAvailable),void 0!==i&&void 0!==i.exception&&void 0!==i.exception.description&&t.Tooltip.Tooltip.install(this.valueElement,i.exception.description);else{const t=y.ObjectPropertiesSection.ObjectPropertiesSection.createPropertyValueWithCustomSupport(e,Boolean(i),!1,r,this.linkifier);this.valueElement=t.element}const s=document.createElement("span");return s.classList.add("watch-expressions-separator"),s.textContent=": ",r.append(this.nameElement,s,this.valueElement),o}createWatchExpressionTreeElement(e,i){const o=this.createWatchExpressionHeader(e,i);!i&&e&&e.hasChildren&&!e.customPreview()?(o.classList.add("watch-expression-object-header"),this.treeElementInternal=new y.ObjectPropertiesSection.RootElement(e,this.linkifier),this.expandController.watchSection(this.expressionInternal,this.treeElementInternal),this.treeElementInternal.toggleOnClick=!1,this.treeElementInternal.listItemElement.addEventListener("click",this.onSectionClick.bind(this),!1),this.treeElementInternal.listItemElement.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this))):(o.addEventListener("dblclick",this.dblClickOnWatchExpression.bind(this)),this.treeElementInternal=new t.TreeOutline.TreeElement),this.treeElementInternal.title=this.element,this.treeElementInternal.listItemElement.classList.add("watch-expression-tree-item"),this.treeElementInternal.listItemElement.addEventListener("keydown",(e=>{"Enter"!==e.key||this.isEditing()?"Delete"!==e.key||this.isEditing()||this.deleteWatchExpression(e):(this.startEditing(),e.consume(!0))}))}onSectionClick(e){e.consume(!0);1===e.detail?this.preventClickTimeout=window.setTimeout(function(){if(!this.treeElementInternal)return;this.treeElementInternal.expanded?this.treeElementInternal.collapse():this.editing||this.treeElementInternal.expand()}.bind(this),333):void 0!==this.preventClickTimeout&&(window.clearTimeout(this.preventClickTimeout),this.preventClickTimeout=void 0)}promptKeyDown(e){const t=l.KeyboardUtilities.isEscKey(e);("Enter"===e.key||t)&&this.finishEditing(e,t)}populateContextMenu(e,i){this.isEditing()||e.editSection().appendItem(Pn(Ln.deleteWatchExpression),this.updateExpression.bind(this,null),{jslogContext:"delete-watch-expression"}),this.isEditing()||!this.result||"number"!==this.result.type&&"string"!==this.result.type||e.clipboardSection().appendItem(Pn(Ln.copyValue),this.copyValueButtonClicked.bind(this),{jslogContext:"copy-watch-expression-value"});const o=t.UIUtils.deepElementFromEvent(i);o&&this.valueElement.isSelfOrAncestor(o)&&this.result&&e.appendApplicableItems(this.result)}copyValueButtonClicked(){c.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(this.valueElement.textContent)}static watchObjectGroupId="watch-group"}var An=Object.freeze({__proto__:null,WatchExpressionsSidebarPane:Dn,WatchExpression:Nn});export{W as AddSourceMapURLDialog,G as BreakpointEditDialog,_e as CSSPlugin,ne as CallStackSidebarPane,he as CategorizedBreakpointL10n,Te as CoveragePlugin,Ye as DebuggerPausedMessage,Bo as DebuggerPlugin,xt as EditingLocationHistoryManager,Vo as FilePathScoreFunction,zo as FilteredUISourceCodeListProvider,Jo as GoToLineQuickOpen,tn as InplaceFormatterEditorAction,Ct as NavigatorView,on as OpenFileQuickOpen,ln as OutlineQuickOpen,ge as Plugin,Ht as ResourceOriginPlugin,bn as ScopeChainSidebarPane,rt as SearchSourcesView,Gt as SnippetsPlugin,kn as SourcesNavigator,$i as SourcesPanel,it as SourcesSearchScope,Mi as SourcesView,vi as TabbedEditorContainer,Ui as ThreadsSidebarPane,ci as UISourceCodeFrame,An as WatchExpressionsSidebarPane}; diff --git a/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js b/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js index a8c37b3594b..19eed806043 100644 --- a/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js +++ b/packages/debugger-frontend/dist/third-party/front_end/ui/legacy/legacy.js @@ -1,4 +1,4 @@ -import*as e from"../../core/common/common.js";import*as t from"../../core/i18n/i18n.js";import*as i from"../../core/platform/platform.js";import*as n from"../../core/root/root.js";import*as s from"../../core/host/host.js";import*as o from"../visual_logging/visual_logging.js";import*as r from"../../models/text_utils/text_utils.js";import*as a from"../components/icon_button/icon_button.js";import*as l from"../components/adorners/adorners.js";import*as h from"../components/settings/settings.js";import*as d from"./utils/utils.js";export{d as Utils};import*as c from"../../core/dom_extension/dom_extension.js";import*as u from"../components/helpers/helpers.js";import*as m from"./theme_support/theme_support.js";import*as p from"../lit-html/lit-html.js";let g;class b{flavorsInternal;eventDispatchers;constructor(){this.flavorsInternal=new Map,this.eventDispatchers=new Map}static instance(e={forceNew:null}){const{forceNew:t}=e;return g&&!t||(g=new b),g}static removeInstance(){g=void 0}setFlavor(e,t){(this.flavorsInternal.get(e)||null)!==t&&(t?this.flavorsInternal.set(e,t):this.flavorsInternal.delete(e),this.dispatchFlavorChange(e,t))}dispatchFlavorChange(e,t){for(const i of f)i.contextTypes().includes(e)&&i.loadListener().then((e=>e.flavorChanged(t)));const i=this.eventDispatchers.get(e);i&&i.dispatchEventToListeners("FlavorChanged",t)}addFlavorChangeListener(t,i,n){let s=this.eventDispatchers.get(t);s||(s=new e.ObjectWrapper.ObjectWrapper,this.eventDispatchers.set(t,s)),s.addEventListener("FlavorChanged",i,n)}removeFlavorChangeListener(e,t,i){const n=this.eventDispatchers.get(e);n&&(n.removeEventListener("FlavorChanged",t,i),n.hasEventListeners("FlavorChanged")||this.eventDispatchers.delete(e))}flavor(e){return this.flavorsInternal.get(e)||null}flavors(){return new Set(this.flavorsInternal.keys())}}const f=[];var v=Object.freeze({__proto__:null,Context:b,registerListener:function(e){f.push(e)}});const w={elements:"Elements",screenshot:"Screenshot",network:"Network",memory:"Memory",javascript_profiler:"JavaScript Profiler",console:"Console",performance:"Performance",mobile:"Mobile",help:"Help",layers:"Layers",navigation:"Navigation",drawer:"Drawer",global:"Global",resources:"Resources",background_services:"Background Services",settings:"Settings",debugger:"Debugger",sources:"Sources",rendering:"Rendering",recorder:"Recorder",changes:"Changes"},x=t.i18n.registerUIStrings("ui/legacy/ActionRegistration.ts",w),E=t.i18n.getLocalizedString.bind(void 0,x);class I extends e.ObjectWrapper.ObjectWrapper{enabledInternal=!0;toggledInternal=!1;actionRegistration;constructor(e){super(),this.actionRegistration=e}id(){return this.actionRegistration.actionId}async execute(){if(!this.actionRegistration.loadActionDelegate)return!1;const e=await this.actionRegistration.loadActionDelegate(),t=this.id();return e.handleAction(b.instance(),t)}icon(){return this.actionRegistration.iconClass}toggledIcon(){return this.actionRegistration.toggledIconClass}toggleWithRedColor(){return Boolean(this.actionRegistration.toggleWithRedColor)}setEnabled(e){this.enabledInternal!==e&&(this.enabledInternal=e,this.dispatchEventToListeners("Enabled",e))}enabled(){return this.enabledInternal}category(){return this.actionRegistration.category}tags(){if(this.actionRegistration.tags)return this.actionRegistration.tags.map((e=>e())).join("\0")}toggleable(){return Boolean(this.actionRegistration.toggleable)}title(){let e=this.actionRegistration.title?this.actionRegistration.title():t.i18n.lockedString("");const i=this.actionRegistration.options;if(i)for(const t of i)t.value!==this.toggledInternal&&(e=t.title());return e}toggled(){return this.toggledInternal}setToggled(e){console.assert(this.toggleable(),"Shouldn't be toggling an untoggleable action",this.id()),this.toggledInternal!==e&&(this.toggledInternal=e,this.dispatchEventToListeners("Toggled",e))}options(){return this.actionRegistration.options}contextTypes(){if(this.actionRegistration.contextTypes)return this.actionRegistration.contextTypes()}canInstantiate(){return Boolean(this.actionRegistration.loadActionDelegate)}bindings(){return this.actionRegistration.bindings}experiment(){return this.actionRegistration.experiment}setting(){return this.actionRegistration.setting}condition(){return this.actionRegistration.condition}order(){return this.actionRegistration.order}}const y=new Map;function S(){y.clear()}function C(){return Array.from(y.values()).filter((t=>{const i=t.setting();try{if(i&&!e.Settings.moduleSetting(i).get())return!1}catch(e){if(e.message.startsWith("No setting registered"))return!1}return n.Runtime.Runtime.isDescriptorEnabled({experiment:t.experiment(),condition:t.condition()})})).sort(((e,t)=>(e.order()||0)-(t.order()||0)))}var T=Object.freeze({__proto__:null,Action:I,registerActionExtension:function(e){const t=e.actionId;if(y.has(t))throw new Error(`Duplicate action ID '${t}'`);if(!i.StringUtilities.isExtendedKebabCase(t))throw new Error(`Invalid action ID '${t}'`);y.set(t,new I(e))},reset:S,getRegisteredActionExtensions:C,maybeRemoveActionExtension:function(e){return y.delete(e)},getLocalizedActionCategory:function(e){switch(e){case"ELEMENTS":return E(w.elements);case"SCREENSHOT":return E(w.screenshot);case"NETWORK":return E(w.network);case"MEMORY":return E(w.memory);case"JAVASCRIPT_PROFILER":return E(w.javascript_profiler);case"CONSOLE":return E(w.console);case"PERFORMANCE":return E(w.performance);case"MOBILE":return E(w.mobile);case"HELP":return E(w.help);case"LAYERS":return E(w.layers);case"NAVIGATION":return E(w.navigation);case"DRAWER":return E(w.drawer);case"GLOBAL":return E(w.global);case"RESOURCES":return E(w.resources);case"BACKGROUND_SERVICES":return E(w.background_services);case"SETTINGS":return E(w.settings);case"DEBUGGER":return E(w.debugger);case"SOURCES":return E(w.sources);case"RENDERING":return E(w.rendering);case"RECORDER":return E(w.recorder);case"CHANGES":return E(w.changes);case"":return t.i18n.lockedString("")}return t.i18n.lockedString(e)}});let k;class M{actionsById;constructor(){this.actionsById=new Map,this.registerActions()}static instance(e={forceNew:null}){const{forceNew:t}=e;return k&&!t||(k=new M),k}static removeInstance(){k=void 0}static reset(){M.removeInstance(),S()}registerActions(){for(const e of C())this.actionsById.set(e.id(),e),e.canInstantiate()||e.setEnabled(!1)}availableActions(){return this.applicableActions([...this.actionsById.keys()],b.instance())}actions(){return[...this.actionsById.values()]}applicableActions(e,t){const i=[];for(const s of e){const e=this.actionsById.get(s);e&&e.enabled()&&n(e,t.flavors())&&i.push(e)}return i;function n(e,t){const i=e.contextTypes();if(!i)return!0;for(let e=0;e0?Math.PI/2:-Math.PI/2,n=0):e.m13>0?(t=Math.atan2(-e.m21,e.m22),i=Math.asin(e.m23),n=-Math.PI/2):(t=Math.atan2(e.m21,-e.m22),i=-Math.asin(e.m23),i+=i>0||Math.abs(i)0?(t=Math.atan2(-e.m21,e.m22),i=Math.asin(e.m23),n=Math.atan2(-e.m13,e.m33)):(t=Math.atan2(e.m21,-e.m22),i=-Math.asin(e.m23),i+=i>0||Math.abs(i)this.preferred.width||this.minimum.height>this.preferred.height)throw new Error("Minimum size is greater than preferred.")}isEqual(e){return null!==e&&this.minimum.isEqual(e.minimum)&&this.preferred.isEqual(e.preferred)}widthToMax(e){return"number"==typeof e?new je(this.minimum.widthToMax(e),this.preferred.widthToMax(e)):new je(this.minimum.widthToMax(e.minimum),this.preferred.widthToMax(e.preferred))}addWidth(e){return"number"==typeof e?new je(this.minimum.addWidth(e),this.preferred.addWidth(e)):new je(this.minimum.addWidth(e.minimum),this.preferred.addWidth(e.preferred))}heightToMax(e){return"number"==typeof e?new je(this.minimum.heightToMax(e),this.preferred.heightToMax(e)):new je(this.minimum.heightToMax(e.minimum),this.preferred.heightToMax(e.preferred))}addHeight(e){return"number"==typeof e?new je(this.minimum.addHeight(e),this.preferred.addHeight(e)):new je(this.minimum.addHeight(e.minimum),this.preferred.addHeight(e.preferred))}}var Ve=Object.freeze({__proto__:null,_Eps:Ae,Vector:Re,Point:Be,CubicBezier:Oe,LINEAR_BEZIER:Fe,EulerAngles:ze,scalarProduct:We,crossProduct:function(e,t){const i=e.y*t.z-e.z*t.y,n=e.z*t.x-e.x*t.z,s=e.x*t.y-e.y*t.x;return new Re(i,n,s)},subtract:function(e,t){const i=e.x-t.x,n=e.y-t.y,s=e.z-t.z;return new Re(i,n,s)},multiplyVectorByMatrixAndNormalize:He,calculateAngle:function(e,t){const i=e.length(),n=t.length();if(i<=Ae||n<=Ae)return 0;const s=We(e,t)/i/n;return Math.abs(s)>1?0:Ne(Math.acos(s))},degreesToRadians:function(e){return e*Math.PI/180},degreesToGradians:function(e){return e/9*10},degreesToTurns:function(e){return e/360},radiansToDegrees:Ne,radiansToGradians:function(e){return 200*e/Math.PI},radiansToTurns:function(e){return e/(2*Math.PI)},gradiansToRadians:function(e){return e*Math.PI/200},turnsToRadians:function(e){return 2*e*Math.PI},boundsForTransformedPoints:function(e,t,i){i||(i={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0}),t.length%3&&console.warn("Invalid size of points array");for(let n=0;ne.name)).join(" ")}isDefault(){return"DefaultShortcut"===this.type||"DisabledDefault"===this.type||"KeybindSetShortcut"===this.type&&this.keybindSets.has(Hs)}changeType(e){return new Ke(this.descriptors,this.action,e)}changeKeys(e){return this.descriptors=e,this}descriptorsMatch(e){return e.length===this.descriptors.length&&e.every(((e,t)=>e.key===this.descriptors[t].key))}hasKeybindSet(e){return!this.keybindSets||this.keybindSets.has(e)}equals(e){return this.descriptorsMatch(e.descriptors)&&this.type===e.type&&this.action===e.action}static createShortcutFromSettingObject(e){return new Ke(e.descriptors,e.action,e.type)}static makeKey(e,t){return"string"==typeof e&&(e=e.charCodeAt(0)-(/^[a-z]/.test(e)?32:0)),t=t||qe.None,Ke.makeKeyFromCodeAndModifiers(e,t)}static makeKeyFromEvent(e){let t=qe.None;e.shiftKey&&(t|=qe.Shift),e.ctrlKey&&(t|=qe.Ctrl),e.altKey&&(t|=qe.Alt),e.metaKey&&(t|=qe.Meta);const i=e.keyCode||e.__keyCode;return Ke.makeKeyFromCodeAndModifiers(i,t)}static makeKeyFromEventIgnoringModifiers(e){const t=e.keyCode||e.__keyCode;return Ke.makeKeyFromCodeAndModifiers(t,qe.None)}static eventHasCtrlEquivalentKey(e){return s.Platform.isMac()?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}static eventHasEitherCtrlOrMeta(e){return e.metaKey||e.ctrlKey}static hasNoModifiers(e){const t=e;return!(t.ctrlKey||t.shiftKey||t.altKey||t.metaKey)}static makeDescriptor(e,t){return{key:Ke.makeKey("string"==typeof e?e:e.code,t),name:Ke.shortcutToString(e,t)}}static makeDescriptorFromBindingShortcut(e){const[t,...i]=e.split(/\+(?!$)/).reverse();let n=0;for(const t of i){const i=qe[t];console.assert(void 0!==i,`Only one key other than modifier is allowed in shortcut <${e}>`),n|=i}console.assert(t.length>0,`Modifiers-only shortcuts are not allowed (encountered <${e}>)`);const s=nt[t]||st[t];return s&&"shiftKey"in s&&s.shiftKey&&(n|=qe.Shift),Ke.makeDescriptor(s||t,n)}static shortcutToString(e,t){return"string"!=typeof e&&Ke.isModifier(e.code)?Ke.modifiersToString(t):Ke.modifiersToString(t)+Ke.keyName(e)}static keyName(e){return"string"==typeof e?e.toUpperCase():"string"==typeof e.name?e.name:e.name[s.Platform.platform()]||e.name.other||""}static makeKeyFromCodeAndModifiers(e,t){return 255&e|(t||0)<<8}static keyCodeAndModifiersFromKey(e){return{keyCode:255&e,modifiers:e>>8}}static isModifier(e){const{keyCode:t}=Ke.keyCodeAndModifiersFromKey(e);return t===nt.Shift.code||t===nt.Ctrl.code||t===nt.Alt.code||t===nt.Meta.code}static modifiersToString(e){const t=s.Platform.isMac(),i=qe,n=new Map([[i.Ctrl,t?"Ctrl ":"Ctrl + "],[i.Alt,t?"⌥ ":"Alt + "],[i.Shift,t?"⇧ ":"Shift + "],[i.Meta,t?"⌘ ":"Win + "]]);return[i.Meta,i.Ctrl,i.Alt,i.Shift].map((function(t){return(e||0)&t?n.get(t):""})).join("")}}const qe={None:0,Shift:1,Ctrl:2,Alt:4,Meta:8,CtrlOrMeta:s.Platform.isMac()?8:2,ShiftOrOption:s.Platform.isMac()?4:1},$e={code:37,name:"←"},Ge={code:38,name:"↑"},Xe={code:39,name:"→"},Ye={code:40,name:"↓"},Qe={code:17,name:"Ctrl"},Ze={code:27,name:"Esc"},Je={code:32,name:"Space"},et={code:187,name:"+"},tt={code:192,name:"`"},it={code:222,name:"'"},nt={Backspace:{code:8,name:"↤"},Tab:{code:9,name:{mac:"⇥",other:"Tab"}},Enter:{code:13,name:{mac:"↩",other:"Enter"}},Shift:{code:16,name:{mac:"⇧",other:"Shift"}},Ctrl:Qe,Control:Qe,Alt:{code:18,name:"Alt"},Esc:Ze,Escape:Ze,Space:Je," ":Je,PageUp:{code:33,name:{mac:"⇞",other:"PageUp"}},PageDown:{code:34,name:{mac:"⇟",other:"PageDown"}},End:{code:35,name:{mac:"↗",other:"End"}},Home:{code:36,name:{mac:"↖",other:"Home"}},Left:$e,Up:Ge,Right:Xe,Down:Ye,ArrowLeft:$e,ArrowUp:Ge,ArrowRight:Xe,ArrowDown:Ye,Delete:{code:46,name:"Del"},Zero:{code:48,name:"0"},H:{code:72,name:"H"},N:{code:78,name:"N"},P:{code:80,name:"P"},Meta:{code:91,name:"Meta"},F1:{code:112,name:"F1"},F2:{code:113,name:"F2"},F3:{code:114,name:"F3"},F4:{code:115,name:"F4"},F5:{code:116,name:"F5"},F6:{code:117,name:"F6"},F7:{code:118,name:"F7"},F8:{code:119,name:"F8"},F9:{code:120,name:"F9"},F10:{code:121,name:"F10"},F11:{code:122,name:"F11"},F12:{code:123,name:"F12"},Semicolon:{code:186,name:";"},NumpadPlus:{code:107,name:"Numpad +"},NumpadMinus:{code:109,name:"Numpad -"},Numpad0:{code:96,name:"Numpad 0"},Plus:et,Equal:et,Comma:{code:188,name:","},Minus:{code:189,name:"-"},Period:{code:190,name:"."},Slash:{code:191,name:"/"},QuestionMark:{code:191,name:"?"},Apostrophe:tt,Tilde:{code:192,name:"Tilde"},Backquote:tt,IntlBackslash:tt,LeftSquareBracket:{code:219,name:"["},RightSquareBracket:{code:221,name:"]"},Backslash:{code:220,name:"\\"},SingleQuote:it,Quote:it,get CtrlOrMeta(){return s.Platform.isMac()?this.Meta:this.Ctrl}},st={};!function(){for(const e in nt){const t=nt[e];if("object"==typeof t&&t.code){const i="string"==typeof t.name?t.name:e;st[i]=t}}}();var ot=Object.freeze({__proto__:null,KeyboardShortcut:Ke,Modifiers:qe,Keys:nt,KeyBindings:st}),rt={cssContent:"::slotted(input.dt-radio-button){height:17px;width:17px;min-width:17px;border-radius:8px;vertical-align:middle;margin:0 5px 5px 0;accent-color:var(--sys-color-primary-bright);color:var(--sys-color-on-primary)}::slotted(input.dt-radio-button:focus){box-shadow:var(--legacy-focus-ring-active-shadow)}@media (forced-colors: active){::slotted(input.dt-radio-button){--gradient-start:ButtonFace;--gradient-end:ButtonFace}::slotted(input.dt-radio-button:checked){--gradient-start:Highlight;--gradient-end:Highlight}}"},at={cssContent:".dt-range-input{appearance:none;margin:0;padding:0;height:10px;width:88px;outline:none;background:none}.dt-range-input::-webkit-slider-thumb,\n.-theme-preserve{appearance:none;margin:0;padding:0;border:0;width:12px;height:12px;margin-top:-5px;border-radius:50%;background-color:var(--sys-color-primary)}.dt-range-input::-webkit-slider-runnable-track{appearance:none;margin:0;padding:0;width:100%;height:2px;background-color:var(--sys-color-surface-variant)}.dt-range-input:focus::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--sys-color-inverse-primary)}.dt-range-input:disabled::-webkit-slider-thumb{background-color:var(--sys-color-state-disabled)}@media (forced-colors: active){.dt-range-input{forced-color-adjust:none}}"},lt={cssContent:"div{display:inline-flex;height:14px;align-items:center;vertical-align:middle;white-space:nowrap;padding:1px 4px;text-align:left;font-size:11px;line-height:normal;font-weight:bold;text-shadow:none;color:var(--sys-color-inverse-on-surface);border-radius:7px}div.verbose{background-color:var(--sys-color-token-attribute-value)}:host-context(.-theme-with-dark-background) div.verbose{background-color:var(--sys-color-token-tag)}div.info{background-color:var(--sys-color-token-meta)}div.warning{background-color:var(--sys-color-token-attribute)}:host-context(.-theme-with-dark-background) div.warning{background-color:var(--sys-color-token-attribute-value)}div.error{background-color:var(--sys-color-error-bright)}"};const ht={close:"Close",dockToRight:"Dock to right",dockToBottom:"Dock to bottom",dockToLeft:"Dock to left",undockIntoSeparateWindow:"Undock into separate window",devtoolsUndocked:"DevTools is undocked",devToolsDockedTo:"DevTools is docked to {PH1}"},dt=t.i18n.registerUIStrings("ui/legacy/DockController.ts",ht),ct=t.i18n.getLocalizedString.bind(void 0,dt);let ut;class mt extends e.ObjectWrapper.ObjectWrapper{canDockInternal;closeButton;currentDockStateSetting;lastDockStateSetting;dockSideInternal=void 0;titles;savedFocus;constructor(t){if(super(),this.canDockInternal=t,this.closeButton=new wn(ct(ht.close),"cross"),this.closeButton.element.setAttribute("jslog",`${o.close().track({click:!0})}`),this.closeButton.element.classList.add("close-devtools"),this.closeButton.addEventListener("Click",s.InspectorFrontendHost.InspectorFrontendHostInstance.closeWindow.bind(s.InspectorFrontendHost.InspectorFrontendHostInstance)),this.currentDockStateSetting=e.Settings.Settings.instance().moduleSetting("currentDockState"),this.lastDockStateSetting=e.Settings.Settings.instance().createSetting("last-dock-state","bottom"),!t)return this.dockSideInternal="undocked",void this.closeButton.setVisible(!1);this.currentDockStateSetting.addChangeListener(this.dockSideChanged,this),-1===pt.indexOf(this.currentDockStateSetting.get())&&this.currentDockStateSetting.set("right"),-1===pt.indexOf(this.lastDockStateSetting.get())&&this.currentDockStateSetting.set("bottom")}static instance(e={forceNew:null,canDock:!1}){const{forceNew:t,canDock:i}=e;return ut&&!t||(ut=new mt(i)),ut}initialize(){this.canDockInternal&&(this.titles=[ct(ht.dockToRight),ct(ht.dockToBottom),ct(ht.dockToLeft),ct(ht.undockIntoSeparateWindow)],this.dockSideChanged())}dockSideChanged(){this.setDockSide(this.currentDockStateSetting.get()),setTimeout(this.announceDockLocation.bind(this),2e3)}dockSide(){return this.dockSideInternal}canDock(){return this.canDockInternal}isVertical(){return"right"===this.dockSideInternal||"left"===this.dockSideInternal}setDockSide(e){if(-1===pt.indexOf(e)&&(e=pt[0]),this.dockSideInternal===e)return;void 0!==this.dockSideInternal&&document.body.classList.remove(this.dockSideInternal),document.body.classList.add(e),this.dockSideInternal&&this.lastDockStateSetting.set(this.dockSideInternal),this.savedFocus=i.DOMUtilities.deepActiveElement(document);const t={from:this.dockSideInternal,to:e};this.dispatchEventToListeners("BeforeDockSideChanged",t),console.timeStamp("DockController.setIsDocked"),this.dockSideInternal=e,this.currentDockStateSetting.set(e),s.InspectorFrontendHost.InspectorFrontendHostInstance.setIsDocked("undocked"!==e,this.setIsDockedResponse.bind(this,t)),this.closeButton.setVisible("undocked"!==this.dockSideInternal),this.dispatchEventToListeners("DockSideChanged",t)}setIsDockedResponse(e){this.dispatchEventToListeners("AfterDockSideChanged",e),this.savedFocus&&(this.savedFocus.focus(),this.savedFocus=null)}toggleDockSide(){if(this.lastDockStateSetting.get()===this.currentDockStateSetting.get()){const e=pt.indexOf(this.currentDockStateSetting.get())||0;this.lastDockStateSetting.set(pt[(e+1)%pt.length])}this.setDockSide(this.lastDockStateSetting.get())}announceDockLocation(){"undocked"===this.dockSideInternal?Se(ct(ht.devtoolsUndocked)):Se(ct(ht.devToolsDockedTo,{PH1:this.dockSideInternal||""}))}}const pt=["right","bottom","left","undocked"];let gt;class bt{static instance(e={forceNew:null}){const{forceNew:t}=e;return gt&&!t||(gt=new bt),gt}item(){return mt.instance().closeButton}}var ft=Object.freeze({__proto__:null,DockController:mt,ToggleDockActionDelegate:class{handleAction(e,t){return mt.instance().toggleDockSide(),!0}},CloseButtonProvider:bt}),vt={cssContent:".infobar{color:var(--sys-color-on-surface);display:flex;flex:auto;flex-direction:column;position:relative;padding:6px;min-width:fit-content}.infobar:focus{outline:2px solid var(--sys-color-state-focus-ring);outline-offset:-2px}.infobar-warning{background-color:var(--sys-color-surface-yellow);color:var(--sys-color-on-surface-yellow)}.infobar-error{--override-infobar-error-background:var(--sys-color-surface-error);--override-infobar-error-text:var(--sys-color-on-surface-error);background-color:var(--override-infobar-error-background);color:var(--override-infobar-error-text)}.infobar-main-row{display:flex;flex-direction:row;justify-content:flex-start;min-height:25px}.infobar-info-container{display:flex;align-items:center;flex-grow:1;flex-wrap:wrap}.infobar-info-message{display:flex;margin:5px 0}.infobar-info-text{display:flex;align-items:center;margin:0 4px}.infobar-details-rows{padding:5px 5px 0}.infobar-details-row{display:flex;flex-direction:column;line-height:18px;padding-bottom:6px}.infobar-close-container{display:flex;flex-shrink:0;align-items:center}.infobar-close-container > .infobar-button.link-style{margin:4px}.infobar-selectable{user-select:text}.infobar-button{color:var(--sys-color-token-subtle);padding:0 4px}.info-icon{mask-image:var(--image-file-info);background-color:var(--icon-info)}.warning-icon{mask-image:var(--image-file-warning);background-color:var(--icon-warning)}.error-icon{mask-image:var(--image-file-cross-circle);background-color:var(--icon-error)}.issue-icon{mask-image:var(--image-file-issue-text-filled);background-color:var(--icon-info)}.icon{mask-size:20px 20px;width:20px;height:20px;flex-shrink:0}.devtools-link.text-button:hover,\n.devtools-link.text-button:focus,\n.devtools-link.text-button:active{background-color:transparent;box-shadow:none}"};const wt={dontShowAgain:"Don't show again",showMore:"Show more",close:"Close"},xt=t.i18n.registerUIStrings("ui/legacy/Infobar.ts",wt),Et=t.i18n.getLocalizedString.bind(void 0,xt);class It{element;shadowRoot;contentElement;mainRow;detailsRows;hasDetails;detailsMessage;infoContainer;infoMessage;infoText;actionContainer;disableSetting;closeContainer;toggleElement;closeButton;closeCallback;#e=null;parentView;constructor(e,t,i,n,s=!0,r){if(this.element=document.createElement("div"),r&&this.element.setAttribute("jslog",`${o.dialog(r).track({resize:!0})}`),this.element.classList.add("flex-none"),this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:vt,delegatesFocus:void 0}),this.contentElement=this.shadowRoot.createChild("div","infobar infobar-"+e),this.mainRow=this.contentElement.createChild("div","infobar-main-row"),this.detailsRows=this.contentElement.createChild("div","infobar-details-rows hidden"),this.hasDetails=!1,this.detailsMessage="",this.infoContainer=this.mainRow.createChild("div","infobar-info-container"),this.infoMessage=this.infoContainer.createChild("div","infobar-info-message"),this.infoMessage.createChild("div",e+"-icon icon"),this.infoText=this.infoMessage.createChild("div","infobar-info-text"),this.infoText.textContent=t,O(this.infoText),this.actionContainer=this.infoContainer.createChild("div","infobar-info-actions"),i){this.contentElement.setAttribute("role","group");for(const e of i){const t=this.actionCallbackFactory(e);let i="infobar-button";e.highlight&&(i+=" primary-button");const n=os(e.text,t,{className:i,jslogContext:e.jslogContext});e.highlight&&!this.#e&&(this.#e=n),this.actionContainer.appendChild(n)}}if(this.disableSetting=n||null,n){const e=os(Et(wt.dontShowAgain),this.onDisable.bind(this),{className:"infobar-button"});this.actionContainer.appendChild(e)}this.closeContainer=this.mainRow.createChild("div","infobar-close-container"),this.toggleElement=os(Et(wt.showMore),this.onToggleDetails.bind(this),{className:"link-style devtools-link hidden",jslogContext:"show-more"}),this.toggleElement.setAttribute("role","link"),this.closeContainer.appendChild(this.toggleElement),this.closeButton=this.closeContainer.createChild("div","close-button","dt-close-button"),this.closeButton.hidden=!s,this.closeButton.setTabbable(!0),fe(this.closeButton,Et(wt.close)),self.onInvokeElement(this.closeButton,this.dispose.bind(this)),"issue"!==e&&(this.contentElement.tabIndex=0),be(this.contentElement,t),this.contentElement.addEventListener("keydown",(e=>e.keyCode===nt.Esc.code?(this.dispose(),void e.consume()):e.target===this.contentElement&&"Enter"===e.key&&this.hasDetails?(this.onToggleDetails(),void e.consume()):void 0)),this.closeCallback=null}static create(e,t,i,n,s){return n&&n.get()?null:new It(e,t,i,n,void 0,s)}dispose(){this.element.remove(),this.onResize(),this.closeCallback&&this.closeCallback.call(null)}setText(e){this.infoText.textContent=e,this.onResize()}setCloseCallback(e){this.closeCallback=e}setParentView(e){this.parentView=e}actionCallbackFactory(e){return e.delegate?e.dismiss?(()=>{e.delegate&&e.delegate(),this.dispose()}).bind(this):e.delegate:e.dismiss?this.dispose.bind(this):()=>{}}onResize(){this.parentView&&this.parentView.doResize()}onDisable(){this.disableSetting&&this.disableSetting.set(!0),this.dispose()}onToggleDetails(){this.detailsRows.classList.remove("hidden"),this.toggleElement.remove(),this.onResize(),Se("string"==typeof this.detailsMessage?this.detailsMessage:this.detailsMessage.textContent||""),this.#e?this.#e.focus():this.closeButton.focus()}createDetailsRowMessage(e){this.hasDetails=!0,this.detailsMessage=e,this.toggleElement.classList.remove("hidden");const t=this.detailsRows.createChild("div","infobar-details-row").createChild("span","infobar-row-message");return"string"==typeof e?t.textContent=e:t.appendChild(e),t}}var yt=Object.freeze({__proto__:null,Infobar:It}),St={cssContent:".tabbed-pane-header-tab{height:26px;margin:0;border:none;border-left:2px solid transparent;border-right:2px solid transparent;&.selected{border-width:0 2px}& > .tabbed-pane-header-tab-icon > devtools-icon{width:14px;height:14px;color:var(--icon-warning)}}.tabbed-pane-header-contents{margin-left:0;min-width:min-content}.tabbed-pane-left-toolbar{margin-right:0!important}"};class Ct extends e.ObjectWrapper.ObjectWrapper{isEnabledInternal;elementsInternal;installDragOnMouseDownBound;cursorInternal;startX;startY;constructor(){super(),this.isEnabledInternal=!0,this.elementsInternal=new Set,this.installDragOnMouseDownBound=this.installDragOnMouseDown.bind(this),this.cursorInternal="nwse-resize"}isEnabled(){return this.isEnabledInternal}setEnabled(e){this.isEnabledInternal=e,this.updateElementCursors()}elements(){return[...this.elementsInternal]}addElement(e){this.elementsInternal.has(e)||(this.elementsInternal.add(e),e.addEventListener("pointerdown",this.installDragOnMouseDownBound,!1),this.updateElementCursor(e))}removeElement(e){this.elementsInternal.has(e)&&(this.elementsInternal.delete(e),e.removeEventListener("pointerdown",this.installDragOnMouseDownBound,!1),e.style.removeProperty("cursor"))}updateElementCursors(){this.elementsInternal.forEach(this.updateElementCursor.bind(this))}updateElementCursor(e){this.isEnabledInternal?(e.style.setProperty("cursor",this.cursor()),e.style.setProperty("touch-action","none")):(e.style.removeProperty("cursor"),e.style.removeProperty("touch-action"))}cursor(){return this.cursorInternal}setCursor(e){this.cursorInternal=e,this.updateElementCursors()}installDragOnMouseDown(e){const t=e.target;if(!this.elementsInternal.has(t))return!1;Rn(t,this.dragStart.bind(this),(e=>{this.drag(e)}),this.dragEnd.bind(this),this.cursor(),e)}dragStart(e){return!!this.isEnabledInternal&&(this.startX=e.pageX,this.startY=e.pageY,this.sendDragStart(this.startX,this.startY),!0)}sendDragStart(e,t){this.dispatchEventToListeners("ResizeStart",{startX:e,currentX:e,startY:t,currentY:t})}drag(e){return this.isEnabledInternal?(this.sendDragMove(this.startX,e.pageX,this.startY,e.pageY,e.shiftKey),e.preventDefault(),!1):(this.dragEnd(e),!0)}sendDragMove(e,t,i,n,s){this.dispatchEventToListeners("ResizeUpdateXY",{startX:e,currentX:t,startY:i,currentY:n,shiftKey:s})}dragEnd(e){this.dispatchEventToListeners("ResizeEnd"),delete this.startX,delete this.startY}}class Tt extends Ct{isVerticalInternal;constructor(){super(),this.isVerticalInternal=!0}isVertical(){return this.isVerticalInternal}setVertical(e){this.isVerticalInternal=e,this.updateElementCursors()}cursor(){return this.isVerticalInternal?"ns-resize":"ew-resize"}sendDragStart(e,t){const i=this.isVerticalInternal?t:e;this.dispatchEventToListeners("ResizeStart",{startPosition:i,currentPosition:i})}sendDragMove(e,t,i,n,s){this.isVerticalInternal?this.dispatchEventToListeners("ResizeUpdatePosition",{startPosition:i,currentPosition:n,shiftKey:s}):this.dispatchEventToListeners("ResizeUpdatePosition",{startPosition:e,currentPosition:t,shiftKey:s})}}var kt=Object.freeze({__proto__:null,ResizerWidget:Ct,SimpleResizerWidget:Tt}),Mt={cssContent:".shadow-split-widget{display:flex;overflow:hidden}.shadow-split-widget-contents{display:flex;position:relative;flex-direction:column;contain:layout size style}.shadow-split-widget-sidebar{flex:none}.shadow-split-widget-main,\n.shadow-split-widget-sidebar.maximized{flex:auto}.shadow-split-widget.hbox > .shadow-split-widget-resizer{position:absolute;top:0;bottom:0;width:6px;z-index:4000}.shadow-split-widget.vbox > .shadow-split-widget-resizer{position:absolute;left:0;right:0;height:6px;z-index:4000}.shadow-split-widget.vbox > .shadow-split-widget-sidebar.no-default-splitter{border:0!important}.shadow-split-widget.vbox > .shadow-split-widget-sidebar:not(.maximized){border:0;border-top:1px solid var(--sys-color-divider)}.shadow-split-widget.hbox > .shadow-split-widget-sidebar:not(.maximized){border:0;border-left:1px solid var(--sys-color-divider)}.shadow-split-widget.vbox > .shadow-split-widget-sidebar:first-child:not(.maximized){border:0;border-bottom:1px solid var(--sys-color-divider)}.shadow-split-widget.hbox > .shadow-split-widget-sidebar:first-child:not(.maximized){border:0;border-right:1px solid var(--sys-color-divider)}:host-context(.disable-resizer-for-elements-hack) .shadow-split-widget-resizer{pointer-events:none}"};class Lt extends HTMLElement{static get observedAttributes(){return["flex","padding","padding-top","padding-bottom","padding-left","padding-right","margin","margin-top","margin-bottom","margin-left","margin-right","overflow","overflow-x","overflow-y","font-size","color","background","background-color","border","border-top","border-bottom","border-left","border-right","max-width","max-height"]}attributeChangedCallback(e,t,i){if("flex"!==e)if(null===i){if(this.style.removeProperty(e),e.startsWith("padding-")||e.startsWith("margin-")||e.startsWith("border-")||e.startsWith("background-")||e.startsWith("overflow-")){const t=e.substring(0,e.indexOf("-")),i=this.getAttribute(t);null!==i&&this.style.setProperty(t,i)}}else this.style.setProperty(e,i);else null===i?this.style.removeProperty("flex"):"initial"===i||"auto"===i||"none"===i||-1!==i.indexOf(" ")?this.style.setProperty("flex",i):this.style.setProperty("flex","0 0 "+i)}}class Pt extends Lt{constructor(e){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction",e),this.style.setProperty("justify-content","flex-start")}static get observedAttributes(){return super.observedAttributes.concat(["x-start","x-center","x-stretch","x-baseline","justify-content"])}attributeChangedCallback(e,t,i){"x-start"!==e&&"x-center"!==e&&"x-stretch"!==e&&"x-baseline"!==e?super.attributeChangedCallback(e,t,i):null===i?this.style.removeProperty("align-items"):this.style.setProperty("align-items","x-start"===e?"flex-start":e.substr(2))}}customElements.define("x-vbox",class extends Pt{constructor(){super("column")}}),customElements.define("x-hbox",class extends Pt{constructor(){super("row")}}),customElements.define("x-cbox",class extends Lt{constructor(){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction","column"),this.style.setProperty("justify-content","center"),this.style.setProperty("align-items","center")}}),customElements.define("x-div",class extends Lt{constructor(){super(),this.style.setProperty("display","block")}}),customElements.define("x-span",class extends Lt{constructor(){super(),this.style.setProperty("display","inline")}}),customElements.define("x-text",class extends Lt{constructor(){super(),this.style.setProperty("display","inline"),this.style.setProperty("white-space","pre")}});var Dt=Object.freeze({__proto__:null,XElement:Lt});let At=null;const Rt=new WeakMap;class Bt extends Lt{visible;shadowRootInternal;defaultFocusedElement;elementsToRestoreScrollPositionsFor;onShownCallback;onHiddenCallback;onResizedCallback;constructor(){super(),this.style.setProperty("display","flex"),this.style.setProperty("flex-direction","column"),this.style.setProperty("align-items","stretch"),this.style.setProperty("justify-content","flex-start"),this.style.setProperty("contain","layout style"),this.visible=!1,this.defaultFocusedElement=null,this.elementsToRestoreScrollPositionsFor=[],At||(At=new ResizeObserver((e=>{for(const t of e){const e=t.target;e.visible&&e.onResizedCallback&&e.onResizedCallback.call(null)}}))),At.observe(this),this.setElementsToRestoreScrollPositionsFor([this])}isShowing(){return this.visible}setOnShown(e){this.onShownCallback=e}setOnHidden(e){this.onHiddenCallback=e}setOnResized(e){this.onResizedCallback=e}setElementsToRestoreScrollPositionsFor(e){for(const e of this.elementsToRestoreScrollPositionsFor)e.removeEventListener("scroll",Bt.storeScrollPosition,{capture:!1});this.elementsToRestoreScrollPositionsFor=e;for(const e of this.elementsToRestoreScrollPositionsFor)e.addEventListener("scroll",Bt.storeScrollPosition,{passive:!0,capture:!1})}restoreScrollPositions(){for(const e of this.elementsToRestoreScrollPositionsFor){const t=Rt.get(e);t&&(e.scrollTop=t.scrollTop,e.scrollLeft=t.scrollLeft)}}static storeScrollPosition(e){const t=e.currentTarget;Rt.set(t,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop})}setDefaultFocusedElement(e){if(e&&!this.isSelfOrAncestor(e))throw new Error("Default focus must be descendant");this.defaultFocusedElement=e}focus(){if(!this.visible)return;let e;if(this.defaultFocusedElement&&this.isSelfOrAncestor(this.defaultFocusedElement))e=this.defaultFocusedElement;else if(-1!==this.tabIndex)e=this;else{let t=this.traverseNextNode(this);for(;t;){if(t instanceof Bt&&t.visible){e=t;break}t=t.traverseNextNode(this)}}e&&!e.hasFocus()&&(e===this?HTMLElement.prototype.focus.call(this):e.focus())}connectedCallback(){this.visible=!0,this.restoreScrollPositions(),this.onShownCallback&&this.onShownCallback.call(null)}disconnectedCallback(){this.visible=!1,this.onHiddenCallback&&this.onHiddenCallback.call(null)}}customElements.define("x-widget",Bt);var Ot=Object.freeze({__proto__:null,XWidget:Bt});class Ft extends HTMLDivElement{__widget;__widgetCounter;constructor(){super()}}function zt(e,t){if(!e)throw new Error(t)}class Wt{element;contentElement;shadowRoot;isWebComponent;visibleInternal;isRoot;isShowingInternal;childrenInternal;hideOnDetach;notificationDepth;invalidationsSuspended;defaultFocusedChild;parentWidgetInternal;registeredCSSFiles;defaultFocusedElement;cachedConstraints;constraintsInternal;invalidationsRequested;externallyManaged;constructor(e,t){this.contentElement=document.createElement("div"),this.contentElement.classList.add("widget"),e?(this.element=document.createElement("div"),this.element.classList.add("vbox"),this.element.classList.add("flex-auto"),this.shadowRoot=d.createShadowRootWithCoreStyles(this.element,{cssFile:void 0,delegatesFocus:t}),this.shadowRoot.appendChild(this.contentElement)):this.element=this.contentElement,this.isWebComponent=e,this.element.__widget=this,this.visibleInternal=!1,this.isRoot=!1,this.isShowingInternal=!1,this.childrenInternal=[],this.hideOnDetach=!1,this.notificationDepth=0,this.invalidationsSuspended=0,this.defaultFocusedChild=null,this.parentWidgetInternal=null,this.registeredCSSFiles=!1}static incrementWidgetCounter(e,t){const i=(t.__widgetCounter||0)+(t.__widget?1:0);if(!i)return;let n=e;for(;n;)n.__widgetCounter=(n.__widgetCounter||0)+i,n=Vt(n)}static decrementWidgetCounter(e,t){const i=(t.__widgetCounter||0)+(t.__widget?1:0);if(!i)return;let n=e;for(;n;)n.__widgetCounter&&(n.__widgetCounter-=i),n=Vt(n)}markAsRoot(){zt(!this.element.parentElement,"Attempt to mark as root attached node"),this.isRoot=!0}parentWidget(){return this.parentWidgetInternal}children(){return this.childrenInternal}childWasDetached(e){}isShowing(){return this.isShowingInternal}shouldHideOnDetach(){if(!this.element.parentElement)return!1;if(this.hideOnDetach)return!0;for(const e of this.childrenInternal)if(e.shouldHideOnDetach())return!0;return!1}setHideOnDetach(){this.hideOnDetach=!0}inNotification(){return Boolean(this.notificationDepth)||Boolean(this.parentWidgetInternal&&this.parentWidgetInternal.inNotification())}parentIsShowing(){return!!this.isRoot||null!==this.parentWidgetInternal&&this.parentWidgetInternal.isShowing()}callOnVisibleChildren(e){const t=this.childrenInternal.slice();for(let i=0;i