UNPKG

@cocalc/static

Version:

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

1 lines 85.7 kB
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[330],{64677:(e,t,n)=>{n.d(t,{Z:()=>He});var r=n(16230),o=n(63505),i=n(34183),a=n(93654),l=n(90303),c=n(52224),u=n(63505);function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(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){s(e,t,n[t])}))}return e}function f(e){var t=e.start,n=e.end,r=e.arrowSize,o=void 0===r?24:r,i=e.thickness,a=void 0===i?1:i,l=e.color,s=void 0===l?"black":l,f=e.opacity,p=e.style,v=e.onClick,y=e.preview,m=t.x,h=t.y,b=n.x-m,g=n.y-h,w=Math.sqrt(b*b+g*g),x=Math.atan(g/b)-(b<0?Math.PI:0);return u.createElement("div",{onClick:v,style:d({position:"absolute",left:m,top:h,width:"".concat(w,"px"),transformOrigin:"0 0",transform:"rotate(".concat(x,"rad)")},p)},u.createElement("div",{style:{position:"relative",border:"".concat(a/2,"px ").concat(y?"dashed":"solid"," ").concat(s),borderRadius:"".concat(a,"px"),color:s,opacity:f}},u.createElement(c.JO,{name:"caret-right",style:{position:"absolute",right:"-".concat(3*o/8,"px"),top:"-".concat(o/2,"px"),fontSize:"".concat(o,"px")}})))}var p=n(39530),v=n(68943),y=n(63505);function m(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){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){m(e,t,n[t])}))}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function g(e){var t,n,r,o,i=e.element,a=e.elementsMap,l=e.transforms,c=(e.cursors,e.selected),u=e.previewMode,s=e.onClick,d=function(e,t,n,r){var o,i,a,l=(null!==(a=e.data)&&void 0!==a?a:{}).from;if(null==l)return null;var c=null===(o=t.get(l))||void 0===o?void 0:o.toJS();if(null==c||null!=c.hide)return null;var u,s,d,f,v=w(n,c);if(null==r&&(r=null!==(s=n.zMap[null!==(u=e.z)&&void 0!==u?u:0])&&void 0!==s?s:0),null!=(null===(i=e.data)||void 0===i?void 0:i.previewTo)){var y,m=null===(y=e.data)||void 0===y?void 0:y.previewTo,g=m.x,x=m.y;f=b(h({},d=n.dataToWindowNoScale(g,x,r)),{w:1,h:1})}else{var O,E,S=(null!==(E=e.data)&&void 0!==E?E:{}).to;if(null==S)return null;var j=null===(O=t.get(S))||void 0===O?void 0:O.toJS();if(null==j||null!=j.hide)return null;f=w(n,j),d=(0,p.kZ)(f,v)}return{start:(0,p.kZ)(v,f),end:d,zIndex:r}}(i,a,l,e.zIndex);if(null==d)return null;var m,g=d.start,x=d.end,O=2*(null!==(m=null===(t=i.data)||void 0===t?void 0:t.radius)&&void 0!==m?m:.5);return y.createElement(f,{start:g,end:x,arrowSize:5*O+14,thickness:O,color:u?"#9fc3ff":null===(n=i.data)||void 0===n?void 0:n.color,opacity:null===(r=i.data)||void 0===r?void 0:r.opacity,style:h({zIndex:d.zIndex,border:"".concat(v.Hw,"px solid ").concat(c?v.aT:"transparent"),background:u?"#9fc3ff":void 0},null!=s?{padding:"2.5px 10px",marginTop:"-5px",cursor:"pointer"}:{padding:"0 10px"}),onClick:s,preview:null!=(null===(o=i.data)||void 0===o?void 0:o.previewTo)})}function w(e,t){var n=(0,p.bt)(t),r=n.x,o=n.y,i=n.z,a=n.w,l=n.h;return b(h({},e.dataToWindowNoScale(r,o,i)),{w:a,h:l})}var x=n(60799),O=n(62403),E=n.n(O),S=n(54822),j=n(86171),P=n(67304),k=n(63505);function _(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 M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function z(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){M(e,t,n[t])}))}return e}var R=v.cf+v.Hw,C="".concat(20,"px"),T=-10,D={"true-true":"nwse-resize","true-false":"nesw-resize","false-true":"nesw-resize","false-false":"nwse-resize"};function A(e){var t=e.top,n=e.left,r=e.setOffset,i=e.canvasScale,a=e.element,l=e.selectedElements,u=function(e){if(t&&n)return{x:e.x,y:e.y,w:-e.x,h:-e.y};if(t&&!n)return{x:0,y:e.y,w:e.x,h:-e.y};if(!t&&n)return{x:e.x,y:0,w:-e.x,h:e.y};if(!t&&!n)return{x:0,y:0,w:e.x,h:e.y};throw Error("impossible")},s=function(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,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return _(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,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.")}()}((0,o.useState)({x:0,y:0}),2),d=s[0],f=s[1],v=(0,S.s)();if(1!=l.length)return null;var y={pointerEvents:"all",cursor:D["".concat(t,"-").concat(n)],position:"absolute",background:"white",color:"#888",fontSize:C,zIndex:p.O4+15,transform:"scale(".concat(1/i,")")};return t?y.top="".concat(T-R,"px"):y.bottom="".concat(T+R,"px"),n?y.left="".concat(T-R,"px"):y.right="".concat(T+R,"px"),k.createElement(E(),{scale:i,position:d,onDrag:function(e,t){f(t),r(u(t))},onStop:function(e,t){var n,o=(0,p.bt)(a),i=o.w,l=o.h,c=o.x,s=o.y,d=u(t),y=(d.w+i)/i,m=(d.h+l)/l;if(i+=d.w,l+=d.h,c+=d.x,s+=d.y,null===(n=a.data)||void 0===n?void 0:n.aspectRatio){var h,b=(0,P.dr)(null===(h=a.data)||void 0===h?void 0:h.aspectRatio);b&&(l=i/b)}setTimeout((function(){var e,t,n;if(f({x:0,y:0}),r({x:0,y:0,w:0,h:0}),"pen"==a.type&&(null===(e=a.data)||void 0===e?void 0:e.path)){for(var o=[],u=0;u<a.data.path.length;u+=2)o[u]=a.data.path[u]*y,o[u+1]=a.data.path[u+1]*m;v.actions.setElement({obj:{id:a.id,x:c,y:s,w:i,h:l,data:(t=z({},a.data),n={path:o},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)},cursors:[{}]})}else v.actions.setElement({obj:{id:a.id,x:c,y:s,w:i,h:l},cursors:[{}]})}),0)}},k.createElement(x.Z,{title:"Resize"},k.createElement(c.JO,{className:"nodrag",style:y,name:"square"})))}var I=n(36134),Z=n(63505),N=v.cf+v.Hw,K=4*v.Hw,F=-K/2;function J(e){var t,n,r=e.position,o=e.canvasScale,i=e.element,a=(0,S.s)(),l=a.actions,u=a.desc,s=a.id,d={pointerEvents:"all",position:"absolute",color:v.aT,fontSize:"".concat(K,"px"),zIndex:p.O4+15,transform:"scale(".concat(1/o,")"),cursor:"pointer"},f=null!==(t=i.h)&&void 0!==t?t:p.R$,y=null!==(n=i.w)&&void 0!==n?n:p.$7;return"top"==r?(d.top="".concat(-K/2-N/2,"px"),d.left="".concat(y/2+F,"px")):"bottom"==r?(d.bottom=0,d.left="".concat(y/2+F,"px")):"left"==r?(d.top="".concat(f/2+F,"px"),d.left="".concat(-K/2-N/2,"px")):"right"==r&&(d.top="".concat(f/2+F,"px"),d.right=0),Z.createElement(x.Z,{title:"Click to create adjacent ".concat(i.type,"; shift+click to create edge"),mouseEnterDelay:1,mouseLeaveDelay:0},Z.createElement(c.JO,{className:"nodrag",style:d,name:"circle",onClick:function(e){if(null==e?void 0:e.shiftKey)l.setSelectedTool(s,"edge"),l.setEdgeCreateStart(s,i.id,r);else{var t=l.createAdjacentElement(i.id,r,!1);t&&l.createEdge(s,i.id,t,(0,I.Qf)("edge",u.get("edgeId")))}}}))}var B=n(63505);function H(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=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){H(e,t,n[t])}))}return e}function W(e){var t=e.children,n=e.x,r=e.y,o=e.z,i=e.w,a=e.h,l=e.style,c={position:"absolute",left:isFinite(n)?n:0,top:isFinite(r)?r:0,width:"".concat(i,"px"),height:"".concat(a,"px"),zIndex:o};return B.createElement("div",{style:U({},l,c)},t)}var X=n(66652),Y=n(48949),L=n(85733),G=n(12407),$=n(24620),q=n(97400),V=n(63505);function Q(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 ee(e){var t=e.canvasScale,n=e.cursors,r=function(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,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Q(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)?Q(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.")}()}((0,o.useState)(0),2),i=r[0],a=r[1];if((0,q.Y)((function(){a(i+1)}),2e3),null==n)return V.createElement(V.Fragment,null);var l=(0,$.server_time)().valueOf(),c=[];for(var u in n){var s,d,f,v,y=null!==(v=null===(s=n[u])||void 0===s||null===(d=s[0])||void 0===d||null===(f=d.time)||void 0===f?void 0:f.valueOf())&&void 0!==v?v:0;l-y>=3e4||c.push(V.createElement("div",{key:u,style:{display:"flex",height:"".concat(20,"px")}},V.createElement(L.q,{account_id:u,size:20}),l-y<=1e4&&V.createElement("div",{style:{paddingLeft:"5px",paddingTop:"2px",color:"#666",fontSize:"10px"}},(0,G.oY)(u))))}return V.createElement("div",{style:{zIndex:p.O4,width:"200px",position:"absolute",top:"".concat(-5-20*c.length,"px"),height:"".concat(20*c.length,"px"),background:"white",opacity:.6,transform:"scale(".concat(1/t,")"),transformOrigin:"top left"}},c)}var te=n(84787),ne=n(63505);function re(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 oe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ie(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){oe(e,t,n[t])}))}return e}function ae(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function le(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,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return re(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)?re(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.")}()}for(var ce=50,ue=[],se=0;se<=8;se++)ue.push(se*Math.PI/4);var de={opacity:.7,background:"white",fontSize:"24px"};function fe(e){var t=e.children,n=e.canvasScale,i=e.element,a=e.selectedElements,l=e.transforms,u=e.allElements,s=e.readOnly,d=e.cursors,f=e.multi,y=(0,S.s)(),m=y.desc.get("editFocus"),h=(0,o.useRef)(null),b=le((0,o.useState)({x:0,y:0,w:0,h:0}),2),g=b[0],w=b[1],O=le((0,o.useState)(void 0),2),P=O[0],k=O[1],_=le((0,o.useState)(!1),2),M=_[0],z=_[1],R=(0,p.bt)(i),C=l.dataToWindowNoScale(R.x,R.y,R.z),T=M||g.x||g.y||g.w||g.h||P,D=(0,X.p)(a),I=(0,Y.x)(a),Z=(0,o.useRef)(null);(0,r.useWheel)((function(e){e.event.stopPropagation()}),{target:Z,eventOptions:{passive:!1,capture:!0}});var N=(0,o.useMemo)((function(){var e;if(D||s||I||f||(null===(e=te.D[i.type])||void 0===e?void 0:e.noResize))return null;for(var t=[],r=0,o=[!0,!1];r<o.length;r++)for(var l=o[r],c=0,u=[!0,!1];c<u.length;c++){var d=u[c];t.push(ne.createElement(A,{key:"".concat(l,"-").concat(d),top:l,left:d,canvasScale:n,element:i,selectedElements:a,setOffset:w}))}return t}),[i,n]),K=(0,o.useMemo)((function(){return a.length>=2||s||I||f?null:["top","bottom","left","right"].map((function(e){return ne.createElement(J,{key:e,position:e,canvasScale:n,element:i})}))}),[i,n]),F=(0,o.useMemo)((function(){var e=function(e){var t=h.current;if(t){var r=t.getBoundingClientRect(),o=r.height,i=r.width,a={x:-50/n-i/2,y:ce/n+o/2},l={x:a.x+e.x*n,y:a.y+e.y*n};return(0,p._O)(l)-(0,p._O)(a)}};return a.length>=2||"code"==i.type||D||I||s||f?null:ne.createElement(E(),{key:"rotate",position:{x:0,y:0},scale:n,onDrag:function(t,n){k(e(n))},onStop:function(t,n){var r=e(n);if(null!=r){var o=i.id,a=i.rotate;a=(null!=a?a:0)+r;var l=!0,c=!1,u=void 0;try{for(var s,d=ue[Symbol.iterator]();!(l=(s=d.next()).done);l=!0){var f=s.value;if(Math.abs(a-f)<.07){a=f;break}}}catch(e){c=!0,u=e}finally{try{l||null==d.return||d.return()}finally{if(c)throw u}}setTimeout((function(){"selection"!=o&&(y.actions.setElement({obj:{id:o,rotate:a},cursors:[{}]}),k(void 0))}),0)}}},ne.createElement(x.Z,{title:"Rotate"},ne.createElement(c.JO,{className:"nodrag",style:ae(ie({},de),{cursor:D||s?void 0:"grab",position:"absolute",bottom:"-".concat(ce/n,"px"),left:"-".concat(ce/n,"px"),transform:"scale(".concat(1/n,")"),pointerEvents:"all"}),name:"reload"})))}),[i.rotate,n,a.length,f]),B=f||D||s?null:ne.createElement(x.Z,{key:"move",title:"Move"},ne.createElement(c.JO,{name:"move",style:ae(ie({},de),{cursor:D?void 0:"grab",position:"absolute",top:"-".concat(ce/n,"px"),left:"-".concat(ce/n,"px"),visibility:T?"hidden":void 0,transform:"scale(".concat(1/n,")"),pointerEvents:"all"})})),H=i.w?(i.w+g.w)/i.w:1,U=i.h?(i.h+g.h)/i.h:1;return ne.createElement(W,{x:C.x,y:C.y,z:p.O4+1,w:R.w,h:R.h,style:1==a.length&&["pen","frame","edge"].includes(a[0].type)?{pointerEvents:"none"}:void 0},ne.createElement("div",{ref:Z,style:{visibility:T?"hidden":void 0}},ne.createElement(ee,{cursors:d,canvasScale:n}),F,ne.createElement("div",{style:ae(ie({zIndex:p.O4+2,position:"absolute",width:"100%",height:"100%"},i.rotate?{transform:"rotate(".concat(i.rotate,"rad)"),transformOrigin:"center"}:void 0),{pointerEvents:"none"})},N,K),ne.createElement("div",{className:"nodrag",style:{position:"absolute",bottom:"-".concat(ce/v.Hw/n,"px"),left:"".concat(ce/v.Hw/n,"px"),transform:"scale(".concat(1/n,")"),transformOrigin:"top left",pointerEvents:"all",zIndex:1}},ne.createElement(j.ZP,{readOnly:s,elements:a,allElements:u}))),ne.createElement(E(),{disabled:D||s,cancel:".nodrag",position:{x:0,y:0},scale:n,onStart:function(){z(!0)},onStop:function(e,t){z(!1),y.actions.moveElements(a,t)}},ne.createElement("div",{ref:h,style:ae(ie({cursor:D?void 0:"grab",position:"relative"},P?{border:"".concat(v.Hw/n,"px ").concat(m?v.YK:v._K," ").concat(m?v.gA:v.aT),marginLeft:"".concat(-v.Hw/n+g.x,"px"),marginTop:"".concat(-v.Hw/n+g.y,"px")}:{marginLeft:"".concat(g.x,"px"),marginTop:"".concat(g.y,"px")}),{width:T?"".concat(R.w+g.w,"px"):"100%",height:T?"".concat(R.h+g.h,"px"):"100%"})},B,ne.createElement("div",{style:ie({width:"".concat(i.w,"px"),height:"".concat(i.h,"px")},1!=H||1!=U?{transform:"scale(".concat(H,",").concat(U,")"),transformOrigin:"top left",opacity:.5,background:"lightblue"}:void 0)},ne.createElement("div",{style:ae(ie({},P?{transform:"rotate(".concat(P,"rad)"),transformOrigin:"center"}:void 0),{width:"100%",height:"100%"})},t)))))}var pe=n(95788),ve=n(63505);function ye(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,o)}function me(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){ye(i,r,o,a,l,"next",e)}function l(e){ye(i,r,o,a,l,"throw",e)}a(void 0)}))}}var he=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}};function be(e){var t=e.children,n=e.element,r=e.selectable,i=e.edgeCreate,a=e.edgeStart,l=e.frame,c=e.canvasScale,u=e.readOnly,s=n.id,d=(0,o.useRef)(!1),f=(0,o.useCallback)((function(e){d.current?d.current=!1:"ant-checkbox-input"!=(null==e?void 0:e.target.className)&&(u||r?function(e,t,n){we.apply(this,arguments)}(s,e,l):i&&function(e,t){var n=t.desc.getIn(["edgeStart","id"]);if(null!=n){var r=(0,I.sb)("edge",t.desc.get("edgeId"));n!=e&&t.actions.createEdge(t.id,n,e,r.data),t.actions.clearEdgeCreateStart(t.id)}else t.actions.setEdgeCreateStart(t.id,e)}(s,l))}),[r,i,s,l,u]),p=u||!(r&&!n.locked);return ve.createElement(E(),{position:{x:0,y:0},cancel:".nodrag",scale:c,disabled:p,onStop:function(e,t){t.x||t.y?(l.actions.moveElements([n],t),d.current=!0):f(e)}},ve.createElement("div",{className:i?"cocalc-whiteboard-edge-select".concat(a?"ed":""):void 0,style:{width:"100%",height:"100%",cursor:r?"pointer":void 0},onClick:p?f:void 0},t,a&&ve.createElement("div",{style:ge},"Select target of edge")))}var ge={position:"absolute",bottom:"-38px",overflow:"visible",width:"150px",background:"white",border:"1px solid #ccc",padding:"5px",borderRadius:"3px",boxShadow:"3px 3px 3px #ccc"};function we(){return(we=me((function(e,t,n){return he(this,(function(r){switch(r.label){case 0:return null==t||t.stopPropagation(),[4,(0,pe.delay)(0)];case 1:return r.sent(),n.actions.setSelection(n.id,e,t&&(t.altKey||t.metaKey||t.ctrlKey||t.shiftKey)?"toggle":"only"),[2]}}))}))).apply(this,arguments)}var xe=n(26286),Oe=n(83389),Ee=n(63505);function Se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function je(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){Se(e,t,n[t])}))}return e}var Pe="#f0f0f0",ke="#f9f9f9",_e={backgroundPosition:"-1.5px -1.5px, -1.5px -1.5px, -1px -1px, -1px -1px",backgroundSize:"100px 100px, 100px 100px, 20px 20px, 20px 20px",backgroundImage:"linear-gradient(".concat(Pe," 1.5px, transparent 1.5px), linear-gradient(90deg, ").concat(Pe," 1.5px, transparent 1.5px), linear-gradient(").concat(ke," 1px, transparent 1px), linear-gradient(90deg, ").concat(ke," 1px, transparent 1px)")};function Me(e){var t=e.transforms,n=e.divRef;return Ee.createElement("div",{ref:n,style:je({position:"absolute",left:0,top:0,width:"".concat(t.width,"px"),height:"".concat(t.height,"px")},_e)})}var ze=n(15690),Re=n(20812),Ce=n(71096),Te=n(99810),De=n(77441),Ae=n(29534),Ie=n(63505);function Ze(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 Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ke(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){Ne(e,t,n[t])}))}return e}function Fe(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function Je(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,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ze(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)?Ze(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 Be=window.devicePixelRatio;function He(e){var t,n,c=e.elements,u=e.elementsMap,s=e.font_size,d=e.scale,f=e.selection,y=e.margin,m=void 0===y?1e4:y,h=e.readOnly,b=e.selectedTool,w=e.evtToDataRef,x=e.isNavigator,O=e.style,j=e.previewMode,k=e.cursors,_=function(e){var t,n=(0,I.sb)(e,F.desc.get("".concat(e,"Id")));if(null===(t=n.data)||void 0===t?void 0:t.aspectRatio){var r=(0,P.dr)(n.data.aspectRatio);null==n.w&&(n.w=500),n.h=n.w/(0!=r?r:1)}return n},M=function(){var e=X.current;if(null!=e){var t=e.getBoundingClientRect();if(null!=t&&null!=Y.current){var n=te.get(),r=n.x,o=n.y;return{x:-r+t.width/2,y:-o+t.height/2}}}},z=function(e){var t=e.x,n=e.y;if(K.current){var r=T({x:t,y:n}),o=M();if(null!=o){var i=r.x-o.x,a=r.y-o.y;te.translate({x:i,y:a})}}},R=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.id,r=e.rotate,o=(0,p.bt)(e),i=o.x,a=o.y,l=o.z,s=o.w,d=o.h,y=ve.current.dataToWindowNoScale(i,a,l);if(null==e.hide||!h&&"select"==b&&!e.hide.frame){if("edge"==e.type){if(null==u)return;return Ie.createElement(g,{key:e.id,element:e,elementsMap:u,transforms:ve.current,selected:null==f?void 0:f.has(e.id),previewMode:j,onClick:function(t){F.actions.setSelection(F.id,e.id,t.altKey||t.shiftKey||t.metaKey?"add":"only")}})}if(j&&!t){if("edge"==e.type)return;return Ie.createElement(W,{key:n,x:y.x,y:y.y,z:0,w:s,h:d},Ie.createElement("div",{style:{width:"100%",height:"100%",opacity:"0.8",background:"#9fc3ff",pointerEvents:"none",touchAction:"none"}}))}var m=null==f?void 0:f.has(n),w=!(!m||1!==(null==f?void 0:f.size));w&&(Ge=!0);var O=Ie.createElement(H,{element:e,focused:w,canvasScale:B,readOnly:h||x,cursors:null==k?void 0:k[n]});if(!t&&(e.style||m||x)&&(O=Ie.createElement("div",{style:Fe(Ke({},e.style,m?{cursor:"text",border:"".concat(v.Hw/B,"px ").concat(F.desc.get("editFocus")?v.YK:v._K," ").concat(F.desc.get("editFocus")?v.gA:v.aT),marginLeft:"-".concat((v.Hw+v.cf)/B,"px"),marginTop:"-".concat((v.Hw+v.cf)/B,"px"),padding:"".concat(v.cf/B,"px")}:void 0),{width:"100%",height:"100%"})},O)),r&&(O=Ie.createElement("div",{style:{transform:"rotate(".concat("number"!=typeof r?parseFloat(r):r,"rad)"),transformOrigin:"center",width:"100%",height:"100%"}},O)),w)return Ie.createElement(fe,{key:n,canvasScale:B,element:e,allElements:c,selectedElements:[e],transforms:ve.current,readOnly:h,cursors:null==k?void 0:k[n]},O);var E="edge"==b&&Le==n;return Ie.createElement(W,{key:n,x:y.x,y:y.y,z:t?l:E?p.O4:y.z,w:s,h:d},Ie.createElement(ee,{cursors:null==k?void 0:k[n],canvasScale:B}),Ie.createElement(be,{element:e,selectable:"select"==b,edgeCreate:"edge"==b,edgeStart:E,frame:F,canvasScale:B,readOnly:h},O))}},C=function(e){var t=e.x,n=e.y;return ve.current.windowToDataNoScale(t/q.current,n/q.current)},T=function(e){var t=e.x,n=e.y,r=ve.current.dataToWindowNoScale(t,n);return r.x*=q.current,r.y*=q.current,{x:r.x,y:r.y}},D=function(){var e=A();if(null!=e){var t=C(e);return{x:t.x,y:t.y,w:e.w/q.current,h:e.h/q.current}}},A=function(){var e=X.current;if(null!=e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;if(n&&r){var o=te.get();return{x:-o.x,y:-o.y,w:n,h:r}}}},Z=function(e){var t,n;(null===(t=e.changedTouches)||void 0===t?void 0:t.length)>0?e=e.changedTouches[0]:(null===(n=e.touches)||void 0===n?void 0:n.length)>0&&(e=e.touches[0]);var r=e.clientX,o=e.clientY;return C(function(e){var t=e.x,n=e.y,r=X.current;if(null==r)return{x:0,y:0};var o=r.getBoundingClientRect();if(null==o)return{x:0,y:0};var i=te.get();return{x:-i.x+t-o.left,y:-i.y+n-o.top}}({x:r,y:o}))},N=function(e){if(null!=e){var t=X.current;if(null!=t){var n=t.getBoundingClientRect();if(null!=n){var r=te.get(),o=r.x,i=r.y;return{x:(-o+e.clientX-n.left)/q.current,y:(-i+e.clientY-n.top)/q.current}}}}},K=(0,De.Z)(),F=(0,S.s)(),J=F.desc.get("editFocus"),B=null!=d?d:(0,p.eo)(s),H=h?l.Z:a.Z,U=(0,o.useRef)(null),X=(0,o.useRef)(null),Y=(0,o.useRef)(null),L=(0,o.useRef)({scale:1,offset:{x:0,y:0},mouse:{x:0,y:0}}),G=(0,o.useRef)(0),$=(0,xe.ZP)({disabled:x,target:X,min:ze.CP,max:ze.uK,throttleMs:100,getFontSize:function(){return null!=s?s:ze.n5},onZoom:function(e){var t=e.fontSize,n=e.first;if(G.current=(new Date).valueOf(),n){var r,o=null===(r=Y.current)||void 0===r?void 0:r.getBoundingClientRect(),i=null!=o&&Se.current?{x:Se.current.clientX-o.left,y:Se.current.clientY-o.top}:{x:0,y:0};L.current={offset:te.get(),scale:V.get(),mouse:i}}var a=(0,p.eo)(t);V.set(a);var l=L.current.mouse,c=l.x*a/L.current.scale-l.x,u=l.y*a/L.current.scale-l.y,s=L.current.offset.x-c,d=L.current.offset.y-u;te.set({x:s,y:d}),V.setFontSize()}});(0,o.useEffect)((function(){x||kt()}),[B]);var q=(0,o.useRef)(B),V=(0,o.useMemo)((function(){return{set:function(e){null!=Y.current&&(q.current=e,Y.current.style.setProperty("transform","scale(".concat(e,")")))},get:function(){return q.current},setFontSize:(0,Re.throttle)((function(){F.actions.set_font_size(F.id,(0,p.wQ)(q.current))}),250)}}),[q,Y,F.id]),Q=(0,o.useRef)({left:0,top:0}),te=(0,o.useMemo)((function(){var e=function(e){var t=e.x,n=e.y;if(!x){var r,o,i=Y.current,a=X.current,l=null==a?void 0:a.getBoundingClientRect();null!=i&&(null==l?void 0:l.width)?(r=Math.min(0,Math.max(t,-i.offsetWidth*q.current+l.width)),o=Math.min(0,Math.max(n,-i.offsetHeight*q.current+l.height))):(r=t,o=n),Q.current={left:r,top:o},i.style.setProperty("left","".concat(r,"px")),i.style.setProperty("top","".concat(o,"px")),kt()}};return{set:e,get:function(){return{x:Q.current.left,y:Q.current.top}},translate:function(t){var n=t.x,r=t.y,o=Q.current,i=o.left,a=o.top;e({x:-n+i,y:-r+a})}}}),[Y,X,Q]);if(q.current!=B)if(x)q.current=B;else if((new Date).valueOf()>=G.current+500){var ne,re=null===(ne=Y.current)||void 0===ne?void 0:ne.getBoundingClientRect();if(null!=re){var oe,ie=null===(oe=X.current)||void 0===oe?void 0:oe.getBoundingClientRect(),ae=ie.left+ie.width/2,le=ie.top+ie.height/2,ce={x:ae-re.left,y:le-re.top},ue=ce.x*B/q.current-ce.x,se=ce.y*B/q.current-ce.y,de=te.get();Q.current={left:de.x-ue,top:de.y-se}}q.current=B}(0,r.useWheel)((function(e){e.event.ctrlKey||$.current||te.translate({x:e.delta[0],y:e.delta[1]})}),{target:X,disabled:x});var pe=(0,o.useRef)(null),ve=(0,o.useRef)((0,p.fg)(c,m));(0,o.useEffect)((function(){ve.current=(0,p.fg)(c,m)}),[c,m]);var ye=(0,o.useRef)(null);(0,o.useEffect)((function(){if(!x){if(null!=ye.current){var e=(ye.current.xMin-ve.current.xMin)*B,t=(ye.current.yMin-ve.current.yMin)*B;(e||t)&&te.translate({x:e,y:t})}ye.current=ve.current}}),[c]);var me=(0,o.useRef)(null),he=(0,o.useRef)(null),ge=(0,o.useRef)(null),we=(0,o.useRef)(!1),Ee=(0,o.useRef)(!1),Se=(0,o.useRef)(null),je=Je((0,o.useState)(null),2),Pe=je[0],ke=je[1];(0,o.useEffect)((function(){ke(null),F.actions.clearSelection(F.id)}),[F.desc.get("page")]);var _e=Je((0,o.useState)(null),2),Ze=_e[0],Ne=_e[1],He=(0,o.useRef)(null),We=(0,o.useRef)({scale:1,rect:{left:0,top:0,width:0,height:0}}),Xe=(0,Oe.Z)({ref:X});(0,o.useEffect)((function(){var e,t=null===(e=X.current)||void 0===e?void 0:e.getBoundingClientRect();(null==t?void 0:t.width)&&(We.current={scale:(0,Ce.fK)(Be*t.width,Be*t.height),rect:t})}),[Xe]);var Ye=(0,o.useRef)(void 0);(0,o.useEffect)((function(){var e;if(!x){var t=null===(e=F.desc.get("viewport"))||void 0===e?void 0:e.toJS();null==t||(0,p._H)(t,Ye.current)||setTimeout((function(){return z((0,p.kU)(t))}),0)}}),[F.desc.get("viewport")]),(0,o.useEffect)((function(){x||null==F.desc.get("viewport")&&F.actions.fitToScreen(F.id,!0)}),[]),(0,o.useEffect)((function(){if(!x&&F.desc.get("fitToScreen"))try{var e=D();if(null==e)return;if(0==c.length)return z({x:0,y:0}),Ye.current=e,void F.actions.set_font_size(F.id,(0,p.wQ)(1));Ye.current=e;var t=(0,p.vd)(c),n=.95*Math.min(1/.95,Math.max(ze.Zj,(0,p.qX)(t,e).scale*B));V.set(n),F.actions.set_font_size(F.id,(0,p.wQ)(n)),z({x:t.x+t.w/2,y:t.y+t.h/2}),kt()}finally{F.actions.fitToScreen(F.id,!1)}}),[F.desc.get("fitToScreen")]);var Le="edge"==b?F.desc.getIn(["edgeStart","id"]):void 0,Ge=!1,$e=[],qe=!0,Ve=!1,Qe=void 0;try{for(var et,tt=c[Symbol.iterator]();!(qe=(et=tt.next()).done);qe=!0){var nt=R(et.value);null!=nt&&$e.push(nt)}}catch(e){Ve=!0,Qe=e}finally{try{qe||null==tt.return||tt.return()}finally{if(Ve)throw Qe}}if(!Ge&&null!=f&&f.size>=1){var rt=c.filter((function(e){return f.has(e.id)})),ot=[],it=void 0,at=!0,lt=!0,ct=!1,ut=void 0;try{for(var st,dt=rt[Symbol.iterator]();!(lt=(st=dt.next()).done);lt=!0){var ft=st.value;if("edge"==ft.type&&null!=u){it=!0;for(var pt=0,vt=["from","to"];pt<vt.length;pt++){var yt,mt,ht,bt=vt[pt],gt=null===(mt=null==u?void 0:u.get(null!==(ht=null===(yt=ft.data)||void 0===yt?void 0:yt[bt])&&void 0!==ht?ht:""))||void 0===mt?void 0:mt.toJS();null!=gt&&ot.push(gt)}}else at=!1;ot.push(ft)}}catch(e){ct=!0,ut=e}finally{try{lt||null==dt.return||dt.return()}finally{if(ct)throw ut}}var wt=(0,p.UA)(ot,0),xt=wt.xMin,Ot=wt.yMin,Et={type:"selection",id:"selection",x:xt,y:Ot,w:wt.xMax-xt+1,h:wt.yMax-Ot+1,z:0};$e.push(Ie.createElement(fe,{key:"selection",canvasScale:B,element:Et,allElements:c,selectedElements:rt,transforms:ve.current,readOnly:h,multi:it},!at&&Ie.createElement(H,{element:Et,canvasScale:B,focused:!0})))}if(null!=u&&"edge"==b&&Le&&Ze){var St=_("edge");if(null==St.data)throw Error("bug");St.data=Fe(Ke({},St.data),{from:Le,previewTo:Ze}),$e.push(Ie.createElement(g,{key:"edge-preview",element:St,elementsMap:u,transforms:ve.current,zIndex:0}))}if(x){var jt,Pt=null===(jt=F.desc.get("viewport"))||void 0===jt?void 0:jt.toJS();Pt&&$e.unshift(Ie.createElement(E(),{key:"nav",position:{x:0,y:0},scale:B,onStart:function(){we.current=!0},onStop:function(e,t){if(null!=Pt){var n=(0,p.kU)(Pt),r=n.x,o=n.y;F.actions.setViewportCenter(F.id,{x:r+t.x,y:o+t.y})}}},Ie.createElement("div",{style:{zIndex:p.O4+1,position:"absolute",cursor:"move"}},R(Fe(Ke({id:"nav-frame"},Pt),{z:p.O4+1,type:"frame",data:{color:"#888",radius:.5},style:{background:"rgba(200,200,200,0.2)"}}),!0))))}null!=w&&(w.current=Z);var kt=x?function(){}:(0,o.useMemo)((function(){return(0,Re.throttle)((function(){var e=D();e&&(Ye.current=e,F.actions.saveViewport(F.id,e))}),100)}),[]),_t=function(e){if(!Ee.current)if("hand"!=b&&1!=e.button)if("select"!=b&&"frame"!=b){if("pen"==b){var t=N(e);if(null==t)return;return me.current=[t],he.current=[{x:e.clientX,y:e.clientY}],void(we.current=!0)}}else{if(e.target!=U.current)return;var n=N(e);if(null==n)return;me.current=[n]}else{if(null==X.current)return;ge.current={clientX:e.clientX,clientY:e.clientY,start:te.get()}}},Mt=function(e){if(Ee.current)return Ee.current=!1,void(me.current=null);if(null==ge.current){if(ke(null),null!=me.current)try{if("select"==b||"frame"==b){if(me.current.length<2)return;ke(null),we.current=!0,null==e||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey||F.actions.clearSelection(F.id);var t=me.current[0],n=me.current[1],r=(0,p.Xq)(ve.current.windowToDataNoScale(t.x,t.y),ve.current.windowToDataNoScale(n.x,n.y));if("frame"==b){var o,i=_("frame");if(null===(o=i.data)||void 0===o?void 0:o.aspectRatio){var a=(0,P.dr)(i.data.aspectRatio);0!=a&&(r.h=r.w/a)}F.actions.createElement(F.id,Fe(Ke({},i,r),{z:ve.current.zMin-1}),!0),F.actions.setSelectedTool(F.id,"select")}else{var l=(0,p.Ce)(c,r).map((function(e){return e.id}));F.actions.setSelectionMulti(F.id,l,"add")}return}if("pen"==b){he.current=null;var u=He.current;if(null!=u&&setTimeout((function(){var e=u.getContext("2d");null!=e&&((0,Ce.UN)({ctx:e}),null==he.current&&u.style.setProperty("visibility","hidden"))}),0),null==me.current||me.current.length<=0)return;we.current=!0;var d=(0,p.eo)(s)<1?function(e){var t=e.x,n=e.y;return(0,p.rP)(ve.current.windowToDataNoScale(t,n))}:function(e){var t=e.x,n=e.y;return ve.current.windowToDataNoScale(t,n)},f=d(me.current[0]),v=f.x,y=f.y,m=v,h=v,g=y,w=y,x=[{x:v,y}],O=x[0],E=0,S=!0,j=!1,k=void 0;try{for(var M,z=me.current.slice(1)[Symbol.iterator]();!(S=(M=z.next()).done);S=!0){var R=M.value;E+=1;var C=d(R);if((0,p.Qe)(O,C,.5)&&E<me.current.length-1)O=C;else{O=C;var T=C.x,D=C.y;x.push({x:T,y:D}),T<m&&(m=T),T>h&&(h=T),D<g&&(g=D),D>w&&(w=D)}}}catch(e){j=!0,k=e}finally{try{S||null==z.return||z.return()}finally{if(j)throw k}}var A=!0,I=!1,Z=void 0;try{for(var N,K=x[Symbol.iterator]();!(A=(N=K.next()).done);A=!0){var J=N.value;J.x=J.x-m,J.y=J.y-g}}catch(e){I=!0,Z=e}finally{try{A||null==K.return||K.return()}finally{if(I)throw Z}}return void F.actions.createElement(F.id,{x:m,y:g,z:ve.current.zMax+1,w:h-m+1,h:w-g+1,data:Ke({path:(0,p.Gz)(x)},_("pen").data),type:"pen"},!0)}}finally{me.current=null}}else ge.current=null},zt=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Ee.current)if(Se.current={clientX:e.clientX,clientY:e.clientY},"edge"==b&&Le)Ne(Z(e));else if(n||e.buttons)if(null==ge.current){if(null!=me.current){if(null===(t=e.preventDefault)||void 0===t||t.call(e),"select"==b||"frame"==b){if($.current)return;var r=N(e);if(null==r)return;return me.current[1]=r,void ke((0,p.Xq)(me.current[0],me.current[1]))}if("pen"!=b);else{var o=N(e);if(null==o)return;if(me.current.push(o),null==he.current)return;he.current.push({x:e.clientX,y:e.clientY});var i=He.current;if(null==i)return;var a=i.getContext("2d");if(null==a)return;he.current.length<=2&&(i.style.setProperty("visibility","visible"),(0,Ce.UN)({ctx:a}),a.restore(),a.save(),a.scale(Be,Be));var l,c=[],u=We.current.rect,s=!0,d=!1,f=void 0;try{for(var v,y=he.current.slice(he.current.length-2)[Symbol.iterator]();!(s=(v=y.next()).done);s=!0){var m=v.value;c.push({x:(m.x-u.left)/Be,y:(m.y-u.top)/Be})}}catch(e){d=!0,f=e}finally{try{s||null==y.return||y.return()}finally{if(d)throw f}}var h=null!==(l=_("pen").data)&&void 0!==l?l:{},g=h.color,w=h.radius,x=h.opacity;(0,Ce.cO)({ctx:a,path:c,color:g,radius:q.current*(null!=w?w:1)/Be,opacity:x})}}}else{if($.current)return;var O=X.current;if(null==O)return;var E=ge.current,S=E.clientX,j=E.clientY,P=E.start,k=e.clientX-S,M=e.clientY-j;te.set({x:P.x+k,y:P.y+M})}else Mt(e)};return Ie.createElement("div",{className:"smc-vfill",ref:X,style:Fe(Ke({},O),{touchAction:"string"==typeof b&&["hand","select","pen","frame"].includes(b)?"none":void 0,overflow:"hidden",position:"relative"}),onClick:function(e){if(me.current=null,x)return we.current?void(we.current=!1):void F.actions.setViewportCenter(F.id,Z(e));h||function(e){var t;if(!Ee.current&&F.isFocused)if(we.current)we.current=!1;else if("hand"!=b)if("select"!=b)if("edge"!=b){var n=Ke(Fe(Ke({},Z(e)),{z:ve.current.zMax+1}),_(b)),r=F.actions.createElement(F.id,n,!0).id;b&&(null===(t=i.T[b])||void 0===t?void 0:t.select)&&(F.actions.setSelectedTool(F.id,"select"),F.actions.setSelection(F.id,r),F.actions.setEditFocus(F.id,!0))}else Ze&&(F.actions.clearEdgeCreateStart(F.id),Ne(null));else e.target==U.current&&(F.actions.clearSelection(F.id),F.desc.get("edgeStart")&&F.actions.clearEdgeCreateStart(F.id))}(e)},onScroll:function(){kt()},onMouseDown:x?void 0:_t,onMouseMove:x?void 0:zt,onMouseUp:x?void 0:Mt,onTouchStart:x?void 0:function(e){_t(e.touches[0]),"pen"==b&&e.preventDefault()},onTouchMove:x?void 0:function(e){zt(e.touches[0],!0),"pen"==b&&e.preventDefault()},onTouchEnd:x?void 0:function(e){Mt(e),"pen"==b&&e.preventDefault()},onTouchCancel:x?void 0:function(e){"pen"==b&&e.preventDefault()},onPointerMove:x?void 0:function(e){if(32==e.buttons){Ee.current=!0;var t=N(e);if(null==t)return;var n=ve.current.windowToDataNoScale(t.x,t.y),r=n.x,o=n.y,i=Math.max(2,ze.wZ/q.current),a={x:r-i/2,y:o-i/2,w:i,h:i};F.actions.deleteElements((0,p.Ce)(c,a))}},onCopy:x?void 0:function(e){if(!J){e.preventDefault();var t=Ue({elements:c,selection:f});(0,Ae.extendToIncludeEdges)(t,c);var n=(0,Te.De)(t);e.clipboardData.setData("application/x-cocalc-whiteboard",n)}},onCut:x||h?void 0:function(e){if(!J){e.preventDefault();var t=Ue({elements:c,selection:f});(0,Ae.extendToIncludeEdges)(t,c);var n=(0,Te.De)(t);e.clipboardData.setData("application/x-cocalc-whiteboard",n),F.actions.deleteElements(t),F.actions.clearSelection(F.id)}},onPaste:x||h?void 0:function(e){if(!J){var t=e.clipboardData.getData("application/x-cocalc-whiteboard");if(t){var n=(0,Te.py)(t),r=void 0,o=N(Se.current);if(null!=o){var i=o.x,a=o.y;r=ve.current.windowToDataNoScale(i,a)}else{var l=M();null!=l&&(r=C(l))}var c=F.actions.insertElements(F.id,n,r);F.actions.setSelectionMulti(F.id,c)}}}},!x&&"pen"==b&&Ie.createElement("canvas",{className:"smc-vfill",ref:He,width:We.current.scale*Be*We.current.rect.width,height:We.current.scale*Be*We.current.rect.height,style:{cursor:null===(t=i.T[b])||void 0===t?void 0:t.cursor,position:"absolute",zIndex:p.O4+1,top:0,left:0,visibility:"hidden"}}),Ie.createElement("div",{ref:Y,style:{position:"absolute",left:"".concat(Q.current.left,"px"),top:"".concat(Q.current.top,"px"),transform:"scale(".concat(B,")"),transformOrigin:"top left"}},null!=Pe&&Ie.createElement("div",{style:{position:"absolute",left:"".concat(Pe.x,"px"),top:"".concat(Pe.y,"px"),width:"".concat(Pe.w,"px"),height:"".concat(Pe.h,"px"),border:"".concat(v.Hw/B,"px solid ").concat(v.aT),zIndex:p.O4+100}},Ie.createElement("div",{style:{width:"100%",height:"100%",background:"blue",opacity:.1}})),Ie.createElement("div",{ref:pe,style:{cursor:F.isFocused&&b?"hand"==b&&ge.current?"grabbing":null===(n=i.T[b])||void 0===n?void 0:n.cursor:void 0,position:"relative",overflow:"hidden",width:"".concat(ve.current.width,"px"),height:"".concat(ve.current.height,"px")}},!x&&Ie.createElement(Me,{transforms:ve.current,divRef:U}),$e)))}function Ue(e){var t=e.elements,n=e.selection;return n?t.filter((function(e){return n.has(e.id)})):[]}},2543:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(83915),o=n(60148),i=n(63505);function a(e){var t,n,a=e.element,l=e.mode;return i.createElement(r.CodeMirrorStatic,{value:null!==(n=a.str)&&void 0!==n?n:"",font_size:null===(t=a.data)||void 0===t?void 0:t.fontSize,options:{lineNumbers:!1,mode:null!=l?l:(0,o.Ej)("py")}})}},98134:(e,t,n)=>{n.d(t,{Z:()=>v,P:()=>y});var r=n(2543),o=n(63505),i=n(85460),a=n(63185),l=n(63505);function c(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 u(e){var t,n,r=e.cell,u=e.project_id,s=e.directory,d=e.more_output,f=(t=(0,o.useState)((0,i.fromJS)(r)),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,o,i=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw o}}return i}}(t,n)||function(e,t){if(e){if("string"==typeof e)return c(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)?c(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.")}()),p=f[0],v=f[1],y={toggle_output:function(e,t){v(p.set(t,!p.get(t)))}};return l.createElement(a.O,{id:r.id,cell:p,actions:y,project_id:u,directory:s,more_output:d})}var s=n(26662),d=n(48853),f=n.n(d),p=n(63505);function v(e){var t,n,o,i=e.element,a=null!==(o=i.data)&&void 0!==o?o:{},l=a.hideInput,c=a.hideOutput;return p.createElement("div",{style:(0,s.Z)(i)},!l&&p.createElement(r.Z,{element:i}),!c&&(null===(t=i.data)||void 0===t?void 0:t.output)&&p.createElement(u,{cell:{id:i.id,output:null===(n=i.data)||void 0===n?void 0:n.output},more_output:y.get(i.id)}))}var y=new(f())({max:50})},20906:(e,t,n)=>{n.d(t,{Z:()=>o});var r=n(63505);function o(e){var t,n,o,i,a=e.element,l=(e.focused,e.canvasScale);return r.createElement("div",{style:{width:"100%",height:"100%",border:"".concat(2*(null!==(o=null===(t=a.data)||void 0===t?void 0:t.radius)&&void 0!==o?o:.5)/l,"px solid ").concat(null!==(i=null===(n=a.data)||void 0===n?void 0:n.color)&&void 0!==i?i:"#252937"),borderRadius:"3px",boxShadow:"1px 3px 5px #ccc",background:"rgba(200, 200, 200, 0.3)"}})}},11436:(e,t,n)=>{n.d(t,{Z:()=>i});var r=n(85755),o=n(63505);function i(e){var t=e.element;return o.createElement(r.Z,{value:"```js\n"+JSON.stringify(t,void 0,2)+"\n```",style:{width:"100%",height:"100%"}})}},70057:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(52224),o=n(40216),i=n(63505);function a(e){var t,n,a=e.element;return i.createElement(r.JO,{name:null!==(n=null===(t=a.data)||void 0===t?void 0:t.icon)&&void 0!==n?n:"square",style:(0,o.C2)(a,{background:"white"})})}},72490:(e,t,n)=>{n.d(t,{B:()=>s,Z:()=>d});var r=n(40216),o=n(15690),i=n(4160),a=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}function c(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}function u(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}var s={borderBottomRightRadius:"60px 5px",boxShadow:"1px 5px 7px rgb(33 33 33 / 70%)",width:"100%",border:"1px solid lightgrey",overflow:"hidden"};function d(e){var t,n,l,d=e.element,f=u(c({},d.data),{color:(0,i.d)(null===(t=d.data)||void 0===t?void 0:t.color)});return a.createElement("div",{style:u(c({},s),{background:null!==(l=null===(n=d.data)||void 0===n?void 0:n.color)&&void 0!==l?l:o.QG.color,padding:"10px"})},a.createElement(r.ZP,{element:u(c({},d),{data:f})}))}},71096:(e,t,n)=>{n.d(t,{UN:()=>c,ZP:()=>l,cO:()=>u,fK:()=>s});var r=n(63505),o=n(39530),i=n(63505),a=4096;function l(e){var t,n,a,l=e.element,d=e.renderStatic?2:window.devicePixelRatio,f=(0,r.useRef)(null),p=(0,r.useRef)(1),v=Math.round(2*(null!==(n=null===(t=l.data)||void 0===t?void 0:t.radius)&&void 0!==n?n:1)*p.current);(0,r.useEffect)((function(){var e=f.current;if(null!=e){var t=e.getContext("2d");if(null!=t){var n=l.data;if(null!=n){var r=n.path,i=n.radius,a=n.color,s=n.opacity;null!=r&&(t.restore(),t.save(),t.scale(d,d),t.translate(v,v),c({ctx:t}),u({ctx:t,path:(0,o.b2)(r,p.current),color:null!=a?a:"black",radius:(null!=i?i:1)*p.current,opacity:s}))}}}}),[v,l]);var y,m=(null!==(a=l.w)&&void 0!==a?a:100)+2*v,h=(null!==(y=l.h)&&void 0!==y?y:100)+2*v;return p.current=s(m*d,h*d),i.createElement("div",null,i.createElement("canvas",{ref:f,width:p.current*m*d,height:p.current*h*d,style:{width:"".concat(m,"px"),height:"".concat(h,"px"),position:"absolute",top:-v,left:-v}}))}function c(e){var t=e.ctx;t.clearRect(0,0,t.canvas.width,t.canvas.height)}function u(e){var t=e.ctx,n=e.path,r=e.color,i=e.radius,a=e.opacity;if(0!=n.length){if(t.lineJoin="round",t.lineCap="round",t.strokeStyle=null!=r?r:"#000",a&&(t.globalAlpha=a),t.lineWidth=2*(null!=i?i:.5),n.length<=1){var l=n[0];return t.moveTo(l.x,l.y),t.beginPath(),t.lineTo(l.x,l.y),void t.stroke()}var c=n[0],u=n[1];t.moveTo(u.x,u.y),t.beginPath();for(var s=1,d=n.length;s<d;s++){var f=(0,o.kh)(c,u),p=f.x,v=f.y;t.quadraticCurveTo(c.x,c.y,p,v),c=n[s],u=n[s+1]}t.lineTo(c.x,c.y),t.stroke()}}function s(e,t){return e<=a&&e<=a?1:e>=t?a/e:a/t}},90303:(e,t,n)=>{n.d(t,{Z:()=>m});var r=n(11436),o=n(40216),i=n(72490),a=n(70057),l=n(71096),c=n(98134),u=n(20906),s=n(71308),d=n(63505);function f(e){var t,n,r,i,a,l,c,u=e.element;return null!=(null===(t=u.data)||void 0===t?void 0:t.countdown)?d.createElement(s.J,{style:(0,o.C2)(u,{fontSize:20}),compact:!0,amount:1e3*(null===(n=u.data)||void 0===n?void 0:n.countdown)-(null!==(a=null===(r=u.data)||void 0===r?void 0:r.total)&&void 0!==a?a:0),countdown:null===(i=u.data)||void 0===i?void 0:i.countdown}):d.createElement(s.J,{compact:!0,amount:null!==(c=null===(l=u.data)||void 0===l?void 0:l.total)&&void 0!==c?c:0})}var p=n(61187),v=n(63505);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 m(e){if(e.element.hide)return null;switch(e.element.type){case"text":return v.createElement(o.ZP,y({},e));case"note":return v.createElement(i.Z,y({},e));case"icon":return v.createElement(a.Z,y({},e));case"pen":return v.createElement(l.ZP,y({},e,{renderStatic:!0}));case"code":return v.createElement(c.Z,y({},e));case"frame":return v.createElement(u.Z,y({},e));case"timer":return v.createElement(f,y({},e));case"chat":return v.createElement(p.ZP,y({},e));case"selection":return null;default:return v.createElement(r.Z,y({},e))}}},93654:(e,t,n)=>{n.d(t,{Z:()=>Ze});var r=n(25732),o=n(29486),i=n(15690),a=n(4160),l=n(63505);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=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){c(e,t,n[t])}))}return e}function s(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}var d={borderBottomRightRadius:"60px 5px",boxShadow:"1px 5px 7px rgb(33 33 33 / 70%)",width:"100%",border:"1px solid lightgrey",overflow:"hidden"};function f(e){var t,n,r,c=e.element,f=e.readOnly,p=s(u({},c.data),{color:(0,a.d)(null===(t=c.data)||void 0===t?void 0:t.color)});return l.createElement("div",{style:s(u({},d),{background:null!==(r=null===(n=c.data)||void 0===n?void 0:n.color)&&void 0!==r?r:i.QG.color,padding:"10px"})},l.createElement(o.Z,{element:s(u({},c),{data:p}),readOnly:f}))}var p=n(63505);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 m(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 h(e,t){return t=null!=t?t:{},Object.