@ridp/threejs 1.1.6 → 1.2.0

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 (74) hide show
  1. package/dist/{common-BHi3qsZW.cjs → common-C1rNPPkt.cjs} +2 -2
  2. package/dist/{common-fbJUHqlj.js → common-D1_IztgM.js} +1 -1
  3. package/dist/hooks.cjs +1 -1
  4. package/dist/hooks.js +1 -1
  5. package/dist/modelSerialize-5oJb1ka7.js +965 -0
  6. package/dist/modelSerialize-Ds_2KBaA.cjs +5 -0
  7. package/dist/threejs.cjs +1 -1
  8. package/dist/threejs.js +185 -25
  9. package/dist/useGLTFLoader-2awW2QaH.cjs +4 -0
  10. package/dist/{useGLTFLoader-DusnFN5B.js → useGLTFLoader-BBGTGOYm.js} +1800 -1952
  11. package/dist/utils.cjs +1 -1
  12. package/dist/utils.js +9 -7
  13. package/esdoc/ast/source/.external-ecmascript.js.json +2801 -2801
  14. package/esdoc/ast/source/hooks/index.js.json +738 -738
  15. package/esdoc/ast/source/hooks/useGLTFLoader.js.json +9110 -9110
  16. package/esdoc/ast/source/hooks/useObb.js.json +16462 -16462
  17. package/esdoc/ast/source/hooks/useRaycaster.js.json +15555 -15555
  18. package/esdoc/ast/source/hooks/useThreeJs.js.json +52886 -52886
  19. package/esdoc/ast/source/index.js.json +569 -569
  20. package/esdoc/ast/source/instance/IDBCache.js.json +40977 -40977
  21. package/esdoc/ast/source/instance/index.js.json +231 -231
  22. package/esdoc/ast/source/utils/ImageLoader.js.json +7036 -7036
  23. package/esdoc/ast/source/utils/common.js.json +5133 -5133
  24. package/esdoc/ast/source/utils/css3dHelper.js.json +9100 -9100
  25. package/esdoc/ast/source/utils/disposeObject.js.json +5977 -5977
  26. package/esdoc/ast/source/utils/helper.js.json +10521 -10521
  27. package/esdoc/ast/source/utils/index.js.json +907 -907
  28. package/esdoc/badge.svg +17 -17
  29. package/esdoc/class/src/instance/IDBCache.js~IDBCache.html +1299 -1299
  30. package/esdoc/coverage.json +85 -85
  31. package/esdoc/css/github.css +83 -83
  32. package/esdoc/css/identifiers.css +37 -37
  33. package/esdoc/css/manual.css +134 -134
  34. package/esdoc/css/prettify-tomorrow.css +132 -132
  35. package/esdoc/css/search.css +84 -84
  36. package/esdoc/css/source.css +55 -55
  37. package/esdoc/css/style.css +608 -608
  38. package/esdoc/css/test.css +58 -58
  39. package/esdoc/file/src/hooks/index.js.html +75 -75
  40. package/esdoc/file/src/hooks/useGLTFLoader.js.html +75 -75
  41. package/esdoc/file/src/hooks/useObb.js.html +75 -75
  42. package/esdoc/file/src/hooks/useRaycaster.js.html +75 -75
  43. package/esdoc/file/src/hooks/useThreeJs.js.html +75 -75
  44. package/esdoc/file/src/index.js.html +75 -75
  45. package/esdoc/file/src/instance/IDBCache.js.html +75 -75
  46. package/esdoc/file/src/instance/index.js.html +75 -75
  47. package/esdoc/file/src/utils/ImageLoader.js.html +75 -75
  48. package/esdoc/file/src/utils/common.js.html +75 -75
  49. package/esdoc/file/src/utils/css3dHelper.js.html +75 -75
  50. package/esdoc/file/src/utils/disposeObject.js.html +75 -75
  51. package/esdoc/file/src/utils/helper.js.html +75 -75
  52. package/esdoc/file/src/utils/index.js.html +75 -75
  53. package/esdoc/function/index.html +2019 -2019
  54. package/esdoc/identifiers.html +738 -738
  55. package/esdoc/image/badge.svg +17 -17
  56. package/esdoc/image/manual-badge.svg +17 -17
  57. package/esdoc/index.html +153 -153
  58. package/esdoc/index.json +2050 -2050
  59. package/esdoc/script/inherited-summary.js +28 -28
  60. package/esdoc/script/inner-link.js +32 -32
  61. package/esdoc/script/manual.js +12 -12
  62. package/esdoc/script/patch-for-local.js +8 -8
  63. package/esdoc/script/prettify/Apache-License-2.0.txt +202 -202
  64. package/esdoc/script/prettify/prettify.js +46 -46
  65. package/esdoc/script/pretty-print.js +25 -25
  66. package/esdoc/script/search.js +117 -117
  67. package/esdoc/script/search_index.js +571 -571
  68. package/esdoc/script/test-summary.js +54 -54
  69. package/esdoc/source.html +213 -213
  70. package/esdoc/variable/index.html +225 -225
  71. package/package.json +3 -2
  72. package/dist/ImageLoader-CB_URfeZ.js +0 -860
  73. package/dist/ImageLoader-DwvBWW6h.cjs +0 -5
  74. package/dist/useGLTFLoader-BiveFkS6.cjs +0 -4
