@tomorrowevening/hermes 0.0.44 → 0.0.46

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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("three"),Nt=require("@theatre/studio"),fn=require("tweakpane"),pn=require("@tweakpane/plugin-essentials"),C=require("react"),Wt=require("framer-motion");function hn(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const t=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,t.get?t:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const mn=hn(pn),_t=()=>{},vn=()=>{};function Ke(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function gn(e,n,a){return Math.min(n,Math.max(e,a))}function bn(e,n){const a=e-n;return Math.sqrt(a*a)}function $t(){return Math.round(Math.random()*1e6).toString()}function qt(e){return e.r!==void 0&&e.g!==void 0&&e.b!==void 0}function Kt(e){const n=Math.round(e.r*255),a=Math.round(e.g*255),t=Math.round(e.b*255),r=d=>{const f=d.toString(16);return f.length===1?"0"+f:f},l=r(n),m=r(a),s=r(t);return"#"+l+m+s}function vt(e,n=1){return Number(e.toFixed(n))}exports.totalThreeObjects=0;const Xt=()=>{exports.totalThreeObjects=0},At=e=>{if(!e)return;let n=e.name.replace(" ","");n.length===0&&(n=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),e.parent!==null&&(n=`${e.parent.uuid}.${n}`),e.uuid=n,e.children.forEach(a=>{At(a)})},yn=e=>{e?.dispose()},Zt=e=>{e&&(Array.isArray(e)?e.forEach(n=>n.dispose()):e.dispose())},Pt=e=>{if(e){for(;e.children.length>0;){const n=e.children[0];n instanceof c.PositionalAudio?(n.pause(),n.parent&&n.parent.remove(n)):Pt(n)}if(e.parent&&e.parent.remove(e),e.isMesh){const n=e;n.geometry?.dispose(),Zt(n.material)}e.dispose!==void 0&&e.dispose()}};class En{components=new Map;listen;_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(n,a,t=!0){this._debugEnabled=a,a&&(this._useBC=t,t?(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){this._mode!==n.target&&(this._useBC?this._broadcastChannel?.postMessage(n):this._connected&&this._webSocket?.send(JSON.stringify(n)))}messageHandler=n=>{this.listen!==void 0&&(this._useBC?this.listen(n.data):this.listen(JSON.parse(n.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};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")}}const j=new c.EventDispatcher,D={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 rt{app;constructor(n){this.app=n}dispose(){}}class Sn extends rt{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 Cn(e,n,a){switch(a.event){case"selectComponent":j.dispatchEvent({type:D.SELECT_DROPDOWN,value:a.data});break;case"draggableListUpdate":j.dispatchEvent({type:D.DRAG_UPDATE,value:a.data});break}}function xn(e,n,a){let t;switch(a.event){case"setSheet":t=n.sheets.get(a.data.sheet),t!==void 0&&(n.activeSheet=t,Nt.setSelection([t]));break;case"setSheetObject":t=n.sheetObjects.get(`${a.data.sheet}_${a.data.key}`),t!==void 0&&Nt.setSelection([t]);break;case"updateSheetObject":t=n.sheets.get(a.data.sheet),t!==void 0&&t.sequence.pause(),t=n.sheetObjectCBs.get(a.data.sheetObject),t!==void 0&&t(a.data.values);break;case"updateTimeline":t=n.sheets.get(a.data.sheet),n.activeSheet!==void 0&&(n.activeSheet.sequence.position=a.data.position);break}}function wn(e,n,a){if(e.editor)switch(a.event){case"playSheet":n.sheet(a.data.sheet)?.sequence.play(a.data.value);break;case"pauseSheet":n.sheet(a.data.sheet)?.sequence.pause();break}}function On(e,n,a){switch(a.event){case"getObject":j.dispatchEvent({type:D.GET_OBJECT,value:a.data});break;case"updateObject":j.dispatchEvent({type:D.UPDATE_OBJECT,value:a.data});break;case"createTexture":j.dispatchEvent({type:D.CREATE_TEXTURE,value:a.data});break;case"requestMethod":j.dispatchEvent({type:D.REQUEST_METHOD,value:a.data});break}}function Mn(e,n,a){switch(a.event){case"setObject":j.dispatchEvent({type:D.SET_OBJECT,value:a.data});break;case"setScene":j.dispatchEvent({type:D.SET_SCENE,value:a.data});break;case"addCamera":j.dispatchEvent({type:D.ADD_CAMERA,value:a.data});break;case"removeCamera":j.dispatchEvent({type:D.REMOVE_CAMERA,value:a.data});break}}function Tn(e,n,a){switch(a.event){case"addFolder":n.addFolder(a.data.name,a.data.params,a.data.parent);break;case"bindObject":n.bind(a.data.name,a.data.params,a.data.parent);break;case"updateBind":n.triggerBind(a.data.id,a.data.value);break;case"addButton":n.button(a.data.name,a.data.callback,a.data.parent);break;case"clickButton":n.triggerButton(a.data.id);break}}class Jt extends rt{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;static rafDriver=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let a=this.sheets.get(n);return a!==void 0||(a=this.project?.sheet(n),this.sheets.set(n,a)),a}playSheet(n,a){this.sheet(n)?.sequence.play(a),this.app.send({event:"playSheet",target:"editor",data:{sheet:n,value:a}})}pauseSheet(n){this.sheet(n)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:n}})}clearSheetObjects(n){this.sheetObjects.forEach((a,t)=>{t.search(`${n}_`)>-1&&this.unsubscribe(a)})}sheetObject(n,a,t,r){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const l=this.sheet(n);if(l===void 0)return;const m=`${n}_${a}`;let s=this.sheetObjects.get(m);s!==void 0?s=l.object(a,{...t,...s.value},{reconfigure:!0}):s=l.object(a,t),this.sheetObjects.set(m,s),this.sheetObjectCBs.set(m,r!==void 0?r:_t);const d=s.onValuesChange(f=>{if(this.app.editor){for(const y in f){const S=f[y];typeof S=="object"&&qt(S)&&(f[y]={r:S.r,g:S.g,b:S.b,a:S.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:n,sheetObject:m,values:f}})}const g=this.sheetObjectCBs.get(m);g!==void 0&&g(f)});return this.sheetObjectUnsubscribe.set(m,d),s}unsubscribe(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const a=n.address.sheetId,t=n.address.objectKey;this.sheets.get(a)?.detachObject(t);const l=`${a}_${t}`,m=this.sheetObjectUnsubscribe.get(l);m!==void 0&&(this.sheetObjects.delete(l),this.sheetObjectCBs.delete(l),this.sheetObjectUnsubscribe.delete(l),m())}}function Rn(e,n,a){if(e.editor){a.ui.restore(),a.onSelectionChange(m=>{m.length<1||m.forEach(s=>{let d=s.address.sheetId,f="setSheet",g={};switch(s.type){case"Theatre_Sheet_PublicAPI":f="setSheet",g={sheet:s.address.sheetId},n.activeSheet=n.sheets.get(s.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":f="setSheetObject",d+=`_${s.address.objectKey}`,g={id:d,sheet:s.address.sheetId,key:s.address.objectKey},n.activeSheet=n.sheets.get(s.address.sheetId);break}e.send({event:f,target:"app",data:g})})});let t=-1;const r=()=>{if(Jt.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&t!==n.activeSheet.sequence.position){t=n.activeSheet.sequence.position;const m=n.activeSheet;e.send({event:"updateTimeline",target:"app",data:{position:t,sheet:m.address.sheetId}})}},l=()=>{r(),requestAnimationFrame(l)};r(),l()}else a.ui.hide()}function _n(e){if(e.name==="cameras")return"camera";if(e.name==="interactive")return"interactive";if(e.name==="lights")return"light";if(e.name==="ui")return"ui";if(e.name==="utils")return"utils";const n=e.type;return n.search("Helper")>-1?"icon_utils":n.search("Camera")>-1?"camera":n.search("Light")>-1?"light":"obj3D"}function Qt(e){const n={name:e.name,type:e.type,uuid:e.uuid,children:[]};return e.children.forEach(a=>{n.children.push(Qt(a))}),n}function An(e){const n={};for(const a in e){const t=e[a].value;n[a]={value:t},t===null?n[a].value={src:""}:t.isTexture&&(n[a].value={src:t.image.src})}return n}function Pn(e){switch(e){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function We(e){const n={};for(const a in e){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||Pn(a))continue;const t=typeof e[a],r=e[a];switch(t){case"boolean":case"number":case"string":n[a]=r;break;case"object":if(r!==null)if(n[a]=r,r.isTexture)if(r instanceof c.Texture){const l=r.source.toJSON();n[a]={src:l.url}}else r instanceof c.CubeTexture&&(console.log("env map"),console.log(r.source.data),console.log(r.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=An(n[a]));else n[a]={src:""};break}}return n}function wt(e){e.updateMatrix();const n={name:e.name,type:e.type,uuid:e.uuid,visible:e.visible,matrix:e.matrix.elements,animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0};e.animations.forEach(t=>{n.animations.push({name:t.name,duration:t.duration,blendMode:t.blendMode})});const a=e.type.toLowerCase();if(a.search("mesh")>-1){const t=e;if(Array.isArray(t.material)){const r=[];t.material.forEach(l=>{r.push(We(l))}),n.material=r}else n.material=We(t.material)}else if(a.search("points")>-1){const t=e;if(Array.isArray(t.material)){const r=[];t.material.forEach(l=>{r.push(We(l))}),n.material=r}else n.material=We(t.material)}else if(a.search("line")>-1){const t=e;if(Array.isArray(t.material)){const r=[];t.material.forEach(l=>{r.push(We(l))}),n.material=r}else n.material=We(t.material)}else a.search("camera")>-1?e.type==="PerspectiveCamera"?n.perspectiveCameraInfo={fov:e.fov,zoom:e.zoom,near:e.near,far:e.far,focus:e.focus,aspect:e.aspect,filmGauge:e.filmGauge,filmOffset:e.filmOffset}:e.type==="OrthographicCamera"&&(n.orthographicCameraInfo={zoom:e.zoom,near:e.near,far:e.far,left:e.left,right:e.right,top:e.top,bottom:e.bottom}):a.search("light")>-1&&(n.lightInfo={color:e.color,intensity:e.intensity,decay:e.decay,distance:e.distance,angle:e.angle,penumbra:e.penumbra,groundColor:e.groundColor});return n}function kn(e,n){const a=n.split(".");switch(a.length){case 1:return e[a[0]];case 2:return e[a[0]][a[1]];case 3:return e[a[0]][a[1]][a[2]];case 4:return e[a[0]][a[1]][a[2]][a[3]];case 5:return e[a[0]][a[1]][a[2]][a[3]][a[4]];case 6:return e[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]]}}function te(e,n,a){const t=n.split(".");switch(t.length){case 1:e[t[0]]=a;break;case 2:e[t[0]][t[1]]=a;break;case 3:e[t[0]][t[1]][t[2]]=a;break;case 4:e[t[0]][t[1]][t[2]][t[3]]=a;break;case 5:e[t[0]][t[1]][t[2]][t[3]][t[4]]=a;break}}function Tt(e){return new Promise((n,a)=>{const t=new Image;t.onload=()=>{const r=new c.Texture(t);r.wrapS=c.RepeatWrapping,r.wrapT=c.RepeatWrapping,r.needsUpdate=!0,n(r)},t.onerror=a,t.src=e})}class jn extends rt{scene=void 0;getObject(n){this.app.debugEnabled&&this.app.send({event:"getObject",target:"app",data:n})}setObject(n){const a=wt(n);this.app.send({event:"setObject",target:"editor",data:a})}requestMethod(n,a,t,r){this.app.send({event:"requestMethod",target:"app",data:{uuid:n,key:a,value:t,subitem:r}})}updateObject(n,a,t){this.app.send({event:"updateObject",target:"app",data:{uuid:n,key:a,value:t}})}createTexture(n,a,t){this.app.send({event:"createTexture",target:"app",data:{uuid:n,key:a,value:t}})}setScene(n){if(n===void 0||(this.scene=n,!this.app.debugEnabled))return;Xt(),At(this.scene);const a=Qt(this.scene);this.app.send({event:"setScene",target:"editor",data:a})}addCamera(n){if(!this.app.debugEnabled)return;const a=wt(n);this.app.send({event:"addCamera",target:"editor",data:a})}removeCamera(n){if(!this.app.debugEnabled)return;const a=wt(n);this.app.send({event:"removeCamera",target:"editor",data:a})}}class Dn extends rt{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(n){super(n),this.bindCBs=new Map,this.buttonCBs=new Map,n.editor&&this.createGUI()}createGUI(){this.pane=new fn.Pane({title:"GUI"}),this.pane.registerPlugin(mn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(n,a=void 0,t=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addFolder({title:n,...a});this.app.send({event:"addFolder",target:"app",data:{name:n,params:a,parent:t}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(n,a,t,r=void 0){const l=this.bindID,m=t.onChange!==void 0?t.onChange:_t;this.bindCBs.set(l,m),this.app.editor?(this.pane===void 0&&this.createGUI(),(r!==void 0?r:this.pane).addBinding(n,a,t).on("change",d=>{this.app.send({event:"updateBind",target:"app",data:{id:l,value:d.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:l,name:a,params:t,parent:r}}),this.appCallbacks++)}triggerBind(n,a){const t=this.bindCBs.get(n);t!==void 0?t(a):console.warn(`No callback for: ${n}`,a)}button(n,a,t=void 0){const r=this.bindID;this.buttonCBs.set(r,a),this.app.editor?(this.pane===void 0&&this.createGUI(),(t!==void 0?t:this.pane).addButton({title:n}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:r}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:r,name:n,callback:a,parent:t}}),this.appCallbacks++)}triggerButton(n){const a=this.buttonCBs.get(n);a!==void 0&&a()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const n=this.inspectorFolder.children.length-1;for(let a=n;a>-1;--a)this.inspectorFolder.remove(this.inspectorFolder.children[a])}}var Rt={exports:{}},tt={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("three"),un=require("tweakpane"),dn=require("@tweakpane/plugin-essentials"),C=require("react"),Ht=require("framer-motion");function hn(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 fn=hn(dn),_t=()=>{},pn=()=>{};function qe(t){return t.substring(0,1).toUpperCase()+t.substring(1)}function mn(t,n,a){return Math.min(n,Math.max(t,a))}function vn(t,n){const a=t-n;return Math.sqrt(a*a)}function Wt(){return Math.round(Math.random()*1e6).toString()}function $t(t){return t.r!==void 0&&t.g!==void 0&&t.b!==void 0}function qt(t){const n=Math.round(t.r*255),a=Math.round(t.g*255),e=Math.round(t.b*255),i=d=>{const h=d.toString(16);return h.length===1?"0"+h:h},s=i(n),f=i(a),c=i(e);return"#"+s+f+c}function mt(t,n=1){return Number(t.toFixed(n))}exports.totalThreeObjects=0;const Kt=()=>{exports.totalThreeObjects=0},At=t=>{if(!t)return;let n=t.name.replace(" ","");n.length===0&&(n=`obj_${exports.totalThreeObjects}`,exports.totalThreeObjects++),t.parent!==null&&(n=`${t.parent.uuid}.${n}`),t.uuid=n,t.children.forEach(a=>{At(a)})},gn=t=>{t?.dispose()},Xt=t=>{t&&(Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose())},Pt=t=>{if(t){for(;t.children.length>0;){const n=t.children[0];n.type==="Audio"?(n.pause(),n.parent&&n.parent.remove(n)):Pt(n)}if(t.parent&&t.parent.remove(t),t.isMesh){const n=t;n.geometry?.dispose(),Xt(n.material)}t.dispose!==void 0&&t.dispose()}};class bn{components=new Map;listen;_debugEnabled;_broadcastChannel=void 0;_webSocket=void 0;_mode="app";_connected=!1;_useBC=!1;constructor(n,a,e=!0){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){this._mode!==n.target&&(this._useBC?this._broadcastChannel?.postMessage(n):this._connected&&this._webSocket?.send(JSON.stringify(n)))}messageHandler=n=>{this.listen!==void 0&&(this._useBC?this.listen(n.data):this.listen(JSON.parse(n.data)))};openHandler=()=>{this._connected=!0};closeHandler=()=>{this._connected=!1};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")}}const j=new l.EventDispatcher,D={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 it{app;constructor(n){this.app=n}dispose(){}handleApp(n,a,e){}handleEditor(n,a,e){}}class yn extends it{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}})}handleApp(n,a,e){switch(e.event){case"selectComponent":j.dispatchEvent({type:D.SELECT_DROPDOWN,value:e.data});break;case"draggableListUpdate":j.dispatchEvent({type:D.DRAG_UPDATE,value:e.data});break}}}class gt extends it{project;sheets=new Map;sheetObjects=new Map;sheetObjectCBs=new Map;sheetObjectUnsubscribe=new Map;activeSheet;studio;static rafDriver=void 0;dispose(){this.project=void 0,this.sheets=new Map,this.sheetObjects=new Map,this.sheetObjectCBs=new Map,this.sheetObjectUnsubscribe=new Map}sheet(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}let a=this.sheets.get(n);return a!==void 0||(a=this.project?.sheet(n),this.sheets.set(n,a)),a}playSheet(n,a){this.sheet(n)?.sequence.play(a),this.app.send({event:"playSheet",target:"editor",data:{sheet:n,value:a}})}pauseSheet(n){this.sheet(n)?.sequence.pause(),this.app.send({event:"pauseSheet",target:"editor",data:{sheet:n}})}clearSheetObjects(n){this.sheetObjects.forEach((a,e)=>{e.search(`${n}_`)>-1&&this.unsubscribe(a)})}sheetObject(n,a,e,i){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const s=this.sheet(n);if(s===void 0)return;const f=`${n}_${a}`;let c=this.sheetObjects.get(f);c!==void 0?c=s.object(a,{...e,...c.value},{reconfigure:!0}):c=s.object(a,e),this.sheetObjects.set(f,c),this.sheetObjectCBs.set(f,i!==void 0?i:_t);const d=c.onValuesChange(h=>{if(this.app.editor){for(const y in h){const S=h[y];typeof S=="object"&&$t(S)&&(h[y]={r:S.r,g:S.g,b:S.b,a:S.a})}this.app.send({event:"updateSheetObject",target:"app",data:{sheet:n,sheetObject:f,values:h}})}const g=this.sheetObjectCBs.get(f);g!==void 0&&g(h)});return this.sheetObjectUnsubscribe.set(f,d),c}unsubscribe(n){if(this.project===void 0){console.error("Theatre Project hasn't been created yet.");return}const a=n.address.sheetId,e=n.address.objectKey;this.sheets.get(a)?.detachObject(e);const s=`${a}_${e}`,f=this.sheetObjectUnsubscribe.get(s);f!==void 0&&(this.sheetObjects.delete(s),this.sheetObjectCBs.delete(s),this.sheetObjectUnsubscribe.delete(s),f())}handleApp(n,a,e){const i=a;let s;switch(e.event){case"setSheet":s=i.sheets.get(e.data.sheet),s!==void 0&&(i.activeSheet=s,this.studio.setSelection([s]));break;case"setSheetObject":s=i.sheetObjects.get(`${e.data.sheet}_${e.data.key}`),s!==void 0&&this.studio.setSelection([s]);break;case"updateSheetObject":s=i.sheets.get(e.data.sheet),s!==void 0&&s.sequence.pause(),s=i.sheetObjectCBs.get(e.data.sheetObject),s!==void 0&&s(e.data.values);break;case"updateTimeline":s=i.sheets.get(e.data.sheet),i.activeSheet!==void 0&&(i.activeSheet.sequence.position=e.data.position);break}}handleEditor(n,a,e){if(n.editor){const i=a;switch(e.event){case"playSheet":i.sheet(e.data.sheet)?.sequence.play(e.data.value);break;case"pauseSheet":i.sheet(e.data.sheet)?.sequence.pause();break}}}handleEditorApp(n,a){if(n.editor){this.studio.ui.restore(),this.studio.onSelectionChange(f=>{f.length<1||f.forEach(c=>{let d=c.address.sheetId,h="setSheet",g={};switch(c.type){case"Theatre_Sheet_PublicAPI":h="setSheet",g={sheet:c.address.sheetId},a.activeSheet=a.sheets.get(c.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":h="setSheetObject",d+=`_${c.address.objectKey}`,g={id:d,sheet:c.address.sheetId,key:c.address.objectKey},a.activeSheet=a.sheets.get(c.address.sheetId);break}n.send({event:h,target:"app",data:g})})});let e=-1;const i=()=>{if(gt.rafDriver?.tick(performance.now()),a.activeSheet!==void 0&&e!==a.activeSheet.sequence.position){e=a.activeSheet.sequence.position;const f=a.activeSheet;n.send({event:"updateTimeline",target:"app",data:{position:e,sheet:f.address.sheetId}})}},s=()=>{i(),requestAnimationFrame(s)};i(),s()}else this.studio.ui.hide()}}function En(t,n,a){if(t.editor){a.ui.restore(),a.onSelectionChange(f=>{f.length<1||f.forEach(c=>{let d=c.address.sheetId,h="setSheet",g={};switch(c.type){case"Theatre_Sheet_PublicAPI":h="setSheet",g={sheet:c.address.sheetId},n.activeSheet=n.sheets.get(c.address.sheetId);break;case"Theatre_SheetObject_PublicAPI":h="setSheetObject",d+=`_${c.address.objectKey}`,g={id:d,sheet:c.address.sheetId,key:c.address.objectKey},n.activeSheet=n.sheets.get(c.address.sheetId);break}t.send({event:h,target:"app",data:g})})});let e=-1;const i=()=>{if(gt.rafDriver?.tick(performance.now()),n.activeSheet!==void 0&&e!==n.activeSheet.sequence.position){e=n.activeSheet.sequence.position;const f=n.activeSheet;t.send({event:"updateTimeline",target:"app",data:{position:e,sheet:f.address.sheetId}})}},s=()=>{i(),requestAnimationFrame(s)};i(),s()}else a.ui.hide()}function Sn(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 Cn(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 xn(t){switch(t){case"blendSrcAlpha":case"blendDstAlpha":case"blendEquationAlpha":case"clippingPlanes":case"shadowSide":case"precision":return!0}return!1}function We(t){const n={};for(const a in t){if(a.substring(0,1)==="_"||a.substring(0,2)==="is"||xn(a))continue;const e=typeof t[a],i=t[a];switch(e){case"boolean":case"number":case"string":n[a]=i;break;case"object":if(i!==null)if(n[a]=i,i.isTexture)if(i instanceof l.Texture){const s=i.source.toJSON();n[a]={src:s.url}}else i instanceof l.CubeTexture&&(console.log("env map"),console.log(i.source.data),console.log(i.source.toJSON()),n[a]={src:""});else a==="uniforms"&&(n[a]=Cn(n[a]));else n[a]={src:""};break}}return n}function wt(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 i=[];e.material.forEach(s=>{i.push(We(s))}),n.material=i}else n.material=We(e.material)}else if(a.search("points")>-1){const e=t;if(Array.isArray(e.material)){const i=[];e.material.forEach(s=>{i.push(We(s))}),n.material=i}else n.material=We(e.material)}else if(a.search("line")>-1){const e=t;if(Array.isArray(e.material)){const i=[];e.material.forEach(s=>{i.push(We(s))}),n.material=i}else n.material=We(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 wn(t,n){const a=n.split(".");switch(a.length){case 1:return t[a[0]];case 2:return t[a[0]][a[1]];case 3:return t[a[0]][a[1]][a[2]];case 4:return t[a[0]][a[1]][a[2]][a[3]];case 5:return t[a[0]][a[1]][a[2]][a[3]][a[4]];case 6:return t[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]]}}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 Tt(t){return new Promise((n,a)=>{const e=new Image;e.onload=()=>{const i=new l.Texture(e);i.wrapS=l.RepeatWrapping,i.wrapT=l.RepeatWrapping,i.needsUpdate=!0,n(i)},e.onerror=a,e.src=t})}class On extends it{scene=void 0;renderer=void 0;getObject(n){this.app.debugEnabled&&this.app.send({event:"getObject",target:"app",data:n})}setObject(n){const a=wt(n);this.app.send({event:"setObject",target:"editor",data:a})}requestMethod(n,a,e,i){this.app.send({event:"requestMethod",target:"app",data:{uuid:n,key:a,value:e,subitem:i}})}updateObject(n,a,e){this.app.send({event:"updateObject",target:"app",data:{uuid:n,key:a,value:e}})}createTexture(n,a,e){this.app.send({event:"createTexture",target:"app",data:{uuid:n,key:a,value:e}})}setScene(n){if(n===void 0||(this.scene=n,!this.app.debugEnabled))return;Kt(),At(this.scene);const a=Zt(this.scene);this.app.send({event:"setScene",target:"editor",data:a})}addCamera(n){if(!this.app.debugEnabled)return;const a=wt(n);this.app.send({event:"addCamera",target:"editor",data:a})}removeCamera(n){if(!this.app.debugEnabled)return;const a=wt(n);this.app.send({event:"removeCamera",target:"editor",data:a})}handleApp(n,a,e){switch(e.event){case"getObject":j.dispatchEvent({type:D.GET_OBJECT,value:e.data});break;case"updateObject":j.dispatchEvent({type:D.UPDATE_OBJECT,value:e.data});break;case"createTexture":j.dispatchEvent({type:D.CREATE_TEXTURE,value:e.data});break;case"requestMethod":j.dispatchEvent({type:D.REQUEST_METHOD,value:e.data});break}}handleEditor(n,a,e){switch(e.event){case"setObject":j.dispatchEvent({type:D.SET_OBJECT,value:e.data});break;case"setScene":j.dispatchEvent({type:D.SET_SCENE,value:e.data});break;case"addCamera":j.dispatchEvent({type:D.ADD_CAMERA,value:e.data});break;case"removeCamera":j.dispatchEvent({type:D.REMOVE_CAMERA,value:e.data});break}}}class Mn extends it{bindCBs;buttonCBs;pane=void 0;appCallbacks=0;editorCallbacks=0;inspectorFolder=void 0;constructor(n){super(n),this.bindCBs=new Map,this.buttonCBs=new Map,n.editor&&this.createGUI()}createGUI(){this.pane=new un.Pane({title:"GUI"}),this.pane.registerPlugin(fn)}dispose(){this.bindCBs.clear(),this.buttonCBs.clear(),this.appCallbacks=0,this.editorCallbacks=0,this.app.editor&&(this.pane?.dispose(),this.pane=void 0)}addFolder(n,a=void 0,e=void 0){if(this.app.editor)return this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addFolder({title:n,...a});this.app.send({event:"addFolder",target:"app",data:{name:n,params:a,parent:e}})}get bindID(){return`debug_${Math.max(this.appCallbacks,this.editorCallbacks)}`}bind(n,a,e,i=void 0){const s=this.bindID,f=e.onChange!==void 0?e.onChange:_t;this.bindCBs.set(s,f),this.app.editor?(this.pane===void 0&&this.createGUI(),(i!==void 0?i:this.pane).addBinding(n,a,e).on("change",d=>{this.app.send({event:"updateBind",target:"app",data:{id:s,value:d.value}})}),this.editorCallbacks++):(this.app.send({event:"bindObject",target:"app",data:{id:s,name:a,params:e,parent:i}}),this.appCallbacks++)}triggerBind(n,a){const e=this.bindCBs.get(n);e!==void 0?e(a):console.warn(`No callback for: ${n}`,a)}button(n,a,e=void 0){const i=this.bindID;this.buttonCBs.set(i,a),this.app.editor?(this.pane===void 0&&this.createGUI(),(e!==void 0?e:this.pane).addButton({title:n}).on("click",()=>{this.app.send({event:"clickButton",target:"app",data:{id:i}})}),this.editorCallbacks++):(this.app.send({event:"addButton",target:"app",data:{id:i,name:n,callback:a,parent:e}}),this.appCallbacks++)}triggerButton(n){const a=this.buttonCBs.get(n);a!==void 0&&a()}createInspector(){this.inspectorFolder=this.addFolder("Inspector",this.pane)}clearInspector(){const n=this.inspectorFolder.children.length-1;for(let a=n;a>-1;--a)this.inspectorFolder.remove(this.inspectorFolder.children[a])}handleApp(n,a,e){const i=a;switch(e.event){case"addFolder":i.addFolder(e.data.name,e.data.params,e.data.parent);break;case"bindObject":i.bind(e.data.name,e.data.params,e.data.parent);break;case"updateBind":i.triggerBind(e.data.id,e.data.value);break;case"addButton":i.button(e.data.name,e.data.callback,e.data.parent);break;case"clickButton":i.triggerButton(e.data.id);break}}}var Rt={exports:{}},et={};/**
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 Lt;function In(){if(Lt)return tt;Lt=1;var e=C,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function m(s,d,f){var g,y={},S=null,x=null;f!==void 0&&(S=""+f),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(x=d.ref);for(g in d)t.call(d,g)&&!l.hasOwnProperty(g)&&(y[g]=d[g]);if(s&&s.defaultProps)for(g in d=s.defaultProps,d)y[g]===void 0&&(y[g]=d[g]);return{$$typeof:n,type:s,key:S,ref:x,props:y,_owner:r.current}}return tt.Fragment=a,tt.jsx=m,tt.jsxs=m,tt}var nt={};/**
9
+ */var Nt;function Tn(){if(Nt)return et;Nt=1;var t=C,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function f(c,d,h){var g,y={},S=null,x=null;h!==void 0&&(S=""+h),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(x=d.ref);for(g in d)e.call(d,g)&&!s.hasOwnProperty(g)&&(y[g]=d[g]);if(c&&c.defaultProps)for(g in d=c.defaultProps,d)y[g]===void 0&&(y[g]=d[g]);return{$$typeof:n,type:c,key:S,ref:x,props:y,_owner:i.current}}return et.Fragment=a,et.jsx=f,et.jsxs=f,et}var tt={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,20 +14,20 @@
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 Ft;function Nn(){return Ft||(Ft=1,process.env.NODE_ENV!=="production"&&function(){var e=C,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),s=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),N=Symbol.iterator,L="@@iterator";function K(i){if(i===null||typeof i!="object")return null;var p=N&&i[N]||i[L];return typeof p=="function"?p:null}var V=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(i){{for(var p=arguments.length,b=new Array(p>1?p-1:0),w=1;w<p;w++)b[w-1]=arguments[w];H("error",i,b)}}function H(i,p,b){{var w=V.ReactDebugCurrentFrame,I=w.getStackAddendum();I!==""&&(p+="%s",b=b.concat([I]));var U=b.map(function(k){return String(k)});U.unshift("Warning: "+p),Function.prototype.apply.call(console[i],console,U)}}var Ce=!1,ce=!1,G=!1,ee=!1,O=!1,Me;Me=Symbol.for("react.module.reference");function De(i){return!!(typeof i=="string"||typeof i=="function"||i===t||i===l||O||i===r||i===f||i===g||ee||i===x||Ce||ce||G||typeof i=="object"&&i!==null&&(i.$$typeof===S||i.$$typeof===y||i.$$typeof===m||i.$$typeof===s||i.$$typeof===d||i.$$typeof===Me||i.getModuleId!==void 0))}function xe(i,p,b){var w=i.displayName;if(w)return w;var I=p.displayName||p.name||"";return I!==""?b+"("+I+")":b}function he(i){return i.displayName||"Context"}function ne(i){if(i==null)return null;if(typeof i.tag=="number"&&R("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 t:return"Fragment";case a:return"Portal";case l:return"Profiler";case r:return"StrictMode";case f:return"Suspense";case g:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case s:var p=i;return he(p)+".Consumer";case m:var b=i;return he(b._context)+".Provider";case d:return xe(i,i.render,"ForwardRef");case y:var w=i.displayName||null;return w!==null?w:ne(i.type)||"Memo";case S:{var I=i,U=I._payload,k=I._init;try{return ne(k(U))}catch{return null}}}return null}var de=Object.assign,me=0,ve,X,pe,Te,Re,fe,h;function v(){}v.__reactDisabledLog=!0;function M(){{if(me===0){ve=console.log,X=console.info,pe=console.warn,Te=console.error,Re=console.group,fe=console.groupCollapsed,h=console.groupEnd;var i={configurable:!0,enumerable:!0,value:v,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}me++}}function A(){{if(me--,me===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:de({},i,{value:ve}),info:de({},i,{value:X}),warn:de({},i,{value:pe}),error:de({},i,{value:Te}),group:de({},i,{value:Re}),groupCollapsed:de({},i,{value:fe}),groupEnd:de({},i,{value:h})})}me<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var W=V.ReactCurrentDispatcher,$;function ie(i,p,b){{if($===void 0)try{throw Error()}catch(I){var w=I.stack.trim().match(/\n( *(at )?)/);$=w&&w[1]||""}return`
18
- `+$+i}}var z=!1,Z;{var re=typeof WeakMap=="function"?WeakMap:Map;Z=new re}function P(i,p){if(!i||z)return"";{var b=Z.get(i);if(b!==void 0)return b}var w;z=!0;var I=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var U;U=W.current,W.current=null,M();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(Oe){w=Oe}Reflect.construct(i,[],k)}else{try{k.call()}catch(Oe){w=Oe}i.call(k.prototype)}}else{try{throw Error()}catch(Oe){w=Oe}i()}}catch(Oe){if(Oe&&w&&typeof Oe.stack=="string"){for(var _=Oe.stack.split(`
17
+ */var Lt;function Rn(){return Lt||(Lt=1,process.env.NODE_ENV!=="production"&&function(){var t=C,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),N=Symbol.iterator,L="@@iterator";function K(r){if(r===null||typeof r!="object")return null;var p=N&&r[N]||r[L];return typeof p=="function"?p:null}var V=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(r){{for(var p=arguments.length,b=new Array(p>1?p-1:0),w=1;w<p;w++)b[w-1]=arguments[w];G("error",r,b)}}function G(r,p,b){{var w=V.ReactDebugCurrentFrame,I=w.getStackAddendum();I!==""&&(p+="%s",b=b.concat([I]));var U=b.map(function(k){return String(k)});U.unshift("Warning: "+p),Function.prototype.apply.call(console[r],console,U)}}var Ce=!1,ce=!1,H=!1,ee=!1,O=!1,Me;Me=Symbol.for("react.module.reference");function De(r){return!!(typeof r=="string"||typeof r=="function"||r===e||r===s||O||r===i||r===h||r===g||ee||r===x||Ce||ce||H||typeof r=="object"&&r!==null&&(r.$$typeof===S||r.$$typeof===y||r.$$typeof===f||r.$$typeof===c||r.$$typeof===d||r.$$typeof===Me||r.getModuleId!==void 0))}function xe(r,p,b){var w=r.displayName;if(w)return w;var I=p.displayName||p.name||"";return I!==""?b+"("+I+")":b}function pe(r){return r.displayName||"Context"}function ne(r){if(r==null)return null;if(typeof r.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case e:return"Fragment";case a:return"Portal";case s:return"Profiler";case i:return"StrictMode";case h:return"Suspense";case g:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case c:var p=r;return pe(p)+".Consumer";case f:var b=r;return pe(b._context)+".Provider";case d:return xe(r,r.render,"ForwardRef");case y:var w=r.displayName||null;return w!==null?w:ne(r.type)||"Memo";case S:{var I=r,U=I._payload,k=I._init;try{return ne(k(U))}catch{return null}}}return null}var de=Object.assign,me=0,ve,X,fe,Te,Re,he,m;function v(){}v.__reactDisabledLog=!0;function M(){{if(me===0){ve=console.log,X=console.info,fe=console.warn,Te=console.error,Re=console.group,he=console.groupCollapsed,m=console.groupEnd;var r={configurable:!0,enumerable:!0,value:v,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}me++}}function A(){{if(me--,me===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:de({},r,{value:ve}),info:de({},r,{value:X}),warn:de({},r,{value:fe}),error:de({},r,{value:Te}),group:de({},r,{value:Re}),groupCollapsed:de({},r,{value:he}),groupEnd:de({},r,{value:m})})}me<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var W=V.ReactCurrentDispatcher,$;function ie(r,p,b){{if($===void 0)try{throw Error()}catch(I){var w=I.stack.trim().match(/\n( *(at )?)/);$=w&&w[1]||""}return`
18
+ `+$+r}}var z=!1,Z;{var re=typeof WeakMap=="function"?WeakMap:Map;Z=new re}function P(r,p){if(!r||z)return"";{var b=Z.get(r);if(b!==void 0)return b}var w;z=!0;var I=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var U;U=W.current,W.current=null,M();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(Oe){w=Oe}Reflect.construct(r,[],k)}else{try{k.call()}catch(Oe){w=Oe}r.call(k.prototype)}}else{try{throw Error()}catch(Oe){w=Oe}r()}}catch(Oe){if(Oe&&w&&typeof Oe.stack=="string"){for(var _=Oe.stack.split(`
19
19
  `),ue=w.stack.split(`
20
20
  `),J=_.length-1,Q=ue.length-1;J>=1&&Q>=0&&_[J]!==ue[Q];)Q--;for(;J>=1&&Q>=0;J--,Q--)if(_[J]!==ue[Q]){if(J!==1||Q!==1)do if(J--,Q--,Q<0||_[J]!==ue[Q]){var ye=`
21
- `+_[J].replace(" at new "," at ");return i.displayName&&ye.includes("<anonymous>")&&(ye=ye.replace("<anonymous>",i.displayName)),typeof i=="function"&&Z.set(i,ye),ye}while(J>=1&&Q>=0);break}}}finally{z=!1,W.current=U,A(),Error.prepareStackTrace=I}var Ge=i?i.displayName||i.name:"",It=Ge?ie(Ge):"";return typeof i=="function"&&Z.set(i,It),It}function B(i,p,b){return P(i,!1)}function ae(i){var p=i.prototype;return!!(p&&p.isReactComponent)}function Ee(i,p,b){if(i==null)return"";if(typeof i=="function")return P(i,ae(i));if(typeof i=="string")return ie(i);switch(i){case f:return ie("Suspense");case g:return ie("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case d:return B(i.render);case y:return Ee(i.type,p,b);case S:{var w=i,I=w._payload,U=w._init;try{return Ee(U(I),p,b)}catch{}}}return""}var we=Object.prototype.hasOwnProperty,ot={},st=V.ReactDebugCurrentFrame;function Ie(i){if(i){var p=i._owner,b=Ee(i.type,i._source,p?p.type:null);st.setExtraStackFrame(b)}else st.setExtraStackFrame(null)}function Xe(i,p,b,w,I){{var U=Function.call.bind(we);for(var k in i)if(U(i,k)){var _=void 0;try{if(typeof i[k]!="function"){var ue=Error((w||"React class")+": "+b+" 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 ue.name="Invariant Violation",ue}_=i[k](p,k,w,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){_=J}_&&!(_ instanceof Error)&&(Ie(I),R("%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).",w||"React class",b,k,typeof _),Ie(null)),_ instanceof Error&&!(_.message in ot)&&(ot[_.message]=!0,Ie(I),R("Failed %s type: %s",b,_.message),Ie(null))}}}var Ne=Array.isArray;function Ze(i){return Ne(i)}function yt(i){{var p=typeof Symbol=="function"&&Symbol.toStringTag,b=p&&i[Symbol.toStringTag]||i.constructor.name||"Object";return b}}function ct(i){try{return lt(i),!1}catch{return!0}}function lt(i){return""+i}function ut(i){if(ct(i))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",yt(i)),lt(i)}var _e=V.ReactCurrentOwner,Je={key:!0,ref:!0,__self:!0,__source:!0},Qe,dt,He;He={};function Et(i){if(we.call(i,"ref")){var p=Object.getOwnPropertyDescriptor(i,"ref").get;if(p&&p.isReactWarning)return!1}return i.ref!==void 0}function St(i){if(we.call(i,"key")){var p=Object.getOwnPropertyDescriptor(i,"key").get;if(p&&p.isReactWarning)return!1}return i.key!==void 0}function ft(i,p){if(typeof i.ref=="string"&&_e.current&&p&&_e.current.stateNode!==p){var b=ne(_e.current.type);He[b]||(R('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',ne(_e.current.type),i.ref),He[b]=!0)}}function Ae(i,p){{var b=function(){Qe||(Qe=!0,R("%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))};b.isReactWarning=!0,Object.defineProperty(i,"key",{get:b,configurable:!0})}}function Dt(i,p){{var b=function(){dt||(dt=!0,R("%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))};b.isReactWarning=!0,Object.defineProperty(i,"ref",{get:b,configurable:!0})}}var o=function(i,p,b,w,I,U,k){var _={$$typeof:n,type:i,key:p,ref:b,props:k,_owner:U};return _._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(_,"_self",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.defineProperty(_,"_source",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_};function E(i,p,b,w,I){{var U,k={},_=null,ue=null;b!==void 0&&(ut(b),_=""+b),St(p)&&(ut(p.key),_=""+p.key),Et(p)&&(ue=p.ref,ft(p,I));for(U in p)we.call(p,U)&&!Je.hasOwnProperty(U)&&(k[U]=p[U]);if(i&&i.defaultProps){var J=i.defaultProps;for(U in J)k[U]===void 0&&(k[U]=J[U])}if(_||ue){var Q=typeof i=="function"?i.displayName||i.name||"Unknown":i;_&&Ae(k,Q),ue&&Dt(k,Q)}return o(i,_,ue,I,w,_e.current,k)}}var T=V.ReactCurrentOwner,F=V.ReactDebugCurrentFrame;function q(i){if(i){var p=i._owner,b=Ee(i.type,i._source,p?p.type:null);F.setExtraStackFrame(b)}else F.setExtraStackFrame(null)}var ge;ge=!1;function le(i){return typeof i=="object"&&i!==null&&i.$$typeof===n}function Ct(){{if(T.current){var i=ne(T.current.type);if(i)return`
21
+ `+_[J].replace(" at new "," at ");return r.displayName&&ye.includes("<anonymous>")&&(ye=ye.replace("<anonymous>",r.displayName)),typeof r=="function"&&Z.set(r,ye),ye}while(J>=1&&Q>=0);break}}}finally{z=!1,W.current=U,A(),Error.prepareStackTrace=I}var He=r?r.displayName||r.name:"",It=He?ie(He):"";return typeof r=="function"&&Z.set(r,It),It}function B(r,p,b){return P(r,!1)}function ae(r){var p=r.prototype;return!!(p&&p.isReactComponent)}function Ee(r,p,b){if(r==null)return"";if(typeof r=="function")return P(r,ae(r));if(typeof r=="string")return ie(r);switch(r){case h:return ie("Suspense");case g:return ie("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case d:return B(r.render);case y:return Ee(r.type,p,b);case S:{var w=r,I=w._payload,U=w._init;try{return Ee(U(I),p,b)}catch{}}}return""}var we=Object.prototype.hasOwnProperty,rt={},ot=V.ReactDebugCurrentFrame;function Ie(r){if(r){var p=r._owner,b=Ee(r.type,r._source,p?p.type:null);ot.setExtraStackFrame(b)}else ot.setExtraStackFrame(null)}function Ke(r,p,b,w,I){{var U=Function.call.bind(we);for(var k in r)if(U(r,k)){var _=void 0;try{if(typeof r[k]!="function"){var ue=Error((w||"React class")+": "+b+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ue.name="Invariant Violation",ue}_=r[k](p,k,w,b,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(J){_=J}_&&!(_ instanceof Error)&&(Ie(I),R("%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).",w||"React class",b,k,typeof _),Ie(null)),_ instanceof Error&&!(_.message in rt)&&(rt[_.message]=!0,Ie(I),R("Failed %s type: %s",b,_.message),Ie(null))}}}var Ne=Array.isArray;function Xe(r){return Ne(r)}function yt(r){{var p=typeof Symbol=="function"&&Symbol.toStringTag,b=p&&r[Symbol.toStringTag]||r.constructor.name||"Object";return b}}function st(r){try{return ct(r),!1}catch{return!0}}function ct(r){return""+r}function lt(r){if(st(r))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",yt(r)),ct(r)}var _e=V.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},Je,ut,Ge;Ge={};function Et(r){if(we.call(r,"ref")){var p=Object.getOwnPropertyDescriptor(r,"ref").get;if(p&&p.isReactWarning)return!1}return r.ref!==void 0}function St(r){if(we.call(r,"key")){var p=Object.getOwnPropertyDescriptor(r,"key").get;if(p&&p.isReactWarning)return!1}return r.key!==void 0}function dt(r,p){if(typeof r.ref=="string"&&_e.current&&p&&_e.current.stateNode!==p){var b=ne(_e.current.type);Ge[b]||(R('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',ne(_e.current.type),r.ref),Ge[b]=!0)}}function Ae(r,p){{var b=function(){Je||(Je=!0,R("%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))};b.isReactWarning=!0,Object.defineProperty(r,"key",{get:b,configurable:!0})}}function Dt(r,p){{var b=function(){ut||(ut=!0,R("%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))};b.isReactWarning=!0,Object.defineProperty(r,"ref",{get:b,configurable:!0})}}var o=function(r,p,b,w,I,U,k){var _={$$typeof:n,type:r,key:p,ref:b,props:k,_owner:U};return _._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(_,"_self",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.defineProperty(_,"_source",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_};function E(r,p,b,w,I){{var U,k={},_=null,ue=null;b!==void 0&&(lt(b),_=""+b),St(p)&&(lt(p.key),_=""+p.key),Et(p)&&(ue=p.ref,dt(p,I));for(U in p)we.call(p,U)&&!Ze.hasOwnProperty(U)&&(k[U]=p[U]);if(r&&r.defaultProps){var J=r.defaultProps;for(U in J)k[U]===void 0&&(k[U]=J[U])}if(_||ue){var Q=typeof r=="function"?r.displayName||r.name||"Unknown":r;_&&Ae(k,Q),ue&&Dt(k,Q)}return o(r,_,ue,I,w,_e.current,k)}}var T=V.ReactCurrentOwner,F=V.ReactDebugCurrentFrame;function q(r){if(r){var p=r._owner,b=Ee(r.type,r._source,p?p.type:null);F.setExtraStackFrame(b)}else F.setExtraStackFrame(null)}var ge;ge=!1;function le(r){return typeof r=="object"&&r!==null&&r.$$typeof===n}function Ct(){{if(T.current){var r=ne(T.current.type);if(r)return`
22
22
 
23
- Check the render method of \``+i+"`."}return""}}function xt(i){{if(i!==void 0){var p=i.fileName.replace(/^.*[\\\/]/,""),b=i.lineNumber;return`
23
+ Check the render method of \``+r+"`."}return""}}function xt(r){{if(r!==void 0){var p=r.fileName.replace(/^.*[\\\/]/,""),b=r.lineNumber;return`
24
24
 
25
- Check your code at `+p+":"+b+"."}return""}}var et={};function Se(i){{var p=Ct();if(!p){var b=typeof i=="string"?i:i.displayName||i.name;b&&(p=`
25
+ Check your code at `+p+":"+b+"."}return""}}var Qe={};function Se(r){{var p=Ct();if(!p){var b=typeof r=="string"?r:r.displayName||r.name;b&&(p=`
26
26
 
27
- Check the top-level render call using <`+b+">.")}return p}}function be(i,p){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var b=Se(p);if(et[b])return;et[b]=!0;var w="";i&&i._owner&&i._owner!==T.current&&(w=" It was passed a child from "+ne(i._owner.type)+"."),q(i),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,w),q(null)}}function Le(i,p){{if(typeof i!="object")return;if(Ze(i))for(var b=0;b<i.length;b++){var w=i[b];le(w)&&be(w,p)}else if(le(i))i._store&&(i._store.validated=!0);else if(i){var I=K(i);if(typeof I=="function"&&I!==i.entries)for(var U=I.call(i),k;!(k=U.next()).done;)le(k.value)&&be(k.value,p)}}}function Fe(i){{var p=i.type;if(p==null||typeof p=="string")return;var b;if(typeof p=="function")b=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===d||p.$$typeof===y))b=p.propTypes;else return;if(b){var w=ne(p);Xe(b,i.props,"prop",w,i)}else if(p.PropTypes!==void 0&&!ge){ge=!0;var I=ne(p);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ue(i){{for(var p=Object.keys(i.props),b=0;b<p.length;b++){var w=p[b];if(w!=="children"&&w!=="key"){q(i),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",w),q(null);break}}i.ref!==null&&(q(i),R("Invalid attribute `ref` supplied to `React.Fragment`."),q(null))}}function Be(i,p,b,w,I,U){{var k=De(i);if(!k){var _="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(_+=" 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 ue=xt(I);ue?_+=ue:_+=Ct();var J;i===null?J="null":Ze(i)?J="array":i!==void 0&&i.$$typeof===n?(J="<"+(ne(i.type)||"Unknown")+" />",_=" Did you accidentally export a JSX literal instead of a component?"):J=typeof i,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,_)}var Q=E(i,p,b,I,U);if(Q==null)return Q;if(k){var ye=p.children;if(ye!==void 0)if(w)if(Ze(ye)){for(var Ge=0;Ge<ye.length;Ge++)Le(ye[Ge],i);Object.freeze&&Object.freeze(ye)}else R("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 Le(ye,i)}return i===t?Ue(Q):Fe(Q),Q}}function cn(i,p,b){return Be(i,p,b,!0)}function ln(i,p,b){return Be(i,p,b,!1)}var un=ln,dn=cn;nt.Fragment=t,nt.jsx=un,nt.jsxs=dn}()),nt}process.env.NODE_ENV==="production"?Rt.exports=In():Rt.exports=Nn();var u=Rt.exports;function kt(e){return e.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:e.title}}):u.jsx("button",{children:e.title})}const Ln=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),Fn=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.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 <`+b+">.")}return p}}function be(r,p){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var b=Se(p);if(Qe[b])return;Qe[b]=!0;var w="";r&&r._owner&&r._owner!==T.current&&(w=" It was passed a child from "+ne(r._owner.type)+"."),q(r),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,w),q(null)}}function Le(r,p){{if(typeof r!="object")return;if(Xe(r))for(var b=0;b<r.length;b++){var w=r[b];le(w)&&be(w,p)}else if(le(r))r._store&&(r._store.validated=!0);else if(r){var I=K(r);if(typeof I=="function"&&I!==r.entries)for(var U=I.call(r),k;!(k=U.next()).done;)le(k.value)&&be(k.value,p)}}}function Fe(r){{var p=r.type;if(p==null||typeof p=="string")return;var b;if(typeof p=="function")b=p.propTypes;else if(typeof p=="object"&&(p.$$typeof===d||p.$$typeof===y))b=p.propTypes;else return;if(b){var w=ne(p);Ke(b,r.props,"prop",w,r)}else if(p.PropTypes!==void 0&&!ge){ge=!0;var I=ne(p);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof p.getDefaultProps=="function"&&!p.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ue(r){{for(var p=Object.keys(r.props),b=0;b<p.length;b++){var w=p[b];if(w!=="children"&&w!=="key"){q(r),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",w),q(null);break}}r.ref!==null&&(q(r),R("Invalid attribute `ref` supplied to `React.Fragment`."),q(null))}}function Be(r,p,b,w,I,U){{var k=De(r);if(!k){var _="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(_+=" 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 ue=xt(I);ue?_+=ue:_+=Ct();var J;r===null?J="null":Xe(r)?J="array":r!==void 0&&r.$$typeof===n?(J="<"+(ne(r.type)||"Unknown")+" />",_=" Did you accidentally export a JSX literal instead of a component?"):J=typeof r,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",J,_)}var Q=E(r,p,b,I,U);if(Q==null)return Q;if(k){var ye=p.children;if(ye!==void 0)if(w)if(Xe(ye)){for(var He=0;He<ye.length;He++)Le(ye[He],r);Object.freeze&&Object.freeze(ye)}else R("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 Le(ye,r)}return r===e?Ue(Q):Fe(Q),Q}}function on(r,p,b){return Be(r,p,b,!0)}function sn(r,p,b){return Be(r,p,b,!1)}var cn=sn,ln=on;tt.Fragment=e,tt.jsx=cn,tt.jsxs=ln}()),tt}process.env.NODE_ENV==="production"?Rt.exports=Tn():Rt.exports=Rn();var u=Rt.exports;function kt(t){return t.title.search("<")>-1?u.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:t.title}}):u.jsx("button",{children:t.title})}const _n=u.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[u.jsx("circle",{cx:"7",cy:"7",r:"6"}),u.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),u.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),An=u.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:u.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(e){return u.jsx(Wt.Reorder.Item,{value:e.title,children:u.jsxs("div",{children:[Fn,u.jsx("span",{children:e.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{e.onDelete(e.index)},children:Ln})]})},e.title)}function tn(e){const[n,a]=C.useState(!1),[t,r]=C.useState(e.options),l=f=>{e.onDragComplete(f),r(f)},m=f=>{const g=[...t];g.splice(f,1),l(g)},s=[];t.forEach((f,g)=>{s.push(u.jsx(en,{index:g,title:f,onDelete:m},f))});let d="dropdown draggable";return e.subdropdown&&(d+=" subdropdown"),u.jsxs("div",{className:d,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(kt,{title:e.title}),u.jsx(Wt.Reorder.Group,{axis:"y",values:t,onReorder:l,style:{visibility:n?"visible":"hidden"},children:s})]})}function nn(e){const[n,a]=C.useState(!1),t=[];e.options.map((l,m)=>{e.onSelect!==void 0&&(l.onSelect=e.onSelect),t.push(u.jsx(an,{option:l},m))});let r="dropdown";return e.subdropdown&&(r+=" subdropdown"),u.jsxs("div",{className:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(kt,{title:e.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:t})]})}function an(e){const{option:n}=e,[a,t]=C.useState("");let r;switch(n.type){case"draggable":r=u.jsx(tn,{title:n.title,options:n.value,onDragComplete:l=>{n.onDragComplete!==void 0&&n.onDragComplete(l)},subdropdown:!0});break;case"dropdown":r=u.jsx(nn,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":r=u.jsx("button",{onClick:()=>{n.onSelect!==void 0&&n.onSelect(n.value),n.selectable&&(a!==n.title?t(n.title):t(""))},children:n.title});break}return u.jsx("li",{className:a===n.title?"selected":"",children:r},$t())}class qe{appHandlers=[];editorHandlers=[];_app;static _instance;handleAppBroadcast=n=>{switch(this.appHandlers.forEach(a=>{a.callback(this._app,a.remote,n)}),n.event){case"custom":j.dispatchEvent({type:D.CUSTOM,value:n.data});break}};handleEditorBroadcast=n=>{switch(this.editorHandlers.forEach(a=>{a.callback(this._app,a.remote,n)}),n.event){case"custom":j.dispatchEvent({type:D.CUSTOM,value:n.data});break}};set app(n){this._app=n,n.listen=a=>{a.target==="editor"?this.handleEditorBroadcast(a):this.handleAppBroadcast(a)}}static get instance(){return qe._instance===void 0&&(qe._instance=new qe),qe._instance}}function bt(e){const[n,a]=C.useState(e.open!==void 0?e.open:!0),t=!n||e.children===void 0;return u.jsxs("div",{className:`accordion ${t?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const r=!n;e.onToggle!==void 0&&e.onToggle(r),a(r)},children:[u.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:Ke(e.label)})]}),e.button,u.jsx("div",{className:n?"open":"",children:u.jsx("div",{children:e.children})})]})}function jt(e){const[n,a]=C.useState(!1),t=e.child!==void 0&&e.child.children.length>0,r=[];return e.child!==void 0&&e.child.children.length>0&&e.child.children.map(l=>{r.push(u.jsx(jt,{child:l,three:e.three},Math.random()))}),u.jsx(u.Fragment,{children:e.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[t?u.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,u.jsx("button",{className:"name",style:{left:t?"20px":"5px"},onClick:()=>{e.child!==void 0&&(e.three.getObject(e.child.uuid),n||a(!0))},children:e.child.name.length>0?`${e.child.name} (${e.child.type})`:`${e.child.type}::${e.child.uuid}`}),u.jsx("div",{className:`icon ${_n(e.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:r})})]},Math.random())})}function rn(e){const n=[];return e.child?.children.map(a=>{n.push(u.jsx(jt,{child:a,three:e.three},Math.random()))}),u.jsx("div",{className:`scene ${e.class!==void 0?e.class:""}`,children:n})}const Un="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function Bn(e){return"items"in e}function Ye(e){const n=[];return e.items.forEach(a=>{Bn(a)?n.push(u.jsx(Ye,{title:Ke(a.title),items:a.items},Math.random())):n.push(u.jsx(it,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,options:a.options,onChange:(t,r)=>{a.onChange!==void 0&&a.onChange(t,r)}},Math.random()))}),u.jsx(bt,{label:e.title,open:e.expanded===!0,children:n})}function Vn(e){return!(e==="alphaHash"||e==="alphaToCoverage"||e==="attenuationDistance"||e==="blendDstAlpha"||e==="colorWrite"||e==="combine"||e==="defaultAttributeValues"||e==="depthFunc"||e==="forceSinglePass"||e==="glslVersion"||e==="linecap"||e==="linejoin"||e==="linewidth"||e==="normalMapType"||e==="precision"||e==="premultipliedAlpha"||e==="shadowSide"||e==="toneMapped"||e==="uniformsGroups"||e==="uniformsNeedUpdate"||e==="userData"||e==="vertexColors"||e==="version"||e==="wireframeLinecap"||e==="wireframeLinejoin"||e==="wireframeLinewidth"||e.slice(0,4)==="clip"||e.slice(0,7)==="polygon"||e.slice(0,7)==="stencil"||e.slice(0,2)==="is")}function Ve(e){switch(e){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"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";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"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";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 e}function zn(e){return e.toLowerCase().search("intensity")>-1||e==="anisotropyRotation"||e==="blendAlpha"||e==="bumpScale"||e==="clearcoatRoughness"||e==="displacementBias"||e==="displacementScale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionRatio"||e==="roughness"||e==="sheenRoughness"||e==="thickness"}function Yn(){const e=document.createElement("input");return e.type="file",new Promise((n,a)=>{e.addEventListener("change",function(){if(e.files===null)a();else{const t=e.files[0],r=new FileReader;r.onload=function(l){n(l.target.result)},r.readAsDataURL(t)}}),e.click()})}const Hn=[{title:"Front",value:c.FrontSide},{title:"Back",value:c.BackSide},{title:"Double",value:c.DoubleSide}],Gn=[{title:"No Blending",value:c.NoBlending},{title:"Normal",value:c.NormalBlending},{title:"Additive",value:c.AdditiveBlending},{title:"Subtractive",value:c.SubtractiveBlending},{title:"Multiply",value:c.MultiplyBlending},{title:"Custom",value:c.CustomBlending}],Wn=[{title:"Add",value:c.AddEquation},{title:"Subtract",value:c.SubtractEquation},{title:"Reverse Subtract",value:c.ReverseSubtractEquation},{title:"Min",value:c.MinEquation},{title:"Max",value:c.MaxEquation}],$n=[{title:"Zero",valye:c.ZeroFactor},{title:"One",valye:c.OneFactor},{title:"Src Color",valye:c.SrcColorFactor},{title:"One Minus Src Color",valye:c.OneMinusSrcColorFactor},{title:"Src Alpha",valye:c.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:c.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:c.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:c.OneMinusDstAlphaFactor},{title:"Dst Color",valye:c.DstColorFactor},{title:"One Minus Dst Color",valye:c.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:c.SrcAlphaSaturateFactor},{title:"Constant Color",valye:c.ConstantColorFactor},{title:"One Minus Constant Color",valye:c.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:c.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:c.OneMinusConstantAlphaFactor}],qn=[{title:"Zero",valye:c.ZeroFactor},{title:"One",valye:c.OneFactor},{title:"Src Color",valye:c.SrcColorFactor},{title:"One Minus Src Color",valye:c.OneMinusSrcColorFactor},{title:"Src Alpha",valye:c.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:c.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:c.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:c.OneMinusDstAlphaFactor},{title:"Dst Color",valye:c.DstColorFactor},{title:"One Minus Dst Color",valye:c.OneMinusDstColorFactor},{title:"Constant Color",valye:c.ConstantColorFactor},{title:"One Minus Constant Color",valye:c.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:c.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:c.OneMinusConstantAlphaFactor}];function at(e,n){e.needsUpdate=!0,e.type="option",e.options=n}function Ut(e,n,a){const t=[];for(const r in e){if(!Vn(r))continue;const l=typeof e[r],m=e[r];if(l==="boolean"||l==="number"||l==="string"){const s={title:Ve(r),prop:r,type:l,value:m,min:void 0,max:void 0,needsUpdate:l==="boolean",onChange:(f,g)=>{a.updateObject(n.uuid,`material.${f}`,g),s.needsUpdate&&a.updateObject(n.uuid,"material.needsUpdate",!0);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${f}`,g)}};switch(r){case"blending":at(s,Gn);break;case"blendDst":at(s,qn);break;case"blendEquation":at(s,Wn);break;case"blendSrc":at(s,$n);break;case"side":at(s,Hn);break}zn(r)&&(s.value=Number(m),s.type="range",s.min=0,s.max=1,s.step=.01);const d=l==="string"&&(r==="vertexShader"||r==="fragmentShader");d&&(s.disabled=!1,s.latest=s.value,s.onChange=(f,g)=>{s.latest=g}),t.push(s),d&&t.push({title:`${Ke(r)} - Update`,type:"button",onChange:()=>{a.updateObject(n.uuid,`material.${r}`,s.latest),a.updateObject(n.uuid,"material.needsUpdate",!0);const f=a.scene?.getObjectByProperty("uuid",n.uuid);f!==void 0&&(te(f,`material.${r}`,s.latest),f.material.needsUpdate=!0)}})}else if(l==="object")if(m.isColor)t.push({title:Ve(r),prop:r,type:"color",value:m,onChange:(s,d)=>{const f=new c.Color(d);a.updateObject(n.uuid,`material.${s}`,f);const g=a.scene?.getObjectByProperty("uuid",n.uuid);g!==void 0&&te(g,`material.${s}`,f)}});else if(Array.isArray(m)){const s=[];for(const d in m)s.push({title:`${d}`,type:`${typeof m[d]}`,value:m[d],onChange:(f,g)=>{a.updateObject(n.uuid,`material.${r}`,g);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${r}`,g)}});t.push({title:Ve(r),items:s})}else{const s=[];for(const d in m){const f=m[d];switch(typeof f){case"boolean":case"number":case"string":d==="src"?t.push({title:Ve(r),type:"image",value:f,onChange:(y,S)=>{a.createTexture(n.uuid,`material.${r}`,S);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&Tt(S).then(N=>{te(x,`material.${r}`,N),te(x,"material.needsUpdate",!0)})}}):s.push({title:`${Ve(d)}`,prop:`material.${r}.${d}`,type:`${typeof e[r][d]}`,value:m[d],onChange:(y,S)=>{a.updateObject(n.uuid,`material.${r}.${d}`,S);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${r}.${d}`,S)}});break;case"object":if(f.value!==void 0&&f.value.src!==void 0)s.push({title:Ve(d),type:"image",value:f.value.src,onChange:(y,S)=>{a.createTexture(n.uuid,`material.${r}.${d}.value`,m);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&Tt(S).then(N=>{te(x,`material.${r}.${d}.value`,N)})}});else if(r==="uniforms"){const y=f.value,S=(x,N,L)=>({title:x,type:"number",value:L,step:.01,onChange:(K,V)=>{const R=`material.uniforms.${d}.value.${N}`;a.updateObject(n.uuid,R,V);const H=a.scene?.getObjectByProperty("uuid",n.uuid);H!==void 0&&te(H,R,V)}});if(typeof f.value=="number")s.push({title:d,type:"number",value:f.value,onChange:(x,N)=>{const L=`material.${r}.${x}.value`;a.updateObject(n.uuid,L,N);const K=a.scene?.getObjectByProperty("uuid",n.uuid);K!==void 0&&te(K,L,N)}});else if(y.r!==void 0&&y.g!==void 0&&y.b!==void 0)s.push({title:d,type:"color",value:f.value,onChange:(x,N)=>{const L=new c.Color(N),K=`material.${r}.${x}.value`;a.updateObject(n.uuid,K,L);const V=a.scene?.getObjectByProperty("uuid",n.uuid);V!==void 0&&te(V,K,L)}});else if(y.x!==void 0&&y.y!==void 0&&y.z===void 0&&y.w===void 0)s.push({title:d,items:[S("X","x",f.value.x),S("Y","y",f.value.y)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w===void 0)s.push({title:d,items:[S("X","x",f.value.x),S("Y","y",f.value.y),S("Z","z",f.value.z)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w!==void 0)s.push({title:d,items:[S("X","x",f.value.x),S("Y","y",f.value.y),S("Z","z",f.value.z),S("W","w",f.value.w)]});else if(y.elements!==void 0){const x=y.elements,N=[];for(let L=0;L<x.length;L++)N.push(S(L.toString(),L.toString(),x[L]));s.push({title:d,items:N})}else console.log(">>> need to add this format:",d,y)}else s.push({title:d,type:`${typeof f.value}`,value:f.value,onChange:(y,S)=>{a.updateObject(n.uuid,`material.${r}.${d}.value`,S);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${r}.${d}.value`,S)}});break}}s.length>0&&t.push({title:Ve(r),items:s})}else m!==void 0&&console.log("other:",r,l,m)}return t.sort((r,l)=>r.title<l.title?-1:r.title>l.title?1:0),t.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),t}function Kn(e,n){const a=e.material;if(Array.isArray(a)){const t=[],r=a.length;for(let l=0;l<r;l++)t.push(u.jsx(Ye,{title:`Material ${l}`,items:Ut(a[l],e,n)},`Material ${l}`));return u.jsx(u.Fragment,{children:t})}else return u.jsx(Ye,{title:"Material",items:Ut(a,e,n)})}function it(e){let n=e.value;n!==void 0&&n.isColor!==void 0&&(n=Kt(e.value));const[a,t]=C.useState(n),r=C.useRef(null),l=C.useRef(null),m=C.useRef(null);C.useEffect(()=>{let g=!1,y=-1,S=0,x=Number(a);const N=H=>{g=!0,S=x,y=H.clientX},L=H=>{if(!g)return;const Ce=e.step!==void 0?e.step:1,ce=(H.clientX-y)*Ce;x=Number((S+ce).toFixed(4)),l.current!==null&&(l.current.value=x.toString()),e.onChange!==void 0&&e.onChange(e.prop!==void 0?e.prop:e.title,x)},K=()=>{g=!1},V=()=>{g=!1},R=e.type==="number";return R&&(r.current?.addEventListener("mousedown",N,!1),document.addEventListener("mouseup",K,!1),document.addEventListener("mousemove",L,!1),document.addEventListener("contextmenu",V,!1)),()=>{R&&(r.current?.removeEventListener("mousedown",N),document.removeEventListener("mouseup",K),document.removeEventListener("mousemove",L),document.removeEventListener("contextmenu",V))}},[a]);const s=e.type==="string"&&(a.length>100||a.search(`
30
- `)>-1),d=s||e.type==="image",f=g=>{let y=g.target.value;e.type==="boolean"?y=g.target.checked:e.type==="option"&&(y=e.options[y].value),t(y),e.onChange!==void 0&&e.onChange(e.prop!==void 0?e.prop:e.title,y)};return u.jsxs("div",{className:`field ${d?"block":""}`,children:[e.type!=="button"&&u.jsx("label",{ref:r,children:Ke(e.title)},"fieldLabel"),e.type==="string"&&!s&&u.jsx("input",{type:"text",disabled:e.disabled,onChange:f,value:a}),e.type==="string"&&s&&u.jsx("textarea",{cols:50,rows:10,disabled:e.disabled!==void 0?e.disabled:!0,onChange:f,value:a}),e.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:e.disabled,onChange:f,checked:a}),e.type==="number"&&u.jsx("input",{ref:l,type:"number",value:a,min:e.min,max:e.max,step:e.step,disabled:e.disabled,onChange:f}),e.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:f,disabled:e.disabled,className:"min"}),u.jsx("input",{disabled:e.disabled,type:"range",value:a,min:e.min,max:e.max,step:e.step,onChange:f})]}),e.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:f,disabled:e.disabled,className:"color"}),u.jsx("input",{type:"color",value:a,onChange:f,disabled:e.disabled})]}),e.type==="button"&&u.jsx("button",{disabled:e.disabled,onClick:()=>{e.onChange!==void 0&&e.onChange(e.prop!==void 0?e.prop:e.title,!0)},children:e.title}),e.type==="image"&&u.jsx("img",{ref:m,onClick:()=>{Yn().then(g=>{m.current.src=g,e.onChange!==void 0&&e.onChange(e.prop!==void 0?e.prop:e.title,g)})},src:a.length>0?a:Un}),e.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:f,disabled:e.disabled,defaultValue:e.value,children:e.options?.map((g,y)=>u.jsx("option",{value:g.value,children:Ke(g.title)},y))})})]})}function Bt(e){switch(e){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 e}function Xn(e,n){const a=[];if(e.perspectiveCameraInfo!==void 0)for(const t in e.perspectiveCameraInfo)a.push({title:Bt(t),prop:t,type:"number",step:.01,value:e.perspectiveCameraInfo[t],onChange:(r,l)=>{n.updateObject(e.uuid,r,l),n.requestMethod(e.uuid,"updateProjectionMatrix");const m=n.scene?.getObjectByProperty("uuid",e.uuid);m!==void 0&&(te(m,r,l),m.updateProjectionMatrix())}});else if(e.orthographicCameraInfo!==void 0)for(const t in e.orthographicCameraInfo)a.push({title:Bt(t),prop:t,type:"number",step:.01,value:e.perspectiveCameraInfo[t],onChange:(r,l)=>{n.updateObject(e.uuid,r,l),n.requestMethod(e.uuid,"updateProjectionMatrix");const m=n.scene?.getObjectByProperty("uuid",e.uuid);m!==void 0&&(te(m,r,l),m.updateProjectionMatrix())}});return u.jsx(Ye,{title:"Camera",items:a})}const Zn=Math.PI/180,Jn=180/Math.PI;function $e(e,n,a,t,r){return t+(e-n)*(r-t)/(a-n)}function Qn(e){return e*Zn}function Ot(e){return e*Jn}function ea(e,n){const a=new c.Matrix4;a.elements=e.matrix;const t=new c.Vector3,r=new c.Euler,l=new c.Vector3;e.uuid.length>0&&(t.setFromMatrixPosition(a),r.setFromRotationMatrix(a),l.setFromMatrixScale(a));const m=(d,f)=>{n.updateObject(e.uuid,d,f);const g=n.scene?.getObjectByProperty("uuid",e.uuid);g!==void 0&&te(g,d,f)},s=(d,f)=>{m(d,Qn(f))};return u.jsx(Ye,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:t.x,onChange:m},{title:"Position Y",prop:"position.y",type:"number",value:t.y,onChange:m},{title:"Position Z",prop:"position.z",type:"number",value:t.z,onChange:m},{title:"Rotation X",prop:"rotation.x",type:"number",value:vt(Ot(r.x)),min:-360,max:360,step:.1,onChange:s},{title:"Rotation Y",prop:"rotation.y",type:"number",value:vt(Ot(r.y)),min:-360,max:360,step:.1,onChange:s},{title:"Rotation Z",prop:"rotation.z",type:"number",value:vt(Ot(r.z)),min:-360,max:360,step:.1,onChange:s},{title:"Scale X",prop:"scale.x",type:"number",value:l.x,step:.01,onChange:m},{title:"Scale Y",prop:"scale.y",type:"number",value:l.y,step:.01,onChange:m},{title:"Scale Z",prop:"scale.z",type:"number",value:l.z,step:.01,onChange:m}]})}function Vt(e){switch(e){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 e}function ta(e,n){const a=[];if(e.lightInfo!==void 0)for(const t in e.lightInfo){const r=e.lightInfo[t];r!==void 0&&(r.isColor!==void 0?a.push({title:Vt(t),prop:t,type:"color",value:r,onChange:(l,m)=>{const s=new c.Color(m);n.updateObject(e.uuid,l,s);const d=n.scene?.getObjectByProperty("uuid",e.uuid);d!==void 0&&te(d,l,s)}}):a.push({title:Vt(t),prop:t,type:typeof r,value:r,step:typeof r=="number"?.01:void 0,onChange:(l,m)=>{n.updateObject(e.uuid,l,m);const s=n.scene?.getObjectByProperty("uuid",e.uuid);s!==void 0&&te(s,l,m)}}))}return u.jsx(Ye,{title:"Light",items:a})}function na(e,n){const a=[],t=[];let r=0;e.animations.forEach(s=>{r=Math.max(r,s.duration),s.duration>0&&t.push({title:s.name,items:[{title:"Duration",type:"number",value:s.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:t});const l=n.scene?.getObjectByProperty("uuid",e.uuid);let m=!1;if(l!==void 0){const s=l.mixer;if(m=s!==void 0,m){const d=[{title:"Time Scale",type:"range",value:s.timeScale,step:.01,min:-1,max:2,onChange:(f,g)=>{s.timeScale=g,n.updateObject(e.uuid,"mixer.timeScale",g)}}];d.push({title:"Stop All",type:"button",onChange:()=>{s.stopAllAction(),n.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:d})}}return u.jsx(Ye,{title:"Animation",items:a})}const on={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 oe={...on};function sn(e){const[n,a]=C.useState(-1);C.useEffect(()=>{function m(d){oe={...d.value},a(Date.now())}function s(){oe={...on},a(Date.now())}return j.addEventListener(D.SET_SCENE,s),j.addEventListener(D.SET_OBJECT,m),()=>{j.removeEventListener(D.SET_SCENE,s),j.removeEventListener(D.SET_OBJECT,m)}},[]);const t=oe.type.toLowerCase(),r=oe.animations.length>0||oe.mixer!==void 0,l=t.search("mesh")>-1||t.search("line")>-1||t.search("points")>-1;return u.jsx(bt,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:e.class,children:oe.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(it,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),u.jsx(it,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),u.jsx(it,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0}),u.jsx(it,{type:"boolean",title:"Visible",prop:"visible",value:oe.visible,onChange:(m,s)=>{e.three.updateObject(oe.uuid,m,s);const d=e.three.scene?.getObjectByProperty("uuid",oe.uuid);d!==void 0&&te(d,m,s)}})]}),u.jsxs(u.Fragment,{children:[ea(oe,e.three),r?na(oe,e.three):null,t.search("camera")>-1?Xn(oe,e.three):null,t.search("light")>-1?ta(oe,e.three):null,l?Kn(oe,e.three):null]})]})},n)},"Inspector")}function aa(e){const[n,a]=C.useState(e.scene);C.useEffect(()=>{const l=m=>{a(m.value)};return j.addEventListener(D.SET_SCENE,l),()=>{j.removeEventListener(D.SET_SCENE,l)}},[]);const t=n!==null,r="Hierarchy - "+(t?`${n?.name}`:"No Scene");return u.jsxs("div",{id:"SidePanel",children:[u.jsx(bt,{label:r,open:!0,children:u.jsx(u.Fragment,{children:t&&u.jsx(rn,{child:n,three:e.three})})}),u.jsx(sn,{three:e.three})]},"SidePanel")}function ia(e){function n(){return e.three.scene===void 0?(console.log("No scene:",e.three),!1):!0}const a=s=>{if(!n())return;const d=e.three.scene?.getObjectByProperty("uuid",s.value);d!==void 0&&e.three.setObject(d)},t=(s,d,f)=>{if(!n())return;const g=e.three.scene?.getObjectByProperty("uuid",s);g!==void 0&&te(g,d,f)},r=s=>{if(!n())return;const d=s.value,{key:f,value:g,uuid:y}=d;t(y,f,g)},l=s=>{if(!n())return;const d=s.value;Tt(d.value).then(f=>{t(d.uuid,d.key,f),t(d.uuid,"material.needsUpdate",!0)})},m=s=>{if(!n())return;const{key:d,uuid:f,value:g,subitem:y}=s.value,S=e.three.scene?.getObjectByProperty("uuid",f);if(S!==void 0)try{y!==void 0?kn(S,y)[d](g):S[d](g)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(d),console.log(g)}};return C.useEffect(()=>(j.addEventListener(D.GET_OBJECT,a),j.addEventListener(D.UPDATE_OBJECT,r),j.addEventListener(D.CREATE_TEXTURE,l),j.addEventListener(D.REQUEST_METHOD,m),()=>{j.removeEventListener(D.GET_OBJECT,a),j.removeEventListener(D.UPDATE_OBJECT,r),j.removeEventListener(D.CREATE_TEXTURE,l),j.removeEventListener(D.REQUEST_METHOD,m)}),[]),null}const zt={type:"change"},Mt={type:"start"},Yt={type:"end"},pt=new c.Ray,Ht=new c.Plane,ra=Math.cos(70*c.MathUtils.DEG2RAD);class oa extends c.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new c.Vector3,this.cursor=new c.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:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN},this.touches={ONE:c.TOUCH.ROTATE,TWO:c.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 s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(o){o.addEventListener("keydown",Je),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Je),this._domElementKeyEvents=null},this.saveState=function(){t.target0.copy(t.target),t.position0.copy(t.object.position),t.zoom0=t.object.zoom},this.reset=function(){t.target.copy(t.target0),t.object.position.copy(t.position0),t.object.zoom=t.zoom0,t.object.updateProjectionMatrix(),t.dispatchEvent(zt),t.update(),l=r.NONE},this.update=function(){const o=new c.Vector3,E=new c.Quaternion().setFromUnitVectors(n.up,new c.Vector3(0,1,0)),T=E.clone().invert(),F=new c.Vector3,q=new c.Quaternion,ge=new c.Vector3,le=2*Math.PI;return function(xt=null){const et=t.object.position;o.copy(et).sub(t.target),o.applyQuaternion(E),s.setFromVector3(o),t.autoRotate&&l===r.NONE&&he(De(xt)),t.enableDamping?(s.theta+=d.theta*t.dampingFactor,s.phi+=d.phi*t.dampingFactor):(s.theta+=d.theta,s.phi+=d.phi);let Se=t.minAzimuthAngle,be=t.maxAzimuthAngle;isFinite(Se)&&isFinite(be)&&(Se<-Math.PI?Se+=le:Se>Math.PI&&(Se-=le),be<-Math.PI?be+=le:be>Math.PI&&(be-=le),Se<=be?s.theta=Math.max(Se,Math.min(be,s.theta)):s.theta=s.theta>(Se+be)/2?Math.max(Se,s.theta):Math.min(be,s.theta)),s.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,s.phi)),s.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(g,t.dampingFactor):t.target.add(g),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor),t.zoomToCursor&&G||t.object.isOrthographicCamera?s.radius=Re(s.radius):s.radius=Re(s.radius*f),o.setFromSpherical(s),o.applyQuaternion(T),et.copy(t.target).add(o),t.object.lookAt(t.target),t.enableDamping===!0?(d.theta*=1-t.dampingFactor,d.phi*=1-t.dampingFactor,g.multiplyScalar(1-t.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let Le=!1;if(t.zoomToCursor&&G){let Fe=null;if(t.object.isPerspectiveCamera){const Ue=o.length();Fe=Re(Ue*f);const Be=Ue-Fe;t.object.position.addScaledVector(Ce,Be),t.object.updateMatrixWorld()}else if(t.object.isOrthographicCamera){const Ue=new c.Vector3(ce.x,ce.y,0);Ue.unproject(t.object),t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/f)),t.object.updateProjectionMatrix(),Le=!0;const Be=new c.Vector3(ce.x,ce.y,0);Be.unproject(t.object),t.object.position.sub(Be).add(Ue),t.object.updateMatrixWorld(),Fe=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),t.zoomToCursor=!1;Fe!==null&&(this.screenSpacePanning?t.target.set(0,0,-1).transformDirection(t.object.matrix).multiplyScalar(Fe).add(t.object.position):(pt.origin.copy(t.object.position),pt.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot(pt.direction))<ra?n.lookAt(t.target):(Ht.setFromNormalAndCoplanarPoint(t.object.up,t.target),pt.intersectPlane(Ht,t.target))))}else t.object.isOrthographicCamera&&(Le=f!==1,Le&&(t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/f)),t.object.updateProjectionMatrix()));return f=1,G=!1,Le||F.distanceToSquared(t.object.position)>m||8*(1-q.dot(t.object.quaternion))>m||ge.distanceToSquared(t.target)>0?(t.dispatchEvent(zt),F.copy(t.object.position),q.copy(t.object.quaternion),ge.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",He),t.domElement.removeEventListener("pointerdown",Ie),t.domElement.removeEventListener("pointercancel",Ne),t.domElement.removeEventListener("wheel",ct),t.domElement.removeEventListener("pointermove",Xe),t.domElement.removeEventListener("pointerup",Ne),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",Je),t._domElementKeyEvents=null)};const t=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 l=r.NONE;const m=1e-6,s=new c.Spherical,d=new c.Spherical;let f=1;const g=new c.Vector3,y=new c.Vector2,S=new c.Vector2,x=new c.Vector2,N=new c.Vector2,L=new c.Vector2,K=new c.Vector2,V=new c.Vector2,R=new c.Vector2,H=new c.Vector2,Ce=new c.Vector3,ce=new c.Vector2;let G=!1;const ee=[],O={};let Me=!1;function De(o){return o!==null?2*Math.PI/60*t.autoRotateSpeed*o:2*Math.PI/60/60*t.autoRotateSpeed}function xe(o){const E=Math.abs(o*.01);return Math.pow(.95,t.zoomSpeed*E)}function he(o){d.theta-=o}function ne(o){d.phi-=o}const de=function(){const o=new c.Vector3;return function(T,F){o.setFromMatrixColumn(F,0),o.multiplyScalar(-T),g.add(o)}}(),me=function(){const o=new c.Vector3;return function(T,F){t.screenSpacePanning===!0?o.setFromMatrixColumn(F,1):(o.setFromMatrixColumn(F,0),o.crossVectors(t.object.up,o)),o.multiplyScalar(T),g.add(o)}}(),ve=function(){const o=new c.Vector3;return function(T,F){const q=t.domElement;if(t.object.isPerspectiveCamera){const ge=t.object.position;o.copy(ge).sub(t.target);let le=o.length();le*=Math.tan(t.object.fov/2*Math.PI/180),de(2*T*le/q.clientHeight,t.object.matrix),me(2*F*le/q.clientHeight,t.object.matrix)}else t.object.isOrthographicCamera?(de(T*(t.object.right-t.object.left)/t.object.zoom/q.clientWidth,t.object.matrix),me(F*(t.object.top-t.object.bottom)/t.object.zoom/q.clientHeight,t.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function X(o){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?f/=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function pe(o){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?f*=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Te(o,E){if(!t.zoomToCursor)return;G=!0;const T=t.domElement.getBoundingClientRect(),F=o-T.left,q=E-T.top,ge=T.width,le=T.height;ce.x=F/ge*2-1,ce.y=-(q/le)*2+1,Ce.set(ce.x,ce.y,1).unproject(t.object).sub(t.object.position).normalize()}function Re(o){return Math.max(t.minDistance,Math.min(t.maxDistance,o))}function fe(o){y.set(o.clientX,o.clientY)}function h(o){Te(o.clientX,o.clientX),V.set(o.clientX,o.clientY)}function v(o){N.set(o.clientX,o.clientY)}function M(o){S.set(o.clientX,o.clientY),x.subVectors(S,y).multiplyScalar(t.rotateSpeed);const E=t.domElement;he(2*Math.PI*x.x/E.clientHeight),ne(2*Math.PI*x.y/E.clientHeight),y.copy(S),t.update()}function A(o){R.set(o.clientX,o.clientY),H.subVectors(R,V),H.y>0?X(xe(H.y)):H.y<0&&pe(xe(H.y)),V.copy(R),t.update()}function W(o){L.set(o.clientX,o.clientY),K.subVectors(L,N).multiplyScalar(t.panSpeed),ve(K.x,K.y),N.copy(L),t.update()}function $(o){Te(o.clientX,o.clientY),o.deltaY<0?pe(xe(o.deltaY)):o.deltaY>0&&X(xe(o.deltaY)),t.update()}function ie(o){let E=!1;switch(o.code){case t.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?ne(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ve(0,t.keyPanSpeed),E=!0;break;case t.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?ne(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ve(0,-t.keyPanSpeed),E=!0;break;case t.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?he(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ve(t.keyPanSpeed,0),E=!0;break;case t.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?he(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):ve(-t.keyPanSpeed,0),E=!0;break}E&&(o.preventDefault(),t.update())}function z(o){if(ee.length===1)y.set(o.pageX,o.pageY);else{const E=Ae(o),T=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);y.set(T,F)}}function Z(o){if(ee.length===1)N.set(o.pageX,o.pageY);else{const E=Ae(o),T=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);N.set(T,F)}}function re(o){const E=Ae(o),T=o.pageX-E.x,F=o.pageY-E.y,q=Math.sqrt(T*T+F*F);V.set(0,q)}function P(o){t.enableZoom&&re(o),t.enablePan&&Z(o)}function B(o){t.enableZoom&&re(o),t.enableRotate&&z(o)}function ae(o){if(ee.length==1)S.set(o.pageX,o.pageY);else{const T=Ae(o),F=.5*(o.pageX+T.x),q=.5*(o.pageY+T.y);S.set(F,q)}x.subVectors(S,y).multiplyScalar(t.rotateSpeed);const E=t.domElement;he(2*Math.PI*x.x/E.clientHeight),ne(2*Math.PI*x.y/E.clientHeight),y.copy(S)}function Ee(o){if(ee.length===1)L.set(o.pageX,o.pageY);else{const E=Ae(o),T=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);L.set(T,F)}K.subVectors(L,N).multiplyScalar(t.panSpeed),ve(K.x,K.y),N.copy(L)}function we(o){const E=Ae(o),T=o.pageX-E.x,F=o.pageY-E.y,q=Math.sqrt(T*T+F*F);R.set(0,q),H.set(0,Math.pow(R.y/V.y,t.zoomSpeed)),X(H.y),V.copy(R);const ge=(o.pageX+E.x)*.5,le=(o.pageY+E.y)*.5;Te(ge,le)}function ot(o){t.enableZoom&&we(o),t.enablePan&&Ee(o)}function st(o){t.enableZoom&&we(o),t.enableRotate&&ae(o)}function Ie(o){t.enabled!==!1&&(ee.length===0&&(t.domElement.setPointerCapture(o.pointerId),t.domElement.addEventListener("pointermove",Xe),t.domElement.addEventListener("pointerup",Ne)),Et(o),o.pointerType==="touch"?Qe(o):Ze(o))}function Xe(o){t.enabled!==!1&&(o.pointerType==="touch"?dt(o):yt(o))}function Ne(o){switch(St(o),ee.length){case 0:t.domElement.releasePointerCapture(o.pointerId),t.domElement.removeEventListener("pointermove",Xe),t.domElement.removeEventListener("pointerup",Ne),t.dispatchEvent(Yt),l=r.NONE;break;case 1:const E=ee[0],T=O[E];Qe({pointerId:E,pageX:T.x,pageY:T.y});break}}function Ze(o){let E;switch(o.button){case 0:E=t.mouseButtons.LEFT;break;case 1:E=t.mouseButtons.MIDDLE;break;case 2:E=t.mouseButtons.RIGHT;break;default:E=-1}switch(E){case c.MOUSE.DOLLY:if(t.enableZoom===!1)return;h(o),l=r.DOLLY;break;case c.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(t.enablePan===!1)return;v(o),l=r.PAN}else{if(t.enableRotate===!1)return;fe(o),l=r.ROTATE}break;case c.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(t.enableRotate===!1)return;fe(o),l=r.ROTATE}else{if(t.enablePan===!1)return;v(o),l=r.PAN}break;default:l=r.NONE}l!==r.NONE&&t.dispatchEvent(Mt)}function yt(o){switch(l){case r.ROTATE:if(t.enableRotate===!1)return;M(o);break;case r.DOLLY:if(t.enableZoom===!1)return;A(o);break;case r.PAN:if(t.enablePan===!1)return;W(o);break}}function ct(o){t.enabled===!1||t.enableZoom===!1||l!==r.NONE||(o.preventDefault(),t.dispatchEvent(Mt),$(lt(o)),t.dispatchEvent(Yt))}function lt(o){const E=o.deltaMode,T={clientX:o.clientX,clientY:o.clientY,deltaY:o.deltaY};switch(E){case 1:T.deltaY*=16;break;case 2:T.deltaY*=100;break}return o.ctrlKey&&!Me&&(T.deltaY*=10),T}function ut(o){o.key==="Control"&&(Me=!0,t.domElement.getRootNode().addEventListener("keyup",_e,{passive:!0,capture:!0}))}function _e(o){o.key==="Control"&&(Me=!1,t.domElement.getRootNode().removeEventListener("keyup",_e,{passive:!0,capture:!0}))}function Je(o){t.enabled===!1||t.enablePan===!1||ie(o)}function Qe(o){switch(ft(o),ee.length){case 1:switch(t.touches.ONE){case c.TOUCH.ROTATE:if(t.enableRotate===!1)return;z(o),l=r.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(t.enablePan===!1)return;Z(o),l=r.TOUCH_PAN;break;default:l=r.NONE}break;case 2:switch(t.touches.TWO){case c.TOUCH.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;P(o),l=r.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;B(o),l=r.TOUCH_DOLLY_ROTATE;break;default:l=r.NONE}break;default:l=r.NONE}l!==r.NONE&&t.dispatchEvent(Mt)}function dt(o){switch(ft(o),l){case r.TOUCH_ROTATE:if(t.enableRotate===!1)return;ae(o),t.update();break;case r.TOUCH_PAN:if(t.enablePan===!1)return;Ee(o),t.update();break;case r.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;ot(o),t.update();break;case r.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;st(o),t.update();break;default:l=r.NONE}}function He(o){t.enabled!==!1&&o.preventDefault()}function Et(o){ee.push(o.pointerId)}function St(o){delete O[o.pointerId];for(let E=0;E<ee.length;E++)if(ee[E]==o.pointerId){ee.splice(E,1);return}}function ft(o){let E=O[o.pointerId];E===void 0&&(E=new c.Vector2,O[o.pointerId]=E),E.set(o.pageX,o.pageY)}function Ae(o){const E=o.pointerId===ee[0]?ee[1]:ee[0];return O[E]}t.domElement.addEventListener("contextmenu",He),t.domElement.addEventListener("pointerdown",Ie),t.domElement.addEventListener("pointercancel",Ne),t.domElement.addEventListener("wheel",ct,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",ut,{passive:!0,capture:!0}),this.update()}}const gt=e=>{const[n,a]=C.useState(e.options[e.index]),t=()=>{e.onToggle(!e.open)},r=l=>{l!==n&&(e.onSelect(l),a(l)),e.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${e.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:t,children:n}),e.open&&u.jsx("ul",{className:"dropdown-menu",children:e.options.map(l=>u.jsx("li",{onClick:()=>r(l),children:l},l))})]})},ze=C.forwardRef(function(n,a){const[t,r]=C.useState(!1),l=n.options.indexOf(n.camera.name);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:a,className:"clickable",onClick:()=>{t&&r(!1)}}),u.jsx(gt,{index:l,open:t,options:n.options,onSelect:n.onSelect,onToggle:m=>{r(m)},up:!0})]})});class sa extends c.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:c.GLSL3,side:c.DoubleSide,transparent:!0,uniforms:{uScale:{value:n?.scale!==void 0?n?.scale:.1},uDivisions:{value:n?.divisions!==void 0?n?.divisions:10},uColor:{value:n?.color!==void 0?n?.color:new c.Color(16777215)},uDistance:{value:n?.distance!==void 0?n?.distance:1e4},uSubgridOpacity:{value:n?.subgridOpacity!==void 0?n?.subgridOpacity:.15},uGridOpacity:{value:n?.gridOpacity!==void 0?n?.gridOpacity:.25}},vertexShader:`out vec3 worldPosition;
29
+ C11,8.22,10.74,8,10.43,8z`})});function Jt(t){return u.jsx(Ht.Reorder.Item,{value:t.title,children:u.jsxs("div",{children:[An,u.jsx("span",{children:t.title}),u.jsx("button",{className:"closeIcon",onClick:()=>{t.onDelete(t.index)},children:_n})]})},t.title)}function Qt(t){const[n,a]=C.useState(!1),[e,i]=C.useState(t.options),s=h=>{t.onDragComplete(h),i(h)},f=h=>{const g=[...e];g.splice(h,1),s(g)},c=[];e.forEach((h,g)=>{c.push(u.jsx(Jt,{index:g,title:h,onDelete:f},h))});let d="dropdown draggable";return t.subdropdown&&(d+=" subdropdown"),u.jsxs("div",{className:d,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(kt,{title:t.title}),u.jsx(Ht.Reorder.Group,{axis:"y",values:e,onReorder:s,style:{visibility:n?"visible":"hidden"},children:c})]})}function en(t){const[n,a]=C.useState(!1),e=[];t.options.map((s,f)=>{t.onSelect!==void 0&&(s.onSelect=t.onSelect),e.push(u.jsx(tn,{option:s},f))});let i="dropdown";return t.subdropdown&&(i+=" subdropdown"),u.jsxs("div",{className:i,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx(kt,{title:t.title}),u.jsx("ul",{style:{visibility:n?"visible":"hidden"},children:e})]})}function tn(t){const{option:n}=t,[a,e]=C.useState("");let i;switch(n.type){case"draggable":i=u.jsx(Qt,{title:n.title,options:n.value,onDragComplete:s=>{n.onDragComplete!==void 0&&n.onDragComplete(s)},subdropdown:!0});break;case"dropdown":i=u.jsx(en,{title:n.title,options:n.value,onSelect:n.onSelect,subdropdown:!0});break;case"option":i=u.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 u.jsx("li",{className:a===n.title?"selected":"",children:i},Wt())}function Pn(t,n,a){function e(s){switch(n.forEach(f=>{f.callback(t,f.remote,s)}),s.event){case"custom":j.dispatchEvent({type:D.CUSTOM,value:s.data});break}}function i(s){switch(a.forEach(f=>{f.callback(t,f.remote,s)}),s.event){case"custom":j.dispatchEvent({type:D.CUSTOM,value:s.data});break}}t.listen=s=>{s.target==="editor"?i(s):e(s)}}function bt(t){const[n,a]=C.useState(t.open!==void 0?t.open:!0),e=!n||t.children===void 0;return u.jsxs("div",{className:`accordion ${e?"hide":""}`,children:[u.jsxs("button",{className:"toggle",onClick:()=>{const i=!n;t.onToggle!==void 0&&t.onToggle(i),a(i)},children:[u.jsx("p",{className:`status ${n?"open":""}`,children:"Toggle"}),u.jsx("p",{className:"label",children:qe(t.label)})]}),t.button,u.jsx("div",{className:n?"open":"",children:u.jsx("div",{children:t.children})})]})}function jt(t){const[n,a]=C.useState(!1),e=t.child!==void 0&&t.child.children.length>0,i=[];return t.child!==void 0&&t.child.children.length>0&&t.child.children.map(s=>{i.push(u.jsx(jt,{child:s,three:t.three},Math.random()))}),u.jsx(u.Fragment,{children:t.child!==void 0&&u.jsxs("div",{className:"childObject",children:[u.jsxs("div",{className:"child",children:[e?u.jsx("button",{className:"status",style:{backgroundPositionX:n?"-14px":"2px"},onClick:()=>{a(!n)}}):null,u.jsx("button",{className:"name",style:{left:e?"20px":"5px"},onClick:()=>{t.child!==void 0&&(t.three.getObject(t.child.uuid),n||a(!0))},children:t.child.name.length>0?`${t.child.name} (${t.child.type})`:`${t.child.type}::${t.child.uuid}`}),u.jsx("div",{className:`icon ${Sn(t.child)}`})]}),u.jsx("div",{className:n?"open":"",children:u.jsx("div",{className:"container",children:i})})]},Math.random())})}function nn(t){const n=[];return t.child?.children.map(a=>{n.push(u.jsx(jt,{child:a,three:t.three},Math.random()))}),u.jsx("div",{className:`scene ${t.class!==void 0?t.class:""}`,children:n})}const kn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5klEQVRoge2Y0Q6EIAwE6cX//+X6cCFpSMEKVTdk501OpRNKiyelFC0b8Ps6gCwoggZF0KAIGhRBgyJoUAQNiqCxjciR9SLV//eZiAyvK3U8i/QVaQO2YyLSFVvlkdTKDjJCukh2ykR5ZEW+kHmlatl90RaBtDkK/w7CYhuRUEO0ee3l+J3m55Vm+17vtwjTnV1V3QA8qfbeUXCzRWDpiLLS+OyzvRW7IzW9R+okvclsqR09743bo0yUpc1+lSJvNsa002+Euk9GKzV7SmZDRIMiaFAEDYqgQRE0KIIGRdCgCBoUQeMEMERadX7YUz8AAAAASUVORK5CYII=";function jn(t){return"items"in t}function Ye(t){const n=[];return t.items.forEach(a=>{jn(a)?n.push(u.jsx(Ye,{title:qe(a.title),items:a.items},Math.random())):n.push(u.jsx(at,{title:a.title,prop:a.prop,value:a.value,type:a.type,min:a.min,max:a.max,step:a.step,disabled:a.disabled,options:a.options,onChange:(e,i)=>{a.onChange!==void 0&&a.onChange(e,i)}},Math.random()))}),u.jsx(bt,{label:t.title,open:t.expanded===!0,children:n})}function Dn(t){return!(t==="alphaHash"||t==="alphaToCoverage"||t==="attenuationDistance"||t==="blendDstAlpha"||t==="colorWrite"||t==="combine"||t==="defaultAttributeValues"||t==="depthFunc"||t==="forceSinglePass"||t==="glslVersion"||t==="linecap"||t==="linejoin"||t==="linewidth"||t==="normalMapType"||t==="precision"||t==="premultipliedAlpha"||t==="shadowSide"||t==="toneMapped"||t==="uniformsGroups"||t==="uniformsNeedUpdate"||t==="userData"||t==="vertexColors"||t==="version"||t==="wireframeLinecap"||t==="wireframeLinejoin"||t==="wireframeLinewidth"||t.slice(0,4)==="clip"||t.slice(0,7)==="polygon"||t.slice(0,7)==="stencil"||t.slice(0,2)==="is")}function Ve(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"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";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"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";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 In(t){return t.toLowerCase().search("intensity")>-1||t==="anisotropyRotation"||t==="blendAlpha"||t==="bumpScale"||t==="clearcoatRoughness"||t==="displacementBias"||t==="displacementScale"||t==="metalness"||t==="opacity"||t==="reflectivity"||t==="refractionRatio"||t==="roughness"||t==="sheenRoughness"||t==="thickness"}function Nn(){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],i=new FileReader;i.onload=function(s){n(s.target.result)},i.readAsDataURL(e)}}),t.click()})}const Ln=[{title:"Front",value:l.FrontSide},{title:"Back",value:l.BackSide},{title:"Double",value:l.DoubleSide}],Fn=[{title:"No Blending",value:l.NoBlending},{title:"Normal",value:l.NormalBlending},{title:"Additive",value:l.AdditiveBlending},{title:"Subtractive",value:l.SubtractiveBlending},{title:"Multiply",value:l.MultiplyBlending},{title:"Custom",value:l.CustomBlending}],Un=[{title:"Add",value:l.AddEquation},{title:"Subtract",value:l.SubtractEquation},{title:"Reverse Subtract",value:l.ReverseSubtractEquation},{title:"Min",value:l.MinEquation},{title:"Max",value:l.MaxEquation}],Bn=[{title:"Zero",valye:l.ZeroFactor},{title:"One",valye:l.OneFactor},{title:"Src Color",valye:l.SrcColorFactor},{title:"One Minus Src Color",valye:l.OneMinusSrcColorFactor},{title:"Src Alpha",valye:l.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:l.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:l.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:l.OneMinusDstAlphaFactor},{title:"Dst Color",valye:l.DstColorFactor},{title:"One Minus Dst Color",valye:l.OneMinusDstColorFactor},{title:"Src Alpha Saturate",valye:l.SrcAlphaSaturateFactor},{title:"Constant Color",valye:l.ConstantColorFactor},{title:"One Minus Constant Color",valye:l.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:l.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:l.OneMinusConstantAlphaFactor}],Vn=[{title:"Zero",valye:l.ZeroFactor},{title:"One",valye:l.OneFactor},{title:"Src Color",valye:l.SrcColorFactor},{title:"One Minus Src Color",valye:l.OneMinusSrcColorFactor},{title:"Src Alpha",valye:l.SrcAlphaFactor},{title:"One Minus Src Alpha",valye:l.OneMinusSrcAlphaFactor},{title:"Dst Alpha",valye:l.DstAlphaFactor},{title:"One Minus Dst Alpha",valye:l.OneMinusDstAlphaFactor},{title:"Dst Color",valye:l.DstColorFactor},{title:"One Minus Dst Color",valye:l.OneMinusDstColorFactor},{title:"Constant Color",valye:l.ConstantColorFactor},{title:"One Minus Constant Color",valye:l.OneMinusConstantColorFactor},{title:"Constant Alpha",valye:l.ConstantAlphaFactor},{title:"One Minus Constant Alpha",valye:l.OneMinusConstantAlphaFactor}];function nt(t,n){t.needsUpdate=!0,t.type="option",t.options=n}function Ft(t,n,a){const e=[];for(const i in t){if(!Dn(i))continue;const s=typeof t[i],f=t[i];if(s==="boolean"||s==="number"||s==="string"){const c={title:Ve(i),prop:i,type:s,value:f,min:void 0,max:void 0,needsUpdate:s==="boolean",onChange:(h,g)=>{a.updateObject(n.uuid,`material.${h}`,g),c.needsUpdate&&a.updateObject(n.uuid,"material.needsUpdate",!0);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${h}`,g)}};switch(i){case"blending":nt(c,Fn);break;case"blendDst":nt(c,Vn);break;case"blendEquation":nt(c,Un);break;case"blendSrc":nt(c,Bn);break;case"side":nt(c,Ln);break}In(i)&&(c.value=Number(f),c.type="range",c.min=0,c.max=1,c.step=.01);const d=s==="string"&&(i==="vertexShader"||i==="fragmentShader");d&&(c.disabled=!1,c.latest=c.value,c.onChange=(h,g)=>{c.latest=g}),e.push(c),d&&e.push({title:`${qe(i)} - Update`,type:"button",onChange:()=>{a.updateObject(n.uuid,`material.${i}`,c.latest),a.updateObject(n.uuid,"material.needsUpdate",!0);const h=a.scene?.getObjectByProperty("uuid",n.uuid);h!==void 0&&(te(h,`material.${i}`,c.latest),h.material.needsUpdate=!0)}})}else if(s==="object")if(f.isColor)e.push({title:Ve(i),prop:i,type:"color",value:f,onChange:(c,d)=>{const h=new l.Color(d);a.updateObject(n.uuid,`material.${c}`,h);const g=a.scene?.getObjectByProperty("uuid",n.uuid);g!==void 0&&te(g,`material.${c}`,h)}});else if(Array.isArray(f)){const c=[];for(const d in f)c.push({title:`${d}`,type:`${typeof f[d]}`,value:f[d],onChange:(h,g)=>{a.updateObject(n.uuid,`material.${i}`,g);const y=a.scene?.getObjectByProperty("uuid",n.uuid);y!==void 0&&te(y,`material.${i}`,g)}});e.push({title:Ve(i),items:c})}else{const c=[];for(const d in f){const h=f[d];switch(typeof h){case"boolean":case"number":case"string":d==="src"?e.push({title:Ve(i),type:"image",value:h,onChange:(y,S)=>{a.createTexture(n.uuid,`material.${i}`,S);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&Tt(S).then(N=>{te(x,`material.${i}`,N),te(x,"material.needsUpdate",!0)})}}):c.push({title:`${Ve(d)}`,prop:`material.${i}.${d}`,type:`${typeof t[i][d]}`,value:f[d],onChange:(y,S)=>{a.updateObject(n.uuid,`material.${i}.${d}`,S);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${i}.${d}`,S)}});break;case"object":if(h.value!==void 0&&h.value.src!==void 0)c.push({title:Ve(d),type:"image",value:h.value.src,onChange:(y,S)=>{a.createTexture(n.uuid,`material.${i}.${d}.value`,f);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&Tt(S).then(N=>{te(x,`material.${i}.${d}.value`,N)})}});else if(i==="uniforms"){const y=h.value,S=(x,N,L)=>({title:x,type:"number",value:L,step:.01,onChange:(K,V)=>{const R=`material.uniforms.${d}.value.${N}`;a.updateObject(n.uuid,R,V);const G=a.scene?.getObjectByProperty("uuid",n.uuid);G!==void 0&&te(G,R,V)}});if(typeof h.value=="number")c.push({title:d,type:"number",value:h.value,onChange:(x,N)=>{const L=`material.${i}.${x}.value`;a.updateObject(n.uuid,L,N);const K=a.scene?.getObjectByProperty("uuid",n.uuid);K!==void 0&&te(K,L,N)}});else if(y.r!==void 0&&y.g!==void 0&&y.b!==void 0)c.push({title:d,type:"color",value:h.value,onChange:(x,N)=>{const L=new l.Color(N),K=`material.${i}.${x}.value`;a.updateObject(n.uuid,K,L);const V=a.scene?.getObjectByProperty("uuid",n.uuid);V!==void 0&&te(V,K,L)}});else if(y.x!==void 0&&y.y!==void 0&&y.z===void 0&&y.w===void 0)c.push({title:d,items:[S("X","x",h.value.x),S("Y","y",h.value.y)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w===void 0)c.push({title:d,items:[S("X","x",h.value.x),S("Y","y",h.value.y),S("Z","z",h.value.z)]});else if(y.x!==void 0&&y.y!==void 0&&y.z!==void 0&&y.w!==void 0)c.push({title:d,items:[S("X","x",h.value.x),S("Y","y",h.value.y),S("Z","z",h.value.z),S("W","w",h.value.w)]});else if(y.elements!==void 0){const x=y.elements,N=[];for(let L=0;L<x.length;L++)N.push(S(L.toString(),L.toString(),x[L]));c.push({title:d,items:N})}else console.log(">>> need to add this format:",d,y)}else c.push({title:d,type:`${typeof h.value}`,value:h.value,onChange:(y,S)=>{a.updateObject(n.uuid,`material.${i}.${d}.value`,S);const x=a.scene?.getObjectByProperty("uuid",n.uuid);x!==void 0&&te(x,`material.${i}.${d}.value`,S)}});break}}c.length>0&&e.push({title:Ve(i),items:c})}else f!==void 0&&console.log("other:",i,s,f)}return e.sort((i,s)=>i.title<s.title?-1:i.title>s.title?1:0),e.push({title:"Update Material",type:"button",onChange:()=>{a.updateObject(n.uuid,"material.needsUpdate",!0)}}),e}function zn(t,n){const a=t.material;if(Array.isArray(a)){const e=[],i=a.length;for(let s=0;s<i;s++)e.push(u.jsx(Ye,{title:`Material ${s}`,items:Ft(a[s],t,n)},`Material ${s}`));return u.jsx(u.Fragment,{children:e})}else return u.jsx(Ye,{title:"Material",items:Ft(a,t,n)})}function at(t){let n=t.value;n!==void 0&&n.isColor!==void 0&&(n=qt(t.value));const[a,e]=C.useState(n),i=C.useRef(null),s=C.useRef(null),f=C.useRef(null);C.useEffect(()=>{let g=!1,y=-1,S=0,x=Number(a);const N=G=>{g=!0,S=x,y=G.clientX},L=G=>{if(!g)return;const Ce=t.step!==void 0?t.step:1,ce=(G.clientX-y)*Ce;x=Number((S+ce).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)},K=()=>{g=!1},V=()=>{g=!1},R=t.type==="number";return R&&(i.current?.addEventListener("mousedown",N,!1),document.addEventListener("mouseup",K,!1),document.addEventListener("mousemove",L,!1),document.addEventListener("contextmenu",V,!1)),()=>{R&&(i.current?.removeEventListener("mousedown",N),document.removeEventListener("mouseup",K),document.removeEventListener("mousemove",L),document.removeEventListener("contextmenu",V))}},[a]);const c=t.type==="string"&&(a.length>100||a.search(`
30
+ `)>-1),d=c||t.type==="image",h=g=>{let y=g.target.value;t.type==="boolean"?y=g.target.checked:t.type==="option"&&(y=t.options[y].value),e(y),t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,y)};return u.jsxs("div",{className:`field ${d?"block":""}`,children:[t.type!=="button"&&u.jsx("label",{ref:i,children:qe(t.title)},"fieldLabel"),t.type==="string"&&!c&&u.jsx("input",{type:"text",disabled:t.disabled,onChange:h,value:a}),t.type==="string"&&c&&u.jsx("textarea",{cols:50,rows:10,disabled:t.disabled!==void 0?t.disabled:!0,onChange:h,value:a}),t.type==="boolean"&&u.jsx("input",{type:"checkbox",disabled:t.disabled,onChange:h,checked:a}),t.type==="number"&&u.jsx("input",{ref:s,type:"number",value:a,min:t.min,max:t.max,step:t.step,disabled:t.disabled,onChange:h}),t.type==="range"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:h,disabled:t.disabled,className:"min"}),u.jsx("input",{disabled:t.disabled,type:"range",value:a,min:t.min,max:t.max,step:t.step,onChange:h})]}),t.type==="color"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"text",value:a.toString(),onChange:h,disabled:t.disabled,className:"color"}),u.jsx("input",{type:"color",value:a,onChange:h,disabled:t.disabled})]}),t.type==="button"&&u.jsx("button",{disabled:t.disabled,onClick:()=>{t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,!0)},children:t.title}),t.type==="image"&&u.jsx("img",{ref:f,onClick:()=>{Nn().then(g=>{f.current.src=g,t.onChange!==void 0&&t.onChange(t.prop!==void 0?t.prop:t.title,g)})},src:a.length>0?a:kn}),t.type==="option"&&u.jsx(u.Fragment,{children:u.jsx("select",{onChange:h,disabled:t.disabled,defaultValue:t.value,children:t.options?.map((g,y)=>u.jsx("option",{value:g.value,children:qe(g.title)},y))})})]})}function Ut(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 Yn(t,n){const a=[];if(t.perspectiveCameraInfo!==void 0)for(const e in t.perspectiveCameraInfo)a.push({title:Ut(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(i,s)=>{n.updateObject(t.uuid,i,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const f=n.scene?.getObjectByProperty("uuid",t.uuid);f!==void 0&&(te(f,i,s),f.updateProjectionMatrix())}});else if(t.orthographicCameraInfo!==void 0)for(const e in t.orthographicCameraInfo)a.push({title:Ut(e),prop:e,type:"number",step:.01,value:t.perspectiveCameraInfo[e],onChange:(i,s)=>{n.updateObject(t.uuid,i,s),n.requestMethod(t.uuid,"updateProjectionMatrix");const f=n.scene?.getObjectByProperty("uuid",t.uuid);f!==void 0&&(te(f,i,s),f.updateProjectionMatrix())}});return u.jsx(Ye,{title:"Camera",items:a})}const Gn=Math.PI/180,Hn=180/Math.PI;function $e(t,n,a,e,i){return e+(t-n)*(i-e)/(a-n)}function Wn(t){return t*Gn}function Ot(t){return t*Hn}function $n(t,n){const a=new l.Matrix4;a.elements=t.matrix;const e=new l.Vector3,i=new l.Euler,s=new l.Vector3;t.uuid.length>0&&(e.setFromMatrixPosition(a),i.setFromRotationMatrix(a),s.setFromMatrixScale(a));const f=(d,h)=>{n.updateObject(t.uuid,d,h);const g=n.scene?.getObjectByProperty("uuid",t.uuid);g!==void 0&&te(g,d,h)},c=(d,h)=>{f(d,Wn(h))};return u.jsx(Ye,{title:"Transform",items:[{title:"Position X",prop:"position.x",type:"number",value:e.x,onChange:f},{title:"Position Y",prop:"position.y",type:"number",value:e.y,onChange:f},{title:"Position Z",prop:"position.z",type:"number",value:e.z,onChange:f},{title:"Rotation X",prop:"rotation.x",type:"number",value:mt(Ot(i.x)),min:-360,max:360,step:.1,onChange:c},{title:"Rotation Y",prop:"rotation.y",type:"number",value:mt(Ot(i.y)),min:-360,max:360,step:.1,onChange:c},{title:"Rotation Z",prop:"rotation.z",type:"number",value:mt(Ot(i.z)),min:-360,max:360,step:.1,onChange:c},{title:"Scale X",prop:"scale.x",type:"number",value:s.x,step:.01,onChange:f},{title:"Scale Y",prop:"scale.y",type:"number",value:s.y,step:.01,onChange:f},{title:"Scale Z",prop:"scale.z",type:"number",value:s.z,step:.01,onChange:f}]})}function Bt(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 qn(t,n){const a=[];if(t.lightInfo!==void 0)for(const e in t.lightInfo){const i=t.lightInfo[e];i!==void 0&&(i.isColor!==void 0?a.push({title:Bt(e),prop:e,type:"color",value:i,onChange:(s,f)=>{const c=new l.Color(f);n.updateObject(t.uuid,s,c);const d=n.scene?.getObjectByProperty("uuid",t.uuid);d!==void 0&&te(d,s,c)}}):a.push({title:Bt(e),prop:e,type:typeof i,value:i,step:typeof i=="number"?.01:void 0,onChange:(s,f)=>{n.updateObject(t.uuid,s,f);const c=n.scene?.getObjectByProperty("uuid",t.uuid);c!==void 0&&te(c,s,f)}}))}return u.jsx(Ye,{title:"Light",items:a})}function Kn(t,n){const a=[],e=[];let i=0;t.animations.forEach(c=>{i=Math.max(i,c.duration),c.duration>0&&e.push({title:c.name,items:[{title:"Duration",type:"number",value:c.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),a.push({title:"Animations",items:e});const s=n.scene?.getObjectByProperty("uuid",t.uuid);let f=!1;if(s!==void 0){const c=s.mixer;if(f=c!==void 0,f){const d=[{title:"Time Scale",type:"range",value:c.timeScale,step:.01,min:-1,max:2,onChange:(h,g)=>{c.timeScale=g,n.updateObject(t.uuid,"mixer.timeScale",g)}}];d.push({title:"Stop All",type:"button",onChange:()=>{c.stopAllAction(),n.requestMethod(t.uuid,"stopAllAction",void 0,"mixer")}}),a.push({title:"Mixer",items:d})}}return u.jsx(Ye,{title:"Animation",items:a})}const an={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 oe={...an};function rn(t){const[n,a]=C.useState(-1);C.useEffect(()=>{function f(d){oe={...d.value},a(Date.now())}function c(){oe={...an},a(Date.now())}return j.addEventListener(D.SET_SCENE,c),j.addEventListener(D.SET_OBJECT,f),()=>{j.removeEventListener(D.SET_SCENE,c),j.removeEventListener(D.SET_OBJECT,f)}},[]);const e=oe.type.toLowerCase(),i=oe.animations.length>0||oe.mixer!==void 0,s=e.search("mesh")>-1||e.search("line")>-1||e.search("points")>-1;return u.jsx(bt,{label:"Inspector",children:u.jsx("div",{id:"Inspector",className:t.class,children:oe.uuid.length>0&&u.jsxs(u.Fragment,{children:[u.jsxs(u.Fragment,{children:[u.jsx(at,{type:"string",title:"Name",prop:"name",value:oe.name,disabled:!0}),u.jsx(at,{type:"string",title:"Type",prop:"type",value:oe.type,disabled:!0}),u.jsx(at,{type:"string",title:"UUID",prop:"uuid",value:oe.uuid,disabled:!0}),u.jsx(at,{type:"boolean",title:"Visible",prop:"visible",value:oe.visible,onChange:(f,c)=>{t.three.updateObject(oe.uuid,f,c);const d=t.three.scene?.getObjectByProperty("uuid",oe.uuid);d!==void 0&&te(d,f,c)}})]}),u.jsxs(u.Fragment,{children:[$n(oe,t.three),i?Kn(oe,t.three):null,e.search("camera")>-1?Yn(oe,t.three):null,e.search("light")>-1?qn(oe,t.three):null,s?zn(oe,t.three):null]})]})},n)},"Inspector")}function Xn(t){const[n,a]=C.useState(t.scene);C.useEffect(()=>{const s=f=>{a(f.value)};return j.addEventListener(D.SET_SCENE,s),()=>{j.removeEventListener(D.SET_SCENE,s)}},[]);const e=n!==null,i="Hierarchy - "+(e?`${n?.name}`:"No Scene");return u.jsxs("div",{id:"SidePanel",children:[u.jsx(bt,{label:i,open:!0,children:u.jsx(u.Fragment,{children:e&&u.jsx(nn,{child:n,three:t.three})})}),u.jsx(rn,{three:t.three})]},"SidePanel")}function Zn(t){function n(){return t.three.scene===void 0?(console.log("No scene:",t.three),!1):!0}const a=c=>{if(!n())return;const d=t.three.scene?.getObjectByProperty("uuid",c.value);d!==void 0&&t.three.setObject(d)},e=(c,d,h)=>{if(!n())return;const g=t.three.scene?.getObjectByProperty("uuid",c);g!==void 0&&te(g,d,h)},i=c=>{if(!n())return;const d=c.value,{key:h,value:g,uuid:y}=d;e(y,h,g)},s=c=>{if(!n())return;const d=c.value;Tt(d.value).then(h=>{e(d.uuid,d.key,h),e(d.uuid,"material.needsUpdate",!0)})},f=c=>{if(!n())return;const{key:d,uuid:h,value:g,subitem:y}=c.value,S=t.three.scene?.getObjectByProperty("uuid",h);if(S!==void 0)try{y!==void 0?wn(S,y)[d](g):S[d](g)}catch(x){console.log("Error requesting method:"),console.log(x),console.log(d),console.log(g)}};return C.useEffect(()=>(j.addEventListener(D.GET_OBJECT,a),j.addEventListener(D.UPDATE_OBJECT,i),j.addEventListener(D.CREATE_TEXTURE,s),j.addEventListener(D.REQUEST_METHOD,f),()=>{j.removeEventListener(D.GET_OBJECT,a),j.removeEventListener(D.UPDATE_OBJECT,i),j.removeEventListener(D.CREATE_TEXTURE,s),j.removeEventListener(D.REQUEST_METHOD,f)}),[]),null}const Vt={type:"change"},Mt={type:"start"},zt={type:"end"},ht=new l.Ray,Yt=new l.Plane,Jn=Math.cos(70*l.MathUtils.DEG2RAD);class Qn extends l.EventDispatcher{constructor(n,a){super(),this.object=n,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new l.Vector3,this.cursor=new l.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:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN},this.touches={ONE:l.TOUCH.ROTATE,TWO:l.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 c.phi},this.getAzimuthalAngle=function(){return c.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(o){o.addEventListener("keydown",Ze),this._domElementKeyEvents=o},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ze),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(Vt),e.update(),s=i.NONE},this.update=function(){const o=new l.Vector3,E=new l.Quaternion().setFromUnitVectors(n.up,new l.Vector3(0,1,0)),T=E.clone().invert(),F=new l.Vector3,q=new l.Quaternion,ge=new l.Vector3,le=2*Math.PI;return function(xt=null){const Qe=e.object.position;o.copy(Qe).sub(e.target),o.applyQuaternion(E),c.setFromVector3(o),e.autoRotate&&s===i.NONE&&pe(De(xt)),e.enableDamping?(c.theta+=d.theta*e.dampingFactor,c.phi+=d.phi*e.dampingFactor):(c.theta+=d.theta,c.phi+=d.phi);let Se=e.minAzimuthAngle,be=e.maxAzimuthAngle;isFinite(Se)&&isFinite(be)&&(Se<-Math.PI?Se+=le:Se>Math.PI&&(Se-=le),be<-Math.PI?be+=le:be>Math.PI&&(be-=le),Se<=be?c.theta=Math.max(Se,Math.min(be,c.theta)):c.theta=c.theta>(Se+be)/2?Math.max(Se,c.theta):Math.min(be,c.theta)),c.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,c.phi)),c.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(g,e.dampingFactor):e.target.add(g),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor),e.zoomToCursor&&H||e.object.isOrthographicCamera?c.radius=Re(c.radius):c.radius=Re(c.radius*h),o.setFromSpherical(c),o.applyQuaternion(T),Qe.copy(e.target).add(o),e.object.lookAt(e.target),e.enableDamping===!0?(d.theta*=1-e.dampingFactor,d.phi*=1-e.dampingFactor,g.multiplyScalar(1-e.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let Le=!1;if(e.zoomToCursor&&H){let Fe=null;if(e.object.isPerspectiveCamera){const Ue=o.length();Fe=Re(Ue*h);const Be=Ue-Fe;e.object.position.addScaledVector(Ce,Be),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const Ue=new l.Vector3(ce.x,ce.y,0);Ue.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/h)),e.object.updateProjectionMatrix(),Le=!0;const Be=new l.Vector3(ce.x,ce.y,0);Be.unproject(e.object),e.object.position.sub(Be).add(Ue),e.object.updateMatrixWorld(),Fe=o.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;Fe!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(Fe).add(e.object.position):(ht.origin.copy(e.object.position),ht.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(ht.direction))<Jn?n.lookAt(e.target):(Yt.setFromNormalAndCoplanarPoint(e.object.up,e.target),ht.intersectPlane(Yt,e.target))))}else e.object.isOrthographicCamera&&(Le=h!==1,Le&&(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/h)),e.object.updateProjectionMatrix()));return h=1,H=!1,Le||F.distanceToSquared(e.object.position)>f||8*(1-q.dot(e.object.quaternion))>f||ge.distanceToSquared(e.target)>0?(e.dispatchEvent(Vt),F.copy(e.object.position),q.copy(e.object.quaternion),ge.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",Ge),e.domElement.removeEventListener("pointerdown",Ie),e.domElement.removeEventListener("pointercancel",Ne),e.domElement.removeEventListener("wheel",st),e.domElement.removeEventListener("pointermove",Ke),e.domElement.removeEventListener("pointerup",Ne),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",Ze),e._domElementKeyEvents=null)};const e=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const f=1e-6,c=new l.Spherical,d=new l.Spherical;let h=1;const g=new l.Vector3,y=new l.Vector2,S=new l.Vector2,x=new l.Vector2,N=new l.Vector2,L=new l.Vector2,K=new l.Vector2,V=new l.Vector2,R=new l.Vector2,G=new l.Vector2,Ce=new l.Vector3,ce=new l.Vector2;let H=!1;const ee=[],O={};let Me=!1;function De(o){return o!==null?2*Math.PI/60*e.autoRotateSpeed*o:2*Math.PI/60/60*e.autoRotateSpeed}function xe(o){const E=Math.abs(o*.01);return Math.pow(.95,e.zoomSpeed*E)}function pe(o){d.theta-=o}function ne(o){d.phi-=o}const de=function(){const o=new l.Vector3;return function(T,F){o.setFromMatrixColumn(F,0),o.multiplyScalar(-T),g.add(o)}}(),me=function(){const o=new l.Vector3;return function(T,F){e.screenSpacePanning===!0?o.setFromMatrixColumn(F,1):(o.setFromMatrixColumn(F,0),o.crossVectors(e.object.up,o)),o.multiplyScalar(T),g.add(o)}}(),ve=function(){const o=new l.Vector3;return function(T,F){const q=e.domElement;if(e.object.isPerspectiveCamera){const ge=e.object.position;o.copy(ge).sub(e.target);let le=o.length();le*=Math.tan(e.object.fov/2*Math.PI/180),de(2*T*le/q.clientHeight,e.object.matrix),me(2*F*le/q.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(de(T*(e.object.right-e.object.left)/e.object.zoom/q.clientWidth,e.object.matrix),me(F*(e.object.top-e.object.bottom)/e.object.zoom/q.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function X(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?h/=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function fe(o){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?h*=o:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function Te(o,E){if(!e.zoomToCursor)return;H=!0;const T=e.domElement.getBoundingClientRect(),F=o-T.left,q=E-T.top,ge=T.width,le=T.height;ce.x=F/ge*2-1,ce.y=-(q/le)*2+1,Ce.set(ce.x,ce.y,1).unproject(e.object).sub(e.object.position).normalize()}function Re(o){return Math.max(e.minDistance,Math.min(e.maxDistance,o))}function he(o){y.set(o.clientX,o.clientY)}function m(o){Te(o.clientX,o.clientX),V.set(o.clientX,o.clientY)}function v(o){N.set(o.clientX,o.clientY)}function M(o){S.set(o.clientX,o.clientY),x.subVectors(S,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;pe(2*Math.PI*x.x/E.clientHeight),ne(2*Math.PI*x.y/E.clientHeight),y.copy(S),e.update()}function A(o){R.set(o.clientX,o.clientY),G.subVectors(R,V),G.y>0?X(xe(G.y)):G.y<0&&fe(xe(G.y)),V.copy(R),e.update()}function W(o){L.set(o.clientX,o.clientY),K.subVectors(L,N).multiplyScalar(e.panSpeed),ve(K.x,K.y),N.copy(L),e.update()}function $(o){Te(o.clientX,o.clientY),o.deltaY<0?fe(xe(o.deltaY)):o.deltaY>0&&X(xe(o.deltaY)),e.update()}function ie(o){let E=!1;switch(o.code){case e.keys.UP:o.ctrlKey||o.metaKey||o.shiftKey?ne(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ve(0,e.keyPanSpeed),E=!0;break;case e.keys.BOTTOM:o.ctrlKey||o.metaKey||o.shiftKey?ne(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ve(0,-e.keyPanSpeed),E=!0;break;case e.keys.LEFT:o.ctrlKey||o.metaKey||o.shiftKey?pe(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ve(e.keyPanSpeed,0),E=!0;break;case e.keys.RIGHT:o.ctrlKey||o.metaKey||o.shiftKey?pe(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):ve(-e.keyPanSpeed,0),E=!0;break}E&&(o.preventDefault(),e.update())}function z(o){if(ee.length===1)y.set(o.pageX,o.pageY);else{const E=Ae(o),T=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);y.set(T,F)}}function Z(o){if(ee.length===1)N.set(o.pageX,o.pageY);else{const E=Ae(o),T=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);N.set(T,F)}}function re(o){const E=Ae(o),T=o.pageX-E.x,F=o.pageY-E.y,q=Math.sqrt(T*T+F*F);V.set(0,q)}function P(o){e.enableZoom&&re(o),e.enablePan&&Z(o)}function B(o){e.enableZoom&&re(o),e.enableRotate&&z(o)}function ae(o){if(ee.length==1)S.set(o.pageX,o.pageY);else{const T=Ae(o),F=.5*(o.pageX+T.x),q=.5*(o.pageY+T.y);S.set(F,q)}x.subVectors(S,y).multiplyScalar(e.rotateSpeed);const E=e.domElement;pe(2*Math.PI*x.x/E.clientHeight),ne(2*Math.PI*x.y/E.clientHeight),y.copy(S)}function Ee(o){if(ee.length===1)L.set(o.pageX,o.pageY);else{const E=Ae(o),T=.5*(o.pageX+E.x),F=.5*(o.pageY+E.y);L.set(T,F)}K.subVectors(L,N).multiplyScalar(e.panSpeed),ve(K.x,K.y),N.copy(L)}function we(o){const E=Ae(o),T=o.pageX-E.x,F=o.pageY-E.y,q=Math.sqrt(T*T+F*F);R.set(0,q),G.set(0,Math.pow(R.y/V.y,e.zoomSpeed)),X(G.y),V.copy(R);const ge=(o.pageX+E.x)*.5,le=(o.pageY+E.y)*.5;Te(ge,le)}function rt(o){e.enableZoom&&we(o),e.enablePan&&Ee(o)}function ot(o){e.enableZoom&&we(o),e.enableRotate&&ae(o)}function Ie(o){e.enabled!==!1&&(ee.length===0&&(e.domElement.setPointerCapture(o.pointerId),e.domElement.addEventListener("pointermove",Ke),e.domElement.addEventListener("pointerup",Ne)),Et(o),o.pointerType==="touch"?Je(o):Xe(o))}function Ke(o){e.enabled!==!1&&(o.pointerType==="touch"?ut(o):yt(o))}function Ne(o){switch(St(o),ee.length){case 0:e.domElement.releasePointerCapture(o.pointerId),e.domElement.removeEventListener("pointermove",Ke),e.domElement.removeEventListener("pointerup",Ne),e.dispatchEvent(zt),s=i.NONE;break;case 1:const E=ee[0],T=O[E];Je({pointerId:E,pageX:T.x,pageY:T.y});break}}function Xe(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 l.MOUSE.DOLLY:if(e.enableZoom===!1)return;m(o),s=i.DOLLY;break;case l.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enablePan===!1)return;v(o),s=i.PAN}else{if(e.enableRotate===!1)return;he(o),s=i.ROTATE}break;case l.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(e.enableRotate===!1)return;he(o),s=i.ROTATE}else{if(e.enablePan===!1)return;v(o),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&e.dispatchEvent(Mt)}function yt(o){switch(s){case i.ROTATE:if(e.enableRotate===!1)return;M(o);break;case i.DOLLY:if(e.enableZoom===!1)return;A(o);break;case i.PAN:if(e.enablePan===!1)return;W(o);break}}function st(o){e.enabled===!1||e.enableZoom===!1||s!==i.NONE||(o.preventDefault(),e.dispatchEvent(Mt),$(ct(o)),e.dispatchEvent(zt))}function ct(o){const E=o.deltaMode,T={clientX:o.clientX,clientY:o.clientY,deltaY:o.deltaY};switch(E){case 1:T.deltaY*=16;break;case 2:T.deltaY*=100;break}return o.ctrlKey&&!Me&&(T.deltaY*=10),T}function lt(o){o.key==="Control"&&(Me=!0,e.domElement.getRootNode().addEventListener("keyup",_e,{passive:!0,capture:!0}))}function _e(o){o.key==="Control"&&(Me=!1,e.domElement.getRootNode().removeEventListener("keyup",_e,{passive:!0,capture:!0}))}function Ze(o){e.enabled===!1||e.enablePan===!1||ie(o)}function Je(o){switch(dt(o),ee.length){case 1:switch(e.touches.ONE){case l.TOUCH.ROTATE:if(e.enableRotate===!1)return;z(o),s=i.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(e.enablePan===!1)return;Z(o),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(e.touches.TWO){case l.TOUCH.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;P(o),s=i.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;B(o),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&e.dispatchEvent(Mt)}function ut(o){switch(dt(o),s){case i.TOUCH_ROTATE:if(e.enableRotate===!1)return;ae(o),e.update();break;case i.TOUCH_PAN:if(e.enablePan===!1)return;Ee(o),e.update();break;case i.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;rt(o),e.update();break;case i.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;ot(o),e.update();break;default:s=i.NONE}}function Ge(o){e.enabled!==!1&&o.preventDefault()}function Et(o){ee.push(o.pointerId)}function St(o){delete O[o.pointerId];for(let E=0;E<ee.length;E++)if(ee[E]==o.pointerId){ee.splice(E,1);return}}function dt(o){let E=O[o.pointerId];E===void 0&&(E=new l.Vector2,O[o.pointerId]=E),E.set(o.pageX,o.pageY)}function Ae(o){const E=o.pointerId===ee[0]?ee[1]:ee[0];return O[E]}e.domElement.addEventListener("contextmenu",Ge),e.domElement.addEventListener("pointerdown",Ie),e.domElement.addEventListener("pointercancel",Ne),e.domElement.addEventListener("wheel",st,{passive:!1}),e.domElement.getRootNode().addEventListener("keydown",lt,{passive:!0,capture:!0}),this.update()}}const vt=t=>{const[n,a]=C.useState(t.options[t.index]),e=()=>{t.onToggle(!t.open)},i=s=>{s!==n&&(t.onSelect(s),a(s)),t.onToggle(!1)};return u.jsxs("div",{className:`dropdown ${t.up===!0?"up":""}`,children:[u.jsx("div",{className:"dropdown-toggle",onClick:e,children:n}),t.open&&u.jsx("ul",{className:"dropdown-menu",children:t.options.map(s=>u.jsx("li",{onClick:()=>i(s),children:s},s))})]})},ze=C.forwardRef(function(n,a){const[e,i]=C.useState(!1),s=n.options.indexOf(n.camera.name);return u.jsxs("div",{className:"CameraWindow",children:[u.jsx("div",{ref:a,className:"clickable",onClick:()=>{e&&i(!1)}}),u.jsx(vt,{index:s,open:e,options:n.options,onSelect:n.onSelect,onToggle:f=>{i(f)},up:!0})]})});class ea extends l.ShaderMaterial{constructor(n){super({extensions:{derivatives:!0},glslVersion:l.GLSL3,side:l.DoubleSide,transparent:!0,uniforms:{uScale:{value:n?.scale!==void 0?n?.scale:.1},uDivisions:{value:n?.divisions!==void 0?n?.divisions:10},uColor:{value:n?.color!==void 0?n?.color:new l.Color(16777215)},uDistance:{value:n?.distance!==void 0?n?.distance:1e4},uSubgridOpacity:{value:n?.subgridOpacity!==void 0?n?.subgridOpacity:.15},uGridOpacity:{value:n?.gridOpacity!==void 0?n?.gridOpacity:.25}},vertexShader:`out vec3 worldPosition;
31
31
  uniform float uDistance;
32
32
 
33
33
  void main() {
@@ -103,7 +103,7 @@ C11,8.22,10.74,8,10.43,8z`})});function en(e){return u.jsx(Wt.Reorder.Item,{valu
103
103
  fragColor.a = mix(fragColor.a, baseOpacity * uGridOpacity, nextGrid);
104
104
 
105
105
  if (fragColor.a <= 0.0) discard;
106
- }`,name:"InfiniteGrid",depthWrite:!1})}}class ca extends c.Mesh{gridMaterial;constructor(){const n=new sa;super(new c.PlaneGeometry(2,2),n),this.gridMaterial=n,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const la=`#include <common>
106
+ }`,name:"InfiniteGrid",depthWrite:!1})}}class ta extends l.Mesh{gridMaterial;constructor(){const n=new ea;super(new l.PlaneGeometry(2,2),n),this.gridMaterial=n,this.frustumCulled=!1,this.name="InfiniteGridHelper",this.position.y=.1}update(){this.gridMaterial.needsUpdate=!0}}const na=`#include <common>
107
107
  #include <batching_pars_vertex>
108
108
  #include <uv_pars_vertex>
109
109
  #include <color_pars_vertex>
@@ -133,7 +133,7 @@ void main() {
133
133
  #include <logdepthbuf_vertex>
134
134
  #include <clipping_planes_vertex>
135
135
  #include <worldpos_vertex>
136
- }`,ua=`
136
+ }`,aa=`
137
137
  #include <common>
138
138
  #include <uv_pars_fragment>
139
139
  #include <clipping_planes_pars_fragment>
@@ -141,4 +141,4 @@ void main() {
141
141
  void main() {
142
142
  #include <clipping_planes_fragment>
143
143
  gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
144
- }`;class da extends c.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:la,fragmentShader:ua})}}let ht="Renderer",Pe,mt=!1,Gt=!1,Y,se,ke,je;function fa(e){const n=C.useMemo(()=>new Map,[]),a=C.useMemo(()=>new Map,[]),t=C.useMemo(()=>new Map,[]),r=C.useMemo(()=>new c.Scene,[]),l=C.useMemo(()=>new c.Group,[]),m=C.useMemo(()=>new ca,[]),s=C.useMemo(()=>new c.AxesHelper(500),[]),d=C.useMemo(()=>new c.AxesHelper(100),[]),f=C.useMemo(()=>new c.MeshDepthMaterial,[]),g=C.useMemo(()=>new c.MeshNormalMaterial,[]),y=C.useMemo(()=>new da,[]),S=C.useMemo(()=>new c.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),[]);function x(h,v){const M=new c.OrthographicCamera(-100,100,100,-100,50,3e3);return M.name=h,M.position.copy(v),M.lookAt(0,0,0),n.set(h,M),M}const N=["Renderer","Depth","Normals","UVs","Wireframe"],L=["Single","Side by Side","Stacked","Quad"];C.useEffect(()=>{r.name="Debug Scene",l.name="helpers",r.add(l),l.add(m),s.name="axisHelper",l.add(s),d.name="interactionHelper",l.add(d),d.visible=!1,x("Top",new c.Vector3(0,1e3,0)),x("Bottom",new c.Vector3(0,-1e3,0)),x("Left",new c.Vector3(-1e3,0,0)),x("Right",new c.Vector3(1e3,0,0)),x("Front",new c.Vector3(0,0,1e3)),x("Back",new c.Vector3(0,0,-1e3)),x("Orthographic",new c.Vector3(1e3,1e3,1e3));const h=new c.PerspectiveCamera(60,1,50,3e3);h.name="Debug",h.position.set(500,500,500),h.lookAt(0,0,0),n.set("Debug",h),Y=n.get("Debug"),se=n.get("Orthographic"),ke=n.get("Front"),je=n.get("Top")},[]);const K=C.useRef(null),V=C.useRef(null),R=C.useRef(null),H=C.useRef(null),Ce=C.useRef(null),ce=C.useRef(null),[G,ee]=C.useState(e.mode!==void 0?e.mode:"Single"),[O,Me]=C.useState(null),[De,xe]=C.useState(!1),[he,ne]=C.useState(!1),[de,me]=C.useState(!1),[,ve]=C.useState(Date.now()),X=(h,v)=>{const M=a.get(h.name);M!==void 0&&M.dispose(),a.delete(h.name);const A=t.get(h.name);A!==void 0&&(r.remove(A),A.dispose()),t.delete(h.name);const W=new oa(h,v);switch(W.enableDamping=!0,W.dampingFactor=.05,h.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":W.enableRotate=!1;break}if(a.set(h.name,W),h instanceof c.PerspectiveCamera){const $=new c.CameraHelper(h);t.set(h.name,$),r.add($)}},pe=h=>{const v=t.get(h.name);v!==void 0&&(r.remove(v),v.dispose(),t.delete(h.name));const M=a.get(h.name);M!==void 0&&(M.dispose(),a.delete(h.name))},Te=()=>{a.forEach((h,v)=>{h.dispose();const M=t.get(v);M!==void 0&&(r.remove(M),M.dispose()),t.delete(v),a.delete(v)}),a.clear(),t.clear()},Re=()=>{switch(G){case"Single":X(Y,R.current);break;case"Side by Side":case"Stacked":X(Y,R.current),X(se,H.current);break;case"Quad":X(Y,R.current),X(se,H.current),X(ke,Ce.current),X(je,ce.current);break}};C.useEffect(()=>{const h=new c.WebGLRenderer({canvas:K.current,stencil:!1});h.autoClear=!1,h.shadowMap.enabled=!0,h.setPixelRatio(devicePixelRatio),h.setClearColor(0),Me(h)},[]),C.useEffect(()=>{const h=A=>{Pt(Pe),r.remove(Pe);const W=e.scenes.get(A.value.name);if(W!==void 0){const $=new W;e.onSceneSet!==void 0&&e.onSceneSet($),Pe=$,e.three.scene=Pe,r.add(Pe),Gt=!0}},v=A=>{const W=A.value,$=e.three.scene?.getObjectByProperty("uuid",W.uuid);$!==void 0&&n.set(W.name,$),ve(Date.now())},M=A=>{n.delete(A.value.name),ve(Date.now())};return j.addEventListener(D.SET_SCENE,h),j.addEventListener(D.ADD_CAMERA,v),j.addEventListener(D.REMOVE_CAMERA,M),()=>{j.removeEventListener(D.SET_SCENE,h),j.removeEventListener(D.ADD_CAMERA,v),j.removeEventListener(D.REMOVE_CAMERA,M)}},[]),C.useEffect(()=>{if(O===null)return;let h=window.innerWidth,v=window.innerHeight,M=Math.floor(h/2),A=Math.floor(v/2),W=-1;const $=()=>{h=window.innerWidth-300,v=window.innerHeight,M=Math.floor(h/2),A=Math.floor(v/2),O.setSize(h,v);let P=h,B=v;switch(G){case"Side by Side":P=M,B=v;break;case"Stacked":P=h,B=A;break;case"Quad":P=M,B=A;break}n.forEach(ae=>{ae instanceof c.OrthographicCamera?(ae.left=P/-2,ae.right=P/2,ae.top=B/2,ae.bottom=B/-2,ae.updateProjectionMatrix()):ae instanceof c.PerspectiveCamera&&(ae.aspect=P/B,ae.updateProjectionMatrix(),t.get(ae.name)?.update())})},ie=()=>{O.setViewport(0,0,h,v),O.setScissor(0,0,h,v),O.render(r,Y)},z=()=>{if(G==="Side by Side")O.setViewport(0,0,M,v),O.setScissor(0,0,M,v),O.render(r,Y),O.setViewport(M,0,M,v),O.setScissor(M,0,M,v),O.render(r,se);else{const P=v-A;O.setViewport(0,P,h,A),O.setScissor(0,P,h,A),O.render(r,Y),O.setViewport(0,0,h,A),O.setScissor(0,0,h,A),O.render(r,se)}},Z=()=>{let P=0,B=0;B=v-A,P=0,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(r,Y),P=M,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(r,se),B=0,P=0,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(r,ke),P=M,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(r,je)},re=()=>{switch(a.forEach(P=>{P.update()}),e.onSceneUpdate!==void 0&&Gt&&e.onSceneUpdate(Pe),O.clear(),G){case"Single":ie();break;case"Side by Side":case"Stacked":z();break;case"Quad":Z();break}W=requestAnimationFrame(re)};return Re(),window.addEventListener("resize",$),$(),re(),()=>{window.removeEventListener("resize",$),cancelAnimationFrame(W),W=-1}},[G,O]),C.useEffect(()=>{if(O!==null){const h=new c.Raycaster,v=new c.Vector2,M=(ie,z,Z,re)=>{switch(G){case"Quad":ie<Z?z<re?h.setFromCamera(v,Y):h.setFromCamera(v,ke):z<re?h.setFromCamera(v,se):h.setFromCamera(v,je);break;case"Side by Side":ie<Z?h.setFromCamera(v,Y):h.setFromCamera(v,se);break;case"Single":h.setFromCamera(v,Y);break;case"Stacked":z<re?h.setFromCamera(v,Y):h.setFromCamera(v,se);break}},A=ie=>{if(!mt)return;const z=new c.Vector2;O.getSize(z);const Z=Math.min(ie.clientX,z.x),re=Math.min(ie.clientY,z.y);v.x=$e(Z,0,z.x,-1,1),v.y=$e(re,0,z.y,1,-1);const P=z.x/2,B=z.y/2,ae=()=>{Z<P?v.x=$e(Z,0,P,-1,1):v.x=$e(Z,P,z.x,-1,1)},Ee=()=>{re<B?v.y=$e(re,0,B,1,-1):v.y=$e(re,B,z.y,1,-1)};switch(G){case"Quad":ae(),Ee();break;case"Side by Side":ae();break;case"Stacked":Ee(),Ee();break}M(Z,re,P,B);const we=h.intersectObjects(Pe.children);we.length>0&&d.position.copy(we[0].point)},W=ie=>{if(!mt)return;const z=new c.Vector2;if(O.getSize(z),ie.clientX>=z.x)return;A(ie);const Z=h.intersectObjects(Pe.children);Z.length>0&&e.three.getObject(Z[0].object.uuid)},$=V.current;return $.addEventListener("mousemove",A,!1),$.addEventListener("click",W,!1),()=>{$.removeEventListener("mousemove",A),$.removeEventListener("click",W)}}},[G,O]);const fe=[];return n.forEach((h,v)=>{fe.push(v)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:K}),O!==null&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:`cameras ${G==="Single"||G==="Stacked"?"single":""}`,ref:V,children:[G==="Single"&&u.jsx(u.Fragment,{children:u.jsx(ze,{camera:Y,options:fe,ref:R,onSelect:h=>{a.get(Y.name)?.dispose();const v=n.get(h);v!==void 0&&(pe(Y),Y=v,X(v,R.current))}})}),(G==="Side by Side"||G==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(ze,{camera:Y,options:fe,ref:R,onSelect:h=>{a.get(Y.name)?.dispose();const v=n.get(h);v!==void 0&&(pe(Y),Y=v,X(v,R.current))}}),u.jsx(ze,{camera:se,options:fe,ref:H,onSelect:h=>{a.get(se.name)?.dispose();const v=n.get(h);v!==void 0&&(pe(se),se=v,X(v,H.current))}})]}),G==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(ze,{camera:Y,options:fe,ref:R,onSelect:h=>{a.get(Y.name)?.dispose();const v=n.get(h);v!==void 0&&(pe(Y),Y=v,X(v,R.current))}}),u.jsx(ze,{camera:se,options:fe,ref:H,onSelect:h=>{a.get(se.name)?.dispose();const v=n.get(h);v!==void 0&&(pe(se),se=v,X(v,H.current))}}),u.jsx(ze,{camera:ke,options:fe,ref:Ce,onSelect:h=>{a.get(ke.name)?.dispose();const v=n.get(h);v!==void 0&&(pe(ke),ke=v,X(v,Ce.current))}}),u.jsx(ze,{camera:je,options:fe,ref:ce,onSelect:h=>{a.get(je.name)?.dispose();const v=n.get(h);v!==void 0&&(pe(je),je=v,X(v,ce.current))}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(gt,{index:L.indexOf(G),options:L,onSelect:h=>{h!==G&&(Te(),ee(h))},open:De,onToggle:h=>{xe(h),he&&ne(!1),de&&me(!1)}}),u.jsx(gt,{index:N.indexOf(ht),options:N,onSelect:h=>{if(h!==ht)switch(ht=h,ht){case"Depth":r.overrideMaterial=f;break;case"Normals":r.overrideMaterial=g;break;default:case"Renderer":r.overrideMaterial=null;break;case"Wireframe":r.overrideMaterial=S;break;case"UVs":r.overrideMaterial=y;break}},open:he,onToggle:h=>{De&&xe(!1),ne(h),de&&me(!1)}}),u.jsx(gt,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:h=>{mt=h==="Selection Mode",d.visible=mt},open:de,onToggle:h=>{De&&xe(!1),he&&ne(!1),me(h)}})]})]})]})}function pa(e){return u.jsxs("div",{className:"editor",ref:e.ref,style:e.style,children:[u.jsx("header",{children:e.header}),e.children,u.jsx("footer",{children:e.footer})]})}exports.Accordion=bt;exports.Application=En;exports.BaseRemote=rt;exports.ChildObject=jt;exports.ContainerObject=rn;exports.Draggable=tn;exports.DraggableItem=en;exports.Dropdown=nn;exports.DropdownItem=an;exports.Editor=pa;exports.Inspector=sn;exports.MultiView=fa;exports.NavButton=kt;exports.RemoteComponents=Sn;exports.RemoteController=qe;exports.RemoteTheatre=Jt;exports.RemoteThree=jn;exports.RemoteTweakpane=Dn;exports.SceneInspector=ia;exports.SidePanel=aa;exports.ToolEvents=D;exports.capitalize=Ke;exports.clamp=gn;exports.colorToHex=Kt;exports.componentsApp=Cn;exports.debugDispatcher=j;exports.defaultTheatreCallback=vn;exports.dispose=Pt;exports.disposeMaterial=Zt;exports.disposeTexture=yn;exports.distance=bn;exports.hierarchyUUID=At;exports.isColor=qt;exports.noop=_t;exports.randomID=$t;exports.resetThreeObjects=Xt;exports.round=vt;exports.theatreApp=xn;exports.theatreEditor=wn;exports.theatreEditorApp=Rn;exports.threeApp=On;exports.threeEditor=Mn;exports.tweakpaneApp=Tn;
144
+ }`;class ia extends l.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:na,fragmentShader:aa})}}let ft="Renderer",Pe,pt=!1,Gt=!1,Y,se,ke,je;function ra(t){const n=C.useMemo(()=>new Map,[]),a=C.useMemo(()=>new Map,[]),e=C.useMemo(()=>new Map,[]),i=C.useMemo(()=>new l.Scene,[]),s=C.useMemo(()=>new l.Group,[]),f=C.useMemo(()=>new ta,[]),c=C.useMemo(()=>new l.AxesHelper(500),[]),d=C.useMemo(()=>new l.AxesHelper(100),[]),h=C.useMemo(()=>new l.MeshDepthMaterial,[]),g=C.useMemo(()=>new l.MeshNormalMaterial,[]),y=C.useMemo(()=>new ia,[]),S=C.useMemo(()=>new l.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0}),[]);function x(m,v){const M=new l.OrthographicCamera(-100,100,100,-100,50,3e3);return M.name=m,M.position.copy(v),M.lookAt(0,0,0),n.set(m,M),M}const N=["Renderer","Depth","Normals","UVs","Wireframe"],L=["Single","Side by Side","Stacked","Quad"];C.useEffect(()=>{i.name="Debug Scene",s.name="helpers",i.add(s),s.add(f),c.name="axisHelper",s.add(c),d.name="interactionHelper",s.add(d),d.visible=!1,x("Top",new l.Vector3(0,1e3,0)),x("Bottom",new l.Vector3(0,-1e3,0)),x("Left",new l.Vector3(-1e3,0,0)),x("Right",new l.Vector3(1e3,0,0)),x("Front",new l.Vector3(0,0,1e3)),x("Back",new l.Vector3(0,0,-1e3)),x("Orthographic",new l.Vector3(1e3,1e3,1e3));const m=new l.PerspectiveCamera(60,1,50,3e3);m.name="Debug",m.position.set(500,500,500),m.lookAt(0,0,0),n.set("Debug",m),Y=n.get("Debug"),se=n.get("Orthographic"),ke=n.get("Front"),je=n.get("Top")},[]);const K=C.useRef(null),V=C.useRef(null),R=C.useRef(null),G=C.useRef(null),Ce=C.useRef(null),ce=C.useRef(null),[H,ee]=C.useState(t.mode!==void 0?t.mode:"Single"),[O,Me]=C.useState(null),[De,xe]=C.useState(!1),[pe,ne]=C.useState(!1),[de,me]=C.useState(!1),[,ve]=C.useState(Date.now()),X=(m,v)=>{const M=a.get(m.name);M!==void 0&&M.dispose(),a.delete(m.name);const A=e.get(m.name);A!==void 0&&(i.remove(A),A.dispose()),e.delete(m.name);const W=new Qn(m,v);switch(W.enableDamping=!0,W.dampingFactor=.05,m.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":W.enableRotate=!1;break}if(a.set(m.name,W),m instanceof l.PerspectiveCamera){const $=new l.CameraHelper(m);e.set(m.name,$),i.add($)}},fe=m=>{const v=e.get(m.name);v!==void 0&&(i.remove(v),v.dispose(),e.delete(m.name));const M=a.get(m.name);M!==void 0&&(M.dispose(),a.delete(m.name))},Te=()=>{a.forEach((m,v)=>{m.dispose();const M=e.get(v);M!==void 0&&(i.remove(M),M.dispose()),e.delete(v),a.delete(v)}),a.clear(),e.clear()},Re=()=>{switch(H){case"Single":X(Y,R.current);break;case"Side by Side":case"Stacked":X(Y,R.current),X(se,G.current);break;case"Quad":X(Y,R.current),X(se,G.current),X(ke,Ce.current),X(je,ce.current);break}};C.useEffect(()=>{const m=new l.WebGLRenderer({canvas:K.current,stencil:!1});m.autoClear=!1,m.shadowMap.enabled=!0,m.setPixelRatio(devicePixelRatio),m.setClearColor(0),t.three.renderer=m,Me(m)},[]),C.useEffect(()=>{const m=A=>{Pt(Pe),i.remove(Pe);const W=t.scenes.get(A.value.name);if(W!==void 0){const $=new W;t.onSceneSet!==void 0&&t.onSceneSet($),Pe=$,t.three.scene=Pe,i.add(Pe),Gt=!0}},v=A=>{const W=A.value,$=t.three.scene?.getObjectByProperty("uuid",W.uuid);$!==void 0&&n.set(W.name,$),ve(Date.now())},M=A=>{n.delete(A.value.name),ve(Date.now())};return j.addEventListener(D.SET_SCENE,m),j.addEventListener(D.ADD_CAMERA,v),j.addEventListener(D.REMOVE_CAMERA,M),()=>{j.removeEventListener(D.SET_SCENE,m),j.removeEventListener(D.ADD_CAMERA,v),j.removeEventListener(D.REMOVE_CAMERA,M)}},[]),C.useEffect(()=>{if(O===null)return;let m=window.innerWidth,v=window.innerHeight,M=Math.floor(m/2),A=Math.floor(v/2),W=-1;const $=()=>{m=window.innerWidth-300,v=window.innerHeight,M=Math.floor(m/2),A=Math.floor(v/2),O.setSize(m,v);let P=m,B=v;switch(H){case"Side by Side":P=M,B=v;break;case"Stacked":P=m,B=A;break;case"Quad":P=M,B=A;break}n.forEach(ae=>{ae instanceof l.OrthographicCamera?(ae.left=P/-2,ae.right=P/2,ae.top=B/2,ae.bottom=B/-2,ae.updateProjectionMatrix()):ae instanceof l.PerspectiveCamera&&(ae.aspect=P/B,ae.updateProjectionMatrix(),e.get(ae.name)?.update())})},ie=()=>{O.setViewport(0,0,m,v),O.setScissor(0,0,m,v),O.render(i,Y)},z=()=>{if(H==="Side by Side")O.setViewport(0,0,M,v),O.setScissor(0,0,M,v),O.render(i,Y),O.setViewport(M,0,M,v),O.setScissor(M,0,M,v),O.render(i,se);else{const P=v-A;O.setViewport(0,P,m,A),O.setScissor(0,P,m,A),O.render(i,Y),O.setViewport(0,0,m,A),O.setScissor(0,0,m,A),O.render(i,se)}},Z=()=>{let P=0,B=0;B=v-A,P=0,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(i,Y),P=M,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(i,se),B=0,P=0,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(i,ke),P=M,O.setViewport(P,B,M,A),O.setScissor(P,B,M,A),O.render(i,je)},re=()=>{switch(a.forEach(P=>{P.update()}),t.onSceneUpdate!==void 0&&Gt&&t.onSceneUpdate(Pe),O.clear(),H){case"Single":ie();break;case"Side by Side":case"Stacked":z();break;case"Quad":Z();break}W=requestAnimationFrame(re)};return Re(),window.addEventListener("resize",$),$(),re(),()=>{window.removeEventListener("resize",$),cancelAnimationFrame(W),W=-1}},[H,O]),C.useEffect(()=>{if(O!==null){const m=new l.Raycaster,v=new l.Vector2,M=(ie,z,Z,re)=>{switch(H){case"Quad":ie<Z?z<re?m.setFromCamera(v,Y):m.setFromCamera(v,ke):z<re?m.setFromCamera(v,se):m.setFromCamera(v,je);break;case"Side by Side":ie<Z?m.setFromCamera(v,Y):m.setFromCamera(v,se);break;case"Single":m.setFromCamera(v,Y);break;case"Stacked":z<re?m.setFromCamera(v,Y):m.setFromCamera(v,se);break}},A=ie=>{if(!pt)return;const z=new l.Vector2;O.getSize(z);const Z=Math.min(ie.clientX,z.x),re=Math.min(ie.clientY,z.y);v.x=$e(Z,0,z.x,-1,1),v.y=$e(re,0,z.y,1,-1);const P=z.x/2,B=z.y/2,ae=()=>{Z<P?v.x=$e(Z,0,P,-1,1):v.x=$e(Z,P,z.x,-1,1)},Ee=()=>{re<B?v.y=$e(re,0,B,1,-1):v.y=$e(re,B,z.y,1,-1)};switch(H){case"Quad":ae(),Ee();break;case"Side by Side":ae();break;case"Stacked":Ee(),Ee();break}M(Z,re,P,B);const we=m.intersectObjects(Pe.children);we.length>0&&d.position.copy(we[0].point)},W=ie=>{if(!pt)return;const z=new l.Vector2;if(O.getSize(z),ie.clientX>=z.x)return;A(ie);const Z=m.intersectObjects(Pe.children);Z.length>0&&t.three.getObject(Z[0].object.uuid)},$=V.current;return $.addEventListener("mousemove",A,!1),$.addEventListener("click",W,!1),()=>{$.removeEventListener("mousemove",A),$.removeEventListener("click",W)}}},[H,O]);const he=[];return n.forEach((m,v)=>{he.push(v)}),u.jsxs("div",{className:"multiview",children:[u.jsx("canvas",{ref:K}),O!==null&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:`cameras ${H==="Single"||H==="Stacked"?"single":""}`,ref:V,children:[H==="Single"&&u.jsx(u.Fragment,{children:u.jsx(ze,{camera:Y,options:he,ref:R,onSelect:m=>{a.get(Y.name)?.dispose();const v=n.get(m);v!==void 0&&(fe(Y),Y=v,X(v,R.current))}})}),(H==="Side by Side"||H==="Stacked")&&u.jsxs(u.Fragment,{children:[u.jsx(ze,{camera:Y,options:he,ref:R,onSelect:m=>{a.get(Y.name)?.dispose();const v=n.get(m);v!==void 0&&(fe(Y),Y=v,X(v,R.current))}}),u.jsx(ze,{camera:se,options:he,ref:G,onSelect:m=>{a.get(se.name)?.dispose();const v=n.get(m);v!==void 0&&(fe(se),se=v,X(v,G.current))}})]}),H==="Quad"&&u.jsxs(u.Fragment,{children:[u.jsx(ze,{camera:Y,options:he,ref:R,onSelect:m=>{a.get(Y.name)?.dispose();const v=n.get(m);v!==void 0&&(fe(Y),Y=v,X(v,R.current))}}),u.jsx(ze,{camera:se,options:he,ref:G,onSelect:m=>{a.get(se.name)?.dispose();const v=n.get(m);v!==void 0&&(fe(se),se=v,X(v,G.current))}}),u.jsx(ze,{camera:ke,options:he,ref:Ce,onSelect:m=>{a.get(ke.name)?.dispose();const v=n.get(m);v!==void 0&&(fe(ke),ke=v,X(v,Ce.current))}}),u.jsx(ze,{camera:je,options:he,ref:ce,onSelect:m=>{a.get(je.name)?.dispose();const v=n.get(m);v!==void 0&&(fe(je),je=v,X(v,ce.current))}})]})]}),u.jsxs("div",{className:"settings",children:[u.jsx(vt,{index:L.indexOf(H),options:L,onSelect:m=>{m!==H&&(Te(),ee(m))},open:De,onToggle:m=>{xe(m),pe&&ne(!1),de&&me(!1)}}),u.jsx(vt,{index:N.indexOf(ft),options:N,onSelect:m=>{if(m!==ft)switch(ft=m,ft){case"Depth":i.overrideMaterial=h;break;case"Normals":i.overrideMaterial=g;break;default:case"Renderer":i.overrideMaterial=null;break;case"Wireframe":i.overrideMaterial=S;break;case"UVs":i.overrideMaterial=y;break}},open:pe,onToggle:m=>{De&&xe(!1),ne(m),de&&me(!1)}}),u.jsx(vt,{index:0,options:["Orbit Mode","Selection Mode"],onSelect:m=>{pt=m==="Selection Mode",d.visible=pt},open:de,onToggle:m=>{De&&xe(!1),pe&&ne(!1),me(m)}})]})]})]})}function oa(t){return u.jsxs("div",{className:"editor",ref:t.ref,style:t.style,children:[u.jsx("div",{className:"header",children:t.header}),t.children,u.jsx("div",{className:"footer",children:t.footer})]})}exports.Accordion=bt;exports.Application=bn;exports.BaseRemote=it;exports.ChildObject=jt;exports.ContainerObject=nn;exports.Draggable=Qt;exports.DraggableItem=Jt;exports.Dropdown=en;exports.DropdownItem=tn;exports.Editor=oa;exports.Inspector=rn;exports.MultiView=ra;exports.NavButton=kt;exports.RemoteComponents=yn;exports.RemoteController=Pn;exports.RemoteTheatre=gt;exports.RemoteThree=On;exports.RemoteTweakpane=Mn;exports.SceneInspector=Zn;exports.SidePanel=Xn;exports.ToolEvents=D;exports.capitalize=qe;exports.clamp=mn;exports.colorToHex=qt;exports.debugDispatcher=j;exports.defaultTheatreCallback=pn;exports.dispose=Pt;exports.disposeMaterial=Xt;exports.disposeTexture=gn;exports.distance=vn;exports.hierarchyUUID=At;exports.isColor=$t;exports.noop=_t;exports.randomID=Wt;exports.resetThreeObjects=Kt;exports.round=mt;exports.theatreEditorApp=En;