"use strict";(self.rspackChunk_jupyter_docprovider_extension=self.rspackChunk_jupyter_docprovider_extension||[]).push([[44],{5068(e,t,r){var s=r(6758),o=r.n(s),n=r(935),i=r.n(n)()(o());i.push([e.id,`/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|---------------------------------------------------------------------------- */

.jp-timelineSliderWrapper .jp-sliderContainer{
  display: flex;
  align-items: center;
}

.jp-Slider {
  height: 4.5px
}

#jp-slider-status-bar {
  display: flex;
}

.jp-timestampDisplay {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.jp-restoreBtnContainer {
  width: 192px;
}

.jp-ToolbarButtonComponent.jp-restoreBtn {
  cursor: pointer;
  color: var(--jp-layout-color2);
  width: 100%;
  background: var(--jp-accept-color-normal)
}
`,""]),r.d(t,{},{A:i})},4735(e,t,r){r.r(t),r.d(t,{ForkManager:()=>K,IAwarenessProviderFactory:()=>V,IDocumentProviderFactory:()=>J,IForkManagerToken:()=>B,JUPYTER_COLLABORATION_FORK_EVENTS_URI:()=>q,NotebookCellServerExecutor:()=>c,ROOM_FORK_URL:()=>d,RtcContentProvider:()=>m,TimelineWidget:()=>O,WebSocketAwarenessProvider:()=>o,WebSocketProvider:()=>b,requestAPI:()=>h,requestDocSession:()=>u,requestDocumentTimeline:()=>_,requestUndoRedo:()=>p});var s=r(6459);class o extends s.WebsocketProvider{constructor(e){super(e.url,e.roomID,e.awareness.doc,{awareness:e.awareness}),this._isDisposed=!1,this.awareness=e.awareness,this._user=e.user,this._user.ready.then(()=>this._onUserChanged(this._user)).catch(e=>console.error(e)),this._user.userChanged.connect(this._onUserChanged,this)}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._user.userChanged.disconnect(this._onUserChanged,this),this._isDisposed=!0,this.destroy())}_onUserChanged(e){this.awareness.setLocalStateField("user",e.identity)}}var n=r(5748),i=r(9687),a=r(5374),l=r(9180);class c{constructor(e){var t;this._serverSettings=null!=(t=e.serverSettings)?t:a.ServerConnection.makeSettings()}async runCell({cell:e,notebook:t,notebookConfig:r,onCellExecuted:s,onCellExecutionScheduled:o,sessionContext:c,sessionDialogs:d,translator:h}){var u,_,p;let g=(h=null!=h?h:l.nullTranslator).load("jupyterlab");switch(e.model.type){case"markdown":e.rendered=!0,e.inputHidden=!1,s({cell:e,success:!0});break;case"code":if(c){if(c.isTerminating){await (0,n.showDialog)({title:g.__("Kernel Terminating"),body:g.__("The kernel for %1 appears to be terminating. You can not run any cell for now.",null==(u=c.session)?void 0:u.path),buttons:[n.Dialog.okButton()]});break}if(c.pendingInput)return await (0,n.showDialog)({title:g.__("Cell not executed due to pending input"),body:g.__("The cell has not been executed to avoid kernel deadlock as there is another pending input! Submit your pending input and try again."),buttons:[n.Dialog.okButton()]}),!1;if(c.hasNoKernel&&await c.startKernel()&&d&&await d.selectKernel(c),c.hasNoKernel)return e.model.sharedModel.transact(()=>{e.model.clearExecution()}),!0;let r=null==(p=null==(_=null==c?void 0:c.session)?void 0:_.kernel)?void 0:p.id,l=i.URLExt.join(this._serverSettings.baseUrl,`api/kernels/${r}/execute`),h={method:"POST",body:JSON.stringify({cell_id:e.model.sharedModel.getId(),document_id:t.sharedModel.getState("document_id")})};o({cell:e});let v=!1;try{v=(await a.ServerConnection.makeRequest(l,h,this._serverSettings)).ok}catch(t){if(s({cell:e,success:!1}),e.isDisposed)return!1;throw t}return s({cell:e,success:v}),!0}e.model.sharedModel.transact(()=>{e.model.clearExecution()},!1)}return Promise.resolve(!0)}}let d="api/collaboration/fork";async function h(e="",t={},r){let s,o=null!=r?r:a.ServerConnection.makeSettings(),n=i.URLExt.join(o.baseUrl,e);try{s=await a.ServerConnection.makeRequest(n,t,o)}catch(e){throw new a.ServerConnection.NetworkError(e)}let l=await s.text();if(l.length>0)try{l=JSON.parse(l)}catch(e){console.error("Not a JSON response body.",s)}if(!s.ok)throw new a.ServerConnection.ResponseError(s,l.message||l);return l}async function u(e,t,r,s){let o,n=null!=s?s:a.ServerConnection.makeSettings(),l=i.URLExt.join(n.baseUrl,"api/collaboration/session",encodeURIComponent(r)),c={method:"PUT",body:JSON.stringify({format:e,type:t})};try{o=await a.ServerConnection.makeRequest(l,c,n)}catch(e){throw new a.ServerConnection.NetworkError(e)}let d=await o.text();if(d.length>0)try{d=JSON.parse(d)}catch(e){console.log("Not a JSON response body.",o)}if(!o.ok)throw new a.ServerConnection.ResponseError(o,d.message||d);return d}async function _(e,t,r,s){let o,n=null!=s?s:a.ServerConnection.makeSettings(),l=i.URLExt.join(n.baseUrl,"api/collaboration/timeline",r);l=l.concat(`?format=${e}&&type=${t}`);try{o=await a.ServerConnection.makeRequest(l,{method:"GET"},n)}catch(e){throw new a.ServerConnection.NetworkError(e)}return o}async function p(e,t,r,s,o){let n,l=null!=o?o:a.ServerConnection.makeSettings(),c=i.URLExt.join(l.baseUrl,"api/collaboration/undo_redo",encodeURIComponent(e));c=c.concat(`?action=${t}&&steps=${r}&&forkRoom=${s}`);try{n=await a.ServerConnection.makeRequest(c,{method:"PUT"},l)}catch(e){throw new a.ServerConnection.NetworkError(e)}let d=await n.text();if(d.length>0)try{d=JSON.parse(d)}catch(e){console.log("Not a JSON response body.",n)}if(!n.ok)throw new a.ServerConnection.ResponseError(n,d.message||d);return d}var g=r(6401);let v="true"===i.PageConfig.getOption("disableRTC");class m{constructor(e){var t,r;this._onCreate=(e,t)=>{var r,s,o;if("string"!=typeof e.format)return;let n=()=>{var e,t,r,s;return this._documentManager?null==(e=this._documentManager.autosave)||e:null==(s=null==(r=null==(t=this._docmanagerSettings)?void 0:t.composite)?void 0:r.autosave)||s};if(t.awareness.setLocalStateField("autosave",n()),this._documentManager){let e=(e,r)=>{"autosave"===r.name&&t.awareness.setLocalStateField("autosave",n())};this._documentManager.stateChanged.connect(e),t.disposed.connect(()=>{var t;null==(t=this._documentManager)||t.stateChanged.disconnect(e)})}else if(this._docmanagerSettings){let e=()=>{t.awareness.setLocalStateField("autosave",n())};this._docmanagerSettings.changed.connect(e),t.disposed.connect(()=>{var t;null==(t=this._docmanagerSettings)||t.changed.disconnect(e)})}try{let n={path:e.path,format:e.format,contentType:e.contentType,model:t,user:this._user,translator:this._trans,serverSettings:this._serverSettings,drive:this._currentDrive},i=this._providerFactory.create(n),a=((null==(r=this._globalAwareness)?void 0:r.getLocalState())||{}).documents||[];a.includes(e.path)||(a.push(e.path),null==(s=this._globalAwareness)||s.setLocalStateField("documents",a));let l=e.path,c=`${e.format}:${e.contentType}:${l}`;this._providers.set(c,i);let d=t=>{var r,s;let o=t.oldValue,n=t.newValue;if(!o||!n)return console.debug("New or old path not given",t),!1;if(o!==l&&n===l)return!1;let i=`${e.format}:${e.contentType}:${o}`;if(i!==c)return console.error("The computed old provider key is different from the current key"),!1;let a=`${e.format}:${e.contentType}:${n}`,d=this._providers.get(i);if(!d)return console.warn(`Could not find a provider to update after rename ${i}, ${a}`),!1;this._providers.set(a,d),this._providers.delete(i),c=a,l=n;let h=((null==(r=this._globalAwareness)?void 0:r.getLocalState())||{}).documents||[],u=h.indexOf(o);return h.includes(o)&&!h.includes(n)&&(h.splice(u,1),h.push(n),null==(s=this._globalAwareness)||s.setLocalStateField("documents",h)),this._providerFileChanged.emit({type:"rename",oldValue:{path:o},newValue:{path:n}}),!0},h=(e,t)=>{var r,s;if("rename"!==t.type)return;let o=null==(r=t.oldValue)?void 0:r.path,n=null==(s=t.newValue)?void 0:s.path;o===l&&d({oldValue:o,newValue:n,name:"path"})};null==(o=this._driveFileChanged)||o.connect(h),t.changed.connect(async(e,t)=>{if(!t.stateChange)return;for(let e of t.stateChange.filter(e=>"path"===e.name))d(e);let r=t.stateChange.filter(e=>"hash"===e.name);if(0===r.length)return;r.length>1&&console.error("Unexpected multiple changes to hash value in a single transaction");let s=r[0],o=await this.get(l,{content:!1});this._providerFileChanged.emit({type:"save",newValue:{...o,hash:s.newValue},oldValue:{hash:s.oldValue}})}),t.disposed.connect(()=>{var e,t,r;let s=this._providers.get(c);s&&(s.dispose(),this._providers.delete(c));let o=((null==(e=this._globalAwareness)?void 0:e.getLocalState())||{}).documents||[],n=o.indexOf(l);n>-1&&o.splice(n,1),null==(t=this._globalAwareness)||t.setLocalStateField("documents",o),null==(r=this._driveFileChanged)||r.disconnect(h)})}catch(t){console.error(`Failed to open websocket connection for ${e.path}.
:${t}`)}},this._providerFileChanged=new g.Signal(this),this._user=e.user,this._trans=e.trans,this._globalAwareness=e.globalAwareness,this._serverSettings=e.serverSettings,this._currentDrive=e.currentDrive,this.sharedModelFactory=new f(this._onCreate),this._providers=new Map,this._documentManager=null!=(t=e.documentManager)?t:null,this._docmanagerSettings=null!=(r=e.docmanagerSettings)?r:null,this._driveFileChanged=e.fileChanged,this._providerFactory=e.providerFactory}get providers(){return this._providers}async get(e,t){if(t&&t.format&&t.type){let r=`${t.format}:${t.type}:${e}`,s=this._providers.get(r);if(s){let[r]=await Promise.all([this._currentDrive.get(e,{...t,content:!1,contentProviderId:void 0}),s.ready]);return{...r,format:t.format}}}return this._currentDrive.get(e,{...t,contentProviderId:void 0})}async save(e,t={}){if(t.format&&t.type){let r=`${t.format}:${t.type}:${e}`,s=this._providers.get(r);if(s){s.save&&await s.save();let r={type:t.type,format:t.format,content:!1};return this.get(e,r)}console.warn(`Could not find a provider for ${e}, falling back to REST API save`)}return this._currentDrive.save(e,{...t,contentProviderId:void 0})}get fileChanged(){return this._providerFileChanged}}class f{constructor(e){this._onCreate=e,this.collaborative=!v,this.documentFactories=new Map}registerDocumentFactory(e,t){if(this.documentFactories.has(e))throw Error(`The content type ${e} already exists`);this.documentFactories.set(e,t)}createNew(e){if("string"!=typeof e.format)return void console.warn(`Only defined format are supported; got ${e.format}.`);if(this.collaborative&&e.collaborative&&this.documentFactories.has(e.contentType)){let t=this.documentFactories.get(e.contentType);if(!t)return;let r=t(e);return this._onCreate(e,r),r}}}var y=r(1926),w=r(6214),S=r(7989);class b{constructor(e){var t;this._onLoadTimeout=async()=>{if(this._isDisposed||this._hasSynced||this._isShowingDialog)return;this._isShowingDialog=!0;let e=await (0,n.showDialog)({title:this._trans.__("Loading"),body:this._trans.__("The document is taking some time to load. What would you like to do?"),buttons:[n.Dialog.cancelButton({label:this._trans.__("Cancel")}),n.Dialog.okButton({label:this._trans.__("Continue waiting"),actions:["continue"]}),n.Dialog.warnButton({label:this._trans.__("Retry"),actions:["retry"]})]});if(this._isShowingDialog=!1,!this._isDisposed&&!this._hasSynced)if(e.button.actions.includes("continue"))this._startLoadTimeout();else if(e.button.actions.includes("retry"))await this.reconnect();else{this._disconnect();let e=this._trans.__("The document failed to load. Please try opening it again.");this._ready.reject(e),this._ready.promise.catch(()=>void 0),this._sharedModel.dispose()}},this._onConnectionClosed=async e=>{if([4400,4404,4500].includes(e.code)&&!this._hasSynced){let t=this._getCloseReasonMessage(e.code);this._ready.reject(t),this._sharedModel.dispose()}if(1003===e.code){let t;console.error("Document provider closed:",e.reason);try{t=JSON.parse(e.reason)}catch(r){t={reason:"unknown_session",sessionId:"",reloadable:!1,errorReason:e.reason}}let{title:r,body:s}=this._buildSessionExpiredMessage(t,this._trans);(await (0,n.showDialog)({title:r,body:s,buttons:t.reloadable?[n.Dialog.cancelButton({label:this._trans.__("Continue")}),n.Dialog.okButton({label:this._trans.__("Reload")})]:[n.Dialog.okButton({label:this._trans.__("Ok")})]})).button.accept&&t.reloadable&&window.location.reload(),this._sharedModel.dispose()}},this._handleConflictMessage=async e=>{var t,r,s;if(!(e.data instanceof ArrayBuffer))return;let o=new Uint8Array(e.data);if(0===o.length)return;let i=y.$C(o);try{if(2!==y.cw(i))return;let e=JSON.parse(y.t3(i));if(!e||"conflict"!==e.type)return}catch(e){return}let a=[n.Dialog.cancelButton({label:this._trans.__("Dismiss")})];this._onConflictRevert&&a.push(n.Dialog.warnButton({label:this._trans.__("Revert"),actions:["revert"]})),this._onConflictShowDiff&&a.push(n.Dialog.okButton({label:this._trans.__("Show Diff"),actions:["show-diff"]})),this._onConflictSaveAs&&a.push(n.Dialog.okButton({label:this._trans.__("Save As"),actions:["save-as"]}));let l=await (0,n.showDialog)({title:this._trans.__("Edit Conflict"),body:this._trans.__("Your recent changes could not be applied because the document structure changed while you were disconnected (for example, another user or external tool modified the file). Your edits were not saved to the shared document."),buttons:a});l.button.actions.includes("revert")?await (null==(t=this._onConflictRevert)?void 0:t.call(this)):l.button.actions.includes("show-diff")?await (null==(r=this._onConflictShowDiff)?void 0:r.call(this,this._sharedModel.getSource())):l.button.actions.includes("save-as")&&await (null==(s=this._onConflictSaveAs)?void 0:s.call(this))},this._onSync=e=>{e&&(this._hasSynced=!0,this._clearLoadTimeout(),this._yWebsocketProvider&&(this._yWebsocketProvider.off("sync",this._onSync),this._sharedModel.ydoc.getMap("state").set("document_id",this._yWebsocketProvider.roomname)),this._ready.resolve())},this._ready=new S.PromiseDelegate,this._hasSynced=!1,this._saveCounter=0,this._conflictWs=null,this._loadTimeoutId=null,this._isShowingDialog=!1,this._isDisposed=!1,this._path=e.path,this._contentType=e.contentType,this._format=e.format,this._customServerUrl=e.url,this._sharedModel=e.model,this._awareness=e.model.awareness,this._yWebsocketProvider=null,this._serverSettings=null!=(t=e.serverSettings)?t:a.ServerConnection.makeSettings(),this._trans=e.translator,this._onConflictSaveAs=e.onConflictSaveAs,this._onConflictRevert=e.onConflictRevert,this._onConflictShowDiff=e.onConflictShowDiff;const r=e.user;r.ready.then(()=>{this._onUserChanged(r)}).catch(e=>console.error(e)),r.userChanged.connect(this._onUserChanged,this),this._connect().catch(e=>console.warn(e)),this._startLoadTimeout()}get isDisposed(){return this._isDisposed}get ready(){return this._ready.promise}get contentType(){return this._contentType}get format(){return this._format}dispose(){var e,t,r;this.isDisposed||(this._isDisposed=!0,this._clearLoadTimeout(),this._conflictWs&&(this._conflictWs.removeEventListener("message",this._handleConflictMessage),this._conflictWs=null),null==(e=this._yWebsocketProvider)||e.off("connection-close",this._onConnectionClosed),null==(t=this._yWebsocketProvider)||t.off("sync",this._onSync),null==(r=this._yWebsocketProvider)||r.destroy(),this._disconnect(),g.Signal.clearData(this))}async reconnect(){this._clearLoadTimeout(),this._disconnect(),this._connect().catch(e=>console.warn(e))}async save(){var e;let t=null==(e=this._yWebsocketProvider)?void 0:e.ws;if(t){let e=++this._saveCounter,r=new S.PromiseDelegate,s=t=>{let s=new Uint8Array(t.data),o=y.$C(s);try{if(2!==y.cw(o))return}catch(e){return}let n=y.t3(o),i=null;try{i=JSON.parse(n)}catch(e){console.debug("The raw reply received was not a JSON reply")}i&&"save"===i.type&&i.responseTo===e&&("success"===i.status?r.resolve():"failed"===i.status?r.reject("Saving failed"):"skipped"===i.status?r.reject("Saving already in progress"):r.reject("Unrecognised save reply status"))};t.addEventListener("message",s);let o=w.xv();w.zd(o,2),w.Qj(o,"save"),w.zd(o,e);let n=w.Fo(o);t.send(n);try{await r.promise}finally{t.removeEventListener("message",s)}}}get _serverUrl(){var e;return null!=(e=this._customServerUrl)?e:i.URLExt.join(this._serverSettings.wsUrl,"api/collaboration/room")}async _connect(){let e=await u(this._format,this._contentType,this._path,this._serverSettings),t=this._serverSettings.token,r={sessionId:e.sessionId};this._serverSettings.appendToken&&""!==t&&(r.token=t),this._yWebsocketProvider=new s.WebsocketProvider(this._serverUrl,`${e.format}:${e.type}:${e.fileId}`,this._sharedModel.ydoc,{disableBc:!0,params:r,awareness:this._awareness,WebSocketPolyfill:this._serverSettings.WebSocket}),this._yWebsocketProvider.on("sync",this._onSync),this._yWebsocketProvider.on("connection-close",this._onConnectionClosed),this._yWebsocketProvider.on("status",({status:e})=>{"connected"===e&&this._attachConflictListener()}),this._startLoadTimeout()}_startLoadTimeout(){this._clearLoadTimeout(),this._isDisposed||(this._loadTimeoutId=window.setTimeout(()=>{this._onLoadTimeout()},5e3))}_clearLoadTimeout(){null!==this._loadTimeoutId&&(clearTimeout(this._loadTimeoutId),this._loadTimeoutId=null)}async connectToForkDoc(e,t){let r=this._serverSettings.token,o={sessionId:t};this._serverSettings.appendToken&&""!==r&&(o.token=r),this._disconnect(),this._yWebsocketProvider=new s.WebsocketProvider(this._serverUrl,e,this._sharedModel.ydoc,{disableBc:!0,params:o,awareness:this._awareness,WebSocketPolyfill:this._serverSettings.WebSocket})}get wsProvider(){return this._yWebsocketProvider}_disconnect(){var e,t,r;null==(e=this._yWebsocketProvider)||e.off("connection-close",this._onConnectionClosed),null==(t=this._yWebsocketProvider)||t.off("sync",this._onSync),null==(r=this._yWebsocketProvider)||r.destroy(),this._yWebsocketProvider=null}_onUserChanged(e){this._awareness.setLocalStateField("user",e.identity)}_buildSessionExpiredMessage(e,t){switch(e.reason){case"version_mismatch":return{title:t.__("Collaboration extension updated"),body:t.__("Reload the browser tab to load the new version.")};case"initialization_error":return{title:t.__("Document error"),body:t.__("Failed to initialize the document. Close this tab and reopen the file.")};default:return{title:t.__("Session expired"),body:e.errorReason?t.__(e.errorReason):t.__("Reload the browser tab to continue.")}}}_attachConflictListener(){var e;this._conflictWs&&this._conflictWs.removeEventListener("message",this._handleConflictMessage);let t=null==(e=this._yWebsocketProvider)?void 0:e.ws;t&&(t.addEventListener("message",this._handleConflictMessage),this._conflictWs=t)}_getCloseReasonMessage(e){switch(e){case 4400:return this._trans.__("Bad request for %1",this._path);case 4404:return this._trans.__("Could not find %1",this._path);case 4500:return this._trans.__("Internal server error when loading %1",this._path)}}}var k=r(5524),C=r.n(k),T=r(2591),D=r.n(T),R=r(1740),E=r.n(R),L=r(8128),P=r.n(L),U=r(855),$=r.n(U),x=r(3051),F=r.n(x),j=r(3656),M=r.n(j),I=r(5068),W={};W.styleTagTransform=M(),W.setAttributes=$(),W.insert=P().bind(null,"head"),W.domAPI=E(),W.insertStyleElement=F(),D()(I.A,W),I.A&&I.A.locals&&I.A.locals;var N=r(5518);let A=({apiURL:e,provider:t,contentType:r,format:s,documentTimelineUrl:o,serverSettings:i})=>{let a,l,c,d,h,g,v,[m,f]=(0,k.useState)({roomId:"",timestamps:[],forkRoom:"",sessionId:""}),[y,w]=(0,k.useState)(m.timestamps.length-1),[S,b]=(0,k.useState)(!1),[T,D]=(0,k.useState)(!1),R=(0,k.useRef)(!0),E=(0,k.useRef)(!0),L=(0,k.useRef)(null);async function P(o){try{if(R.current){let a=await _(s,r,o,i);if(!a.ok)if(404===a.status)throw Error("Not found");else if(503===a.status)throw Error("WebSocket closed");else throw Error(`Failed to fetch data: ${a.statusText}`);let l=await a.text(),c={roomId:"",timestamps:[],forkRoom:"",sessionId:""};return l&&(n.Notification.warning("Document is now in read-only mode. Changes will not be saved.",{autoClose:2500}),c=JSON.parse(l),f(c),w(c.timestamps.length-1),t.connectToForkDoc(c.forkRoom,c.sessionId),L.current=await u(s,r,x(e),i)),b(!0),R.current=!1,c}}catch(e){console.error("Error fetching data:",e)}}let U=async()=>{if(!L.current)return void console.error("Session is not initialized");let e=await p(`${L.current.format}:${L.current.type}:${L.current.fileId}`,"restore",0,m.forkRoom,i);200===e.code?(n.Notification.success(e.status,{autoClose:4e3}),t.reconnect(),b(!1),R.current=!0):n.Notification.error(e.status,{autoClose:4e3})},$=async e=>{let t=parseInt(e.target.value),r=Math.abs(t-y);try{let e=t<y?"undo":"redo";if(w(t),E.current&&(D(!0),E.current=!1),!L.current)return void console.error("Session is not initialized");await p(`${L.current.format}:${L.current.type}:${L.current.fileId}`,e,r,m.forkRoom,i)}catch(e){console.error("Error fetching or applying updates:",e)}};function x(e){try{let t=new URL(e).pathname,r=t.lastIndexOf(o);if(-1===r)throw Error(`API segment "${o}" not found in URL.`);return t.slice(r+o.length)}catch(e){return console.error("Invalid URL or unable to extract filename:",e),""}}return C().createElement("div",{className:"jp-sliderContainer"},C().createElement("div",{onClick:()=>{P(x(e))},className:"jp-mod-highlighted",title:"Document Timeline"},C().createElement(N.historyIcon.react,{marginRight:"4px"})),S&&C().createElement("div",{className:"jp-timestampDisplay"},C().createElement("input",{type:"range",min:0,max:m.timestamps.length-1,value:y,onChange:$,className:"jp-Slider"}),C().createElement("div",null,C().createElement("strong",null,x(e).split("/").pop()," ")," "),T&&C().createElement("div",{className:"jp-restoreBtnContainer"},C().createElement("button",{onClick:U,className:"jp-ToolbarButtonComponent jp-restoreBtn"},"Restore version"," ",(l=(a=new Date(1e3*m.timestamps[y])).getFullYear(),c=String(a.getMonth()+1).padStart(2,"0"),d=String(a.getDate()).padStart(2,"0"),h=String(a.getHours()).padStart(2,"0"),g=String(a.getMinutes()).padStart(2,"0"),v=String(a.getSeconds()).padStart(2,"0"),`${l}-${c}-${d} ${h}:${g}:${v}`)))))};class O extends n.ReactWidget{constructor(e,t,r,s,o,n){super(),this.apiURL=e,this.provider=t,this.contentType=r,this.format=s,this.documentTimelineUrl=o,this._serverSettings=n,this.addClass("jp-timelineSliderWrapper")}render(){return k.createElement(A,{key:this.apiURL,apiURL:this.apiURL,provider:this.provider,contentType:this.contentType,format:this.format,documentTimelineUrl:this.documentTimelineUrl,serverSettings:this._serverSettings})}updateContent(e,t){this.apiURL=e,this.provider=t,this.contentType=this.provider.contentType,this.format=this.provider.format,this.update()}}let B=new S.Token("@jupyter/docprovider:IForkManagerToken"),J=new S.Token("@jupyter/docprovider:IDocumentProviderFactory"),V=new S.Token("@jupyter/docprovider:IAwarenessProviderFactory"),q="https://schema.jupyter.org/jupyter_collaboration/fork/v1";class K{constructor(e){this._disposed=!1,this._forkAddedSignal=new g.Signal(this),this._forkDeletedSignal=new g.Signal(this);const{contentProvider:t,eventManager:r}=e;this._contentProvider=t,this._eventManager=r,this._eventManager.stream.connect(this._handleEvent,this),this._serverSettings=e.serverSettings}get isDisposed(){return this._disposed}get forkAdded(){return this._forkAddedSignal}get forkDeleted(){return this._forkDeletedSignal}dispose(){var e;this._disposed||(null==(e=this._eventManager)||e.stream.disconnect(this._handleEvent),this._disposed=!0)}async createFork(e){let{rootId:t,title:r,description:s,synchronize:o}=e,n={method:"PUT",body:JSON.stringify({title:r,description:s,synchronize:o})},a=i.URLExt.join(d,t);return await h(a,n,this._serverSettings)}async getAllForks(e){let t=i.URLExt.join(d,e);return await h(t,{method:"GET"},this._serverSettings)}async deleteFork(e){let{forkId:t,merge:r}=e,s=i.URLExt.join(d,t),o=i.URLExt.objectToQueryString({merge:r});await h(`${s}${o}`,{method:"DELETE"},this._serverSettings)}getProvider(e){let{documentPath:t,format:r,type:s}=e,o=this._contentProvider;if(o)return o.providers.get(`${r}:${s}:${t}`)}_handleEvent(e,t){if(t.schema_id===q)switch(t.action){case"create":this._forkAddedSignal.emit(t);break;case"delete":this._forkDeletedSignal.emit(t)}}}}}]);