UNPKG

@cocalc/static

Version:

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

1 lines 58.3 kB
(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[9169],{49169:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Actions:()=>Ut,ScrollIntoViewRecord:()=>Jt});var n=r(95788),i=r(56393),s=r(20812),a=r(56160),o=r(85460),u=r(4538),c=r(94873),l=r(5010),f=r(84884),h=r(12430);function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var d=/^LaTeX Warning: (.*)$/,_=/^(Over|Under)full \\(v|h)box/,v=/^(Package \b.+\b Warning:.*)$/,y=/lines? ([0-9]+)/,g=/^Package (\b.+\b) Warning/,b=function(){function t(e){p(this,t);var r=(e=e.replace(/(\r\n)|\r/g,"\n")).split("\n");this.lines=[r[0]];for(var n=1;n<r.length;)79===r[n-1].length&&"..."!==r[n-1].slice(-3)?this.lines[this.lines.length-1]+=r[n]:this.lines.push(r[n]),n++;this.row=0}var e=t.prototype;return e.nextLine=function(){return this.row++,this.row>=this.lines.length?null:this.lines[this.row]},e.rewindLine=function(){this.row--},e.linesUpToNextWhitespaceLine=function(){return this.linesUpToNextMatchingLine(/^ *$/)},e.linesUpToNextMatchingLine=function(t){var e=[],r=this.nextLine();for(null!=r&&e.push(r);null!=r&&!r.match(t);)null!=(r=this.nextLine())&&e.push(r);return e},t}(),m=function(){function t(){p(this,t),this.errors=[],this.warnings=[],this.typesetting=[],this.all=[],this.files=[],this.deps=[]}return t.prototype.toJS=function(){return Object.assign({},this)},t}(),w=function(){function t(e,r){p(this,t),this.files=new Set([]),this.log=new b(e),this.state=0,r=r||{},this.ignoreDuplicates=r.ignoreDuplicates,this.data=[],this.fileStack=[],this.rootFileList=[],this.openParens=0,this.deps=[]}var e=t.prototype;return e.parse=function(){for(;null!=(this.currentLine=this.log.nextLine());)if(0===this.state)if(this.currentLineIsError())this.state=1,this.currentError={line:null,file:this.currentFilePath,level:"error",message:this.currentLine.slice(2),content:"",raw:this.currentLine+"\n"};else if(this.currentLineIsRunawayArgument())this.parseRunawayArgumentError();else if(this.currentLineIsWarning())this.parseSingleWarningLine(d);else if(this.currentLineIsHboxWarning())this.parseHboxLine();else if(this.currentLineIsPackageWarning())this.parseMultipleWarningLine();else{if(this.currentLineIsDependenciesList()){this.state=2;continue}this.parseParensForFilenames()}else if(1===this.state){this.currentError.content+=this.log.linesUpToNextMatchingLine(/^l\.[0-9]+/).join("\n"),this.currentError.content+="\n",this.currentError.raw+=this.currentError.content;var t=this.currentError.raw.match(/l\.([0-9]+)/);t&&(this.currentError.line=parseInt(t[1],10)),this.data.push(this.currentError),this.state=0}else 2===this.state&&(this.currentLineIsDependenciesListEnd()?this.state=0:this.addDeps(this.currentLine));return this.postProcess(this.data).toJS()},e.currentLineIsDependenciesList=function(){return this.currentLine.startsWith("#===Dependents")},e.currentLineIsDependenciesListEnd=function(){return this.currentLine.startsWith("#===End dependents for")},e.addDeps=function(t){if("/"!==(t=t.trim())[0]){"\\"===t[t.length-1]&&(t=t.slice(0,t.length-1));var e=t.toLowerCase();(e.endsWith(".tex")||e.endsWith(".bib"))&&this.deps.push(t)}},e.currentLineIsError=function(){return"!"===this.currentLine[0]},e.currentLineIsRunawayArgument=function(){return!!this.currentLine.match(/^Runaway argument/)},e.currentLineIsWarning=function(){return!!this.currentLine.match(d)},e.currentLineIsPackageWarning=function(){return!!this.currentLine.match(v)},e.currentLineIsHboxWarning=function(){return!!this.currentLine.match(_)},e.parseRunawayArgumentError=function(){this.currentError={line:null,file:this.currentFilePath,level:"error",message:this.currentLine,content:"",raw:this.currentLine+"\n"},this.currentError.content+=this.log.linesUpToNextWhitespaceLine().join("\n"),this.currentError.content+="\n",this.currentError.content+=this.log.linesUpToNextWhitespaceLine().join("\n"),this.currentError.raw+=this.currentError.content;var t=this.currentError.raw.match(/l\.([0-9]+)/);t&&(this.currentError.line=parseInt(t[1],10)),this.data.push(this.currentError)},e.parseSingleWarningLine=function(t){var e=this.currentLine.match(t);if(e){var r=e[1],n=r.match(y),i=n?parseInt(n[1],10):null;this.data.push({line:i,file:this.currentFilePath,level:"warning",message:r,raw:r})}},e.parseMultipleWarningLine=function(){var t=this.currentLine.match(v);if(t){var e=[t[1]],r=this.currentLine.match(y),n=r?parseInt(r[1],10):null,i=this.currentLine.match(g);if(i){for(var s=i[1],a=new RegExp("(?:\\(".concat(s,"\\))*[\\s]*(.*)"),"i");this.currentLine=this.log.nextLine();)n=(r=this.currentLine.match(y))?parseInt(r[1],10):n,(t=this.currentLine.match(a))&&e.push(t[1]);var o=e.join(" ");this.data.push({line:n,file:this.currentFilePath,level:"warning",message:o,raw:o})}}},e.parseHboxLine=function(){var t=this.currentLine.match(y),e=t?parseInt(t[1],10):null;this.data.push({line:e,file:this.currentFilePath,level:"typesetting",message:this.currentLine,raw:this.currentLine})},e.parseParensForFilenames=function(){var t=this.currentLine.search(/\(|\)/);if(-1!==t){var e=this.currentLine[t];if(this.currentLine=this.currentLine.slice(t+1),"("===e){var r=this.consumeFilePath();if(r){this.currentFilePath=r;var n={path:r,files:[]};this.fileStack.push(n),this.files.add(r),0==this.rootFileList.length&&(this.rootFileList=n.files)}else this.openParens++}else if(")"===e)if(this.openParens>0)this.openParens--;else if(this.fileStack.length>1){this.fileStack.pop();var i=this.fileStack[this.fileStack.length-1];this.currentFilePath=i.path}this.parseParensForFilenames()}},e.consumeFilePath=function(){if(!this.currentLine.match(/^\/?([^ \)]+\/)+/))return null;var t,e=r(37897)(this.currentLine.search(RegExp("$|\\)")));return-1===e?(t=this.currentLine,this.currentLine=""):(t=this.currentLine.slice(0,e),this.currentLine=this.currentLine.slice(e)),(0,i.normalize)(t)},e.postProcess=function(t){var e=new m,r=!0,n=!1,i=void 0;try{for(var s,a=this.files[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var o=s.value,u=o.toLowerCase();(u.endsWith(".tex")||u.endsWith(".bib"))&&e.files.push(o)}}catch(t){n=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}var c=[],l=function(t){return t.raw};e.deps=this.deps;for(var f=0;f<t.length;)this.ignoreDuplicates&&c.indexOf(l(t[f]))>-1||("error"===t[f].level?e.errors.push(t[f]):"typesetting"===t[f].level?e.typesetting.push(t[f]):"warning"===t[f].level&&e.warnings.push(t[f]),e.all.push(t[f]),c.push(l(t[f]))),f++;return e},t}();function x(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function k(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){x(s,n,i,a,o,"next",t)}function o(t){x(s,n,i,a,o,"throw",t)}a(void 0)}))}}var S=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};function L(t){return t+".sagetex.sage"}function E(t,e,r,n,i){return j.apply(this,arguments)}function j(){return(j=k((function(t,e,r,n,i){var s,a,o,u;return S(this,(function(l){switch(l.label){case 0:return s=(0,h.l)(e),a=s.base,o=s.directory,u=L(a),n("sha1sum ".concat(u)),[4,(0,c.GL)({timeout:10,command:"sha1sum",args:[u],project_id:t,path:i||o,err_on_exit:!0,aggregate:r})];case 1:return[2,l.sent().stdout.split(" ")[0]]}}))}))).apply(this,arguments)}function O(t,e,r,n,i){return P.apply(this,arguments)}function P(){return(P=k((function(t,e,r,n,i){var s,a,o,u;return S(this,(function(l){return s=(0,h.l)(e),a=s.base,o=s.directory,u=L(a),n("sage ".concat(u)),[2,(0,c.GL)({timeout:360,bash:!0,command:"sage",args:[u],project_id:t,path:i||o,err_on_exit:!1,aggregate:r?{value:r}:void 0})]}))}))).apply(this,arguments)}function I(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function R(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){I(s,n,i,a,o,"next",t)}function o(t){I(s,n,i,a,o,"throw",t)}a(void 0)}))}}var T=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};function W(t,e,r,n,i,s){return A.apply(this,arguments)}function A(){return(A=R((function(t,e,r,n,i,s){var a,o,u,l,f,p;return T(this,(function(d){return a=(0,h.l)(e),o=a.base,u=a.directory,l="--jobs 2 ".concat(n?"--rerun=always":""," '").concat(o,"'"),f="$(which {pythontex3,pythontex} | head -1) ".concat(l),i("pythontex[3] ".concat(l)),p=r&&!n?{value:r}:void 0,[2,(0,c.GL)({timeout:360,bash:!0,command:f,env:{MPLBACKEND:"Agg"},project_id:t,path:s||u,err_on_exit:!1,aggregate:p})]}))}))).apply(this,arguments)}function F(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function G(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function z(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){G(s,n,i,a,o,"next",t)}function o(t){G(s,n,i,a,o,"throw",t)}a(void 0)}))}}function C(t){return function(t){if(Array.isArray(t))return F(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return F(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?F(t,e):void 0}}(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 D=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}},J="R",U=["--no-save","--no-restore","--quiet","--no-readline","-e"];function N(t,e,r,n){return M.apply(this,arguments)}function M(){return(M=z((function(t,e,r,n){var i,s,a,o;return D(this,(function(u){return i=(0,h.l)(e),s=i.directory,a=i.filename,o='require(knitr); opts_knit$set(concordance = TRUE, progress = FALSE); knit("'.concat(a,'")'),n("".concat(o)),[2,(0,c.GL)({timeout:360,command:J,args:C(U).concat([o]),bash:!0,project_id:t,path:s,err_on_exit:!1,aggregate:r?{value:r}:void 0})]}))}))).apply(this,arguments)}function X(t,e,r,n){return $.apply(this,arguments)}function $(){return($=z((function(t,e,r,n){var i,s,a,o;return D(this,(function(u){return i=(0,h.l)(e),s=i.directory,a=i.filename,o='require(patchSynctex); patchSynctex("'.concat(a,'")'),n("".concat(o)),[2,(0,c.GL)({timeout:10,command:J,args:C(U).concat([o]),bash:!1,project_id:t,path:s,err_on_exit:!1,aggregate:r?{value:r}:void 0})]}))}))).apply(this,arguments)}var B=r(24620);function H(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function q(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function Z(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){q(s,n,i,a,o,"next",t)}function o(t){q(s,n,i,a,o,"throw",t)}a(void 0)}))}}function K(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,s=[],a=!0,o=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);a=!0);}catch(t){o=!0,i=t}finally{try{a||null==r.return||r.return()}finally{if(o)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return H(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var V=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};function Q(t,e,r){return(0,c.GL)({timeout:5,command:"synctex",args:r,project_id:t,path:e,err_on_exit:!0})}function Y(t){return tt.apply(this,arguments)}function tt(){return(tt=Z((function(t){var e,r,n,i,s,a,o,u,l;return V(this,(function(f){switch(f.label){case 0:return e=(0,B.path_split)(t.pdf_path),r=e.head,n=e.tail,i=null!=t.output_directory?t.output_directory:r,s=["edit","-o","".concat(t.page,":").concat(t.x,":").concat(t.y,":").concat(n)],[4,Q(t.project_id,i,s)];case 1:return a=f.sent(),null==(o=nt(a.stdout)).Input?[3,6]:[4,(0,c.ZO)(t.project_id)];case 2:u=f.sent(),l="".concat(o.Input),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,u.canonical_path(l)];case 4:return o.Input=f.sent(),[3,6];case 5:return f.sent(),o.Input=t.src,[3,6];case 6:return[2,o]}}))}))).apply(this,arguments)}function et(t){return rt.apply(this,arguments)}function rt(){return(rt=Z((function(t){var e;return V(this,(function(r){switch(r.label){case 0:return t.knitr&&(t.tex_path=(0,B.change_filename_extension)(t.tex_path,"Rnw")),[4,(0,c.ZO)(t.project_id)];case 1:return[4,r.sent().eval_code("process.env.HOME")];case 2:return e=r.sent(),[4,Q(t.project_id,t.dir,["view","-i","".concat(t.line,":").concat(t.column,":").concat(e,"/").concat(t.source_dir,"/").concat(t.tex_path),"-o",(0,B.path_split)(t.pdf_path).tail])];case 3:return[2,nt(r.sent().stdout)]}}))}))).apply(this,arguments)}function nt(t){var e=new RegExp("^((?:NaN|-?(?:(?:\\d+|\\d*\\.\\d+)(?:[E|e][+|-]?\\d+)?|Infinity)))$"),r="SyncTeX result begin",n=t.indexOf(r);if(-1==n)return{};var i=t.indexOf("SyncTeX result end");if(-1==i)return{};var s=t.slice(n+r.length+1,i-1),a=(0,B.splitlines)(s),o={},u=!0,c=!1,l=void 0;try{for(var f,h=a[Symbol.iterator]();!(u=(f=h.next()).done);u=!0){var p=K(f.value.split(":"),2),d=p[0],_=p[1];_.match(e)?o[d]=parseFloat(_):o[d]=_}}catch(t){c=!0,l=t}finally{try{u||null==h.return||h.return()}finally{if(c)throw l}}return o}function it(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function st(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){it(s,n,i,a,o,"next",t)}function o(t){it(s,n,i,a,o,"throw",t)}a(void 0)}))}}var at=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};function ot(t,e,r,n){return ut.apply(this,arguments)}function ut(){return(ut=st((function(t,e,r,n){var i,s,a;return at(this,(function(o){switch(o.label){case 0:return i=(0,h.l)(e),s=i.base,a=i.directory,[4,(0,c.GL)({command:"bibtex",args:[s],project_id:t,path:n||a,err_on_exit:!1,aggregate:r})];case 1:return[2,o.sent()]}}))}))).apply(this,arguments)}function ct(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function lt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){ct(s,n,i,a,o,"next",t)}function o(t){ct(s,n,i,a,o,"throw",t)}a(void 0)}))}}var ft=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}};function ht(t,e,r){return pt.apply(this,arguments)}function pt(){return(pt=lt((function(t,e,r){var n,i,s;return ft(this,(function(a){switch(a.label){case 0:return n=(0,B.path_split)(e),i=n.head,s=n.tail,[4,(0,c.GL)({command:"texcount",args:[s],project_id:t,path:i,err_on_exit:!1,aggregate:r})];case 1:return[2,a.sent()]}}))}))).apply(this,arguments)}function dt(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function _t(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){dt(s,n,i,a,o,"next",t)}function o(t){dt(s,n,i,a,o,"throw",t)}a(void 0)}))}}var vt=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}},yt=[".aux",".logger",".bbl",".fls",".synctex.gz",".sagetex.py",".sagetex.sage",".sagetex.sage.py",".sagetex.scmd",".sagetex.sout",".pdfsync","-concordance.tex",".pytxcode",".pgf-plot.gnuplot",".pgf-plot.table"];function gt(t,e){return bt.apply(this,arguments)}function bt(){return bt=_t((function(t,e){var r,n,i,s,a,o,u,l,f,p,d,_,v=arguments;return vt(this,(function(y){switch(y.label){case 0:return r=v.length>2&&void 0!==v[2]&&v[2],n=v.length>3?v[3]:void 0,i=v.length>4?v[4]:void 0,s=(0,h.l)(e),a=s.directory,o=s.base,n("Running 'latexmk -f -c ".concat(o,"'\n")),u=["-f","-c",o],null!=i&&u.push("-output-directory=".concat(i)),[4,(0,c.GL)({command:"latexmk",args:u,project_id:t,path:a})];case 1:return(l=y.sent())&&n(l.stdout+"\n"+l.stderr+"\n"),f=yt,r&&(f=f.concat(".tex")),p=f.map((function(t){return"".concat(o).concat(t)})),d="pythontex-files-".concat(o.replace(/ /g,"-")),p=p.concat(d),_=["-v","-f","-r","--"].concat(p),n("Removing ".concat(p.join(", "))),[4,(0,c.GL)({command:"rm",args:_,project_id:t,path:a})];case 2:return(l=y.sent())&&n(l.stdout+"\n"+l.stderr+"\n"),[2]}}))})),bt.apply(this,arguments)}var mt=r(19990),wt=r(24816),xt=r(63505);var kt=r(89550),St=r(98101),Lt=r(56570),Et=r(32295),jt=r(78193),Ot=r(97891);function Pt(t){var e=0,r=[],n=[0],i=!0,s=!1,a=void 0;try{for(var o,u=t.split("\n")[Symbol.iterator]();!(i=(o=u.next()).done);i=!0){var c=o.value;e+=1;var l,f,h,p,d=c.trim();d.startsWith("\\section{")?(n=[n[0]+1],r.push({level:1,value:d.slice("\\section{".length,-1),id:"".concat(e)})):d.startsWith("\\subsection{")?(n=[n[0],(null!==(l=n[1])&&void 0!==l?l:0)+1],r.push({level:2,value:d.slice("\\subsection{".length,-1),id:"".concat(e)})):d.startsWith("\\subsubsection{")?(n=[n[0],n[1],(null!==(f=n[2])&&void 0!==f?f:0)+1],r.push({level:3,value:d.slice("\\subsubsection{".length,-1),id:"".concat(e)})):d.startsWith("\\paragraph{")?(n=[n[0],n[1],n[2],(null!==(h=n[3])&&void 0!==h?h:0)+1],r.push({level:4,value:d.slice("\\paragraph{".length,-1),id:"".concat(e)})):d.startsWith("\\subparagraph{")&&(n=[n[0],n[1],n[2],n[3],(null!==(p=n[4])&&void 0!==p?p:0)+1],r.push({level:5,value:d.slice("\\subparagraph{".length,-1),id:"".concat(e)}))}}catch(t){s=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(s)throw a}}return r}function It(t,e,r,n,i,s,a){try{var o=t[s](a),u=o.value}catch(t){return void r(t)}o.done?e(u):Promise.resolve(u).then(n,i)}function Rt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var s=t.apply(e,r);function a(t){It(s,n,i,a,o,"next",t)}function o(t){It(s,n,i,a,o,"throw",t)}a(void 0)}))}}function Tt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Wt(t,e,r){return Wt="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=At(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}},Wt(t,e,r||t)}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}function Ft(t,e){return!e||"object"!==zt(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function Gt(t,e){return Gt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Gt(t,e)}var zt=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};var Ct=function(t,e){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}},Dt=["pdfjs_canvas","pdf_embed","build"],Jt=(0,Et.createTypedMap)(),Ut=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&&Gt(t,e)}(p,t);var e,r,l=(e=p,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=At(e);if(r){var i=At(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return Ft(this,t)});function p(){var t;return Tt(this,p),(t=l.apply(this,arguments)).is_building=!1,t.ext="tex",t.knitr=!1,t.engine_config=void 0,t.relative_paths={},t.canonical_paths={},t}var d=p.prototype;return d.output_directory_path=function(){return"/tmp/".concat((0,B.sha1)(this.path))},d._init2=function(){this.set_gutter=this.set_gutter.bind(this),this.is_public||(this.init_bad_filename(),this.init_ext_filename(),this._init_syncstring_value(),this.init_ext_path(),this.init_latexmk(),this._init_spellcheck(),this.init_config(),this.knitr||(this.output_directory=this.output_directory_path()),this._syncstring.on("change",(0,s.debounce)(this.updateTableOfContents.bind(this),1500)))},d.init_bad_filename=function(){this.bad_filename=/\s\s+/.test(this.path)},d.init_ext_filename=function(){var t=(0,B.separate_file_extension)(this.path).ext;t&&(this.ext=t.toLowerCase(),St.Y.includes(this.ext)&&(this.knitr=!0,this.filename_knitr=this.path))},d.get_spellcheck_path=function(){return this.knitr?this.filename_knitr:Wt(At(p.prototype),"get_spellcheck_path",this).call(this)},d.init_ext_path=function(){this.knitr&&(this.path=(0,B.change_filename_extension)(this.path,"tex"),this.setState({knitr:this.knitr,knitr_error:!1}))},d.not_ready=function(){return null==this._syncstring||"ready"!=this._syncstring.get_state()},d.is_likely_master=function(){if(this.not_ready())return!1;var t=this._syncstring.to_str();return t&&-1!=t.indexOf("\\document")},d.init_latexmk=function(){var t=this.redux.getStore("account"),e=this;this._syncstring.on("save-to-disk",(0,a.reuseInFlight)(Rt((function(){var r,n,i;return Ct(this,(function(s){switch(s.label){case 0:return e.not_ready()?[2]:(r=e._syncstring.hash_of_saved_version(),t&&t.getIn(["editor_settings","build_on_save"])&&e._last_syncstring_hash!=r?(e._last_syncstring_hash=r,null==e.parent_file||e.parent_file==e.path?[3,2]:[4,null==(i=e.redux.getEditorActions(e.project_id,e.parent_file))||null===(n=i.build)||void 0===n?void 0:n.call(i,"",!1)]):[3,4]);case 1:return s.sent(),[3,4];case 2:return null==e.parent_file&&e.is_likely_master()?[4,e.build("",!1)]:[3,4];case 3:s.sent(),s.label=4;case 4:return[2]}}))}))))},d.rescan_latex_directive=function(){var t=this;return Rt((function(){return Ct(this,(function(e){switch(e.label){case 0:return[4,t.init_build_directive(!0)];case 1:return e.sent(),[2]}}))}))()},d.init_build_directive=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this;return Rt((function(){var r,n,i,s,a,o,c,l,h,p,d,_;return Ct(this,(function(v){switch(v.label){case 0:return void 0!==e.engine_config?[2]:"init"!=e._syncstring.get_state()?[3,2]:[4,(0,u.once)(e._syncstring,"ready")];case 1:v.sent(),v.label=2;case 2:if("closed"==e._state)return[2];r="",n="",i=e._syncstring.to_str(),a=0,o=!0,c=!1,l=void 0;try{for(h=(0,B.splitlines)(i)[Symbol.iterator]();!((o=(p=h.next()).done)||(s=p.value,(a+=1)>1e3)||(0,B.startswith)(s,"%")&&-1!=(d=s.indexOf("="))&&(_=s.slice(0,d).trim().toLowerCase().replace(/\s+/g," "),t||!(0,B.startswith)(_,"% !tex program")&&!(0,B.startswith)(_,"% !tex ts-program")?(0,B.startswith)(_,"% !tex cocalc")&&(n=s.slice(d+1).trim()):r=s.slice(d+1).trim(),n||n&&r));o=!0);}catch(t){c=!0,l=t}finally{try{o||null==h.return||h.return()}finally{if(c)throw l}}return n?(e.set_build_command(n),e.setState({build_command_hardcoded:!0})):r?(e.engine_config=(0,f.Cr)(r),null!=e.engine_config&&e.set_build_command((0,f.mT)(e.engine_config,(0,B.path_split)(e.path).tail,e.knitr,e.output_directory)),e.setState({build_command_hardcoded:!1})):e.setState({build_command_hardcoded:!1}),[2]}}))}))()},d.init_config=function(){var t=this;return Rt((function(){var e,r;return Ct(this,(function(n){switch(n.label){case 0:if(t.setState({build_command:""}),e=t.knitr?t.filename_knitr:t.path,t._init_syncdb(["key"],void 0,e),null==t._syncdb)throw Error("syncdb must be defined");return"init"!=t._syncdb.get_state()?[3,2]:[4,(0,u.once)(t._syncdb,"ready")];case 1:if(n.sent(),"closed"==t._state)return[2];n.label=2;case 2:if(null==t._syncdb)throw Error("syncdb must be defined");return null!=t._syncdb.get_one({key:"build_command"})?[3,4]:[4,t.init_build_directive()];case 3:return n.sent(),"closed"==t._state?[2]:[3,6];case 4:return[4,t.init_build_directive(!0)];case 5:n.sent(),n.label=6;case 6:return(r=function(){if(null==t._syncdb)throw Error("syncdb must be defined");var e=t._syncdb.get_one({key:"build_command"});if(void 0!==e&&void 0!==e.get("value")){var r=e.get("value");if("string"==typeof r){if(r.length>0){var n=t.sanitize_build_cmd_str(r);return t.setState({build_command:n}),void t.set_build_command(n)}}else if(r.size>0){var i=t.sanitize_build_cmd(r);return t.setState({build_command:i}),void t.set_build_command(i.toJS())}}var s=(0,f.mT)(t.engine_config||"PDFLaTeX",(0,B.path_split)(t.path).tail,t.knitr,t.output_directory);t.set_build_command(s)})(),t._syncdb.on("change",r),t.is_likely_master()&&t.force_build(),[2]}}))}))()},d.output_directory_cmd_flag=function(t){var e=null!=t?t:this.output_directory;return"-output-directory=".concat(e)},d.sanitize_build_cmd_str=function(t){if(-1!=t.indexOf(";"))return t;var e=t.indexOf("-output-directory=");if(-1!=e){var r=t.indexOf(" ",e);-1==r&&(r=t.length),this.output_directory?t.slice(e+"-output-directory=".length,r)!=this.output_directory&&(t=t.slice(0,e)+"-output-directory=".concat(this.output_directory," ")+t.slice(r)):t=t.slice(0,e)+t.slice(r)}if(!(t=(0,kt.q)(t,(0,B.path_split)(this.path).tail)).trim().startsWith("latexmk"))return t;for(var n=0,i=[" -dependents- "," -deps- "];n<i.length;n++){var s=i[n];-1!==t.indexOf(s)&&(t=t.replace(s," "))}if(-1!==t.indexOf(" -deps "))return t;var a=t.split(" ");return a.splice(2,0,"-deps"),a.join(" ")},d.sanitize_build_cmd=function(t){var e;if(null===(e=t.get(0))||void 0===e?void 0:e.startsWith("false"))return t;var r=void 0,n=-1,i=!0,s=!1,a=void 0;try{for(var o,u=t[Symbol.iterator]();!(i=(o=u.next()).done);i=!0){var c=o.value;if(n+=1,(0,B.startswith)(c,"-output-directory=")){r=c;break}}}catch(t){s=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(s)throw a}}if(null!=r)if(null!=this.output_directory){var l=this.output_directory_cmd_flag();r!=l&&(t=t.set(n,l))}else t=t.delete(n);for(var f=0,h=["-dependents-","-deps-"];f<h.length;f++){var p=h[f],d=t.indexOf(p);-1!==d&&(t=t.delete(d))}t.some((function(t){return"-deps"===t||"-dependents"===t}))||(t=t.splice(3,0,"-deps"));var _=(0,B.path_split)(this.path).tail;return _!=t.get(t.size-1)&&(t=t.set(t.size-1,_)),t},d.ensure_output_directory_disabled=function(){if(this.output_directory=void 0,null==this._syncdb)throw Error("syncdb must be defined");var t=this._syncdb.get_one({key:"build_command"});if(null==t)return!1;var e=t.get("value"),r="string"==typeof e?e:e.toJS(),n=this.output_directory_cmd_flag(this.output_directory_path()),i=!1;if("string"==typeof e){var s=e.indexOf(n);if(s>=0){i=!0;var a=e.slice(0,s),o=e.slice(s+n.length);r="".concat(a).concat(o)}}else{var u=e.filter((function(t){return t!=n}));i=!u.equals(e),r=u.toJS()}return this.set_build_command(r),i},d._raw_default_frame_tree=function(){return this.is_public?{type:"cm"}:{type:"node",direction:"col",first:{direction:"row",type:"node",first:{type:"cm"},second:{type:"node",direction:"col",first:{type:"latex_table_of_contents"},second:{type:"error"},pos:.3},pos:.7},second:{direction:"row",type:"node",first:{type:"pdfjs_canvas"},second:{type:"build"},pos:.7},pos:.5}},d.check_for_fatal_error=function(){var t=this.store.get("build_logs");if(t){var e=t.getIn(["latex","parse","errors"]);if(!(void 0===e||e.size<1)){var r=e.get(e.size-1),n=r.get("message")+r.get("content");if(-1!=n.indexOf("no output PDF")){var i=n.indexOf("Fatal error");-1!==i&&(n=n.slice(i)),-1!=(i=n.indexOf("!"))&&(n=n.slice(0,i+1));var s="WARNING: It is not possible to generate a useful PDF file.\n"+n.trim();console.warn(s),this.set_error(s)}}}},d._forget_pdf_document=function(){(0,Lt.j5)((0,Lt.t$)(this.project_id,this.path,this.store.unsafe_getIn(["reload",Dt[0]])))},d.close=function(){this._forget_pdf_document(),Wt(At(p.prototype),"close",this).call(this)},d.force_build=function(t){var e=this;return Rt((function(){return Ct(this,(function(r){switch(r.label){case 0:return[4,e.build(t,!0)];case 1:return r.sent(),[2]}}))}))()},d.all_actions=function(){var t=this.store.get("switch_to_files");if(null==t||t.size<=1)return[this];var e=[],r=!0,n=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done);r=!0){var o=s.value,u=this.redux.getEditorActions(this.project_id,o);null!=u&&(this.path!=o&&u.set_parent_file(this.path),e.push(u))}}catch(t){n=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(n)throw i}}return e},d.save_all=function(t){var e=this;return Rt((function(){var r,n,i,s,a,o;return Ct(this,(function(u){switch(u.label){case 0:r=!0,n=!1,i=void 0,u.label=1;case 1:u.trys.push([1,6,7,8]),s=e.all_actions()[Symbol.iterator](),u.label=2;case 2:return(r=(a=s.next()).done)?[3,5]:[4,a.value.save(t)];case 3:u.sent(),u.label=4;case 4:return r=!0,[3,2];case 5:return[3,8];case 6:return o=u.sent(),n=!0,i=o,[3,8];case 7:try{r||null==s.return||s.return()}finally{if(n)throw i}return[7];case 8:return[2]}}))}))()},d.explicit_save=function(){var t=this;return Rt((function(){var e;return Ct(this,(function(r){switch(r.label){case 0:return null!=(e=t.redux.getStore("account"))&&e.getIn(["editor_settings","build_on_save"])&&t.is_likely_master()?[3,2]:[4,t.save_all(!0)];case 1:return r.sent(),[2,!1];case 2:return[4,t.build()];case 3:return r.sent(),[2,!0]}}))}))()},d.build=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this;return Rt((function(){var n;return Ct(this,(function(i){switch(i.label){case 0:if(t&&(n=r._get_cm(t))&&n.focus(),r.is_building)return[2];r.is_building=!0,i.label=1;case 1:return i.trys.push([1,,4,5]),[4,r.save_all(!1)];case 2:return i.sent(),[4,r.run_build(r.last_save_time(),e)];case 3:return i.sent(),[3,5];case 4:return r.is_building=!1,[7];case 5:return[2]}}))}))()},d.clean=function(){var t=this;return Rt((function(){return Ct(this,(function(e){switch(e.label){case 0:return[4,t.build_action("clean")];case 1:return e.sent(),[2]}}))}))()},d.run_build=function(t,e){var r=this;return Rt((function(){var n,i,s,a,u,c;return Ct(this,(function(l){switch(l.label){case 0:return r.setState({build_logs:(0,o.Map)()}),r.bad_filename?(n="ERROR: It is not possible to compile this LaTeX file with the name '".concat(r.path,"'.\n Please modify the filename, such that it does **not** contain two or more consecutive spaces."),r.set_error(n),[2]):r.knitr?[4,r.run_knitr(t,e)]:[3,2];case 1:if(l.sent(),r.store.get("knitr_error"))return[2];l.label=2;case 2:return i=r.word_count(t,e),[4,r.run_latex(t,e,!1)];case 3:return l.sent(),r.knitr?[4,r.run_patch_synctex(t,e)]:[3,5];case 4:l.sent(),l.label=5;case 5:return s=r.store.unsafe_getIn(["build_logs","latex","stdout"]),a=!0,"string"!=typeof s?[3,11]:(u=-1!=s.indexOf("sagetex.sty"),c=-1!=s.indexOf("pythontex.sty")||-1!=s.indexOf("PythonTeX"),u||c?r.ensure_output_directory_disabled()?[4,r.run_latex(t,!0,!1)]:[3,7]:[3,11]);case 6:l.sent(),l.label=7;case 7:return a=!1,u?[4,r.run_sagetex(t,e)]:[3,9];case 8:l.sent(),l.label=9;case 9:return c?[4,r.run_pythontex(t,e)]:[3,11];case 10:l.sent(),l.label=11;case 11:return a&&r.update_pdf(t,e),[4,i];case 12:return l.sent(),[2]}}))}))()},d.run_knitr=function(t,e){var r=this;return Rt((function(){var n,i,s,a,o;return Ct(this,(function(u){switch(u.label){case 0:(a=function(t){return r.set_status("Running Knitr... ".concat(t))})(""),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,N(r.project_id,r.filename_knitr,r.make_timestamp(t,e),a)];case 2:return s=u.sent(),[3,5];case 3:return o=u.sent(),r.set_error(o),r.setState({knitr_error:!0}),[2];case 4:return r.set_status(""),[7];case 5:return s.parse=function(t){var e=new m,r="",n=void 0,i="Warning message:",s="Quitting from lines ",a=!0,o=!1,u=void 0;try{for(var c,l=t.stderr.split("\n")[Symbol.iterator]();!(a=(c=l.next()).done);a=!0){var f=c.value;if(0!=f.search("Error"))if(f.substring(f.length-i.length)!=i){if(0==f.search("processing file:")&&(r=f.substring("processing file:".length).trim()),null!=n&&0==f.indexOf(s))try{var h=f.substring(s.length).split(" ")[0].split("-")[0];0==h.search(/\d+/)&&(n.line=parseInt(h))}catch(t){}null!=n&&(n.content+="".concat(f,"\n"))}else n={line:null,file:"".concat(r),level:"warning",message:f,content:"",raw:""},e.warnings.push(n),e.all.push(n);else n={line:null,file:"".concat(r),level:"error",message:f,content:"",raw:""},e.errors.push(n),e.all.push(n)}}catch(t){o=!0,u=t}finally{try{a||null==l.return||l.return()}finally{if(o)throw u}}return e}(s).toJS(),r.merge_parsed_output_log(s.parse),r.set_build_logs({knitr:s}),r.update_gutters(),r.setState({knitr_error:(null===(n=s.parse)||void 0===n||null===(i=n.errors)||void 0===i?void 0:i.length)>0}),[2]}}))}))()},d.run_patch_synctex=function(t,e){var r=this;return Rt((function(){var n,i;return Ct(this,(function(s){switch(s.label){case 0:(n=function(t){return r.set_status('Running Knitr/Synctex... "'.concat(t,'"'))})(""),s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,X(r.project_id,r.path,r.make_timestamp(t,e),n)];case 2:return s.sent(),[3,5];case 3:return i=s.sent(),r.set_error(i),[2];case 4:return r.set_status(""),[7];case 5:return[2]}}))}))()},d.get_output_directory=function(){if(!this.knitr){var t=this.store.get("build_command");if(t){if("string"==typeof t)return-1==t.indexOf("-output-directory")?void 0:this.output_directory;var e=!0,r=!1,n=void 0;try{for(var i,s=t.toJS()[Symbol.iterator]();!(e=(i=s.next()).done);e=!0)if(i.value.startsWith("-output-directory"))return this.output_directory}catch(t){r=!0,n=t}finally{try{e||null==s.return||s.return()}finally{if(r)throw n}}}}},d.run_latex=function(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this;return Rt((function(){var i,s,a,o,u,c;return Ct(this,(function(l){switch(l.label){case 0:if(a=n.make_timestamp(t,e),!(o=n.store.get("build_command")))return[2];n.set_error(""),n.set_build_logs({latex:void 0}),s="string"==typeof o?o:o.toJS(),u=function(t){return n.set_status("Running Latex... ".concat(t))},u(""),l.label=1;case 1:return l.trys.push([1,3,,4]),[4,(0,f.bF)(n.project_id,n.path,s,a,u,n.get_output_directory())];case 2:return i=l.sent(),[3,4];case 3:return c=l.sent(),n.set_error(c),[2];case 4:return n.set_status(""),n.parsed_output_log=i.parse=new w(i.stdout,{ignoreDuplicates:!0}).parse(),n.set_build_logs({latex:i}),n.knitr||null==n.parsed_output_log.deps||n.set_switch_to_files(n.parsed_output_log.deps),n.check_for_fatal_error(),n.update_gutters(),r&&n.update_pdf(t,e),[2]}}))}))()},d.merge_parsed_output_log=function(t){var e=this,r=function(r,n){var i=n[r],s=e.parsed_output_log[i];t[i].forEach((function(t){return s.push(t)}))};if(null!=this.parsed_output_log){for(var n=0,i=["errors","warnings","typesetting","all"];n<i.length;n++)r(n,i);for(var a=0,o=["files","deps"];a<o.length;a++){var u=o[a];this.parsed_output_log[u]=(0,s.union)(this.parsed_output_log[u],t[u])}}else this.parsed_output_log=t},d.update_gutters_soon=function(){var t=this;return Rt((function(){return Ct(this,(function(e){switch(e.label){case 0:return[4,(0,n.delay)(500)];case 1:return e.sent(),"closed"==t._state||t.update_gutters(),[2]}}))}))()},d.update_gutters=function(){null!=this.parsed_output_log&&(this.clear_gutters(),function(t){for(var e=0,r=["typesetting","warnings","errors"];e<r.length;e++){var n=r[e],i=void 0,s=!0,a=!1,o=void 0;try{for(var u,c=t.log[n][Symbol.iterator]();!(s=(u=c.next()).done);s=!0)(i=u.value).file&&null!=i.line&&t.set_gutter(i.file,i.line-1,(l=i.level,f=i.message,h=i.content,p=void 0,p=wt._[l],void 0===h&&(h=f,f=(0,B.capitalize)(l)),xt.createElement(mt.Tip,{title:f,tip:h,placement:"right",icon:p.icon,stable:!0,popover_style:{padding:0,opacity:.9,border:"2px solid ".concat(p.color),borderRadius:"3px"},delayShow:0,allow_touch:!0},xt.createElement(mt.Icon,{name:p.icon,style:{color:p.color,cursor:"pointer"}}))))}catch(t){a=!0,o=t}finally{try{s||null==c.return||c.return()}finally{if(a)throw o}}}var l,f,h,p}({log:this.parsed_output_log,set_gutter:this.set_gutter}))},d.clear_gutters=function(){var t=!0,e=!1,r=void 0;try{for(var n,i=this.all_actions()[Symbol.iterator]();!(t=(n=i.next()).done);t=!0)n.value.clear_gutter("Codemirror-latex-errors")}catch(t){e=!0,r=t}finally{try{t||null==i.return||i.return()}finally{if(e)throw r}}},d.set_gutter=function(t,e,r){var n=this.get_canonical_path(t);null!=n&&(t=n);var s=this.redux.getEditorActions(this.project_id,(0,i.normalize)(t));null!=s&&s.set_gutter_marker({line:e,component:r,gutter_id:"Codemirror-latex-errors"})},d.get_canonical_path=function(t){var e=(0,i.normalize)(t);return this.canonical_paths[e]},d.set_switch_to_files=function(t){var e=this;return Rt((function(){var r,n,s,a,o,u,l,f,h,p,d;return Ct(this,(function(_){switch(_.label){case 0:if(n=e.store.get("switch_to_files"),r=null!=n?n.toJS():[],""==(a=(0,B.path_split)(e.path).head))s=t;else for(s=[],o=0;o<t.length;o++)t[o].startsWith("/")?s.push(t[o]):s.push(a+"/"+t[o]);return[4,(0,c.ZO)(e.project_id)];case 1:u=_.sent(),_.label=2;case 2:return _.trys.push([2,4,,5]),[4,u.canonical_paths(s)];case 3:return l=_.sent(),e.setState({includeError:""}),[3,5];case 4:return f=_.sent(),e.setState({includeError:f.toString()}),[2];case 5:for(h=0;h<l.length;h++)(p=l[h]).startsWith("/")||(r.push(p),d=(0,i.normalize)(t[h]),e.relative_paths[p]=d,e.canonical_paths[d]=p);return e.setState({switch_to_files:Array.from(new Set(r)).sort()}),[2]}}))}))()},d.update_pdf=function(t,e){var r=this.make_timestamp(t,e);this._forget_pdf_document();var n=!0,i=!1,s=void 0;try{for(var a,o=Dt[Symbol.iterator]();!(n=(a=o.next()).done);n=!0){var u=a.value;this.set_reload(u,r)}}catch(t){i=!0,s=t}finally{try{n||null==o.return||o.return()}finally{if(i)throw s}}},d.run_bibtex=function(t,e){var r=this;return Rt((function(){var n,i;return Ct(this,(function(s){switch(s.label){case 0:r.set_status("Running BibTeX..."),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,ot(r.project_id,r.path,r.make_timestamp(t,e),r.get_output_directory())];case 2:return n=s.sent(),r.set_build_logs({bibtex:n}),[3,4];case 3:return i=s.sent(),r.set_error(i),[3,4];case 4:return r.set_status(""),[2]}}))}))()},d.run_sagetex=function(t,e){var r=this;return Rt((function(){var n,i,s,a,o;return Ct(this,(function(u){switch(u.label){case 0:if((n=function(t){return r.set_status("Running SageTeX... ".concat(t))})(""),i="",e)return[3,5];u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,E(r.project_id,r.path,t,n,r.get_output_directory())];case 2:return(i=u.sent())===r._last_sagetex_hash?(r.update_pdf(t,e),[2]):[3,5];case 3:return s=u.sent(),r.set_error(s),r.update_pdf(t,e),[2];case 4:return r.set_status(""),[7];case 5:return u.trys.push([5,8,9,10]),[4,O(r.project_id,r.path,i,n,r.get_output_directory())];case 6:if(-1!=(a=u.sent()).stderr.indexOf("sagetex.VersionError"))throw Error("SageTex in CoCalc currently only works with the default verison of Sage. Delete ~/bin/sage and try again.");return[4,r.run_latex(t+1,e)];case 7:return u.sent(),[3,10];case 8:return o=u.sent(),r.set_error(o),r.update_pdf(t,e),[3,10];case 9:return r._last_sagetex_hash=i,r.set_status(""),[7];case 10:return null!=a&&(a.parse=function(t,e){var r=new m,n=void 0;if(e.stderr.indexOf("Sage processing complete")>=0)return r;var i=!0,s=!1,a=void 0;try{for(var o,u=e.stderr.split("\n")[Symbol.iterator]();!(i=(o=u.next()).done);i=!0){var c=o.value;c.trim().length>0?(null==n&&(n={line:null,file:t,level:"error",message:c,content:"",raw:""},r.errors.push(n),r.all.push(n)),n.content+="".concat(c,"\n"),n.message=c):n=void 0}}catch(t){s=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(s)throw a}}return r}((0,B.path_split)(r.path).tail,a).toJS(),r.merge_parsed_output_log(a.parse),r.set_build_logs({sagetex:a})),[2]}}))}))()},d.run_pythontex=function(t,e){var r=this;return Rt((function(){var n,i,s;return Ct(this,(function(a){switch(a.label){case 0:(i=function(t){return r.set_status("Running PythonTeX... ".concat(t))})(""),a.label=1;case 1:return a.trys.push([1,4,5,6]),[4,W(r.project_id,r.path,t,e,i,r.get_output_directory())];case 2:return n=a.sent(),[4,r.run_latex(t+2,e)];case 3:return a.sent(),[3,6];case 4:return s=a.sent(),r.set_error(s),r.update_pdf(t,e),[2];case 5:return r.set_status(""),[7];case 6:return n.parse=function(t,e){var r=new m,n=void 0,i=!0,s=!1,a=void 0;try{for(var o,u=e.stdout.split("\n")[Symbol.iterator]();!(i=(o=u.next()).done);i=!0){var c=o.value;if(c.search("PythonTeX stderr")>0){var l=c.match(/line (\d+):/),f=null;null!==l&&l.length>=2&&(f=parseInt(l[1])),n={line:f,file:t,level:"error",message:c,content:"",raw:""},r.errors.push(n),r.all.push(n)}else if(null!=n){if(c.startsWith("-----"))break;n.content+="".concat(c,"\n")}}}catch(t){s=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(s)throw a}}return r}((0,B.path_split)(r.path).tail,n).toJS(),r.merge_parsed_output_log(n.parse),r.set_build_logs({pythontex:n}),r.update_gutters(),[2]}}))}))()},d.synctex_pdf_to_tex=function(t,e,r){var n=this;return Rt((function(){var i,s,a;return Ct(this,(function(o){switch(o.label){case 0:n.set_status("Running SyncTex..."),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,Y({x:e,y:r,page:t,pdf_path:(0,kt.n)(n.path),project_id:n.project_id,output_directory:n.get_output_directory(),src:n.path})];case 2:if(i=o.sent(),"number"!=typeof(s=i.Line))throw Error("invalid synctex output (Line must be a number).");if("string"!=typeof i.Input)throw Error("unable to determine source file");return n.goto_line_in_file(s,i.Input),[3,5];case 3:return-1!=(a=o.sent()).message.indexOf("ENOENT")?(console.log("synctex_pdf_to_tex err:",a),n.set_error('Synctex failed to run. Try "Force Rebuild" your project (use the Build frame) or retry once the build is complete.'),[2]):(console.warn("ERROR ",a),n.set_error(a),[3,5]);case 4:return n.set_status(""),[7];case 5:return[2]}}))}))()},d.goto_line_in_file=func