Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@netless/app-geogebra

Package Overview
Dependencies
0
Maintainers
12
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 0.0.8

8

dist/ggb/index.d.ts

@@ -7,3 +7,9 @@ import type { GGBApplet, GGBAppletParameters } from "../types";

}
export default function getGGBApplet(codebase?: string): Promise<typeof GGBApplet>;
export interface GetGGBAppletParams {
/**
* @default https://www.geogebra.org/apps/latest/deployggb.js
*/
deployggb?: string;
}
export default function getGGBApplet({ deployggb, }?: GetGGBAppletParams): Promise<typeof GGBApplet>;
export declare const defaultParameters: GGBAppletParameters;

@@ -8,2 +8,6 @@ import type { NetlessApp } from "@netless/window-manager";

}
export interface AppOptions {
deployggb?: string;
HTML5Codebase?: string;
}
/**

@@ -18,3 +22,3 @@ * NOTE: GeoGebra is licensed under GPLv3 and is free only in non-commercial use.

*/
declare const GeoGebra: NetlessApp<Attributes>;
declare const GeoGebra: NetlessApp<Attributes, {}, AppOptions>;
export default GeoGebra;

4

dist/main.cjs.js

@@ -1,3 +0,3 @@

"use strict";var X=Object.defineProperty,D=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var A=(s,n,e)=>n in s?X(s,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[n]=e,S=(s,n)=>{for(var e in n||(n={}))B.call(n,e)&&A(s,e,n[e]);if(O)for(var e of O(n))R.call(n,e)&&A(s,e,n[e]);return s},T=(s,n)=>D(s,x(n));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",U=j.length,G=Array(20),_=()=>{for(let s=0;s<20;s++)G[s]=j.charAt(Math.random()*U);return G.join("")};function I(s){try{return s()}catch(n){console.error(n)}}class P{constructor(){this.disposers=new Map}addDisposer(n,e=this.genUID()){return this.flush(e),this.disposers.set(e,Array.isArray(n)?()=>n.forEach(I):n),e}add(n,e=this.genUID()){return this.addDisposer(n(),e)}addEventListener(n,e,i,t,a=this.genUID()){return n.addEventListener(e,i,t),this.addDisposer(()=>n.removeEventListener(e,i,t),a),a}setTimeout(n,e,i=this.genUID()){const t=window.setTimeout(()=>{this.remove(i),n()},e);return this.addDisposer(()=>window.clearTimeout(t),i)}setInterval(n,e,i=this.genUID()){const t=window.setInterval(n,e);return this.addDisposer(()=>window.clearInterval(t),i)}remove(n){const e=this.disposers.get(n);return this.disposers.delete(n),e}flush(n){const e=this.remove(n);if(e)try{e()}catch(i){console.error(i)}}flushAll(){this.disposers.forEach(I),this.disposers.clear()}genUID(){let n;do n=_();while(this.disposers.has(n));return n}}function F(s){return s!=null&&typeof s=="object"&&!Array.isArray(s)}function J(s,n){let e=s.getAttributes();if(e||(s.setAttributes(n),e=s.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return F(n)&&Object.keys(n).forEach(i=>{Object.prototype.hasOwnProperty.call(e,i)||s.updateAttributes([i],n[i])}),e}let v;function W(s){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(v)return v;{const n=document.createElement("script");if(v=new Promise((e,i)=>{n.onload=()=>e(window.GGBApplet),n.onerror=()=>{v=void 0,i()}}),s){const e=s.lastIndexOf("GeoGebra")+8;n.src=s.slice(0,e)+"/deployggb.js"}else n.src="https://www.geogebra.org/apps/deployggb.js";return document.head.appendChild(n),v}}const $={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},L=class{constructor(s){var n;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const e of this.api.getAllObjectNames("embed"))this.initEmbed(e)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:e}=this;this.objectsInWaiting=[];for(const i of e){const t=this.api.getEmbeddedCalculators(!0),a=t==null?void 0:t[i];a!=null&&a.controller&&this.sendEvent("evalGMContent",a.toJSON(),i);const o=this.api.getCommandString(i,!1);if(o){this.sendEvent("evalCommand",`${i} := ${o}`,i);const r=this.api.getObjectsOfItsGroup(i);r!=null&&r.length&&this.sendEvent("addToGroup",i,r)}if(!o||this.api.isMoveable(i)){const r=this.api.getXML(i);this.sendEvent("evalXML",r,i)}this.sendEvent("select",i,!0)}this.updateCallback=0},this.updateListener=e=>{(this.api.hasUnlabeledPredecessors(e)||this.api.isMoveable(e))&&!this.currentAnimations.includes(e)&&(this.objectsInWaiting.includes(e)||(this.objectsInWaiting.push(e),this.dispatchUpdates()))},this.addListener=e=>{const i=this.api.getImageFileName(e);if(i){const r=this.api.getFileJSON();for(const h of r.archive)h.fileName.includes(i)&&this.sendEvent("addImage",JSON.stringify(h))}const t=this.api.getXML(e),o=this.api.getCommandString(e)&&this.api.getAlgorithmXML(e);this.sendEvent("addObject",o||t,e),this.sendEvent("deselect"),this.sendEvent("select",e,!0),setTimeout(()=>this.initEmbed(e),500)},this.removeListener=e=>{this.sendEvent("deleteObject",e),delete this.embeds[e]},this.renameListener=(e,i)=>{this.sendEvent("renameObject",e,i)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:e,invYscale:i,xMin:t,yMin:a}=JSON.parse(this.api.getViewProperties(0)),o=1/e,r=-t/e,h=-a/i;return this.viewState={scale:o,x:r,y:h},this.viewSyncCallback=0,this.viewState},this.clientListener=e=>{let i,t;const a=e.type;switch(a){case"updateStyle":i=e.target,t=this.api.getXML(i),this.sendEvent("evalXML",t);break;case"editorStart":this.lastEditingLabel=e.target;break;case"editorKeyTyped":t=this.api.getEditorState(),this.sendEvent("setEditorState",t,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",e.target);break;case"select":this.sendEvent("select",e.target);break;case"embeddedContentChanged":i=e[1],t=e[2],this.sendEvent("embeddedContentChanged",t,i);break;case"undo":case"redo":case"addPolygonComplete":t=this.api.getXML(),this.sendEvent("setXML",t);break;case"addSlide":this.sendEvent(a);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":t=e[2],this.sendEvent(a,t);break;case"pasteSlide":({cardIdx:t,ggbFile:i}=e),this.sendEvent(a,t,i);break;case"startAnimation":i=e[1],this.currentAnimations.push(i),this.sendEvent(a,i,i);break;case"stopAnimation":i=e[1],this.currentAnimations.splice(this.currentAnimations.indexOf(i),1),this.sendEvent(a,i,i);break;case"groupObjects":case"ungroupObjects":t=e.targets,this.sendEvent(a,t);break;case"pasteElmsComplete":t=e.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",t);break;case"addGeoToTV":case"removeGeoFromTV":t=e[1],this.sendEvent(a,t);break;case"setValuesOfTV":t=e[2],this.sendEvent(a,t);break;case"showPointsTV":({column:t,show:i}=e),this.sendEvent(a,t,i);break;case"lockTextElement":case"unlockTextElement":t=e[1],this.sendEvent(a,t);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",e.type,e)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=e=>{var h,p;if(this.conflictedObjects.includes(e.label)&&e.type!=="conflictResolution")return;const t=e.embedLabel?this.embeds[e.embedLabel]:this,a=e.type,o=e.label,r=e.content;if(console.debug("[GeoGebra] receive:",a,o,r),a==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let l=1,c;do c=`${o}_${l}`,l++;while(t.api.exists(c));this.unregisterListeners(),t.api.renameObject(o,c),this.registerListeners();const d=t.api.getAlgorithmXML(c)||t.api.getXML(c);this.sendEvent("conflictResolution",d,o)}else this.conflictedObjects.push(o);else t.evalXML(r),t.api.previewRefresh();else t.evalXML(r),t.api.previewRefresh();else if(a==="conflictResolution"){const l=this.conflictedObjects.indexOf(o);l!==-1&&this.conflictedObjects.splice(l,1),t.evalXML(r),t.api.previewRefresh()}else if(a==="evalXML")t.evalXML(r),t.api.previewRefresh();else if(a==="setXML")t.setXML(r);else if(a==="evalCommand")t.evalCommand(r),t.api.previewRefresh();else if(a==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[r],t.api.deleteObject(r),t.registerListeners();else if(a==="setEditorState")t.unregisterListeners(),t.api.setEditorState(r,o),t.registerListeners();else if(a==="addImage"){const l=JSON.parse(r);t.api.addImage(l.fileName,l.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(a))t.api.handleSlideAction(a,r);else if(a==="selectSlide")t.unregisterListeners(),t.api.selectSlide(r),t.registerListeners();else if(a==="renameObject")t.unregisterListeners(),t.api.renameObject(r,o),t.registerListeners();else if(a==="pasteSlide")t.api.handleSlideAction(a,r,o);else if(a==="evalGMContent"){const l=(t.api.getEmbeddedCalculators(!0)||{})[o];l&&l.loadFromJSON(r)}else if(a==="startAnimation")t.api.setAnimating(o,!0),t.api.startAnimation();else if(a==="stopAnimation")t.api.setAnimating(o,!1);else if(a==="select"){if(r){const l=((p=(h=this.context).getColor)==null?void 0:p.call(h,e.clientId))||"#80808080";t.api.addMultiuserSelection(String(e.nickName),l,r,!!o)}}else if(a==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(a==="orderingChange")t.api.updateOrdering(r);else if(a==="groupObjects")t.api.groupObjects(r);else if(a==="ungroupObjects")t.api.ungroupObjects(r);else if(a==="addToGroup")t.api.addToGroup(r,o);else if(a==="embeddedContentChanged")t.api.setEmbedContent(o,r);else if(a==="addGeoToTV")t.api.addGeoToTV(r);else if(a==="setValuesOfTV")t.api.setValuesOfTV(r);else if(a==="removeGeoFromTV")t.api.removeGeoFromTV(r);else if(a==="showPointsTV")t.api.showPointsTV(r,o);else if(a==="lockTextElement")t.api.lockTextElement(r);else if(a==="unlockTextElement")t.api.unlockTextElement(r);else if(a==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:l,x:c,y:d}=JSON.parse(r),g=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${c-g.x},${d-g.y})`),t.api.evalCommand(`ZoomIn(${l/g.scale})`)}else console.debug("[GeoGebra] unknown event",a,r,o)},this.api=s.api,this.clientId=s.clientId,this.nickName=s.nickName,this.delay=(n=s.delay)!=null?n:200,this.context=s,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(s,n,e){const i={type:s,content:n,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(i.embedLabel=this.context.embedLabel),e&&(i.label=e),i}sendEvent(s,n,e){console.log("[GeoGebra] send:",s,e,n),this.context.postMessage(this.createEvent(s,n,e)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(s){this.unregisterListeners(),this.api.evalCommand(s),this.registerListeners()}evalXML(s){this.unregisterListeners(),this.api.evalXML(s),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(s){this.unregisterListeners(),this.api.setXML(s),this.api.updateConstruction(),this.registerListeners()}initEmbed(s){if(this.embeds[s])return;const n=this.api.getEmbeddedCalculators();if(!n)return;const e=n[s];if(e&&"registerClientListener"in e){const i=new L(T(S({},this.context),{clientId:this.clientId,nickName:this.nickName,api:e,embedLabel:s}));i.registerListeners(),this.embeds[s]=i}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(s,n,e,i){return Math.abs(n-s.scale)>L.Threshold/10||Math.abs(e-s.x)>L.Threshold||Math.abs(i-s.y)>L.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let N=L;N.Threshold=20;var z=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
`)();function H(s,n){const e=new ResizeObserver(()=>n(s));return e.observe(s),()=>e.disconnect()}function Z(s,n,e){const i=s.getDisplayer(),t=s.getRoom();let a=[];const o=l=>{l.authorId!==i.observerId&&a.forEach(c=>c(l.payload))},r="sync--"+s.appId;return i.addMagixEventListener(r,o),{service:{addListener(l){a.push(l)},postMessage(l){t==null||t.dispatchMagixEvent(r,l)},load(){return n[e]},save(l){s.updateAttributes([e],l)}},disposer:()=>{a=[],i.removeMagixEventListener(r)}}}const K=new Set(["classic","graphing","geometry","3d","suite","evaluator","scientific"]),Y={kind:"GeoGebra",async setup(s){var E,C;const n=s.getDisplayer(),e=n.observerId,i=(E=n.state.roomMembers.find(u=>u.memberId===e))==null?void 0:E.payload,t=(i==null?void 0:i.uid)||"",a=(i==null?void 0:i.nickName)||t,o=(C=s.getAppOptions())==null?void 0:C.HTML5Codebase,r=J(s,{uid:"",ggbBase64:"",appName:"classic"}),h=s.getBox();h.mountStyles(z);const p=document.createElement("div");p.classList.add("netless-app-geogebra","loading"),t!==r.uid&&r.uid&&p.classList.add("netless-app-geogebra","readonly"),h.mountContent(p);const l=new P,c=S({},$);K.has(r.appName)&&(c.appName=r.appName),c.language=navigator.language.startsWith("zh")?"zh":"en",r.ggbBase64&&(c.ggbBase64=r.ggbBase64),c.id="ggb_"+s.appId;let d;const g=Z(s,r,"ggbBase64");function w(){const{width:u,height:m}=p.getBoundingClientRect();d==null||d.setWidth(u),d==null||d.setHeight(m)}c.appletOnLoad=u=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(c.id)}`),d=u,w(),p.classList.remove("loading");const m=s.getDisplayer(),k=new N(S({clientId:m.observerId,nickName:a,api:u,isDecider:b=>m.state.roomMembers.map(f=>f.memberId).every(f=>b<=f),getColor:b=>{const M=m.memberState(b).strokeColor;return"#"+M.map(f=>f.toString(16).padStart(2,"0")).join("")+"80"}},g.service));k.registerListeners(),g.service.addListener(b=>{k.dispatch(b),d==null||d.setUndoPoint()})},l.add(()=>H(p,w)),s.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),l.flushAll(),g.disposer(),d==null||d.remove()});const V=await W(o),y=new V(c);o&&y.setHTML5Codebase(o),y.inject(p)}};exports.default=Y;
"use strict";var D=Object.defineProperty,x=Object.defineProperties;var B=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var T=(i,n,e)=>n in i?D(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e,w=(i,n)=>{for(var e in n||(n={}))R.call(n,e)&&T(i,e,n[e]);if(A)for(var e of A(n))U.call(n,e)&&T(i,e,n[e]);return i},G=(i,n)=>x(i,B(n));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",_=N.length,I=Array(20),P=()=>{for(let i=0;i<20;i++)I[i]=N.charAt(Math.random()*_);return I.join("")};function j(i){try{return i()}catch(n){console.error(n)}}class F{constructor(){this.disposers=new Map}addDisposer(n,e=this.genUID()){return this.flush(e),this.disposers.set(e,Array.isArray(n)?()=>n.forEach(j):n),e}add(n,e=this.genUID()){return this.addDisposer(n(),e)}addEventListener(n,e,s,t,a=this.genUID()){return n.addEventListener(e,s,t),this.addDisposer(()=>n.removeEventListener(e,s,t),a),a}setTimeout(n,e,s=this.genUID()){const t=window.setTimeout(()=>{this.remove(s),n()},e);return this.addDisposer(()=>window.clearTimeout(t),s)}setInterval(n,e,s=this.genUID()){const t=window.setInterval(n,e);return this.addDisposer(()=>window.clearInterval(t),s)}remove(n){const e=this.disposers.get(n);return this.disposers.delete(n),e}flush(n){const e=this.remove(n);if(e)try{e()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(j),this.disposers.clear()}genUID(){let n;do n=P();while(this.disposers.has(n));return n}}function J(i){return i!=null&&typeof i=="object"&&!Array.isArray(i)}function W(i,n){let e=i.getAttributes();if(e||(i.setAttributes(n),e=i.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return J(n)&&Object.keys(n).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||i.updateAttributes([s],n[s])}),e}let L;function $({deployggb:i="https://www.geogebra.org/apps/latest/deployggb.js"}={}){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(L)return L;{const n=document.createElement("script");return L=new Promise((e,s)=>{n.onload=()=>e(window.GGBApplet),n.onerror=()=>{L=void 0,s()}}),n.src=i,document.head.appendChild(n),L}}const z={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},S=class{constructor(i){var n;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const e of this.api.getAllObjectNames("embed"))this.initEmbed(e)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:e}=this;this.objectsInWaiting=[];for(const s of e){const t=this.api.getEmbeddedCalculators(!0),a=t==null?void 0:t[s];a!=null&&a.controller&&this.sendEvent("evalGMContent",a.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const r=this.api.getObjectsOfItsGroup(s);r!=null&&r.length&&this.sendEvent("addToGroup",s,r)}if(!o||this.api.isMoveable(s)){const r=this.api.getXML(s);this.sendEvent("evalXML",r,s)}this.sendEvent("select",s,!0)}this.updateCallback=0},this.updateListener=e=>{(this.api.hasUnlabeledPredecessors(e)||this.api.isMoveable(e))&&!this.currentAnimations.includes(e)&&(this.objectsInWaiting.includes(e)||(this.objectsInWaiting.push(e),this.dispatchUpdates()))},this.addListener=e=>{const s=this.api.getImageFileName(e);if(s){const r=this.api.getFileJSON();for(const h of r.archive)h.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(h))}const t=this.api.getXML(e),o=this.api.getCommandString(e)&&this.api.getAlgorithmXML(e);this.sendEvent("addObject",o||t,e),this.sendEvent("deselect"),this.sendEvent("select",e,!0),setTimeout(()=>this.initEmbed(e),500)},this.removeListener=e=>{this.sendEvent("deleteObject",e),delete this.embeds[e]},this.renameListener=(e,s)=>{this.sendEvent("renameObject",e,s)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:e,invYscale:s,xMin:t,yMin:a}=JSON.parse(this.api.getViewProperties(0)),o=1/e,r=-t/e,h=-a/s;return this.viewState={scale:o,x:r,y:h},this.viewSyncCallback=0,this.viewState},this.clientListener=e=>{let s,t;const a=e.type;switch(a){case"updateStyle":s=e.target,t=this.api.getXML(s),this.sendEvent("evalXML",t);break;case"editorStart":this.lastEditingLabel=e.target;break;case"editorKeyTyped":t=this.api.getEditorState(),this.sendEvent("setEditorState",t,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",e.target);break;case"select":this.sendEvent("select",e.target);break;case"embeddedContentChanged":s=e[1],t=e[2],this.sendEvent("embeddedContentChanged",t,s);break;case"undo":case"redo":case"addPolygonComplete":t=this.api.getXML(),this.sendEvent("setXML",t);break;case"addSlide":this.sendEvent(a);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":t=e[2],this.sendEvent(a,t);break;case"pasteSlide":({cardIdx:t,ggbFile:s}=e),this.sendEvent(a,t,s);break;case"startAnimation":s=e[1],this.currentAnimations.push(s),this.sendEvent(a,s,s);break;case"stopAnimation":s=e[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(a,s,s);break;case"groupObjects":case"ungroupObjects":t=e.targets,this.sendEvent(a,t);break;case"pasteElmsComplete":t=e.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",t);break;case"addGeoToTV":case"removeGeoFromTV":t=e[1],this.sendEvent(a,t);break;case"setValuesOfTV":t=e[2],this.sendEvent(a,t);break;case"showPointsTV":({column:t,show:s}=e),this.sendEvent(a,t,s);break;case"lockTextElement":case"unlockTextElement":t=e[1],this.sendEvent(a,t);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",e.type,e)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=e=>{var h,p;if(this.conflictedObjects.includes(e.label)&&e.type!=="conflictResolution")return;const t=e.embedLabel?this.embeds[e.embedLabel]:this,a=e.type,o=e.label,r=e.content;if(console.debug("[GeoGebra] receive:",a,o,r),a==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let c=1,l;do l=`${o}_${c}`,c++;while(t.api.exists(l));this.unregisterListeners(),t.api.renameObject(o,l),this.registerListeners();const u=t.api.getAlgorithmXML(l)||t.api.getXML(l);this.sendEvent("conflictResolution",u,o)}else this.conflictedObjects.push(o);else t.evalXML(r),t.api.previewRefresh();else t.evalXML(r),t.api.previewRefresh();else if(a==="conflictResolution"){const c=this.conflictedObjects.indexOf(o);c!==-1&&this.conflictedObjects.splice(c,1),t.evalXML(r),t.api.previewRefresh()}else if(a==="evalXML")t.evalXML(r),t.api.previewRefresh();else if(a==="setXML")t.setXML(r);else if(a==="evalCommand")t.evalCommand(r),t.api.previewRefresh();else if(a==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[r],t.api.deleteObject(r),t.registerListeners();else if(a==="setEditorState")t.unregisterListeners(),t.api.setEditorState(r,o),t.registerListeners();else if(a==="addImage"){const c=JSON.parse(r);t.api.addImage(c.fileName,c.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(a))t.api.handleSlideAction(a,r);else if(a==="selectSlide")t.unregisterListeners(),t.api.selectSlide(r),t.registerListeners();else if(a==="renameObject")t.unregisterListeners(),t.api.renameObject(r,o),t.registerListeners();else if(a==="pasteSlide")t.api.handleSlideAction(a,r,o);else if(a==="evalGMContent"){const c=(t.api.getEmbeddedCalculators(!0)||{})[o];c&&c.loadFromJSON(r)}else if(a==="startAnimation")t.api.setAnimating(o,!0),t.api.startAnimation();else if(a==="stopAnimation")t.api.setAnimating(o,!1);else if(a==="select"){if(r){const c=((p=(h=this.context).getColor)==null?void 0:p.call(h,e.clientId))||"#80808080";try{t.api.addMultiuserSelection(String(e.nickName),c,r,!!o)}catch(l){console.error(l)}}}else if(a==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(a==="orderingChange")t.api.updateOrdering(r);else if(a==="groupObjects")t.api.groupObjects(r);else if(a==="ungroupObjects")t.api.ungroupObjects(r);else if(a==="addToGroup")t.api.addToGroup(r,o);else if(a==="embeddedContentChanged")t.api.setEmbedContent(o,r);else if(a==="addGeoToTV")t.api.addGeoToTV(r);else if(a==="setValuesOfTV")t.api.setValuesOfTV(r);else if(a==="removeGeoFromTV")t.api.removeGeoFromTV(r);else if(a==="showPointsTV")t.api.showPointsTV(r,o);else if(a==="lockTextElement")t.api.lockTextElement(r);else if(a==="unlockTextElement")t.api.unlockTextElement(r);else if(a==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:c,x:l,y:u}=JSON.parse(r),g=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${l-g.x},${u-g.y})`),t.api.evalCommand(`ZoomIn(${c/g.scale})`)}else console.debug("[GeoGebra] unknown event",a,r,o)},this.api=i.api,this.clientId=i.clientId,this.nickName=i.nickName,this.delay=(n=i.delay)!=null?n:200,this.context=i,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(i,n,e){const s={type:i,content:n,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),e&&(s.label=e),s}sendEvent(i,n,e){console.log("[GeoGebra] send:",i,e,n),this.context.postMessage(this.createEvent(i,n,e)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(i){this.unregisterListeners(),this.api.evalCommand(i),this.registerListeners()}evalXML(i){this.unregisterListeners(),this.api.evalXML(i),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(i){this.unregisterListeners(),this.api.setXML(i),this.api.updateConstruction(),this.registerListeners()}initEmbed(i){if(this.embeds[i])return;const n=this.api.getEmbeddedCalculators();if(!n)return;const e=n[i];if(e&&"registerClientListener"in e){const s=new S(G(w({},this.context),{clientId:this.clientId,nickName:this.nickName,api:e,embedLabel:i}));s.registerListeners(),this.embeds[i]=s}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(i,n,e,s){return Math.abs(n-i.scale)>S.Threshold/10||Math.abs(e-i.x)>S.Threshold||Math.abs(s-i.y)>S.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let V=S;V.Threshold=20;var H=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
`)();function Z(i,n){const e=new ResizeObserver(()=>n(i));return e.observe(i),()=>e.disconnect()}function K(i,n,e){const s=i.getDisplayer(),t=i.getRoom();let a=[];const o=c=>{c.authorId!==s.observerId&&a.forEach(l=>l(c.payload))},r="sync--"+i.appId;return s.addMagixEventListener(r,o),{service:{addListener(c){a.push(c)},postMessage(c){t==null||t.dispatchMagixEvent(r,c)},load(){return n[e]},save(c){i.updateAttributes([e],c)}},disposer:()=>{a=[],s.removeMagixEventListener(r)}}}const Y=new Set(["classic","graphing","geometry","3d","suite","evaluator","scientific"]),q={kind:"GeoGebra",async setup(i){var k;const n=i.getDisplayer(),e=n.observerId,s=(k=n.state.roomMembers.find(m=>m.memberId===e))==null?void 0:k.payload,t=(s==null?void 0:s.uid)||"",a=(s==null?void 0:s.nickName)||t,o=i.getAppOptions()||{},r=o.deployggb,h=o.HTML5Codebase,p=W(i,{uid:"",ggbBase64:"",appName:"classic"}),c=i.getBox();c.mountStyles(H);const l=document.createElement("div");l.classList.add("netless-app-geogebra","loading"),t!==p.uid&&p.uid&&l.classList.add("netless-app-geogebra","readonly"),c.mountContent(l);const u=new F,g=w({},z);Y.has(p.appName)&&(g.appName=p.appName),g.language=navigator.language.startsWith("zh")?"zh":"en",p.ggbBase64&&(g.ggbBase64=p.ggbBase64),g.id="ggb_"+i.appId;let d;const y=K(i,p,"ggbBase64");function E(){const{width:m,height:b}=l.getBoundingClientRect();d==null||d.setWidth(m),d==null||d.setHeight(b)}g.appletOnLoad=m=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(g.id)}`),d=m,E(),l.classList.remove("loading");const b=i.getDisplayer(),M=new V(w({clientId:b.observerId,nickName:a,api:m,isDecider:f=>b.state.roomMembers.map(v=>v.memberId).every(v=>f<=v),getColor:f=>{const O=b.memberState(f).strokeColor;return"#"+O.map(v=>v.toString(16).padStart(2,"0")).join("")+"80"}},y.service));M.registerListeners(),y.service.addListener(f=>{M.dispatch(f),d==null||d.setUndoPoint()})},u.add(()=>Z(l,E)),i.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),u.flushAll(),y.disposer(),d==null||d.remove()});const X=await $({deployggb:r}),C=new X(g);h&&C.setHTML5Codebase(h),C.inject(l)}};exports.default=q;
//# sourceMappingURL=main.cjs.js.map

