var bt=Object.defineProperty;var u=(r,e)=>{for(var t in e)bt(r,t,{get:e[t],enumerable:!0})};var We={};u(We,{DEFAULT_VIEW:()=>Ae,PlayerEventsView:()=>L});import"./../../ui/legacy/components/data_grid/data_grid.js";import*as ne from"./../../core/i18n/i18n.js";import*as ae from"./../../ui/legacy/components/source_frame/source_frame.js";import*as oe from"./../../ui/legacy/legacy.js";import{Directives as wt,html as re,render as Et}from"./../../ui/lit/lit.js";import*as _e from"./../../ui/visual_logging/visual_logging.js";var ie=`devtools-data-grid.no-border-top-datagrid{border-top:0}devtools-data-grid.event-display-table-contents-table-container{height:100%}.event-display-table-basic-text-table-entry{line-height:26px}.event-display-table-contents-json-wrapper > devtools-widget.json-view{overflow:visible}.data-grid > .data-container > table.data{height:auto;table-layout:auto}
/*# sourceURL=${import.meta.resolve("./eventDisplayTable.css")} */`;var{widget:xt}=oe.Widget,{repeat:Pt}=wt,M={timestamp:"Timestamp",eventName:"Event name",value:"Value",eventDisplay:"Event display"},St=ne.i18n.registerUIStrings("panels/media/EventDisplayTable.ts",M),_=ne.i18n.getLocalizedString.bind(void 0,St),Ae=(r,e,t)=>{Et(re`
      <style>${ie}</style>
      <devtools-data-grid row-height='auto' autoscroll striped name=${_(M.eventDisplay)}
        class="event-display-table-contents-table-container no-border-top-datagrid"
        .template=${re`
          <style>${ie}</style>
          <table>
            <thead>
              <tr>
                <th id="display-timestamp" weight="1">${_(M.timestamp)}</th>
                <th id="event" weight="2">${_(M.eventName)}</th>
                <th id="value" weight="7">${_(M.value)}</th>
              </tr>
            </thead>
            <tbody>
              ${Pt(r.parsedEvents,s=>s,s=>re`
                <tr>
                  <td class="event-display-table-basic-text-table-entry">${s.displayTimestamp}</td>
                  <td class="event-display-table-basic-text-table-entry">${s.event}</td>
                  <td class="event-display-table-contents-json-wrapper">
                    ${xt(i=>new ae.JSONView.JSONView(new ae.JSONView.ParsedJSON(s.value,"",""),!0,i))}
                  </td>
                </tr>
              `)}
            </tbody>
          </table>
        `}>
      </devtools-data-grid>
    `,t)},L=class extends oe.Widget.VBox{firstEventTime;#e;#s=[];constructor(e=Ae){super({jslog:`${_e.pane("events")}`}),this.#e=e,this.firstEventTime=0,this.requestUpdate()}wasShown(){super.wasShown(),this.requestUpdate()}performUpdate(){let e={parsedEvents:this.#s};this.#e(e,void 0,this.contentElement)}onEvent(e){this.firstEventTime===0&&typeof e.timestamp=="number"&&(this.firstEventTime=e.timestamp),e=this.subtractFirstEventTime(e);let t=e.value;try{let s=JSON.parse(t);e.event=s.event,delete s.event,this.#s.push({displayTimestamp:e.displayTimestamp,event:e.event,value:s}),this.requestUpdate()}catch{}}subtractFirstEventTime(e){return typeof e.timestamp=="number"&&(e.displayTimestamp=(e.timestamp-this.firstEventTime).toFixed(3)),e}};var gt={};u(gt,{MainView:()=>Pe,PlayerDataDownloadManager:()=>Q});import*as Se from"./../../core/i18n/i18n.js";import*as Z from"./../../core/sdk/sdk.js";import*as ee from"./../../ui/legacy/legacy.js";var He={};u(He,{MediaModel:()=>f});import*as le from"./../../core/sdk/sdk.js";var f=class extends le.SDKModel.SDKModel{enabled;agent;constructor(e){super(e),this.enabled=!1,this.agent=e.mediaAgent(),e.registerMediaDispatcher(this)}async resumeModel(){if(!this.enabled)return await Promise.resolve();await this.agent.invoke_enable()}ensureEnabled(){this.agent.invoke_enable(),this.enabled=!0}playerPropertiesChanged(e){this.dispatchEventToListeners("PlayerPropertiesChanged",e)}playerEventsAdded(e){this.dispatchEventToListeners("PlayerEventsAdded",e)}playerMessagesLogged(e){this.dispatchEventToListeners("PlayerMessagesLogged",e)}playerErrorsRaised(e){this.dispatchEventToListeners("PlayerErrorsRaised",e)}playerCreated({player:e}){this.dispatchEventToListeners("PlayerCreated",e)}};le.SDKModel.SDKModel.register(f,{capabilities:262144,autostart:!1});var dt={};u(dt,{PlayerDetailView:()=>F});import*as we from"./../../core/i18n/i18n.js";import*as lt from"./../../ui/legacy/legacy.js";import*as pe from"./../../core/i18n/i18n.js";import*as Ze from"./../../ui/visual_logging/visual_logging.js";var qe={};u(qe,{ColdColorScheme:()=>H,Event:()=>A,HotColorScheme:()=>w,TickingFlameChart:()=>I});import*as W from"./../../core/common/common.js";import*as je from"./../../core/host/host.js";import*as ce from"./../../ui/legacy/components/perf_ui/perf_ui.js";import*as Ge from"./../../ui/legacy/legacy.js";import*as V from"./../../ui/legacy/theme_support/theme_support.js";var Oe={};u(Oe,{Bounds:()=>D,formatMillisecondsToSeconds:()=>b});function b(r,e){let t=Math.pow(10,3-e),s=Math.pow(10,Math.max(0,e));return`${Math.round(r/t)/s} s`}var D=class{#e;#s;#t;#i;maxRange;minRange;constructor(e,t,s,i){this.#e=e,this.#s=t,this.#t=this.#e,this.#i=this.#s,this.maxRange=s,this.minRange=i}get low(){return this.#t}get high(){return this.#i}get min(){return this.#e}get max(){return this.#s}get range(){return this.#i-this.#t}reassertBounds(){let e=!0;for(;e;){if(e=!1,this.range<this.minRange){e=!0;let t=(this.minRange-this.range)/2;this.#i+=t,this.#t-=t}this.#t<this.#e&&(e=!0,this.#t=this.#e),this.#i>this.#s&&(e=!0,this.#i=this.#s)}}zoomOut(e,t){let s=this.#i-this.#t,i=s*Math.pow(1.1,e)-s,n=i*t,d=i-n;this.#t-=n,this.#i+=d,this.reassertBounds()}zoomIn(e,t){let s=this.#i-this.#t;if(this.range<=this.minRange)return;let i=s-s/Math.pow(1.1,e),n=i*t,d=i-n;this.#t+=n,this.#i-=d,this.reassertBounds()}addMax(e){let t=this.#i-this.#t,s=this.#i===this.#s,i=this.#t===this.#e||t>=this.maxRange;this.#s+=e,s&&i&&(this.#i=this.#s),this.reassertBounds()}pushMaxAtLeastTo(e){return this.#s<e?(this.addMax(e-this.#s),!0):!1}};var Je="11px "+je.Platform.fontFamily();function Ke(){return V.ThemeSupport.instance().getComputedValue("--sys-color-on-surface")}var Tt=()=>({height:20,padding:2,collapsible:1,font:Je,color:Ke(),backgroundColor:"rgba(100 0 0 / 10%)",nestingLevel:0,itemsHeight:20,shareHeaderLine:!1,useFirstLineForOverview:!1,useDecoratorsForOverview:!1}),w=["#ffba08","#faa307","#f48c06","#e85d04","#dc2f02","#d00000","#9d0208"],H=["#7400b8","#6930c3","#5e60ce","#5390d9","#4ea8de","#48bfe3","#56cfe1","#64dfdf"];function ze(r){let e=W.Color.parse(r)?.as("hsl");return e&&e.l<.5?"#eee":"#444"}var A=class{timelineData;setLive;setComplete;updateMaxTime;selfIndex;#e;title;#s;#t;constructor(e,t,s={color:void 0,duration:void 0,level:0,name:"",startTime:0}){this.timelineData=e,this.setLive=t.setLive,this.setComplete=t.setComplete,this.updateMaxTime=t.updateMaxTime,this.selfIndex=this.timelineData.entryLevels.length,this.#e=!1;let i=s.duration===void 0?0:s.duration;this.timelineData.entryLevels.push(s.level||0),this.timelineData.entryStartTimes.push(s.startTime||0),this.timelineData.entryTotalTimes.push(i),i===-1&&(this.endTime=-1),this.title=s.name||"",this.#s=s.color||w[0],this.#t=ze(this.#s)}decorate(e){e.createChild("span").textContent=`Name: ${this.title}`,e.createChild("br");let t=b(this.startTime,2);if(this.#e)e.createChild("span").textContent=`Duration: ${t} - LIVE!`;else if(isNaN(this.duration))e.createChild("span").textContent=`Time: ${t}`;else{let s=b(this.duration+this.startTime,2);e.createChild("span").textContent=`Duration: ${t} - ${s}`}}set endTime(e){if(e===-1)this.timelineData.entryTotalTimes[this.selfIndex]=this.setLive(this.selfIndex),this.#e=!0;else{this.#e=!1;let t=e-this.timelineData.entryStartTimes[this.selfIndex];this.timelineData.entryTotalTimes[this.selfIndex]=t,this.setComplete(this.selfIndex),this.updateMaxTime(e)}}get id(){return this.selfIndex}set level(e){this.timelineData.entryLevels[this.selfIndex]=e}set color(e){this.#s=e,this.#t=ze(this.#s)}get color(){return this.#s}get fontColor(){return this.#t}get startTime(){return this.timelineData.entryStartTimes[this.selfIndex]}get duration(){return this.timelineData.entryTotalTimes[this.selfIndex]}get live(){return this.#e}},I=class extends Ge.Widget.VBox{intervalTimer;lastTimestamp;#e;ticking;isShown;bounds;dataProvider;delegate;chartGroupExpansionSetting;chart;stoppedPermanently;constructor(){super(),this.intervalTimer=0,this.lastTimestamp=0,this.#e=!0,this.ticking=!1,this.isShown=!1,this.bounds=new D(0,1e3,3e4,1e3),this.dataProvider=new he(this.bounds,this.updateMaxTime.bind(this)),this.delegate=new de,this.chartGroupExpansionSetting=W.Settings.Settings.instance().createSetting("media-flame-chart-group-expansion",{}),this.chart=new ce.FlameChart.FlameChart(this.dataProvider,this.delegate,this.chartGroupExpansionSetting),this.chart.disableRangeSelection(),this.chart.bindCanvasEvent("wheel",e=>{this.onScroll(e)}),this.chart.show(this.contentElement)}addMarker(e){e.duration=NaN,this.startEvent(e)}startEvent(e){e.duration===void 0&&(e.duration=-1);let t=e.startTime||0,s=this.dataProvider.startEvent(e);return this.updateMaxTime(t),s}addGroup(e,t){this.dataProvider.addGroup(e,t)}updateMaxTime(e){this.bounds.pushMaxAtLeastTo(e)&&this.updateRender()}onScroll(e){let t=Math.round(e.deltaY/50),s=e.offsetX/e.srcElement.clientWidth;t>0?this.bounds.zoomOut(t,s):this.bounds.zoomIn(-t,s),this.updateRender()}willHide(){super.willHide(),this.isShown=!1,this.ticking&&this.stop()}wasShown(){super.wasShown(),this.isShown=!0,this.#e&&!this.ticking&&this.start()}set canTick(e){this.#e=e,this.ticking&&!e&&this.stop(),!this.ticking&&this.isShown&&e&&this.start()}start(){this.lastTimestamp===0&&(this.lastTimestamp=Date.now()),!(this.intervalTimer!==0||this.stoppedPermanently)&&(this.intervalTimer=window.setInterval(this.updateRender.bind(this),16),this.ticking=!0)}stop(e=!1){window.clearInterval(this.intervalTimer),this.intervalTimer=0,e&&(this.stoppedPermanently=!0),this.ticking=!1}updateRender(){if(this.ticking){let e=Date.now(),t=e-this.lastTimestamp;this.lastTimestamp=e,this.bounds.addMax(t)}this.dataProvider.updateMaxTime(this.bounds),this.chart.setWindowTimes(this.bounds.low,this.bounds.high,!0),this.chart.scheduleUpdate()}},de=class{windowChanged(e,t,s){}updateRangeSelection(e,t){}updateSelectedGroup(e,t){}},he=class{updateMaxTimeHandle;bounds;liveEvents;eventMap;#e;maxLevel;constructor(e,t){this.updateMaxTimeHandle=t,this.bounds=e,this.liveEvents=new Set,this.eventMap=new Map,this.#e=ce.FlameChart.FlameChartTimelineData.createEmpty(),this.maxLevel=0}hasTrackConfigurationMode(){return!1}addGroup(e,t){if(this.#e.groups){let s={name:e,startLevel:this.maxLevel,expanded:!0,selectable:!1,style:Tt(),track:null};this.#e.groups.push(s),V.ThemeSupport.instance().addEventListener(V.ThemeChangeEvent.eventName,()=>{s.style.color=Ke()})}this.maxLevel+=t}startEvent(e){if(e.level=e.level||0,e.level>this.maxLevel)throw new Error(`level ${e.level} is above the maximum allowed of ${this.maxLevel}`);let t=new A(this.#e,{setLive:this.setLive.bind(this),setComplete:this.setComplete.bind(this),updateMaxTime:this.updateMaxTimeHandle},e);return this.eventMap.set(t.id,t),t}setLive(e){return this.liveEvents.add(e),this.bounds.max}setComplete(e){this.liveEvents.delete(e)}updateMaxTime(e){this.bounds=e;for(let t of this.liveEvents.entries())this.eventMap.get(t[0]).endTime=-1}maxStackDepth(){return this.maxLevel+1}timelineData(){return this.#e}minimumBoundary(){return this.bounds.low}totalTime(){return this.bounds.high}entryColor(e){return this.eventMap.get(e).color}textColor(e){return this.eventMap.get(e).fontColor}entryTitle(e){return this.eventMap.get(e).title}entryFont(e){return Je}decorateEntry(e,t,s,i,n,d,y,te,se){return!1}forceDecoration(e){return!1}preparePopoverElement(e){let t=document.createElement("div");return this.eventMap.get(e).decorate(t),t}formatValue(e,t){return e+=Math.round(this.bounds.low),this.bounds.range<2800?b(e,2):this.bounds.range<3e4?b(e,1):b(e,0)}canJumpToEntry(e){return!1}};var Xe=-1.5,me={playbackStatus:"Playback status",bufferingStatus:"Buffering status"},kt=pe.i18n.registerUIStrings("panels/media/EventTimelineView.ts",me),Ye=pe.i18n.getLocalizedString.bind(void 0,kt),O=class extends I{normalizedTimestamp;playbackStatusLastEvent;audioBufferingStateEvent;videoBufferingStateEvent;constructor(){super(),this.element.setAttribute("jslog",`${Ze.pane("timeline")}`),this.normalizedTimestamp=Xe,this.addGroup(Ye(me.playbackStatus),2),this.addGroup(Ye(me.bufferingStatus),2),this.playbackStatusLastEvent=null,this.audioBufferingStateEvent=null,this.videoBufferingStateEvent=null}ensureNoPreviousPlaybackEvent(e){this.playbackStatusLastEvent!==null&&(this.playbackStatusLastEvent.endTime=e,this.playbackStatusLastEvent=null)}onPlaybackEvent(e,t){switch(e.event){case"kPlay":this.canTick=!0,this.ensureNoPreviousPlaybackEvent(t),this.playbackStatusLastEvent=this.startEvent({level:0,startTime:t,name:"Play"});break;case"kPause":this.ensureNoPreviousPlaybackEvent(t),this.playbackStatusLastEvent=this.startEvent({level:0,startTime:t,name:"Pause",color:w[1]});break;case"kWebMediaPlayerDestroyed":this.canTick=!1,this.ensureNoPreviousPlaybackEvent(t),this.addMarker({level:1,startTime:t,name:"Destroyed",color:w[4]});break;case"kSuspended":this.canTick=!1,this.ensureNoPreviousPlaybackEvent(t),this.playbackStatusLastEvent=this.startEvent({level:1,startTime:t,name:"Suspended",color:w[3]});break;case"kEnded":this.ensureNoPreviousPlaybackEvent(t),this.playbackStatusLastEvent=this.startEvent({level:1,startTime:t,name:"Ended",color:w[2]});break;default:throw new Error(`_onPlaybackEvent cant handle ${e.event}`)}}bufferedEnough(e){return e.state==="BUFFERING_HAVE_ENOUGH"}onBufferingStatus(e,t){let s=null,i=null;if(e.event==="kBufferingStateChanged")s=e.value.audio_buffering_state,i=e.value.video_buffering_state,s&&(this.audioBufferingStateEvent!==null&&(this.audioBufferingStateEvent.endTime=t,this.audioBufferingStateEvent=null),this.bufferedEnough(s)||(this.audioBufferingStateEvent=this.startEvent({level:3,startTime:t,name:"Audio Buffering",color:H[1]}))),i&&(this.videoBufferingStateEvent!==null&&(this.videoBufferingStateEvent.endTime=t,this.videoBufferingStateEvent=null),this.bufferedEnough(i)||(this.videoBufferingStateEvent=this.startEvent({level:2,startTime:t,name:"Video Buffering",color:H[0]})));else throw new Error(`_onPlaybackEvent cant handle ${e.event}`)}onEvent(e){this.normalizedTimestamp===Xe&&(this.normalizedTimestamp=Number(e.timestamp));let t=(Number(e.timestamp)-this.normalizedTimestamp)*1e3;switch(e.event){case"kPlay":case"kPause":case"kWebMediaPlayerDestroyed":case"kSuspended":case"kEnded":return this.onPlaybackEvent(e,t);case"kBufferingStateChanged":return this.onBufferingStatus(e,t);default:}}};var et={};u(et,{PlayerMessagesView:()=>U});import"./../../ui/legacy/legacy.js";import*as ve from"./../../core/i18n/i18n.js";import*as c from"./../../ui/legacy/legacy.js";import{html as T,nothing as ge,render as Ct}from"./../../ui/lit/lit.js";import*as Qe from"./../../ui/visual_logging/visual_logging.js";var ue=`.media-messages-header{background-color:var(--sys-color-cdt-base-container);border-bottom:1px solid var(--sys-color-divider);min-height:26px}.media-messages-body{overflow-y:scroll}.media-messages-level-dropdown-element{height:18px;line-height:18px}.media-messages-level-dropdown-text{float:left}.media-messages-level-dropdown-checkbox{float:left;width:18px;height:100%;padding-left:2px}.media-messages-message-container{margin:4px;font-size:14px;line-height:18px;padding:4px;user-select:text}.media-messages-message-container + .media-messages-message-container{border-top:1px solid var(--sys-color-divider);&.media-message-warning,
  &.media-message-error{border:none}}.media-message-warning{border-radius:5px;background-color:var(--sys-color-surface-yellow);color:var(--sys-color-on-surface-yellow)}.media-message-error{border-radius:5px;background-color:var(--sys-color-surface-error);color:var(--sys-color-on-surface-error)}.media-messages-message-filtered{display:none}.media-messages-message-unselected{display:none}.status-error-box{font-family:var(--monospace-font-family);border:1px solid var(--sys-color-error-outline);border-radius:5px;padding:4px}.status-error-field-label{padding-right:10px;color:var(--sys-color-token-subtle)}.status-error-field-labeled{display:flex}
