vis-core 0.33.17 → 0.33.19

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.
package/dist/io.d.ts CHANGED
@@ -1,8 +1,12 @@
1
+ export declare function assertMapNavigationTarget(catalog: RuntimeAssetCatalog | undefined, adcode: number, sceneId?: string): void;
2
+
3
+ export declare function assertMediaAssets(value: unknown): asserts value is MediaAssetManifest | undefined;
4
+
1
5
  export declare function assetDigest(bytes: Uint8Array): Promise<string>;
2
6
 
3
7
  export declare const cityJsonName: (key: string, data: string) => string;
4
8
 
5
- export declare function decodeAssetBytes(data: string): Uint8Array;
9
+ export declare function decodeAssetBytes(data: string | ArrayBuffer): Uint8Array;
6
10
 
7
11
  declare type DownloadProgress = {
8
12
  percent: number;
@@ -12,6 +16,12 @@ declare type DownloadProgress = {
12
16
 
13
17
  export declare function encodeAssetBytes(bytes: Uint8Array): string;
14
18
 
19
+ declare type FileEntry = {
20
+ path: string;
21
+ info: MediaAssetInfo;
22
+ file: MediaAssetFile;
23
+ };
24
+
15
25
  export declare const isGzip: (url: string) => boolean;
16
26
 
17
27
  export declare const jsonFetch: <T = any>(url: string, onDownloadProgress?: (progress: DownloadProgress) => void, gzip?: (url: string) => boolean, options?: JsonFetchOptions) => Promise<{
@@ -35,6 +45,14 @@ export declare interface MapExportScope {
35
45
  maxLevel: 'province' | 'city' | 'district';
36
46
  }
37
47
 
48
+ export declare type MapNavigation = {
49
+ mode: 'static';
50
+ } | {
51
+ mode: 'dynamic';
52
+ scope: MapExportScope;
53
+ templates: Partial<Record<MapExportScope['maxLevel'], string>>;
54
+ };
55
+
38
56
  declare interface MapRegionBackInteraction {
39
57
  trigger: 'click' | 'clickOutside';
40
58
  objectId: string;
@@ -82,6 +100,45 @@ declare type MaterialScope = {
82
100
  sceneId: string;
83
101
  };
84
102
 
103
+ export declare interface MediaAssetFile {
104
+ data: Uint8Array;
105
+ mimeType: string;
106
+ }
107
+
108
+ /** File metadata belongs to the manifest, never to a Three image URL. */
109
+ export declare interface MediaAssetInfo {
110
+ sha256: string;
111
+ bytes: number;
112
+ mimeType: string;
113
+ kind: 'image' | 'hdr' | 'tga' | 'video' | 'pixels';
114
+ pixels?: {
115
+ type: string;
116
+ width: number;
117
+ height: number;
118
+ depth?: number;
119
+ };
120
+ }
121
+
122
+ export declare type MediaAssetManifest = Record<string, MediaAssetInfo>;
123
+
124
+ /** Private decoder input; only the manifest and native URL strings are persisted. */
125
+ export declare function mediaAssetPayload(info: MediaAssetInfo, data: ArrayBuffer | string): any;
126
+
127
+ /** COW projection preserves unchanged geometry/object graphs and cached file
128
+ * bytes. Owned history snapshots are never rewritten with deployment paths. */
129
+ export declare class MediaAssetWriter {
130
+ private payloads;
131
+ private graphs;
132
+ private rows;
133
+ private row;
134
+ writePayload(value: any): FileEntry | undefined;
135
+ prepare<T extends Record<string, any>>(document: T): {
136
+ document: T;
137
+ assets: MediaAssetManifest;
138
+ files: Record<string, MediaAssetFile>;
139
+ };
140
+ }
141
+
85
142
  export declare function mergeRuntimeAssets(previous?: RuntimeAssetCatalog, incoming?: RuntimeAssetCatalog): RuntimeAssetCatalog | undefined;
86
143
 
87
144
  declare interface PrefabAsset {
@@ -98,6 +155,11 @@ declare interface PrefabAsset {
98
155
  /** Read a self-contained ZIP into a document with persistent image payloads. */
99
156
  export declare function readSceneBundleZip(input: SceneBundleBinary, name?: string): Promise<VisSceneDocument>;
100
157
 
158
+ /** Resolve declared URLs only. Repeated calls leave already hydrated data alone. */
159
+ export declare function resolveMediaAssets(value: any, assets: MediaAssetManifest | undefined, read: (path: string, info: MediaAssetInfo) => ArrayBuffer | string): void;
160
+
161
+ export declare const resolveResourceUrl: (source: string, prefix?: string) => string;
162
+
101
163
  /** Static dependencies owned by a project. Source URLs are lookup keys, never fallbacks. */
102
164
  export declare interface RuntimeAsset {
103
165
  id: string;
@@ -107,14 +169,16 @@ export declare interface RuntimeAsset {
107
169
  encoding: 'identity' | 'gzip';
108
170
  bytes: number;
109
171
  sha256: string;
110
- /** Compressed/original file bytes, base64 encoded for project persistence. */
111
- data?: string;
172
+ /** Owned file bytes; legacy encoded catalogs must be imported by the platform. */
173
+ data?: ArrayBuffer;
112
174
  }
113
175
 
114
176
  export declare interface RuntimeAssetCatalog {
115
177
  version: 1;
116
178
  entries: RuntimeAsset[];
117
179
  scope?: MapExportScope;
180
+ /** Explicit delivery contract; omitted only in older packages. */
181
+ mapNavigation?: MapNavigation;
118
182
  /** Enumerated interaction targets, including regions never opened in the editor. */
119
183
  regions?: Record<string, number[]>;
120
184
  declaredSources?: string[];
@@ -135,8 +199,10 @@ export declare class RuntimeAssetResolver {
135
199
  private externals;
136
200
  readonly catalog: RuntimeAssetCatalog;
137
201
  private strict;
202
+ private prefix;
138
203
  constructor(catalog: RuntimeAssetCatalog, prefix?: string, strict?: boolean);
139
204
  resolve: (source: string) => string;
205
+ dispose(): void;
140
206
  }
141
207
 
142
208
  declare const SCENE_DOCUMENT_FORMAT: "vis-scene";
@@ -201,8 +267,6 @@ declare interface VisSceneDocument extends SceneDocumentMarker {
201
267
  runtimeAssets?: RuntimeAssetCatalog;
202
268
  entrySceneId: string;
203
269
  scenes: SceneViewportDocument[];
204
- /** Schema 3: scene payloads; schema 6 also shares material-library payloads. */
205
- _resourcePool?: any[];
206
270
  /** Schema 4: serializable definitions shared by explicit asset identity. */
207
271
  materialLibrary?: MaterialAsset[];
208
272
  /** Reusable definitions. SDK-enabled assets are retained in deployment exports. */
package/dist/io.js CHANGED
@@ -1 +1 @@
1
- import{c as s,d as a,f as o,i as m,l as r,m as t,n as e,o as i,p,r as c,t as f,u as n}from"./e-DDhN_TXt.js";export{i as RuntimeAssetResolver,s as assetDigest,f as cityJsonName,r as decodeAssetBytes,n as encodeAssetBytes,p as isGzip,t as jsonFetch,a as mergeRuntimeAssets,m as readSceneBundleZip,o as verifyAssetBytes,e as verifySwitchKey,c as verifySwitchKeyScope};
1
+ import{r as s}from"./sha2-BCqd-su1.js";import{_ as a,a as r,c as o,d as m,g as t,h as i,i as p,m as e,n as c,o as f,p as h,r as j,s as n,t as v,u as y,v as d,y as g}from"./e-BTBbEYEO.js";var u=s;export{p as MediaAssetWriter,y as RuntimeAssetResolver,m as assertMapNavigationTarget,r as assertMediaAssets,h as assetDigest,v as cityJsonName,e as decodeAssetBytes,i as encodeAssetBytes,d as isGzip,g as jsonFetch,f as mediaAssetPayload,t as mergeRuntimeAssets,o as readSceneBundleZip,n as resolveMediaAssets,u as resolveResourceUrl,a as verifyAssetBytes,c as verifySwitchKey,j as verifySwitchKeyScope};
@@ -0,0 +1 @@
1
+ import{Nt as e,O as t,u as a}from"./dist-6e_r_Ils.js";import{a as s}from"./sha2-BCqd-su1.js";import{i as r,s as o}from"./e-BTBbEYEO.js";var i=/* @__PURE__ */e({externalizeRuntimeImages:()=>n,resolveRuntimeAssetImages:()=>f,resolveRuntimeImages:()=>u,restoreRuntimeImageFiles:()=>d});function n(e){const t=(new r).prepare(e);return Object.assign(e,t.document,{assets:t.assets}),t.files}function u(e,a,s){o(e,a,e=>{const a=s(e);return t(a)?a.data:a})}function d(e,t,s){u(e,t,e=>{const t=s[e];if(!t)throw Error(`Missing texture resource: ${e}`);return a(t.data.buffer.slice(t.data.byteOffset,t.data.byteOffset+t.data.byteLength),t.mimeType)})}function f(e,a,r){var o,i,n,u;const d=new Set(a),f=e=>Array.isArray(e)?e.map(f):"string"==typeof e?d.has(e)?r(e):e:t(e)&&"string"==typeof e.data&&d.has(e.data)?s(s({},e),{},{data:r(e.data)}):e,l=e=>{var t,a,s;for(const r of null!==(t=null==e?void 0:e.images)&&void 0!==t?t:[])r.url=f(r.url);for(const r of null!==(a=null==e?void 0:e.textures)&&void 0!==a?a:[])void 0!==(null===(s=r.userData)||void 0===s?void 0:s._videoSrc)&&(r.userData._videoSrc=f(r.userData._videoSrc))};l(e.scene);for(const t of null!==(o=e.scenes)&&void 0!==o?o:[])l(t.scene);for(const t of null!==(i=e.materialLibrary)&&void 0!==i?i:[])l(t.material);for(const t of null!==(n=e.prefabLibrary)&&void 0!==n?n:[])l(t.snapshot);(null===(u=e.d)||void 0===u?void 0:u.chartBg)&&l({images:e.d.chartBg.images,textures:[e.d.chartBg]})}export{i as a,d as i,f as n,u as r,n as t};
@@ -0,0 +1 @@
1
+ import{Nt as e}from"./dist-6e_r_Ils.js";var s=/* @__PURE__ */e({SCENE_DOCUMENT_FORMAT:()=>n,SCENE_DOCUMENT_SCHEMA_VERSION:()=>6,SCENE_MANIFEST_FORMAT:()=>o,SCENE_MANIFEST_SCHEMA_VERSION:()=>5,assertSupportedSceneDocument:()=>c,isSceneDocument:()=>i,isSceneManifest:()=>a}),n="vis-scene",r=6,o="vis-scene-manifest",t=5;function i(e){if(!e||"object"!=typeof e)return!1;const s=e;return"vis-scene"===s.format&&Number.isInteger(s.schemaVersion)&&s.schemaVersion>=1}function a(e){return!(!e||"object"!=typeof e)&&e.format===o}function c(e){if(i(e)&&6!==e.schemaVersion)throw new Error(`Unsupported scene schema version: ${e.schemaVersion}. Import older documents in editor-platform. Required version: 6`)}export{c as a,s as c,t as i,r as n,i as o,o as r,a as s,n as t};
@@ -0,0 +1 @@
1
+ function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(e){var r=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,r||"default");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==t(r)?r:r+""}function r(t,r,n){return(r=e(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(Object(i),!0).forEach(function(e){r(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function o(t,e,r,n,i,o,s){try{var h=t[o](s),u=h.value}catch(t){return void r(t)}h.done?e(u):Promise.resolve(u).then(n,i)}function s(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function h(t){o(s,n,i,h,u,"next",t)}function u(t){o(s,n,i,h,u,"throw",t)}h(void 0)})}}function h(t,e=""){if(!t||/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(t)||!e)return t;const r=e.replace(/\/+$/,"");return r&&(t===r||t.startsWith(`${r}/`))?t:`${r}/${t.replace(/^\/+/,"").replace(/^(?:\.\/)+/,"")}`}function u(t,e,r=""){const n=(i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name&&"BYTES_PER_ELEMENT"in i&&1===i.BYTES_PER_ELEMENT;var i;const o=null==t?void 0:t.length,s=void 0!==e;if(!n||s&&o!==e){const i=(r&&`"${r}" `)+"expected Uint8Array"+(s?` of length ${e}`:"")+", got "+(n?`length=${o}`:"type="+typeof t);if(!n)throw new TypeError(i);throw new RangeError(i)}return t}function c(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function f(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function a(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function l(t,e){return t<<32-e|t>>>e}var p=/* @__PURE__ */(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),d=/* @__PURE__ */Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function b(t){if(u(t),p)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=d[t[r]];return e}var y;y=s(function*(){});function g(t,e={}){const r=(e,r)=>t(r).update(e).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=e=>t(e),Object.assign(r,e),Object.freeze(r)}var v=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function w(t,e,r){return t&e^~t&r}function m(t,e,r){return t&e^t&r^e&r}var E=class{constructor(t,e,n,i){r(this,"blockLen",void 0),r(this,"outputLen",void 0),r(this,"canXOF",!1),r(this,"padOffset",void 0),r(this,"isLE",void 0),r(this,"buffer",void 0),r(this,"view",void 0),r(this,"finished",!1),r(this,"length",0),r(this,"pos",0),r(this,"destroyed",!1),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=a(this.buffer)}update(t){c(this),u(t);const{view:e,buffer:r,blockLen:n}=this,i=t.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const e=a(t);for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){c(this),function(t,e){u(t,void 0,"digestInto() output");const r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,f(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let u=o;u<n;u++)e[u]=0;r.setBigUint64(n-8,BigInt(8*this.length),i),this.process(r,0);const s=a(t),h=this.outputLen;if(h%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const l=h/4,p=this.get();if(l>p.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)s.setUint32(4*u,p[u],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=n,t.pos=s,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}},O=/* @__PURE__ */Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),L=/* @__PURE__ */Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),A=/* @__PURE__ */new Uint32Array(64),j=class extends E{constructor(t){super(64,t,8,!1)}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:h}=this;return[t,e,r,n,i,o,s,h]}set(t,e,r,n,i,o,s,h){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|h}process(t,e){for(let f=0;f<16;f++,e+=4)A[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){const t=A[f-15],e=A[f-2],r=l(t,7)^l(t,18)^t>>>3;A[f]=(l(e,17)^l(e,19)^e>>>10)+A[f-7]+r+A[f-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:h,G:u,H:c}=this;for(let f=0;f<64;f++){const t=c+(l(s,6)^l(s,11)^l(s,25))+w(s,h,u)+L[f]+A[f]|0,e=(l(r,2)^l(r,13)^l(r,22))+m(r,n,i)|0;c=u,u=h,h=s,s=o+t|0,o=i,i=n,n=r,r=t+e|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,h=h+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,h,u,c)}roundClean(){f(A)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),f(this.buffer)}},P=class extends j{constructor(){super(32),r(this,"A",0|O[0]),r(this,"B",0|O[1]),r(this,"C",0|O[2]),r(this,"D",0|O[3]),r(this,"E",0|O[4]),r(this,"F",0|O[5]),r(this,"G",0|O[6]),r(this,"H",0|O[7])}},S=/* @__PURE__ */g(()=>new P,/* @__PURE__ */v(1));export{i as a,s as i,b as n,r as o,h as r,S as t};
@@ -0,0 +1 @@
1
+ import{E as e,F as t,Nt as r,w as i}from"./dist-6e_r_Ils.js";import{a}from"./sha2-BCqd-su1.js";import{a as o,i as n,n as s,o as d,s as l}from"./schema-Brre1WzE.js";import{a as u,f as c,x as f}from"./e-BTBbEYEO.js";var v=["scenes","materialLibrary","prefabLibrary"],m=()=>{throw Error("Legacy resource pools must be imported in editor-platform before runtime loading")};function p(e){var t,r;const i=e.scene;void 0!==(null==i?void 0:i._texDataPool)&&m();const a=e=>{Array.isArray(e)?e.forEach(a):e&&"object"==typeof e&&("_documentResource"in e||"base64"===e.encoding)&&m()};for(const d of null!==(t=null==i?void 0:i.images)&&void 0!==t?t:[])a(d.url);for(const d of null!==(r=null==i?void 0:i.textures)&&void 0!==r?r:[]){var o,n,s;void 0===(null===(o=d.userData)||void 0===o?void 0:o._dataTexBase64)&&"number"!=typeof(null===(n=d.userData)||void 0===n?void 0:n._videoSrc)||m(),a(null===(s=d.userData)||void 0===s?void 0:s._videoSrc)}}function y(e){void 0===e._resourcePool&&void 0===e.imageAssets||m();for(const t of Array.isArray(e.scenes)?e.scenes:[])p(t);for(const t of Array.isArray(e.materialLibrary)?e.materialLibrary:[])p({scene:t.material});for(const t of Array.isArray(e.prefabLibrary)?e.prefabLibrary:[])p({scene:t.snapshot})}function w(e){return o(e),y(e),e}function b(e){w(e);const{scenes:t,materialLibrary:r,prefabLibrary:i}=e,a=f(e,v),o=structuredClone(a);return o.scenes=t.map(e=>structuredClone(e)),r&&(o.materialLibrary=r.map(e=>structuredClone(e))),i&&(o.prefabLibrary=i.map(e=>structuredClone(e))),o}function h(e,t,r){const i=JSON.stringify([e,t,r]),a=[2166136261,2654435769,2246822507,3266489909].map(e=>{let t=e;for(let r=0;r<i.length;r++)t=Math.imul(t^i.charCodeAt(r),16777619);return t^=t>>>16,t=Math.imul(t,2246822507),(t^t>>>13)>>>0}).map(e=>e.toString(16).padStart(8,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-8${a.slice(13,16)}-${(3&parseInt(a[16],16)|8).toString(16)}${a.slice(17,20)}-${a.slice(20)}`}var g="_resourceSource",I="_materialAssetId",E="_materialAssetRevision",$="_materialRuntimeProperties",j=e=>structuredClone(e),D=e=>!!e&&"object"==typeof e&&!Array.isArray(e),A=e=>"map"===e||"matcap"===e||e.endsWith("Map");function O(e,t){var r;if(D(e)){t(e);for(const i of null!==(r=e.children)&&void 0!==r?r:[])O(i,t)}}function k(e,t){if("string"==typeof e)return t(e);if(Array.isArray(e))return e.map(e=>k(e,t));if(D(e))for(const r of Object.keys(e))e[r]=k(e[r],t);return e}function M(e,t){var r;const a=/* @__PURE__ */new Set;i(e,(e,t)=>{"PMREM_PLACEHOLDER"!==e[t]&&a.add(e[t])});for(const[i,d]of Object.entries(e))A(i)&&"string"==typeof d&&"PMREM_PLACEHOLDER"!==d&&a.add(d);const o=/* @__PURE__ */new Set,n=e=>{if("string"!=typeof e){if(e&&"object"==typeof e&&!o.has(e)){o.add(e);for(const t of Object.values(e))n(t)}}else t.has(e)&&a.add(e)};n(e.uniforms);for(const i of Object.values(null!==(r=e.uniforms)&&void 0!==r?r:{})){var s;if("t"===(null==i?void 0:i.type)&&"string"==typeof i.value&&"PMREM_PLACEHOLDER"!==i.value&&a.add(i.value),"tv"===(null==i?void 0:i.type))for(const e of null!==(s=i.value)&&void 0!==s?s:[])"string"==typeof e&&"PMREM_PLACEHOLDER"!==e&&a.add(e)}return a}function S(e,t){i(e,(e,r)=>{var i;e[r]=null!==(i=t.get(e[r]))&&void 0!==i?i:e[r]});for(const i of Object.keys(e)){var r;A(i)&&"string"==typeof e[i]&&(e[i]=null!==(r=t.get(e[i]))&&void 0!==r?r:e[i])}e.uniforms&&(e.uniforms=k(e.uniforms,e=>{var r;return null!==(r=t.get(e))&&void 0!==r?r:e}))}function _(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}~${i++}`;return t.add(r),r}function L(e){const t=j(e);return t.userData&&(delete t.userData[I],delete t.userData[E],delete t.userData._materialAssetOverrideHash,delete t.userData._materialDynamic,delete t.userData[$],Object.keys(t.userData).length||delete t.userData),t}function x(e,t,r={}){var i,o,n,s,d,l;const u=new Set(null!==(i=r.editedProperties)&&void 0!==i?i:[]),c=null===(o=t.userData)||void 0===o?void 0:o[$],f=Array.isArray(c)?c.filter(e=>"string"==typeof e&&A(e)&&!u.has(e)):[],v=L(t);if(!f.length)return v;const m=L(e),p=null!==(n=v.textures)&&void 0!==n?n:[],y=null!==(s=v.images)&&void 0!==s?s:[],w=new Set(p.map(e=>e.uuid)),b=new Set(y.map(e=>e.uuid)),h=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(const $ of null!==(d=m.images)&&void 0!==d?d:[]){const e=y.find(e=>e.uuid===$.uuid),t=e&&JSON.stringify(e)!==JSON.stringify($)?_(`${$.uuid}:authored`,b):$.uuid;h.set($.uuid,t),b.add(t),y.some(e=>e.uuid===t)||y.push(a(a({},$),{},{uuid:t}))}for(const $ of null!==(l=m.textures)&&void 0!==l?l:[]){void 0!==$.image&&($.image=k($.image,e=>{var t;return null!==(t=h.get(e))&&void 0!==t?t:e}));const e=p.find(e=>e.uuid===$.uuid),t=e&&JSON.stringify(e)!==JSON.stringify($)?_(`${$.uuid}:authored`,w):$.uuid;g.set($.uuid,t),w.add(t),p.some(e=>e.uuid===t)||p.push(a(a({},$),{},{uuid:t}))}S(m,g);for(const a of f){var I,E;const e=v[a];if(!Object.hasOwn(m,a)){delete v[a];continue}v[a]=m[a];const t=p.find(e=>e.uuid===m[a]),r=p.find(t=>t.uuid===e);if(!t||!r)continue;const i=j(r);i.uuid=t.uuid,void 0===t.image?delete i.image:i.image=j(t.image);const o=null!==(I=i.userData)&&void 0!==I?I:i.userData={};for(const a of Object.keys(o))("_videoSrc"===a||a.startsWith("_dataTex"))&&delete o[a];for(const[a,n]of Object.entries(null!==(E=t.userData)&&void 0!==E?E:{}))("_videoSrc"===a||a.startsWith("_dataTex"))&&(o[a]=j(n));Object.keys(o).length||delete i.userData,JSON.stringify(i)!==JSON.stringify(t)&&(i.uuid=_(`${t.uuid}:sampler`,w),p.push(i),v[a]=i.uuid)}return U({id:"authored-material",name:"",vis:{type:"base",options:{}},scene:{materials:[v],textures:p,images:y}},v.uuid)}function P(e){const t=e.scene,r=r=>{var i;const a=/* @__PURE__ */new Map;for(const o of null!==(i=t[r])&&void 0!==i?i:[]){if("string"!=typeof(null==o?void 0:o.uuid)||!o.uuid||a.has(o.uuid))throw new Error(`Invalid ${r} identity in scene ${e.id}`);a.set(o.uuid,o)}return a},i=r("materials"),a=r("textures");return{scene:e,materials:i,textures:a,images:r("images"),textureIds:new Set(a.keys())}}function C(e,t){const{scene:r,materials:i,textures:a,images:o,textureIds:n}=e;r.scene;const s=i.get(t);if(!s)throw new Error(`Missing material ${t} in scene ${r.id}`);const d=L(s);delete d.textures,delete d.images;const l=M(d,n),u=[],c=/* @__PURE__ */new Set;for(const v of l){const e=a.get(v);if(!e)throw new Error(`Missing texture ${v} for material ${t} in scene ${r.id}`);const i=j(e);u.push(i);for(const t of[i.image].flat()){var f;if("string"==typeof t)if(o.has(t))c.add(t);else if(!(null===(f=i.userData)||void 0===f?void 0:f._videoSrc))throw new Error(`Missing image ${t} for texture ${v} in scene ${r.id}`)}}return u.length&&(d.textures=u),c.size&&(d.images=[...c].map(e=>j(o.get(e)))),d}function U(e,t){return K(e)(t)}function K(e){const t=P(e);return e=>C(t,e)}function R(e,t=h(e.id,"material",e.material.uuid)){var r,i;const o=L(e.material),n=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(const a of null!==(r=o.images)&&void 0!==r?r:[]){const t=a.uuid;a.uuid=h(e.id,"image",t),n.set(t,a.uuid)}for(const d of null!==(i=o.textures)&&void 0!==i?i:[]){const t=d.uuid;d.uuid=h(e.id,"texture",t),s.set(t,d.uuid),d.userData=a(a({},d.userData),{},{[g]:{assetId:e.id,textureUuid:t,imageUuids:[d.image].flat().filter(e=>"string"==typeof e)}}),void 0!==d.image&&(d.image=k(d.image,e=>{var t;return null!==(t=n.get(e))&&void 0!==t?t:e}))}return S(o,s),o.uuid=t,o.name=e.name,o.userData=a(a({},o.userData),{},{[I]:e.id,[E]:e.revision,[g]:{assetId:e.id,materialUuid:e.material.uuid}}),o}function T(e,t){return N(e,t).filter(e=>!e.optionPath)}function N(t,r){const i=[];for(const n of t.scenes){var a,o;const t=new Map((null!==(a=n.scene.materials)&&void 0!==a?a:[]).filter(e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t[I]}).map(e=>[e.uuid,e.userData[I]]));O(n.scene.object,a=>{const o=new Set([a.material].flat());[a.material].flat().forEach((e,o)=>{const s=t.get(e);!s||void 0!==r&&s!==r||i.push({assetId:s,sceneId:n.id,objectId:a.uuid||"",slot:o})}),e(a.userData,(e,s,d)=>{const l=e[s],u=t.get(l);!u||o.has(l)||void 0!==r&&u!==r||(o.add(l),i.push({assetId:u,sceneId:n.id,objectId:a.uuid||"",slot:0,optionPath:d}))},n.scene._sharedOptionsPool)});for(const[e,a]of Object.entries(null!==(o=n.materialAliases)&&void 0!==o?o:{}))void 0!==r&&r!==a.assetId||i.push({assetId:a.assetId,sceneId:n.id,objectId:"",slot:0,alias:e})}return i}function J(e,t){var r;return(null!==(r=e.prefabLibrary)&&void 0!==r?r:[]).filter(e=>{var r;return null===(r=e.snapshot.materials)||void 0===r?void 0:r.some(e=>{var r;return(null===(r=e.userData)||void 0===r?void 0:r[I])===t})})}function z(e,t=[],r=[]){return V(e,t,r).map(e=>j(e))}function V(e,t=[],r=[]){var i,a,o;const n=new Set((null!==(i=e.scene.materials)&&void 0!==i?i:[]).map(e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t[I]}).filter(Boolean));for(const d of r)for(const e of null!==(a=d.snapshot.materials)&&void 0!==a?a:[]){var s;const t=null===(s=e.userData)||void 0===s?void 0:s[I];t&&n.add(t)}for(const d of Object.values(null!==(o=e.materialAliases)&&void 0!==o?o:{}))n.add(d.assetId);return t.filter(t=>n.has(t.id)||"scene"===t.scope.kind&&t.scope.sceneId===e.id)}function H(e){if(void 0!==e&&!Array.isArray(e))throw new Error("Invalid project material library");const t=/* @__PURE__ */new Map;for(const l of null!=e?e:[]){var r,i,a,o,n;if(!D(l)||"string"!=typeof l.id||!l.id||t.has(l.id)||!Number.isInteger(l.revision)||l.revision<1||"string"!=typeof l.name||!D(l.material)||"string"!=typeof l.material.type||!l.material.type||"string"!=typeof l.material.uuid||!l.material.uuid||void 0!==l.locked&&"boolean"!=typeof l.locked||void 0!==l.alwaysExport&&"boolean"!=typeof l.alwaysExport||!D(l.scope)||!["project","scene"].includes(l.scope.kind)||"scene"===l.scope.kind&&("string"!=typeof l.scope.sceneId||!l.scope.sceneId))throw new Error(`Invalid or duplicate material asset ${null!==(n=null==l?void 0:l.id)&&void 0!==n?n:""}`);if(void 0!==(null===(r=l.material.userData)||void 0===r?void 0:r._materialAssetId)||void 0!==(null===(i=l.material.userData)||void 0===i?void 0:i._materialAssetRevision))throw new Error(`Material asset ${l.id} must not contain its own binding`);for(const t of["textures","images"]){var s;if(void 0!==l.material[t]&&!Array.isArray(l.material[t]))throw new Error(`Invalid ${t} in material asset ${l.id}`);const e=/* @__PURE__ */new Set;for(const r of null!==(s=l.material[t])&&void 0!==s?s:[]){if(!D(r)||"string"!=typeof r.uuid||!r.uuid||e.has(r.uuid))throw new Error(`Invalid ${t} identity in material asset ${l.id}`);e.add(r.uuid)}}p({scene:l.material});const e=new Map((null!==(a=l.material.textures)&&void 0!==a?a:[]).map(e=>[e.uuid,e])),u=new Set((null!==(o=l.material.images)&&void 0!==o?o:[]).map(e=>e.uuid));for(const t of M(l.material,new Set(e.keys()))){const r=e.get(t);if(!r)throw new Error(`Missing texture ${t} for material ${l.material.uuid} in scene ${l.id}`);for(const e of[r.image].flat()){var d;if("string"==typeof e&&!u.has(e)&&!(null===(d=r.userData)||void 0===d?void 0:d._videoSrc))throw new Error(`Missing image ${e} for texture ${t} in scene ${l.id}`)}}t.set(l.id,l)}return t}function q(e){G(e,H(e.materialLibrary))}function G(e,t){var r;if(void 0!==e.materialLibrary&&e.schemaVersion<4)throw new Error("Project material library requires schema 4");const i=new Set(e.scenes.map(e=>null==e?void 0:e.id));for(const f of t.values())if("scene"===f.scope.kind&&!i.has(f.scope.sceneId))throw new Error(`Material asset ${f.id} belongs to missing scene ${f.scope.sceneId}`);if(void 0!==e.prefabLibrary&&!Array.isArray(e.prefabLibrary))throw new Error("Invalid prefab library");for(const f of null!==(r=e.prefabLibrary)&&void 0!==r?r:[]){var a;if(!D(f)||!D(f.snapshot)||void 0!==f.snapshot.materials&&!Array.isArray(f.snapshot.materials))throw new Error("Invalid prefab material definitions");for(const e of null!==(a=f.snapshot.materials)&&void 0!==a?a:[]){var o,n;if(!D(e))throw new Error("Invalid prefab material definition");const r=null===(o=e.userData)||void 0===o?void 0:o[I];if(void 0===r)continue;const i=t.get(r);if(!i)throw new Error(`Missing material asset ${r} in prefab ${f.name}`);if("project"!==i.scope.kind)throw new Error(`Prefab ${f.name} requires project material ${r}`);const a=null===(n=e.userData)||void 0===n?void 0:n[E];if(void 0!==a&&(!Number.isInteger(a)||a<1||a>i.revision))throw new Error(`Invalid material asset revision in prefab ${f.name}`)}}for(const f of e.scenes){var s,d,l;if(!f)throw new Error("Invalid material scene");if(void 0!==f.materialAliases&&!D(f.materialAliases))throw new Error(`Invalid material catalog in scene ${f.id}`);for(const[e,r]of Object.entries(null!==(s=f.materialAliases)&&void 0!==s?s:{})){if(!e||!D(r)||!t.has(r.assetId)||void 0!==r.locked&&"boolean"!=typeof r.locked)throw new Error(`Invalid material catalog entry ${e} in scene ${f.id}`);F(t.get(r.assetId),f.id)}for(const e of null!==(d=null===(l=f.scene)||void 0===l?void 0:l.materials)&&void 0!==d?d:[]){var u,c;const r=null===(u=e.userData)||void 0===u?void 0:u[I];if(void 0===r)continue;const i=t.get(r);if(!i)throw new Error(`Missing material asset ${r} in scene ${f.id}`);F(i,f.id);const a=null===(c=e.userData)||void 0===c?void 0:c[E];if(void 0!==a&&(!Number.isInteger(a)||a<1||a>i.revision))throw new Error(`Invalid material asset revision in scene ${f.id}`)}}}function F(e,t){if("scene"===e.scope.kind&&e.scope.sceneId!==t)throw new Error(`Material asset ${e.id} belongs to scene ${e.scope.sceneId}, not ${t}`)}function W(e){const t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,a=e=>{var a;const o=null===(a=e.userData)||void 0===a?void 0:a[I];t.has(e.uuid)||t.set(e.uuid,e),r.has(o)||r.set(o,e);let n=i.get(e.uuid);n||i.set(e.uuid,n=/* @__PURE__ */new Map),n.has(o)||n.set(o,e)};for(const o of e)a(o);return{byUuid:t,add:a,bound:(e,t)=>{var r;return null===(r=i.get(e))||void 0===r?void 0:r.get(t)},resolve:(e,t)=>{var a,o;return null!==(a=null===(o=i.get(e))||void 0===o?void 0:o.get(t))&&void 0!==a?a:r.get(t)}}}function B(e){const t=/* @__PURE__ */new Map;return e.forEach((e,r)=>{t.has(e.uuid)||t.set(e.uuid,r)}),t}function Q(e,r){var i,a,o;const n=e.scene,s=null!==(i=n.materials)&&void 0!==i?i:[];let d=W(s);for(const[t,y]of Object.entries(null!==(a=e.materialAliases)&&void 0!==a?a:{})){var l,u,c,f,v;const i=r.get(y.assetId);if(!i)throw new Error(`Missing material asset ${y.assetId} in scene ${e.id}`);let a=d.resolve(t,y.assetId);a||(a={uuid:t,type:i.material.type,userData:{[I]:i.id,[E]:i.revision}},s.push(a),d.add(a),n.materials=s);const o=null!==(l=n.materialAliases)&&void 0!==l?l:n.materialAliases={};if(o[t]&&o[t].materialUuid!==a.uuid)throw new Error(`Conflicting material catalog ${t}`);o[t]={materialUuid:a.uuid,locked:!(!(null===(u=o[t])||void 0===u?void 0:u.locked)&&!y.locked),roles:[.../* @__PURE__ */new Set([...null!==(c=null===(f=o[t])||void 0===f?void 0:f.roles)&&void 0!==c?c:[],...null!==(v=y.roles)&&void 0!==v?v:[]])]}}t(n,e.vis.options),d=W(s);const m={};for(const[t,y]of Object.entries(null!==(o=n.materialAliases)&&void 0!==o?o:{})){var p;const e=d.byUuid.get(y.materialUuid),r=null==e||null===(p=e.userData)||void 0===p?void 0:p[I];r&&(m[t]={assetId:r,locked:!!y.locked})}Object.keys(m).length?e.materialAliases=m:delete e.materialAliases}function X(e){return o(e),Y(b(e))}function Y(e){var t;const r=w(e),i=H(r.materialLibrary),o=new Set(i.keys()),n=null!==(t=r.materialLibrary)&&void 0!==t?t:[];for(const f of r.scenes){var s,d,l;let e;Q(f,i);const t=/* @__PURE__ */new Map;for(const d of null!==(s=f.scene.materials)&&void 0!==s?s:[]){var u;if(t.has(d.uuid))throw new Error(`Duplicate material ${d.uuid} in scene ${f.id}`);t.set(d.uuid,d);let r=null===(u=d.userData)||void 0===u?void 0:u[I];if(void 0===r){var c;r=h(f.id,"material-asset",d.uuid);let t=0;for(;o.has(r);)r=h(f.id,"material-asset",`${d.uuid}:${++t}`);o.add(r);const s={id:r,revision:1,name:d.name||d.uuid,scope:{kind:"scene",sceneId:f.id},material:C(null!==(c=e)&&void 0!==c?c:e=P(f),d.uuid)};n.push(s),i.set(r,s),d.userData=a(a({},d.userData),{},{[I]:r,[E]:1})}if(!i.has(r))throw new Error(`Missing material asset ${r} in scene ${f.id}`);F(i.get(r),f.id)}const r={},v=(e,a,o)=>{var n,s,d;const l=i.get(a.assetId);if(!l)throw new Error(`Missing material asset ${a.assetId} in scene ${f.id}`);const u=t.get(null!=o?o:e),c=(null==u||null===(n=u.userData)||void 0===n?void 0:n._materialAssetId)===a.assetId?u.uuid:null!==(s=null===(d=[...t.values()].find(e=>{var t;return(null===(t=e.userData)||void 0===t?void 0:t._materialAssetId)===a.assetId}))||void 0===d?void 0:d.uuid)&&void 0!==s?s:h(l.id,"material",l.material.uuid),v=r[c];if(v&&v.assetId!==a.assetId)throw new Error(`Conflicting material UUID ${c} in scene ${f.id}`);r[c]={assetId:a.assetId,locked:!(!(null==v?void 0:v.locked)&&!a.locked)},a.locked&&(l.locked=!0)};for(const[i,a]of Object.entries(null!==(d=f.materialAliases)&&void 0!==d?d:{}))v(i,a);for(const[i,a]of Object.entries(null!==(l=f.scene.materialAliases)&&void 0!==l?l:{})){const e=t.get(null==a?void 0:a.materialUuid);if(!i||!e||void 0!==a.locked&&"boolean"!=typeof a.locked)throw new Error(`Invalid runtime material alias ${i} in scene ${f.id}`);v(i,{assetId:e.userData[I],locked:!!a.locked},e.uuid)}Object.keys(r).length?f.materialAliases=r:delete f.materialAliases,delete f.scene.materialAliases}return r.schemaVersion=Math.max(r.schemaVersion,4),r.materialLibrary=n,q(r),r}function Z(e,t=[]){return ae(e,H(t))}function ee(e,t=[]){return oe(e,H(t))}function te(e,t=[]){const r=H(t);return e.map(e=>ae(e,r))}function re(e,t){if(Object.is(e,t))return!0;if(!e||!t||"object"!=typeof e||"object"!=typeof t||Array.isArray(e)!==Array.isArray(t))return!1;const r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&re(e[r],t[r]))}function ie(e,t,r,i){const o=H(t),n=H(r);if(o.size!==n.size)throw new Error("Material definition patches cannot add or remove assets");const s=function(e,t){if(void 0===e)return;const r=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e&&!!e)&&new Set(e).size===e.length;if(!e||!r(e.assetIds)||!r(e.properties))throw new Error("Invalid material definition scope");const i=new Set(e.assetIds);if(i.size!==t.length||t.some(e=>!i.has(e)))throw new Error("Material definition scope must match the patched assets");return new Set(e.properties)}(i,[...n.keys()]),d=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set(["uuid","type","metadata","textures","images","nodes","inputNodes","uniforms","userData","name"]),u=e=>null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e&&Number.isFinite(e);for(const[a,c]of n){const e=o.get(a);if(!e||!re(e.scope,c.scope)||e.locked!==c.locked)throw new Error("Material definition patches cannot change asset identity, scope or lock");if(e.name!==c.name&&s&&!s.has("name"))throw new Error("Material definition patch exceeds declared properties: name");const t=[];for(const r of/* @__PURE__ */new Set([...Object.keys(e.material),...Object.keys(c.material)]))if(!re(e.material[r],c.material[r])||Object.hasOwn(e.material,r)!==Object.hasOwn(c.material,r)){if(l.has(r)||A(r)||!u(e.material[r])||!u(c.material[r]))throw new Error(`Material definition patch requires full materialization: ${r}`);if(s&&!s.has(r))throw new Error(`Material definition patch exceeds declared properties: ${r}`);t.push(r)}d.set(a,{asset:c,properties:t})}return e.map(e=>{var t;let r=!1;const i=(null!==(t=e.scene.materials)&&void 0!==t?t:[]).map(t=>{var i;const o=d.get(null===(i=t.userData)||void 0===i?void 0:i[I]);if(!o)return t;if(F(o.asset,e.id),"string"!=typeof t.uuid||!t.uuid||t.type!==o.asset.material.type)throw new Error("Material definition patches require normalized scene bindings");r=!0;const n=a(a({},t),{},{name:o.asset.name,userData:a(a({},t.userData),{},{[E]:o.asset.revision})});for(const e of o.properties)Object.hasOwn(o.asset.material,e)?n[e]=o.asset.material[e]:delete n[e];return n});return r?a(a({},e),{},{scene:a(a({},e.scene),{},{materials:i})}):e})}function ae(e,t){return oe(j(e),t)}function oe(e,t){var r,i,o,n,s,d,l;const u=e;Q(e,t);const c=e.scene;delete c.materialAliases;const f=null!==(r=c.materials)&&void 0!==r?r:[],v=W(f),m={};for(const[a,I]of Object.entries(null!==(i=e.materialAliases)&&void 0!==i?i:{})){var p;const e=t.get(I.assetId);if(!e)throw new Error(`Missing material asset ${I.assetId} in scene ${u.id}`);const r=v.resolve(a,I.assetId),i=null!==(p=null==r?void 0:r.uuid)&&void 0!==p?p:h(e.id,"material",e.material.uuid),o=m[i];m[i]={assetId:I.assetId,locked:!(!(null==o?void 0:o.locked)&&!I.locked)}}Object.keys(m).length?e.materialAliases=m:delete e.materialAliases;for(const[a,h]of Object.entries(null!==(o=e.materialAliases)&&void 0!==o?o:{})){if(v.bound(a,h.assetId))continue;const e=t.get(h.assetId);if(!e)throw new Error(`Missing material asset ${h.assetId} in scene ${u.id}`);const r={uuid:a,type:e.material.type,userData:{[I]:e.id,[E]:e.revision}};f.push(r),v.add(r)}f.length&&(c.materials=f);const y=null!==(n=c.textures)&&void 0!==n?n:[],w=null!==(s=c.images)&&void 0!==s?s:[],b=B(y),g=B(w),$=new Set(y.map(e=>e.uuid)),D=/* @__PURE__ */new Map,A=/* @__PURE__ */new Set;for(const a of null!==(d=c.materials)&&void 0!==d?d:[]){var k,S,_;const e=null===(k=a.userData)||void 0===k?void 0:k[I];if(void 0===e)continue;const r=t.get(e);if(!r)throw new Error(`Missing material asset ${e} in scene ${u.id}`);F(r,u.id);for(const t of M(a,$))A.add(t);if(D.has(e))continue;const i=R(r);for(const t of null!==(S=i.images)&&void 0!==S?S:[]){const e=g.get(t.uuid);void 0!==e?w[e]=t:(g.set(t.uuid,w.length),w.push(t))}for(const t of null!==(_=i.textures)&&void 0!==_?_:[]){const e=b.get(t.uuid);$.add(t.uuid),void 0!==e?y[e]=t:(b.set(t.uuid,y.length),y.push(t))}delete i.textures,delete i.images,delete i.metadata,D.set(e,i)}c.materials&&(c.materials=c.materials.map(e=>{var t;const r=D.get(null===(t=e.userData)||void 0===t?void 0:t[I]);return r?a(a({},j(r)),{},{uuid:e.uuid}):e}));const L=/* @__PURE__ */new Set;for(const a of null!==(l=c.materials)&&void 0!==l?l:[])for(const e of M(a,$))L.add(e);O(c.object,e=>{for(const t of["background","environment"])"string"==typeof e[t]&&L.add(e[t])});const x=/* @__PURE__ */new Set,P=y.filter(e=>{if(!A.has(e.uuid)||L.has(e.uuid))return!0;for(const t of[e.image].flat())"string"==typeof t&&x.add(t);return!1}),C=new Set(P.flatMap(e=>[e.image].flat()));return(c.textures||P.length)&&(c.textures=P),(c.images||w.length)&&(c.images=w.filter(e=>!x.has(e.uuid)||C.has(e.uuid))),e}function ne(e){const t=b(e),r=H(t.materialLibrary);return G(t,r),t.scenes=t.scenes.map(e=>ae(e,r)),t}function se(e){const t=w(e),r=H(t.materialLibrary);return G(t,r),t.scenes=t.scenes.map(e=>oe(e,r)),t}function de(e,r={}){var i,o,n;const s=r.consumeInput?e.scene:j(e.scene);if(r.omitPrefabPreviews){const e=t=>{var r,i,a,o,n;return!t||!((null===(r=t.userData)||void 0===r?void 0:r._prefabPreview)||(null===(i=t.userData)||void 0===i||null===(i=i._baseObjectUserData)||void 0===i?void 0:i._prefabPreview)||(null===(a=t.userData)||void 0===a?void 0:a._templatePreviewContainer)||(null===(o=t.userData)||void 0===o||null===(o=o._baseObjectUserData)||void 0===o?void 0:o._templatePreviewContainer)||"@TemplatePreview"===(null===(n=t.userData)||void 0===n?void 0:n._baseObjectKeyType))&&(t.children&&(t.children=t.children.filter(e)),!0)};if(!e(s.object))throw new Error("A scene root cannot be a prefab preview")}const d=new Map((null!==(i=s.materials)&&void 0!==i?i:[]).map(e=>{var t;return[null===(t=e.userData)||void 0===t?void 0:t[I],e.uuid]})),l=new Map((null!==(o=s.materials)&&void 0!==o?o:[]).map(e=>[e.uuid,e])),u=a({},s.materialAliases);for(const[t,a]of Object.entries(null!==(n=e.materialAliases)&&void 0!==n?n:{})){var c,f,v,m,p;const r=(null===(c=l.get(t))||void 0===c||null===(c=c.userData)||void 0===c?void 0:c._materialAssetId)===a.assetId?t:d.get(a.assetId);if(!r)throw new Error(`Missing material for alias ${t} in scene ${e.id}`);if(u[t]&&u[t].materialUuid!==r)throw new Error(`Conflicting material catalog ${t}`);u[t]={materialUuid:r,locked:!(!(null===(f=u[t])||void 0===f?void 0:f.locked)&&!a.locked),roles:[.../* @__PURE__ */new Set([...null!==(v=null===(m=u[t])||void 0===m?void 0:m.roles)&&void 0!==v?v:[],...null!==(p=a.roles)&&void 0!==p?p:[]])]}}return Object.keys(u).length&&(s.materialAliases=u),t(s),s}var le=["scenes","materialLibrary","prefabLibrary"];function ue(e,t=e.entrySceneId,r={}){const i=e.scenes.find(e=>e.id===t);if(!i)throw Error(`Scene ${t} was not found`);if(!r.resolveResources)return i;p(i);const a=structuredClone(i);return e.materialLibrary&&ee(a,e.materialLibrary),a}function ce(e,t){const r=ue(e,t,{resolveResources:!0}),{scenes:i,materialLibrary:o,prefabLibrary:n}=e,s=f(e,le);return a(a(a(a({},structuredClone(s)),n?{prefabLibrary:structuredClone(n)}:{}),o?{materialLibrary:z(r,o,n)}:{}),{},{entrySceneId:r.id,scenes:[a(a({},r),{},{interactions:void 0})]})}var fe=/* @__PURE__ */r({assertRuntimeSceneDocument:()=>we,assertSceneManifest:()=>pe});function ve(e,t){if(void 0===e)return;if(!Array.isArray(e))throw new Error("Invalid prefab library");const r=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const n of e){var a,o;if(!n||"string"!=typeof n.id||!n.id||r.has(n.id)||"string"!=typeof n.name||!Number.isInteger(n.revision)||n.revision<1||!(null===(a=n.snapshot)||void 0===a?void 0:a.object))throw new Error("Invalid prefab definition");if(r.add(n.id),void 0!==n.sdkKey){if("string"!=typeof n.sdkKey||!n.sdkKey.trim()||n.sdkKey!==n.sdkKey.trim()||i.has(n.sdkKey))throw new Error("Invalid or duplicate prefab SDK key");i.add(n.sdkKey)}if(void 0!==n.materialMode&&"embedded"!==n.materialMode)throw new Error("Invalid prefab material mode");if("embedded"===n.materialMode&&(null!==(o=n.snapshot.materials)&&void 0!==o?o:[]).some(e=>{var t;return void 0!==(null==e||null===(t=e.userData)||void 0===t?void 0:t._materialAssetId)}))throw new Error("Embedded prefab materials must not reference the project material library");me(n.snapshot.object),t&&ye(n.snapshot,`prefab ${n.id}`)}for(const n of e)if(void 0!==n.sdkKey&&n.sdkKey!==n.id&&r.has(n.sdkKey))throw new Error("Prefab SDK key conflicts with another asset id")}function me(e){var t;if(e){if(["@Group","@PrefabGroup"].some(t=>{var r,i;return(null===(r=e.userData)||void 0===r?void 0:r._baseObjectKeyType)===t||(null===(i=e.userData)||void 0===i?void 0:i._baseObjectKey)===t}))throw new Error("Legacy object or prefab groups must be imported in editor-platform before runtime loading or export");for(const r of null!==(t=e.children)&&void 0!==t?t:[])me(r)}}function pe(e){if(!l(e))throw new Error("Invalid scene manifest format");if(5!==e.schemaVersion)throw new Error(`Unsupported scene manifest version: ${e.schemaVersion}`);if(!Array.isArray(e.scenes)||0===e.scenes.length)throw new Error("Invalid scene manifest: scenes must not be empty");c(e.runtimeAssets),u(e.assets),y(e),ve(e.prefabLibrary,!0);const t=/* @__PURE__ */new Set;for(const i of e.scenes){var r;if("string"!=typeof(null==i?void 0:i.id)||!i.id||t.has(i.id)||"string"!=typeof i.name||!i.name||"string"!=typeof(null===(r=i.vis)||void 0===r?void 0:r.type)||!i.vis.type||"string"!=typeof i.source||!i.source)throw new Error("Invalid scene manifest entry");t.add(i.id)}if(!t.has(e.entrySceneId))throw new Error(`Invalid scene manifest: entry scene ${e.entrySceneId} was not found`);q({schemaVersion:6,materialLibrary:e.materialLibrary,prefabLibrary:e.prefabLibrary,scenes:e.scenes.map(e=>a(a({},e),{},{scene:{}}))});for(const i of e.scenes)for(const e of i.interactions||[]){const r="switchScene"===e.action.type||"switchMapRegion"===e.action.type?e.action.sceneId:void 0;if(r&&!t.has(r))throw new Error(`Invalid interaction target ${r} in scene ${i.id}`)}}function ye(e,t){const r=e=>{var i;if(!e)return;const a=e.userData;if(void 0!==(null==a?void 0:a._baseObjectKey)||void 0!==(null==a?void 0:a._baseObjectUuid))throw new Error(`Legacy wrapper identity in ${t}; import it in editor-platform before exporting schema 5`);if(void 0!==(null==a?void 0:a._baseObjectObjectType)&&(1!==a._baseObjectIdentityVersion||"string"!=typeof e.uuid||!e.uuid))throw new Error(`Invalid canonical wrapper identity in ${t}`);for(const t of null!==(i=e.children)&&void 0!==i?i:[])r(t)};r(null==e?void 0:e.object)}function we(e){if(!d(e))throw new Error("Unsupported legacy JSON. Import it in editor-platform and export a vis-scene document first.");if(o(e),c(e.runtimeAssets),!Array.isArray(e.scenes)||0===e.scenes.length)throw new Error("Invalid vis-scene document: scenes must not be empty");y(e),q(e),ve(e.prefabLibrary,!0);const t=/* @__PURE__ */new Set;for(const o of e.scenes){var r;if(void 0!==(null==o?void 0:o.eo))throw new Error("Legacy eo must be migrated in editor-platform before runtime loading");if(void 0!==(null==o?void 0:o.set))throw new Error("Legacy set must be migrated to vis.options.controls in editor-platform before runtime loading");if(!(null==o?void 0:o.id)||t.has(o.id))throw new Error("Invalid vis-scene document: duplicate or empty scene id");if(!(null===(r=o.vis)||void 0===r?void 0:r.type)||!o.scene)throw new Error(`Invalid scene ${o.id}: missing vis or scene graph`);const e=t=>{var r,i,a,o,n,s;if(t){if(!0===(null===(r=t.userData)||void 0===r?void 0:r.prefab)||!0===(null===(i=t.userData)||void 0===i||null===(i=i._baseObjectUserData)||void 0===i?void 0:i.prefab))throw new Error("Legacy prefab sources must be imported in editor-platform before runtime loading or export");if(["@Group","@PrefabGroup"].some(e=>{var r,i;return(null===(r=t.userData)||void 0===r?void 0:r._baseObjectKeyType)===e||(null===(i=t.userData)||void 0===i?void 0:i._baseObjectKey)===e}))throw new Error("Legacy object or prefab groups must be imported in editor-platform before runtime loading or export");var d;if((null===(a=t.userData)||void 0===a?void 0:a._templatePreviewContainer)||(null===(o=t.userData)||void 0===o||null===(o=o._baseObjectUserData)||void 0===o?void 0:o._templatePreviewContainer)||"@TemplatePreview"===(null===(n=t.userData)||void 0===n?void 0:n._baseObjectKeyType))for(const e of null!==(d=t.children)&&void 0!==d?d:[]){var l,u,c,f;if(!(null===(l=e.userData)||void 0===l?void 0:l._prefabPreview)&&!(null===(u=e.userData)||void 0===u||null===(u=u._baseObjectUserData)||void 0===u?void 0:u._prefabPreview)&&!(null===(c=e.userData)||void 0===c?void 0:c._templatePreviewContainer)&&"@TemplatePreview"!==(null===(f=e.userData)||void 0===f?void 0:f._baseObjectKeyType))throw new Error("Template preview containers cannot contain ordinary scene instances")}for(const r of null!==(s=t.children)&&void 0!==s?s:[])e(r)}};e(o.scene.object),ye(o.scene,`scene ${o.id}`),t.add(o.id)}if(!t.has(e.entrySceneId))throw new Error(`Invalid vis-scene document: entry scene ${e.entrySceneId} was not found`);for(const o of e.scenes){if(void 0!==o.interactions&&!Array.isArray(o.interactions))throw new Error(`Invalid scene ${o.id}: interactions must be an array`);const r=/* @__PURE__ */new Set;for(const d of o.interactions||[]){var i,a,n,s,l,u,f;const c="back"===(null==d||null===(i=d.action)||void 0===i?void 0:i.type)||"backMapRegion"===(null==d||null===(a=d.action)||void 0===a?void 0:a.type)&&"map"===o.vis.type||"switchScene"===(null==d||null===(n=d.action)||void 0===n?void 0:n.type)&&t.has(d.action.sceneId)||"switchMapRegion"===(null==d||null===(s=d.action)||void 0===s?void 0:s.type)&&"map"===o.vis.type&&t.has(d.action.sceneId)&&"map"===ue(e,d.action.sceneId).vis.type&&("clicked"===d.action.adcode||Number.isInteger(d.action.adcode)&&d.action.adcode>=0);if("click"!==(null==d?void 0:d.trigger)&&"clickOutside"!==(null==d?void 0:d.trigger)||"switchMapRegion"===(null==d||null===(l=d.action)||void 0===l?void 0:l.type)&&"click"!==d.trigger||!d.objectId||"clickOutside"===d.trigger&&void 0!==d.filter||void 0!==d.filter&&("include"!==d.filter.mode&&"exclude"!==d.filter.mode||void 0!==d.filter.objectIds&&(!Array.isArray(d.filter.objectIds)||d.filter.objectIds.some(e=>"string"!=typeof e||!e))||void 0!==d.filter.baseObjectTypes&&(!Array.isArray(d.filter.baseObjectTypes)||d.filter.baseObjectTypes.some(e=>"string"!=typeof e||!e))||!(null===(u=d.filter.objectIds)||void 0===u?void 0:u.length)&&!(null===(f=d.filter.baseObjectTypes)||void 0===f?void 0:f.length))||!c||r.has(`${d.trigger}:${d.objectId}`))throw new Error(`Invalid interaction in scene ${o.id}`);r.add(`${d.trigger}:${d.objectId}`)}}}export{L as A,E as C,U as D,K as E,y as F,p as I,b as L,O as M,g as N,R as O,h as P,w as R,I as S,j as T,N as _,ce as a,V as b,ee as c,Z as d,te as f,q as g,F as h,ue as i,_ as j,x as k,ne as l,X as m,pe as n,de as o,Y as p,fe as r,se as s,we as t,ie as u,T as v,$ as w,z as x,J as y};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vis-core",
3
- "version": "0.33.17",
3
+ "version": "0.33.19",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "prettier": "fe-stack/prettier.json",
@@ -36,6 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@noble/curves": "^2.0.1",
39
+ "@noble/hashes": "^2.2.0",
39
40
  "@turf/turf": "^6.5.0",
40
41
  "@types/d3-geo": "^3.0.2",
41
42
  "@types/events": "^3.0.0",
@@ -49,7 +50,7 @@
49
50
  "devDependencies": {
50
51
  "@types/node": "^25.0.6",
51
52
  "fe-stack": "0.2.0",
52
- "gl-draw": "0.19.15",
53
+ "gl-draw": "0.19.17",
53
54
  "terser": "^5.46.1",
54
55
  "three": "0.186.1",
55
56
  "vite": "^8.1.0",
@@ -1 +0,0 @@
1
- function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,r||"default");if("object"!=e(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function r(e,r,n){return(r=t(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?n(Object(s),!0).forEach(function(t){r(e,t,s[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):n(Object(s)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))})}return e}function o(e,t,r,n,s,o,i){try{var a=e[o](i),l=a.value}catch(e){return void r(e)}a.done?t(l):Promise.resolve(l).then(n,s)}function i(e){return function(){var t=this,r=arguments;return new Promise(function(n,s){var i=e.apply(t,r);function a(e){o(i,n,s,a,l,"next",e)}function l(e){o(i,n,s,a,l,"throw",e)}a(void 0)})}}function a(e,t){if(null==e)return{};var r,n,s=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var l,c,u,d=new class{constructor(e=32,t=67108864){r(this,"pending",/* @__PURE__ */new Map),r(this,"values",/* @__PURE__ */new Map),r(this,"bytes",0),r(this,"maxEntries",void 0),r(this,"maxBytes",void 0),this.maxEntries=e,this.maxBytes=t}load(e,t){const r=this.values.get(e);if(r)return this.values.delete(e),this.values.set(e,r),Promise.resolve(r);const n=this.pending.get(e);if(n)return n;const s=Promise.resolve().then(t).then(t=>{if(this.pending.get(e)===s&&(this.pending.delete(e),this.maxEntries>0&&t.bytes<=this.maxBytes))for(this.values.set(e,t),this.bytes+=t.bytes;this.values.size>this.maxEntries||this.bytes>this.maxBytes;)this.deleteValue(this.values.keys().next().value);return t},t=>{throw this.pending.get(e)===s&&this.pending.delete(e),t});return this.pending.set(e,s),s}deleteValue(e){const t=this.values.get(e);t&&(this.bytes-=t.bytes),this.values.delete(e)}clear(e){void 0!==e?(this.pending.delete(e),this.deleteValue(e)):(this.pending.clear(),this.values.clear(),this.bytes=0)}},p=e=>!!/\.(gzip|gz)(?:[?#]|$)/i.test(e),f=(l=i(function*(e,t,r=p){const n=yield window.fetch(e);if(!n.ok){try{var s;yield null===(s=n.body)||void 0===s?void 0:s.cancel()}catch(l){}throw new Error("Network response was not ok.")}let o=n;if(t)try{o=((e,t)=>{const r=Number(e.headers.get("content-length"))||0;let n=0;return e.body?new globalThis.Response(e.body.pipeThrough(new globalThis.TransformStream({start(){t({percent:0,transferredBytes:0,totalBytes:r})},transform(e,s){n+=e.byteLength,t({percent:0===r?0:n/r,transferredBytes:n,totalBytes:r}),s.enqueue(e)},flush(){t({percent:1,transferredBytes:n,totalBytes:r})}})),{status:e.status,statusText:e.statusText,headers:e.headers}):(t({percent:1,totalBytes:r,transferredBytes:n}),new globalThis.Response(null,{status:e.status,statusText:e.statusText,headers:e.headers}))})(o,t)}catch(c){try{var i;yield null===(i=n.body)||void 0===i?void 0:i.cancel(c)}catch(u){}throw c}if(r(e)&&"gzip"!==o.headers.get("content-encoding")){const e=new DecompressionStream("gzip"),t=o.body.pipeThrough(e);o=new Response(t)}const a=yield o.text();return{json:JSON.parse(a),bytes:2*a.length}}),function(e,t){return l.apply(this,arguments)}),h=(c=i(function*(e,t,r=p,n){try{var s,o;const i=null!==(s=null==n||null===(o=n.resolveURL)||void 0===o?void 0:o.call(n,e))&&void 0!==s?s:e,a=((e,t)=>{const r=null==t?void 0:t.cache;if(!1===r)return{enabled:!1,key:e,clone:!1};if(!0===r)return{enabled:!0,key:e,clone:!0};if(r&&"object"==typeof r){var n,s,o;const t=null===(n=r.enabled)||void 0===n||n;return{enabled:t,key:null!==(s=r.key)&&void 0!==s?s:e,clone:!!t&&(null===(o=r.clone)||void 0===o||o)}}return{enabled:!1,key:e,clone:!1}})(i,n),l=()=>f(i,t,()=>r(e)),c=(yield a.enabled?d.load(a.key,l):l()).json;return{res:a.enabled&&a.clone?structuredClone(c):c,err:void 0}}catch(i){return{res:void 0,err:i}}}),function(e,t){return c.apply(this,arguments)}),y=/^(?:[a-z]+:)?\/\//i,g=(u=i(function*(e,t){const{res:r,err:n}=yield h(((e,t="")=>y.test(e)?e:`${t.endsWith("/")?t.slice(0,-1):t}${e.startsWith("/")?e:`/${e}`}`)(e,null==t?void 0:t.assetsPrefix),void 0,void 0,(null==t?void 0:t.fetchOptions)||{cache:!0});if(n)throw n;return r}),function(e,t){return u.apply(this,arguments)}),v=e=>"string"==typeof e&&!!e&&!/[:\\?#\0]/.test(e)&&!e.split("/").some(e=>!e||"."===e||".."===e);function m(e){if(void 0===e)return;const t=e;if(!t||1!==t.version||!Array.isArray(t.entries))throw Error("Invalid runtime asset catalog");const r=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set;for(const i of t.entries){var o;if(!i||"string"!=typeof i.id||!i.id||r.has(i.id)||!v(i.path)||n.has(i.path)||!Array.isArray(i.sources)||!i.sources.length||i.sources.some(e=>"string"!=typeof e||!e||s.has(e))||new Set(i.sources).size!==i.sources.length||"string"!=typeof i.mimeType||!/^[\w.+-]+\/[\w.+-]+$/.test(i.mimeType)||!["identity","gzip"].includes(i.encoding)||!Number.isSafeInteger(i.bytes)||i.bytes<0||!/^[a-f0-9]{64}$/.test(i.sha256)||void 0!==i.data&&("string"!=typeof i.data||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i.data)))throw Error(`Invalid runtime asset: ${null!==(o=null==i?void 0:i.path)&&void 0!==o?o:"unknown"}`);r.add(i.id),n.add(i.path),i.sources.forEach(e=>s.add(e))}if(t.scope&&(!Number.isInteger(t.scope.rootAdcode)||t.scope.rootAdcode<0||!["province","city","district"].includes(t.scope.maxLevel)))throw Error("Invalid map export scope");if(t.regions&&("object"!=typeof t.regions||Array.isArray(t.regions)||Object.values(t.regions).some(e=>!Array.isArray(e)||e.some(e=>!Number.isInteger(e)||e<0))))throw Error("Invalid runtime region catalog");if(void 0!==t.declaredSources&&(!Array.isArray(t.declaredSources)||t.declaredSources.some(e=>"string"!=typeof e||!e.trim())))throw Error("Invalid declared asset sources");if(void 0!==t.externalSources&&(!Array.isArray(t.externalSources)||t.externalSources.some(e=>"string"!=typeof e||!e.trim()||/[{}\0]/.test(e)||/^(?:data:|blob:|asset:)/i.test(e)||s.has(e))||new Set(t.externalSources).size!==t.externalSources.length))throw Error("Invalid external asset sources");if(void 0!==t.mapDataMode&&!["bundled","external"].includes(t.mapDataMode))throw Error("Invalid map data mode");if(void 0!==t.mapSwitchKey&&("string"!=typeof t.mapSwitchKey||!t.mapSwitchKey.trim()))throw Error("Invalid bundled map switch key");if(void 0!==t.projectId&&("string"!=typeof t.projectId||!t.projectId.trim()||t.projectId.length>64))throw Error("Invalid runtime asset project")}function w(e){const t=[];for(let r=0;r<e.length;r+=32768)t.push(String.fromCharCode(...e.subarray(r,r+32768)));return btoa(t.join(""))}function b(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function S(e){return j.apply(this,arguments)}function j(){return(j=i(function*(e){const t=yield crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,"0")).join("")})).apply(this,arguments)}function A(e,t){return x.apply(this,arguments)}function x(){return(x=i(function*(e,t){if(t.length!==e.bytes||(yield S(t))!==e.sha256)throw Error(`资源校验失败:${e.path}`)})).apply(this,arguments)}function E(e,t){var r,n,o,i;if(!t)return e;if(!e)return structuredClone(t);const a=structuredClone(e),l=new Map(a.entries.map(e=>[e.id,e])),c=new Map(a.entries.flatMap(e=>e.sources.map(t=>[t,e.sha256])));for(const s of t.entries){for(const t of s.sources)if(c.has(t)&&c.get(t)!==s.sha256)throw Error(`资源地址存在不同内容:${t}。请修改资源地址或使用“打开项目”导入。`);const e=l.get(s.id);if(e)e.sources=[.../* @__PURE__ */new Set([...e.sources,...s.sources])];else{const e=structuredClone(s);a.entries.push(e),l.set(e.id,e)}for(const t of s.sources)c.set(t,s.sha256)}a.regions=s(s({},e.regions),t.regions),a.declaredSources=[.../* @__PURE__ */new Set([...null!==(r=e.declaredSources)&&void 0!==r?r:[],...null!==(n=t.declaredSources)&&void 0!==n?n:[]])];const u=[.../* @__PURE__ */new Set([...null!==(o=e.externalSources)&&void 0!==o?o:[],...null!==(i=t.externalSources)&&void 0!==i?i:[]])].filter(e=>!c.has(e));return u.length?a.externalSources=u:delete a.externalSources,m(a),a}var I=class{constructor(e,t="",n=!0){var s;r(this,"sources",/* @__PURE__ */new Map),r(this,"resolved",/* @__PURE__ */new Map),r(this,"externals",/* @__PURE__ */new Map),r(this,"catalog",void 0),r(this,"strict",void 0),r(this,"resolve",e=>{if(/^(data:|blob:)/i.test(e))return e;const t=this.sources.get(e);if(!t){const t=this.externals.get(e);if(void 0!==t)return t;if(!this.strict)return e;throw Error(`资源包未包含:${e}。请扩大导出范围或补充资源后重新导出。`)}let r=this.resolved.get(t.id);if(!r){if(void 0!==t.data)r=`data:${"gzip"===t.encoding?"application/gzip":t.mimeType};base64,${t.data}`;else{const e=this.catalog.baseUrl;if(!e)throw Error(`资源缺少文件内容或部署地址:${t.path}`);const n="undefined"==typeof location?"https://bundle.invalid/":location.href;r=new URL(t.path,new URL(e,n)).href}this.resolved.set(t.id,r)}return r}),this.catalog=e,this.strict=n,m(e);const o=(e,t)=>{const r=this.sources.get(e);if(r&&r.id!==t.id)throw Error(`资源地址重复:${e}`);this.sources.set(e,t)},i=e=>/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)?[e,...t?[t+e]:[]]:[e,t+e,`${t.replace(/\/$/,"")}/${e.replace(/^\//,"")}`,`/${e.replace(/^\//,"")}`];for(const r of e.entries)for(const e of[...r.sources,`asset://${r.id}`])for(const t of i(e))o(t,r);for(const r of null!==(s=e.externalSources)&&void 0!==s?s:[]){const e=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(r)?r:`${t.replace(/\/$/,"")}/${r.replace(/^\//,"")}`;for(const t of i(r))this.externals.set(t,e)}}},$=["format","schemaVersion","scenes","imageAssets"];function O(e){const t=e.replace(/[?#].*$/,""),r=e.slice(t.length),n=new URL(e,"https://bundle.invalid").pathname;if(/\.zip$/i.test(n)||/(?:^|\/)manifest\.json$/i.test(n))return e;if(/\.[^/]+$/.test(n))throw Error("vis-core 仅支持 ZIP、分包目录或 manifest.json;独立 JSON/GZ 请先通过编辑平台导入并导出 ZIP。");return`${t.replace(/\/$/,"")}/manifest.json${r}`}function P(e,t){return z.apply(this,arguments)}function z(){return(z=i(function*(e,t){try{const r=new Uint8Array(yield e.slice(0,2).arrayBuffer()),n=/\.(gz|gzip)$/i.test(t)||31===r[0]&&139===r[1]?yield new Response(e.stream().pipeThrough(new DecompressionStream("gzip"))).text():yield e.text(),s=JSON.parse(n);if(!s||"object"!=typeof s||Array.isArray(s))throw Error("需要 JSON 对象");return s}catch(r){throw new Error(`无法读取文件 ${t}:${r instanceof Error?r.message:String(r)}`,{cause:r})}})).apply(this,arguments)}function B(e){return C.apply(this,arguments)}function C(){return C=i(function*(e,t="project.zip"){var r;const[{default:n},o,{SCENE_DOCUMENT_FORMAT:l},{resolveRuntimeImages:c}]=yield Promise.all([import("jszip"),import("./validation-DiMfvx_5.js").then(e=>e.r),import("./schema-BpVVlDZn.js").then(e=>e.c),import("./runtimeImages-BnSAIZUX.js").then(e=>e.r)]),u=o;let d;try{d=yield n.loadAsync(e instanceof Blob?yield e.arrayBuffer():e)}catch(B){throw new Error(`无法解压 ZIP 文件 ${t}`,{cause:B})}const p=Object.values(d.files).filter(e=>!e.dir&&/(^|\/)manifest\.json$/.test(e.name)&&!e.name.startsWith("__MACOSX/")),f=null!==(r=d.file("manifest.json"))&&void 0!==r?r:1===p.length?p[0]:void 0;if(!f)throw new Error(p.length>1?"ZIP 中有多个 manifest.json,无法确定要导入的项目":"ZIP 中缺少 manifest.json,请选择平台导出的场景分包 ZIP");const h=f.name.slice(0,-13),y=yield P(new Blob([yield f.async("uint8array")]),f.name);u.assertSceneManifest(y);const g=function(){var e=i(function*(e){if(/[:\\?#\0]/.test(e)||e.split("/").some(e=>!e||"."===e||".."===e))throw new Error(`ZIP 内文件路径无效:${e}`);const t=d.file(h+e);if(!t)throw new Error(`ZIP 中缺少文件:${e}`);if(t.unsafeOriginalName&&t.unsafeOriginalName!==t.name)throw new Error(`ZIP 内文件路径无效:${e}`);return new Blob([yield t.async("uint8array")])});return function(t){return e.apply(this,arguments)}}(),v=[];for(const s of y.scenes){var m,b;const e=yield P(yield g(s.source),s.source);if(!(null===(m=e.scene)||void 0===m?void 0:m.object)||e.id!==s.id||(null===(b=e.vis)||void 0===b?void 0:b.type)!==s.vis.type)throw new Error(`场景文件与 manifest 不匹配:${s.source}`);v.push(e)}const{format:S,schemaVersion:j,scenes:x,imageAssets:E}=y,I=s(s({},a(y,$)),{},{format:l,schemaVersion:1===j?4:2===j?5:6,scenes:v});if(u.assertRuntimeSceneDocument(I),I.runtimeAssets){delete I.runtimeAssets.baseUrl;for(const e of I.runtimeAssets.entries){const t=new Uint8Array(yield(yield g(e.path)).arrayBuffer());yield A(e,t),e.data=w(t)}}const O=/* @__PURE__ */new Map,z={png:"image/png",jpg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",bmp:"image/bmp"};for(const s of null!=E?E:[]){const e=new Uint8Array(yield(yield g(s)).arrayBuffer()),t=[];for(let n=0;n<e.length;n+=32768)t.push(String.fromCharCode(...e.subarray(n,n+32768)));const r=z[s.split(".").pop()];O.set(s,`data:${r};base64,${btoa(t.join(""))}`)}return c(I,E,e=>O.get(e)),I}),C.apply(this,arguments)}var N="undefined"!=typeof crypto&&void 0!==crypto.subtle;function U(e){const t=e.replace(/-----BEGIN PUBLIC KEY-----/g,"").replace(/-----END PUBLIC KEY-----/g,"").replace(/\s/g,""),r=atob(t),n=new Uint8Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);return n.buffer}function M(){return(M=i(function*(e){return crypto.subtle.importKey("spki",U(e),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])})).apply(this,arguments)}var T="-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEU2vGIjpJQFRkGxVrw4gZL3dXm/1\nfrZBlUc8gjzam/VNZbT1swQSq/kLPmYH7ZykBvLzp7SpNdvOQ8rAqdSdvg==\n-----END PUBLIC KEY-----";var Z=N?function(e){return M.apply(this,arguments)}(T):null,k=N?null:new Uint8Array(U(T)).slice(26);function D(e){return L.apply(this,arguments)}function L(){return(L=i(function*(e){let t;try{t=function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,n=atob(t+"=".repeat(r)),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return s}(e)}catch(i){return null}if(t.length<=64)return null;const r=t.slice(0,t.length-64),n=t.slice(t.length-64);let s;try{if(N){const e=yield Z;s=yield crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},e,n,r)}else{const{p256:e}=yield import("@noble/curves/nist.js");s=e.verify(n,r,k,{lowS:!1})}}catch(a){return null}if(!s)return null;const o=function(e){if(e.length<1)return null;if(123===e[0])try{const t=JSON.parse((new TextDecoder).decode(e));return 2!==t.version||!["runtime","preview"].includes(t.purpose)||"string"!=typeof t.projectId||!t.projectId.trim()||t.projectId.length>64||!Array.isArray(t.adcodes)||!t.adcodes.length||t.adcodes.length>65535||t.adcodes.some(e=>!Number.isInteger(e)||e<0||e>16777215)||new Set(t.adcodes).size!==t.adcodes.length||void 0!==t.expire&&(!Number.isSafeInteger(t.expire)||t.expire<=0)||"preview"===t.purpose&&!t.expire?null:{purpose:t.purpose,projectId:t.projectId,adcodes:t.adcodes,expire:t.expire}}catch(l){return null}const t=e[0],r=!!(2&t),n=!!(4&t),s=!!(8&t);if(-16&t||r&&(n||s))return null;let o,i=1;if(1&t){if(e.length<i+4)return null;o=36e5*((e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])>>>0),i+=4}let a=null;if(!r){if(e.length<i+1)return null;let t=e[i++];if(s){if(e.length<i+1)return null;t=t<<8|e[i++]}if(!t||e.length!==i+3*t)return null;a=[];for(let r=0;r<t;r++){const t=e[i]<<16|e[i+1]<<8|e[i+2];a.push(t),i+=3}}return i!==e.length?null:{adcodes:a,expire:o,prefixMatch:n}}(r);return o?o.expire&&Date.now()>o.expire?null:o:null})).apply(this,arguments)}function R(e,t,r){return K.apply(this,arguments)}function K(){return(K=i(function*(e,t,r){const n=yield D(t);if(!(null==n?void 0:n.adcodes)||n.prefixMatch||"preview"===n.purpose||void 0!==r&&n.projectId!==r)return!1;const s=new Set(e),o=new Set(n.adcodes);return s.size>0&&s.size===o.size&&[...s].every(e=>o.has(e))})).apply(this,arguments)}function V(e,t){return Y.apply(this,arguments)}function Y(){return(Y=i(function*(e,t){const r=yield D(t);return!(!(null==r?void 0:r.adcodes)||r.prefixMatch||"preview"===r.purpose)&&r.adcodes.includes(e)})).apply(this,arguments)}var J=(e,t)=>{const r=Q(e),n=Q(t).map(function(e,t){return e^r[Math.floor(t%r.length)]}).join(",");return btoa(n)};function Q(e){const t=[];let r=0;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);s<128?t[r++]=s:s<2048?(t[r++]=s>>6|192,t[r++]=63&s|128):55296==(64512&s)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++n)),t[r++]=s>>18|240,t[r++]=s>>12&63|128,t[r++]=s>>6&63|128,t[r++]=63&s|128):(t[r++]=s>>12|224,t[r++]=s>>6&63|128,t[r++]=63&s|128)}return t}export{i as _,O as a,S as c,E as d,A as f,a as g,g as h,B as i,b as l,h as m,V as n,I as o,p,R as r,m as s,J as t,w as u,s as v,r as y};
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,a=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),u=(e,r)=>{let o={};for(var l in e)t(o,l,{get:e[l],enumerable:!0});return r||t(o,Symbol.toStringTag,{value:"Module"}),o},p=(a,u,p)=>(p=null!=a?e(l(a)):{},((e,l,a,u)=>{if(l&&"object"==typeof l||"function"==typeof l)for(var p,b=o(l),c=0,s=b.length;c<s;c++)p=b[c],n.call(e,p)||p===a||t(e,p,{get:(e=>l[e]).bind(null,p),enumerable:!(u=r(l,p))||u.enumerable});return e})(!u&&a&&a.__esModule?p:t(p,"default",{value:a,enumerable:!0}),a));export{u as n,p as r,a as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-NMqb_1LM.js";var r=/* @__PURE__ */e({externalizeRuntimeImages:()=>n,resolveRuntimeImages:()=>t});function o(e,r){var o,n,t,i,a,s,l;const g=e=>{for(const o of null!=e?e:[])"string"==typeof o.url?o.url=r(o.url):Array.isArray(o.url)&&(o.url=o.url.map(e=>"string"==typeof e?r(e):e))};g(null===(o=e.scene)||void 0===o?void 0:o.images);for(const p of null!==(n=e.materialLibrary)&&void 0!==n?n:[])g(null===(t=p.material)||void 0===t?void 0:t.images);for(const p of null!==(i=e.prefabLibrary)&&void 0!==i?i:[])g(null===(a=p.snapshot)||void 0===a?void 0:a.images);for(const p of null!==(s=e.scenes)&&void 0!==s?s:[])g(null===(l=p.scene)||void 0===l?void 0:l.images)}function n(e){const r={},n=/* @__PURE__ */new Map,t={png:"png",jpeg:"jpg",jpg:"jpg",webp:"webp",gif:"gif",avif:"avif",bmp:"bmp"};return o(e,e=>{const o=n.get(e);if(o)return o;const i=/^data:image\/(png|jpeg|jpg|webp|gif|avif|bmp);base64,([\s\S]*)$/i.exec(e);if(!i)return e;let a;try{const e=atob(i[2]);a=new Uint8Array(e.length);for(let r=0;r<e.length;r++)a[r]=e.charCodeAt(r)}catch(g){return e}const s=i[1].toLowerCase(),l=`assets/image-${n.size}.${t[s]}`;return n.set(e,l),r[l]={data:a,mimeType:`image/${"jpg"===s?"jpeg":s}`},l}),r}function t(e,r,n){if(!(null==r?void 0:r.length))return;const t=new Set(r),i=e=>t.has(e)?n(e):e;o(e,i),e._resourcePool&&(e._resourcePool=e._resourcePool.map(e=>"string"==typeof e?i(e):Array.isArray(e)?e.map(e=>"string"==typeof e?i(e):e):e))}export{t as n,r,n as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-NMqb_1LM.js";var s=/* @__PURE__ */e({SCENE_DOCUMENT_FORMAT:()=>n,SCENE_DOCUMENT_SCHEMA_VERSION:()=>6,SCENE_MANIFEST_FORMAT:()=>o,SCENE_MANIFEST_SCHEMA_VERSION:()=>4,assertSupportedSceneDocument:()=>c,isSceneDocument:()=>i,isSceneManifest:()=>a}),n="vis-scene",r=6,o="vis-scene-manifest",t=4;function i(e){if(!e||"object"!=typeof e)return!1;const s=e;return"vis-scene"===s.format&&Number.isInteger(s.schemaVersion)&&s.schemaVersion>=1}function a(e){return!(!e||"object"!=typeof e)&&e.format===o}function c(e){if(i(e)&&e.schemaVersion>6)throw new Error(`Unsupported scene schema version: ${e.schemaVersion}. Maximum supported version: 6`)}export{c as a,s as c,t as i,r as n,i as o,o as r,a as s,n as t};