UNPKG

@cocalc/static

Version:

CoCalc's static frontend Webpack-based build system and framework

1 lines 24.4 kB
(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[349],{61011:(t,i,e)=>{var s,n,r,o,h,l,d,a,c,u,_,f,m,p,g,v,y=function(t,i){if(!(t instanceof i))throw new Error("Bound instance method accessed before binding")};s=window.$,g=e(16539),r=e(29280),c=e(24620),({webapp_client:v}=e(97636)),({redux:_}=e(32295)),({FileEditor:n,codemirror_session_editor:o}=e(54177)),m=e(56677),l=e(33633),({jupyter_history_viewer_jquery_shim:d}=e(99815)),p=s("#webapp-editor-templates"),({file_associations:h}=e(6279)),f=i.HistoryEditor=class extends n{constructor(t,i,e,s){super(t,i),this.init_paths=this.init_paths.bind(this),this.init_syncstring=this.init_syncstring.bind(this),this.init_ui=this.init_ui.bind(this),this.close=this.close.bind(this),this.remove=this.remove.bind(this),this.disconnect_from_session=this.disconnect_from_session.bind(this),this.init_view_doc=this.init_view_doc.bind(this),this.init_slider=this.init_slider.bind(this),this.diff_mode=this.diff_mode.bind(this),this.set_doc=this.set_doc.bind(this),this.set_doc_diff=this.set_doc_diff.bind(this),this.account_id_to_username=this.account_id_to_username.bind(this),this.goto_revision=this.goto_revision.bind(this),this.goto_diff=this.goto_diff.bind(this),this.update_buttons=this.update_buttons.bind(this),this.render_slider=this.render_slider.bind(this),this.resize_slider=this.resize_slider.bind(this),this.render_diff_slider=this.render_diff_slider.bind(this),this.resize_diff_slider=this.resize_diff_slider.bind(this),this.process_view=this.process_view.bind(this),this.mount=this.mount.bind(this),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.load_full_history=this.load_full_history.bind(this),this.export_to_json=this.export_to_json.bind(this),this._use_timeago=!_.getStore("account").getIn(["other_settings","time_ago_absolute"]),this.init_paths(),this.element=p.find(".webapp-editor-history").clone(),this.element.processIcons(),r.series([t=>this.init_syncstring(t),t=>this.init_view_doc(s,t)],(t=>t?alert_message({type:"error",message:`Failed to open history document -- ${t}`}):(this.init_slider(),this.init_ui())))}jupyter_classic(){var t;return null!=this._jupyter_classic?this._jupyter_classic:this._jupyter_classic=!!(null!=(t=_.getStore("account"))?t.getIn(["editor_settings","jupyter_classic"]):void 0)}init_paths(){var t;if(y(this,f),t=c.path_split(this.filename),this._path=t.tail.slice(1,t.tail.length-".sage-history".length),this._open_file_path=this._path,t.head?this._open_file_path=t.head+"/"+this._path:this._open_file_path=this._path,this.ext=c.filename_extension(this._path),"ipynb"===this.ext&&(this.jupyter_classic()?this._path="."+this._path+e(33633).IPYTHON_SYNCFILE_EXTENSION:this._path=c.meta_file(this._path,"jupyter2")),t.head)return this._path=t.head+"/"+this._path}async init_syncstring(t){y(this,f);try{return this.syncstring=await v.sync_client.open_existing_sync_document({project_id:this.project_id,path:this._path,persistent:"ipynb"===this.ext||"sagews"===this.ext}),this.syncstring.once("ready",t)}catch(i){return"function"==typeof t?t(i):void 0}}async init_ui(){if(y(this,f),this.render_slider(),this.render_diff_slider(),this.syncstring.on("change",(()=>this._diff_mode?this.resize_diff_slider():this.resize_slider())),this.syncstring.has_full_history()?this.load_all.hide():this.load_all.show(),await this.syncstring.wait_until_read_only_known(),!this.syncstring.is_read_only())return this.element.find('a[href="#revert"]').show()}close(){return y(this,f),this.remove()}remove(){var t,i;return y(this,f),null!=(t=this.syncstring)&&t.close(),null!=(i=this.view_doc)&&"function"==typeof i.remove?i.remove():void 0}disconnect_from_session(){return y(this,f),this.close()}init_view_doc(t,i){var e,s;return y(this,f),t.mode="",t.read_only=!0,this._use_react=!1,"ipynb"===this.ext?this.jupyter_classic()?(this.view_doc=l.jupyter_notebook(this,this._open_file_path,t).data("jupyter_notebook"),this.element.find('a[href="#show-diff"]').hide()):(this._use_react=!0,this.view_doc=d(this.syncstring),this.diff_doc=o(this.project_id,this.filename,t)):this.view_doc=o(this.project_id,this.filename,t),"course"===(s=this.ext)||"sage-chat"===s?(this.element.find(".webapp-editor-history-no-viewer").show(),this.top_elt=this.element.find(".webapp-editor-history-no-viewer")):this.top_elt=this.element.find(".webapp-editor-history-sliders"),this.element.find(".webapp-editor-history-history_editor").append(this.view_doc.element),"sagews"===this.ext&&(e={allow_javascript_eval:!1,static_viewer:!0},this.worksheet=new m.SynchronizedWorksheet(this.view_doc,e)),"ipynb"===this.ext&&this.jupyter_classic()?(this.view_doc.once("ready",(()=>(this.view_doc.element.find(".smc-jupyter-notebook-buttons").hide(),this.show(),i()))),this.view_doc.once("failed",(()=>i("failed")))):(this.show(),i()),null!=this.diff_doc?this.diff_doc:this.diff_doc=this.view_doc}init_slider(){var t,i,e,s,n,r;for(y(this,f),this.slider=this.element.find(".webapp-editor-history-slider"),this.forward_button=this.element.find('a[href="#forward"]'),this.back_button=this.element.find('a[href="#back"]'),this.load_all=this.element.find('a[href="#all"]'),i=0,e=(r=[this.view_doc,this.diff_doc]).length;i<e;i++)null!=(t=r[i])&&(t.element.find(".webapp-editor-save-group").hide(),t.element.find(".webapp-editor-chat-title").hide(),t.element.find(".smc-editor-file-info-dropdown").hide());return this.slider.show(),this.load_all.click((async()=>(await this.load_full_history(),this.load_all.hide()))),this.forward_button.click((()=>(this.forward_button.hasClass("disabled")||(this._diff_mode?this.set_doc_diff(...this.goto_diff(this.revision_num1+1,this.revision_num+1)):this.set_doc(this.goto_revision(this.revision_num+1))),!1))),this.back_button.click((()=>(this.back_button.hasClass("disabled")||(this._diff_mode?this.set_doc_diff(...this.goto_diff(this.revision_num1-1,this.revision_num-1)):this.set_doc(this.goto_revision(this.revision_num-1))),!1))),s=()=>_.getProjectActions(this.project_id).open_file({path:this._open_file_path,foreground:!0}),n=()=>_.getProjectActions(this.project_id).open_directory(".snapshots"),this.element.find('a[href="#snapshots"]').click((()=>n())),this.element.find('a[href="#export"]').click((()=>(this.export_to_json(),!1))),this.element.find('a[href="#file"]').click(s),this.element.find('a[href="#revert"]').click((()=>{var t,i,e;if(null!=this.revision_num&&null!=(e=null!=(t=this.syncstring)&&null!=(i=t.all_versions())?i[this.revision_num]:void 0))return this.syncstring.revert(e),this.syncstring.commit(),s(),this.syncstring.emit("change")})),this.diff_slider=this.element.find(".webapp-editor-history-diff-slider"),this.element.find('a[href="#show-diff"]').click((()=>(this.diff_mode(!0),!1))),this.element.find('a[href="#hide-diff"]').click((()=>(this.diff_mode(!1),!1)))}diff_mode(t){var i,e,s,n,r,o,h,l,d,a;if(y(this,f),null!=this.syncstring){if(this._diff_mode=t,t){for(this.view_doc!==this.diff_doc&&(this.element.find(".webapp-editor-history-history_editor").empty().append(this.diff_doc.element),"function"==typeof(i=this.diff_doc).show&&i.show()),this.element.find('a[href="#hide-diff"]').show(),this.element.find('a[href="#show-diff"]').hide(),this.element.find(".webapp-editor-history-diff-mode").show(),this.diff_slider.show(),this.slider.hide(),this.set_doc_diff(...this.goto_diff()),a=[],n=0,o=(l=this.diff_doc.codemirrors()).length;n<o;n++)s=l[n],null==this._non_diff_theme&&(this._non_diff_theme=s.getOption("theme")),a.push(s.setOption("theme",""));return a}for(this.view_doc!==this.diff_doc&&(this.element.find(".webapp-editor-history-history_editor").empty().append(this.view_doc.element),"function"==typeof(e=this.view_doc).show&&e.show()),r=0,h=(d=this.diff_doc.codemirrors()).length;r<h;r++)(s=d[r]).setOption("lineNumbers",!0),s.setOption("gutters",[]),null!=this._non_diff_theme&&s.setOption("theme",this._non_diff_theme),s.setValue(""),s.setValue(this.syncstring.version(this.goto_revision(this.revision_num)).to_str());return this.element.find('a[href="#hide-diff"]').hide(),this.element.find('a[href="#show-diff"]').show(),this.element.find(".webapp-editor-history-diff-mode").hide(),this.diff_slider.hide(),this.slider.show(),this.set_doc(this.goto_revision())}}set_doc(t){var i;if(y(this,f),null!=t)return this._use_react?this.view_doc.set_version(t):(i=this.syncstring.version(t).to_str(),"ipynb"===this.ext?this.view_doc.dom.set(i):this.view_doc.codemirror.setValueNoJump(i)),this.process_view()}set_doc_diff(t,i){var e,n,r,o,h,l,d,u,_,m,p,g,v,w,b,x,k,j,C,A,S,L,E,N,z,O,M,$,P,I,D,T,R,U,G,F,V,B,H,W,J,K,Y,X,q,Z,Q,tt,it,et,st,nt,rt;if(y(this,f),null!=this.syncstring){for(this._use_react?(it=this.view_doc.to_str(t),et=this.view_doc.to_str(i)):(it=this.syncstring.version(t).to_str(),et=this.syncstring.version(i).to_str()),({patches:P,to_line:Y}=a(it,et)),L=[],X=[],S=[],J={},o=[],C=0,d=0,m=P.length;d<m;d++){for(N=(nt=P[d]).start1,z=nt.start2,N+=C,C+=nt.length1-nt.length2,_=0,p=(T=nt.diffs).length;_<p;_++)for(E=0,g=(R=(rt=T[_])[1]).length;E<g;E++){if(r=R[E],-1===rt[0])N+=1,S.push([N,""]);else if(1===rt[0])z+=1,S.push(["",z]);else{if(J[u=`${N+=1}-${z+=1}`])continue;S.push([N,z]),J[u]=!0}L.push(Y[r]),X.push(rt[0])}o.push(L.length-1)}for(W=L.join("\n"),A=function(t,i){return s(`<span class='smc-history-diff-number'>${S[t][i]}</span>`)[0]},M=0,v=(U=this.diff_doc.codemirrors()).length;M<v;M++){for((h=U[M]).setValueNoJump(W),h.setOption("lineNumbers",!1),h.setOption("gutters",["smc-history-diff-gutter1","smc-history-diff-gutter2"]),l=$=0,G=X.length;0<=G?$<G:$>G;l=0<=G?++$:--$)if(-1===X[l]){for(I=0,w=(F=["wrap","gutter"]).length;I<w;I++)K=F[I],h.addLineClass(l,K,`smc-history-diff-${K}-delete`),h.removeLineClass(l,K,`smc-history-diff-${K}-insert`);h.setGutterMarker(l,"smc-history-diff-gutter1",A(l,0))}else if(1===X[l]){for(D=0,b=(V=["wrap","gutter"]).length;D<b;D++)K=V[D],h.addLineClass(l,K,`smc-history-diff-${K}-insert`),h.removeLineClass(l,K,`smc-history-diff-${K}-delete`);h.setGutterMarker(l,"smc-history-diff-gutter2",A(l,1))}else{for(q=0,x=(B=["wrap","gutter"]).length;q<x;q++)K=B[q],h.removeLineClass(l,K),h.removeLineClass(l,K);h.setGutterMarker(l,"smc-history-diff-gutter1",A(l,0)),h.setGutterMarker(l,"smc-history-diff-gutter2",A(l,1))}for(tt=0,k=o.length;tt<k;tt++)l=o[tt],h.addLineClass(l,"wrap","smc-history-diff-wrap-divide")}for(n={},st=0,j=(H=this.syncstring.versions()).length;st<j;st++)(K=H[st])>t&&K<=i&&(n[this.syncstring.account_id(K)]=!0);for(e in Q=[],n)n[e],O=this.account_id_to_username(e),Q.push(c.trunc_middle(O,25).trim());return Q.length>0?(Q.sort((function(t,i){return c.cmp(t.toLowerCase(),i.toLowerCase())})),Z=Q.join(", ")):Z="",this.element.find(".webapp-editor-history-revision-user").text(Z),this.process_view()}}account_id_to_username(t){var i,e,s;return y(this,f),t===this.project_id?"Project: "+(null!=(i=_.getStore("projects"))?i.get_title(t):void 0):null!=(e=null!=(s=_.getStore("users"))?s.get_name(t):void 0)?e:"Unknown"}goto_revision(t){var i,e,n,r,o,h,l,d,a,u;if(y(this,f),null==t&&(t=this.revision_num),null!=t&&null!=(u=null!=(n=this.syncstring)?n.all_versions():void 0)&&(null==(l=u[t])&&(l=u[t=this.length-1]),this.revision_num=t,null!=l))return this.slider.slider("option","value",this.revision_num),this.update_buttons(),h=l.toLocaleString(),this.element.find(".webapp-editor-history-revision-time").text(this._use_timeago?s.timeago(h):h).attr("title",h),this.element.find(".webapp-editor-history-revision-number").text(`, revision ${t+1} (of ${this.length})`),i=this.syncstring.account_id(l),null!=(d=this.syncstring.time_sent(l))&&Math.abs(d-l)<6e4&&(d=void 0),a=null!=(e=i===this.project_id?"Project: "+(null!=(r=_.getStore("projects"))?r.get_title(i):void 0):null!=(o=_.getStore("users"))?o.get_name(i):void 0)?c.trunc_middle(e,50):"",null!=d&&(a+=` (OFFLINE WARNING: sent ${s.timeago(d)}) `),this.element.find(".webapp-editor-history-revision-user").text(a),l}goto_diff(t,i){var e,n,r,o,h,l,d;if(y(this,f),null==i&&(i=this.revision_num),null!=i&&(null==t&&(t=null!=(e=this.revision_num1)?e:Math.max(0,Math.floor(i/2))),null!=(d=null!=(n=this.syncstring)?n.all_versions():void 0)&&(null==(h=d[t])&&(h=d[t=0]),null==(l=d[i])&&(l=d[i=this.length-1]),this.revision_num1=t,this.revision_num=i,null!=h&&null!=l)))return this.diff_slider.slider("option","values",[t,i]),this.update_buttons(),r=h.toLocaleString(),this.element.find(".webapp-editor-history-revision-time").text(this._use_timeago?s.timeago(r):r).attr("title",r),o=l.toLocaleString(),this.element.find(".webapp-editor-history-revision-time2").text(this._use_timeago?s.timeago(o):o).attr("title",o),this.element.find(".webapp-editor-history-revision-number").text(`, revisions ${t+1} to ${i+1} (of ${this.length})`),[h,l]}update_buttons(){return y(this,f),0===this.revision_num?this.back_button.addClass("disabled"):this.back_button.removeClass("disabled"),this.revision_num===this.length-1?this.forward_button.addClass("disabled"):this.forward_button.removeClass("disabled")}render_slider(){var t,i,e;if(y(this,f),null!=this.syncstring)return this.length=this.syncstring.all_versions().length,this.revision_num=this.length-1,""!==this.ext&&null!=(null!=(t=h[this.ext])?t.opts.mode:void 0)&&null!=(i=this.view_doc.codemirror)&&i.setOption("mode",h[this.ext].opts.mode),e=g.debounce((t=>this.set_doc(t)),150),this.slider.slider({animate:!1,min:0,max:this.length-1,step:1,value:this.revision_num,slide:(t,i)=>e(this.goto_revision(i.value))}),this.set_doc(this.goto_revision(this.revision_num))}resize_slider(){var t;if(y(this,f),null!=this.syncstring&&(t=this.syncstring.all_versions().length)!==this.length)return this.length=t,this.slider.slider({max:this.length-1}),this.update_buttons(),this.goto_revision()}render_diff_slider(){var t;if(y(this,f),null!=this.syncstring)return this.length=this.syncstring.all_versions().length,this.revision_num=this.length-1,t=g.debounce((t=>{if(null!=t)return this.set_doc_diff(t[0],t[1])}),150),this.diff_slider.slider({animate:!1,min:0,max:this.length-1,step:1,values:[Math.max(Math.floor(this.revision_num/2),0),this.revision_num],range:!0,slide:(i,e)=>e.values[0]>=e.values[1]?(e.values[0]=Math.max(0,e.values[1]-1),setTimeout((()=>this.diff_slider.slider({values:e.values})),200)):t(this.goto_diff(e.values[0],e.values[1]))})}resize_diff_slider(){var t;if(y(this,f),null!=this.syncstring&&(t=this.syncstring.all_versions().length)!==this.length)return this.length=t,this.diff_slider.slider({max:this.length-1}),this.goto_diff()}process_view(){if(y(this,f),"sagews"===this.ext)return this.worksheet.process_sage_updates()}mount(){return y(this,f),this.mounted||(s(document.body).append(this.element),this.mounted=!0),this.mounted}show(){var t;if(y(this,f),this.is_active()&&null!=this.element&&null!=this.view_doc)return this.element.show(),this.view_doc.show(),"sagews"===this.ext&&null!=(t=this.worksheet)?t.process_sage_updates():void 0}hide(){var t;return y(this,f),null!=(t=this.view_doc)?t.hide():void 0}async load_full_history(){var t,i;if(y(this,f),null!=this.syncstring)return t=this.syncstring.all_versions().length,await this.syncstring.load_full_history(),this._diff_mode?this.resize_diff_slider():this.resize_slider(),null!=this.revision_num?(i=this.syncstring.all_versions().length-t,this.goto_revision(this.revision_num+i)):void 0}async export_to_json(){var t,i,e,s,n;if(y(this,f),null!=this.syncstring&&"ready"!==!this.syncstring.get_state()){for(i=0,e=(n=this.syncstring.export_history({patches:!1,patch_lengths:!0})).length;i<e;i++)(t=n[i]).user=this.account_id_to_username(t.account_id);s=this._path+"-timetravel.json";try{return await v.project_client.write_text_file({project_id:this.project_id,path:s,content:JSON.stringify(n,null,2)}),alert_message({type:"info",message:`Exported history to ${s}.`,timeout:5}),_.getProjectActions(this.project_id).open_file({path:s,foreground:!0})}catch(t){return alert_message({type:"error",message:`Error exporting history to file -- ${t}`,timeout:15})}}else alert_message({type:"error",message:"History not yet available. Try again later.",timeout:15})}},({patch_make:u}=e(42188)),a=function(t,i){var e;return e=new c.StringCharMapping,{patches:u(e.to_string(t.split("\n")),e.to_string(i.split("\n"))),to_line:e._to_string}}},99815:(t,i,e)=>{"use strict";e.r(i),e.d(i,{HistoryViewer:()=>p,jupyter_history_viewer_jquery_shim:()=>v,to_ipynb:()=>g});var s=e(85460),n=e(32295),r=e(24620),o=e(14471),h=e(38403),l=e(19428),d=e(19990),a=e(60005),c=e(92990),u=e(63510),_=e.n(u),f=e(63505);function m(t,i){var e=(0,s.Map)(),n=t.version(i).get({type:"cell"});null!=n&&n.forEach((function(t){return e=e.set(t.get("id"),t)}));var r=o.kr(e);return{cells:e,cell_list:r}}var p=function(t){var i,e,o=t.syncdb,c=t.version,u=t.font_size,_=null!==(e=(0,n.useTypedRedux)("account","font_size"))&&void 0!==e?e:14,p=o.get_project_id(),g=(0,r.path_split)(o.get_path()).head,v=m(o,c),y=v.cells,w=v.cell_list,b=(0,s.fromJS)({markdown:void 0,options:(0,l.C)()}),x=null===(i=o.version(c).get_one({type:"settings"}))||void 0===i?void 0:i.get("kernel_error");return f.createElement("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflowY:"hidden"}},x&&f.createElement(d.ErrorDisplay,{bsStyle:"warning",error:x,style:a.m}),f.createElement(h.R,{cell_list:w,cells:y,font_size:null!=u?u:_,mode:"escape",cm_options:b,project_id:p,directory:g,trust:!1}))};function g(t,i){return(0,c.m)(m(t,i))}function v(t){var i=$("<div class='smc-vfill'></div>");return{element:i,show:function(){return i.show()},hide:function(){return i.hide()},remove:function(){return n.ReactDOM.unmountComponentAtNode(i[0])},set_version:function(e){return n.ReactDOM.render(f.createElement(n.Redux,null,f.createElement(p,{syncdb:t,version:e})),i[0])},to_str:function(i){var e=g(t,i);return _()(e,{space:1})}}}},92858:(t,i)=>{"use strict";i.dd=void 0,i.dd={bootstrap:"3.4.1",codemirror:"5.65.3",jest:"29.3.1",katex:"0.15.0",mathjax:"2.7.9","pdfjs-dist":"2.13.216"}},16609:(t,i,e)=>{"use strict";e.d(i,{v:()=>r});var s=e(33638),n=e(24620);function r(t,i,e,r){(0,n.merge)(t,{"Shift-Alt-L":function(t){return t.align_assignments()},"Alt-Z":function(t){return t.undo()},"Shift-Alt-Z":function(t){return t.redo()},"Alt-A":function(t){return t.execCommand("selectAll")},"Shift-Alt-A":function(t){return t.execCommand("selectAll")},"Shift-Alt-K":function(t){return t.execCommand("killLine")},"Alt-D":function(t){return t.execCommand("selectNextOccurrence")},"Alt-F":function(t){return t.execCommand("find")},"Shift-Alt-F":function(t){return t.execCommand("replace")},"Shift-Alt-R":function(t){return t.execCommand("replaceAll")},"Shift-Alt-D":function(t){return t.execCommand("duplicateLine")},"Alt-G":function(t){return t.execCommand("findNext")},"Shift-Alt-G":function(t){return t.execCommand("findPrev")},"Cmd-Up":function(t){return t.execCommand("goPageUp")},"Cmd-Down":function(t){return t.execCommand("goPageDown")},"Alt-K":function(t){return t.execCommand("goPageUp")},"Alt-J":function(t){return t.execCommand("goPageDown")},"Alt-P":function(t){return t.execCommand("goLineUp")},"Alt-N":function(t){return t.execCommand("goLineDown")},"Alt-L":function(t){return t.execCommand("jumpToLine")},"Alt-C":function(){return i.copy(e)},"Alt-X":function(){return i.cut(e)},"Alt-V":function(){return i.paste(e)},"Alt-S":function(){return i.save(!0)}}),"vim"===(null==r?void 0:r.bindings)&&(t["Alt-C"]=function(t){s.Vim.exitInsertMode(t)},t["Alt-F"]=function(t){t.execCommand("goPageDown")},t["Alt-B"]=function(t){t.execCommand("goPageUp")})}},8407:(t,i,e)=>{"use strict";function s(t){return"number"!=typeof t||isNaN(t)||t<=1?4:t}function n(t){var i=t.getWrapperElement();i.classList.add("smc-vfill"),i.setAttribute("style",i.getAttribute("style")+"; height:100%; font-family:monospace !important;")}e.d(i,{L:()=>n,k:()=>s})},48668:(t,i,e)=>{"use strict";e.d(i,{U:()=>s});var s="sitemap"},78193:(t,i,e)=>{"use strict";e.d(i,{gk:()=>c,kX:()=>u,oC:()=>_});var s=e(24620),n=e(19990),r=e(32295),o=e(97891),h=e(92858),l="cdn";var d=e(74481),a=void 0;function c(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:800,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:640,s=window.open(t,"_blank","menubar=yes,toolbar=no,resizable=yes,scrollbars=yes,height=".concat(e,",width=").concat(i));if(!s||void 0===s.closed)throw a||void 0===a?(a=!0,Error("Popup blocked. Please unblock popups for this site.")):Error("If you have a window already opened printing a document, close it first.");return a=!1,s}function u(t){t.src||(t.src="");var i=c(t.src);if(""==t.src){if(!t.project_id||!t.path)throw Error("BUG project_id and path must be specified if src not given.");!function(t,i){if(!i.path)throw Error("write_content -- path must be defined");var e,a=(0,s.path_split)(i.path);if(null==i.html){var c={value:i.value,project_id:i.project_id,file_path:a.head},u=r.React.createElement(r.Redux,{redux:r.redux},r.React.createElement(n.HTML,c));e=d.renderToStaticMarkup(u)}else e=i.html;e=function(t,i){var e=function(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"/"!=t.slice(-1)&&(t+="/");var e=function(t){return i?"-".concat(h.dd[t]):""};return[{href:"".concat(t).concat(l,"/bootstrap").concat(e("bootstrap"),"/bootstrap.min.css"),rel:"stylesheet"},{href:"".concat(t).concat(l,"/codemirror").concat(e("codemirror"),"/lib/codemirror.css"),rel:"stylesheet"},{href:"".concat(t).concat(l,"/katex").concat(e("katex"),"/katex.min.css"),rel:"stylesheet"}]}(o.BASE_URL).map((function(t){var i=t.href,e=t.rel,s=t.integrity,n=t.crossOrigin,r=[];return r.push('href="'.concat(i,'"')),e&&r.push('rel="'.concat(e,'"')),s&&r.push('integrity="'.concat(s,'"')),n&&r.push('crossOrigin="'.concat(n,'"')),"<link ".concat(r.join(" ")," />")})).join(" ");return'<html lang="en">\n <head>\n <title>'.concat(i,'</title>\n <meta name="google" content="notranslate"/>\n ').concat(e,"\n </head>\n <body style='margin:7%'>\n ").concat(t,"\n </body>\n</html>")}(e,(0,s.path_split)(i.path).tail),t.document.write(e),t.document.close()}(i,t)}_(i)}function _(t){null!==t.window.print&&(t.window.onload=function(){t.window.print()})}},14471:(t,i,e)=>{"use strict";e.d(i,{A9:()=>r,Yw:()=>h,kr:()=>o,tg:()=>l,wo:()=>d});var s=e(85460),n=e(24620);function r(t,i,e){var s,n,r;null!=t&&null!=i&&t>i&&(t=(r=[i,t])[0],i=r[1]),null==t?null==i?(n=0,s=1):(n=i-e,s=1):null==i?(n=t+1,s=1):n=t+(s=(i-t)/(e+1));for(var o=[],h=0,l=e,d=0<=l;d?h<l:h>l;d?h++:h--)o.push(n),n+=s;return o}function o(t){return null==t?(0,s.List)([]):t.map((function(t,i){return{id:i,pos:t.get("pos",-1)}})).filter((function(t){return null!=t.id})).sort((0,n.field_cmp)("pos")).map((function(t){return t.id})).toList()}function h(t){if(null!=t){var i={},e=!0;if(t.forEach((function(t){var s=t.get("pos");if(null==s||i[s])return e=!1,!1;i[s]=!0})),!e){var s=0,n={};return o(t).forEach((function(t){n[t]=s,s+=1})),n}}}function l(t,i,e,s){var n,r;(n=null==i?o(t):i).forEach((function(t,i){if(t===e){var o=i+s;return o>=0&&o<n.size&&(r=n.get(o)),!1}}));var h=t.getIn([r,"pos"]),l=t.getIn([e,"pos"]);return null!=h?(h+l)/2:l+s}function d(t,i,e){if(null!=t&&null!=i&&e&&0!==(0,n.len)(i)){for(var s=[],r=0;r<t.length;r++)if(i[t[r]]){var o=r+e;if(o<0||o>=t.length)return;s[o]=t[r]}for(var h=0,l=0;l<t.length;l++)if(!i[t[l]]){for(;null!=s[h];)h+=1;s[h]=t[l]}return s}}},19428:(t,i,e)=>{"use strict";e.d(i,{C:()=>o});var s=e(67941),n=e(8407),r=e(16609);function o(t,i,e,o){var h;null==i&&(i={}),null==t&&(t={name:"python"}),"string"==typeof t&&(t={name:t}),"gp"===t.name&&(t.name="pari"),"singular"===t.name&&(t.name="clike"),"ihaskell"===t.name&&(t.name="haskell");var l={mode:t,firstLineNumber:i.first_line_number,showTrailingSpace:i.show_trailing_whitespace||"gfm2"===(t&&t.name),indentUnit:(0,n.k)(i.tab_size),tabSize:(0,n.k)(i.tab_size),smartIndent:i.smart_indent,electricChars:i.electric_chars,undoDepth:i.undo_depth,matchBrackets:i.match_brackets,autoCloseBrackets:i.auto_close_brackets,autoCloseTags:i.auto_close_xml_tags,foldGutter:i.code_folding,lineWrapping:!0,readOnly:o,indentWithTabs:!i.spaces_instead_of_tabs,showCursorWhenSelecting:!0,extraKeys:{}};return"gfm2"==(null===(h=l.mode)||void 0===h?void 0:h.name)&&(l.spellcheck=!0,l.inputStyle="contenteditable"),s.IS_TOUCH&&(0,r.v)(l.extraKeys,void 0,i),null!=e&&(l.lineNumbers=e),null!=i.bindings&&"standard"!==i.bindings&&(l.keyMap=i.bindings),null!=i.theme&&"standard"!==i.theme&&(l.theme=i.theme),"ipython"===l.mode.name&&(l.mode.name="python"),l}}}]);