@@ -0,0 +1,4 @@
1
+ "use strict";const T=require("three"),it=require("vue"),Mt=require("./modelSerialize-Ds_2KBaA.cjs");function ei(L,i){if(i===T.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),L;if(i===T.TriangleFanDrawMode||i===T.TriangleStripDrawMode){let o=L.getIndex();if(o===null){const l=[],p=L.getAttribute("position");if(p!==void 0){for(let h=0;h<p.count;h++)l.push(h);L.setIndex(l),o=L.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),L}const a=o.count-2,u=[];if(i===T.TriangleFanDrawMode)for(let l=1;l<=a;l++)u.push(o.getX(0)),u.push(o.getX(l)),u.push(o.getX(l+1));else for(let l=0;l<a;l++)l%2===0?(u.push(o.getX(l)),u.push(o.getX(l+1)),u.push(o.getX(l+2))):(u.push(o.getX(l+2)),u.push(o.getX(l+1)),u.push(o.getX(l)));u.length/3!==a&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const c=L.clone();return c.setIndex(u),c.clearGroups(),c}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",i),L}const hr=new WeakMap;class Vi extends T.Loader{constructor(i){super(i),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(i){return this.decoderPath=i,this}setDecoderConfig(i){return this.decoderConfig=i,this}setWorkerLimit(i){return this.workerLimit=i,this}load(i,o,a,u){const c=new T.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(i,l=>{this.parse(l,o,u)},a,u)}parse(i,o,a=()=>{}){this.decodeDracoFile(i,o,null,null,T.SRGBColorSpace,a).catch(a)}decodeDracoFile(i,o,a,u,c=T.LinearSRGBColorSpace,l=()=>{}){const p={attributeIDs:a||this.defaultAttributeIDs,attributeTypes:u||this.defaultAttributeTypes,useUniqueIDs:!!a,vertexColorSpace:c};return this.decodeGeometry(i,p).then(o).catch(l)}decodeGeometry(i,o){const a=JSON.stringify(o);if(hr.has(i)){const h=hr.get(i);if(h.key===a)return h.promise;if(i.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let u;const c=this.workerNextTaskID++,l=i.byteLength,p=this._getWorker(c,l).then(h=>(u=h,new Promise((y,E)=>{u._callbacks[c]={resolve:y,reject:E},u.postMessage({type:"decode",id:c,taskConfig:o,buffer:i},[i])}))).then(h=>this._createGeometry(h.geometry));return p.catch(()=>!0).then(()=>{u&&c&&this._releaseTask(u,c)}),hr.set(i,{key:a,promise:p}),p}_createGeometry(i){const o=new T.BufferGeometry;i.index&&o.setIndex(new T.BufferAttribute(i.index.array,1));for(let a=0;a<i.attributes.length;a++){const u=i.attributes[a],c=u.name,l=u.array,p=u.itemSize,h=new T.BufferAttribute(l,p);c==="color"&&(this._assignVertexColorSpace(h,u.vertexColorSpace),h.normalized=!(l instanceof Float32Array)),o.setAttribute(c,h)}return o}_assignVertexColorSpace(i,o){if(o!==T.SRGBColorSpace)return;const a=new T.Color;for(let u=0,c=i.count;u<c;u++)a.fromBufferAttribute(i,u),T.ColorManagement.colorSpaceToWorking(a,T.SRGBColorSpace),i.setXYZ(u,a.r,a.g,a.b)}_loadLibrary(i,o){const a=new T.FileLoader(this.manager);return a.setPath(this.decoderPath),a.setResponseType(o),a.setWithCredentials(this.withCredentials),new Promise((u,c)=>{a.load(i,u,void 0,c)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const i=typeof WebAssembly!="object"||this.decoderConfig.type==="js",o=[];return i?o.push(this._loadLibrary("draco_decoder.js","text")):(o.push(this._loadLibrary("draco_wasm_wrapper.js","text")),o.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(o).then(a=>{const u=a[0];i||(this.decoderConfig.wasmBinary=a[1]);const c=Xi.toString(),l=["/* draco decoder */",u,"","/* worker */",c.substring(c.indexOf("{")+1,c.lastIndexOf("}"))].join(`
2
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([l]))}),this.decoderPending}_getWorker(i,o){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const u=new Worker(this.workerSourceURL);u._callbacks={},u._taskCosts={},u._taskLoad=0,u.postMessage({type:"init",decoderConfig:this.decoderConfig}),u.onmessage=function(c){const l=c.data;switch(l.type){case"decode":u._callbacks[l.id].resolve(l);break;case"error":u._callbacks[l.id].reject(l);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+l.type+'"')}},this.workerPool.push(u)}else this.workerPool.sort(function(u,c){return u._taskLoad>c._taskLoad?-1:1});const a=this.workerPool[this.workerPool.length-1];return a._taskCosts[i]=o,a._taskLoad+=o,a})}_releaseTask(i,o){i._taskLoad-=i._taskCosts[o],delete i._callbacks[o],delete i._taskCosts[o]}debug(){console.log("Task load: ",this.workerPool.map(i=>i._taskLoad))}dispose(){for(let i=0;i<this.workerPool.length;++i)this.workerPool[i].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Xi(){let L,i;onmessage=function(l){const p=l.data;switch(p.type){case"init":L=p.decoderConfig,i=new Promise(function(E){L.onModuleLoaded=function(w){E({draco:w})},DracoDecoderModule(L)});break;case"decode":const h=p.buffer,y=p.taskConfig;i.then(E=>{const w=E.draco,P=new w.Decoder;try{const D=o(w,P,new Int8Array(h),y),G=D.attributes.map(W=>W.array.buffer);D.index&&G.push(D.index.array.buffer),self.postMessage({type:"decode",id:p.id,geometry:D},G)}catch(D){console.error(D),self.postMessage({type:"error",id:p.id,error:D.message})}finally{w.destroy(P)}});break}};function o(l,p,h,y){const E=y.attributeIDs,w=y.attributeTypes;let P,D;const G=p.GetEncodedGeometryType(h);if(G===l.TRIANGULAR_MESH)P=new l.Mesh,D=p.DecodeArrayToMesh(h,h.byteLength,P);else if(G===l.POINT_CLOUD)P=new l.PointCloud,D=p.DecodeArrayToPointCloud(h,h.byteLength,P);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!D.ok()||P.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+D.error_msg());const W={index:null,attributes:[]};for(const z in E){const Y=self[w[z]];let ee,le;if(y.useUniqueIDs)le=E[z],ee=p.GetAttributeByUniqueId(P,le);else{if(le=p.GetAttributeId(P,l[E[z]]),le===-1)continue;ee=p.GetAttribute(P,le)}const $=u(l,p,P,z,Y,ee);z==="color"&&($.vertexColorSpace=y.vertexColorSpace),W.attributes.push($)}return G===l.TRIANGULAR_MESH&&(W.index=a(l,p,P)),l.destroy(P),W}function a(l,p,h){const E=h.num_faces()*3,w=E*4,P=l._malloc(w);p.GetTrianglesUInt32Array(h,w,P);const D=new Uint32Array(l.HEAPF32.buffer,P,E).slice();return l._free(P),{array:D,itemSize:1}}function u(l,p,h,y,E,w){const P=w.num_components(),G=h.num_points()*P,W=G*E.BYTES_PER_ELEMENT,z=c(l,E),Y=l._malloc(W);p.GetAttributeDataArrayForAllPoints(h,w,z,W,Y);const ee=new E(l.HEAPF32.buffer,Y,G).slice();return l._free(Y),{name:y,array:ee,itemSize:P}}function c(l,p){switch(p){case Float32Array:return l.DT_FLOAT32;case Int8Array:return l.DT_INT8;case Int16Array:return l.DT_INT16;case Int32Array:return l.DT_INT32;case Uint8Array:return l.DT_UINT8;case Uint16Array:return l.DT_UINT16;case Uint32Array:return l.DT_UINT32}}}class Wi extends T.Loader{constructor(i){super(i),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(o){return new Zi(o)}),this.register(function(o){return new es(o)}),this.register(function(o){return new cs(o)}),this.register(function(o){return new ls(o)}),this.register(function(o){return new fs(o)}),this.register(function(o){return new ns(o)}),this.register(function(o){return new rs(o)}),this.register(function(o){return new is(o)}),this.register(function(o){return new ss(o)}),this.register(function(o){return new Ji(o)}),this.register(function(o){return new os(o)}),this.register(function(o){return new ts(o)}),this.register(function(o){return new us(o)}),this.register(function(o){return new as(o)}),this.register(function(o){return new $i(o)}),this.register(function(o){return new hs(o)}),this.register(function(o){return new ds(o)})}load(i,o,a,u){const c=this;let l;if(this.resourcePath!=="")l=this.resourcePath;else if(this.path!==""){const y=T.LoaderUtils.extractUrlBase(i);l=T.LoaderUtils.resolveURL(y,this.path)}else l=T.LoaderUtils.extractUrlBase(i);this.manager.itemStart(i);const p=function(y){u?u(y):console.error(y),c.manager.itemError(i),c.manager.itemEnd(i)},h=new T.FileLoader(this.manager);h.setPath(this.path),h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setWithCredentials(this.withCredentials),h.load(i,function(y){try{c.parse(y,l,function(E){o(E),c.manager.itemEnd(i)},p)}catch(E){p(E)}},a,p)}setDRACOLoader(i){return this.dracoLoader=i,this}setKTX2Loader(i){return this.ktx2Loader=i,this}setMeshoptDecoder(i){return this.meshoptDecoder=i,this}register(i){return this.pluginCallbacks.indexOf(i)===-1&&this.pluginCallbacks.push(i),this}unregister(i){return this.pluginCallbacks.indexOf(i)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(i),1),this}parse(i,o,a,u){let c;const l={},p={},h=new TextDecoder;if(typeof i=="string")c=JSON.parse(i);else if(i instanceof ArrayBuffer)if(h.decode(new Uint8Array(i,0,4))===hi){try{l[re.KHR_BINARY_GLTF]=new ps(i)}catch(w){u&&u(w);return}c=JSON.parse(l[re.KHR_BINARY_GLTF].content)}else c=JSON.parse(h.decode(i));else c=i;if(c.asset===void 0||c.asset.version[0]<2){u&&u(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const y=new As(c,{path:o||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});y.fileLoader.setRequestHeader(this.requestHeader);for(let E=0;E<this.pluginCallbacks.length;E++){const w=this.pluginCallbacks[E](y);w.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),p[w.name]=w,l[w.name]=!0}if(c.extensionsUsed)for(let E=0;E<c.extensionsUsed.length;++E){const w=c.extensionsUsed[E],P=c.extensionsRequired||[];switch(w){case re.KHR_MATERIALS_UNLIT:l[w]=new Qi;break;case re.KHR_DRACO_MESH_COMPRESSION:l[w]=new ms(c,this.dracoLoader);break;case re.KHR_TEXTURE_TRANSFORM:l[w]=new ys;break;case re.KHR_MESH_QUANTIZATION:l[w]=new gs;break;default:P.indexOf(w)>=0&&p[w]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+w+'".')}}y.setExtensions(l),y.setPlugins(p),y.parse(a,u)}parseAsync(i,o){const a=this;return new Promise(function(u,c){a.parse(i,o,u,c)})}}function Yi(){let L={};return{get:function(i){return L[i]},add:function(i,o){L[i]=o},remove:function(i){delete L[i]},removeAll:function(){L={}}}}const re={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class $i{constructor(i){this.parser=i,this.name=re.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const i=this.parser,o=this.parser.json.nodes||[];for(let a=0,u=o.length;a<u;a++){const c=o[a];c.extensions&&c.extensions[this.name]&&c.extensions[this.name].light!==void 0&&i._addNodeRef(this.cache,c.extensions[this.name].light)}}_loadLight(i){const o=this.parser,a="light:"+i;let u=o.cache.get(a);if(u)return u;const c=o.json,h=((c.extensions&&c.extensions[this.name]||{}).lights||[])[i];let y;const E=new T.Color(16777215);h.color!==void 0&&E.setRGB(h.color[0],h.color[1],h.color[2],T.LinearSRGBColorSpace);const w=h.range!==void 0?h.range:0;switch(h.type){case"directional":y=new T.DirectionalLight(E),y.target.position.set(0,0,-1),y.add(y.target);break;case"point":y=new T.PointLight(E),y.distance=w;break;case"spot":y=new T.SpotLight(E),y.distance=w,h.spot=h.spot||{},h.spot.innerConeAngle=h.spot.innerConeAngle!==void 0?h.spot.innerConeAngle:0,h.spot.outerConeAngle=h.spot.outerConeAngle!==void 0?h.spot.outerConeAngle:Math.PI/4,y.angle=h.spot.outerConeAngle,y.penumbra=1-h.spot.innerConeAngle/h.spot.outerConeAngle,y.target.position.set(0,0,-1),y.add(y.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+h.type)}return y.position.set(0,0,0),We(y,h),h.intensity!==void 0&&(y.intensity=h.intensity),y.name=o.createUniqueName(h.name||"light_"+i),u=Promise.resolve(y),o.cache.add(a,u),u}getDependency(i,o){if(i==="light")return this._loadLight(o)}createNodeAttachment(i){const o=this,a=this.parser,c=a.json.nodes[i],p=(c.extensions&&c.extensions[this.name]||{}).light;return p===void 0?null:this._loadLight(p).then(function(h){return a._getNodeRef(o.cache,p,h)})}}class Qi{constructor(){this.name=re.KHR_MATERIALS_UNLIT}getMaterialType(){return T.MeshBasicMaterial}extendParams(i,o,a){const u=[];i.color=new T.Color(1,1,1),i.opacity=1;const c=o.pbrMetallicRoughness;if(c){if(Array.isArray(c.baseColorFactor)){const l=c.baseColorFactor;i.color.setRGB(l[0],l[1],l[2],T.LinearSRGBColorSpace),i.opacity=l[3]}c.baseColorTexture!==void 0&&u.push(a.assignTexture(i,"map",c.baseColorTexture,T.SRGBColorSpace))}return Promise.all(u)}}class Ji{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(i,o){const u=this.parser.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=u.extensions[this.name].emissiveStrength;return c!==void 0&&(o.emissiveIntensity=c),Promise.resolve()}}class Zi{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_CLEARCOAT}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];if(l.clearcoatFactor!==void 0&&(o.clearcoat=l.clearcoatFactor),l.clearcoatTexture!==void 0&&c.push(a.assignTexture(o,"clearcoatMap",l.clearcoatTexture)),l.clearcoatRoughnessFactor!==void 0&&(o.clearcoatRoughness=l.clearcoatRoughnessFactor),l.clearcoatRoughnessTexture!==void 0&&c.push(a.assignTexture(o,"clearcoatRoughnessMap",l.clearcoatRoughnessTexture)),l.clearcoatNormalTexture!==void 0&&(c.push(a.assignTexture(o,"clearcoatNormalMap",l.clearcoatNormalTexture)),l.clearcoatNormalTexture.scale!==void 0)){const p=l.clearcoatNormalTexture.scale;o.clearcoatNormalScale=new T.Vector2(p,p)}return Promise.all(c)}}class es{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_DISPERSION}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const u=this.parser.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=u.extensions[this.name];return o.dispersion=c.dispersion!==void 0?c.dispersion:0,Promise.resolve()}}class ts{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_IRIDESCENCE}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return l.iridescenceFactor!==void 0&&(o.iridescence=l.iridescenceFactor),l.iridescenceTexture!==void 0&&c.push(a.assignTexture(o,"iridescenceMap",l.iridescenceTexture)),l.iridescenceIor!==void 0&&(o.iridescenceIOR=l.iridescenceIor),o.iridescenceThicknessRange===void 0&&(o.iridescenceThicknessRange=[100,400]),l.iridescenceThicknessMinimum!==void 0&&(o.iridescenceThicknessRange[0]=l.iridescenceThicknessMinimum),l.iridescenceThicknessMaximum!==void 0&&(o.iridescenceThicknessRange[1]=l.iridescenceThicknessMaximum),l.iridescenceThicknessTexture!==void 0&&c.push(a.assignTexture(o,"iridescenceThicknessMap",l.iridescenceThicknessTexture)),Promise.all(c)}}class ns{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_SHEEN}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[];o.sheenColor=new T.Color(0,0,0),o.sheenRoughness=0,o.sheen=1;const l=u.extensions[this.name];if(l.sheenColorFactor!==void 0){const p=l.sheenColorFactor;o.sheenColor.setRGB(p[0],p[1],p[2],T.LinearSRGBColorSpace)}return l.sheenRoughnessFactor!==void 0&&(o.sheenRoughness=l.sheenRoughnessFactor),l.sheenColorTexture!==void 0&&c.push(a.assignTexture(o,"sheenColorMap",l.sheenColorTexture,T.SRGBColorSpace)),l.sheenRoughnessTexture!==void 0&&c.push(a.assignTexture(o,"sheenRoughnessMap",l.sheenRoughnessTexture)),Promise.all(c)}}class rs{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_TRANSMISSION}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return l.transmissionFactor!==void 0&&(o.transmission=l.transmissionFactor),l.transmissionTexture!==void 0&&c.push(a.assignTexture(o,"transmissionMap",l.transmissionTexture)),Promise.all(c)}}class is{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_VOLUME}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];o.thickness=l.thicknessFactor!==void 0?l.thicknessFactor:0,l.thicknessTexture!==void 0&&c.push(a.assignTexture(o,"thicknessMap",l.thicknessTexture)),o.attenuationDistance=l.attenuationDistance||1/0;const p=l.attenuationColor||[1,1,1];return o.attenuationColor=new T.Color().setRGB(p[0],p[1],p[2],T.LinearSRGBColorSpace),Promise.all(c)}}class ss{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_IOR}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const u=this.parser.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=u.extensions[this.name];return o.ior=c.ior!==void 0?c.ior:1.5,Promise.resolve()}}class os{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_SPECULAR}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];o.specularIntensity=l.specularFactor!==void 0?l.specularFactor:1,l.specularTexture!==void 0&&c.push(a.assignTexture(o,"specularIntensityMap",l.specularTexture));const p=l.specularColorFactor||[1,1,1];return o.specularColor=new T.Color().setRGB(p[0],p[1],p[2],T.LinearSRGBColorSpace),l.specularColorTexture!==void 0&&c.push(a.assignTexture(o,"specularColorMap",l.specularColorTexture,T.SRGBColorSpace)),Promise.all(c)}}class as{constructor(i){this.parser=i,this.name=re.EXT_MATERIALS_BUMP}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return o.bumpScale=l.bumpFactor!==void 0?l.bumpFactor:1,l.bumpTexture!==void 0&&c.push(a.assignTexture(o,"bumpMap",l.bumpTexture)),Promise.all(c)}}class us{constructor(i){this.parser=i,this.name=re.KHR_MATERIALS_ANISOTROPY}getMaterialType(i){const a=this.parser.json.materials[i];return!a.extensions||!a.extensions[this.name]?null:T.MeshPhysicalMaterial}extendMaterialParams(i,o){const a=this.parser,u=a.json.materials[i];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return l.anisotropyStrength!==void 0&&(o.anisotropy=l.anisotropyStrength),l.anisotropyRotation!==void 0&&(o.anisotropyRotation=l.anisotropyRotation),l.anisotropyTexture!==void 0&&c.push(a.assignTexture(o,"anisotropyMap",l.anisotropyTexture)),Promise.all(c)}}class cs{constructor(i){this.parser=i,this.name=re.KHR_TEXTURE_BASISU}loadTexture(i){const o=this.parser,a=o.json,u=a.textures[i];if(!u.extensions||!u.extensions[this.name])return null;const c=u.extensions[this.name],l=o.options.ktx2Loader;if(!l){if(a.extensionsRequired&&a.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return o.loadTextureImage(i,c.source,l)}}class ls{constructor(i){this.parser=i,this.name=re.EXT_TEXTURE_WEBP}loadTexture(i){const o=this.name,a=this.parser,u=a.json,c=u.textures[i];if(!c.extensions||!c.extensions[o])return null;const l=c.extensions[o],p=u.images[l.source];let h=a.textureLoader;if(p.uri){const y=a.options.manager.getHandler(p.uri);y!==null&&(h=y)}return a.loadTextureImage(i,l.source,h)}}class fs{constructor(i){this.parser=i,this.name=re.EXT_TEXTURE_AVIF}loadTexture(i){const o=this.name,a=this.parser,u=a.json,c=u.textures[i];if(!c.extensions||!c.extensions[o])return null;const l=c.extensions[o],p=u.images[l.source];let h=a.textureLoader;if(p.uri){const y=a.options.manager.getHandler(p.uri);y!==null&&(h=y)}return a.loadTextureImage(i,l.source,h)}}class hs{constructor(i){this.name=re.EXT_MESHOPT_COMPRESSION,this.parser=i}loadBufferView(i){const o=this.parser.json,a=o.bufferViews[i];if(a.extensions&&a.extensions[this.name]){const u=a.extensions[this.name],c=this.parser.getDependency("buffer",u.buffer),l=this.parser.options.meshoptDecoder;if(!l||!l.supported){if(o.extensionsRequired&&o.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return c.then(function(p){const h=u.byteOffset||0,y=u.byteLength||0,E=u.count,w=u.byteStride,P=new Uint8Array(p,h,y);return l.decodeGltfBufferAsync?l.decodeGltfBufferAsync(E,w,P,u.mode,u.filter).then(function(D){return D.buffer}):l.ready.then(function(){const D=new ArrayBuffer(E*w);return l.decodeGltfBuffer(new Uint8Array(D),E,w,P,u.mode,u.filter),D})})}else return null}}class ds{constructor(i){this.name=re.EXT_MESH_GPU_INSTANCING,this.parser=i}createNodeMesh(i){const o=this.parser.json,a=o.nodes[i];if(!a.extensions||!a.extensions[this.name]||a.mesh===void 0)return null;const u=o.meshes[a.mesh];for(const y of u.primitives)if(y.mode!==Le.TRIANGLES&&y.mode!==Le.TRIANGLE_STRIP&&y.mode!==Le.TRIANGLE_FAN&&y.mode!==void 0)return null;const l=a.extensions[this.name].attributes,p=[],h={};for(const y in l)p.push(this.parser.getDependency("accessor",l[y]).then(E=>(h[y]=E,h[y])));return p.length<1?null:(p.push(this.parser.createNodeMesh(i)),Promise.all(p).then(y=>{const E=y.pop(),w=E.isGroup?E.children:[E],P=y[0].count,D=[];for(const G of w){const W=new T.Matrix4,z=new T.Vector3,Y=new T.Quaternion,ee=new T.Vector3(1,1,1),le=new T.InstancedMesh(G.geometry,G.material,P);for(let $=0;$<P;$++)h.TRANSLATION&&z.fromBufferAttribute(h.TRANSLATION,$),h.ROTATION&&Y.fromBufferAttribute(h.ROTATION,$),h.SCALE&&ee.fromBufferAttribute(h.SCALE,$),le.setMatrixAt($,W.compose(z,Y,ee));for(const $ in h)if($==="_COLOR_0"){const we=h[$];le.instanceColor=new T.InstancedBufferAttribute(we.array,we.itemSize,we.normalized)}else $!=="TRANSLATION"&&$!=="ROTATION"&&$!=="SCALE"&&G.geometry.setAttribute($,h[$]);T.Object3D.prototype.copy.call(le,G),this.parser.assignFinalMaterial(le),D.push(le)}return E.isGroup?(E.clear(),E.add(...D),E):D[0]}))}}const hi="glTF",Vt=12,ti={JSON:1313821514,BIN:5130562};class ps{constructor(i){this.name=re.KHR_BINARY_GLTF,this.content=null,this.body=null;const o=new DataView(i,0,Vt),a=new TextDecoder;if(this.header={magic:a.decode(new Uint8Array(i.slice(0,4))),version:o.getUint32(4,!0),length:o.getUint32(8,!0)},this.header.magic!==hi)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const u=this.header.length-Vt,c=new DataView(i,Vt);let l=0;for(;l<u;){const p=c.getUint32(l,!0);l+=4;const h=c.getUint32(l,!0);if(l+=4,h===ti.JSON){const y=new Uint8Array(i,Vt+l,p);this.content=a.decode(y)}else if(h===ti.BIN){const y=Vt+l;this.body=i.slice(y,y+p)}l+=p}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ms{constructor(i,o){if(!o)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=re.KHR_DRACO_MESH_COMPRESSION,this.json=i,this.dracoLoader=o,this.dracoLoader.preload()}decodePrimitive(i,o){const a=this.json,u=this.dracoLoader,c=i.extensions[this.name].bufferView,l=i.extensions[this.name].attributes,p={},h={},y={};for(const E in l){const w=yr[E]||E.toLowerCase();p[w]=l[E]}for(const E in i.attributes){const w=yr[E]||E.toLowerCase();if(l[E]!==void 0){const P=a.accessors[i.attributes[E]],D=Ot[P.componentType];y[w]=D.name,h[w]=P.normalized===!0}}return o.getDependency("bufferView",c).then(function(E){return new Promise(function(w,P){u.decodeDracoFile(E,function(D){for(const G in D.attributes){const W=D.attributes[G],z=h[G];z!==void 0&&(W.normalized=z)}w(D)},p,y,T.LinearSRGBColorSpace,P)})})}}class ys{constructor(){this.name=re.KHR_TEXTURE_TRANSFORM}extendTexture(i,o){return(o.texCoord===void 0||o.texCoord===i.channel)&&o.offset===void 0&&o.rotation===void 0&&o.scale===void 0||(i=i.clone(),o.texCoord!==void 0&&(i.channel=o.texCoord),o.offset!==void 0&&i.offset.fromArray(o.offset),o.rotation!==void 0&&(i.rotation=o.rotation),o.scale!==void 0&&i.repeat.fromArray(o.scale),i.needsUpdate=!0),i}}class gs{constructor(){this.name=re.KHR_MESH_QUANTIZATION}}class di extends T.Interpolant{constructor(i,o,a,u){super(i,o,a,u)}copySampleValue_(i){const o=this.resultBuffer,a=this.sampleValues,u=this.valueSize,c=i*u*3+u;for(let l=0;l!==u;l++)o[l]=a[c+l];return o}interpolate_(i,o,a,u){const c=this.resultBuffer,l=this.sampleValues,p=this.valueSize,h=p*2,y=p*3,E=u-o,w=(a-o)/E,P=w*w,D=P*w,G=i*y,W=G-y,z=-2*D+3*P,Y=D-P,ee=1-z,le=Y-P+w;for(let $=0;$!==p;$++){const we=l[W+$+p],ve=l[W+$+h]*E,ue=l[G+$+p],Ie=l[G+$]*E;c[$]=ee*we+le*ve+z*ue+Y*Ie}return c}}const vs=new T.Quaternion;class bs extends di{interpolate_(i,o,a,u){const c=super.interpolate_(i,o,a,u);return vs.fromArray(c).normalize().toArray(c),c}}const Le={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ot={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ni={9728:T.NearestFilter,9729:T.LinearFilter,9984:T.NearestMipmapNearestFilter,9985:T.LinearMipmapNearestFilter,9986:T.NearestMipmapLinearFilter,9987:T.LinearMipmapLinearFilter},ri={33071:T.ClampToEdgeWrapping,33648:T.MirroredRepeatWrapping,10497:T.RepeatWrapping},dr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yr={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},st={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ws={CUBICSPLINE:void 0,LINEAR:T.InterpolateLinear,STEP:T.InterpolateDiscrete},pr={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function _s(L){return L.DefaultMaterial===void 0&&(L.DefaultMaterial=new T.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:T.FrontSide})),L.DefaultMaterial}function vt(L,i,o){for(const a in o.extensions)L[a]===void 0&&(i.userData.gltfExtensions=i.userData.gltfExtensions||{},i.userData.gltfExtensions[a]=o.extensions[a])}function We(L,i){i.extras!==void 0&&(typeof i.extras=="object"?Object.assign(L.userData,i.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+i.extras))}function xs(L,i,o){let a=!1,u=!1,c=!1;for(let y=0,E=i.length;y<E;y++){const w=i[y];if(w.POSITION!==void 0&&(a=!0),w.NORMAL!==void 0&&(u=!0),w.COLOR_0!==void 0&&(c=!0),a&&u&&c)break}if(!a&&!u&&!c)return Promise.resolve(L);const l=[],p=[],h=[];for(let y=0,E=i.length;y<E;y++){const w=i[y];if(a){const P=w.POSITION!==void 0?o.getDependency("accessor",w.POSITION):L.attributes.position;l.push(P)}if(u){const P=w.NORMAL!==void 0?o.getDependency("accessor",w.NORMAL):L.attributes.normal;p.push(P)}if(c){const P=w.COLOR_0!==void 0?o.getDependency("accessor",w.COLOR_0):L.attributes.color;h.push(P)}}return Promise.all([Promise.all(l),Promise.all(p),Promise.all(h)]).then(function(y){const E=y[0],w=y[1],P=y[2];return a&&(L.morphAttributes.position=E),u&&(L.morphAttributes.normal=w),c&&(L.morphAttributes.color=P),L.morphTargetsRelative=!0,L})}function Ts(L,i){if(L.updateMorphTargets(),i.weights!==void 0)for(let o=0,a=i.weights.length;o<a;o++)L.morphTargetInfluences[o]=i.weights[o];if(i.extras&&Array.isArray(i.extras.targetNames)){const o=i.extras.targetNames;if(L.morphTargetInfluences.length===o.length){L.morphTargetDictionary={};for(let a=0,u=o.length;a<u;a++)L.morphTargetDictionary[o[a]]=a}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ss(L){let i;const o=L.extensions&&L.extensions[re.KHR_DRACO_MESH_COMPRESSION];if(o?i="draco:"+o.bufferView+":"+o.indices+":"+mr(o.attributes):i=L.indices+":"+mr(L.attributes)+":"+L.mode,L.targets!==void 0)for(let a=0,u=L.targets.length;a<u;a++)i+=":"+mr(L.targets[a]);return i}function mr(L){let i="";const o=Object.keys(L).sort();for(let a=0,u=o.length;a<u;a++)i+=o[a]+":"+L[o[a]]+";";return i}function gr(L){switch(L){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Es(L){return L.search(/\.jpe?g($|\?)/i)>0||L.search(/^data\:image\/jpeg/)===0?"image/jpeg":L.search(/\.webp($|\?)/i)>0||L.search(/^data\:image\/webp/)===0?"image/webp":L.search(/\.ktx2($|\?)/i)>0||L.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Rs=new T.Matrix4;class As{constructor(i={},o={}){this.json=i,this.extensions={},this.plugins={},this.options=o,this.cache=new Yi,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let a=!1,u=-1,c=!1,l=-1;if(typeof navigator<"u"){const p=navigator.userAgent;a=/^((?!chrome|android).)*safari/i.test(p)===!0;const h=p.match(/Version\/(\d+)/);u=a&&h?parseInt(h[1],10):-1,c=p.indexOf("Firefox")>-1,l=c?p.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||a&&u<17||c&&l<98?this.textureLoader=new T.TextureLoader(this.options.manager):this.textureLoader=new T.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new T.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(i){this.extensions=i}setPlugins(i){this.plugins=i}parse(i,o){const a=this,u=this.json,c=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(l){return l._markDefs&&l._markDefs()}),Promise.all(this._invokeAll(function(l){return l.beforeRoot&&l.beforeRoot()})).then(function(){return Promise.all([a.getDependencies("scene"),a.getDependencies("animation"),a.getDependencies("camera")])}).then(function(l){const p={scene:l[0][u.scene||0],scenes:l[0],animations:l[1],cameras:l[2],asset:u.asset,parser:a,userData:{}};return vt(c,p,u),We(p,u),Promise.all(a._invokeAll(function(h){return h.afterRoot&&h.afterRoot(p)})).then(function(){for(const h of p.scenes)h.updateMatrixWorld();i(p)})}).catch(o)}_markDefs(){const i=this.json.nodes||[],o=this.json.skins||[],a=this.json.meshes||[];for(let u=0,c=o.length;u<c;u++){const l=o[u].joints;for(let p=0,h=l.length;p<h;p++)i[l[p]].isBone=!0}for(let u=0,c=i.length;u<c;u++){const l=i[u];l.mesh!==void 0&&(this._addNodeRef(this.meshCache,l.mesh),l.skin!==void 0&&(a[l.mesh].isSkinnedMesh=!0)),l.camera!==void 0&&this._addNodeRef(this.cameraCache,l.camera)}}_addNodeRef(i,o){o!==void 0&&(i.refs[o]===void 0&&(i.refs[o]=i.uses[o]=0),i.refs[o]++)}_getNodeRef(i,o,a){if(i.refs[o]<=1)return a;const u=a.clone(),c=(l,p)=>{const h=this.associations.get(l);h!=null&&this.associations.set(p,h);for(const[y,E]of l.children.entries())c(E,p.children[y])};return c(a,u),u.name+="_instance_"+i.uses[o]++,u}_invokeOne(i){const o=Object.values(this.plugins);o.push(this);for(let a=0;a<o.length;a++){const u=i(o[a]);if(u)return u}return null}_invokeAll(i){const o=Object.values(this.plugins);o.unshift(this);const a=[];for(let u=0;u<o.length;u++){const c=i(o[u]);c&&a.push(c)}return a}getDependency(i,o){const a=i+":"+o;let u=this.cache.get(a);if(!u){switch(i){case"scene":u=this.loadScene(o);break;case"node":u=this._invokeOne(function(c){return c.loadNode&&c.loadNode(o)});break;case"mesh":u=this._invokeOne(function(c){return c.loadMesh&&c.loadMesh(o)});break;case"accessor":u=this.loadAccessor(o);break;case"bufferView":u=this._invokeOne(function(c){return c.loadBufferView&&c.loadBufferView(o)});break;case"buffer":u=this.loadBuffer(o);break;case"material":u=this._invokeOne(function(c){return c.loadMaterial&&c.loadMaterial(o)});break;case"texture":u=this._invokeOne(function(c){return c.loadTexture&&c.loadTexture(o)});break;case"skin":u=this.loadSkin(o);break;case"animation":u=this._invokeOne(function(c){return c.loadAnimation&&c.loadAnimation(o)});break;case"camera":u=this.loadCamera(o);break;default:if(u=this._invokeOne(function(c){return c!=this&&c.getDependency&&c.getDependency(i,o)}),!u)throw new Error("Unknown type: "+i);break}this.cache.add(a,u)}return u}getDependencies(i){let o=this.cache.get(i);if(!o){const a=this,u=this.json[i+(i==="mesh"?"es":"s")]||[];o=Promise.all(u.map(function(c,l){return a.getDependency(i,l)})),this.cache.add(i,o)}return o}loadBuffer(i){const o=this.json.buffers[i],a=this.fileLoader;if(o.type&&o.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+o.type+" buffer type is not supported.");if(o.uri===void 0&&i===0)return Promise.resolve(this.extensions[re.KHR_BINARY_GLTF].body);const u=this.options;return new Promise(function(c,l){a.load(T.LoaderUtils.resolveURL(o.uri,u.path),c,void 0,function(){l(new Error('THREE.GLTFLoader: Failed to load buffer "'+o.uri+'".'))})})}loadBufferView(i){const o=this.json.bufferViews[i];return this.getDependency("buffer",o.buffer).then(function(a){const u=o.byteLength||0,c=o.byteOffset||0;return a.slice(c,c+u)})}loadAccessor(i){const o=this,a=this.json,u=this.json.accessors[i];if(u.bufferView===void 0&&u.sparse===void 0){const l=dr[u.type],p=Ot[u.componentType],h=u.normalized===!0,y=new p(u.count*l);return Promise.resolve(new T.BufferAttribute(y,l,h))}const c=[];return u.bufferView!==void 0?c.push(this.getDependency("bufferView",u.bufferView)):c.push(null),u.sparse!==void 0&&(c.push(this.getDependency("bufferView",u.sparse.indices.bufferView)),c.push(this.getDependency("bufferView",u.sparse.values.bufferView))),Promise.all(c).then(function(l){const p=l[0],h=dr[u.type],y=Ot[u.componentType],E=y.BYTES_PER_ELEMENT,w=E*h,P=u.byteOffset||0,D=u.bufferView!==void 0?a.bufferViews[u.bufferView].byteStride:void 0,G=u.normalized===!0;let W,z;if(D&&D!==w){const Y=Math.floor(P/D),ee="InterleavedBuffer:"+u.bufferView+":"+u.componentType+":"+Y+":"+u.count;let le=o.cache.get(ee);le||(W=new y(p,Y*D,u.count*D/E),le=new T.InterleavedBuffer(W,D/E),o.cache.add(ee,le)),z=new T.InterleavedBufferAttribute(le,h,P%D/E,G)}else p===null?W=new y(u.count*h):W=new y(p,P,u.count*h),z=new T.BufferAttribute(W,h,G);if(u.sparse!==void 0){const Y=dr.SCALAR,ee=Ot[u.sparse.indices.componentType],le=u.sparse.indices.byteOffset||0,$=u.sparse.values.byteOffset||0,we=new ee(l[1],le,u.sparse.count*Y),ve=new y(l[2],$,u.sparse.count*h);p!==null&&(z=new T.BufferAttribute(z.array.slice(),z.itemSize,z.normalized)),z.normalized=!1;for(let ue=0,Ie=we.length;ue<Ie;ue++){const Oe=we[ue];if(z.setX(Oe,ve[ue*h]),h>=2&&z.setY(Oe,ve[ue*h+1]),h>=3&&z.setZ(Oe,ve[ue*h+2]),h>=4&&z.setW(Oe,ve[ue*h+3]),h>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}z.normalized=G}return z})}loadTexture(i){const o=this.json,a=this.options,c=o.textures[i].source,l=o.images[c];let p=this.textureLoader;if(l.uri){const h=a.manager.getHandler(l.uri);h!==null&&(p=h)}return this.loadTextureImage(i,c,p)}loadTextureImage(i,o,a){const u=this,c=this.json,l=c.textures[i],p=c.images[o],h=(p.uri||p.bufferView)+":"+l.sampler;if(this.textureCache[h])return this.textureCache[h];const y=this.loadImageSource(o,a).then(function(E){E.flipY=!1,E.name=l.name||p.name||"",E.name===""&&typeof p.uri=="string"&&p.uri.startsWith("data:image/")===!1&&(E.name=p.uri);const P=(c.samplers||{})[l.sampler]||{};return E.magFilter=ni[P.magFilter]||T.LinearFilter,E.minFilter=ni[P.minFilter]||T.LinearMipmapLinearFilter,E.wrapS=ri[P.wrapS]||T.RepeatWrapping,E.wrapT=ri[P.wrapT]||T.RepeatWrapping,E.generateMipmaps=!E.isCompressedTexture&&E.minFilter!==T.NearestFilter&&E.minFilter!==T.LinearFilter,u.associations.set(E,{textures:i}),E}).catch(function(){return null});return this.textureCache[h]=y,y}loadImageSource(i,o){const a=this,u=this.json,c=this.options;if(this.sourceCache[i]!==void 0)return this.sourceCache[i].then(w=>w.clone());const l=u.images[i],p=self.URL||self.webkitURL;let h=l.uri||"",y=!1;if(l.bufferView!==void 0)h=a.getDependency("bufferView",l.bufferView).then(function(w){y=!0;const P=new Blob([w],{type:l.mimeType});return h=p.createObjectURL(P),h});else if(l.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+i+" is missing URI and bufferView");const E=Promise.resolve(h).then(function(w){return new Promise(function(P,D){let G=P;o.isImageBitmapLoader===!0&&(G=function(W){const z=new T.Texture(W);z.needsUpdate=!0,P(z)}),o.load(T.LoaderUtils.resolveURL(w,c.path),G,void 0,D)})}).then(function(w){return y===!0&&p.revokeObjectURL(h),We(w,l),w.userData.mimeType=l.mimeType||Es(l.uri),w}).catch(function(w){throw console.error("THREE.GLTFLoader: Couldn't load texture",h),w});return this.sourceCache[i]=E,E}assignTexture(i,o,a,u){const c=this;return this.getDependency("texture",a.index).then(function(l){if(!l)return null;if(a.texCoord!==void 0&&a.texCoord>0&&(l=l.clone(),l.channel=a.texCoord),c.extensions[re.KHR_TEXTURE_TRANSFORM]){const p=a.extensions!==void 0?a.extensions[re.KHR_TEXTURE_TRANSFORM]:void 0;if(p){const h=c.associations.get(l);l=c.extensions[re.KHR_TEXTURE_TRANSFORM].extendTexture(l,p),c.associations.set(l,h)}}return u!==void 0&&(l.colorSpace=u),i[o]=l,l})}assignFinalMaterial(i){const o=i.geometry;let a=i.material;const u=o.attributes.tangent===void 0,c=o.attributes.color!==void 0,l=o.attributes.normal===void 0;if(i.isPoints){const p="PointsMaterial:"+a.uuid;let h=this.cache.get(p);h||(h=new T.PointsMaterial,T.Material.prototype.copy.call(h,a),h.color.copy(a.color),h.map=a.map,h.sizeAttenuation=!1,this.cache.add(p,h)),a=h}else if(i.isLine){const p="LineBasicMaterial:"+a.uuid;let h=this.cache.get(p);h||(h=new T.LineBasicMaterial,T.Material.prototype.copy.call(h,a),h.color.copy(a.color),h.map=a.map,this.cache.add(p,h)),a=h}if(u||c||l){let p="ClonedMaterial:"+a.uuid+":";u&&(p+="derivative-tangents:"),c&&(p+="vertex-colors:"),l&&(p+="flat-shading:");let h=this.cache.get(p);h||(h=a.clone(),c&&(h.vertexColors=!0),l&&(h.flatShading=!0),u&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),this.cache.add(p,h),this.associations.set(h,this.associations.get(a))),a=h}i.material=a}getMaterialType(){return T.MeshStandardMaterial}loadMaterial(i){const o=this,a=this.json,u=this.extensions,c=a.materials[i];let l;const p={},h=c.extensions||{},y=[];if(h[re.KHR_MATERIALS_UNLIT]){const w=u[re.KHR_MATERIALS_UNLIT];l=w.getMaterialType(),y.push(w.extendParams(p,c,o))}else{const w=c.pbrMetallicRoughness||{};if(p.color=new T.Color(1,1,1),p.opacity=1,Array.isArray(w.baseColorFactor)){const P=w.baseColorFactor;p.color.setRGB(P[0],P[1],P[2],T.LinearSRGBColorSpace),p.opacity=P[3]}w.baseColorTexture!==void 0&&y.push(o.assignTexture(p,"map",w.baseColorTexture,T.SRGBColorSpace)),p.metalness=w.metallicFactor!==void 0?w.metallicFactor:1,p.roughness=w.roughnessFactor!==void 0?w.roughnessFactor:1,w.metallicRoughnessTexture!==void 0&&(y.push(o.assignTexture(p,"metalnessMap",w.metallicRoughnessTexture)),y.push(o.assignTexture(p,"roughnessMap",w.metallicRoughnessTexture))),l=this._invokeOne(function(P){return P.getMaterialType&&P.getMaterialType(i)}),y.push(Promise.all(this._invokeAll(function(P){return P.extendMaterialParams&&P.extendMaterialParams(i,p)})))}c.doubleSided===!0&&(p.side=T.DoubleSide);const E=c.alphaMode||pr.OPAQUE;if(E===pr.BLEND?(p.transparent=!0,p.depthWrite=!1):(p.transparent=!1,E===pr.MASK&&(p.alphaTest=c.alphaCutoff!==void 0?c.alphaCutoff:.5)),c.normalTexture!==void 0&&l!==T.MeshBasicMaterial&&(y.push(o.assignTexture(p,"normalMap",c.normalTexture)),p.normalScale=new T.Vector2(1,1),c.normalTexture.scale!==void 0)){const w=c.normalTexture.scale;p.normalScale.set(w,w)}if(c.occlusionTexture!==void 0&&l!==T.MeshBasicMaterial&&(y.push(o.assignTexture(p,"aoMap",c.occlusionTexture)),c.occlusionTexture.strength!==void 0&&(p.aoMapIntensity=c.occlusionTexture.strength)),c.emissiveFactor!==void 0&&l!==T.MeshBasicMaterial){const w=c.emissiveFactor;p.emissive=new T.Color().setRGB(w[0],w[1],w[2],T.LinearSRGBColorSpace)}return c.emissiveTexture!==void 0&&l!==T.MeshBasicMaterial&&y.push(o.assignTexture(p,"emissiveMap",c.emissiveTexture,T.SRGBColorSpace)),Promise.all(y).then(function(){const w=new l(p);return c.name&&(w.name=c.name),We(w,c),o.associations.set(w,{materials:i}),c.extensions&&vt(u,w,c),w})}createUniqueName(i){const o=T.PropertyBinding.sanitizeNodeName(i||"");return o in this.nodeNamesUsed?o+"_"+ ++this.nodeNamesUsed[o]:(this.nodeNamesUsed[o]=0,o)}loadGeometries(i){const o=this,a=this.extensions,u=this.primitiveCache;function c(p){return a[re.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(p,o).then(function(h){return ii(h,p,o)})}const l=[];for(let p=0,h=i.length;p<h;p++){const y=i[p],E=Ss(y),w=u[E];if(w)l.push(w.promise);else{let P;y.extensions&&y.extensions[re.KHR_DRACO_MESH_COMPRESSION]?P=c(y):P=ii(new T.BufferGeometry,y,o),u[E]={primitive:y,promise:P},l.push(P)}}return Promise.all(l)}loadMesh(i){const o=this,a=this.json,u=this.extensions,c=a.meshes[i],l=c.primitives,p=[];for(let h=0,y=l.length;h<y;h++){const E=l[h].material===void 0?_s(this.cache):this.getDependency("material",l[h].material);p.push(E)}return p.push(o.loadGeometries(l)),Promise.all(p).then(function(h){const y=h.slice(0,h.length-1),E=h[h.length-1],w=[];for(let D=0,G=E.length;D<G;D++){const W=E[D],z=l[D];let Y;const ee=y[D];if(z.mode===Le.TRIANGLES||z.mode===Le.TRIANGLE_STRIP||z.mode===Le.TRIANGLE_FAN||z.mode===void 0)Y=c.isSkinnedMesh===!0?new T.SkinnedMesh(W,ee):new T.Mesh(W,ee),Y.isSkinnedMesh===!0&&Y.normalizeSkinWeights(),z.mode===Le.TRIANGLE_STRIP?Y.geometry=ei(Y.geometry,T.TriangleStripDrawMode):z.mode===Le.TRIANGLE_FAN&&(Y.geometry=ei(Y.geometry,T.TriangleFanDrawMode));else if(z.mode===Le.LINES)Y=new T.LineSegments(W,ee);else if(z.mode===Le.LINE_STRIP)Y=new T.Line(W,ee);else if(z.mode===Le.LINE_LOOP)Y=new T.LineLoop(W,ee);else if(z.mode===Le.POINTS)Y=new T.Points(W,ee);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+z.mode);Object.keys(Y.geometry.morphAttributes).length>0&&Ts(Y,c),Y.name=o.createUniqueName(c.name||"mesh_"+i),We(Y,c),z.extensions&&vt(u,Y,z),o.assignFinalMaterial(Y),w.push(Y)}for(let D=0,G=w.length;D<G;D++)o.associations.set(w[D],{meshes:i,primitives:D});if(w.length===1)return c.extensions&&vt(u,w[0],c),w[0];const P=new T.Group;c.extensions&&vt(u,P,c),o.associations.set(P,{meshes:i});for(let D=0,G=w.length;D<G;D++)P.add(w[D]);return P})}loadCamera(i){let o;const a=this.json.cameras[i],u=a[a.type];if(!u){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return a.type==="perspective"?o=new T.PerspectiveCamera(T.MathUtils.radToDeg(u.yfov),u.aspectRatio||1,u.znear||1,u.zfar||2e6):a.type==="orthographic"&&(o=new T.OrthographicCamera(-u.xmag,u.xmag,u.ymag,-u.ymag,u.znear,u.zfar)),a.name&&(o.name=this.createUniqueName(a.name)),We(o,a),Promise.resolve(o)}loadSkin(i){const o=this.json.skins[i],a=[];for(let u=0,c=o.joints.length;u<c;u++)a.push(this._loadNodeShallow(o.joints[u]));return o.inverseBindMatrices!==void 0?a.push(this.getDependency("accessor",o.inverseBindMatrices)):a.push(null),Promise.all(a).then(function(u){const c=u.pop(),l=u,p=[],h=[];for(let y=0,E=l.length;y<E;y++){const w=l[y];if(w){p.push(w);const P=new T.Matrix4;c!==null&&P.fromArray(c.array,y*16),h.push(P)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',o.joints[y])}return new T.Skeleton(p,h)})}loadAnimation(i){const o=this.json,a=this,u=o.animations[i],c=u.name?u.name:"animation_"+i,l=[],p=[],h=[],y=[],E=[];for(let w=0,P=u.channels.length;w<P;w++){const D=u.channels[w],G=u.samplers[D.sampler],W=D.target,z=W.node,Y=u.parameters!==void 0?u.parameters[G.input]:G.input,ee=u.parameters!==void 0?u.parameters[G.output]:G.output;W.node!==void 0&&(l.push(this.getDependency("node",z)),p.push(this.getDependency("accessor",Y)),h.push(this.getDependency("accessor",ee)),y.push(G),E.push(W))}return Promise.all([Promise.all(l),Promise.all(p),Promise.all(h),Promise.all(y),Promise.all(E)]).then(function(w){const P=w[0],D=w[1],G=w[2],W=w[3],z=w[4],Y=[];for(let ee=0,le=P.length;ee<le;ee++){const $=P[ee],we=D[ee],ve=G[ee],ue=W[ee],Ie=z[ee];if($===void 0)continue;$.updateMatrix&&$.updateMatrix();const Oe=a._createAnimationTracks($,we,ve,ue,Ie);if(Oe)for(let Ye=0;Ye<Oe.length;Ye++)Y.push(Oe[Ye])}return new T.AnimationClip(c,void 0,Y)})}createNodeMesh(i){const o=this.json,a=this,u=o.nodes[i];return u.mesh===void 0?null:a.getDependency("mesh",u.mesh).then(function(c){const l=a._getNodeRef(a.meshCache,u.mesh,c);return u.weights!==void 0&&l.traverse(function(p){if(p.isMesh)for(let h=0,y=u.weights.length;h<y;h++)p.morphTargetInfluences[h]=u.weights[h]}),l})}loadNode(i){const o=this.json,a=this,u=o.nodes[i],c=a._loadNodeShallow(i),l=[],p=u.children||[];for(let y=0,E=p.length;y<E;y++)l.push(a.getDependency("node",p[y]));const h=u.skin===void 0?Promise.resolve(null):a.getDependency("skin",u.skin);return Promise.all([c,Promise.all(l),h]).then(function(y){const E=y[0],w=y[1],P=y[2];P!==null&&E.traverse(function(D){D.isSkinnedMesh&&D.bind(P,Rs)});for(let D=0,G=w.length;D<G;D++)E.add(w[D]);return E})}_loadNodeShallow(i){const o=this.json,a=this.extensions,u=this;if(this.nodeCache[i]!==void 0)return this.nodeCache[i];const c=o.nodes[i],l=c.name?u.createUniqueName(c.name):"",p=[],h=u._invokeOne(function(y){return y.createNodeMesh&&y.createNodeMesh(i)});return h&&p.push(h),c.camera!==void 0&&p.push(u.getDependency("camera",c.camera).then(function(y){return u._getNodeRef(u.cameraCache,c.camera,y)})),u._invokeAll(function(y){return y.createNodeAttachment&&y.createNodeAttachment(i)}).forEach(function(y){p.push(y)}),this.nodeCache[i]=Promise.all(p).then(function(y){let E;if(c.isBone===!0?E=new T.Bone:y.length>1?E=new T.Group:y.length===1?E=y[0]:E=new T.Object3D,E!==y[0])for(let w=0,P=y.length;w<P;w++)E.add(y[w]);if(c.name&&(E.userData.name=c.name,E.name=l),We(E,c),c.extensions&&vt(a,E,c),c.matrix!==void 0){const w=new T.Matrix4;w.fromArray(c.matrix),E.applyMatrix4(w)}else c.translation!==void 0&&E.position.fromArray(c.translation),c.rotation!==void 0&&E.quaternion.fromArray(c.rotation),c.scale!==void 0&&E.scale.fromArray(c.scale);if(!u.associations.has(E))u.associations.set(E,{});else if(c.mesh!==void 0&&u.meshCache.refs[c.mesh]>1){const w=u.associations.get(E);u.associations.set(E,{...w})}return u.associations.get(E).nodes=i,E}),this.nodeCache[i]}loadScene(i){const o=this.extensions,a=this.json.scenes[i],u=this,c=new T.Group;a.name&&(c.name=u.createUniqueName(a.name)),We(c,a),a.extensions&&vt(o,c,a);const l=a.nodes||[],p=[];for(let h=0,y=l.length;h<y;h++)p.push(u.getDependency("node",l[h]));return Promise.all(p).then(function(h){for(let E=0,w=h.length;E<w;E++)c.add(h[E]);const y=E=>{const w=new Map;for(const[P,D]of u.associations)(P instanceof T.Material||P instanceof T.Texture)&&w.set(P,D);return E.traverse(P=>{const D=u.associations.get(P);D!=null&&w.set(P,D)}),w};return u.associations=y(c),c})}_createAnimationTracks(i,o,a,u,c){const l=[],p=i.name?i.name:i.uuid,h=[];st[c.path]===st.weights?i.traverse(function(P){P.morphTargetInfluences&&h.push(P.name?P.name:P.uuid)}):h.push(p);let y;switch(st[c.path]){case st.weights:y=T.NumberKeyframeTrack;break;case st.rotation:y=T.QuaternionKeyframeTrack;break;case st.translation:case st.scale:y=T.VectorKeyframeTrack;break;default:switch(a.itemSize){case 1:y=T.NumberKeyframeTrack;break;case 2:case 3:default:y=T.VectorKeyframeTrack;break}break}const E=u.interpolation!==void 0?ws[u.interpolation]:T.InterpolateLinear,w=this._getArrayFromAccessor(a);for(let P=0,D=h.length;P<D;P++){const G=new y(h[P]+"."+st[c.path],o.array,w,E);u.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(G),l.push(G)}return l}_getArrayFromAccessor(i){let o=i.array;if(i.normalized){const a=gr(o.constructor),u=new Float32Array(o.length);for(let c=0,l=o.length;c<l;c++)u[c]=o[c]*a;o=u}return o}_createCubicSplineTrackInterpolant(i){i.createInterpolant=function(a){const u=this instanceof T.QuaternionKeyframeTrack?bs:di;return new u(this.times,this.values,this.getValueSize()/3,a)},i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ks(L,i,o){const a=i.attributes,u=new T.Box3;if(a.POSITION!==void 0){const p=o.json.accessors[a.POSITION],h=p.min,y=p.max;if(h!==void 0&&y!==void 0){if(u.set(new T.Vector3(h[0],h[1],h[2]),new T.Vector3(y[0],y[1],y[2])),p.normalized){const E=gr(Ot[p.componentType]);u.min.multiplyScalar(E),u.max.multiplyScalar(E)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const c=i.targets;if(c!==void 0){const p=new T.Vector3,h=new T.Vector3;for(let y=0,E=c.length;y<E;y++){const w=c[y];if(w.POSITION!==void 0){const P=o.json.accessors[w.POSITION],D=P.min,G=P.max;if(D!==void 0&&G!==void 0){if(h.setX(Math.max(Math.abs(D[0]),Math.abs(G[0]))),h.setY(Math.max(Math.abs(D[1]),Math.abs(G[1]))),h.setZ(Math.max(Math.abs(D[2]),Math.abs(G[2]))),P.normalized){const W=gr(Ot[P.componentType]);h.multiplyScalar(W)}p.max(h)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}u.expandByVector(p)}L.boundingBox=u;const l=new T.Sphere;u.getCenter(l.center),l.radius=u.min.distanceTo(u.max)/2,L.boundingSphere=l}function ii(L,i,o){const a=i.attributes,u=[];function c(l,p){return o.getDependency("accessor",l).then(function(h){L.setAttribute(p,h)})}for(const l in a){const p=yr[l]||l.toLowerCase();p in L.attributes||u.push(c(a[l],p))}if(i.indices!==void 0&&!L.index){const l=o.getDependency("accessor",i.indices).then(function(p){L.setIndex(p)});u.push(l)}return T.ColorManagement.workingColorSpace!==T.LinearSRGBColorSpace&&"COLOR_0"in a&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${T.ColorManagement.workingColorSpace}" not supported.`),We(L,i),ks(L,i,o),Promise.all(u).then(function(){return i.targets!==void 0?xs(L,i.targets,o):L})}const se={c:null,u:[new T.Vector3,new T.Vector3,new T.Vector3],e:[]},ae={c:null,u:[new T.Vector3,new T.Vector3,new T.Vector3],e:[]},pe=[[],[],[]],J=[[],[],[]],he=[],bt=new T.Vector3,wt=new T.Vector3,_t=new T.Vector3,be=new T.Vector3,si=new T.Vector3,oi=new T.Vector3,De=new T.Matrix3,ai=new T.Box3,En=new T.Matrix4,ui=new T.Matrix4,ci=new T.Ray;class vr{constructor(i=new T.Vector3,o=new T.Vector3,a=new T.Matrix3){this.center=i,this.halfSize=o,this.rotation=a}set(i,o,a){return this.center=i,this.halfSize=o,this.rotation=a,this}copy(i){return this.center.copy(i.center),this.halfSize.copy(i.halfSize),this.rotation.copy(i.rotation),this}clone(){return new this.constructor().copy(this)}getSize(i){return i.copy(this.halfSize).multiplyScalar(2)}clampPoint(i,o){const a=this.halfSize;be.subVectors(i,this.center),this.rotation.extractBasis(bt,wt,_t),o.copy(this.center);const u=T.MathUtils.clamp(be.dot(bt),-a.x,a.x);o.add(bt.multiplyScalar(u));const c=T.MathUtils.clamp(be.dot(wt),-a.y,a.y);o.add(wt.multiplyScalar(c));const l=T.MathUtils.clamp(be.dot(_t),-a.z,a.z);return o.add(_t.multiplyScalar(l)),o}containsPoint(i){return be.subVectors(i,this.center),this.rotation.extractBasis(bt,wt,_t),Math.abs(be.dot(bt))<=this.halfSize.x&&Math.abs(be.dot(wt))<=this.halfSize.y&&Math.abs(be.dot(_t))<=this.halfSize.z}intersectsBox3(i){return this.intersectsOBB(Ms.fromBox3(i))}intersectsSphere(i){return this.clampPoint(i.center,oi),oi.distanceToSquared(i.center)<=i.radius*i.radius}intersectsOBB(i,o=Number.EPSILON){se.c=this.center,se.e[0]=this.halfSize.x,se.e[1]=this.halfSize.y,se.e[2]=this.halfSize.z,this.rotation.extractBasis(se.u[0],se.u[1],se.u[2]),ae.c=i.center,ae.e[0]=i.halfSize.x,ae.e[1]=i.halfSize.y,ae.e[2]=i.halfSize.z,i.rotation.extractBasis(ae.u[0],ae.u[1],ae.u[2]);for(let c=0;c<3;c++)for(let l=0;l<3;l++)pe[c][l]=se.u[c].dot(ae.u[l]);be.subVectors(ae.c,se.c),he[0]=be.dot(se.u[0]),he[1]=be.dot(se.u[1]),he[2]=be.dot(se.u[2]);for(let c=0;c<3;c++)for(let l=0;l<3;l++)J[c][l]=Math.abs(pe[c][l])+o;let a,u;for(let c=0;c<3;c++)if(a=se.e[c],u=ae.e[0]*J[c][0]+ae.e[1]*J[c][1]+ae.e[2]*J[c][2],Math.abs(he[c])>a+u)return!1;for(let c=0;c<3;c++)if(a=se.e[0]*J[0][c]+se.e[1]*J[1][c]+se.e[2]*J[2][c],u=ae.e[c],Math.abs(he[0]*pe[0][c]+he[1]*pe[1][c]+he[2]*pe[2][c])>a+u)return!1;return a=se.e[1]*J[2][0]+se.e[2]*J[1][0],u=ae.e[1]*J[0][2]+ae.e[2]*J[0][1],!(Math.abs(he[2]*pe[1][0]-he[1]*pe[2][0])>a+u||(a=se.e[1]*J[2][1]+se.e[2]*J[1][1],u=ae.e[0]*J[0][2]+ae.e[2]*J[0][0],Math.abs(he[2]*pe[1][1]-he[1]*pe[2][1])>a+u)||(a=se.e[1]*J[2][2]+se.e[2]*J[1][2],u=ae.e[0]*J[0][1]+ae.e[1]*J[0][0],Math.abs(he[2]*pe[1][2]-he[1]*pe[2][2])>a+u)||(a=se.e[0]*J[2][0]+se.e[2]*J[0][0],u=ae.e[1]*J[1][2]+ae.e[2]*J[1][1],Math.abs(he[0]*pe[2][0]-he[2]*pe[0][0])>a+u)||(a=se.e[0]*J[2][1]+se.e[2]*J[0][1],u=ae.e[0]*J[1][2]+ae.e[2]*J[1][0],Math.abs(he[0]*pe[2][1]-he[2]*pe[0][1])>a+u)||(a=se.e[0]*J[2][2]+se.e[2]*J[0][2],u=ae.e[0]*J[1][1]+ae.e[1]*J[1][0],Math.abs(he[0]*pe[2][2]-he[2]*pe[0][2])>a+u)||(a=se.e[0]*J[1][0]+se.e[1]*J[0][0],u=ae.e[1]*J[2][2]+ae.e[2]*J[2][1],Math.abs(he[1]*pe[0][0]-he[0]*pe[1][0])>a+u)||(a=se.e[0]*J[1][1]+se.e[1]*J[0][1],u=ae.e[0]*J[2][2]+ae.e[2]*J[2][0],Math.abs(he[1]*pe[0][1]-he[0]*pe[1][1])>a+u)||(a=se.e[0]*J[1][2]+se.e[1]*J[0][2],u=ae.e[0]*J[2][1]+ae.e[1]*J[2][0],Math.abs(he[1]*pe[0][2]-he[0]*pe[1][2])>a+u))}intersectsPlane(i){this.rotation.extractBasis(bt,wt,_t);const o=this.halfSize.x*Math.abs(i.normal.dot(bt))+this.halfSize.y*Math.abs(i.normal.dot(wt))+this.halfSize.z*Math.abs(i.normal.dot(_t)),a=i.normal.dot(this.center)-i.constant;return Math.abs(a)<=o}intersectRay(i,o){return this.getSize(si),ai.setFromCenterAndSize(be.set(0,0,0),si),En.setFromMatrix3(this.rotation),En.setPosition(this.center),ui.copy(En).invert(),ci.copy(i).applyMatrix4(ui),ci.intersectBox(ai,o)?o.applyMatrix4(En):null}intersectsRay(i){return this.intersectRay(i,be)!==null}fromBox3(i){return i.getCenter(this.center),i.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(i){return i.center.equals(this.center)&&i.halfSize.equals(this.halfSize)&&i.rotation.equals(this.rotation)}applyMatrix4(i){const o=i.elements;let a=be.set(o[0],o[1],o[2]).length();const u=be.set(o[4],o[5],o[6]).length(),c=be.set(o[8],o[9],o[10]).length();i.determinant()<0&&(a=-a),De.setFromMatrix4(i);const p=1/a,h=1/u,y=1/c;return De.elements[0]*=p,De.elements[1]*=p,De.elements[2]*=p,De.elements[3]*=h,De.elements[4]*=h,De.elements[5]*=h,De.elements[6]*=y,De.elements[7]*=y,De.elements[8]*=y,this.rotation.multiply(De),this.halfSize.x*=a,this.halfSize.y*=u,this.halfSize.z*=c,be.setFromMatrixPosition(i),this.center.add(be),this}}const Ms=new vr,Os={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:T.MathUtils.degToRad(60)};function Cs(L,i){const o=Object.assign({css3d:!1,stats:!1,renderType:"change",control:{init:!0,options:{}}},i||{});let a,u,c,l=[];const p=it.ref(!1),h=it.shallowRef(),y=it.ref(0),E=it.ref(0),w=new T.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),P=new T.Scene({}),D=new T.PerspectiveCamera(50,1,.1,2e3),G=Math.tan(Math.PI/180*D.fov/2);let W=!1;w.setPixelRatio(window.devicePixelRatio);function z(){p.value=!1;const me=Ie();y.value=me[0],E.value=me[1],D.aspect=y.value/E.value,D.position.set(47,39,100),D.fov=360/Math.PI*Math.atan(G*(E.value/y.value)),D.lookAt(0,0,0),D.updateProjectionMatrix(),w.setSize(y.value,E.value),a.appendChild(w.domElement),o.stats&&Oe(),o.css3d&&Xt();let Ne;if(o.control&&o.control.init){Ne=Mt.createOrbitControl(D,w.domElement);const Ce=Object.assign(Os,o.control.options||{});Object.keys(Ce).forEach(He=>{Ne[He]=Ce[He]})}return it.nextTick(()=>p.value=!0),Ne}function Y(me){me.preventDefault(),cancelAnimationFrame($)}function ee(me){me.preventDefault(),z(),$()}function le(me){l.push(me)}function $(me){l&&l.length&&l.forEach(Ne=>{typeof Ne=="function"&&Ne()}),o.renderType==="loop"&&we(),requestAnimationFrame($)}function we(){W=!1,u&&u.update(),h.value&&h.value.update(),w.render(P,D),c&&c.render(P,D)}function ve(){W||(W=!0,requestAnimationFrame(we))}function ue(){it.nextTick(()=>{const me=Ie();y.value=me[0],E.value=me[1],D.aspect=y.value/E.value,D.fov=360/Math.PI*Math.atan(G*(E.value/y.value)),D.updateProjectionMatrix(),D.lookAt(P.position),w.setSize(y.value,E.value),c&&c.setSize(y.value,E.value),we()})}function Ie(){return a=document.querySelector(L),a?[a.clientWidth,a.clientHeight]:[0,0]}function Oe(){u=new Mt.Stats,u.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.appendChild(u.dom)}function Ye(me,Ne,Ce,He,Wt){const Fe=new T.Box3().setFromObject(me),ze=Fe.getSize(new T.Vector3).length(),Te=Fe.getCenter(new T.Vector3);Wt&&Te.add(Wt);const Mn=ze*Ne*.5,$e=T.MathUtils.degToRad(Ce.fov*.5),$t=Mn/Math.tan($e),Ke=new T.Vector3().subVectors(Ce.position,Te).multiply(new T.Vector3(1,1,1)).normalize().multiplyScalar($t).add(Te),je={x:Ke.x,y:Ke.y,z:Ke.z,lookAt_x:Te.x,lookAt_y:Te.y,lookAt_z:Te.z};return Ce.position.set(je.x,je.y,je.z),Ce.lookAt(je.lookAt_x,je.lookAt_y,je.lookAt_z),Ce.updateProjectionMatrix(),He.target.copy(Te),He.update(),ze}function Xt(){c=new Mt.CSS3DRenderer,c.setSize(y.value,E.value),c.domElement.style.position="absolute",c.domElement.style.top=0,c.domElement.style.left=0,c.domElement.style.pointerEvents="none",a.appendChild(c.domElement)}function ot(){Mt.disposeThreeObject(P)}return it.onMounted(()=>{h.value=z(),window.addEventListener("resize",ue,!1),w.domElement.addEventListener("webglcontextlost",Y,!1),w.domElement.addEventListener("webglcontextrestored",ee,!1),o.renderType==="loop"?requestAnimationFrame($):o.renderType==="change"&&h.value&&h.value.addEventListener("change",ve)}),it.onUnmounted(()=>{cancelAnimationFrame($),w.domElement.removeEventListener("resize",ue,!1),w.domElement.removeEventListener("webglcontextlost",Y,!1),w.domElement.removeEventListener("webglcontextrestored",ee,!1),ot()}),{addAnimate:le,frameArea:Ye,onRender:we,css3dRenderer:c,scene:P,camera:D,control:h,renderer:w,domWidth:y,domHeight:E,isReady:p}}const Ps=(L="app")=>{const i=new T.Raycaster;i.params.Line.threshold=8;const o=new T.Vector2,a=document.getElementById(L);function u(p,h){const{scaleX:y,scaleY:E}=l(a),{clientWidth:w,clientHeight:P}=h,D=h.getBoundingClientRect(),G=w*y,W=P*E,z=p.clientX-D.left,Y=p.clientY-D.top;return o.x=(p.clientX-D.left)/G*2-1,o.y=-((p.clientY-D.top)/W)*2+1,{pointer:o,x:z,y:Y}}function c(p,h,y,E){const{pointer:w,x:P,y:D}=u(p,h);return i.setFromCamera(w,y),{intersects:i.intersectObjects(E),pointer:w,x:P,y:D}}function l(p){const h=window.getComputedStyle(p),y=h.transform||h.webkitTransform||h.mozTransform;if(y&&y!=="none"){const E=y.match(/^matrix\((.+)\)$/);if(E){const w=E[1].split(", "),P=parseFloat(w[0]),D=parseFloat(w[3]);return{scaleX:P,scaleY:D}}}return{scaleX:1,scaleY:1}}return{raycaster:i,pointer:o,getPointer:u,getScale:l,getIntersects:c}},Ge=[],Ls=new T.Color(16711680),Is=()=>{const L=()=>{Ge.splice(0)},i=(p,h)=>{h.traverse(y=>{y&&o(p,y)})},o=(p,h)=>{if(h.userData.needCheck&&(h.autoUpdateMatrix=!1,h.updateMatrix(),h.updateMatrixWorld(),h.isMesh)){const y=new T.Box3(new T.Vector3).setFromObject(h);h.geometry.userData.obb=new vr,h.geometry.userData.obb.halfSize.copy(y.getSize(new T.Vector3)).multiplyScalar(.5).multiplyScalar(.88),h.userData.obb=new vr,h.userData.originColor=h.material.color.clone(),h.userData.parentUid=p,Ge.push({object:h,parentUid:p})}};return{resetObbs:L,initObb:i,getObbObjectByParentUid:p=>Ge.filter(h=>h.parentUid===p),addObbFromArray:(p,h)=>{for(let y=0,E=h.length;y<E;y++)o(p,h[y])},removeObbFromArray:p=>{const h=Ge.filter(y=>!p.includes(y.object));Ge.splice(0,Ge.length,...h)},removeUidObb:p=>{for(let h=Ge.length-1;h>=0;h--)Ge[h].parentUid===p&&Ge.splice(h,1)}}};var Ds=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ns(L){return L&&L.__esModule&&Object.prototype.hasOwnProperty.call(L,"default")?L.default:L}var An={exports:{}},Fs=An.exports,li;function Ks(){return li||(li=1,function(L,i){(function(o,a){L.exports=a()})(Fs,function(){var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])})(e,t)},a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function u(e,t,n){for(var r,s=0,f=t.length;s<f;s++)!r&&s in t||((r=r||Array.prototype.slice.call(t,0,s))[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}var c=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Ds,l=Object.keys,p=Array.isArray;function h(e,t){return typeof t!="object"||l(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||c.Promise||(c.Promise=Promise);var y=Object.getPrototypeOf,E={}.hasOwnProperty;function w(e,t){return E.call(e,t)}function P(e,t){typeof t=="function"&&(t=t(y(e))),(typeof Reflect>"u"?l:Reflect.ownKeys)(t).forEach(function(n){G(e,n,t[n])})}var D=Object.defineProperty;function G(e,t,n,r){D(e,t,h(n&&w(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function W(e){return{from:function(t){return e.prototype=Object.create(t.prototype),G(e.prototype,"constructor",e),{extend:P.bind(null,e.prototype)}}}}var z=Object.getOwnPropertyDescriptor,Y=[].slice;function ee(e,t,n){return Y.call(e,t,n)}function le(e,t){return t(e)}function $(e){if(!e)throw new Error("Assertion Failed")}function we(e){c.setImmediate?setImmediate(e):setTimeout(e,0)}function ve(e,t){if(typeof t=="string"&&w(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],r=0,s=t.length;r<s;++r){var f=ve(e,t[r]);n.push(f)}return n}var d=t.indexOf(".");if(d!==-1){var m=e[t.substr(0,d)];return m==null?void 0:ve(m,t.substr(d+1))}}function ue(e,t,n){if(e&&t!==void 0&&!("isFrozen"in Object&&Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){$(typeof n!="string"&&"length"in n);for(var r=0,s=t.length;r<s;++r)ue(e,t[r],n[r])}else{var f,d,m=t.indexOf(".");m!==-1?(f=t.substr(0,m),(d=t.substr(m+1))===""?n===void 0?p(e)&&!isNaN(parseInt(f))?e.splice(f,1):delete e[f]:e[f]=n:ue(m=!(m=e[f])||!w(e,f)?e[f]={}:m,d,n)):n===void 0?p(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function Ie(e){var t,n={};for(t in e)w(e,t)&&(n[t]=e[t]);return n}var Oe=[].concat;function Ye(e){return Oe.apply([],e)}var ut="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Ye([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return c[e]}),Xt=new Set(ut.map(function(e){return c[e]})),ot=null;function me(e){return ot=new WeakMap,e=function t(n){if(!n||typeof n!="object")return n;var r=ot.get(n);if(r)return r;if(p(n)){r=[],ot.set(n,r);for(var s=0,f=n.length;s<f;++s)r.push(t(n[s]))}else if(Xt.has(n.constructor))r=n;else{var d,m=y(n);for(d in r=m===Object.prototype?{}:Object.create(m),ot.set(n,r),n)w(n,d)&&(r[d]=t(n[d]))}return r}(e),ot=null,e}var Ne={}.toString;function Ce(e){return Ne.call(e).slice(8,-1)}var He=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Wt=typeof He=="symbol"?function(e){var t;return e!=null&&(t=e[He])&&t.apply(e)}:function(){return null};function Fe(e,t){return t=e.indexOf(t),0<=t&&e.splice(t,1),0<=t}var ze={};function Te(e){var t,n,r,s;if(arguments.length===1){if(p(e))return e.slice();if(this===ze&&typeof e=="string")return[e];if(s=Wt(e)){for(n=[];!(r=s.next()).done;)n.push(r.value);return n}if(e==null)return[e];if(typeof(t=e.length)!="number")return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var Yt=typeof Symbol<"u"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},It=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Pe=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(It),Mn={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function $e(e,t){this.name=e,this.message=t}function $t(e,t){return e+". Errors: "+Object.keys(t).map(function(n){return t[n].toString()}).filter(function(n,r,s){return s.indexOf(n)===r}).join(`
3
+ `)}function Ct(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=$t(e,t)}function Ke(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(n){return t[n]}),this.failuresByPos=t,this.message=$t(e,this.failures)}W($e).from(Error).extend({toString:function(){return this.name+": "+this.message}}),W(Ct).from($e),W(Ke).from($e);var je=Pe.reduce(function(e,t){return e[t]=t+"Error",e},{}),mi=$e,X=Pe.reduce(function(e,t){var n=t+"Error";function r(s,f){this.name=n,s?typeof s=="string"?(this.message="".concat(s).concat(f?`
4
+ `+f:""),this.inner=f||null):typeof s=="object"&&(this.message="".concat(s.name," ").concat(s.message),this.inner=s):(this.message=Mn[t]||n,this.inner=null)}return W(r).from(mi),e[t]=r,e},{});X.Syntax=SyntaxError,X.Type=TypeError,X.Range=RangeError;var wr=It.reduce(function(e,t){return e[t+"Error"]=X[t],e},{}),Qt=Pe.reduce(function(e,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=X[t]),e},{});function ce(){}function Pt(e){return e}function yi(e,t){return e==null||e===Pt?t:function(n){return t(e(n))}}function at(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function gi(e,t){return e===ce?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var f=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?at(r,this.onsuccess):r),s&&(this.onerror=this.onerror?at(s,this.onerror):s),f!==void 0?f:n}}function vi(e,t){return e===ce?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?at(n,this.onsuccess):n),r&&(this.onerror=this.onerror?at(r,this.onerror):r)}}function bi(e,t){return e===ce?t:function(n){var r=e.apply(this,arguments);h(n,r);var s=this.onsuccess,f=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),s&&(this.onsuccess=this.onsuccess?at(s,this.onsuccess):s),f&&(this.onerror=this.onerror?at(f,this.onerror):f),r===void 0?n===void 0?void 0:n:h(r,n)}}function wi(e,t){return e===ce?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function On(e,t){return e===ce?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,s=arguments.length,f=new Array(s);s--;)f[s]=arguments[s];return n.then(function(){return t.apply(r,f)})}return t.apply(this,arguments)}}Qt.ModifyError=Ct,Qt.DexieError=$e,Qt.BulkError=Ke;var Be=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function _r(e){Be=e}var Lt={},xr=100,ut=typeof Promise>"u"?[]:function(){var e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,y(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,y(t),e]}(),It=ut[0],Pe=ut[1],ut=ut[2],Pe=Pe&&Pe.then,ct=It&&It.constructor,Cn=!!ut,Dt=function(e,t){Nt.push([e,t]),Jt&&(queueMicrotask(xi),Jt=!1)},Pn=!0,Jt=!0,lt=[],Zt=[],Ln=Pt,Qe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ce,pgp:!1,env:{},finalize:ce},V=Qe,Nt=[],ft=0,en=[];function q(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=V;if(typeof e!="function"){if(e!==Lt)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Dn(this,this._value))}this._state=null,this._value=null,++t.ref,function n(r,s){try{s(function(f){if(r._state===null){if(f===r)throw new TypeError("A promise cannot be resolved with itself.");var d=r._lib&&xt();f&&typeof f.then=="function"?n(r,function(m,v){f instanceof q?f._then(m,v):f.then(m,v)}):(r._state=!0,r._value=f,Sr(r)),d&&Tt()}},Dn.bind(null,r))}catch(f){Dn(r,f)}}(this,e)}var In={get:function(){var e=V,t=sn;function n(r,s){var f=this,d=!e.global&&(e!==V||t!==sn),m=d&&!Ze(),v=new q(function(_,R){Nn(f,new Tr(Rr(r,e,d,m),Rr(s,e,d,m),_,R,e))});return this._consoleTask&&(v._consoleTask=this._consoleTask),v}return n.prototype=Lt,n},set:function(e){G(this,"then",e&&e.prototype===Lt?In:{get:function(){return e},set:In.set})}};function Tr(e,t,n,r,s){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=r,this.psd=s}function Dn(e,t){var n,r;Zt.push(t),e._state===null&&(n=e._lib&&xt(),t=Ln(t),e._state=!1,e._value=t,r=e,lt.some(function(s){return s._value===r._value})||lt.push(r),Sr(e),n&&Tt())}function Sr(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Nn(e,t[n]);var s=e._PSD;--s.ref||s.finalize(),ft===0&&(++ft,Dt(function(){--ft==0&&Fn()},[]))}function Nn(e,t){if(e._state!==null){var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ft,Dt(_i,[n,e,t])}else e._listeners.push(t)}function _i(e,t,n){try{var r,s=t._value;!t._state&&Zt.length&&(Zt=[]),r=Be&&t._consoleTask?t._consoleTask.run(function(){return e(s)}):e(s),t._state||Zt.indexOf(s)!==-1||function(f){for(var d=lt.length;d;)if(lt[--d]._value===f._value)return lt.splice(d,1)}(t),n.resolve(r)}catch(f){n.reject(f)}finally{--ft==0&&Fn(),--n.psd.ref||n.psd.finalize()}}function xi(){ht(Qe,function(){xt()&&Tt()})}function xt(){var e=Pn;return Jt=Pn=!1,e}function Tt(){var e,t,n;do for(;0<Nt.length;)for(e=Nt,Nt=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(0<Nt.length);Jt=Pn=!0}function Fn(){var e=lt;lt=[],e.forEach(function(r){r._PSD.onunhandled.call(null,r._value,r)});for(var t=en.slice(0),n=t.length;n;)t[--n]()}function tn(e){return new q(Lt,!1,e)}function de(e,t){var n=V;return function(){var r=xt(),s=V;try{return et(n,!0),e.apply(this,arguments)}catch(f){t&&t(f)}finally{et(s,!1),r&&Tt()}}}P(q.prototype,{then:In,_then:function(e,t){Nn(this,new Tr(null,null,e,t,V))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=e,n=arguments[1];return typeof t=="function"?this.then(null,function(r){return(r instanceof t?n:tn)(r)}):this.then(null,function(r){return(r&&r.name===t?n:tn)(r)})},finally:function(e){return this.then(function(t){return q.resolve(e()).then(function(){return t})},function(t){return q.resolve(e()).then(function(){return tn(t)})})},timeout:function(e,t){var n=this;return e<1/0?new q(function(r,s){var f=setTimeout(function(){return s(new X.Timeout(t))},e);n.then(r,s).finally(clearTimeout.bind(null,f))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&G(q.prototype,Symbol.toStringTag,"Dexie.Promise"),Qe.env=Er(),P(q,{all:function(){var e=Te.apply(null,arguments).map(on);return new q(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach(function(s,f){return q.resolve(s).then(function(d){e[f]=d,--r||t(e)},n)})})},resolve:function(e){return e instanceof q?e:e&&typeof e.then=="function"?new q(function(t,n){e.then(t,n)}):new q(Lt,!0,e)},reject:tn,race:function(){var e=Te.apply(null,arguments).map(on);return new q(function(t,n){e.map(function(r){return q.resolve(r).then(t,n)})})},PSD:{get:function(){return V},set:function(e){return V=e}},totalEchoes:{get:function(){return sn}},newPSD:Je,usePSD:ht,scheduler:{get:function(){return Dt},set:function(e){Dt=e}},rejectionMapper:{get:function(){return Ln},set:function(e){Ln=e}},follow:function(e,t){return new q(function(n,r){return Je(function(s,f){var d=V;d.unhandleds=[],d.onunhandled=f,d.finalize=at(function(){var m,v=this;m=function(){v.unhandleds.length===0?s():f(v.unhandleds[0])},en.push(function _(){m(),en.splice(en.indexOf(_),1)}),++ft,Dt(function(){--ft==0&&Fn()},[])},d.finalize),e()},t,n,r)})}}),ct&&(ct.allSettled&&G(q,"allSettled",function(){var e=Te.apply(null,arguments).map(on);return new q(function(t){e.length===0&&t([]);var n=e.length,r=new Array(n);e.forEach(function(s,f){return q.resolve(s).then(function(d){return r[f]={status:"fulfilled",value:d}},function(d){return r[f]={status:"rejected",reason:d}}).then(function(){return--n||t(r)})})})}),ct.any&&typeof AggregateError<"u"&&G(q,"any",function(){var e=Te.apply(null,arguments).map(on);return new q(function(t,n){e.length===0&&n(new AggregateError([]));var r=e.length,s=new Array(r);e.forEach(function(f,d){return q.resolve(f).then(function(m){return t(m)},function(m){s[d]=m,--r||n(new AggregateError(s))})})})}),ct.withResolvers&&(q.withResolvers=ct.withResolvers));var _e={awaits:0,echoes:0,id:0},Ti=0,nn=[],rn=0,sn=0,Si=0;function Je(e,t,n,r){var s=V,f=Object.create(s);return f.parent=s,f.ref=0,f.global=!1,f.id=++Si,Qe.env,f.env=Cn?{Promise:q,PromiseProp:{value:q,configurable:!0,writable:!0},all:q.all,race:q.race,allSettled:q.allSettled,any:q.any,resolve:q.resolve,reject:q.reject}:{},t&&h(f,t),++s.ref,f.finalize=function(){--this.parent.ref||this.parent.finalize()},r=ht(f,e,n,r),f.ref===0&&f.finalize(),r}function St(){return _e.id||(_e.id=++Ti),++_e.awaits,_e.echoes+=xr,_e.id}function Ze(){return!!_e.awaits&&(--_e.awaits==0&&(_e.id=0),_e.echoes=_e.awaits*xr,!0)}function on(e){return _e.echoes&&e&&e.constructor===ct?(St(),e.then(function(t){return Ze(),t},function(t){return Ze(),ye(t)})):e}function Ei(){var e=nn[nn.length-1];nn.pop(),et(e,!1)}function et(e,t){var n,r=V;(t?!_e.echoes||rn++&&e===V:!rn||--rn&&e===V)||queueMicrotask(t?(function(s){++sn,_e.echoes&&--_e.echoes!=0||(_e.echoes=_e.awaits=_e.id=0),nn.push(V),et(s,!0)}).bind(null,e):Ei),e!==V&&(V=e,r===Qe&&(Qe.env=Er()),Cn&&(n=Qe.env.Promise,t=e.env,(r.global||e.global)&&(Object.defineProperty(c,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function Er(){var e=c.Promise;return Cn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(c,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function ht(e,t,n,r,s){var f=V;try{return et(e,!0),t(n,r,s)}finally{et(f,!1)}}function Rr(e,t,n,r){return typeof e!="function"?e:function(){var s=V;n&&St(),et(t,!0);try{return e.apply(this,arguments)}finally{et(s,!1),r&&queueMicrotask(Ze)}}}function Kn(e){Promise===ct&&_e.echoes===0?rn===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(""+Pe).indexOf("[native code]")===-1&&(St=Ze=ce);var ye=q.reject,dt="￿",Ve="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ar="String expected.",Et=[],an="__dbnames",jn="readonly",Bn="readwrite";function pt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var kr={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function un(e){return typeof e!="string"||/\./.test(e)?function(t){return t}:function(t){return t[e]===void 0&&e in t&&delete(t=me(t))[e],t}}function Mr(){throw X.Type()}function ie(e,t){try{var n=Or(e),r=Or(t);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(s,f){for(var d=s.length,m=f.length,v=d<m?d:m,_=0;_<v;++_)if(s[_]!==f[_])return s[_]<f[_]?-1:1;return d===m?0:d<m?-1:1}(Cr(e),Cr(t));case"Array":return function(s,f){for(var d=s.length,m=f.length,v=d<m?d:m,_=0;_<v;++_){var R=ie(s[_],f[_]);if(R!==0)return R}return d===m?0:d<m?-1:1}(e,t)}}catch{}return NaN}function Or(e){var t=typeof e;return t!="object"?t:ArrayBuffer.isView(e)?"binary":(e=Ce(e),e==="ArrayBuffer"?"binary":e)}function Cr(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Pr=(fe.prototype._trans=function(e,t,n){var r=this._tx||V.trans,s=this.name,f=Be&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(e==="readonly"?"read":"write"," ").concat(this.name));function d(_,R,g){if(!g.schema[s])throw new X.NotFound("Table "+s+" not part of transaction");return t(g.idbtrans,g)}var m=xt();try{var v=r&&r.db._novip===this.db._novip?r===V.trans?r._promise(e,d,n):Je(function(){return r._promise(e,d,n)},{trans:r,transless:V.transless||V}):function _(R,g,k,b){if(R.idbdb&&(R._state.openComplete||V.letThrough||R._vip)){var S=R._createTransaction(g,k,R._dbSchema);try{S.create(),R._state.PR1398_maxLoop=3}catch(A){return A.name===je.InvalidState&&R.isOpen()&&0<--R._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),R.close({disableAutoOpen:!1}),R.open().then(function(){return _(R,g,k,b)})):ye(A)}return S._promise(g,function(A,x){return Je(function(){return V.trans=S,b(A,x,S)})}).then(function(A){if(g==="readwrite")try{S.idbtrans.commit()}catch{}return g==="readonly"?A:S._completion.then(function(){return A})})}if(R._state.openComplete)return ye(new X.DatabaseClosed(R._state.dbOpenError));if(!R._state.isBeingOpened){if(!R._state.autoOpen)return ye(new X.DatabaseClosed);R.open().catch(ce)}return R._state.dbReadyPromise.then(function(){return _(R,g,k,b)})}(this.db,e,[this.name],d);return f&&(v._consoleTask=f,v=v.catch(function(_){return console.trace(_),ye(_)})),v}finally{m&&Tt()}},fe.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?ye(new X.Type("Invalid argument to Table.get()")):this._trans("readonly",function(r){return n.core.get({trans:r,key:e}).then(function(s){return n.hook.reading.fire(s)})}).then(t)},fe.prototype.where=function(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(p(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=l(e);if(t.length===1)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(m){if(m.compound&&t.every(function(_){return 0<=m.keyPath.indexOf(_)})){for(var v=0;v<t.length;++v)if(t.indexOf(m.keyPath[v])===-1)return!1;return!0}return!1}).sort(function(m,v){return m.keyPath.length-v.keyPath.length})[0];if(n&&this.db._maxKey!==dt){var f=n.keyPath.slice(0,t.length);return this.where(f).equals(f.map(function(v){return e[v]}))}!n&&Be&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var r=this.schema.idxByName;function s(m,v){return ie(m,v)===0}var d=t.reduce(function(g,v){var _=g[0],R=g[1],g=r[v],k=e[v];return[_||g,_||!g?pt(R,g&&g.multi?function(b){return b=ve(b,v),p(b)&&b.some(function(S){return s(k,S)})}:function(b){return s(k,ve(b,v))}):R]},[null,null]),f=d[0],d=d[1];return f?this.where(f.name).equals(e[f.keyPath]).filter(d):n?this.filter(d):this.where(t).equals("")},fe.prototype.filter=function(e){return this.toCollection().and(e)},fe.prototype.count=function(e){return this.toCollection().count(e)},fe.prototype.offset=function(e){return this.toCollection().offset(e)},fe.prototype.limit=function(e){return this.toCollection().limit(e)},fe.prototype.each=function(e){return this.toCollection().each(e)},fe.prototype.toArray=function(e){return this.toCollection().toArray(e)},fe.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},fe.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,p(e)?"[".concat(e.join("+"),"]"):e))},fe.prototype.reverse=function(){return this.toCollection().reverse()},fe.prototype.mapToClass=function(e){var t,n=this.db,r=this.name;function s(){return t!==null&&t.apply(this,arguments)||this}(this.schema.mappedClass=e).prototype instanceof Mr&&(function(v,_){if(typeof _!="function"&&_!==null)throw new TypeError("Class extends value "+String(_)+" is not a constructor or null");function R(){this.constructor=v}o(v,_),v.prototype=_===null?Object.create(_):(R.prototype=_.prototype,new R)}(s,t=e),Object.defineProperty(s.prototype,"db",{get:function(){return n},enumerable:!1,configurable:!0}),s.prototype.table=function(){return r},e=s);for(var f=new Set,d=e.prototype;d;d=y(d))Object.getOwnPropertyNames(d).forEach(function(v){return f.add(v)});function m(v){if(!v)return v;var _,R=Object.create(e.prototype);for(_ in v)if(!f.has(_))try{R[_]=v[_]}catch{}return R}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=m,this.hook("reading",m),e},fe.prototype.defineClass=function(){return this.mapToClass(function(e){h(this,e)})},fe.prototype.add=function(e,t){var n=this,r=this.schema.primKey,s=r.auto,f=r.keyPath,d=e;return f&&s&&(d=un(f)(e)),this._trans("readwrite",function(m){return n.core.mutate({trans:m,type:"add",keys:t!=null?[t]:null,values:[d]})}).then(function(m){return m.numFailures?q.reject(m.failures[0]):m.lastResult}).then(function(m){if(f)try{ue(e,f,m)}catch{}return m})},fe.prototype.update=function(e,t){return typeof e!="object"||p(e)?this.where(":id").equals(e).modify(t):(e=ve(e,this.schema.primKey.keyPath),e===void 0?ye(new X.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t))},fe.prototype.put=function(e,t){var n=this,r=this.schema.primKey,s=r.auto,f=r.keyPath,d=e;return f&&s&&(d=un(f)(e)),this._trans("readwrite",function(m){return n.core.mutate({trans:m,type:"put",values:[d],keys:t!=null?[t]:null})}).then(function(m){return m.numFailures?q.reject(m.failures[0]):m.lastResult}).then(function(m){if(f)try{ue(e,f,m)}catch{}return m})},fe.prototype.delete=function(e){var t=this;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]})}).then(function(n){return n.numFailures?q.reject(n.failures[0]):void 0})},fe.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:kr})}).then(function(t){return t.numFailures?q.reject(t.failures[0]):void 0})},fe.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(r){return r.map(function(s){return t.hook.reading.fire(s)})})})},fe.prototype.bulkAdd=function(e,t,n){var r=this,s=Array.isArray(t)?t:void 0,f=(n=n||(s?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(d){var _=r.schema.primKey,m=_.auto,_=_.keyPath;if(_&&s)throw new X.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");var v=e.length,_=_&&m?e.map(un(_)):e;return r.core.mutate({trans:d,type:"add",keys:s,values:_,wantResults:f}).then(function(S){var g=S.numFailures,k=S.results,b=S.lastResult,S=S.failures;if(g===0)return f?k:b;throw new Ke("".concat(r.name,".bulkAdd(): ").concat(g," of ").concat(v," operations failed"),S)})})},fe.prototype.bulkPut=function(e,t,n){var r=this,s=Array.isArray(t)?t:void 0,f=(n=n||(s?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(d){var _=r.schema.primKey,m=_.auto,_=_.keyPath;if(_&&s)throw new X.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");var v=e.length,_=_&&m?e.map(un(_)):e;return r.core.mutate({trans:d,type:"put",keys:s,values:_,wantResults:f}).then(function(S){var g=S.numFailures,k=S.results,b=S.lastResult,S=S.failures;if(g===0)return f?k:b;throw new Ke("".concat(r.name,".bulkPut(): ").concat(g," of ").concat(v," operations failed"),S)})})},fe.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map(function(d){return d.key}),s=e.map(function(d){return d.changes}),f=[];return this._trans("readwrite",function(d){return n.getMany({trans:d,keys:r,cache:"clone"}).then(function(m){var v=[],_=[];e.forEach(function(g,k){var b=g.key,S=g.changes,A=m[k];if(A){for(var x=0,M=Object.keys(S);x<M.length;x++){var O=M[x],C=S[O];if(O===t.schema.primKey.keyPath){if(ie(C,b)!==0)throw new X.Constraint("Cannot update primary key in bulkUpdate()")}else ue(A,O,C)}f.push(k),v.push(b),_.push(A)}});var R=v.length;return n.mutate({trans:d,type:"put",keys:v,values:_,updates:{keys:r,changeSpecs:s}}).then(function(g){var k=g.numFailures,b=g.failures;if(k===0)return R;for(var S=0,A=Object.keys(b);S<A.length;S++){var x,M=A[S],O=f[Number(M)];O!=null&&(x=b[M],delete b[M],b[O]=x)}throw new Ke("".concat(t.name,".bulkUpdate(): ").concat(k," of ").concat(R," operations failed"),b)})})})},fe.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(r){return t.core.mutate({trans:r,type:"delete",keys:e})}).then(function(d){var s=d.numFailures,f=d.lastResult,d=d.failures;if(s===0)return f;throw new Ke("".concat(t.name,".bulkDelete(): ").concat(s," of ").concat(n," operations failed"),d)})},fe);function fe(){}function Ft(e){function t(d,m){if(m){for(var v=arguments.length,_=new Array(v-1);--v;)_[v-1]=arguments[v];return n[d].subscribe.apply(null,_),e}if(typeof d=="string")return n[d]}var n={};t.addEventType=f;for(var r=1,s=arguments.length;r<s;++r)f(arguments[r]);return t;function f(d,m,v){if(typeof d!="object"){var _;m=m||wi;var R={subscribers:[],fire:v=v||ce,subscribe:function(g){R.subscribers.indexOf(g)===-1&&(R.subscribers.push(g),R.fire=m(R.fire,g))},unsubscribe:function(g){R.subscribers=R.subscribers.filter(function(k){return k!==g}),R.fire=R.subscribers.reduce(m,v)}};return n[d]=t[d]=R}l(_=d).forEach(function(g){var k=_[g];if(p(k))f(g,_[g][0],_[g][1]);else{if(k!=="asap")throw new X.InvalidArgument("Invalid event config");var b=f(g,Pt,function(){for(var S=arguments.length,A=new Array(S);S--;)A[S]=arguments[S];b.subscribers.forEach(function(x){we(function(){x.apply(null,A)})})})}})}}function Kt(e,t){return W(t).from({prototype:e}),t}function Rt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Un(e,t){e.filter=pt(e.filter,t)}function qn(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return pt(r(),t())}:t,e.justLimit=n&&!r}function cn(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new X.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Lr(e,t,n){var r=cn(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function ln(e,t,n,r){var s=e.replayFilter?pt(e.filter,e.replayFilter()):e.filter;if(e.or){var f={},d=function(m,v,_){var R,g;s&&!s(v,_,function(k){return v.stop(k)},function(k){return v.fail(k)})||((g=""+(R=v.primaryKey))=="[object ArrayBuffer]"&&(g=""+new Uint8Array(R)),w(f,g)||(f[g]=!0,t(m,v,_)))};return Promise.all([e.or._iterate(d,n),Ir(Lr(e,r,n),e.algorithm,d,!e.keysOnly&&e.valueMapper)])}return Ir(Lr(e,r,n),pt(e.algorithm,s),t,!e.keysOnly&&e.valueMapper)}function Ir(e,t,n,r){var s=de(r?function(f,d,m){return n(r(f),d,m)}:n);return e.then(function(f){if(f)return f.start(function(){var d=function(){return f.continue()};t&&!t(f,function(m){return d=m},function(m){f.stop(m),d=ce},function(m){f.fail(m),d=ce})||s(f.value,f,function(m){return d=m}),d()})})}var jt=(Dr.prototype.execute=function(e){var t=this["@@propmod"];if(t.add!==void 0){var n=t.add;if(p(n))return u(u([],p(e)?e:[],!0),n).sort();if(typeof n=="number")return(Number(e)||0)+n;if(typeof n=="bigint")try{return BigInt(e)+n}catch{return BigInt(0)+n}throw new TypeError("Invalid term ".concat(n))}if(t.remove!==void 0){var r=t.remove;if(p(r))return p(e)?e.filter(function(s){return!r.includes(s)}).sort():[];if(typeof r=="number")return Number(e)-r;if(typeof r=="bigint")try{return BigInt(e)-r}catch{return BigInt(0)-r}throw new TypeError("Invalid subtrahend ".concat(r))}return n=(n=t.replacePrefix)===null||n===void 0?void 0:n[0],n&&typeof e=="string"&&e.startsWith(n)?t.replacePrefix[1]+e.substring(n.length):e},Dr);function Dr(e){this["@@propmod"]=e}var Ri=(oe.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,ye.bind(null,n.error)):n.table._trans("readonly",e).then(t)},oe.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,ye.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},oe.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=pt(t.algorithm,e)},oe.prototype._iterate=function(e,t){return ln(this._ctx,e,t,this._ctx.table.core)},oe.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&h(n,e),t._ctx=n,t},oe.prototype.raw=function(){return this._ctx.valueMapper=null,this},oe.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return ln(t,e,n,t.table.core)})},oe.prototype.count=function(e){var t=this;return this._read(function(n){var r=t._ctx,s=r.table.core;if(Rt(r,!0))return s.count({trans:n,query:{index:cn(r,s.schema),range:r.range}}).then(function(d){return Math.min(d,r.limit)});var f=0;return ln(r,function(){return++f,!1},n,s).then(function(){return f})}).then(e)},oe.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],s=n.length-1;function f(v,_){return _?f(v[n[_]],_-1):v[r]}var d=this._ctx.dir==="next"?1:-1;function m(v,_){return ie(f(v,s),f(_,s))*d}return this.toArray(function(v){return v.sort(m)}).then(t)},oe.prototype.toArray=function(e){var t=this;return this._read(function(n){var r=t._ctx;if(r.dir==="next"&&Rt(r,!0)&&0<r.limit){var s=r.valueMapper,f=cn(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:f,range:r.range}}).then(function(m){return m=m.result,s?m.map(s):m})}var d=[];return ln(r,function(m){return d.push(m)},n,r.table.core).then(function(){return d})},e)},oe.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,Rt(t)?qn(t,function(){var n=e;return function(r,s){return n===0||(n===1?--n:s(function(){r.advance(n),n=0}),!1)}}):qn(t,function(){var n=e;return function(){return--n<0}})),this},oe.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),qn(this._ctx,function(){var t=e;return function(n,r,s){return--t<=0&&r(s),0<=t}},!0),this},oe.prototype.until=function(e,t){return Un(this._ctx,function(n,r,s){return!e(n.value)||(r(s),t)}),this},oe.prototype.first=function(e){return this.limit(1).toArray(function(t){return t[0]}).then(e)},oe.prototype.last=function(e){return this.reverse().first(e)},oe.prototype.filter=function(e){var t;return Un(this._ctx,function(n){return e(n.value)}),(t=this._ctx).isMatch=pt(t.isMatch,e),this},oe.prototype.and=function(e){return this.filter(e)},oe.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},oe.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},oe.prototype.desc=function(){return this.reverse()},oe.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.key,r)})},oe.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},oe.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.primaryKey,r)})},oe.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(r,s){n.push(s.key)}).then(function(){return n}).then(e)},oe.prototype.primaryKeys=function(e){var t=this._ctx;if(t.dir==="next"&&Rt(t,!0)&&0<t.limit)return this._read(function(r){var s=cn(t,t.table.core.schema);return t.table.core.query({trans:r,values:!1,limit:t.limit,query:{index:s,range:t.range}})}).then(function(r){return r.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(r,s){n.push(s.primaryKey)}).then(function(){return n}).then(e)},oe.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},oe.prototype.firstKey=function(e){return this.limit(1).keys(function(t){return t[0]}).then(e)},oe.prototype.lastKey=function(e){return this.reverse().firstKey(e)},oe.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var t={};return Un(this._ctx,function(s){var r=s.primaryKey.toString(),s=w(t,r);return t[r]=!0,!s}),this},oe.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(r){var s,f,d;d=typeof e=="function"?e:(s=l(e),f=s.length,function(x){for(var M=!1,O=0;O<f;++O){var C=s[O],I=e[C],N=ve(x,C);I instanceof jt?(ue(x,C,I.execute(N)),M=!0):N!==I&&(ue(x,C,I),M=!0)}return M});var m=n.table.core,g=m.schema.primaryKey,v=g.outbound,_=g.extractKey,R=200,g=t.db._options.modifyChunkSize;g&&(R=typeof g=="object"?g[m.name]||g["*"]||200:g);function k(x,C){var O=C.failures,C=C.numFailures;S+=x-C;for(var I=0,N=l(O);I<N.length;I++){var B=N[I];b.push(O[B])}}var b=[],S=0,A=[];return t.clone().primaryKeys().then(function(x){function M(C){var I=Math.min(R,x.length-C);return m.getMany({trans:r,keys:x.slice(C,C+I),cache:"immutable"}).then(function(N){for(var B=[],F=[],K=v?[]:null,U=[],j=0;j<I;++j){var H=N[j],Z={value:me(H),primKey:x[C+j]};d.call(Z,Z.value,Z)!==!1&&(Z.value==null?U.push(x[C+j]):v||ie(_(H),_(Z.value))===0?(F.push(Z.value),v&&K.push(x[C+j])):(U.push(x[C+j]),B.push(Z.value)))}return Promise.resolve(0<B.length&&m.mutate({trans:r,type:"add",values:B}).then(function(te){for(var ne in te.failures)U.splice(parseInt(ne),1);k(B.length,te)})).then(function(){return(0<F.length||O&&typeof e=="object")&&m.mutate({trans:r,type:"put",keys:K,values:F,criteria:O,changeSpec:typeof e!="function"&&e,isAdditionalChunk:0<C}).then(function(te){return k(F.length,te)})}).then(function(){return(0<U.length||O&&e===Gn)&&m.mutate({trans:r,type:"delete",keys:U,criteria:O,isAdditionalChunk:0<C}).then(function(te){return k(U.length,te)})}).then(function(){return x.length>C+I&&M(C+R)})})}var O=Rt(n)&&n.limit===1/0&&(typeof e!="function"||e===Gn)&&{index:n.index,range:n.range};return M(0).then(function(){if(0<b.length)throw new Ct("Error modifying one or more objects",b,S,A);return x.length})})})},oe.prototype.delete=function(){var e=this._ctx,t=e.range;return Rt(e)&&(e.isPrimKey||t.type===3)?this._write(function(n){var r=e.table.core.schema.primaryKey,s=t;return e.table.core.count({trans:n,query:{index:r,range:s}}).then(function(f){return e.table.core.mutate({trans:n,type:"deleteRange",range:s}).then(function(d){var m=d.failures;if(d.lastResult,d.results,d=d.numFailures,d)throw new Ct("Could not delete some values",Object.keys(m).map(function(v){return m[v]}),f-d);return f-d})})}):this.modify(Gn)},oe);function oe(){}var Gn=function(e,t){return t.value=null};function Ai(e,t){return e<t?-1:e===t?0:1}function ki(e,t){return t<e?-1:e===t?0:1}function ke(e,t,n){return e=e instanceof Fr?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function At(e){return new e.Collection(e,function(){return Nr("")}).limit(0)}function fn(e,t,n,r){var s,f,d,m,v,_,R,g=n.length;if(!n.every(function(S){return typeof S=="string"}))return ke(e,Ar);function k(S){s=S==="next"?function(x){return x.toUpperCase()}:function(x){return x.toLowerCase()},f=S==="next"?function(x){return x.toLowerCase()}:function(x){return x.toUpperCase()},d=S==="next"?Ai:ki;var A=n.map(function(x){return{lower:f(x),upper:s(x)}}).sort(function(x,M){return d(x.lower,M.lower)});m=A.map(function(x){return x.upper}),v=A.map(function(x){return x.lower}),R=(_=S)==="next"?"":r}k("next"),e=new e.Collection(e,function(){return tt(m[0],v[g-1]+r)}),e._ondirectionchange=function(S){k(S)};var b=0;return e._addAlgorithm(function(S,A,x){var M=S.key;if(typeof M!="string")return!1;var O=f(M);if(t(O,v,b))return!0;for(var C=null,I=b;I<g;++I){var N=function(B,F,K,U,j,H){for(var Z=Math.min(B.length,U.length),te=-1,ne=0;ne<Z;++ne){var Me=F[ne];if(Me!==U[ne])return j(B[ne],K[ne])<0?B.substr(0,ne)+K[ne]+K.substr(ne+1):j(B[ne],U[ne])<0?B.substr(0,ne)+U[ne]+K.substr(ne+1):0<=te?B.substr(0,te)+F[te]+K.substr(te+1):null;j(B[ne],Me)<0&&(te=ne)}return Z<U.length&&H==="next"?B+K.substr(B.length):Z<B.length&&H==="prev"?B.substr(0,K.length):te<0?null:B.substr(0,te)+U[te]+K.substr(te+1)}(M,O,m[I],v[I],d,_);N===null&&C===null?b=I+1:(C===null||0<d(C,N))&&(C=N)}return A(C!==null?function(){S.continue(C+R)}:x),!1}),e}function tt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Nr(e){return{type:1,lower:e,upper:e}}var Fr=(Object.defineProperty(xe.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),xe.prototype.between=function(e,t,n,r){n=n!==!1,r=r===!0;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||r)&&(!n||!r)?At(this):new this.Collection(this,function(){return tt(e,t,!n,!r)})}catch{return ke(this,Ve)}},xe.prototype.equals=function(e){return e==null?ke(this,Ve):new this.Collection(this,function(){return Nr(e)})},xe.prototype.above=function(e){return e==null?ke(this,Ve):new this.Collection(this,function(){return tt(e,void 0,!0)})},xe.prototype.aboveOrEqual=function(e){return e==null?ke(this,Ve):new this.Collection(this,function(){return tt(e,void 0,!1)})},xe.prototype.below=function(e){return e==null?ke(this,Ve):new this.Collection(this,function(){return tt(void 0,e,!1,!0)})},xe.prototype.belowOrEqual=function(e){return e==null?ke(this,Ve):new this.Collection(this,function(){return tt(void 0,e)})},xe.prototype.startsWith=function(e){return typeof e!="string"?ke(this,Ar):this.between(e,e+dt,!0,!0)},xe.prototype.startsWithIgnoreCase=function(e){return e===""?this.startsWith(e):fn(this,function(t,n){return t.indexOf(n[0])===0},[e],dt)},xe.prototype.equalsIgnoreCase=function(e){return fn(this,function(t,n){return t===n[0]},[e],"")},xe.prototype.anyOfIgnoreCase=function(){var e=Te.apply(ze,arguments);return e.length===0?At(this):fn(this,function(t,n){return n.indexOf(t)!==-1},e,"")},xe.prototype.startsWithAnyOfIgnoreCase=function(){var e=Te.apply(ze,arguments);return e.length===0?At(this):fn(this,function(t,n){return n.some(function(r){return t.indexOf(r)===0})},e,dt)},xe.prototype.anyOf=function(){var e=this,t=Te.apply(ze,arguments),n=this._cmp;try{t.sort(n)}catch{return ke(this,Ve)}if(t.length===0)return At(this);var r=new this.Collection(this,function(){return tt(t[0],t[t.length-1])});r._ondirectionchange=function(f){n=f==="next"?e._ascending:e._descending,t.sort(n)};var s=0;return r._addAlgorithm(function(f,d,m){for(var v=f.key;0<n(v,t[s]);)if(++s===t.length)return d(m),!1;return n(v,t[s])===0||(d(function(){f.continue(t[s])}),!1)}),r},xe.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},xe.prototype.noneOf=function(){var e=Te.apply(ze,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return ke(this,Ve)}var t=e.reduce(function(n,r){return n?n.concat([[n[n.length-1][1],r]]):[[-1/0,r]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},xe.prototype.inAnyRange=function(M,t){var n=this,r=this._cmp,s=this._ascending,f=this._descending,d=this._min,m=this._max;if(M.length===0)return At(this);if(!M.every(function(O){return O[0]!==void 0&&O[1]!==void 0&&s(O[0],O[1])<=0}))return ke(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",X.InvalidArgument);var v=!t||t.includeLowers!==!1,_=t&&t.includeUppers===!0,R,g=s;function k(O,C){return g(O[0],C[0])}try{(R=M.reduce(function(O,C){for(var I=0,N=O.length;I<N;++I){var B=O[I];if(r(C[0],B[1])<0&&0<r(C[1],B[0])){B[0]=d(B[0],C[0]),B[1]=m(B[1],C[1]);break}}return I===N&&O.push(C),O},[])).sort(k)}catch{return ke(this,Ve)}var b=0,S=_?function(O){return 0<s(O,R[b][1])}:function(O){return 0<=s(O,R[b][1])},A=v?function(O){return 0<f(O,R[b][0])}:function(O){return 0<=f(O,R[b][0])},x=S,M=new this.Collection(this,function(){return tt(R[0][0],R[R.length-1][1],!v,!_)});return M._ondirectionchange=function(O){g=O==="next"?(x=S,s):(x=A,f),R.sort(k)},M._addAlgorithm(function(O,C,I){for(var N,B=O.key;x(B);)if(++b===R.length)return C(I),!1;return!S(N=B)&&!A(N)||(n._cmp(B,R[b][1])===0||n._cmp(B,R[b][0])===0||C(function(){g===s?O.continue(R[b][0]):O.continue(R[b][1])}),!1)}),M},xe.prototype.startsWithAnyOf=function(){var e=Te.apply(ze,arguments);return e.every(function(t){return typeof t=="string"})?e.length===0?At(this):this.inAnyRange(e.map(function(t){return[t,t+dt]})):ke(this,"startsWithAnyOf() only works with strings")},xe);function xe(){}function Ue(e){return de(function(t){return Bt(t),e(t.target.error),!1})}function Bt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Ut="storagemutated",Hn="x-storagemutated-1",nt=Ft(null,Ut),Mi=(qe.prototype._lock=function(){return $(!V.global),++this._reculock,this._reculock!==1||V.global||(V.lockOwnerFor=this),this},qe.prototype._unlock=function(){if($(!V.global),--this._reculock==0)for(V.global||(V.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{ht(e[1],e[0])}catch{}}return this},qe.prototype._locked=function(){return this._reculock&&V.lockOwnerFor!==this},qe.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if($(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new X.DatabaseClosed(r);case"MissingAPIError":throw new X.MissingAPI(r.message,r);default:throw new X.OpenFailed(r)}if(!this.active)throw new X.TransactionInactive;return $(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=de(function(s){Bt(s),t._reject(e.error)}),e.onabort=de(function(s){Bt(s),t.active&&t._reject(new X.Abort(e.error)),t.active=!1,t.on("abort").fire(s)}),e.oncomplete=de(function(){t.active=!1,t._resolve(),"mutatedParts"in e&&nt.storagemutated.fire(e.mutatedParts)}),this},qe.prototype._promise=function(e,t,n){var r=this;if(e==="readwrite"&&this.mode!=="readwrite")return ye(new X.ReadOnly("Transaction is readonly"));if(!this.active)return ye(new X.TransactionInactive);if(this._locked())return new q(function(f,d){r._blockedFuncs.push([function(){r._promise(e,t,n).then(f,d)},V])});if(n)return Je(function(){var f=new q(function(d,m){r._lock();var v=t(d,m,r);v&&v.then&&v.then(d,m)});return f.finally(function(){return r._unlock()}),f._lib=!0,f});var s=new q(function(f,d){var m=t(f,d,r);m&&m.then&&m.then(f,d)});return s._lib=!0,s},qe.prototype._root=function(){return this.parent?this.parent._root():this},qe.prototype.waitFor=function(e){var t,n=this._root(),r=q.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function f(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=f)}());var s=n._waitingFor;return new q(function(f,d){r.then(function(m){return n._waitingQueue.push(de(f.bind(null,m)))},function(m){return n._waitingQueue.push(de(d.bind(null,m)))}).finally(function(){n._waitingFor===s&&(n._waitingFor=null)})})},qe.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new X.Abort))},qe.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(w(t,e))return t[e];var n=this.schema[e];if(!n)throw new X.NotFound("Table "+e+" not part of transaction");return n=new this.db.Table(e,n,this),n.core=this.db.core.table(e),t[e]=n},qe);function qe(){}function zn(e,t,n,r,s,f,d){return{name:e,keyPath:t,unique:n,multi:r,auto:s,compound:f,src:(n&&!d?"&":"")+(r?"*":"")+(s?"++":"")+Kr(t)}}function Kr(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Vn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(s){return[s.name,s]},n.reduce(function(s,f,d){return d=r(f,d),d&&(s[d[0]]=d[1]),s},{}))};var r}var qt=function(e){try{return e.only([[]]),qt=function(){return[[]]},[[]]}catch{return qt=function(){return dt},dt}};function Xn(e){return e==null?function(){}:typeof e=="string"?(t=e).split(".").length===1?function(n){return n[t]}:function(n){return ve(n,t)}:function(n){return ve(n,e)};var t}function jr(e){return[].slice.call(e)}var Oi=0;function Gt(e){return e==null?":id":typeof e=="string"?e:"[".concat(e.join("+"),"]")}function Ci(e,t,v){function r(x){if(x.type===3)return null;if(x.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var b=x.lower,S=x.upper,A=x.lowerOpen,x=x.upperOpen;return b===void 0?S===void 0?null:t.upperBound(S,!!x):S===void 0?t.lowerBound(b,!!A):t.bound(b,S,!!A,!!x)}function s(k){var b,S=k.name;return{name:S,schema:k,mutate:function(A){var x=A.trans,M=A.type,O=A.keys,C=A.values,I=A.range;return new Promise(function(N,B){N=de(N);var F=x.objectStore(S),K=F.keyPath==null,U=M==="put"||M==="add";if(!U&&M!=="delete"&&M!=="deleteRange")throw new Error("Invalid operation type: "+M);var j,H=(O||C||{length:1}).length;if(O&&C&&O.length!==C.length)throw new Error("Given keys array must have same length as given values array.");if(H===0)return N({numFailures:0,failures:{},results:[],lastResult:void 0});function Z(Ae){++Me,Bt(Ae)}var te=[],ne=[],Me=0;if(M==="deleteRange"){if(I.type===4)return N({numFailures:Me,failures:ne,results:[],lastResult:void 0});I.type===3?te.push(j=F.clear()):te.push(j=F.delete(r(I)))}else{var K=U?K?[C,O]:[C,null]:[O,null],Q=K[0],Ee=K[1];if(U)for(var Re=0;Re<H;++Re)te.push(j=Ee&&Ee[Re]!==void 0?F[M](Q[Re],Ee[Re]):F[M](Q[Re])),j.onerror=Z;else for(Re=0;Re<H;++Re)te.push(j=F[M](Q[Re])),j.onerror=Z}function Sn(Ae){Ae=Ae.target.result,te.forEach(function(gt,fr){return gt.error!=null&&(ne[fr]=gt.error)}),N({numFailures:Me,failures:ne,results:M==="delete"?O:te.map(function(gt){return gt.result}),lastResult:Ae})}j.onerror=function(Ae){Z(Ae),Sn(Ae)},j.onsuccess=Sn})},getMany:function(A){var x=A.trans,M=A.keys;return new Promise(function(O,C){O=de(O);for(var I,N=x.objectStore(S),B=M.length,F=new Array(B),K=0,U=0,j=function(te){te=te.target,F[te._pos]=te.result,++U===K&&O(F)},H=Ue(C),Z=0;Z<B;++Z)M[Z]!=null&&((I=N.get(M[Z]))._pos=Z,I.onsuccess=j,I.onerror=H,++K);K===0&&O(F)})},get:function(A){var x=A.trans,M=A.key;return new Promise(function(O,C){O=de(O);var I=x.objectStore(S).get(M);I.onsuccess=function(N){return O(N.target.result)},I.onerror=Ue(C)})},query:(b=_,function(A){return new Promise(function(x,M){x=de(x);var O,C,I,K=A.trans,N=A.values,B=A.limit,j=A.query,F=B===1/0?void 0:B,U=j.index,j=j.range,K=K.objectStore(S),U=U.isPrimaryKey?K:K.index(U.name),j=r(j);if(B===0)return x({result:[]});b?((F=N?U.getAll(j,F):U.getAllKeys(j,F)).onsuccess=function(H){return x({result:H.target.result})},F.onerror=Ue(M)):(O=0,C=!N&&"openKeyCursor"in U?U.openKeyCursor(j):U.openCursor(j),I=[],C.onsuccess=function(H){var Z=C.result;return Z?(I.push(N?Z.value:Z.primaryKey),++O===B?x({result:I}):void Z.continue()):x({result:I})},C.onerror=Ue(M))})}),openCursor:function(A){var x=A.trans,M=A.values,O=A.query,C=A.reverse,I=A.unique;return new Promise(function(N,B){N=de(N);var U=O.index,F=O.range,K=x.objectStore(S),K=U.isPrimaryKey?K:K.index(U.name),U=C?I?"prevunique":"prev":I?"nextunique":"next",j=!M&&"openKeyCursor"in K?K.openKeyCursor(r(F),U):K.openCursor(r(F),U);j.onerror=Ue(B),j.onsuccess=de(function(H){var Z,te,ne,Me,Q=j.result;Q?(Q.___id=++Oi,Q.done=!1,Z=Q.continue.bind(Q),te=(te=Q.continuePrimaryKey)&&te.bind(Q),ne=Q.advance.bind(Q),Me=function(){throw new Error("Cursor not stopped")},Q.trans=x,Q.stop=Q.continue=Q.continuePrimaryKey=Q.advance=function(){throw new Error("Cursor not started")},Q.fail=de(B),Q.next=function(){var Ee=this,Re=1;return this.start(function(){return Re--?Ee.continue():Ee.stop()}).then(function(){return Ee})},Q.start=function(Ee){function Re(){if(j.result)try{Ee()}catch(Ae){Q.fail(Ae)}else Q.done=!0,Q.start=function(){throw new Error("Cursor behind last entry")},Q.stop()}var Sn=new Promise(function(Ae,gt){Ae=de(Ae),j.onerror=Ue(gt),Q.fail=gt,Q.stop=function(fr){Q.stop=Q.continue=Q.continuePrimaryKey=Q.advance=Me,Ae(fr)}});return j.onsuccess=de(function(Ae){j.onsuccess=Re,Re()}),Q.continue=Z,Q.continuePrimaryKey=te,Q.advance=ne,Re(),Sn},N(Q)):N(null)},B)})},count:function(A){var x=A.query,M=A.trans,O=x.index,C=x.range;return new Promise(function(I,N){var B=M.objectStore(S),F=O.isPrimaryKey?B:B.index(O.name),B=r(C),F=B?F.count(B):F.count();F.onsuccess=de(function(K){return I(K.target.result)}),F.onerror=Ue(N)})}}}var f,d,m,R=(d=v,m=jr((f=e).objectStoreNames),{schema:{name:f.name,tables:m.map(function(k){return d.objectStore(k)}).map(function(k){var b=k.keyPath,x=k.autoIncrement,S=p(b),A={},x={name:k.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:b==null,compound:S,keyPath:b,autoIncrement:x,unique:!0,extractKey:Xn(b)},indexes:jr(k.indexNames).map(function(M){return k.index(M)}).map(function(I){var O=I.name,C=I.unique,N=I.multiEntry,I=I.keyPath,N={name:O,compound:p(I),keyPath:I,unique:C,multiEntry:N,extractKey:Xn(I)};return A[Gt(I)]=N}),getIndexByKeyPath:function(M){return A[Gt(M)]}};return A[":id"]=x.primaryKey,b!=null&&(A[Gt(b)]=x.primaryKey),x})},hasGetAll:0<m.length&&"getAll"in d.objectStore(m[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),v=R.schema,_=R.hasGetAll,R=v.tables.map(s),g={};return R.forEach(function(k){return g[k.name]=k}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(k){if(!g[k])throw new Error("Table '".concat(k,"' not found"));return g[k]},MIN_KEY:-1/0,MAX_KEY:qt(t),schema:v}}function Pi(e,t,n,r){var s=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=Ci(t,s,r),e.dbcore.reduce(function(f,d){return d=d.create,a(a({},f),d(f))},r))}}function hn(e,r){var n=r.db,r=Pi(e._middlewares,n,e._deps,r);e.core=r.dbcore,e.tables.forEach(function(s){var f=s.name;e.core.schema.tables.some(function(d){return d.name===f})&&(s.core=e.core.table(f),e[f]instanceof e.Table&&(e[f].core=s.core))})}function dn(e,t,n,r){n.forEach(function(s){var f=r[s];t.forEach(function(d){var m=function v(_,R){return z(_,R)||(_=y(_))&&v(_,R)}(d,s);(!m||"value"in m&&m.value===void 0)&&(d===e.Transaction.prototype||d instanceof e.Transaction?G(d,s,{get:function(){return this.table(s)},set:function(v){D(this,s,{value:v,writable:!0,configurable:!0,enumerable:!0})}}):d[s]=new e.Table(s,f))})})}function Wn(e,t){t.forEach(function(n){for(var r in n)n[r]instanceof e.Table&&delete n[r]})}function Li(e,t){return e._cfg.version-t._cfg.version}function Ii(e,t,n,r){var s=e._dbSchema;n.objectStoreNames.contains("$meta")&&!s.$meta&&(s.$meta=Vn("$meta",Ur("")[0],[]),e._storeNames.push("$meta"));var f=e._createTransaction("readwrite",e._storeNames,s);f.create(n),f._completion.catch(r);var d=f._reject.bind(f),m=V.transless||V;Je(function(){return V.trans=f,V.transless=m,t!==0?(hn(e,n),_=t,((v=f).storeNames.includes("$meta")?v.table("$meta").get("version").then(function(R){return R??_}):q.resolve(_)).then(function(R){return k=R,b=f,S=n,A=[],R=(g=e)._versions,x=g._dbSchema=mn(0,g.idbdb,S),(R=R.filter(function(M){return M._cfg.version>=k})).length!==0?(R.forEach(function(M){A.push(function(){var O=x,C=M._cfg.dbschema;yn(g,O,S),yn(g,C,S),x=g._dbSchema=C;var I=Yn(O,C);I.add.forEach(function(U){$n(S,U[0],U[1].primKey,U[1].indexes)}),I.change.forEach(function(U){if(U.recreate)throw new X.Upgrade("Not yet support for changing primary key");var j=S.objectStore(U.name);U.add.forEach(function(H){return pn(j,H)}),U.change.forEach(function(H){j.deleteIndex(H.name),pn(j,H)}),U.del.forEach(function(H){return j.deleteIndex(H)})});var N=M._cfg.contentUpgrade;if(N&&M._cfg.version>k){hn(g,S),b._memoizedTables={};var B=Ie(C);I.del.forEach(function(U){B[U]=O[U]}),Wn(g,[g.Transaction.prototype]),dn(g,[g.Transaction.prototype],l(B),B),b.schema=B;var F,K=Yt(N);return K&&St(),I=q.follow(function(){var U;(F=N(b))&&K&&(U=Ze.bind(null,null),F.then(U,U))}),F&&typeof F.then=="function"?q.resolve(F):I.then(function(){return F})}}),A.push(function(O){var C,I,N=M._cfg.dbschema;C=N,I=O,[].slice.call(I.db.objectStoreNames).forEach(function(B){return C[B]==null&&I.db.deleteObjectStore(B)}),Wn(g,[g.Transaction.prototype]),dn(g,[g.Transaction.prototype],g._storeNames,g._dbSchema),b.schema=g._dbSchema}),A.push(function(O){g.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(g.idbdb.version/10)===M._cfg.version?(g.idbdb.deleteObjectStore("$meta"),delete g._dbSchema.$meta,g._storeNames=g._storeNames.filter(function(C){return C!=="$meta"})):O.objectStore("$meta").put(M._cfg.version,"version"))})}),function M(){return A.length?q.resolve(A.shift()(b.idbtrans)).then(M):q.resolve()}().then(function(){Br(x,S)})):q.resolve();var g,k,b,S,A,x}).catch(d)):(l(s).forEach(function(R){$n(n,R,s[R].primKey,s[R].indexes)}),hn(e,n),void q.follow(function(){return e.on.populate.fire(f)}).catch(d));var v,_})}function Di(e,t){Br(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains("$meta")||t.db.createObjectStore("$meta").add(Math.ceil(t.db.version/10-1),"version");var n=mn(0,e.idbdb,t);yn(e,e._dbSchema,t);for(var r=0,s=Yn(n,e._dbSchema).change;r<s.length;r++){var f=function(d){if(d.change.length||d.recreate)return console.warn("Unable to patch indexes of table ".concat(d.name," because it has changes on the type of index or primary key.")),{value:void 0};var m=t.objectStore(d.name);d.add.forEach(function(v){Be&&console.debug("Dexie upgrade patch: Creating missing index ".concat(d.name,".").concat(v.src)),pn(m,v)})}(s[r]);if(typeof f=="object")return f.value}}function Yn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var s=e[n],f=t[n];if(s){var d={name:n,def:f,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(f.primKey.keyPath||"")||s.primKey.auto!==f.primKey.auto)d.recreate=!0,r.change.push(d);else{var m=s.idxByName,v=f.idxByName,_=void 0;for(_ in m)v[_]||d.del.push(_);for(_ in v){var R=m[_],g=v[_];R?R.src!==g.src&&d.change.push(g):d.add.push(g)}(0<d.del.length||0<d.add.length||0<d.change.length)&&r.change.push(d)}}else r.add.push([n,f])}return r}function $n(e,t,n,r){var s=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(f){return pn(s,f)}),s}function Br(e,t){l(e).forEach(function(n){t.db.objectStoreNames.contains(n)||(Be&&console.debug("Dexie: Creating missing table",n),$n(t,n,e[n].primKey,e[n].indexes))})}function pn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function mn(e,t,n){var r={};return ee(t.objectStoreNames,0).forEach(function(s){for(var f=n.objectStore(s),d=zn(Kr(_=f.keyPath),_||"",!0,!1,!!f.autoIncrement,_&&typeof _!="string",!0),m=[],v=0;v<f.indexNames.length;++v){var R=f.index(f.indexNames[v]),_=R.keyPath,R=zn(R.name,_,!!R.unique,!!R.multiEntry,!1,_&&typeof _!="string",!1);m.push(R)}r[s]=Vn(s,d,m)}),r}function yn(e,t,n){for(var r=n.db.objectStoreNames,s=0;s<r.length;++s){var f=r[s],d=n.objectStore(f);e._hasGetAll="getAll"in d;for(var m=0;m<d.indexNames.length;++m){var v=d.indexNames[m],_=d.index(v).keyPath,R=typeof _=="string"?_:"["+ee(_).join("+")+"]";!t[f]||(_=t[f].idxByName[R])&&(_.name=v,delete t[f].idxByName[R],t[f].idxByName[v]=_)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&c.WorkerGlobalScope&&c instanceof c.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function Ur(e){return e.split(",").map(function(t,n){var r=(t=t.trim()).replace(/([&*]|\+\+)/g,""),s=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return zn(r,s||null,/\&/.test(t),/\*/.test(t),/\+\+/.test(t),p(s),n===0)})}var Ni=(gn.prototype._parseStoresSpec=function(e,t){l(e).forEach(function(n){if(e[n]!==null){var r=Ur(e[n]),s=r.shift();if(s.unique=!0,s.multi)throw new X.Schema("Primary key cannot be multi-valued");r.forEach(function(f){if(f.auto)throw new X.Schema("Only primary key can be marked as autoIncrement (++)");if(!f.keyPath)throw new X.Schema("Index must have a name and cannot be an empty string")}),t[n]=Vn(n,s,r)}})},gn.prototype.stores=function(n){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?h(this._cfg.storesSource,n):n;var n=t._versions,r={},s={};return n.forEach(function(f){h(r,f._cfg.storesSource),s=f._cfg.dbschema={},f._parseStoresSpec(r,s)}),t._dbSchema=s,Wn(t,[t._allTables,t,t.Transaction.prototype]),dn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],l(s),s),t._storeNames=l(s),this},gn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=On(this._cfg.contentUpgrade||ce,e),this},gn);function gn(){}function Qn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Xe(an,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Jn(e){return e&&typeof e.databases=="function"}function Zn(e){return Je(function(){return V.letThrough=!0,e()})}function er(e){return!("from"in e)}var Se=function(e,t){if(!this){var n=new Se;return e&&"d"in e&&h(n,e),n}h(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function Ht(e,t,n){var r=ie(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(er(e))return h(e,{from:t,to:n,d:1});var s=e.l,r=e.r;if(ie(n,e.from)<0)return s?Ht(s,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Gr(e);if(0<ie(t,e.to))return r?Ht(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Gr(e);ie(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<ie(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),n=!e.r,s&&!e.l&&zt(e,s),r&&n&&zt(e,r)}}function zt(e,t){er(t)||function n(r,v){var f=v.from,d=v.to,m=v.l,v=v.r;Ht(r,f,d),m&&n(r,m),v&&n(r,v)}(e,t)}function qr(e,t){var n=vn(t),r=n.next();if(r.done)return!1;for(var s=r.value,f=vn(e),d=f.next(s.from),m=d.value;!r.done&&!d.done;){if(ie(m.from,s.to)<=0&&0<=ie(m.to,s.from))return!0;ie(s.from,m.from)<0?s=(r=n.next(m.from)).value:m=(d=f.next(s.from)).value}return!1}function vn(e){var t=er(e)?null:{s:0,n:e};return{next:function(n){for(var r=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&ie(n,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||ie(n,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Gr(e){var t,n,r=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((n=e.l)===null||n===void 0?void 0:n.d)||0),s=1<r?"r":r<-1?"l":"";s&&(t=s=="r"?"l":"r",n=a({},e),r=e[s],e.from=r.from,e.to=r.to,e[s]=r[s],n[s]=r[t],(e[t]=n).d=Hr(n)),e.d=Hr(e)}function Hr(n){var t=n.r,n=n.l;return(t?n?Math.max(t.d,n.d):t.d:n?n.d:0)+1}function bn(e,t){return l(t).forEach(function(n){e[n]?zt(e[n],t[n]):e[n]=function r(s){var f,d,m={};for(f in s)w(s,f)&&(d=s[f],m[f]=!d||typeof d!="object"||Xt.has(d.constructor)?d:r(d));return m}(t[n])}),e}function tr(e,t){return e.all||t.all||Object.keys(e).some(function(n){return t[n]&&qr(t[n],e[n])})}P(Se.prototype,((Pe={add:function(e){return zt(this,e),this},addKey:function(e){return Ht(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(n){return Ht(t,n,n)}),this},hasKey:function(e){var t=vn(this).next(e).value;return t&&ie(t.from,e)<=0&&0<=ie(t.to,e)}})[He]=function(){return vn(this)},Pe));var mt={},nr={},rr=!1;function wn(e){bn(nr,e),rr||(rr=!0,setTimeout(function(){rr=!1,ir(nr,!(nr={}))},0))}function ir(e,t){t===void 0&&(t=!1);var n=new Set;if(e.all)for(var r=0,s=Object.values(mt);r<s.length;r++)zr(d=s[r],e,n,t);else for(var f in e){var d,m=/^idb\:\/\/(.*)\/(.*)\//.exec(f);m&&(f=m[1],m=m[2],(d=mt["idb://".concat(f,"/").concat(m)])&&zr(d,e,n,t))}n.forEach(function(v){return v()})}function zr(e,t,n,r){for(var s=[],f=0,d=Object.entries(e.queries.query);f<d.length;f++){for(var m=d[f],v=m[0],_=[],R=0,g=m[1];R<g.length;R++){var k=g[R];tr(t,k.obsSet)?k.subscribers.forEach(function(x){return n.add(x)}):r&&_.push(k)}r&&s.push([v,_])}if(r)for(var b=0,S=s;b<S.length;b++){var A=S[b],v=A[0],_=A[1];e.queries.query[v]=_}}function Fi(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?ye(t.dbOpenError):e});t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var r=t.openCanceller,s=Math.round(10*e.verno),f=!1;function d(){if(t.openCanceller!==r)throw new X.DatabaseClosed("db.open() was cancelled")}function m(){return new q(function(k,b){if(d(),!n)throw new X.MissingAPI;var S=e.name,A=t.autoSchema||!s?n.open(S):n.open(S,s);if(!A)throw new X.MissingAPI;A.onerror=Ue(b),A.onblocked=de(e._fireOnBlocked),A.onupgradeneeded=de(function(x){var M;R=A.transaction,t.autoSchema&&!e._options.allowEmptyDB?(A.onerror=Bt,R.abort(),A.result.close(),(M=n.deleteDatabase(S)).onsuccess=M.onerror=de(function(){b(new X.NoSuchDatabase("Database ".concat(S," doesnt exist")))})):(R.onerror=Ue(b),x=x.oldVersion>Math.pow(2,62)?0:x.oldVersion,g=x<1,e.idbdb=A.result,f&&Di(e,R),Ii(e,x/10,R,b))},b),A.onsuccess=de(function(){R=null;var x,M,O,C,I,N=e.idbdb=A.result,B=ee(N.objectStoreNames);if(0<B.length)try{var F=N.transaction((C=B).length===1?C[0]:C,"readonly");if(t.autoSchema)M=N,O=F,(x=e).verno=M.version/10,O=x._dbSchema=mn(0,M,O),x._storeNames=ee(M.objectStoreNames,0),dn(x,[x._allTables],l(O),O);else if(yn(e,e._dbSchema,F),((I=Yn(mn(0,(I=e).idbdb,F),I._dbSchema)).add.length||I.change.some(function(K){return K.add.length||K.change.length}))&&!f)return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."),N.close(),s=N.version+1,f=!0,k(m());hn(e,F)}catch{}Et.push(e),N.onversionchange=de(function(K){t.vcFired=!0,e.on("versionchange").fire(K)}),N.onclose=de(function(K){e.on("close").fire(K)}),g&&(I=e._deps,F=S,N=I.indexedDB,I=I.IDBKeyRange,Jn(N)||F===an||Qn(N,I).put({name:F}).catch(ce)),k()},b)}).catch(function(k){switch(k==null?void 0:k.name){case"UnknownError":if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),m();break;case"VersionError":if(0<s)return s=0,m()}return q.reject(k)})}var v,_=t.dbReadyResolve,R=null,g=!1;return q.race([r,(typeof navigator>"u"?q.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(k){function b(){return indexedDB.databases().finally(k)}v=setInterval(b,100),b()}).finally(function(){return clearInterval(v)}):Promise.resolve()).then(m)]).then(function(){return d(),t.onReadyBeingFired=[],q.resolve(Zn(function(){return e.on.ready.fire(e.vip)})).then(function k(){if(0<t.onReadyBeingFired.length){var b=t.onReadyBeingFired.reduce(On,ce);return t.onReadyBeingFired=[],q.resolve(Zn(function(){return b(e.vip)})).then(k)}})}).finally(function(){t.openCanceller===r&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)}).catch(function(k){t.dbOpenError=k;try{R&&R.abort()}catch{}return r===t.openCanceller&&e._close(),ye(k)}).finally(function(){t.openComplete=!0,_()}).then(function(){var k;return g&&(k={},e.tables.forEach(function(b){b.schema.indexes.forEach(function(S){S.name&&(k["idb://".concat(e.name,"/").concat(b.name,"/").concat(S.name)]=new Se(-1/0,[[[]]]))}),k["idb://".concat(e.name,"/").concat(b.name,"/")]=k["idb://".concat(e.name,"/").concat(b.name,"/:dels")]=new Se(-1/0,[[[]]])}),nt(Ut).fire(k),ir(k,!0)),e})}function sr(e){function t(f){return e.next(f)}var n=s(t),r=s(function(f){return e.throw(f)});function s(f){return function(v){var m=f(v),v=m.value;return m.done?v:v&&typeof v.then=="function"?v.then(n,r):p(v)?Promise.all(v).then(n,r):n(v)}}return s(t)()}function _n(e,t,n){for(var r=p(e)?e.slice():[e],s=0;s<n;++s)r.push(t);return r}var Ki={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return a(a({},e),{table:function(t){var n=e.table(t),r=n.schema,s={},f=[];function d(g,k,b){var S=Gt(g),A=s[S]=s[S]||[],x=g==null?0:typeof g=="string"?1:g.length,M=0<k,M=a(a({},b),{name:M?"".concat(S,"(virtual-from:").concat(b.name,")"):b.name,lowLevelIndex:b,isVirtual:M,keyTail:k,keyLength:x,extractKey:Xn(g),unique:!M&&b.unique});return A.push(M),M.isPrimaryKey||f.push(M),1<x&&d(x===2?g[0]:g.slice(0,x-1),k+1,b),A.sort(function(O,C){return O.keyTail-C.keyTail}),M}t=d(r.primaryKey.keyPath,0,r.primaryKey),s[":id"]=[t];for(var m=0,v=r.indexes;m<v.length;m++){var _=v[m];d(_.keyPath,0,_)}function R(g){var k,b=g.query.index;return b.isVirtual?a(a({},g),{query:{index:b.lowLevelIndex,range:(k=g.query.range,b=b.keyTail,{type:k.type===1?2:k.type,lower:_n(k.lower,k.lowerOpen?e.MAX_KEY:e.MIN_KEY,b),lowerOpen:!0,upper:_n(k.upper,k.upperOpen?e.MIN_KEY:e.MAX_KEY,b),upperOpen:!0})}}):g}return a(a({},n),{schema:a(a({},r),{primaryKey:t,indexes:f,getIndexByKeyPath:function(g){return(g=s[Gt(g)])&&g[0]}}),count:function(g){return n.count(R(g))},query:function(g){return n.query(R(g))},openCursor:function(g){var k=g.query.index,b=k.keyTail,S=k.isVirtual,A=k.keyLength;return S?n.openCursor(R(g)).then(function(M){return M&&x(M)}):n.openCursor(g);function x(M){return Object.create(M,{continue:{value:function(O){O!=null?M.continue(_n(O,g.reverse?e.MAX_KEY:e.MIN_KEY,b)):g.unique?M.continue(M.key.slice(0,A).concat(g.reverse?e.MIN_KEY:e.MAX_KEY,b)):M.continue()}},continuePrimaryKey:{value:function(O,C){M.continuePrimaryKey(_n(O,e.MAX_KEY,b),C)}},primaryKey:{get:function(){return M.primaryKey}},key:{get:function(){var O=M.key;return A===1?O[0]:O.slice(0,A)}},value:{get:function(){return M.value}}})}}})}})}};function or(e,t,n,r){return n=n||{},r=r||"",l(e).forEach(function(s){var f,d,m;w(t,s)?(f=e[s],d=t[s],typeof f=="object"&&typeof d=="object"&&f&&d?(m=Ce(f))!==Ce(d)?n[r+s]=t[s]:m==="Object"?or(f,d,n,r+s+"."):f!==d&&(n[r+s]=t[s]):f!==d&&(n[r+s]=t[s])):n[r+s]=void 0}),l(t).forEach(function(s){w(e,s)||(n[r+s]=t[s])}),n}function ar(e,t){return t.type==="delete"?t.keys:t.keys||t.values.map(e.extractKey)}var ji={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return a(a({},e),{table:function(t){var n=e.table(t),r=n.schema.primaryKey;return a(a({},n),{mutate:function(s){var f=V.trans,d=f.table(t).hook,m=d.deleting,v=d.creating,_=d.updating;switch(s.type){case"add":if(v.fire===ce)break;return f._promise("readwrite",function(){return R(s)},!0);case"put":if(v.fire===ce&&_.fire===ce)break;return f._promise("readwrite",function(){return R(s)},!0);case"delete":if(m.fire===ce)break;return f._promise("readwrite",function(){return R(s)},!0);case"deleteRange":if(m.fire===ce)break;return f._promise("readwrite",function(){return function g(k,b,S){return n.query({trans:k,values:!1,query:{index:r,range:b},limit:S}).then(function(A){var x=A.result;return R({type:"delete",keys:x,trans:k}).then(function(M){return 0<M.numFailures?Promise.reject(M.failures[0]):x.length<S?{failures:[],numFailures:0,lastResult:void 0}:g(k,a(a({},b),{lower:x[x.length-1],lowerOpen:!0}),S)})})}(s.trans,s.range,1e4)},!0)}return n.mutate(s);function R(g){var k,b,S,A=V.trans,x=g.keys||ar(r,g);if(!x)throw new Error("Keys missing");return(g=g.type==="add"||g.type==="put"?a(a({},g),{keys:x}):a({},g)).type!=="delete"&&(g.values=u([],g.values)),g.keys&&(g.keys=u([],g.keys)),k=n,S=x,((b=g).type==="add"?Promise.resolve([]):k.getMany({trans:b.trans,keys:S,cache:"immutable"})).then(function(M){var O=x.map(function(C,I){var N,B,F,K=M[I],U={onerror:null,onsuccess:null};return g.type==="delete"?m.fire.call(U,C,K,A):g.type==="add"||K===void 0?(N=v.fire.call(U,C,g.values[I],A),C==null&&N!=null&&(g.keys[I]=C=N,r.outbound||ue(g.values[I],r.keyPath,C))):(N=or(K,g.values[I]),(B=_.fire.call(U,N,C,K,A))&&(F=g.values[I],Object.keys(B).forEach(function(j){w(F,j)?F[j]=B[j]:ue(F,j,B[j])}))),U});return n.mutate(g).then(function(C){for(var I=C.failures,N=C.results,B=C.numFailures,C=C.lastResult,F=0;F<x.length;++F){var K=(N||x)[F],U=O[F];K==null?U.onerror&&U.onerror(I[F]):U.onsuccess&&U.onsuccess(g.type==="put"&&M[F]?g.values[F]:K)}return{failures:I,results:N,numFailures:B,lastResult:C}}).catch(function(C){return O.forEach(function(I){return I.onerror&&I.onerror(C)}),Promise.reject(C)})})}}})}})}};function Vr(e,t,n){try{if(!t||t.keys.length<e.length)return null;for(var r=[],s=0,f=0;s<t.keys.length&&f<e.length;++s)ie(t.keys[s],e[f])===0&&(r.push(n?me(t.values[s]):t.values[s]),++f);return r.length===e.length?r:null}catch{return null}}var Bi={stack:"dbcore",level:-1,create:function(e){return{table:function(t){var n=e.table(t);return a(a({},n),{getMany:function(r){if(!r.cache)return n.getMany(r);var s=Vr(r.keys,r.trans._cache,r.cache==="clone");return s?q.resolve(s):n.getMany(r).then(function(f){return r.trans._cache={keys:r.keys,values:r.cache==="clone"?me(f):f},f})},mutate:function(r){return r.type!=="add"&&(r.trans._cache=null),n.mutate(r)}})}}}};function Xr(e,t){return e.trans.mode==="readonly"&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!=="disabled"&&!t.schema.primaryKey.outbound}function Wr(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Ui={stack:"dbcore",level:0,name:"Observability",create:function(e){var t=e.schema.name,n=new Se(e.MIN_KEY,e.MAX_KEY);return a(a({},e),{transaction:function(r,s,f){if(V.subscr&&s!=="readonly")throw new X.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(V.querier));return e.transaction(r,s,f)},table:function(r){var s=e.table(r),f=s.schema,d=f.primaryKey,g=f.indexes,m=d.extractKey,v=d.outbound,_=d.autoIncrement&&g.filter(function(b){return b.compound&&b.keyPath.includes(d.keyPath)}),R=a(a({},s),{mutate:function(b){function S(j){return j="idb://".concat(t,"/").concat(r,"/").concat(j),C[j]||(C[j]=new Se)}var A,x,M,O=b.trans,C=b.mutatedParts||(b.mutatedParts={}),I=S(""),N=S(":dels"),B=b.type,U=b.type==="deleteRange"?[b.range]:b.type==="delete"?[b.keys]:b.values.length<50?[ar(d,b).filter(function(j){return j}),b.values]:[],F=U[0],K=U[1],U=b.trans._cache;return p(F)?(I.addKeys(F),(U=B==="delete"||F.length===K.length?Vr(F,U):null)||N.addKeys(F),(U||K)&&(A=S,x=U,M=K,f.indexes.forEach(function(j){var H=A(j.name||"");function Z(ne){return ne!=null?j.extractKey(ne):null}function te(ne){return j.multiEntry&&p(ne)?ne.forEach(function(Me){return H.addKey(Me)}):H.addKey(ne)}(x||M).forEach(function(ne,Ee){var Q=x&&Z(x[Ee]),Ee=M&&Z(M[Ee]);ie(Q,Ee)!==0&&(Q!=null&&te(Q),Ee!=null&&te(Ee))})}))):F?(K={from:(K=F.lower)!==null&&K!==void 0?K:e.MIN_KEY,to:(K=F.upper)!==null&&K!==void 0?K:e.MAX_KEY},N.add(K),I.add(K)):(I.add(n),N.add(n),f.indexes.forEach(function(j){return S(j.name).add(n)})),s.mutate(b).then(function(j){return!F||b.type!=="add"&&b.type!=="put"||(I.addKeys(j.results),_&&_.forEach(function(H){for(var Z=b.values.map(function(Q){return H.extractKey(Q)}),te=H.keyPath.findIndex(function(Q){return Q===d.keyPath}),ne=0,Me=j.results.length;ne<Me;++ne)Z[ne][te]=j.results[ne];S(H.name).addKeys(Z)})),O.mutatedParts=bn(O.mutatedParts||{},C),j})}}),g=function(S){var A=S.query,S=A.index,A=A.range;return[S,new Se((S=A.lower)!==null&&S!==void 0?S:e.MIN_KEY,(A=A.upper)!==null&&A!==void 0?A:e.MAX_KEY)]},k={get:function(b){return[d,new Se(b.key)]},getMany:function(b){return[d,new Se().addKeys(b.keys)]},count:g,query:g,openCursor:g};return l(k).forEach(function(b){R[b]=function(S){var A=V.subscr,x=!!A,M=Xr(V,s)&&Wr(b,S)?S.obsSet={}:A;if(x){var O=function(K){return K="idb://".concat(t,"/").concat(r,"/").concat(K),M[K]||(M[K]=new Se)},C=O(""),I=O(":dels"),A=k[b](S),x=A[0],A=A[1];if((b==="query"&&x.isPrimaryKey&&!S.values?I:O(x.name||"")).add(A),!x.isPrimaryKey){if(b!=="count"){var N=b==="query"&&v&&S.values&&s.query(a(a({},S),{values:!1}));return s[b].apply(this,arguments).then(function(K){if(b==="query"){if(v&&S.values)return N.then(function(Z){return Z=Z.result,C.addKeys(Z),K});var U=S.values?K.result.map(m):K.result;(S.values?C:I).addKeys(U)}else if(b==="openCursor"){var j=K,H=S.values;return j&&Object.create(j,{key:{get:function(){return I.addKey(j.primaryKey),j.key}},primaryKey:{get:function(){var Z=j.primaryKey;return I.addKey(Z),Z}},value:{get:function(){return H&&C.addKey(j.primaryKey),j.value}}})}return K})}I.add(n)}}return s[b].apply(this,arguments)}}),R}})}};function Yr(e,t,n){if(n.numFailures===0)return t;if(t.type==="deleteRange")return null;var r=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;return n.numFailures===r?null:(t=a({},t),p(t.keys)&&(t.keys=t.keys.filter(function(s,f){return!(f in n.failures)})),"values"in t&&p(t.values)&&(t.values=t.values.filter(function(s,f){return!(f in n.failures)})),t)}function ur(e,t){return n=e,((r=t).lower===void 0||(r.lowerOpen?0<ie(n,r.lower):0<=ie(n,r.lower)))&&(e=e,(t=t).upper===void 0||(t.upperOpen?ie(e,t.upper)<0:ie(e,t.upper)<=0));var n,r}function $r(e,t,k,r,s,f){if(!k||k.length===0)return e;var d=t.query.index,m=d.multiEntry,v=t.query.range,_=r.schema.primaryKey.extractKey,R=d.extractKey,g=(d.lowLevelIndex||d).extractKey,k=k.reduce(function(b,S){var A=b,x=[];if(S.type==="add"||S.type==="put")for(var M=new Se,O=S.values.length-1;0<=O;--O){var C,I=S.values[O],N=_(I);M.hasKey(N)||(C=R(I),(m&&p(C)?C.some(function(j){return ur(j,v)}):ur(C,v))&&(M.addKey(N),x.push(I)))}switch(S.type){case"add":var B=new Se().addKeys(t.values?b.map(function(H){return _(H)}):b),A=b.concat(t.values?x.filter(function(H){return H=_(H),!B.hasKey(H)&&(B.addKey(H),!0)}):x.map(function(H){return _(H)}).filter(function(H){return!B.hasKey(H)&&(B.addKey(H),!0)}));break;case"put":var F=new Se().addKeys(S.values.map(function(H){return _(H)}));A=b.filter(function(H){return!F.hasKey(t.values?_(H):H)}).concat(t.values?x:x.map(function(H){return _(H)}));break;case"delete":var K=new Se().addKeys(S.keys);A=b.filter(function(H){return!K.hasKey(t.values?_(H):H)});break;case"deleteRange":var U=S.range;A=b.filter(function(H){return!ur(_(H),U)})}return A},e);return k===e?e:(k.sort(function(b,S){return ie(g(b),g(S))||ie(_(b),_(S))}),t.limit&&t.limit<1/0&&(k.length>t.limit?k.length=t.limit:e.length===t.limit&&k.length<t.limit&&(s.dirty=!0)),f?Object.freeze(k):k)}function Qr(e,t){return ie(e.lower,t.lower)===0&&ie(e.upper,t.upper)===0&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function qi(e,t){return function(n,r,s,f){if(n===void 0)return r!==void 0?-1:0;if(r===void 0)return 1;if((r=ie(n,r))===0){if(s&&f)return 0;if(s)return 1;if(f)return-1}return r}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(n,r,s,f){if(n===void 0)return r!==void 0?1:0;if(r===void 0)return-1;if((r=ie(n,r))===0){if(s&&f)return 0;if(s)return-1;if(f)return 1}return r}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function Gi(e,t,n,r){e.subscribers.add(n),r.addEventListener("abort",function(){var s,f;e.subscribers.delete(n),e.subscribers.size===0&&(s=e,f=t,setTimeout(function(){s.subscribers.size===0&&Fe(f,s)},3e3))})}var Hi={stack:"dbcore",level:0,name:"Cache",create:function(e){var t=e.schema.name;return a(a({},e),{transaction:function(n,r,s){var f,d,m=e.transaction(n,r,s);return r==="readwrite"&&(d=(f=new AbortController).signal,s=function(v){return function(){if(f.abort(),r==="readwrite"){for(var _=new Set,R=0,g=n;R<g.length;R++){var k=g[R],b=mt["idb://".concat(t,"/").concat(k)];if(b){var S=e.table(k),A=b.optimisticOps.filter(function(H){return H.trans===m});if(m._explicit&&v&&m.mutatedParts)for(var x=0,M=Object.values(b.queries.query);x<M.length;x++)for(var O=0,C=(B=M[x]).slice();O<C.length;O++)tr((F=C[O]).obsSet,m.mutatedParts)&&(Fe(B,F),F.subscribers.forEach(function(H){return _.add(H)}));else if(0<A.length){b.optimisticOps=b.optimisticOps.filter(function(H){return H.trans!==m});for(var I=0,N=Object.values(b.queries.query);I<N.length;I++)for(var B,F,K,U=0,j=(B=N[I]).slice();U<j.length;U++)(F=j[U]).res!=null&&m.mutatedParts&&(v&&!F.dirty?(K=Object.isFrozen(F.res),K=$r(F.res,F.req,A,S,F,K),F.dirty?(Fe(B,F),F.subscribers.forEach(function(H){return _.add(H)})):K!==F.res&&(F.res=K,F.promise=q.resolve({result:K}))):(F.dirty&&Fe(B,F),F.subscribers.forEach(function(H){return _.add(H)})))}}}_.forEach(function(H){return H()})}}},m.addEventListener("abort",s(!1),{signal:d}),m.addEventListener("error",s(!1),{signal:d}),m.addEventListener("complete",s(!0),{signal:d})),m},table:function(n){var r=e.table(n),s=r.schema.primaryKey;return a(a({},r),{mutate:function(f){var d=V.trans;if(s.outbound||d.db._options.cache==="disabled"||d.explicit||d.idbtrans.mode!=="readwrite")return r.mutate(f);var m=mt["idb://".concat(t,"/").concat(n)];return m?(d=r.mutate(f),f.type!=="add"&&f.type!=="put"||!(50<=f.values.length||ar(s,f).some(function(v){return v==null}))?(m.optimisticOps.push(f),f.mutatedParts&&wn(f.mutatedParts),d.then(function(v){0<v.numFailures&&(Fe(m.optimisticOps,f),(v=Yr(0,f,v))&&m.optimisticOps.push(v),f.mutatedParts&&wn(f.mutatedParts))}),d.catch(function(){Fe(m.optimisticOps,f),f.mutatedParts&&wn(f.mutatedParts)})):d.then(function(v){var _=Yr(0,a(a({},f),{values:f.values.map(function(R,g){var k;return v.failures[g]?R:(R=(k=s.keyPath)!==null&&k!==void 0&&k.includes(".")?me(R):a({},R),ue(R,s.keyPath,v.results[g]),R)})}),v);m.optimisticOps.push(_),queueMicrotask(function(){return f.mutatedParts&&wn(f.mutatedParts)})}),d):r.mutate(f)},query:function(f){if(!Xr(V,r)||!Wr("query",f))return r.query(f);var d=((_=V.trans)===null||_===void 0?void 0:_.db._options.cache)==="immutable",g=V,m=g.requery,v=g.signal,_=function(S,A,x,M){var O=mt["idb://".concat(S,"/").concat(A)];if(!O)return[];if(!(A=O.queries[x]))return[null,!1,O,null];var C=A[(M.query?M.query.index.name:null)||""];if(!C)return[null,!1,O,null];switch(x){case"query":var I=C.find(function(N){return N.req.limit===M.limit&&N.req.values===M.values&&Qr(N.req.query.range,M.query.range)});return I?[I,!0,O,C]:[C.find(function(N){return("limit"in N.req?N.req.limit:1/0)>=M.limit&&(!M.values||N.req.values)&&qi(N.req.query.range,M.query.range)}),!1,O,C];case"count":return I=C.find(function(N){return Qr(N.req.query.range,M.query.range)}),[I,!!I,O,C]}}(t,n,"query",f),R=_[0],g=_[1],k=_[2],b=_[3];return R&&g?R.obsSet=f.obsSet:(g=r.query(f).then(function(S){var A=S.result;if(R&&(R.res=A),d){for(var x=0,M=A.length;x<M;++x)Object.freeze(A[x]);Object.freeze(A)}else S.result=me(A);return S}).catch(function(S){return b&&R&&Fe(b,R),Promise.reject(S)}),R={obsSet:f.obsSet,promise:g,subscribers:new Set,type:"query",req:f,dirty:!1},b?b.push(R):(b=[R],(k=k||(mt["idb://".concat(t,"/").concat(n)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[f.query.index.name||""]=b)),Gi(R,b,m,v),R.promise.then(function(S){return{result:$r(S.result,f,k==null?void 0:k.optimisticOps,r,R,d)}})}})}})}};function xn(e,t){return new Proxy(e,{get:function(n,r,s){return r==="db"?t:Reflect.get(n,r,s)}})}var Xe=(ge.prototype.version=function(e){if(isNaN(e)||e<.1)throw new X.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new X.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(r){return r._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(Li),n.stores({}),this._state.autoSchema=!1,n)},ge.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||V.letThrough||this._vip)?e():new q(function(n,r){if(t._state.openComplete)return r(new X.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void r(new X.DatabaseClosed);t.open().catch(ce)}t._state.dbReadyPromise.then(n,r)}).then(e)},ge.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,s=e.name;return s&&this.unuse({stack:t,name:s}),e=this._middlewares[t]||(this._middlewares[t]=[]),e.push({stack:t,create:n,level:r??10,name:s}),e.sort(function(f,d){return f.level-d.level}),this},ge.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(s){return r?s.create!==r:!!n&&s.name!==n})),this},ge.prototype.open=function(){var e=this;return ht(Qe,function(){return Fi(e)})},ge.prototype._close=function(){var e=this._state,t=Et.indexOf(this);if(0<=t&&Et.splice(t,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new q(function(n){e.dbReadyResolve=n}),e.openCanceller=new q(function(n,r){e.cancelOpen=r}))},ge.prototype.close=function(n){var t=(n===void 0?{disableAutoOpen:!0}:n).disableAutoOpen,n=this._state;t?(n.isBeingOpened&&n.cancelOpen(new X.DatabaseClosed),this._close(),n.autoOpen=!1,n.dbOpenError=new X.DatabaseClosed):(this._close(),n.autoOpen=this._options.autoOpen||n.isBeingOpened,n.openComplete=!1,n.dbOpenError=null)},ge.prototype.delete=function(e){var t=this;e===void 0&&(e={disableAutoOpen:!0});var n=0<arguments.length&&typeof arguments[0]!="object",r=this._state;return new q(function(s,f){function d(){t.close(e);var m=t._deps.indexedDB.deleteDatabase(t.name);m.onsuccess=de(function(){var v,_,R;v=t._deps,_=t.name,R=v.indexedDB,v=v.IDBKeyRange,Jn(R)||_===an||Qn(R,v).delete(_).catch(ce),s()}),m.onerror=Ue(f),m.onblocked=t._fireOnBlocked}if(n)throw new X.InvalidArgument("Invalid closeOptions argument to db.delete()");r.isBeingOpened?r.dbReadyPromise.then(d):d()})},ge.prototype.backendDB=function(){return this.idbdb},ge.prototype.isOpen=function(){return this.idbdb!==null},ge.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"},ge.prototype.hasFailed=function(){return this._state.dbOpenError!==null},ge.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(ge.prototype,"tables",{get:function(){var e=this;return l(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!1,configurable:!0}),ge.prototype.transaction=function(){var e=(function(t,n,r){var s=arguments.length;if(s<2)throw new X.InvalidArgument("Too few arguments");for(var f=new Array(s-1);--s;)f[s-1]=arguments[s];return r=f.pop(),[t,Ye(f),r]}).apply(this,arguments);return this._transaction.apply(this,e)},ge.prototype._transaction=function(e,t,n){var r=this,s=V.trans;s&&s.db===this&&e.indexOf("!")===-1||(s=null);var f,d,m=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");try{if(d=t.map(function(_){if(_=_ instanceof r.Table?_.name:_,typeof _!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return _}),e=="r"||e===jn)f=jn;else{if(e!="rw"&&e!=Bn)throw new X.InvalidArgument("Invalid transaction mode: "+e);f=Bn}if(s){if(s.mode===jn&&f===Bn){if(!m)throw new X.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");s=null}s&&d.forEach(function(_){if(s&&s.storeNames.indexOf(_)===-1){if(!m)throw new X.SubTransaction("Table "+_+" not included in parent transaction.");s=null}}),m&&s&&!s.active&&(s=null)}}catch(_){return s?s._promise(null,function(R,g){g(_)}):ye(_)}var v=(function _(R,g,k,b,S){return q.resolve().then(function(){var A=V.transless||V,x=R._createTransaction(g,k,R._dbSchema,b);if(x.explicit=!0,A={trans:x,transless:A},b)x.idbtrans=b.idbtrans;else try{x.create(),x.idbtrans._explicit=!0,R._state.PR1398_maxLoop=3}catch(C){return C.name===je.InvalidState&&R.isOpen()&&0<--R._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),R.close({disableAutoOpen:!1}),R.open().then(function(){return _(R,g,k,null,S)})):ye(C)}var M,O=Yt(S);return O&&St(),A=q.follow(function(){var C;(M=S.call(x,x))&&(O?(C=Ze.bind(null,null),M.then(C,C)):typeof M.next=="function"&&typeof M.throw=="function"&&(M=sr(M)))},A),(M&&typeof M.then=="function"?q.resolve(M).then(function(C){return x.active?C:ye(new X.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):A.then(function(){return M})).then(function(C){return b&&x._resolve(),x._completion.then(function(){return C})}).catch(function(C){return x._reject(C),ye(C)})})}).bind(null,this,f,d,s,n);return s?s._promise(f,v,"lock"):V.trans?ht(V.transless,function(){return r._whenReady(v)}):this._whenReady(v)},ge.prototype.table=function(e){if(!w(this._allTables,e))throw new X.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},ge);function ge(e,t){var n=this;this._middlewares={},this.verno=0;var r=ge.dependencies;this._options=t=a({addons:ge.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,cache:"cloned"},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange},r=t.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var s,f,d,m,v,_={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ce,dbReadyPromise:null,cancelOpen:ce,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:t.autoOpen};_.dbReadyPromise=new q(function(g){_.dbReadyResolve=g}),_.openCanceller=new q(function(g,k){_.cancelOpen=k}),this._state=_,this.name=e,this.on=Ft(this,"populate","blocked","versionchange","close",{ready:[On,ce]}),this.on.ready.subscribe=le(this.on.ready.subscribe,function(g){return function(k,b){ge.vip(function(){var S,A=n._state;A.openComplete?(A.dbOpenError||q.resolve().then(k),b&&g(k)):A.onReadyBeingFired?(A.onReadyBeingFired.push(k),b&&g(k)):(g(k),S=n,b||g(function x(){S.on.ready.unsubscribe(k),S.on.ready.unsubscribe(x)}))})}}),this.Collection=(s=this,Kt(Ri.prototype,function(M,x){this.db=s;var b=kr,S=null;if(x)try{b=x()}catch(O){S=O}var A=M._ctx,x=A.table,M=x.hook.reading.fire;this._ctx={table:x,index:A.index,isPrimKey:!A.index||x.schema.primKey.keyPath&&A.index===x.schema.primKey.name,range:b,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:S,or:A.or,valueMapper:M!==Pt?M:null}})),this.Table=(f=this,Kt(Pr.prototype,function(g,k,b){this.db=f,this._tx=b,this.name=g,this.schema=k,this.hook=f._allTables[g]?f._allTables[g].hook:Ft(null,{creating:[gi,ce],reading:[yi,Pt],updating:[bi,ce],deleting:[vi,ce]})})),this.Transaction=(d=this,Kt(Mi.prototype,function(g,k,b,S,A){var x=this;this.db=d,this.mode=g,this.storeNames=k,this.schema=b,this.chromeTransactionDurability=S,this.idbtrans=null,this.on=Ft(this,"complete","error","abort"),this.parent=A||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new q(function(M,O){x._resolve=M,x._reject=O}),this._completion.then(function(){x.active=!1,x.on.complete.fire()},function(M){var O=x.active;return x.active=!1,x.on.error.fire(M),x.parent?x.parent._reject(M):O&&x.idbtrans&&x.idbtrans.abort(),ye(M)})})),this.Version=(m=this,Kt(Ni.prototype,function(g){this.db=m,this._cfg={version:g,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(v=this,Kt(Fr.prototype,function(g,k,b){if(this.db=v,this._ctx={table:g,index:k===":id"?null:k,or:b},this._cmp=this._ascending=ie,this._descending=function(S,A){return ie(A,S)},this._max=function(S,A){return 0<ie(S,A)?S:A},this._min=function(S,A){return ie(S,A)<0?S:A},this._IDBKeyRange=v._deps.IDBKeyRange,!this._IDBKeyRange)throw new X.MissingAPI})),this.on("versionchange",function(g){0<g.newVersion?console.warn("Another connection wants to upgrade database '".concat(n.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(n.name,"'. Closing db now to resume the delete request.")),n.close({disableAutoOpen:!1})}),this.on("blocked",function(g){!g.newVersion||g.newVersion<g.oldVersion?console.warn("Dexie.delete('".concat(n.name,"') was blocked")):console.warn("Upgrade '".concat(n.name,"' blocked by other connection holding version ").concat(g.oldVersion/10))}),this._maxKey=qt(t.IDBKeyRange),this._createTransaction=function(g,k,b,S){return new n.Transaction(g,k,b,n._options.chromeTransactionDurability,S)},this._fireOnBlocked=function(g){n.on("blocked").fire(g),Et.filter(function(k){return k.name===n.name&&k!==n&&!k._state.vcFired}).map(function(k){return k.on("versionchange").fire(g)})},this.use(Bi),this.use(Hi),this.use(Ui),this.use(Ki),this.use(ji);var R=new Proxy(this,{get:function(g,k,b){if(k==="_vip")return!0;if(k==="table")return function(A){return xn(n.table(A),R)};var S=Reflect.get(g,k,b);return S instanceof Pr?xn(S,R):k==="tables"?S.map(function(A){return xn(A,R)}):k==="_createTransaction"?function(){return xn(S.apply(this,arguments),R)}:S}});this.vip=R,r.forEach(function(g){return g(n)})}var Tn,Pe=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",zi=(cr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:t,complete:n})},cr.prototype[Pe]=function(){return this},cr);function cr(e){this._subscribe=e}try{Tn={indexedDB:c.indexedDB||c.mozIndexedDB||c.webkitIndexedDB||c.msIndexedDB,IDBKeyRange:c.IDBKeyRange||c.webkitIDBKeyRange}}catch{Tn={indexedDB:null,IDBKeyRange:null}}function Jr(e){var t,n=!1,r=new zi(function(s){var f=Yt(e),d,m=!1,v={},_={},R={get closed(){return m},unsubscribe:function(){m||(m=!0,d&&d.abort(),g&&nt.storagemutated.unsubscribe(b))}};s.start&&s.start(R);var g=!1,k=function(){return Kn(S)},b=function(A){bn(v,A),tr(_,v)&&k()},S=function(){var A,x,M;!m&&Tn.indexedDB&&(v={},A={},d&&d.abort(),d=new AbortController,M=function(O){var C=xt();try{f&&St();var I=Je(e,O);return I=f?I.finally(Ze):I}finally{C&&Tt()}}(x={subscr:A,signal:d.signal,requery:k,querier:e,trans:null}),Promise.resolve(M).then(function(O){n=!0,t=O,m||x.signal.aborted||(v={},function(C){for(var I in C)if(w(C,I))return;return 1}(_=A)||g||(nt(Ut,b),g=!0),Kn(function(){return!m&&s.next&&s.next(O)}))},function(O){n=!1,["DatabaseClosedError","AbortError"].includes(O==null?void 0:O.name)||m||Kn(function(){m||s.error&&s.error(O)})}))};return setTimeout(k,0),R});return r.hasValue=function(){return n},r.getValue=function(){return t},r}var yt=Xe;function lr(e){var t=rt;try{rt=!0,nt.storagemutated.fire(e),ir(e,!0)}finally{rt=t}}P(yt,a(a({},Qt),{delete:function(e){return new yt(e,{addons:[]}).delete()},exists:function(e){return new yt(e,{addons:[]}).open().then(function(t){return t.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=yt.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Jn(n)?Promise.resolve(n.databases()).then(function(r){return r.map(function(s){return s.name}).filter(function(s){return s!==an})}):Qn(n,t).toCollection().primaryKeys()).then(e)}catch{return ye(new X.MissingAPI)}var t,n},defineClass:function(){return function(e){h(this,e)}},ignoreTransaction:function(e){return V.trans?ht(V.transless,e):e()},vip:Zn,async:function(e){return function(){try{var t=sr(e.apply(this,arguments));return t&&typeof t.then=="function"?t:q.resolve(t)}catch(n){return ye(n)}}},spawn:function(e,t,n){try{var r=sr(e.apply(n,t||[]));return r&&typeof r.then=="function"?r:q.resolve(r)}catch(s){return ye(s)}},currentTransaction:{get:function(){return V.trans||null}},waitFor:function(e,t){return t=q.resolve(typeof e=="function"?yt.ignoreTransaction(e):e).timeout(t||6e4),V.trans?V.trans.waitFor(t):t},Promise:q,debug:{get:function(){return Be},set:function(e){_r(e)}},derive:W,extend:h,props:P,override:le,Events:Ft,on:nt,liveQuery:Jr,extendObservabilitySet:bn,getByKeyPath:ve,setByKeyPath:ue,delByKeyPath:function(e,t){typeof t=="string"?ue(e,t,void 0):"length"in t&&[].map.call(t,function(n){ue(e,n,void 0)})},shallowClone:Ie,deepClone:me,getObjectDiff:or,cmp:ie,asap:we,minKey:-1/0,addons:[],connections:Et,errnames:je,dependencies:Tn,cache:mt,semVer:"4.0.11",version:"4.0.11".split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),yt.maxKey=qt(yt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(nt(Ut,function(e){rt||(e=new CustomEvent(Hn,{detail:e}),rt=!0,dispatchEvent(e),rt=!1)}),addEventListener(Hn,function(e){e=e.detail,rt||lr(e)}));var kt,rt=!1,Zr=function(){};return typeof BroadcastChannel<"u"&&((Zr=function(){(kt=new BroadcastChannel(Hn)).onmessage=function(e){return e.data&&lr(e.data)}})(),typeof kt.unref=="function"&&kt.unref(),nt(Ut,function(e){rt||kt.postMessage(e)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(e){if(!Xe.disableBfCache&&e.persisted){Be&&console.debug("Dexie: handling persisted pagehide"),kt!=null&&kt.close();for(var t=0,n=Et;t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!Xe.disableBfCache&&e.persisted&&(Be&&console.debug("Dexie: handling persisted pageshow"),Zr(),lr({all:new Se(-1/0,[[]])}))})),q.rejectionMapper=function(e,t){return!e||e instanceof $e||e instanceof TypeError||e instanceof SyntaxError||!e.name||!wr[e.name]?e:(t=new wr[e.name](t||e.message,e),"stack"in e&&G(t,"stack",{get:function(){return this.inner.stack}}),t)},_r(Be),a(Xe,Object.freeze({__proto__:null,Dexie:Xe,liveQuery:Jr,Entity:Mr,cmp:ie,PropModification:jt,replacePrefix:function(e,t){return new jt({replacePrefix:[e,t]})},add:function(e){return new jt({add:e})},remove:function(e){return new jt({remove:e})},default:Xe,RangeSet:Se,mergeRanges:zt,rangesOverlap:qr}),{default:Xe}),Xe})}(An)),An.exports}var js=Ks();const br=Ns(js),fi=Symbol.for("Dexie"),kn=globalThis[fi]||(globalThis[fi]=br);if(br.semVer!==kn.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${br.semVer} and ${kn.semVer}`);const{liveQuery:Us,mergeRanges:qs,rangesOverlap:Gs,RangeSet:Hs,cmp:zs,Entity:Vs,PropModification:Xs,replacePrefix:Ws,add:Ys,remove:$s}=kn;class pi{constructor(i="threeJsIDBCache",o=3){this.version=o,this.dbName=i,this.dbInit()}dbInit(){this.db=new kn(this.dbName),this.materialMap={},this.db.version(this.version).stores({models:"&path, version, data"})}getDatabase(){return this.db}async cacheModel(i,o,a){try{this.db.table("models").put({version:a,path:i,data:o}).then(()=>{console.log(`Model "${i}" cached successfully in table models`)})}catch{console.log(" 缓存模型失败 =====> ")}return o}async loadCachedModel(i,o){let a=null;try{if(a=await this.db.table("models").get(i),!a)return console.warn(`Model "${o}" not found in table models`),null;if(a.version!==o)return console.log(" =====> 模型版本不一致, 清除当前记录"),await this.db.table("models").delete(i),null}catch{return console.log(" =====> 查询表中模型失败"),this.db.delete().then(()=>{this.init()}),null}return a.data}}let Rn;const Bs=()=>{const L=new Wi,i=new Vi;i.setDecoderPath("/draco/"),L.setDRACOLoader(i);function o(c,l,p,h){return L.load(c,l,p,h)}function a(c,l){return new Promise((p,h)=>{L.load(c,p,l,h)})}async function u(c,l,p=!0,h){Rn||(Rn=new pi);const y=await Rn.loadCachedModel(c,l);return y?p?Mt.dataToObject3D(y):y:new Promise((E,w)=>{L.load(c,E,h,w)}).then(async E=>{const w=Mt.object3DToData(E);return Rn.cacheModel(c,E.scene,l),p?E.scene:w})}return{load:o,asyncLoad:a,asyncCacheLoad:u}};exports.IDBCache=pi;exports.intersectColor=Ls;exports.obbObjects=Ge;exports.useGLTFLoader=Bs;exports.useObb=Is;exports.useRaycaster=Ps;exports.useThreeJs=Cs;