@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 64.2 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[9534],{61187:(e,t,n)=>{n.d(t,{Ln:()=>h,WG:()=>y,ZP:()=>d,iw:()=>p,pj:()=>v,ul:()=>m});var r=n(92942),i=n(63505),o=n(40216),l=n(52224),a=n(31791),u=n(24620),c=n(85755),s=n(68245),f=n(63505);function d(e){var t=e.element;return f.createElement(f.Fragment,null,f.createElement(l.JO,{name:"comment",style:(0,o.C2)(t,{fontSize:24,background:"white"})}),f.createElement("div",{style:v(t)},f.createElement(y,{Message:g,element:t,style:{flex:1,overflowY:"auto",background:"white"}})))}function v(e){var t,n;return{padding:"5px",margin:"0 30px 30px 30px",background:"white",height:"".concat(e.h-60,"px"),display:"flex",flexDirection:"column",border:"3px solid ".concat(null!==(n=null===(t=e.data)||void 0===t?void 0:t.color)&&void 0!==n?n:"#ccc"),borderRadius:"5px",boxShadow:"1px 5px 7px rgb(33 33 33 / 70%)"}}function y(e){var t=e.element,n=e.style,o=e.Message,l=(0,i.useRef)(null);(0,s.Z)(l),(0,i.useEffect)((function(){var e=r.findDOMNode(l.current);e&&(e.scrollTop=e.scrollHeight)}),[t.data]);var a=[],c=!0,d=!1,v=void 0;try{for(var y,h=function(e){var t,n=[];for(var r in null!==(t=e.data)&&void 0!==t?t:{})if(!(0,u.is_valid_uuid_string)(r)){var i=parseInt(r);isNaN(i)||n.push(i)}return n.sort(u.cmp),n}(t)[Symbol.iterator]();!(c=(y=h.next()).done);c=!0){var p=y.value;a.push(f.createElement(o,{key:p,element:t,messageId:p}))}}catch(e){d=!0,v=e}finally{try{c||null==h.return||h.return()}finally{if(d)throw v}}return f.createElement("div",{ref:l,style:n},a)}function h(e){var t,n=-1;for(var r in null!==(t=e.data)&&void 0!==t?t:{}){var i=parseInt(r);isNaN(i)||(n=Math.max(n,i))}return n}function p(e){if(null!=e.data&&"chat"==e.type)for(var t in e.data){(0,u.is_valid_uuid_string)(t)&&delete e.data[t];var n=parseInt(t);isNaN(n)||delete e.data[n]}}var m={border:"1px solid #ccc",borderRadius:"5px",margin:"5px 0",padding:"5px 15px"};function g(e){var t,n,r=e.element,i=e.messageId,o=null!==(n=null===(t=r.data)||void 0===t?void 0:t[i])&&void 0!==n?n:{},l=o.input,u=o.sender_name,s=o.time;return f.createElement("div",{style:m},f.createElement(a.Z,{author:u,content:"number"==typeof i?f.createElement(c.Z,{value:null!=l?l:""}):"...",datetime:new Date(s).toLocaleString()}))}},12407:(e,t,n)=>{n.d(t,{v0:()=>C,ZP:()=>z,oY:()=>I});var r=n(63505),i=n(32295),o=n(19990),l=n(25732),a=n(54822),u=n(85755),c=(n(68613),n(60799)),s=n(24809),f=n(31791),d=n(24620),v=n(85733),y=n(17867),h=n(11600),p=n(74591),m=n(63505);function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function b(e){var t,n,o=e.element,l=e.focused,a=(0,i.useIsMountedRef)(),u=(t=(0,r.useState)(0),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){a=!0,i=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw i}}return o}}(t,n)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(t,n)||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.")}()),c=u[0],s=u[1],f=(0,r.useMemo)((function(){var e,t=(new Date).valueOf()-6e4,n=[];for(var r in null!==(e=o.data)&&void 0!==e?e:{})if(36==r.length){var u,f=null!==(u=o.data[r])&&void 0!==u?u:{},d=f.input,v=f.time;!(null==d?void 0:d.trim())||null==v||!(v>=t||r==i.redux.getStore("account").get_account_id())||l&&r==i.redux.getStore("account").get_account_id()||n.push(m.createElement(C,{key:r,element:o,messageId:r}))}return n.length>0&&setTimeout((function(){a.current&&s(c+1)}),5e3),m.createElement("div",null,n)}),[o.data,l,c]);return f}var w=n(68245),_=n(85166),x=n(61187),S=n(63505);function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){O(e,t,n[t])}))}return e}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){a=!0,i=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(e,t):void 0}}(e,t)||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 P="123px";function z(e){var t=e.element,n=e.focused;return S.createElement(S.Fragment,null,S.createElement(o.Icon,{name:"comment",style:(0,l.C)(t,{fontSize:24,background:"white"})}),S.createElement(M,{element:t,focused:n}))}function M(e){var t=e.element,n=e.focused,o=(0,a.s)(),l=o.actions,u=o.desc,f=k((0,h.Z)(u.get("editFocus")),2),v=f[0],m=f[1],g=k((0,r.useState)(""),2),E=g[0],O=g[1],z=(0,r.useRef)(),M=(0,p.Z)((function(e){F.current=e,l.saveChat({id:t.id,input:e})}),_.SAVE_DEBOUNCE_MS),I=k((0,r.useState)(""),2),T=I[0],A=I[1],F=(0,r.useRef)("");(0,r.useEffect)((function(){var e,r;if(n){var o,l=null!==(o=null===(e=t.data)||void 0===e||null===(r=e[i.redux.getStore("account").get_account_id()])||void 0===r?void 0:r.input)&&void 0!==o?o:"";l!=F.current&&(M.cancel(),A(l)),F.current=l}}),[t,n]);var Z=function(){F.current="",A(""),M.cancel()};(0,r.useEffect)((function(){return function(){M.flush()}}),[M]);var D=(0,r.useRef)(null);return(0,w.Z)(D),S.createElement("div",{style:(0,x.pj)(t)},S.createElement(x.WG,{Message:C,element:t,style:{flex:1,overflowY:"auto",background:"white"}}),S.createElement(b,{element:t,focused:n}),(n||0===(0,d.len)(t.data))&&S.createElement("div",{ref:D,style:{height:"125px",display:"flex"},className:v?"nodrag":void 0,onClick:function(){n&&!v&&m(!0)},onTouchStart:function(){n&&!v&&m(!0)}},S.createElement(y.Z,{submitMentionsRef:z,saveDebounceMs:0,onFocus:function(){m(!0)},onBlur:function(){m(!1)},isFocused:n&&v,hideHelp:!0,noVfill:!0,minimal:!0,placeholder:"Type a message...",height:P,value:T,style:j({width:"".concat(t.w-152,"px")},"editor"==E?{border:"1px solid #ccc",paddingLeft:"5px"}:void 0),onChange:function(e){A(e),M(e)},onShiftEnter:function(e){var n;M.cancel(),l.sendChat({id:t.id,input:e}),null===(n=z.current)||void 0===n||n.call(z,{id:t.id}),Z()},onUndo:function(){M.cancel(),l.undo()},onRedo:function(){M.cancel(),l.redo()},editBarStyle:{visibility:v&&"markdown"!=E?void 0:"hidden",bottom:"-36px",left:"126px",position:"absolute",boxShadow:"1px 3px 5px #ccc",margin:"5px",minWidth:"500px",background:"white",fontFamily:"sans-serif",paddingRight:0},modeSwitchStyle:{visibility:v?void 0:"hidden",bottom:"-30px",left:0,width:"130px",boxShadow:"1px 3px 5px #ccc"},onModeChange:O,cmOptions:{lineNumbers:!1}}),S.createElement(c.Z,{title:"Send message (shift+enter)"},S.createElement(s.Z,{disabled:!T.trim(),type:"primary",style:{height:P,marginLeft:"5px"},onClick:function(){var e;l.sendChat({id:t.id,input:T}),null===(e=z.current)||void 0===e||e.call(z,{id:t.id}),Z()}},"Send"))))}function C(e){var t,n,r,i=e.element,l=e.messageId,a=null!==(n=null===(t=i.data)||void 0===t?void 0:t[l])&&void 0!==n?n:{},c=a.input,s=a.sender_id,d=a.sender_name,y=a.time;return"string"==typeof l&&(s=l),S.createElement("div",{style:x.ul},S.createElement(f.Z,{author:s?null!==(r=I(s))&&void 0!==r?r:d:void 0,avatar:s?S.createElement(v.q,{account_id:s}):void 0,content:"number"==typeof l?S.createElement(u.Z,{value:null!=c?c:""}):S.createElement(o.Icon,{name:"ellipsis",style:{fontSize:"24px"}}),datetime:S.createElement(o.TimeAgo,{date:y})}))}function I(e){var t,n=null===(t=i.redux.getStore("users").get_name(e))||void 0===t?void 0:t.trim();if(n)return(0,d.trunc_middle)(n,20)}},29486:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(40216),i=n(46152),o=n(54822),l=n(63505);function a(e){var t,n,a=e.element,u=e.readOnly,c=(0,o.s)().actions,s=!(null===(t=a.str)||void 0===t?void 0:t.trim());return l.createElement(i.Z,{value:s?r.l7:null!==(n=a.str)&&void 0!==n?n:"",style:(0,r.W2)(a,s),onChange:u||null==c?void 0:function(e){c.setElement({obj:{id:a.id,str:e},commit:!0})}})}},40216:(e,t,n)=>{n.d(t,{C2:()=>s,W2:()=>f,ZP:()=>c,l7:()=>u,tr:()=>a});var r=n(85755),i=n(15690),o=n(63505);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=5,u="Type text...";function c(e){var t,n,i=e.element,l=!(null===(t=i.str)||void 0===t?void 0:t.trim());return o.createElement(r.Z,{value:l?u:null!==(n=i.str)&&void 0!==n?n:"",style:f(i,l)})}function s(e,t){var n,r,o,l,a,u,c,s,f,d,v=null!==(u=null!==(a=null===(n=e.data)||void 0===n?void 0:n.fontFamily)&&void 0!==a?a:null==t?void 0:t.fontFamily)&&void 0!==u?u:i.rk;return"Sans"==v&&(v="sans-serif"),{color:null!==(c=null===(r=e.data)||void 0===r?void 0:r.color)&&void 0!==c?c:null==t?void 0:t.color,fontSize:null!==(f=null!==(s=null===(o=e.data)||void 0===o?void 0:o.fontSize)&&void 0!==s?s:null==t?void 0:t.fontSize)&&void 0!==f?f:i.n5,fontFamily:v,background:null!==(d=null===(l=e.data)||void 0===l?void 0:l.background)&&void 0!==d?d:null==t?void 0:t.background}}function f(e,t){return n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){l(e,t,n[t])}))}return e}({opacity:t?.5:void 0},s(e)),r=null!=(r={padding:"".concat(a+1,"px"),height:"auto",whiteSpace:"pre-wrap",overflowWrap:"break-word"})?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(r)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))})),n;var n,r}},25732:(e,t,n)=>{n.d(t,{Z:()=>m,C:()=>a.C2});var r=n(63505),i=n(54822),o=n(15690),l=n(29486),a=n(40216),u=n(17867),c=n(11600),s=n(83389),f=n(63505);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(){return y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){v(e,t,n[t])}))}return e}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){a=!0,i=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e,t)||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.")}()}function m(e){return!e.readOnly&&e.focused&&!e.element.locked||null!=e.cursors?f.createElement(g,y({},e)):f.createElement(l.Z,{element:e.element})}function g(e){var t,n=e.element,l=e.canvasScale,d=e.cursors,v=e.focused,m=e.readOnly,g=(0,i.s)().actions,b=p((0,r.useState)(""),2),w=b[0],_=b[1],x=p((0,c.Z)(!1),2),S=x[0],E=x[1],O=(0,r.useCallback)((function(e){if(null==e){if(!j.current)return;e=j.current()}var t;e!=(null!==(t=n.str)&&void 0!==t?t:"")&&g.setElement({obj:{id:n.id,str:e}})}),[n.id]);(0,r.useEffect)((function(){return function(){setTimeout(O,0)}}),[]);var j=(0,r.useRef)(null);(0,r.useEffect)((function(){if(null!=g._syncstring)return g._syncstring.on("before-change",O),function(){g._syncstring.removeListener("before-change",O),O()}}),[n.id]);var k,P,z,M=(0,r.useRef)(null),C=(0,s.Z)({ref:m||!S?void 0:M}),I=(0,r.useRef)(null);return(0,r.useEffect)((function(){I.current=!m&&S?function(){var e,t;if(!(m||g.in_undo_mode()&&n.str==(null===(e=j.current)||void 0===e?void 0:e.call(j))||n.rotate)){var r=M.current;if(null!=r){var i,o=Math.max((null!==(i=null===(t=r.getBoundingClientRect())||void 0===t?void 0:t.height)&&void 0!==i?i:0)/l+2*a.tr+2+15,78);g.setElement({obj:{id:n.id,h:o},commit:!1})}}}:null}),[l,n.id,S,m]),(0,r.useEffect)((function(){var e;null===(e=I.current)||void 0===e||e.call(I)}),[C]),f.createElement("div",y({},{},{style:(P=h({},(0,a.C2)(n)),z={padding:"".concat(a.tr,"px ").concat(a.tr,"px 0 ").concat(a.tr,"px "),height:"100%"},z=null!=z?z:{},Object.getOwnPropertyDescriptors?Object.defineProperties(P,Object.getOwnPropertyDescriptors(z)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(z)).forEach((function(e){Object.defineProperty(P,e,Object.getOwnPropertyDescriptor(z,e))})),P),className:S?"nodrag":void 0}),f.createElement("div",{ref:M},f.createElement(u.Z,{getValueRef:j,fixedMode:n.rotate||!v?"editor":void 0,refresh:l,noVfill:!0,minimal:!0,hideHelp:!0,placeholder:a.l7,isFocused:S&&v,onFocus:function(){E(!0)},value:n.str,fontSize:null!==(k=null===(t=n.data)||void 0===t?void 0:t.fontSize)&&void 0!==k?k:o.n5,onChange:O,cmOptions:{lineNumbers:!1},onModeChange:_,editBarStyle:{visibility:v&&"markdown"!=w?void 0:"hidden",top:"".concat(-60,"px"),left:"-24px",position:"absolute",boxShadow:"1px 3px 5px #ccc",margin:"5px",minWidth:"500px",background:"white",fontFamily:"sans-serif",paddingRight:0},modeSwitchStyle:{top:"-82px",left:"-18px"},onCursors:function(e){g.setCursors(n.id,e)},cursors:d,onSave:function(){g.save(!0)},onUndo:function(){g.undo()},onRedo:function(){g.redo()},compact:!0})))}},29534:(e,t,n)=>{n.r(t),n.d(t,{Actions:()=>Q,elementsList:()=>B,extendToIncludeEdges:()=>X});var r=n(2835),i=n(85460),o=n(5010),l=n(34183),a=n(24620),u=n(39530),c=n(15690),s=n(20812),f=n(13414);function d(e,t,n,r,i,o,l){try{var a=e[o](l),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,i)}function v(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function l(e){d(o,r,i,l,a,"next",e)}function a(e){d(o,r,i,l,a,"throw",e)}l(void 0)}))}}var y=function(e,t){var n,r,i,o,l={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,r=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!((i=(i=l.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){l.label=o[1];break}if(6===o[0]&&l.label<i[1]){l.label=i[1],i=o;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(o);break}i[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};function h(){return(h=v((function(e){var t,n,r,i,o,l,a,u,c;function s(){var e,t=a.get("cells").get(i);null!=t&&(o({output:null===(e=t.get("output"))||void 0===e?void 0:e.toJS(),runState:t.get("state"),execCount:t.get("exec_count"),kernel:t.get("kernel"),start:t.get("start"),end:t.get("end")}),"done"==t.get("state")&&(a.removeListener("change",s),l.syncdb.save()))}return y(this,(function(d){switch(d.label){case 0:return t=e.project_id,n=e.path,r=e.input,i=e.id,o=e.set,[4,(0,f.Ag)({project_id:t,path:n})];case 1:return l=d.sent(),null==(a=l.store).get("cells").get(i)&&(c=(null===(u=a.getIn(["cells",a.get_cell_list().last()]))||void 0===u?void 0:u.get("pos",0))+1,l.insert_cell_at(c,!1,i)),l.clear_outputs([i],!1),l.set_cell_input(i,r,!1),l.run_code_cell(i),a.on("change",s),[2]}}))}))).apply(this,arguments)}var p=n(12407),m=n(61187),g=n(99810),b={};for(var w in l.T){var _=l.T[w].key;if(null!=_)if("string"==typeof _)b[_]=w;else{var x=!0,S=!1,E=void 0;try{for(var O,j=_[Symbol.iterator]();!(x=(O=j.next()).done);x=!0){var k=O.value;b[k]=w}}catch(e){S=!0,E=e}finally{try{x||null==j.return||j.return()}finally{if(S)throw E}}}}var P={arrowup:{x:0,y:-1},arrowdown:{x:0,y:1},arrowright:{x:1,y:0},arrowleft:{x:-1,y:0}};var z=["input","select","button","textarea"],M=n(1527),C=n(75087);function I(e){var t=[],n={},r=!0,i=!1,o=void 0;try{for(var l,a=(0,C.Z)(e)[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){var u=l.value;if(u.str){var c=0,s=!0,f=!1,d=void 0;try{for(var v,y=(0,M.parseTableOfContents)(u.str,n)[Symbol.iterator]();!(s=(v=y.next()).done);s=!0){var h=v.value;c+=1,h.id="".concat(c,"-").concat(u.id),t.push(h)}}catch(e){f=!0,d=e}finally{try{s||null==y.return||y.return()}finally{if(f)throw d}}}}}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return t}var T=n(95788),A=n(97891),F=n(25042);function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function D(e,t,n,r,i,o,l){try{var a=e[o](l),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,i)}function R(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function l(e){D(o,r,i,l,a,"next",e)}function a(e){D(o,r,i,l,a,"throw",e)}l(void 0)}))}}function K(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function H(e,t,n){return H="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=N(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}},H(e,t,n||e)}function N(e){return N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},N(e)}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){J(e,t,n[t])}))}return e}function L(e,t){return!t||"object"!==$(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function W(e,t){return W=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},W(e,t)}function G(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){a=!0,i=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw i}}return o}}(e,t)||V(e,t)||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 $=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};function V(e,t){if(e){if("string"==typeof e)return Z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Z(e,t):void 0}}var Y=function(e,t){var n,r,i,o,l={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,r=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!((i=(i=l.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){l.label=o[1];break}if(6===o[0]&&l.label<i[1]){l.label=i[1],i=o;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(o);break}i[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},q=n.n(F)()("whiteboard:actions"),Q=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&W(e,t)}(f,e);var t,n,o=(t=f,n=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(e){return!1}}(),function(){var e,r=N(t);if(n){var i=N(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return L(this,e)});function f(){var e;return K(this,f),(e=o.apply(this,arguments)).doctype="syncdb",e.primary_keys=["id"],e.string_cols=["str"],e}var d=f.prototype;return d._raw_default_frame_tree=function(){return{type:"whiteboard"}},d._init2=function(){var e=this;this.setState({}),this._syncstring.on("change",(function(t){var n,r,o=e.store.get("elements"),l=null!=o?o:(0,i.Map)({}),a=null!==(n=e.store.get("pages"))&&void 0!==n?n:(0,i.Map)({});t.forEach((function(t){var n=t.get("id");if(n){var r=e._syncstring.get_one(t),o=l.get(n);if(r)if(r.get("type")){var u;l=l.set(n,r);var c,s,f=null!==(u=null==o?void 0:o.get("page"))&&void 0!==u?u:1,d=null!==(c=r.get("page"))&&void 0!==c?c:1,v=null!==(s=a.get(d))&&void 0!==s?s:(0,i.Map)({});if(a=a.set(d,v.set(n,r)),f!=d){var y=a.get(f);void 0!==y&&(y=y.delete(n),a=0==y.size?a.delete(f):a.set(f,y))}}else{var h;e._syncstring.delete({id:n}),l=l.delete(n);var p=null!==(h=null==o?void 0:o.get("page"))&&void 0!==h?h:1,m=a.get(p);void 0!==m&&(m=m.delete(n),a=0==m.size?a.delete(p):a.set(p,m))}else{var g,b=null!==(g=null==o?void 0:o.get("page"))&&void 0!==g?g:1,w=a.get(b);void 0!==w&&(w=w.delete(n),a=0==w.size?a.delete(b):a.set(b,w)),l=l.delete(n)}}}));for(var u=null!==(r=a.keySeq().max())&&void 0!==r?r:1,c=1;c<=u;c++)null==a.get(c)&&(a=a.set(c,(0,i.Map)({})));l!==o&&e.setState({elements:l,pages:a}),e._syncstring.on("change",(0,s.debounce)(e.updateTableOfContents.bind(e),1500))}))},d.setCursors=function(e,t,n){if(null!=this._syncstring){var r=!0,i=!1,o=void 0;try{for(var l,a=t[Symbol.iterator]();!(r=(l=a.next()).done);r=!0)l.value.id=e}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}this._syncstring.set_cursor_locs(t,n)}},d.idToElement=function(e){var t;return null===(t=this.store.getIn(["elements",e]))||void 0===t?void 0:t.toJS()},d.createAdjacentElement=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"bottom",i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(null!=this._syncstring){var o=null===(t=this._syncstring.get_one({id:e}))||void 0===t?void 0:t.toJS();if(null!=o){delete o.z,delete o.locked;var l,a=!1;null!=o.str&&(a=!0,o.str=""),null!=(null===(n=o.data)||void 0===n?void 0:n.output)&&(a=!0,delete o.data.output),"chat"==o.type&&(a=!0,(0,m.iw)(o)),(0,u.So)(o,r);var c,s=null!==(l=o.page)&&void 0!==l?l:1,f="frame"==o.type?void 0:function(e){return"frame"!=e.get("type")&&(null!==(c=e.get("page"))&&void 0!==c?c:1)==s},d=this.getElements(f),v=r.toLowerCase(),y=v.includes("top")||v.includes("bottom")?"x":"y";return(0,u.v7)(o,d,y),a&&(delete o.w,delete o.h),this.createElement(void 0,o,i).id}}},d.setElement=function(e){var t=e.obj,n=e.commit,r=void 0===n||n,i=e.cursors,o=e.create;if(null!=this._syncstring){if(null==(null==t?void 0:t.id))throw Error("setElement -- id must be specified");(o||null!=this._syncstring.get_one({id:t.id}))&&((0,u.bY)(t),this._syncstring.set(t),r&&this.syncstring_commit(),null!=i&&this.setCursors(t.id,i))}},d.setElementData=function(e){var t=e.element,n=e.obj,r=e.commit,i=e.cursors;null==r&&(r=!0),this.setElement({obj:{id:t.id,data:U({},t.data,n)},commit:r,cursors:i})},d.createId=function(e){var t=this.store.get("elements");if(null==t)return(0,a.uuid)().slice(0,8);for(;!e||t.has(e);)e=(0,a.uuid)().slice(0,8);return e},d.getGroupIds=function(){var e,t=new Set([]);return null===(e=this.store.get("elements"))||void 0===e||e.map((function(e){var n=e.get("group");null!=n&&t.add(n)})),t},d.createGroupId=function(e){for(var t=this.getGroupIds();;){var n=(0,a.uuid)().slice(0,8);if(!(t.has(n)||null!=e&&e.has(n)))return n}},d.getElement=function(e){var t;return null===(t=this.store.getIn(["elements",e]))||void 0===t?void 0:t.toJS()},d.getElements=function(e){var t,n=this.store.get("elements");return null!=e&&(n=null==n?void 0:n.filter((function(t){return null!=t&&e(t)}))),null!==(t=B(n))&&void 0!==t?t:[]},d.getPageSpan=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.getElements();return(0,u.UA)(t,e)},d.createElement=function(e,t){var n,r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return q("createElement",e,t,i),(null==t.id||this.store.getIn(["elements",t.id]))&&(t.id=this.createId()),null==t.z&&(t.z=this.getPageSpan().zMax+1),null!=t.w&&null!=t.h||!t.type||(0,l.e)(t),null==t.page&&(t.page=null==e?1:null!==(r=null===(n=this._get_frame_node(e))||void 0===n?void 0:n.get("page"))&&void 0!==r?r:1),null!=t.data&&(delete t.data.runState,delete t.data.start),this.setElement({create:!0,obj:t,commit:i,cursors:[{}]}),t},d.delete=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(null!=this._syncstring&&!this.isLocked(e)){this._syncstring.delete({id:e});var n=this.store.get("elements");if(null!=n){var r=!0,i=!1,o=void 0;try{for(var l,a=n[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){var u=G(l.value,2),c=u[0],s=u[1];null==s||"edge"!=s.get("type")||s.getIn(["data","from"])!=e&&s.getIn(["data","to"])!=e||this._syncstring.delete({id:c})}}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}t&&this.syncstring_commit()}}},d.deleteElements=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(null!=this._syncstring){var n=!0,r=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(n=(o=l.next()).done);n=!0){var a=o.value.id;this.delete(a,!1)}}catch(e){r=!0,i=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw i}}t&&this.syncstring_commit()}},d.setFragmentIdToPage=function(e){var t=this._get_frame_node(e);if("whiteboard"==(null==t?void 0:t.get("type"))){var n=null==t?void 0:t.get("page");this.store.get("visible")&&(null!=n?r.Z.set({page:n}):r.Z.clear())}},d.clearSelection=function(e){var t,n,r=this._get_frame_node(e);null!=r&&0!=(null!==(n=null===(t=r.get("selection"))||void 0===t?void 0:t.size)&&void 0!==n?n:0)&&(this.set_frame_tree({id:e,selection:[],editFocus:!1}),this.setFragmentIdToPage(e))},d.setSelection=function(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"only",o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],l=this._get_frame_node(e);if(null!=l){var a,u=null!==(a=null===(n=l.get("selection"))||void 0===n?void 0:n.toJS())&&void 0!==a?a:[];try{if(o){var c=this.store.get("elements");if(null==c)return;var f=c.getIn([t,"group"]);if(f){var d=this.getGroup(f).map((function(e){return e.id}));if(d.length>1)return"toggle"==i&&(i=u.includes(t)?"remove":"add"),void this.setSelectionMulti(e,d,i,!1)}}if("toggle"==i){var v=u.indexOf(t);-1==v?u.push(t):u.splice(v,1)}else if("add"==i){if(u.includes(t))return;u.push(t)}else if("remove"==i){var y=u.indexOf(t);if(-1==y)return;u.splice(y,1)}else"only"==i&&(u=[t]);this.setEditFocus(e,"only"==i&&1==(0,s.size)(u)),this.set_frame_tree({id:e,selection:u})}finally{if("whiteboard"!=l.get("type"))return;this.store.get("visible")&&(0==(0,s.size)(u)?this.setFragmentIdToPage(e):r.Z.set({id:u[0]}))}}},d.setSelectionMulti=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"only",r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=new Set(t);if(r){var o=new Set([]),l=this.store.get("elements");if(null==l)return;var a=!0,u=!1,c=void 0;try{for(var s,f=t[Symbol.iterator]();!(a=(s=f.next()).done);a=!0){var d=s.value,v=l.getIn([d,"group"]);if(v&&!o.has(v)){o.add(v);var y=!0,h=!1,p=void 0;try{for(var m,g=this.getGroup(v)[Symbol.iterator]();!(y=(m=g.next()).done);y=!0){var b=m.value;i.add(b.id)}}catch(e){h=!0,p=e}finally{try{y||null==g.return||g.return()}finally{if(h)throw p}}}}}catch(e){u=!0,c=e}finally{try{a||null==f.return||f.return()}finally{if(u)throw c}}}"only"==n&&(this.clearSelection(e),n="add");var w=!0,_=!1,x=void 0;try{for(var S,E=i[Symbol.iterator]();!(w=(S=E.next()).done);w=!0){var O=S.value;this.setSelection(e,O,n,!1)}}catch(e){_=!0,x=e}finally{try{w||null==E.return||E.return()}finally{if(_)throw x}}this.setEditFocus(e,!1)},d.groupElements=function(e){var t=this.createGroupId(),n=!0,r=!1,i=void 0;try{for(var o,l=e[Symbol.iterator]();!(n=(o=l.next()).done);n=!0){var a=o.value;this.setElement({obj:{id:a,group:t},commit:!1})}}catch(e){r=!0,i=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw i}}this.syncstring_commit()},d.ungroupElements=function(e){var t=!0,n=!1,r=void 0;try{for(var i,o=e[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var l=i.value;this.setElement({obj:{id:l,group:null},commit:!1})}}catch(e){n=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw r}}this.syncstring_commit()},d.setSelectedTool=function(e,t){var n=this._get_frame_node(e);null!=n&&(this.clearSelection(e),this.set_frame_tree({id:e,selectedTool:t,selectedToolHidePanel:n.get("selectedTool")==t&&!n.get("selectedToolHidePanel")}))},d.undo=function(e){null!=this._syncstring&&(this._syncstring.undo(),this._syncstring.commit())},d.redo=function(e){null!=this._syncstring&&(this._syncstring.redo(),this._syncstring.commit())},d.in_undo_mode=function(){var e;return null===(e=this._syncstring)||void 0===e?void 0:e.in_undo_mode()},d.fitToScreen=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.set_frame_tree({id:e,fitToScreen:!!t||void 0})},d.toggleMapType=function(e){var t=this._get_frame_node(e);if(null!=t){var n,r=null!==(n=t.get("navMap"))&&void 0!==n?n:"map";r="map"==r?"preview":"preview"==r?"hide":"map",this.set_frame_tree({id:e,navMap:r})}},d.saveViewport=function(e,t){this.set_frame_tree({id:e,viewport:t})},d.setViewportCenter=function(e,t){var n,r=this._get_frame_node(e);if(null!=r){var i=null===(n=r.get("viewport"))||void 0===n?void 0:n.toJS();null!=i&&((0,u.ES)([i],t),this.saveViewport(e,i))}},d.zoom_page_width=function(e){this.fitToScreen(e)},d.zoom100=function(e){this.set_font_size(e,c.n5)},d.setEdgeCreateStart=function(e,t,n){this.set_frame_tree({id:e,edgeStart:{id:t,position:n}})},d.clearEdgeCreateStart=function(e){this.set_frame_tree({id:e,edgeStart:null})},d.createEdge=function(e,t,n,r){if(t!=n)return this.createElement(e,{x:0,y:0,w:0,h:0,type:"edge",data:U({from:t,to:n},r)})},d.insertElements=function(e,t,n){var r;t=(0,s.cloneDeep)(t),null!=n&&(0,u.ES)(t,n),(0,u.Yj)(t,this.getPageSpan().zMax+1);var i,o=[],l={},a={},c=!0,f=!1,d=void 0;try{for(var v,y=t[Symbol.iterator]();!(c=(v=y.next()).done);c=!0){var h=v.value,p=this.createId(h.id);if(l[h.id]=p,o.push(p),h.id=p,delete h.locked,null!=h.group){var m=a[h.group];null==m&&(m=this.createGroupId(new Set(Object.keys(a))),a[h.group]=m),h.group=m}}}catch(e){f=!0,d=e}finally{try{c||null==y.return||y.return()}finally{if(f)throw d}}var g=null!=e&&null!==(i=null===(r=this._get_frame_node(e))||void 0===r?void 0:r.get("page"))&&void 0!==i?i:1,b=!0,w=!1,_=void 0;try{for(var x,S=t[Symbol.iterator]();!(b=(x=S.next()).done);b=!0){var E=x.value;if("edge"==E.type&&null!=E.data){var O,j,k=l[null!==(O=E.data.from)&&void 0!==O?O:""];if(null==k)continue;E.data.from=k;var P=l[null!==(j=E.data.to)&&void 0!==j?j:""];if(null==P)continue;E.data.to=P}E.page=g,this.createElement(e,E,!1)}}catch(e){w=!0,_=e}finally{try{b||null==S.return||S.return()}finally{if(w)throw _}}return this.syncstring_commit(),o},d.runCodeElement=function(e){var t,n,r,i=e.id,o=e.str,l=this,a=null===(n=null===(t=this.store.get("elements"))||void 0===t?void 0:t.get(i))||void 0===n?void 0:n.toJS();null!=a&&"code"==a.type?function(e){h.apply(this,arguments)}({project_id:this.project_id,path:this.path,input:null!==(r=null!=o?o:a.str)&&void 0!==r?r:"",id:i,set:function(e){return l.setElementData({element:a,obj:(t=U({},e),n={hideOutput:!1},n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})),t),commit:!0,cursors:[{}]});var t,n}}):console.warn("no cell with id",i)},d.saveChat=function(e){var t,n,r=e.id,i=e.input,o=null===(n=null===(t=this.store.get("elements"))||void 0===t?void 0:t.get(r))||void 0===n?void 0:n.toJS();if(null!=o){var l=(new Date).valueOf(),a=this.redux.getStore("account").get_account_id(),u=(0,p.oY)(a);this.setElementData({element:o,obj:J({},a,{input:i,time:l,sender_name:u}),commit:!0,cursors:[{}]})}else console.warn("no cell with id",r)},d.sendChat=function(e){var t,n,r=e.id,i=e.input,o=null===(n=null===(t=this.store.get("elements"))||void 0===t?void 0:t.get(r))||void 0===n?void 0:n.toJS();if(null!=o){var l,a=(new Date).valueOf(),u=this.redux.getStore("account").get_account_id(),c=(0,p.oY)(u),s=(0,m.Ln)(o);if(s>=0){var f,d,v=null===(f=o.data)||void 0===f?void 0:f[s];if((null==v?void 0:v.sender_id)==u&&v.time>a-6e4)return void this.setElementData({element:o,obj:(d={},J(d,s,{input:v.input+"\n\n"+i,time:a,sender_id:u,sender_name:c}),J(d,u,null),d),commit:!0,cursors:[{}]})}this.setElementData({element:o,obj:(l={},J(l,(0,m.Ln)(o)+1,{input:i,time:a,sender_id:u,sender_name:c}),J(l,u,null),l),commit:!0,cursors:[{}]})}else console.warn("no cell with id",r)},d.getSelectedElements=function(e){var t=this._get_frame_node(e);if(null!=t){var n=t.get("selection");if(null!=n){var r=[],i=this.store.get("elements");if(null!=i){var o=!0,l=!1,a=void 0;try{for(var u,c=n[Symbol.iterator]();!(o=(u=c.next()).done);o=!0){var s,f=u.value,d=null===(s=i.get(f))||void 0===s?void 0:s.toJS();null!=d&&r.push(d)}}catch(e){l=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(l)throw a}}return r}}}},d.cut=function(e){var t=this.getSelectedElements(e);t&&(X(t,this.getElements()),(0,g.vQ)(t),this.deleteElements(t),this.clearSelection(e))},d.copy=function(e){var t=this.getSelectedElements(e);t&&(X(t,this.getElements()),(0,g.vQ)(t))},d.paste=function(e,t,n){if(!e||"whiteboard"==this._get_frame_type(e)){var r=(0,g.Lz)(),i={x:0,y:0};if(null!=n){var o=(0,u.vd)(n),l=o.x,a=o.y,c=o.w,s=o.h;i={x:l+c+(0,u.vd)(r).w/2+u.SH,y:a+s/2}}else if(null!=e){var f,d,v=null===(d=null===(f=this._get_frame_node(e))||void 0===f?void 0:f.get("viewport"))||void 0===d?void 0:d.toJS();null!=v&&(i=(0,u.kU)(v))}var y=this.insertElements(e,r,i);null!=e&&this.setSelectionMulti(e,y)}},d.centerElement=function(e,t){var n,r=this.getElement(e);null!=r&&(t=null!=t?t:this.show_focused_frame_of_type("whiteboard"),H(N(f.prototype),"setPage",this).call(this,t,null!==(n=r.page)&&void 0!==n?n:1),this.setViewportCenter(t,(0,u.kU)(r)))},d.scrollElementIntoView=function(e,t){this.centerElement(e,t)},d.gotoUser=function(e,t){var n,r,i=null===(r=null===(n=this._syncstring.get_cursors(0))||void 0===n?void 0:n.getIn([e,"locs"]))||void 0===r?void 0:r.toJS();if(null!=i){var o=!0,l=!1,a=void 0;try{for(var u,c=i[Symbol.iterator]();!(o=(u=c.next()).done);o=!0){var s=u.value;if(null!=s.id)return void this.centerElement(s.id,t)}}catch(e){l=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(l)throw a}}}},d.hideElements=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(0!=e.length){var r=!0,i=!1,o=void 0;try{for(var l,a=this,c=function(){var e=l.value,t=e.id,r=e.w,i=e.h,o=e.type;if(n)a.setElement({obj:{id:t,hide:{frame:n}},commit:!1,cursors:[{}]});else if("frame"==o){a.setElement({obj:{id:t,hide:{w:r,h:i},w:30,h:30},commit:!1,cursors:[{}]});var c=(0,u.Ce)(a.getElements(),e).filter((function(e){return e.id!=t}));a.hideElements(c,!1,t)}else a.setElement({obj:{id:t,hide:{w:r,h:i},w:30,h:30},commit:!1,cursors:[{}]})},s=e[Symbol.iterator]();!(r=(l=s.next()).done);r=!0)c()}catch(e){i=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}t&&this.syncstring_commit()}},d.unhideElements=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(0!=e.length){var n=!0,r=!1,i=void 0;try{for(var o,l=this,a=function(){var e=o.value;if(null==(null==e?void 0:e.hide))return"continue";if(null!=e.hide.frame){var t={id:e.id,hide:null};null!=e.hide.w&&(t.hide={w:e.hide.w,h:e.hide.h}),l.setElement({obj:t,commit:!1,cursors:[{}]})}else{var n=e.hide,r=n.w,i=n.h;l.setElement({obj:{id:e.id,hide:null,w:r,h:i},commit:!1,cursors:[{}]})}if("frame"==e.type){var a=l.getElements().filter((function(t){var n;return(null===(n=t.hide)||void 0===n?void 0:n.frame)==e.id}));l.unhideElements(a,!1)}},u=e[Symbol.iterator]();!(n=(o=u.next()).done);n=!0)a()}catch(e){r=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(r)throw i}}t&&this.syncstring_commit()}},d.isLocked=function(e){return!!this.store.getIn(["elements",e,"locked"])},d.lockElements=function(e){if(0!=e.length){var t=!0,n=!1,r=void 0;try{for(var i,o=e[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var l=i.value;this.setElement({obj:{id:l.id,locked:!0},commit:!1,cursors:[{}]})}}catch(e){n=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw r}}this.syncstring_commit()}},d.unlockElements=function(e){if(0!=e.length){var t=!0,n=!1,r=void 0;try{for(var i,o=e[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var l=i.value;this.setElement({obj:{id:l.id,locked:null},commit:!1,cursors:[{}]})}}catch(e){n=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw r}}this.syncstring_commit()}},d.moveElements=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Set,i=void 0,o=Math.round(t.x),l=Math.round(t.y),a=!0,c=!1,s=void 0;try{for(var f,d=this,v=function(){var e=f.value;if("string"==typeof e){var n=d.idToElement(e);if(null==n)return"continue";e=n}if("string"==typeof e)throw Error("bug");var a=e.id;if(r.has(a))return"continue";var c=e.x+o,s=e.y+l;if(d.setElement({obj:{id:a,x:c,y:s},commit:!1,cursors:[{}]}),r.add(a),"frame"==e.type){null==i&&(i=d.getElements());var v;v=null!=e.hide?i.filter((function(e){var t;return(null===(t=e.hide)||void 0===t?void 0:t.frame)==a})):(0,u.Ce)(i,e).filter((function(e){return"frame"!=e.type})),d.moveElements(v,t,!1,r)}e.group&&d.moveElements(d.getGroup(e.group),t,!1,r)},y=e[Symbol.iterator]();!(a=(f=y.next()).done);a=!0)v()}catch(e){c=!0,s=e}finally{try{a||null==y.return||y.return()}finally{if(c)throw s}}n&&this.syncstring_commit()},d.duplicateElements=function(e,t){var n,r=function(e){if(Array.isArray(e))return Z(e)}(n=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||V(n)||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.")}();X(r,this.getElements()),(0,g.vQ)(r),this.paste(t,void 0,e)},d.getGroup=function(e){var t=[];if(!e)return t;var n=this.store.get("elements");if(!n)return t;var r=!0,i=!1,o=void 0;try{for(var l,a=n[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){var u=G(l.value,2),c=(u[0],u[1]);(null==c?void 0:c.get("group"))==e&&t.push(c.toJS())}}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return t},d.enableWhiteboardKeyHandler=function(e){"whiteboard"==this._get_frame_type(e)&&(this.keyHandler=function(e,t){return function(n){var r=e._get_frame_node(t);if(null!=r&&null!=(null==n?void 0:n.key)){var i=n.key.toLowerCase();if("s"==i&&(n.metaKey||n.ctrlKey))return e.save(!0),void n.preventDefault();if(","==i&&n.shiftKey&&n.ctrlKey)e.decrease_font_size(t);else if("."==i&&n.shiftKey&&n.ctrlKey)e.increase_font_size(t);else if("escape"!=i||"edge"!=r.get("selectedTool")){var o=r.get("selection");if(null!=o&&o.size>0){if(i.startsWith("arrow")&&!r.get("editFocus")){var l=P[i];if(null!=l)return void e.moveElements(o,l)}if(o.size>=1&&"escape"==i)return void(r.get("editFocus")?e.setEditFocus(t,!1):e.clearSelection(t));if(1==o.size){if(r.get("editFocus"))return;"enter"==i&&(e.setEditFocus(t,!0),n.preventDefault())}}if(!(null!=(a=document.activeElement)&&z.includes(a.tagName.toLowerCase())||r.get("editFocus"))){var a;if((null==o||0==o.size)&&i.startsWith("arrow")){var s,f=null===(s=r.get("viewport"))||void 0===s?void 0:s.toJS();if(null!=f){var d=(0,u.kU)(f),v=P[i];null!=v&&(d.x+=10*v.x,d.y+=10*v.y,e.setViewportCenter(t,d))}}if("z"!=i||!n.metaKey&&!n.ctrlKey)if("-"!=i)if("="!=i){if("0"==i){if(n.ctrlKey||n.metaKey||n.altKey)return void e.fitToScreen(t);if(!n.shiftKey)return void e.set_font_size(t,c.n5)}if("m"!=i){if("backspace"==i||"delete"==i)return e.deleteElements(null==o?void 0:o.toJS().map((function(e){return{id:e}}))),void e.clearSelection(t);if(!(n.ctrlKey||n.metaKey||n.altKey||n.shiftKey)){var y=b[i];if(null!=y)return void e.setSelectedTool(t,y)}}else e.toggleMapType(t)}else e.increase_font_size(t);else e.decrease_font_size(t);else n.shiftKey?e.redo():e.undo()}}else e.clearEdgeCreateStart(t)}}}(this,e),this.set_active_key_handler(this.keyHandler))},d.disableWhiteboardKeyHandler=function(){null!=this.keyHandler&&(this.erase_active_key_handler(this.keyHandler),delete this.keyHandler)},d.hide=function(){this.disableWhiteboardKeyHandler()},d.focus=function(e){void 0===e&&(e=this._get_active_id());var t=this._get_frame_node(e);"whiteboard"==(null==t?void 0:t.get("type"))?this.enableWhiteboardKeyHandler(e):this.disableWhiteboardKeyHandler(),H(N(f.prototype),"focus",this).call(this,e)},d.increase_font_size=function(e){var t,n;this.set_font_size(e,(null!==(n=null===(t=this._get_frame_node(e))||void 0===t?void 0:t.get("font_size"))&&void 0!==n?n:c.n5)+1)},d.decrease_font_size=function(e){var t,n;this.set_font_size(e,(null!==(n=null===(t=this._get_frame_node(e))||void 0===t?void 0:t.get("font_size"))&&void 0!==n?n:c.n5)-1)},d.set_font_size=function(e,t){t=Math.min(c.uK,Math.max(c.CP,t)),this.set_frame_tree({id:e,font_size:t})},d.setEditFocus=function(e,t){"whiteboard"==this._get_frame_type(e)&&this.set_frame_tree({id:e,editFocus:t})},d.selectionContainsCellOfType=function(e,t){var n,r=null===(n=this._get_frame_node(e))||void 0===n?void 0:n.get("selection");if(!r)return!1;var i=this.store.get("elements");if(null==i)return!1;var o=!0,l=!1,a=void 0;try{for(var u,c=r[Symbol.iterator]();!(o=(u=c.next()).done);o=!0){var s=u.value;if(i.getIn([s,"type"])==t)return!0}}catch(e){l=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(l)throw a}}return!1},d.setSearch=function(e,t){this.set_frame_tree({id:e,search:t})},d.newPage=function(e){var t,n,r=(null!==(n=null===(t=this._get_frame_node(e))||void 0===t?void 0:t.get("pages"))&&void 0!==n?n:1)+1,i=this.createElement(e,{type:"text",str:"# New Page",x:0,y:0,page:r});this.setPages(e,r),this.setPage(e,r),this.centerElement(i.id,e)},d.programmatical_goto_line=function(e,t,n,r){var i=this;return R((function(){var t;return Y(this,(function(n){switch(n.label){case 0:return[4,i.wait_until_syncdoc_ready()];case 1:return n.sent()?(null==r&&(r=i.show_focused_frame_of_type("whiteboard")),t="".concat(e),i.centerElement(t,r),i.zoom100(r),[2]):[2]}}))}))()},d.setPage=function(e,t){null!=this._get_frame_node(e)&&(H(N(f.prototype),"setPage",this).call(this,e,t),this.setFragmentIdToPage(e),this.fitToScreen(e))},d.gotoFragment=function(e){var t=this;return R((function(){var n,r,i;return Y(this,(function(o){switch(o.label){case 0:return[4,t.waitUntilFrameReady({type:"whiteboard"})];case 1:return(n=o.sent())?(r=e.id,null!=(i=e.page)?(t.setPage(n,parseInt(i)),t.fitToScreen(n),[2]):null!=r?(t.centerElement(r,n),t.zoom100(n),[2]):[2]):[2]}}))}))()},d.show_table_of_contents=function(){var e=this;return R((function(){var t;return Y(this,(function(n){switch(n.label){case 0:return t=e.show_focused_frame_of_type("whiteboard_table_of_contents","col",!0,.2),[4,(0,T.delay)(0)];case 1:return n.sent(),"closed"===e._state||e.set_active_id(t,!0),[2]}}))}))()},d.updateTableOfContents=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if("closed"!=this._state&&null!=this._syncstring&&(e||this.get_matching_frame({type:"whiteboard_table_of_contents"}))){var t=this.store.get("elements");if(null!=t){var n=(0,i.fromJS)(I(t));this.setState({contents:n})}}},d.scrollToHeading=function(e){var t=this;return R((function(){return Y(this,(function(n){return t.gotoFragment({id:e.id.split("-")[1]}),[2]}))}))()},d.help=function(){(0,A.open_new_tab)("https://doc.cocalc.com/whiteboard.html")},f}(o.e);function B(e){return null==e?void 0:e.valueSeq().filter((function(e){return null!=e})).toJS()}function X(e,t){var n=new Set(e.map((function(e){return e.id}))),r=!0,i=!1,o=void 0;try{for(var l,a=t[Symbol.iterator]();!(r=(l=a.next()).done);r=!0){var u=l.value;if("edge"==u.type&&null!=u.data){var c=u.data,s=c.from,f=c.to;if(null==s||null==f)continue;n.has(s)&&n.has(f)&&!n.has(u.id)&&e.push(u)}}}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}}},13414:(e,t,n)=>{n.d(t,{Ag:()=>f,Po:()=>d,iJ:()=>p,pz:()=>y});var r=n(32295),i=n(24620),o=n(4538),l=n(56160);function a(e,t,n,r,i,o,l){try{var a=e[o](l),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,i)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function l(e){a(o,r,i,l,u,"next",e)}function u(e){a(o,r,i,l,u,"throw",e)}l(void 0)}))}}var c=function(e,t){var n,r,i,o,l={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,r=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!((i=(i=l.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){l.label=o[1];break}if(6===o[0]&&l.label<i[1]){l.label=i[1],i=o;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(o);break}i[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};function s(){return(s=u((function(e){var t,n,r,i;return c(this,(function(l){switch(l.label){case 0:return t=e.project_id,n=e.path,[4,d({project_id:t,path:n})];case 1:return r=l.sent(),"ready"==(i=r.jupyter_actions).syncdb.get_state()?[3,3]:[4,(0,o.once)(i.syncdb,"ready")];case 2:l.sent(),l.label=3;case 3:return[2,i]}}))}))).apply(this,arguments)}var f=(0,l.reuseInFlight)((function(e){return s.apply(this,arguments)}));function d(e){return v.apply(this,arguments)}function v(){return(v=u((function(e){var t,n,i,o;return c(this,(function(l){switch(l.label){case 0:return t=e.project_id,n=e.path,i=h(n),null!=(o=r.redux.getEditorActions(t,i))?[3,2]:[4,r.redux.getProjectActions(t).initFileRedux(i)];case 1:l.sent(),o=r.redux.getEditorActions(t,i),l.la