UNPKG

@cocalc/static

Version:

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

1 lines 153 kB
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[435],{14333:(t,e,n)=>{n.d(e,{F:()=>l,Z:()=>s});var r=n(63505),o=n(63505);function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t){var e=t.id,n=t.level,s=t.children,a=t.attributes,c=[],u=!0,_=!1,d=void 0;try{for(var f,h=(null!=s?s:[])[Symbol.iterator]();!(u=(f=h.next()).done);u=!0){var p,g,y=f.value;null!=(null==y||null===(p=y.props)||void 0===p?void 0:p.element)&&c.push(null==y||null===(g=y.props)||void 0===g?void 0:g.element)}}catch(t){_=!0,d=t}finally{try{u||null==h.return||h.return()}finally{if(_)throw d}}var v,m,b=l(c);return(0,r.createElement)("h".concat(n),(v=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),r.forEach((function(e){i(t,e,n[e])}))}return t}({id:e},a),m=null!=(m={className:"cocalc-jupyter-header"})?m:{},Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(m)):function(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n.push.apply(n,r)}return n}(Object(m)).forEach((function(t){Object.defineProperty(v,t,Object.getOwnPropertyDescriptor(m,t))})),v),(null!=s?s:[]).concat(o.createElement("a",{key:"jupyter-anchor",className:"cocalc-jupyter-anchor-link",href:"#".concat(b)},"¶")))}function l(t){var e="",n=!0,r=!1,o=void 0;try{for(var i,s=t[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var l=i.value,a=l.text,c=l.value;e+=null!=a?a:c?"$"+c+"$":""}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}return e.replace(/\s/g,"-")}},64445:(t,e,n)=>{n.d(e,{Bw:()=>o,Dg:()=>a,Eb:()=>s,lJ:()=>l,sm:()=>r,uz:()=>i});var r="student",o=6e4,i=6e5,s=5e5,l=4e6,a="GRADING-GUIDE.md"},60435:(t,e,n)=>{n.r(e),n.d(e,{Actions:()=>sn,JupyterEditorActions:()=>sn});var r={};n.r(r),n.d(r,{OutputModel:()=>wt,OutputView:()=>kt});var o={};n.r(o),n.d(o,{AccordionModel:()=>Ht,AccordionView:()=>Gt,BoxModel:()=>Dt,BoxView:()=>Mt,GridBoxModel:()=>Jt,GridBoxView:()=>Nt,HBoxModel:()=>qt,HBoxView:()=>Bt,ReactModel:()=>Tt,ReactView:()=>At,TabModel:()=>Yt,TabView:()=>Lt,UnsupportedModel:()=>Ft,UnsupportedView:()=>Vt,VBoxModel:()=>zt,VBoxView:()=>Ut});var i=n(95788),s=n(5010),l=n(24620),a=n(94873),c=n(11306);function u(t,e,n,r,o,i,s){try{var l=t[i](s),a=l.value}catch(t){return void n(t)}l.done?e(a):Promise.resolve(a).then(r,o)}function _(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){u(i,r,o,s,l,"next",t)}function l(t){u(i,r,o,s,l,"throw",t)}s(void 0)}))}}var d=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}};function f(t,e){return h.apply(this,arguments)}function h(){return(h=_((function(t,e){var n,r,o,i,s,u;return d(this,(function(_){switch(_.label){case 0:return n=(0,l.path_split)(e),r="._"+(0,l.separate_file_extension)(n.tail).name,o=["nbconvert","--to","slides",(0,c.sanitize_nbconvert_path)(e),"--output",r],i={command:"/usr/local/bin/jupyter",args:o,project_id:t},[4,(0,a.GL)(i)];case 1:return _.sent(),s=".slides.html",u=n.head?[n.head,r+s].join("/"):r+s,[2,(0,a.hN)(t,u)]}}))}))).apply(this,arguments)}var p=n(44965),g=n(85460),y=n(56160),v=n(20812),m=n(4538),b=n(42188),w=n(32295),k=n(28900);function j(t,e,n){if(!t)return"empty";if("prolog"!==n){var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"python",n=void 0;return k.Z.runMode(t,e,(function(t,e){n=e})),n}(t,e);if("comment"===r||"string"===r)return"execute";if(t.endsWith("??"))return"show_source";if(t.endsWith("?"))return"show_doc"}return"execute"}function S(t,e,n){if("python3"!==e)return t;switch(n){case"escape":var r;if((null===(r=t.match(/^#\%{3}#/gm))||void 0===r?void 0:r.length)>0)throw new Error("Cells with lines starting with '#%%%#' cannot be formatted.");return t.split("\n").map((function(t){return t.replace(/^\%(.*)$/,(function(t,e){return null!=e?"#%%%#%".concat(e):t}))})).join("\n");case"unescape":return t.split("\n").map((function(t){return t.replace(/^#\%{3}#(.*)$/,(function(t,e){return null!=e?"".concat(e):t}))})).join("\n")}}var O=n(14471),E=n(19428),x=n(43651);function I(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var R=[{cell_type:"code",execution_count:null,metadata:{},outputs:[],source:[]}],P={kernelspec:void 0,language_info:void 0},C=4,T=4,A=function(){function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.import=function(t){t=l.defaults(t,{ipynb:{},new_id:void 0,existing_ids:[],output_handler:void 0,process_attachment:void 0}),e._ipynb=l.deep_copy(t.ipynb),e._new_id=t.new_id,e._output_handler=t.output_handler,e._process_attachment=t.process_attachment,e._existing_ids=t.existing_ids,e._handle_old_versions(),e._sanity_improvements(),e._import_settings(),e._import_metadata(),e._read_in_cells()},this.cells=function(){return e._cells},this.kernel=function(){return e._kernel},this.metadata=function(){return e._metadata},this.close=function(){delete e._cells,delete e._kernel,delete e._metadata,delete e._language_info,delete e._ipynb,delete e._existing_ids,delete e._new_id,delete e._output_handler,delete e._process_attachment},this._sanity_improvements=function(){var t=e._ipynb;null!=t.cells&&0!==t.cells.length||(t.cells=l.deep_copy(R)),null==t.metadata&&(t.metadata=l.deep_copy(P)),null==t.nbformat&&(t.nbformat=C),null!=t.nbformat_minor?t.nbformat_minor:t.nbformat_minor=T},this._handle_old_versions=function(){var t=e._ipynb;if(!(t.nbformat>=4)){null==t.cells&&(t.cells=[]);var n=!0,r=!1,o=void 0;try{for(var i,s=(t.worksheets||[])[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var a=i.value,c=!0,u=!1,_=void 0;try{for(var d,f=(a.cells||[])[Symbol.iterator]();!(c=(d=f.next()).done);c=!0){var h=d.value;if(null!=h.input&&(h.source=h.input,delete h.input),"heading"===h.cell_type&&(h.cell_type="markdown",l.is_array(h.source)&&(h.source=h.source.join("")),h.source="# ".concat(h.source)),h.outputs){var p=!0,g=!1,y=void 0;try{for(var v,m=h.outputs[Symbol.iterator]();!(p=(v=m.next()).done);p=!0){var b=v.value;if("pyout"===b.output_type){var w=!0,k=!1,j=void 0;try{for(var S,O=x.b7[Symbol.iterator]();!(w=(S=O.next()).done);w=!0){var E=S.value,R=E.split("/")[1];if(null!=b[R]){var P=I({},E,b[R]);for(var C in b)delete b[C];b.data=P;break}}}catch(t){k=!0,j=t}finally{try{w||null==O.return||O.return()}finally{if(k)throw j}}if(null!=b.text){var T={"text/plain":b.text.join("")};for(var A in b)delete b[A];b.data=T}}}}catch(t){g=!0,y=t}finally{try{p||null==m.return||m.return()}finally{if(g)throw y}}}t.cells.push(h)}}catch(t){u=!0,_=t}finally{try{c||null==f.return||f.return()}finally{if(u)throw _}}}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}}},this._import_settings=function(){e._kernel=e._ipynb&&e._ipynb.metadata&&e._ipynb.metadata.kernelspec&&e._ipynb.metadata.kernelspec.name},this._import_metadata=function(){var t=null!=e._ipynb?e._ipynb.metadata:void 0;if(null!=t){var n={};for(var r in t){var o=t[r];"kernelspec"!==r&&(n[r]=o)}l.len(n)>0&&(e._metadata=n)}},this._read_in_cells=function(){var t=e._ipynb;if(e._cells={},null!=(null!=t?t.cells:void 0)){var n=0,r=!0,o=!1,i=void 0;try{for(var s,l=t.cells[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var a=s.value;a=e._import_cell(a,n),e._cells[a.id]=a,n+=1}}catch(t){o=!0,i=t}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}}},this._update_output_format=function(t){if((null!=e._ipynb?e._ipynb.nbformat:void 0)>=4)return t;if("stream"===t.output_type)l.is_array(t.text)&&(t.text=t.text.join("")),t.name=t.stream;else{var n=!0,r=!1,o=void 0;try{for(var i,s=x.b7[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var a=i.value,c=a.split("/")[1];if(null!=t[c]){t={data:I({},a,t[c])};break}}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}null!=t.text&&(t={data:{"text/plain":t.text},output_type:"stream"})}return t},this._join_array_strings_obj=function(t){if(null!=t)for(var e in t){var n=t[e];l.is_array(n)&&(t[e]=n.join(""))}return t},this._import_cell_output_content=function(t){t=e._update_output_format(t),e._join_array_strings_obj(t.data),l.is_array(t.text)&&(t.text=t.text.join("")),function(t){if(null!=t){var e,n=!0,r=!1,o=void 0;try{for(var i,s=x.b7[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var l=i.value;if(null!=t[l]){e=l;break}}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}if(null!=e)for(var a in t)void 0!==x.b7[a]&&a!==e&&delete t[a]}}(t.data),delete t.prompt_number},this._id_is_available=function(t){return!((null!=e._cells?e._cells[t]:void 0)||(null!=e._existing_ids?e._existing_ids:[]).includes(t))},this._get_new_id=function(){if(null!=e._new_id)return e._new_id(e._id_is_available);for(var t=0;;){var n="".concat(t);if(e._id_is_available(n))return n;t+=1}},this._get_exec_count=function(t,e){return null!=t?t:null!=e?e:null},this._get_cell_type=function(t){return null!=t?t:"code"},this._get_cell_output=function(t,n,r){if(null==t||0==t.length)return null;var o,i,s={id:r,output:{}};for(i in null!=e._output_handler&&(o=e._output_handler(s)),t){var l=t[i];null!=n&&null!=n[i]&&(l=n[i]),e._import_cell_output_content(l),null!=o?o.message(l):s.output[i]=l}return null!=o&&"function"==typeof o.done&&o.done(),s.output}}var e=t.prototype;return e._get_cell_input=function(t){return null!=t?l.is_array(t)?t.join(""):t:null},e._import_cell=function(t,e){var n=null!=(null!=this._existing_ids?this._existing_ids[e]:void 0)?null!=this._existing_ids?this._existing_ids[e]:void 0:this._get_new_id(),r={type:"cell",id:n,pos:e,input:this._get_cell_input(t.source),output:this._get_cell_output(t.outputs,null!=t.metadata&&null!=t.metadata.cocalc?t.metadata.cocalc.outputs:void 0,n),cell_type:this._get_cell_type(t.cell_type),exec_count:this._get_exec_count(t.execution_count,t.prompt_number)};if(null!=t.metadata){for(var o=0,i=["collapsed","scrolled"];o<i.length;o++){var s=i[o];t.metadata[s]&&(r[s]=!!(null!=t.metadata?t.metadata[s]:void 0))}null!=t.metadata.slideshow&&(r.slide=t.metadata.slideshow.slide_type),null!=t.metadata.tags&&(r.tags=l.dict(t.metadata.tags.map((function(t){return[t,!0]}))));var a=l.copy_without(t.metadata,["collapsed","scrolled","slideshow","tags","_root","__ownerID","__hash","__altered"]);l.len(a)>0&&(r.metadata=a)}if(null!=t.attachments)for(var c in r.attachments={},t.attachments){var u=t.attachments[c];for(var _ in u){var d=u[_];if(null!=this._process_attachment){var f=this._process_attachment(d,_);r.attachments[c]={type:"sha1",value:f}}else r.attachments[c]={type:"base64",value:d}}}return r},t}();var D=n(431);function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function J(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function N(t,e,n,r,o,i,s){try{var l=t[i](s),a=l.value}catch(t){return void n(t)}l.done?e(a):Promise.resolve(a).then(r,o)}function z(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){N(i,r,o,s,l,"next",t)}function l(t){N(i,r,o,s,l,"throw",t)}s(void 0)}))}}function U(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function q(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B(t){return B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},B(t)}function H(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),r.forEach((function(e){q(t,e,n[e])}))}return t}function G(t,e){return!e||"object"!==F(e)&&"function"!=typeof e?J(t):e}function Y(t,e){return Y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Y(t,e)}function L(t){return function(t){if(Array.isArray(t))return M(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||V(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var F=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};function V(t,e){if(t){if("string"==typeof t)return M(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(t,e):void 0}}var W=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}},K=1e5,Z=l.close,X=l.required,Q=l.defaults,tt=g.Map(),et=new Error("CellWriteProtectedException"),nt=new Error("CellDeleteProtectedException"),rt=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Y(t,e)}(s,t);var e,r,o=(e=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,n=B(e);if(r){var o=B(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return G(this,t)});function s(){var t;U(this,s),(t=o.apply(this,arguments)).last_cursor_move_time=new Date(0),t.sync_read_only=function(){if("closed"!=t._state){var e=t.store.get("read_only"),n=null!=t.syncdb?t.syncdb.is_read_only():void 0;e!==n&&(t.setState({read_only:n}),t.set_cm_options())}};var e=J(t);t.init_project_conn=(0,y.reuseInFlight)(z((function(){return W(this,(function(t){switch(t.label){case 0:return[4,(0,n(5850).zN)(e.store.get("project_id"))];case 1:return[2,e.project_conn=t.sent()]}}))})));var r=J(t);t.fetch_jupyter_kernels=z((function(){var t,e,n,o,i;return W(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,r.api_call("kernels")];case 1:return t=s.sent(),"closed"===r._state?[2]:[3,3];case 2:return e=s.sent(),"closed"===r._state||r.set_error(e),[2];case 3:return n=g.fromJS(t).filter((function(t){return!t.getIn(["metadata","cocalc","disabled"],!1)})),[4,r.store.jupyter_kernel_key()];case 4:return o=s.sent(),tt=tt.set(o,n),r.setState({kernels:n}),i=r.store.get_kernel_info(r.store.get("kernel")),r.setState({kernel_info:i}),[2]}}))}));var i=J(t);t.set_jupyter_kernels=z((function(){var t,e;return W(this,(function(n){switch(n.label){case 0:return null==i.store?[2]:(e=tt.get,[4,i.store.jupyter_kernel_key()]);case 1:return null==(t=e.apply(tt,[n.sent()]))?[3,2]:(i.setState({kernels:t}),[3,4]);case 2:return[4,i.fetch_jupyter_kernels()];case 3:n.sent(),n.label=4;case 4:return[4,i.update_select_kernel_data()];case 5:return n.sent(),i.check_select_kernel(),[2]}}))})),t.set_error=function(e){if("closed"!==t._state)if(null!=e){"string"!=typeof e&&(e="".concat(e));var n=t.store.get("error");(null!=n?n.indexOf(e):void 0)>=0||(n&&(e=e+"\n\n"+n),t.setState({error:e}))}else t.setState({error:void 0})},t.set_cell_output=function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t._set({type:"cell",id:e,output:n},r)},t.clear_selected_outputs=function(){t.deprecated("clear_selected_outputs")},t.set_md_cell_editing=function(e){t.deprecated("set_md_cell_editing",e)},t.set_md_cell_not_editing=function(e){t.deprecated("set_md_cell_not_editing",e)},t.set_cur_id=function(e){t.deprecated("set_cur_id",e)},t._syncdb_change=function(e){null!=t.syncdb&&(t.store.emit("syncdb-before-change"),t.__syncdb_change(e),t.store.emit("syncdb-after-change"),null!=t.set_save_status&&t.set_save_status())},t.__syncdb_change=function(e){if(null!=t.syncdb&&null!=e&&(null==e||0!=e.size)){var n=t.is_project&&"init"===t._state,r=!1;if("all"==e||null==t.store.get("cells")){var o=g.Map();t.syncdb.get().forEach((function(e){switch(e.get("type")){case"cell":o=o.set(e.get("id"),e);break;case"settings":if(null==e)return;var n=t.store.get("kernel"),r=e.get("kernel"),i={trust:!!e.get("trust"),backend_state:e.get("backend_state"),kernel_state:e.get("kernel_state"),metadata:e.get("metadata"),max_output_length:ot(e.get("max_output_length"),100,25e4,K)};r!==n&&(i.kernel=r,i.kernel_info=t.store.get_kernel_info(r),i.backend_kernel_info=void 0),t.setState(i),t.is_project||n===r||t.set_cm_options()}})),t.setState({cells:o,cell_list:O.kr(o)}),r=!1}else e.forEach((function(e){var n=e.get("type"),o=t.syncdb.get_one(e);switch(n){case"cell":t.syncdb_cell_change(e.get("id"),o)&&(r=!0);break;case"fatal":var i=null!=o?o.get("error"):void 0;t.setState({fatal:i}),null!=i&&-1!==i.indexOf("file is currently being read or written")&&(t.syncdb.delete({type:"fatal"}),t.syncdb.commit());break;case"nbconvert":t.is_project&&t.handle_nbconvert_change(t.store.get("nbconvert"),o),t.setState({nbconvert:o});break;case"settings":if(null==o)return;var s,l=t.store.get("kernel"),a=o.get("kernel"),c={trust:!!o.get("trust"),backend_state:o.get("backend_state"),kernel_state:o.get("kernel_state"),kernel_error:o.get("kernel_error"),metadata:o.get("metadata"),connection_file:null!==(s=o.get("connection_file"))&&void 0!==s?s:"",max_output_length:ot(o.get("max_output_length"),100,25e4,K)};a!==l&&(c.kernel=a,c.kernel_info=t.store.get_kernel_info(a),c.backend_kernel_info=void 0);var u=t.store.get("backend_state");if(t.setState(c),!t.is_project){var _="running"===o.get("backend_state")&&"running"!==u;(l!==a||_)&&t.set_cm_options()}}}));r&&t.set_cell_list(),t.is_project?(n&&(t.syncdb.set({type:"settings",backend_state:"init",kernel_state:"idle",kernel_usage:{memory:0,cpu:0}}),t.syncdb.commit(),t.initialize_manager()),t.store.get("kernel")&&t.manager_run_cell_process_queue()):("init"===t._state&&(t._state="ready"),t.check_select_kernel(),t.update_contents())}},t._syncdb_init_kernel=function(){if(null==t.store.get("kernel")){if(!t.is_project){var e=!1,n=t.redux.getStore("account").get("editor_settings");if(null!=n&&!n.get("ask_jupyter_kernel")){var r=n.getIn(["jupyter","kernel"]);null!=r&&(t.set_kernel(r),e=!0)}e||t.show_select_kernel("bad kernel"),t.setState({check_select_kernel_init:!0})}}else null==t.store.get_default_kernel()&&t.store.get("kernel")&&t.set_default_kernel(t.store.get("kernel"))},t._set=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!("ready"!==t._state||t.store.get("read_only")||null!=t.syncdb&&"ready"!=t.syncdb.get_state())){if("cell"===e.type&&null!=e.id&&!t.store.is_cell_editable(e.id))for(var r=0,o=["input","cell_type","attachments"];r<o.length;r++){var i=o[r];if(l.has_key(e,i))throw et}t.syncdb.set(e),n&&t.syncdb.commit(),t._syncdb_change(g.fromJS([l.copy_with(e,["id","type"])]))}},t._delete=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("closed"!==t._state&&!t.store.get("read_only")){if("cell"===e.type&&null!=e.id&&!t.store.is_cell_deletable(e.id))throw nt;t.syncdb.delete(e),n&&t.syncdb.commit(),t._syncdb_change(g.fromJS([{type:e.type,id:e.id}]))}},t._sync=function(){"closed"!==t._state&&t.syncdb.commit()};var a=J(t);t.save=z((function(){var t;return W(this,(function(e){switch(e.label){case 0:if(a.store.get("read_only"))return[2];"edit"===a.store.get("mode")&&a._get_cell_input(),e.label=1;case 1:return e.trys.push([1,5,6,7]),[4,a.syncdb.save()];case 2:return e.sent(),"closed"===a._state?[2]:[4,a.api_call("save_ipynb_file",{})];case 3:return e.sent(),"closed"===a._state?[2]:[4,a.syncdb.save_to_disk()];case 4:return e.sent(),[3,7];case 5:return t=e.sent(),"closed"===a._state||-1!=t.toString().indexOf("no kernel with path")?[2]:-1!=t.toString().indexOf("unknown endpoint")?(a.set_error("You MUST restart your project to run the latest Jupyter server! Click 'Restart Project' in your project's settings."),[2]):(a.set_error(t.toString()),[3,7]);case 6:return"closed"===a._state?[2]:("function"==typeof a.set_save_status&&a.set_save_status(),[7]);case 7:return[2]}}))}));var c=J(t);t.save_asap=z((function(){return W(this,(function(t){switch(t.label){case 0:return null==c.syncdb?[3,2]:[4,c.syncdb.save()];case 1:t.sent(),t.label=2;case 2:return[2]}}))})),t.delete_selected_cells=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];t.deprecated("delete_selected_cells",e)},t.move_selected_cells=function(e){t.deprecated("move_selected_cells",e)},t.undo=function(){null!=t.syncdb&&t.syncdb.undo()},t.redo=function(){null!=t.syncdb&&t.syncdb.redo()},t.clear_cell=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t._set({type:"cell",id:e,state:null,start:null,end:null,output:null,exec_count:null,collapsed:null},n)},t.clear_cell_run_state=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t._set({type:"cell",id:e,state:"done"},n)},t.run_selected_cells=function(){t.deprecated("run_selected_cells")},t.run_all_cells=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t.store.get_cell_list().forEach((function(n){t.run_cell(n,!1,e)})),t.save_asap()},t.clear_all_cell_run_state=function(){t.store.get_cell_list().forEach((function(e){t.clear_cell_run_state(e,!1)})),t.save_asap()},t.toggle_toolbar=function(){return t.set_toolbar_state(!t.store.get("toolbar"))},t.set_line_numbers=function(e){t.set_local_storage("line_numbers",!!e);var n=t.store.get("cells").map((function(t){return t.delete("line_numbers")}));n.equals(t.store.get("cells"))||t.setState({cells:n}),t.set_cm_options()},t.set_local_storage=function(e,n){if(null!=localStorage){var r=(0,D.sK)(t.name),o=null!=r?"string"==typeof r?l.from_json(r):r:{};null===n?delete o[e]:o[e]=n,(0,D.nL)(t.name,l.to_json(o))}},t.file_open=function(){null!=t.redux&&t.redux.getProjectActions(t.store.get("project_id")).set_active_tab("files")},t.file_new=function(){null!=t.redux&&t.redux.getProjectActions(t.store.get("project_id")).set_active_tab("new")},t._get_cell_input=function(e){return t.deprecated("_get_cell_input",e),""},t.set_kernel=function(e){"ready"==t.syncdb.get_state()?(t.store.get("kernel")!==e&&t._set({type:"settings",kernel:e}),t.store.get("show_kernel_selector")&&t.hide_select_kernel()):console.warn("Jupyter syncdb not yet ready -- not setting kernel")},t.clear_complete=function(){t._complete_request=(null!=t._complete_request?t._complete_request:0)+1,t.setState({complete:void 0})},t.complete_handle_key=function(e,n){var r=t.store.get("complete");if(null!=r){var o=String.fromCharCode(n),i=(r=r.toJS()).code,s=r.pos;r.code=i.slice(0,s)+o+i.slice(s),r.cursor_end+=1,r.pos+=1;var a=r.code.slice(r.cursor_start,r.cursor_end);if(r.matches=function(){var t=[],e=!0,n=!1,o=void 0;try{for(var i,s=r.matches[Symbol.iterator]();!(e=(i=s.next()).done);e=!0){var c=i.value;l.startswith(c,a)&&t.push(c)}}catch(t){n=!0,o=t}finally{try{e||null==s.return||s.return()}finally{if(n)throw o}}return t}(),0===r.matches.length)t.clear_complete();else{var c=r.base;r.base=r.code,t.setState({complete:g.fromJS(r)}),t.complete_cell(r.id,c,r.code)}}},t.introspect_close=function(){var e;t.is_introspecting()&&(null===(e=t.getFrameActions())||void 0===e||e.setState({introspect:void 0}))};var u,_=J(t);t.introspect_at_pos=(u=z((function(t){var e,n,r=arguments;return W(this,(function(o){switch(o.label){case 0:return e=r.length>1&&void 0!==r[1]?r[1]:0,n=r.length>2?r[2]:void 0,""===t?[2]:[4,_.introspect(t,e,(0,x.zo)(t,n))];case 1:return o.sent(),[2]}}))})),function(t){return u.apply(this,arguments)});var d=J(t);t.introspect=function(){var t=z((function(t,e,n){var r,o,i,s,l;return W(this,(function(a){switch(a.label){case 0:o=d._introspect_request=(null!=d._introspect_request?d._introspect_request:0)+1,null==n&&(n=t.length),n=(0,x.Af)(n,t),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,d.api_call("introspect",{code:t,cursor_pos:n,level:e})];case 2:return"ok"!==(i=a.sent()).status&&(i={error:"completion failed"}),delete i.status,[3,4];case 3:return s=a.sent(),i={error:s},[3,4];case 4:return d._introspect_request>o?[2]:(l=g.fromJS(i),null===(r=d.getFrameActions())||void 0===r||r.setState({introspect:l}),[2,l])}}))}));return function(e,n,r){return t.apply(this,arguments)}}(),t.clear_introspect=function(){var e;t._introspect_request=(null!=t._introspect_request?t._introspect_request:0)+1,null===(e=t.getFrameActions())||void 0===e||e.setState({introspect:void 0})};var f=J(t);t.halt=(0,y.reuseInFlight)(z((function(){var t;return W(this,(function(e){switch(e.label){case 0:return[4,f.signal("SIGKILL")];case 1:return e.sent(),t=function(t){if("closed"===f._state)return!0;var e=t.get_one({type:"settings"});return null!=e&&"running"!=e.get("backend_state")},[4,f.syncdb.wait(t,30)];case 2:return e.sent(),[2]}}))})));var h=J(t);t.restart=(0,y.reuseInFlight)(z((function(){return W(this,(function(t){switch(t.label){case 0:return[4,h.halt()];case 1:return t.sent(),"closed"===h._state?[2]:[4,h.set_backend_kernel_info()];case 2:return t.sent(),[2]}}))})));var p=J(t);t.shutdown=(0,y.reuseInFlight)(z((function(){return W(this,(function(t){switch(t.label){case 0:return"closed"===p._state?[2]:[4,p.signal("SIGKILL")];case 1:return t.sent(),"closed"===p._state?[2]:(p.clear_all_cell_run_state(),[4,p.save_asap()]);case 2:return t.sent(),[2]}}))})));var v=J(t);t.set_backend_kernel_info=z((function(){var t,e,n,r;return W(this,(function(o){switch(o.label){case 0:if("closed"===v._state||v.syncdb.is_read_only())return[2];if(!v.is_project)return[3,5];if(t=v.dbg("set_backend_kernel_info ".concat(l.uuid())),null==v.jupyter_kernel||"closed"==v.jupyter_kernel.get_state())return t("no Jupyter kernel defined"),[2];t("getting kernel_info..."),o.label=1;case 1:return o.trys.push([1,3,,4]),n=g.fromJS,[4,v.jupyter_kernel.kernel_info()];case 2:return e=n.apply(g,[o.sent()]),[3,4];case 3:return r=o.sent(),t("error = ".concat(r)),[2];case 4:return v.setState({backend_kernel_info:e}),[3,7];case 5:return[4,v._set_backend_kernel_info_client()];case 6:o.sent(),o.label=7;case 7:return[2]}}))}));var b=J(t);t._set_backend_kernel_info_client=(0,y.reuseInFlight)(z((function(){return W(this,(function(t){switch(t.label){case 0:return[4,(0,m.retry_until_success)({max_time:12e4,start_delay:1e3,max_delay:1e4,f:b._fetch_backend_kernel_info_from_server,desc:"jupyter:_set_backend_kernel_info_client"})];case 1:return t.sent(),[2]}}))})));var w=J(t);t._fetch_backend_kernel_info_from_server=z((function(){var t,e;return W(this,(function(n){switch(n.label){case 0:t=function(){var t=z((function(){var t;return W(this,(function(e){switch(e.label){case 0:return"closed"===w._state?[2]:[4,w.api_call("kernel_info",{})];case 1:return t=e.sent(),w.setState({backend_kernel_info:t,start_time:t.start_time}),[2]}}))}));return function(){return t.apply(this,arguments)}}(),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,(0,m.retry_until_success)({max_time:18e5,start_delay:500,max_delay:3e3,f:t,desc:"jupyter:_fetch_backend_kernel_info_from_server"})];case 2:return n.sent(),[3,4];case 3:return e=n.sent(),w.set_error(e),[3,4];case 4:return w.is_closed()||w.set_cm_options(),[2]}}))})),t.set_max_output_length=function(e){return t._set({type:"settings",max_output_length:e})},t.set_more_output=function(e,n,r){if(null!=t.store.getIn(["cells",e])){var o=t.store.get("more_output",g.Map());t.setState({more_output:o.set(e,g.fromJS(n))})}},t.reset_more_output=function(e){var n,r=null!=(n=t.store.get("more_output"))?n:g.Map();r.has(e)&&t.setState({more_output:r.delete(e)})},t.set_trust_notebook=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t._set({type:"settings",trust:!!e},n)};var k=J(t);t.submit_password=function(){var t=z((function(t,e){return W(this,(function(n){switch(n.label){case 0:return[4,k.set_in_backend_key_value_store(t,e)];case 1:return n.sent(),[2]}}))}));return function(e,n){return t.apply(this,arguments)}}();var j=J(t);return t.set_in_backend_key_value_store=function(){var t=z((function(t,e){var n;return W(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,j.api_call("store",{key:t,value:e})];case 1:return r.sent(),[3,3];case 2:return n=r.sent(),j.set_error(n),[3,3];case 3:return[2]}}))}));return function(e,n){return t.apply(this,arguments)}}(),t.set_default_kernel=function(e){if(!t.is_project){var n=t.redux.getStore("account");if(null!=n){var r={},o=n.getIn(["editor_settings","jupyter"]);null!=o&&Object.assign(r,o.toJS()),r.kernel=e,t.redux.getTable("account").set({editor_settings:{jupyter:r}})}}},t.edit_attachments=function(e){t.setState({edit_attachments:e})},t._attachment_markdown=function(t){return"![".concat(t,"](attachment:").concat(t,")")},t.insert_input_at_cursor=function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(null!=t.store.getIn(["cells",e])&&!t.check_edit_protection(e,"inserting input")){var o=t.store.getIn(["cells",e,"input"],""),i=null!=t._cursor_locs?t._cursor_locs[0]:void 0;if((null!=i?i.id:void 0)===e){var s=o.split("\n"),l=s[i.y];s[i.y]=l.slice(0,i.x)+n+l.slice(i.x),o=s.join("\n")}else o+=n;return t._set({type:"cell",id:e,input:o},r)}},t.delete_attachment_from_cell=function(e,n){t.check_edit_protection(e,"deleting an attachment")||(t.set_cell_attachment(e,n,null,!1),t.set_cell_input(e,l.replace_all(t._get_cell_input(e),t._attachment_markdown(n),"")))},t.edit_cell_metadata=function(e){var n=t.store.getIn(["cells",e,"metadata"],g.Map());t.setState({edit_cell_metadata:{id:e,metadata:n}})},t.hide_select_kernel=function(){t.setState({show_kernel_selector_reason:void 0,show_kernel_selector:!1,kernel_selection:void 0,kernels_by_name:void 0})},t.select_kernel=function(e){t.set_kernel(e),t.set_default_kernel(e),t.focus(!0),t.hide_select_kernel()},t.kernel_dont_ask_again=function(e){t.redux.getTable("account").set({editor_settings:{ask_jupyter_kernel:!e}})},t.split_current_cell=function(){t.deprecated("split_current_cell")},t}var a=s.prototype;return a._init=function(t,e,n,r,o){if(null==t||null==e)throw Error("type error -- project_id and path can't be null");r.dbg=function(t){return o.dbg("JupyterStore('".concat(r.get("path"),"').").concat(t))},this._state="init",this.store=r,this.project_id=t,this.path=e,r.syncdb=n,this.syncdb=n,this._client=o,this.update_contents=(0,v.debounce)(this.update_contents.bind(this),2e3),this.is_project=o.is_project(),r._is_project=this.is_project,this._account_id=o.client_id();var i,s=this.store.get_local_storage("font_size");if(null==s){var a=this.redux.getStore("account");null!=a&&(s=a.get("font_size"))}null==s&&(s=14);var c=l.path_split(e);null!=c&&(i=c.head),this.setState({error:void 0,cur_id:this.store.get_local_storage("cur_id"),toolbar:!this.store.get_local_storage("hide_toolbar"),has_unsaved_changes:!1,sel_ids:g.Set(),md_edit_ids:g.Set(),mode:"escape",font_size:s,project_id:t,directory:i,path:e,max_output_length:K,cell_toolbar:this.store.get_local_storage("cell_toolbar")}),this.syncdb.on("change",this._syncdb_change),this.is_project||this.init_client_only()},a.getFrameActions=function(){return this.redux.getEditorActions(this.project_id,this.path)},a.init_client_only=function(){throw Error("must define in a derived class")},a.set_kernel_after_load=function(){var t=this;return z((function(){return W(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,t.syncdb.wait((function(t){return!!t.get_one({type:"file"})}),600)];case 1:return e.sent(),[3,3];case 2:if(e.sent(),"ready"!=t._state)return[2];throw Error("error waiting for ipynb file to load");case 3:return t._syncdb_init_kernel(),[2]}}))}))()},a.api_call=function(t,e,n){var r=this;return z((function(){return W(this,(function(o){switch(o.label){case 0:if("closed"===r._state)throw Error("closed");return[4,r.init_project_conn()];case 1:return[4,o.sent().api.jupyter(r.path,t,e,n)];case 2:return[2,o.sent()]}}))}))()},a.dbg=function(t){return this._client.dbg("JupyterActions('".concat(this.store.get("path"),"').").concat(t))},a.close_client_only=function(){throw Error("must define in derived client class")},a.is_closed=function(){return"closed"===this._state},a.close=function(){var t=this;return z((function(){return W(this,(function(e){switch(e.label){case 0:return t.is_closed()?[2]:[4,t.save()];case 1:return e.sent(),t.set_local_storage("cur_id",t.store.get("cur_id")),null!=t.syncdb&&t.syncdb.close(),null!=t._file_watcher&&t._file_watcher.close(),t.is_project?t.close_project_only():t.close_client_only(),Z(t),t._state="closed",[2]}}))}))()},a.close_project_only=function(){},a.set_cell_input=function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.store.getIn(["cells",t,"input"])!=e&&(this.check_edit_protection(t,"changing input")||this._set({type:"cell",id:t,input:e,start:null,end:null},n))},a.clear_outputs=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.store.get("cells");if(null!=n){var r=!0,o=!1,i=void 0;try{for(var s,l=t[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var a=s.value,c=n.get(a);(null!=c.get("output")||c.get("exec_count"))&&this._set({type:"cell",id:a,output:null,exec_count:null},!1)}}catch(t){o=!0,i=t}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}e&&this._sync()}},a.clear_all_outputs=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.clear_outputs(this.store.get_cell_list().toJS(),t)},a.show_not_xable_error=function(t,e,n){if(!(e<=0)){var r=1===e?"is":"are",o=l.plural(e,"cell");this.set_error("".concat(e," ").concat(o," ").concat(r," protected from ").concat(t).concat(n?" when "+n:"","."))}},a.show_not_editable_error=function(t){this.show_not_xable_error("editing",1,t)},a.show_not_deletable_error=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.show_not_xable_error("deletion",t)},a.toggle_output=function(t,e){this.toggle_outputs([t],e)},a.toggle_outputs=function(t,e){var n=this.store.get("cells");if(null==n)throw Error("cells not defined");var r=!0,o=!1,i=void 0;try{for(var s,l=t[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var a=s.value,c=n.get(a);if(null==c)throw Error("no cell with id ".concat(a));"code"==c.get("cell_type","code")&&this._set(q({type:"cell",id:a},e,!c.get(e)),!1)}}catch(t){o=!0,i=t}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}this._sync()},a.toggle_all_outputs=function(t){this.toggle_outputs(this.store.get_cell_ids_list(),t)},a.set_cell_pos=function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this._set({type:"cell",id:t,pos:e},n)},a.set_cell_type=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"code",n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!this.check_edit_protection(t,"changing cell type")){if("markdown"!==e&&"raw"!==e&&"code"!==e)throw Error("cell type (='".concat(e,"') must be 'markdown', 'raw', or 'code'"));var r={type:"cell",id:t,cell_type:e};"code"!==e&&(r.output=r.start=r.end=r.collapsed=r.scrolled=null),this._set(r,n)}},a.set_selected_cell_type=function(t){this.deprecated("set_selected_cell_type",t)},a.deprecated=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var o,i="DEPRECATED JupyterActions("+this.path+")."+t;(o=console).warn.apply(o,[i].concat(L(n)))},a.set_cell_list=function(){var t=this.store.get("cells");if(null!=t){var e=O.kr(t);e.equals(this.store.get_cell_list())||(this.setState({cell_list:e}),this.store.emit("cell-list-recompute"))}},a.syncdb_cell_change=function(t,e){var n=this.store.get("cells");if(null==n)throw Error("BUG -- cells must have been initialized!");var r=!1,o=n.get(t);if(null==e){if(this.reset_more_output(t),null!=o){var i=this.store.get_cell_list().filter((function(e){return e!==t}));this.setState({cells:n.delete(t),cell_list:i})}}else{if(o=n.get(t),e.equals(o))return!1;null!=o&&e.get("start")!==o.get("start")&&this.reset_more_output(t),null!=o&&o.get("pos")===e.get("pos")||(r=!0),(null==o?void 0:o.has("cursors"))&&(e=e.set("cursors",o.get("cursors"))),this.setState({cells:n.set(t,e)}),this.store.getIn(["edit_cell_metadata","id"])===t&&this.edit_cell_metadata(t)}return this.is_project&&this.manager_on_cell_change(t,e,o),this.store.emit("cell_change",t,e,o),r},a.id_is_available=function(t){return null==this.store.getIn(["cells",t])},a.new_id=function(t){for(;;){var e=l.uuid().slice(0,6);if(null!=t&&t(e)||this.id_is_available(e))return e}},a.insert_cell=function(t){return this.deprecated("insert-cell",t),""},a.insert_cell_at=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(this.store.get("read_only"))throw Error("document is read only");var r=null!=n?n:this.new_id();return this._set({type:"cell",id:r,pos:t,input:""},e),r},a.insert_cell_adjacent=function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=O.tg(this.store.get("cells"),this.store.get_cell_list(),t,e);return this.insert_cell_at(r,n)},a.delete_cells=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=0,r=!0,o=!1,i=void 0;try{for(var s,l=t[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var a=s.value;this.store.is_cell_deletable(a)?this._delete({type:"cell",id:a},!1):n+=1}}catch(t){o=!0,i=t}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}e&&this._sync(),0!==n&&this.show_not_deletable_error(n)},a.delete_all_blank_code_cells=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=[],n=!0,r=!1,o=void 0;try{for(var i,s=this.store.get_cell_list()[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var l=i.value;if(this.store.is_cell_deletable(l)){var a=this.store.getIn(["cells",l]);"code"==a.get("cell_type","code")&&""==a.get("input","").trim()&&0==a.get("output",[]).length&&e.push(l)}}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}this.delete_cells(e,t)},a.in_undo_mode=function(){var t,e;return null!==(e=null===(t=this.syncdb)||void 0===t?void 0:t.in_undo_mode())&&void 0!==e&&e},a.run_cell=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.store.get("read_only")){var r=this.store.getIn(["cells",t]);if(null==r)throw Error("can't run cell ".concat(t," since it does not exist"));var o=r.get("cell_type","code");if("code"===o){var i=this.get_cell_input(t).trim();if(this.is_project)this.run_code_cell(t,e,n);else{var s=this.store.getIn(["cm_options","mode","name"]),l=this.store.get_kernel_language();switch(j(i,s,l)){case"show_source":this.introspect(i.slice(0,i.length-2),1);break;case"show_doc":this.introspect(i.slice(0,i.length-1),0);break;case"empty":this.clear_cell(t,e);break;case"execute":this.run_code_cell(t,e,n)}}}e&&this.save_asap()}},a.run_code_cell=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.store.getIn(["cells",t]);if(null==r)throw Error("can't run cell ".concat(t," since it does not exist"));if("done"==r.get("state","done")){var o=this._client.server_time().valueOf();null!=this._last_start&&o<=this._last_start&&(o=this._last_start+1),this._last_start=o,this.set_jupyter_metadata(t,"outputs_hidden",void 0,!1),this._set({type:"cell",id:t,state:"start",start:o,end:null,output:null,exec_count:null,collapsed:null,no_halt:n||null},e),this.set_trust_notebook(!0,e)}},a.run_all_above_cell=function(t){var e=this.store.get_cell_index(t),n=this.store.get_cell_list().toJS(),r=!0,o=!1,i=void 0;try{for(var s,l=n.slice(0,e)[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var a=s.value;this.run_cell(a,!1)}}catch(t){o=!0,i=t}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}this.save_asap()},a.run_all_below_cell=function(t){var e=this.store.get_cell_index(t),n=this.store.get_cell_list().toJS(),r=!0,o=!1,i=void 0;try{for(var s,l=n.slice(e)[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var a=s.value;this.run_cell(a,!1)}}catch(t){o=!0,i=t}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}this.save_asap()},a.set_cursor_locs=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.last_cursor_move_time=new Date,null!=this.syncdb&&0!==t.length&&(this._cursor_locs=t,this.syncdb.set_cursor_locs(t,e))},a.split_cell=function(t,e){if(!this.check_edit_protection(t,"splitting cell")){var n=this.insert_cell_adjacent(t,-1,!1),r=this.store.get("cells").get(t);if(null==r)throw Error("no cell with id=".concat(t));var o=r.get("cell_type");"code"!==o&&this.set_cell_type(n,o,!1);var i=r.get("input");if(null!=i){var s=i.split("\n"),l=s.slice(0,e.line),a=s[e.line];if(null!=a){var c=a.slice(0,e.ch);c&&l.push(c)}var u=l.join("\n");if(l=s.slice(e.line+1),null!=a){var _=a.slice(e.ch);_&&(l=[_].concat(l))}var d=l.join("\n");this.set_cell_input(n,u,!1),this.set_cell_input(t,d,!0)}else this.syncdb.commit()}},a.merge_cell_below_cell=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.store.get_cell_id(1,t);if(null!=n){for(var r=0,o=[t,n];r<o.length;r++){var i=o[r];if(this.check_edit_protection(i,"merging cell"))return}if(!this.check_delete_protection(n)){var s=this.store.get("cells");if(null!=s){var l=s.getIn([t,"input"],"")+"\n"+s.getIn([n,"input"],""),a=s.getIn([t,"output"]),c=s.getIn([n,"output"]),u=void 0;if(null==a)u=c;else if(null==c)u=a;else{u=a;for(var _=a.size,d=0;d<c.size;d++)u=u.set("".concat(_),c.get("".concat(d))),_+=1}this._delete({type:"cell",id:n},!1),this._set({type:"cell",id:t,input:l,output:null!=u?u:null,start:null,end:null},e)}}}},a.merge_cells=function(t){var e=t.length;if(!(e<=1))for(var n=0;n<e-1;n++)this.merge_cell_below_cell(t[0],n==e-2)},a.copy_cells=function(t){var e=this.store.get("cells"),n=g.List(),r=!0,o=!1,i=void 0;try{for(var s,l=t[Symbol.iterator]();!(r=(s=l.next()).done);r=!0){var a=s.value;n=n.push(e.get(a))}}catch(t){o=!0,i=t}finally{try{r||null==l.return||l.return()}finally{if(o)throw i}}this.store.set_global_clipboard(n)},a.studentProjectFunctionality=function(){return this.redux.getStore("projects").get_student_project_functionality(this.project_id)},a.requireToggleReadonly=function(){if(this.studentProjectFunctionality().disableJupyterToggleReadonly)throw Error("Toggling of write protection is disabled in this project.")},a.toggle_write_protection_on_cells=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.requireToggleReadonly(),this.toggle_metadata_boolean_on_cells(t,"editable",!0,e)},a.toggle_delete_protection_on_cells=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.requireToggleReadonly(),this.toggle_metadata_boolean_on_cells(t,"deletable",!0,e)},a.toggle_metadata_boolean_on_cells=function(t,e,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=!0,i=!1,s=void 0;try{for(var l,a=t[Symbol.iterator]();!(o=(l=a.next()).done);o=!0){var c=l.value;this.set_cell_metadata({id:c,metadata:q({},e,!this.store.getIn(["cells",c,"metadata",e],n)),merge:!0,save:r,bypass_edit_protection:!0})}}catch(t){i=!0,s=t}finally{try{o||null==a.return||a.return()}finally{if(i)throw s}}r&&this.save_asap()},a.toggle_jupyter_metadata_boolean=function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.store.getIn(["cells",t,"metadata","jupyter"],g.Map()).toJS();r[e]=!r[e],this.set_cell_metadata({id:t,metadata:{jupyter:r},merge:!0,save:n})},a.set_jupyter_metadata=function(t,e,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=this.store.getIn(["cells",t,"metadata","jupyter"],g.Map()).toJS();null==n&&null==o[e]||(null!=n?o[e]=n:delete o[e],this.set_cell_metadata({id:t,metadata:{jupyter:o},merge:!0,save:r}))},a.paste_cells_at=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this,r=this.store.get_global_clipboard();if(null!=r&&0!==r.size){if(0===t.length)return r.forEach((function(t,e){t=(t=t.set("id",n.new_id())).set("pos",e),n._set(t,!1)})),this.ensure_positions_are_unique(),void this._sync();var o,i=this.store.get("cells");if(-1===e||0===e)o=this.store.get_cell_id(-1,t[0]);else{if(1!==e)throw Error("delta (=".concat(e,") must be 0, -1, or 1"));o=t[t.length-1]}try{var s,l;0===e&&t.length>1&&this.delete_cells(t,!1),null==o?(l=void 0,s=i.getIn([t[0],"pos"])):(l=i.getIn([o,"pos"]),s=i.getIn([this.store.get_cell_id(1,o),"pos"]));var a=O.A9(l,s,r.size);r.forEach((function(t,e){t=(t=t.set("id",n.new_id())).set("pos",a[e]),n._set(t,!1)}))}finally{this._sync()}}},a.set_toolbar_state=function(t){this.setState({toolbar:t}),this.set_local_storage("hide_toolbar",!t)},a.toggle_header=function(){this.redux.getActions("page").toggle_fullscreen()},a.set_header_state=function(t){this.redux.getActions("page").set_fullscreen(t?"default":void 0)},a.get_cell_input=function(t){return this.store.getIn(["cells",t,"input"],"")},a.show_history_viewer=function(){var t=this.redux.getProjectActions(this.project_id);null!=t&&t.open_file({path:l.history_path(this.path),foreground:!0})},a.complete=function(t,e,n,r){var o=this;return z((function(){var i,s,l,a,c,u;return W(this,(function(_){switch(_.label){case 0:if(void 0===o.project_conn)return o.setState({complete:{error:"no project connection"}}),[2,!1];s=o._complete_request=(null!=o._complete_request?o._complete_request:0)+1,o.setState({complete:void 0}),i=null==e||"number"==typeof e?e:(0,x.zo)(t,e),i=(0,x.Af)(i,t),l=new Date,_.label=1;case 1:return _.trys.push([1,3,,4]),[4,o.api_call("complete",{code:t,cursor_pos:i})];case 2:return a=_.sent(),[3,4];case 3:if(c=_.sent(),o._complete_request>s)return[2,!1];throw o.setState({complete:{error:c}}),Error("ignore -- ".concat(c));case 4:if(o.last_cursor_move_time>=l)throw Error("ignore");if(o._complete_request>s)throw Error("ignore");return"ok"!==a.status?(o.setState({complete:{error:a.error?a.error:"completion failed"}}),[2,!1]):0==a.matches?[2,!1]:(delete a.status,a.base=t,a.code=t,a.pos=(0,x.wC)(i,t),a.cursor_start=(0,x.wC)(a.cursor_start,t),a.cursor_end=(0,x.wC)(a.cursor_end,t),a.id=n,null!=r&&(a.offset=r),a.matches=Array.from(new Set(a.matches)).sort(),u=g.fromJS(a),a.matches&&1===a.matches.length&&null!=n?(o.select_complete(n,a.matches[0],u),[2,!1]):(o.setState({complete:u}),[2,!0]))}}))}))()},a.select_complete=function(t,e,n){if(null==n&&(n=this.store.get("complete")),this.clear_complete(),null!=n){var r=n.get("code");if(null!=r&&null==n.get("error")){var o=r.slice(0,n.get("cursor_start"))+e+r.slice(n.get("cursor_end")),i=n.get("base");this.complete_cell(t,i,o)}}},a.complete_cell=function(t,e,n){this.merge_cell_input(t,e,n)},a.merge_cell_input=function(t,e,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=this.store.getIn(["cells",t,"input"]);if(null!=o&&null!=e&&null!=n){var i=(0,b.three_way_merge)({base:e,local:n,remote:o});this.set_cell_input(t,i,r)}},a.is_introspecting=function(){var t,e=this.getFrameActions();return null!=(null==e||null===(t=e.store)||void 0===t?void 0:t.get("introspect"))},a.signal=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SIGINT",e=this;return z((function(){var n;return W(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.api_call("signal",{signal:t},5e3)];case 1:return r.sent(),[3,3];case 2:return n=r.sent(),e.set_error(n),[3,3];case 3:return[2]}}))}))()},a.file_action=function(t,e){var n=this;return z((function(){var r,o,s,a;return W(thi