/*# sourceURL=${import.meta.resolve("./playerMessagesView.css")} */`;var h={default:"Default",custom:"Custom",all:"All",error:"Error",warning:"Warning",info:"Info",debug:"Debug",logLevel:"Log level:",filterByLogMessages:"Filter by log messages",errorGroupLabel:"Error group:",errorCodeLabel:"Error code:",errorDataLabel:"Data:",errorStackLabel:"Stack trace:",errorCauseLabel:"Caused by:"},Mt=ve.i18n.registerUIStrings("panels/media/PlayerMessagesView.ts",h),m=ve.i18n.getLocalizedString.bind(void 0,Mt),fe=class{items;view;itemMap;hiddenLevels;bitFieldValue;#e;customTitle;allTitle;elementsForItems;constructor(e,t){this.items=e,this.view=t,this.itemMap=new Map,this.hiddenLevels=[],this.bitFieldValue=7,this.#e=m(h.default),this.customTitle=m(h.custom),this.allTitle=m(h.all),this.elementsForItems=new WeakMap}defaultTitle(){return this.#e}setDefault(e){e.selectItem(this.items.at(0))}populate(){this.items.insert(this.items.length,{title:this.#e,overwrite:!0,stringValue:"",value:7}),this.items.insert(this.items.length,{title:this.allTitle,overwrite:!0,stringValue:"",value:15}),this.items.insert(this.items.length,{title:m(h.error),overwrite:!1,stringValue:"error",value:1}),this.items.insert(this.items.length,{title:m(h.warning),overwrite:!1,stringValue:"warning",value:2}),this.items.insert(this.items.length,{title:m(h.info),overwrite:!1,stringValue:"info",value:4}),this.items.insert(this.items.length,{title:m(h.debug),overwrite:!1,stringValue:"debug",value:8})}updateCheckMarks(){this.hiddenLevels=[];for(let[e,t]of this.itemMap)if(!t.overwrite){let s=this.elementsForItems.get(t);s?.firstChild&&s.firstChild.remove(),s&&e&this.bitFieldValue?c.UIUtils.createTextChild(s.createChild("div"),"\u2713"):this.hiddenLevels.push(t.stringValue)}}titleFor(e){if(e.overwrite?this.bitFieldValue=e.value:this.bitFieldValue^=e.value,this.bitFieldValue===7)return this.#e;if(this.bitFieldValue===15)return this.allTitle;let t=this.itemMap.get(this.bitFieldValue);return t?t.title:this.customTitle}createElementForItem(e){let t=document.createElement("div"),i=c.UIUtils.createShadowRootWithCoreStyles(t,{cssFile:ue}).createChild("div","media-messages-level-dropdown-element"),n=i.createChild("div","media-messages-level-dropdown-checkbox"),d=i.createChild("span","media-messages-level-dropdown-text");return c.UIUtils.createTextChild(d,e.title),this.elementsForItems.set(e,n),this.itemMap.set(e.value,e),this.updateCheckMarks(),this.view.regenerateMessageDisplayCss(this.hiddenLevels),t}isItemSelectable(e){return!0}itemSelected(e){this.updateCheckMarks(),this.view.regenerateMessageDisplayCss(this.hiddenLevels)}highlightedItemChanged(e,t,s,i){}},U=class extends c.Widget.VBox{headerPanel;bodyPanel;messageLevelSelector;constructor(){super({jslog:`${Qe.pane("messages")}`}),this.registerRequiredCSS(ue),this.headerPanel=this.contentElement.createChild("div","media-messages-header"),this.bodyPanel=this.contentElement.createChild("div","media-messages-body"),this.buildToolbar()}buildToolbar(){let e=this.headerPanel.createChild("devtools-toolbar","media-messages-toolbar");e.appendText(m(h.logLevel)),e.appendToolbarItem(this.createDropdown()),e.appendSeparator(),e.appendToolbarItem(this.createFilterInput())}createDropdown(){let e=new c.ListModel.ListModel;this.messageLevelSelector=new fe(e,this);let t=new c.SoftDropDown.SoftDropDown(e,this.messageLevelSelector,"log-level");t.setRowHeight(18),this.messageLevelSelector.populate(),this.messageLevelSelector.setDefault(t);let s=new c.Toolbar.ToolbarItem(t.element);return s.element.classList.add("toolbar-has-dropdown"),s.setEnabled(!0),s.setTitle(this.messageLevelSelector.defaultTitle()),c.ARIAUtils.setLabel(s.element,`${m(h.logLevel)} ${this.messageLevelSelector.defaultTitle()}`),s}createFilterInput(){let e=new c.Toolbar.ToolbarFilter(m(h.filterByLogMessages),1,1);return e.addEventListener("TextChanged",t=>{this.filterByString(t)},this),e}regenerateMessageDisplayCss(e){let t=this.bodyPanel.getElementsByClassName("media-messages-message-container");for(let s of t)this.matchesHiddenLevels(s,e)?s.classList.add("media-messages-message-unselected"):s.classList.remove("media-messages-message-unselected")}matchesHiddenLevels(e,t){for(let s of t)if(e.classList.contains("media-message-"+s))return!0;return!1}filterByString(e){let t=e.data,s=this.bodyPanel.getElementsByClassName("media-messages-message-container");for(let i of s)t===""||i.textContent?.includes(t)?i.classList.remove("media-messages-message-filtered"):i.classList.add("media-messages-message-filtered")}addMessage(e){let t=this.bodyPanel.createChild("div","media-messages-message-container media-message-"+e.level);c.UIUtils.createTextChild(t,e.message)}renderError(e){return T`
      <div class="status-error-box">
        <div class="status-error-field-labeled">
          <span class="status-error-field-label"
            >${m(h.errorGroupLabel)}</span
          >
          <span>${e.errorType}</span>
        </div>
        <div class="status-error-field-labeled">
          <span class="status-error-field-label"
            >${m(h.errorCodeLabel)}</span
          >
          <span>${e.code}</span>
        </div>
        <div class="status-error-field-labeled">
        ${Object.keys(e.data).length!==0?T`<span class="status-error-field-label"
                  >${m(h.errorDataLabel)}</span
                >
                <div>
                  ${Object.entries(e.data).map(([t,s])=>T`<div>${t}: ${s}</div>`)}
                </div>`:ge}
        </div>
        <div class="status-error-field-labeled">
          ${e.stack.length!==0?T`<span class="status-error-field-label"
                    >${m(h.errorStackLabel)}</span
                  >
                  <div>
                    ${e.stack.map(t=>T`<div>${t.file}:${t.line}</div>`)}
                  </div>`:ge}
        </div>
        <div class="status-error-field-labeled">
          ${e.cause.length!==0?T`
                  <span class="status-error-field-label"
                    >${m(h.errorCauseLabel)}</span
                  >
                  ${this.renderError(e.cause[0])}
                `:ge}
        </div>
      </div>
    `}addError(e){let t=this.bodyPanel.createChild("div","media-messages-message-container media-message-error");Ct(this.renderError(e),t)}};var ot={};u(ot,{AttributesView:()=>P,AudioTrackManager:()=>J,DefaultPropertyRenderer:()=>x,FormattedPropertyRenderer:()=>E,NestedPropertyRenderer:()=>z,PlayerPropertiesView:()=>N,PropertyRenderer:()=>l,TextTrackManager:()=>G,TrackManager:()=>C,VideoTrackManager:()=>j});import*as k from"./../../core/i18n/i18n.js";import*as rt from"./../../core/platform/platform.js";import*as ye from"./../../ui/legacy/components/source_frame/source_frame.js";import*as p from"./../../ui/legacy/legacy.js";import*as at from"./../../ui/visual_logging/visual_logging.js";var tt=`.media-attributes-view{border-bottom:1px solid var(--sys-color-divider)}.media-property-renderer{line-height:20px;min-height:28px;padding:4px 10px;display:block;overflow:hidden;&:hover{background:var(--sys-color-state-hover-on-subtle)}}.media-property-renderer:nth-child(even):not(:hover){background:var(--sys-color-surface1)}.media-property-renderer:has(.json-view){padding-bottom:0}.media-property-renderer:has(.json-view > .expanded){padding-bottom:4px}.media-property-renderer-hidden{display:none}.media-property-renderer-title{font-size:12px;float:left;width:150px}.media-property-renderer-title::first-letter{text-transform:uppercase}.media-property-renderer-contents{position:relative;& > .json-view{overflow:hidden;padding:0}}.media-properties-frame{display:block;overflow-x:hidden}
