var it=Object.defineProperty;var K=(s,e)=>{for(var t in e)it(s,t,{get:e[t],enumerable:!0})};var _e={};K(_e,{CustomPreviewComponent:()=>H,CustomPreviewSection:()=>ue});import*as Q from"./../../../../core/common/common.js";import*as Ee from"./../../../../core/i18n/i18n.js";import{createIcon as vt}from"./../../../kit/kit.js";import*as me from"./../../legacy.js";var Ie=`.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 Xe={};K(Xe,{ArrayGroupTreeNode:()=>W,ArrayGroupingTreeElement:()=>M,EXPANDABLE_MAX_DEPTH:()=>he,EXPANDABLE_TEXT_DEFAULT_VIEW:()=>ze,ExpandableTextPropertyValue:()=>A,InitialVisibleChildrenLimit:()=>Ke,OBJECT_PROPERTY_DEFAULT_VIEW:()=>Je,ObjectPropertiesSection:()=>S,ObjectPropertiesSectionsTreeOutline:()=>Y,ObjectPropertyTreeElement:()=>I,ObjectPropertyWidget:()=>de,ObjectTree:()=>F,ObjectTreeExpansionTracker:()=>Pe,ObjectTreeNode:()=>O,ObjectTreeNodeBase:()=>D,Renderer:()=>Ce,getObjectPropertiesSectionFrom:()=>mt,isWasmObject:()=>We,objectPropertiesSectionStyles:()=>q,objectValueStyles:()=>$,populateObjectTreeContextMenu:()=>Be,renderObjectPropertiesSection:()=>bt,renderObjectTree:()=>gt});import*as R from"./../../../../core/common/common.js";import*as L from"./../../../../core/host/host.js";import*as _ from"./../../../../core/i18n/i18n.js";import*as C from"./../../../../core/platform/platform.js";import*as E from"./../../../../core/sdk/sdk.js";import*as le from"./../../../../core/text_utils/text_utils.js";import*as De from"./../../../i18n/i18n.js";import*as B from"./../../../components/highlighting/highlighting.js";import*as Fe from"./../../../components/text_editor/text_editor.js";import{Directives as dt,html as x,nothing as ce,render as V}from"./../../../lit/lit.js";import*as pe from"./../../../visual_logging/visual_logging.js";import*as w from"./../../legacy.js";var Ue={};K(Ue,{JavaScriptREPL:()=>J});import*as Le from"./../../../../core/sdk/sdk.js";import*as Te from"./../../../../models/bindings/bindings.js";import*as $e from"./../../../../models/formatter/formatter.js";import*as Me from"./../../../../models/source_map_scopes/source_map_scopes.js";import*as Re from"./../../../../third_party/acorn/acorn.js";import*as Ae from"./../../legacy.js";var ke={};K(ke,{RemoteObjectPreviewFormatter:()=>N,renderNodeTitle:()=>se,renderTrustedType:()=>oe});import*as be from"./../../../../core/i18n/i18n.js";import*as ne from"./../../../../core/platform/platform.js";import*as re from"./../../../../core/sdk/sdk.js";import{Directives as st,html as k,nothing as U,render as ot}from"./../../../lit/lit.js";var{ifDefined:at,repeat:lt}=st,ie={emptyD:"empty \xD7 {PH1}",empty:"empty",thePropertyIsComputedWithAGetter:"The property is computed with a getter"},ct=be.i18n.registerUIStrings("ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts",ie),ge=be.i18n.getLocalizedString.bind(void 0,ct),N=class s{static objectPropertyComparator(e,t){return n(e)-n(t);function n(r){return r.name==="[[PromiseState]]"?1:r.name==="[[PromiseResult]]"?2:r.name==="[[GeneratorState]]"||r.name==="[[PrimitiveValue]]"||r.name==="[[WeakRefTarget]]"?3:r.type!=="function"&&!r.name.startsWith("#")?4:5}}renderObjectPreview(e,t=!0){let n=e.description,r=new Set(["arraybuffer","dataview","error","null","regexp","webassemblymemory","internal#entry","trustedtype"]);if(e.type!=="object"||e.subtype&&r.has(e.subtype))return this.renderPropertyPreview(e.type,e.subtype,void 0,n);let i=e.subtype==="array"||e.subtype==="typedarray",o="";if(n)if(i){let a=re.RemoteObject.RemoteObject.arrayLength(e),m=a>1?"("+a+")":"",f=re.RemoteObject.RemoteObject.arrayNameFromDescription(n);o=f==="Array"?m:f+m}else o=n==="Object"?"":n;let l=Array.from(e.entries?this.renderEntries(e):i?this.renderArrayProperties(e):this.renderObjectProperties(e,t)),p=a=>k`<span class=name>${/^\s|\s$|^$|\n/.test(a)?'"'+a.replace(/\n/g,"\u21B5")+'"':a}</span>`,h=a=>k`<span class=object-value-undefined>${a}</span>`,d=a=>this.renderPropertyPreview(a.type,a.subtype,a.name,a.value),c=a=>k`${a.key&&k`${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)}`,u=({name:a,entry:m,value:f,placeholder:g},j)=>k`${j>0?", ":""}${g!==void 0?h(g):U}${a!==void 0?p(a):U}${a!==void 0&&f?": ":""}${f?d(f):U}${m?c(m):U}`;return k`${o.length>0?k`<span class=object-description>${o+"\xA0"}</span>`:U}<span class=object-properties-preview>${i?"[":"{"}${lt(l,u)}${e.overflow?k`<span>${l.length>0?",\xA0\u2026":"\u2026"}</span>`:""}
    ${i?"]":"}"}</span>`}*renderObjectProperties(e,t){let n=e.properties.filter(r=>r.type!=="accessor").sort(s.objectPropertyComparator);for(let r=0;r<n.length;++r){let i=n[r],o=i.name;if(!(!t&&(i.type==="undefined"||i.type==="object"&&i.subtype==="null")))if(e.subtype==="promise"&&o==="[[PromiseState]]"){let l=n.at(r+1)?.name==="[[PromiseResult]]"?n.at(r+1):void 0;l&&r++,yield{name:"<"+i.value+">",value:i.value!=="pending"?l:void 0}}else e.subtype==="generator"&&o==="[[GeneratorState]]"?yield{name:"<"+i.value+">"}:o==="[[PrimitiveValue]]"?yield{value:i}:o==="[[WeakRefTarget]]"?i.type==="undefined"?yield{name:"<cleared>"}:yield{value:i}:yield{name:o,value:i}}}*renderArrayProperties(e){let t=re.RemoteObject.RemoteObject.arrayLength(e),n=e.properties.filter(c=>o(c.name)!==-1).sort(i),r=e.properties.filter(c=>o(c.name)===-1).sort(s.objectPropertyComparator);function i(c,u){return o(c.name)-o(u.name)}function o(c){let u=Number(c)>>>0;return String(u)===c&&u<t?u:-1}let l=!e.overflow,p=[];for(let c of n){let u=o(c.name),a=u-(p.at(-1)?.index??-1)-1,m=u!==p.length;p.push({property:c,index:u,gap:a,hasGaps:m})}let h=t-(p.at(-1)?.index??-1)-1,d=c=>({placeholder:c!==1?ge(ie.emptyD,{PH1:c}):ge(ie.empty)});for(let{property:c,gap:u,hasGaps:a}of p)l&&u>0&&(yield d(u)),yield{name:!l&&a?c.name:void 0,value:c};l&&h>0&&(yield d(h));for(let c of r)yield{name:c.name,value:c}}*renderEntries(e){for(let t of e.entries??[])yield{entry:t}}renderPropertyPreview(e,t,n,r){let i;switch(e){case"accessor":i=ge(ie.thePropertyIsComputedWithAGetter);break;case"string":i=r;break;case"object":t||(i=r);break}let o=p=>{let h=p.split(".");for(let d=0;d<h.length-1;++d)h[d]=ne.StringUtilities.trimMiddle(h[d],3);return h.length===1&&h[0]==="Object"?"{\u2026}":h.join(".")},l=()=>e==="accessor"?"(...)":e==="function"?"\u0192":e==="object"&&t==="trustedtype"&&n?oe(r??"",n):e==="object"&&t==="node"&&r?se(r):e==="string"?ne.StringUtilities.formatAsJSLiteral(r??""):e==="object"&&!t?o(r??""):r;return k`<span class='object-value-${t||e}' title=${at(i)}>${l()}</span>`}renderEvaluationResultPreview(e,t){if("error"in e)return U;if(e.exceptionDetails?.exception?.description){let p=e.exceptionDetails.exception.description;return p.startsWith("TypeError: ")||t?k`<span>${e.exceptionDetails.text} ${p}</span>`:U}let{preview:n,type:r,subtype:i,className:o,description:l}=e.object;return n&&r==="object"&&i!=="node"&&i!=="trustedtype"?this.renderObjectPreview(n):this.renderPropertyPreview(r,i,o,ne.StringUtilities.trimEndWithMaxLength(l||"",400))}renderEvaluationResultPreviewFragment(e,t){let n=document.createDocumentFragment();return ot(this.renderEvaluationResultPreview(e,t),n),n}};function se(s){let e=s.match(/([^#.]+)(#[^.]+)?(\..*)?/);return e?k`<span class=webkit-html-tag-name>${e[1]}</span>${e[2]&&k`<span class=webkit-html-attribute-value>${e[2]}</span>`}${e[3]&&k`<span class=webkit-html-attribute-name>${e[3]}</span>`}`:null}function oe(s,e){return k`${e} <span class=object-value-string title=${s}>"${s.replace(/\n/g,"\u21B5")}"</span>`}var J=class s{static wrapObjectLiteral(e){let t=/^\s*\{\s*(.*)\s*\}[\s;]*$/.exec(e);if(t===null)return e;let[,n]=t,r=0;for(let o of n)if(o==="{")r++;else if(o==="}"&&--r<0)return e;let i=o=>{Re.parse(o,{ecmaVersion:2022,allowAwaitOutsideFunction:!0,ranges:!1,allowReturnOutsideFunction:!0})};try{i("return {"+n+"};");let o="({"+n+"})";return i(o),o}catch{return e}}static async evaluate(e,t,n,r,i,o,l=!1,p=!1){let h=e.length>pt;if(!e||n&&h)return null;let d=e,c=t.debuggerModel.selectedCallFrame();if(c?.script.isJavaScript()){let a=await Me.NamesResolver.allVariablesInCallFrame(c,Te.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance());try{d=await $e.FormatterWorkerPool.formatterWorkerPool().javaScriptSubstitute(d,a)}catch{}}d=s.wrapObjectLiteral(d);let u={expression:d,generatePreview:!0,includeCommandLineAPI:!0,throwOnSideEffect:n,timeout:i,objectGroup:o,disableBreaks:!0,replMode:r,silent:p};return await t.evaluate(u,!1,l)}static async evaluateAndBuildPreview(e,t,n,r,i,o,l=!1,p=!1){let h=Ae.Context.Context.instance().flavor(Le.RuntimeModel.ExecutionContext);if(!h)return{preview:document.createDocumentFragment(),result:null};let d=await s.evaluate(e,h,t,n,r,o,l,p);return d?{preview:new N().renderEvaluationResultPreviewFragment(d,i),result:d}:{preview:document.createDocumentFragment(),result:null}}},pt=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 $=`.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: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;unicode-bidi:isolate}.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:ye}=w.Widget,{ref:Ne,repeat:ht,ifDefined:z,classMap:ae,until:ut}=dt,b={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}",showAll:"Show all",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"},He=_.i18n.registerUIStrings("ui/legacy/components/object_ui/ObjectPropertiesSection.ts",b),v=_.i18n.getLocalizedString.bind(void 0,He),he=100,Ve=new WeakMap,ve=new WeakMap;function We(s){return s?.subtype==="webassemblymemory"||s?.subtype==="wasmvalue"}var we=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),r=t.get(n)??new s;return t.has(n)||t.set(n,r),r}clear(e){this[e].clear()}clearMissing(e,t){let n=new Set(t.map(s.#e)),r=this[e];for(let i of r.keys())n.has(i)||r.delete(i)}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}`}},Pe=class s{#e=null;static#t(e){if(e instanceof O)return e.parent?.children?.internalProperties?.find(t=>t.name==="[[Prototype]]"&&t.children?.properties?.includes(e))}static#n(e){if(e instanceof O){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#r(e,t){return e==="arrayRanges"?t instanceof W?{type:e,key:t.range}:null:t instanceof O?{type:e,key:t.name}:null}clear(){this.#e=null}async#i(e,t){let n=async r=>{let i=t.children?.[r];if(!i){e.clear(r);return}let o=[];for(let l of i){let p=s.#r(r,l);if(!p)continue;let h=e.get(p);h&&(await this.#i(h,l),o.push(p))}e.clearMissing(r,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.#i(this.#e,e)}static*#s(e){if(!e)return;let t=s.#t(e);t?yield*this.#s(t):yield*this.#s(e.parent);let n=this.#n(e),r=n&&s.#r(n,e);r&&(yield r)}collapse(e){if(!this.#e)return;if(e instanceof F){this.#e=null;return}let t,n=null,r=this.#e;for(let i of s.#s(e)){t=i,n=r;let o=r.get(i);if(!o)return;r=o}t&&n&&n.remove(t)}expand(e){this.#e||(this.#e=new we);let t=this.#e;for(let n of s.#s(e))t=t.getOrInsert(n)}},D=class s extends R.ObjectWrapper.ObjectWrapper{parent;#e;options;filter=null;extraProperties=[];#t=!1;#n;constructor(e,t){super(),this.parent=e,this.filter=e?.filter??null,this.options={...t},this.#n=e?e.#n:R.Settings.Settings.instance().createSetting("object-properties-sort-alphabetically",!0)}get isWasm(){return We(this.object)}get expanded(){return this.#t}set expanded(e){e?this.options.expansionTracker?.expand(this):this.options.expansionTracker?.collapse(this),this.#t!==e&&(this.#t=e,this.dispatchEventToListeners("expanded-changed",e))}get readOnly(){return this.options.readOnly}get propertiesMode(){return this.options.propertiesMode}get search(){return this.options.search}get includeNullOrUndefinedValues(){return this.filter?.includeNullOrUndefinedValues??!0}set includeNullOrUndefinedValues(e){this.setFilter({includeNullOrUndefinedValues:e,regex:this.filter?.regex??null})}get canExpandRecursively(){return!0}get sortPropertiesAlphabetically(){return this.isWasm?!1:this.#n.get()}set sortPropertiesAlphabetically(e){this.isWasm||this.#n.get()===e||(this.#n.set(e),this.removeChildren())}*treeNodeChildren(){this.#e&&(yield*this.#e.properties??[],yield*this.#e.arrayRanges??[],yield*this.#e.internalProperties??[])}*#r(e=-1,t){if(!(t&&!t(this))&&(yield this,e!==0))for(let n of this.treeNodeChildren())yield*n.#r(Math.max(-1,e-1),t)}async expandRecursively(e){for(let t of this.#r(e,n=>n.canExpandRecursively))await t.populateChildrenIfNeeded(),t.expanded=!0}collapseRecursively(){for(let e of this.#r())e.expanded=!1}setFilter(e){this.filter=e,this.dispatchEventToListeners("filter-changed"),this.#r().forEach(t=>{t.filter=e,t.dispatchEventToListeners("filter-changed")})}removeChildren(){this.#e=void 0,this.dispatchEventToListeners("children-changed")}match(e){return[]}removeChild(e){t(this.#e?.arrayRanges,e),t(this.#e?.internalProperties,e),t(this.#e?.properties,e),this.dispatchEventToListeners("children-changed");function t(n,r){if(!n)return;let i=n.indexOf(r);i>=0&&n.splice(i,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>ft){let h=(await qe(e,0,this.arrayLength-1))?.ranges.map(([m,f,g])=>new W(e,{fromIndex:m,toIndex:f,count:g},t,{...this.options}));if(!h)return{};let{properties:d,internalProperties:c}=await E.RemoteObject.RemoteObject.loadFromObjectPerProto(this.object,!0,!0),u=d?.map(m=>new O(m,t,{...this.options,propertiesMode:1})),a=c?.map(m=>new O(m,t,{...this.options,propertiesMode:1}));return{arrayRanges:h,properties:u,internalProperties:a}}let n=null,r=null;switch(this.propertiesMode){case 0:({properties:n}=await e.getAllProperties(!1,!0));break;case 1:({properties:n,internalProperties:r}=await E.RemoteObject.RemoteObject.loadFromObjectPerProto(e,!0));break}let i=n?.map(p=>new O(p,t,{...this.options,propertiesMode:1}));i?.push(...this.extraProperties),i?.sort((p,h)=>S.compareProperties(p,h,this.sortPropertiesAlphabetically));let o=i&&s.getGettersAndSetters(i,this.options),l=r?.map(p=>new O(p,t,{...this.options,propertiesMode:1}));return{properties:i,internalProperties:l,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 O(t,this,{...this.options,propertiesMode:1})))}static getGettersAndSetters(e,t){let n=[];for(let r of e)if(r.property.isOwn){if(r.property.getter){let i=new E.RemoteObject.RemoteObjectProperty("get "+r.property.name,r.property.getter,!1);n.push(new O(i,r.parent,{...t,propertiesMode:r.propertiesMode,readOnly:r.readOnly}))}if(r.property.setter){let i=new E.RemoteObject.RemoteObjectProperty("set "+r.property.name,r.property.setter,!1);n.push(new O(i,r.parent,{...t,propertiesMode:r.propertiesMode,readOnly:r.readOnly}))}}return n}},F=class extends D{#e;constructor(e,t){super(void 0,t),this.#e=e}get object(){return this.#e}},W=class s extends D{#e;#t;constructor(e,t,n,r){super(n,r),this.#e=e,this.#t=t}async populateChildrenIfNeededImpl(){if(this.#t.count>M.bucketThreshold)return{arrayRanges:(await qe(this.object,this.#t.fromIndex,this.#t.toIndex))?.ranges.map(([p,h,d])=>new s(this.object,{fromIndex:p,toIndex:h,count:d},this,{readOnly:this.readOnly,propertiesMode:this.propertiesMode,expansionTracker:this.options.expansionTracker}))};let e=await this.#e.callFunction(yt,[{value:this.#t.fromIndex},{value:this.#t.toIndex},{value:M.sparseIterationThreshold}]);if(!e.object||e.wasThrown)return{};let t=e.object,n=await t.getAllProperties(!1,!0);t.release();let r=n.properties?.map(o=>new O(o,this,{...this.options}));r?.push(...this.extraProperties),r?.sort((o,l)=>S.compareProperties(o,l,this.sortPropertiesAlphabetically));let i=r&&D.getGettersAndSetters(r,this.options);return{properties:r,accessors:i}}get singular(){return this.#t.fromIndex===this.#t.toIndex}get range(){return this.#t}get object(){return this.#e}},O=class s extends D{property;nonSyntheticParent;#e;constructor(e,t,n,r){super(t,n),this.property=e,this.nonSyntheticParent=r}get object(){return this.property.value}get isFiltered(){return!!(this.filter&&!this.property.match(this.filter))}get canExpandRecursively(){return this.property.name!=="[[Prototype]]"}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}[${C.StringUtilities.formatAsJSLiteral(this.name)}]`}return this.#e}selfOrParentIfInternal(){return this.name==="[[Prototype]]"?this.parent??this:this}async setValue(e){let t=E.RemoteObject.RemoteObject.toCallArgument(this.property.symbol||this.name);if(e=J.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, []);
          }`,[E.RemoteObject.RemoteObject.toCallArgument(e)]);n?.object&&(this.property.value=n.object,this.property.wasThrown=n.wasThrown||!1,this.dispatchEventToListeners("value-changed"))}#t(){return/^\s|\s$|^$|\n/.test(this.property.name)?`"${this.property.name.replace(/\n/g,"\u21B5")}"`:this.property.name}#n(){let e=this.property.value;if(!e||e.type!=="string"&&e.type!=="number"||e.description===void 0)return"";if(e.type==="string"&&typeof e.description=="string"){let t=C.StringUtilities.safeEscapeUnicode(JSON.stringify(e.description));return e.description.length>X?t.slice(0,A.EXPANDABLE_MAX_LENGTH):t}return e.description}match(e){let t=[],n=this.#t(),r=e.global?e:new RegExp(e.source,e.flags+"g");for(let o of n.matchAll(r))t.push({node:this,isPostOrderMatch:!1,matchIndexInNode:t.length,matchType:"name",range:new le.TextRange.SourceRange(o.index??0,o[0].length)});let i=this.#n();if(i){let o=e.global?e:new RegExp(e.source,e.flags+"g");for(let l of i.matchAll(o))t.push({node:this,isPostOrderMatch:!1,matchIndexInNode:t.length,matchType:"value",range:new le.TextRange.SourceRange(l.index??0,l[0].length)})}return t}},mt=s=>Ve.get(s),S=class s extends w.TreeOutline.TreeOutlineInShadow{root;#e;titleElement;skipProtoInternal;constructor(e,t,n,r,i=!0,o){super(),this.root=new F(e,{readOnly:!i,propertiesMode:1,search:o}),r||this.setHideOverflow(!0),this.setFocusable(!0),this.setShowSelectionOnKeyboardFocus(!0),this.#e=new je(this.root,n),this.appendChild(this.#e),typeof t=="string"||!t?(this.titleElement=this.element.createChild("span"),this.titleElement.textContent=t?C.StringUtilities.escapeUnicodeAsText(t):""):(this.titleElement=t,this.element.appendChild(t)),this.titleElement instanceof HTMLElement&&!this.titleElement.hasAttribute("tabIndex")&&(this.titleElement.tabIndex=-1),Ve.set(this.element,this),this.registerRequiredCSS($,q),this.rootElement().childrenListElement.classList.add("source-code","object-properties-section")}static defaultObjectPresentation(e,t,n,r){let i=s.defaultObjectPropertiesSection(e,t,n,r);return e.hasChildren?i.element:i.titleElement}static defaultObjectPropertiesSection(e,t,n,r){let i=document.createElement("span");i.classList.add("source-code");let o=w.UIUtils.createShadowRootWithCoreStyles(i,{cssFile:$}),l=s.createPropertyValue(e,!1,!0);o.appendChild(l);let p=new s(e,i,t,void 0,!r);return n&&p.skipProto(),p}static compareProperties(e,t,n=!0){if(e instanceof O&&(e=e.property),t instanceof O&&(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 r=e.name,i=t.name;return r.startsWith("_")&&!i.startsWith("_")?1:i.startsWith("_")&&!r.startsWith("_")?-1:C.StringUtilities.naturalOrderComparator(r,i)}return 0}static createNameElement(e,t){let n=document.createElement("span");if(n.classList.add("name"),e===null)return n;let r=C.StringUtilities.escapeUnicodeAsText(e);if(/^\s|\s$|^$|\n/.test(r))return n.textContent=`"${r.replace(/\n/g,"\u21B5")}"`,n;if(t){let i=document.createElement("span");return i.classList.add("private-property-hash"),i.textContent=r[0],n.appendChild(i),n.appendChild(document.createTextNode(r.substring(1))),n}return n.textContent=r,n}static valueElementForFunctionDescription(e,t,n,r){let i=(c,u)=>{let a=c.replace(/^function [gs]et /,"function ").replace(/^function [gs]et\(/,"function(").replace(/^[gs]et /,""),m=a.match(/^(async\s+function)/),f=a.startsWith("function*"),g=a.startsWith("*"),j=!f&&a.startsWith("function"),ee=a.startsWith("class ")||a.startsWith("class{"),G=a.indexOf("=>"),y=!m&&!f&&!j&&!ee&&G>0;if(ee){let P=a.substring(5),T=/^[^{\s]+/.exec(P.trim()),te=u;return T&&(te=T[0].trim()||u),{prefix:"class",body:P,abbreviation:te}}if(m){let P=a.substring(m[1].length);return{prefix:"async \u0192",body:P,abbreviation:d(P)}}if(f){let P=a.substring(9);return{prefix:"\u0192*",body:P,abbreviation:d(P)}}if(g){let P=a.substring(1);return{prefix:"\u0192*",body:P,abbreviation:d(P)}}if(j){let P=a.substring(8);return{prefix:"\u0192",body:P,abbreviation:d(P)}}if(y){let T=a;return u?T=u+"()":a.length>60&&(T=a.substring(0,G+2)+" {\u2026}"),{prefix:"",body:a,abbreviation:T}}return{prefix:"\u0192",body:a,abbreviation:d(a)}},{prefix:o,body:l,abbreviation:p}=i(e??"",n??"");return x`<span
      class="object-value-function ${r??""}"
      title=${C.StringUtilities.trimEndWithMaxLength(e??"",500)}>${o&&x`<span class=object-value-function-prefix>${o} </span>`}${t?C.StringUtilities.trimEndWithMaxLength(l.trim(),200):p.replace(/\n/g," ")}</span>`;function d(c){let u=c.indexOf("("),a=c.match(/\)\s*{/);if(u!==-1&&a?.index!==void 0&&a.index>u){let m=c.substring(0,u).trim()||(n??""),f=c.substring(u,a.index+1);return m+f}return n+"()"}}static createPropertyValueWithCustomSupport(e,t,n,r,i,o,l){if(e.customPreview()){let p=new H(e).element;return p.classList.add("object-properties-section-custom-section"),p}return s.createPropertyValue(e,t,n,r,i,o,l)}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(),R.Revealer.reveal(new E.RemoteObject.LinearMemoryInspectable(e,t))}}
      jslog=${pe.action("open-memory-inspector").track({click:!0})}
      title=${v(b.openInMemoryInpector)}
      aria-label=${v(b.openInMemoryInpector)}></devtools-icon>`:ce}static appendMemoryIcon(e,t,n){let r=document.createDocumentFragment();V(s.getMemoryIcon(t,n),r),e.appendChild(r)}static createPropertyValue(e,t,n,r,i=!1,o,l){let p=document.createDocumentFragment(),h=e.type,d=e.subtype,c=e.description||"",u=e.className,a=()=>{if(h==="object"&&d==="internal#location"){let g=e.debuggerModel().createRawLocationByScriptId(e.value.scriptId,e.value.lineNumber,e.value.columnNumber);return g&&r?x`${r.linkifyRawLocation(g,C.DevToolsPath.EmptyUrlString,"value")}`:x`<span class=value title=${z(c||void 0)}>${"<"+v(b.unknown)+">"}</span>`}if(h==="string"&&typeof c=="string"){let g=C.StringUtilities.escapeUnicodeAsText(JSON.stringify(c)),j=c.length>X;return x`<span class="value object-value-string" title=${z(j?void 0:c)}>${j?ye(A,{text:g}):g}</span>`}if(h==="object"&&d==="trustedtype"){let g=`${u} "${c}"`,j=g.length>X;return x`<span class="value object-value-trustedtype" title=${z(j?void 0:g)}>${j?ye(A,{text:g}):oe(c,u)}</span>`}if(h==="function")return s.valueElementForFunctionDescription(c,void 0,void 0,"value");if(h==="object"&&d==="node"&&c)return x`<span class="value object-value-node"
            @click=${g=>{R.Revealer.reveal(e),g.consume(!0)}}
            @mousemove=${()=>E.OverlayModel.OverlayModel.highlightObjectAsDOMNode(e)}
            @mouseleave=${()=>E.OverlayModel.OverlayModel.hideDOMNodeHighlight(E.TargetManager.TargetManager.instance())}
          >${se(c)}</span>`;if(c.length>X)return x`<span class="value object-value-${d||h}" title=${c}>
          ${ye(A,{text:c})}
        </span>`;let f=e.preview&&n;return x`<span class="value object-value-${d||h}" title=${c}>${f?new N().renderObjectPreview(e.preview,l):c}${i?ce:this.getMemoryIcon(e,o)}</span>`};t?V(x`<span class="error value">${De.getFormatLocalizedStringTemplate(He,b.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,r){return e.debuggerModel().functionDetailsPromise(e).then(i);function i(o){n&&o?.location&&(t.classList.add("linkified"),t.addEventListener("click",()=>(R.Revealer.reveal(o.location),!1)));let l=r?"":"anonymous";o?.functionName&&(l=o.functionName);let p=document.createDocumentFragment();V(s.valueElementForFunctionDescription(e.description,r,l),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 w.ContextMenu.ContextMenu(e);t.appendApplicableItems(this.root),this.root.object instanceof E.RemoteObject.LocalJSONObject&&(t.viewSection().appendItem(v(b.expandRecursively),this.#e.expandRecursively.bind(this.#e,he),{jslogContext:"expand-recursively"}),t.viewSection().appendItem(v(b.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()}},ft=100,X=1e4,Y=class extends w.TreeOutline.TreeOutlineInShadow{constructor(){super(),this.registerRequiredCSS($,q),this.contentElement.classList.add("source-code"),this.contentElement.classList.add("object-properties-section")}};function Be(s,e,t,n,r,i){if(s.appendApplicableItems(e.object),e.object instanceof E.RemoteObject.LocalJSONObject){let{value:o}=e.object,l=typeof o=="object"?C.StringUtilities.escapeUnicodeAsText(JSON.stringify(o,null,2)):o,p=()=>{L.userMetrics.actionTaken(L.UserMetrics.Action.NetworkPanelCopyValue),L.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(l)};s.clipboardSection().appendItem(v(b.copyValue),p,{jslogContext:"copy-value"})}s.viewSection().appendItem(v(b.expandRecursively),t,{jslogContext:"expand-recursively"}),s.viewSection().appendItem(v(b.collapseChildren),n,{jslogContext:"collapse-children"}),e.isWasm||s.viewSection().appendCheckboxItem(v(b.sortPropertiesAlphabetically),r,{checked:e.sortPropertiesAlphabetically,jslogContext:"sort-properties-alphabetically"}),s.viewSection().appendCheckboxItem(v(b.showAll),i,{checked:e.includeNullOrUndefinedValues,jslogContext:"show-all"})}function Ge(s,e,t,n={}){let r=ve.get(s);if(r&&r.linkifier===e)return x`
      <ul class=${ae(n)} role="group">
        ${r.nodes.map(o=>x`<devtools-tree-wrapper .treeElement=${o}></devtools-tree-wrapper>`)}
      </ul>
    `;let i=(async()=>{await I.populateChildrenIfNeeded(s);let o=Array.from(I.createNodes(s,!1,!1,e,t));ve.set(s,{linkifier:e,nodes:o});let l=()=>{ve.delete(s),s.removeEventListener("children-changed",l)};return s.addEventListener("children-changed",l),x`
      <ul class=${ae(n)} role="group">
        ${o.map(p=>x`<devtools-tree-wrapper .treeElement=${p}></devtools-tree-wrapper>`)}
      </ul>
    `})();return ut(i,x`<ul class=${ae(n)} role="group"></ul>`)}function gt(s,e,t){return Ge(s,e,t,{"source-code":!0,"object-properties-section":!0})}function bt(s,e,t){let n=Ge(s,t,void 0,{});return x`<devtools-tree class="object-properties-section" show-selection-on-keyboard-focus .template=${x`
    <ul role="tree" class="source-code object-properties-section">
      <style>${$}</style>
      <style>${q}</style>
      <li role="treeitem" class="object-properties-section-root-element" ?open=${s.expanded}>
        ${e}
        ${n}
      </li>
    </ul>
  `}></devtools-tree>`}var je=class extends w.TreeOutline.TreeElement{object;linkifier;emptyPlaceholder;toggleOnClick;constructor(e,t,n){let r=document.createElement("slot");super(r),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 w.ContextMenu.ContextMenu(e);Be(t,this.object,this.expandRecursively.bind(this,he),this.collapseChildren.bind(this),()=>{this.object.sortPropertiesAlphabetically=!this.object.sortPropertiesAlphabetically},()=>{this.object.includeNullOrUndefinedValues=!this.object.includeNullOrUndefinedValues}),t.show()}async onpopulate(){this.removeChildren();let e=this.treeOutline,t=e?!!e.skipProtoInternal:!1;return await I.populate(this,this.object,t,!1,this.linkifier,this.emptyPlaceholder)}},Ke=200,Je=(s,e,t)=>{let{property:n}=s.node,r=n.synthetic&&s.node.name==="[[Entries]]",i=`completions-${s.node.parent?.object?.objectId?.replaceAll(".","-")}-${s.node.name}`,o=async y=>{y.target instanceof w.TextPrompt.TextPromptElement&&s.onAutoComplete(y.detail.expression,y.detail.filter,y.detail.force)},l=ae({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=!r&&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),d=s.search,c=d?.getResults(s.node),u=d?.currentMatch(),a=u?.node===s.node,m=a&&u?.matchType==="name"?u.range.cssValue():"",f=a&&u?.matchType==="value"?u.range.cssValue():"",g=(c??[]).filter(y=>y!==u&&y.matchType==="name").map(y=>y.range.cssValue()).join(" "),j=(c??[]).filter(y=>y!==u&&y.matchType==="value").map(y=>y.range.cssValue()).join(" "),ee=()=>{let y=Ne(P=>{e.valueElement=P});if(r)return x`<span ${y} class=value></span>`;if(n.value){let P=n.name!=="[[Prototype]]",T=S.createPropertyValueWithCustomSupport(n.value,n.wasThrown,P,s.linkifier,n.synthetic,s.node.path,s.node.includeNullOrUndefinedValues);return e.valueElement=T,T}if(n.getter){let P=n.getter,T=te=>{te.consume(),s.invokeGetter(P)};return x`<span ${y}><span
        class=object-value-calculate-value-button
        title=${v(b.invokePropertyGetter)}
        @click=${T}
        >${v(b.dots)}</span></span>`}return x`<span ${y}
        class=object-value-unavailable
        title=${v(b.valueNotAccessibleToTheDebugger)}>${v(b.valueUnavailable)}</span>`},G=y=>{y instanceof KeyboardEvent&&!C.KeyboardUtilities.isEnterOrSpaceKey(y)||(y.consume(!0),s.editable&&n.value&&!n.value.customPreview()&&(n.writable||n.setter)&&s.startEditing())};V(x`<span class=name-and-value><span
          ${Ne(y=>{e.nameElement=y})}
          class=${l}
          title=${s.node.path}><devtools-highlight ranges=${g} current-range=${m}>${n.private?x`<span class="private-property-hash">${n.name[0]}</span>${n.name.substring(1)}`:p}</devtools-highlight></span>${r?ce:x`<span class='separator'>: </span><devtools-prompt
                @commit=${y=>s.editingCommitted(y.detail)}
                @cancel=${()=>s.editingEnded()}
                @beforeautocomplete=${o}
                @dblclick=${G}
                @keydown=${G}
                completions=${i}
                placeholder=${v(b.stringIsTooLargeToEdit)}
                ?editing=${s.editing}>
                  <devtools-highlight ranges=${j} current-range=${f}>${s.expanded&&h&&n.value?x`<span
                      class="value object-value-${n.value.subtype||n.value.type}"
                      title=${z(n.value.description)}>${n.value.description==="Object"?"":C.StringUtilities.trimMiddle(n.value.description??"",X)}${n.synthetic?ce:S.getMemoryIcon(n.value)}</span>`:ee()}</devtools-highlight>
                  <datalist id=${i}>${ht(s.completions,y=>x`<option>${y}</option>`)}</datalist>
                </devtools-prompt></span>`}</span>`,t)},de=class extends w.Widget.Widget{#e=[];#t;#n;#r;#i=[];#s=!1;#p;#a=!1;#l;#c=!1;#o;constructor(e,t=Je){super(e),this.#p=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.#o?.removeEventListener("SearchChanged",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.#o=e.search,this.#o?.addEventListener("SearchChanged",this.requestUpdate,this),this.requestUpdate()}get expanded(){return this.#a}set expanded(e){this.#a=e,this.requestUpdate()}get linkifier(){return this.#l}set linkifier(e){this.#l=e,this.requestUpdate()}get editable(){return this.#c}set editable(e){this.#c=e,this.requestUpdate()}performUpdate(){if(!this.#t)return;let e={editable:this.#c,expanded:this.#a,editing:this.#s,editingEnded:this.#h.bind(this),editingCommitted:this.#m.bind(this),node:this.#t,linkifier:this.#l,completions:this.#s?this.#i:[],onAutoComplete:this.#u.bind(this),invokeGetter:this.#f.bind(this),startEditing:this.startEditing.bind(this),search:this.#o},t=this,n={set nameElement(r){t.#n=r},set valueElement(r){t.#r=r}};this.#p(e,n,this.element)}setSearchRegex(e,t){let n=B.highlightedSearchResultClassName;return t&&(n+=" "+t),this.revertHighlightChanges(),this.#n&&this.#d(e,this.#n,n),this.property?.object&&this.property?.object.type!=="object"&&this.#r&&this.#d(e,this.#r,n),!!this.#e.length}#d(e,t,n){let r=[],i=t.textContent||"";e.lastIndex=0;let o=e.exec(i);for(;o;)r.push(new le.TextRange.SourceRange(o.index,o[0].length)),o=e.exec(i);r.length&&B.highlightRangesWithStyleClass(t,r,n,this.#e)}revertHighlightChanges(){B.revertDomChanges(this.#e),this.#e=[]}async#u(e,t,n){let r=await Fe.JavaScript.completeInContext(e,t,n);this.#i=r.map(i=>i.text),this.requestUpdate()}get editing(){return this.#s}startEditing(){this.#s=!0,this.requestUpdate()}#h(){this.#i=[],this.#s=!1,this.requestUpdate()}async#m(e){this.#h(),await this.#t?.setValue(e)}#f(e){this.#t?.invokeGetter(e)}},I=class s extends w.TreeOutline.TreeElement{property;toggleOnClick;linkifier;maxNumPropertiesToShow;#e;constructor(e,t){super(),this.#e=new de,this.#e.markAsRoot(),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.#r,this),this.property.addEventListener("expanded-changed",this.#i,this),this.toggleOnClick=!0,this.linkifier=t,this.maxNumPropertiesToShow=Ke,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,r,i,o){await s.populateChildrenIfNeeded(t),s.populateImpl(e,t,n,r,i,o)}static async populateChildrenIfNeeded(e){let t=await e.populateChildrenIfNeeded();await M.populateChildrenIfNeeded(t)}static populateImpl(e,t,n,r,i,o){for(let l of s.createNodes(t,n,r,i,o,p=>e instanceof s&&!S.isDisplayableProperty(p,e.property?.property)))e.appendChild(l)}static*createNodes(e,t,n,r,i,o){let l=e.children;l&&(l.arrayRanges?yield*M.createNodes(l,r,o):yield*s.createPropertyNodes(l,t,n,r,i,o))}static*createPropertyNodes({properties:e,internalProperties:t,accessors:n,arrayRanges:r},i,o,l,p,h){let d=!0;r&&r.length>0&&(d=!1);let c=e?.[0]?.parent?.sortPropertiesAlphabetically??!0;e?.sort((a,m)=>S.compareProperties(a,m,c));let u=t?.find(({property:a})=>a.name==="[[Entries]]");if(u){let a=new s(u,l);a.setExpandable(!0),a.expand(),d=!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,l);a.property.name==="memories"&&a.object?.className==="Memories"&&(f.updateExpandable(),f.isExpandable()&&f.expand()),d=!1,yield f}}for(let a of n??[])yield new s(a,l);for(let a of t??[]){let m=new s(a,l);a.property.name!=="[[Entries]]"&&(a.property.name==="[[Prototype]]"&&i||(d=!1,yield m))}if(d){let a=document.createElement("div");a.classList.add("gray-info-message"),a.textContent=p||v(b.noProperties),yield new w.TreeOutline.TreeElement(a)}}static populateWithProperties(e,t,n,r,i,o){for(let l of this.createPropertyNodes(t,n,r,i,o,p=>e instanceof s&&!S.isDisplayableProperty(p,e.property?.property)))e.appendChild(l)}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=v(b.dots),w.Tooltip.Tooltip.install(e,v(b.showAllD,{PH1:this.childCount()}));let t=this.children();for(let r=this.maxNumPropertiesToShow;r<this.childCount();++r)t[r].hidden=!0;let n=new w.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.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()}#r(){this.hidden=this.property.isFiltered}#i(e){e.data?this.expand():this.collapse()}getContextMenu(e){let t=new w.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 E.RemoteObject.LocalJSONObject)){let{object:{value:r}}=this.property,i=typeof r=="object"?C.StringUtilities.escapeUnicodeAsText(JSON.stringify(r,null,2)):r,o=()=>{L.userMetrics.actionTaken(L.UserMetrics.Action.NetworkPanelCopyValue),L.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(i)};t.clipboardSection().appendItem(v(b.copyValue),o,{jslogContext:"copy-value"})}if(!this.property.property.synthetic&&this.property.path){let r=L.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(L.InspectorFrontendHost.InspectorFrontendHostInstance,this.property.path);t.clipboardSection().appendItem(v(b.copyPropertyPath),r,{jslogContext:"copy-property-path"})}this.property.parent?.object instanceof E.RemoteObject.LocalJSONObject&&(t.viewSection().appendItem(v(b.expandRecursively),this.expandRecursively.bind(this,he),{jslogContext:"expand-recursively"}),t.viewSection().appendItem(v(b.collapseChildren),this.collapseChildren.bind(this),{jslogContext:"collapse-children"}));let n=this.property;for(;n.parent;)n=n.parent;return n.isWasm||t.viewSection().appendCheckboxItem(v(b.sortPropertiesAlphabetically),()=>{n.sortPropertiesAlphabetically=!n.sortPropertiesAlphabetically},{checked:n.sortPropertiesAlphabetically,jslogContext:"sort-properties-alphabetically"}),t.viewSection().appendCheckboxItem(v(b.showAll),()=>{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 qe(s,e,t){return await s.callFunctionJSON(n,[{value:e},{value:t},{value:M.bucketThreshold},{value:M.sparseIterationThreshold}]);function n(r,i,o,l){if(r===void 0||i===void 0||l===void 0||o===void 0)return;let p=null,h=i-r>=l&&ArrayBuffer.isView(this);function*d(m){if(!(r===void 0||i===void 0||l===void 0))if(i-r<l)for(let f=r;f<=i;++f)f in m&&(yield f);else{p=p||Object.getOwnPropertyNames(m);for(let f=0;f<p.length;++f){let g=p[f],j=Number(g)>>>0;String(j)===g&&r<=j&&j<=i&&(yield j)}}}let c=0;if(h)c=i-r+1;else for(let m of d(this))++c;let u=c;c<=o?u=c:u=Math.pow(o,Math.ceil(Math.log(c)/Math.log(o))-1);let a=[];if(h)for(let m=r;m<=i;m+=u){let f=m,g=f+u-1;g>i&&(g=i),a.push([f,g,g-f+1])}else{c=0;let m=-1,f=0;for(let g of d(this))m===-1&&(m=g),f=g,++c===u&&(a.push([m,f,c]),c=0,m=-1);c>0&&a.push([m,f,c])}return{ranges:a}}}function yt(s,e,t){let n=Object.create(null);if(!(s===void 0||e===void 0||t===void 0)){if(e-s<t)for(let r=s;r<=e;++r)r in this&&(n[r]=this[r]);else{let r=Object.getOwnPropertyNames(this);for(let i=0;i<r.length;++i){let o=r[i],l=Number(o)>>>0;String(l)===o&&s<=l&&l<=e&&(n[l]=this[l])}}return n}}var M=class s extends w.TreeOutline.TreeElement{toggleOnClick;linkifier;#e;constructor(e,t){super(C.StringUtilities.sprintf("[%d \u2026 %d]",e.range.fromIndex,e.range.toIndex),!0),this.#e=e,this.#e.addEventListener("children-changed",this.onpopulate,this),this.#e.addEventListener("expanded-changed",this.#t,this),this.toggleOnClick=!0,this.linkifier=t,e.expanded&&this.expand()}#t(e){e.data?this.expand():this.collapse()}static*createNodes(e,t,n){if(e.arrayRanges){if(e.arrayRanges.length===1)yield*I.createNodes(e.arrayRanges[0],!1,!1,t,null,n);else for(let r of e.arrayRanges)r.singular?yield*I.createNodes(r,!1,!1,t,null,n):yield new s(r,t);yield*I.createPropertyNodes(e,!1,!1,t,null,n)}}static async populateChildrenIfNeeded(e){e.arrayRanges&&(e.arrayRanges.length===1?await I.populateChildrenIfNeeded(e.arrayRanges[0]):await Promise.all(e.arrayRanges.filter(t=>t.singular).map(t=>I.populateChildrenIfNeeded(t))))}onexpand(){this.#e.expanded=!0}oncollapse(){this.#e.expanded=!1}async onpopulate(){this.removeChildren(),await I.populate(this,this.#e,!1,!1,this.linkifier)}onattach(){this.listItemElement.classList.add("object-properties-section-name")}static bucketThreshold=100;static sparseIterationThreshold=25e4},xe,Ce=class s{static instance(e={forceNew:!1}){let{forceNew:t}=e;return(!xe||t)&&(xe=new s),xe}async render(e,t){if(!(e instanceof E.RemoteObject.RemoteObject))throw new Error("Can't render "+e);let n=t?.title,r=new S(e,n,void 0,void 0,!!t?.editable);n||r.titleLessMode(),t?.expand&&r.firstChild()?.expand();let i=()=>{r.element.dispatchEvent(new CustomEvent("dimensionschanged"))};return r.addEventListener(w.TreeOutline.Events.ElementAttached,i),r.addEventListener(w.TreeOutline.Events.ElementExpanded,i),r.addEventListener(w.TreeOutline.Events.ElementCollapsed,i),{element:r.element,forceSelect:r.forceSelect.bind(r)}}},ze=(s,e,t)=>{let n=_.ByteUtilities.bytesToString(s.byteCount),r=s.text.length<A.MAX_DISPLAYABLE_TEXT_LENGTH,i=l=>{let{target:p}=l;if(!(p instanceof Element))return;let h=p.closest("li"),d=h&&w.TreeOutline.TreeElement.getTreeElementBylistItemNode(h);if(!(d instanceof I))return;let c=d.getContextMenu(l);r&&!s.expanded&&c.clipboardSection().appendItem(v(b.showMoreS,{PH1:n}),s.expandText,{jslogContext:"show-more"}),c.clipboardSection().appendItem(v(b.copy),s.copyText,{jslogContext:"copy"}),c.show(),l.consume(!0)},o=s.text.slice(0,s.maxLength);V(x`<span title=${o+"\u2026"} @contextmenu=${i}>
               ${s.expanded?s.text:o}
               <button
                 ?hidden=${s.expanded}
                 @click=${r?s.expandText:void 0}
                 jslog=${z(r?pe.action("expand").track({click:!0}):void 0)}
                 class=${r?"expandable-inline-button":"undisplayable-text"}
                 data-text=${r?v(b.showMoreS,{PH1:n}):v(b.longTextWasTruncatedS,{PH1:n})}
                 ></button>
               <button
                 class=expandable-inline-button
                 @click=${s.copyText}
                 data-text=${v(b.copy)}
                 jslog=${pe.action("copy").track({click:!0})}
                 ></button>
              </span>`,t)},A=class s extends w.Widget.Widget{static MAX_DISPLAYABLE_TEXT_LENGTH=1e7;static EXPANDABLE_MAX_LENGTH=50;#e="";#t=0;#n=!1;#r=s.EXPANDABLE_MAX_LENGTH;#i;constructor(e,t=ze){super(e),this.#i=t}set text(e){this.#e=e,this.#t=C.StringUtilities.countWtf8Bytes(e),this.requestUpdate()}set maxLength(e){this.#r=e,this.requestUpdate()}performUpdate(){let e={copyText:()=>L.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(this.#e),expandText:()=>{this.#n||(this.#n=!0,this.requestUpdate())},expanded:this.#n,byteCount:this.#t,maxLength:this.#r,text:this.#e};this.#i(e,{},this.contentElement)}};var Ye={showAsJavascriptObject:"Show as JavaScript object"},xt=Ee.i18n.registerUIStrings("ui/legacy/components/object_ui/CustomPreviewComponent.ts",Ye),wt=Ee.i18n.getLocalizedString.bind(void 0,xt),ue=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(r){Q.Console.Console.instance().error("Broken formatter: header is invalid json "+r);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=vt("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(!Pt.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 r=e.shift();for(let i in r){let o=r[i];i!=="style"||typeof o!="string"||n.setAttribute(i,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 r=S.defaultObjectPresentation(n);return r.classList.toggle("custom-expandable-section-standard-section",n.hasChildren),r}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 Y,this.defaultBodyTreeOutline.setShowSelectionOnKeyboardFocus(!0,!1),this.defaultBodyTreeOutline.element.classList.add("custom-expandable-section-default-body"),I.populate(this.defaultBodyTreeOutline.rootElement(),new F(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()}}},Pt=["span","div","ol","li","table","tr","td"],H=class{object;customPreviewSection;element;constructor(e){this.object=e,this.customPreviewSection=new ue(e),this.element=document.createElement("span"),this.element.classList.add("source-code");let t=me.UIUtils.createShadowRootWithCoreStyles(this.element,{cssFile:Ie});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 me.ContextMenu.ContextMenu(e);this.customPreviewSection&&t.revealSection().appendItem(wt(Ye.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(S.defaultObjectPresentation(this.object)))}};var rt={};K(rt,{ObjectPopoverHelper:()=>Se});import*as Oe from"./../../../../core/i18n/i18n.js";import*as Qe from"./../../../../core/platform/platform.js";import*as Z from"./../../../../core/sdk/sdk.js";import*as Ze from"./../../../../models/geometry/geometry.js";import{Link as jt}from"./../../../kit/kit.js";import{render as Ct}from"./../../../lit/lit.js";import*as et from"./../../legacy.js";import*as tt from"./../utils/utils.js";var fe=`.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 nt={learnMore:"Learn more"},Et=Oe.i18n.registerUIStrings("ui/legacy/components/object_ui/ObjectPopoverHelper.ts",nt),St=Oe.i18n.getLocalizedString.bind(void 0,Et),Se=class s{linkifier;resultHighlightedAsDOM;constructor(e,t){this.linkifier=e,this.resultHighlightedAsDOM=t}dispose(){this.resultHighlightedAsDOM&&Z.OverlayModel.OverlayModel.hideDOMNodeHighlight(Z.TargetManager.TargetManager.instance()),this.linkifier&&this.linkifier.dispose()}static async buildObjectPopover(e,t){let n=Qe.StringUtilities.trimEndWithMaxLength(e.description||"",Ot),r=null;if(e.type==="function"||e.type==="object"){let o=null,l=!1;if(e.subtype==="node"&&(Z.OverlayModel.OverlayModel.highlightObjectAsDOMNode(e),l=!0),e.customPreview()){let p=new H(e);p.expandIfPossible(),r=p.element}else{r=document.createElement("div"),r.classList.add("object-popover-content"),t.registerRequiredCSS($,fe);let p=r.createChild("div","object-popover-title");e.type==="function"?(p.classList.add("source-code"),Ct(S.valueElementForFunctionDescription(e.description),p)):(p.classList.add("monospace"),p.createChild("span").textContent=n),o=new tt.Linkifier.Linkifier;let h=new S(e,"",o,!0);h.element.classList.add("object-popover-tree"),h.titleLessMode(),r.appendChild(h.element)}return r.dataset.stableNameForTest="object-popover-content",t.setMaxContentSize(new Ze.Size(300,250)),t.setSizeBehavior("SetExactSize"),t.contentElement.appendChild(r),new s(o,l)}r=document.createElement("span"),r.dataset.stableNameForTest="object-popover-content",t.registerRequiredCSS($,fe);let i=r.createChild("span","monospace object-value-"+e.type);return i.style.whiteSpace="pre",e.type==="string"?et.UIUtils.createTextChildren(i,`"${n}"`):i.textContent=n,t.contentElement.appendChild(r),new s(null,!1)}static buildDescriptionPopover(e,t,n){let r=document.createElement("div");r.classList.add("object-popover-description-box");let i=document.createElement("div");i.dataset.stableNameForTest="object-popover-content",n.registerRequiredCSS(fe),i.textContent=e;let o=jt.create(t,St(nt.learnMore),void 0,"learn-more"),l=document.createElement("div");return l.classList.add("object-popover-footer"),l.appendChild(o),r.appendChild(i),r.appendChild(l),n.contentElement.appendChild(r),new s(null,!1)}},Ot=1e4;export{_e as CustomPreviewComponent,Ue as JavaScriptREPL,rt as ObjectPopoverHelper,Xe as ObjectPropertiesSection,ke as RemoteObjectPreviewFormatter};
//# sourceMappingURL=object_ui.js.map
