import{Capability,SDKModel}from"./SDKModel.js";export class PaintProfilerModel extends SDKModel{constructor(e){super(e),this._layerTreeAgent=e.layerTreeAgent()}async loadSnapshotFromFragments(e){const{snapshotId:t}=await this._layerTreeAgent.invoke_loadSnapshot({tiles:e});return t?new PaintProfilerSnapshot(this,t):null}loadSnapshot(e){const t={x:0,y:0,picture:e};return this.loadSnapshotFromFragments([t])}async makeSnapshot(e){const{snapshotId:t}=await this._layerTreeAgent.invoke_makeSnapshot({layerId:e});return t?new PaintProfilerSnapshot(this,t):null}}export class PaintProfilerSnapshot{constructor(e,t){this._paintProfilerModel=e,this._id=t,this._refCount=1}release(){console.assert(this._refCount>0,"release is already called on the object"),--this._refCount||this._paintProfilerModel._layerTreeAgent.invoke_releaseSnapshot({snapshotId:this._id})}addReference(){++this._refCount,console.assert(this._refCount>0,"Referencing a dead object")}async replay(e,t,o){return(await this._paintProfilerModel._layerTreeAgent.invoke_replaySnapshot({snapshotId:this._id,fromStep:t,toStep:o,scale:e||1})).dataURL}async profile(e){return(await this._paintProfilerModel._layerTreeAgent.invoke_profileSnapshot({snapshotId:this._id,minRepeatCount:5,minDuration:1,clipRect:e||void 0})).timings}async commandLog(){const e=await this._paintProfilerModel._layerTreeAgent.invoke_snapshotCommandLog({snapshotId:this._id});return e.commandLog?e.commandLog.map(((e,t)=>new PaintProfilerLogItem(e,t))):null}}export class PaintProfilerLogItem{constructor(e,t){this.method=e.method,this.params=e.params,this.commandIndex=t}}SDKModel.register(PaintProfilerModel,Capability.DOM,!1);