/*# sourceURL=${import.meta.resolve("./playerPropertiesView.css")} */`;var a={video:"Video",audio:"Audio",track:"Track",decoder:"Decoder",properties:"Properties",textTrack:"Text track",noTextTracks:"No text tracks",resolution:"Resolution",fileSize:"File size",bitrate:"Bitrate",duration:"Duration",startTime:"Start time",streaming:"Streaming",playbackFrameUrl:"Playback frame URL",playbackFrameTitle:"Playback frame title",singleoriginPlayback:"Single-origin playback",rangeHeaderSupport:"`Range` header support",frameRate:"Frame rate",videoPlaybackRoughness:"Video playback roughness",videoFreezingScore:"Video freezing score",rendererName:"Renderer name",decoderName:"Decoder name",noDecoder:"No decoder",hardwareDecoder:"Hardware decoder",decryptingDemuxer:"Decrypting demuxer",encoderName:"Encoder name",noEncoder:"No encoder",hardwareEncoder:"Hardware encoder",hlsBufferedRanges:"Buffered media ranges"},nt=k.i18n.registerUIStrings("panels/media/PlayerPropertiesView.ts",a),o=k.i18n.getLocalizedString.bind(void 0,nt),st=k.i18n.getLazilyComputedLocalizedString.bind(void 0,nt),l=class extends p.Widget.VBox{contents;value;pseudoColorProtectionElement;constructor(e){super(),this.contentElement.classList.add("media-property-renderer");let t=this.contentElement.createChild("span","media-property-renderer-title");this.contents=this.contentElement.createChild("div","media-property-renderer-contents"),p.UIUtils.createTextChild(t,e),this.value=null,this.pseudoColorProtectionElement=null,this.contentElement.classList.add("media-property-renderer-hidden")}updateData(e){if(e===""||e===null)this.changeContents(null);else{if(this.value===e)return;this.value=e,this.updateDataInternal(e)}}updateDataInternal(e){try{let t=JSON.parse(e);this.changeContents(t)}catch{this.changeContents(e)}}unsetNestedContents(){this.contentElement.classList.add("media-property-renderer-hidden"),this.pseudoColorProtectionElement===null&&(this.pseudoColorProtectionElement=document.createElement("div"),this.pseudoColorProtectionElement.classList.add("media-property-renderer"),this.pseudoColorProtectionElement.classList.add("media-property-renderer-hidden"),this.contentElement.parentNode.insertBefore(this.pseudoColorProtectionElement,this.contentElement))}changeNestedContents(e){e===null||Object.keys(e).length===0?this.unsetNestedContents():(this.pseudoColorProtectionElement!==null&&(this.pseudoColorProtectionElement.remove(),this.pseudoColorProtectionElement=null),this.contentElement.classList.remove("media-property-renderer-hidden"),this.contents.removeChildren(),new ye.JSONView.JSONView(new ye.JSONView.ParsedJSON(e,"",""),!0).show(this.contents))}changeContents(e){if(e===null)this.unsetNestedContents();else{this.pseudoColorProtectionElement!==null&&(this.pseudoColorProtectionElement.remove(),this.pseudoColorProtectionElement=null),this.contentElement.classList.remove("media-property-renderer-hidden"),this.contents.removeChildren();let t=document.createElement("span");t.textContent=e,this.contents.appendChild(t)}}},E=class extends l{formatfunction;constructor(e,t){super(e),this.formatfunction=t}updateDataInternal(e){try{let t=JSON.parse(e);this.changeContents(this.formatfunction(t))}catch{let t=e;this.changeContents(this.formatfunction(t))}}},x=class extends l{constructor(e,t){super(e),this.changeContents(t)}},z=class extends l{constructor(e,t){super(e),this.changeNestedContents(t)}},P=class extends p.Widget.VBox{contentHash;constructor(e){super(),this.contentHash=0,this.contentElement.classList.add("media-attributes-view");for(let t of e){t.show(this.contentElement);let s=this.contentElement.textContent;s!==null&&(this.contentHash+=rt.StringUtilities.hashCode(s))}}getContentHash(){return this.contentHash}},C=class{type;view;constructor(e,t){this.type=t,this.view=e}updateData(e){let t=this.view.getTabs(this.type),s=JSON.parse(e),i=1;for(let n of s)this.addNewTab(t,n,i),i++}addNewTab(e,t,s){let i=[];for(let[d,y]of Object.entries(t))typeof y=="object"?i.push(new z(k.i18n.lockedString(d),y)):i.push(new x(k.i18n.lockedString(d),y));let n=new P(i);e.addNewTab(s,n)}},j=class extends C{constructor(e){super(e,"video")}},G=class extends C{constructor(e){super(e,"text")}},J=class extends C{constructor(e){super(e,"audio")}},it={Video:st(a.video),Audio:st(a.audio)},K=class extends p.TabbedPane.TabbedPane{decoderName;trackName;constructor(e,t=o(a.track)){super(),this.decoderName=e,this.trackName=t}addNewTab(e,t){let s=o(a.track),i=`track-${e}`;if(this.hasTab(i)){let n=this.tabView(i);if(n===null||n.getContentHash()===t.getContentHash())return;this.closeTab(i,!1)}this.appendTab(i,`${this.trackName} #${e}`,t,`${this.decoderName} ${s} #${e}`)}},q=class extends K{constructor(e,t){super(e);let s=o(a.decoder),i=`${e} ${s}`,n=o(a.properties),d=`${i} ${n}`;this.appendTab("decoder-properties",i,t,d)}},be=class extends p.Widget.VBox{isPlaceholder;wrapping;constructor(e,t){super(),this.isPlaceholder=!0,this.wrapping=e,this.wrapping.appendTab("_placeholder",t,new p.Widget.VBox,t),this.wrapping.show(this.contentElement)}addNewTab(e,t){this.isPlaceholder&&(this.wrapping.closeTab("_placeholder"),this.isPlaceholder=!1),this.wrapping.addNewTab(e,t)}},N=class extends p.Widget.VBox{mediaElements;videoDecoderElements;audioDecoderElements;attributeMap;videoProperties;videoDecoderProperties;audioDecoderProperties;videoDecoderTabs;audioDecoderTabs;textTracksTabs;constructor(){super({jslog:`${at.pane("properties")}`}),this.registerRequiredCSS(tt),this.contentElement.classList.add("media-properties-frame"),this.mediaElements=[],this.videoDecoderElements=[],this.audioDecoderElements=[],this.attributeMap=new Map,this.populateAttributesAndElements(),this.videoProperties=new P(this.mediaElements),this.videoDecoderProperties=new P(this.videoDecoderElements),this.audioDecoderProperties=new P(this.audioDecoderElements),this.videoProperties.show(this.contentElement),this.videoDecoderTabs=new q(it.Video(),this.videoDecoderProperties),this.videoDecoderTabs.show(this.contentElement),this.audioDecoderTabs=new q(it.Audio(),this.audioDecoderProperties),this.audioDecoderTabs.show(this.contentElement),this.textTracksTabs=null}lazyCreateTrackTabs(){let e=this.textTracksTabs;if(e===null){let t=new K(o(a.textTrack));e=new be(t,o(a.noTextTracks)),e.show(this.contentElement),this.textTracksTabs=e}return e}getTabs(e){if(e==="audio")return this.audioDecoderTabs;if(e==="video")return this.videoDecoderTabs;if(e==="text")return this.lazyCreateTrackTabs();throw new Error("Unreachable")}onProperty(e){let t=this.attributeMap.get(e.name);if(!t)throw new Error(`Player property "${e.name}" not supported.`);t.updateData(e.value)}formatKbps(e){return e===""?"0 kbps":`${Math.floor(Number(e)/1e3)} kbps`}formatTime(e){if(e==="")return"0:00";let t=new Date;return t.setSeconds(Number(e)),t.toISOString().substr(11,8)}formatFileSize(e){if(e==="")return"0 bytes";let t=Number(e);if(t<1e3)return`${e} bytes`;let s=Math.floor(Math.log10(t)/3),i=["bytes","kB","MB","GB","TB"][s];return`${(t/Math.pow(1e3,s)).toFixed(2)} ${i}`}formatBufferedRanges(e){return e.map(t=>"["+t[0]+" \u2192 "+t[1]+"]").join(", ")}populateAttributesAndElements(){let e=new l(o(a.resolution));this.mediaElements.push(e),this.attributeMap.set("kResolution",e);let t=new E(o(a.fileSize),this.formatFileSize);this.mediaElements.push(t),this.attributeMap.set("kTotalBytes",t);let s=new E(o(a.bitrate),this.formatKbps);this.mediaElements.push(s),this.attributeMap.set("kBitrate",s);let i=new E(o(a.duration),this.formatTime);this.mediaElements.push(i),this.attributeMap.set("kMaxDuration",i);let n=new l(o(a.startTime));this.mediaElements.push(n),this.attributeMap.set("kStartTime",n);let d=new l(o(a.streaming));this.mediaElements.push(d),this.attributeMap.set("kIsStreaming",d);let y=new l(o(a.playbackFrameUrl));this.mediaElements.push(y),this.attributeMap.set("kFrameUrl",y);let te=new l(o(a.playbackFrameTitle));this.mediaElements.push(te),this.attributeMap.set("kFrameTitle",te);let se=new l(o(a.singleoriginPlayback));this.mediaElements.push(se),this.attributeMap.set("kIsSingleOrigin",se);let Te=new l(o(a.rangeHeaderSupport));this.mediaElements.push(Te),this.attributeMap.set("kIsRangeHeaderSupported",Te);let ke=new l(o(a.frameRate));this.mediaElements.push(ke),this.attributeMap.set("kFramerate",ke);let Ce=new l(o(a.videoPlaybackRoughness));this.mediaElements.push(Ce),this.attributeMap.set("kVideoPlaybackRoughness",Ce);let Me=new l(o(a.videoFreezingScore));this.mediaElements.push(Me),this.attributeMap.set("kVideoPlaybackFreezing",Me);let Le=new l(o(a.rendererName));this.mediaElements.push(Le),this.attributeMap.set("kRendererName",Le);let De=new E(o(a.hlsBufferedRanges),this.formatBufferedRanges);this.mediaElements.push(De),this.attributeMap.set("kHlsBufferedRanges",De);let Ie=new x(o(a.decoderName),o(a.noDecoder));this.videoDecoderElements.push(Ie),this.attributeMap.set("kVideoDecoderName",Ie);let Ve=new l(o(a.hardwareDecoder));this.videoDecoderElements.push(Ve),this.attributeMap.set("kIsPlatformVideoDecoder",Ve);let Ue=new x(o(a.encoderName),o(a.noEncoder));this.videoDecoderElements.push(Ue),this.attributeMap.set("kVideoEncoderName",Ue);let Ne=new l(o(a.hardwareEncoder));this.videoDecoderElements.push(Ne),this.attributeMap.set("kIsPlatformVideoEncoder",Ne);let Fe=new l(o(a.decryptingDemuxer));this.videoDecoderElements.push(Fe),this.attributeMap.set("kIsVideoDecryptingDemuxerStream",Fe);let ft=new j(this);this.attributeMap.set("kVideoTracks",ft);let $e=new x(o(a.decoderName),o(a.noDecoder));this.audioDecoderElements.push($e),this.attributeMap.set("kAudioDecoderName",$e);let Be=new l(o(a.hardwareDecoder));this.audioDecoderElements.push(Be),this.attributeMap.set("kIsPlatformAudioDecoder",Be);let Re=new l(o(a.decryptingDemuxer));this.audioDecoderElements.push(Re),this.attributeMap.set("kIsAudioDecryptingDemuxerStream",Re);let vt=new J(this);this.attributeMap.set("kAudioTracks",vt);let yt=new G(this);this.attributeMap.set("kTextTracks",yt)}};var g={properties:"Properties",playerProperties:"Player properties",events:"Events",playerEvents:"Player events",messages:"Messages",playerMessages:"Player messages",timeline:"Timeline",playerTimeline:"Player timeline"},Lt=we.i18n.registerUIStrings("panels/media/PlayerDetailView.ts",g),v=we.i18n.getLocalizedString.bind(void 0,Lt),F=class extends lt.TabbedPane.TabbedPane{eventView;propertyView;messageView;timelineView;constructor(){super(),this.eventView=new L,this.propertyView=new N,this.messageView=new U,this.timelineView=new O,this.appendTab("properties",v(g.properties),this.propertyView,v(g.playerProperties)),this.appendTab("events",v(g.events),this.eventView,v(g.playerEvents)),this.appendTab("messages",v(g.messages),this.messageView,v(g.playerMessages)),this.appendTab("timeline",v(g.timeline),this.timelineView,v(g.playerTimeline))}onProperty(e){this.propertyView.onProperty(e)}onError(e){this.messageView.addError(e)}onMessage(e){this.messageView.addMessage(e)}onEvent(e){this.eventView.onEvent(e),this.timelineView.onEvent(e)}};var ut={};u(ut,{PlayerListView:()=>B});import"./../../ui/kit/kit.js";import*as Ee from"./../../core/i18n/i18n.js";import*as mt from"./../../core/platform/platform.js";import*as Y from"./../../ui/legacy/legacy.js";import{Directives as Dt,html as ct,render as It}from"./../../ui/lit/lit.js";import*as pt from"./../../ui/visual_logging/visual_logging.js";var ht=`.tree-outline{padding-left:0;color:var(--sys-color-token-subtle)}li.storage-group-list-item{padding:10px 8px 6px}li.storage-group-list-item:not(:first-child){border-top:1px solid var(--sys-color-divider)}li.storage-group-list-item::before{display:none}.player-entry-row{height:26px;min-height:26px;line-height:26px;&:nth-child(odd){background:var(--sys-color-surface1)}&:hover{background:var(--sys-color-state-hover-on-subtle)}&:focus-visible{outline:var(--sys-size-2) solid var(--sys-color-state-focus-ring);outline-offset:calc(var(--sys-size-2) * -1)}&.selected{background:var(--sys-color-tonal-container);color:var(--sys-color-on-tonal-container)}}.player-entry-status-icon-centering{margin:auto;display:inherit;& > devtools-icon{height:16px;width:16px}}.player-entry-status-icon{width:28px;min-width:28px;height:26px;border-right:1px solid var(--sys-color-divider);overflow:hidden}.player-entry-frame-title{height:26px;width:125px;min-width:125px;text-overflow:ellipsis;padding:0 10px;border-right:1px solid var(--sys-color-divider);overflow:hidden}.player-entry-player-title{height:26px;padding-left:10px;overflow:hidden}.player-entry-header{height:27px;line-height:27px;min-height:27px;padding-left:10px;border-bottom:1px solid var(--sys-color-divider)}
/*# sourceURL=${import.meta.resolve("./playerListView.css")} */`;var{classMap:Vt}=Dt,$={hidePlayer:"Hide player",hideAllOthers:"Hide all others",savePlayerInfo:"Save player info",players:"Players"},Ut=Ee.i18n.registerUIStrings("panels/media/PlayerListView.ts",$),X=Ee.i18n.getLocalizedString.bind(void 0,Ut),Nt=(r,e,t)=>{It(ct`
      <style>${ht}</style>
      <div class="player-entry-header" id="players-header">${X($.players)}</div>
      <div role="listbox" aria-labelledby="players-header">
      ${r.players.map(s=>{let i=s.playerID===r.selectedPlayerID;return ct`
          <div class=${Vt({"player-entry-row":!0,hbox:!0,selected:i,"force-white-icons":i})}
               tabindex="0"
               @click=${()=>r.onPlayerClick(s.playerID)}
               @keydown=${n=>{mt.KeyboardUtilities.isEnterOrSpaceKey(n)&&(n.preventDefault(),r.onPlayerClick(s.playerID))}}
               @contextmenu=${n=>r.onPlayerContextMenu(s.playerID,n)}
               role="option"
               aria-selected=${i}
               jslog=${pt.item("player").track({click:!0,resize:!0})}>
            <div class="player-entry-status-icon vbox">
              <div class="player-entry-status-icon-centering">
                <devtools-icon name=${s.iconName}></devtools-icon>
              </div>
            </div>
            <div class="player-entry-frame-title">${s.frameTitle}</div>
            <div class="player-entry-player-title">${s.playerTitle}</div>
          </div>
        `})}
      </div>
    `,t)},B=class extends Y.Widget.VBox{#e;playerStatuses;playerEntriesWithHostnameFrameTitle;mainContainer;currentlySelectedPlayerID;constructor(e,t=Nt){super({useShadowDom:!0}),this.#e=t,this.playerStatuses=new Map,this.playerEntriesWithHostnameFrameTitle=new Set,this.mainContainer=e,this.currentlySelectedPlayerID=null,this.requestUpdate()}performUpdate(){let e={players:Array.from(this.playerStatuses.values()),selectedPlayerID:this.currentlySelectedPlayerID,onPlayerClick:this.selectPlayer.bind(this),onPlayerContextMenu:this.rightClickPlayer.bind(this)};this.#e(e,{},this.contentElement)}selectPlayerById(e){this.playerStatuses.has(e)&&this.selectPlayer(e)}selectPlayer(e){this.mainContainer.renderMainPanel(e),this.currentlySelectedPlayerID=e,this.requestUpdate()}rightClickPlayer(e,t){let s=new Y.ContextMenu.ContextMenu(t);s.headerSection().appendItem(X($.hidePlayer),this.mainContainer.markPlayerForDeletion.bind(this.mainContainer,e),{jslogContext:"hide-player"}),s.headerSection().appendItem(X($.hideAllOthers),this.mainContainer.markOtherPlayersForDeletion.bind(this.mainContainer,e),{jslogContext:"hide-all-others"}),s.headerSection().appendItem(X($.savePlayerInfo),this.mainContainer.exportPlayerData.bind(this.mainContainer,e),{jslogContext:"save-player-info"}),s.show()}setMediaElementFrameTitle(e,t,s){if(this.playerEntriesWithHostnameFrameTitle.has(e))s||this.playerEntriesWithHostnameFrameTitle.delete(e);else if(s)return;if(!this.playerStatuses.has(e))return;let i=this.playerStatuses.get(e);i&&(i.frameTitle=t,this.requestUpdate())}setMediaElementPlayerTitle(e,t){if(!this.playerStatuses.has(e))return;let s=this.playerStatuses.get(e);s&&(s.playerTitle=t,this.requestUpdate())}setMediaElementPlayerIcon(e,t){if(!this.playerStatuses.has(e))return;let s=this.playerStatuses.get(e);s&&(s.iconName=t,this.requestUpdate())}formatAndEvaluate(e,t,s,i,n){s.length<=i||(s.length>=n&&(s=s.substring(0,n-1)+"\u2026"),t.bind(this)(e,s))}addMediaElementItem(e){this.playerStatuses.set(e,{playerTitle:"PlayerTitle",frameTitle:"FrameTitle",playerID:e,exists:!0,playing:!1,titleEdited:!1,iconName:"pause"}),this.playerEntriesWithHostnameFrameTitle.add(e),this.requestUpdate()}deletePlayer(e){this.playerStatuses.has(e)&&(this.playerStatuses.delete(e),this.requestUpdate())}onEvent(e,t){let s=JSON.parse(t.value),i=s.event;if(i==="kLoad"){let n=s.url,d=n.substring(n.lastIndexOf("/")+1);this.formatAndEvaluate(e,this.setMediaElementPlayerTitle,d,1,20);return}if(i==="kPlay"){this.setMediaElementPlayerIcon(e,"play");return}if(i==="kPause"||i==="kEnded"){this.setMediaElementPlayerIcon(e,"pause");return}if(i==="kWebMediaPlayerDestroyed"){this.setMediaElementPlayerIcon(e,"cross");return}}onProperty(e,t){if(t.name==="kFrameUrl"){let s=new URL(t.value).hostname;this.formatAndEvaluate(e,this.setMediaElementFrameTitle,s,1,20);return}if(t.name==="kFrameTitle"&&t.value){this.formatAndEvaluate(e,this.setMediaElementFrameTitle,t.value,1,20);return}}onError(e,t){}onMessage(e,t){}};var S={noPlayerDetailsSelected:"No media player selected",selectToViewDetails:"Select a media player to inspect its details.",noMediaPlayer:"No media player",mediaPlayerDescription:"On this page you can view and export media player details."},Ft=Se.i18n.registerUIStrings("panels/media/MainView.ts",S),R=Se.i18n.getLocalizedString.bind(void 0,Ft),$t="https://developer.chrome.com/docs/devtools/media-panel#hide-show",xe=class{properties;messages;events;errors;constructor(){this.properties=new Map,this.messages=[],this.events=[],this.errors=[]}onProperty(e){this.properties.set(e.name,e.value)}onError(e){this.errors.push(e)}onMessage(e){this.messages.push(e)}onEvent(e){this.events.push(e)}export(){return{properties:this.properties,messages:this.messages,events:this.events,errors:this.errors}}},Q=class{playerDataCollection;constructor(){this.playerDataCollection=new Map}addPlayer(e){this.playerDataCollection.set(e,new xe)}onProperty(e,t){let s=this.playerDataCollection.get(e);s&&s.onProperty(t)}onError(e,t){let s=this.playerDataCollection.get(e);s&&s.onError(t)}onMessage(e,t){let s=this.playerDataCollection.get(e);s&&s.onMessage(t)}onEvent(e,t){let s=this.playerDataCollection.get(e);s&&s.onEvent(t)}exportPlayerData(e){let t=this.playerDataCollection.get(e);if(!t)throw new Error("Unable to find player");return t.export()}deletePlayer(e){this.playerDataCollection.delete(e)}},Pe=class extends ee.Panel.PanelWithSidebar{detailPanels;deletedPlayers;downloadStore;sidebar;#e;#s;#t;#i;#r=()=>{};constructor(e=new Q){super("media"),this.detailPanels=new Map,this.#e=new Map,this.#s=new Map,this.#i=new Promise(t=>{this.#r=t}),this.deletedPlayers=new Set,this.downloadStore=e,this.sidebar=new B(this),this.sidebar.show(this.panelSidebarElement()),this.splitWidget().hideSidebar(),this.#t=new ee.EmptyWidget.EmptyWidget(R(S.noMediaPlayer),S.mediaPlayerDescription),this.#t.show(this.mainElement()),this.#t.link=$t,Z.TargetManager.TargetManager.instance().observeModels(f,this,{scoped:!0})}renderMainPanel(e){if(!this.detailPanels.has(e))return;let t=this.splitWidget().mainWidget();t&&t.detachChildWidgets(),this.detailPanels.get(e)?.show(this.mainElement())}wasShown(){super.wasShown();for(let e of Z.TargetManager.TargetManager.instance().models(f,{scoped:!0}))this.addEventListeners(e)}willHide(){super.willHide();for(let e of Z.TargetManager.TargetManager.instance().models(f,{scoped:!0}))this.removeEventListeners(e)}modelAdded(e){this.isShowing()&&this.addEventListeners(e)}modelRemoved(e){this.removeEventListeners(e)}addEventListeners(e){e.ensureEnabled(),e.addEventListener("PlayerPropertiesChanged",this.propertiesChanged,this),e.addEventListener("PlayerEventsAdded",this.eventsAdded,this),e.addEventListener("PlayerMessagesLogged",this.messagesLogged,this),e.addEventListener("PlayerErrorsRaised",this.errorsRaised,this),e.addEventListener("PlayerCreated",this.playerCreated,this)}removeEventListeners(e){e.removeEventListener("PlayerPropertiesChanged",this.propertiesChanged,this),e.removeEventListener("PlayerEventsAdded",this.eventsAdded,this),e.removeEventListener("PlayerMessagesLogged",this.messagesLogged,this),e.removeEventListener("PlayerErrorsRaised",this.errorsRaised,this),e.removeEventListener("PlayerCreated",this.playerCreated,this)}propertiesChanged(e){for(let t of e.data.properties)this.onProperty(e.data.playerId,t)}eventsAdded(e){for(let t of e.data.events)this.onEvent(e.data.playerId,t)}messagesLogged(e){for(let t of e.data.messages)this.onMessage(e.data.playerId,t)}errorsRaised(e){for(let t of e.data.errors)this.onError(e.data.playerId,t)}shouldPropagate(e){return!this.deletedPlayers.has(e)&&this.detailPanels.has(e)}onProperty(e,t){this.shouldPropagate(e)&&(this.sidebar.onProperty(e,t),this.downloadStore.onProperty(e,t),this.detailPanels.get(e)?.onProperty(t))}onError(e,t){this.shouldPropagate(e)&&(this.sidebar.onError(e,t),this.downloadStore.onError(e,t),this.detailPanels.get(e)?.onError(t))}onMessage(e,t){this.shouldPropagate(e)&&(this.sidebar.onMessage(e,t),this.downloadStore.onMessage(e,t),this.detailPanels.get(e)?.onMessage(t))}onEvent(e,t){this.shouldPropagate(e)&&(this.sidebar.onEvent(e,t),this.downloadStore.onEvent(e,t),this.detailPanels.get(e)?.onEvent(t))}selectPlayerByDOMNodeId(e){let t=this.#s.get(e);if(!t)return;let s=this.#e.get(t);s&&this.sidebar.selectPlayerById(s.playerId)}waitForInitialPlayers(){return this.#i}playerCreated(e){let t=e.data;this.#e.set(t.playerId,t),t.domNodeId&&this.#s.set(t.domNodeId,t.playerId),this.splitWidget().showMode()!=="Both"&&this.splitWidget().showBoth(),this.sidebar.addMediaElementItem(t.playerId),this.detailPanels.set(t.playerId,new F),this.downloadStore.addPlayer(t.playerId),this.detailPanels.size===1&&(this.#t.header=R(S.noPlayerDetailsSelected),this.#t.text=R(S.selectToViewDetails)),this.#r()}markPlayerForDeletion(e){this.deletedPlayers.add(e),this.detailPanels.delete(e);let t=this.#e.get(e);if(t?.domNodeId&&this.#s.delete(t.domNodeId),this.#e.delete(e),this.sidebar.deletePlayer(e),this.downloadStore.deletePlayer(e),this.detailPanels.size===0){this.#t.header=R(S.noMediaPlayer),this.#t.text=R(S.mediaPlayerDescription),this.splitWidget().hideSidebar();let s=this.splitWidget().mainWidget();s&&s.detachChildWidgets(),this.#t.show(this.mainElement())}}markOtherPlayersForDeletion(e){for(let t of this.detailPanels.keys())t!==e&&this.markPlayerForDeletion(t)}exportPlayerData(e){let t=this.downloadStore.exportPlayerData(e),s="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(t,null,2)),i=document.createElement("a");i.href=s,i.download=e+".json",i.click()}};export{gt as MainView,He as MediaModel,dt as PlayerDetailView,We as PlayerEventsView,ut as PlayerListView,et as PlayerMessagesView,ot as PlayerPropertiesView,qe as TickingFlameChart,Oe as TickingFlameChartHelpers};
//# sourceMappingURL=media.js.map