@@ -101,3 +101,5 @@ var __defProp = Object.defineProperty;

let getGGBAppletPromise;
function getGGBApplet(codebase) {
function getGGBApplet({
deployggb = "https://www.geogebra.org/apps/latest/deployggb.js"
} = {}) {
if (window.GGBApplet) {

@@ -116,8 +118,3 @@ return Promise.resolve(window.GGBApplet);

});
if (codebase) {
const index = codebase.lastIndexOf("GeoGebra") + 8;
script.src = codebase.slice(0, index) + "/deployggb.js";
} else {
script.src = "https://www.geogebra.org/apps/deployggb.js";
}
script.src = deployggb;
document.head.appendChild(script);

@@ -441,3 +438,7 @@ return getGGBAppletPromise;

const color = ((_b = (_a2 = this.context).getColor) == null ? void 0 : _b.call(_a2, last.clientId)) || "#80808080";
target.api.addMultiuserSelection(String(last.nickName), color, content, !!label);
try {
target.api.addMultiuserSelection(String(last.nickName), color, content, !!label);
} catch (error) {
console.error(error);
}
}

@@ -611,3 +612,3 @@ } else if (type === "deselect") {

async setup(context) {
var _a, _b;
var _a;
const displayer = context.getDisplayer();

@@ -618,3 +619,5 @@ const memberId = displayer.observerId;

const nickName = (userPayload == null ? void 0 : userPayload.nickName) || uid;
const codebase = (_b = context.getAppOptions()) == null ? void 0 : _b.HTML5Codebase;
const appOptions = context.getAppOptions() || {};
const deployggb = appOptions.deployggb;
const codebase = appOptions.HTML5Codebase;
const attrs = ensureAttributes(context, {

@@ -682,3 +685,3 @@ uid: "",

});
const GGBApplet = await getGGBApplet(codebase);
const GGBApplet = await getGGBApplet({ deployggb });
const applet = new GGBApplet(params);

@@ -685,0 +688,0 @@ if (codebase) {

@@ -1,3 +0,3 @@

var NetlessAppGeoGebra=function(p){"use strict";var H=Object.defineProperty,Z=Object.defineProperties;var K=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var Y=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var V=(p,h,g)=>h in p?H(p,h,{enumerable:!0,configurable:!0,writable:!0,value:g}):p[h]=g,E=(p,h)=>{for(var g in h||(h={}))Y.call(h,g)&&V(p,g,h[g]);if(N)for(var g of N(h))q.call(h,g)&&V(p,g,h[g]);return p},X=(p,h)=>Z(p,K(h));const h="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",g=h.length,C=Array(20),D=()=>{for(let i=0;i<20;i++)C[i]=h.charAt(Math.random()*g);return C.join("")};function k(i){try{return i()}catch(a){console.error(a)}}class x{constructor(){this.disposers=new Map}addDisposer(a,e=this.genUID()){return this.flush(e),this.disposers.set(e,Array.isArray(a)?()=>a.forEach(k):a),e}add(a,e=this.genUID()){return this.addDisposer(a(),e)}addEventListener(a,e,s,t,n=this.genUID()){return a.addEventListener(e,s,t),this.addDisposer(()=>a.removeEventListener(e,s,t),n),n}setTimeout(a,e,s=this.genUID()){const t=window.setTimeout(()=>{this.remove(s),a()},e);return this.addDisposer(()=>window.clearTimeout(t),s)}setInterval(a,e,s=this.genUID()){const t=window.setInterval(a,e);return this.addDisposer(()=>window.clearInterval(t),s)}remove(a){const e=this.disposers.get(a);return this.disposers.delete(a),e}flush(a){const e=this.remove(a);if(e)try{e()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(k),this.disposers.clear()}genUID(){let a;do a=D();while(this.disposers.has(a));return a}}function B(i){return i!=null&&typeof i=="object"&&!Array.isArray(i)}function R(i,a){let e=i.getAttributes();if(e||(i.setAttributes(a),e=i.getAttributes()),!e)throw new Error("[NetlessAppMonaco] No attributes");return B(a)&&Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||i.updateAttributes([s],a[s])}),e}let v;function U(i){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(v)return v;{const a=document.createElement("script");if(v=new Promise((e,s)=>{a.onload=()=>e(window.GGBApplet),a.onerror=()=>{v=void 0,s()}}),i){const e=i.lastIndexOf("GeoGebra")+8;a.src=i.slice(0,e)+"/deployggb.js"}else a.src="https://www.geogebra.org/apps/deployggb.js";return document.head.appendChild(a),v}}const _={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},L=class{constructor(i){var a;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const e of this.api.getAllObjectNames("embed"))this.initEmbed(e)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:e}=this;this.objectsInWaiting=[];for(const s of e){const t=this.api.getEmbeddedCalculators(!0),n=t==null?void 0:t[s];n!=null&&n.controller&&this.sendEvent("evalGMContent",n.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const r=this.api.getObjectsOfItsGroup(s);r!=null&&r.length&&this.sendEvent("addToGroup",s,r)}if(!o||this.api.isMoveable(s)){const r=this.api.getXML(s);this.sendEvent("evalXML",r,s)}this.sendEvent("select",s,!0)}this.updateCallback=0},this.updateListener=e=>{(this.api.hasUnlabeledPredecessors(e)||this.api.isMoveable(e))&&!this.currentAnimations.includes(e)&&(this.objectsInWaiting.includes(e)||(this.objectsInWaiting.push(e),this.dispatchUpdates()))},this.addListener=e=>{const s=this.api.getImageFileName(e);if(s){const r=this.api.getFileJSON();for(const u of r.archive)u.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(u))}const t=this.api.getXML(e),o=this.api.getCommandString(e)&&this.api.getAlgorithmXML(e);this.sendEvent("addObject",o||t,e),this.sendEvent("deselect"),this.sendEvent("select",e,!0),setTimeout(()=>this.initEmbed(e),500)},this.removeListener=e=>{this.sendEvent("deleteObject",e),delete this.embeds[e]},this.renameListener=(e,s)=>{this.sendEvent("renameObject",e,s)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:e,invYscale:s,xMin:t,yMin:n}=JSON.parse(this.api.getViewProperties(0)),o=1/e,r=-t/e,u=-n/s;return this.viewState={scale:o,x:r,y:u},this.viewSyncCallback=0,this.viewState},this.clientListener=e=>{let s,t;const n=e.type;switch(n){case"updateStyle":s=e.target,t=this.api.getXML(s),this.sendEvent("evalXML",t);break;case"editorStart":this.lastEditingLabel=e.target;break;case"editorKeyTyped":t=this.api.getEditorState(),this.sendEvent("setEditorState",t,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",e.target);break;case"select":this.sendEvent("select",e.target);break;case"embeddedContentChanged":s=e[1],t=e[2],this.sendEvent("embeddedContentChanged",t,s);break;case"undo":case"redo":case"addPolygonComplete":t=this.api.getXML(),this.sendEvent("setXML",t);break;case"addSlide":this.sendEvent(n);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":t=e[2],this.sendEvent(n,t);break;case"pasteSlide":({cardIdx:t,ggbFile:s}=e),this.sendEvent(n,t,s);break;case"startAnimation":s=e[1],this.currentAnimations.push(s),this.sendEvent(n,s,s);break;case"stopAnimation":s=e[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(n,s,s);break;case"groupObjects":case"ungroupObjects":t=e.targets,this.sendEvent(n,t);break;case"pasteElmsComplete":t=e.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",t);break;case"addGeoToTV":case"removeGeoFromTV":t=e[1],this.sendEvent(n,t);break;case"setValuesOfTV":t=e[2],this.sendEvent(n,t);break;case"showPointsTV":({column:t,show:s}=e),this.sendEvent(n,t,s);break;case"lockTextElement":case"unlockTextElement":t=e[1],this.sendEvent(n,t);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",e.type,e)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=e=>{var u,m;if(this.conflictedObjects.includes(e.label)&&e.type!=="conflictResolution")return;const t=e.embedLabel?this.embeds[e.embedLabel]:this,n=e.type,o=e.label,r=e.content;if(console.debug("[GeoGebra] receive:",n,o,r),n==="addObject")if(t.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let l=1,c;do c=`${o}_${l}`,l++;while(t.api.exists(c));this.unregisterListeners(),t.api.renameObject(o,c),this.registerListeners();const d=t.api.getAlgorithmXML(c)||t.api.getXML(c);this.sendEvent("conflictResolution",d,o)}else this.conflictedObjects.push(o);else t.evalXML(r),t.api.previewRefresh();else t.evalXML(r),t.api.previewRefresh();else if(n==="conflictResolution"){const l=this.conflictedObjects.indexOf(o);l!==-1&&this.conflictedObjects.splice(l,1),t.evalXML(r),t.api.previewRefresh()}else if(n==="evalXML")t.evalXML(r),t.api.previewRefresh();else if(n==="setXML")t.setXML(r);else if(n==="evalCommand")t.evalCommand(r),t.api.previewRefresh();else if(n==="deleteObject")t.unregisterListeners(),t===this&&delete this.embeds[r],t.api.deleteObject(r),t.registerListeners();else if(n==="setEditorState")t.unregisterListeners(),t.api.setEditorState(r,o),t.registerListeners();else if(n==="addImage"){const l=JSON.parse(r);t.api.addImage(l.fileName,l.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(n))t.api.handleSlideAction(n,r);else if(n==="selectSlide")t.unregisterListeners(),t.api.selectSlide(r),t.registerListeners();else if(n==="renameObject")t.unregisterListeners(),t.api.renameObject(r,o),t.registerListeners();else if(n==="pasteSlide")t.api.handleSlideAction(n,r,o);else if(n==="evalGMContent"){const l=(t.api.getEmbeddedCalculators(!0)||{})[o];l&&l.loadFromJSON(r)}else if(n==="startAnimation")t.api.setAnimating(o,!0),t.api.startAnimation();else if(n==="stopAnimation")t.api.setAnimating(o,!1);else if(n==="select"){if(r){const l=((m=(u=this.context).getColor)==null?void 0:m.call(u,e.clientId))||"#80808080";t.api.addMultiuserSelection(String(e.nickName),l,r,!!o)}}else if(n==="deselect")t.api.removeMultiuserSelections(String(e.nickName));else if(n==="orderingChange")t.api.updateOrdering(r);else if(n==="groupObjects")t.api.groupObjects(r);else if(n==="ungroupObjects")t.api.ungroupObjects(r);else if(n==="addToGroup")t.api.addToGroup(r,o);else if(n==="embeddedContentChanged")t.api.setEmbedContent(o,r);else if(n==="addGeoToTV")t.api.addGeoToTV(r);else if(n==="setValuesOfTV")t.api.setValuesOfTV(r);else if(n==="removeGeoFromTV")t.api.removeGeoFromTV(r);else if(n==="showPointsTV")t.api.showPointsTV(r,o);else if(n==="lockTextElement")t.api.lockTextElement(r);else if(n==="unlockTextElement")t.api.unlockTextElement(r);else if(n==="viewChanged2D")if(t.viewState.scale===0)t.api.evalCommand("Pan(0,0)"),t.startSyncViewState();else{const{scale:l,x:c,y:d}=JSON.parse(r),b=t._flushViewState();t.startSyncViewState(),t.api.evalCommand(`Pan(${c-b.x},${d-b.y})`),t.api.evalCommand(`ZoomIn(${l/b.scale})`)}else console.debug("[GeoGebra] unknown event",n,r,o)},this.api=i.api,this.clientId=i.clientId,this.nickName=i.nickName,this.delay=(a=i.delay)!=null?a:200,this.context=i,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(i,a,e){const s={type:i,content:a,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),e&&(s.label=e),s}sendEvent(i,a,e){console.log("[GeoGebra] send:",i,e,a),this.context.postMessage(this.createEvent(i,a,e)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(i){this.unregisterListeners(),this.api.evalCommand(i),this.registerListeners()}evalXML(i){this.unregisterListeners(),this.api.evalXML(i),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(i){this.unregisterListeners(),this.api.setXML(i),this.api.updateConstruction(),this.registerListeners()}initEmbed(i){if(this.embeds[i])return;const a=this.api.getEmbeddedCalculators();if(!a)return;const e=a[i];if(e&&"registerClientListener"in e){const s=new L(X(E({},this.context),{clientId:this.clientId,nickName:this.nickName,api:e,embedLabel:i}));s.registerListeners(),this.embeds[i]=s}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(i,a,e,s){return Math.abs(a-i.scale)>L.Threshold/10||Math.abs(e-i.x)>L.Threshold||Math.abs(s-i.y)>L.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let M=L;M.Threshold=20;var P=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
`)();function F(i,a){const e=new ResizeObserver(()=>a(i));return e.observe(i),()=>e.disconnect()}function J(i,a,e){const s=i.getDisplayer(),t=i.getRoom();let n=[];const o=l=>{l.authorId!==s.observerId&&n.forEach(c=>c(l.payload))},r="sync--"+i.appId;return s.addMagixEventListener(r,o),{service:{addListener(l){n.push(l)},postMessage(l){t==null||t.dispatchMagixEvent(r,l)},load(){return a[e]},save(l){i.updateAttributes([e],l)}},disposer:()=>{n=[],s.removeMagixEventListener(r)}}}const W=new Set(["classic","graphing","geometry","3d","suite","evaluator","scientific"]),$={kind:"GeoGebra",async setup(i){var T,G;const a=i.getDisplayer(),e=a.observerId,s=(T=a.state.roomMembers.find(f=>f.memberId===e))==null?void 0:T.payload,t=(s==null?void 0:s.uid)||"",n=(s==null?void 0:s.nickName)||t,o=(G=i.getAppOptions())==null?void 0:G.HTML5Codebase,r=R(i,{uid:"",ggbBase64:"",appName:"classic"}),u=i.getBox();u.mountStyles(P);const m=document.createElement("div");m.classList.add("netless-app-geogebra","loading"),t!==r.uid&&r.uid&&m.classList.add("netless-app-geogebra","readonly"),u.mountContent(m);const l=new x,c=E({},_);W.has(r.appName)&&(c.appName=r.appName),c.language=navigator.language.startsWith("zh")?"zh":"en",r.ggbBase64&&(c.ggbBase64=r.ggbBase64),c.id="ggb_"+i.appId;let d;const b=J(i,r,"ggbBase64");function A(){const{width:f,height:S}=m.getBoundingClientRect();d==null||d.setWidth(f),d==null||d.setHeight(S)}c.appletOnLoad=f=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(c.id)}`),d=f,A(),m.classList.remove("loading");const S=i.getDisplayer(),I=new M(E({clientId:S.observerId,nickName:n,api:f,isDecider:w=>S.state.roomMembers.map(y=>y.memberId).every(y=>w<=y),getColor:w=>{const j=S.memberState(w).strokeColor;return"#"+j.map(y=>y.toString(16).padStart(2,"0")).join("")+"80"}},b.service));I.registerListeners(),b.service.addListener(w=>{I.dispatch(w),d==null||d.setUndoPoint()})},l.add(()=>F(m,A)),i.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),l.flushAll(),b.disposer(),d==null||d.remove()});const z=await U(o),O=new z(c);o&&O.setHTML5Codebase(o),O.inject(m)}};return p.default=$,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),p}({});
var NetlessAppGeoGebra=function(h){"use strict";var Z=Object.defineProperty,K=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var X=(h,d,g)=>d in h?Z(h,d,{enumerable:!0,configurable:!0,writable:!0,value:g}):h[d]=g,C=(h,d)=>{for(var g in d||(d={}))q.call(d,g)&&X(h,g,d[g]);if(V)for(var g of V(d))Q.call(d,g)&&X(h,g,d[g]);return h},D=(h,d)=>K(h,Y(d));const d="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",g=d.length,M=Array(20),B=()=>{for(let n=0;n<20;n++)M[n]=d.charAt(Math.random()*g);return M.join("")};function A(n){try{return n()}catch(a){console.error(a)}}class x{constructor(){this.disposers=new Map}addDisposer(a,t=this.genUID()){return this.flush(t),this.disposers.set(t,Array.isArray(a)?()=>a.forEach(A):a),t}add(a,t=this.genUID()){return this.addDisposer(a(),t)}addEventListener(a,t,s,e,i=this.genUID()){return a.addEventListener(t,s,e),this.addDisposer(()=>a.removeEventListener(t,s,e),i),i}setTimeout(a,t,s=this.genUID()){const e=window.setTimeout(()=>{this.remove(s),a()},t);return this.addDisposer(()=>window.clearTimeout(e),s)}setInterval(a,t,s=this.genUID()){const e=window.setInterval(a,t);return this.addDisposer(()=>window.clearInterval(e),s)}remove(a){const t=this.disposers.get(a);return this.disposers.delete(a),t}flush(a){const t=this.remove(a);if(t)try{t()}catch(s){console.error(s)}}flushAll(){this.disposers.forEach(A),this.disposers.clear()}genUID(){let a;do a=B();while(this.disposers.has(a));return a}}function R(n){return n!=null&&typeof n=="object"&&!Array.isArray(n)}function U(n,a){let t=n.getAttributes();if(t||(n.setAttributes(a),t=n.getAttributes()),!t)throw new Error("[NetlessAppMonaco] No attributes");return R(a)&&Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(t,s)||n.updateAttributes([s],a[s])}),t}let L;function _({deployggb:n="https://www.geogebra.org/apps/latest/deployggb.js"}={}){if(window.GGBApplet)return Promise.resolve(window.GGBApplet);if(L)return L;{const a=document.createElement("script");return L=new Promise((t,s)=>{a.onload=()=>t(window.GGBApplet),a.onerror=()=>{L=void 0,s()}}),a.src=n,document.head.appendChild(a),L}}const P={appName:"classic",showMenuBar:!0,showAlgebraInput:!0,showToolBar:!0,customToolBar:"0 39 73 62 | 1 501 67 , 5 19 , 72 75 76 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 14 68 | 30 29 54 32 31 33 | 25 17 26 60 52 61 | 40 41 42 , 27 28 35 , 6",showToolBarHelp:!1,showResetIcon:!1,enableFileFeatures:!1,enableLabelDrags:!1,enableShiftDragZoom:!0,enableRightClick:!0,errorDialogsActive:!1,allowStyleBar:!1,preventFocus:!1,useBrowserForJS:!0,language:"en",borderColor:"transparent"},S=class{constructor(n){var a;this.currentAnimations=[],this.embeds={},this.storageCallback=0,this.initAllEmbeds=()=>{for(const t of this.api.getAllObjectNames("embed"))this.initEmbed(t)},this.objectsInWaiting=[],this.updateCallback=0,this.dispatchUpdates=()=>{this.updateCallback||(this.updateCallback=setTimeout(this._dispatchUpdates,this.delay))},this._dispatchUpdates=()=>{const{objectsInWaiting:t}=this;this.objectsInWaiting=[];for(const s of t){const e=this.api.getEmbeddedCalculators(!0),i=e==null?void 0:e[s];i!=null&&i.controller&&this.sendEvent("evalGMContent",i.toJSON(),s);const o=this.api.getCommandString(s,!1);if(o){this.sendEvent("evalCommand",`${s} := ${o}`,s);const r=this.api.getObjectsOfItsGroup(s);r!=null&&r.length&&this.sendEvent("addToGroup",s,r)}if(!o||this.api.isMoveable(s)){const r=this.api.getXML(s);this.sendEvent("evalXML",r,s)}this.sendEvent("select",s,!0)}this.updateCallback=0},this.updateListener=t=>{(this.api.hasUnlabeledPredecessors(t)||this.api.isMoveable(t))&&!this.currentAnimations.includes(t)&&(this.objectsInWaiting.includes(t)||(this.objectsInWaiting.push(t),this.dispatchUpdates()))},this.addListener=t=>{const s=this.api.getImageFileName(t);if(s){const r=this.api.getFileJSON();for(const u of r.archive)u.fileName.includes(s)&&this.sendEvent("addImage",JSON.stringify(u))}const e=this.api.getXML(t),o=this.api.getCommandString(t)&&this.api.getAlgorithmXML(t);this.sendEvent("addObject",o||e,t),this.sendEvent("deselect"),this.sendEvent("select",t,!0),setTimeout(()=>this.initEmbed(t),500)},this.removeListener=t=>{this.sendEvent("deleteObject",t),delete this.embeds[t]},this.renameListener=(t,s)=>{this.sendEvent("renameObject",t,s)},this.isSyncingViewState=0,this.stopSyncViewState=()=>{this.isSyncingViewState=0},this._flushViewState=()=>{const{invXscale:t,invYscale:s,xMin:e,yMin:i}=JSON.parse(this.api.getViewProperties(0)),o=1/t,r=-e/t,u=-i/s;return this.viewState={scale:o,x:r,y:u},this.viewSyncCallback=0,this.viewState},this.clientListener=t=>{let s,e;const i=t.type;switch(i){case"updateStyle":s=t.target,e=this.api.getXML(s),this.sendEvent("evalXML",e);break;case"editorStart":this.lastEditingLabel=t.target;break;case"editorKeyTyped":e=this.api.getEditorState(),this.sendEvent("setEditorState",e,this.lastEditingLabel);break;case"editorStop":this.lastEditingLabel=void 0,this.sendEvent("setEditorState",JSON.stringify({content:""}));break;case"deselect":this.sendEvent("deselect",t.target);break;case"select":this.sendEvent("select",t.target);break;case"embeddedContentChanged":s=t[1],e=t[2],this.sendEvent("embeddedContentChanged",e,s);break;case"undo":case"redo":case"addPolygonComplete":e=this.api.getXML(),this.sendEvent("setXML",e);break;case"addSlide":this.sendEvent(i);break;case"removeSlide":case"moveSlide":case"selectSlide":case"clearSlide":case"orderingChange":e=t[2],this.sendEvent(i,e);break;case"pasteSlide":({cardIdx:e,ggbFile:s}=t),this.sendEvent(i,e,s);break;case"startAnimation":s=t[1],this.currentAnimations.push(s),this.sendEvent(i,s,s);break;case"stopAnimation":s=t[1],this.currentAnimations.splice(this.currentAnimations.indexOf(s),1),this.sendEvent(i,s,s);break;case"groupObjects":case"ungroupObjects":e=t.targets,this.sendEvent(i,e);break;case"pasteElmsComplete":e=t.targets.map(o=>this.api.getXML(o)).join(""),this.sendEvent("evalXML",e);break;case"addGeoToTV":case"removeGeoFromTV":e=t[1],this.sendEvent(i,e);break;case"setValuesOfTV":e=t[2],this.sendEvent(i,e);break;case"showPointsTV":({column:e,show:s}=t),this.sendEvent(i,e,s);break;case"lockTextElement":case"unlockTextElement":e=t[1],this.sendEvent(i,e);break;case"viewChanged2D":this.viewSyncCallback||(this.isSyncingViewState||this.viewState.scale===0?this.viewSyncCallback=setTimeout(this._flushViewState,this.delay):this.viewSyncCallback=setTimeout(this._sendViewSyncEvent,this.delay));break;case"mouseDown":case"deleteGeos":case"dragEnd":break;default:console.debug("[GeoGebra] unhandled event ",t.type,t)}},this.viewSyncCallback=0,this.viewState={scale:0,x:0,y:0},this._sendViewSyncEvent=()=>{this._flushViewState(),this.sendEvent("viewChanged2D",JSON.stringify(this.viewState)),this.viewSyncCallback=0},this._delayedRegisterListeners=()=>{this.registerListeners(),this.viewSyncCallback=0},this.conflictedObjects=[],this.dispatch=t=>{var u,m;if(this.conflictedObjects.includes(t.label)&&t.type!=="conflictResolution")return;const e=t.embedLabel?this.embeds[t.embedLabel]:this,i=t.type,o=t.label,r=t.content;if(console.debug("[GeoGebra] receive:",i,o,r),i==="addObject")if(e.api.exists(o))if(this.context.isDecider)if(this.context.isDecider(this.clientId)){let c=1,l;do l=`${o}_${c}`,c++;while(e.api.exists(l));this.unregisterListeners(),e.api.renameObject(o,l),this.registerListeners();const f=e.api.getAlgorithmXML(l)||e.api.getXML(l);this.sendEvent("conflictResolution",f,o)}else this.conflictedObjects.push(o);else e.evalXML(r),e.api.previewRefresh();else e.evalXML(r),e.api.previewRefresh();else if(i==="conflictResolution"){const c=this.conflictedObjects.indexOf(o);c!==-1&&this.conflictedObjects.splice(c,1),e.evalXML(r),e.api.previewRefresh()}else if(i==="evalXML")e.evalXML(r),e.api.previewRefresh();else if(i==="setXML")e.setXML(r);else if(i==="evalCommand")e.evalCommand(r),e.api.previewRefresh();else if(i==="deleteObject")e.unregisterListeners(),e===this&&delete this.embeds[r],e.api.deleteObject(r),e.registerListeners();else if(i==="setEditorState")e.unregisterListeners(),e.api.setEditorState(r,o),e.registerListeners();else if(i==="addImage"){const c=JSON.parse(r);e.api.addImage(c.fileName,c.fileContent)}else if(["addSlide","removeSlide","moveSlide","clearSlide"].includes(i))e.api.handleSlideAction(i,r);else if(i==="selectSlide")e.unregisterListeners(),e.api.selectSlide(r),e.registerListeners();else if(i==="renameObject")e.unregisterListeners(),e.api.renameObject(r,o),e.registerListeners();else if(i==="pasteSlide")e.api.handleSlideAction(i,r,o);else if(i==="evalGMContent"){const c=(e.api.getEmbeddedCalculators(!0)||{})[o];c&&c.loadFromJSON(r)}else if(i==="startAnimation")e.api.setAnimating(o,!0),e.api.startAnimation();else if(i==="stopAnimation")e.api.setAnimating(o,!1);else if(i==="select"){if(r){const c=((m=(u=this.context).getColor)==null?void 0:m.call(u,t.clientId))||"#80808080";try{e.api.addMultiuserSelection(String(t.nickName),c,r,!!o)}catch(l){console.error(l)}}}else if(i==="deselect")e.api.removeMultiuserSelections(String(t.nickName));else if(i==="orderingChange")e.api.updateOrdering(r);else if(i==="groupObjects")e.api.groupObjects(r);else if(i==="ungroupObjects")e.api.ungroupObjects(r);else if(i==="addToGroup")e.api.addToGroup(r,o);else if(i==="embeddedContentChanged")e.api.setEmbedContent(o,r);else if(i==="addGeoToTV")e.api.addGeoToTV(r);else if(i==="setValuesOfTV")e.api.setValuesOfTV(r);else if(i==="removeGeoFromTV")e.api.removeGeoFromTV(r);else if(i==="showPointsTV")e.api.showPointsTV(r,o);else if(i==="lockTextElement")e.api.lockTextElement(r);else if(i==="unlockTextElement")e.api.unlockTextElement(r);else if(i==="viewChanged2D")if(e.viewState.scale===0)e.api.evalCommand("Pan(0,0)"),e.startSyncViewState();else{const{scale:c,x:l,y:f}=JSON.parse(r),b=e._flushViewState();e.startSyncViewState(),e.api.evalCommand(`Pan(${l-b.x},${f-b.y})`),e.api.evalCommand(`ZoomIn(${c/b.scale})`)}else console.debug("[GeoGebra] unknown event",i,r,o)},this.api=n.api,this.clientId=n.clientId,this.nickName=n.nickName,this.delay=(a=n.delay)!=null?a:200,this.context=n,setTimeout(()=>{this.api.evalCommand("Pan(0,0)")},this.delay)}createEvent(n,a,t){const s={type:n,content:a,clientId:this.clientId,nickName:this.nickName};return this.context.embedLabel&&(s.embedLabel=this.context.embedLabel),t&&(s.label=t),s}sendEvent(n,a,t){console.log("[GeoGebra] send:",n,t,a),this.context.postMessage(this.createEvent(n,a,t)),this.storageCallback||(this.storageCallback=setTimeout(()=>{this.context.save(this.api.getBase64()),this.storageCallback=0},this.delay))}evalCommand(n){this.unregisterListeners(),this.api.evalCommand(n),this.registerListeners()}evalXML(n){this.unregisterListeners(),this.api.evalXML(n),this.api.updateConstruction(),this.registerListeners(),setTimeout(this.initAllEmbeds,500)}setXML(n){this.unregisterListeners(),this.api.setXML(n),this.api.updateConstruction(),this.registerListeners()}initEmbed(n){if(this.embeds[n])return;const a=this.api.getEmbeddedCalculators();if(!a)return;const t=a[n];if(t&&"registerClientListener"in t){const s=new S(D(C({},this.context),{clientId:this.clientId,nickName:this.nickName,api:t,embedLabel:n}));s.registerListeners(),this.embeds[n]=s}}startSyncViewState(){clearTimeout(this.isSyncingViewState),this.isSyncingViewState=setTimeout(this.stopSyncViewState,1e3)}shouldSyncView(n,a,t,s){return Math.abs(a-n.scale)>S.Threshold/10||Math.abs(t-n.x)>S.Threshold||Math.abs(s-n.y)>S.Threshold}registerListeners(){this.api.registerUpdateListener(this.updateListener),this.api.registerRemoveListener(this.removeListener),this.api.registerAddListener(this.addListener),this.api.registerClientListener(this.clientListener),this.api.registerRenameListener(this.renameListener)}unregisterListeners(){this.api.unregisterUpdateListener(this.updateListener),this.api.unregisterRemoveListener(this.removeListener),this.api.unregisterAddListener(this.addListener),this.api.unregisterClientListener(this.clientListener),this.api.unregisterRenameListener(this.renameListener)}};let O=S;O.Threshold=20;var F=(()=>`.netless-app-geogebra{width:100%!important;height:100%!important;overflow:hidden}.netless-app-geogebra.loading{background-color:#fff}.netless-app-geogebra.readonly{user-select:none;pointer-events:none}
`)();function J(n,a){const t=new ResizeObserver(()=>a(n));return t.observe(n),()=>t.disconnect()}function W(n,a,t){const s=n.getDisplayer(),e=n.getRoom();let i=[];const o=c=>{c.authorId!==s.observerId&&i.forEach(l=>l(c.payload))},r="sync--"+n.appId;return s.addMagixEventListener(r,o),{service:{addListener(c){i.push(c)},postMessage(c){e==null||e.dispatchMagixEvent(r,c)},load(){return a[t]},save(c){n.updateAttributes([t],c)}},disposer:()=>{i=[],s.removeMagixEventListener(r)}}}const $=new Set(["classic","graphing","geometry","3d","suite","evaluator","scientific"]),z={kind:"GeoGebra",async setup(n){var I;const a=n.getDisplayer(),t=a.observerId,s=(I=a.state.roomMembers.find(v=>v.memberId===t))==null?void 0:I.payload,e=(s==null?void 0:s.uid)||"",i=(s==null?void 0:s.nickName)||e,o=n.getAppOptions()||{},r=o.deployggb,u=o.HTML5Codebase,m=U(n,{uid:"",ggbBase64:"",appName:"classic"}),c=n.getBox();c.mountStyles(F);const l=document.createElement("div");l.classList.add("netless-app-geogebra","loading"),e!==m.uid&&m.uid&&l.classList.add("netless-app-geogebra","readonly"),c.mountContent(l);const f=new x,b=C({},P);$.has(m.appName)&&(b.appName=m.appName),b.language=navigator.language.startsWith("zh")?"zh":"en",m.ggbBase64&&(b.ggbBase64=m.ggbBase64),b.id="ggb_"+n.appId;let p;const k=W(n,m,"ggbBase64");function T(){const{width:v,height:w}=l.getBoundingClientRect();p==null||p.setWidth(v),p==null||p.setHeight(w)}b.appletOnLoad=v=>{console.log(`[GeoGebra]: loaded ${JSON.stringify(b.id)}`),p=v,T(),l.classList.remove("loading");const w=n.getDisplayer(),j=new O(C({clientId:w.observerId,nickName:i,api:v,isDecider:y=>w.state.roomMembers.map(E=>E.memberId).every(E=>y<=E),getColor:y=>{const N=w.memberState(y).strokeColor;return"#"+N.map(E=>E.toString(16).padStart(2,"0")).join("")+"80"}},k.service));j.registerListeners(),k.service.addListener(y=>{j.dispatch(y),p==null||p.setUndoPoint()})},f.add(()=>J(l,T)),n.emitter.on("destroy",()=>{console.log("[GeoGebra]: destroy"),f.flushAll(),k.disposer(),p==null||p.remove()});const H=await _({deployggb:r}),G=new H(b);u&&G.setHTML5Codebase(u),G.inject(l)}};return h.default=z,Object.defineProperties(h,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),h}({});
//# sourceMappingURL=main.iife.js.map
{
"name": "@netless/app-geogebra",
"version": "0.0.7",
"version": "0.0.8",
"main": "dist/main.cjs.js",

@@ -5,0 +5,0 @@ "module": "dist/main.es.js",

@@ -11,3 +11,12 @@ import type { GGBApplet, GGBAppletParameters } from "../types";

export default function getGGBApplet(codebase?: string): Promise<typeof GGBApplet> {
export interface GetGGBAppletParams {
/**
* @default https://www.geogebra.org/apps/latest/deployggb.js
*/
deployggb?: string;
}
export default function getGGBApplet({
deployggb = "https://www.geogebra.org/apps/latest/deployggb.js",
}: GetGGBAppletParams = {}): Promise<typeof GGBApplet> {
if (window.GGBApplet) {

@@ -26,8 +35,3 @@ return Promise.resolve(window.GGBApplet);

});
if (codebase) {
const index = codebase.lastIndexOf("GeoGebra") + 8; /* "GeoGebra".length */
script.src = codebase.slice(0, index) + "/deployggb.js";
} else {
script.src = "https://www.geogebra.org/apps/deployggb.js";
}
script.src = deployggb;
document.head.appendChild(script);

@@ -34,0 +38,0 @@ return getGGBAppletPromise;

@@ -550,3 +550,7 @@ import type { AppletObject, ClientEvent } from "../types";

const color = this.context.getColor?.(last.clientId) || "#80808080";
target.api.addMultiuserSelection(String(last.nickName), color, content, !!label);
try {
target.api.addMultiuserSelection(String(last.nickName), color, content, !!label);
} catch (error) {
console.error(error);
}
}

@@ -553,0 +557,0 @@ } else if (type === "deselect") {

@@ -26,2 +26,7 @@ import { ensureAttributes } from "@netless/app-shared";

export interface AppOptions {
deployggb?: string;
HTML5Codebase?: string;
}
interface UserPayload {

@@ -43,3 +48,3 @@ uid: string;

*/
const GeoGebra: NetlessApp<Attributes> = {
const GeoGebra: NetlessApp<Attributes, {}, AppOptions> = {
kind: "GeoGebra",

@@ -55,3 +60,5 @@ async setup(context) {

const codebase = context.getAppOptions()?.HTML5Codebase;
const appOptions = context.getAppOptions() || {};
const deployggb = appOptions.deployggb;
const codebase = appOptions.HTML5Codebase;

@@ -141,3 +148,3 @@ const attrs = ensureAttributes(context, {

const GGBApplet = await getGGBApplet(codebase);
const GGBApplet = await getGGBApplet({ deployggb });
const applet = new GGBApplet(params);

@@ -144,0 +151,0 @@ if (codebase) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc