oomi-ai 0.2.38 → 0.2.40

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.
Files changed (49) hide show
  1. package/README.md +24 -14
  2. package/agent_instructions.md +9 -0
  3. package/bin/oomi-ai.js +1 -1
  4. package/lib/openclawPaths.js +27 -18
  5. package/lib/personaRuntimeManager.js +181 -61
  6. package/lib/personaRuntimeProcess.js +392 -49
  7. package/lib/personaRuntimeSupervisor.js +20 -7
  8. package/lib/scaffold.js +14 -14
  9. package/openclaw.plugin.json +1 -1
  10. package/package.json +10 -8
  11. package/templates/persona-app/package.json +6 -4
  12. package/templates/persona-app/src/App.css +564 -79
  13. package/templates/persona-app/src/App.tsx +2 -2
  14. package/templates/persona-app/src/main.tsx +13 -0
  15. package/templates/persona-app/src/pages/HomePage.tsx +120 -39
  16. package/templates/persona-app/src/pages/ScenePage.tsx +2 -15
  17. package/templates/persona-app/src/persona/notes.ts +3 -1
  18. package/templates/persona-app/src/spatial.ts +82 -0
  19. package/templates/persona-app/template.json +1 -1
  20. package/templates/persona-app/vendor/webspatial/FORK.md +6 -0
  21. package/templates/persona-app/vendor/webspatial/core-sdk/LICENSE +21 -0
  22. package/templates/persona-app/vendor/webspatial/core-sdk/dist/iife/index.d.ts +906 -0
  23. package/templates/persona-app/vendor/webspatial/core-sdk/dist/iife/index.global.js +75 -0
  24. package/templates/persona-app/vendor/webspatial/core-sdk/dist/iife/index.global.js.map +1 -0
  25. package/templates/persona-app/vendor/webspatial/core-sdk/dist/index.d.ts +906 -0
  26. package/templates/persona-app/vendor/webspatial/core-sdk/dist/index.js +3131 -0
  27. package/templates/persona-app/vendor/webspatial/core-sdk/dist/index.js.map +1 -0
  28. package/templates/persona-app/vendor/webspatial/core-sdk/package.json +45 -0
  29. package/templates/persona-app/vendor/webspatial/react-sdk/LICENSE +21 -0
  30. package/templates/persona-app/vendor/webspatial/react-sdk/dist/default/index.d.ts +365 -0
  31. package/templates/persona-app/vendor/webspatial/react-sdk/dist/default/index.js +4296 -0
  32. package/templates/persona-app/vendor/webspatial/react-sdk/dist/default/index.js.map +1 -0
  33. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.d.ts +82 -0
  34. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.js +66 -0
  35. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.js.map +1 -0
  36. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.web.d.ts +2 -0
  37. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.web.js +18 -0
  38. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-dev-runtime.web.js.map +1 -0
  39. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.d.ts +5 -0
  40. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.js +66 -0
  41. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.js.map +1 -0
  42. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.web.d.ts +1 -0
  43. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.web.js +18 -0
  44. package/templates/persona-app/vendor/webspatial/react-sdk/dist/jsx/jsx-runtime.web.js.map +1 -0
  45. package/templates/persona-app/vendor/webspatial/react-sdk/dist/web/index.d.ts +365 -0
  46. package/templates/persona-app/vendor/webspatial/react-sdk/dist/web/index.js +4336 -0
  47. package/templates/persona-app/vendor/webspatial/react-sdk/dist/web/index.js.map +1 -0
  48. package/templates/persona-app/vendor/webspatial/react-sdk/package.json +94 -0
  49. package/templates/persona-app/vite.config.ts +13 -0
@@ -0,0 +1,75 @@
1
+
2
+ (function(){
3
+ if(typeof window === 'undefined') return;
4
+ if(!window.__webspatialsdk__) window.__webspatialsdk__ = {}
5
+ window.__webspatialsdk__['core-sdk-version'] = "1.2.1"
6
+ })()
7
+
8
+ "use strict";var webspatialCore=(()=>{var $t=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var D=(i,e)=>()=>(i&&(e=i(i=0)),e);var A=(i,e)=>{for(var t in e)$t(i,t,{get:e[t],enumerable:!0})},je=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ke(e))!Fe.call(i,n)&&n!==t&&$t(i,n,{get:()=>e[n],enumerable:!(r=Be(e,n))||r.enumerable});return i};var G=i=>je($t({},"__esModule",{value:!0}),i);function m(i){return{success:!0,data:i,errorCode:"",errorMessage:""}}function u(i,e=""){return{success:!1,data:void 0,errorCode:i,errorMessage:e}}var V=D(()=>{"use strict"});var ie={};A(ie,{PuppeteerPlatform:()=>Ut});var Ut,re=D(()=>{"use strict";V();console.log("PuppeteerPlatform");Ut=class{iframeRegistry=new Map;constructor(){}callJSB(e,t){return new Promise(r=>{try{if(window.__handleJSBMessage)try{console.log(` core-sdk Puppeteer Platform: callJSB: ${e}::${t}`);let n=window.__handleJSBMessage(`${e}::${t}`);console.log(` core-sdk Puppeteer Platform callJSB result: ${n}`),r(m(n))}catch{r(u("500","JSB execution error"))}else r(m("ok"))}catch(n){console.error(`PuppeteerPlatform cmd Error: ${e}, msg: ${t} error: ${n}`),r(u("500","Internal error"))}})}createSpatializedElementSync(e,t){try{console.log(`[Puppeteer Platform] Creating spatialized element sync with id: ${e}, url: ${t}`);let r=window;if(r.__handleJSBMessage){let n={id:e,url:t};r.__handleJSBMessage(`CreateSpatialized2DElement::${JSON.stringify(n)}`)}}catch(r){console.error("Error creating spatialized element sync:",r)}}callWebSpatialProtocol(e,t,r,n){return console.log(`PuppeteerPlatform: Calling webspatial protocol: webspatial://${e}${t?`?${t}`:""}`),new Promise(a=>{try{let o=`webspatial://${e}${t?`?${t}`:""}`,{spatialId:s,iframe:l,windowProxy:c}=this.createIframeWindow(o,r,n);e==="createSpatialized2DElement"&&this.createSpatializedElementSync(s,o),console.log(`[Puppeteer Platform] iframe created with spatialId: ${s}`),this.iframeRegistry.set(s,l),a(m({windowProxy:c,id:s}))}catch(o){console.error("Error calling webspatial protocol:",o),a(u("500","Failed to call webspatial protocol"))}})}callWebSpatialProtocolSync(e,t,r,n){try{let a=`webspatial://${e}${t?`?${t}`:""}`;console.log(`Calling webspatial protocol sync: ${a}`);let{spatialId:o,iframe:s,windowProxy:l}=this.createIframeWindow(a,r,n);return e==="createSpatialized2DElement"&&this.createSpatializedElementSync(o,a),this.iframeRegistry.set(o,s),m({windowProxy:l,id:o})}catch(a){return console.error("Error calling webspatial protocol sync:",a),u("500","Failed to call webspatial protocol sync")}}createIframeWindow(e,t,r){let n=document.createElement("iframe");n.style.border="none",n.style.display="none",n.style.width="100%",n.style.height="100%";let a=this.generateUUID();n.spatialId=a,n.id=`spatial-iframe-${a}`;let o=this.parseFeatures(r||"");o.width&&(n.style.width=o.width),o.height&&(n.style.height=o.height),o.left&&(n.style.left=o.left,n.style.position="absolute"),o.top&&(n.style.top=o.top,n.style.position="absolute"),document.body.appendChild(n);let s=this.createEnhancedWindowProxy(n,e,a);return n.src="about:blank",console.log(`PuppeteerPlatform created iframe window with spatialId: ${a}, URL: ${e}`),this.initializeIframeContent(n,e,a),{spatialId:a,iframe:n,windowProxy:s}}createEnhancedWindowProxy(e,t,r){return{location:{href:t,toString:()=>t,reload:()=>{e.contentWindow&&e.contentWindow.location.reload()}},navigator:{userAgent:`Mozilla/5.0 (WebKit) SpatialId/${r}`},close:()=>{console.log(`Closing iframe with spatialId: ${r}`),e.remove(),this.iframeRegistry.delete(r)},document:e.contentDocument||{},contentWindow:e.contentWindow||{},postMessage:(n,a)=>{e.contentWindow&&e.contentWindow.postMessage(n,a||"*")},addEventListener:(n,a)=>{e.contentWindow&&e.contentWindow.addEventListener(n,a)},removeEventListener:(n,a)=>{e.contentWindow&&e.contentWindow.removeEventListener(n,a)},executeScript:n=>{if(e.contentWindow)try{return e.contentWindow.eval(n)}catch(a){return console.error(`Error executing script in iframe ${r}:`,a),null}return null},getIframe:()=>e,getSpatialId:()=>r}}initializeIframeContent(e,t,r){try{e.onload=()=>{try{let n=`
9
+ // \u6CE8\u5165\u901A\u4FE1\u811A\u672C
10
+ window.webSpatialId = '${r}';
11
+ window.SpatialId = '${r}';
12
+
13
+ // \u91CD\u5199window.open\u4EE5\u652F\u6301webspatial\u534F\u8BAE
14
+ const originalOpen = window.open;
15
+ window.open = function(url, target, features) {
16
+ if (url && url.startsWith('webspatial://')) {
17
+ // \u901A\u8FC7windowProxy\u5904\u7406webspatial\u534F\u8BAE
18
+ const windowProxy = new Proxy({}, {
19
+ get: function(target, prop) {
20
+ if (prop === 'toString') {
21
+ return function() { return url; };
22
+ }
23
+ return undefined;
24
+ }
25
+ });
26
+ return windowProxy;
27
+ }
28
+ return originalOpen.call(window, url, target, features);
29
+ };
30
+
31
+ // \u8BBE\u7F6Enavigator.userAgent\u4EE5\u8BC6\u522Bwebspatial\u73AF\u5883
32
+ Object.defineProperty(navigator, 'userAgent', {
33
+ value: 'WebSpatial/1.0 ' + navigator.userAgent,
34
+ configurable: true
35
+ });
36
+
37
+ // \u53D1\u9001\u52A0\u8F7D\u5B8C\u6210\u6D88\u606F
38
+ window.parent.postMessage({
39
+ type: 'iframe_loaded',
40
+ spatialId: '${r}',
41
+ url: '${t}'
42
+ }, '${window.location.origin}');
43
+
44
+ // \u8BBE\u7F6E\u6D88\u606F\u5904\u7406\u5668
45
+ window.addEventListener('message', (event) => {
46
+ if (event.origin !== window.parent.location.origin) return;
47
+
48
+ const data = event.data;
49
+ if (data && data.type === 'webspatial_command') {
50
+ // \u5904\u7406\u6765\u81EA\u7236\u7A97\u53E3\u7684\u547D\u4EE4
51
+ console.log('Received command in iframe from parent:', data.command);
52
+ // \u8FD9\u91CC\u53EF\u4EE5\u6DFB\u52A0\u547D\u4EE4\u5904\u7406\u903B\u8F91
53
+ }
54
+ });
55
+ `,a=e.contentDocument;a&&(a.open(),a.write(`
56
+ <!DOCTYPE html>
57
+ <html>
58
+ <head>
59
+ <title>Spatial Iframe - ${r}</title>
60
+ <meta charset="UTF-8">
61
+ <style>
62
+ body {
63
+ margin: 0;
64
+ padding: 0;
65
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
66
+ }
67
+ </style>
68
+ </head>
69
+ <body>
70
+ <script>${n}</script>
71
+ </body>
72
+ </html>
73
+ `),a.close())}catch(n){console.error("Error initializing iframe content:",n)}}}catch(n){console.error("Error setting up iframe:",n)}}parseFeatures(e){let t={};return e.split(",").forEach(n=>{let[a,o]=n.split("=").map(s=>s.trim());a&&o&&(t[a]=o)}),t}sendMessageToIframe(e,t){let r=this.iframeRegistry.get(e);return r&&r.contentWindow?(r.contentWindow.postMessage(t,window.location.origin),!0):!1}getAllActiveIframes(){let e=[];return this.iframeRegistry.forEach((t,r)=>{e.push({spatialId:r,iframe:t})}),e}dispose(){this.iframeRegistry.forEach((e,t)=>{console.log(`Disposing iframe with spatialId: ${t}`),e.remove()}),this.iframeRegistry.clear()}generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16).toUpperCase()})}}});var d,w=D(()=>{"use strict";d=class i{static eventReceiver={};static init(){window.__SpatialWebEvent=({id:e,data:t})=>{i.eventReceiver[e]?.(t)}}static addEventReceiver(e,t){i.eventReceiver[e]=t}static removeEventReceiver(e){delete i.eventReceiver[e]}}});var ae={};A(ae,{XRPlatform:()=>kt});function ne(){return Bt=(Bt+1)%Ne,`rId_${Bt}`}var Bt,Ne,kt,oe=D(()=>{"use strict";V();w();Bt=0,Ne=1e5;kt=class{async callJSB(e,t){return new Promise((r,n)=>{try{let a=ne();d.addEventReceiver(a,s=>{if(d.removeEventReceiver(a),s.success)r(m(s.data));else{let{code:l,message:c}=s.data;r(u(l,c))}});let o=window.webspatialBridge.postMessage(a,e,t);if(o!==""){d.removeEventReceiver(a);let s=JSON.parse(o);if(s.success)r(m(s.data));else{let{code:l,message:c}=s.data;r(u(l,c))}}}catch(a){console.error(`XRPlatform cmd: ${e}, msg: ${t} error: ${a}`);let{code:o,message:s}=a;r(u(o,s))}})}async callWebSpatialProtocol(e,t,r,n){return new Promise((a,o)=>{let s=ne();try{let l=null;d.addEventReceiver(s,c=>{console.log("createdId",s,c.spatialId),a(m({windowProxy:l,id:c.spatialId})),d.removeEventReceiver(s)}),l=this.openWindow(e,t,r,n).windowProxy,l?.open(`about:blank?rid=${s}`,"_self")}catch(l){console.error(`open window error: ${l}`);let{code:c,message:I}=l;d.removeEventReceiver(s),a(u(c,I))}})}callWebSpatialProtocolSync(e,t,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(e,t,r,n);return m({windowProxy:o,id:a})}openWindow(e,t,r,n){return{spatialId:"",windowProxy:window.open(`webspatial://${e}?${t||""}`,r,n)}}}});var ce={};A(ce,{AndroidPlatform:()=>jt});function qe(){return Ft=(Ft+1)%He,`rId_${Ft}`}function Y(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}function se(){return window.__WebSpatialAndroidConfig?.renderMode==="live-window"}function le(i,e,t){return`${i&&i.length>0?`${i}&`:""}${e}=${encodeURIComponent(t)}`}function Qe(i){let e=i,t=e.location?.href;if(!t||t.startsWith("about:"))return!1;let r=e.document;return!r?.head||!r.body||r.readyState!=="interactive"&&r.readyState!=="complete"?!1:e.__WebSpatialChildReady===!0}function Xe(i){let e=i.location?.href;if(!e||e.startsWith("about:"))return!1;let t=i.document;return!!(t?.head&&t.body)}async function Ke(i,e=8e3){let t=Date.now();for(;Date.now()-t<e;){try{if(Qe(i))return!0}catch{}await new Promise(r=>setTimeout(r,16))}try{if(Xe(i))return console.warn("[AndroidPlatform] Falling back to partially ready child window after timeout",i.location?.href),!0}catch{}return!1}function pe(i){let e=()=>{let a={cssText:"",backgroundColor:"",margin:"",display:"",minWidth:"",minHeight:"",maxWidth:"",background:"",visibility:"",position:"",top:"",left:"",width:"",height:"",overflow:"",transform:"",opacity:"",borderRadius:""};return new Proxy(a,{get(o,s){return s==="setProperty"?(l,c)=>{o[l]=c}:s==="getPropertyValue"?l=>o[l]||"":s==="removeProperty"?l=>{let c=o[l];return delete o[l],c||""}:o[s]??""},set(o,s,l){return o[s]=l,!0}})},t=a=>({tagName:a.toUpperCase(),style:e(),setAttribute:()=>{},getAttribute:()=>null,appendChild:()=>{},removeChild:()=>{},innerHTML:"",textContent:"",className:"",id:"",name:"",content:""}),r={documentElement:{style:e(),className:""},head:{innerHTML:"",appendChild:()=>{},removeChild:()=>{},children:[],querySelectorAll:()=>[]},body:{innerHTML:"",style:e(),appendChild:()=>{},removeChild:()=>{},className:""},title:"",onclick:null,createElement:a=>t(a),createTextNode:a=>({textContent:a}),getElementById:()=>null,querySelector:a=>null,querySelectorAll:()=>[],write:()=>{},close:()=>{}},n={__SpatialId:i,document:r,location:{href:"about:blank"},navigator:{userAgent:window?.navigator?.userAgent??""},addEventListener:()=>{},removeEventListener:()=>{},postMessage:()=>{},close:()=>{},focus:()=>{},blur:()=>{},open:()=>n,parent:null,top:null,closed:!1};return n.parent=n,n.top=n,n}var Ft,He,jt,de=D(()=>{"use strict";V();w();Ft=0,He=1e5;jt=class{async callJSB(e,t){return new Promise((r,n)=>{try{let a=qe();d.addEventReceiver(a,s=>{if(d.removeEventReceiver(a),s.success)r(m(s.data));else{let{code:l,message:c}=s.data;r(u(l,c))}});let o=window.webspatialBridge.postMessage(a,e,t);if(o!==""){d.removeEventReceiver(a);let s=JSON.parse(o);if(s.success)r(m(s.data));else{let{code:l,message:c}=s.data;r(u(l,c))}}}catch(a){console.error(`AndroidPlatform cmd: ${e}, msg: ${t} error: ${a}`);let{code:o,message:s}=a;r(u(o,s))}})}async callWebSpatialProtocol(e,t,r,n){if(e==="createSpatialized2DElement"&&se()){let M=Y(),S=window.open(`webspatial://${e}?${le(t,"id",M)}`,r,n);if(!S)return u("WindowOpenFailed",`Unable to open child window for ${e}`);try{S.__SpatialId=M}catch{}return await Ke(S)?m({windowProxy:S,id:M}):u("WindowProxyUnavailable",`Timed out waiting for ${e} child window to become scriptable`)}let a=this.mapProtocolToJSBCommand(e);if(!a)return console.warn(`[AndroidPlatform] Unknown protocol command: ${e}`),u("UnknownCommand",`Unknown command: ${e}`);let o=Y(),s={id:o};t&&new URLSearchParams(t).forEach((S,Lt)=>{try{s[Lt]=JSON.parse(decodeURIComponent(S))}catch{s[Lt]=decodeURIComponent(S)}});let l=await this.callJSB(a,JSON.stringify(s));if(!l.success)return l;let c=l.data?.id||o,I=pe(c);return m({windowProxy:I,id:c})}mapProtocolToJSBCommand(e){return{createSpatialized2DElement:"CreateSpatialized2DElement",createSpatializedStatic3DElement:"CreateSpatializedStatic3DElement",createSpatializedDynamic3DElement:"CreateSpatializedDynamic3DElement",createSpatialScene:"CreateSpatialScene"}[e]||null}callWebSpatialProtocolSync(e,t,r,n){if(e==="createSpatialized2DElement"&&se()){let s=Y(),l=window.open(`webspatial://${e}?${le(t,"id",s)}`,r,n);if(!l)return u("WindowOpenFailed",`Unable to open child window for ${e}`);try{l.__SpatialId=s}catch{}return m({windowProxy:l,id:s})}let a=Y(),o=pe(a);try{window.open(`webspatial://${e}?id=${a}&${t||""}`,r,n)}catch(s){console.warn("[AndroidPlatform] window.open failed:",s)}return m({windowProxy:o,id:a})}}});var me={};A(me,{VisionOSPlatform:()=>Jt});var Jt,ue=D(()=>{"use strict";V();Jt=class{async callJSB(e,t){try{let r=await window.webkit.messageHandlers.bridge.postMessage(`${e}::${t}`);return m(r)}catch(r){let{code:n,message:a}=JSON.parse(r.message);return u(n,a)}}callWebSpatialProtocol(e,t,r,n){let{spatialId:a,windowProxy:o}=this.openWindow(e,t,r,n);return Promise.resolve(m({windowProxy:o,id:a}))}callWebSpatialProtocolSync(e,t,r,n){let{spatialId:a="",windowProxy:o}=this.openWindow(e,t,r,n);return m({windowProxy:o,id:a})}openWindow(e,t,r,n){let a=window.open(`webspatial://${e}?${t||""}`,r,n);return{spatialId:a?.navigator.userAgent?.match(/\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\b/gi)?.[0],windowProxy:a}}}});var mi={};A(mi,{Attachment:()=>It,BaseplateVisibilityValues:()=>he,CubeInfo:()=>$,ModelComponent:()=>k,Spatial:()=>W,SpatialBoxGeometry:()=>N,SpatialComponent:()=>B,SpatialConeGeometry:()=>X,SpatialCylinderGeometry:()=>q,SpatialEntity:()=>P,SpatialGeometry:()=>g,SpatialMaterial:()=>F,SpatialModelAsset:()=>J,SpatialModelEntity:()=>U,SpatialObject:()=>y,SpatialPlaneGeometry:()=>Q,SpatialScene:()=>x,SpatialSceneState:()=>Yt,SpatialSceneValues:()=>Ee,SpatialSession:()=>z,SpatialSphereGeometry:()=>H,SpatialUnlitMaterial:()=>j,Spatialized2DElement:()=>R,SpatializedDynamic3DElement:()=>T,SpatializedElement:()=>h,SpatializedElementType:()=>ge,SpatializedStatic3DElement:()=>C,WorldAlignmentValues:()=>be,WorldScalingValues:()=>xe,createAttachmentEntity:()=>ee,isSSREnv:()=>_,isValidBaseplateVisibilityType:()=>qt,isValidSceneUnit:()=>zt,isValidSpatialSceneType:()=>Kt,isValidWorldAlignmentType:()=>Xt,isValidWorldScalingType:()=>Qt});var Je=typeof window>"u",_=()=>Je;var K=class{callJSB(e,t){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocol(e,t,r,n){return Promise.resolve({success:!0,data:void 0,errorCode:void 0,errorMessage:void 0})}callWebSpatialProtocolSync(e,t,r,n,a){return{success:!0,data:void 0,errorCode:void 0,errorMessage:void 0}}};function Ye(i){let e=i.match(/WebSpatial\/(\d+)\.(\d+)\.(\d+)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null}function Ze(i,e){if(!i)return!1;for(let t=0;t<3;t+=1){let r=i[t]-e[t];if(r>0)return!0;if(r<0)return!1}return!1}function ye(){if(_())return new K;let i=window.navigator.userAgent,e=Ye(i);if(window.navigator.userAgent.includes("Puppeteer")){let t=(re(),G(ie)).PuppeteerPlatform;return new t}else if(i.includes("PicoWebApp")&&Ze(e,[0,0,1])){let t=(oe(),G(ae)).XRPlatform;return new t}else if(i.includes("Android")||i.includes("Linux")){let t=(de(),G(ce)).AndroidPlatform;return new t}else{let t=(ue(),G(me)).VisionOSPlatform;return new t}}function Z(i,e){return i===""?0:i.endsWith("%")?e*parseFloat(i)/100:parseFloat(i)}function fe(i){let e=parseFloat(i.getPropertyValue("width")),t=i.getPropertyValue("border-top-left-radius"),r=i.getPropertyValue("border-top-right-radius"),n=i.getPropertyValue("border-bottom-left-radius"),a=i.getPropertyValue("border-bottom-right-radius");return{topLeading:Z(t,e),bottomLeading:Z(n,e),topTrailing:Z(r,e),bottomTrailing:Z(a,e)}}function Se(i,e,t){let{x:r,y:n,z:a}=i,{x:o,y:s,z:l}=e,{x:c,y:I,z:M}=t,S=new DOMMatrix;return S=S.translate(r,n,a),S=S.rotate(o,s,l),S=S.scale(c,I,M),S}var Nt=ye(),p=class{commandType="";async execute(){let e=this.getParams(),t=e?JSON.stringify(e):"";return Nt.callJSB(this.commandType,t)}},tt=class extends p{constructor(t,r){super();this.entity=t;this.properties=r}commandType="UpdateEntityProperties";getParams(){let t=Se(this.properties.position??this.entity.position,this.properties.rotation??this.entity.rotation,this.properties.scale??this.entity.scale).toFloat64Array();return{entityId:this.entity.id,transform:t}}},et=class extends p{constructor(t,r,n){super();this.entity=t;this.type=r;this.isEnable=n}commandType="UpdateEntityEvent";getParams(){return{type:this.type,entityId:this.entity.id,isEnable:this.isEnable}}};var it=class extends p{properties;commandType="UpdateSpatialSceneProperties";constructor(e){super(),this.properties=e}getParams(){return this.properties}},rt=class extends p{config;commandType="UpdateSceneConfig";constructor(e){super(),this.config=e}getParams(){return{config:this.config}}},nt=class extends p{constructor(t){super();this.id=t}commandType="FocusScene";getParams(){return{id:this.id}}},at=class extends p{commandType="GetSpatialSceneState";constructor(){super()}getParams(){return{}}},b=class extends p{constructor(t){super();this.spatialObject=t}getParams(){let t=this.getExtraParams();return{id:this.spatialObject.id,...t}}},ot=class extends b{properties;commandType="UpdateSpatialized2DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},st=class extends b{properties;commandType="UpdateSpatializedDynamic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return{id:this.spatialObject.id,...this.properties}}},lt=class extends b{properties;commandType="UpdateUnlitMaterialProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},pt=class extends b{matrix;commandType="UpdateSpatializedElementTransform";constructor(e,t){super(e),this.matrix=t}getExtraParams(){return{matrix:Array.from(this.matrix.toFloat64Array())}}},ct=class extends b{properties;commandType="UpdateSpatializedStatic3DElementProperties";constructor(e,t){super(e),this.properties=t}getExtraParams(){return this.properties}},dt=class extends b{commandType="AddSpatializedElementToSpatialized2DElement";spatializedElement;constructor(e,t){super(e),this.spatializedElement=t}getExtraParams(){return{spatializedElementId:this.spatializedElement.id}}},mt=class extends p{commandType="AddSpatializedElementToSpatialScene";spatializedElement;constructor(e){super(),this.spatializedElement=e}getParams(){return{spatializedElementId:this.spatializedElement.id}}},ut=class extends p{constructor(t){super();this.modelURL=t;this.modelURL=t}commandType="CreateSpatializedStatic3DElement";getParams(){return{modelURL:this.modelURL}}},yt=class extends p{getParams(){return{test:!0}}commandType="CreateSpatializedDynamic3DElement"},ft=class extends p{constructor(t){super();this.name=t}getParams(){return{name:this.name}}commandType="CreateSpatialEntity"},St=class extends p{constructor(t){super();this.options=t}getParams(){let t=this.options.mesh.id,r=this.options.materials.map(n=>n.id);return{geometryId:t,materialIds:r}}commandType="CreateModelComponent"},gt=class extends p{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateSpatialModelEntity"},ht=class extends p{constructor(t){super();this.options=t}getParams(){return{url:this.options.url}}commandType="CreateModelAsset"},xt=class extends p{constructor(t,r={}){super();this.type=t;this.options=r}getParams(){return{type:this.type,...this.options}}commandType="CreateGeometry"},bt=class extends p{constructor(t){super();this.options=t}getParams(){return this.options}commandType="CreateUnlitMaterial"},Et=class extends p{constructor(t,r){super();this.entity=t;this.comp=r}getParams(){return{entityId:this.entity.id,componentId:this.comp.id}}commandType="AddComponentToEntity"};var v=class extends p{constructor(t,r){super();this.childId=t;this.parentId=r}getParams(){return{childId:this.childId,parentId:this.parentId}}commandType="SetParentToEntity"},wt=class extends p{constructor(t,r,n){super();this.fromEntityId=t;this.toEntityId=r;this.fromPosition=n}getParams(){return{fromEntityId:this.fromEntityId,toEntityId:this.toEntityId,position:this.fromPosition}}commandType="ConvertFromEntityToEntity"},vt=class extends p{constructor(t,r){super();this.fromEntityId=t;this.position=r}getParams(){return{fromEntityId:this.fromEntityId,position:this.position}}commandType="ConvertFromEntityToScene"},Pt=class extends p{constructor(t,r){super();this.entityId=t;this.position=r}getParams(){return{entityId:this.entityId,position:this.position}}commandType="ConvertFromSceneToEntity"};var Mt=class extends p{constructor(t=""){super();this.id=t}commandType="Inspect";getParams(){return this.id?{id:this.id}:{id:""}}},Dt=class extends p{constructor(t){super();this.id=t}commandType="Destroy";getParams(){return{id:this.id}}};var L=class extends p{target;features;async execute(){let e=this.getQuery();return Nt.callWebSpatialProtocol(this.commandType,e,this.target,this.features)}executeSync(){let e=this.getQuery();return Nt.callWebSpatialProtocolSync(this.commandType,e,this.target,this.features)}getQuery(){let e,t=this.getParams();return t&&(e=Object.keys(t).map(r=>{let n=t[r],a=typeof n=="object"?JSON.stringify(n):n;return`${r}=${encodeURIComponent(a)}`}).join("&")),e}},Rt=class extends L{commandType="createSpatialized2DElement";constructor(){super()}getParams(){return{}}},Ct=class extends L{constructor(t,r,n,a){super();this.url=t;this.config=r;this.target=n;this.features=a}commandType="createSpatialScene";getParams(){return{url:this.url,config:this.config}}},Tt=class extends L{constructor(t){super();this.options=t}commandType="createAttachment";getParams(){return{parentEntityId:this.options.parentEntityId,position:this.options.position??[0,0,0],size:this.options.size}}},Ot=class extends p{constructor(t,r){super();this.attachmentId=t;this.options=r}commandType="UpdateAttachmentEntity";getParams(){return{id:this.attachmentId,...this.options}}};var y=class{constructor(e){this.id=e}name;isDestroyed=!1;async inspect(){let e=await new Mt(this.id).execute();if(e.success)return e.data;throw new Error(e.errorMessage)}async destroy(){if(this.isDestroyed)return;let e=await new Dt(this.id).execute();if(e.success)return this.onDestroy(),this.isDestroyed=!0,e.data;if(this.isDestroyed)return;throw new Error(e.errorMessage)}onDestroy(){}};var Ht,x=class i extends y{static getInstance(){return Ht||(Ht=new i("")),Ht}async updateSpatialProperties(e){return new it(e).execute()}async addSpatializedElement(e){return new mt(e).execute()}async updateSceneCreationConfig(e){return new rt(e).execute()}async getState(){return(await new at().execute()).data.name}};var ge=(r=>(r[r.Spatialized2DElement=0]="Spatialized2DElement",r[r.SpatializedStatic3DElement=1]="SpatializedStatic3DElement",r[r.SpatializedDynamic3DElement=2]="SpatializedDynamic3DElement",r))(ge||{}),he=["automatic","visible","hidden"];function qt(i){return he.includes(i)}var xe=["automatic","dynamic"];function Qt(i){return xe.includes(i)}var be=["adaptive","automatic","gravityAligned"];function Xt(i){return be.includes(i)}var Ee=["window","volume"];function Kt(i){return Ee.includes(i)}function zt(i){if(typeof i=="number")return i>=0;if(typeof i=="string"){if(i.endsWith("px"))return isNaN(Number(i.slice(0,-2)))?!1:Number(i.slice(0,-2))>=0;if(i.endsWith("m"))return isNaN(Number(i.slice(0,-1)))?!1:Number(i.slice(0,-1))>=0}return!1}var Yt=(a=>(a.idle="idle",a.pending="pending",a.willVisible="willVisible",a.visible="visible",a.fail="fail",a))(Yt||{}),$=class{constructor(e,t){this.size=e;this.origin=t;this.size=e,this.origin=t}get x(){return this.origin.x}get y(){return this.origin.y}get z(){return this.origin.z}get width(){return this.size.width}get height(){return this.size.height}get depth(){return this.size.depth}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get back(){return this.z}get front(){return this.z+this.depth}};var ti={defaultSize:{width:1280,height:720}},ei={defaultSize:{width:.94,height:.94,depth:.94}},ii="webspatial://",Wt=class i{originalOpen;static instance;static getInstance(){return i.instance||(i.instance=new i),i.instance}init(e){this.originalOpen=e.open.bind(e),e.open=this.open}configMap={};getConfig(e){if(!(e===void 0||!this.configMap[e]))return this.configMap[e]}ensureAbsoluteUrl(e){if(!e||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e))return e;if(e.startsWith("//"))return`${window.location.protocol}${e}`;try{return new URL(e,document.baseURI).toString()}catch{return e}}open=(e,t,r)=>{if(e?.startsWith(ii))return this.originalOpen(e,t,r);if(e=this.ensureAbsoluteUrl(e),t==="_self"||t==="_parent"||t==="_top")return this.originalOpen(e,t,r);let n=t?this.getConfig(t):void 0,o=new Ct(e,n,t,r).executeSync(),s=o.data?.id;return s&&new nt(s).execute(),o.data?.windowProxy};initScene(e,t,r){let n=r?.type??"window",a=te(n),o=t({...a}),[s,l]=Me(o,n);l.length>0&&console.warn(`initScene ${e} with errors: ${l.join(", ")}`),this.configMap[e]={...s,type:n}}};function we(i){return i/1360}function ve(i){return i*1360}function Pe(i,e,t){if(typeof i=="number")return t==="px"&&e==="px"||t==="m"&&e==="m"?i:t==="px"&&e==="m"?we(i):t==="m"&&e==="px"?ve(i):i;if(e==="m"){if(i.endsWith("m"))return Number(i.slice(0,-1));if(i.endsWith("px"))return we(Number(i.slice(0,-2)));throw new Error("formatToNumber: invalid str")}else if(e==="px"){if(i.endsWith("px"))return Number(i.slice(0,-2));if(i.endsWith("m"))return ve(Number(i.slice(0,-1)));throw new Error("formatToNumber: invalid str")}else throw new Error("formatToNumber: invalid targetUnit")}function Me(i,e){let t=te(e),r=[],n=e==="window";if(Kt(e)||r.push("sceneType"),i.defaultSize){let a=["width","height","depth"];for(let o of a)o in i.defaultSize&&(zt(i.defaultSize[o])?i.defaultSize[o]=Pe(i.defaultSize[o],n?"px":"m",n?"px":"m"):(i.defaultSize[o]=t.defaultSize[o],r.push(`defaultSize.${o}`)))}if(i.resizability){let a=["minWidth","minHeight","maxWidth","maxHeight"];for(let o of a)o in i.resizability&&(zt(i.resizability[o])?i.resizability[o]=Pe(i.resizability[o],"px",n?"px":"m"):(i.resizability[o]=void 0,r.push(`resizability.${o}`)))}return i.worldScaling&&(Qt(i.worldScaling)||(i.worldScaling="automatic",r.push("worldScaling"))),i.worldAlignment&&(Xt(i.worldAlignment)||(i.worldAlignment="automatic",r.push("worldAlignment"))),i.baseplateVisibility&&(qt(i.baseplateVisibility)||(i.baseplateVisibility="automatic",r.push("baseplateVisibility"))),[i,r]}function De(i,e,t){return Wt.getInstance().initScene(i,e,t)}function ri(i){Wt.getInstance().init(i)}function Zt(i){i.document.onclick=function(e){let t=e.target,r=!1;for(;!r;){if(t&&t.tagName=="A")return!ni(e);if(t&&t.parentElement)t=t.parentElement;else break}}}function ni(i){let e=i.target;if(e.tagName==="A"){let t=e,r=t.target,n=t.href;if(r&&r!=="_self")return i.preventDefault(),window.open(n,r),!0}}function te(i){return i==="window"?ti:ei}async function ai(){if(!window.opener||await x.getInstance().getState()!=="pending")return;function e(t){document.readyState==="interactive"||document.readyState==="complete"?t():document.addEventListener("DOMContentLoaded",t)}e(async()=>{let t=te(window.xrCurrentSceneType??"window"),r=t;if(typeof window.xrCurrentSceneDefaults=="function")try{r=await window.xrCurrentSceneDefaults?.(t)}catch(s){console.error(s)}await new Promise((s,l)=>{setTimeout(()=>{s(null)},1e3)});let n=window.xrCurrentSceneType??"window",[a,o]=Me(r,n);o.length>0&&console.warn(`window.xrCurrentSceneDefaults with errors: ${o.join(", ")}`),await x.getInstance().updateSceneCreationConfig({...a,type:n})})}function Re(){ri(window),Zt(window),ai()}w();function f(i,e){return new CustomEvent(i,{bubbles:!0,cancelable:!1,detail:e})}var h=class extends y{constructor(t){super(t);this.id=t;d.addEventReceiver(t,this.onReceiveEvent.bind(this))}async updateTransform(t){return new pt(this,t).execute()}_cubeInfo;get cubeInfo(){return this._cubeInfo}_transform;_transformInv;get transform(){return this._transform}get transformInv(){return this._transformInv}onReceiveEvent(t){let{type:r}=t;if(r==="objectdestroy")this.isDestroyed=!0;else if(r==="cubeInfo"){let n=t;this._cubeInfo=new $(n.size,n.origin)}else if(r==="transform")this._transform=new DOMMatrix([t.detail.column0[0],t.detail.column0[1],t.detail.column0[2],0,t.detail.column1[0],t.detail.column1[1],t.detail.column1[2],0,t.detail.column2[0],t.detail.column2[1],t.detail.column2[2],0,t.detail.column3[0],t.detail.column3[1],t.detail.column3[2],1]),this._transformInv=this._transform.inverse();else if(r==="spatialtap"){let n=f("spatialtap",t.detail);this._onSpatialTap?.(n)}else if(r==="spatialdragstart"){let n=f("spatialdragstart",t.detail);this._onSpatialDragStart?.(n)}else if(r==="spatialdrag"){let n=f("spatialdrag",t.detail);this._onSpatialDrag?.(n)}else if(r==="spatialdragend"){let n=f("spatialdragend",t.detail);this._onSpatialDragEnd?.(n)}else if(r==="spatialrotate"){let n=f("spatialrotate",t.detail);this._onSpatialRotate?.(n)}else if(r==="spatialrotateend"){let n=f("spatialrotateend",t.detail);this._onSpatialRotateEnd?.(n)}else if(r==="spatialmagnify"){let n=f("spatialmagnify",t.detail);this._onSpatialMagnify?.(n)}else if(r==="spatialmagnifyend"){let n=f("spatialmagnifyend",t.detail);this._onSpatialMagnifyEnd?.(n)}}_onSpatialTap;set onSpatialTap(t){this._onSpatialTap=t,this.updateProperties({enableTapGesture:t!==void 0})}_onSpatialDragStart;set onSpatialDragStart(t){this._onSpatialDragStart=t,this.updateProperties({enableDragStartGesture:this._onSpatialDragStart!==void 0})}_onSpatialDrag;set onSpatialDrag(t){this._onSpatialDrag=t,this.updateProperties({enableDragGesture:this._onSpatialDrag!==void 0})}_onSpatialDragEnd;set onSpatialDragEnd(t){this._onSpatialDragEnd=t,this.updateProperties({enableDragEndGesture:t!==void 0})}_onSpatialRotate;set onSpatialRotate(t){this._onSpatialRotate=t,this.updateProperties({enableRotateGesture:this._onSpatialRotate!==void 0})}_onSpatialRotateEnd;set onSpatialRotateEnd(t){this._onSpatialRotateEnd=t,this.updateProperties({enableRotateEndGesture:t!==void 0})}_onSpatialMagnify;set onSpatialMagnify(t){this._onSpatialMagnify=t,this.updateProperties({enableMagnifyGesture:t!==void 0})}_onSpatialMagnifyEnd;set onSpatialMagnifyEnd(t){this._onSpatialMagnifyEnd=t,this.updateProperties({enableMagnifyEndGesture:t!==void 0})}onDestroy(){d.removeEventReceiver(this.id)}};var R=class extends h{constructor(t,r){super(t);this.windowProxy=r;Zt(r)}async updateProperties(t){return new ot(this,t).execute()}async addSpatializedElement(t){return new dt(this,t).execute()}};var C=class extends h{constructor(e,t){super(e),this.modelURL=t}_readyResolve;modelURL;createReadyPromise(){return new Promise(e=>{this._readyResolve=e})}ready=this.createReadyPromise();async updateProperties(e){return e.modelURL!==void 0&&this.modelURL!==e.modelURL&&(this.modelURL=e.modelURL,this.ready=this.createReadyPromise()),new ct(this,e).execute()}onReceiveEvent(e){e.type==="modelloaded"?(this._onLoadCallback?.(),this._readyResolve?.(!0)):e.type==="modelloadfailed"?(this._onLoadFailureCallback?.(),this._readyResolve?.(!1)):super.onReceiveEvent(e)}_onLoadCallback;set onLoadCallback(e){this._onLoadCallback=e}_onLoadFailureCallback;set onLoadFailureCallback(e){this._onLoadFailureCallback=e}updateModelTransform(e){let t=Array.from(e.toFloat64Array());this.updateProperties({modelTransform:t})}};var T=class extends h{children=[];constructor(e){super(e)}async addEntity(e){let t=new v(e.id,this.id).execute();return this.children.push(e),e.parent=this,t}async updateProperties(e){return new st(this,e).execute()}};async function Ce(){let i=await new Rt().execute();if(i.success){let{id:e,windowProxy:t}=i.data;return t.document.head.innerHTML=`<meta name="viewport" content="width=device-width, initial-scale=1">
74
+ <base href="${document.baseURI}">`,new R(e,t)}else throw new Error("createSpatialized2DElement failed")}async function Te(i){let e=await new ut(i).execute();if(e.success){let{id:t}=e.data;return new C(t,i)}else throw new Error("createSpatializedStatic3DElement failed")}async function Oe(){let i=await new yt().execute();if(i.success){let{id:e}=i.data;return new T(e)}else throw new Error("createSpatializedDynamic3DElement failed")}var It=class extends y{constructor(t,r,n){super(t);this.windowProxy=r;this.options=n}getContainer(){return this.windowProxy.document.body}getWindowProxy(){return this.windowProxy}async update(t){if(!this.isDestroyed)return t.position&&(this.options.position=t.position),t.size&&(this.options.size=t.size),new Ot(this.id,t).execute()}};async function ee(i){let e=await new Tt(i).execute();if(!e.success)throw new Error("createAttachmentEntity failed: "+e?.errorMessage);let{id:t,windowProxy:r}=e.data;return new It(t,r,i)}w();var P=class i extends y{constructor(t,r){super(t);this.userData=r;d.addEventReceiver(t,this.onReceiveEvent)}position={x:0,y:0,z:0};rotation={x:0,y:0,z:0};scale={x:1,y:1,z:1};events={};children=[];parent=null;async addComponent(t){return new Et(this,t).execute()}async setPosition(t){return this.updateTransform({position:t})}async setRotation(t){return this.updateTransform({rotation:t})}async setScale(t){return this.updateTransform({scale:t})}async addEntity(t){let r=await new v(t.id,this.id).execute();return this.children.push(t),t.parent=this,r}async removeFromParent(){let t=await new v(this.id,void 0).execute();return this.parent&&(this.parent.children=this.parent.children.filter(r=>r.id!==this.id),this.parent=null),t}async updateTransform(t){return this.position=t.position??this.position,this.rotation=t.rotation??this.rotation,this.scale=t.scale??this.scale,new tt(this,t).execute()}async addEvent(t,r){if(this.events[t])this.events[t]=r;else try{await this.updateEntityEvent(t,!0),this.events[t]=r}catch{console.error("addEvent failed",t)}}async removeEvent(t){if(this.events[t]){delete this.events[t];try{await this.updateEntityEvent(t,!1)}catch{console.error("removeEvent failed",t)}}}async updateEntityEvent(t,r){return new et(this,t,r).execute()}onReceiveEvent=t=>{let{type:r}=t;if(r==="objectdestroy")this.isDestroyed=!0;else if(r==="spatialtap"){let n=f("spatialtap",t.detail);this.dispatchEvent(n)}else if(r==="spatialdragstart"){let n=f("spatialdragstart",t.detail);this.dispatchEvent(n)}else if(r==="spatialdrag"){let n=f("spatialdrag",t.detail);this.dispatchEvent(n)}else if(r==="spatialdragend"){let n=f("spatialdragend",t.detail);this.dispatchEvent(n)}else if(r==="spatialrotate"){let n=f("spatialrotate",t.detail);this.dispatchEvent(n)}else if(r==="spatialrotateend"){let n=f("spatialrotateend",t.detail);this.dispatchEvent(n)}else if(r==="spatialmagnify"){let n=f("spatialmagnify",t.detail);this.dispatchEvent(n)}else if(r==="spatialmagnifyend"){let n=f("spatialmagnifyend",t.detail);this.dispatchEvent(n)}};dispatchEvent(t){t.__origin||Object.defineProperty(t,"__origin",{value:this,enumerable:!1}),this.events[t.type]?.(t),t.bubbles&&!t.cancelBubble&&this.parent&&this.parent instanceof i&&this.parent.dispatchEvent(t)}onDestroy(){d.removeEventReceiver(this.id),this.children.forEach(t=>{t.parent=null}),this.children=[],this.parent&&(this.parent.children=this.parent.children.filter(t=>t.id!==this.id),this.parent=null)}async convertFromEntityToEntity(t,r,n){return new wt(t,r,n).execute()}async convertFromEntityToScene(t,r){return new vt(t,r).execute()}async convertFromSceneToEntity(t,r){return new Pt(t,r).execute()}};var U=class extends P{constructor(t,r,n){super(t,n);this.id=t;this.options=r;this.userData=n}};w();var B=class extends y{constructor(e){super(e),d.addEventReceiver(e,this.onReceiveEvent)}onReceiveEvent=e=>{let{type:t}=e;t==="objectdestroy"&&(this.isDestroyed=!0)}};var k=class extends B{constructor(t,r){super(t);this.options=r}};var F=class extends y{constructor(t,r){super(t);this.id=t;this.type=r;this.type=r}};var j=class extends F{constructor(t,r){super(t,"unlit");this.id=t;this.options=r}updateProperties(t){return new lt(this,t).execute()}};var J=class extends y{constructor(t,r){super(t);this.id=t;this.options=r}};async function ze(i){let e=await new ft(i?.name).execute();if(e.success){let{id:t}=e.data;return new P(t,i)}else throw new Error("createSpatialEntity failed:"+e?.errorMessage)}async function O(i,e){let t=await new xt(i.type,e).execute();if(t.success){let{id:r}=t.data;return new i(r,e)}else throw new Error("createSpatialGeometry failed:"+t?.errorMessage)}async function We(i){let e=await new bt(i).execute();if(e.success){let{id:t}=e.data;return new j(t,i)}else throw new Error("createSpatialUnlitMaterial failed:"+e?.errorMessage)}async function Ie(i){let e=await new St(i).execute();if(e.success){let{id:t}=e.data;return new k(t,i)}else throw new Error("createModelComponent failed:"+e?.errorMessage)}async function Ae(i,e){let t=await new gt(i).execute();if(t.success){let{id:r}=t.data;return new U(r,i,e)}else throw new Error("createSpatialModelEntity failed:"+t?.errorMessage)}async function Ge(i){let e=await new ht(i).execute();if(e.success){let{id:t}=e.data;return new J(t,i)}else throw new Error("createModelAsset failed:"+e?.errorMessage)}var g=class extends y{constructor(t,r){super(t);this.id=t;this.options=r}static type};var N=class extends g{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="BoxGeometry"};var H=class extends g{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="SphereGeometry"};var q=class extends g{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="CylinderGeometry"};var Q=class extends g{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="PlaneGeometry"};var X=class extends g{constructor(t,r){super(t,r);this.id=t;this.options=r}static type="ConeGeometry"};var z=class{getSpatialScene(){return x.getInstance()}createSpatialized2DElement(){return Ce()}createSpatializedStatic3DElement(e){return Te(e)}initScene=De;createSpatializedDynamic3DElement(){return Oe()}createEntity(e){return ze(e)}createBoxGeometry(e={}){return O(N,e)}createPlaneGeometry(e={}){return O(Q,e)}createSphereGeometry(e={}){return O(H,e)}createConeGeometry(e){return O(X,e)}createCylinderGeometry(e){return O(q,e)}createModelComponent(e){return Ie(e)}createUnlitMaterial(e){return We(e)}createModelAsset(e){return Ge(e)}createSpatialModelEntity(e,t){return Ae(e,t)}createAttachmentEntity(e){return ee(e)}};w();var W=class{requestSession(){return this.runInSpatialWeb()?(d.init(),new z):null}runInSpatialWeb(){return navigator.userAgent.indexOf("WebSpatial/")>0}isSupported(){return!0}getNativeVersion(){return window.__WebSpatialData&&window.__WebSpatialData.getNativeVersion?window.__WebSpatialData.getNativeVersion():window.WebSpatailNativeVersion==="PACKAGE_VERSION"?this.getClientVersion():window.WebSpatailNativeVersion}getClientVersion(){return"1.2.1"}};var _e=new W,Vt,At={backgroundMaterial:"--xr-background-material"},Ve="";function Gt(i){i!==Ve&&(Vt?.getSpatialScene()?.updateSpatialProperties({material:i}),Ve=i)}function oi(){let e=getComputedStyle(document.documentElement).getPropertyValue(At.backgroundMaterial);Gt(e||"none")}var E={topLeading:0,bottomLeading:0,topTrailing:0,bottomTrailing:0};function Le(){let i=getComputedStyle(document.documentElement),e=fe(i);si(e)}function si(i){(E.topLeading!==i.topLeading||E.bottomLeading!==i.bottomLeading||E.topTrailing!==i.topTrailing||E.bottomTrailing!==i.bottomTrailing)&&(Vt?.getSpatialScene()?.updateSpatialProperties({cornerRadius:i}),E.topLeading=i.topLeading,E.bottomLeading=i.bottomLeading,E.topTrailing=i.topTrailing,E.bottomTrailing=i.bottomTrailing)}function li(i){Vt?.getSpatialScene().updateSpatialProperties({opacity:i})}function $e(){let i=getComputedStyle(document.documentElement),e=parseFloat(i.getPropertyValue("opacity"));li(e)}function pi(){let i=document.documentElement.style,e=new Proxy(i,{set:function(t,r,n){let a=Reflect.set(t,r,n);return r===At.backgroundMaterial&&Gt(n),(r==="border-radius"||r==="borderRadius"||r==="border-top-left-radius"||r==="borderTopLeftRadius"||r==="border-top-right-radius"||r==="borderTopRightRadius"||r==="border-bottom-left-radius"||r==="borderBottomLeftRadius"||r==="border-bottom-right-radius"||r==="borderBottomRightRadius")&&Le(),r==="opacity"&&$e(),a},get:function(t,r){return typeof t[r]=="function"?function(...n){if(r==="setProperty"){let[a,o]=n;a===At.backgroundMaterial&&Gt(o)}else if(r==="removeProperty"){let[a]=n;a===At.backgroundMaterial&&Gt("none")}return t[r](...n)}:Reflect.get(t,r)}});Object.defineProperty(document.documentElement,"style",{get:function(){return e}})}function ci(){new MutationObserver(_t).observe(document.head,{childList:!0,subtree:!0})}function _t(){oi(),Le(),$e()}function di(){new MutationObserver(e=>{e.forEach(t=>{t.type==="attributes"&&t.attributeName&&_t()})}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}async function Ue(){_e.runInSpatialWeb()&&(Vt=await _e.requestSession(),document.readyState==="complete"?_t():window.addEventListener("load",()=>{_t()}),pi(),ci(),di())}!_()&&navigator.userAgent.indexOf("WebSpatial/")>0&&(Re(),Ue());return G(mi);})();
75
+ //# sourceMappingURL=index.global.js.map