import{OverlayModel}from"./OverlayModel.js";import{Capability,SDKModel}from"./SDKModel.js";export class ScreenCaptureModel extends SDKModel{constructor(e){super(e),this._agent=e.pageAgent(),this._onScreencastFrame=null,this._onScreencastVisibilityChanged=null,e.registerPageDispatcher(this)}startScreencast(e,t,a,i,n,r,s){this._onScreencastFrame=r,this._onScreencastVisibilityChanged=s,this._agent.invoke_startScreencast({format:e,quality:t,maxWidth:a,maxHeight:i,everyNthFrame:n})}stopScreencast(){this._onScreencastFrame=null,this._onScreencastVisibilityChanged=null,this._agent.invoke_stopScreencast()}async captureScreenshot(e,t,a){await OverlayModel.muteHighlight();const i=await this._agent.invoke_captureScreenshot({format:e,quality:t,clip:a,fromSurface:!0,captureBeyondViewport:!0});return await OverlayModel.unmuteHighlight(),i.data}async fetchLayoutMetrics(){const e=await this._agent.invoke_getLayoutMetrics();return e.getError()?null:{viewportX:e.visualViewport.pageX,viewportY:e.visualViewport.pageY,viewportScale:e.visualViewport.scale,contentWidth:e.contentSize.width,contentHeight:e.contentSize.height}}screencastFrame({data:e,metadata:t,sessionId:a}){this._agent.invoke_screencastFrameAck({sessionId:a}),this._onScreencastFrame&&this._onScreencastFrame.call(null,e,t)}screencastVisibilityChanged({visible:e}){this._onScreencastVisibilityChanged&&this._onScreencastVisibilityChanged.call(null,e)}domContentEventFired(e){}loadEventFired(e){}lifecycleEvent(e){}navigatedWithinDocument(e){}frameAttached(e){}frameNavigated(e){}documentOpened(e){}frameDetached(e){}frameStartedLoading(e){}frameStoppedLoading(e){}frameRequestedNavigation(e){}frameScheduledNavigation(e){}frameClearedScheduledNavigation(e){}frameResized(){}javascriptDialogOpening(e){}javascriptDialogClosed(e){}interstitialShown(){}interstitialHidden(){}windowOpen(e){}fileChooserOpened(e){}compilationCacheProduced(e){}downloadWillBegin(e){}downloadProgress(){}}SDKModel.register(ScreenCaptureModel,Capability.ScreenCapture,!1);