import{Settings as e}from"../common/common.js";import{ls as o}from"../platform/platform.js";import{Runtime as t}from"../root/root.js";import{ViewManager as i,ActionRegistration as r}from"../ui/ui.js";let a;async function n(){return a||(await t.Runtime.instance().loadModulePromise("profiler"),a=await import("./profiler.js")),a}function l(e){return void 0===a?[]:e(a)}i.registerViewExtension({location:"panel",id:"heap_profiler",commandPrompt:"Show Memory",title:()=>o`Memory`,order:60,loadView:async()=>(await n()).HeapProfilerPanel.HeapProfilerPanel.instance()}),i.registerViewExtension({location:"drawer-view",id:"live_heap_profile",commandPrompt:"Show Live Heap Profile",title:()=>o`Live Heap Profile`,persistence:"closeable",order:100,loadView:async()=>(await n()).LiveHeapProfileView.LiveHeapProfileView.instance(),experiment:t.ExperimentName.LIVE_HEAP_PROFILE}),r.registerActionExtension({actionId:"live-heap-profile.toggle-recording",iconClass:"largeicon-start-recording",toggleable:!0,toggledIconClass:"largeicon-stop-recording",toggleWithRedColor:!0,loadActionDelegate:async()=>(await n()).LiveHeapProfileView.ActionDelegate.instance(),category:r.ActionCategory.MEMORY,experiment:t.ExperimentName.LIVE_HEAP_PROFILE,options:[{value:!0,title:()=>o`Start recording heap allocations`},{value:!1,title:()=>o`Stop recording heap allocations`}]}),r.registerActionExtension({actionId:"live-heap-profile.start-with-reload",iconClass:"largeicon-refresh",loadActionDelegate:async()=>(await n()).LiveHeapProfileView.ActionDelegate.instance(),category:r.ActionCategory.MEMORY,experiment:t.ExperimentName.LIVE_HEAP_PROFILE,title:()=>o`Start recording heap allocations and reload the page`}),r.registerActionExtension({actionId:"profiler.heap-toggle-recording",category:r.ActionCategory.MEMORY,iconClass:"largeicon-start-recording",title:()=>o`Start/stop recording`,toggleable:!0,toggledIconClass:"largeicon-stop-recording",toggleWithRedColor:!0,contextTypes:()=>l((e=>[e.HeapProfilerPanel.HeapProfilerPanel])),loadActionDelegate:async()=>(await n()).HeapProfilerPanel.HeapProfilerPanel.instance(),bindings:[{platform:"windows,linux",shortcut:"Ctrl+E"},{platform:"mac",shortcut:"Meta+E"}]}),r.registerActionExtension({actionId:"profiler.js-toggle-recording",category:r.ActionCategory.JAVASCRIPT_PROFILER,title:()=>o`Start/stop recording`,iconClass:"largeicon-start-recording",toggleable:!0,toggledIconClass:"largeicon-stop-recording",toggleWithRedColor:!0,contextTypes:()=>l((e=>[e.ProfilesPanel.JSProfilerPanel])),loadActionDelegate:async()=>(await n()).ProfilesPanel.JSProfilerPanel.instance(),bindings:[{platform:"windows,linux",shortcut:"Ctrl+E"},{platform:"mac",shortcut:"Meta+E"}]}),e.registerSettingExtension({category:e.SettingCategoryObject.PERFORMANCE,title:()=>o`Show native functions in JS Profile`,settingName:"showNativeFunctionsInJSProfile",settingType:e.SettingTypeObject.BOOLEAN,defaultValue:!0});
