@tomorrowevening/hermes 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(w,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("three"),require("@theatre/core"),require("@theatre/studio"),require("tweakpane"),require("@tweakpane/plugin-essentials"),require("react"),require("framer-motion")):typeof define=="function"&&define.amd?define(["exports","three","@theatre/core","@theatre/studio","tweakpane","@tweakpane/plugin-essentials","react","framer-motion"],u):(w=typeof globalThis<"u"?globalThis:w||self,u(w.Hermes={},w.Three,w["Theatre Core"],w["Theatre Studio"],w.tweakpane,w["tweakpane-plugin-essentials"],w.React,w["framer-motion"]))})(this,function(w,u,Se,Xe,xn,On,R,Bt){"use strict";var Ra=Object.defineProperty;var Pa=(w,u,Se)=>u in w?Ra(w,u,{enumerable:!0,configurable:!0,writable:!0,value:Se}):w[u]=Se;var Z=(w,u,Se)=>(Pa(w,typeof u!="symbol"?u+"":u,Se),Se);function Tn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const e=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,e.get?e:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const Mn=Tn(On);function Rn(t,n,a){return Math.min(n,Math.max(t,a))}function Pn(t,n){const a=t-n;return Math.sqrt(a*a)}function Gt(){return Math.round(Math.random()*1e6).toString()}function Ht(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function zt(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),r=f=>{const m=f.toString(16);return m.length===1?"0"+m:m},s=r(n),d=r(a),l=r(e);return"#"+s+d+l}function ct(t,n=1){return Number(t.toFixed(n))}w.totalThreeObjects=0;const Yt=()=>{w.totalThreeObjects=0},Tt=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${w.totalThreeObjects}`,w.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{Tt(a)})},jn=t=>{t==null||t.dispose()},Wt=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Mt=t=>{var n;if(t){for(;t.children.length>0;){const a=t.children[0];a instanceof u.PositionalAudio?(a.pause(),a.parent&&a.parent.remove(a)):Mt(a)}if(t.parent&&t.parent.remove(t),t.isMesh){const a=t;(n=a.geometry)==null||n.dispose(),Wt(a.material)}t.dispose!==void 0&&t.dispose()}};class _n{constructor(n,a,e="editor"){Z(this,"channel");Z(this,"components",new Map);Z(this,"_mode","app");this.editor=a&&document.location.hash.search(e)>-1,a&&(this.channel=new BroadcastChannel(n))}addComponent(n,a){this.components.set(n,a)}dispose(){this.components.forEach(n=>{n.dispose()}),this.components.clear()}send(n){this.channel!==void 0&&this._mode!==n.target&&this.channel.postMessage(n)}listen(n){this.channel!==void 0&&(this.channel.onmessage=a=>{n(a.data)})}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(n){n&&(this._mode="editor",document.title+=" - Editor")}}const D=new u.EventDispatcher,A={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera"};class Ze{constructor(n){Z(this,"app");this.app=n}dispose(){}}class Kt extends Ze{selectDropdown(n,a){this.app.send({event:"selectComponent",target:"app",data:{dropdown:n,value:a}})}updateDropdown(n,a){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:n,value:a}})}}function kn(t,n){switch(n.event){case"selectComponent":D.dispatchEvent({type:A.SELECT_DROPDOWN,value:n.data});break;case"draggableListUpdate":D.dispatchEvent({type:A.DRAG_UPDATE,value:n.data});break}}const Xt=()=>{},Ge=class Ge extends Ze{constructor(){super(...arguments);Z(this,"project");Z(this,"sheets",new Map);Z(this,"sheetObjects",new Map);Z(this,"sheetObjectCBs",new Map);Z(this,"sheetObjectUnsubscribe",new Map)}init(a,e){return this.project=Se.getProject(a,e),this.project.ready}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(a){var r;if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let e=this.sheets.get(a);return e!==void 0||(e=(r=this.project)==null?void 0:r.sheet(a),this.sheets.set(a,e)),e}playSheet(a,e){var r;(r=this.sheet(a))==null||r.sequence.play(e),this.app.send({event:"playSheet",target:"editor",data:{sheet:a,value:e}})}pauseSheet(a){var e;(e=this.sheet(a))==null||e.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:a}})}clearSheetObjects(a){this.sheetObjects.forEach((e,r)=>{r.search(`${a}_`)>-1&&this.unsubscribe(e)})}sheetObject(a,e,r,s){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const d=this.sheet(a);if(d===void 0)return;const l=`${a}_${e}`;let f=this.sheetObjects.get(l);f!==void 0?f=d.object(e,{...r,...f.value},{reconfigure:!0}):f=d.object(e,r),this.sheetObjects.set(l,f),this.sheetObjectCBs.set(l,s!==void 0?s:Xt);const m=f.onValuesChange(b=>{if(this.app.editor){for(const x in b){const O=b[x];typeof O=="object"&&Ht(O)&&(b[x]={r:O.r,g:O.g,b:O.b,a:O.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheetObject:l,values:b}})}const C=this.sheetObjectCBs.get(l);C!==void 0&&C(b)});return this.sheetObjectUnsubscribe.set(l,m),f}unsubscribe(a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const e=a.address.sheetId,r=a.address.objectKey,s=this.sheets.get(e);s==null||s.detachObject(r);const d=`${e}_${r}`,l=this.sheetObjectUnsubscribe.get(d);l!==void 0&&(this.sheetObjects.delete(d),this.sheetObjectCBs.delete(d),this.sheetObjectUnsubscribe.delete(d),l())}static getRafDriver(){return Ge.rafDriver||(Ge.rafDriver=Se.createRafDriver()),Ge.rafDriver}};Z(Ge,"rafDriver",null);let xe=Ge,Oe;function Dn(t,n){t.components.forEach(a=>{if(a instanceof xe){let e;const r=a;switch(n.event){case"setSheet":e=r.sheets.get(n.data.sheet),e!==void 0&&(Oe=e,Xe.setSelection([e]));break;case"setSheetObject":e=r.sheetObjects.get(`${n.data.sheet}_${n.data.key}`),e!==void 0&&Xe.setSelection([e]);break;case"updateSheetObject":e=r.sheetObjectCBs.get(n.data.sheetObject),e!==void 0&&e(n.data.values);break;case"updateTimeline":e=r.sheets.get(n.data.sheet),Oe!==void 0&&(Oe.sequence.position=n.data.position);break}}})}function An(t){if(t.editor){let n;t.components.forEach(s=>{s instanceof xe&&(n=s)}),Xe.ui.restore(),Xe.onSelectionChange(s=>{s.length<1||s.forEach(d=>{let l=d.address.sheetId,f="setSheet",m={};switch(d.type){case"Theatre_Sheet_PublicAPI":f="setSheet",m={sheet:d.address.sheetId},Oe=n.sheets.get(d.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":f="setSheetObject",l+=`_${d.address.objectKey}`,m={id:l,sheet:d.address.sheetId,key:d.address.objectKey};break}t.send({event:f,target:"app",data:m})})});let a=0;const e=()=>{if(xe.getRafDriver().tick(performance.now()),Oe!==void 0&&a!==Oe.sequence.position){a=Oe.sequence.position;const s=Oe;t.send({event:"updateTimeline",target:"app",data:{position:a,sheet:s.address.sheetId}})}},r=()=>{e(),requestAnimationFrame(r)};e(),r()}else Xe.ui.hide()}function In(t,n){t.editor&&t.components.forEach(a=>{var e,r;if(a instanceof xe){const s=a;switch(n.event){case"playSheet":(e=s.sheet(n.data.sheet))==null||e.sequence.play(n.data.value);break;case"pauseSheet":(r=s.sheet(n.data.sheet))==null||r.sequence.pause();break}return}})}function Nn(t){if(t.name==="cameras")return"camera";if(t.name==="interactive")return"interactive";if(t.name==="lights")return"light";if(t.name==="ui")return"ui";if(t.name==="utils")return"utils";const n=t.type;return n.search("Helper")>-1?"icon_utils":n.search("Camera")>-1?"camera":n.search("Light")>-1?"light":"obj3D"}function Zt(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(Zt(a))}),n}function Ln(t){const n={};for(const a in t){const e=t[a].value;n[a]={value:e},e===null?n[a].value={src:""}:e.isTexture&&(n[a].value={src:e.image.src})}return n}function Un(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Jt(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Un(a))continue;const e=typeof t[a],r=t[a];switch(e){case"boolean":case"number":case"string":n[a]=r;break;case"object":if(r!==null)if(n[a]=r,r.isTexture)if(r instanceof u.Texture){const s=r.source.toJSON();n[a]={src:s.url}}else r instanceof u.CubeTexture&&(console.log("env map"),console.log(r.source.data),console.log(r.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=Ln(n[a]));else n[a]={src:""};break}}return n}function Rt(t){t.updateMatrix();const n={name:t.name,type:t.type,uuid:t.uuid,visible:t.visible,matrix:t.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};t.animations.forEach(e=>{n.animations.push({name:e.name,duration:e.duration,blendMode:e.blendMode})});const a=t.type.toLowerCase();if(a.search("mesh")>-1){const e=t;if(Array.isArray(e.material)){const r=[];e.material.forEach(s=>{r.push(Jt(s))}),n.material=r}else n.material=Jt(e.material)}else a.search("camera")>-1?t.type==="PerspectiveCamera"?n.perspectiveCameraInfo={fov:t.fov,zoom:t.zoom,near:t.near,far:t.far,focus:t.focus,aspect:t.aspect,filmGauge:t.filmGauge,filmOffset:t.filmOffset}:t.type==="OrthographicCamera"&&(n.orthographicCameraInfo={zoom:t.zoom,near:t.near,far:t.far,left:t.left,right:t.right,top:t.top,bottom:t.bottom}):a.search("light")>-1&&(n.lightInfo={color:t.color,intensity:t.intensity,decay:t.decay,distance:t.distance,angle:t.angle,penumbra:t.penumbra,groundColor:t.groundColor});return n}function te(t,n,a){const e=n.split(".");switch(e.length){case 1:t[e[0]]=a;break;case 2:t[e[0]][e[1]]=a;break;case 3:t[e[0]][e[1]][e[2]]=a;break;case 4:t[e[0]][e[1]][e[2]][e[3]]=a;break;case 5:t[e[0]][e[1]][e[2]][e[3]][e[4]]=a;break}}function Pt(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const r=new u.Texture(e);r.wrapS=u.RepeatWrapping,r.wrapT=u.RepeatWrapping,r.needsUpdate=!0,n(r)},e.onerror=a,e.src=t})}class Qt extends Ze{constructor(){super(...arguments);Z(this,"scene")}getObject(a){this.app.send({event:"getObject",target:"app",data:a})}setObject(a){const e=Rt(a);this.app.send({event:"setObject",target:"editor",data:e})}requestMethod(a,e,r){this.app.send({event:"requestMethod",target:"app",data:{uuid:a,key:e,value:r}})}updateObject(a,e,r){this.app.send({event:"updateObject",target:"app",data:{uuid:a,key:e,value:r}})}createTexture(a,e,r){this.app.send({event:"createTexture",target:"app",data:{uuid:a,key:e,value:r}})}setScene(a){if(a===void 0)return;this.scene=a,Yt(),Tt(this.scene);const e=Zt(this.scene);this.app.send({event:"setScene",target:"editor",data:e})}addCamera(a){const e=Rt(a);this.app.send({event:"addCamera",target:"editor",data:e})}removeCamera(a){const e=Rt(a);this.app.send({event:"removeCamera",target:"editor",data:e})}}function Fn(t,n){switch(n.event){case"getObject":D.dispatchEvent({type:A.GET_OBJECT,value:n.data});break;case"updateObject":D.dispatchEvent({type:A.UPDATE_OBJECT,value:n.data});break;case"createTexture":D.dispatchEvent({type:A.CREATE_TEXTURE,value:n.data});break;case"requestMethod":D.dispatchEvent({type:A.REQUEST_METHOD,value:n.data});break}}function Vn(t,n){switch(n.event){case"setObject":D.dispatchEvent({type:A.SET_OBJECT,value:n.data});break;case"setScene":D.dispatchEvent({type:A.SET_SCENE,value:n.data});break;case"addCamera":D.dispatchEvent({type:A.ADD_CAMERA,value:n.data});break;case"removeCamera":D.dispatchEvent({type:A.REMOVE_CAMERA,value:n.data});break}}class jt extends Ze{constructor(a){super(a);Z(this,"bindCBs");Z(this,"buttonCBs");Z(this,"pane");Z(this,"appCallbacks",0);Z(this,"editorCallbacks",0);Z(this,"inspectorFolder");this.bindCBs=new Map,this.buttonCBs=new Map,a.editor&&this.createGUI()}createGUI(){this.pane=new xn.Pane({title:"GUI"}),this.pane.registerPlugin(Mn)}dispose(){var a;this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&((a=this.pane)==null||a.dispose(),this.pane=void 0)}addFolder(a,e=void 0,r=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addFolder({title:a,...e});this.app.send({event:"addFolder",target:"app",data:{name:a,params:e,parent:r}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(a,e,r,s=void 0){const d=this.bindID,l=r.onChange!==void 0?r.onChange:Xt;this.bindCBs.set(d,l),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(a,e,r).on("change",m=>{this.app.send({event:"updateBind",target:"app",data:{id:d,value:m.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:d,name:e,params:r,parent:s}}),this.appCallbacks++)}triggerBind(a,e){const r=this.bindCBs.get(a);r!==void 0?r(e):console.warn(`No callback for: ${a}`,e)}button(a,e,r=void 0){const s=this.bindID;this.buttonCBs.set(s,e),this.app.editor?(this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addButton({title:a}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:s}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:s,name:a,callback:e,parent:r}}),this.appCallbacks++)}triggerButton(a){const e=this.buttonCBs.get(a);e!==void 0&&e()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const a=this.inspectorFolder.children.length-1;for(let e=a;e>-1;--e)this.inspectorFolder.remove(this.inspectorFolder.children[e])}}function Bn(t,n){t.components.forEach(a=>{if(a instanceof jt){const e=a;switch(n.event){case"addFolder":e.addFolder(n.data.name,n.data.params,n.data.parent);break;case"bindObject":e.bind(n.data.name,n.data.params,n.data.parent);break;case"updateBind":e.triggerBind(n.data.id,n.data.value);break;case"addButton":e.button(n.data.name,n.data.callback,n.data.parent);break;case"clickButton":e.triggerButton(n.data.id);break}return}})}var _t={exports:{}},Je={};/**
1
+ (function(w,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("three"),require("@theatre/core"),require("@theatre/studio"),require("tweakpane"),require("@tweakpane/plugin-essentials"),require("react"),require("framer-motion")):typeof define=="function"&&define.amd?define(["exports","three","@theatre/core","@theatre/studio","tweakpane","@tweakpane/plugin-essentials","react","framer-motion"],u):(w=typeof globalThis<"u"?globalThis:w||self,u(w.Hermes={},w.Three,w["Theatre Core"],w["Theatre Studio"],w.tweakpane,w["tweakpane-plugin-essentials"],w.React,w["framer-motion"]))})(this,function(w,u,Ce,Xe,On,xn,R,Bt){"use strict";var Ra=Object.defineProperty;var Pa=(w,u,Ce)=>u in w?Ra(w,u,{enumerable:!0,configurable:!0,writable:!0,value:Ce}):w[u]=Ce;var F=(w,u,Ce)=>(Pa(w,typeof u!="symbol"?u+"":u,Ce),Ce);function Tn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const e=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,e.get?e:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const Mn=Tn(xn);function Rn(t,n,a){return Math.min(n,Math.max(t,a))}function Pn(t,n){const a=t-n;return Math.sqrt(a*a)}function Ht(){return Math.round(Math.random()*1e6).toString()}function Gt(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function zt(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),r=f=>{const m=f.toString(16);return m.length===1?"0"+m:m},s=r(n),d=r(a),l=r(e);return"#"+s+d+l}function ct(t,n=1){return Number(t.toFixed(n))}w.totalThreeObjects=0;const Yt=()=>{w.totalThreeObjects=0},Tt=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${w.totalThreeObjects}`,w.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{Tt(a)})},jn=t=>{t==null||t.dispose()},Wt=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Mt=t=>{var n;if(t){for(;t.children.length>0;){const a=t.children[0];a instanceof u.PositionalAudio?(a.pause(),a.parent&&a.parent.remove(a)):Mt(a)}if(t.parent&&t.parent.remove(t),t.isMesh){const a=t;(n=a.geometry)==null||n.dispose(),Wt(a.material)}t.dispose!==void 0&&t.dispose()}};class _n{constructor(n,a,e=!0,r="editor"){F(this,"components",new Map);F(this,"listen");F(this,"_debugEnabled");F(this,"broadcastChannel");F(this,"webSocket");F(this,"_mode","app");F(this,"_connected",!1);F(this,"useBC",!1);F(this,"messageHandler",n=>{this.listen!==void 0&&(this.useBC?this.listen(n.data):this.listen(JSON.parse(n.data)))});F(this,"openHandler",()=>{this._connected=!0});F(this,"closeHandler",()=>{this._connected=!1});this.editor=a&&document.location.hash.search(r)>-1,this._debugEnabled=a,a&&(this.useBC=e,e?(this.broadcastChannel=new BroadcastChannel(n),this.broadcastChannel.addEventListener("message",this.messageHandler)):(this.webSocket=new WebSocket(n),this.webSocket.addEventListener("open",this.openHandler),this.webSocket.addEventListener("close",this.closeHandler),this.webSocket.addEventListener("message",this.messageHandler)))}addComponent(n,a){this.components.set(n,a)}dispose(){this.broadcastChannel!==void 0&&this.broadcastChannel.removeEventListener("message",this.messageHandler),this.webSocket!==void 0&&(this.webSocket.removeEventListener("open",this.openHandler),this.webSocket.removeEventListener("close",this.closeHandler),this.webSocket.removeEventListener("message",this.messageHandler)),this.components.forEach(n=>{n.dispose()}),this.components.clear()}send(n){var a,e;this._mode!==n.target&&(this.useBC?(a=this.broadcastChannel)==null||a.postMessage(n):this._connected&&((e=this.webSocket)==null||e.send(JSON.stringify(n))))}get connected(){return this._connected}get debugEnabled(){return this._debugEnabled}get mode(){return this._mode}get isApp(){return this._mode==="app"}get editor(){return this._mode==="editor"}set editor(n){n&&(this._mode="editor",document.title+=" - Editor")}}const D=new u.EventDispatcher,A={CUSTOM:"ToolEvents::custom",SELECT_DROPDOWN:"ToolEvents::selectDropdown",DRAG_UPDATE:"ToolEvents::dragUpdate",SET_SCENE:"ToolEvents::setScene",GET_OBJECT:"ToolEvents::getObject",SET_OBJECT:"ToolEvents::setObject",UPDATE_OBJECT:"ToolEvents::updateObject",CREATE_TEXTURE:"ToolEvents::createTexture",REQUEST_METHOD:"ToolEvents::requestMethod",ADD_CAMERA:"ToolEvents::addCamera",REMOVE_CAMERA:"ToolEvents::removeCamera"};class Ze{constructor(n){F(this,"app");this.app=n}dispose(){}}class Kt extends Ze{selectDropdown(n,a){this.app.send({event:"selectComponent",target:"app",data:{dropdown:n,value:a}})}updateDropdown(n,a){this.app.send({event:"draggableListUpdate",target:"app",data:{dropdown:n,value:a}})}}function kn(t,n){switch(n.event){case"selectComponent":D.dispatchEvent({type:A.SELECT_DROPDOWN,value:n.data});break;case"draggableListUpdate":D.dispatchEvent({type:A.DRAG_UPDATE,value:n.data});break}}const Xt=()=>{},He=class He extends Ze{constructor(){super(...arguments);F(this,"project");F(this,"sheets",new Map);F(this,"sheetObjects",new Map);F(this,"sheetObjectCBs",new Map);F(this,"sheetObjectUnsubscribe",new Map)}init(a,e){return this.project=Ce.getProject(a,e),this.project.ready}dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(a){var r;if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let e=this.sheets.get(a);return e!==void 0||(e=(r=this.project)==null?void 0:r.sheet(a),this.sheets.set(a,e)),e}playSheet(a,e){var r;(r=this.sheet(a))==null||r.sequence.play(e),this.app.send({event:"playSheet",target:"editor",data:{sheet:a,value:e}})}pauseSheet(a){var e;(e=this.sheet(a))==null||e.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:a}})}clearSheetObjects(a){this.sheetObjects.forEach((e,r)=>{r.search(`${a}_`)>-1&&this.unsubscribe(e)})}sheetObject(a,e,r,s){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const d=this.sheet(a);if(d===void 0)return;const l=`${a}_${e}`;let f=this.sheetObjects.get(l);f!==void 0?f=d.object(e,{...r,...f.value},{reconfigure:!0}):f=d.object(e,r),this.sheetObjects.set(l,f),this.sheetObjectCBs.set(l,s!==void 0?s:Xt);const m=f.onValuesChange(b=>{if(this.app.editor){for(const O in b){const x=b[O];typeof x=="object"&&Gt(x)&&(b[O]={r:x.r,g:x.g,b:x.b,a:x.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:a,sheetObject:l,values:b}})}const S=this.sheetObjectCBs.get(l);S!==void 0&&S(b)});return this.sheetObjectUnsubscribe.set(l,m),f}unsubscribe(a){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const e=a.address.sheetId,r=a.address.objectKey,s=this.sheets.get(e);s==null||s.detachObject(r);const d=`${e}_${r}`,l=this.sheetObjectUnsubscribe.get(d);l!==void 0&&(this.sheetObjects.delete(d),this.sheetObjectCBs.delete(d),this.sheetObjectUnsubscribe.delete(d),l())}static getRafDriver(){return He.rafDriver||(He.rafDriver=Ce.createRafDriver()),He.rafDriver}};F(He,"rafDriver",null);let Oe=He,xe;function Dn(t,n){t.components.forEach(a=>{if(a instanceof Oe){let e;const r=a;switch(n.event){case"setSheet":e=r.sheets.get(n.data.sheet),e!==void 0&&(xe=e,Xe.setSelection([e]));break;case"setSheetObject":e=r.sheetObjects.get(`${n.data.sheet}_${n.data.key}`),e!==void 0&&Xe.setSelection([e]);break;case"updateSheetObject":e=r.sheets.get(n.data.sheet),e!==void 0&&e.sequence.pause(),e=r.sheetObjectCBs.get(n.data.sheetObject),e!==void 0&&e(n.data.values);break;case"updateTimeline":e=r.sheets.get(n.data.sheet),xe!==void 0&&(xe.sequence.position=n.data.position);break}}})}function An(t){if(t.editor){let n;t.components.forEach(s=>{s instanceof Oe&&(n=s)}),Xe.ui.restore(),Xe.onSelectionChange(s=>{s.length<1||s.forEach(d=>{let l=d.address.sheetId,f="setSheet",m={};switch(d.type){case"Theatre_Sheet_PublicAPI":f="setSheet",m={sheet:d.address.sheetId},xe=n.sheets.get(d.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":f="setSheetObject",l+=`_${d.address.objectKey}`,m={id:l,sheet:d.address.sheetId,key:d.address.objectKey};break}t.send({event:f,target:"app",data:m})})});let a=0;const e=()=>{if(Oe.getRafDriver().tick(performance.now()),xe!==void 0&&a!==xe.sequence.position){a=xe.sequence.position;const s=xe;t.send({event:"updateTimeline",target:"app",data:{position:a,sheet:s.address.sheetId}})}},r=()=>{e(),requestAnimationFrame(r)};e(),r()}else Xe.ui.hide()}function In(t,n){t.editor&&t.components.forEach(a=>{var e,r;if(a instanceof Oe){const s=a;switch(n.event){case"playSheet":(e=s.sheet(n.data.sheet))==null||e.sequence.play(n.data.value);break;case"pauseSheet":(r=s.sheet(n.data.sheet))==null||r.sequence.pause();break}return}})}function Ln(t){if(t.name==="cameras")return"camera";if(t.name==="interactive")return"interactive";if(t.name==="lights")return"light";if(t.name==="ui")return"ui";if(t.name==="utils")return"utils";const n=t.type;return n.search("Helper")>-1?"icon_utils":n.search("Camera")>-1?"camera":n.search("Light")>-1?"light":"obj3D"}function Zt(t){const n={name:t.name,type:t.type,uuid:t.uuid,children:[]};return t.children.forEach(a=>{n.children.push(Zt(a))}),n}function Nn(t){const n={};for(const a in t){const e=t[a].value;n[a]={value:e},e===null?n[a].value={src:""}:e.isTexture&&(n[a].value={src:e.image.src})}return n}function Un(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function Jt(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Un(a))continue;const e=typeof t[a],r=t[a];switch(e){case"boolean":case"number":case"string":n[a]=r;break;case"object":if(r!==null)if(n[a]=r,r.isTexture)if(r instanceof u.Texture){const s=r.source.toJSON();n[a]={src:s.url}}else r instanceof u.CubeTexture&&(console.log("env map"),console.log(r.source.data),console.log(r.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=Nn(n[a]));else n[a]={src:""};break}}return n}function Rt(t){t.updateMatrix();const n={name:t.name,type:t.type,uuid:t.uuid,visible:t.visible,matrix:t.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};t.animations.forEach(e=>{n.animations.push({name:e.name,duration:e.duration,blendMode:e.blendMode})});const a=t.type.toLowerCase();if(a.search("mesh")>-1){const e=t;if(Array.isArray(e.material)){const r=[];e.material.forEach(s=>{r.push(Jt(s))}),n.material=r}else n.material=Jt(e.material)}else a.search("camera")>-1?t.type==="PerspectiveCamera"?n.perspectiveCameraInfo={fov:t.fov,zoom:t.zoom,near:t.near,far:t.far,focus:t.focus,aspect:t.aspect,filmGauge:t.filmGauge,filmOffset:t.filmOffset}:t.type==="OrthographicCamera"&&(n.orthographicCameraInfo={zoom:t.zoom,near:t.near,far:t.far,left:t.left,right:t.right,top:t.top,bottom:t.bottom}):a.search("light")>-1&&(n.lightInfo={color:t.color,intensity:t.intensity,decay:t.decay,distance:t.distance,angle:t.angle,penumbra:t.penumbra,groundColor:t.groundColor});return n}function te(t,n,a){const e=n.split(".");switch(e.length){case 1:t[e[0]]=a;break;case 2:t[e[0]][e[1]]=a;break;case 3:t[e[0]][e[1]][e[2]]=a;break;case 4:t[e[0]][e[1]][e[2]][e[3]]=a;break;case 5:t[e[0]][e[1]][e[2]][e[3]][e[4]]=a;break}}function Pt(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const r=new u.Texture(e);r.wrapS=u.RepeatWrapping,r.wrapT=u.RepeatWrapping,r.needsUpdate=!0,n(r)},e.onerror=a,e.src=t})}class Qt extends Ze{constructor(){super(...arguments);F(this,"scene")}getObject(a){this.app.debugEnabled&&this.app.send({event:"getObject",target:"app",data:a})}setObject(a){const e=Rt(a);this.app.send({event:"setObject",target:"editor",data:e})}requestMethod(a,e,r){this.app.send({event:"requestMethod",target:"app",data:{uuid:a,key:e,value:r}})}updateObject(a,e,r){this.app.send({event:"updateObject",target:"app",data:{uuid:a,key:e,value:r}})}createTexture(a,e,r){this.app.send({event:"createTexture",target:"app",data:{uuid:a,key:e,value:r}})}setScene(a){if(a===void 0||(this.scene=a,!this.app.debugEnabled))return;Yt(),Tt(this.scene);const e=Zt(this.scene);this.app.send({event:"setScene",target:"editor",data:e})}addCamera(a){if(!this.app.debugEnabled)return;const e=Rt(a);this.app.send({event:"addCamera",target:"editor",data:e})}removeCamera(a){if(!this.app.debugEnabled)return;const e=Rt(a);this.app.send({event:"removeCamera",target:"editor",data:e})}}function Fn(t,n){switch(n.event){case"getObject":D.dispatchEvent({type:A.GET_OBJECT,value:n.data});break;case"updateObject":D.dispatchEvent({type:A.UPDATE_OBJECT,value:n.data});break;case"createTexture":D.dispatchEvent({type:A.CREATE_TEXTURE,value:n.data});break;case"requestMethod":D.dispatchEvent({type:A.REQUEST_METHOD,value:n.data});break}}function Vn(t,n){switch(n.event){case"setObject":D.dispatchEvent({type:A.SET_OBJECT,value:n.data});break;case"setScene":D.dispatchEvent({type:A.SET_SCENE,value:n.data});break;case"addCamera":D.dispatchEvent({type:A.ADD_CAMERA,value:n.data});break;case"removeCamera":D.dispatchEvent({type:A.REMOVE_CAMERA,value:n.data});break}}class jt extends Ze{constructor(a){super(a);F(this,"bindCBs");F(this,"buttonCBs");F(this,"pane");F(this,"appCallbacks",0);F(this,"editorCallbacks",0);F(this,"inspectorFolder");this.bindCBs=new Map,this.buttonCBs=new Map,a.editor&&this.createGUI()}createGUI(){this.pane=new On.Pane({title:"GUI"}),this.pane.registerPlugin(Mn)}dispose(){var a;this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&((a=this.pane)==null||a.dispose(),this.pane=void 0)}addFolder(a,e=void 0,r=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addFolder({title:a,...e});this.app.send({event:"addFolder",target:"app",data:{name:a,params:e,parent:r}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(a,e,r,s=void 0){const d=this.bindID,l=r.onChange!==void 0?r.onChange:Xt;this.bindCBs.set(d,l),this.app.editor?(this.pane===void 0&&this.createGUI(),(s!==void 0?s:this.pane).addBinding(a,e,r).on("change",m=>{this.app.send({event:"updateBind",target:"app",data:{id:d,value:m.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:d,name:e,params:r,parent:s}}),this.appCallbacks++)}triggerBind(a,e){const r=this.bindCBs.get(a);r!==void 0?r(e):console.warn(`No callback for: ${a}`,e)}button(a,e,r=void 0){const s=this.bindID;this.buttonCBs.set(s,e),this.app.editor?(this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addButton({title:a}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:s}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:s,name:a,callback:e,parent:r}}),this.appCallbacks++)}triggerButton(a){const e=this.buttonCBs.get(a);e!==void 0&&e()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const a=this.inspectorFolder.children.length-1;for(let e=a;e>-1;--e)this.inspectorFolder.remove(this.inspectorFolder.children[e])}}function Bn(t,n){t.components.forEach(a=>{if(a instanceof jt){const e=a;switch(n.event){case"addFolder":e.addFolder(n.data.name,n.data.params,n.data.parent);break;case"bindObject":e.bind(n.data.name,n.data.params,n.data.parent);break;case"updateBind":e.triggerBind(n.data.id,n.data.value);break;case"addButton":e.button(n.data.name,n.data.callback,n.data.parent);break;case"clickButton":e.triggerButton(n.data.id);break}return}})}var _t={exports:{}},Je={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var qt;function Gn(){if(qt)return Je;qt=1;var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function d(l,f,m){var b,C={},x=null,O=null;m!==void 0&&(x=""+m),f.key!==void 0&&(x=""+f.key),f.ref!==void 0&&(O=f.ref);for(b in f)e.call(f,b)&&!s.hasOwnProperty(b)&&(C[b]=f[b]);if(l&&l.defaultProps)for(b in f=l.defaultProps,f)C[b]===void 0&&(C[b]=f[b]);return{$$typeof:n,type:l,key:x,ref:O,props:C,_owner:r.current}}return Je.Fragment=a,Je.jsx=d,Je.jsxs=d,Je}var Qe={};/**
9
+ */var qt;function Hn(){if(qt)return Je;qt=1;var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function d(l,f,m){var b,S={},O=null,x=null;m!==void 0&&(O=""+m),f.key!==void 0&&(O=""+f.key),f.ref!==void 0&&(x=f.ref);for(b in f)e.call(f,b)&&!s.hasOwnProperty(b)&&(S[b]=f[b]);if(l&&l.defaultProps)for(b in f=l.defaultProps,f)S[b]===void 0&&(S[b]=f[b]);return{$$typeof:n,type:l,key:O,ref:x,props:S,_owner:r.current}}return Je.Fragment=a,Je.jsx=d,Je.jsxs=d,Je}var Qe={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,19 +14,19 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var $t;function Hn(){return $t||($t=1,process.env.NODE_ENV!=="production"&&function(){var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),l=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),j=Symbol.iterator,K="@@iterator";function ce(i){if(i===null||typeof i!="object")return null;var p=j&&i[j]||i[K];return typeof p=="function"?p:null}var J=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(i){{for(var p=arguments.length,v=new Array(p>1?p-1:0),S=1;S<p;S++)v[S-1]=arguments[S];Q("error",i,v)}}function Q(i,p,v){{var S=J.ReactDebugCurrentFrame,I=S.getStackAddendum();I!==""&&(p+="%s",v=v.concat([I]));var V=v.map(function(k){return String(k)});V.unshift("Warning: "+p),Function.prototype.apply.call(console[i],console,V)}}var fe=!1,ue=!1,ae=!1,h=!1,g=!1,y;y=Symbol.for("react.module.reference");function M(i){return!!(typeof i=="string"||typeof i=="function"||i===e||i===s||g||i===r||i===m||i===b||h||i===O||fe||ue||ae||typeof i=="object"&&i!==null&&(i.$$typeof===x||i.$$typeof===C||i.$$typeof===d||i.$$typeof===l||i.$$typeof===f||i.$$typeof===y||i.getModuleId!==void 0))}function H(i,p,v){var S=i.displayName;if(S)return S;var I=p.displayName||p.name||"";return I!==""?v+"("+I+")":v}function z(i){return i.displayName||"Context"}function B(i){if(i==null)return null;if(typeof i.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case e:return"Fragment";case a:return"Portal";case s:return"Profiler";case r:return"StrictMode";case m:return"Suspense";case b:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case l:var p=i;return z(p)+".Consumer";case d:var v=i;return z(v._context)+".Provider";case f:return H(i,i.render,"ForwardRef");case C:var S=i.displayName||null;return S!==null?S:B(i.type)||"Memo";case x:{var I=i,V=I._payload,k=I._init;try{return B(k(V))}catch{return null}}}return null}var L=Object.assign,G=0,ee,_,U,q,me,Ie,tt;function mt(){}mt.__reactDisabledLog=!0;function Nt(){{if(G===0){ee=console.log,_=console.info,U=console.warn,q=console.error,me=console.group,Ie=console.groupCollapsed,tt=console.groupEnd;var i={configurable:!0,enumerable:!0,value:mt,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}G++}}function Lt(){{if(G--,G===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},i,{value:ee}),info:L({},i,{value:_}),warn:L({},i,{value:U}),error:L({},i,{value:q}),group:L({},i,{value:me}),groupCollapsed:L({},i,{value:Ie}),groupEnd:L({},i,{value:tt})})}G<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var nt=J.ReactCurrentDispatcher,at;function Ne(i,p,v){{if(at===void 0)try{throw Error()}catch(I){var S=I.stack.trim().match(/\n( *(at )?)/);at=S&&S[1]||""}return`
18
- `+at+i}}var He=!1,Le;{var Ut=typeof WeakMap=="function"?WeakMap:Map;Le=new Ut}function gt(i,p){if(!i||He)return"";{var v=Le.get(i);if(v!==void 0)return v}var S;He=!0;var I=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var V;V=nt.current,nt.current=null,Nt();try{if(p){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(Ce){S=Ce}Reflect.construct(i,[],k)}else{try{k.call()}catch(Ce){S=Ce}i.call(k.prototype)}}else{try{throw Error()}catch(Ce){S=Ce}i()}}catch(Ce){if(Ce&&S&&typeof Ce.stack=="string"){for(var P=Ce.stack.split(`
19
- `),le=S.stack.split(`
20
- `),X=P.length-1,$=le.length-1;X>=1&&$>=0&&P[X]!==le[$];)$--;for(;X>=1&&$>=0;X--,$--)if(P[X]!==le[$]){if(X!==1||$!==1)do if(X--,$--,$<0||P[X]!==le[$]){var ge=`
21
- `+P[X].replace(" at new "," at ");return i.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",i.displayName)),typeof i=="function"&&Le.set(i,ge),ge}while(X>=1&&$>=0);break}}}finally{He=!1,nt.current=V,Lt(),Error.prepareStackTrace=I}var Ke=i?i.displayName||i.name:"",Sn=Ke?Ne(Ke):"";return typeof i=="function"&&Le.set(i,Sn),Sn}function vt(i,p,v){return gt(i,!1)}function bt(i){var p=i.prototype;return!!(p&&p.isReactComponent)}function Ue(i,p,v){if(i==null)return"";if(typeof i=="function")return gt(i,bt(i));if(typeof i=="string")return Ne(i);switch(i){case m:return Ne("Suspense");case b:return Ne("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case f:return vt(i.render);case C:return Ue(i.type,p,v);case x:{var S=i,I=S._payload,V=S._init;try{return Ue(V(I),p,v)}catch{}}}return""}var ze=Object.prototype.hasOwnProperty,yt={},it=J.ReactDebugCurrentFrame;function Te(i){if(i){var p=i._owner,v=Ue(i.type,i._source,p?p.type:null);it.setExtraStackFrame(v)}else it.setExtraStackFrame(null)}function Fe(i,p,v,S,I){{var V=Function.call.bind(ze);for(var k in i)if(V(i,k)){var P=void 0;try{if(typeof i[k]!="function"){var le=Error((S||"React class")+": "+v+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}P=i[k](p,k,S,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(X){P=X}P&&!(P instanceof Error)&&(Te(I),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",S||"React class",v,k,typeof P),Te(null)),P instanceof Error&&!(P.message in yt)&&(yt[P.message]=!0,Te(I),T("Failed %s type: %s",v,P.message),Te(null))}}}var Ft=Array.isArray;function rt(i){return Ft(i)}function Et(i){{var p=typeof Symbol=="function"&&Symbol.toStringTag,v=p&&i[Symbol.toStringTag]||i.constructor.name||"Object";return v}}function ot(i){try{return wt(i),!1}catch{return!0}}function wt(i){return""+i}function Ct(i){if(ot(i))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Et(i)),wt(i)}var Me=J.ReactCurrentOwner,Vt={key:!0,ref:!0,__self:!0,__source:!0},St,st,ve;ve={};function o(i){if(ze.call(i,"ref")){var p=Object.getOwnPropertyDescriptor(i,"ref").get;if(p&&p.isReactWarning)return!1}return i.ref!==void 0}function E(i){if(ze.call(i,"key")){var p=Object.getOwnPropertyDescriptor(i,"key").get;if(p&&p.isReactWarning)return!1}return i.key!==void 0}function N(i,p){if(typeof i.ref=="string"&&Me.current&&p&&Me.current.stateNode!==p){var v=B(Me.current.type);ve[v]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',B(Me.current.type),i.ref),ve[v]=!0)}}function F(i,p){{var v=function(){St||(St=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"key",{get:v,configurable:!0})}}function ie(i,p){{var v=function(){st||(st=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"ref",{get:v,configurable:!0})}}var be=function(i,p,v,S,I,V,k){var P={$$typeof:n,type:i,key:p,ref:v,props:k,_owner:V};return P._store={},Object.defineProperty(P._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(P,"_self",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.defineProperty(P,"_source",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.freeze&&(Object.freeze(P.props),Object.freeze(P)),P};function de(i,p,v,S,I){{var V,k={},P=null,le=null;v!==void 0&&(Ct(v),P=""+v),E(p)&&(Ct(p.key),P=""+p.key),o(p)&&(le=p.ref,N(p,I));for(V in p)ze.call(p,V)&&!Vt.hasOwnProperty(V)&&(k[V]=p[V]);if(i&&i.defaultProps){var X=i.defaultProps;for(V in X)k[V]===void 0&&(k[V]=X[V])}if(P||le){var $=typeof i=="function"?i.displayName||i.name||"Unknown":i;P&&F(k,$),le&&ie(k,$)}return be(i,P,le,I,S,Me.current,k)}}var xt=J.ReactCurrentOwner,Ot=J.ReactDebugCurrentFrame;function we(i){if(i){var p=i._owner,v=Ue(i.type,i._source,p?p.type:null);Ot.setExtraStackFrame(v)}else Ot.setExtraStackFrame(null)}var he;he=!1;function pe(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function Ye(){{if(xt.current){var i=B(xt.current.type);if(i)return`
17
+ */var $t;function Gn(){return $t||($t=1,process.env.NODE_ENV!=="production"&&function(){var t=R,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),l=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),j=Symbol.iterator,X="@@iterator";function ce(i){if(i===null||typeof i!="object")return null;var p=j&&i[j]||i[X];return typeof p=="function"?p:null}var J=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(i){{for(var p=arguments.length,v=new Array(p>1?p-1:0),C=1;C<p;C++)v[C-1]=arguments[C];Q("error",i,v)}}function Q(i,p,v){{var C=J.ReactDebugCurrentFrame,I=C.getStackAddendum();I!==""&&(p+="%s",v=v.concat([I]));var B=v.map(function(k){return String(k)});B.unshift("Warning: "+p),Function.prototype.apply.call(console[i],console,B)}}var fe=!1,ue=!1,ae=!1,h=!1,g=!1,y;y=Symbol.for("react.module.reference");function M(i){return!!(typeof i=="string"||typeof i=="function"||i===e||i===s||g||i===r||i===m||i===b||h||i===x||fe||ue||ae||typeof i=="object"&&i!==null&&(i.$$typeof===O||i.$$typeof===S||i.$$typeof===d||i.$$typeof===l||i.$$typeof===f||i.$$typeof===y||i.getModuleId!==void 0))}function z(i,p,v){var C=i.displayName;if(C)return C;var I=p.displayName||p.name||"";return I!==""?v+"("+I+")":v}function Y(i){return i.displayName||"Context"}function H(i){if(i==null)return null;if(typeof i.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case e:return"Fragment";case a:return"Portal";case s:return"Profiler";case r:return"StrictMode";case m:return"Suspense";case b:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case l:var p=i;return Y(p)+".Consumer";case d:var v=i;return Y(v._context)+".Provider";case f:return z(i,i.render,"ForwardRef");case S:var C=i.displayName||null;return C!==null?C:H(i.type)||"Memo";case O:{var I=i,B=I._payload,k=I._init;try{return H(k(B))}catch{return null}}}return null}var N=Object.assign,G=0,ee,_,U,q,me,Ie,tt;function mt(){}mt.__reactDisabledLog=!0;function Lt(){{if(G===0){ee=console.log,_=console.info,U=console.warn,q=console.error,me=console.group,Ie=console.groupCollapsed,tt=console.groupEnd;var i={configurable:!0,enumerable:!0,value:mt,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}G++}}function Nt(){{if(G--,G===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},i,{value:ee}),info:N({},i,{value:_}),warn:N({},i,{value:U}),error:N({},i,{value:q}),group:N({},i,{value:me}),groupCollapsed:N({},i,{value:Ie}),groupEnd:N({},i,{value:tt})})}G<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var nt=J.ReactCurrentDispatcher,at;function Le(i,p,v){{if(at===void 0)try{throw Error()}catch(I){var C=I.stack.trim().match(/\n( *(at )?)/);at=C&&C[1]||""}return`
18
+ `+at+i}}var Ge=!1,Ne;{var Ut=typeof WeakMap=="function"?WeakMap:Map;Ne=new Ut}function gt(i,p){if(!i||Ge)return"";{var v=Ne.get(i);if(v!==void 0)return v}var C;Ge=!0;var I=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var B;B=nt.current,nt.current=null,Lt();try{if(p){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(Se){C=Se}Reflect.construct(i,[],k)}else{try{k.call()}catch(Se){C=Se}i.call(k.prototype)}}else{try{throw Error()}catch(Se){C=Se}i()}}catch(Se){if(Se&&C&&typeof Se.stack=="string"){for(var P=Se.stack.split(`
19
+ `),le=C.stack.split(`
20
+ `),Z=P.length-1,$=le.length-1;Z>=1&&$>=0&&P[Z]!==le[$];)$--;for(;Z>=1&&$>=0;Z--,$--)if(P[Z]!==le[$]){if(Z!==1||$!==1)do if(Z--,$--,$<0||P[Z]!==le[$]){var ge=`
21
+ `+P[Z].replace(" at new "," at ");return i.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",i.displayName)),typeof i=="function"&&Ne.set(i,ge),ge}while(Z>=1&&$>=0);break}}}finally{Ge=!1,nt.current=B,Nt(),Error.prepareStackTrace=I}var Ke=i?i.displayName||i.name:"",Cn=Ke?Le(Ke):"";return typeof i=="function"&&Ne.set(i,Cn),Cn}function vt(i,p,v){return gt(i,!1)}function bt(i){var p=i.prototype;return!!(p&&p.isReactComponent)}function Ue(i,p,v){if(i==null)return"";if(typeof i=="function")return gt(i,bt(i));if(typeof i=="string")return Le(i);switch(i){case m:return Le("Suspense");case b:return Le("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case f:return vt(i.render);case S:return Ue(i.type,p,v);case O:{var C=i,I=C._payload,B=C._init;try{return Ue(B(I),p,v)}catch{}}}return""}var ze=Object.prototype.hasOwnProperty,yt={},it=J.ReactDebugCurrentFrame;function Te(i){if(i){var p=i._owner,v=Ue(i.type,i._source,p?p.type:null);it.setExtraStackFrame(v)}else it.setExtraStackFrame(null)}function Fe(i,p,v,C,I){{var B=Function.call.bind(ze);for(var k in i)if(B(i,k)){var P=void 0;try{if(typeof i[k]!="function"){var le=Error((C||"React class")+": "+v+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw le.name="Invariant Violation",le}P=i[k](p,k,C,v,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Z){P=Z}P&&!(P instanceof Error)&&(Te(I),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",C||"React class",v,k,typeof P),Te(null)),P instanceof Error&&!(P.message in yt)&&(yt[P.message]=!0,Te(I),T("Failed %s type: %s",v,P.message),Te(null))}}}var Ft=Array.isArray;function rt(i){return Ft(i)}function Et(i){{var p=typeof Symbol=="function"&&Symbol.toStringTag,v=p&&i[Symbol.toStringTag]||i.constructor.name||"Object";return v}}function ot(i){try{return wt(i),!1}catch{return!0}}function wt(i){return""+i}function St(i){if(ot(i))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Et(i)),wt(i)}var Me=J.ReactCurrentOwner,Vt={key:!0,ref:!0,__self:!0,__source:!0},Ct,st,ve;ve={};function o(i){if(ze.call(i,"ref")){var p=Object.getOwnPropertyDescriptor(i,"ref").get;if(p&&p.isReactWarning)return!1}return i.ref!==void 0}function E(i){if(ze.call(i,"key")){var p=Object.getOwnPropertyDescriptor(i,"key").get;if(p&&p.isReactWarning)return!1}return i.key!==void 0}function L(i,p){if(typeof i.ref=="string"&&Me.current&&p&&Me.current.stateNode!==p){var v=H(Me.current.type);ve[v]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',H(Me.current.type),i.ref),ve[v]=!0)}}function V(i,p){{var v=function(){Ct||(Ct=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"key",{get:v,configurable:!0})}}function ie(i,p){{var v=function(){st||(st=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",p))};v.isReactWarning=!0,Object.defineProperty(i,"ref",{get:v,configurable:!0})}}var be=function(i,p,v,C,I,B,k){var P={$$typeof:n,type:i,key:p,ref:v,props:k,_owner:B};return P._store={},Object.defineProperty(P._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(P,"_self",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.defineProperty(P,"_source",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.freeze&&(Object.freeze(P.props),Object.freeze(P)),P};function de(i,p,v,C,I){{var B,k={},P=null,le=null;v!==void 0&&(St(v),P=""+v),E(p)&&(St(p.key),P=""+p.key),o(p)&&(le=p.ref,L(p,I));for(B in p)ze.call(p,B)&&!Vt.hasOwnProperty(B)&&(k[B]=p[B]);if(i&&i.defaultProps){var Z=i.defaultProps;for(B in Z)k[B]===void 0&&(k[B]=Z[B])}if(P||le){var $=typeof i=="function"?i.displayName||i.name||"Unknown":i;P&&V(k,$),le&&ie(k,$)}return be(i,P,le,I,C,Me.current,k)}}var Ot=J.ReactCurrentOwner,xt=J.ReactDebugCurrentFrame;function we(i){if(i){var p=i._owner,v=Ue(i.type,i._source,p?p.type:null);xt.setExtraStackFrame(v)}else xt.setExtraStackFrame(null)}var he;he=!1;function pe(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function Ye(){{if(Ot.current){var i=H(Ot.current.type);if(i)return`
22
22
 
23
23
  Check the render method of \``+i+"`."}return""}}function Ve(i){{if(i!==void 0){var p=i.fileName.replace(/^.*[\\\/]/,""),v=i.lineNumber;return`
24
24
 
25
25
  Check your code at `+p+":"+v+"."}return""}}var Re={};function We(i){{var p=Ye();if(!p){var v=typeof i=="string"?i:i.displayName||i.name;v&&(p=`
26
26
 
27
- Check the top-level render call using <`+v+">.")}return p}}function En(i,p){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var v=We(p);if(Re[v])return;Re[v]=!0;var S="";i&&i._owner&&i._owner!==xt.current&&(S=" It was passed a child from "+B(i._owner.type)+"."),we(i),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,S),we(null)}}function wn(i,p){{if(typeof i!="object")return;if(rt(i))for(var v=0;v<i.length;v++){var S=i[v];pe(S)&&En(S,p)}else if(pe(i))i._store&&(i._store.validated=!0);else if(i){var I=ce(i);if(typeof I=="function"&&I!==i.entries)for(var V=I.call(i),k;!(k=V.next()).done;)pe(k.value)&&En(k.value,p)}}}function Ca(i){{var p=i.type;if(p==null||typeof p=="string")return;var v;if(typeof p=="function")v=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===f||p.$$typeof===C))v=p.propTypes;else return;if(v){var S=B(p);Fe(v,i.props,"prop",S,i)}else if(p.PropTypes!==void 0&&!he){he=!0;var I=B(p);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Sa(i){{for(var p=Object.keys(i.props),v=0;v<p.length;v++){var S=p[v];if(S!=="children"&&S!=="key"){we(i),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",S),we(null);break}}i.ref!==null&&(we(i),T("Invalid attribute `ref` supplied to `React.Fragment`."),we(null))}}function Cn(i,p,v,S,I,V){{var k=M(i);if(!k){var P="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(P+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=Ve(I);le?P+=le:P+=Ye();var X;i===null?X="null":rt(i)?X="array":i!==void 0&&i.$$typeof===n?(X="<"+(B(i.type)||"Unknown")+" />",P=" Did you accidentally export a JSX literal instead of a component?"):X=typeof i,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",X,P)}var $=de(i,p,v,I,V);if($==null)return $;if(k){var ge=p.children;if(ge!==void 0)if(S)if(rt(ge)){for(var Ke=0;Ke<ge.length;Ke++)wn(ge[Ke],i);Object.freeze&&Object.freeze(ge)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else wn(ge,i)}return i===e?Sa($):Ca($),$}}function xa(i,p,v){return Cn(i,p,v,!0)}function Oa(i,p,v){return Cn(i,p,v,!1)}var Ta=Oa,Ma=xa;Qe.Fragment=e,Qe.jsx=Ta,Qe.jsxs=Ma}()),Qe}process.env.NODE_ENV==="production"?_t.exports=Gn():_t.exports=Hn();var c=_t.exports;function kt(t){return t.title.search("<")>-1?c.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):c.jsx("button",{children:t.title})}const zn=c.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[c.jsx("circle",{cx:"7",cy:"7",r:"6"}),c.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),c.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Yn=c.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:c.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
27
+ Check the top-level render call using <`+v+">.")}return p}}function En(i,p){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var v=We(p);if(Re[v])return;Re[v]=!0;var C="";i&&i._owner&&i._owner!==Ot.current&&(C=" It was passed a child from "+H(i._owner.type)+"."),we(i),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',v,C),we(null)}}function wn(i,p){{if(typeof i!="object")return;if(rt(i))for(var v=0;v<i.length;v++){var C=i[v];pe(C)&&En(C,p)}else if(pe(i))i._store&&(i._store.validated=!0);else if(i){var I=ce(i);if(typeof I=="function"&&I!==i.entries)for(var B=I.call(i),k;!(k=B.next()).done;)pe(k.value)&&En(k.value,p)}}}function Sa(i){{var p=i.type;if(p==null||typeof p=="string")return;var v;if(typeof p=="function")v=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===f||p.$$typeof===S))v=p.propTypes;else return;if(v){var C=H(p);Fe(v,i.props,"prop",C,i)}else if(p.PropTypes!==void 0&&!he){he=!0;var I=H(p);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ca(i){{for(var p=Object.keys(i.props),v=0;v<p.length;v++){var C=p[v];if(C!=="children"&&C!=="key"){we(i),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",C),we(null);break}}i.ref!==null&&(we(i),T("Invalid attribute `ref` supplied to `React.Fragment`."),we(null))}}function Sn(i,p,v,C,I,B){{var k=M(i);if(!k){var P="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(P+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var le=Ve(I);le?P+=le:P+=Ye();var Z;i===null?Z="null":rt(i)?Z="array":i!==void 0&&i.$$typeof===n?(Z="<"+(H(i.type)||"Unknown")+" />",P=" Did you accidentally export a JSX literal instead of a component?"):Z=typeof i,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Z,P)}var $=de(i,p,v,I,B);if($==null)return $;if(k){var ge=p.children;if(ge!==void 0)if(C)if(rt(ge)){for(var Ke=0;Ke<ge.length;Ke++)wn(ge[Ke],i);Object.freeze&&Object.freeze(ge)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else wn(ge,i)}return i===e?Ca($):Sa($),$}}function Oa(i,p,v){return Sn(i,p,v,!0)}function xa(i,p,v){return Sn(i,p,v,!1)}var Ta=xa,Ma=Oa;Qe.Fragment=e,Qe.jsx=Ta,Qe.jsxs=Ma}()),Qe}process.env.NODE_ENV==="production"?_t.exports=Hn():_t.exports=Gn();var c=_t.exports;function kt(t){return t.title.search("<")>-1?c.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):c.jsx("button",{children:t.title})}const zn=c.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[c.jsx("circle",{cx:"7",cy:"7",r:"6"}),c.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),c.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Yn=c.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:c.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1
28
28
  C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1
29
- C11,8.22,10.74,8,10.43,8z`})});function en(t){return c.jsx(Bt.Reorder.Item,{value:t.title,children:c.jsxs("div",{children:[Yn,c.jsx("span",{children:t.title}),c.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:zn})]})},t.title)}function tn(t){const[n,a]=R.useState(!1),[e,r]=R.useState(t.options),s=m=>{t.onDragComplete(m),r(m)},d=m=>{const b=[...e];b.splice(m,1),s(b)},l=[];e.forEach((m,b)=>{l.push(c.jsx(en,{index:b,title:m,onDelete:d},m))});let f="dropdown draggable";return t.subdropdown&&(f+=" subdropdown"),c.jsxs("div",{className:f,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(kt,{title:t.title}),c.jsx(Bt.Reorder.Group,{axis:"y",values:e,onReorder:s,style:{visibility:n?"visible":"hidden"},children:l})]})}function nn(t){const[n,a]=R.useState(!1),e=[];t.options.map((s,d)=>{t.onSelect!==void 0&&(s.onSelect=t.onSelect),e.push(c.jsx(an,{option:s},d))});let r="dropdown";return t.subdropdown&&(r+=" subdropdown"),c.jsxs("div",{className:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(kt,{title:t.title}),c.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function an(t){const{option:n}=t,[a,e]=R.useState("");let r;switch(n.type){case"draggable":r=c.jsx(tn,{title:n.title,options:n.value,onDragComplete:s=>{n.onDragComplete!==void 0&&n.onDragComplete(s)},subdropdown:!0});break;case"dropdown":r=c.jsx(nn,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":r=c.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(a!==n.title?e(n.title):e(""))},children:n.title});break}return c.jsx("li",{className:a===n.title?"selected":"",children:r},Gt())}function Wn(t){const n=[],a=[];t.components.forEach(s=>{s instanceof Kt?n.push(kn):s instanceof xe?(n.push(Dn),a.push(In),An(t)):s instanceof Qt?(n.push(Fn),a.push(Vn)):s instanceof jt&&n.push(Bn)});function e(s){switch(n.forEach(d=>d(t,s)),s.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:s.data});break}}function r(s){switch(a.forEach(d=>d(t,s)),s.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:s.data});break}}t.listen(s=>{t.editor?r(s):e(s)})}const Kn=`out vec3 worldPosition;
29
+ C11,8.22,10.74,8,10.43,8z`})});function en(t){return c.jsx(Bt.Reorder.Item,{value:t.title,children:c.jsxs("div",{children:[Yn,c.jsx("span",{children:t.title}),c.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:zn})]})},t.title)}function tn(t){const[n,a]=R.useState(!1),[e,r]=R.useState(t.options),s=m=>{t.onDragComplete(m),r(m)},d=m=>{const b=[...e];b.splice(m,1),s(b)},l=[];e.forEach((m,b)=>{l.push(c.jsx(en,{index:b,title:m,onDelete:d},m))});let f="dropdown draggable";return t.subdropdown&&(f+=" subdropdown"),c.jsxs("div",{className:f,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(kt,{title:t.title}),c.jsx(Bt.Reorder.Group,{axis:"y",values:e,onReorder:s,style:{visibility:n?"visible":"hidden"},children:l})]})}function nn(t){const[n,a]=R.useState(!1),e=[];t.options.map((s,d)=>{t.onSelect!==void 0&&(s.onSelect=t.onSelect),e.push(c.jsx(an,{option:s},d))});let r="dropdown";return t.subdropdown&&(r+=" subdropdown"),c.jsxs("div",{className:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[c.jsx(kt,{title:t.title}),c.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function an(t){const{option:n}=t,[a,e]=R.useState("");let r;switch(n.type){case"draggable":r=c.jsx(tn,{title:n.title,options:n.value,onDragComplete:s=>{n.onDragComplete!==void 0&&n.onDragComplete(s)},subdropdown:!0});break;case"dropdown":r=c.jsx(nn,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":r=c.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(a!==n.title?e(n.title):e(""))},children:n.title});break}return c.jsx("li",{className:a===n.title?"selected":"",children:r},Ht())}function Wn(t){const n=[],a=[];t.components.forEach(s=>{s instanceof Kt?n.push(kn):s instanceof Oe?(n.push(Dn),a.push(In),An(t)):s instanceof Qt?(n.push(Fn),a.push(Vn)):s instanceof jt&&n.push(Bn)});function e(s){switch(n.forEach(d=>d(t,s)),s.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:s.data});break}}function r(s){switch(a.forEach(d=>d(t,s)),s.event){case"custom":D.dispatchEvent({type:A.CUSTOM,value:s.data});break}}t.listen=s=>{s.target==="editor"?r(s):e(s)}}const Kn=`out vec3 worldPosition;
30
30
  uniform float uDistance;
31
31
 
32
32
  void main() {
@@ -102,7 +102,7 @@ void main() {
102
102
  fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
103
103
 
104
104
  if (fragColor.a <= 0.0) discard;
105
- }`;class Zn extends u.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:u.GLSL3,side:u.DoubleSide,transparent:!0,uniforms:{uScale:{value:(n==null?void 0:n.scale)!==void 0?n==null?void 0:n.scale:.1},uDivisions:{value:(n==null?void 0:n.divisions)!==void 0?n==null?void 0:n.divisions:10},uColor:{value:(n==null?void 0:n.color)!==void 0?n==null?void 0:n.color:new u.Color(16777215)},uDistance:{value:(n==null?void 0:n.distance)!==void 0?n==null?void 0:n.distance:1e4},uSubgridOpacity:{value:(n==null?void 0:n.subgridOpacity)!==void 0?n==null?void 0:n.subgridOpacity:.15},uGridOpacity:{value:(n==null?void 0:n.gridOpacity)!==void 0?n==null?void 0:n.gridOpacity:.25}},vertexShader:Kn,fragmentShader:Xn,name:"InfiniteGrid",depthWrite:!1})}}class rn extends u.Mesh{constructor(){const a=new Zn;super(new u.PlaneGeometry(2,2),a);Z(this,"gridMaterial");this.gridMaterial=a,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const Jn=`#include <common>
105
+ }`;class Zn extends u.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:u.GLSL3,side:u.DoubleSide,transparent:!0,uniforms:{uScale:{value:(n==null?void 0:n.scale)!==void 0?n==null?void 0:n.scale:.1},uDivisions:{value:(n==null?void 0:n.divisions)!==void 0?n==null?void 0:n.divisions:10},uColor:{value:(n==null?void 0:n.color)!==void 0?n==null?void 0:n.color:new u.Color(16777215)},uDistance:{value:(n==null?void 0:n.distance)!==void 0?n==null?void 0:n.distance:1e4},uSubgridOpacity:{value:(n==null?void 0:n.subgridOpacity)!==void 0?n==null?void 0:n.subgridOpacity:.15},uGridOpacity:{value:(n==null?void 0:n.gridOpacity)!==void 0?n==null?void 0:n.gridOpacity:.25}},vertexShader:Kn,fragmentShader:Xn,name:"InfiniteGrid",depthWrite:!1})}}class rn extends u.Mesh{constructor(){const a=new Zn;super(new u.PlaneGeometry(2,2),a);F(this,"gridMaterial");this.gridMaterial=a,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const Jn=`#include <common>
106
106
  #include <batching_pars_vertex>
107
107
  #include <uv_pars_vertex>
108
108
  #include <color_pars_vertex>
@@ -140,5 +140,5 @@ void main() {
140
140
  void main() {
141
141
  #include <clipping_planes_fragment>
142
142
  gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
143
- }`;class on extends u.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Jn,fragmentShader:Qn})}}const ja="";function lt(t){const[n,a]=R.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return c.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[c.jsxs("button",{className:"toggle",onClick:()=>{const r=!n;t.onToggle!==void 0&&t.onToggle(r),a(r)},children:[c.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),c.jsx("p",{className:"label",children:t.label})]}),t.button,c.jsx("div",{className:n?"open":"",children:c.jsx("div",{children:t.children})})]})}function Dt(t){const[n,a]=R.useState(!1),e=t.child.children.length>0,r=[];return t.child.children.length>0&&t.child.children.map(s=>{r.push(c.jsx(Dt,{child:s,three:t.three},Math.random()))}),c.jsxs("div",{className:"childObject",children:[c.jsxs("div",{className:"child",children:[e?c.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,c.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.three.getObject(t.child.uuid)},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),c.jsx("div",{className:`icon ${Nn(t.child)}`})]}),c.jsx("div",{className:n?"open":"",children:c.jsx("div",{className:"container",children:r})})]},Math.random())}function sn(t){const n=[];return t.child.children.map(a=>{n.push(c.jsx(Dt,{child:a,three:t.three},Math.random()))}),c.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const _a="",qn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function $n(t){return"items"in t}function Pe(t){const n=[];return t.items.forEach(a=>{$n(a)?n.push(c.jsx(Pe,{title:a.title,items:a.items},Math.random())):n.push(c.jsx(qe,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,onChange:(e,r)=>{a.onChange!==void 0&&a.onChange(e,r)}},Math.random()))}),c.jsx(lt,{label:t.title,open:t.expanded===!0,children:n})}function ea(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="side"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||t.slice(0,5)==="blend"||t.slice(0,4)==="clip"||t.slice(0,7)==="polygon"||t.slice(0,7)==="stencil"||t.slice(0,2)==="is")}function je(t){switch(t){case"alphaMap":return"Alpha Map";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"defines":return"Defines";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return t}function ta(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="bumpScale"||t==="clearcoatRoughness"||t==="displacementBias"||t==="displacementScale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionRatio"||t==="roughness"||t==="sheenRoughness"||t==="thickness"}function na(){const t=document.createElement("input");return t.type="file",new Promise((n,a)=>{t.addEventListener("change",function(){if(t.files===null)a();else{const e=t.files[0],r=new FileReader;r.onload=function(s){n(s.target.result)},r.readAsDataURL(e)}}),t.click()})}function cn(t,n,a){const e=[];for(const r in t){if(!ea(r))continue;const s=typeof t[r],d=t[r];if(s==="boolean"||s==="number"||s==="string"){const l={title:je(r),prop:r,type:s,value:d,min:void 0,max:void 0,onChange:(f,m)=>{var C;a.updateObject(n.uuid,`material.${f}`,m),s==="boolean"&&a.updateObject(n.uuid,"material.needsUpdate",!0);const b=(C=a.scene)==null?void 0:C.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${f}`,m)}};ta(r)&&(l.value=Number(d),l.type="range",l.min=0,l.max=1,l.step=.01),e.push(l)}else if(s==="object")if(d.isColor)e.push({title:je(r),prop:r,type:"color",value:d,onChange:(l,f)=>{var C;const m=new u.Color(f);a.updateObject(n.uuid,`material.${l}`,m);const b=(C=a.scene)==null?void 0:C.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${l}`,m)}});else if(Array.isArray(d)){const l=[];for(const f in d)l.push({title:`${f}`,type:`${typeof d[f]}`,value:d[f],onChange:(m,b)=>{var x;a.updateObject(n.uuid,`material.${r}`,b);const C=(x=a.scene)==null?void 0:x.getObjectByProperty("uuid",n.uuid);C!==void 0&&te(C,`material.${r}`,b)}});e.push({title:je(r),items:l})}else{const l=[];for(const f in d){const m=d[f];switch(typeof m){case"boolean":case"number":case"string":f==="src"?e.push({title:je(r),type:"image",value:m,onChange:(C,x)=>{var j;a.createTexture(n.uuid,`material.${r}`,x);const O=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);O!==void 0&&Pt(x).then(K=>{te(O,`material.${r}`,K),te(O,"material.needsUpdate",!0)})}}):l.push({title:`${je(f)}`,prop:`material.${r}.${f}`,type:`${typeof t[r][f]}`,value:d[f],onChange:(C,x)=>{var j;a.updateObject(n.uuid,`material.${r}.${f}`,x);const O=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);O!==void 0&&te(O,`material.${r}.${f}`,x)}});break;case"object":m.value!==void 0&&m.value.src!==void 0?l.push({title:je(f),type:"image",value:m.value.src,onChange:(C,x)=>{var j;a.createTexture(n.uuid,`material.${r}.${f}.value`,x);const O=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);O!==void 0&&Pt(x).then(K=>{te(O,`material.${r}.${f}.value`,K)})}}):l.push({title:f,type:`${typeof m.value}`,value:m.value,onChange:(C,x)=>{var j;a.updateObject(n.uuid,`material.${r}.${f}.value`,x);const O=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);O!==void 0&&te(O,`material.${r}.${f}.value`,x)}});break}}l.length>0&&e.push({title:je(r),items:l})}else d!==void 0&&console.log("other:",r,s,d)}return e.sort((r,s)=>r.title<s.title?-1:r.title>s.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function aa(t,n){const a=t.material;if(Array.isArray(a)){const e=[],r=a.length;for(let s=0;s<r;s++)e.push(c.jsx(Pe,{title:`Material ${s}`,items:cn(a[s],t,n)},`Material ${s}`));return c.jsx(c.Fragment,{children:e})}else return c.jsx(Pe,{title:"Material",items:cn(a,t,n)})}function qe(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=zt(t.value));const[a,e]=R.useState(n),r=R.useRef(null),s=R.useRef(null),d=R.useRef(null);R.useEffect(()=>{var Q;let b=!1,C=-1,x=0,O=Number(a);const j=fe=>{b=!0,x=O,C=fe.clientX},K=fe=>{if(!b)return;const ue=t.step!==void 0?t.step:1,ae=(fe.clientX-C)*ue;O=Number((x+ae).toFixed(4)),s.current!==null&&(s.current.value=O.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,O)},ce=()=>{b=!1},J=()=>{b=!1},T=t.type==="number";return T&&((Q=r.current)==null||Q.addEventListener("mousedown",j,!1),document.addEventListener("mouseup",ce,!1),document.addEventListener("mousemove",K,!1),document.addEventListener("contextmenu",J,!1)),()=>{var fe;T&&((fe=r.current)==null||fe.removeEventListener("mousedown",j),document.removeEventListener("mouseup",ce),document.removeEventListener("mousemove",K),document.removeEventListener("contextmenu",J))}},[a]);const l=t.type==="string"&&(a.length>100||a.search(`
144
- `)>-1),f=l||t.type==="image",m=b=>{let C=b.target.value;t.type==="boolean"&&(C=b.target.checked),e(C),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,C)};return c.jsxs("div",{className:`field ${f?"block":""}`,children:[t.type!=="button"&&c.jsx("label",{ref:r,children:t.title},"fieldLabel"),t.type==="string"&&!l&&c.jsx("input",{type:"text",disabled:t.disabled,onChange:m,value:a}),t.type==="string"&&l&&c.jsx("textarea",{cols:50,rows:10,disabled:!0,onChange:m,value:a}),t.type==="boolean"&&c.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:m,checked:a}),t.type==="number"&&c.jsx("input",{ref:s,type:"number",value:a,min:t.min,max:t.max,step:t.step,onChange:m}),t.type==="range"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"min"}),c.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:m})]}),t.type==="color"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"color"}),c.jsx("input",{type:"color",value:a,onChange:m})]}),t.type==="button"&&c.jsx("button",{onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&c.jsx("img",{ref:d,onClick:()=>{na().then(b=>{d.current.src=b,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,b)})},src:a.length>0?a:qn})]})}function ln(t){switch(t){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return t}function ia(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:ln(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&(te(d,r,s),d.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:ln(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&(te(d,r,s),d.updateProjectionMatrix())}});return c.jsx(Pe,{title:"Camera",items:a})}const ra=Math.PI/180,oa=180/Math.PI;function Be(t,n,a,e,r){return e+(t-n)*(r-e)/(a-n)}function sa(t){return t*ra}function At(t){return t*oa}function ca(t,n){const a=new u.Matrix4;a.elements=t.matrix;const e=new u.Vector3,r=new u.Euler,s=new u.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),r.setFromRotationMatrix(a),s.setFromMatrixScale(a));const d=(f,m)=>{var C;n.updateObject(t.uuid,f,m);const b=(C=n.scene)==null?void 0:C.getObjectByProperty("uuid",t.uuid);b!==void 0&&te(b,f,m)},l=(f,m)=>{d(f,sa(m))};return c.jsx(Pe,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:d},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:d},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:d},{title:"Rotation X",prop:"rotation.x",type:"number",value:ct(At(r.x)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Y",prop:"rotation.y",type:"number",value:ct(At(r.y)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Z",prop:"rotation.z",type:"number",value:ct(At(r.z)),min:-360,max:360,step:.1,onChange:l},{title:"Scale X",prop:"scale.x",type:"number",value:s.x,step:.01,onChange:d},{title:"Scale Y",prop:"scale.y",type:"number",value:s.y,step:.01,onChange:d},{title:"Scale Z",prop:"scale.z",type:"number",value:s.z,step:.01,onChange:d}]})}function un(t){switch(t){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color"}return t}function la(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const r=t.lightInfo[e];r!==void 0&&(r.isColor!==void 0?a.push({title:un(e),prop:e,type:"color",value:r,onChange:(s,d)=>{var m;const l=new u.Color(d);n.updateObject(t.uuid,s,l);const f=(m=n.scene)==null?void 0:m.getObjectByProperty("uuid",t.uuid);f!==void 0&&te(f,s,l)}}):a.push({title:un(e),prop:e,type:typeof r,value:r,step:typeof r=="number"?.01:void 0,onChange:(s,d)=>{var f;n.updateObject(t.uuid,s,d);const l=(f=n.scene)==null?void 0:f.getObjectByProperty("uuid",t.uuid);l!==void 0&&te(l,s,d)}}))}return c.jsx(Pe,{title:"Light",items:a})}function ua(t,n){const a=[];return t.animations.forEach(e=>{a.push({title:"Name",type:"string",prop:"name",value:e.name,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,r,s)}}),a.push({title:"Duration",type:"number",prop:"duration",value:e.duration,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,r,s)}}),a.push({title:"Blend Mode",type:"number",prop:"blendMode",value:e.blendMode,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,r,s)}})}),c.jsx(Pe,{title:"Animations",items:a})}const dn={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};let re={...dn};function fn(t){const[n,a]=R.useState(-1);R.useEffect(()=>{function r(d){re={...d.value},a(Date.now())}function s(){re={...dn},a(Date.now())}return D.addEventListener(A.SET_SCENE,s),D.addEventListener(A.SET_OBJECT,r),()=>{D.removeEventListener(A.SET_SCENE,s),D.removeEventListener(A.SET_OBJECT,r)}},[]);const e=re.type.toLowerCase();return c.jsx(lt,{label:"Inspector",children:c.jsx("div",{id:"Inspector",className:t.class,children:re.uuid.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsx(qe,{type:"string",title:"Name",prop:"name",value:re.name,disabled:!0}),c.jsx(qe,{type:"string",title:"Type",prop:"type",value:re.type,disabled:!0}),c.jsx(qe,{type:"string",title:"UUID",prop:"uuid",value:re.uuid,disabled:!0}),c.jsx(qe,{type:"boolean",title:"Visible",prop:"visible",value:re.visible,onChange:(r,s)=>{var l;t.three.updateObject(re.uuid,r,s);const d=(l=t.three.scene)==null?void 0:l.getObjectByProperty("uuid",re.uuid);d!==void 0&&te(d,r,s)}})]}),c.jsxs(c.Fragment,{children:[ca(re,t.three),re.animations.length>0?ua(re,t.three):null,e.search("camera")>-1?ia(re,t.three):null,e.search("light")>-1?la(re,t.three):null,e.search("mesh")>-1?aa(re,t.three):null]})]})},n)},"Inspector")}class da extends R.Component{constructor(a){super(a);Z(this,"three");Z(this,"setScene",a=>{this.setState(()=>({scene:a.value}))});this.state={scene:a.scene!==void 0?a.scene:null},this.three=a.three,D.addEventListener(A.SET_SCENE,this.setScene)}componentWillUnmount(){D.removeEventListener(A.SET_SCENE,this.setScene)}render(){var r;const a=this.componentState.scene!==null,e="Hierarchy - "+(a?`${(r=this.componentState.scene)==null?void 0:r.name}`:"No Scene");return c.jsx("div",{id:"SidePanel",children:c.jsxs(c.Fragment,{children:[c.jsx(lt,{label:e,open:!0,children:c.jsx(c.Fragment,{children:a&&c.jsx(sn,{child:this.componentState.scene,three:this.three})})}),c.jsx(fn,{three:this.three})]})},"SidePanel")}get componentState(){return this.state}}function fa(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=l=>{var m;if(!n())return;const f=(m=t.three.scene)==null?void 0:m.getObjectByProperty("uuid",l.value);f!==void 0&&t.three.setObject(f)},e=(l,f,m)=>{var C;if(!n())return;const b=(C=t.three.scene)==null?void 0:C.getObjectByProperty("uuid",l);b!==void 0&&te(b,f,m)},r=l=>{if(!n())return;const f=l.value,{key:m,value:b,uuid:C}=f;e(C,m,b)},s=l=>{if(!n())return;const f=l.value;Pt(f.value).then(m=>{e(f.uuid,f.key,m),e(f.uuid,"material.needsUpdate",!0)})},d=l=>{var x;if(!n())return;const{key:f,uuid:m,value:b}=l.value,C=(x=t.three.scene)==null?void 0:x.getObjectByProperty("uuid",m);if(C!==void 0)try{C[f](b)}catch(O){console.log("Error requesting method:"),console.log(O),console.log(f),console.log(b)}};return R.useEffect(()=>(D.addEventListener(A.GET_OBJECT,a),D.addEventListener(A.UPDATE_OBJECT,r),D.addEventListener(A.CREATE_TEXTURE,s),D.addEventListener(A.REQUEST_METHOD,d),()=>{D.removeEventListener(A.GET_OBJECT,a),D.removeEventListener(A.UPDATE_OBJECT,r),D.removeEventListener(A.CREATE_TEXTURE,s),D.removeEventListener(A.REQUEST_METHOD,d)}),[]),null}const hn={type:"change"},It={type:"start"},pn={type:"end"},ut=new u.Ray,mn=new u.Plane,ha=Math.cos(70*u.MathUtils.DEG2RAD);class pa extends u.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(o){o.addEventListener("keydown",ot),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ot),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(hn),e.update(),s=r.NONE},this.update=function(){const o=new u.Vector3,E=new u.Quaternion().setFromUnitVectors(n.up,new u.Vector3(0,1,0)),N=E.clone().invert(),F=new u.Vector3,ie=new u.Quaternion,be=new u.Vector3,de=2*Math.PI;return function(Ot=null){const we=e.object.position;o.copy(we).sub(e.target),o.applyQuaternion(E),l.setFromVector3(o),e.autoRotate&&s===r.NONE&&H(y(Ot)),e.enableDamping?(l.theta+=f.theta*e.dampingFactor,l.phi+=f.phi*e.dampingFactor):(l.theta+=f.theta,l.phi+=f.phi);let he=e.minAzimuthAngle,pe=e.maxAzimuthAngle;isFinite(he)&&isFinite(pe)&&(he<-Math.PI?he+=de:he>Math.PI&&(he-=de),pe<-Math.PI?pe+=de:pe>Math.PI&&(pe-=de),he<=pe?l.theta=Math.max(he,Math.min(pe,l.theta)):l.theta=l.theta>(he+pe)/2?Math.max(he,l.theta):Math.min(pe,l.theta)),l.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,l.phi)),l.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(b,e.dampingFactor):e.target.add(b),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&ae||e.object.isOrthographicCamera?l.radius=q(l.radius):l.radius=q(l.radius*m),o.setFromSpherical(l),o.applyQuaternion(N),we.copy(e.target).add(o),e.object.lookAt(e.target),e.enableDamping===!0?(f.theta*=1-e.dampingFactor,f.phi*=1-e.dampingFactor,b.multiplyScalar(1-e.dampingFactor)):(f.set(0,0,0),b.set(0,0,0));let Ye=!1;if(e.zoomToCursor&&ae){let Ve=null;if(e.object.isPerspectiveCamera){const Re=o.length();Ve=q(Re*m);const We=Re-Ve;e.object.position.addScaledVector(fe,We),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Re=new u.Vector3(ue.x,ue.y,0);Re.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),Ye=!0;const We=new u.Vector3(ue.x,ue.y,0);We.unproject(e.object),e.object.position.sub(We).add(Re),e.object.updateMatrixWorld(),Ve=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Ve!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Ve).add(e.object.position):(ut.origin.copy(e.object.position),ut.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(ut.direction))<ha?n.lookAt(e.target):(mn.setFromNormalAndCoplanarPoint(e.object.up,e.target),ut.intersectPlane(mn,e.target))))}else e.object.isOrthographicCamera&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),Ye=!0);return m=1,ae=!1,Ye||F.distanceToSquared(e.object.position)>d||8*(1-ie.dot(e.object.quaternion))>d||be.distanceToSquared(e.target)>0?(e.dispatchEvent(hn),F.copy(e.object.position),ie.copy(e.object.quaternion),be.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Me),e.domElement.removeEventListener("pointerdown",it),e.domElement.removeEventListener("pointercancel",Fe),e.domElement.removeEventListener("wheel",Et),e.domElement.removeEventListener("pointermove",Te),e.domElement.removeEventListener("pointerup",Fe),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",ot),e._domElementKeyEvents=null)};const e=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const d=1e-6,l=new u.Spherical,f=new u.Spherical;let m=1;const b=new u.Vector3,C=new u.Vector2,x=new u.Vector2,O=new u.Vector2,j=new u.Vector2,K=new u.Vector2,ce=new u.Vector2,J=new u.Vector2,T=new u.Vector2,Q=new u.Vector2,fe=new u.Vector3,ue=new u.Vector2;let ae=!1;const h=[],g={};function y(o){return o!==null?2*Math.PI/60*e.autoRotateSpeed*o:2*Math.PI/60/60*e.autoRotateSpeed}function M(o){const E=Math.abs(o)/(100*(window.devicePixelRatio|0));return Math.pow(.95,e.zoomSpeed*E)}function H(o){f.theta-=o}function z(o){f.phi-=o}const B=function(){const o=new u.Vector3;return function(N,F){o.setFromMatrixColumn(F,0),o.multiplyScalar(-N),b.add(o)}}(),L=function(){const o=new u.Vector3;return function(N,F){e.screenSpacePanning===!0?o.setFromMatrixColumn(F,1):(o.setFromMatrixColumn(F,0),o.crossVectors(e.object.up,o)),o.multiplyScalar(N),b.add(o)}}(),G=function(){const o=new u.Vector3;return function(N,F){const ie=e.domElement;if(e.object.isPerspectiveCamera){const be=e.object.position;o.copy(be).sub(e.target);let de=o.length();de*=Math.tan(e.object.fov/2*Math.PI/180),B(2*N*de/ie.clientHeight,e.object.matrix),L(2*F*de/ie.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(B(N*(e.object.right-e.object.left)/e.object.zoom/ie.clientWidth,e.object.matrix),L(F*(e.object.top-e.object.bottom)/e.object.zoom/ie.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function ee(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m/=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function _(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m*=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function U(o,E){if(!e.zoomToCursor)return;ae=!0;const N=e.domElement.getBoundingClientRect(),F=o-N.left,ie=E-N.top,be=N.width,de=N.height;ue.x=F/be*2-1,ue.y=-(ie/de)*2+1,fe.set(ue.x,ue.y,1).unproject(e.object).sub(e.object.position).normalize()}function q(o){return Math.max(e.minDistance,Math.min(e.maxDistance,o))}function me(o){C.set(o.clientX,o.clientY)}function Ie(o){U(o.clientX,o.clientX),J.set(o.clientX,o.clientY)}function tt(o){j.set(o.clientX,o.clientY)}function mt(o){x.set(o.clientX,o.clientY),O.subVectors(x,C).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*O.x/E.clientHeight),z(2*Math.PI*O.y/E.clientHeight),C.copy(x),e.update()}function Nt(o){T.set(o.clientX,o.clientY),Q.subVectors(T,J),Q.y>0?ee(M(Q.y)):Q.y<0&&_(M(Q.y)),J.copy(T),e.update()}function Lt(o){K.set(o.clientX,o.clientY),ce.subVectors(K,j).multiplyScalar(e.panSpeed),G(ce.x,ce.y),j.copy(K),e.update()}function nt(o){U(o.clientX,o.clientY),o.deltaY<0?_(M(o.deltaY)):o.deltaY>0&&ee(M(o.deltaY)),e.update()}function at(o){let E=!1;switch(o.code){case e.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?z(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?z(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?H(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?H(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(-e.keyPanSpeed,0),E=!0;break}E&&(o.preventDefault(),e.update())}function Ne(o){if(h.length===1)C.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);C.set(N,F)}}function He(o){if(h.length===1)j.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);j.set(N,F)}}function Le(o){const E=ve(o),N=o.pageX-E.x,F=o.pageY-E.y,ie=Math.sqrt(N*N+F*F);J.set(0,ie)}function Ut(o){e.enableZoom&&Le(o),e.enablePan&&He(o)}function gt(o){e.enableZoom&&Le(o),e.enableRotate&&Ne(o)}function vt(o){if(h.length==1)x.set(o.pageX,o.pageY);else{const N=ve(o),F=.5*(o.pageX+N.x),ie=.5*(o.pageY+N.y);x.set(F,ie)}O.subVectors(x,C).multiplyScalar(e.rotateSpeed);const E=e.domElement;H(2*Math.PI*O.x/E.clientHeight),z(2*Math.PI*O.y/E.clientHeight),C.copy(x)}function bt(o){if(h.length===1)K.set(o.pageX,o.pageY);else{const E=ve(o),N=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);K.set(N,F)}ce.subVectors(K,j).multiplyScalar(e.panSpeed),G(ce.x,ce.y),j.copy(K)}function Ue(o){const E=ve(o),N=o.pageX-E.x,F=o.pageY-E.y,ie=Math.sqrt(N*N+F*F);T.set(0,ie),Q.set(0,Math.pow(T.y/J.y,e.zoomSpeed)),ee(Q.y),J.copy(T);const be=(o.pageX+E.x)*.5,de=(o.pageY+E.y)*.5;U(be,de)}function ze(o){e.enableZoom&&Ue(o),e.enablePan&&bt(o)}function yt(o){e.enableZoom&&Ue(o),e.enableRotate&&vt(o)}function it(o){e.enabled!==!1&&(h.length===0&&(e.domElement.setPointerCapture(o.pointerId),e.domElement.addEventListener("pointermove",Te),e.domElement.addEventListener("pointerup",Fe)),Vt(o),o.pointerType==="touch"?wt(o):Ft(o))}function Te(o){e.enabled!==!1&&(o.pointerType==="touch"?Ct(o):rt(o))}function Fe(o){St(o),h.length===0&&(e.domElement.releasePointerCapture(o.pointerId),e.domElement.removeEventListener("pointermove",Te),e.domElement.removeEventListener("pointerup",Fe)),e.dispatchEvent(pn),s=r.NONE}function Ft(o){let E;switch(o.button){case 0:E=e.mouseButtons.LEFT;break;case 1:E=e.mouseButtons.MIDDLE;break;case 2:E=e.mouseButtons.RIGHT;break;default:E=-1}switch(E){case u.MOUSE.DOLLY:if(e.enableZoom===!1)return;Ie(o),s=r.DOLLY;break;case u.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enablePan===!1)return;tt(o),s=r.PAN}else{if(e.enableRotate===!1)return;me(o),s=r.ROTATE}break;case u.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enableRotate===!1)return;me(o),s=r.ROTATE}else{if(e.enablePan===!1)return;tt(o),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(It)}function rt(o){switch(s){case r.ROTATE:if(e.enableRotate===!1)return;mt(o);break;case r.DOLLY:if(e.enableZoom===!1)return;Nt(o);break;case r.PAN:if(e.enablePan===!1)return;Lt(o);break}}function Et(o){e.enabled===!1||e.enableZoom===!1||s!==r.NONE||(o.preventDefault(),e.dispatchEvent(It),nt(o),e.dispatchEvent(pn))}function ot(o){e.enabled===!1||e.enablePan===!1||at(o)}function wt(o){switch(st(o),h.length){case 1:switch(e.touches.ONE){case u.TOUCH.ROTATE:if(e.enableRotate===!1)return;Ne(o),s=r.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(e.enablePan===!1)return;He(o),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(e.touches.TWO){case u.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ut(o),s=r.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;gt(o),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(It)}function Ct(o){switch(st(o),s){case r.TOUCH_ROTATE:if(e.enableRotate===!1)return;vt(o),e.update();break;case r.TOUCH_PAN:if(e.enablePan===!1)return;bt(o),e.update();break;case r.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ze(o),e.update();break;case r.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;yt(o),e.update();break;default:s=r.NONE}}function Me(o){e.enabled!==!1&&o.preventDefault()}function Vt(o){h.push(o.pointerId)}function St(o){delete g[o.pointerId];for(let E=0;E<h.length;E++)if(h[E]==o.pointerId){h.splice(E,1);return}}function st(o){let E=g[o.pointerId];E===void 0&&(E=new u.Vector2,g[o.pointerId]=E),E.set(o.pageX,o.pageY)}function ve(o){const E=o.pointerId===h[0]?h[1]:h[0];return g[E]}e.domElement.addEventListener("contextmenu",Me),e.domElement.addEventListener("pointerdown",it),e.domElement.addEventListener("pointercancel",Fe),e.domElement.addEventListener("wheel",Et,{passive:!1}),this.update()}}const dt=t=>{const[n,a]=R.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},r=s=>{s!==n&&(t.onSelect(s),a(s)),t.onToggle(!1)};return c.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[c.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&c.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>c.jsx("li",{onClick:()=>r(s),children:s},s))})]})},_e=R.forwardRef(function(n,a){const[e,r]=R.useState(!1),s=n.options.indexOf(n.camera.name);return c.jsxs("div",{className:"CameraWindow",children:[c.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&r(!1)}}),c.jsx(dt,{index:s,open:e,options:n.options,onSelect:n.onSelect,onToggle:d=>{r(d)},up:!0})]})}),gn=["Single","Side by Side","Stacked","Quad"],ne=new Map,oe=new Map,ye=new Map;function ke(t,n){const a=new u.OrthographicCamera(-100,100,100,-100,50,3e3);return a.name=t,a.position.copy(n),a.lookAt(0,0,0),ne.set(t,a),a}ke("Top",new u.Vector3(0,1e3,0)),ke("Bottom",new u.Vector3(0,-1e3,0)),ke("Left",new u.Vector3(-1e3,0,0)),ke("Right",new u.Vector3(1e3,0,0)),ke("Front",new u.Vector3(0,0,1e3)),ke("Back",new u.Vector3(0,0,-1e3)),ke("Orthographic",new u.Vector3(1e3,1e3,1e3));const ft=new u.PerspectiveCamera(60,1,50,3e3);ft.name="Debug",ft.position.set(500,500,500),ft.lookAt(0,0,0),ne.set("Debug",ft);const vn=["Renderer","Depth","Normals","UVs","Wireframe"],ma=new u.MeshDepthMaterial,ga=new u.MeshNormalMaterial,va=new on,ba=new u.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),ka="";let ht="Renderer";const Y=new u.Scene;Y.name="Debug Scene";let Ee=new u.Scene;Y.add(Ee);const $e=new u.Group;$e.name="helpers",Y.add($e);const ya=new rn;$e.add(ya);const bn=new u.AxesHelper(500);bn.name="axisHelper",$e.add(bn);const et=new u.AxesHelper(100);et.name="interactionHelper",$e.add(et),et.visible=!1;let pt=!1,W=ne.get("Debug"),se=ne.get("Orthographic"),De=ne.get("Front"),Ae=ne.get("Top"),yn=!1;function Ea(t){const[n,a]=R.useState(t.mode!==void 0?t.mode:"Single"),[e,r]=R.useState(null),[s,d]=R.useState(!1),[l,f]=R.useState(!1),[m,b]=R.useState(!1),[,C]=R.useState(Date.now()),x=R.useRef(null),O=R.useRef(null),j=R.useRef(null),K=R.useRef(null),ce=R.useRef(null),J=R.useRef(null),T=(h,g)=>{const y=oe.get(h.name);y!==void 0&&y.dispose(),oe.delete(h.name);const M=ye.get(h.name);M!==void 0&&(Y.remove(M),M.dispose()),ye.delete(h.name);const H=new pa(h,g);switch(H.enableDamping=!0,H.dampingFactor=.05,h.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":H.enableRotate=!1;break}if(oe.set(h.name,H),h instanceof u.PerspectiveCamera){const z=new u.CameraHelper(h);ye.set(h.name,z),Y.add(z)}},Q=h=>{const g=ye.get(h.name);g!==void 0&&(Y.remove(g),g.dispose(),ye.delete(h.name));const y=oe.get(h.name);y!==void 0&&(y.dispose(),oe.delete(h.name))},fe=()=>{oe.forEach((h,g)=>{h.dispose();const y=ye.get(g);y!==void 0&&(Y.remove(y),y.dispose()),ye.delete(g),oe.delete(g)}),oe.clear(),ye.clear()},ue=()=>{switch(n){case"Single":T(W,j.current);break;case"Side by Side":case"Stacked":T(W,j.current),T(se,K.current);break;case"Quad":T(W,j.current),T(se,K.current),T(De,ce.current),T(Ae,J.current);break}};R.useEffect(()=>{const h=new u.WebGLRenderer({canvas:x.current,stencil:!1});h.autoClear=!1,h.shadowMap.enabled=!0,h.setPixelRatio(devicePixelRatio),h.setClearColor(0),r(h)},[]),R.useEffect(()=>{const h=M=>{Mt(Ee),Y.remove(Ee);const H=t.scenes.get(M.value.name);if(H!==void 0){const z=new H;t.onSceneSet!==void 0&&t.onSceneSet(z),Ee=z,t.three.scene=Ee,Y.add(Ee),yn=!0}},g=M=>{var B;const H=M.value,z=(B=t.three.scene)==null?void 0:B.getObjectByProperty("uuid",H.uuid);z!==void 0&&ne.set(H.name,z),C(Date.now())},y=M=>{ne.delete(M.value.name),C(Date.now())};return D.addEventListener(A.SET_SCENE,h),D.addEventListener(A.ADD_CAMERA,g),D.addEventListener(A.REMOVE_CAMERA,y),()=>{D.removeEventListener(A.SET_SCENE,h),D.removeEventListener(A.ADD_CAMERA,g),D.removeEventListener(A.REMOVE_CAMERA,y)}},[]),R.useEffect(()=>{if(e===null)return;let h=window.innerWidth,g=window.innerHeight,y=Math.floor(h/2),M=Math.floor(g/2),H=-1;const z=()=>{h=window.innerWidth-300,g=window.innerHeight,y=Math.floor(h/2),M=Math.floor(g/2),e.setSize(h,g);let _=h,U=g;switch(n){case"Side by Side":_=y,U=g;break;case"Stacked":_=h,U=M;break;case"Quad":_=y,U=M;break}ne.forEach(q=>{var me;q instanceof u.OrthographicCamera?(q.left=_/-2,q.right=_/2,q.top=U/2,q.bottom=U/-2,q.updateProjectionMatrix()):q instanceof u.PerspectiveCamera&&(q.aspect=_/U,q.updateProjectionMatrix(),(me=ye.get(q.name))==null||me.update())})},B=()=>{e.setViewport(0,0,h,g),e.setScissor(0,0,h,g),e.render(Y,W)},L=()=>{if(n==="Side by Side")e.setViewport(0,0,y,g),e.setScissor(0,0,y,g),e.render(Y,W),e.setViewport(y,0,y,g),e.setScissor(y,0,y,g),e.render(Y,se);else{const _=g-M;e.setViewport(0,_,h,M),e.setScissor(0,_,h,M),e.render(Y,W),e.setViewport(0,0,h,M),e.setScissor(0,0,h,M),e.render(Y,se)}},G=()=>{let _=0,U=0;U=g-M,_=0,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(Y,W),_=y,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(Y,se),U=0,_=0,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(Y,De),_=y,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(Y,Ae)},ee=()=>{switch(oe.forEach(_=>{_.update()}),t.onSceneUpdate!==void 0&&yn&&t.onSceneUpdate(Ee),e.clear(),n){case"Single":B();break;case"Side by Side":case"Stacked":L();break;case"Quad":G();break}H=requestAnimationFrame(ee)};return ue(),window.addEventListener("resize",z),z(),ee(),()=>{window.removeEventListener("resize",z),cancelAnimationFrame(H),H=-1}},[n,e]),R.useEffect(()=>{if(e!==null){const h=new u.Raycaster,g=new u.Vector2,y=(B,L,G,ee)=>{switch(n){case"Quad":B<G?L<ee?h.setFromCamera(g,W):h.setFromCamera(g,De):L<ee?h.setFromCamera(g,se):h.setFromCamera(g,Ae);break;case"Side by Side":B<G?h.setFromCamera(g,W):h.setFromCamera(g,se);break;case"Single":h.setFromCamera(g,W);break;case"Stacked":L<ee?h.setFromCamera(g,W):h.setFromCamera(g,se);break}},M=B=>{if(!pt)return;const L=new u.Vector2;e.getSize(L);const G=Math.min(B.clientX,L.x),ee=Math.min(B.clientY,L.y);g.x=Be(G,0,L.x,-1,1),g.y=Be(ee,0,L.y,1,-1);const _=L.x/2,U=L.y/2,q=()=>{G<_?g.x=Be(G,0,_,-1,1):g.x=Be(G,_,L.x,-1,1)},me=()=>{ee<U?g.y=Be(ee,0,U,1,-1):g.y=Be(ee,U,L.y,1,-1)};switch(n){case"Quad":q(),me();break;case"Side by Side":q();break;case"Stacked":me(),me();break}y(G,ee,_,U);const Ie=h.intersectObjects(Ee.children);Ie.length>0&&et.position.copy(Ie[0].point)},H=B=>{if(!pt)return;const L=new u.Vector2;if(e.getSize(L),B.clientX>=L.x)return;M(B);const G=h.intersectObjects(Ee.children);G.length>0&&t.three.getObject(G[0].object.uuid)},z=O.current;return z.addEventListener("mousemove",M,!1),z.addEventListener("click",H,!1),()=>{z.removeEventListener("mousemove",M),z.removeEventListener("click",H)}}},[n,e]);const ae=[];return ne.forEach((h,g)=>{ae.push(g)}),c.jsxs("div",{className:"multiview",children:[c.jsx("canvas",{ref:x}),c.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:O,children:[n==="Single"&&c.jsx(c.Fragment,{children:c.jsx(_e,{camera:W,options:ae,ref:j,onSelect:h=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(W),W=g,T(g,j.current))}})}),(n==="Side by Side"||n==="Stacked")&&c.jsxs(c.Fragment,{children:[c.jsx(_e,{camera:W,options:ae,ref:j,onSelect:h=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(W),W=g,T(g,j.current))}}),c.jsx(_e,{camera:se,options:ae,ref:K,onSelect:h=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(se),se=g,T(g,K.current))}})]}),n==="Quad"&&c.jsxs(c.Fragment,{children:[c.jsx(_e,{camera:W,options:ae,ref:j,onSelect:h=>{var y;(y=oe.get(W.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(W),W=g,T(g,j.current))}}),c.jsx(_e,{camera:se,options:ae,ref:K,onSelect:h=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(se),se=g,T(g,K.current))}}),c.jsx(_e,{camera:De,options:ae,ref:ce,onSelect:h=>{var y;(y=oe.get(De.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(De),De=g,T(g,ce.current))}}),c.jsx(_e,{camera:Ae,options:ae,ref:J,onSelect:h=>{var y;(y=oe.get(Ae.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(Ae),Ae=g,T(g,J.current))}})]})]}),c.jsxs("div",{className:"settings",children:[c.jsx(dt,{index:gn.indexOf(n),options:gn,onSelect:h=>{h!==n&&(fe(),a(h))},open:s,onToggle:h=>{d(h),l&&f(!1),m&&b(!1)}}),c.jsx(dt,{index:vn.indexOf(ht),options:vn,onSelect:h=>{if(h!==ht)switch(ht=h,ht){case"Depth":Y.overrideMaterial=ma;break;case"Normals":Y.overrideMaterial=ga;break;default:case"Renderer":Y.overrideMaterial=null;break;case"Wireframe":Y.overrideMaterial=ba;break;case"UVs":Y.overrideMaterial=va;break}},open:l,onToggle:h=>{s&&d(!1),f(h),m&&b(!1)}}),c.jsx(dt,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:h=>{pt=h==="Selection Mode",et.visible=pt},open:m,onToggle:h=>{s&&d(!1),l&&f(!1),b(h)}})]})]})}const Da="";function wa(t){return c.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[c.jsx("header",{children:t.header}),t.children,c.jsx("footer",{children:t.footer})]})}w.Accordion=lt,w.Application=_n,w.BaseRemote=Ze,w.ChildObject=Dt,w.ContainerObject=sn,w.Draggable=tn,w.DraggableItem=en,w.Dropdown=nn,w.DropdownItem=an,w.Editor=wa,w.InfiniteGridHelper=rn,w.Inspector=fn,w.MultiView=Ea,w.NavButton=kt,w.RemoteComponents=Kt,w.RemoteController=Wn,w.RemoteTheatre=xe,w.RemoteThree=Qt,w.RemoteTweakpane=jt,w.SceneInspector=fa,w.SidePanel=da,w.ToolEvents=A,w.UVMaterial=on,w.clamp=Rn,w.colorToHex=zt,w.debugDispatcher=D,w.dispose=Mt,w.disposeMaterial=Wt,w.disposeTexture=jn,w.distance=Pn,w.hierarchyUUID=Tt,w.isColor=Ht,w.randomID=Gt,w.resetThreeObjects=Yt,w.round=ct,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
143
+ }`;class on extends u.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:Jn,fragmentShader:Qn})}}const ja="";function lt(t){const[n,a]=R.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return c.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[c.jsxs("button",{className:"toggle",onClick:()=>{const r=!n;t.onToggle!==void 0&&t.onToggle(r),a(r)},children:[c.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),c.jsx("p",{className:"label",children:t.label})]}),t.button,c.jsx("div",{className:n?"open":"",children:c.jsx("div",{children:t.children})})]})}function Dt(t){const[n,a]=R.useState(!1),e=t.child.children.length>0,r=[];return t.child.children.length>0&&t.child.children.map(s=>{r.push(c.jsx(Dt,{child:s,three:t.three},Math.random()))}),c.jsxs("div",{className:"childObject",children:[c.jsxs("div",{className:"child",children:[e?c.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,c.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.three.getObject(t.child.uuid)},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),c.jsx("div",{className:`icon ${Ln(t.child)}`})]}),c.jsx("div",{className:n?"open":"",children:c.jsx("div",{className:"container",children:r})})]},Math.random())}function sn(t){const n=[];return t.child.children.map(a=>{n.push(c.jsx(Dt,{child:a,three:t.three},Math.random()))}),c.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const _a="",qn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function $n(t){return"items"in t}function Pe(t){const n=[];return t.items.forEach(a=>{$n(a)?n.push(c.jsx(Pe,{title:a.title,items:a.items},Math.random())):n.push(c.jsx(qe,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,onChange:(e,r)=>{a.onChange!==void 0&&a.onChange(e,r)}},Math.random()))}),c.jsx(lt,{label:t.title,open:t.expanded===!0,children:n})}function ea(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="side"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||t.slice(0,5)==="blend"||t.slice(0,4)==="clip"||t.slice(0,7)==="polygon"||t.slice(0,7)==="stencil"||t.slice(0,2)==="is")}function je(t){switch(t){case"alphaMap":return"Alpha Map";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"defines":return"Defines";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return t}function ta(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="bumpScale"||t==="clearcoatRoughness"||t==="displacementBias"||t==="displacementScale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionRatio"||t==="roughness"||t==="sheenRoughness"||t==="thickness"}function na(){const t=document.createElement("input");return t.type="file",new Promise((n,a)=>{t.addEventListener("change",function(){if(t.files===null)a();else{const e=t.files[0],r=new FileReader;r.onload=function(s){n(s.target.result)},r.readAsDataURL(e)}}),t.click()})}function cn(t,n,a){const e=[];for(const r in t){if(!ea(r))continue;const s=typeof t[r],d=t[r];if(s==="boolean"||s==="number"||s==="string"){const l={title:je(r),prop:r,type:s,value:d,min:void 0,max:void 0,onChange:(f,m)=>{var S;a.updateObject(n.uuid,`material.${f}`,m),s==="boolean"&&a.updateObject(n.uuid,"material.needsUpdate",!0);const b=(S=a.scene)==null?void 0:S.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${f}`,m)}};ta(r)&&(l.value=Number(d),l.type="range",l.min=0,l.max=1,l.step=.01),e.push(l)}else if(s==="object")if(d.isColor)e.push({title:je(r),prop:r,type:"color",value:d,onChange:(l,f)=>{var S;const m=new u.Color(f);a.updateObject(n.uuid,`material.${l}`,m);const b=(S=a.scene)==null?void 0:S.getObjectByProperty("uuid",n.uuid);b!==void 0&&te(b,`material.${l}`,m)}});else if(Array.isArray(d)){const l=[];for(const f in d)l.push({title:`${f}`,type:`${typeof d[f]}`,value:d[f],onChange:(m,b)=>{var O;a.updateObject(n.uuid,`material.${r}`,b);const S=(O=a.scene)==null?void 0:O.getObjectByProperty("uuid",n.uuid);S!==void 0&&te(S,`material.${r}`,b)}});e.push({title:je(r),items:l})}else{const l=[];for(const f in d){const m=d[f];switch(typeof m){case"boolean":case"number":case"string":f==="src"?e.push({title:je(r),type:"image",value:m,onChange:(S,O)=>{var j;a.createTexture(n.uuid,`material.${r}`,O);const x=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);x!==void 0&&Pt(O).then(X=>{te(x,`material.${r}`,X),te(x,"material.needsUpdate",!0)})}}):l.push({title:`${je(f)}`,prop:`material.${r}.${f}`,type:`${typeof t[r][f]}`,value:d[f],onChange:(S,O)=>{var j;a.updateObject(n.uuid,`material.${r}.${f}`,O);const x=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${r}.${f}`,O)}});break;case"object":m.value!==void 0&&m.value.src!==void 0?l.push({title:je(f),type:"image",value:m.value.src,onChange:(S,O)=>{var j;a.createTexture(n.uuid,`material.${r}.${f}.value`,O);const x=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);x!==void 0&&Pt(O).then(X=>{te(x,`material.${r}.${f}.value`,X)})}}):l.push({title:f,type:`${typeof m.value}`,value:m.value,onChange:(S,O)=>{var j;a.updateObject(n.uuid,`material.${r}.${f}.value`,O);const x=(j=a.scene)==null?void 0:j.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${r}.${f}.value`,O)}});break}}l.length>0&&e.push({title:je(r),items:l})}else d!==void 0&&console.log("other:",r,s,d)}return e.sort((r,s)=>r.title<s.title?-1:r.title>s.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function aa(t,n){const a=t.material;if(Array.isArray(a)){const e=[],r=a.length;for(let s=0;s<r;s++)e.push(c.jsx(Pe,{title:`Material ${s}`,items:cn(a[s],t,n)},`Material ${s}`));return c.jsx(c.Fragment,{children:e})}else return c.jsx(Pe,{title:"Material",items:cn(a,t,n)})}function qe(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=zt(t.value));const[a,e]=R.useState(n),r=R.useRef(null),s=R.useRef(null),d=R.useRef(null);R.useEffect(()=>{var Q;let b=!1,S=-1,O=0,x=Number(a);const j=fe=>{b=!0,O=x,S=fe.clientX},X=fe=>{if(!b)return;const ue=t.step!==void 0?t.step:1,ae=(fe.clientX-S)*ue;x=Number((O+ae).toFixed(4)),s.current!==null&&(s.current.value=x.toString()),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,x)},ce=()=>{b=!1},J=()=>{b=!1},T=t.type==="number";return T&&((Q=r.current)==null||Q.addEventListener("mousedown",j,!1),document.addEventListener("mouseup",ce,!1),document.addEventListener("mousemove",X,!1),document.addEventListener("contextmenu",J,!1)),()=>{var fe;T&&((fe=r.current)==null||fe.removeEventListener("mousedown",j),document.removeEventListener("mouseup",ce),document.removeEventListener("mousemove",X),document.removeEventListener("contextmenu",J))}},[a]);const l=t.type==="string"&&(a.length>100||a.search(`
144
+ `)>-1),f=l||t.type==="image",m=b=>{let S=b.target.value;t.type==="boolean"&&(S=b.target.checked),e(S),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,S)};return c.jsxs("div",{className:`field ${f?"block":""}`,children:[t.type!=="button"&&c.jsx("label",{ref:r,children:t.title},"fieldLabel"),t.type==="string"&&!l&&c.jsx("input",{type:"text",disabled:t.disabled,onChange:m,value:a}),t.type==="string"&&l&&c.jsx("textarea",{cols:50,rows:10,disabled:!0,onChange:m,value:a}),t.type==="boolean"&&c.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:m,checked:a}),t.type==="number"&&c.jsx("input",{ref:s,type:"number",value:a,min:t.min,max:t.max,step:t.step,onChange:m}),t.type==="range"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"min"}),c.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:m})]}),t.type==="color"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"text",value:a.toString(),onChange:m,className:"color"}),c.jsx("input",{type:"color",value:a,onChange:m})]}),t.type==="button"&&c.jsx("button",{onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&c.jsx("img",{ref:d,onClick:()=>{na().then(b=>{d.current.src=b,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,b)})},src:a.length>0?a:qn})]})}function ln(t){switch(t){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return t}function ia(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:ln(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&(te(d,r,s),d.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:ln(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&(te(d,r,s),d.updateProjectionMatrix())}});return c.jsx(Pe,{title:"Camera",items:a})}const ra=Math.PI/180,oa=180/Math.PI;function Be(t,n,a,e,r){return e+(t-n)*(r-e)/(a-n)}function sa(t){return t*ra}function At(t){return t*oa}function ca(t,n){const a=new u.Matrix4;a.elements=t.matrix;const e=new u.Vector3,r=new u.Euler,s=new u.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),r.setFromRotationMatrix(a),s.setFromMatrixScale(a));const d=(f,m)=>{var S;n.updateObject(t.uuid,f,m);const b=(S=n.scene)==null?void 0:S.getObjectByProperty("uuid",t.uuid);b!==void 0&&te(b,f,m)},l=(f,m)=>{d(f,sa(m))};return c.jsx(Pe,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:d},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:d},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:d},{title:"Rotation X",prop:"rotation.x",type:"number",value:ct(At(r.x)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Y",prop:"rotation.y",type:"number",value:ct(At(r.y)),min:-360,max:360,step:.1,onChange:l},{title:"Rotation Z",prop:"rotation.z",type:"number",value:ct(At(r.z)),min:-360,max:360,step:.1,onChange:l},{title:"Scale X",prop:"scale.x",type:"number",value:s.x,step:.01,onChange:d},{title:"Scale Y",prop:"scale.y",type:"number",value:s.y,step:.01,onChange:d},{title:"Scale Z",prop:"scale.z",type:"number",value:s.z,step:.01,onChange:d}]})}function un(t){switch(t){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color"}return t}function la(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const r=t.lightInfo[e];r!==void 0&&(r.isColor!==void 0?a.push({title:un(e),prop:e,type:"color",value:r,onChange:(s,d)=>{var m;const l=new u.Color(d);n.updateObject(t.uuid,s,l);const f=(m=n.scene)==null?void 0:m.getObjectByProperty("uuid",t.uuid);f!==void 0&&te(f,s,l)}}):a.push({title:un(e),prop:e,type:typeof r,value:r,step:typeof r=="number"?.01:void 0,onChange:(s,d)=>{var f;n.updateObject(t.uuid,s,d);const l=(f=n.scene)==null?void 0:f.getObjectByProperty("uuid",t.uuid);l!==void 0&&te(l,s,d)}}))}return c.jsx(Pe,{title:"Light",items:a})}function ua(t,n){const a=[];return t.animations.forEach(e=>{a.push({title:"Name",type:"string",prop:"name",value:e.name,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,r,s)}}),a.push({title:"Duration",type:"number",prop:"duration",value:e.duration,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,r,s)}}),a.push({title:"Blend Mode",type:"number",prop:"blendMode",value:e.blendMode,disabled:!0,onChange:(r,s)=>{var l;n.updateObject(t.uuid,r,s);const d=(l=n.scene)==null?void 0:l.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,r,s)}})}),c.jsx(Pe,{title:"Animations",items:a})}const dn={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};let re={...dn};function fn(t){const[n,a]=R.useState(-1);R.useEffect(()=>{function r(d){re={...d.value},a(Date.now())}function s(){re={...dn},a(Date.now())}return D.addEventListener(A.SET_SCENE,s),D.addEventListener(A.SET_OBJECT,r),()=>{D.removeEventListener(A.SET_SCENE,s),D.removeEventListener(A.SET_OBJECT,r)}},[]);const e=re.type.toLowerCase();return c.jsx(lt,{label:"Inspector",children:c.jsx("div",{id:"Inspector",className:t.class,children:re.uuid.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs(c.Fragment,{children:[c.jsx(qe,{type:"string",title:"Name",prop:"name",value:re.name,disabled:!0}),c.jsx(qe,{type:"string",title:"Type",prop:"type",value:re.type,disabled:!0}),c.jsx(qe,{type:"string",title:"UUID",prop:"uuid",value:re.uuid,disabled:!0}),c.jsx(qe,{type:"boolean",title:"Visible",prop:"visible",value:re.visible,onChange:(r,s)=>{var l;t.three.updateObject(re.uuid,r,s);const d=(l=t.three.scene)==null?void 0:l.getObjectByProperty("uuid",re.uuid);d!==void 0&&te(d,r,s)}})]}),c.jsxs(c.Fragment,{children:[ca(re,t.three),re.animations.length>0?ua(re,t.three):null,e.search("camera")>-1?ia(re,t.three):null,e.search("light")>-1?la(re,t.three):null,e.search("mesh")>-1?aa(re,t.three):null]})]})},n)},"Inspector")}class da extends R.Component{constructor(a){super(a);F(this,"three");F(this,"setScene",a=>{this.setState(()=>({scene:a.value}))});this.state={scene:a.scene!==void 0?a.scene:null},this.three=a.three,D.addEventListener(A.SET_SCENE,this.setScene)}componentWillUnmount(){D.removeEventListener(A.SET_SCENE,this.setScene)}render(){var r;const a=this.componentState.scene!==null,e="Hierarchy - "+(a?`${(r=this.componentState.scene)==null?void 0:r.name}`:"No Scene");return c.jsx("div",{id:"SidePanel",children:c.jsxs(c.Fragment,{children:[c.jsx(lt,{label:e,open:!0,children:c.jsx(c.Fragment,{children:a&&c.jsx(sn,{child:this.componentState.scene,three:this.three})})}),c.jsx(fn,{three:this.three})]})},"SidePanel")}get componentState(){return this.state}}function fa(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=l=>{var m;if(!n())return;const f=(m=t.three.scene)==null?void 0:m.getObjectByProperty("uuid",l.value);f!==void 0&&t.three.setObject(f)},e=(l,f,m)=>{var S;if(!n())return;const b=(S=t.three.scene)==null?void 0:S.getObjectByProperty("uuid",l);b!==void 0&&te(b,f,m)},r=l=>{if(!n())return;const f=l.value,{key:m,value:b,uuid:S}=f;e(S,m,b)},s=l=>{if(!n())return;const f=l.value;Pt(f.value).then(m=>{e(f.uuid,f.key,m),e(f.uuid,"material.needsUpdate",!0)})},d=l=>{var O;if(!n())return;const{key:f,uuid:m,value:b}=l.value,S=(O=t.three.scene)==null?void 0:O.getObjectByProperty("uuid",m);if(S!==void 0)try{S[f](b)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(f),console.log(b)}};return R.useEffect(()=>(D.addEventListener(A.GET_OBJECT,a),D.addEventListener(A.UPDATE_OBJECT,r),D.addEventListener(A.CREATE_TEXTURE,s),D.addEventListener(A.REQUEST_METHOD,d),()=>{D.removeEventListener(A.GET_OBJECT,a),D.removeEventListener(A.UPDATE_OBJECT,r),D.removeEventListener(A.CREATE_TEXTURE,s),D.removeEventListener(A.REQUEST_METHOD,d)}),[]),null}const hn={type:"change"},It={type:"start"},pn={type:"end"},ut=new u.Ray,mn=new u.Plane,ha=Math.cos(70*u.MathUtils.DEG2RAD);class pa extends u.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(o){o.addEventListener("keydown",ot),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ot),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(hn),e.update(),s=r.NONE},this.update=function(){const o=new u.Vector3,E=new u.Quaternion().setFromUnitVectors(n.up,new u.Vector3(0,1,0)),L=E.clone().invert(),V=new u.Vector3,ie=new u.Quaternion,be=new u.Vector3,de=2*Math.PI;return function(xt=null){const we=e.object.position;o.copy(we).sub(e.target),o.applyQuaternion(E),l.setFromVector3(o),e.autoRotate&&s===r.NONE&&z(y(xt)),e.enableDamping?(l.theta+=f.theta*e.dampingFactor,l.phi+=f.phi*e.dampingFactor):(l.theta+=f.theta,l.phi+=f.phi);let he=e.minAzimuthAngle,pe=e.maxAzimuthAngle;isFinite(he)&&isFinite(pe)&&(he<-Math.PI?he+=de:he>Math.PI&&(he-=de),pe<-Math.PI?pe+=de:pe>Math.PI&&(pe-=de),he<=pe?l.theta=Math.max(he,Math.min(pe,l.theta)):l.theta=l.theta>(he+pe)/2?Math.max(he,l.theta):Math.min(pe,l.theta)),l.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,l.phi)),l.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(b,e.dampingFactor):e.target.add(b),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&ae||e.object.isOrthographicCamera?l.radius=q(l.radius):l.radius=q(l.radius*m),o.setFromSpherical(l),o.applyQuaternion(L),we.copy(e.target).add(o),e.object.lookAt(e.target),e.enableDamping===!0?(f.theta*=1-e.dampingFactor,f.phi*=1-e.dampingFactor,b.multiplyScalar(1-e.dampingFactor)):(f.set(0,0,0),b.set(0,0,0));let Ye=!1;if(e.zoomToCursor&&ae){let Ve=null;if(e.object.isPerspectiveCamera){const Re=o.length();Ve=q(Re*m);const We=Re-Ve;e.object.position.addScaledVector(fe,We),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Re=new u.Vector3(ue.x,ue.y,0);Re.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),Ye=!0;const We=new u.Vector3(ue.x,ue.y,0);We.unproject(e.object),e.object.position.sub(We).add(Re),e.object.updateMatrixWorld(),Ve=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Ve!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Ve).add(e.object.position):(ut.origin.copy(e.object.position),ut.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(ut.direction))<ha?n.lookAt(e.target):(mn.setFromNormalAndCoplanarPoint(e.object.up,e.target),ut.intersectPlane(mn,e.target))))}else e.object.isOrthographicCamera&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/m)),e.object.updateProjectionMatrix(),Ye=!0);return m=1,ae=!1,Ye||V.distanceToSquared(e.object.position)>d||8*(1-ie.dot(e.object.quaternion))>d||be.distanceToSquared(e.target)>0?(e.dispatchEvent(hn),V.copy(e.object.position),ie.copy(e.object.quaternion),be.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Me),e.domElement.removeEventListener("pointerdown",it),e.domElement.removeEventListener("pointercancel",Fe),e.domElement.removeEventListener("wheel",Et),e.domElement.removeEventListener("pointermove",Te),e.domElement.removeEventListener("pointerup",Fe),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",ot),e._domElementKeyEvents=null)};const e=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const d=1e-6,l=new u.Spherical,f=new u.Spherical;let m=1;const b=new u.Vector3,S=new u.Vector2,O=new u.Vector2,x=new u.Vector2,j=new u.Vector2,X=new u.Vector2,ce=new u.Vector2,J=new u.Vector2,T=new u.Vector2,Q=new u.Vector2,fe=new u.Vector3,ue=new u.Vector2;let ae=!1;const h=[],g={};function y(o){return o!==null?2*Math.PI/60*e.autoRotateSpeed*o:2*Math.PI/60/60*e.autoRotateSpeed}function M(o){const E=Math.abs(o)/(100*(window.devicePixelRatio|0));return Math.pow(.95,e.zoomSpeed*E)}function z(o){f.theta-=o}function Y(o){f.phi-=o}const H=function(){const o=new u.Vector3;return function(L,V){o.setFromMatrixColumn(V,0),o.multiplyScalar(-L),b.add(o)}}(),N=function(){const o=new u.Vector3;return function(L,V){e.screenSpacePanning===!0?o.setFromMatrixColumn(V,1):(o.setFromMatrixColumn(V,0),o.crossVectors(e.object.up,o)),o.multiplyScalar(L),b.add(o)}}(),G=function(){const o=new u.Vector3;return function(L,V){const ie=e.domElement;if(e.object.isPerspectiveCamera){const be=e.object.position;o.copy(be).sub(e.target);let de=o.length();de*=Math.tan(e.object.fov/2*Math.PI/180),H(2*L*de/ie.clientHeight,e.object.matrix),N(2*V*de/ie.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(H(L*(e.object.right-e.object.left)/e.object.zoom/ie.clientWidth,e.object.matrix),N(V*(e.object.top-e.object.bottom)/e.object.zoom/ie.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function ee(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m/=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function _(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?m*=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function U(o,E){if(!e.zoomToCursor)return;ae=!0;const L=e.domElement.getBoundingClientRect(),V=o-L.left,ie=E-L.top,be=L.width,de=L.height;ue.x=V/be*2-1,ue.y=-(ie/de)*2+1,fe.set(ue.x,ue.y,1).unproject(e.object).sub(e.object.position).normalize()}function q(o){return Math.max(e.minDistance,Math.min(e.maxDistance,o))}function me(o){S.set(o.clientX,o.clientY)}function Ie(o){U(o.clientX,o.clientX),J.set(o.clientX,o.clientY)}function tt(o){j.set(o.clientX,o.clientY)}function mt(o){O.set(o.clientX,o.clientY),x.subVectors(O,S).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*x.x/E.clientHeight),Y(2*Math.PI*x.y/E.clientHeight),S.copy(O),e.update()}function Lt(o){T.set(o.clientX,o.clientY),Q.subVectors(T,J),Q.y>0?ee(M(Q.y)):Q.y<0&&_(M(Q.y)),J.copy(T),e.update()}function Nt(o){X.set(o.clientX,o.clientY),ce.subVectors(X,j).multiplyScalar(e.panSpeed),G(ce.x,ce.y),j.copy(X),e.update()}function nt(o){U(o.clientX,o.clientY),o.deltaY<0?_(M(o.deltaY)):o.deltaY>0&&ee(M(o.deltaY)),e.update()}function at(o){let E=!1;switch(o.code){case e.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?Y(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?Y(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?z(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?z(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):G(-e.keyPanSpeed,0),E=!0;break}E&&(o.preventDefault(),e.update())}function Le(o){if(h.length===1)S.set(o.pageX,o.pageY);else{const E=ve(o),L=.5*(o.pageX+E.x),V=.5*(o.pageY+E.y);S.set(L,V)}}function Ge(o){if(h.length===1)j.set(o.pageX,o.pageY);else{const E=ve(o),L=.5*(o.pageX+E.x),V=.5*(o.pageY+E.y);j.set(L,V)}}function Ne(o){const E=ve(o),L=o.pageX-E.x,V=o.pageY-E.y,ie=Math.sqrt(L*L+V*V);J.set(0,ie)}function Ut(o){e.enableZoom&&Ne(o),e.enablePan&&Ge(o)}function gt(o){e.enableZoom&&Ne(o),e.enableRotate&&Le(o)}function vt(o){if(h.length==1)O.set(o.pageX,o.pageY);else{const L=ve(o),V=.5*(o.pageX+L.x),ie=.5*(o.pageY+L.y);O.set(V,ie)}x.subVectors(O,S).multiplyScalar(e.rotateSpeed);const E=e.domElement;z(2*Math.PI*x.x/E.clientHeight),Y(2*Math.PI*x.y/E.clientHeight),S.copy(O)}function bt(o){if(h.length===1)X.set(o.pageX,o.pageY);else{const E=ve(o),L=.5*(o.pageX+E.x),V=.5*(o.pageY+E.y);X.set(L,V)}ce.subVectors(X,j).multiplyScalar(e.panSpeed),G(ce.x,ce.y),j.copy(X)}function Ue(o){const E=ve(o),L=o.pageX-E.x,V=o.pageY-E.y,ie=Math.sqrt(L*L+V*V);T.set(0,ie),Q.set(0,Math.pow(T.y/J.y,e.zoomSpeed)),ee(Q.y),J.copy(T);const be=(o.pageX+E.x)*.5,de=(o.pageY+E.y)*.5;U(be,de)}function ze(o){e.enableZoom&&Ue(o),e.enablePan&&bt(o)}function yt(o){e.enableZoom&&Ue(o),e.enableRotate&&vt(o)}function it(o){e.enabled!==!1&&(h.length===0&&(e.domElement.setPointerCapture(o.pointerId),e.domElement.addEventListener("pointermove",Te),e.domElement.addEventListener("pointerup",Fe)),Vt(o),o.pointerType==="touch"?wt(o):Ft(o))}function Te(o){e.enabled!==!1&&(o.pointerType==="touch"?St(o):rt(o))}function Fe(o){Ct(o),h.length===0&&(e.domElement.releasePointerCapture(o.pointerId),e.domElement.removeEventListener("pointermove",Te),e.domElement.removeEventListener("pointerup",Fe)),e.dispatchEvent(pn),s=r.NONE}function Ft(o){let E;switch(o.button){case 0:E=e.mouseButtons.LEFT;break;case 1:E=e.mouseButtons.MIDDLE;break;case 2:E=e.mouseButtons.RIGHT;break;default:E=-1}switch(E){case u.MOUSE.DOLLY:if(e.enableZoom===!1)return;Ie(o),s=r.DOLLY;break;case u.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enablePan===!1)return;tt(o),s=r.PAN}else{if(e.enableRotate===!1)return;me(o),s=r.ROTATE}break;case u.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enableRotate===!1)return;me(o),s=r.ROTATE}else{if(e.enablePan===!1)return;tt(o),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(It)}function rt(o){switch(s){case r.ROTATE:if(e.enableRotate===!1)return;mt(o);break;case r.DOLLY:if(e.enableZoom===!1)return;Lt(o);break;case r.PAN:if(e.enablePan===!1)return;Nt(o);break}}function Et(o){e.enabled===!1||e.enableZoom===!1||s!==r.NONE||(o.preventDefault(),e.dispatchEvent(It),nt(o),e.dispatchEvent(pn))}function ot(o){e.enabled===!1||e.enablePan===!1||at(o)}function wt(o){switch(st(o),h.length){case 1:switch(e.touches.ONE){case u.TOUCH.ROTATE:if(e.enableRotate===!1)return;Le(o),s=r.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(e.enablePan===!1)return;Ge(o),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(e.touches.TWO){case u.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ut(o),s=r.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;gt(o),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&e.dispatchEvent(It)}function St(o){switch(st(o),s){case r.TOUCH_ROTATE:if(e.enableRotate===!1)return;vt(o),e.update();break;case r.TOUCH_PAN:if(e.enablePan===!1)return;bt(o),e.update();break;case r.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ze(o),e.update();break;case r.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;yt(o),e.update();break;default:s=r.NONE}}function Me(o){e.enabled!==!1&&o.preventDefault()}function Vt(o){h.push(o.pointerId)}function Ct(o){delete g[o.pointerId];for(let E=0;E<h.length;E++)if(h[E]==o.pointerId){h.splice(E,1);return}}function st(o){let E=g[o.pointerId];E===void 0&&(E=new u.Vector2,g[o.pointerId]=E),E.set(o.pageX,o.pageY)}function ve(o){const E=o.pointerId===h[0]?h[1]:h[0];return g[E]}e.domElement.addEventListener("contextmenu",Me),e.domElement.addEventListener("pointerdown",it),e.domElement.addEventListener("pointercancel",Fe),e.domElement.addEventListener("wheel",Et,{passive:!1}),this.update()}}const dt=t=>{const[n,a]=R.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},r=s=>{s!==n&&(t.onSelect(s),a(s)),t.onToggle(!1)};return c.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[c.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&c.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>c.jsx("li",{onClick:()=>r(s),children:s},s))})]})},_e=R.forwardRef(function(n,a){const[e,r]=R.useState(!1),s=n.options.indexOf(n.camera.name);return c.jsxs("div",{className:"CameraWindow",children:[c.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&r(!1)}}),c.jsx(dt,{index:s,open:e,options:n.options,onSelect:n.onSelect,onToggle:d=>{r(d)},up:!0})]})}),gn=["Single","Side by Side","Stacked","Quad"],ne=new Map,oe=new Map,ye=new Map;function ke(t,n){const a=new u.OrthographicCamera(-100,100,100,-100,50,3e3);return a.name=t,a.position.copy(n),a.lookAt(0,0,0),ne.set(t,a),a}ke("Top",new u.Vector3(0,1e3,0)),ke("Bottom",new u.Vector3(0,-1e3,0)),ke("Left",new u.Vector3(-1e3,0,0)),ke("Right",new u.Vector3(1e3,0,0)),ke("Front",new u.Vector3(0,0,1e3)),ke("Back",new u.Vector3(0,0,-1e3)),ke("Orthographic",new u.Vector3(1e3,1e3,1e3));const ft=new u.PerspectiveCamera(60,1,50,3e3);ft.name="Debug",ft.position.set(500,500,500),ft.lookAt(0,0,0),ne.set("Debug",ft);const vn=["Renderer","Depth","Normals","UVs","Wireframe"],ma=new u.MeshDepthMaterial,ga=new u.MeshNormalMaterial,va=new on,ba=new u.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),ka="";let ht="Renderer";const W=new u.Scene;W.name="Debug Scene";let Ee=new u.Scene;W.add(Ee);const $e=new u.Group;$e.name="helpers",W.add($e);const ya=new rn;$e.add(ya);const bn=new u.AxesHelper(500);bn.name="axisHelper",$e.add(bn);const et=new u.AxesHelper(100);et.name="interactionHelper",$e.add(et),et.visible=!1;let pt=!1,K=ne.get("Debug"),se=ne.get("Orthographic"),De=ne.get("Front"),Ae=ne.get("Top"),yn=!1;function Ea(t){const[n,a]=R.useState(t.mode!==void 0?t.mode:"Single"),[e,r]=R.useState(null),[s,d]=R.useState(!1),[l,f]=R.useState(!1),[m,b]=R.useState(!1),[,S]=R.useState(Date.now()),O=R.useRef(null),x=R.useRef(null),j=R.useRef(null),X=R.useRef(null),ce=R.useRef(null),J=R.useRef(null),T=(h,g)=>{const y=oe.get(h.name);y!==void 0&&y.dispose(),oe.delete(h.name);const M=ye.get(h.name);M!==void 0&&(W.remove(M),M.dispose()),ye.delete(h.name);const z=new pa(h,g);switch(z.enableDamping=!0,z.dampingFactor=.05,h.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":z.enableRotate=!1;break}if(oe.set(h.name,z),h instanceof u.PerspectiveCamera){const Y=new u.CameraHelper(h);ye.set(h.name,Y),W.add(Y)}},Q=h=>{const g=ye.get(h.name);g!==void 0&&(W.remove(g),g.dispose(),ye.delete(h.name));const y=oe.get(h.name);y!==void 0&&(y.dispose(),oe.delete(h.name))},fe=()=>{oe.forEach((h,g)=>{h.dispose();const y=ye.get(g);y!==void 0&&(W.remove(y),y.dispose()),ye.delete(g),oe.delete(g)}),oe.clear(),ye.clear()},ue=()=>{switch(n){case"Single":T(K,j.current);break;case"Side by Side":case"Stacked":T(K,j.current),T(se,X.current);break;case"Quad":T(K,j.current),T(se,X.current),T(De,ce.current),T(Ae,J.current);break}};R.useEffect(()=>{const h=new u.WebGLRenderer({canvas:O.current,stencil:!1});h.autoClear=!1,h.shadowMap.enabled=!0,h.setPixelRatio(devicePixelRatio),h.setClearColor(0),r(h)},[]),R.useEffect(()=>{const h=M=>{Mt(Ee),W.remove(Ee);const z=t.scenes.get(M.value.name);if(z!==void 0){const Y=new z;t.onSceneSet!==void 0&&t.onSceneSet(Y),Ee=Y,t.three.scene=Ee,W.add(Ee),yn=!0}},g=M=>{var H;const z=M.value,Y=(H=t.three.scene)==null?void 0:H.getObjectByProperty("uuid",z.uuid);Y!==void 0&&ne.set(z.name,Y),S(Date.now())},y=M=>{ne.delete(M.value.name),S(Date.now())};return D.addEventListener(A.SET_SCENE,h),D.addEventListener(A.ADD_CAMERA,g),D.addEventListener(A.REMOVE_CAMERA,y),()=>{D.removeEventListener(A.SET_SCENE,h),D.removeEventListener(A.ADD_CAMERA,g),D.removeEventListener(A.REMOVE_CAMERA,y)}},[]),R.useEffect(()=>{if(e===null)return;let h=window.innerWidth,g=window.innerHeight,y=Math.floor(h/2),M=Math.floor(g/2),z=-1;const Y=()=>{h=window.innerWidth-300,g=window.innerHeight,y=Math.floor(h/2),M=Math.floor(g/2),e.setSize(h,g);let _=h,U=g;switch(n){case"Side by Side":_=y,U=g;break;case"Stacked":_=h,U=M;break;case"Quad":_=y,U=M;break}ne.forEach(q=>{var me;q instanceof u.OrthographicCamera?(q.left=_/-2,q.right=_/2,q.top=U/2,q.bottom=U/-2,q.updateProjectionMatrix()):q instanceof u.PerspectiveCamera&&(q.aspect=_/U,q.updateProjectionMatrix(),(me=ye.get(q.name))==null||me.update())})},H=()=>{e.setViewport(0,0,h,g),e.setScissor(0,0,h,g),e.render(W,K)},N=()=>{if(n==="Side by Side")e.setViewport(0,0,y,g),e.setScissor(0,0,y,g),e.render(W,K),e.setViewport(y,0,y,g),e.setScissor(y,0,y,g),e.render(W,se);else{const _=g-M;e.setViewport(0,_,h,M),e.setScissor(0,_,h,M),e.render(W,K),e.setViewport(0,0,h,M),e.setScissor(0,0,h,M),e.render(W,se)}},G=()=>{let _=0,U=0;U=g-M,_=0,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(W,K),_=y,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(W,se),U=0,_=0,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(W,De),_=y,e.setViewport(_,U,y,M),e.setScissor(_,U,y,M),e.render(W,Ae)},ee=()=>{switch(oe.forEach(_=>{_.update()}),t.onSceneUpdate!==void 0&&yn&&t.onSceneUpdate(Ee),e.clear(),n){case"Single":H();break;case"Side by Side":case"Stacked":N();break;case"Quad":G();break}z=requestAnimationFrame(ee)};return ue(),window.addEventListener("resize",Y),Y(),ee(),()=>{window.removeEventListener("resize",Y),cancelAnimationFrame(z),z=-1}},[n,e]),R.useEffect(()=>{if(e!==null){const h=new u.Raycaster,g=new u.Vector2,y=(H,N,G,ee)=>{switch(n){case"Quad":H<G?N<ee?h.setFromCamera(g,K):h.setFromCamera(g,De):N<ee?h.setFromCamera(g,se):h.setFromCamera(g,Ae);break;case"Side by Side":H<G?h.setFromCamera(g,K):h.setFromCamera(g,se);break;case"Single":h.setFromCamera(g,K);break;case"Stacked":N<ee?h.setFromCamera(g,K):h.setFromCamera(g,se);break}},M=H=>{if(!pt)return;const N=new u.Vector2;e.getSize(N);const G=Math.min(H.clientX,N.x),ee=Math.min(H.clientY,N.y);g.x=Be(G,0,N.x,-1,1),g.y=Be(ee,0,N.y,1,-1);const _=N.x/2,U=N.y/2,q=()=>{G<_?g.x=Be(G,0,_,-1,1):g.x=Be(G,_,N.x,-1,1)},me=()=>{ee<U?g.y=Be(ee,0,U,1,-1):g.y=Be(ee,U,N.y,1,-1)};switch(n){case"Quad":q(),me();break;case"Side by Side":q();break;case"Stacked":me(),me();break}y(G,ee,_,U);const Ie=h.intersectObjects(Ee.children);Ie.length>0&&et.position.copy(Ie[0].point)},z=H=>{if(!pt)return;const N=new u.Vector2;if(e.getSize(N),H.clientX>=N.x)return;M(H);const G=h.intersectObjects(Ee.children);G.length>0&&t.three.getObject(G[0].object.uuid)},Y=x.current;return Y.addEventListener("mousemove",M,!1),Y.addEventListener("click",z,!1),()=>{Y.removeEventListener("mousemove",M),Y.removeEventListener("click",z)}}},[n,e]);const ae=[];return ne.forEach((h,g)=>{ae.push(g)}),c.jsxs("div",{className:"multiview",children:[c.jsx("canvas",{ref:O}),c.jsxs("div",{className:`cameras ${n==="Single"||n==="Stacked"?"single":""}`,ref:x,children:[n==="Single"&&c.jsx(c.Fragment,{children:c.jsx(_e,{camera:K,options:ae,ref:j,onSelect:h=>{var y;(y=oe.get(K.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(K),K=g,T(g,j.current))}})}),(n==="Side by Side"||n==="Stacked")&&c.jsxs(c.Fragment,{children:[c.jsx(_e,{camera:K,options:ae,ref:j,onSelect:h=>{var y;(y=oe.get(K.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(K),K=g,T(g,j.current))}}),c.jsx(_e,{camera:se,options:ae,ref:X,onSelect:h=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(se),se=g,T(g,X.current))}})]}),n==="Quad"&&c.jsxs(c.Fragment,{children:[c.jsx(_e,{camera:K,options:ae,ref:j,onSelect:h=>{var y;(y=oe.get(K.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(K),K=g,T(g,j.current))}}),c.jsx(_e,{camera:se,options:ae,ref:X,onSelect:h=>{var y;(y=oe.get(se.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(se),se=g,T(g,X.current))}}),c.jsx(_e,{camera:De,options:ae,ref:ce,onSelect:h=>{var y;(y=oe.get(De.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(De),De=g,T(g,ce.current))}}),c.jsx(_e,{camera:Ae,options:ae,ref:J,onSelect:h=>{var y;(y=oe.get(Ae.name))==null||y.dispose();const g=ne.get(h);g!==void 0&&(Q(Ae),Ae=g,T(g,J.current))}})]})]}),c.jsxs("div",{className:"settings",children:[c.jsx(dt,{index:gn.indexOf(n),options:gn,onSelect:h=>{h!==n&&(fe(),a(h))},open:s,onToggle:h=>{d(h),l&&f(!1),m&&b(!1)}}),c.jsx(dt,{index:vn.indexOf(ht),options:vn,onSelect:h=>{if(h!==ht)switch(ht=h,ht){case"Depth":W.overrideMaterial=ma;break;case"Normals":W.overrideMaterial=ga;break;default:case"Renderer":W.overrideMaterial=null;break;case"Wireframe":W.overrideMaterial=ba;break;case"UVs":W.overrideMaterial=va;break}},open:l,onToggle:h=>{s&&d(!1),f(h),m&&b(!1)}}),c.jsx(dt,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:h=>{pt=h==="Selection Mode",et.visible=pt},open:m,onToggle:h=>{s&&d(!1),l&&f(!1),b(h)}})]})]})}const Da="";function wa(t){return c.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[c.jsx("header",{children:t.header}),t.children,c.jsx("footer",{children:t.footer})]})}w.Accordion=lt,w.Application=_n,w.BaseRemote=Ze,w.ChildObject=Dt,w.ContainerObject=sn,w.Draggable=tn,w.DraggableItem=en,w.Dropdown=nn,w.DropdownItem=an,w.Editor=wa,w.InfiniteGridHelper=rn,w.Inspector=fn,w.MultiView=Ea,w.NavButton=kt,w.RemoteComponents=Kt,w.RemoteController=Wn,w.RemoteTheatre=Oe,w.RemoteThree=Qt,w.RemoteTweakpane=jt,w.SceneInspector=fa,w.SidePanel=da,w.ToolEvents=A,w.UVMaterial=on,w.clamp=Rn,w.colorToHex=zt,w.debugDispatcher=D,w.dispose=Mt,w.disposeMaterial=Wt,w.disposeTexture=jn,w.distance=Pn,w.hierarchyUUID=Tt,w.isColor=Gt,w.randomID=Ht,w.resetThreeObjects=Yt,w.round=ct,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "module": "./dist/hermes.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "type": "module",
10
- "version": "0.0.22",
10
+ "version": "0.0.24",
11
11
  "homepage": "https://github.com/tomorrowevening/hermes#readme",
12
12
  "bugs": {
13
13
  "url": "https://github.com/tomorrowevening/hermes/issues"
@@ -33,13 +33,15 @@
33
33
  "import": "./dist/hermes.js",
34
34
  "require": "./dist/hermes.umd.cjs"
35
35
  },
36
- "./dist/style.css": "./dist/style.css"
36
+ "./dist/style.css": "./dist/style.css",
37
+ "./server/index.mjs": "./server/index.mjs"
37
38
  },
38
39
  "repository": {
39
40
  "type": "git",
40
41
  "url": "git+https://github.com/tomorrowevening/hermes.git"
41
42
  },
42
43
  "scripts": {
44
+ "server": "node server/index.mjs",
43
45
  "clean": "rm -r dist && rm -r types",
44
46
  "dev": "vite",
45
47
  "declare": "tsc --declaration --emitDeclarationOnly --declarationDir types",
@@ -75,6 +77,7 @@
75
77
  "path": "^0.12.7",
76
78
  "sass": "^1.66.1",
77
79
  "typescript": "^5.0.2",
78
- "vite": "^4.4.5"
80
+ "vite": "^4.4.5",
81
+ "ws": "^8.16.0"
79
82
  }
80
83
  }
@@ -2,15 +2,33 @@ import BaseRemote from './remote/BaseRemote';
2
2
  import type { ApplicationMode, BroadcastCallback, BroadcastData } from './types';
3
3
 
4
4
  export default class Application {
5
- channel?: BroadcastChannel | undefined = undefined;
6
5
  components: Map<string, any> = new Map();
7
-
6
+ listen?: BroadcastCallback;
7
+
8
8
  // Protected
9
+ protected _debugEnabled: boolean;
10
+ protected broadcastChannel?: BroadcastChannel | undefined = undefined;
11
+ protected webSocket?: WebSocket | undefined = undefined;
9
12
  protected _mode: ApplicationMode = 'app';
13
+ protected _connected = false;
14
+ protected useBC = false;
10
15
 
11
- constructor(name: string, debugEnabled: boolean, editorHashtag: string = 'editor') {
16
+ constructor(id: string, debugEnabled: boolean, useBC:boolean = true, editorHashtag: string = 'editor') {
12
17
  this.editor = debugEnabled && document.location.hash.search(editorHashtag) > -1;
13
- if (debugEnabled) this.channel = new BroadcastChannel(name);
18
+ this._debugEnabled = debugEnabled;
19
+
20
+ if (debugEnabled) {
21
+ this.useBC = useBC;
22
+ if (useBC) {
23
+ this.broadcastChannel = new BroadcastChannel(id);
24
+ this.broadcastChannel.addEventListener('message', this.messageHandler);
25
+ } else {
26
+ this.webSocket = new WebSocket(id);
27
+ this.webSocket.addEventListener('open', this.openHandler);
28
+ this.webSocket.addEventListener('close', this.closeHandler);
29
+ this.webSocket.addEventListener('message', this.messageHandler);
30
+ }
31
+ }
14
32
  }
15
33
 
16
34
  addComponent(name: string, component: BaseRemote) {
@@ -18,6 +36,14 @@ export default class Application {
18
36
  }
19
37
 
20
38
  dispose() {
39
+ if (this.broadcastChannel !== undefined) {
40
+ this.broadcastChannel.removeEventListener('message', this.messageHandler);
41
+ }
42
+ if (this.webSocket !== undefined) {
43
+ this.webSocket.removeEventListener('open', this.openHandler);
44
+ this.webSocket.removeEventListener('close', this.closeHandler);
45
+ this.webSocket.removeEventListener('message', this.messageHandler);
46
+ }
21
47
  this.components.forEach((value: BaseRemote) => {
22
48
  value.dispose();
23
49
  });
@@ -27,23 +53,43 @@ export default class Application {
27
53
  // Remote
28
54
 
29
55
  send(data: BroadcastData) {
30
- if (this.channel !== undefined) {
31
- if (this._mode !== data.target) {
32
- this.channel.postMessage(data);
56
+ if (this._mode !== data.target) {
57
+ if (this.useBC) {
58
+ this.broadcastChannel?.postMessage(data);
59
+ } else if (this._connected) {
60
+ this.webSocket?.send(JSON.stringify(data));
33
61
  }
34
62
  }
35
63
  }
36
64
 
37
- listen(callback: BroadcastCallback) {
38
- if (this.channel !== undefined) {
39
- this.channel.onmessage = (event: MessageEvent) => {
40
- callback(event.data);
41
- };
65
+ private messageHandler = (evt: MessageEvent) => {
66
+ if (this.listen !== undefined) {
67
+ if (this.useBC) {
68
+ this.listen(evt.data);
69
+ } else {
70
+ this.listen(JSON.parse(evt.data));
71
+ }
42
72
  }
43
- }
73
+ };
74
+
75
+ private openHandler = () => {
76
+ this._connected = true;
77
+ };
78
+
79
+ private closeHandler = () => {
80
+ this._connected = false;
81
+ };
44
82
 
45
83
  // Getters / Setters
46
84
 
85
+ get connected(): boolean {
86
+ return this._connected;
87
+ }
88
+
89
+ get debugEnabled(): boolean {
90
+ return this._debugEnabled;
91
+ }
92
+
47
93
  get mode(): ApplicationMode {
48
94
  return this._mode;
49
95
  }
@@ -48,11 +48,11 @@ export default function RemoteController(app: Application) {
48
48
 
49
49
  // Begin app
50
50
 
51
- app.listen((msg: BroadcastData) => {
52
- if (app.editor) {
51
+ app.listen = (msg: BroadcastData) => {
52
+ if (msg.target === 'editor') {
53
53
  handleEditorBroadcast(msg);
54
54
  } else {
55
55
  handleAppBroadcast(msg);
56
56
  }
57
- });
57
+ };
58
58
  }