var tt=Object.defineProperty;var B=(s,e)=>{for(var t in e)tt(s,t,{get:e[t],enumerable:!0})};var qe={};B(qe,{CustomPreviewComponent:()=>F,CustomPreviewSection:()=>se});import*as q from"./../../../../core/common/common.js";import*as ye from"./../../../../core/i18n/i18n.js";import{createIcon as mt}from"./../../../kit/kit.js";import*as oe from"./../../legacy.js";var Ee=`.custom-expandable-section{display:inline-flex;flex-direction:column}.custom-expand-icon{user-select:none;margin-right:4px;margin-bottom:-4px}.custom-expandable-section-standard-section{display:inline-flex}.custom-expandable-section-default-body{padding-left:12px}
/*# sourceURL=${import.meta.resolve("./customPreviewComponent.css")} */`;var Ke={};B(Ke,{ArrayGroupTreeNode:()=>W,ArrayGroupingTreeElement:()=>$,EXPANDABLE_TEXT_DEFAULT_VIEW:()=>Be,ExpandableTextPropertyValue:()=>A,InitialVisibleChildrenLimit:()=>Ve,OBJECT_PROPERTY_DEFAULT_VIEW:()=>We,ObjectPropertiesSection:()=>P,ObjectPropertiesSectionsTreeOutline:()=>J,ObjectPropertyTreeElement:()=>k,ObjectPropertyWidget:()=>re,ObjectTree:()=>D,ObjectTreeExpansionTracker:()=>fe,ObjectTreeNode:()=>w,ObjectTreeNodeBase:()=>U,Renderer:()=>be,RootElement:()=>ie,getObjectPropertiesSectionFrom:()=>dt,isWasmObject:()=>He,objectPropertiesSectionStyles:()=>Q,objectValueStyles:()=>T,sortPropertiesAlphabeticallySetting:()=>ue});import*as L from"./../../../../core/common/common.js";import*as O from"./../../../../core/host/host.js";import*as N from"./../../../../core/i18n/i18n.js";import*as I from"./../../../../core/platform/platform.js";import*as j from"./../../../../core/sdk/sdk.js";import*as Ae from"./../../../../models/text_utils/text_utils.js";import*as Ue from"./../../../i18n/i18n.js";import*as G from"./../../../components/highlighting/highlighting.js";import*as De from"./../../../components/text_editor/text_editor.js";import{Directives as lt,html as x,nothing as ee,render as V}from"./../../../lit/lit.js";import*as te from"./../../../visual_logging/visual_logging.js";import*as v from"./../../legacy.js";var Me={};B(Me,{JavaScriptREPL:()=>K});import*as ke from"./../../../../core/sdk/sdk.js";import*as Ie from"./../../../../models/formatter/formatter.js";import*as Te from"./../../../../models/source_map_scopes/source_map_scopes.js";import*as Le from"./../../../../third_party/acorn/acorn.js";import*as $e from"./../../legacy.js";var Oe={};B(Oe,{RemoteObjectPreviewFormatter:()=>R,renderNodeTitle:()=>_,renderTrustedType:()=>Se});import*as ce from"./../../../../core/i18n/i18n.js";import*as z from"./../../../../core/platform/platform.js";import*as X from"./../../../../core/sdk/sdk.js";import{Directives as nt,html as S,nothing as M,render as it}from"./../../../lit/lit.js";var{ifDefined:rt,repeat:st}=nt,Y={emptyD:"empty \xD7 {PH1}",empty:"empty",thePropertyIsComputedWithAGetter:"The property is computed with a getter"},ot=ce.i18n.registerUIStrings("ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts",Y),le=ce.i18n.getLocalizedString.bind(void 0,ot),R=class s{static objectPropertyComparator(e,t){return n(e)-n(t);function n(i){return i.name==="[[PromiseState]]"?1:i.name==="[[PromiseResult]]"?2:i.name==="[[GeneratorState]]"||i.name==="[[PrimitiveValue]]"||i.name==="[[WeakRefTarget]]"?3:i.type!=="function"&&!i.name.startsWith("#")?4:5}}renderObjectPreview(e,t=!0){let n=e.description,i=new Set(["arraybuffer","dataview","error","null","regexp","webassemblymemory","internal#entry","trustedtype"]);if(e.type!=="object"||e.subtype&&i.has(e.subtype))return this.renderPropertyPreview(e.type,e.subtype,void 0,n);let r=e.subtype==="array"||e.subtype==="typedarray",o="";if(n)if(r){let a=X.RemoteObject.RemoteObject.arrayLength(e),m=a>1?"("+a+")":"",f=X.RemoteObject.RemoteObject.arrayNameFromDescription(n);o=f==="Array"?m:f+m}else o=n==="Object"?"":n;let c=Array.from(e.entries?this.renderEntries(e):r?this.renderArrayProperties(e):this.renderObjectProperties(e,t)),p=a=>S`<span class=name>${/^\s|\s$|^$|\n/.test(a)?'"'+a.replace(/\n/g,"\u21B5")+'"':a}</span>`,h=a=>S`<span class=object-value-undefined>${a}</span>`,u=a=>this.renderPropertyPreview(a.type,a.subtype,a.name,a.value),l=a=>S`${a.key&&S`${this.renderPropertyPreview(a.key.type,a.key.subtype,void 0,a.key.description)} => `}
          ${this.renderPropertyPreview(a.value.type,a.value.subtype,void 0,a.value.description)}`,d=({name:a,entry:m,value:f,placeholder:b},C)=>S`${C>0?", ":""}${b!==void 0?h(b):M}${a!==void 0?p(a):M}${a!==void 0&&f?": ":""}${f?u(f):M}${m?l(m):M}`;return S`${o.length>0?S`<span class=object-description>${o+"\xA0"}</span>`:M}<span class=object-properties-preview>${r?"[":"{"}${st(c,d)}${e.overflow?S`<span>${c.length>0?",\xA0\u2026":"\u2026"}</span>`:""}
    ${r?"]":"}"}</span>`}*renderObjectProperties(e,t){let n=e.properties.filter(i=>i.type!=="accessor").sort(s.objectPropertyComparator);for(let i=0;i<n.length;++i){let r=n[i],o=r.name;if(!(!t&&(r.type==="undefined"||r.type==="object"&&r.subtype==="null")))if(e.subtype==="promise"&&o==="[[PromiseState]]"){let c=n.at(i+1)?.name==="[[PromiseResult]]"?n.at(i+1):void 0;c&&i++,yield{name:"<"+r.value+">",value:r.value!=="pending"?c:void 0}}else e.subtype==="generator"&&o==="[[GeneratorState]]"?yield{name:"<"+r.value+">"}:o==="[[PrimitiveValue]]"?yield{value:r}:o==="[[WeakRefTarget]]"?r.type==="undefined"?yield{name:"<cleared>"}:yield{value:r}:yield{name:o,value:r}}}*renderArrayProperties(e){let t=X.RemoteObject.RemoteObject.arrayLength(e),n=e.properties.filter(l=>o(l.name)!==-1).sort(r),i=e.properties.filter(l=>o(l.name)===-1).sort(s.objectPropertyComparator);function r(l,d){return o(l.name)-o(d.name)}function o(l){let d=Number(l)>>>0;return String(d)===l&&d<t?d:-1}let c=!e.overflow,p=[];for(let l of n){let d=o(l.name),a=d-(p.at(-1)?.index??-1)-1,m=d!==p.length;p.push({property:l,index:d,gap:a,hasGaps:m})}let h=t-(p.at(-1)?.index??-1)-1,u=l=>({placeholder:l!==1?le(Y.emptyD,{PH1:l}):le(Y.empty)});for(let{property:l,gap:d,hasGaps:a}of p)c&&d>0&&(yield u(d)),yield{name:!c&&a?l.name:void 0,value:l};c&&h>0&&(yield u(h));for(let l of i)yield{name:l.name,value:l}}*renderEntries(e){for(let t of e.entries??[])yield{entry:t}}renderPropertyPreview(e,t,n,i){let r;switch(e){case"accessor":r=le(Y.thePropertyIsComputedWithAGetter);break;case"string":r=i;break;case"object":t||(r=i);break}let o=p=>{let h=p.split(".");for(let u=0;u<h.length-1;++u)h[u]=z.StringUtilities.trimMiddle(h[u],3);return h.length===1&&h[0]==="Object"?"{\u2026}":h.join(".")},c=()=>e==="accessor"?"(...)":e==="function"?"\u0192":e==="object"&&t==="trustedtype"&&n?Se(i??"",n):e==="object"&&t==="node"&&i?_(i):e==="string"?z.StringUtilities.formatAsJSLiteral(i??""):e==="object"&&!t?o(i??""):i;return S`<span class='object-value-${t||e}' title=${rt(r)}>${c()}</span>`}renderEvaluationResultPreview(e,t){if("error"in e)return M;if(e.exceptionDetails?.exception?.description){let p=e.exceptionDetails.exception.description;return p.startsWith("TypeError: ")||t?S`<span>${e.exceptionDetails.text} ${p}</span>`:M}let{preview:n,type:i,subtype:r,className:o,description:c}=e.object;return n&&i==="object"&&r!=="node"&&r!=="trustedtype"?this.renderObjectPreview(n):this.renderPropertyPreview(i,r,o,z.StringUtilities.trimEndWithMaxLength(c||"",400))}renderEvaluationResultPreviewFragment(e,t){let n=document.createDocumentFragment();return it(this.renderEvaluationResultPreview(e,t),n),n}};function _(s){let e=s.match(/([^#.]+)(#[^.]+)?(\..*)?/);return e?S`<span class=webkit-html-tag-name>${e[1]}</span>${e[2]&&S`<span class=webkit-html-attribute-value>${e[2]}</span>`}${e[3]&&S`<span class=webkit-html-attribute-name>${e[3]}</span>`}`:null}function Se(s,e){return S`${e} <span class=object-value-string title=${s}>"${s.replace(/\n/g,"\u21B5")}"</span>`}var K=class s{static wrapObjectLiteral(e){let t=/^\s*\{\s*(.*)\s*\}[\s;]*$/.exec(e);if(t===null)return e;let[,n]=t,i=0;for(let o of n)if(o==="{")i++;else if(o==="}"&&--i<0)return e;let r=o=>{Le.parse(o,{ecmaVersion:2022,allowAwaitOutsideFunction:!0,ranges:!1,allowReturnOutsideFunction:!0})};try{r("return {"+n+"};");let o="({"+n+"})";return r(o),o}catch{return e}}static async evaluate(e,t,n,i,r,o,c=!1,p=!1){let h=e.length>at;if(!e||n&&h)return null;let u=e,l=t.debuggerModel.selectedCallFrame();if(l?.script.isJavaScript()){let a=await Te.NamesResolver.allVariablesInCallFrame(l);try{u=await Ie.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(u,a)}catch{}}u=s.wrapObjectLiteral(u);let d={expression:u,generatePreview:!0,includeCommandLineAPI:!0,throwOnSideEffect:n,timeout:r,objectGroup:o,disableBreaks:!0,replMode:i,silent:p};return await t.evaluate(d,!1,c)}static async evaluateAndBuildPreview(e,t,n,i,r,o,c=!1,p=!1){let h=$e.Context.Context.instance().flavor(ke.RuntimeModel.ExecutionContext);if(!h)return{preview:document.createDocumentFragment(),result:null};let u=await s.evaluate(e,h,t,n,i,o,c,p);return u?{preview:new R().renderEvaluationResultPreviewFragment(u,r),result:u}:{preview:document.createDocumentFragment(),result:null}}},at=2e3;var Q=`.object-properties-section-dimmed{opacity:60%}.object-properties-section{padding:0;color:var(--sys-color-on-surface);display:flex;flex-direction:column;overflow-x:auto}.object-properties-section li,
li.object-properties-section{user-select:text;&::before{flex-shrink:0;margin-right:2px;align-self:flex-start}}.object-properties-section li.editing-sub-part{padding:3px 12px 8px 6px;margin:-1px -6px -8px;text-overflow:clip}.object-properties-section li.editing{margin-left:10px;text-overflow:clip}.tree-outline ol.title-less-mode{padding-left:0}.object-properties-section .own-property{font-weight:bold}.object-properties-section .synthetic-property{color:var(--sys-color-token-subtle)}.object-properties-section .private-property-hash{color:var(--sys-color-on-surface)}.object-properties-section-root-element{display:flex;flex-direction:row}.object-properties-section .editable-div{overflow:hidden}.name-and-value{line-height:16px;display:flex;white-space:nowrap}.name-and-value .separator{white-space:pre;flex-shrink:0}.editing-sub-part .name-and-value{overflow:visible;display:inline-flex}.property-prompt{margin-left:4px}.tree-outline.hide-selection-when-blurred .selected:focus-visible{background:none}.tree-outline.hide-selection-when-blurred .selected:focus-visible ::slotted(*),
.tree-outline.hide-selection-when-blurred .selected:focus-visible .tree-element-title,
.tree-outline.hide-selection-when-blurred .selected:focus-visible .name-and-value,
.tree-outline.hide-selection-when-blurred .selected:focus-visible .gray-info-message{background:var(--sys-color-state-focus-highlight);border-radius:2px}@media (forced-colors: active){.object-properties-section-dimmed{opacity:100%}.tree-outline.hide-selection-when-blurred .selected:focus-visible{background:Highlight}.tree-outline li:hover .tree-element-title,
  .tree-outline li.selected .tree-element-title{color:ButtonText}.tree-outline.hide-selection-when-blurred .selected:focus-visible .tree-element-title,
  .tree-outline.hide-selection-when-blurred .selected:focus-visible .name-and-value{background:transparent;box-shadow:none}.tree-outline.hide-selection-when-blurred .selected:focus-visible span,
  .tree-outline.hide-selection-when-blurred .selected:focus-visible .gray-info-message{color:HighlightText}.tree-outline-disclosure:hover li.parent::before{background-color:ButtonText}}
/*# sourceURL=${import.meta.resolve("./objectPropertiesSection.css")} */`;var T=`.value.object-value-node:hover{background-color:var(--sys-color-state-hover-on-subtle)}.object-value-function-prefix,
.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,
: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,
.object-value-regexp,
.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,
.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,
:host-context(.theme-with-dark-background) .object-value-number,
.theme-with-dark-background .object-value-boolean,
: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}}
/*# sourceURL=${import.meta.resolve("./objectValue.css")} */`;var{widget:pe}=v.Widget,{ref:Re,repeat:ct,ifDefined:ne,classMap:pt}=lt,g={exceptionS:"[Exception: {PH1}]",unknown:"unknown",expandRecursively:"Expand recursively",collapseChildren:"Collapse children",sortPropertiesAlphabetically:"Sort properties alphabetically",noProperties:"No properties",dots:"(...)",invokePropertyGetter:"Invoke property getter",showAllD:"Show all {PH1}",valueUnavailable:"<value unavailable>",valueNotAccessibleToTheDebugger:"Value is not accessible to the debugger",copyValue:"Copy value",copyPropertyPath:"Copy property path",stringIsTooLargeToEdit:"<string is too large to edit>",showMoreS:"Show more ({PH1})",longTextWasTruncatedS:"long text was truncated ({PH1})",copy:"Copy",openInMemoryInpector:"Open in Memory inspector panel"},Ne=N.i18n.registerUIStrings("ui/legacy/components/object_ui/ObjectPropertiesSection.ts",g),y=N.i18n.getLocalizedString.bind(void 0,Ne),ge=100,Fe=new WeakMap,de;function ue(){return de||(de=L.Settings.Settings.instance().createSetting("object-properties-sort-alphabetically",!0)),de}function He(s){return s?.subtype==="webassemblymemory"||s?.subtype==="wasmvalue"}var me=class s{properties=new Map;internalProperties=new Map;arrayRanges=new Map;accessors=new Map;remove(e){return this[e.type].delete(s.#e(e))}get(e){return this[e.type].get(s.#e(e))}getOrInsert(e){let t=this[e.type],n=s.#e(e),i=t.get(n)??new s;return t.has(n)||t.set(n,i),i}clear(e){this[e].clear()}clearMissing(e,t){let n=new Set(t.map(s.#e)),i=this[e];for(let r of i.keys())n.has(r)||i.delete(r)}get empty(){return this.properties.size===0&&this.internalProperties.size===0&&this.arrayRanges.size===0&&this.accessors.size===0}static#e(e){return typeof e.key=="string"?`${e.type}:${e.key}`:`${e.type}:${e.key.fromIndex}-${e.key.toIndex}`}},fe=class s{#e=null;static#t(e){if(e instanceof w)return e.parent?.children?.internalProperties?.find(t=>t.name==="[[Prototype]]"&&t.children?.properties?.includes(e))}static#n(e){if(e instanceof w){if(e.parent?.children?.properties?.includes(e))return"properties";if(e.parent?.children?.internalProperties?.includes(e))return"internalProperties";if(e.parent?.children?.accessors?.includes(e))return"accessors";if(s.#t(e))return"properties"}return e instanceof W&&e.parent?.children?.arrayRanges?.includes(e)?"arrayRanges":null}static#i(e,t){return e==="arrayRanges"?t instanceof W?{type:e,key:t.range}:null:t instanceof w?{type:e,key:t.name}:null}clear(){this.#e=null}async#s(e,t){let n=async i=>{let r=t.children?.[i];if(!r){e.clear(i);return}let o=[];for(let c of r){let p=s.#i(i,c);if(!p)continue;let h=e.get(p);h&&(await this.#s(h,c),o.push(p))}e.clearMissing(i,o)};t.expanded=!0,await t.populateChildrenIfNeeded(),await n("properties"),await n("internalProperties"),await n("arrayRanges"),await n("accessors")}async apply(e){if(this.#e)return await this.#s(this.#e,e)}static*#r(e){if(!e)return;let t=s.#t(e);t?yield*this.#r(t):yield*this.#r(e.parent);let n=this.#n(e),i=n&&s.#i(n,e);i&&(yield i)}collapse(e){if(!this.#e)return;if(e instanceof D){this.#e=null;return}let t,n=null,i=this.#e;for(let r of s.#r(e)){t=r,n=i;let o=i.get(r);if(!o)return;i=o}t&&n&&n.remove(t)}expand(e){this.#e||(this.#e=new me);let t=this.#e;for(let n of s.#r(e))t=t.getOrInsert(n)}},U=class s extends L.ObjectWrapper.ObjectWrapper{parent;#e;options;filter=null;extraProperties=[];#t=!1;constructor(e,t){super(),this.parent=e,this.filter=e?.filter??null,this.options={...t}}get isWasm(){return He(this.object)}get expanded(){return this.#t}set expanded(e){e?this.options.expansionTracker?.expand(this):this.options.expansionTracker?.collapse(this),this.#t=e}get readOnly(){return this.options.readOnly}get propertiesMode(){return this.options.propertiesMode}get includeNullOrUndefinedValues(){return this.filter?.includeNullOrUndefinedValues??!0}set includeNullOrUndefinedValues(e){this.setFilter({includeNullOrUndefinedValues:e,regex:this.filter?.regex??null})}get sortPropertiesAlphabetically(){return this.isWasm?!1:ue().get()}set sortPropertiesAlphabetically(e){let t=ue();this.isWasm||t.get()===e||(t.set(e),this.removeChildren())}*#n(e=-1){function*t(n){if(n)for(let i of n)yield*i.#n(Math.max(-1,e-1))}yield this,e!==0&&(yield*t(this.#e?.properties),yield*t(this.#e?.arrayRanges),yield*t(this.#e?.internalProperties))}async expandRecursively(e){for(let t of this.#n(e))await t.populateChildrenIfNeeded(),t.expanded=!0}collapseRecursively(){for(let e of this.#n())e.expanded=!1}setFilter(e){this.filter=e,this.dispatchEventToListeners("filter-changed"),this.#n().forEach(t=>{t.filter=e,t.dispatchEventToListeners("filter-changed")})}removeChildren(){this.#e=void 0,this.dispatchEventToListeners("children-changed")}removeChild(e){t(this.#e?.arrayRanges,e),t(this.#e?.internalProperties,e),t(this.#e?.properties,e),this.dispatchEventToListeners("children-changed");function t(n,i){if(!n)return;let r=n.indexOf(i);r>=0&&n.splice(r,1)}}selfOrParentIfInternal(){return this}get children(){return this.#e}#i;async populateChildrenIfNeeded(){return this.#e?this.#e:(this.#i||(this.#i=this.populateChildrenIfNeededImpl().then(e=>(this.#e=e,e)).finally(()=>{this.#i=void 0})),await this.#i)}async populateChildrenIfNeededImpl(){let e=this.object;if(!e)return{};let t=this.selfOrParentIfInternal();if(this.arrayLength>ht){let h=(await Ge(e,0,this.arrayLength-1))?.ranges.map(([m,f,b])=>new W(e,{fromIndex:m,toIndex:f,count:b},t,{readOnly:this.readOnly,propertiesMode:this.propertiesMode,expansionTracker:this.options.expansionTracker}));if(!h)return{};let{properties:u,internalProperties:l}=await j.RemoteObject.RemoteObject.loadFromObjectPerProto(this.object,!0,!0),d=u?.map(m=>new w(m,t,{readOnly:this.readOnly,propertiesMode:1,expansionTracker:this.options.expansionTracker})),a=l?.map(m=>new w(m,t,{readOnly:this.readOnly,propertiesMode:1,expansionTracker:this.options.expansionTracker}));return{arrayRanges:h,properties:d,internalProperties:a}}let n=null,i=null;switch(this.propertiesMode){case 0:({properties:n}=await e.getAllProperties(!1,!0));break;case 1:({properties:n,internalProperties:i}=await j.RemoteObject.RemoteObject.loadFromObjectPerProto(e,!0));break}let r=n?.map(p=>new w(p,t,{readOnly:this.readOnly,propertiesMode:1,expansionTracker:this.options.expansionTracker}));r?.push(...this.extraProperties),r?.sort((p,h)=>P.compareProperties(p,h,this.sortPropertiesAlphabetically));let o=r&&s.getGettersAndSetters(r,this.options),c=i?.map(p=>new w(p,t,{readOnly:this.readOnly,propertiesMode:1,expansionTracker:this.options.expansionTracker}));return{properties:r,internalProperties:c,accessors:o}}get hasChildren(){return this.object?.hasChildren??!1}get arrayLength(){return this.object?.arrayLength()??0}async setPropertyValue(e,t){return await this.object?.setPropertyValue(e,t)}addExtraProperties(...e){this.extraProperties.push(...e.map(t=>new w(t,this,{readOnly:this.readOnly,propertiesMode:1,expansionTracker:this.options.expansionTracker})))}static getGettersAndSetters(e,t){let n=[];for(let i of e)if(i.property.isOwn){if(i.property.getter){let r=new j.RemoteObject.RemoteObjectProperty("get "+i.property.name,i.property.getter,!1);n.push(new w(r,i.parent,{propertiesMode:i.propertiesMode,readOnly:i.readOnly,expansionTracker:t.expansionTracker}))}if(i.property.setter){let r=new j.RemoteObject.RemoteObjectProperty("set "+i.property.name,i.property.setter,!1);n.push(new w(r,i.parent,{propertiesMode:i.propertiesMode,readOnly:i.readOnly,expansionTracker:t.expansionTracker}))}}return n}},D=class extends U{#e;constructor(e,t){super(void 0,t),this.#e=e}get object(){return this.#e}},W=class s extends U{#e;#t;constructor(e,t,n,i){super(n,i),this.#e=e,this.#t=t}async populateChildrenIfNeededImpl(){if(this.#t.count>$.bucketThreshold)return{arrayRanges:(await Ge(this.object,this.#t.fromIndex,this.#t.toIndex))?.ranges.map(([p,h,u])=>new s(this.object,{fromIndex:p,toIndex:h,count:u},this,{readOnly:this.readOnly,propertiesMode:this.propertiesMode,expansionTracker:this.options.expansionTracker}))};let e=await this.#e.callFunction(ut,[{value:this.#t.fromIndex},{value:this.#t.toIndex},{value:$.sparseIterationThreshold}]);if(!e.object||e.wasThrown)return{};let t=e.object,n=await t.getAllProperties(!1,!0);t.release();let i=n.properties?.map(o=>new w(o,this,{propertiesMode:this.propertiesMode,readOnly:this.readOnly,expansionTracker:this.options.expansionTracker}));i?.push(...this.extraProperties),i?.sort((o,c)=>P.compareProperties(o,c,this.sortPropertiesAlphabetically));let r=i&&U.getGettersAndSetters(i,this.options);return{properties:i,accessors:r}}get singular(){return this.#t.fromIndex===this.#t.toIndex}get range(){return this.#t}get object(){return this.#e}},w=class s extends U{property;nonSyntheticParent;#e;constructor(e,t,n,i){super(t,n),this.property=e,this.nonSyntheticParent=i}get object(){return this.property.value}get isFiltered(){return!!(this.filter&&!this.property.match(this.filter))}get name(){return this.property.name}get path(){if(!this.#e){if(this.property.synthetic)return this.#e=this.name,this.name;let e=/^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u,t=/^(?:0|[1-9]\d*)$/,n=this.parent instanceof s&&!this.parent.property.synthetic?this.parent.path:"";this.property.private||e.test(this.name)?this.#e=n?`${n}.${this.name}`:this.name:t.test(this.name)?this.#e=`${n}[${this.name}]`:this.#e=`${n}[${JSON.stringify(this.name)}]`}return this.#e}selfOrParentIfInternal(){return this.name==="[[Prototype]]"?this.parent??this:this}async setValue(e){let t=j.RemoteObject.RemoteObject.toCallArgument(this.property.symbol||this.name);if(e=K.wrapObjectLiteral(e.trim()),this.property.synthetic){let o=!1;e&&(o=await this.property.setSyntheticValue(e)),o?this.parent?.removeChildren():this.dispatchEventToListeners("value-changed");return}let n=this.parent?.object;if(await(e?n.setPropertyValue(t,e):n.deleteProperty(t))){this.dispatchEventToListeners("value-changed");return}e?this.parent?.removeChildren():this.parent?.removeChild(this)}async invokeGetter(e){let n=await this.parent?.object?.callFunction(`
          function invokeGetter(getter) {
            return Reflect.apply(getter, this, []);
          }`,[j.RemoteObject.RemoteObject.toCallArgument(e)]);n?.object&&(this.property.value=n.object,this.property.wasThrown=n.wasThrown||!1,this.dispatchEventToListeners("value-changed"))}},dt=s=>Fe.get(s),P=class s extends v.TreeOutline.TreeOutlineInShadow{root;#e;titleElement;skipProtoInternal;constructor(e,t,n,i,r=!0){super(),this.root=new D(e,{readOnly:!r,propertiesMode:1}),i||this.setHideOverflow(!0),this.setFocusable(!0),this.setShowSelectionOnKeyboardFocus(!0),this.#e=new ie(this.root,n),this.appendChild(this.#e),typeof t=="string"||!t?(this.titleElement=this.element.createChild("span"),this.titleElement.textContent=t||""):(this.titleElement=t,this.element.appendChild(t)),this.titleElement instanceof HTMLElement&&!this.titleElement.hasAttribute("tabIndex")&&(this.titleElement.tabIndex=-1),Fe.set(this.element,this),this.registerRequiredCSS(T,Q),this.rootElement().childrenListElement.classList.add("source-code","object-properties-section")}static defaultObjectPresentation(e,t,n,i){let r=s.defaultObjectPropertiesSection(e,t,n,i);return e.hasChildren?r.element:r.titleElement}static defaultObjectPropertiesSection(e,t,n,i){let r=document.createElement("span");r.classList.add("source-code");let o=v.UIUtils.createShadowRootWithCoreStyles(r,{cssFile:T}),c=s.createPropertyValue(e,!1,!0);o.appendChild(c);let p=new s(e,r,t,void 0,!i);return n&&p.skipProto(),p}static compareProperties(e,t,n=!0){if(e instanceof w&&(e=e.property),t instanceof w&&(t=t.property),!e.synthetic&&t.synthetic)return 1;if(!t.synthetic&&e.synthetic)return-1;if(!e.isOwn&&t.isOwn)return 1;if(!t.isOwn&&e.isOwn)return-1;if(!e.enumerable&&t.enumerable)return 1;if(!t.enumerable&&e.enumerable)return-1;if(e.symbol&&!t.symbol)return 1;if(t.symbol&&!e.symbol)return-1;if(e.private&&!t.private)return 1;if(t.private&&!e.private)return-1;if(n){let i=e.name,r=t.name;return i.startsWith("_")&&!r.startsWith("_")?1:r.startsWith("_")&&!i.startsWith("_")?-1:I.StringUtilities.naturalOrderComparator(i,r)}return 0}static createNameElement(e,t){let n=document.createElement("span");if(n.classList.add("name"),e===null)return n;if(/^\s|\s$|^$|\n/.test(e))return n.textContent=`"${e.replace(/\n/g,"\u21B5")}"`,n;if(t){let i=document.createElement("span");return i.classList.add("private-property-hash"),i.textContent=e[0],n.appendChild(i),n.appendChild(document.createTextNode(e.substring(1))),n}return n.textContent=e,n}static valueElementForFunctionDescription(e,t,n,i){let r=(l,d)=>{let a=l.replace(/^function [gs]et /,"function ").replace(/^function [gs]et\(/,"function(").replace(/^[gs]et /,""),m=a.match(/^(async\s+function)/),f=a.startsWith("function*"),b=a.startsWith("*"),C=!f&&a.startsWith("function"),je=a.startsWith("class ")||a.startsWith("class{"),Pe=a.indexOf("=>"),et=!m&&!f&&!C&&!je&&Pe>0;if(je){let E=a.substring(5),H=/^[^{\s]+/.exec(E.trim()),Ce=d;return H&&(Ce=H[0].trim()||d),{prefix:"class",body:E,abbreviation:Ce}}if(m){let E=a.substring(m[1].length);return{prefix:"async \u0192",body:E,abbreviation:u(E)}}if(f){let E=a.substring(9);return{prefix:"\u0192*",body:E,abbreviation:u(E)}}if(b){let E=a.substring(1);return{prefix:"\u0192*",body:E,abbreviation:u(E)}}if(C){let E=a.substring(8);return{prefix:"\u0192",body:E,abbreviation:u(E)}}if(et){let H=a;return d?H=d+"()":a.length>60&&(H=a.substring(0,Pe+2)+" {\u2026}"),{prefix:"",body:a,abbreviation:H}}return{prefix:"\u0192",body:a,abbreviation:u(a)}},{prefix:o,body:c,abbreviation:p}=r(e??"",n??"");return x`<span
      class="object-value-function ${i??""}"
      title=${I.StringUtilities.trimEndWithMaxLength(e??"",500)}>${o&&x`<span class=object-value-function-prefix>${o} </span>`}${t?I.StringUtilities.trimEndWithMaxLength(c.trim(),200):p.replace(/\n/g," ")}</span>`;function u(l){let d=l.indexOf("("),a=l.match(/\)\s*{/);if(d!==-1&&a?.index!==void 0&&a.index>d){let m=l.substring(0,d).trim()||(n??""),f=l.substring(d,a.index+1);return m+f}return n+"()"}}static createPropertyValueWithCustomSupport(e,t,n,i,r,o,c){if(e.customPreview()){let p=new F(e).element;return p.classList.add("object-properties-section-custom-section"),p}return s.createPropertyValue(e,t,n,i,r,o,c)}static getMemoryIcon(e,t){return e.isLinearMemoryInspectable()?x`<devtools-icon
      name=memory
      style="width: var(--sys-size-8); height: 13px; vertical-align: sub; cursor: pointer;"
      @click=${n=>{n.consume(),L.Revealer.reveal(new j.RemoteObject.LinearMemoryInspectable(e,t))}}
      jslog=${te.action("open-memory-inspector").track({click:!0})}
      title=${y(g.openInMemoryInpector)}
      aria-label=${y(g.openInMemoryInpector)}></devtools-icon>`:ee}static appendMemoryIcon(e,t,n){let i=document.createDocumentFragment();V(s.getMemoryIcon(t,n),i),e.appendChild(i)}static createPropertyValue(e,t,n,i,r=!1,o,c){let p=document.createDocumentFragment(),h=e.type,u=e.subtype,l=e.description||"",d=e.className,a=()=>{if(h==="object"&&u==="internal#location"){let b=e.debuggerModel().createRawLocationByScriptId(e.value.scriptId,e.value.lineNumber,e.value.columnNumber);return b&&i?x`${i.linkifyRawLocation(b,I.DevToolsPath.EmptyUrlString,"value")}`:x`<span class=value title=${l}>${"<"+y(g.unknown)+">"}</span>`}if(h==="string"&&typeof l=="string"){let b=JSON.stringify(l),C=l.length>Z;return x`<span class="value object-value-string" title=${ne(C?void 0:l)}>${C?pe(A,{text:b}):b}</span>`}if(h==="object"&&u==="trustedtype"){let b=`${d} '${l}'`,C=b.length>Z;return x`<span class="value object-value-trustedtype" title=${ne(C?void 0:b)}>${C?pe(A,{text:b}):x`${d} <span class=object-value-string title=${l}>${JSON.stringify(l)}</span>`}</span>`}if(h==="function")return s.valueElementForFunctionDescription(l,void 0,void 0,"value");if(h==="object"&&u==="node"&&l)return x`<span class="value object-value-node"
            @click=${b=>{L.Revealer.reveal(e),b.consume(!0)}}
            @mousemove=${()=>j.OverlayModel.OverlayModel.highlightObjectAsDOMNode(e)}
            @mouseleave=${()=>j.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
          >${_(l)}</span>`;if(l.length>Z)return x`<span class="value object-value-${u||h}" title=${l}>
          ${pe(A,{text:l})}
        </span>`;let f=e.preview&&n;return x`<span class="value object-value-${u||h}" title=${l}>${f?new R().renderObjectPreview(e.preview,c):l}${r?ee:this.getMemoryIcon(e,o)}</span>`};t?V(x`<span class="error value">${Ue.getFormatLocalizedStringTemplate(Ne,g.exceptionS,{PH1:a()})}</span>`,p):V(a(),p);let m=p.firstElementChild;if(!(m instanceof HTMLElement))throw new Error("Expected an HTML element");return m}static formatObjectAsFunction(e,t,n,i){return e.debuggerModel().functionDetailsPromise(e).then(r);function r(o){n&&o?.location&&(t.classList.add("linkified"),t.addEventListener("click",()=>(L.Revealer.reveal(o.location),!1)));let c=i?"":"anonymous";o?.functionName&&(c=o.functionName);let p=document.createDocumentFragment();V(s.valueElementForFunctionDescription(e.description,i,c),p),t.appendChild(p)}}static isDisplayableProperty(e,t){if(!t?.synthetic)return!0;let n=e.name;return!(t.name==="[[Entries]]"&&(n==="length"||n==="__proto__"))}skipProto(){this.skipProtoInternal=!0}expand(){this.#e.expand()}objectTreeElement(){return this.#e}enableContextMenu(){this.element.addEventListener("contextmenu",this.contextMenuEventFired.bind(this),!1)}contextMenuEventFired(e){let t=new v.ContextMenu.ContextMenu(e);t.appendApplicableItems(this.root),this.root.object instanceof j.RemoteObject.LocalJSONObject&&(t.viewSection().appendItem(y(g.expandRecursively),this.#e.expandRecursively.bind(this.#e,ge),{jslogContext:"expand-recursively"}),t.viewSection().appendItem(y(g.collapseChildren),this.#e.collapseChildren.bind(this.#e),{jslogContext:"collapse-children"})),t.show()}titleLessMode(){this.#e.listItemElement.classList.add("hidden"),this.#e.childrenListElement.classList.add("title-less-mode"),this.#e.expand()}},ht=100,Z=1e4,J=class extends v.TreeOutline.TreeOutlineInShadow{constructor(){super(),this.registerRequiredCSS(T,Q),this.contentElement.classList.add("source-code"),this.contentElement.classList.add("object-properties-section")}},ie=class extends v.TreeOutline.TreeElement{object;linkifier;emptyPlaceholder;toggleOnClick;constructor(e,t,n){let i=document.createElement("slot");super(i),this.object=e,this.object.addEventListener("children-changed",this.onpopulate,this),this.linkifier=t,this.emptyPlaceholder=n,this.setExpandable(!0),this.selectable=!0,this.toggleOnClick=!0,this.listItemElement.classList.add("object-properties-section-root-element"),this.listItemElement.addEventListener("contextmenu",this.onContextMenu.bind(this),!1),e.expanded&&this.expand()}onexpand(){this.object.expanded=!0,this.treeOutline&&this.treeOutline.element.classList.add("expanded")}oncollapse(){this.object.expanded=!1,this.treeOutline&&this.treeOutline.element.classList.remove("expanded")}ondblclick(e){return!0}onContextMenu(e){let t=new v.ContextMenu.ContextMenu(e);if(t.appendApplicableItems(this.object.object),this.object instanceof j.RemoteObject.LocalJSONObject){let{value:n}=this.object,i=typeof n=="object"?JSON.stringify(n,null,2):n,r=()=>{O.userMetrics.actionTaken(O.UserMetrics.Action.NetworkPanelCopyValue),O.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(i)};t.clipboardSection().appendItem(y(g.copyValue),r,{jslogContext:"copy-value"})}t.viewSection().appendItem(y(g.expandRecursively),this.expandRecursively.bind(this,ge),{jslogContext:"expand-recursively"}),t.viewSection().appendItem(y(g.collapseChildren),this.collapseChildren.bind(this),{jslogContext:"collapse-children"}),this.object.isWasm||t.viewSection().appendCheckboxItem(y(g.sortPropertiesAlphabetically),()=>{this.object.sortPropertiesAlphabetically=!this.object.sortPropertiesAlphabetically},{checked:this.object.sortPropertiesAlphabetically,jslogContext:"sort-properties-alphabetically"}),t.viewSection().appendCheckboxItem(N.i18n.lockedString("Show all"),()=>{this.object.includeNullOrUndefinedValues=!this.object.includeNullOrUndefinedValues},{checked:this.object.includeNullOrUndefinedValues,jslogContext:"show-all"}),t.show()}async onpopulate(){this.removeChildren();let e=this.treeOutline,t=e?!!e.skipProtoInternal:!1;return await k.populate(this,this.object,t,!1,this.linkifier,this.emptyPlaceholder)}},Ve=200,We=(s,e,t)=>{let{property:n}=s.node,i=n.synthetic&&s.node.name==="[[Entries]]",r=`completions-${s.node.parent?.object?.objectId?.replaceAll(".","-")}-${s.node.name}`,o=async d=>{d.target instanceof v.TextPrompt.TextPromptElement&&s.onAutoComplete(d.detail.expression,d.detail.filter,d.detail.force)},c=pt({name:!0,"object-properties-section-dimmed":!n.enumerable,"own-property":n.isOwn,"synthetic-property":n.synthetic}),p=/^\s|\s$|^$|\n/.test(n.name)?`"${n.name.replace(/\n/g,"\u21B5")}"`:n.name,h=!i&&n.value&&!n.wasThrown&&n.value.hasChildren&&!n.value.customPreview()&&n.value.subtype!=="node"&&n.value.type!=="function"&&(n.value.type!=="object"||n.value.preview),u=()=>{let d=Re(a=>{e.valueElement=a});if(i)return x`<span ${d} class=value></span>`;if(n.value){let a=n.name!=="[[Prototype]]",m=P.createPropertyValueWithCustomSupport(n.value,n.wasThrown,a,s.linkifier,n.synthetic,s.node.path,s.node.includeNullOrUndefinedValues);return e.valueElement=m,m}if(n.getter){let a=n.getter,m=f=>{f.consume(),s.invokeGetter(a)};return x`<span ${d}><span
        class=object-value-calculate-value-button
        title=${y(g.invokePropertyGetter)}
        @click=${m}
        >${y(g.dots)}</span></span>`}return x`<span ${d}
        class=object-value-unavailable
        title=${y(g.valueNotAccessibleToTheDebugger)}>${y(g.valueUnavailable)}</span>`},l=d=>{d instanceof KeyboardEvent&&!I.KeyboardUtilities.isEnterOrSpaceKey(d)||(d.consume(!0),s.editable&&n.value&&!n.value.customPreview()&&(n.writable||n.setter)&&s.startEditing())};V(x`<span class=name-and-value><span
          ${Re(d=>{e.nameElement=d})}
          class=${c}
          title=${s.node.path}>${n.private?x`<span class="private-property-hash">${n.name[0]}</span>${n.name.substring(1)}</span>`:p}</span>${i?ee:x`<span class='separator'>: </span><devtools-prompt
                @commit=${d=>s.editingCommitted(d.detail)}
                @cancel=${()=>s.editingEnded()}
                @beforeautocomplete=${o}
                @dblclick=${l}
                @keydown=${l}
                completions=${r}
                placeholder=${y(g.stringIsTooLargeToEdit)}
                ?editing=${s.editing}>
                  ${s.expanded&&h&&n.value?x`<span
                      class="value object-value-${n.value.subtype||n.value.type}"
                      title=${ne(n.value.description)}>${n.value.description==="Object"?"":I.StringUtilities.trimMiddle(n.value.description??"",Z)}${n.synthetic?ee:P.getMemoryIcon(n.value)}</span>`:u()}
                  <datalist id=${r}>${ct(s.completions,d=>x`<option>${d}</option>`)}</datalist>
                </devtools-prompt></span>`}</span>`,t)},re=class extends v.Widget.Widget{#e=[];#t;#n;#i;#s=[];#r=!1;#c;#o=!1;#a;#l=!1;constructor(e,t=We){super(e),this.#c=t}get property(){return this.#t}set property(e){this.#t&&(this.#t.removeEventListener("value-changed",this.requestUpdate,this),this.#t.removeEventListener("children-changed",this.requestUpdate,this),this.#t.removeEventListener("filter-changed",this.requestUpdate,this)),this.#t=e,this.#t.addEventListener("value-changed",this.requestUpdate,this),this.#t.addEventListener("children-changed",this.requestUpdate,this),this.#t.addEventListener("filter-changed",this.requestUpdate,this),this.requestUpdate()}get expanded(){return this.#o}set expanded(e){this.#o=e,this.requestUpdate()}get linkifier(){return this.#a}set linkifier(e){this.#a=e,this.requestUpdate()}get editable(){return this.#l}set editable(e){this.#l=e,this.requestUpdate()}performUpdate(){if(!this.#t)return;let e={editable:this.#l,expanded:this.#o,editing:this.#r,editingEnded:this.#d.bind(this),editingCommitted:this.#u.bind(this),node:this.#t,linkifier:this.#a,completions:this.#r?this.#s:[],onAutoComplete:this.#h.bind(this),invokeGetter:this.#m.bind(this),startEditing:this.startEditing.bind(this)},t=this,n={set nameElement(i){t.#n=i},set valueElement(i){t.#i=i}};this.#c(e,n,this.element)}setSearchRegex(e,t){let n=G.highlightedSearchResultClassName;return t&&(n+=" "+t),this.revertHighlightChanges(),this.#n&&this.#p(e,this.#n,n),this.property?.object&&this.property?.object.type!=="object"&&this.#i&&this.#p(e,this.#i,n),!!this.#e.length}#p(e,t,n){let i=[],r=t.textContent||"";e.lastIndex=0;let o=e.exec(r);for(;o;)i.push(new Ae.TextRange.SourceRange(o.index,o[0].length)),o=e.exec(r);i.length&&G.highlightRangesWithStyleClass(t,i,n,this.#e)}revertHighlightChanges(){G.revertDomChanges(this.#e),this.#e=[]}async#h(e,t,n){let i=await De.JavaScript.completeInContext(e,t,n);this.#s=i.map(r=>r.text),this.requestUpdate()}get editing(){return this.#r}startEditing(){this.#r=!0,this.requestUpdate()}#d(){this.#s=[],this.#r=!1,this.requestUpdate()}async#u(e){this.#d(),await this.#t?.setValue(e)}#m(e){this.#t?.invokeGetter(e)}},k=class s extends v.TreeOutline.TreeElement{property;toggleOnClick;linkifier;maxNumPropertiesToShow;#e;constructor(e,t){super(),this.#e=new re,this.property=e,this.hidden=e.isFiltered,this.property.addEventListener("value-changed",this.#t,this),this.property.addEventListener("children-changed",this.#n,this),this.property.addEventListener("filter-changed",this.#i,this),this.toggleOnClick=!0,this.linkifier=t,this.maxNumPropertiesToShow=Ve,this.listItemElement.addEventListener("contextmenu",this.contextMenuFired.bind(this),!1),this.listItemElement.dataset.objectPropertyNameForTest=e.name,this.updateExpandable(),this.setExpandRecursively(e.name!=="[[Prototype]]"),e.expanded&&this.expand()}static async populate(e,t,n,i,r,o){let c=await t.populateChildrenIfNeeded();c.arrayRanges?await $.populate(e,c,r):s.populateWithProperties(e,c,n,i,r,o)}static*createPropertyNodes({properties:e,internalProperties:t,accessors:n,arrayRanges:i},r,o,c,p,h){let u=!0;i&&i.length>0&&(u=!1);let l=e?.[0]?.parent?.sortPropertiesAlphabetically??!0;e?.sort((a,m)=>P.compareProperties(a,m,l));let d=t?.find(({property:a})=>a.name==="[[Entries]]");if(d){let a=new s(d,c);a.setExpandable(!0),a.expand(),u=!1,yield a}for(let a of e??[]){if(h?.(a.property))continue;if(a.property.getter||!a.property.isAccessorProperty()){let f=new s(a,c);a.property.name==="memories"&&a.object?.className==="Memories"&&(f.updateExpandable(),f.isExpandable()&&f.expand()),u=!1,yield f}}for(let a of n??[])yield new s(a,c);for(let a of t??[]){let m=new s(a,c);a.property.name!=="[[Entries]]"&&(a.property.name==="[[Prototype]]"&&r||(u=!1,yield m))}if(u){let a=document.createElement("div");a.classList.add("gray-info-message"),a.textContent=p||y(g.noProperties),yield new v.TreeOutline.TreeElement(a)}}static populateWithProperties(e,t,n,i,r,o){for(let c of this.createPropertyNodes(t,n,i,r,o,p=>e instanceof s&&!P.isDisplayableProperty(p,e.property?.property)))e.appendChild(c)}revertHighlightChanges(){this.#e.revertHighlightChanges()}setSearchRegex(e,t){return this.#e.setSearchRegex(e,t)}startEditing(){this.#e.startEditing()}get editing(){return this.#e.editing}get editable(){return this.#e.editable}set editable(e){this.#e.editable=e}async applyExpression(e){await this.property.setValue(e)}showAllPropertiesElementSelected(e){return this.removeChild(e),this.children().forEach(t=>{t.hidden=!1}),!1}createShowAllPropertiesButton(){let e=document.createElement("div");e.classList.add("object-value-calculate-value-button"),e.textContent=y(g.dots),v.Tooltip.Tooltip.install(e,y(g.showAllD,{PH1:this.childCount()}));let t=this.children();for(let i=this.maxNumPropertiesToShow;i<this.childCount();++i)t[i].hidden=!0;let n=new v.TreeOutline.TreeElement(e);n.onselect=this.showAllPropertiesElementSelected.bind(this,n),this.appendChild(n)}async onpopulate(){let e=this.treeOutline,t=e?!!e.skipProtoInternal:!1;this.removeChildren(),this.property.object&&(await s.populate(this,this.property,t,!1,this.linkifier),this.childCount()>this.maxNumPropertiesToShow&&this.createShowAllPropertiesButton())}onattach(){this.updateExpandable(),this.#e.markAsRoot(),this.#e.show(this.listItemElement),this.#e.property=this.property,this.#e.linkifier=this.linkifier,this.#e.editable=!this.property.readOnly}onexpand(){this.property.expanded=!0,this.#e.expanded=!0}oncollapse(){this.property.expanded=!1,this.#e.expanded=!1}#t(){this.updateExpandable()}#n(){this.removeChildren(),this.onpopulate()}#i(){this.hidden=this.property.isFiltered}getContextMenu(e){let t=new v.ContextMenu.ContextMenu(e);if(t.appendApplicableItems(this),this.property.property.symbol&&t.appendApplicableItems(this.property.property.symbol),this.property.object&&(t.appendApplicableItems(this.property.object),this.property.parent?.object instanceof j.RemoteObject.LocalJSONObject)){let{object:{value:i}}=this.property,r=typeof i=="object"?JSON.stringify(i,null,2):i,o=()=>{O.userMetrics.actionTaken(O.UserMetrics.Action.NetworkPanelCopyValue),O.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(r)};t.clipboardSection().appendItem(y(g.copyValue),o,{jslogContext:"copy-value"})}if(!this.property.property.synthetic&&this.property.path){let i=O.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(O.InspectorFrontendHost.InspectorFrontendHostInstance,this.property.path);t.clipboardSection().appendItem(y(g.copyPropertyPath),i,{jslogContext:"copy-property-path"})}this.property.parent?.object instanceof j.RemoteObject.LocalJSONObject&&(t.viewSection().appendItem(y(g.expandRecursively),this.expandRecursively.bind(this,ge),{jslogContext:"expand-recursively"}),t.viewSection().appendItem(y(g.collapseChildren),this.collapseChildren.bind(this),{jslogContext:"collapse-children"}));let n=this.property;for(;n.parent;)n=n.parent;return n.isWasm||t.viewSection().appendCheckboxItem(y(g.sortPropertiesAlphabetically),()=>{n.sortPropertiesAlphabetically=!n.sortPropertiesAlphabetically},{checked:n.sortPropertiesAlphabetically,jslogContext:"sort-properties-alphabetically"}),t.viewSection().appendCheckboxItem(N.i18n.lockedString("Show all"),()=>{n.includeNullOrUndefinedValues=!n.includeNullOrUndefinedValues},{checked:n.includeNullOrUndefinedValues,jslogContext:"show-all"}),t}contextMenuFired(e){this.getContextMenu(e).show()}updateExpandable(){this.property.object?this.setExpandable(!this.property.object.customPreview()&&this.property.object.hasChildren&&!this.property.property.wasThrown):this.setExpandable(!1)}path(){return this.property.path}};async function Ge(s,e,t){return await s.callFunctionJSON(n,[{value:e},{value:t},{value:$.bucketThreshold},{value:$.sparseIterationThreshold}]);function n(i,r,o,c){if(i===void 0||r===void 0||c===void 0||o===void 0)return;let p=null,h=r-i>=c&&ArrayBuffer.isView(this);function*u(m){if(!(i===void 0||r===void 0||c===void 0))if(r-i<c)for(let f=i;f<=r;++f)f in m&&(yield f);else{p=p||Object.getOwnPropertyNames(m);for(let f=0;f<p.length;++f){let b=p[f],C=Number(b)>>>0;String(C)===b&&i<=C&&C<=r&&(yield C)}}}let l=0;if(h)l=r-i+1;else for(let m of u(this))++l;let d=l;l<=o?d=l:d=Math.pow(o,Math.ceil(Math.log(l)/Math.log(o))-1);let a=[];if(h)for(let m=i;m<=r;m+=d){let f=m,b=f+d-1;b>r&&(b=r),a.push([f,b,b-f+1])}else{l=0;let m=-1,f=0;for(let b of u(this))m===-1&&(m=b),f=b,++l===d&&(a.push([m,f,l]),l=0,m=-1);l>0&&a.push([m,f,l])}return{ranges:a}}}function ut(s,e,t){let n=Object.create(null);if(!(s===void 0||e===void 0||t===void 0)){if(e-s<t)for(let i=s;i<=e;++i)i in this&&(n[i]=this[i]);else{let i=Object.getOwnPropertyNames(this);for(let r=0;r<i.length;++r){let o=i[r],c=Number(o)>>>0;String(c)===o&&s<=c&&c<=e&&(n[c]=this[c])}}return n}}var $=class s extends v.TreeOutline.TreeElement{toggleOnClick;linkifier;#e;constructor(e,t){super(I.StringUtilities.sprintf("[%d \u2026 %d]",e.range.fromIndex,e.range.toIndex),!0),this.#e=e,this.#e.addEventListener("children-changed",this.onpopulate,this),this.toggleOnClick=!0,this.linkifier=t,e.expanded&&this.expand()}static async populate(e,t,n){if(t.arrayRanges){if(t.arrayRanges.length===1)await k.populate(e,t.arrayRanges[0],!1,!1,n);else for(let i of t.arrayRanges)i.singular?await k.populate(e,i,!1,!1,n):e.appendChild(new s(i,n));k.populateWithProperties(e,t,!1,!1,n)}}onexpand(){this.#e.expanded=!0}oncollapse(){this.#e.expanded=!1}async onpopulate(){this.removeChildren(),await k.populate(this,this.#e,!1,!1,this.linkifier)}onattach(){this.listItemElement.classList.add("object-properties-section-name")}static bucketThreshold=100;static sparseIterationThreshold=25e4},he,be=class s{static instance(e={forceNew:!1}){let{forceNew:t}=e;return(!he||t)&&(he=new s),he}async render(e,t){if(!(e instanceof j.RemoteObject.RemoteObject))throw new Error("Can't render "+e);let n=t?.title,i=new P(e,n,void 0,void 0,!!t?.editable);n||i.titleLessMode(),t?.expand&&i.firstChild()?.expand();let r=()=>{i.element.dispatchEvent(new CustomEvent("dimensionschanged"))};return i.addEventListener(v.TreeOutline.Events.ElementAttached,r),i.addEventListener(v.TreeOutline.Events.ElementExpanded,r),i.addEventListener(v.TreeOutline.Events.ElementCollapsed,r),{element:i.element,forceSelect:i.forceSelect.bind(i)}}},Be=(s,e,t)=>{let n=N.ByteUtilities.bytesToString(s.byteCount),i=s.text.length<A.MAX_DISPLAYABLE_TEXT_LENGTH,r=c=>{let{target:p}=c;if(!(p instanceof Element))return;let h=p.closest("li"),u=h&&v.TreeOutline.TreeElement.getTreeElementBylistItemNode(h);if(!(u instanceof k))return;let l=u.getContextMenu(c);i&&!s.expanded&&l.clipboardSection().appendItem(y(g.showMoreS,{PH1:n}),s.expandText,{jslogContext:"show-more"}),l.clipboardSection().appendItem(y(g.copy),s.copyText,{jslogContext:"copy"}),l.show(),c.consume(!0)},o=s.text.slice(0,s.maxLength);V(x`<span title=${o+"\u2026"} @contextmenu=${r}>
               ${s.expanded?s.text:o}
               <button
                 ?hidden=${s.expanded}
                 @click=${i?s.expandText:void 0}
                 jslog=${ne(i?te.action("expand").track({click:!0}):void 0)}
                 class=${i?"expandable-inline-button":"undisplayable-text"}
                 data-text=${i?y(g.showMoreS,{PH1:n}):y(g.longTextWasTruncatedS,{PH1:n})}
                 ></button>
               <button
                 class=expandable-inline-button
                 @click=${s.copyText}
                 data-text=${y(g.copy)}
                 jslog=${te.action("copy").track({click:!0})}
                 ></button>
             </span>`,t)},A=class s extends v.Widget.Widget{static MAX_DISPLAYABLE_TEXT_LENGTH=1e7;static EXPANDABLE_MAX_LENGTH=50;#e="";#t=0;#n=!1;#i=s.EXPANDABLE_MAX_LENGTH;#s;constructor(e,t=Be){super(e),this.#s=t}set text(e){this.#e=e,this.#t=I.StringUtilities.countWtf8Bytes(e),this.requestUpdate()}set maxLength(e){this.#i=e,this.requestUpdate()}performUpdate(){let e={copyText:()=>O.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(this.#e),expandText:()=>{this.#n||(this.#n=!0,this.requestUpdate())},expanded:this.#n,byteCount:this.#t,maxLength:this.#i,text:this.#e};this.#s(e,{},this.contentElement)}};var Je={showAsJavascriptObject:"Show as JavaScript object"},ft=ye.i18n.registerUIStrings("ui/legacy/components/object_ui/CustomPreviewComponent.ts",Je),bt=ye.i18n.getLocalizedString.bind(void 0,ft),se=class s{sectionElement;object;expanded;cachedContent;header;expandIcon;constructor(e){this.sectionElement=document.createElement("span"),this.sectionElement.classList.add("custom-expandable-section"),this.object=e,this.expanded=!1,this.cachedContent=null;let t=e.customPreview();if(!t)return;let n;try{n=JSON.parse(t.header)}catch(i){q.Console.Console.instance().error("Broken formatter: header is invalid json "+i);return}if(this.header=this.renderJSONMLTag(n),this.header.nodeType===Node.TEXT_NODE){q.Console.Console.instance().error("Broken formatter: header should be an element node.");return}t.bodyGetterId&&(this.header instanceof Element&&this.header.classList.add("custom-expandable-section-header"),this.header.addEventListener("click",this.onClick.bind(this),!1),this.expandIcon=mt("triangle-right","custom-expand-icon"),this.header.insertBefore(this.expandIcon,this.header.firstChild)),this.sectionElement.appendChild(this.header)}element(){return this.sectionElement}renderJSONMLTag(e){return Array.isArray(e)?e[0]!=="object"?this.renderElement(e):e.length!==2?(q.Console.Console.instance().error("Broken formatter: object reference must contain exactly two elements"),document.createElement("span")):this.layoutObjectTag(e):document.createTextNode(String(e))}renderElement(e){let t=e.shift();if(!gt.includes(t))return q.Console.Console.instance().error("Broken formatter: element "+t+" is not allowed!"),document.createElement("span");let n=document.createElement(t);if(typeof e[0]=="object"&&!Array.isArray(e[0])){let i=e.shift();for(let r in i){let o=i[r];r!=="style"||typeof o!="string"||n.setAttribute(r,o)}}return this.appendJsonMLTags(n,e),n}layoutObjectTag(e){e.shift();let t=e.shift(),n=this.object.runtimeModel().createRemoteObject(t);if(n.customPreview())return new s(n).element();let i=P.defaultObjectPresentation(n);return i.classList.toggle("custom-expandable-section-standard-section",n.hasChildren),i}appendJsonMLTags(e,t){for(let n=0;n<t.length;++n)e.appendChild(this.renderJSONMLTag(t[n]))}onClick(e){e.consume(!0),this.cachedContent?this.toggleExpand():this.loadBody()}toggleExpand(){this.expanded=!this.expanded,this.header instanceof Element&&this.header.classList.toggle("expanded",this.expanded),this.cachedContent instanceof Element&&this.cachedContent.classList.toggle("hidden",!this.expanded),this.expandIcon&&(this.expanded?this.expandIcon.name="triangle-down":this.expandIcon.name="triangle-right")}defaultBodyTreeOutline;async loadBody(){let e=this.object.customPreview();if(e&&e.bodyGetterId){let t=await this.object.callFunctionJSON(n=>n(),[{objectId:e.bodyGetterId}]);t===null?(this.defaultBodyTreeOutline=new J,this.defaultBodyTreeOutline.setShowSelectionOnKeyboardFocus(!0,!1),this.defaultBodyTreeOutline.element.classList.add("custom-expandable-section-default-body"),k.populate(this.defaultBodyTreeOutline.rootElement(),new D(this.object,{readOnly:!0,propertiesMode:1}),!1,!1),this.cachedContent=this.defaultBodyTreeOutline.element):this.cachedContent=this.renderJSONMLTag(t),this.sectionElement.appendChild(this.cachedContent),this.toggleExpand()}}},gt=["span","div","ol","li","table","tr","td"],F=class{object;customPreviewSection;element;constructor(e){this.object=e,this.customPreviewSection=new se(e),this.element=document.createElement("span"),this.element.classList.add("source-code");let t=oe.UIUtils.createShadowRootWithCoreStyles(this.element,{cssFile:Ee});this.element.addEventListener("contextmenu",this.contextMenuEventFired.bind(this),!1),t.appendChild(this.customPreviewSection.element())}expandIfPossible(){let e=this.object.customPreview();e&&e.bodyGetterId&&this.customPreviewSection&&this.customPreviewSection.loadBody()}contextMenuEventFired(e){let t=new oe.ContextMenu.ContextMenu(e);this.customPreviewSection&&t.revealSection().appendItem(bt(Je.showAsJavascriptObject),this.disassemble.bind(this),{jslogContext:"show-as-javascript-object"}),t.appendApplicableItems(this.object),t.show()}disassemble(){this.element.shadowRoot&&(this.element.shadowRoot.textContent="",this.customPreviewSection=null,this.element.shadowRoot.appendChild(P.defaultObjectPresentation(this.object)))}};var Ze={};B(Ze,{ObjectPopoverHelper:()=>xe});import*as we from"./../../../../core/i18n/i18n.js";import*as ze from"./../../../../core/platform/platform.js";import*as ve from"./../../../../core/sdk/sdk.js";import*as Xe from"./../../../../models/geometry/geometry.js";import{Link as yt}from"./../../../kit/kit.js";import{render as vt}from"./../../../lit/lit.js";import*as Ye from"./../../legacy.js";import*as _e from"./../utils/utils.js";var ae=`.widget:has(.object-popover-tree){padding:0;border-radius:var(--sys-shape-corner-extra-small)}.object-popover-content{display:flex;position:relative;overflow:hidden;flex:1 1 auto;flex-direction:column}.object-popover-title{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-weight:bold;padding-left:18px;padding-bottom:2px;padding-top:var(--sys-size-3);flex-shrink:0}.object-popover-tree{border-top:1px solid var(--sys-color-divider);overflow:auto;width:100%;height:calc(100% - 13px)}.object-popover-container{display:inline-block}.object-popover-description-box{padding:6px;max-width:350px;line-height:1.4}.object-popover-footer{margin-top:8px}
/*# sourceURL=${import.meta.resolve("./objectPopover.css")} */`;var Qe={learnMore:"Learn more"},xt=we.i18n.registerUIStrings("ui/legacy/components/object_ui/ObjectPopoverHelper.ts",Qe),wt=we.i18n.getLocalizedString.bind(void 0,xt),xe=class s{linkifier;resultHighlightedAsDOM;constructor(e,t){this.linkifier=e,this.resultHighlightedAsDOM=t}dispose(){this.resultHighlightedAsDOM&&ve.OverlayModel.OverlayModel.hideDOMNodeHighlight(),this.linkifier&&this.linkifier.dispose()}static async buildObjectPopover(e,t){let n=ze.StringUtilities.trimEndWithMaxLength(e.description||"",jt),i=null;if(e.type==="function"||e.type==="object"){let o=null,c=!1;if(e.subtype==="node"&&(ve.OverlayModel.OverlayModel.highlightObjectAsDOMNode(e),c=!0),e.customPreview()){let p=new F(e);p.expandIfPossible(),i=p.element}else{i=document.createElement("div"),i.classList.add("object-popover-content"),t.registerRequiredCSS(T,ae);let p=i.createChild("div","object-popover-title");e.type==="function"?(p.classList.add("source-code"),vt(P.valueElementForFunctionDescription(e.description),p)):(p.classList.add("monospace"),p.createChild("span").textContent=n),o=new _e.Linkifier.Linkifier;let h=new P(e,"",o,!0);h.element.classList.add("object-popover-tree"),h.titleLessMode(),i.appendChild(h.element)}return i.dataset.stableNameForTest="object-popover-content",t.setMaxContentSize(new Xe.Size(300,250)),t.setSizeBehavior("SetExactSize"),t.contentElement.appendChild(i),new s(o,c)}i=document.createElement("span"),i.dataset.stableNameForTest="object-popover-content",t.registerRequiredCSS(T,ae);let r=i.createChild("span","monospace object-value-"+e.type);return r.style.whiteSpace="pre",e.type==="string"?Ye.UIUtils.createTextChildren(r,`"${n}"`):r.textContent=n,t.contentElement.appendChild(i),new s(null,!1)}static buildDescriptionPopover(e,t,n){let i=document.createElement("div");i.classList.add("object-popover-description-box");let r=document.createElement("div");r.dataset.stableNameForTest="object-popover-content",n.registerRequiredCSS(ae),r.textContent=e;let o=yt.create(t,wt(Qe.learnMore),void 0,"learn-more"),c=document.createElement("div");return c.classList.add("object-popover-footer"),c.appendChild(o),i.appendChild(r),i.appendChild(c),n.contentElement.appendChild(i),new s(null,!1)}},jt=1e4;export{qe as CustomPreviewComponent,Me as JavaScriptREPL,Ze as ObjectPopoverHelper,Ke as ObjectPropertiesSection,Oe as RemoteObjectPreviewFormatter};
//# sourceMappingURL=object_ui.js.map
