UNPKG

@cocalc/static

Version:

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

2 lines 6.2 MB
/*! For license information please see embed-2a61c6e95a3fb4c4cd97.js.LICENSE.txt */ (self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[5991],{27631:(e,t,n)=>{var r,o,i,a,s,l,c=function(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")},u=[].indexOf;a=n(16539),s=n(85460),({Actions:r}=n(32295)),({INIT_STATE:i}=n(52488)),o=null,l=t.ExamplesActions=class extends r{constructor(){super(...arguments),this.show=this.show.bind(this),this.hide=this.hide.bind(this)}_init(e,t,n){return this.store=e,this.setState({path:n,project_id:t})}get(e){return this.store.get(e)}set(e){return this.setState(e)}show(e){return c(this,l),null==e&&(e="sage"),e!==this.get("lang")?this.init(e):this.set({show:!0})}reset(){return this.set(i)}hide(){return c(this,l),this.set({show:!1})}init(e){var t;if(null!=e)return this.get("initialized")?this.get("lang")!==e&&this.select_lang(e):(this.reset(),this.set({lang:e}),this.load_data()),this.set({show:!0,initialized:!0,prepend_setup_code:null==(t=this.get("prepend_setup_code"))||t})}init_data(e){var t,n,r;for(t in this.set({data:e}),n=[],e)r=e[t],a.keys(r).length>0&&n.push(t);return this.set({nav_entries:n}),this.select_lang(this.get("lang"))}set_handler(e){return this.set({handler:e})}insert(e){var t,n,r,o,i;return n=this.get("code"),i=this.get("setup_code"),r=this.get("prepend_setup_code"),n=n.toArray(),r&&(null!=i?i.length:void 0)>0&&n.unshift(i),this.store.log(),o={code:n,lang:this.get("lang"),descr:e?this.get("descr"):null,cell_id:this.get("cell_id")},"function"==typeof(t=this.get("handler"))?t(o):void 0}load_data(){return null==o?n.e(5544).then((()=>(o=n(58822),this.init_data(o))).bind(null,n)).catch(n.oe):this.init_data(o)}select_lang(e){var t;if(null!=e!==this.get("lang"))return null==e&&(e=this.get("lang")),this.reset(),this.get("data").has(e)?(this.set({lang:e}),t=this.store.get_category_list0(),this.set({category_list0:t}),1===t.length?this.set_selected_category(0,0):void 0):this.set({unknown_lang:!0})}search(e){var t,n,r,o,i;if(this.reset(),null!=e&&0!==e.length){this.set({search_str:e}),i=e.toLowerCase(),o=[],n=this.store.data_lang(),t={};try{n.forEach((function(e,n){return e.forEach((function(e,r){return e.get("entries").forEach((function(e,a){var s,l,c,u;if(u=e.get(0),s=e.getIn([1,1]),c=u.toLowerCase().indexOf(i),l=s.toLowerCase().indexOf(i),(-1!==c||-1!==l)&&(o.push([n,r,a,u,s,l]),o.length>=30))throw t}))}))}))}catch(e){if((r=e)!==t)throw r}return this.set({hits:o})}this.select_lang(this.get("lang"))}search_selected(e){var t,n,r,o,i,a,s,l;return[i,a,s,l,t,r]=this.get("hits").get(e).toArray(),n=(o=this.store.data_lang()).getIn([i,a,"entries",s]),this.show_doc(o,i,a,n),this.set({search_sel:e})}search_cursor(e){var t,n,r;if(null!=this.get("hits"))return t=this.get("hits").size,null==this.get("search_sel")?n=e>0?0:t-1:(t=this.get("hits").size,(n=(+(this.get("search_sel")+e)%(r=+(r=t))+r)%r)<0&&(n=t-1)),this.set({search_sel:n}),this.search_selected(n)}generate_setup_code(e,t,n,r){var o,i,a,s,l,c,d,f,p,h,m;if(p=e.getIn([t,n,"setup"]),m=e.getIn([t,n,"variables"]),"string"!=typeof(o=r.getIn([1,0]))&&(o=o.toArray().join("\n")),i=void 0,null!=m){for(c=/\b([a-zA-Z_0-9]+)/g,h=[],a=0,s=(d=o.split("\n")).length;a<s;a++)l=d[a],u.call(l,"(")>=0&&(l=l.slice(l.indexOf("("))),l.replace(c,(function(e,t){return h.push(t)}));(i=m.filter((function(e,t){return h.includes(t)})).entrySeq().map((function([e,t]){return`${e} = ${t}`})).toJS()).length>0&&(i=i.join("\n"))}return f="",null!=p&&(f+=`${p}`),null!=i&&(f+=`\n${i}`),f}show_doc(e,t,n,r){var o;return"string"==typeof(o=r.getIn([1,0]))&&(o=s.List([o])),this.set({code:o,descr:r.getIn([1,1]),submittable:!0,setup_code:this.generate_setup_code(e,t,n,r)})}select_cursor(e){var t,n,r,o,i,a,s,l,c,u,d,f,p;if(t=this.get("category0"),r=this.get("category1"),i=this.get("category2"),p=function(t){return e<0?t.length-1:0},null==t){if((null!=(s=this.store.get_category_list0())?s.length:void 0)>0)return this.set_selected_category(0,p(s))}else if(null==r){if((null!=(l=this.store.get_category_list1())?l.length:void 0)>0)return this.set_selected_category(1,p(l))}else{if(null!=i)return u=this.get("category_list0").size,d=this.get("category_list1").size,f=this.get("category_list2").size,(a=i+e)<0?o=r-1:a>=f&&(a=0,o=r+1),o<0?n=t-1:o>=d&&(o=0,n=t+1),null!=n&&((n%=u)<0&&(n=u-1),this.set_selected_category(0,n)),null!=o&&this.set_selected_category(1,o),this.set_selected_category(2,a);if((null!=(c=this.store.get_category_list2())?c.length:void 0)>0)return this.set_selected_category(2,p(c))}}set_selected_category(e,t){var n,r,o,i,a,s;switch(s=this.store.data_lang(),e){case 0:case 1:this.set({code:null,descr:null,category2:null,submittable:!1,setup_code:"",variables:null})}switch(e){case 0:if(this.set({category0:-1===t?this.get("category_list0").size-1:t}),n=this.store.get_category_list1(),this.set({category1:null,category2:null,category_list1:n,category_list2:[]}),1===n.length)return this.set_selected_category(1,0);break;case 1:if(this.get("category0"),this.set({category1:-1===t?this.get("category_list1").size-1:t}),r=this.store.get_category_list2(),this.set({category2:void 0,category_list2:r}),1===r.length)return this.set_selected_category(2,0);break;case 2:return i=this.get("category_list0").get(this.get("category0")),a=this.get("category_list1").get(this.get("category1")),t=-1===t?this.get("category_list2").size-1:t,o=s.getIn([i,a,"entries",t]),this.set({category2:t}),this.show_doc(s,i,a,o)}}}},52488:(e,t)=>{t.ICON_NAME="magic",t.REPO_URL="https://github.com/sagemathinc/cocalc-assistant",t.INIT_STATE={category0:null,category1:null,category2:null,category_list0:[],category_list1:[],category_list2:[],code:void 0,setup_code:void 0,descr:void 0,hits:[],search_str:null,search_sel:null,submittable:!1,category1_top:["Introduction","Tutorial","Help"],unknown_lang:!1}},78980:(e,t,n)=>{var r,o,i,a,s,l,c;({defaults:a,required:c,optional:s}=n(24620)),({redux:l,Redux:i}=n(32295)),({ExamplesStore:o}=n(16)),({ExamplesActions:r}=n(27631)),t.redux_name=function(e,t){return`examples-${e}-${t}`},t.init_action_and_store=function(e,t,n){var i,a;return a=l.createStore(e,o),(i=l.createActions(e,r))._init(a,t,n),[i,a]},t.instantiate_snippets=function(e,n){var r,o,i;return o=t.redux_name(e,n),null==(r=l.getActions(o))&&([r,i]=t.init_action_and_store(o,e,n)),r}},16:(e,t,n)=>{var r,o,i,a;i=n(16539),n(85460),({redux:a,Store:o}=n(32295)),({INIT_STATE:r}=n(52488)),t.ExamplesStore=class extends o{getInitialState(){return r}data_lang(){return this.get("data").get(this.get("lang"))}get_category_list0(){var e,t,n;return e=this.data_lang().keySeq().toArray(),n=this.get("category1_top"),t=function(e){return[-n.reverse().indexOf(e),e]},i.sortBy(e,t)}get_category_list1(){var e,t,n,r,o;return r=this.get_category_list0()[this.get("category0")],e=(t=this.data_lang().get(r)).keySeq().toArray(),o=this.get("category1_top"),n=function(e){var n;return[null!=(n=null!=t?t.getIn([e,"sortweight"]):void 0)?n:0,-o.reverse().indexOf(e),e]},i.sortBy(e,n)}get_category_list2(){var e,t;return e=this.get_category_list0()[this.get("category0")],t=this.get_category_list1()[this.get("category1")],this.data_lang().getIn([e,t,"entries"]).map((function(e){return e.get(0)})).toArray()}log(){var e,t,n,r,o,i,s,l,c,u,d,f,p,h,m,g,v;if(f=this.get("lang"),g=this.get("path"),null!=this.get("search_sel")){if(u=this.get("search_sel"),null==(c=this.get("hits").get(u)))return;[p,h,m,v,s,d]=c.toArray(),[e,t,n]=[p,h,v]}else{if(r=this.get("category0"),o=this.get("category1"),i=this.get("category2"),null==r||null==o||null==i)return;e=this.get_category_list0()[r],t=this.get_category_list1()[o],n=this.get_category_list2()[i]}return l=[e,t,n],a.getProjectActions(this.get("project_id")).log({event:"assistant",action:"insert",entry:l,lang:f,path:g})}}},471:(e,t,n)=>{var r,o,i,a,s,l,c,u,d,f,p,h,m,g,v,b,y,_,w,x,k,E,C,S,T=function(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")};r=window.$,({debounce:d}=n(16539)),({EventEmitter:i}=n(32821)),_=n(24620),({copy:u,filename_extension:m,required:x,defaults:f,to_json:E,uuid:C,from_json:v}=n(24620)),({redux:w}=n(32295)),({alert_message:s}=n(34440)),k=r("#webapp-console-templates"),c=k.find(".webapp-console"),({getStudentProjectFunctionality:b}=n(53924)),({delay:p}=n(95788)),h=n(67941),({webapp_client:S}=n(97636)),a=h.IS_TOUCH,y=function(e){return`# This initialization file is associated with your terminal in ${e}.\n# It is automatically run whenever it starts up -- restart the terminal via Ctrl-d and Return-key.\n\n# Usually, your ~/.bashrc is executed and this behavior is emulated for completeness:\nsource ~/.bashrc\n\n# You can export environment variables, e.g. to set custom GIT_* variables\n# https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables\n#export GIT_AUTHOR_NAME="Your Name"\n#export GIT_AUTHOR_EMAIL="your@email.address"\n#export GIT_COMMITTER_NAME="Your Name"\n#export GIT_COMMITTER_EMAIL="your@email.address"\n\n# It is also possible to automatically start a program ...\n\n#sage\n#sage -ipython\n#top\n\n# ... or even define a terminal specific function.\n#hello () { echo "hello world"; }`},g=void 0,l=function(e){return null!=g?g.client_keydown(e):void 0},o=class e extends i{constructor(e={}){super(),this.connect=this.connect.bind(this),this.reconnect=this.reconnect.bind(this),this.handle_control_mesg=this.handle_control_mesg.bind(this),this.handle_resize=this.handle_resize.bind(this),this.append_to_value=this.append_to_value.bind(this),this.init_mesg=this.init_mesg.bind(this),this.reconnect_if_no_recent_data=this.reconnect_if_no_recent_data.bind(this),this.set_state_connected=this.set_state_connected.bind(this),this.set_state_disconnected=this.set_state_disconnected.bind(this),this.render=this.render.bind(this),this.reset=this.reset.bind(this),this.update_scrollbar=this.update_scrollbar.bind(this),this.pause_rendering=this.pause_rendering.bind(this),this.unpause_rendering=this.unpause_rendering.bind(this),this._on_pause_button_clicked=this._on_pause_button_clicked.bind(this),this._init_rendering_pause=this._init_rendering_pause.bind(this),this.mark_file_use=this.mark_file_use.bind(this),this.client_keydown=this.client_keydown.bind(this),this._increase_font_size=this._increase_font_size.bind(this),this._decrease_font_size=this._decrease_font_size.bind(this),this._font_size_changed=this._font_size_changed.bind(this),this._init_font_make_default=this._init_font_make_default.bind(this),this._init_default_settings=this._init_default_settings.bind(this),this.remove=this.remove.bind(this),this._focus_hidden_textarea=this._focus_hidden_textarea.bind(this),this._init_fullscreen=this._init_fullscreen.bind(this),this.open_copyable_history=this.open_copyable_history.bind(this),this.open_init_file=this.open_init_file.bind(this),this._init_input_line=this._init_input_line.bind(this),this._init_paste_bin=this._init_paste_bin.bind(this),this.disconnect=this.disconnect.bind(this),this.fullscreen=this.fullscreen.bind(this),this.exit_fullscreen=this.exit_fullscreen.bind(this),this.refresh=this.refresh.bind(this),this.full_rerender=this.full_rerender.bind(this),this.resize_terminal=this.resize_terminal.bind(this),this.send_size_to_project=this.send_size_to_project.bind(this),this.set_scrollbar_to_term=this.set_scrollbar_to_term.bind(this),this.set_term_to_scrollbar=this.set_term_to_scrollbar.bind(this),this.console_is_open=this.console_is_open.bind(this),this.blur=this.blur.bind(this),this.focus=this.focus.bind(this),this.opts=f(e,{element:x,project_id:x,path:x,title:"",filename:"",rows:40,cols:100,editor:void 0,close:void 0,reconnect:void 0,font:{family:void 0,size:void 0,line_height:120},highlight_mode:"none",color_scheme:void 0,on_pause:void 0,on_unpause:void 0,on_reconnecting:void 0,on_reconnected:void 0,set_title:void 0}),this._init_default_settings(),this.project_id=this.opts.project_id,this.path=this.opts.path,this.mark_file_use=d(this.mark_file_use,3e3),this.resize=d(this.resize,500),this._project_actions=w.getProjectActions(this.project_id),this.is_focused=!1,this.element=c.clone(),this.element.processIcons(),this.textarea=this.element.find(".webapp-console-textarea"),this.element.data("console",this),r(this.opts.element).replaceWith(this.element),this.set_title(this.opts.title),this.terminal=new Terminal({cols:this.opts.cols,rows:this.opts.rows}),this.terminal.IS_TOUCH=a,this.terminal.on("title",(e=>this.set_title(e))),this.init_mesg(),Terminal.bindKeys(l),this.scrollbar=this.element.find(".webapp-console-scrollbar"),this.scrollbar.scroll((()=>{if(!this.ignore_scroll)return this.set_term_to_scrollbar()})),this.terminal.on("scroll",((e,t)=>this.set_scrollbar_to_term())),this.terminal.on("data",(e=>{var t;if(!(null!=this._ignore_terminal&&new Date-this._ignore_terminal<500))return null!=(t=this.conn)?t.write(e):void 0})),this._init_ttyjs(),this._init_buttons(),this._init_input_line(),this._init_font_make_default(),this._init_paste_bin(),this._init_rendering_pause(),this.textarea.on("blur",(()=>{if(null!=this._focusing)return this._focus_hidden_textarea()})),a||(this.element.find(".webapp-console-up").hide(),this.element.find(".webapp-console-down").hide()),this.connect()}async connect(){var t,r,o,i;if(T(this,e),!b(this.opts.project_id).disableTerminals)return t=await S.project_client.api(this.project_id),({aux_file:r}=n(24620)),o=r(`${this.path}-0`,"term"),this.conn=await t.terminal(o),this.conn.on("end",(()=>{if(null!=this.conn)return this.connect()})),this._ignore=!0,i=!0,this.conn.on("data",(e=>"string"==typeof e?this._rendering_is_paused?(null==this._render_buffer&&(this._render_buffer=""),this._render_buffer+=e):(i&&(i=!1,this._ignore_terminal=new Date),this.render(e)):"object"==typeof e?this.handle_control_mesg(e):void 0)),this.resize_terminal();this.render("Terminals are currently disabled\r\nin this project.\r\nPlease contact your instructor\r\nif you have questions.\r\n")}reconnect(){return T(this,e),this.disconnect(),this.connect()}handle_control_mesg(t){var n,r;switch(T(this,e),t.cmd){case"size":this.handle_resize(t.rows,t.cols);break;case"burst":this.element.find(".webapp-burst-indicator").show();break;case"no-burst":this.element.find(".webapp-burst-indicator").fadeOut(2e3);break;case"no-ignore":delete this._ignore;break;case"close":s({type:"info",message:`You have been booted out of ${this.opts.filename}.`}),null!=(n=this._project_actions)&&n.close_file(this.opts.filename),null!=(r=this._project_actions)&&r.set_active_tab("files")}}handle_resize(t,n){if(T(this,e),!this._terminal_size||t!==this._terminal_size.rows||n!==this._terminal_size.cols)return this._terminal_size={rows:t,cols:n},this.terminal.resize(n,t),this.element.find(".webapp-console-terminal").css({width:null,height:null}),this.full_rerender()}append_to_value(t){if(T(this,e),null==this.value_orig&&(this.value_orig=""),this.value_orig+=t,this.value+=t.replace(/\x1b\[.{1,5}m|\x1b\].*0;|\x1b\[.*~|\x1b\[?.*l/g,""),this.value_orig.length>5e5)return this.value_orig=this.value_orig.slice(this.value_orig.length-Math.round(333333.3333333333)),this.full_rerender()}init_mesg(){return T(this,e),this.terminal.on("mesg",(e=>{var t,n,r,o,i,a,s,l,c,u;if(!this._ignore&&this.is_focused)try{if("open"===(e=v(e)).event){for(r=0,n=!1,a=e.paths,c=[],o=0,i=a.length;o<i;o++)u=a[o],(r+=1)===e.paths.length&&(n=!0),null!=u.file&&null!=(s=this._project_actions)&&s.open_file({path:u.file,foreground:n}),null!=u.directory&&n?c.push(null!=(l=this._project_actions)?l.open_directory(u.directory):void 0):c.push(void 0);return c}}catch(e){return t=e,console.log("issue parsing message -- ",t)}}))}reconnect_if_no_recent_data(){if(T(this,e),null==this._got_remote_data||new Date-this._got_remote_data>=15e3)return this.reconnect()}set_state_connected(){return T(this,e),this.element.find(".webapp-console-terminal").css({opacity:"1"}),this.element.find('a[href="#refresh"]').removeClass("btn-success").find(".fa").removeClass("fa-spin")}set_state_disconnected(){return T(this,e),this.element.find(".webapp-console-terminal").css({opacity:".5"}),this.element.find('a[href="#refresh"]').addClass("btn-success").find(".fa").addClass("fa-spin")}render(t){var n;if(T(this,e),null!=t)try{return this.terminal.write(t),this.append_to_value(t),this.scrollbar_nlines<this.terminal.ybase&&this.update_scrollbar(),setTimeout(this.set_scrollbar_to_term,10)}catch(e){return n=e,console.warn("terminal error -- ",n)}}reset(){return T(this,e),this.value=this.value_orig="",this.scrollbar_nlines=0,this.scrollbar.empty(),this.terminal.reset()}update_scrollbar(){var t;for(T(this,e),t=[];this.scrollbar_nlines<this.terminal.ybase;)this.scrollbar.append(r("<br>")),t.push(this.scrollbar_nlines+=1);return t}pause_rendering(t){var n,r;if(T(this,e),!this._rendering_is_paused)return this._rendering_is_paused=!0,null==this._render_buffer&&(this._render_buffer=""),r=()=>{if(this._rendering_is_paused)return this.element.find('a[href="#pause"]').addClass("btn-success").find("i").addClass("fa-play").removeClass("fa-pause")},t?r():setTimeout(r,500),"function"==typeof(n=this.opts).on_pause?n.on_pause():void 0}unpause_rendering(){var t;if(T(this,e),this._rendering_is_paused)return this._rendering_is_paused=!1,setTimeout((()=>(this.render(this._render_buffer),this._render_buffer="")),0),this.element.find('a[href="#pause"]').removeClass("btn-success").find("i").addClass("fa-pause").removeClass("fa-play"),"function"==typeof(t=this.opts).on_unpause?t.on_unpause():void 0}_on_pause_button_clicked(t){return T(this,e),this._rendering_is_paused?this.unpause_rendering():this.pause_rendering(!0),!1}_init_rendering_pause(){var t;return T(this,e),this.element.find('a[href="#pause"]').click((e=>(this._rendering_is_paused?this.unpause_rendering():this.pause_rendering(!0),!1))),(t=this.element.find(".webapp-console-terminal")).mousedown((()=>this.pause_rendering(!1))),t.mouseup((()=>{getSelection().toString()||this.unpause_rendering()})),t.on("copy",(()=>(this.unpause_rendering(),setTimeout(this.focus,5))))}mark_file_use(){return T(this,e),w.getActions("file_use").mark_file(this.project_id,this.path,"edit")}client_keydown(t){var n;if(T(this,e),this.allow_resize=!0,this._ignore&&(this._ignore=!1),this.mark_file_use(),t.ctrlKey&&t.shiftKey)switch(t.keyCode){case 190:return this._increase_font_size(),!1;case 188:return this._decrease_font_size(),!1}else delete this._ignore_terminal;if(!(t.metaKey||t.ctrlKey||t.altKey)||17!==(n=t.keyCode)&&86!==n&&91!==n&&93!==n&&223!==n&&224!==n||this.textarea.val(""),this._rendering_is_paused)return!(t.ctrlKey||t.metaKey||t.altKey)&&this.unpause_rendering()}_increase_font_size(){if(T(this,e),this.opts.font.size+=1,this.opts.font.size<=159)return this._font_size_changed()}_decrease_font_size(){if(T(this,e),this.opts.font.size>=2)return this.opts.font.size-=1,this._font_size_changed()}_font_size_changed(){var t;return T(this,e),null!=(t=this.opts.editor)&&t.local_storage("font-size",this.opts.font.size),r(this.terminal.element).css({"font-size":`${this.opts.font.size}px`}),this.element.find(".webapp-console-font-indicator-size").text(this.opts.font.size),this.element.find(".webapp-console-font-indicator").stop().show().animate({opacity:1}).fadeOut({duration:8e3}),this.resize_terminal()}_init_font_make_default(){return T(this,e),this.element.find('a[href="#font-make-default"]').click((()=>(w.getTable("account").set({terminal:{font_size:this.opts.font.size}}),!1)))}_init_default_settings(){var t,n,r,o;if(T(this,e),o=w.getStore("account").get_terminal_settings(),null==this.opts.font.size&&(this.opts.font.size=null!=(t=null!=o?o.font_size:void 0)?t:14),null==this.opts.color_scheme&&(this.opts.color_scheme=null!=(n=null!=o?o.color_scheme:void 0)?n:"default"),null==this.opts.font.family)return this.opts.font.family=null!=(r=null!=o?o.font:void 0)?r:"monospace"}_init_ttyjs(){var e,t;return this.terminal.open(),this.terminal.set_color_scheme(this.opts.color_scheme),this.terminal.element.className="webapp-console-terminal",t=r(this.terminal.element),this.element.find(".webapp-console-terminal").replaceWith(t),t.css({"font-family":this.opts.font.family+", monospace","font-size":`${this.opts.font.size}px`,"line-height":`${this.opts.font.line_height}%`}),a?(this.mobile_target=this.element.find(".webapp-console-for-mobile").show(),this.mobile_target.css("width",t.css("width")),this.mobile_target.css("height",t.css("height")),this._click=e=>{var t;if(!this.is_hidden)return(t=r(e.target))[0]===this.mobile_target[0]||t.hasParent(this.element).length>0?this.focus():this.blur()},r(document).on("click",this._click)):(e=!1,this._mousedown=t=>{if(!this.is_hidden)return e||r(t.target).hasParent(this.element).length>0?(e=!0,this.focus()):this.blur()},r(document).on("mousedown",this._mousedown),this._mouseup=t=>{var n,o;if(!this.is_hidden)return e=!1,o=r(t.target),n=window.getSelection().toString(),o.hasParent(this.element).length>0&&0===n.length?this._focus_hidden_textarea():void 0},r(document).on("mouseup",this._mouseup),r(this.terminal.element).bind("copy",(e=>setTimeout(this._focus_hidden_textarea,10))))}remove(){if(T(this,e),this.disconnect(),null!=this._mousedown&&r(document).off("mousedown",this._mousedown),null!=this._mouseup&&r(document).off("mouseup",this._mouseup),null!=this._click)return r(document).off("click",this._click)}_focus_hidden_textarea(){return T(this,e),this.textarea.focus()}_init_fullscreen(){var t,n;return T(this,e),n=this.element.find('a[href="#fullscreen"]'),t=this.element.find('a[href="#exit_fullscreen"]'),n.on("click",(()=>(this.fullscreen(),t.show(),n.hide(),!1))),t.hide().on("click",(()=>(this.exit_fullscreen(),t.hide(),n.show(),!1)))}_init_buttons(){return this.terminal.editor,this.element.find("a").tooltip({delay:{show:500,hide:100}}),this.element.find('a[href="#increase-font"]').click((()=>(this._increase_font_size(),!1))),this.element.find('a[href="#decrease-font"]').click((()=>(this._decrease_font_size(),!1))),this.element.find('a[href="#refresh"]').click((()=>(this.reconnect(),!1))),this.element.find('a[href="#paste"]').click((()=>{var e,t,n;return n=`<h2><i class='fa project-file-icon fa-terminal'></i> Terminal Copy and Paste</h2>Copy and paste in terminals works as usual: to copy, highlight text then press ctrl+c (or command+c); press ctrl+v (or command+v) to paste. <br><br><span class='lighten'>NOTE: When no text is highlighted, ctrl+c sends the usual interrupt signal.</span><br><hr>You can copy the terminal history from here:<br><br><textarea readonly style='font-family: monospace;cursor: auto;width: 97%' id='${t=C()}' rows=10></textarea>`,bootbox.alert(n),(e=r(`#${t}`)).val(this.value).scrollTop(e[0].scrollHeight),!1})),this.element.find('a[href="#boot"]').click((()=>{var e;return null!=(e=this.conn)&&e.write({cmd:"boot"}),s({type:"info",message:"This terminal should now close for all other users, which allows you to resize it as large as you want."})})),this.element.find('a[href="#initfile"]').click((()=>{var e,t;return t=_.console_init_filename(this.opts.filename),e=y(this.opts.filename),S.exec({project_id:this.project_id,command:`test ! -r '${t}' && echo '${e}' > '${t}'`,bash:!0,err_on_exit:!1,cb:(e,n)=>{var r;return e?s({type:"error",message:`problem creating initfile: ${e}`}):null!=(r=this._project_actions)?r.open_file({path:t,foreground:!0}):void 0}})}))}open_copyable_history(){var t,n,o;return T(this,e),o=`<h2><i class='fa project-file-icon fa-terminal'></i> Terminal Copy and Paste</h2>Copy and paste in terminals works as usual: to copy, highlight text then press ctrl+c (or command+c); press ctrl+v (or command+v) to paste. <br><br><span class='lighten'>NOTE: When no text is highlighted, ctrl+c sends the usual interrupt signal.</span><br><hr>You can copy the terminal history from here:<br><br><textarea readonly style='font-family: monospace;cursor: auto;width: 97%' id='${n=C()}' rows=10></textarea>`,bootbox.alert(o),(t=r(`#${n}`)).val(this.value).scrollTop(t[0].scrollHeight)}open_init_file(){var t,n;return T(this,e),n=_.console_init_filename(this.opts.filename),t=y(this.opts.filename),S.exec({project_id:this.project_id,command:`test ! -r '${n}' && echo '${t}' > '${n}'`,bash:!0,err_on_exit:!1,cb:(e,t)=>{var r;return e?s({type:"error",message:`problem creating initfile: ${e}`}):null!=(r=this._project_actions)?r.open_file({path:n,foreground:!0}):void 0}})}_init_input_line(){var t,n;return T(this,e),a||this.element.find(".webapp-console-mobile-input").hide(),(t=this.element.find(".webapp-console-input-line")).on("focus",(()=>(this._input_line_is_focused=!0,this.terminal.blur()))),t.on("blur",(()=>this._input_line_is_focused=!1)),n=()=>{var e,n;return n=t.val(),n=_.replace_all(n,"“",'"'),n=_.replace_all(n,"”",'"'),n=_.replace_all(n,"‘","'"),n=_.replace_all(n,"’","'"),n=_.replace_all(n,"–","--"),n=_.replace_all(n,"—","---"),this._ignore=!1,null!=(e=this.conn)&&e.write(n),t.val("")},t.on("keydown",(e=>{var t;return 13===e.which?(e.preventDefault(),n(),this._ignore=!1,null!=(t=this.conn)&&t.write("\n"),!1):67===e.which&&e.ctrlKey?(n(),this.terminal.keyDown({keyCode:67,shiftKey:!1,ctrlKey:!0})):void 0})),this.element.find(".webapp-console-submit-line").click((()=>{var e;return n(),this._ignore=!1,null!=(e=this.conn)&&e.write("\n"),!1})),this.element.find(".webapp-console-submit-submit").click((()=>(n(),!1))),this.element.find(".webapp-console-submit-tab").click((()=>(n(),this.terminal.keyDown({keyCode:9,shiftKey:!1})))),this.element.find(".webapp-console-submit-esc").click((()=>(n(),this.terminal.keyDown({keyCode:27,shiftKey:!1,ctrlKey:!1})))),this.element.find(".webapp-console-submit-up").click((()=>(n(),this.terminal.keyDown({keyCode:38,shiftKey:!1,ctrlKey:!1})))),this.element.find(".webapp-console-submit-down").click((()=>(n(),this.terminal.keyDown({keyCode:40,shiftKey:!1,ctrlKey:!1})))),this.element.find(".webapp-console-submit-left").click((()=>(n(),this.terminal.keyDown({keyCode:37,shiftKey:!1,ctrlKey:!1})))),this.element.find(".webapp-console-submit-right").click((()=>(n(),this.terminal.keyDown({keyCode:39,shiftKey:!1,ctrlKey:!1})))),this.element.find(".webapp-console-submit-ctrl-c").show().click((e=>(n(),this.terminal.keyDown({keyCode:67,shiftKey:!1,ctrlKey:!0})))),this.element.find(".webapp-console-submit-ctrl-b").show().click((e=>(n(),this.terminal.keyDown({keyCode:66,shiftKey:!1,ctrlKey:!0}))))}_init_paste_bin(){var t,n;return T(this,e),n=this.textarea,t=e=>{var t,r;return this._ignore=!1,t=n.val(),n.val(""),null!=(r=this.conn)?r.write(t):void 0},n.on("paste",(()=>(n.val(""),setTimeout(t,5))))}disconnect(){var t;if(T(this,e),t=this.conn,delete this.conn,null!=t)try{return t.end()}catch(e){}}fullscreen(){var t;return T(this,e),t=r(".navbar-fixed-top").height(),this.element.css({position:"absolute",width:"97%",top:t,left:0,right:0,bottom:1}),r(this.terminal.element).css({position:"absolute",width:"100%",top:"3.5em",bottom:1}),this.resize_terminal()}exit_fullscreen(){var t,n,o;for(T(this,e),t=0,n=(o=[r(this.terminal.element),this.element]).length;t<n;t++)o[t].css({position:"relative",top:0,width:"100%"});return this.resize_terminal()}refresh(){return T(this,e),this.terminal.refresh(0,this.opts.rows-1),this.terminal.showCursor()}full_rerender(){var t;return T(this,e),this._ignore_terminal=new Date,t={value:this.value_orig,ignore:this._ignore},this.reset(),this._ignore=!0,null!=t.value&&this.render(t.value),this._ignore=t.ignore,this.terminal.showCursor()}async resize_terminal(){var t,n,o,i,s,l,c,u;if(T(this,e),this.element.find(".webapp-console-terminal").css({width:"100%",height:"100%"}),await p(0),this._c=r("<span>Term-inal&nbsp;</span>").prependTo(this.terminal.element),t=this._c.width()/10,this._c.remove(),n=r(this.terminal.element),i=function(){var e,t,o,i;for(i=[],e=0,t=(o=n.children()).length;e<t;e++)u=o[e],i.push(r(u).height());return i}(),i=function(){var e,t,n;for(n=[],e=0,t=i.length;e<t;e++)(u=i[e])<=i[0]+2&&n.push(u);return n}(),c=Math.max(...i),0!==t&&0!==c)return this.opts.font.size,s=Math.max(1,Math.floor(n.width()/t)),o=n.height(),a&&(o-=60),l=Math.max(1,Math.floor(o/c)),this.opts.cols=s,this.opts.rows=l,this.send_size_to_project(),this.element.find(".webapp-console-terminal").css({width:"100%",height:""})}send_size_to_project(){var t;return T(this,e),null!=(t=this.conn)?t.write({cmd:"size",rows:this.opts.rows,cols:this.opts.cols}):void 0}set_scrollbar_to_term(){var t;if(T(this,e),0!==this.terminal.ybase){if(this.scrollbar.show(),!this.ignore_scroll)return this.ignore_scroll=!0,setTimeout((()=>this.ignore_scroll=!1),100),t=this.scrollbar[0].scrollHeight-this.scrollbar.height(),this.scrollbar.scrollTop(t*this.terminal.ydisp/this.terminal.ybase)}else this.scrollbar.hide()}set_term_to_scrollbar(){var t,n;return T(this,e),t=this.scrollbar[0].scrollHeight-this.scrollbar.height(),n=Math.floor(this.scrollbar.scrollTop()*this.terminal.ybase/t),this.terminal.ydisp=n,this.terminal.refresh(0,this.terminal.rows-1)}console_is_open(){return T(this,e),this.element.closest(document.documentElement).length>0}blur(){T(this,e),g===this&&(g=void 0),this.is_focused=!1;try{this.terminal.blur()}catch(e){}return r(this.terminal.element).addClass("webapp-console-blur").removeClass("webapp-console-focus")}focus(t){if(T(this,e),null!=this._reconnecting&&new Date-this._reconnecting>1e4&&this.reconnect_if_no_recent_data(),!this.is_focused||t)return this._focusing=!0,g=this,this.is_focused=!0,this.textarea.blur(),r(this.terminal.element).focus(),a||this._focus_hidden_textarea(),this.terminal.focus(),r(this.terminal.element).addClass("webapp-console-focus").removeClass("webapp-console-blur"),setTimeout((()=>delete this._focusing),5)}set_title(e){var t;return"function"==typeof(t=this.opts).set_title&&t.set_title(e),this.element.find(".webapp-console-title").text(e)}},t.Console=o,r.fn.extend({webapp_console:function(e={}){return this.each((function(){var t,n,i;return i=r(this),!1===e?(null!=(t=i.data("console"))&&t.remove(),i):((n=u(e)).element=this,i.data("console",new o(n)))}))}})},54177:(e,t,n)=>{var r,o,i,a,s,l,c,u,d,f,p,h,m,g,v,b,y,_,w,x,k,E,C,S,T,O,A,j,M,I,P,D,R,N,z,L,F,B,q,H,U,Z,W,G,V,$,K,Y,X,J,Q,ee,te,ne,re=function(e,t){if(!(e instanceof t))throw new Error("Bound instance method accessed before binding")},oe=[].indexOf;r=window.$,X=n(1738).Z+n(41504).Z+n(1307).Z+n(66687).Z+n(88780).Z+n(72354).Z,r("body").append(X),Y=r("#webapp-editor-templates"),({init_buttonbars:R}=n(78905)),R(),t.SHOW_BUTTON_LABELS=4,t.MIN_SPLIT=.02,t.MAX_SPLIT=.98,d={delay:{show:500,hide:100}},v=n(29280),n(63536),({redux:U}=n(32295)),h=ee=n(16539),({webapp_client:ne}=n(97636)),({EventEmitter:a}=n(32821)),({alert_message:m}=n(34440)),({appBasePath:g}=n(41780)),T=n(67941),c=T.IS_MOBILE,B=n(24620),({drag_start_iframe_disable:k,drag_stop_iframe_enable:E,sagews_canonical_mode:V}=n(97891)),o=n(33638),n(471),({copy:_,trunc:Q,from_json:D,to_json:J,keys:z,defaults:x,required:W,filename_extension:I,filename_extension_notilde:P,len:L,path_split:q,uuid:te}=n(24620)),K=n(59391),G=n(56677),H=n(15581),({file_nonzero_size:j}=n(23474)),({render_snippets_dialog:Z}=n(92627)),w=n(81805),S=function(e,t,n){if(B.merge(e,{"Shift-Alt-L":e=>e.align_assignments(),"Alt-Z":e=>e.undo(),"Shift-Alt-Z":e=>e.redo(),"Alt-A":e=>e.execCommand("selectAll"),"Shift-Alt-A":e=>e.execCommand("selectAll"),"Alt-K":e=>e.execCommand("killLine"),"Alt-D":e=>e.execCommand("selectNextOccurrence"),"Alt-F":e=>e.execCommand("find"),"Shift-Alt-F":e=>e.execCommand("replace"),"Shift-Alt-R":e=>e.execCommand("replaceAll"),"Shift-Alt-D":e=>e.execCommand("duplicateLine"),"Alt-G":e=>e.execCommand("findNext"),"Shift-Alt-G":e=>e.execCommand("findPrev"),"Alt-Up":e=>e.execCommand("goPageUp"),"Alt-Down":e=>e.execCommand("goPageDown"),"Alt-K":e=>e.execCommand("goPageUp"),"Alt-J":e=>e.execCommand("goPageDown"),"Alt-P":e=>e.execCommand("goLineUp"),"Alt-N":e=>e.execCommand("goLineDown")}),null!=(null!=t?t.goto_line:void 0)&&(e["Alt-L"]=e=>t.goto_line(e)),null!=(null!=t?t.toggle_split_view:void 0)&&(e["Alt-I"]=e=>t.toggle_split_view(e)),null!=(null!=t?t.copy:void 0)?e["Alt-C"]=e=>t.copy(e):e["Alt-C"]=e=>w.set_buffer(e.getSelection()),null!=(null!=t?t.cut:void 0)?e["Alt-X"]=e=>t.cut(e):e["Alt-X"]=e=>(w.set_buffer(e.getSelection()),e.replaceSelection("")),null!=(null!=t?t.paste:void 0)?e["Alt-V"]=e=>t.paste(e):e["Alt-V"]=e=>e.replaceSelection(w.get_buffer()),null!=(null!=t?t.click_save_button:void 0)?e["Alt-S"]=e=>t.click_save_button():null!=(null!=t?t.save:void 0)&&(e["Alt-S"]=e=>t.save()),"vim"===n.bindings)return e["Alt-C"]=e=>o.Vim.exitInsertMode(e),e["Alt-F"]=e=>e.execCommand("goPageDown"),e["Alt-B"]=e=>e.execCommand("goPageUp")},({file_associations:O,VIDEO_EXTS:p}=n(6279)),M=async(e,t,n)=>{try{return await j(e,t)?n():n("Unable to convert file to PDF")}catch(e){return n(e)}},function(){var e,t,n,o,i,a,s,l,c;for(n={},(c=B.keys(O)).sort(),t=function(e,t,o){var i,a;if(t&&(i=O[t],!o||!i.exclude_from_menu))return null==i.name||n[i.name]?void 0:(n[i.name]=!0,a=r(`<li><a href='#new-file' data-ext='${t}'><i style='width: 18px;' class='fa ${i.icon}'></i> <span style='text-transform:capitalize'>${i.name} </span> <span class='lighten'>(.${t})</span></a></li>`),e.append(a))},e=r(".smc-new-file-type-list"),o=0,a=c.length;o<a;o++)t(e,c[o],!0);for(e=r(".smc-mini-new-file-type-list"),n={},i=0,s=(l=["sagews","term","ipynb","tex","md","tasks","course","sage","py"]).length;i<s;i++)t(e,l[i]);e.append(r("<li class='divider'></li><li><a href='#new-folder'><i style='width: 18px;' class='fa fa-folder'></i> <span>Folder </span></a></li>")),e.append(r("<li class='divider'></li><li><a href='#projects-add-collaborators'><i style='width: 18px;' class='fa fa-user'></i> <span>Collaborators... </span></a></li>"))}(),t.file_icon_class=A=function(e){return t.file_options("x."+e).icon},({sagews_decorator_modes:$}=n(19817)),t.file_options=n(70051).file_options,C=n(65618),t.local_storage_delete=C.local_storage_delete,t.local_storage=C.local_storage,F=t.local_storage,s=class e extends a{constructor(e,t){var n;super(),this.is_active=this.is_active.bind(this),this.init_font_size=this.init_font_size.bind(this),this.val=this.val.bind(this),this.has_unsaved_changes=this.has_unsaved_changes.bind(this),this.has_uncommitted_changes=this.has_uncommitted_changes.bind(this),this._show_uncommitted_warning=this._show_uncommitted_warning.bind(this),this.focus=this.focus.bind(this),this._get=this._get.bind(this),this._set=this._set.bind(this),this.restore_cursor_position=this.restore_cursor_position.bind(this),this.disconnect_from_session=this.disconnect_from_session.bind(this),this.local_storage=this.local_storage.bind(this),this.show=this.show.bind(this),this._show=this._show.bind(this),this.hide=this.hide.bind(this),this.remove=this.remove.bind(this),this.terminate_session=this.terminate_session.bind(this),this.project_id=e,this.filename=t,this.ext=null!=(n=B.filename_extension_notilde(this.filename))?n.toLowerCase():void 0,this._show=ee.debounce(this._show,50)}is_active(){return re(this,e),B.tab_to_path(U.getProjectStore(this.project_id).get("active_project_tab"))===this.filename}init_font_size(){return re(this,e),this.default_font_size=U.getStore("account").get("font_size")}val(t){return re(this,e),null==t?this._get():this._set(t)}has_unsaved_changes(t){return re(this,e),null==t?this._has_unsaved_changes:(null!=this._has_unsaved_changes&&this._has_unsaved_changes===t||(t?this.save_button.removeClass("disabled"):(this._when_had_no_unsaved_changes=new Date,this.save_button.addClass("disabled"))),this._has_unsaved_changes=t)}has_uncommitted_changes(t){var n;return re(this,e),null==t?this._has_uncommitted_changes:(this._has_uncommitted_changes=t,t?null==this._show_uncommitted_warning_timeout?this._show_uncommitted_warning_timeout=setTimeout((()=>this._show_uncommitted_warning()),3e4):void 0:(null!=this._show_uncommitted_warning_timeout&&(clearTimeout(this._show_uncommitted_warning_timeout),delete this._show_uncommitted_warning_timeout),null!=(n=this.uncommitted_element)?n.hide():void 0))}_show_uncommitted_warning(){var t;return re(this,e),delete this._show_uncommitted_warning_timeout,null!=(t=this.uncommitted_element)?t.show():void 0}focus(){re(this,e)}_get(){return re(this,e),console.warn("Incomplete: editor -- needs to implement _get in derived class")}_set(t){return re(this,e),console.warn("Incomplete: editor -- needs to implement _set in derived class")}restore_cursor_position(){re(this,e)}disconnect_from_session(t){re(this,e)}local_storage(t,n){return re(this,e),F(this.project_id,this.filename,t,n)}show(t){re(this,e),null==t&&(t=null!=this._last_show_opts?this._last_show_opts:{}),this._last_show_opts=t,("function"==typeof this.is_active?this.is_active():void 0)&&(this.element.show(),this._show(t),setTimeout((()=>this._show(t)),10))}_show(t={}){re(this,e)}hide(){re(this,e)}remove(){var t,n;return re(this,e),null!=(t=this.syncdoc)&&t.close(),null!=(n=this.element)&&n.remove(),this.removeAllListeners()}terminate_session(){re(this,e)}},t.FileEditor=s,i=class e extends s{constructor(e,t,n,i){var a,s,l,u,d,f,p,h,g,v,b,y,_,w;super(e,t),this.programmatical_goto_line=this.programmatical_goto_line.bind(this),this.get_users_cursors=this.get_users_cursors.bind(this),this.init_file_actions=this.init_file_actions.bind(this),this.init_draggable_splits=this.init_draggable_splits.bind(this),this.hide_content=this.hide_content.bind(this),this.show_content=this.show_content.bind(this),this.hide_startup_message=this.hide_startup_message.bind(this),this.show_startup_message=this.show_startup_message.bind(this),this.is_active=this.is_active.bind(this),this.set_theme=this.set_theme.bind(this),this.set_readonly_ui=this.set_readonly_ui.bind(this),this.set_cursor_center_focus=this.set_cursor_center_focus.bind(this),this.disconnect_from_session=this.disconnect_from_session.bind(this),this.codemirrors=this.codemirrors.bind(this),this.focused_codemirror=this.focused_codemirror.bind(this),this.action_key=this.action_key.bind(this),this.interrupt_key=this.interrupt_key.bind(this),this.press_tab_key=this.press_tab_key.bind(this),this.tab_nothing_selected=this.tab_nothing_selected.bind(this),this.init_edit_buttons=this.init_edit_buttons.bind(this),this.click_edit_button=this.click_edit_button.bind(this),this.restore_font_size=this.restore_font_size.bind(this),this.set_font_size=this.set_font_size.bind(this),this.change_font_size=this.change_font_size.bind(this),this.toggle_split_view=this.toggle_split_view.bind(this),this.goto_line=this.goto_line.bind(this),this.copy=this.copy.bind(this),this.convert_to_ipynb=this.convert_to_ipynb.bind(this),this.cut=this.cut.bind(this),this.paste=this.paste.bind(this),this.print=this.print.bind(this),this.print_html=this.print_html.bind(this),this.print_sagews=this.print_sagews.bind(this),this.init_save_button=this.init_save_button.bind(this),this.init_uncommitted_element=this.init_uncommitted_element.bind(this),this.init_history_button=this.init_history_button.bind(this),this.click_save_button=this.click_save_button.bind(this),this.click_history_button=this.click_history_button.bind(this),this._get=this._get.bind(this),this._set=this._set.bind(this),this.save_view_state=this.save_view_state.bind(this),this.restore_view_state=this.restore_view_state.bind(this),this.restore_cursor_position=this.restore_cursor_position.bind(this),this._style_active_line=this._style_active_line.bind(this),this._show_codemirror_editors=this._show_codemirror_editors.bind(this),this._show=this._show.bind(this),this.focus=this.focus.bind(this),this.textedit_command=this.textedit_command.bind(this),this.snippets_dialog_handler=this.snippets_dialog_handler.bind(this),this.example_insert_handler=this.example_insert_handler.bind(this),this.init_sagews_edit_buttons=this.init_sagews_edit_buttons.bind(this),s=U.getStore("account").get_editor_settings(),i=this.opts=x(i,{mode:void 0,geometry:void 0,read_only:!1,delete_trailing_whitespace:s.strip_trailing_whitespace,show_trailing_whitespace:s.show_trailing_whitespace,allow_javascript_eval:!0,line_numbers:s.line_numbers,first_line_number:s.first_line_number,indent_unit:s.indent_unit,tab_size:s.tab_size,smart_indent:s.smart_indent,electric_chars:s.electric_chars,undo_depth:s.undo_depth,match_brackets:s.match_brackets,code_folding:s.code_folding,auto_close_brackets:s.auto_close_brackets,match_xml_tags:s.match_xml_tags,auto_close_xml_tags:s.auto_close_xml_tags,line_wrapping:s.line_wrapping,spaces_instead_of_tabs:s.spaces_instead_of_tabs,style_active_line:15,bindings:s.bindings,theme:s.theme,track_revisions:s.track_revisions,public_access:!1,latex_editor:!1,cursor_interval:1e3,sync_interval:500,completions_size:20}),this.element=Y.find(".webapp-editor-codemirror").clone(),this.element.data("editor",this),this.init_save_button(),this.init_uncommitted_element(),this.init_history_button(),this.init_edit_buttons(),this.init_file_actions(),(t=this.filename).length>30&&(t="…"+t.slice(t.length-30)),this.show_exec_warning=null==(v=U.getStore("account").getIn(["editor_settings","show_exec_warning"]))||v,!this.show_exec_warning||"py"!==(b=this.ext)&&"r"!==b&&"sage"!==b&&"f90"!==b||(h=`<strong>INFO:</strong> you can only run <code>*.${this.ext}</code> files in a terminal or create a worksheet/notebook. <a href='#'>Close</a>`,(g=this.element.find(".webapp-editor-codemirror-message")).html(h),g.find("a").click((function(){return g.hide(),U.getTable("account").set({editor_settings:{show_exec_warning:!1}})}))),this._video_is_on=this.local_storage("video_is_on"),null==this._video_is_on&&(this._video_is_on=!1),f={"Alt-Enter":e=>this.action_key({execute:!0,advance:!1,split:!1}),"Cmd-Enter":e=>this.action_key({execute:!0,advance:!1,split:!1}),"Ctrl-Enter":e=>this.action_key({execute:!0,advance:!0,split:!0}),"Ctrl-;":e=>this.action_key({split:!0,execute:!1,advance:!1}),"Cmd-;":e=>this.action_key({split:!0,execute:!1,advance:!1}),"Ctrl-\\":e=>this.action_key({execute:!1,toggle_input:!0}),"Shift-Ctrl-\\":e=>this.action_key({execute:!1,toggle_output:!0}),"Cmd-S":e=>this.click_save_button(),"Alt-S":e=>this.click_save_button(),"Ctrl-L":e=>this.goto_line(e),"Cmd-L":e=>this.goto_line(e),"Shift-Ctrl-I":e=>this.toggle_split_view(e),"Shift-Cmd-I":e=>this.toggle_split_view(e),"Shift-Cmd-L":e=>e.align_assignments(),"Shift-Ctrl-L":e=>e.align_assignments(),"Shift-Ctrl-.":e=>this.change_font_size(e,1),"Shift-Ctrl-,":e=>this.change_font_size(e,-1),"Shift-Cmd-.":e=>this.change_font_size(e,1),"Shift-Cmd-,":e=>this.change_font_size(e,-1),"Shift-Tab":e=>e.unindent_selection(),"Ctrl-'":"indentAuto","Cmd-'":"indentAuto","Cmd-/":"toggleComment","Ctrl-/":"toggleComment",Tab:e=>this.press_tab_key(e),"Shift-Ctrl-C":e=>this.interrupt_key(),"Ctrl-Space":"autocomplete","Alt-Space":"autocomplete"},T.IS_TOUCH&&S(f,this,i),i.match_xml_tags&&(f["Ctrl-J"]="toMatchingTag"),"emacs"!==i.bindings&&(f["Ctrl-S"]=e=>this.click_save_button()),"sagews"===B.filename_extension_notilde(t).toLowerCase()?(d=U.getStore("account").get("evaluate_key").toLowerCase(),f[d="enter"===d?"Enter":"Shift-Enter"]=e=>this.action_key({execute:!0,advance:!0,split:!1})):f["Shift-Enter"]=()=>m({type:"error",message:"You can only evaluate code in a file that ends with the extension 'sagews' or 'ipynb'. Create a Sage Worksheet or Jupyter notebook instead."}),this._layout=c?0:null!=(y=this.local_storage("layout"))?y:0,0!==(_=this._layout)&&1!==_&&2!==_&&(this._layout=0),this._last_layout=void 0,T.isMobile.Android()&&(i.style_active_line=!1),p=e=>{var n,a,s,l;return s={firstLineNumber:i.first_line_number,autofocus:!1,mode:{name:i.mode,globalVars:!0},lineNumbers:i.line_numbers,showTrailingSpace:i.show_trailing_whitespace,indentUnit:i.indent_unit,tabSize:i.tab_size,smartIndent:i.smart_indent,electricChars:i.electric_chars,undoDepth:i.undo_depth,matchBrackets:i.match_brackets,autoCloseBrackets:i.auto_close_brackets&&"hs"!==(l=B.filename_extension_notilde(t))&&"lhs"!==l,autoCloseTags:i.auto_close_xml_tags,lineWrapping:i.line_wrapping,readOnly:i.read_only,styleActiveLine:i.style_active_line,indentWithTabs:!i.spaces_instead_of_tabs,showCursorWhenSelecting:!0,extraKeys:f,cursorScrollMargin:6,viewportMargin:300},i.match_xml_tags&&(s.matchTags={bothTags:!0}),i.code_folding&&(f["Ctrl-Q"]=function(e){return e.foldCodeSelectionAware()},f["Alt-Q"]=function(e){return e.foldCodeSelectionAware()},s.foldGutter=!0,s.gutters=["CodeMirror-linenumbers","CodeMirror-foldgutter"]),i.latex_editor&&(null==s.gutters&&(s.gutters=[]),s.gutters.push("Codemirror-latex-errors")),null!=i.bindings&&"standard"!==i.bindings&&(s.keyMap=i.bindings),null!=i.theme&&"standard"!==i.theme&&(s.theme=i.theme),(n=o.fromTextArea(e,s)).save=()=>this.click_save_button(),(a=r(n.getWrapperElement())).attr("style",a.attr("style")+"; height:100%; font-family:monospace !important;"),"vim"===i.bindings&&n.setOption("vimMode",!0),n},(l=this.element.find(".webapp-editor-textarea-0")).text(n),this.codemirror=p(l[0]),this.codemirror.name="0",u=this.element.find(".webapp-editor-textarea-1"),this.codemirror1=p(u[0]),this.codemirror1.name="1",a=this.codemirror.linkedDoc({sharedHist:!0}),this.codemirror1.swapDoc(a),this.codemirror.on("focus",(()=>this.codemirror_with_last_focus=this.codemirror)),this.codemirror1.on("focus",(()=>this.codemirror_with_last_focus=this.codemirror1)),"vim"===this.opts.bindings&&(this._vim_mode="visual",this.codemirror.on("vim-mode-change",(e=>"normal"===e.mode?(this._vim_mode="visual",this.element.find("a[href='#vim-mode-toggle']").text("esc")):(this._vim_mode="insert",this.element.find("a[href='#vim-mode-toggle']").text("i"))))),T.IS_TOUCH&&(this.element.find(".webapp-editor-resize-bar-layout-1").height("12px"),this.element.find(".webapp-editor-resize-bar-layout-2").width("12px")),this.init_font_size(),this.restore_font_size(),this.init_draggable_splits(),i.read_only&&this.set_readonly_ui(),"sagews"===(null!=(w=B.filename_extension(this.filename))?w.toLowerCase():void 0)&&this.init_sagews_edit_buttons(),this.snippets_dialog=null,this.element.processIcons()}programmatical_goto_line(t){var n,r,o;if(re(this,e),null!=(n=this.codemirror_with_last_focus))return o={line:t-1,ch:0},r=n.getScrollInfo(),n.scrollIntoView(o,r.clientHeight/2)}get_users_cursors(t){var n;return re(this,e),null!=(n=this.syncdoc)?n.get_users_cursors(t):void 0}init_file_actions(){var t;if(re(this,e),null!=this.element)return t=this.element.find(".smc-editor-file-info-dropdown")[0],n(6407).b(this.filename,this.project_id,t,this.opts.public_access)}init_draggable_splits(){var t,n;return re(this,e),this._layout1_split_pos=this.local_storage("layout1_split_pos"),this._layout2_split_pos=this.local_storage("layout2_split_pos"),(t=this.element.find(".webapp-editor-resize-bar-layout-1")).draggable({axis:"y",containment:this.element,zIndex:10,start:k,stop:(e,n)=>{var r,o,i,a;return E(),a=(r=this.element.find(".webapp-editor-codemirror-input-container-layout-1")).offset().top,o=r.height(),i=t.offset().top+t.height()/2,this._layout1_split_pos=(i-a)/o,this.local_storage("layout1_split_pos",this._layout1_split_pos),this.show()}}),(n=this.element.find(".webapp-editor-resize-bar-layout-2")).draggable({axis:"x",containment:this.element,zIndex:100,start:k,stop:(e,t)=>{var r,o,i,a;return E(),o=(r=this.element.find(".webapp-editor-codemirror-input-container-layout-2")).offset().left,a=r.width(),i=n.offset().left,this._layout2_split_pos=(i-o)/a,this.local_storage("layout2_split_pos",this._layout2_split_pos),this.show()}})}hide_content(){return re(this,e),this.element.find(".webapp-editor-codemirror-content").hide()}show_content(){var t,n,r,o,i;for(re(this,e),this.hide_startup_message(),this.element.find(".webapp-editor-codemirror-content").show(),i=[],n=0,r=(o=this.codemirrors()).length;n<r;n++)t=o[n],i.push(b(t));return i}hide_startup_message(){return re(this,e),this.element.find(".webapp-editor-codemirror-startup-message").hide()}show_startup_message(t,n="info"){var r,o,i,a,s;for(re(this,e),this.hide_content(),"string"!=typeof t&&(t=JSON.stringify(t)),r=this.element.find(".webapp-editor-codemirror-startup-message").show().text(t),o=0,i=(a=["success","info","warning","danger"]).length;o<i;o++)s=a[o],r.removeClass(`alert-${s}`);return r.addClass(`alert-${n}`)}is_active(){return re(this,e),null!=this.codemirror&&B.tab_to_path(U.getProjectStore(this.project_id).get("active_project_tab"))===this.filename}set_theme(t){var n,r,o;for(re(this,e),n=0,r=(o=this.codemirrors()).length;n<r;n++)o[n].setOption("theme",t);return this.opts.theme=t}set_readonly_ui(t=!0){var n,r,o,i,a;for(re(this,e),this.opts.read_only=t,this.element.find(".webapp-editor-write-only").toggle(!t),this.element.find(".webapp-editor-read-only").toggle(t),a=[],r=0,o=(i=this.codemirrors()).length;r<o;r++)n=i[r],a.push(n.setOption("readOnly",t));return a}set_cursor_center_focus(t,n=5){var r,o;if(re(this,e),!(n<=0)&&(null==(r=this.codemirror_with_last_focus)&&(r=this.codemirror),null!=r)){r.setCursor(t),o=r.getScrollInfo();try{r.scrollIntoView(t,o.clientHeight/2)}catch(e){setTimeout((()=>this.set_cursor_center_focus(t,n-1)),250)}return r.focus()}}disconnect_from_session(t){var n;return re(this,e),null!=(n=this.syncdoc)&&n.disconnect_from_session(),"function"==typeof t?t():void 0}codemirrors(){var t;return re(this,e),t=[this.codemirror,this.codemirror1],ee.filter(t,(function(e){return null!=e}))}focused_codemirror(){return re(this,e),null!=this.codemirror_with_last_focus?this.codemirror_with_last_focus:this.codemirror}action_key(t){return re(this,e),this.click_save_button()}interrupt_key(){re(this,e)}press_tab_key(t){return re(this,e),t.somethingSelected()?o.commands.defaultTab(t):this.tab_nothing_selected(t)}tab_nothing_selected(t){return re(this,e),this.opts.spaces_instead_of_tabs?t.tab_as_space():o.commands.defaultTab(t)}init_edit_buttons(){var t,n,o,i,a,s,l;for(re(this,e),l=this,t=["search","next","prev","replace","undo","redo","autoindent","shift-left","shift-right","split-view","increase-font","decrease-font","goto-line","copy","paste","vim-mode-toggle"],"vim"!==this.opts.bindings&&this.element.find("a[href='#vim-mode-toggle']").remove(),H.can_print(